Bug 448909 - Need more controls WHATWG Video tag (followup patch). r=mconnor
[wine-gecko.git] / editor / composer / src / nsComposerCommands.h
blob60e046c476286f2f9d6cfb59f7f1b4a8736c72f2
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
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/
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.
15 * The Original Code is Mozilla Communicator client code.
17 * The Initial Developer of the Original Code is
18 * Netscape Communications Corporation.
19 * Portions created by the Initial Developer are Copyright (C) 1998-2000
20 * the Initial Developer. All Rights Reserved.
22 * Contributor(s):
23 * Ryan Cassin <rcassin@supernova.org>
24 * Daniel Glazman <glazman@netscape.com>
25 * Charles Manske <cmanske@netscape.com>
27 * Alternatively, the contents of this file may be used under the terms of
28 * either of the GNU General Public License Version 2 or later (the "GPL"),
29 * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
30 * in which case the provisions of the GPL or the LGPL are applicable instead
31 * of those above. If you wish to allow use of your version of this file only
32 * under the terms of either the GPL or the LGPL, and not to allow others to
33 * use your version of this file under the terms of the MPL, indicate your
34 * decision by deleting the provisions above and replace them with the notice
35 * and other provisions required by the GPL or the LGPL. If you do not delete
36 * the provisions above, a recipient may use your version of this file under
37 * the terms of any one of the MPL, the GPL or the LGPL.
39 * ***** END LICENSE BLOCK ***** */
41 #ifndef nsComposerCommands_h_
42 #define nsComposerCommands_h_
44 #include "nsIControllerCommand.h"
45 #include "nsString.h"
47 class nsIEditor;
49 // This is a virtual base class for commands registered with the composer controller.
50 // Note that such commands are instantiated once per composer, so can store state.
51 // Also note that IsCommandEnabled can be called with an editor that may not
52 // have an editor yet (because the document is loading). Most commands will want
53 // to return false in this case.
54 // Don't hold on to any references to the editor or document from
55 // your command. This will cause leaks. Also, be aware that the document the
56 // editor is editing can change under you (if the user Reverts the file, for
57 // instance).
58 class nsBaseComposerCommand : public nsIControllerCommand
60 public:
62 nsBaseComposerCommand();
63 virtual ~nsBaseComposerCommand() {}
65 // nsISupports
66 NS_DECL_ISUPPORTS
68 // nsIControllerCommand. Declared longhand so we can make them pure virtual
69 NS_IMETHOD IsCommandEnabled(const char * aCommandName, nsISupports *aCommandRefCon, PRBool *_retval) = 0;
70 NS_IMETHOD DoCommand(const char * aCommandName, nsISupports *aCommandRefCon) = 0;
75 #define NS_DECL_COMPOSER_COMMAND(_cmd) \
76 class _cmd : public nsBaseComposerCommand \
77 { \
78 public: \
79 NS_DECL_NSICONTROLLERCOMMAND \
82 // virtual base class for commands that need to save and update Boolean state (like styles etc)
83 class nsBaseStateUpdatingCommand : public nsBaseComposerCommand
85 public:
87 nsBaseStateUpdatingCommand(const char* aTagName);
88 virtual ~nsBaseStateUpdatingCommand();
90 NS_DECL_ISUPPORTS_INHERITED
92 NS_DECL_NSICONTROLLERCOMMAND
94 protected:
96 // get the current state (on or off) for this style or block format
97 virtual nsresult GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams) = 0;
99 // add/remove the style
100 virtual nsresult ToggleState(nsIEditor *aEditor, const char* aTagName) = 0;
102 protected:
104 const char* mTagName;
108 // Shared class for the various style updating commands like bold, italics etc.
109 // Suitable for commands whose state is either 'on' or 'off'.
110 class nsStyleUpdatingCommand : public nsBaseStateUpdatingCommand
112 public:
114 nsStyleUpdatingCommand(const char* aTagName);
116 protected:
118 // get the current state (on or off) for this style or block format
119 virtual nsresult GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams);
121 // add/remove the style
122 virtual nsresult ToggleState(nsIEditor *aEditor, const char* aTagName);
127 class nsInsertTagCommand : public nsBaseComposerCommand
129 public:
131 nsInsertTagCommand(const char* aTagName);
132 virtual ~nsInsertTagCommand();
134 NS_DECL_ISUPPORTS_INHERITED
136 NS_DECL_NSICONTROLLERCOMMAND
138 protected:
140 const char* mTagName;
144 class nsListCommand : public nsBaseStateUpdatingCommand
146 public:
148 nsListCommand(const char* aTagName);
150 protected:
152 // get the current state (on or off) for this style or block format
153 virtual nsresult GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams);
155 // add/remove the style
156 virtual nsresult ToggleState(nsIEditor *aEditor, const char* aTagName);
159 class nsListItemCommand : public nsBaseStateUpdatingCommand
161 public:
163 nsListItemCommand(const char* aTagName);
165 protected:
167 // get the current state (on or off) for this style or block format
168 virtual nsresult GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams);
170 // add/remove the style
171 virtual nsresult ToggleState(nsIEditor *aEditor, const char* aTagName);
174 // Base class for commands whose state consists of a string (e.g. para format)
175 class nsMultiStateCommand : public nsBaseComposerCommand
177 public:
179 nsMultiStateCommand();
180 virtual ~nsMultiStateCommand();
182 NS_DECL_ISUPPORTS_INHERITED
183 NS_DECL_NSICONTROLLERCOMMAND
185 protected:
187 virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams) =0;
188 virtual nsresult SetState(nsIEditor *aEditor, nsString& newState) = 0;
193 class nsParagraphStateCommand : public nsMultiStateCommand
195 public:
196 nsParagraphStateCommand();
198 protected:
200 virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
201 virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
204 class nsFontFaceStateCommand : public nsMultiStateCommand
206 public:
207 nsFontFaceStateCommand();
209 protected:
211 virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
212 virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
215 class nsFontSizeStateCommand : public nsMultiStateCommand
217 public:
218 nsFontSizeStateCommand();
220 protected:
222 virtual nsresult GetCurrentState(nsIEditor *aEditor,
223 nsICommandParams* aParams);
224 virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
227 class nsHighlightColorStateCommand : public nsMultiStateCommand
229 public:
230 nsHighlightColorStateCommand();
232 protected:
234 NS_IMETHOD IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, PRBool *_retval);
235 virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
236 virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
240 class nsFontColorStateCommand : public nsMultiStateCommand
242 public:
243 nsFontColorStateCommand();
245 protected:
247 virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
248 virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
251 class nsAlignCommand : public nsMultiStateCommand
253 public:
254 nsAlignCommand();
256 protected:
258 virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
259 virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
262 class nsBackgroundColorStateCommand : public nsMultiStateCommand
264 public:
265 nsBackgroundColorStateCommand();
267 protected:
269 virtual nsresult GetCurrentState(nsIEditor *aEditor, nsICommandParams* aParams);
270 virtual nsresult SetState(nsIEditor *aEditor, nsString& newState);
273 class nsAbsolutePositioningCommand : public nsBaseStateUpdatingCommand
275 public:
276 nsAbsolutePositioningCommand();
278 protected:
280 NS_IMETHOD IsCommandEnabled(const char *aCommandName, nsISupports *aCommandRefCon, PRBool *_retval);
281 virtual nsresult GetCurrentState(nsIEditor *aEditor, const char* aTagName, nsICommandParams *aParams);
282 virtual nsresult ToggleState(nsIEditor *aEditor, const char* aTagName);
285 // composer commands
287 NS_DECL_COMPOSER_COMMAND(nsCloseCommand)
288 NS_DECL_COMPOSER_COMMAND(nsDocumentStateCommand)
289 NS_DECL_COMPOSER_COMMAND(nsSetDocumentStateCommand)
290 NS_DECL_COMPOSER_COMMAND(nsSetDocumentOptionsCommand)
291 //NS_DECL_COMPOSER_COMMAND(nsPrintingCommands)
293 NS_DECL_COMPOSER_COMMAND(nsDecreaseZIndexCommand)
294 NS_DECL_COMPOSER_COMMAND(nsIncreaseZIndexCommand)
296 // Generic commands
298 // File menu
299 NS_DECL_COMPOSER_COMMAND(nsNewCommands) // handles 'new' anything
301 // Edit menu
302 NS_DECL_COMPOSER_COMMAND(nsPasteNoFormattingCommand)
304 // Block transformations
305 NS_DECL_COMPOSER_COMMAND(nsIndentCommand)
306 NS_DECL_COMPOSER_COMMAND(nsOutdentCommand)
308 NS_DECL_COMPOSER_COMMAND(nsRemoveListCommand)
309 NS_DECL_COMPOSER_COMMAND(nsRemoveStylesCommand)
310 NS_DECL_COMPOSER_COMMAND(nsIncreaseFontSizeCommand)
311 NS_DECL_COMPOSER_COMMAND(nsDecreaseFontSizeCommand)
313 // Insert content commands
314 NS_DECL_COMPOSER_COMMAND(nsInsertHTMLCommand)
316 #endif // nsComposerCommands_h_