Blame dom/commandhandler/nsICommandManager.idl

Packit f0b94e
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
Packit f0b94e
/* This Source Code Form is subject to the terms of the Mozilla Public
Packit f0b94e
 * License, v. 2.0. If a copy of the MPL was not distributed with this
Packit f0b94e
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
Packit f0b94e
Packit f0b94e
#include "nsISupports.idl"
Packit f0b94e
#include "nsIObserver.idl"
Packit f0b94e
#include "nsICommandParams.idl"
Packit f0b94e
Packit f0b94e
interface mozIDOMWindowProxy;
Packit f0b94e
Packit f0b94e
/*
Packit f0b94e
 * nsICommandManager is an interface used to executing user-level commands,
Packit f0b94e
 * and getting the state of available commands.
Packit f0b94e
 *
Packit f0b94e
 * Commands are identified by strings, which are documented elsewhere.
Packit f0b94e
 * In addition, the list of required and optional parameters for
Packit f0b94e
 * each command, that are passed in via the nsICommandParams, are
Packit f0b94e
 * also documented elsewhere. (Where? Need a good location for this).
Packit f0b94e
 */
Packit f0b94e
 
Packit f0b94e
 
Packit f0b94e
[scriptable, uuid(bb5a1730-d83b-4fa2-831b-35b9d5842e84)]
Packit f0b94e
interface nsICommandManager : nsISupports
Packit f0b94e
{
Packit f0b94e
  /*
Packit f0b94e
   * Register an observer on the specified command. The observer's Observe
Packit f0b94e
   * method will get called when the state (enabled/disbaled, or toggled etc)
Packit f0b94e
   * of the command changes.
Packit f0b94e
   *
Packit f0b94e
   * You can register the same observer on multiple commmands by calling this
Packit f0b94e
   * multiple times.
Packit f0b94e
   */
Packit f0b94e
  void        addCommandObserver(in nsIObserver aCommandObserver,
Packit f0b94e
                                 in string aCommandToObserve);
Packit f0b94e
Packit f0b94e
  /*
Packit f0b94e
   * Stop an observer from observering the specified command. If the observer
Packit f0b94e
   * was also registered on ther commands, they will continue to be observed.
Packit f0b94e
   *
Packit f0b94e
   * Passing an empty string in 'aCommandObserved' will remove the observer
Packit f0b94e
   * from all commands.
Packit f0b94e
   */
Packit f0b94e
  void        removeCommandObserver(in nsIObserver aCommandObserver,
Packit f0b94e
                                    in string aCommandObserved);
Packit f0b94e
Packit f0b94e
  /*
Packit f0b94e
   * Ask the command manager if the specified command is supported.
Packit f0b94e
   * If aTargetWindow is null, the focused window is used.
Packit f0b94e
   *
Packit f0b94e
   */
Packit f0b94e
  boolean     isCommandSupported(in string aCommandName,
Packit f0b94e
                                 in mozIDOMWindowProxy aTargetWindow);
Packit f0b94e
Packit f0b94e
  /*
Packit f0b94e
   * Ask the command manager if the specified command is currently.
Packit f0b94e
   * enabled.
Packit f0b94e
   * If aTargetWindow is null, the focused window is used.
Packit f0b94e
   */
Packit f0b94e
  boolean     isCommandEnabled(in string aCommandName,
Packit f0b94e
                               in mozIDOMWindowProxy aTargetWindow);
Packit f0b94e
Packit f0b94e
  /*
Packit f0b94e
   * Get the state of the specified commands.
Packit f0b94e
   *
Packit f0b94e
   * On input: aCommandParams filled in with values that the caller cares
Packit f0b94e
   * about, most of which are command-specific (see the command documentation
Packit f0b94e
   * for details). One boolean value, "enabled", applies to all commands,
Packit f0b94e
   * and, in return will be set to indicate whether the command is enabled
Packit f0b94e
   * (equivalent to calling isCommandEnabled).
Packit f0b94e
   *
Packit f0b94e
   * aCommandName is the name of the command that needs the state
Packit f0b94e
   * aTargetWindow is the source of command controller 
Packit f0b94e
   *      (null means use focus controller)
Packit f0b94e
   * On output: aCommandParams: values set by the caller filled in with
Packit f0b94e
   * state from the command.
Packit f0b94e
   */
Packit f0b94e
  void        getCommandState(in string aCommandName,
Packit f0b94e
                              in mozIDOMWindowProxy aTargetWindow,
Packit f0b94e
                  /* inout */ in nsICommandParams aCommandParams);
Packit f0b94e
    
Packit f0b94e
  /*
Packit f0b94e
   * Execute the specified command.
Packit f0b94e
   * The command will be executed in aTargetWindow if it is specified.
Packit f0b94e
   * If aTargetWindow is null, it will go to the focused window.
Packit f0b94e
   *
Packit f0b94e
   * param: aCommandParams, a list of name-value pairs of command parameters,
Packit f0b94e
   * may be null for parameter-less commands.
Packit f0b94e
   *
Packit f0b94e
   */
Packit f0b94e
  void        doCommand(in string aCommandName,
Packit f0b94e
                        in nsICommandParams aCommandParams,
Packit f0b94e
                        in mozIDOMWindowProxy aTargetWindow);
Packit f0b94e
Packit f0b94e
};
Packit f0b94e
Packit f0b94e
Packit f0b94e
/*
Packit f0b94e
Packit f0b94e
Arguments to observers "Observe" method are as follows:
Packit f0b94e
Packit f0b94e
  void Observe(   in nsISupports aSubject,          // The nsICommandManager calling this Observer
Packit f0b94e
                  in string      aTopic,            // Name of the command
Packit f0b94e
                  in wstring     aDummy );          // unused
Packit f0b94e
Packit f0b94e
*/
Packit f0b94e
Packit f0b94e
// {64edb481-0c04-11d5-a73c-e964b968b0bc}
Packit f0b94e
%{C++
Packit f0b94e
#define NS_COMMAND_MANAGER_CID \
Packit f0b94e
{ 0x64edb481, 0x0c04, 0x11d5, { 0xa7, 0x3c, 0xe9, 0x64, 0xb9, 0x68, 0xb0, 0xbc } }
Packit f0b94e
Packit f0b94e
#define NS_COMMAND_MANAGER_CONTRACTID \
Packit f0b94e
 "@mozilla.org/embedcomp/command-manager;1"
Packit f0b94e
%}
Packit f0b94e
Packit f0b94e
Packit f0b94e