wxDocManagerThe wxDocManager class is part of the document/view framework supported by wxWidgets, and cooperates with the wxView, wxDocument and wxDocTemplate classes. Derived from Include files <wx/docview.h> See also wxDocManager overview, wxDocument, wxView, wxDocTemplate, wxFileHistory Members
wxDocManager::m_currentView
wxDocManager::m_currentViewwxView* m_currentView The currently active view.
wxDocManager::m_defaultDocumentNameCounterint m_defaultDocumentNameCounter Stores the integer to be used for the next default document name.
wxDocManager::m_fileHistorywxFileHistory* m_fileHistory A pointer to an instance of wxFileHistory, which manages the history of recently-visited files on the File menu.
wxDocManager::m_maxDocsOpenint m_maxDocsOpen Stores the maximum number of documents that can be opened before existing documents are closed. By default, this is 10,000.
wxDocManager::m_docswxList m_docs A list of all documents.
wxDocManager::m_flagslong m_flags Stores the flags passed to the constructor.
wxDocManager::m_lastDirectoryThe directory last selected by the user when opening a file. wxFileHistory* m_fileHistory
wxDocManager::m_templateswxList m_templates A list of all document templates.
wxDocManager::wxDocManagerwxDocManager(long flags = wxDEFAULT_DOCMAN_FLAGS, bool initialize = true) Constructor. Create a document manager instance dynamically near the start of your application before doing any document or view operations. flags is currently unused. If initialize is true, the Initialize function will be called to create a default history list object. If you derive from wxDocManager, you may wish to call the base constructor with false, and then call Initialize in your own constructor, to allow your own Initialize or OnCreateFileHistory functions to be called.
wxDocManager::~wxDocManagervoid ~wxDocManager() Destructor.
wxDocManager::ActivateViewvoid ActivateView(wxView* doc, bool activate = true) Sets the current view.
wxDocManager::AddDocumentvoid AddDocument(wxDocument *doc) Adds the document to the list of documents.
wxDocManager::AddFileToHistoryvoid AddFileToHistory(const wxString& filename) Adds a file to the file history list, if we have a pointer to an appropriate file menu.
wxDocManager::AssociateTemplatevoid AssociateTemplate(wxDocTemplate *temp) Adds the template to the document manager's template list.
wxDocManager::CloseDocumentsbool CloseDocuments(bool force = true) Closes all currently opened documents.
wxDocManager::CreateDocumentwxDocument* CreateDocument(const wxString& path, long flags) Creates a new document in a manner determined by the flags parameter, which can be:
If wxDOC_NEW is present, a new document will be created and returned, possibly after asking the user for a template to use if there is more than one document template. If wxDOC_SILENT is present, a new document will be created and the given file loaded into it. If neither of these flags is present, the user will be presented with a file selector for the file to load, and the template to use will be determined by the extension (Windows) or by popping up a template choice list (other platforms). If the maximum number of documents has been reached, this function will delete the oldest currently loaded document before creating a new one.
wxDocManager::CreateViewwxView* CreateView(wxDocument*doc, long flags) Creates a new view for the given document. If more than one view is allowed for the document (by virtue of multiple templates mentioning the same document type), a choice of view is presented to the user.
wxDocManager::DisassociateTemplatevoid DisassociateTemplate(wxDocTemplate *temp) Removes the template from the list of templates.
wxDocManager::FileHistoryAddFilesToMenuvoid FileHistoryAddFilesToMenu() Appends the files in the history list, to all menus managed by the file history object. void FileHistoryAddFilesToMenu(wxMenu* menu) Appends the files in the history list, to the given menu only.
wxDocManager::FileHistoryLoadvoid FileHistoryLoad(wxConfigBase& config) Loads the file history from a config object. See also
wxDocManager::FileHistoryRemoveMenuvoid FileHistoryRemoveMenu(wxMenu* menu) Removes the given menu from the list of menus managed by the file history object.
wxDocManager::FileHistorySavevoid FileHistorySave(wxConfigBase& resourceFile) Saves the file history into a config object. This must be called explicitly by the application. See also
wxDocManager::FileHistoryUseMenuvoid FileHistoryUseMenu(wxMenu* menu) Use this menu for appending recently-visited document filenames, for convenient access. Calling this function with a valid menu pointer enables the history list functionality. Note that you can add multiple menus using this function, to be managed by the file history object.
wxDocManager::FindTemplateForPathwxDocTemplate * FindTemplateForPath(const wxString& path) Given a path, try to find template that matches the extension. This is only an approximate method of finding a template for creating a document.
wxDocManager::GetCurrentDocumentwxDocument * GetCurrentDocument() Returns the document associated with the currently active view (if any).
wxDocManager::GetCurrentViewwxView * GetCurrentView() Returns the currently active view
wxDocManager::GetDocumentswxList& GetDocuments() Returns a reference to the list of documents.
wxDocManager::GetFileHistorywxFileHistory * GetFileHistory() Returns a pointer to file history.
wxDocManager::GetLastDirectorywxString GetLastDirectory() const Returns the directory last selected by the user when opening a file. Initially empty.
wxDocManager::GetMaxDocsOpenint GetMaxDocsOpen() Returns the number of documents that can be open simultaneously.
wxDocManager::GetHistoryFilesCountsize_t GetHistoryFilesCount() Returns the number of files currently stored in the file history.
wxDocManager::GetTemplateswxList& GetTemplates() Returns a reference to the list of associated templates.
wxDocManager::Initializebool Initialize() Initializes data; currently just calls OnCreateFileHistory. Some data cannot always be initialized in the constructor because the programmer must be given the opportunity to override functionality. If OnCreateFileHistory was called from the constructor, an overridden virtual OnCreateFileHistory would not be called due to C++'s 'interesting' constructor semantics. In fact Initialize is called from the wxDocManager constructor, but this can be vetoed by passing false to the second argument, allowing the derived class's constructor to call Initialize, possibly calling a different OnCreateFileHistory from the default. The bottom line: if you're not deriving from Initialize, forget it and construct wxDocManager with no arguments.
wxDocManager::MakeDefaultNamebool MakeDefaultName(const wxString& buf) This method is preserved for backwards compatibility in wxWidgets 2.8 but is renamed to MakeNewDocumentName in wxWidgets 3.0, please see its description for the details. This function simply copies the value returned by MakeNewDocumentName() into the provided buf and returns true. wxPerl note: In wxPerl this function must return the modified name rather than just modifying the argument.
wxDocManager::MakeNewDocumentNamewxString MakeNewDocumentName() Returns the name to be used for a new document. The default implementation appends an integer counter to the string unnamed and increments the counter. To customize this behaviour, you need to override the virtual MakeNewDocumentName method but if you only need to call this method, an not to override it, please use this method which is forward-compatible with wxWidgets 3.0. This function is new since wxWidgets version 2.8.8
wxDocManager::OnCreateFileHistorywxFileHistory * OnCreateFileHistory() A hook to allow a derived class to create a different type of file history. Called from Initialize.
wxDocManager::OnFileClosevoid OnFileClose(wxCommandEvent& event) Closes and deletes the currently active document.
wxDocManager::OnFileCloseAllvoid OnFileCloseAll(wxCommandEvent& event) Closes and deletes all the currently opened documents.
wxDocManager::OnFileNewvoid OnFileNew(wxCommandEvent& event) Creates a document from a list of templates (if more than one template).
wxDocManager::OnFileOpenvoid OnFileOpen(wxCommandEvent& event) Creates a new document and reads in the selected file.
wxDocManager::OnFileRevertvoid OnFileRevert(wxCommandEvent& event) Reverts the current document by calling wxDocument::Revert for the current document.
wxDocManager::OnFileSavevoid OnFileSave(wxCommandEvent& event) Saves the current document by calling wxDocument::Save for the current document.
wxDocManager::OnFileSaveAsvoid OnFileSaveAs(wxCommandEvent& event) Calls wxDocument::SaveAs for the current document.
wxDocManager::RemoveDocumentvoid RemoveDocument(wxDocument *doc) Removes the document from the list of documents.
wxDocManager::SelectDocumentPathwxDocTemplate * SelectDocumentPath(wxDocTemplate **templates, int noTemplates, wxString& path, long flags, bool save) Under Windows, pops up a file selector with a list of filters corresponding to document templates. The wxDocTemplate corresponding to the selected file's extension is returned. On other platforms, if there is more than one document template a choice list is popped up, followed by a file selector. This function is used in wxDocManager::CreateDocument. wxPerl note: In wxPerl templates is a reference to a list of templates. If you override this method in your document manager it must return two values, eg: (doctemplate, path) = My::DocManager->SelectDocumentPath( ... );
wxDocManager::SelectDocumentTypewxDocTemplate * SelectDocumentType(wxDocTemplate **templates, int noTemplates, bool sort=false) Returns a document template by asking the user (if there is more than one template). This function is used in wxDocManager::CreateDocument. Parameters templates
wxPerl note: In wxPerl templates is a reference to a list of templates.
wxDocManager::SelectViewTypewxDocTemplate * SelectViewType(wxDocTemplate **templates, int noTemplates, bool sort=false) Returns a document template by asking the user (if there is more than one template), displaying a list of valid views. This function is used in wxDocManager::CreateView. The dialog normally will not appear because the array of templates only contains those relevant to the document in question, and often there will only be one such. Parameters templates
wxPerl note: In wxPerl templates is a reference to a list of templates.
wxDocManager::SetLastDirectoryvoid SetLastDirectory(const wxString& dir) Sets the directory to be displayed to the user when opening a file. Initially this is empty.
wxDocManager::SetMaxDocsOpenvoid SetMaxDocsOpen(int n) Sets the maximum number of documents that can be open at a time. By default, this is 10,000. If you set it to 1, existing documents will be saved and deleted when the user tries to open or create a new one (similar to the behaviour of Windows Write, for example). Allowing multiple documents gives behaviour more akin to MS Word and other Multiple Document Interface applications.
|