]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/docmanag.tex
Added periods
[wxWidgets.git] / docs / latex / wx / docmanag.tex
CommitLineData
d8245a81
WS
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
a660d684
KB
12\section{\class{wxDocManager}}\label{wxdocmanager}
13
fc2171bd 14The wxDocManager class is part of the document/view framework supported by wxWidgets,
a660d684
KB
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
954b8ae6
JS
23\wxheading{Include files}
24
25<wx/docview.h>
26
a7af285d
VZ
27\wxheading{Library}
28
29\helpref{wxCore}{librarieslist}
30
a660d684
KB
31\wxheading{See also}
32
33\helpref{wxDocManager overview}{wxdocmanageroverview}, \helpref{wxDocument}{wxdocument},\rtfsp
7f555861 34\helpref{wxView}{wxview}, \helpref{wxDocTemplate}{wxdoctemplate}, \helpref{wxFileHistory}{wxfilehistory}
a660d684
KB
35
36\latexignore{\rtfignore{\wxheading{Members}}}
37
d8245a81 38
b236c10f 39\membersection{wxDocManager::m\_currentView}\label{wxdocmanagermcreateview}
a660d684
KB
40
41\member{wxView*}{m\_currentView}
42
43The currently active view.
44
d8245a81 45
b236c10f 46\membersection{wxDocManager::m\_defaultDocumentNameCounter}\label{wxdocmanagermdefaultdocumentnamecounter}
a660d684
KB
47
48\member{int}{m\_defaultDocumentNameCounter}
49
50Stores the integer to be used for the next default document name.
51
d8245a81 52
b236c10f 53\membersection{wxDocManager::m\_fileHistory}\label{wxdocmanagermfilehistory}
a660d684
KB
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
d8245a81 60
b236c10f 61\membersection{wxDocManager::m\_maxDocsOpen}\label{wxdocmanagermmaxdocsopen}
a660d684
KB
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
d8245a81 68
b236c10f 69\membersection{wxDocManager::m\_docs}\label{wxdocmanagermdocs}
a660d684
KB
70
71\member{wxList}{m\_docs}
72
73A list of all documents.
74
d8245a81 75
b236c10f 76\membersection{wxDocManager::m\_flags}\label{wxdocmanagermflags}
a660d684
KB
77
78\member{long}{m\_flags}
79
80Stores the flags passed to the constructor.
81
d8245a81 82
b236c10f 83\membersection{wxDocManager::m\_lastDirectory}\label{wxdocmanagermlastdirectory}
ac0ac824
JS
84
85The directory last selected by the user when opening a file.
86
87\member{wxFileHistory*}{m\_fileHistory}
88
d8245a81 89
b236c10f 90\membersection{wxDocManager::m\_templates}\label{wxdocmanagermtemplates}
a660d684 91
43e8916f 92\member{wxList}{m\_templates}
a660d684
KB
93
94A list of all document templates.
95
d8245a81 96
b236c10f 97\membersection{wxDocManager::wxDocManager}\label{wxdocmanagerctor}
a660d684 98
0e10e38d 99\func{}{wxDocManager}{\param{long}{ flags = wxDEFAULT\_DOCMAN\_FLAGS}, \param{bool}{ initialize = true}}
a660d684
KB
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
cc81d32f 106If {\it initialize} is true, the \helpref{Initialize}{wxdocmanagerinitialize} function will be called
a660d684 107to create a default history list object. If you derive from wxDocManager, you may wish to call the
cc81d32f 108base constructor with false, and then call Initialize in your own constructor, to allow
a660d684
KB
109your own Initialize or OnCreateFileHistory functions to be called.
110
d8245a81 111
b236c10f 112\membersection{wxDocManager::\destruct{wxDocManager}}\label{wxdocmanagerdtor}
a660d684
KB
113
114\func{void}{\destruct{wxDocManager}}{\void}
115
116Destructor.
117
d8245a81 118
b236c10f 119\membersection{wxDocManager::ActivateView}\label{wxdocmanageractivateview}
a660d684 120
f6e9a818 121\func{void}{ActivateView}{\param{wxView* }{doc}, \param{bool}{ activate = true}}
a660d684
KB
122
123Sets the current view.
124
d8245a81 125
b236c10f 126\membersection{wxDocManager::AddDocument}\label{wxdocmanageradddocument}
a660d684
KB
127
128\func{void}{AddDocument}{\param{wxDocument *}{doc}}
129
130Adds the document to the list of documents.
131
d8245a81 132
b236c10f 133\membersection{wxDocManager::AddFileToHistory}\label{wxdocmanageraddfiletohistory}
a660d684
KB
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
d8245a81 139
b236c10f 140\membersection{wxDocManager::AssociateTemplate}\label{wxdocmanagerassociatetemplate}
a660d684
KB
141
142\func{void}{AssociateTemplate}{\param{wxDocTemplate *}{temp}}
143
144Adds the template to the document manager's template list.
145
d8245a81 146
b236c10f 147\membersection{wxDocManager::CloseDocuments}\label{wxdocmanagerclosedocuments}
33a20136 148
cc81d32f 149\func{bool}{CloseDocuments}{\param{bool }{force = true}}
33a20136 150
2edb0bde 151Closes all currently opened documents.
33a20136 152
d8245a81 153
b236c10f 154\membersection{wxDocManager::CreateDocument}\label{wxdocmanagercreatedocument}
a660d684
KB
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
d8245a81 175
b236c10f 176\membersection{wxDocManager::CreateView}\label{wxdocmanagercreateview}
a660d684
KB
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
d8245a81 184
b236c10f 185\membersection{wxDocManager::DisassociateTemplate}\label{wxdocmanagerdisassociatetemplate}
a660d684
KB
186
187\func{void}{DisassociateTemplate}{\param{wxDocTemplate *}{temp}}
188
189Removes the template from the list of templates.
190
d8245a81 191
7f555861 192\membersection{wxDocManager::FileHistoryAddFilesToMenu}\label{wxdocmanagerfilehistoryaddfilestomenu}
a660d684 193
7f555861 194\func{void}{FileHistoryAddFilesToMenu}{\void}
a660d684 195
7f555861
JS
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
d8245a81 202
7f555861
JS
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}
a660d684 210
7f555861 211\helpref{wxConfig}{wxconfigbase}
a660d684 212
d8245a81 213
7f555861 214\membersection{wxDocManager::FileHistoryRemoveMenu}\label{wxdocmanagerfilehistoryremovemenu}
a660d684 215
7f555861
JS
216\func{void}{FileHistoryRemoveMenu}{\param{wxMenu*}{ menu}}
217
218Removes the given menu from the list of menus managed by the file history object.
219
d8245a81 220
7f555861
JS
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
a660d684
KB
226explicitly by the application.
227
7f555861
JS
228\wxheading{See also}
229
230\helpref{wxConfig}{wxconfigbase}
a660d684 231
d8245a81 232
7f555861
JS
233\membersection{wxDocManager::FileHistoryUseMenu}\label{wxdocmanagerfilehistoryusemenu}
234
235\func{void}{FileHistoryUseMenu}{\param{wxMenu*}{ menu}}
a660d684
KB
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
7f555861
JS
241Note that you can add multiple menus using this function, to be managed by the
242file history object.
243
d8245a81 244
b236c10f 245\membersection{wxDocManager::FindTemplateForPath}\label{wxdocmanagerfindtemplateforpath}
a660d684
KB
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
d8245a81 252
b236c10f 253\membersection{wxDocManager::GetCurrentDocument}\label{wxdocmanagergetcurrentdocument}
a660d684
KB
254
255\func{wxDocument *}{GetCurrentDocument}{\void}
256
257Returns the document associated with the currently active view (if any).
258
d8245a81 259
b236c10f 260\membersection{wxDocManager::GetCurrentView}\label{wxdocmanagergetcurrentview}
a660d684
KB
261
262\func{wxView *}{GetCurrentView}{\void}
263
264Returns the currently active view
265
d8245a81 266
b236c10f 267\membersection{wxDocManager::GetDocuments}\label{wxdocmanagergetdocuments}
a660d684
KB
268
269\func{wxList\&}{GetDocuments}{\void}
270
271Returns a reference to the list of documents.
272
d8245a81 273
b236c10f 274\membersection{wxDocManager::GetFileHistory}\label{wxdocmanagergetfilehistory}
a660d684
KB
275
276\func{wxFileHistory *}{GetFileHistory}{\void}
277
278Returns a pointer to file history.
279
d8245a81 280
ac0ac824
JS
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
d8245a81 287
b236c10f 288\membersection{wxDocManager::GetMaxDocsOpen}\label{wxdocmanagergetmaxdocsopen}
a660d684
KB
289
290\func{int}{GetMaxDocsOpen}{\void}
291
292Returns the number of documents that can be open simultaneously.
293
d8245a81 294
b236c10f 295\membersection{wxDocManager::GetHistoryFilesCount}\label{wxdocmanagergethistoryfilescount}
a660d684 296
7af6b69e 297\func{size\_t}{GetHistoryFilesCount}{\void}
a660d684
KB
298
299Returns the number of files currently stored in the file history.
300
d8245a81
WS
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
a660d684
KB
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
cc81d32f 319vetoed by passing false to the second argument, allowing the derived class's
a660d684
KB
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
d8245a81 326
724b119a 327\membersection{wxDocManager::MakeNewDocumentName}\label{wxdocmanagermakenewdocumentname}
a660d684 328
724b119a 329\func{wxString}{MakeNewDocumentName}{\void}
a660d684 330
724b119a
VZ
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.
fa7161e0 335
d8245a81 336
b236c10f 337\membersection{wxDocManager::OnCreateFileHistory}\label{wxdocmanageroncreatefilehistory}
a660d684
KB
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
d8245a81 344
b236c10f 345\membersection{wxDocManager::OnFileClose}\label{wxdocmanageronfileclose}
a660d684 346
3980000c 347\func{void}{OnFileClose}{\param{wxCommandEvent\& }{event}}
a660d684
KB
348
349Closes and deletes the currently active document.
350
d8245a81 351
b236c10f 352\membersection{wxDocManager::OnFileCloseAll}\label{wxdocmanageronfilecloseall}
33a20136 353
3980000c 354\func{void}{OnFileCloseAll}{\param{wxCommandEvent\& }{event}}
33a20136
VZ
355
356Closes and deletes all the currently opened documents.
357
d8245a81 358
b236c10f 359\membersection{wxDocManager::OnFileNew}\label{wxdocmanageronfilenew}
a660d684 360
3980000c 361\func{void}{OnFileNew}{\param{wxCommandEvent\& }{event}}
a660d684
KB
362
363Creates a document from a list of templates (if more than one template).
364
d8245a81 365
b236c10f 366\membersection{wxDocManager::OnFileOpen}\label{wxdocmanageronfileopen}
a660d684 367
3980000c 368\func{void}{OnFileOpen}{\param{wxCommandEvent\& }{event}}
a660d684
KB
369
370Creates a new document and reads in the selected file.
371
d8245a81 372
3980000c
RR
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
d8245a81 379
b236c10f 380\membersection{wxDocManager::OnFileSave}\label{wxdocmanageronfilesave}
a660d684 381
3980000c 382\func{void}{OnFileSave}{\param{wxCommandEvent\& }{event}}
a660d684
KB
383
384Saves the current document by calling wxDocument::Save for the current document.
385
d8245a81 386
b236c10f 387\membersection{wxDocManager::OnFileSaveAs}\label{wxdocmanageronfilesaveas}
a660d684 388
3980000c 389\func{void}{OnFileSaveAs}{\param{wxCommandEvent\& }{event}}
a660d684
KB
390
391Calls wxDocument::SaveAs for the current document.
392
d8245a81 393
b236c10f 394\membersection{wxDocManager::RemoveDocument}\label{wxdocmanagerremovedocument}
a660d684
KB
395
396\func{void}{RemoveDocument}{\param{wxDocument *}{doc}}
397
398Removes the document from the list of documents.
399
d8245a81 400
b236c10f 401\membersection{wxDocManager::SelectDocumentPath}\label{wxdocmanagerselectdocumentpath}
a660d684
KB
402
403\func{wxDocTemplate *}{SelectDocumentPath}{\param{wxDocTemplate **}{templates},
f6e9a818 404 \param{int}{ noTemplates}, \param{wxString\& }{path},
a660d684
KB
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
762e1997
MB
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
d8245a81 421
b236c10f 422\membersection{wxDocManager::SelectDocumentType}\label{wxdocmanagerselectdocumenttype}
a660d684
KB
423
424\func{wxDocTemplate *}{SelectDocumentType}{\param{wxDocTemplate **}{templates},
cc81d32f 425 \param{int}{ noTemplates}, \param{bool}{ sort=false}}
a660d684
KB
426
427Returns a document template by asking the user (if there is more than one template).
428This function is used in wxDocManager::CreateDocument.
429
52b9ca21
GT
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.
cc81d32f 437Default is false.}
52b9ca21 438
762e1997
MB
439\perlnote{In wxPerl {\tt templates} is a reference to a list of templates.}
440
d8245a81 441
b236c10f 442\membersection{wxDocManager::SelectViewType}\label{wxdocmanagerselectviewtype}
a660d684
KB
443
444\func{wxDocTemplate *}{SelectViewType}{\param{wxDocTemplate **}{templates},
cc81d32f 445 \param{int}{ noTemplates}, \param{bool}{ sort=false}}
a660d684
KB
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.
52b9ca21 449The dialog normally will not appear because the array of templates only contains
a660d684
KB
450those relevant to the document in question, and often there will only be one such.
451
52b9ca21
GT
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.
cc81d32f 459Default is false.}
52b9ca21 460
762e1997
MB
461\perlnote{In wxPerl {\tt templates} is a reference to a list of templates.}
462
d8245a81 463
ac0ac824
JS
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
d8245a81 470
b236c10f 471\membersection{wxDocManager::SetMaxDocsOpen}\label{wxdocmanagersetmaxdocsopen}
a660d684
KB
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