1 \section{\class{wxDocManager
}}\label{wxdocmanager
}
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.
7 \wxheading{Derived from
}
9 \helpref{wxEvtHandler
}{wxevthandler
}\\
10 \helpref{wxObject
}{wxobject
}
12 \wxheading{Include files
}
18 \helpref{wxDocManager overview
}{wxdocmanageroverview
},
\helpref{wxDocument
}{wxdocument
},
\rtfsp
19 \helpref{wxView
}{wxview
},
\helpref{wxDocTemplate
}{wxdoctemplate
},
\helpref{wxFileHistory
}{wxfilehistory
}
21 \latexignore{\rtfignore{\wxheading{Members
}}}
23 \membersection{wxDocManager::m
\_currentView}
25 \member{wxView*
}{m
\_currentView}
27 The currently active view.
29 \membersection{wxDocManager::m
\_defaultDocumentNameCounter}
31 \member{int
}{m
\_defaultDocumentNameCounter}
33 Stores the integer to be used for the next default
document name.
35 \membersection{wxDocManager::m
\_fileHistory}
37 \member{wxFileHistory*
}{m
\_fileHistory}
39 A pointer to an instance of
\helpref{wxFileHistory
}{wxfilehistory
},
40 which manages the history of recently-visited files on the File menu.
42 \membersection{wxDocManager::m
\_maxDocsOpen}
44 \member{int
}{m
\_maxDocsOpen}
46 Stores the maximum number of documents that can be opened before
47 existing documents are closed. By default, this is
10,
000.
49 \membersection{wxDocManager::m
\_docs}
51 \member{wxList
}{m
\_docs}
53 A list of all documents.
55 \membersection{wxDocManager::m
\_flags}
57 \member{long
}{m
\_flags}
59 Stores the flags passed to the constructor.
61 \membersection{wxDocManager::m
\_lastDirectory}
63 The directory last selected by the user when opening a file.
65 \member{wxFileHistory*
}{m
\_fileHistory}
67 \membersection{wxDocManager::m
\_templates}
69 \member{wxList
}{mnTemplates
}
71 A list of all
document templates.
73 \membersection{wxDocManager::wxDocManager
}
75 \func{void
}{wxDocManager
}{\param{long
}{ flags = wxDEFAULT
\_DOCMAN\_FLAGS},
\param{bool
}{ initialize = TRUE
}}
77 Constructor. Create a
document manager instance dynamically near the start of your application
78 before doing any
document or view operations.
80 {\it flags
} is currently unused.
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.
87 \membersection{wxDocManager::
\destruct{wxDocManager
}}
89 \func{void
}{\destruct{wxDocManager
}}{\void}
93 \membersection{wxDocManager::ActivateView
}
95 \func{void
}{ActivateView
}{\param{wxView*
}{doc
},
\param{bool
}{ activate
},
\param{bool
}{ deleting
}}
97 Sets the current view.
99 \membersection{wxDocManager::AddDocument
}
101 \func{void
}{AddDocument
}{\param{wxDocument *
}{doc
}}
103 Adds the
document to the list of documents.
105 \membersection{wxDocManager::AddFileToHistory
}
107 \func{void
}{AddFileToHistory
}{\param{const wxString\&
}{filename
}}
109 Adds a file to the file history list, if we have a pointer to an appropriate file menu.
111 \membersection{wxDocManager::AssociateTemplate
}
113 \func{void
}{AssociateTemplate
}{\param{wxDocTemplate *
}{temp
}}
115 Adds the template to the
document manager's template list.
117 \membersection{wxDocManager::CreateDocument
}
119 \func{wxDocument*
}{CreateDocument
}{\param{const wxString\&
}{path
},
\param{long
}{ flags
}}
121 Creates a new
document in a manner determined by the
{\it flags
} parameter, which can be:
123 \begin{itemize
}\itemsep=
0pt
124 \item wxDOC
\_NEW Creates a fresh
document.
125 \item wxDOC
\_SILENT Silently loads the given
document file.
128 If wxDOC
\_NEW is present, a new
document will be created and returned, possibly after
129 asking the user for a template to use if there is more than one
document template.
130 If wxDOC
\_SILENT is present, a new
document will be created and the given file loaded
131 into it. If neither of these flags is present, the user will be presented with
132 a file selector for the file to load, and the template to use will be determined by the
133 extension (Windows) or by popping up a template choice list (other platforms).
135 If the maximum number of documents has been reached, this function
136 will delete the oldest currently loaded
document before creating a new one.
138 \membersection{wxDocManager::CreateView
}
140 \func{wxView*
}{CreateView
}{\param{wxDocument*
}{doc
},
\param{long
}{ flags
}}
142 Creates a new view for the given
document. If more than one view is allowed for the
143 document (by virtue of multiple templates mentioning the same
document type), a choice
144 of view is presented to the user.
146 \membersection{wxDocManager::DisassociateTemplate
}
148 \func{void
}{DisassociateTemplate
}{\param{wxDocTemplate *
}{temp
}}
150 Removes the template from the list of templates.
152 \membersection{wxDocManager::FileHistoryAddFilesToMenu
}\label{wxdocmanagerfilehistoryaddfilestomenu
}
154 \func{void
}{FileHistoryAddFilesToMenu
}{\void}
156 Appends the files in the history list, to all menus managed by the file history object.
158 \func{void
}{FileHistoryAddFilesToMenu
}{\param{wxMenu*
}{ menu
}}
160 Appends the files in the history list, to the given menu only.
162 \membersection{wxDocManager::FileHistoryLoad
}\label{wxdocmanagerfilehistoryload
}
164 \func{void
}{FileHistoryLoad
}{\param{wxConfigBase\&
}{config
}}
166 Loads the file history from a config object.
170 \helpref{wxConfig
}{wxconfigbase
}
172 \membersection{wxDocManager::FileHistoryRemoveMenu
}\label{wxdocmanagerfilehistoryremovemenu
}
174 \func{void
}{FileHistoryRemoveMenu
}{\param{wxMenu*
}{ menu
}}
176 Removes the given menu from the list of menus managed by the file history object.
178 \membersection{wxDocManager::FileHistorySave
}\label{wxdocmanagerfilehistorysave
}
180 \func{void
}{FileHistorySave
}{\param{wxConfigBase\&
}{resourceFile
}}
182 Saves the file history into a config object. This must be called
183 explicitly by the application.
187 \helpref{wxConfig
}{wxconfigbase
}
189 \membersection{wxDocManager::FileHistoryUseMenu
}\label{wxdocmanagerfilehistoryusemenu
}
191 \func{void
}{FileHistoryUseMenu
}{\param{wxMenu*
}{ menu
}}
193 Use this menu for appending recently-visited
document filenames, for convenient
194 access. Calling this function with a valid menu pointer enables the history
197 Note that you can add multiple menus using this function, to be managed by the
200 \membersection{wxDocManager::FindTemplateForPath
}
202 \func{wxDocTemplate *
}{FindTemplateForPath
}{\param{const wxString\&
}{path
}}
204 Given a path, try to find template that matches the extension. This is only
205 an approximate method of finding a template for creating a
document.
207 \membersection{wxDocManager::GetCurrentDocument
}
209 \func{wxDocument *
}{GetCurrentDocument
}{\void}
211 Returns the
document associated with the currently active view (if any).
213 \membersection{wxDocManager::GetCurrentView
}
215 \func{wxView *
}{GetCurrentView
}{\void}
217 Returns the currently active view
219 \membersection{wxDocManager::GetDocuments
}
221 \func{wxList\&
}{GetDocuments
}{\void}
223 Returns a reference to the list of documents.
225 \membersection{wxDocManager::GetFileHistory
}
227 \func{wxFileHistory *
}{GetFileHistory
}{\void}
229 Returns a pointer to file history.
231 \membersection{wxDocManager::GetLastDirectory
}\label{wxdocmanagergetlastdirectory
}
233 \constfunc{wxString
}{GetLastDirectory
}{\void}
235 Returns the directory last selected by the user when opening a file. Initially empty.
237 \membersection{wxDocManager::GetMaxDocsOpen
}
239 \func{int
}{GetMaxDocsOpen
}{\void}
241 Returns the number of documents that can be open simultaneously.
243 \membersection{wxDocManager::GetNoHistoryFiles
}
245 \func{int
}{GetNoHistoryFiles
}{\void}
247 Returns the number of files currently stored in the file history.
249 \membersection{wxDocManager::Initialize
}\label{wxdocmanagerinitialize
}
251 \func{bool
}{Initialize
}{\void}
253 Initializes data; currently just calls OnCreateFileHistory. Some data cannot
254 always be initialized in the constructor because the programmer must be given
255 the opportunity to override functionality. If OnCreateFileHistory was called
256 from the constructor, an overridden virtual OnCreateFileHistory would not be
257 called due to C++'s `interesting' constructor semantics. In fact Initialize
258 \rtfsp{\it is
} called from the wxDocManager constructor, but this can be
259 vetoed by passing FALSE to the second argument, allowing the derived class's
260 constructor to call Initialize, possibly calling a different OnCreateFileHistory
263 The bottom line: if you're not deriving from Initialize, forget it and
264 construct wxDocManager with no arguments.
266 \membersection{wxDocManager::MakeDefaultName
}
268 \func{bool
}{MakeDefaultName
}{\param{const wxString\&
}{buf
}}
270 Copies a suitable default name into
{\it buf
}. This is implemented by
271 appending an integer counter to the string
{\bf unnamed
} and incrementing
274 \membersection{wxDocManager::OnCreateFileHistory
}
276 \func{wxFileHistory *
}{OnCreateFileHistory
}{\void}
278 A hook to allow a derived class to create a different type of file history. Called
279 from
\helpref{Initialize
}{wxdocmanagerinitialize
}.
281 \membersection{wxDocManager::OnFileClose
}
283 \func{void
}{OnFileClose
}{\void}
285 Closes and deletes the currently active
document.
287 \membersection{wxDocManager::OnFileNew
}
289 \func{void
}{OnFileNew
}{\void}
291 Creates a
document from a list of templates (if more than one template).
293 \membersection{wxDocManager::OnFileOpen
}
295 \func{void
}{OnFileOpen
}{\void}
297 Creates a new
document and reads in the selected file.
299 \membersection{wxDocManager::OnFileSave
}
301 \func{void
}{OnFileSave
}{\void}
303 Saves the current
document by calling wxDocument::Save for the current
document.
305 \membersection{wxDocManager::OnFileSaveAs
}
307 \func{void
}{OnFileSaveAs
}{\void}
309 Calls wxDocument::SaveAs for the current
document.
311 \membersection{wxDocManager::OnMenuCommand
}
313 \func{void
}{OnMenuCommand
}{\param{int
}{ cmd
}}
315 Processes menu commands routed from child or parent frames. This deals
316 with the following predefined menu item identifiers:
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.
326 Unrecognized commands are routed to the currently active wxView's OnMenuCommand.
328 \membersection{wxDocManager::RemoveDocument
}
330 \func{void
}{RemoveDocument
}{\param{wxDocument *
}{doc
}}
332 Removes the
document from the list of documents.
334 \membersection{wxDocManager::SelectDocumentPath
}
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
}}
340 Under Windows, pops up a file selector with a list of filters corresponding to
document templates.
341 The wxDocTemplate corresponding to the selected file's extension is returned.
343 On other platforms, if there is more than one
document template a choice list is popped up,
344 followed by a file selector.
346 This function is used in wxDocManager::CreateDocument.
348 \membersection{wxDocManager::SelectDocumentType
}
350 \func{wxDocTemplate *
}{SelectDocumentType
}{\param{wxDocTemplate **
}{templates
},
351 \param{int
}{ noTemplates
},
\param{bool
}{ sort=FALSE
}}
353 Returns a
document template by asking the user (if there is more than one template).
354 This function is used in wxDocManager::CreateDocument.
356 \wxheading{Parameters
}
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
},
361 then this parameter indicates whether the list of templates that the user
362 will have to choose from is sorted or not when shown the choice box dialog.
365 \membersection{wxDocManager::SelectViewType
}
367 \func{wxDocTemplate *
}{SelectViewType
}{\param{wxDocTemplate **
}{templates
},
368 \param{int
}{ noTemplates
},
\param{bool
}{ sort=FALSE
}}
370 Returns a
document template by asking the user (if there is more than one template),
371 displaying a list of valid views. This function is used in wxDocManager::CreateView.
372 The dialog normally will not appear because the array of templates only contains
373 those relevant to the
document in question, and often there will only be one such.
375 \wxheading{Parameters
}
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
},
380 then this parameter indicates whether the list of templates that the user
381 will have to choose from is sorted or not when shown the choice box dialog.
384 \membersection{wxDocManager::SetLastDirectory
}\label{wxdocmanagersetlastdirectory
}
386 \func{void
}{SetLastDirectory
}{\param{const wxString\&
}{ dir
}}
388 Sets the directory to be displayed to the user when opening a file. Initially this is empty.
390 \membersection{wxDocManager::SetMaxDocsOpen
}
392 \func{void
}{SetMaxDocsOpen
}{\param{int
}{ n
}}
394 Sets the maximum number of documents that can be open at a time. By default, this
395 is
10,
000. If you set it to
1, existing documents will be saved and deleted
396 when the user tries to open or create a new one (similar to the behaviour
397 of Windows Write, for example). Allowing multiple documents gives behaviour
398 more akin to MS Word and other Multiple Document Interface applications.