File: wx74.htm

package info (click to toggle)
wxwin2-doc 2.01-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 6,540 kB
  • ctags: 5,968
  • sloc: cpp: 15,157; makefile: 434; sh: 6
file content (438 lines) | stat: -rw-r--r-- 16,746 bytes parent folder | download
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
<HTML>
<head><title>wxDocManager</title></head>

<BODY BGCOLOR=#FFFFFF>
<A NAME="wxdocmanager"></A><CENTER>
<A HREF="wx.htm"><img align=center src="contents.gif" BORDER=0 ALT="Contents"></A> <A HREF="wx22.htm#classref"><img align=center src="up.gif" BORDER=0 ALT="Up"></A> <A HREF="wx73.htm#wxdocchildframe"><img align=center src="back.gif" BORDER=0 ALT="Previous"></A> <A HREF="wx75.htm#wxdocmdichildframe"><img align=center src="forward.gif" BORDER=0 ALT="Next"></A> </CENTER><HR>

<H2>wxDocManager</H2>
<P>
The wxDocManager class is part of the document/view framework supported by wxWindows,
and cooperates with the <A HREF="wx258.htm#wxview">wxView</A>, <A HREF="wx79.htm#wxdocument">wxDocument</A>
and <A HREF="wx78.htm#wxdoctemplate">wxDocTemplate</A> classes.<P>
<B><FONT COLOR="#FF0000">Derived from</FONT></B><P>
<A HREF="wx85.htm#wxevthandler">wxEvtHandler</A><BR>

<A HREF="wx158.htm#wxobject">wxObject</A><P>
<B><FONT COLOR="#FF0000">Include files</FONT></B><P>
&lt;wx/docview.h&gt;<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx298.htm#wxdocmanageroverview">wxDocManager overview</A>, <A HREF="wx79.htm#wxdocument">wxDocument</A>,
<A HREF="wx258.htm#wxview">wxView</A>, <A HREF="wx78.htm#wxdoctemplate">wxDocTemplate</A>, <A HREF="wx92.htm#wxfilehistory">wxFileHistory</A><P>
<B><FONT COLOR="#FF0000">Members</FONT></B><P>
<A HREF="#topic213">wxDocManager::m_currentView</A><BR>
<A HREF="#topic214">wxDocManager::m_defaultDocumentNameCounter</A><BR>
<A HREF="#topic215">wxDocManager::m_fileHistory</A><BR>
<A HREF="#topic216">wxDocManager::m_maxDocsOpen</A><BR>
<A HREF="#topic217">wxDocManager::m_docs</A><BR>
<A HREF="#topic218">wxDocManager::m_flags</A><BR>
<A HREF="#topic219">wxDocManager::m_templates</A><BR>
<A HREF="#topic220">wxDocManager::wxDocManager</A><BR>
<A HREF="#topic221">wxDocManager::~wxDocManager</A><BR>
<A HREF="#topic222">wxDocManager::ActivateView</A><BR>
<A HREF="#topic223">wxDocManager::AddDocument</A><BR>
<A HREF="#topic224">wxDocManager::AddFileToHistory</A><BR>
<A HREF="#topic225">wxDocManager::AssociateTemplate</A><BR>
<A HREF="#topic226">wxDocManager::CreateDocument</A><BR>
<A HREF="#topic227">wxDocManager::CreateView</A><BR>
<A HREF="#topic228">wxDocManager::DisassociateTemplate</A><BR>
<A HREF="#wxdocmanagerfilehistoryaddfilestomenu">wxDocManager::FileHistoryAddFilesToMenu</A><BR>
<A HREF="#wxdocmanagerfilehistoryload">wxDocManager::FileHistoryLoad</A><BR>
<A HREF="#wxdocmanagerfilehistoryremovemenu">wxDocManager::FileHistoryRemoveMenu</A><BR>
<A HREF="#wxdocmanagerfilehistorysave">wxDocManager::FileHistorySave</A><BR>
<A HREF="#wxdocmanagerfilehistoryusemenu">wxDocManager::FileHistoryUseMenu</A><BR>
<A HREF="#topic229">wxDocManager::FindTemplateForPath</A><BR>
<A HREF="#topic230">wxDocManager::GetCurrentDocument</A><BR>
<A HREF="#topic231">wxDocManager::GetCurrentView</A><BR>
<A HREF="#topic232">wxDocManager::GetDocuments</A><BR>
<A HREF="#topic233">wxDocManager::GetFileHistory</A><BR>
<A HREF="#topic234">wxDocManager::GetMaxDocsOpen</A><BR>
<A HREF="#topic235">wxDocManager::GetNoHistoryFiles</A><BR>
<A HREF="#wxdocmanagerinitialize">wxDocManager::Initialize</A><BR>
<A HREF="#topic236">wxDocManager::MakeDefaultName</A><BR>
<A HREF="#topic237">wxDocManager::OnCreateFileHistory</A><BR>
<A HREF="#topic238">wxDocManager::OnFileClose</A><BR>
<A HREF="#topic239">wxDocManager::OnFileNew</A><BR>
<A HREF="#topic240">wxDocManager::OnFileOpen</A><BR>
<A HREF="#topic241">wxDocManager::OnFileSave</A><BR>
<A HREF="#topic242">wxDocManager::OnFileSaveAs</A><BR>
<A HREF="#topic243">wxDocManager::OnMenuCommand</A><BR>
<A HREF="#topic244">wxDocManager::RemoveDocument</A><BR>
<A HREF="#topic245">wxDocManager::SelectDocumentPath</A><BR>
<A HREF="#topic246">wxDocManager::SelectDocumentType</A><BR>
<A HREF="#topic247">wxDocManager::SelectViewType</A><BR>
<A HREF="#topic248">wxDocManager::SetMaxDocsOpen</A><BR>
<P>

