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
}
14 \helpref{wxDocManager overview
}{wxdocmanageroverview
},
\helpref{wxDocument
}{wxdocument
},
\rtfsp
15 \helpref{wxView
}{wxview
},
\helpref{wxDocTemplate
}{wxdoctemplate
},
\helpref{wxFileHistory
}{wxfilehistory
}
17 \latexignore{\rtfignore{\wxheading{Members
}}}
19 \membersection{wxDocManager::m
\_currentView}
21 \member{wxView*
}{m
\_currentView}
23 The currently active view.
25 \membersection{wxDocManager::m
\_defaultDocumentNameCounter}
27 \member{int
}{m
\_defaultDocumentNameCounter}
29 Stores the integer to be used for the next default
document name.
31 \membersection{wxDocManager::m
\_fileHistory}
33 \member{wxFileHistory*
}{m
\_fileHistory}
35 A pointer to an instance of
\helpref{wxFileHistory
}{wxfilehistory
},
36 which manages the history of recently-visited files on the File menu.
38 \membersection{wxDocManager::m
\_maxDocsOpen}
40 \member{int
}{m
\_maxDocsOpen}
42 Stores the maximum number of documents that can be opened before
43 existing documents are closed. By default, this is
10,
000.
45 \membersection{wxDocManager::m
\_docs}
47 \member{wxList
}{m
\_docs}
49 A list of all documents.
51 \membersection{wxDocManager::m
\_flags}
53 \member{long
}{m
\_flags}
55 Stores the flags passed to the constructor.
57 \membersection{wxDocManager::m
\_templates}
59 \member{wxList
}{mnTemplates
}
61 A list of all
document templates.
63 \membersection{wxDocManager::wxDocManager
}
65 \func{void
}{wxDocManager
}{\param{long
}{ flags = wxDEFAULT
\_DOCMAN\_FLAGS},
\param{bool
}{ initialize = TRUE
}}
67 Constructor. Create a
document manager instance dynamically near the start of your application
68 before doing any
document or view operations.
70 {\it flags
} is currently unused.
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.
77 \membersection{wxDocManager::
\destruct{wxDocManager
}}
79 \func{void
}{\destruct{wxDocManager
}}{\void}
83 \membersection{wxDocManager::ActivateView
}
85 \func{void
}{ActivateView
}{\param{wxView*
}{doc
},
\param{bool
}{ activate
},
\param{bool
}{ deleting
}}
87 Sets the current view.
89 \membersection{wxDocManager::AddDocument
}
91 \func{void
}{AddDocument
}{\param{wxDocument *
}{doc
}}
93 Adds the
document to the list of documents.
95 \membersection{wxDocManager::AddFileToHistory
}
97 \func{void
}{AddFileToHistory
}{\param{const wxString\&
}{filename
}}
99 Adds a file to the file history list, if we have a pointer to an appropriate file menu.
101 \membersection{wxDocManager::AssociateTemplate
}
103 \func{void
}{AssociateTemplate
}{\param{wxDocTemplate *
}{temp
}}
105 Adds the template to the
document manager's template list.
107 \membersection{wxDocManager::CreateDocument
}
109 \func{wxDocument*
}{CreateDocument
}{\param{const wxString\&
}{path
},
\param{long
}{ flags
}}
111 Creates a new
document in a manner determined by the
{\it flags
} parameter, which can be:
113 \begin{itemize
}\itemsep=
0pt
114 \item wxDOC
\_NEW Creates a fresh
document.
115 \item wxDOC
\_SILENT Silently loads the given
document file.
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).
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.
128 \membersection{wxDocManager::CreateView
}
130 \func{wxView*
}{CreateView
}{\param{wxDocument*
}{doc
},
\param{long
}{ flags
}}
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.
136 \membersection{wxDocManager::DisassociateTemplate
}
138 \func{void
}{DisassociateTemplate
}{\param{wxDocTemplate *
}{temp
}}
140 Removes the template from the list of templates.
142 \membersection{wxDocManager::FileHistoryAddFilesToMenu
}\label{wxdocmanagerfilehistoryaddfilestomenu
}
144 \func{void
}{FileHistoryAddFilesToMenu
}{\void}
146 Appends the files in the history list, to all menus managed by the file history object.
148 \func{void
}{FileHistoryAddFilesToMenu
}{\param{wxMenu*
}{ menu
}}
150 Appends the files in the history list, to the given menu only.
152 \membersection{wxDocManager::FileHistoryLoad
}\label{wxdocmanagerfilehistoryload
}
154 \func{void
}{FileHistoryLoad
}{\param{wxConfigBase\&
}{config
}}
156 Loads the file history from a config object.
160 \helpref{wxConfig
}{wxconfigbase
}
162 \membersection{wxDocManager::FileHistoryRemoveMenu
}\label{wxdocmanagerfilehistoryremovemenu
}
164 \func{void
}{FileHistoryRemoveMenu
}{\param{wxMenu*
}{ menu
}}
166 Removes the given menu from the list of menus managed by the file history object.
168 \membersection{wxDocManager::FileHistorySave
}\label{wxdocmanagerfilehistorysave
}
170 \func{void
}{FileHistorySave
}{\param{wxConfigBase\&
}{resourceFile
}}
172 Saves the file history into a config object. This must be called
173 explicitly by the application.
177 \helpref{wxConfig
}{wxconfigbase
}
179 \membersection{wxDocManager::FileHistoryUseMenu
}\label{wxdocmanagerfilehistoryusemenu
}
181 \func{void
}{FileHistoryUseMenu
}{\param{wxMenu*
}{ menu
}}
183 Use this menu for appending recently-visited
document filenames, for convenient
184 access. Calling this function with a valid menu pointer enables the history
187 Note that you can add multiple menus using this function, to be managed by the
190 \membersection{wxDocManager::FindTemplateForPath
}
192 \func{wxDocTemplate *
}{FindTemplateForPath
}{\param{const wxString\&
}{path
}}
194 Given a path, try to find template that matches the extension. This is only
195 an approximate method of finding a template for creating a
document.
197 \membersection{wxDocManager::GetCurrentDocument
}
199 \func{wxDocument *
}{GetCurrentDocument
}{\void}
201 Returns the
document associated with the currently active view (if any).
203 \membersection{wxDocManager::GetCurrentView
}
205 \func{wxView *
}{GetCurrentView
}{\void}
207 Returns the currently active view
209 \membersection{wxDocManager::GetDocuments
}
211 \func{wxList\&
}{GetDocuments
}{\void}
213 Returns a reference to the list of documents.
215 \membersection{wxDocManager::GetFileHistory
}
217 \func{wxFileHistory *
}{GetFileHistory
}{\void}
219 Returns a pointer to file history.
221 \membersection{wxDocManager::GetMaxDocsOpen
}
223 \func{int
}{GetMaxDocsOpen
}{\void}
225 Returns the number of documents that can be open simultaneously.
227 \membersection{wxDocManager::GetNoHistoryFiles
}
229 \func{int
}{GetNoHistoryFiles
}{\void}
231 Returns the number of files currently stored in the file history.
233 \membersection{wxDocManager::Initialize
}\label{wxdocmanagerinitialize
}
235 \func{bool
}{Initialize
}{\void}
237 Initializes data; currently just calls OnCreateFileHistory. Some data cannot
238 always be initialized in the constructor because the programmer must be given
239 the opportunity to override functionality. If OnCreateFileHistory was called
240 from the constructor, an overridden virtual OnCreateFileHistory would not be
241 called due to C++'s `interesting' constructor semantics. In fact Initialize
242 \rtfsp{\it is
} called from the wxDocManager constructor, but this can be
243 vetoed by passing FALSE to the second argument, allowing the derived class's
244 constructor to call Initialize, possibly calling a different OnCreateFileHistory
247 The bottom line: if you're not deriving from Initialize, forget it and
248 construct wxDocManager with no arguments.
250 \membersection{wxDocManager::MakeDefaultName
}
252 \func{bool
}{MakeDefaultName
}{\param{const wxString\&
}{buf
}}
254 Copies a suitable default name into
{\it buf
}. This is implemented by
255 appending an integer counter to the string
{\bf unnamed
} and incrementing
258 \membersection{wxDocManager::OnCreateFileHistory
}
260 \func{wxFileHistory *
}{OnCreateFileHistory
}{\void}
262 A hook to allow a derived class to create a different type of file history. Called
263 from
\helpref{Initialize
}{wxdocmanagerinitialize
}.
265 \membersection{wxDocManager::OnFileClose
}
267 \func{void
}{OnFileClose
}{\void}
269 Closes and deletes the currently active
document.
271 \membersection{wxDocManager::OnFileNew
}
273 \func{void
}{OnFileNew
}{\void}
275 Creates a
document from a list of templates (if more than one template).
277 \membersection{wxDocManager::OnFileOpen
}
279 \func{void
}{OnFileOpen
}{\void}
281 Creates a new
document and reads in the selected file.
283 \membersection{wxDocManager::OnFileSave
}
285 \func{void
}{OnFileSave
}{\void}
287 Saves the current
document by calling wxDocument::Save for the current
document.
289 \membersection{wxDocManager::OnFileSaveAs
}
291 \func{void
}{OnFileSaveAs
}{\void}
293 Calls wxDocument::SaveAs for the current
document.
295 \membersection{wxDocManager::OnMenuCommand
}
297 \func{void
}{OnMenuCommand
}{\param{int
}{ cmd
}}
299 Processes menu commands routed from child or parent frames. This deals
300 with the following predefined menu item identifiers:
302 \begin{itemize
}\itemsep=
0pt
303 \item wxID
\_OPEN Creates a new
document and opens a file into it.
304 \item wxID
\_CLOSE Closes the current
document.
305 \item wxID
\_NEW Creates a new
document.
306 \item wxID
\_SAVE Saves the
document.
307 \item wxID
\_SAVE\_AS Saves the
document into a specified filename.
310 Unrecognized commands are routed to the currently active wxView's OnMenuCommand.
312 \membersection{wxDocManager::RemoveDocument
}
314 \func{void
}{RemoveDocument
}{\param{wxDocument *
}{doc
}}
316 Removes the
document from the list of documents.
318 \membersection{wxDocManager::SelectDocumentPath
}
320 \func{wxDocTemplate *
}{SelectDocumentPath
}{\param{wxDocTemplate **
}{templates
},
321 \param{int
}{ noTemplates
},
\param{const wxString\&
}{path
},
\param{const wxString\&
}{bufSize
},
322 \param{long
}{ flags
},
\param{bool
}{ save
}}
324 Under Windows, pops up a file selector with a list of filters corresponding to
document templates.
325 The wxDocTemplate corresponding to the selected file's extension is returned.
327 On other platforms, if there is more than one
document template a choice list is popped up,
328 followed by a file selector.
330 This function is used in wxDocManager::CreateDocument.
332 \membersection{wxDocManager::SelectDocumentType
}
334 \func{wxDocTemplate *
}{SelectDocumentType
}{\param{wxDocTemplate **
}{templates
},
335 \param{int
}{ noTemplates
}}
337 Returns a
document template by asking the user (if there is more than one template).
338 This function is used in wxDocManager::CreateDocument.
340 \membersection{wxDocManager::SelectViewType
}
342 \func{wxDocTemplate *
}{SelectViewType
}{\param{wxDocTemplate **
}{templates
},
343 \param{int
}{ noTemplates
}}
345 Returns a
document template by asking the user (if there is more than one template),
346 displaying a list of valid views. This function is used in wxDocManager::CreateView.
347 The dialog normally won't appear because the array of templates only contains
348 those relevant to the
document in question, and often there will only be one such.
350 \membersection{wxDocManager::SetMaxDocsOpen
}
352 \func{void
}{SetMaxDocsOpen
}{\param{int
}{ n
}}
354 Sets the maximum number of documents that can be open at a time. By default, this
355 is
10,
000. If you set it to
1, existing documents will be saved and deleted
356 when the user tries to open or create a new one (similar to the behaviour
357 of Windows Write, for example). Allowing multiple documents gives behaviour
358 more akin to MS Word and other Multiple Document Interface applications.