1 \section{\class{wxDocManager
}}\label{wxdocmanager
}
3 The wxDocManager class is part of the
document/view framework supported by wxWidgets,
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}\label{wxdocmanagermcreateview
}
25 \member{wxView*
}{m
\_currentView}
27 The currently active view.
29 \membersection{wxDocManager::m
\_defaultDocumentNameCounter}\label{wxdocmanagermdefaultdocumentnamecounter
}
31 \member{int
}{m
\_defaultDocumentNameCounter}
33 Stores the integer to be used for the next default
document name.
35 \membersection{wxDocManager::m
\_fileHistory}\label{wxdocmanagermfilehistory
}
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}\label{wxdocmanagermmaxdocsopen
}
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}\label{wxdocmanagermdocs
}
51 \member{wxList
}{m
\_docs}
53 A list of all documents.
55 \membersection{wxDocManager::m
\_flags}\label{wxdocmanagermflags
}
57 \member{long
}{m
\_flags}
59 Stores the flags passed to the constructor.
61 \membersection{wxDocManager::m
\_lastDirectory}\label{wxdocmanagermlastdirectory
}
63 The directory last selected by the user when opening a file.
65 \member{wxFileHistory*
}{m
\_fileHistory}
67 \membersection{wxDocManager::m
\_templates}\label{wxdocmanagermtemplates
}
69 \member{wxList
}{mnTemplates
}
71 A list of all
document templates.
73 \membersection{wxDocManager::wxDocManager
}\label{wxdocmanagerctor
}
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
}}\label{wxdocmanagerdtor
}
89 \func{void
}{\destruct{wxDocManager
}}{\void}
93 \membersection{wxDocManager::ActivateView
}\label{wxdocmanageractivateview
}
95 \func{void
}{ActivateView
}{\param{wxView*
}{doc
},
\param{bool
}{ activate
},
\param{bool
}{ deleting
}}
97 Sets the current view.
99 \membersection{wxDocManager::AddDocument
}\label{wxdocmanageradddocument
}
101 \func{void
}{AddDocument
}{\param{wxDocument *
}{doc
}}
103 Adds the
document to the list of documents.
105 \membersection{wxDocManager::AddFileToHistory
}\label{wxdocmanageraddfiletohistory
}
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
}\label{wxdocmanagerassociatetemplate
}
113 \func{void
}{AssociateTemplate
}{\param{wxDocTemplate *
}{temp
}}
115 Adds the template to the
document manager's template list.
117 \membersection{wxDocManager::CloseDocuments
}\label{wxdocmanagerclosedocuments
}
119 \func{bool
}{CloseDocuments
}{\param{bool
}{force = true
}}
121 Closes all currently opened documents.
123 \membersection{wxDocManager::CreateDocument
}\label{wxdocmanagercreatedocument
}
125 \func{wxDocument*
}{CreateDocument
}{\param{const wxString\&
}{path
},
\param{long
}{ flags
}}
127 Creates a new
document in a manner determined by the
{\it flags
} parameter, which can be:
129 \begin{itemize
}\itemsep=
0pt
130 \item wxDOC
\_NEW Creates a fresh
document.
131 \item wxDOC
\_SILENT Silently loads the given
document file.
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).
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.
144 \membersection{wxDocManager::CreateView
}\label{wxdocmanagercreateview
}
146 \func{wxView*
}{CreateView
}{\param{wxDocument*
}{doc
},
\param{long
}{ flags
}}
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.
152 \membersection{wxDocManager::DisassociateTemplate
}\label{wxdocmanagerdisassociatetemplate
}
154 \func{void
}{DisassociateTemplate
}{\param{wxDocTemplate *
}{temp
}}
156 Removes the template from the list of templates.
158 \membersection{wxDocManager::FileHistoryAddFilesToMenu
}\label{wxdocmanagerfilehistoryaddfilestomenu
}
160 \func{void
}{FileHistoryAddFilesToMenu
}{\void}
162 Appends the files in the history list, to all menus managed by the file history object.
164 \func{void
}{FileHistoryAddFilesToMenu
}{\param{wxMenu*
}{ menu
}}
166 Appends the files in the history list, to the given menu only.
168 \membersection{wxDocManager::FileHistoryLoad
}\label{wxdocmanagerfilehistoryload
}
170 \func{void
}{FileHistoryLoad
}{\param{wxConfigBase\&
}{config
}}
172 Loads the file history from a config object.
176 \helpref{wxConfig
}{wxconfigbase
}
178 \membersection{wxDocManager::FileHistoryRemoveMenu
}\label{wxdocmanagerfilehistoryremovemenu
}
180 \func{void
}{FileHistoryRemoveMenu
}{\param{wxMenu*
}{ menu
}}
182 Removes the given menu from the list of menus managed by the file history object.
184 \membersection{wxDocManager::FileHistorySave
}\label{wxdocmanagerfilehistorysave
}
186 \func{void
}{FileHistorySave
}{\param{wxConfigBase\&
}{resourceFile
}}
188 Saves the file history into a config object. This must be called
189 explicitly by the application.
193 \helpref{wxConfig
}{wxconfigbase
}
195 \membersection{wxDocManager::FileHistoryUseMenu
}\label{wxdocmanagerfilehistoryusemenu
}
197 \func{void
}{FileHistoryUseMenu
}{\param{wxMenu*
}{ menu
}}
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
203 Note that you can add multiple menus using this function, to be managed by the
206 \membersection{wxDocManager::FindTemplateForPath
}\label{wxdocmanagerfindtemplateforpath
}
208 \func{wxDocTemplate *
}{FindTemplateForPath
}{\param{const wxString\&
}{path
}}
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.
213 \membersection{wxDocManager::GetCurrentDocument
}\label{wxdocmanagergetcurrentdocument
}
215 \func{wxDocument *
}{GetCurrentDocument
}{\void}
217 Returns the
document associated with the currently active view (if any).
219 \membersection{wxDocManager::GetCurrentView
}\label{wxdocmanagergetcurrentview
}
221 \func{wxView *
}{GetCurrentView
}{\void}
223 Returns the currently active view
225 \membersection{wxDocManager::GetDocuments
}\label{wxdocmanagergetdocuments
}
227 \func{wxList\&
}{GetDocuments
}{\void}
229 Returns a reference to the list of documents.
231 \membersection{wxDocManager::GetFileHistory
}\label{wxdocmanagergetfilehistory
}
233 \func{wxFileHistory *
}{GetFileHistory
}{\void}
235 Returns a pointer to file history.
237 \membersection{wxDocManager::GetLastDirectory
}\label{wxdocmanagergetlastdirectory
}
239 \constfunc{wxString
}{GetLastDirectory
}{\void}
241 Returns the directory last selected by the user when opening a file. Initially empty.
243 \membersection{wxDocManager::GetMaxDocsOpen
}\label{wxdocmanagergetmaxdocsopen
}
245 \func{int
}{GetMaxDocsOpen
}{\void}
247 Returns the number of documents that can be open simultaneously.
249 \membersection{wxDocManager::GetHistoryFilesCount
}\label{wxdocmanagergethistoryfilescount
}
251 \func{size
\_t}{GetHistoryFilesCount
}{\void}
253 Returns the number of files currently stored in the file history.
255 \membersection{wxDocManager::Initialize
}\label{wxdocmanagerinitialize
}
257 \func{bool
}{Initialize
}{\void}
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
269 The bottom line: if you're not deriving from Initialize, forget it and
270 construct wxDocManager with no arguments.
272 \membersection{wxDocManager::MakeDefaultName
}\label{wxdocmanagermakedefaultname
}
274 \func{bool
}{MakeDefaultName
}{\param{const wxString\&
}{buf
}}
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
280 \perlnote{In wxPerl this function must return the modified name rather
281 than just modifying the argument.
}
283 \membersection{wxDocManager::OnCreateFileHistory
}\label{wxdocmanageroncreatefilehistory
}
285 \func{wxFileHistory *
}{OnCreateFileHistory
}{\void}
287 A hook to allow a derived class to create a different type of file history. Called
288 from
\helpref{Initialize
}{wxdocmanagerinitialize
}.
290 \membersection{wxDocManager::OnFileClose
}\label{wxdocmanageronfileclose
}
292 \func{void
}{OnFileClose
}{\param{wxCommandEvent\&
}{event
}}
294 Closes and deletes the currently active
document.
296 \membersection{wxDocManager::OnFileCloseAll
}\label{wxdocmanageronfilecloseall
}
298 \func{void
}{OnFileCloseAll
}{\param{wxCommandEvent\&
}{event
}}
300 Closes and deletes all the currently opened documents.
302 \membersection{wxDocManager::OnFileNew
}\label{wxdocmanageronfilenew
}
304 \func{void
}{OnFileNew
}{\param{wxCommandEvent\&
}{event
}}
306 Creates a
document from a list of templates (if more than one template).
308 \membersection{wxDocManager::OnFileOpen
}\label{wxdocmanageronfileopen
}
310 \func{void
}{OnFileOpen
}{\param{wxCommandEvent\&
}{event
}}
312 Creates a new
document and reads in the selected file.
314 \membersection{wxDocManager::OnFileRevert
}\label{wxdocmanageronfilerevert
}
316 \func{void
}{OnFileRevert
}{\param{wxCommandEvent\&
}{event
}}
318 Reverts the current
document by calling wxDocument::Revert for the current
document.
320 \membersection{wxDocManager::OnFileSave
}\label{wxdocmanageronfilesave
}
322 \func{void
}{OnFileSave
}{\param{wxCommandEvent\&
}{event
}}
324 Saves the current
document by calling wxDocument::Save for the current
document.
326 \membersection{wxDocManager::OnFileSaveAs
}\label{wxdocmanageronfilesaveas
}
328 \func{void
}{OnFileSaveAs
}{\param{wxCommandEvent\&
}{event
}}
330 Calls wxDocument::SaveAs for the current
document.
332 \membersection{wxDocManager::OnMenuCommand
}\label{wxdocmanageronmenucommand
}
334 \func{void
}{OnMenuCommand
}{\param{int
}{ cmd
}}
336 Processes menu commands routed from child or parent frames. This deals
337 with the following predefined menu item identifiers:
339 \begin{itemize
}\itemsep=
0pt
340 \item wxID
\_OPEN Creates a new
document and opens a file into it.
341 \item wxID
\_CLOSE Closes the current
document.
342 \item wxID
\_CLOSE\_ALL Closes all documents.
343 \item wxID
\_NEW Creates a new
document.
344 \item wxID
\_SAVE Saves the
document.
345 \item wxID
\_SAVE\_AS Saves the
document into a specified filename.
348 Unrecognized commands are routed to the currently active wxView's OnMenuCommand.
350 \membersection{wxDocManager::RemoveDocument
}\label{wxdocmanagerremovedocument
}
352 \func{void
}{RemoveDocument
}{\param{wxDocument *
}{doc
}}
354 Removes the
document from the list of documents.
356 \membersection{wxDocManager::SelectDocumentPath
}\label{wxdocmanagerselectdocumentpath
}
358 \func{wxDocTemplate *
}{SelectDocumentPath
}{\param{wxDocTemplate **
}{templates
},
359 \param{int
}{ noTemplates
},
\param{const wxString\&
}{path
},
\param{const wxString\&
}{bufSize
},
360 \param{long
}{ flags
},
\param{bool
}{ save
}}
362 Under Windows, pops up a file selector with a list of filters corresponding to
document templates.
363 The wxDocTemplate corresponding to the selected file's extension is returned.
365 On other platforms, if there is more than one
document template a choice list is popped up,
366 followed by a file selector.
368 This function is used in wxDocManager::CreateDocument.
370 \perlnote{In wxPerl
{\tt templates
} is a reference to a list of templates.
371 If you override this method in your
document manager it must return
373 (doctemplate, path) = My::DocManager->SelectDocumentPath( ... );
376 \membersection{wxDocManager::SelectDocumentType
}\label{wxdocmanagerselectdocumenttype
}
378 \func{wxDocTemplate *
}{SelectDocumentType
}{\param{wxDocTemplate **
}{templates
},
379 \param{int
}{ noTemplates
},
\param{bool
}{ sort=false
}}
381 Returns a
document template by asking the user (if there is more than one template).
382 This function is used in wxDocManager::CreateDocument.
384 \wxheading{Parameters
}
386 \docparam{templates
}{Pointer to an array of templates from which to choose a desired template.
}
387 \docparam{noTemplates
}{Number of templates being pointed to by the
{\it templates
} pointer.
}
388 \docparam{sort
}{If more than one template is passed in in
{\it templates
},
389 then this parameter indicates whether the list of templates that the user
390 will have to choose from is sorted or not when shown the choice box dialog.
393 \perlnote{In wxPerl
{\tt templates
} is a reference to a list of templates.
}
395 \membersection{wxDocManager::SelectViewType
}\label{wxdocmanagerselectviewtype
}
397 \func{wxDocTemplate *
}{SelectViewType
}{\param{wxDocTemplate **
}{templates
},
398 \param{int
}{ noTemplates
},
\param{bool
}{ sort=false
}}
400 Returns a
document template by asking the user (if there is more than one template),
401 displaying a list of valid views. This function is used in wxDocManager::CreateView.
402 The dialog normally will not appear because the array of templates only contains
403 those relevant to the
document in question, and often there will only be one such.
405 \wxheading{Parameters
}
407 \docparam{templates
}{Pointer to an array of templates from which to choose a desired template.
}
408 \docparam{noTemplates
}{Number of templates being pointed to by the
{\it templates
} pointer.
}
409 \docparam{sort
}{If more than one template is passed in in
{\it templates
},
410 then this parameter indicates whether the list of templates that the user
411 will have to choose from is sorted or not when shown the choice box dialog.
414 \perlnote{In wxPerl
{\tt templates
} is a reference to a list of templates.
}
416 \membersection{wxDocManager::SetLastDirectory
}\label{wxdocmanagersetlastdirectory
}
418 \func{void
}{SetLastDirectory
}{\param{const wxString\&
}{ dir
}}
420 Sets the directory to be displayed to the user when opening a file. Initially this is empty.
422 \membersection{wxDocManager::SetMaxDocsOpen
}\label{wxdocmanagersetmaxdocsopen
}
424 \func{void
}{SetMaxDocsOpen
}{\param{int
}{ n
}}
426 Sets the maximum number of documents that can be open at a time. By default, this
427 is
10,
000. If you set it to
1, existing documents will be saved and deleted
428 when the user tries to open or create a new one (similar to the behaviour
429 of Windows Write, for example). Allowing multiple documents gives behaviour
430 more akin to MS Word and other Multiple Document Interface applications.