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