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