<HR>
<A NAME="topic213"></A>
<H3>wxDocManager::m_currentView</H3>
<P>
wxView* m_currentView<P>
The currently active view.<P>

<HR>
<A NAME="topic214"></A>
<H3>wxDocManager::m_defaultDocumentNameCounter</H3>
<P>
int m_defaultDocumentNameCounter<P>
Stores the integer to be used for the next default document name.<P>

<HR>
<A NAME="topic215"></A>
<H3>wxDocManager::m_fileHistory</H3>
<P>
wxFileHistory* m_fileHistory<P>
A pointer to an instance of <A HREF="wx92.htm#wxfilehistory">wxFileHistory</A>,
which manages the history of recently-visited files on the File menu.<P>

<HR>
<A NAME="topic216"></A>
<H3>wxDocManager::m_maxDocsOpen</H3>
<P>
int m_maxDocsOpen<P>
Stores the maximum number of documents that can be opened before
existing documents are closed. By default, this is 10,000.<P>

<HR>
<A NAME="topic217"></A>
<H3>wxDocManager::m_docs</H3>
<P>
wxList m_docs<P>
A list of all documents.<P>

<HR>
<A NAME="topic218"></A>
<H3>wxDocManager::m_flags</H3>
<P>
long m_flags<P>
Stores the flags passed to the constructor.<P>

<HR>
<A NAME="topic219"></A>
<H3>wxDocManager::m_templates</H3>
<P>
wxList mnTemplates<P>
A list of all document templates.<P>

<HR>
<A NAME="topic220"></A>
<H3>wxDocManager::wxDocManager</H3>
<P>
<B>void</B> <B>wxDocManager</B>(<B>long</B><I> flags = wxDEFAULT_DOCMAN_FLAGS</I>, <B>bool</B><I> initialize = TRUE</I>)<P>
Constructor. Create a document manager instance dynamically near the start of your application
before doing any document or view operations.<P>
<I>flags</I> is currently unused.<P>
If <I>initialize</I> is TRUE, the <A HREF="wx74.htm#wxdocmanagerinitialize">Initialize</A> function will be called
to create a default history list object. If you derive from wxDocManager, you may wish to call the
base constructor with FALSE, and then call Initialize in your own constructor, to allow
your own Initialize or OnCreateFileHistory functions to be called.<P>

<HR>
<A NAME="topic221"></A>
<H3>wxDocManager::~wxDocManager</H3>
<P>
<B>void</B> <B>~wxDocManager</B>()<P>
Destructor.<P>

<HR>
<A NAME="topic222"></A>
<H3>wxDocManager::ActivateView</H3>
<P>
<B>void</B> <B>ActivateView</B>(<B>wxView* </B><I>doc</I>, <B>bool</B><I> activate</I>, <B>bool</B><I> deleting</I>)<P>
Sets the current view.<P>

