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{wxCore
}{librarieslist
}
33 \helpref{wxDocManager overview
}{wxdocmanageroverview
},
\helpref{wxDocument
}{wxdocument
},
\rtfsp
34 \helpref{wxView
}{wxview
},
\helpref{wxDocTemplate
}{wxdoctemplate
},
\helpref{wxFileHistory
}{wxfilehistory
}
36 \latexignore{\rtfignore{\wxheading{Members
}}}
39 \membersection{wxDocManager::m
\_currentView}\label{wxdocmanagermcreateview
}
41 \member{wxView*
}{m
\_currentView}
43 The currently active view.
46 \membersection{wxDocManager::m
\_defaultDocumentNameCounter}\label{wxdocmanagermdefaultdocumentnamecounter
}
48 \member{int
}{m
\_defaultDocumentNameCounter}
50 Stores the integer to be used for the next default
document name.
53 \membersection{wxDocManager::m
\_fileHistory}\label{wxdocmanagermfilehistory
}
55 \member{wxFileHistory*
}{m
\_fileHistory}
57 A pointer to an instance of
\helpref{wxFileHistory
}{wxfilehistory
},
58 which manages the history of recently-visited files on the File menu.
61 \membersection{wxDocManager::m
\_maxDocsOpen}\label{wxdocmanagermmaxdocsopen
}
63 \member{int
}{m
\_maxDocsOpen}
65 Stores the maximum number of documents that can be opened before
66 existing documents are closed. By default, this is
10,
000.
69 \membersection{wxDocManager::m
\_docs}\label{wxdocmanagermdocs
}
71 \member{wxList
}{m
\_docs}
73 A list of all documents.
76 \membersection{wxDocManager::m
\_flags}\label{wxdocmanagermflags
}
78 \member{long
}{m
\_flags}
80 Stores the flags passed to the constructor.
83 \membersection{wxDocManager::m
\_lastDirectory}\label{wxdocmanagermlastdirectory
}
85 The directory last selected by the user when opening a file.
87 \member{wxFileHistory*
}{m
\_fileHistory}
90 \membersection{wxDocManager::m
\_templates}\label{wxdocmanagermtemplates
}
92 \member{wxList
}{m
\_templates}
94 A list of all
document templates.
97 \membersection{wxDocManager::wxDocManager
}\label{wxdocmanagerctor
}
99 \func{}{wxDocManager
}{\param{long
}{ flags = wxDEFAULT
\_DOCMAN\_FLAGS},
\param{bool
}{ initialize = true
}}
101 Constructor. Create a
document manager instance dynamically near the start of your application
102 before doing any
document or view operations.
104 {\it flags
} is currently unused.
106 If
{\it initialize
} is true, the
\helpref{Initialize
}{wxdocmanagerinitialize
} function will be called
107 to create a default history list object. If you derive from wxDocManager, you may wish to call the
108 base constructor with false, and then call Initialize in your own constructor, to allow
109 your own Initialize or OnCreateFileHistory functions to be called.
112 \membersection{wxDocManager::
\destruct{wxDocManager
}}\label{wxdocmanagerdtor
}
114 \func{void
}{\destruct{wxDocManager
}}{\void}
119 \membersection{wxDocManager::ActivateView
}\label{wxdocmanageractivateview
}
121 \func{void
}{ActivateView
}{\param{wxView*
}{doc
},
\param{bool
}{ activate = true
}}
123 Sets the current view.
126 \membersection{wxDocManager::AddDocument
}\label{wxdocmanageradddocument
}
128 \func{void
}{AddDocument
}{\param{wxDocument *
}{doc
}}
130 Adds the
document to the list of documents.
133 \membersection{wxDocManager::AddFileToHistory
}\label{wxdocmanageraddfiletohistory
}
135 \func{void
}{AddFileToHistory
}{\param{const wxString\&
}{filename
}}
137 Adds a file to the file history list, if we have a pointer to an appropriate file menu.
140 \membersection{wxDocManager::AssociateTemplate
}\label{wxdocmanagerassociatetemplate
}
142 \func{void
}{AssociateTemplate
}{\param{wxDocTemplate *
}{temp
}}
144 Adds the template to the
document manager's template list.
147 \membersection{wxDocManager::CloseDocuments
}\label{wxdocmanagerclosedocuments
}
149 \func{bool
}{CloseDocuments
}{\param{bool
}{force = true
}}
151 Closes all currently opened documents.
154 \membersection{wxDocManager::CreateDocument
}\label{wxdocmanagercreatedocument
}
156 \func{wxDocument*
}{CreateDocument
}{\param{const wxString\&
}{path
},
\param{long
}{ flags
}}
158 Creates a new
document in a manner determined by the
{\it flags
} parameter, which can be:
160 \begin{itemize
}\itemsep=
0pt
161 \item wxDOC
\_NEW Creates a fresh
document.
162 \item wxDOC
\_SILENT Silently loads the given
document file.
165 If wxDOC
\_NEW is present, a new
document will be created and returned, possibly after
166 asking the user for a template to use if there is more than one
document template.
167 If wxDOC
\_SILENT is present, a new
document will be created and the given file loaded
168 into it. If neither of these flags is present, the user will be presented with
169 a file selector for the file to load, and the template to use will be determined by the
170 extension (Windows) or by popping up a template choice list (other platforms).
172 If the maximum number of documents has been reached, this function
173 will delete the oldest currently loaded
document before creating a new one.
176 \membersection{wxDocManager::CreateView
}\label{wxdocmanagercreateview
}
178 \func{wxView*
}{CreateView
}{\param{wxDocument*
}{doc
},
\param{long
}{ flags
}}
180 Creates a new view for the given
document. If more than one view is allowed for the
181 document (by virtue of multiple templates mentioning the same
document type), a choice
182 of view is presented to the user.
185 \membersection{wxDocManager::DisassociateTemplate
}\label{wxdocmanagerdisassociatetemplate
}
187 \func{void
}{DisassociateTemplate
}{\param{wxDocTemplate *
}{temp
}}
189 Removes the template from the list of templates.
192 \membersection{wxDocManager::FileHistoryAddFilesToMenu
}\label{wxdocmanagerfilehistoryaddfilestomenu
}
194 \func{void
}{FileHistoryAddFilesToMenu
}{\void}
196 Appends the files in the history list, to all menus managed by the file history object.
198 \func{void
}{FileHistoryAddFilesToMenu
}{\param{wxMenu*
}{ menu
}}
200 Appends the files in the history list, to the given menu only.
203 \membersection{wxDocManager::FileHistoryLoad
}\label{wxdocmanagerfilehistoryload
}
205 \func{void
}{FileHistoryLoad
}{\param{wxConfigBase\&
}{config
}}
207 Loads the file history from a config object.
211 \helpref{wxConfig
}{wxconfigbase
}
214 \membersection{wxDocManager::FileHistoryRemoveMenu
}\label{wxdocmanagerfilehistoryremovemenu
}
216 \func{void
}{FileHistoryRemoveMenu
}{\param{wxMenu*
}{ menu
}}
218 Removes the given menu from the list of menus managed by the file history object.
221 \membersection{wxDocManager::FileHistorySave
}\label{wxdocmanagerfilehistorysave
}
223 \func{void
}{FileHistorySave
}{\param{wxConfigBase\&
}{resourceFile
}}
225 Saves the file history into a config object. This must be called
226 explicitly by the application.
230 \helpref{wxConfig
}{wxconfigbase
}
233 \membersection{wxDocManager::FileHistoryUseMenu
}\label{wxdocmanagerfilehistoryusemenu
}
235 \func{void
}{FileHistoryUseMenu
}{\param{wxMenu*
}{ menu
}}
237 Use this menu for appending recently-visited
document filenames, for convenient
238 access. Calling this function with a valid menu pointer enables the history
241 Note that you can add multiple menus using this function, to be managed by the
245 \membersection{wxDocManager::FindTemplateForPath
}\label{wxdocmanagerfindtemplateforpath
}
247 \func{wxDocTemplate *
}{FindTemplateForPath
}{\param{const wxString\&
}{path
}}
249 Given a path, try to find template that matches the extension. This is only
250 an approximate method of finding a template for creating a
document.
253 \membersection{wxDocManager::GetCurrentDocument
}\label{wxdocmanagergetcurrentdocument
}
255 \func{wxDocument *
}{GetCurrentDocument
}{\void}
257 Returns the
document associated with the currently active view (if any).
260 \membersection{wxDocManager::GetCurrentView
}\label{wxdocmanagergetcurrentview
}
262 \func{wxView *
}{GetCurrentView
}{\void}
264 Returns the currently active view
267 \membersection{wxDocManager::GetDocuments
}\label{wxdocmanagergetdocuments
}
269 \func{wxList\&
}{GetDocuments
}{\void}
271 Returns a reference to the list of documents.
274 \membersection{wxDocManager::GetFileHistory
}\label{wxdocmanagergetfilehistory
}
276 \func{wxFileHistory *
}{GetFileHistory
}{\void}
278 Returns a pointer to file history.
281 \membersection{wxDocManager::GetLastDirectory
}\label{wxdocmanagergetlastdirectory
}
283 \constfunc{wxString
}{GetLastDirectory
}{\void}
285 Returns the directory last selected by the user when opening a file. Initially empty.
288 \membersection{wxDocManager::GetMaxDocsOpen
}\label{wxdocmanagergetmaxdocsopen
}
290 \func{int
}{GetMaxDocsOpen
}{\void}
292 Returns the number of documents that can be open simultaneously.
295 \membersection{wxDocManager::GetHistoryFilesCount
}\label{wxdocmanagergethistoryfilescount
}
297 \func{size
\_t}{GetHistoryFilesCount
}{\void}
299 Returns the number of files currently stored in the file history.
302 \membersection{wxDocManager::GetTemplates
}\label{wxdocmanagergettemplates
}
304 \func{wxList\&
}{GetTemplates
}{\void}
306 Returns a reference to the list of associated templates.
309 \membersection{wxDocManager::Initialize
}\label{wxdocmanagerinitialize
}
311 \func{bool
}{Initialize
}{\void}
313 Initializes data; currently just calls OnCreateFileHistory. Some data cannot
314 always be initialized in the constructor because the programmer must be given
315 the opportunity to override functionality. If OnCreateFileHistory was called
316 from the constructor, an overridden virtual OnCreateFileHistory would not be
317 called due to C++'s `interesting' constructor semantics. In fact Initialize
318 \rtfsp{\it is
} called from the wxDocManager constructor, but this can be
319 vetoed by passing false to the second argument, allowing the derived class's
320 constructor to call Initialize, possibly calling a different OnCreateFileHistory
323 The bottom line: if you're not deriving from Initialize, forget it and
324 construct wxDocManager with no arguments.
327 \membersection{wxDocManager::MakeNewDocumentName
}\label{wxdocmanagermakenewdocumentname
}
329 \func{wxString
}{MakeNewDocumentName
}{\void}
331 Return a string containing a suitable default name for a new
document. By
332 default this is implemented by appending an integer counter to the string
333 {\bf unnamed
} but can be overridden in the derived classes to do something more
337 \membersection{wxDocManager::OnCreateFileHistory
}\label{wxdocmanageroncreatefilehistory
}
339 \func{wxFileHistory *
}{OnCreateFileHistory
}{\void}
341 A hook to allow a derived class to create a different type of file history. Called
342 from
\helpref{Initialize
}{wxdocmanagerinitialize
}.
345 \membersection{wxDocManager::OnFileClose
}\label{wxdocmanageronfileclose
}
347 \func{void
}{OnFileClose
}{\param{wxCommandEvent\&
}{event
}}
349 Closes and deletes the currently active
document.
352 \membersection{wxDocManager::OnFileCloseAll
}\label{wxdocmanageronfilecloseall
}
354 \func{void
}{OnFileCloseAll
}{\param{wxCommandEvent\&
}{event
}}
356 Closes and deletes all the currently opened documents.
359 \membersection{wxDocManager::OnFileNew
}\label{wxdocmanageronfilenew
}
361 \func{void
}{OnFileNew
}{\param{wxCommandEvent\&
}{event
}}
363 Creates a
document from a list of templates (if more than one template).
366 \membersection{wxDocManager::OnFileOpen
}\label{wxdocmanageronfileopen
}
368 \func{void
}{OnFileOpen
}{\param{wxCommandEvent\&
}{event
}}
370 Creates a new
document and reads in the selected file.
373 \membersection{wxDocManager::OnFileRevert
}\label{wxdocmanageronfilerevert
}
375 \func{void
}{OnFileRevert
}{\param{wxCommandEvent\&
}{event
}}
377 Reverts the current
document by calling wxDocument::Revert for the current
document.
380 \membersection{wxDocManager::OnFileSave
}\label{wxdocmanageronfilesave
}
382 \func{void
}{OnFileSave
}{\param{wxCommandEvent\&
}{event
}}
384 Saves the current
document by calling wxDocument::Save for the current
document.
387 \membersection{wxDocManager::OnFileSaveAs
}\label{wxdocmanageronfilesaveas
}
389 \func{void
}{OnFileSaveAs
}{\param{wxCommandEvent\&
}{event
}}
391 Calls wxDocument::SaveAs for the current
document.
394 \membersection{wxDocManager::RemoveDocument
}\label{wxdocmanagerremovedocument
}
396 \func{void
}{RemoveDocument
}{\param{wxDocument *
}{doc
}}
398 Removes the
document from the list of documents.
401 \membersection{wxDocManager::SelectDocumentPath
}\label{wxdocmanagerselectdocumentpath
}
403 \func{wxDocTemplate *
}{SelectDocumentPath
}{\param{wxDocTemplate **
}{templates
},
404 \param{int
}{ noTemplates
},
\param{wxString\&
}{path
},
405 \param{long
}{ flags
},
\param{bool
}{ save
}}
407 Under Windows, pops up a file selector with a list of filters corresponding to
document templates.
408 The wxDocTemplate corresponding to the selected file's extension is returned.
410 On other platforms, if there is more than one
document template a choice list is popped up,
411 followed by a file selector.
413 This function is used in wxDocManager::CreateDocument.
415 \perlnote{In wxPerl
{\tt templates
} is a reference to a list of templates.
416 If you override this method in your
document manager it must return
418 (doctemplate, path) = My::DocManager->SelectDocumentPath( ... );
422 \membersection{wxDocManager::SelectDocumentType
}\label{wxdocmanagerselectdocumenttype
}
424 \func{wxDocTemplate *
}{SelectDocumentType
}{\param{wxDocTemplate **
}{templates
},
425 \param{int
}{ noTemplates
},
\param{bool
}{ sort=false
}}
427 Returns a
document template by asking the user (if there is more than one template).
428 This function is used in wxDocManager::CreateDocument.
430 \wxheading{Parameters
}
432 \docparam{templates
}{Pointer to an array of templates from which to choose a desired template.
}
433 \docparam{noTemplates
}{Number of templates being pointed to by the
{\it templates
} pointer.
}
434 \docparam{sort
}{If more than one template is passed in in
{\it templates
},
435 then this parameter indicates whether the list of templates that the user
436 will have to choose from is sorted or not when shown the choice box dialog.
439 \perlnote{In wxPerl
{\tt templates
} is a reference to a list of templates.
}
442 \membersection{wxDocManager::SelectViewType
}\label{wxdocmanagerselectviewtype
}
444 \func{wxDocTemplate *
}{SelectViewType
}{\param{wxDocTemplate **
}{templates
},
445 \param{int
}{ noTemplates
},
\param{bool
}{ sort=false
}}
447 Returns a
document template by asking the user (if there is more than one template),
448 displaying a list of valid views. This function is used in wxDocManager::CreateView.
449 The dialog normally will not appear because the array of templates only contains
450 those relevant to the
document in question, and often there will only be one such.
452 \wxheading{Parameters
}
454 \docparam{templates
}{Pointer to an array of templates from which to choose a desired template.
}
455 \docparam{noTemplates
}{Number of templates being pointed to by the
{\it templates
} pointer.
}
456 \docparam{sort
}{If more than one template is passed in in
{\it templates
},
457 then this parameter indicates whether the list of templates that the user
458 will have to choose from is sorted or not when shown the choice box dialog.
461 \perlnote{In wxPerl
{\tt templates
} is a reference to a list of templates.
}
464 \membersection{wxDocManager::SetLastDirectory
}\label{wxdocmanagersetlastdirectory
}
466 \func{void
}{SetLastDirectory
}{\param{const wxString\&
}{ dir
}}
468 Sets the directory to be displayed to the user when opening a file. Initially this is empty.
471 \membersection{wxDocManager::SetMaxDocsOpen
}\label{wxdocmanagersetmaxdocsopen
}
473 \func{void
}{SetMaxDocsOpen
}{\param{int
}{ n
}}
475 Sets the maximum number of documents that can be open at a time. By default, this
476 is
10,
000. If you set it to
1, existing documents will be saved and deleted
477 when the user tries to open or create a new one (similar to the behaviour
478 of Windows Write, for example). Allowing multiple documents gives behaviour
479 more akin to MS Word and other Multiple Document Interface applications.