1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
3 %% Purpose: wxDocManager documentation
4 %% Author: wxWidgets Team
8 %% Copyright: (c) wxWidgets Team
9 %% License: wxWindows license
10 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
12 \section{\class{wxDocManager
}}\label{wxdocmanager
}
14 The wxDocManager class is part of the
document/view framework supported by wxWidgets,
15 and cooperates with the
\helpref{wxView
}{wxview
},
\helpref{wxDocument
}{wxdocument
}\rtfsp
16 and
\helpref{wxDocTemplate
}{wxdoctemplate
} classes.
18 \wxheading{Derived from
}
20 \helpref{wxEvtHandler
}{wxevthandler
}\\
21 \helpref{wxObject
}{wxobject
}
23 \wxheading{Include files
}
29 \helpref{wxDocManager overview
}{wxdocmanageroverview
},
\helpref{wxDocument
}{wxdocument
},
\rtfsp
30 \helpref{wxView
}{wxview
},
\helpref{wxDocTemplate
}{wxdoctemplate
},
\helpref{wxFileHistory
}{wxfilehistory
}
32 \latexignore{\rtfignore{\wxheading{Members
}}}
35 \membersection{wxDocManager::m
\_currentView}\label{wxdocmanagermcreateview
}
37 \member{wxView*
}{m
\_currentView}
39 The currently active view.
42 \membersection{wxDocManager::m
\_defaultDocumentNameCounter}\label{wxdocmanagermdefaultdocumentnamecounter
}
44 \member{int
}{m
\_defaultDocumentNameCounter}
46 Stores the integer to be used for the next default
document name.
49 \membersection{wxDocManager::m
\_fileHistory}\label{wxdocmanagermfilehistory
}
51 \member{wxFileHistory*
}{m
\_fileHistory}
53 A pointer to an instance of
\helpref{wxFileHistory
}{wxfilehistory
},
54 which manages the history of recently-visited files on the File menu.
57 \membersection{wxDocManager::m
\_maxDocsOpen}\label{wxdocmanagermmaxdocsopen
}
59 \member{int
}{m
\_maxDocsOpen}
61 Stores the maximum number of documents that can be opened before
62 existing documents are closed. By default, this is
10,
000.
65 \membersection{wxDocManager::m
\_docs}\label{wxdocmanagermdocs
}
67 \member{wxList
}{m
\_docs}
69 A list of all documents.
72 \membersection{wxDocManager::m
\_flags}\label{wxdocmanagermflags
}
74 \member{long
}{m
\_flags}
76 Stores the flags passed to the constructor.
79 \membersection{wxDocManager::m
\_lastDirectory}\label{wxdocmanagermlastdirectory
}
81 The directory last selected by the user when opening a file.
83 \member{wxFileHistory*
}{m
\_fileHistory}
86 \membersection{wxDocManager::m
\_templates}\label{wxdocmanagermtemplates
}
88 \member{wxList
}{mnTemplates
}
90 A list of all
document templates.
93 \membersection{wxDocManager::wxDocManager
}\label{wxdocmanagerctor
}
95 \func{}{wxDocManager
}{\param{long
}{ flags = wxDEFAULT
\_DOCMAN\_FLAGS},
\param{bool
}{ initialize = true
}}
97 Constructor. Create a
document manager instance dynamically near the start of your application
98 before doing any
document or view operations.
100 {\it flags
} is currently unused.
102 If
{\it initialize
} is true, the
\helpref{Initialize
}{wxdocmanagerinitialize
} function will be called
103 to create a default history list object. If you derive from wxDocManager, you may wish to call the
104 base constructor with false, and then call Initialize in your own constructor, to allow
105 your own Initialize or OnCreateFileHistory functions to be called.
108 \membersection{wxDocManager::
\destruct{wxDocManager
}}\label{wxdocmanagerdtor
}
110 \func{void
}{\destruct{wxDocManager
}}{\void}
115 \membersection{wxDocManager::ActivateView
}\label{wxdocmanageractivateview
}
117 \func{void
}{ActivateView
}{\param{wxView*
}{doc
},
\param{bool
}{ activate = true
}}
119 Sets the current view.
122 \membersection{wxDocManager::AddDocument
}\label{wxdocmanageradddocument
}
124 \func{void
}{AddDocument
}{\param{wxDocument *
}{doc
}}
126 Adds the
document to the list of documents.
129 \membersection{wxDocManager::AddFileToHistory
}\label{wxdocmanageraddfiletohistory
}
131 \func{void
}{AddFileToHistory
}{\param{const wxString\&
}{filename
}}
133 Adds a file to the file history list, if we have a pointer to an appropriate file menu.
136 \membersection{wxDocManager::AssociateTemplate
}\label{wxdocmanagerassociatetemplate
}
138 \func{void
}{AssociateTemplate
}{\param{wxDocTemplate *
}{temp
}}
140 Adds the template to the
document manager's template list.
143 \membersection{wxDocManager::CloseDocuments
}\label{wxdocmanagerclosedocuments
}
145 \func{bool
}{CloseDocuments
}{\param{bool
}{force = true
}}
147 Closes all currently opened documents.
150 \membersection{wxDocManager::CreateDocument
}\label{wxdocmanagercreatedocument
}
152 \func{wxDocument*
}{CreateDocument
}{\param{const wxString\&
}{path
},
\param{long
}{ flags
}}
154 Creates a new
document in a manner determined by the
{\it flags
} parameter, which can be:
156 \begin{itemize
}\itemsep=
0pt
157 \item wxDOC
\_NEW Creates a fresh
document.
158 \item wxDOC
\_SILENT Silently loads the given
document file.
161 If wxDOC
\_NEW is present, a new
document will be created and returned, possibly after
162 asking the user for a template to use if there is more than one
document template.
163 If wxDOC
\_SILENT is present, a new
document will be created and the given file loaded
164 into it. If neither of these flags is present, the user will be presented with
165 a file selector for the file to load, and the template to use will be determined by the
166 extension (Windows) or by popping up a template choice list (other platforms).
168 If the maximum number of documents has been reached, this function
169 will delete the oldest currently loaded
document before creating a new one.
172 \membersection{wxDocManager::CreateView
}\label{wxdocmanagercreateview
}
174 \func{wxView*
}{CreateView
}{\param{wxDocument*
}{doc
},
\param{long
}{ flags
}}
176 Creates a new view for the given
document. If more than one view is allowed for the
177 document (by virtue of multiple templates mentioning the same
document type), a choice
178 of view is presented to the user.
181 \membersection{wxDocManager::DisassociateTemplate
}\label{wxdocmanagerdisassociatetemplate
}
183 \func{void
}{DisassociateTemplate
}{\param{wxDocTemplate *
}{temp
}}
185 Removes the template from the list of templates.
188 \membersection{wxDocManager::FileHistoryAddFilesToMenu
}\label{wxdocmanagerfilehistoryaddfilestomenu
}
190 \func{void
}{FileHistoryAddFilesToMenu
}{\void}
192 Appends the files in the history list, to all menus managed by the file history object.
194 \func{void
}{FileHistoryAddFilesToMenu
}{\param{wxMenu*
}{ menu
}}
196 Appends the files in the history list, to the given menu only.
199 \membersection{wxDocManager::FileHistoryLoad
}\label{wxdocmanagerfilehistoryload
}
201 \func{void
}{FileHistoryLoad
}{\param{wxConfigBase\&
}{config
}}
203 Loads the file history from a config object.
207 \helpref{wxConfig
}{wxconfigbase
}
210 \membersection{wxDocManager::FileHistoryRemoveMenu
}\label{wxdocmanagerfilehistoryremovemenu
}
212 \func{void
}{FileHistoryRemoveMenu
}{\param{wxMenu*
}{ menu
}}
214 Removes the given menu from the list of menus managed by the file history object.
217 \membersection{wxDocManager::FileHistorySave
}\label{wxdocmanagerfilehistorysave
}
219 \func{void
}{FileHistorySave
}{\param{wxConfigBase\&
}{resourceFile
}}
221 Saves the file history into a config object. This must be called
222 explicitly by the application.
226 \helpref{wxConfig
}{wxconfigbase
}
229 \membersection{wxDocManager::FileHistoryUseMenu
}\label{wxdocmanagerfilehistoryusemenu
}
231 \func{void
}{FileHistoryUseMenu
}{\param{wxMenu*
}{ menu
}}
233 Use this menu for appending recently-visited
document filenames, for convenient
234 access. Calling this function with a valid menu pointer enables the history
237 Note that you can add multiple menus using this function, to be managed by the
241 \membersection{wxDocManager::FindTemplateForPath
}\label{wxdocmanagerfindtemplateforpath
}
243 \func{wxDocTemplate *
}{FindTemplateForPath
}{\param{const wxString\&
}{path
}}
245 Given a path, try to find template that matches the extension. This is only
246 an approximate method of finding a template for creating a
document.
249 \membersection{wxDocManager::GetCurrentDocument
}\label{wxdocmanagergetcurrentdocument
}
251 \func{wxDocument *
}{GetCurrentDocument
}{\void}
253 Returns the
document associated with the currently active view (if any).
256 \membersection{wxDocManager::GetCurrentView
}\label{wxdocmanagergetcurrentview
}
258 \func{wxView *
}{GetCurrentView
}{\void}
260 Returns the currently active view
263 \membersection{wxDocManager::GetDocuments
}\label{wxdocmanagergetdocuments
}
265 \func{wxList\&
}{GetDocuments
}{\void}
267 Returns a reference to the list of documents.
270 \membersection{wxDocManager::GetFileHistory
}\label{wxdocmanagergetfilehistory
}
272 \func{wxFileHistory *
}{GetFileHistory
}{\void}
274 Returns a pointer to file history.
277 \membersection{wxDocManager::GetLastDirectory
}\label{wxdocmanagergetlastdirectory
}
279 \constfunc{wxString
}{GetLastDirectory
}{\void}
281 Returns the directory last selected by the user when opening a file. Initially empty.
284 \membersection{wxDocManager::GetMaxDocsOpen
}\label{wxdocmanagergetmaxdocsopen
}
286 \func{int
}{GetMaxDocsOpen
}{\void}
288 Returns the number of documents that can be open simultaneously.
291 \membersection{wxDocManager::GetHistoryFilesCount
}\label{wxdocmanagergethistoryfilescount
}
293 \func{size
\_t}{GetHistoryFilesCount
}{\void}
295 Returns the number of files currently stored in the file history.
298 \membersection{wxDocManager::GetTemplates
}\label{wxdocmanagergettemplates
}
300 \func{wxList\&
}{GetTemplates
}{\void}
302 Returns a reference to the list of associated templates.
305 \membersection{wxDocManager::Initialize
}\label{wxdocmanagerinitialize
}
307 \func{bool
}{Initialize
}{\void}
309 Initializes data; currently just calls OnCreateFileHistory. Some data cannot
310 always be initialized in the constructor because the programmer must be given
311 the opportunity to override functionality. If OnCreateFileHistory was called
312 from the constructor, an overridden virtual OnCreateFileHistory would not be
313 called due to C++'s `interesting' constructor semantics. In fact Initialize
314 \rtfsp{\it is
} called from the wxDocManager constructor, but this can be
315 vetoed by passing false to the second argument, allowing the derived class's
316 constructor to call Initialize, possibly calling a different OnCreateFileHistory
319 The bottom line: if you're not deriving from Initialize, forget it and
320 construct wxDocManager with no arguments.
323 \membersection{wxDocManager::MakeDefaultName
}\label{wxdocmanagermakedefaultname
}
325 \func{bool
}{MakeDefaultName
}{\param{const wxString\&
}{buf
}}
327 Copies a suitable default name into
{\it buf
}. This is implemented by
328 appending an integer counter to the string
{\bf unnamed
} and incrementing
331 \perlnote{In wxPerl this function must return the modified name rather
332 than just modifying the argument.
}
335 \membersection{wxDocManager::OnCreateFileHistory
}\label{wxdocmanageroncreatefilehistory
}
337 \func{wxFileHistory *
}{OnCreateFileHistory
}{\void}
339 A hook to allow a derived class to create a different type of file history. Called
340 from
\helpref{Initialize
}{wxdocmanagerinitialize
}.
343 \membersection{wxDocManager::OnFileClose
}\label{wxdocmanageronfileclose
}
345 \func{void
}{OnFileClose
}{\param{wxCommandEvent\&
}{event
}}
347 Closes and deletes the currently active
document.
350 \membersection{wxDocManager::OnFileCloseAll
}\label{wxdocmanageronfilecloseall
}
352 \func{void
}{OnFileCloseAll
}{\param{wxCommandEvent\&
}{event
}}
354 Closes and deletes all the currently opened documents.
357 \membersection{wxDocManager::OnFileNew
}\label{wxdocmanageronfilenew
}
359 \func{void
}{OnFileNew
}{\param{wxCommandEvent\&
}{event
}}
361 Creates a
document from a list of templates (if more than one template).
364 \membersection{wxDocManager::OnFileOpen
}\label{wxdocmanageronfileopen
}
366 \func{void
}{OnFileOpen
}{\param{wxCommandEvent\&
}{event
}}
368 Creates a new
document and reads in the selected file.
371 \membersection{wxDocManager::OnFileRevert
}\label{wxdocmanageronfilerevert
}
373 \func{void
}{OnFileRevert
}{\param{wxCommandEvent\&
}{event
}}
375 Reverts the current
document by calling wxDocument::Revert for the current
document.
378 \membersection{wxDocManager::OnFileSave
}\label{wxdocmanageronfilesave
}
380 \func{void
}{OnFileSave
}{\param{wxCommandEvent\&
}{event
}}
382 Saves the current
document by calling wxDocument::Save for the current
document.
385 \membersection{wxDocManager::OnFileSaveAs
}\label{wxdocmanageronfilesaveas
}
387 \func{void
}{OnFileSaveAs
}{\param{wxCommandEvent\&
}{event
}}
389 Calls wxDocument::SaveAs for the current
document.
392 \membersection{wxDocManager::RemoveDocument
}\label{wxdocmanagerremovedocument
}
394 \func{void
}{RemoveDocument
}{\param{wxDocument *
}{doc
}}
396 Removes the
document from the list of documents.
399 \membersection{wxDocManager::SelectDocumentPath
}\label{wxdocmanagerselectdocumentpath
}
401 \func{wxDocTemplate *
}{SelectDocumentPath
}{\param{wxDocTemplate **
}{templates
},
402 \param{int
}{ noTemplates
},
\param{wxString\&
}{path
},
403 \param{long
}{ flags
},
\param{bool
}{ save
}}
405 Under Windows, pops up a file selector with a list of filters corresponding to
document templates.
406 The wxDocTemplate corresponding to the selected file's extension is returned.
408 On other platforms, if there is more than one
document template a choice list is popped up,
409 followed by a file selector.
411 This function is used in wxDocManager::CreateDocument.
413 \perlnote{In wxPerl
{\tt templates
} is a reference to a list of templates.
414 If you override this method in your
document manager it must return
416 (doctemplate, path) = My::DocManager->SelectDocumentPath( ... );
420 \membersection{wxDocManager::SelectDocumentType
}\label{wxdocmanagerselectdocumenttype
}
422 \func{wxDocTemplate *
}{SelectDocumentType
}{\param{wxDocTemplate **
}{templates
},
423 \param{int
}{ noTemplates
},
\param{bool
}{ sort=false
}}
425 Returns a
document template by asking the user (if there is more than one template).
426 This function is used in wxDocManager::CreateDocument.
428 \wxheading{Parameters
}
430 \docparam{templates
}{Pointer to an array of templates from which to choose a desired template.
}
431 \docparam{noTemplates
}{Number of templates being pointed to by the
{\it templates
} pointer.
}
432 \docparam{sort
}{If more than one template is passed in in
{\it templates
},
433 then this parameter indicates whether the list of templates that the user
434 will have to choose from is sorted or not when shown the choice box dialog.
437 \perlnote{In wxPerl
{\tt templates
} is a reference to a list of templates.
}
440 \membersection{wxDocManager::SelectViewType
}\label{wxdocmanagerselectviewtype
}
442 \func{wxDocTemplate *
}{SelectViewType
}{\param{wxDocTemplate **
}{templates
},
443 \param{int
}{ noTemplates
},
\param{bool
}{ sort=false
}}
445 Returns a
document template by asking the user (if there is more than one template),
446 displaying a list of valid views. This function is used in wxDocManager::CreateView.
447 The dialog normally will not appear because the array of templates only contains
448 those relevant to the
document in question, and often there will only be one such.
450 \wxheading{Parameters
}
452 \docparam{templates
}{Pointer to an array of templates from which to choose a desired template.
}
453 \docparam{noTemplates
}{Number of templates being pointed to by the
{\it templates
} pointer.
}
454 \docparam{sort
}{If more than one template is passed in in
{\it templates
},
455 then this parameter indicates whether the list of templates that the user
456 will have to choose from is sorted or not when shown the choice box dialog.
459 \perlnote{In wxPerl
{\tt templates
} is a reference to a list of templates.
}
462 \membersection{wxDocManager::SetLastDirectory
}\label{wxdocmanagersetlastdirectory
}
464 \func{void
}{SetLastDirectory
}{\param{const wxString\&
}{ dir
}}
466 Sets the directory to be displayed to the user when opening a file. Initially this is empty.
469 \membersection{wxDocManager::SetMaxDocsOpen
}\label{wxdocmanagersetmaxdocsopen
}
471 \func{void
}{SetMaxDocsOpen
}{\param{int
}{ n
}}
473 Sets the maximum number of documents that can be open at a time. By default, this
474 is
10,
000. If you set it to
1, existing documents will be saved and deleted
475 when the user tries to open or create a new one (similar to the behaviour
476 of Windows Write, for example). Allowing multiple documents gives behaviour
477 more akin to MS Word and other Multiple Document Interface applications.