<HR>
<A NAME="topic223"></A>
<H3>wxDocManager::AddDocument</H3>
<P>
<B>void</B> <B>AddDocument</B>(<B>wxDocument *</B><I>doc</I>)<P>
Adds the document to the list of documents.<P>

<HR>
<A NAME="topic224"></A>
<H3>wxDocManager::AddFileToHistory</H3>
<P>
<B>void</B> <B>AddFileToHistory</B>(<B>const wxString&amp; </B><I>filename</I>)<P>
Adds a file to the file history list, if we have a pointer to an appropriate file menu.<P>

<HR>
<A NAME="topic225"></A>
<H3>wxDocManager::AssociateTemplate</H3>
<P>
<B>void</B> <B>AssociateTemplate</B>(<B>wxDocTemplate *</B><I>temp</I>)<P>
Adds the template to the document manager's template list.<P>

<HR>
<A NAME="topic226"></A>
<H3>wxDocManager::CreateDocument</H3>
<P>
<B>wxDocument*</B> <B>CreateDocument</B>(<B>const wxString&amp; </B><I>path</I>, <B>long</B><I> flags</I>)<P>
Creates a new document in a manner determined by the <I>flags</I> parameter, which can be:<P>
<UL>

<LI> wxDOC_NEW Creates a fresh document.
<LI> wxDOC_SILENT Silently loads the given document file.
</UL>
<P>
If wxDOC_NEW is present, a new document will be created and returned, possibly after
asking the user for a template to use if there is more than one document template.
If wxDOC_SILENT is present, a new document will be created and the given file loaded
into it. If neither of these flags is present, the user will be presented with
a file selector for the file to load, and the template to use will be determined by the
extension (Windows) or by popping up a template choice list (other platforms).<P>
If the maximum number of documents has been reached, this function
will delete the oldest currently loaded document before creating a new one.<P>

<HR>
<A NAME="topic227"></A>
<H3>wxDocManager::CreateView</H3>
<P>
<B>wxView*</B> <B>CreateView</B>(<B>wxDocument*</B><I>doc</I>, <B>long</B><I> flags</I>)<P>
Creates a new view for the given document. If more than one view is allowed for the
document (by virtue of multiple templates mentioning the same document type), a choice
of view is presented to the user.<P>

<HR>
<A NAME="topic228"></A>
<H3>wxDocManager::DisassociateTemplate</H3>
<P>
<B>void</B> <B>DisassociateTemplate</B>(<B>wxDocTemplate *</B><I>temp</I>)<P>
Removes the template from the list of templates.<P>

<HR>
<A NAME="wxdocmanagerfilehistoryaddfilestomenu"></A>
<H3>wxDocManager::FileHistoryAddFilesToMenu</H3>
<P>
<B>void</B> <B>FileHistoryAddFilesToMenu</B>()<P>
Appends the files in the history list, to all menus managed by the file history object.<P>
<B>void</B> <B>FileHistoryAddFilesToMenu</B>(<B>wxMenu*</B><I> menu</I>)<P>
Appends the files in the history list, to the given menu only.<P>

<HR>
<A NAME="wxdocmanagerfilehistoryload"></A>
<H3>wxDocManager::FileHistoryLoad</H3>
<P>
<B>void</B> <B>FileHistoryLoad</B>(<B>wxConfigBase&amp; </B><I>config</I>)<P>
Loads the file history from a config object.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx55.htm#wxconfigbase">wxConfig</A><P>

<HR>
<A NAME="wxdocmanagerfilehistoryremovemenu"></A>
<H3>wxDocManager::FileHistoryRemoveMenu</H3>
<P>
<B>void</B> <B>FileHistoryRemoveMenu</B>(<B>wxMenu*</B><I> menu</I>)<P>
Removes the given menu from the list of menus managed by the file history object.<P>

<HR>
<A NAME="wxdocmanagerfilehistorysave"></A>
<H3>wxDocManager::FileHistorySave</H3>
<P>
<B>void</B> <B>FileHistorySave</B>(<B>wxConfigBase&amp; </B><I>resourceFile</I>)<P>
Saves the file history into a config object. This must be called
explicitly by the application.<P>
<B><FONT COLOR="#FF0000">See also</FONT></B><P>
<A HREF="wx55.htm#wxconfigbase">wxConfig</A><P>

