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