]> git.saurik.com Git - wxWidgets.git/blame - include/wx/cmdproc.h
added info about ShowFullScreen changes
[wxWidgets.git] / include / wx / cmdproc.h
CommitLineData
1e6feb95
VZ
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
af49c4b8 15#if defined(__GNUG__) && !defined(__APPLE__)
1e6feb95
VZ
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
26class WXDLLEXPORT wxCommand : public wxObject
27{
28public:
2b5f62a0 29 wxCommand(bool canUndoIt = FALSE, const wxString& name = wxT(""));
1e6feb95
VZ
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
41protected:
42 bool m_canUndo;
43 wxString m_commandName;
44
45private:
46 DECLARE_CLASS(wxCommand)
47};
48
49// ----------------------------------------------------------------------------
50// wxCommandProcessor: wxCommand manager
51// ----------------------------------------------------------------------------
52
53class WXDLLEXPORT wxCommandProcessor : public wxObject
54{
55public:
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
d863ed83 72 // Initialises the current command and menu strings.
1e6feb95 73 virtual void Initialize();
d863ed83
JS
74
75 // Sets the Undo/Redo menu strings for the current menu.
1e6feb95
VZ
76 virtual void SetMenuStrings();
77
d863ed83
JS
78 // Gets the current Undo menu label.
79 wxString GetUndoMenuLabel() const;
80
81 // Gets the current Undo menu label.
82 wxString GetRedoMenuLabel() const;
83
1e6feb95
VZ
84#if wxUSE_MENUS
85 // Call this to manage an edit menu.
86 void SetEditMenu(wxMenu *menu) { m_commandEditMenu = menu; }
87 wxMenu *GetEditMenu() const { return m_commandEditMenu; }
88#endif // wxUSE_MENUS
89
90 // command list access
91 wxList& GetCommands() const { return (wxList&) m_commands; }
92 wxCommand *GetCurrentCommand() const
93 {
94 return (wxCommand *)(m_currentCommand ? m_currentCommand->Data() : NULL);
95 }
96 int GetMaxCommands() const { return m_maxNoCommands; }
97 virtual void ClearCommands();
98
6aa3ea88
JS
99 // By default, the accelerators are "\tCtrl+Z" and "\tCtrl+Y"
100 const wxString& GetUndoAccelerator() const { return m_undoAccelerator; }
101 const wxString& GetRedoAccelerator() const { return m_redoAccelerator; }
102
103 void SetUndoAccelerator(const wxString& accel) { m_undoAccelerator = accel; }
104 void SetRedoAccelerator(const wxString& accel) { m_redoAccelerator = accel; }
105
1e6feb95
VZ
106protected:
107 // for further flexibility, command processor doesn't call wxCommand::Do()
108 // and Undo() directly but uses these functions which can be overridden in
109 // the derived class
110 virtual bool DoCommand(wxCommand& cmd);
111 virtual bool UndoCommand(wxCommand& cmd);
112
113 int m_maxNoCommands;
114 wxList m_commands;
115 wxNode* m_currentCommand;
116
117#if wxUSE_MENUS
118 wxMenu* m_commandEditMenu;
119#endif // wxUSE_MENUS
120
6aa3ea88
JS
121 wxString m_undoAccelerator;
122 wxString m_redoAccelerator;
123
1e6feb95
VZ
124private:
125 DECLARE_DYNAMIC_CLASS(wxCommandProcessor)
22f3361e 126 DECLARE_NO_COPY_CLASS(wxCommandProcessor)
1e6feb95
VZ
127};
128
129#endif // _WX_CMDPROC_H_