File: overview_docview.html

package info (click to toggle)
wxpython3.0 3.0.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 482,760 kB
  • ctags: 518,293
  • sloc: cpp: 2,127,226; python: 294,045; makefile: 51,942; ansic: 19,033; sh: 3,013; xml: 1,629; perl: 17
file content (198 lines) | stat: -rw-r--r-- 34,545 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<title>wxWidgets: Document/View Framework</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
<link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<div id="page_container">
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0" style="width: 100%;">
 <tbody>
 <tr>
  <td id="projectlogo">
    <a href="http://www.wxwidgets.org/" target="_new">
      <img alt="wxWidgets" src="logo.png"/>
    </a>
  </td>
  <td style="padding-left: 0.5em; text-align: right;">
   <span id="projectnumber">Version: 3.0.2</span>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- Generated by Doxygen 1.8.2 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li class="current"><a href="pages.html"><span>Related&#160;Pages</span></a></li>
      <li><a href="modules.html"><span>Categories</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="index.html">Documentation</a></li><li class="navelem"><a class="el" href="page_topics.html">Programming Guides</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="headertitle">
<div class="title">Document/View Framework </div>  </div>
</div><!--header-->
<div class="contents">
<div class="toc"><h3>Table of Contents</h3>
<ul><li class="level1"><a href="#overview_docview_wxdoc">wxDocument Overview</a></li>
<li class="level1"><a href="#overview_docview_wxview">wxView Overview</a></li>
<li class="level1"><a href="#overview_docview_wxdoctemplate">wxDocTemplate Overview</a></li>
<li class="level1"><a href="#overview_docview_wxdocmanager">wxDocManager Overview</a></li>
<li class="level1"><a href="#overview_docview_events">Event Propagation in Document/View framework</a></li>
<li class="level1"><a href="#overview_docview_wxcommand">wxCommand Overview</a></li>
<li class="level1"><a href="#overview_docview_wxcommandproc">wxCommandProcessor Overview</a></li>
<li class="level1"><a href="#overview_docview_filehistory">wxFileHistory Overview</a></li>
<li class="level1"><a href="#overview_docview_predefid">Predefined Command Identifiers</a></li>
</ul>
</div>
<div class="textblock"><p>The document/view framework is found in most application frameworks, because it can dramatically simplify the code required to build many kinds of application.</p>
<p>The idea is that you can model your application primarily in terms of <em>documents</em> to store data and provide interface-independent operations upon it, and <em>views</em> to visualise and manipulate the data. Documents know how to do input and output given stream objects, and views are responsible for taking input from physical windows and performing the manipulation on the document data.</p>
<p>If a document's data changes, all views should be updated to reflect the change. The framework can provide many user-interface elements based on this model.</p>
<p>Once you have defined your own classes and the relationships between them, the framework takes care of popping up file selectors, opening and closing files, asking the user to save modifications, routing menu commands to appropriate (possibly default) code, even some default print/preview functionality and support for command undo/redo.</p>
<p>The framework is highly modular, allowing overriding and replacement of functionality and objects to achieve more than the default behaviour.</p>
<p>These are the overall steps involved in creating an application based on the document/view framework:</p>
<ul>
<li>Define your own document and view classes, overriding a minimal set of member functions e.g. for input/output, drawing and initialization. </li>
<li>Define any subwindows (such as a scrolled window) that are needed for the view(s). You may need to route some events to views or documents, for example, "OnPaint" needs to be routed to <a class="el" href="classwx_view.html#ab4b046b3cf4280fd35ed6fb711c35a94" title="Override this function to render the view on the given device context.">wxView::OnDraw</a>. </li>
<li>Decide what style of interface you will use: Microsoft's MDI (multiple document child frames surrounded by an overall frame), SDI (a separate, unconstrained frame for each document), or single-window (one document open at a time, as in Windows Write). </li>
<li>Use the appropriate <a class="el" href="classwx_doc_parent_frame.html" title="The wxDocParentFrame class provides a default top-level frame for applications using the document/vie...">wxDocParentFrame</a> and <a class="el" href="classwx_doc_child_frame.html" title="The wxDocChildFrame class provides a default frame for displaying documents on separate windows...">wxDocChildFrame</a> classes. Construct an instance of <a class="el" href="classwx_doc_parent_frame.html" title="The wxDocParentFrame class provides a default top-level frame for applications using the document/vie...">wxDocParentFrame</a> in your <a class="el" href="classwx_app_console.html#a99953775a2fd83fa2456e390779afe15" title="This must be provided by the application, and will usually create the application&#39;s main window...">wxApp::OnInit</a>, and a <a class="el" href="classwx_doc_child_frame.html" title="The wxDocChildFrame class provides a default frame for displaying documents on separate windows...">wxDocChildFrame</a> (if not single-window) when you initialize a view. Create menus using standard menu ids (such as wxID_OPEN, wxID_PRINT). </li>
<li>Construct a single <a class="el" href="classwx_doc_manager.html" title="The wxDocManager class is part of the document/view framework supported by wxWidgets, and cooperates with the wxView, wxDocument and wxDocTemplate classes.">wxDocManager</a> instance at the beginning of your <a class="el" href="classwx_app_console.html#a99953775a2fd83fa2456e390779afe15" title="This must be provided by the application, and will usually create the application&#39;s main window...">wxApp::OnInit</a>, and then as many <a class="el" href="classwx_doc_template.html" title="The wxDocTemplate class is used to model the relationship between a document class and a view class...">wxDocTemplate</a> instances as necessary to define relationships between documents and views. For a simple application, there will be just one <a class="el" href="classwx_doc_template.html" title="The wxDocTemplate class is used to model the relationship between a document class and a view class...">wxDocTemplate</a>.</li>
</ul>
<p>If you wish to implement Undo/Redo, you need to derive your own class(es) from <a class="el" href="classwx_command.html" title="wxCommand is a base class for modelling an application command, which is an action usually performed ...">wxCommand</a> and use <a class="el" href="classwx_command_processor.html#a5c4a270152e0ca5d57d4e0c0c5e9e34a" title="Submits a new command to the command processor.">wxCommandProcessor::Submit</a> instead of directly executing code. The framework will take care of calling Undo and Do functions as appropriate, so long as the wxID_UNDO and wxID_REDO menu items are defined in the view menu.</p>
<p>Here are a few examples of the tailoring you can do to go beyond the default framework behaviour:</p>
<ul>
<li>Override <a class="el" href="classwx_document.html#a179c3d09f2e9d421e12728da96f3ce93" title="Override this function if you want a different (or no) command processor to be created when the docum...">wxDocument::OnCreateCommandProcessor</a> to define a different Do/Undo strategy, or a command history editor. </li>
<li>Override <a class="el" href="classwx_view.html#aad69b22cb876fe4a2ea84419c81a8273" title="If the printing framework is enabled in the library, this function returns a wxPrintout object for th...">wxView::OnCreatePrintout</a> to create an instance of a derived <a class="el" href="classwx_printout.html" title="This class encapsulates the functionality of printing out an application document.">wxPrintout</a> class, to provide multi-page document facilities. </li>
<li>Override <a class="el" href="classwx_doc_manager.html#a453a23981a95bcee042f6e23bd762c7a" title="Under Windows, pops up a file selector with a list of filters corresponding to document templates...">wxDocManager::SelectDocumentPath</a> to provide a different file selector. </li>
<li>Limit the maximum number of open documents and the maximum number of undo commands.</li>
</ul>
<p>Note that to activate framework functionality, you need to use some or all of the wxWidgets <a class="el" href="overview_docview.html#overview_docview_predefid">Predefined Command Identifiers</a> in your menus.</p>
<p><b>wxPerl Note:</b> The document/view framework is available in wxPerl. To use it, you will need the following statements in your application code:</p>
<div class="fragment"><div class="line">use Wx::DocView;</div>
<div class="line">use Wx <span class="stringliteral">&#39;:docview&#39;</span>;   # <span class="keyword">import</span> constants (optional)</div>
</div><!-- fragment --><dl class="section see"><dt>See Also</dt><dd><a class="el" href="group__group__class__docview.html">Document/View Framework</a>,</dd></dl>
<h1><a class="anchor" id="overview_docview_wxdoc"></a>
wxDocument Overview</h1>
<p>The <a class="el" href="classwx_document.html" title="The document class can be used to model an application&#39;s file-based data.">wxDocument</a> class can be used to model an application's file-based data. It is part of the document/view framework supported by wxWidgets, and cooperates with the <a class="el" href="classwx_view.html" title="The view class can be used to model the viewing and editing component of an application&#39;s file-based ...">wxView</a>, <a class="el" href="classwx_doc_template.html" title="The wxDocTemplate class is used to model the relationship between a document class and a view class...">wxDocTemplate</a> and <a class="el" href="classwx_doc_manager.html" title="The wxDocManager class is part of the document/view framework supported by wxWidgets, and cooperates with the wxView, wxDocument and wxDocTemplate classes.">wxDocManager</a> classes. Using this framework can save a lot of routine user-interface programming, since a range of menu commands &ndash; such as open, save, save as &ndash; are supported automatically.</p>
<p>The programmer just needs to define a minimal set of classes and member functions for the framework to call when necessary. Data, and the means to view and edit the data, are explicitly separated out in this model, and the concept of multiple <em>views</em> onto the same data is supported.</p>
<p>Note that the document/view model will suit many but not all styles of application. For example, it would be overkill for a simple file conversion utility, where there may be no call for <em>views</em> on <em>documents</em> or the ability to open, edit and save files. But probably the majority of applications are document-based.</p>
<p>See the example application in <code>samples/docview</code>. To use the abstract <a class="el" href="classwx_document.html" title="The document class can be used to model an application&#39;s file-based data.">wxDocument</a> class, you need to derive a new class and override at least the member functions SaveObject and LoadObject. SaveObject and LoadObject will be called by the framework when the document needs to be saved or loaded.</p>
<p>Use the macros DECLARE_DYNAMIC_CLASS and IMPLEMENT_DYNAMIC_CLASS in order to allow the framework to create document objects on demand. When you create a <a class="el" href="classwx_doc_template.html" title="The wxDocTemplate class is used to model the relationship between a document class and a view class...">wxDocTemplate</a> object on application initialization, you should pass CLASSINFO(YourDocumentClass) to the <a class="el" href="classwx_doc_template.html" title="The wxDocTemplate class is used to model the relationship between a document class and a view class...">wxDocTemplate</a> constructor so that it knows how to create an instance of this class.</p>
<p>If you do not wish to use the wxWidgets method of creating document objects dynamically, you must override <a class="el" href="classwx_doc_template.html#aab182c7d35ba29399cd02c6526f9ce33" title="Creates a new instance of the associated document class.">wxDocTemplate::CreateDocument</a> to return an instance of the appropriate class.</p>
<h1><a class="anchor" id="overview_docview_wxview"></a>
wxView Overview</h1>
<p>The <a class="el" href="classwx_view.html" title="The view class can be used to model the viewing and editing component of an application&#39;s file-based ...">wxView</a> class can be used to model the viewing and editing component of an application's file-based data. It is part of the document/view framework supported by wxWidgets, and cooperates with the <a class="el" href="classwx_document.html" title="The document class can be used to model an application&#39;s file-based data.">wxDocument</a>, <a class="el" href="classwx_doc_template.html" title="The wxDocTemplate class is used to model the relationship between a document class and a view class...">wxDocTemplate</a> and <a class="el" href="classwx_doc_manager.html" title="The wxDocManager class is part of the document/view framework supported by wxWidgets, and cooperates with the wxView, wxDocument and wxDocTemplate classes.">wxDocManager</a> classes.</p>
<p>See the example application in <code>samples/docview</code>.</p>
<p>To use the abstract <a class="el" href="classwx_view.html" title="The view class can be used to model the viewing and editing component of an application&#39;s file-based ...">wxView</a> class, you need to derive a new class and override at least the member functions OnCreate, OnDraw, OnUpdate and OnClose. You will probably want to respond to menu commands from the frame containing the view.</p>
<p>Use the macros DECLARE_DYNAMIC_CLASS and IMPLEMENT_DYNAMIC_CLASS in order to allow the framework to create view objects on demand. When you create a <a class="el" href="classwx_doc_template.html" title="The wxDocTemplate class is used to model the relationship between a document class and a view class...">wxDocTemplate</a> object on application initialization, you should pass CLASSINFO(YourViewClass) to the <a class="el" href="classwx_doc_template.html" title="The wxDocTemplate class is used to model the relationship between a document class and a view class...">wxDocTemplate</a> constructor so that it knows how to create an instance of this class.</p>
<p>If you do not wish to use the wxWidgets method of creating view objects dynamically, you must override <a class="el" href="classwx_doc_template.html#a9efec24a94085a66c35458520e5efcad" title="Creates a new instance of the associated view class.">wxDocTemplate::CreateView</a> to return an instance of the appropriate class.</p>
<h1><a class="anchor" id="overview_docview_wxdoctemplate"></a>
wxDocTemplate Overview</h1>
<p>The <a class="el" href="classwx_doc_template.html" title="The wxDocTemplate class is used to model the relationship between a document class and a view class...">wxDocTemplate</a> class is used to model the relationship between a document class and a view class. The application creates a document template object for each document/view pair. The list of document templates managed by the <a class="el" href="classwx_doc_manager.html" title="The wxDocManager class is part of the document/view framework supported by wxWidgets, and cooperates with the wxView, wxDocument and wxDocTemplate classes.">wxDocManager</a> instance is used to create documents and views. Each document template knows what file filters and default extension are appropriate for a document/view combination, and how to create a document or view.</p>
<p>For example, you might write a small doodling application that can load and save lists of line segments. If you had two views of the data &ndash; graphical, and a list of the segments &ndash; then you would create one document class DoodleDocument, and two view classes (DoodleGraphicView and DoodleListView). You would also need two document templates, one for the graphical view and another for the list view. You would pass the same document class and default file extension to both document templates, but each would be passed a different view class. When the user clicks on the Open menu item, the file selector is displayed with a list of possible file filters &ndash; one for each <a class="el" href="classwx_doc_template.html" title="The wxDocTemplate class is used to model the relationship between a document class and a view class...">wxDocTemplate</a>. Selecting the filter selects the <a class="el" href="classwx_doc_template.html" title="The wxDocTemplate class is used to model the relationship between a document class and a view class...">wxDocTemplate</a>, and when a file is selected, that template will be used for creating a document and view.</p>
<p>For the case where an application has one document type and one view type, a single document template is constructed, and dialogs will be appropriately simplified.</p>
<p><a class="el" href="classwx_doc_template.html" title="The wxDocTemplate class is used to model the relationship between a document class and a view class...">wxDocTemplate</a> is part of the document/view framework supported by wxWidgets, and cooperates with the <a class="el" href="classwx_view.html" title="The view class can be used to model the viewing and editing component of an application&#39;s file-based ...">wxView</a>, <a class="el" href="classwx_document.html" title="The document class can be used to model an application&#39;s file-based data.">wxDocument</a> and <a class="el" href="classwx_doc_manager.html" title="The wxDocManager class is part of the document/view framework supported by wxWidgets, and cooperates with the wxView, wxDocument and wxDocTemplate classes.">wxDocManager</a> classes.</p>
<p>See the example application in <code>samples/docview</code>.</p>
<p>To use the <a class="el" href="classwx_doc_template.html" title="The wxDocTemplate class is used to model the relationship between a document class and a view class...">wxDocTemplate</a> class, you do not need to derive a new class. Just pass relevant information to the constructor including CLASSINFO(YourDocumentClass) and CLASSINFO(YourViewClass) to allow dynamic instance creation.</p>
<p>If you do not wish to use the wxWidgets method of creating document objects dynamically, you must override <a class="el" href="classwx_doc_template.html#aab182c7d35ba29399cd02c6526f9ce33" title="Creates a new instance of the associated document class.">wxDocTemplate::CreateDocument</a> and <a class="el" href="classwx_doc_template.html#a9efec24a94085a66c35458520e5efcad" title="Creates a new instance of the associated view class.">wxDocTemplate::CreateView</a> to return instances of the appropriate class.</p>
<dl class="section note"><dt>Note</dt><dd>The document template has nothing to do with the C++ template construct.</dd></dl>
<h1><a class="anchor" id="overview_docview_wxdocmanager"></a>
wxDocManager Overview</h1>
<p>The <a class="el" href="classwx_doc_manager.html" title="The wxDocManager class is part of the document/view framework supported by wxWidgets, and cooperates with the wxView, wxDocument and wxDocTemplate classes.">wxDocManager</a> class is part of the document/view framework supported by wxWidgets, and cooperates with the <a class="el" href="classwx_view.html" title="The view class can be used to model the viewing and editing component of an application&#39;s file-based ...">wxView</a>, <a class="el" href="classwx_document.html" title="The document class can be used to model an application&#39;s file-based data.">wxDocument</a> and <a class="el" href="classwx_doc_template.html" title="The wxDocTemplate class is used to model the relationship between a document class and a view class...">wxDocTemplate</a> classes.</p>
<p>A <a class="el" href="classwx_doc_manager.html" title="The wxDocManager class is part of the document/view framework supported by wxWidgets, and cooperates with the wxView, wxDocument and wxDocTemplate classes.">wxDocManager</a> instance coordinates documents, views and document templates. It keeps a list of document and template instances, and much functionality is routed through this object, such as providing selection and file dialogs. The application can use this class 'as is' or derive a class and override some members to extend or change the functionality.</p>
<p>Create an instance of this class near the beginning of your application initialization, before any documents, views or templates are manipulated.</p>
<p>There may be multiple <a class="el" href="classwx_doc_manager.html" title="The wxDocManager class is part of the document/view framework supported by wxWidgets, and cooperates with the wxView, wxDocument and wxDocTemplate classes.">wxDocManager</a> instances in an application. See the example application in <code>samples/docview</code>.</p>
<h1><a class="anchor" id="overview_docview_events"></a>
Event Propagation in Document/View framework</h1>
<p>While <a class="el" href="classwx_document.html" title="The document class can be used to model an application&#39;s file-based data.">wxDocument</a>, <a class="el" href="classwx_doc_manager.html" title="The wxDocManager class is part of the document/view framework supported by wxWidgets, and cooperates with the wxView, wxDocument and wxDocTemplate classes.">wxDocManager</a> and <a class="el" href="classwx_view.html" title="The view class can be used to model the viewing and editing component of an application&#39;s file-based ...">wxView</a> are abstract objects, with which the user can't interact directly, all of them derive from <a class="el" href="classwx_evt_handler.html" title="A class that can handle events from the windowing system.">wxEvtHandler</a> class and can handle events arising in the windows showing the document with which the user does interact. This is implemented by adding additional steps to the event handling process described in <a class="el" href="overview_events.html#overview_events_processing">How Events are Processed</a>, so the full list of the handlers searched for an event occurring directly in <a class="el" href="classwx_doc_child_frame.html" title="The wxDocChildFrame class provides a default frame for displaying documents on separate windows...">wxDocChildFrame</a> is: </p>
<ol>
<li>
<a class="el" href="classwx_document.html" title="The document class can be used to model an application&#39;s file-based data.">wxDocument</a> opened in this frame. </li>
<li>
<a class="el" href="classwx_view.html" title="The view class can be used to model the viewing and editing component of an application&#39;s file-based ...">wxView</a> shown in this frame. </li>
<li>
<a class="el" href="classwx_doc_manager.html" title="The wxDocManager class is part of the document/view framework supported by wxWidgets, and cooperates with the wxView, wxDocument and wxDocTemplate classes.">wxDocManager</a> associated with the parent <a class="el" href="classwx_doc_parent_frame.html" title="The wxDocParentFrame class provides a default top-level frame for applications using the document/vie...">wxDocParentFrame</a>. </li>
<li>
<a class="el" href="classwx_doc_child_frame.html" title="The wxDocChildFrame class provides a default frame for displaying documents on separate windows...">wxDocChildFrame</a> itself. </li>
<li>
<a class="el" href="classwx_doc_parent_frame.html" title="The wxDocParentFrame class provides a default top-level frame for applications using the document/vie...">wxDocParentFrame</a>, as per the usual event bubbling up to parent rules. </li>
<li>
<a class="el" href="classwx_app.html" title="The wxApp class represents the application itself when wxUSE_GUI=1.">wxApp</a>, again as the usual fallback for all events. </li>
</ol>
<p>This is mostly useful to define handlers for some menu commands directly in <a class="el" href="classwx_document.html" title="The document class can be used to model an application&#39;s file-based data.">wxDocument</a> or <a class="el" href="classwx_view.html" title="The view class can be used to model the viewing and editing component of an application&#39;s file-based ...">wxView</a> and is also used by the framework itself to define the handlers for several standard commands, such as wxID_NEW or wxID_SAVE, in <a class="el" href="classwx_doc_manager.html" title="The wxDocManager class is part of the document/view framework supported by wxWidgets, and cooperates with the wxView, wxDocument and wxDocTemplate classes.">wxDocManager</a> itself. Notice that due to the order of the event handler search detailed above, the handling of these commands can <em>not</em> be overridden at <a class="el" href="classwx_doc_parent_frame.html" title="The wxDocParentFrame class provides a default top-level frame for applications using the document/vie...">wxDocParentFrame</a> level but must be done at the level of <a class="el" href="classwx_doc_manager.html" title="The wxDocManager class is part of the document/view framework supported by wxWidgets, and cooperates with the wxView, wxDocument and wxDocTemplate classes.">wxDocManager</a> itself.</p>
<h1><a class="anchor" id="overview_docview_wxcommand"></a>
wxCommand Overview</h1>
<p><a class="el" href="classwx_command.html" title="wxCommand is a base class for modelling an application command, which is an action usually performed ...">wxCommand</a> is a base class for modelling an application command, which is an action usually performed by selecting a menu item, pressing a toolbar button or any other means provided by the application to change the data or view.</p>
<p>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.</p>
<p>When a user interface event occurs, the application <em>submits</em> a command to a <a class="el" href="classwx_command_processor.html" title="wxCommandProcessor is a class that maintains a history of wxCommands, with undo/redo functionality bu...">wxCommandProcessor</a> object to execute and store.</p>
<p>The wxWidgets document/view framework handles Undo and Redo by use of <a class="el" href="classwx_command.html" title="wxCommand is a base class for modelling an application command, which is an action usually performed ...">wxCommand</a> and <a class="el" href="classwx_command_processor.html" title="wxCommandProcessor is a class that maintains a history of wxCommands, with undo/redo functionality bu...">wxCommandProcessor</a> objects. You might find further uses for <a class="el" href="classwx_command.html" title="wxCommand is a base class for modelling an application command, which is an action usually performed ...">wxCommand</a>, such as implementing a macro facility that stores, loads and replays commands.</p>
<p>An application can derive a new class for every command, or, more likely, use one class parameterized with an integer or string command identifier.</p>
<h1><a class="anchor" id="overview_docview_wxcommandproc"></a>
wxCommandProcessor Overview</h1>
<p><a class="el" href="classwx_command_processor.html" title="wxCommandProcessor is a class that maintains a history of wxCommands, with undo/redo functionality bu...">wxCommandProcessor</a> is a class that maintains a history of <a class="el" href="classwx_command.html" title="wxCommand is a base class for modelling an application command, which is an action usually performed ...">wxCommand</a> instances, with undo/redo functionality built-in. Derive a new class from this if you want different behaviour.</p>
<h1><a class="anchor" id="overview_docview_filehistory"></a>
wxFileHistory Overview</h1>
<p><a class="el" href="classwx_file_history.html" title="The wxFileHistory encapsulates a user interface convenience, the list of most recently visited files ...">wxFileHistory</a> 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 <a class="el" href="classwx_file_history.html" title="The wxFileHistory encapsulates a user interface convenience, the list of most recently visited files ...">wxFileHistory</a> is used by <a class="el" href="classwx_doc_manager.html" title="The wxDocManager class is part of the document/view framework supported by wxWidgets, and cooperates with the wxView, wxDocument and wxDocTemplate classes.">wxDocManager</a>, 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.</p>
<p>By calling <a class="el" href="classwx_file_history.html#ad73800aba67b30fc9d0dc94f17c4cc09" title="Adds this menu to the list of those menus that are managed by this file history object.">wxFileHistory::UseMenu()</a> 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.</p>
<p>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 <a class="el" href="classwx_file_history.html#a8c77c1d51e18be0b54639953745481a6" title="Appends the files in the history list, to all menus managed by the file history object.">wxFileHistory::AddFilesToMenu()</a> 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).</p>
<p>The filenames are appended using menu identifiers in the range <code>wxID_FILE1</code> to <code>wxID_FILE9</code>.</p>
<p>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:</p>
<div class="fragment"><div class="line">BEGIN_EVENT_TABLE(<a class="code" href="classwx_doc_parent_frame.html" title="The wxDocParentFrame class provides a default top-level frame for applications using the document/vie...">wxDocParentFrame</a>, <a class="code" href="classwx_frame.html" title="A frame is a window whose size and position can (usually) be changed by the user.">wxFrame</a>)</div>
<div class="line">    EVT_MENU(<a class="code" href="defs_8h.html#ac66d0a09761e7d86b2ac0b2e0c6a8cbba37f548d1211c664ede962e943baad4e5">wxID_EXIT</a>, <a class="code" href="classwx_doc_parent_frame.html" title="The wxDocParentFrame class provides a default top-level frame for applications using the document/vie...">wxDocParentFrame</a>::OnExit)</div>
<div class="line">    EVT_MENU_RANGE(<a class="code" href="defs_8h.html#ac66d0a09761e7d86b2ac0b2e0c6a8cbba2e9387433c38391c65eeee71adbf0e13">wxID_FILE1</a>, <a class="code" href="defs_8h.html#ac66d0a09761e7d86b2ac0b2e0c6a8cbba4dc2e1fd2414bf9da8d9af3f23da6f12">wxID_FILE9</a>, <a class="code" href="classwx_doc_parent_frame.html" title="The wxDocParentFrame class provides a default top-level frame for applications using the document/vie...">wxDocParentFrame</a>::OnMRUFile)</div>
<div class="line">END_EVENT_TABLE()</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> <a class="code" href="classwx_doc_parent_frame.html" title="The wxDocParentFrame class provides a default top-level frame for applications using the document/vie...">wxDocParentFrame</a>::OnExit(<a class="code" href="classwx_command_event.html" title="This event class contains information about command events, which originate from a variety of simple ...">wxCommandEvent</a>&amp; WXUNUSED(event))</div>
<div class="line">{</div>
<div class="line">    Close();</div>
<div class="line">}</div>
<div class="line"></div>
<div class="line"><span class="keywordtype">void</span> wxDocParentFrame::OnMRUFile(<a class="code" href="classwx_command_event.html" title="This event class contains information about command events, which originate from a variety of simple ...">wxCommandEvent</a>&amp; event)</div>
<div class="line">{</div>
<div class="line">    <a class="code" href="classwx_string.html" title="String class for passing textual data to or receiving it from wxWidgets.">wxString</a> f(m_docManager-&gt;GetHistoryFile(event.<a class="code" href="classwx_event.html#ac732828ac14cfc289d798a4fea437246" title="Returns the identifier associated with this event, such as a button command id.">GetId</a>() - <a class="code" href="defs_8h.html#ac66d0a09761e7d86b2ac0b2e0c6a8cbba2e9387433c38391c65eeee71adbf0e13">wxID_FILE1</a>));</div>
<div class="line">    <span class="keywordflow">if</span> (!f.empty())</div>
<div class="line">        (<span class="keywordtype">void</span>)m_docManager-CreateDocument(f, wxDOC_SILENT);</div>
<div class="line">}</div>
</div><!-- fragment --><h1><a class="anchor" id="overview_docview_predefid"></a>
Predefined Command Identifiers</h1>
<p>To allow communication between the application's menus and the document/view framework, several command identifiers are predefined for you to use in menus.</p>
<pre class="fragment">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)
</pre> </div></div><!-- contents -->

<address class="footer">
	<small>
		Generated on Thu Nov 27 2014 13:46:42 for wxWidgets by <a href="http://www.doxygen.org/index.html" target="_new">Doxygen</a> 1.8.2
	</small>
</address>
<script src="wxwidgets.js" type="text/javascript"></script>
</div><!-- #page_container -->
</body>
</html>