]> git.saurik.com Git - wxWidgets.git/blob - include/wx/cmdproc.h
don't process VK_OEM_XXX key presses
[wxWidgets.git] / include / wx / cmdproc.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/cmdproc.h
3 // Purpose: undo/redo capable command processing framework
4 // Author: Julian Smart (extracted from docview.h by VZ)
5 // Modified by:
6 // Created: 05.11.00
7 // RCS-ID: $Id$
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_CMDPROC_H_
13 #define _WX_CMDPROC_H_
14
15 #ifdef __GNUG__
16 #pragma interface "cmdproc.h"
17 #endif
18
19 #include "wx/object.h"
20 #include "wx/list.h"
21
22 // ----------------------------------------------------------------------------
23 // wxCommand: a single command capable of performing itself
24 // ----------------------------------------------------------------------------
25
26 class WXDLLEXPORT wxCommand : public wxObject
27 {
28 public:
29 wxCommand(bool canUndoIt = FALSE, const wxString& name = "");
30 ~wxCommand();
31
32 // Override this to perform a command
33 virtual bool Do() = 0;
34
35 // Override this to undo a command
36 virtual bool Undo() = 0;
37
38 virtual bool CanUndo() const { return m_canUndo; }
39 virtual wxString GetName() const { return m_commandName; }
40
41 protected:
42 bool m_canUndo;
43 wxString m_commandName;
44
45 private:
46 DECLARE_CLASS(wxCommand)
47 };
48
49 // ----------------------------------------------------------------------------
50 // wxCommandProcessor: wxCommand manager
51 // ----------------------------------------------------------------------------
52
53 class WXDLLEXPORT wxCommandProcessor : public wxObject
54 {
55 public:
56 // if max number of commands is -1, it is unlimited
57 wxCommandProcessor(int maxCommands = -1);
58 virtual ~wxCommandProcessor();
59
60 // Pass a command to the processor. The processor calls Do(); if
61 // successful, is appended to the command history unless storeIt is FALSE.
62 virtual bool Submit(wxCommand *command, bool storeIt = TRUE);
63
64 // just store the command without executing it
65 virtual void Store(wxCommand *command);
66
67 virtual bool Undo();
68 virtual bool Redo();
69 virtual bool CanUndo() const;
70 virtual bool CanRedo() const;
71
72 virtual void Initialize();
73 virtual void SetMenuStrings();
74
75 #if wxUSE_MENUS
76 // Call this to manage an edit menu.
77 void SetEditMenu(wxMenu *menu) { m_commandEditMenu = menu; }
78 wxMenu *GetEditMenu() const { return m_commandEditMenu; }
79 #endif // wxUSE_MENUS
80
81 // command list access
82 wxList& GetCommands() const { return (wxList&) m_commands; }
83 wxCommand *GetCurrentCommand() const
84 {
85 return (wxCommand *)(m_currentCommand ? m_currentCommand->Data() : NULL);
86 }
87 int GetMaxCommands() const { return m_maxNoCommands; }
88 virtual void ClearCommands();
89
90 protected:
91 // for further flexibility, command processor doesn't call wxCommand::Do()
92 // and Undo() directly but uses these functions which can be overridden in
93 // the derived class
94 virtual bool DoCommand(wxCommand& cmd);
95 virtual bool UndoCommand(wxCommand& cmd);
96
97 int m_maxNoCommands;
98 wxList m_commands;
99 wxNode* m_currentCommand;
100
101 #if wxUSE_MENUS
102 wxMenu* m_commandEditMenu;
103 #endif // wxUSE_MENUS
104
105 private:
106 DECLARE_DYNAMIC_CLASS(wxCommandProcessor)
107 };
108
109 #endif // _WX_CMDPROC_H_