/embedding/components/commandhandler/public/nsICommandManager.idl

http://github.com/zpao/v8monkey · IDL · 152 lines · 28 code · 18 blank · 106 comment · 0 complexity · 15996aabbbb4e6e32c353f3b669e3ee3 MD5 · raw file

  1. /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
  2. /* ***** BEGIN LICENSE BLOCK *****
  3. * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  4. *
  5. * The contents of this file are subject to the Mozilla Public License Version
  6. * 1.1 (the "License"); you may not use this file except in compliance with
  7. * the License. You may obtain a copy of the License at
  8. * http://www.mozilla.org/MPL/
  9. *
  10. * Software distributed under the License is distributed on an "AS IS" basis,
  11. * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  12. * for the specific language governing rights and limitations under the
  13. * License.
  14. *
  15. * The Original Code is mozilla.org code.
  16. *
  17. * The Initial Developer of the Original Code is
  18. * Netscape Communications Corporation.
  19. * Portions created by the Initial Developer are Copyright (C) 1998
  20. * the Initial Developer. All Rights Reserved.
  21. *
  22. * Contributor(s):
  23. * Simon Fraser <sfraser@netscape.com>
  24. * Kathleen Brade <brade@netscape.com>
  25. *
  26. * Alternatively, the contents of this file may be used under the terms of
  27. * either the GNU General Public License Version 2 or later (the "GPL"), or
  28. * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  29. * in which case the provisions of the GPL or the LGPL are applicable instead
  30. * of those above. If you wish to allow use of your version of this file only
  31. * under the terms of either the GPL or the LGPL, and not to allow others to
  32. * use your version of this file under the terms of the MPL, indicate your
  33. * decision by deleting the provisions above and replace them with the notice
  34. * and other provisions required by the GPL or the LGPL. If you do not delete
  35. * the provisions above, a recipient may use your version of this file under
  36. * the terms of any one of the MPL, the GPL or the LGPL.
  37. *
  38. * ***** END LICENSE BLOCK ***** */
  39. #include "nsISupports.idl"
  40. #include "nsIObserver.idl"
  41. #include "nsICommandParams.idl"
  42. interface nsIDOMWindow;
  43. /*
  44. * nsICommandManager is an interface used to executing user-level commands,
  45. * and getting the state of available commands.
  46. *
  47. * Commands are identified by strings, which are documented elsewhere.
  48. * In addition, the list of required and optional parameters for
  49. * each command, that are passed in via the nsICommandParams, are
  50. * also documented elsewhere. (Where? Need a good location for this).
  51. */
  52. [scriptable, uuid(080D2001-F91E-11D4-A73C-F9242928207C)]
  53. interface nsICommandManager : nsISupports
  54. {
  55. /*
  56. * Register an observer on the specified command. The observer's Observe
  57. * method will get called when the state (enabled/disbaled, or toggled etc)
  58. * of the command changes.
  59. *
  60. * You can register the same observer on multiple commmands by calling this
  61. * multiple times.
  62. */
  63. void addCommandObserver(in nsIObserver aCommandObserver,
  64. in string aCommandToObserve);
  65. /*
  66. * Stop an observer from observering the specified command. If the observer
  67. * was also registered on ther commands, they will continue to be observed.
  68. *
  69. * Passing an empty string in 'aCommandObserved' will remove the observer
  70. * from all commands.
  71. */
  72. void removeCommandObserver(in nsIObserver aCommandObserver,
  73. in string aCommandObserved);
  74. /*
  75. * Ask the command manager if the specified command is supported.
  76. * If aTargetWindow is null, the focused window is used.
  77. *
  78. */
  79. boolean isCommandSupported(in string aCommandName,
  80. in nsIDOMWindow aTargetWindow);
  81. /*
  82. * Ask the command manager if the specified command is currently.
  83. * enabled.
  84. * If aTargetWindow is null, the focused window is used.
  85. */
  86. boolean isCommandEnabled(in string aCommandName,
  87. in nsIDOMWindow aTargetWindow);
  88. /*
  89. * Get the state of the specified commands.
  90. *
  91. * On input: aCommandParams filled in with values that the caller cares
  92. * about, most of which are command-specific (see the command documentation
  93. * for details). One boolean value, "enabled", applies to all commands,
  94. * and, in return will be set to indicate whether the command is enabled
  95. * (equivalent to calling isCommandEnabled).
  96. *
  97. * aCommandName is the name of the command that needs the state
  98. * aTargetWindow is the source of command controller
  99. * (null means use focus controller)
  100. * On output: aCommandParams: values set by the caller filled in with
  101. * state from the command.
  102. */
  103. void getCommandState(in string aCommandName,
  104. in nsIDOMWindow aTargetWindow,
  105. /* inout */ in nsICommandParams aCommandParams);
  106. /*
  107. * Execute the specified command.
  108. * The command will be executed in aTargetWindow if it is specified.
  109. * If aTargetWindow is null, it will go to the focused window.
  110. *
  111. * param: aCommandParams, a list of name-value pairs of command parameters,
  112. * may be null for parameter-less commands.
  113. *
  114. */
  115. void doCommand(in string aCommandName,
  116. in nsICommandParams aCommandParams,
  117. in nsIDOMWindow aTargetWindow);
  118. };
  119. /*
  120. Arguments to observers "Observe" method are as follows:
  121. void Observe( in nsISupports aSubject, // The nsICommandManager calling this Observer
  122. in string aTopic, // Name of the command
  123. in wstring aDummy ); // unused
  124. */
  125. // {64edb481-0c04-11d5-a73c-e964b968b0bc}
  126. %{C++
  127. #define NS_COMMAND_MANAGER_CID \
  128. { 0x64edb481, 0x0c04, 0x11d5, { 0xa7, 0x3c, 0xe9, 0x64, 0xb9, 0x68, 0xb0, 0xbc } }
  129. #define NS_COMMAND_MANAGER_CONTRACTID \
  130. "@mozilla.org/embedcomp/command-manager;1"
  131. %}