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