]> git.saurik.com Git - wxWidgets.git/blame_incremental - docs/latex/wx/docmanag.tex
Applied patch [ 1747059 ] wxAUIDefaultTabArt wxAUI_NB_BOTTOM
[wxWidgets.git] / docs / latex / wx / docmanag.tex
... / ...
CommitLineData
1%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
2%% Name: docmanag.tex
3%% Purpose: wxDocManager documentation
4%% Author: wxWidgets Team
5%% Modified by:
6%% Created:
7%% RCS-ID: $Id$
8%% Copyright: (c) wxWidgets Team
9%% License: wxWindows license
10%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
11
12\section{\class{wxDocManager}}\label{wxdocmanager}
13
14The wxDocManager class is part of the document/view framework supported by wxWidgets,
15and cooperates with the \helpref{wxView}{wxview}, \helpref{wxDocument}{wxdocument}\rtfsp
16and \helpref{wxDocTemplate}{wxdoctemplate} classes.
17
18\wxheading{Derived from}
19
20\helpref{wxEvtHandler}{wxevthandler}\\
21\helpref{wxObject}{wxobject}
22
23\wxheading{Include files}
24
25<wx/docview.h>
26
27\wxheading{Library}
28
29\helpref{wxCore}{librarieslist}
30
31\wxheading{See also}
32
33\helpref{wxDocManager overview}{wxdocmanageroverview}, \helpref{wxDocument}{wxdocument},\rtfsp
34\helpref{wxView}{wxview}, \helpref{wxDocTemplate}{wxdoctemplate}, \helpref{wxFileHistory}{wxfilehistory}
35
36\latexignore{\rtfignore{\wxheading{Members}}}
37
38
39\membersection{wxDocManager::m\_currentView}\label{wxdocmanagermcreateview}
40
41\member{wxView*}{m\_currentView}
42
43The currently active view.
44
45
46\membersection{wxDocManager::m\_defaultDocumentNameCounter}\label{wxdocmanagermdefaultdocumentnamecounter}
47
48\member{int}{m\_defaultDocumentNameCounter}
49
50Stores the integer to be used for the next default document name.
51
52
53\membersection{wxDocManager::m\_fileHistory}\label{wxdocmanagermfilehistory}
54
55\member{wxFileHistory*}{m\_fileHistory}
56
57A pointer to an instance of \helpref{wxFileHistory}{wxfilehistory},
58which manages the history of recently-visited files on the File menu.
59
60
61\membersection{wxDocManager::m\_maxDocsOpen}\label{wxdocmanagermmaxdocsopen}
62
63\member{int}{m\_maxDocsOpen}
64
65Stores the maximum number of documents that can be opened before
66existing documents are closed. By default, this is 10,000.
67
68
69\membersection{wxDocManager::m\_docs}\label{wxdocmanagermdocs}
70
71\member{wxList}{m\_docs}
72
73A list of all documents.
74
75
76\membersection{wxDocManager::m\_flags}\label{wxdocmanagermflags}
77
78\member{long}{m\_flags}
79
80Stores the flags passed to the constructor.
81
82
83\membersection{wxDocManager::m\_lastDirectory}\label{wxdocmanagermlastdirectory}
84
85The directory last selected by the user when opening a file.
86
87\member{wxFileHistory*}{m\_fileHistory}
88
89
90\membersection{wxDocManager::m\_templates}\label{wxdocmanagermtemplates}
91
92\member{wxList}{m\_templates}
93
94A list of all document templates.
95
96
97\membersection{wxDocManager::wxDocManager}\label{wxdocmanagerctor}
98
99\func{}{wxDocManager}{\param{long}{ flags = wxDEFAULT\_DOCMAN\_FLAGS}, \param{bool}{ initialize = true}}
100
101Constructor. Create a document manager instance dynamically near the start of your application
102before doing any document or view operations.
103
104{\it flags} is currently unused.
105
106If {\it initialize} is true, the \helpref{Initialize}{wxdocmanagerinitialize} function will be called
107to create a default history list object. If you derive from wxDocManager, you may wish to call the
108base constructor with false, and then call Initialize in your own constructor, to allow
109your own Initialize or OnCreateFileHistory functions to be called.
110
111
112\membersection{wxDocManager::\destruct{wxDocManager}}\label{wxdocmanagerdtor}
113
114\func{void}{\destruct{wxDocManager}}{\void}
115
116Destructor.
117
118
119\membersection{wxDocManager::ActivateView}\label{wxdocmanageractivateview}
120
121\func{void}{ActivateView}{\param{wxView* }{doc}, \param{bool}{ activate = true}}
122
123Sets the current view.
124
125
126\membersection{wxDocManager::AddDocument}\label{wxdocmanageradddocument}
127
128\func{void}{AddDocument}{\param{wxDocument *}{doc}}
129
130Adds the document to the list of documents.
131
132
133\membersection{wxDocManager::AddFileToHistory}\label{wxdocmanageraddfiletohistory}
134
135\func{void}{AddFileToHistory}{\param{const wxString\& }{filename}}
136
137Adds a file to the file history list, if we have a pointer to an appropriate file menu.
138
139
140\membersection{wxDocManager::AssociateTemplate}\label{wxdocmanagerassociatetemplate}
141
142\func{void}{AssociateTemplate}{\param{wxDocTemplate *}{temp}}
143
144Adds the template to the document manager's template list.
145
146
147\membersection{wxDocManager::CloseDocuments}\label{wxdocmanagerclosedocuments}
148
149\func{bool}{CloseDocuments}{\param{bool }{force = true}}
150
151Closes all currently opened documents.
152
153
154\membersection{wxDocManager::CreateDocument}\label{wxdocmanagercreatedocument}
155
156\func{wxDocument*}{CreateDocument}{\param{const wxString\& }{path}, \param{long}{ flags}}
157
158Creates a new document in a manner determined by the {\it flags} parameter, which can be:
159
160\begin{itemize}\itemsep=0pt
161\item wxDOC\_NEW Creates a fresh document.
162\item wxDOC\_SILENT Silently loads the given document file.
163\end{itemize}
164
165If wxDOC\_NEW is present, a new document will be created and returned, possibly after
166asking the user for a template to use if there is more than one document template.
167If wxDOC\_SILENT is present, a new document will be created and the given file loaded
168into it. If neither of these flags is present, the user will be presented with
169a file selector for the file to load, and the template to use will be determined by the
170extension (Windows) or by popping up a template choice list (other platforms).
171
172If the maximum number of documents has been reached, this function
173will delete the oldest currently loaded document before creating a new one.
174
175
176\membersection{wxDocManager::CreateView}\label{wxdocmanagercreateview}
177
178\func{wxView*}{CreateView}{\param{wxDocument*}{doc}, \param{long}{ flags}}
179
180Creates a new view for the given document. If more than one view is allowed for the
181document (by virtue of multiple templates mentioning the same document type), a choice
182of view is presented to the user.
183
184
185\membersection{wxDocManager::DisassociateTemplate}\label{wxdocmanagerdisassociatetemplate}
186
187\func{void}{DisassociateTemplate}{\param{wxDocTemplate *}{temp}}
188
189Removes the template from the list of templates.
190
191
192\membersection{wxDocManager::FileHistoryAddFilesToMenu}\label{wxdocmanagerfilehistoryaddfilestomenu}
193
194\func{void}{FileHistoryAddFilesToMenu}{\void}
195
196Appends the files in the history list, to all menus managed by the file history object.
197
198\func{void}{FileHistoryAddFilesToMenu}{\param{wxMenu*}{ menu}}
199
200Appends the files in the history list, to the given menu only.
201
202
203\membersection{wxDocManager::FileHistoryLoad}\label{wxdocmanagerfilehistoryload}
204
205\func{void}{FileHistoryLoad}{\param{wxConfigBase\& }{config}}
206
207Loads the file history from a config object.
208
209\wxheading{See also}
210
211\helpref{wxConfig}{wxconfigbase}
212
213
214\membersection{wxDocManager::FileHistoryRemoveMenu}\label{wxdocmanagerfilehistoryremovemenu}
215
216\func{void}{FileHistoryRemoveMenu}{\param{wxMenu*}{ menu}}
217
218Removes the given menu from the list of menus managed by the file history object.
219
220
221\membersection{wxDocManager::FileHistorySave}\label{wxdocmanagerfilehistorysave}
222
223\func{void}{FileHistorySave}{\param{wxConfigBase\& }{resourceFile}}
224
225Saves the file history into a config object. This must be called
226explicitly by the application.
227
228\wxheading{See also}
229
230\helpref{wxConfig}{wxconfigbase}
231
232
233\membersection{wxDocManager::FileHistoryUseMenu}\label{wxdocmanagerfilehistoryusemenu}
234
235\func{void}{FileHistoryUseMenu}{\param{wxMenu*}{ menu}}
236
237Use this menu for appending recently-visited document filenames, for convenient
238access. Calling this function with a valid menu pointer enables the history
239list functionality.
240
241Note that you can add multiple menus using this function, to be managed by the
242file history object.
243
244
245\membersection{wxDocManager::FindTemplateForPath}\label{wxdocmanagerfindtemplateforpath}
246
247\func{wxDocTemplate *}{FindTemplateForPath}{\param{const wxString\& }{path}}
248
249Given a path, try to find template that matches the extension. This is only
250an approximate method of finding a template for creating a document.
251
252
253\membersection{wxDocManager::GetCurrentDocument}\label{wxdocmanagergetcurrentdocument}
254
255\func{wxDocument *}{GetCurrentDocument}{\void}
256
257Returns the document associated with the currently active view (if any).
258
259
260\membersection{wxDocManager::GetCurrentView}\label{wxdocmanagergetcurrentview}
261
262\func{wxView *}{GetCurrentView}{\void}
263
264Returns the currently active view
265
266
267\membersection{wxDocManager::GetDocuments}\label{wxdocmanagergetdocuments}
268
269\func{wxList\&}{GetDocuments}{\void}
270
271Returns a reference to the list of documents.
272
273
274\membersection{wxDocManager::GetFileHistory}\label{wxdocmanagergetfilehistory}
275
276\func{wxFileHistory *}{GetFileHistory}{\void}
277
278Returns a pointer to file history.
279
280
281\membersection{wxDocManager::GetLastDirectory}\label{wxdocmanagergetlastdirectory}
282
283\constfunc{wxString}{GetLastDirectory}{\void}
284
285Returns the directory last selected by the user when opening a file. Initially empty.
286
287
288\membersection{wxDocManager::GetMaxDocsOpen}\label{wxdocmanagergetmaxdocsopen}
289
290\func{int}{GetMaxDocsOpen}{\void}
291
292Returns the number of documents that can be open simultaneously.
293
294
295\membersection{wxDocManager::GetHistoryFilesCount}\label{wxdocmanagergethistoryfilescount}
296
297\func{size\_t}{GetHistoryFilesCount}{\void}
298
299Returns the number of files currently stored in the file history.
300
301
302\membersection{wxDocManager::GetTemplates}\label{wxdocmanagergettemplates}
303
304\func{wxList\&}{GetTemplates}{\void}
305
306Returns a reference to the list of associated templates.
307
308
309\membersection{wxDocManager::Initialize}\label{wxdocmanagerinitialize}
310
311\func{bool}{Initialize}{\void}
312
313Initializes data; currently just calls OnCreateFileHistory. Some data cannot
314always be initialized in the constructor because the programmer must be given
315the opportunity to override functionality. If OnCreateFileHistory was called
316from the constructor, an overridden virtual OnCreateFileHistory would not be
317called due to C++'s `interesting' constructor semantics. In fact Initialize
318\rtfsp{\it is} called from the wxDocManager constructor, but this can be
319vetoed by passing false to the second argument, allowing the derived class's
320constructor to call Initialize, possibly calling a different OnCreateFileHistory
321from the default.
322
323The bottom line: if you're not deriving from Initialize, forget it and
324construct wxDocManager with no arguments.
325
326
327\membersection{wxDocManager::MakeNewDocumentName}\label{wxdocmanagermakenewdocumentname}
328
329\func{wxString}{MakeNewDocumentName}{\void}
330
331Return a string containing a suitable default name for a new document. By
332default this is implemented by appending an integer counter to the string
333{\bf unnamed} but can be overridden in the derived classes to do something more
334appropriate.
335
336
337\membersection{wxDocManager::OnCreateFileHistory}\label{wxdocmanageroncreatefilehistory}
338
339\func{wxFileHistory *}{OnCreateFileHistory}{\void}
340
341A hook to allow a derived class to create a different type of file history. Called
342from \helpref{Initialize}{wxdocmanagerinitialize}.
343
344
345\membersection{wxDocManager::OnFileClose}\label{wxdocmanageronfileclose}
346
347\func{void}{OnFileClose}{\param{wxCommandEvent\& }{event}}
348
349Closes and deletes the currently active document.
350
351
352\membersection{wxDocManager::OnFileCloseAll}\label{wxdocmanageronfilecloseall}
353
354\func{void}{OnFileCloseAll}{\param{wxCommandEvent\& }{event}}
355
356Closes and deletes all the currently opened documents.
357
358
359\membersection{wxDocManager::OnFileNew}\label{wxdocmanageronfilenew}
360
361\func{void}{OnFileNew}{\param{wxCommandEvent\& }{event}}
362
363Creates a document from a list of templates (if more than one template).
364
365
366\membersection{wxDocManager::OnFileOpen}\label{wxdocmanageronfileopen}
367
368\func{void}{OnFileOpen}{\param{wxCommandEvent\& }{event}}
369
370Creates a new document and reads in the selected file.
371
372
373\membersection{wxDocManager::OnFileRevert}\label{wxdocmanageronfilerevert}
374
375\func{void}{OnFileRevert}{\param{wxCommandEvent\& }{event}}
376
377Reverts the current document by calling wxDocument::Revert for the current document.
378
379
380\membersection{wxDocManager::OnFileSave}\label{wxdocmanageronfilesave}
381
382\func{void}{OnFileSave}{\param{wxCommandEvent\& }{event}}
383
384Saves the current document by calling wxDocument::Save for the current document.
385
386
387\membersection{wxDocManager::OnFileSaveAs}\label{wxdocmanageronfilesaveas}
388
389\func{void}{OnFileSaveAs}{\param{wxCommandEvent\& }{event}}
390
391Calls wxDocument::SaveAs for the current document.
392
393
394\membersection{wxDocManager::RemoveDocument}\label{wxdocmanagerremovedocument}
395
396\func{void}{RemoveDocument}{\param{wxDocument *}{doc}}
397
398Removes the document from the list of documents.
399
400
401\membersection{wxDocManager::SelectDocumentPath}\label{wxdocmanagerselectdocumentpath}
402
403\func{wxDocTemplate *}{SelectDocumentPath}{\param{wxDocTemplate **}{templates},
404 \param{int}{ noTemplates}, \param{wxString\& }{path},
405 \param{long}{ flags}, \param{bool}{ save}}
406
407Under Windows, pops up a file selector with a list of filters corresponding to document templates.
408The wxDocTemplate corresponding to the selected file's extension is returned.
409
410On other platforms, if there is more than one document template a choice list is popped up,
411followed by a file selector.
412
413This function is used in wxDocManager::CreateDocument.
414
415\perlnote{In wxPerl {\tt templates} is a reference to a list of templates.
416If you override this method in your document manager it must return
417two values, eg:\par
418 (doctemplate, path) = My::DocManager->SelectDocumentPath( ... );
419}
420
421
422\membersection{wxDocManager::SelectDocumentType}\label{wxdocmanagerselectdocumenttype}
423
424\func{wxDocTemplate *}{SelectDocumentType}{\param{wxDocTemplate **}{templates},
425 \param{int}{ noTemplates}, \param{bool}{ sort=false}}
426
427Returns a document template by asking the user (if there is more than one template).
428This function is used in wxDocManager::CreateDocument.
429
430\wxheading{Parameters}
431
432\docparam{templates}{Pointer to an array of templates from which to choose a desired template.}
433\docparam{noTemplates}{Number of templates being pointed to by the {\it templates} pointer.}
434\docparam{sort}{If more than one template is passed in in {\it templates},
435then this parameter indicates whether the list of templates that the user
436will have to choose from is sorted or not when shown the choice box dialog.
437Default is false.}
438
439\perlnote{In wxPerl {\tt templates} is a reference to a list of templates.}
440
441
442\membersection{wxDocManager::SelectViewType}\label{wxdocmanagerselectviewtype}
443
444\func{wxDocTemplate *}{SelectViewType}{\param{wxDocTemplate **}{templates},
445 \param{int}{ noTemplates}, \param{bool}{ sort=false}}
446
447Returns a document template by asking the user (if there is more than one template),
448displaying a list of valid views. This function is used in wxDocManager::CreateView.
449The dialog normally will not appear because the array of templates only contains
450those relevant to the document in question, and often there will only be one such.
451
452\wxheading{Parameters}
453
454\docparam{templates}{Pointer to an array of templates from which to choose a desired template.}
455\docparam{noTemplates}{Number of templates being pointed to by the {\it templates} pointer.}
456\docparam{sort}{If more than one template is passed in in {\it templates},
457then this parameter indicates whether the list of templates that the user
458will have to choose from is sorted or not when shown the choice box dialog.
459Default is false.}
460
461\perlnote{In wxPerl {\tt templates} is a reference to a list of templates.}
462
463
464\membersection{wxDocManager::SetLastDirectory}\label{wxdocmanagersetlastdirectory}
465
466\func{void}{SetLastDirectory}{\param{const wxString\&}{ dir}}
467
468Sets the directory to be displayed to the user when opening a file. Initially this is empty.
469
470
471\membersection{wxDocManager::SetMaxDocsOpen}\label{wxdocmanagersetmaxdocsopen}
472
473\func{void}{SetMaxDocsOpen}{\param{int}{ n}}
474
475Sets the maximum number of documents that can be open at a time. By default, this
476is 10,000. If you set it to 1, existing documents will be saved and deleted
477when the user tries to open or create a new one (similar to the behaviour
478of Windows Write, for example). Allowing multiple documents gives behaviour
479more akin to MS Word and other Multiple Document Interface applications.
480