]> git.saurik.com Git - wxWidgets.git/blame - docs/latex/wx/docmanag.tex
some minor fixes to the docs (bugs 13271[56])
[wxWidgets.git] / docs / latex / wx / docmanag.tex
CommitLineData
a660d684
KB
1\section{\class{wxDocManager}}\label{wxdocmanager}
2
3The wxDocManager class is part of the document/view framework supported by wxWindows,
4and cooperates with the \helpref{wxView}{wxview}, \helpref{wxDocument}{wxdocument}\rtfsp
5and \helpref{wxDocTemplate}{wxdoctemplate} classes.
6
7\wxheading{Derived from}
8
9\helpref{wxEvtHandler}{wxevthandler}\\
10\helpref{wxObject}{wxobject}
11
954b8ae6
JS
12\wxheading{Include files}
13
14<wx/docview.h>
15
a660d684
KB
16\wxheading{See also}
17
18\helpref{wxDocManager overview}{wxdocmanageroverview}, \helpref{wxDocument}{wxdocument},\rtfsp
7f555861 19\helpref{wxView}{wxview}, \helpref{wxDocTemplate}{wxdoctemplate}, \helpref{wxFileHistory}{wxfilehistory}
a660d684
KB
20
21\latexignore{\rtfignore{\wxheading{Members}}}
22
23\membersection{wxDocManager::m\_currentView}
24
25\member{wxView*}{m\_currentView}
26
27The currently active view.
28
29\membersection{wxDocManager::m\_defaultDocumentNameCounter}
30
31\member{int}{m\_defaultDocumentNameCounter}
32
33Stores the integer to be used for the next default document name.
34
35\membersection{wxDocManager::m\_fileHistory}
36
37\member{wxFileHistory*}{m\_fileHistory}
38
39A pointer to an instance of \helpref{wxFileHistory}{wxfilehistory},
40which manages the history of recently-visited files on the File menu.
41
42\membersection{wxDocManager::m\_maxDocsOpen}
43
44\member{int}{m\_maxDocsOpen}
45
46Stores the maximum number of documents that can be opened before
47existing documents are closed. By default, this is 10,000.
48
49\membersection{wxDocManager::m\_docs}
50
51\member{wxList}{m\_docs}
52
53A list of all documents.
54
55\membersection{wxDocManager::m\_flags}
56
57\member{long}{m\_flags}
58
59Stores the flags passed to the constructor.
60
ac0ac824
JS
61\membersection{wxDocManager::m\_lastDirectory}
62
63The directory last selected by the user when opening a file.
64
65\member{wxFileHistory*}{m\_fileHistory}
66
a660d684
KB
67\membersection{wxDocManager::m\_templates}
68
69\member{wxList}{mnTemplates}
70
71A list of all document templates.
72
73\membersection{wxDocManager::wxDocManager}
74
75\func{void}{wxDocManager}{\param{long}{ flags = wxDEFAULT\_DOCMAN\_FLAGS}, \param{bool}{ initialize = TRUE}}
76
77Constructor. Create a document manager instance dynamically near the start of your application
78before doing any document or view operations.
79
80{\it flags} is currently unused.
81
82If {\it initialize} is TRUE, the \helpref{Initialize}{wxdocmanagerinitialize} function will be called
83to create a default history list object. If you derive from wxDocManager, you may wish to call the
84base constructor with FALSE, and then call Initialize in your own constructor, to allow
85your own Initialize or OnCreateFileHistory functions to be called.
86
87\membersection{wxDocManager::\destruct{wxDocManager}}
88
89\func{void}{\destruct{wxDocManager}}{\void}
90
91Destructor.
92
93\membersection{wxDocManager::ActivateView}
94
95\func{void}{ActivateView}{\param{wxView* }{doc}, \param{bool}{ activate}, \param{bool}{ deleting}}
96
97Sets the current view.
98
99\membersection{wxDocManager::AddDocument}
100
101\func{void}{AddDocument}{\param{wxDocument *}{doc}}
102
103Adds the document to the list of documents.
104
105\membersection{wxDocManager::AddFileToHistory}
106
107\func{void}{AddFileToHistory}{\param{const wxString\& }{filename}}
108
109Adds a file to the file history list, if we have a pointer to an appropriate file menu.
110
111\membersection{wxDocManager::AssociateTemplate}
112
113\func{void}{AssociateTemplate}{\param{wxDocTemplate *}{temp}}
114
115Adds the template to the document manager's template list.
116
117\membersection{wxDocManager::CreateDocument}
118
119\func{wxDocument*}{CreateDocument}{\param{const wxString\& }{path}, \param{long}{ flags}}
120
121Creates a new document in a manner determined by the {\it flags} parameter, which can be:
122
123\begin{itemize}\itemsep=0pt
124\item wxDOC\_NEW Creates a fresh document.
125\item wxDOC\_SILENT Silently loads the given document file.
126\end{itemize}
127
128If wxDOC\_NEW is present, a new document will be created and returned, possibly after
129asking the user for a template to use if there is more than one document template.
130If wxDOC\_SILENT is present, a new document will be created and the given file loaded
131into it. If neither of these flags is present, the user will be presented with
132a file selector for the file to load, and the template to use will be determined by the
133extension (Windows) or by popping up a template choice list (other platforms).
134
135If the maximum number of documents has been reached, this function
136will delete the oldest currently loaded document before creating a new one.
137
138\membersection{wxDocManager::CreateView}
139
140\func{wxView*}{CreateView}{\param{wxDocument*}{doc}, \param{long}{ flags}}
141
142Creates a new view for the given document. If more than one view is allowed for the
143document (by virtue of multiple templates mentioning the same document type), a choice
144of view is presented to the user.
145
146\membersection{wxDocManager::DisassociateTemplate}
147
148\func{void}{DisassociateTemplate}{\param{wxDocTemplate *}{temp}}
149
150Removes the template from the list of templates.
151
7f555861 152\membersection{wxDocManager::FileHistoryAddFilesToMenu}\label{wxdocmanagerfilehistoryaddfilestomenu}
a660d684 153
7f555861 154\func{void}{FileHistoryAddFilesToMenu}{\void}
a660d684 155
7f555861
JS
156Appends the files in the history list, to all menus managed by the file history object.
157
158\func{void}{FileHistoryAddFilesToMenu}{\param{wxMenu*}{ menu}}
159
160Appends the files in the history list, to the given menu only.
161
162\membersection{wxDocManager::FileHistoryLoad}\label{wxdocmanagerfilehistoryload}
163
164\func{void}{FileHistoryLoad}{\param{wxConfigBase\& }{config}}
165
166Loads the file history from a config object.
167
168\wxheading{See also}
a660d684 169
7f555861 170\helpref{wxConfig}{wxconfigbase}
a660d684 171
7f555861 172\membersection{wxDocManager::FileHistoryRemoveMenu}\label{wxdocmanagerfilehistoryremovemenu}
a660d684 173
7f555861
JS
174\func{void}{FileHistoryRemoveMenu}{\param{wxMenu*}{ menu}}
175
176Removes the given menu from the list of menus managed by the file history object.
177
178\membersection{wxDocManager::FileHistorySave}\label{wxdocmanagerfilehistorysave}
179
180\func{void}{FileHistorySave}{\param{wxConfigBase\& }{resourceFile}}
181
182Saves the file history into a config object. This must be called
a660d684
KB
183explicitly by the application.
184
7f555861
JS
185\wxheading{See also}
186
187\helpref{wxConfig}{wxconfigbase}
a660d684 188
7f555861
JS
189\membersection{wxDocManager::FileHistoryUseMenu}\label{wxdocmanagerfilehistoryusemenu}
190
191\func{void}{FileHistoryUseMenu}{\param{wxMenu*}{ menu}}
a660d684
KB
192
193Use this menu for appending recently-visited document filenames, for convenient
194access. Calling this function with a valid menu pointer enables the history
195list functionality.
196
7f555861
JS
197Note that you can add multiple menus using this function, to be managed by the
198file history object.
199
a660d684
KB
200\membersection{wxDocManager::FindTemplateForPath}
201
202\func{wxDocTemplate *}{FindTemplateForPath}{\param{const wxString\& }{path}}
203
204Given a path, try to find template that matches the extension. This is only
205an approximate method of finding a template for creating a document.
206
207\membersection{wxDocManager::GetCurrentDocument}
208
209\func{wxDocument *}{GetCurrentDocument}{\void}
210
211Returns the document associated with the currently active view (if any).
212
213\membersection{wxDocManager::GetCurrentView}
214
215\func{wxView *}{GetCurrentView}{\void}
216
217Returns the currently active view
218
219\membersection{wxDocManager::GetDocuments}
220
221\func{wxList\&}{GetDocuments}{\void}
222
223Returns a reference to the list of documents.
224
225\membersection{wxDocManager::GetFileHistory}
226
227\func{wxFileHistory *}{GetFileHistory}{\void}
228
229Returns a pointer to file history.
230
ac0ac824
JS
231\membersection{wxDocManager::GetLastDirectory}\label{wxdocmanagergetlastdirectory}
232
233\constfunc{wxString}{GetLastDirectory}{\void}
234
235Returns the directory last selected by the user when opening a file. Initially empty.
236
a660d684
KB
237\membersection{wxDocManager::GetMaxDocsOpen}
238
239\func{int}{GetMaxDocsOpen}{\void}
240
241Returns the number of documents that can be open simultaneously.
242
243\membersection{wxDocManager::GetNoHistoryFiles}
244
245\func{int}{GetNoHistoryFiles}{\void}
246
247Returns the number of files currently stored in the file history.
248
249\membersection{wxDocManager::Initialize}\label{wxdocmanagerinitialize}
250
251\func{bool}{Initialize}{\void}
252
253Initializes data; currently just calls OnCreateFileHistory. Some data cannot
254always be initialized in the constructor because the programmer must be given
255the opportunity to override functionality. If OnCreateFileHistory was called
256from the constructor, an overridden virtual OnCreateFileHistory would not be
257called due to C++'s `interesting' constructor semantics. In fact Initialize
258\rtfsp{\it is} called from the wxDocManager constructor, but this can be
259vetoed by passing FALSE to the second argument, allowing the derived class's
260constructor to call Initialize, possibly calling a different OnCreateFileHistory
261from the default.
262
263The bottom line: if you're not deriving from Initialize, forget it and
264construct wxDocManager with no arguments.
265
266\membersection{wxDocManager::MakeDefaultName}
267
268\func{bool}{MakeDefaultName}{\param{const wxString\& }{buf}}
269
270Copies a suitable default name into {\it buf}. This is implemented by
271appending an integer counter to the string {\bf unnamed} and incrementing
272the counter.
273
274\membersection{wxDocManager::OnCreateFileHistory}
275
276\func{wxFileHistory *}{OnCreateFileHistory}{\void}
277
278A hook to allow a derived class to create a different type of file history. Called
279from \helpref{Initialize}{wxdocmanagerinitialize}.
280
281\membersection{wxDocManager::OnFileClose}
282
283\func{void}{OnFileClose}{\void}
284
285Closes and deletes the currently active document.
286
287\membersection{wxDocManager::OnFileNew}
288
289\func{void}{OnFileNew}{\void}
290
291Creates a document from a list of templates (if more than one template).
292
293\membersection{wxDocManager::OnFileOpen}
294
295\func{void}{OnFileOpen}{\void}
296
297Creates a new document and reads in the selected file.
298
299\membersection{wxDocManager::OnFileSave}
300
301\func{void}{OnFileSave}{\void}
302
303Saves the current document by calling wxDocument::Save for the current document.
304
305\membersection{wxDocManager::OnFileSaveAs}
306
307\func{void}{OnFileSaveAs}{\void}
308
309Calls wxDocument::SaveAs for the current document.
310
311\membersection{wxDocManager::OnMenuCommand}
312
313\func{void}{OnMenuCommand}{\param{int}{ cmd}}
314
315Processes menu commands routed from child or parent frames. This deals
316with the following predefined menu item identifiers:
317
318\begin{itemize}\itemsep=0pt
319\item wxID\_OPEN Creates a new document and opens a file into it.
320\item wxID\_CLOSE Closes the current document.
321\item wxID\_NEW Creates a new document.
322\item wxID\_SAVE Saves the document.
323\item wxID\_SAVE\_AS Saves the document into a specified filename.
324\end{itemize}
325
326Unrecognized commands are routed to the currently active wxView's OnMenuCommand.
327
328\membersection{wxDocManager::RemoveDocument}
329
330\func{void}{RemoveDocument}{\param{wxDocument *}{doc}}
331
332Removes the document from the list of documents.
333
334\membersection{wxDocManager::SelectDocumentPath}
335
336\func{wxDocTemplate *}{SelectDocumentPath}{\param{wxDocTemplate **}{templates},
337 \param{int}{ noTemplates}, \param{const wxString\& }{path}, \param{const wxString\& }{bufSize},
338 \param{long}{ flags}, \param{bool}{ save}}
339
340Under Windows, pops up a file selector with a list of filters corresponding to document templates.
341The wxDocTemplate corresponding to the selected file's extension is returned.
342
343On other platforms, if there is more than one document template a choice list is popped up,
344followed by a file selector.
345
346This function is used in wxDocManager::CreateDocument.
347
348\membersection{wxDocManager::SelectDocumentType}
349
350\func{wxDocTemplate *}{SelectDocumentType}{\param{wxDocTemplate **}{templates},
52b9ca21 351 \param{int}{ noTemplates}, \param{bool}{ sort=FALSE}}
a660d684
KB
352
353Returns a document template by asking the user (if there is more than one template).
354This function is used in wxDocManager::CreateDocument.
355
52b9ca21
GT
356\wxheading{Parameters}
357
358\docparam{templates}{Pointer to an array of templates from which to choose a desired template.}
359\docparam{noTemplates}{Number of templates being pointed to by the {\it templates} pointer.}
360\docparam{sort}{If more than one template is passed in in {\it templates},
361then this parameter indicates whether the list of templates that the user
362will have to choose from is sorted or not when shown the choice box dialog.
363Default is FALSE.}
364
a660d684
KB
365\membersection{wxDocManager::SelectViewType}
366
367\func{wxDocTemplate *}{SelectViewType}{\param{wxDocTemplate **}{templates},
52b9ca21 368 \param{int}{ noTemplates}, \param{bool}{ sort=FALSE}}
a660d684
KB
369
370Returns a document template by asking the user (if there is more than one template),
371displaying a list of valid views. This function is used in wxDocManager::CreateView.
52b9ca21 372The dialog normally will not appear because the array of templates only contains
a660d684
KB
373those relevant to the document in question, and often there will only be one such.
374
52b9ca21
GT
375\wxheading{Parameters}
376
377\docparam{templates}{Pointer to an array of templates from which to choose a desired template.}
378\docparam{noTemplates}{Number of templates being pointed to by the {\it templates} pointer.}
379\docparam{sort}{If more than one template is passed in in {\it templates},
380then this parameter indicates whether the list of templates that the user
381will have to choose from is sorted or not when shown the choice box dialog.
382Default is FALSE.}
383
ac0ac824
JS
384\membersection{wxDocManager::SetLastDirectory}\label{wxdocmanagersetlastdirectory}
385
386\func{void}{SetLastDirectory}{\param{const wxString\&}{ dir}}
387
388Sets the directory to be displayed to the user when opening a file. Initially this is empty.
389
a660d684
KB
390\membersection{wxDocManager::SetMaxDocsOpen}
391
392\func{void}{SetMaxDocsOpen}{\param{int}{ n}}
393
394Sets the maximum number of documents that can be open at a time. By default, this
395is 10,000. If you set it to 1, existing documents will be saved and deleted
396when the user tries to open or create a new one (similar to the behaviour
397of Windows Write, for example). Allowing multiple documents gives behaviour
398more akin to MS Word and other Multiple Document Interface applications.
399
400
401