- Instead of the application functionality being scattered around
- switch statements and functions in a way that may be hard to
- read and maintain, the functionality for a command is explicitly represented
- as an object which can be manipulated by a framework or application.
-
- When a user interface event occurs, the application @e submits a command
- to a #wxCommandProcessor object to execute and store.
-
- The wxWidgets document/view framework handles Undo and Redo by use of
- wxCommand and wxCommandProcessor objects. You might find further uses
- for wxCommand, such as implementing a macro facility that stores, loads
- and replays commands.
-
- An application can derive a new class for every command, or, more likely, use
- one class parameterized with an integer or string command identifier.
-
-
-
- @section overview_docview_wxcommandproc wxCommandProcessor overview
-
- Classes: #wxCommandProcessor, #wxCommand
-
- wxCommandProcessor is a class that maintains a history of wxCommand
- instances, with undo/redo functionality built-in. Derive a new class from this
- if you want different behaviour.
-
-
-
- @section overview_docview_filehistory wxFileHistory overview
-
- Classes: #wxFileHistory, #wxDocManager
-
- wxFileHistory encapsulates functionality to record the last few files visited, and
- to allow the user to quickly load these files using the list appended to the File menu.
- Although wxFileHistory is used by wxDocManager, it can be used independently. You may wish
- to derive from it to allow different behaviour, such as popping up a scrolling
- list of files.
-
- By calling wxFileHistory::UseMenu() you can associate a file menu with the file history.
- The menu will then be used for appending filenames that are added to the history.
-
- Please notice that currently if the history already contained filenames when UseMenu()
- is called (e.g. when initializing a second MDI child frame), the menu is not automatically
- initialized with the existing filenames in the history and so you need to call
- #AddFilesToMenu() after UseMenu() explicitly in order to initialize the menu with
- the existing list of MRU files (otherwise an assertion failure is raised in debug builds).
-
- The filenames are appended using menu identifiers in the range @c wxID_FILE1 to @c wxID_FILE9.
-
- In order to respond to a file load command from one of these identifiers,
- you need to handle them using an event handler, for example:
-
- @code
- BEGIN_EVENT_TABLE(wxDocParentFrame, wxFrame)
- EVT_MENU(wxID_EXIT, wxDocParentFrame::OnExit)
- EVT_MENU_RANGE(wxID_FILE1, wxID_FILE9, wxDocParentFrame::OnMRUFile)
- END_EVENT_TABLE()
-
- void wxDocParentFrame::OnExit(wxCommandEvent& WXUNUSED(event))
- {
- Close();
- }
-
- void wxDocParentFrame::OnMRUFile(wxCommandEvent& event)
- {
- wxString f(m_docManager->GetHistoryFile(event.GetId() - wxID_FILE1));
- if (!f.empty())
- (void)m_docManager-CreateDocument(f, wxDOC_SILENT);
- }
- @endcode
-
-
-
- @section overview_docview_predefid wxWidgets predefined command identifiers
-
- To allow communication between the application's menus and the
- document/view framework, several command identifiers are predefined for you
- to use in menus.
-
- @verbatim
- wxID_OPEN (5000)
- wxID_CLOSE (5001)
- wxID_NEW (5002)
- wxID_SAVE (5003)
- wxID_SAVEAS (5004)
- wxID_REVERT (5005)
- wxID_EXIT (5006)
- wxID_UNDO (5007)
- wxID_REDO (5008)
- wxID_HELP (5009)
- wxID_PRINT (5010)
- wxID_PRINT_SETUP (5011)
- wxID_PREVIEW (5012)
- @endverbatim