<HR>
<A NAME="wxdocmanagerfilehistoryusemenu"></A>
<H3>wxDocManager::FileHistoryUseMenu</H3>
<P>
<B>void</B> <B>FileHistoryUseMenu</B>(<B>wxMenu*</B><I> menu</I>)<P>
Use this menu for appending recently-visited document filenames, for convenient
access. Calling this function with a valid menu pointer enables the history
list functionality.<P>
Note that you can add multiple menus using this function, to be managed by the
file history object.<P>

<HR>
<A NAME="topic229"></A>
<H3>wxDocManager::FindTemplateForPath</H3>
<P>
<B>wxDocTemplate *</B> <B>FindTemplateForPath</B>(<B>const wxString&amp; </B><I>path</I>)<P>
Given a path, try to find template that matches the extension. This is only
an approximate method of finding a template for creating a document.<P>

<HR>
<A NAME="topic230"></A>
<H3>wxDocManager::GetCurrentDocument</H3>
<P>
<B>wxDocument *</B> <B>GetCurrentDocument</B>()<P>
Returns the document associated with the currently active view (if any).<P>

<HR>
<A NAME="topic231"></A>
<H3>wxDocManager::GetCurrentView</H3>
<P>
<B>wxView *</B> <B>GetCurrentView</B>()<P>
Returns the currently active view <P>

<HR>
<A NAME="topic232"></A>
<H3>wxDocManager::GetDocuments</H3>
<P>
<B>wxList&amp;</B> <B>GetDocuments</B>()<P>
Returns a reference to the list of documents.<P>

<HR>
<A NAME="topic233"></A>
<H3>wxDocManager::GetFileHistory</H3>
<P>
<B>wxFileHistory *</B> <B>GetFileHistory</B>()<P>
Returns a pointer to file history.<P>

<HR>
<A NAME="topic234"></A>
<H3>wxDocManager::GetMaxDocsOpen</H3>
<P>
<B>int</B> <B>GetMaxDocsOpen</B>()<P>
Returns the number of documents that can be open simultaneously.<P>

<HR>
<A NAME="topic235"></A>
<H3>wxDocManager::GetNoHistoryFiles</H3>
<P>
<B>int</B> <B>GetNoHistoryFiles</B>()<P>
Returns the number of files currently stored in the file history.<P>

<HR>
<A NAME="wxdocmanagerinitialize"></A>
<H3>wxDocManager::Initialize</H3>
<P>
<B>bool</B> <B>Initialize</B>()<P>
Initializes data; currently just calls OnCreateFileHistory. Some data cannot
always be initialized in the constructor because the programmer must be given
the opportunity to override functionality. If OnCreateFileHistory was called
from the constructor, an overridden virtual OnCreateFileHistory would not be
called due to C++'s 'interesting' constructor semantics. In fact Initialize
<I>is</I> called from the wxDocManager constructor, but this can be
vetoed by passing FALSE to the second argument, allowing the derived class's
constructor to call Initialize, possibly calling a different OnCreateFileHistory
from the default.<P>
The bottom line: if you're not deriving from Initialize, forget it and
construct wxDocManager with no arguments.<P>

<HR>
<A NAME="topic236"></A>
<H3>wxDocManager::MakeDefaultName</H3>
<P>
<B>bool</B> <B>MakeDefaultName</B>(<B>const wxString&amp; </B><I>buf</I>)<P>
Copies a suitable default name into <I>buf</I>. This is implemented by
appending an integer counter to the string <B>unnamed</B> and incrementing
the counter.<P>

<HR>
<A NAME="topic237"></A>
<H3>wxDocManager::OnCreateFileHistory</H3>
<P>
<B>wxFileHistory *</B> <B>OnCreateFileHistory</B>()<P>
A hook to allow a derived class to create a different type of file history. Called
from <A HREF="wx74.htm#wxdocmanagerinitialize">Initialize</A>.<P>

<HR>
<A NAME="topic238"></A>
<H3>wxDocManager::OnFileClose</H3>
<P>
<B>void</B> <B>OnFileClose</B>()<P>
Closes and deletes the currently active document.<P>

<HR>
<A NAME="topic239"></A>
<H3>wxDocManager::OnFileNew</H3>
<P>
<B>void</B> <B>OnFileNew</B>()<P>
Creates a document from a list of templates (if more than one template).<P>

<HR>
<A NAME="topic240"></A>
<H3>wxDocManager::OnFileOpen</H3>
<P>
<B>void</B> <B>OnFileOpen</B>()<P>
Creates a new document and reads in the selected file.<P>

<HR>
<A NAME="topic241"></A>
<H3>wxDocManager::OnFileSave</H3>
<P>
<B>void</B> <B>OnFileSave</B>()<P>
Saves the current document by calling wxDocument::Save for the current document.<P>

<HR>
<A NAME="topic242"></A>
<H3>wxDocManager::OnFileSaveAs</H3>
<P>
<B>void</B> <B>OnFileSaveAs</B>()<P>
Calls wxDocument::SaveAs for the current document.<P>

<HR>
<A NAME="topic243"></A>
<H3>wxDocManager::OnMenuCommand</H3>
<P>
<B>void</B> <B>OnMenuCommand</B>(<B>int</B><I> cmd</I>)<P>
Processes menu commands routed from child or parent frames. This deals
with the following predefined menu item identifiers:<P>
<UL>

<LI> wxID_OPEN Creates a new document and opens a file into it.
<LI> wxID_CLOSE Closes the current document.
<LI> wxID_NEW Creates a new document.
<LI> wxID_SAVE Saves the document.
<LI> wxID_SAVE_AS Saves the document into a specified filename.
</UL>
<P>
Unrecognized commands are routed to the currently active wxView's OnMenuCommand.<P>

<HR>
<A NAME="topic244"></A>
<H3>wxDocManager::RemoveDocument</H3>
<P>
<B>void</B> <B>RemoveDocument</B>(<B>wxDocument *</B><I>doc</I>)<P>
Removes the document from the list of documents.<P>

<HR>
<A NAME="topic245"></A>
<H3>wxDocManager::SelectDocumentPath</H3>
<P>
<B>wxDocTemplate *</B> <B>SelectDocumentPath</B>(<B>wxDocTemplate **</B><I>templates</I>,
 <B>int</B><I> noTemplates</I>, <B>const wxString&amp; </B><I>path</I>, <B>const wxString&amp; </B><I>bufSize</I>,
 <B>long</B><I> flags</I>, <B>bool</B><I> save</I>)<P>
Under Windows, pops up a file selector with a list of filters corresponding to document templates.
The wxDocTemplate corresponding to the selected file's extension is returned.<P>
On other platforms, if there is more than one document template a choice list is popped up,
followed by a file selector.<P>
This function is used in wxDocManager::CreateDocument.<P>

<HR>
<A NAME="topic246"></A>
<H3>wxDocManager::SelectDocumentType</H3>
<P>
<B>wxDocTemplate *</B> <B>SelectDocumentType</B>(<B>wxDocTemplate **</B><I>templates</I>,
 <B>int</B><I> noTemplates</I>)<P>
Returns a document template by asking the user (if there is more than one template).
This function is used in wxDocManager::CreateDocument.<P>

<HR>
<A NAME="topic247"></A>
<H3>wxDocManager::SelectViewType</H3>
<P>
<B>wxDocTemplate *</B> <B>SelectViewType</B>(<B>wxDocTemplate **</B><I>templates</I>,
 <B>int</B><I> noTemplates</I>)<P>
Returns a document template by asking the user (if there is more than one template),
displaying a list of valid views. This function is used in wxDocManager::CreateView.
The dialog normally won't appear because the array of templates only contains
those relevant to the document in question, and often there will only be one such.<P>

<HR>
<A NAME="topic248"></A>
<H3>wxDocManager::SetMaxDocsOpen</H3>
<P>
<B>void</B> <B>SetMaxDocsOpen</B>(<B>int</B><I> n</I>)<P>
Sets the maximum number of documents that can be open at a time. By default, this
is 10,000. If you set it to 1, existing documents will be saved and deleted
when the user tries to open or create a new one (similar to the behaviour
of Windows Write, for example). Allowing multiple documents gives behaviour
more akin to MS Word and other Multiple Document Interface applications.<P>
<P>

</BODY></HTML>