#include <doccom.h>


Public Member Functions | |
| a2dDocumentCommandProcessor (long flags=a2dDEFAULT_DOCUMENT_FLAGS, bool initialize=true, int maxCommands=-1) | |
| Constructor. | |
| a2dDocumentCommandProcessor (a2dDocumentCommandProcessor *other) | |
| construct and initilize based on other. | |
| ~a2dDocumentCommandProcessor () | |
| destructor | |
| void | OnMenu (wxCommandEvent &event) |
| All menu's a2dMenuIdItem using can be intercepted here. | |
| virtual void | OnExit () |
| Called by Exit(). | |
| virtual void | Initialize () |
| Initializes data; currently just calls OnCreateFileHistory. | |
| virtual bool | SubmitToDocument (a2dCommand *command, bool storeIt=true) |
| redirect the command to the current document ( if available ) | |
| bool | FileClose (bool force=true) |
| Closes and deletes the currently active document unless Close was vetod. | |
| a2dError | FileNew (a2dDocumentPtr &doc, a2dTemplateFlagMask docTemplateFlags=a2dTemplateFlag::VISIBLE) |
| Creates a document from a list of templates (if more than one template). | |
| a2dError | FileOpen (a2dDocumentPtr &doc, const wxFileName &file=wxFileName(wxT("")), a2dTemplateFlagMask docTemplateFlags=a2dTemplateFlag::VISIBLE) |
| Creates a new document and reads in the selected file. | |
| a2dError | FilesOpen (const wxString &openPath=wxT(""), int dialogFlags=wxFD_MULTIPLE|wxFD_OPEN, a2dTemplateFlagMask docTemplateFlags=a2dTemplateFlag::VISIBLE) |
| open one or more files using a file dialog | |
| bool | FileRevert () |
| revert the current document to the non saved document on disk. | |
| bool | FileSave () |
| Saves the current document by calling wxDocument::Save for the current document. | |
| bool | FileSaveAs (const wxFileName &file=wxFileName(wxT("")), a2dDocumentFlagMask flags=a2dREFDOC_NON) |
| Calls wxDocument::SaveAs for the current document. | |
| bool | FileExport (const wxFileName &file=wxFileName(wxT("")), const wxString &description=wxT(""), a2dDocumentFlagMask flags=a2dREFDOC_NON) |
| Calls a2dDocument::Export for the current document. | |
| bool | FileImport (const wxFileName &file=wxFileName(wxT("")), const wxString &description=wxT(""), a2dDocumentFlagMask flags=a2dREFDOC_NON) |
| Calls a2dDocument::Import for the current document. | |
| bool | Print (a2dCommand *command) |
| print the current active view. | |
| bool | Preview (a2dCommand *command) |
| print preview of the current active view. | |
| bool | PrintSetup (a2dCommand *command) |
| printer setup the current active document or central command processor. | |
| void | OnCannotOpenDocument (a2dCommandEvent &event) |
| default handler when a file could not be opened | |
| virtual a2dError | CreateDocuments (const wxString &path, a2dDocumentFlagMask documentflags=a2dREFDOC_NON, a2dDocumentTemplate *wantedDocTemplate=NULL, int dialogflags=wxFD_OPEN, a2dTemplateFlagMask docTemplateFlags=a2dTemplateFlag::VISIBLE) |
| Creates new documents in a manner determined by the flags parameter, which can be:. | |
| a2dView * | AddDocumentCreateView (a2dDocument *newDoc, const wxString &viewTypeName=wxT(""), a2dDocumentFlagMask documentflags=a2dREFDOC_NEW, a2dTemplateFlagMask docTemplateFlags=a2dTemplateFlag::VISIBLE, a2dTemplateFlagMask viewTemplateFlags=a2dTemplateFlag::VISIBLE) |
| adds the given document, and creates a view for it. | |
| void | AddCreatedDocument (a2dDocument *newDoc, bool sentPreAddCreatedDocumentEvent=false, bool sentPostCreateDocumentEvent=false, a2dDocumentFlagMask documentflags=a2dREFDOC_NEW, a2dTemplateFlagMask docTemplateFlags=a2dTemplateFlag::VISIBLE) |
| add a in memory created document, but do not create a view. | |
| virtual a2dView * | CreateView (a2dDocument *doc, const wxString &viewTypeName=wxT(""), a2dDocumentFlagMask flags=a2dREFDOC_NON, a2dTemplateFlagMask viewTemplateFlags=a2dTemplateFlag::VISIBLE) |
| Creates a new view for the given document. | |
| void | ReleaseTemplate (a2dDocumentTemplate *temp, long flags=0) |
| remove/release a template | |
| virtual bool | FlushDoc (a2dDocument *doc) |
| a2dDocumentTemplate * | MatchTemplate (const wxString &path) |
| return template suitable for loading the file in path, using FindTemplateForPath. | |
| virtual a2dError | SelectDocumentPath (const a2dDocumentTemplateList &docTemplates, const wxString &path, a2dDocumentFlagMask flags, wxArrayString *selectedPaths, a2dDocumentTemplate **chosenTemplate, int dialogflags=wxFD_OPEN, a2dTemplateFlagMask docTemplateFlags=a2dTemplateFlag::VISIBLE, const a2dDocumentTemplate *preferedTemplate=NULL) |
| pops up a file selector with optional a list of filters | |
| virtual a2dDocumentTemplate * | SelectDocumentType (bool sort=false, a2dTemplateFlagMask docTemplateFlags=a2dTemplateFlag::VISIBLE) |
| Returns a document template by asking the user. | |
| virtual a2dDocumentTemplate * | FindTemplateForPath (const a2dDocumentTemplateList &docTemplates, const wxString &path, a2dTemplateFlagMask mask=a2dTemplateFlag::VISIBLE) |
| function used in CreateDocument() when a2dREFDOC_SILENT is used for creating it. | |
| virtual a2dViewTemplate * | SelectViewType (a2dDocument *doc, const a2dViewTemplateList &list, const wxString &viewTypeName=wxT(""), bool sort=false, a2dTemplateFlagMask viewTemplateFlags=a2dTemplateFlag::VISIBLE) |
| Returns a view template by asking the user. | |
| void | AssociateDocTemplate (a2dDocumentTemplate *temp) |
| add a reference to a a2dDocumentTemplate to the a2dDocumentTemplateList | |
| void | DisassociateDocTemplate (a2dDocumentTemplate *temp) |
| remove a reference to a a2dDocumentTemplate to the a2dDocumentTemplateList | |
| void | AssociateViewTemplate (a2dViewTemplate *temp) |
| add a reference to a a2dViewTemplate to the wxViewTemplateReflist | |
| void | DisassociateViewTemplate (a2dViewTemplate *temp) |
| remove a reference to a a2dViewTemplate to the wxViewTemplateReflist | |
| void | SetCurrentDocument (a2dDocument *document) |
| set the current document, only needed in cases | |
| a2dDocument * | GetCurrentDocument () const |
| Get the current Document, which is the document that was last accessed from a view. | |
| a2dCommandProcessor * | GetCurrentDocumentCommandProcessor () const |
| get the command processor of the current document. | |
| void | SetMaxDocsOpen (size_t n) |
| Sets the maximum number of documents that can be open at a time. | |
| size_t | GetMaxDocsOpen () const |
| Gets the maximum number of documents that can be open at a time. | |
| void | AddDocument (a2dDocument *doc) |
| Add a document to the manager's list. | |
| void | RemoveDocument (a2dDocument *doc) |
| remove a document from the manager's list | |
| bool | CloseDocuments (bool force=true) |
| closes all currently open documents | |
| bool | Clear (bool force=true) |
| Clear remaining documents and templates. | |
| bool | Exit (bool force=true) |
| Called to Exit the application properly. | |
| void | SetBusyExit (bool exitBusy) |
| bool | GetBusyExit () |
| return true if the application is bussy exiting. | |
| a2dView * | GetCurrentView () const |
| return the one that is active right now (e.g. has focus in case of a wxWindow), or NULL | |
| a2dView * | GetLastView () const |
| return the one that was last made active, or NULL if not available anymore. | |
| const a2dDocumentList & | GetDocuments () const |
| returns a reference to the a2dDocumentList, which contains all a2dDocument's that are open. | |
| const a2dDocumentTemplateList & | GetDocTemplates () |
| returns a reference to the a2dDocumentTemplateList, which contains all a2dDocumentTemplate's. | |
| const a2dViewTemplateList & | GetViewTemplates () |
| returns a reference to the a2dViewTemplateList, which contains all a2dViewTemplate's. | |
| virtual bool | MakeDefaultName (wxString &buf) |
| Make a default document name. | |
| virtual wxString | MakeFrameTitle (a2dDocument *doc, const wxString &modifiedIndicator=wxT("")) |
| Make a frame title (override this to do something different). | |
| virtual a2dFileHistory * | OnCreateFileHistory () |
| A hook to allow a derived class to create a different type of file history. Called from Initialize. | |
| virtual a2dFileHistory * | GetFileHistory () const |
| returns a pointer to the file history list | |
| virtual void | AddFileToHistory (const wxFileName &file, a2dDocumentTemplate *docTemplate=NULL, a2dViewTemplate *viewTemplate=NULL) |
| File history management. | |
| virtual void | RemoveFileFromHistory (size_t i) |
| Remove a file from history. | |
| virtual size_t | GetHistoryFilesCount () const |
| Return number fo files in history. | |
| virtual a2dFileHistoryItem * | GetHistoryFileItem (size_t i) const |
| return the a2dFileHistoryItem of the i'th file in the history | |
| virtual wxString | GetHistoryFile (size_t i) const |
| return the filename of the i'th file in the history | |
| virtual void | FileHistoryUseMenu (wxMenu *menu) |
| Use this menu for appending recently-visited document filenames,. | |
| virtual void | FileHistoryRemoveMenu (wxMenu *menu) |
| Removes the given menu from the list of menus managed by the file history object. | |
| virtual void | FileHistoryAddFilesToMenu () |
| Appends the files in the history list, to all menus managed by the file history object. | |
| virtual void | FileHistoryAddFilesToMenu (wxMenu *menu) |
| Appends the files in the history list, to the given menu only. | |
| wxString | GetLastDirectory () const |
| Gets the directory to be displayed to the user when opening a file. Initially this is empty. | |
| void | SetLastDirectory (const wxString &dir) |
| Sets the directory to be displayed to the user when opening a file. Initially this is empty. | |
| void | SetActiveView (a2dView *view) |
| called when a a2dView is activate or deacivated. | |
| void | CheckCurrentLastView (a2dView *view) |
| Views do inform the document manager when a view will be destroyed. | |
| wxPageSetupData * | GetPageSetupData (void) const |
| void | SetPageSetupData (const wxPageSetupData &pageSetupData) |
| virtual bool | ProcessEvent (wxEvent &event) |
| void | SetUndo (bool withUndo) |
| set undo storage or not | |
| bool | GetUndo () |
| get undo storage setting | |
Protected Member Functions | |
| void | OnUndo (wxCommandEvent &event) |
| default handler for GUI event with id wxID_UNDO | |
| void | OnRedo (wxCommandEvent &event) |
| default handler for GUI event with id wxID_REDO | |
| void | OnUpdateFileOpen (wxUpdateUIEvent &event) |
| Handlers for UI update commands. | |
| void | OnUpdateFileClose (wxUpdateUIEvent &event) |
| Handlers for UI update commands. | |
| void | OnUpdateFileRevert (wxUpdateUIEvent &event) |
| Handlers for UI update commands. | |
| void | OnUpdateFileNew (wxUpdateUIEvent &event) |
| Handlers for UI update commands. | |
| void | OnUpdateFileSave (wxUpdateUIEvent &event) |
| Handlers for UI update commands. | |
| void | OnUpdateFileSaveAs (wxUpdateUIEvent &event) |
| Handlers for UI update commands. | |
| void | OnUpdateUndo (wxUpdateUIEvent &event) |
| Handlers for UI update commands. | |
| void | OnUpdateRedo (wxUpdateUIEvent &event) |
| Handlers for UI update commands. | |
| void | OnUpdatePrint (wxUpdateUIEvent &event) |
| Handlers for UI update commands. | |
| void | OnUpdatePrintSetup (wxUpdateUIEvent &event) |
| Handlers for UI update commands. | |
| void | OnUpdatePreview (wxUpdateUIEvent &event) |
| Handlers for UI update commands. | |
| void | OnActivateView (a2dViewEvent &viewevent) |
| Views do inform the document manager. | |
| void | OnRemoveView (a2dDocumentEvent &viewevent) |
| Views do inform the document manager when a view will be removed. | |
| void | OnAddView (a2dDocumentEvent &docevent) |
| It works when a2dView::SetDocument() executing. | |
Protected Attributes | |
| long | m_flags |
| user flags use at will ( not used internal ) | |
| int | m_defaultDocumentNameCounter |
| to create unique new names for file | |
| size_t | m_maxDocsOpen |
| the maximum of documents allowed open | |
| a2dDocumentList | m_docs |
| list of all that are open | |
| a2dDocumentTemplateList | m_docTemplates |
| templates for documents | |
| a2dViewTemplateList | m_viewTemplates |
| templates for views | |
| a2dView * | m_currentView |
| the current active view | |
| a2dDocument * | m_currentDocument |
| the current active document | |
| a2dView * | m_lastView |
| the view that was last active | |
| a2dFileHistory * | m_fileHistory |
| the file history | |
| wxString | m_lastDirectory |
| the last visited directory | |
| bool | m_withUndo |
| if set, for commands which can undo, will be submitted like that. | |
| bool | m_busyExit |
| set when terminating application | |
| wxPageSetupData * | m_pageSetupData |
| this is the global printer page setup data for printer | |
Events not handled by a a2dDocumentFrame or derived class, are redirected to this class Events in the Application Child frames are also routed to the Parent Frame and from there to this class. This is convenient for combining the event table that is used for menu's in child as well as parent frames.
The a2dDocumentCommandProcessor class is part of the document/view framework supported by wxDocview, and cooperates with the a2dView, a2dDocument, a2dDocumentTemplate, a2dViewTemplate and a2dViewConnector classes.
All open documents and templates are maintained here, and functions to open new documents and views ( via its templates ), are setup from within this class. As such it is the communication class within the docview framework.
It is derived from a2dCommandProcessor, in order to use it as a command interpreter. Although not so much for Undo and Redo in this case. Much more to have a in between level for the Graphical User Interfaces and the commands that open up new documents and views. Defining your own docview commands in a derived a2dDocumentCommandProcessor, makes it easy to implement macro recording to a file, and replay the same macro from a file. Calling all member function of a2dDocumentCommandProcessor directly from the GUI, would make this impractible. So by issueing commands through the Submit() function, you will have a central point for calling member functions on the a2dDocumentCommandProcessor. But you are still free to call all member function directly.
Definition at line 251 of file doccom.h.
| a2dDocumentCommandProcessor::a2dDocumentCommandProcessor | ( | long | flags = a2dDEFAULT_DOCUMENT_FLAGS, |
|
| bool | initialize = true, |
|||
| int | maxCommands = -1 | |||
| ) |
Constructor.
Create a document manager instance dynamically near the start of your application before doing any document or view operations.
| flags | is currently unused. | |
| initialize | if true, the Initialize function will be called to create a default history list object. If you derive from a2dDocumentCommandProcessor, 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. | |
| maxCommands | maximum of commands on the command stack, default -1 is unlimited. |
| void a2dDocumentCommandProcessor::OnExit | ( | ) | [virtual] |
Called by Exit().
Use e.g. to clean up modeless dialogs created from here.
It is common practice to create ( via commands to this class ) tool dialogs, color dialogs modeless, meaning without parent window. You can use this central command processor as owner of such dialogs, by just storing them in a derived commands processor. The trick is to destroy those dialogs when the application terminates. Implementing this can be done by overriding this function here.
Reimplemented in a2dCentralEditorCommandProcessor.
Definition at line 387 of file doccom.cpp.
| void a2dDocumentCommandProcessor::Initialize | ( | ) | [virtual] |
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.
Reimplemented from a2dCommandProcessor.
Definition at line 391 of file doccom.cpp.
| a2dError a2dDocumentCommandProcessor::FileOpen | ( | a2dDocumentPtr & | doc, | |
| const wxFileName & | file = wxFileName( wxT("") ), |
|||
| a2dTemplateFlagMask | docTemplateFlags = a2dTemplateFlag::VISIBLE | |||
| ) |
Creates a new document and reads in the selected file.
CreateDocument() is called with an empty string as path, and therefore a filedialog will be displayed, including the filters from templates, and you need to choose a file like that. If file is not empty, the file will silently be opened, using the right template based on file extension or template IoHandler.
| doc | returns pointer to document in smart pointer. | |
| file | specification for the file to load | |
| docTemplateFlags | flags for templates, default visible templates. |
Definition at line 520 of file doccom.cpp.
| a2dError a2dDocumentCommandProcessor::FilesOpen | ( | const wxString & | openPath = wxT(""), |
|
| int | dialogFlags = wxFD_MULTIPLE | wxFD_OPEN, |
|||
| a2dTemplateFlagMask | docTemplateFlags = a2dTemplateFlag::VISIBLE | |||
| ) |
open one or more files using a file dialog
| openPath | default path to open the file dialog in. | |
| dialogFlags | flags for file dialog | |
| docTemplateFlags | flags for templates, default visible templates. |
Definition at line 575 of file doccom.cpp.
| bool a2dDocumentCommandProcessor::FileRevert | ( | ) |
revert the current document to the non saved document on disk.
Currently call Revert() on current document.
Definition at line 602 of file doccom.cpp.
| bool a2dDocumentCommandProcessor::FileSaveAs | ( | const wxFileName & | file = wxFileName( wxT("") ), |
|
| a2dDocumentFlagMask | flags = a2dREFDOC_NON | |||
| ) |
Calls wxDocument::SaveAs for the current document.
This to save a document to a file of the same type it was created with.
| file | specification for the file to saveas | |
| flags | document flags e.g. a2dREFDOC_SILENT does not show dialog first. |
Definition at line 620 of file doccom.cpp.
| bool a2dDocumentCommandProcessor::FileExport | ( | const wxFileName & | file = wxFileName( wxT("") ), |
|
| const wxString & | description = wxT(""), |
|||
| a2dDocumentFlagMask | flags = a2dREFDOC_NON | |||
| ) |
Calls a2dDocument::Export for the current document.
This to export a document to a file of the chosen type.
| file | specification for the file to export , no description means use file extension, if empty file path ask user. | |
| description | description of a2dDocumentTemplate to use, if empty use filename ext to search template. | |
| flags | for way of export a2dREFDOC_SILENT for saving without filedialog |
Definition at line 638 of file doccom.cpp.
| bool a2dDocumentCommandProcessor::FileImport | ( | const wxFileName & | file = wxFileName( wxT("") ), |
|
| const wxString & | description = wxT(""), |
|||
| a2dDocumentFlagMask | flags = a2dREFDOC_NON | |||
| ) |
Calls a2dDocument::Import for the current document.
This to import into the current document the data stored in a file.
| file | specification for the file to import , no description means use file extension, if empty file path ask user. | |
| description | description of a2dDocumentTemplate to use, if empty use filename ext to search template. | |
| flags | for way of export a2dREFDOC_SILENT for saving without filedialog |
Definition at line 671 of file doccom.cpp.
| void a2dDocumentCommandProcessor::OnCannotOpenDocument | ( | a2dCommandEvent & | event | ) |
default handler when a file could not be opened
The document is already created, and it depends on the document its a2dDocument::OnOpenDocument() how much of the wrong file is stored in it. When nothing is done, to store this document here in the command processor, it will automatically be released on return from this event. If you decide to display what has bin stored in the doc sofar, it can be done here.
The default implementation closes all views that were created on the document, delete its contents, and generates an error log.
Definition at line 816 of file doccom.cpp.
| a2dError a2dDocumentCommandProcessor::CreateDocuments | ( | const wxString & | path, | |
| a2dDocumentFlagMask | documentflags = a2dREFDOC_NON, |
|||
| a2dDocumentTemplate * | wantedDocTemplate = NULL, |
|||
| int | dialogflags = wxFD_OPEN, |
|||
| a2dTemplateFlagMask | docTemplateFlags = a2dTemplateFlag::VISIBLE | |||
| ) | [virtual] |
Creates new documents in a manner determined by the flags parameter, which can be:.
wxDOC_NEW Creates a fresh document.
wxDOC_SILENT Silently loads the given document file.
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, using the first template which fits the file format to read, either based on extension or on the iohandler of the template. See FindTemplateForPath().
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).
When a new document is created and added to the document list the event wxEVT_POST_CREATE_DOCUMENT is sent to the a2dDocumentTemplate::GetViewConnector() or if not set to a2dDocviewGlobals->GetEventDistributer(). It depends on the type of a2dViewConnector what happens, e.g one could create an a2dView instance of the type chosen by the user from a list of a2dViewTemplates. The actual a2dView is created by calling the a2dViewTemplate::CreateView(). And this last sents the wxEVT_POST_CREATE_VIEW event to the a2dViewConnector. And that is the time to set the created view into a a2dDocumentViewWindow and maybe create frames and windows first followed by setting the new view to one of its windows. Another possibility is that the a2dViewConnector does not create new views, but instead of that uses existing views. The things happing in responds to wxEVT_POST_CREATE_DOCUMENT, is what makes this docview framework flexible. Replacing the a2dViewConnector is in general enough to swicth from on type of application (MDI SDI etc. ) to another.
If the maximum number of documents has been reached, this function will delete the oldest currently loaded document before creating a new one.
| path | path to file in case of flags != wxDOC_NEW and flags == wxDOC_SILENT | |
| documentflags | Use at will | |
| wantedDocTemplate | if given, only use this template to create new documents | |
| dialogflags | if not a new document or creating silenet a document, this will be the flags towards the selection dialog | |
| docTemplateFlags | template mask for document template, to filter shown templates. |
Definition at line 824 of file doccom.cpp.
| a2dView * a2dDocumentCommandProcessor::AddDocumentCreateView | ( | a2dDocument * | newDoc, | |
| const wxString & | viewTypeName = wxT(""), |
|||
| a2dDocumentFlagMask | documentflags = a2dREFDOC_NEW, |
|||
| a2dTemplateFlagMask | docTemplateFlags = a2dTemplateFlag::VISIBLE, |
|||
| a2dTemplateFlagMask | viewTemplateFlags = a2dTemplateFlag::VISIBLE | |||
| ) |
adds the given document, and creates a view for it.
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.
| newDoc | document to add and for which to create a new view | |
| viewTypeName | is not empty, this type of view will be searched in the available templates | |
| documentflags | Use at will, default a2dREFDOC_NEW | |
| docTemplateFlags | template mask for document template, to filter shown templates. | |
| viewTemplateFlags | template mask for view template, to filter shown templates. |
Definition at line 1058 of file doccom.cpp.
| void a2dDocumentCommandProcessor::AddCreatedDocument | ( | a2dDocument * | newDoc, | |
| bool | sentPreAddCreatedDocumentEvent = false, |
|||
| bool | sentPostCreateDocumentEvent = false, |
|||
| a2dDocumentFlagMask | documentflags = a2dREFDOC_NEW, |
|||
| a2dTemplateFlagMask | docTemplateFlags = a2dTemplateFlag::VISIBLE | |||
| ) |
add a in memory created document, but do not create a view.
The first document template with the same GetDocumentTypeName() as the document, is set to the document. The sentPreAddCreatedDocumentEvent can be sent to the a2dViewConnector via the document template, to take an action before the new document is add to the document list. For instance to close other files or disconnect views to use them again for the new document. The sentPostCreateDocumentEvent should be sent to use the a2dViewConnector system to create new frames with views.
| newDoc | The document to be added. | |
| sentPreAddDocumentEvent | if true this event is sent to document template | |
| sentPostCreateDocumentEvent | if true this event is sent to document template | |
| documentflags | Use at will, default a2dREFDOC_NEW | |
| docTemplateFlags | template mask for document template, to filter shown templates. |
Definition at line 1068 of file doccom.cpp.
| a2dView * a2dDocumentCommandProcessor::CreateView | ( | a2dDocument * | doc, | |
| const wxString & | viewTypeName = wxT(""), |
|||
| a2dDocumentFlagMask | flags = a2dREFDOC_NON, |
|||
| a2dTemplateFlagMask | viewTemplateFlags = a2dTemplateFlag::VISIBLE | |||
| ) | [virtual] |
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.
| doc | document for which to create a new view | |
| viewTypeName | is not empty, this type of view will be searched in the available templates | |
| flags | Document flags | |
| mask | mask for views to show. |
Definition at line 1152 of file doccom.cpp.
| void a2dDocumentCommandProcessor::ReleaseTemplate | ( | a2dDocumentTemplate * | temp, | |
| long | flags = 0 | |||
| ) |
remove/release a template
Keep in mind that templates or reference counted and placed in smart pointer lists. So releasing it here, might keep it intact when placed/used somewhere else ( e.g. a2dViewConnector ).
Definition at line 1168 of file doccom.cpp.
| a2dError a2dDocumentCommandProcessor::SelectDocumentPath | ( | const a2dDocumentTemplateList & | docTemplates, | |
| const wxString & | path, | |||
| a2dDocumentFlagMask | flags, | |||
| wxArrayString * | selectedPaths, | |||
| a2dDocumentTemplate ** | chosenTemplate, | |||
| int | dialogflags = wxFD_OPEN, |
|||
| a2dTemplateFlagMask | docTemplateFlags = a2dTemplateFlag::VISIBLE, |
|||
| const a2dDocumentTemplate * | preferedTemplate = NULL | |||
| ) | [virtual] |
pops up a file selector with optional a list of filters
corresponding to the document templates to choose from.
Based on the list a2dDocumentTemplateList the list of file filters is setup. Next a file dialog is displayed, to select one or more file, depending on the dialogflags. In case of opening a file, it is checked for existence.
The file dialog opens in m_lastDirectory, unless path is specified, after that m_lastDirectory directory is set to the directory from which the file(s) were selected.
| docTemplates | the doctemplates which are used to present the file filters/types in the file dialog, and/or which are used to test the file chosen against. | |
| path | initial directory where the dialog should be opened | |
| flags | flags = a2dREFDOC_NON | |
| selectedPaths | the files choosen are stored in here | |
| chosenTemplate | The a2dDocumentTemplate corresponding to the selected file's extension/filter or its iohandler, is returned. | |
| dialogflags | may be a combination of wxFD_OPEN, wxFD_SAVE, wxFD_OVERWRITE_PROMPT, wxHIDE_READONLY, wxFD_FILE_MUST_EXIST. | |
| docTemplateFlags | use only templates matching this mask | |
| preferedTemplate | the template to show in the file selection dialog as default. |
Definition at line 1361 of file doccom.cpp.
| a2dDocumentTemplate * a2dDocumentCommandProcessor::SelectDocumentType | ( | bool | sort = false, |
|
| a2dTemplateFlagMask | docTemplateFlags = a2dTemplateFlag::VISIBLE | |||
| ) | [virtual] |
Returns a document template by asking the user.
(if there is more than one template). This function is used in a2dDocumentCommandProcessor::CreateDocument.
| sort | If more than one template then this parameter indicates whether the list of templates that the user will have to choose from is sorted or not when shown the choice box dialog. Default is false. | |
| docTemplateFlag | template filter |
Definition at line 1470 of file doccom.cpp.
| a2dDocumentTemplate * a2dDocumentCommandProcessor::FindTemplateForPath | ( | const a2dDocumentTemplateList & | docTemplates, | |
| const wxString & | path, | |||
| a2dTemplateFlagMask | mask = a2dTemplateFlag::VISIBLE | |||
| ) | [virtual] |
function used in CreateDocument() when a2dREFDOC_SILENT is used for creating it.
It iterates over the document templates, to find a template for the file that is to be loaded. To test each template it uses a2dDocumentTemplate::FileMatchesTemplate() The first matching template is returned. This is based on the file extension, or if not given on the input iohandler of a template, which can load the file.
| docTemplates | the templates to test the filepath against. | |
| path | input filename to an existing file, for which we want to find a template | |
| docTemplateFlag | template filter |
Definition at line 1321 of file doccom.cpp.
| a2dViewTemplate * a2dDocumentCommandProcessor::SelectViewType | ( | a2dDocument * | doc, | |
| const a2dViewTemplateList & | list, | |||
| const wxString & | viewTypeName = wxT(""), |
|||
| bool | sort = false, |
|||
| a2dTemplateFlagMask | viewTemplateFlags = a2dTemplateFlag::VISIBLE | |||
| ) | [virtual] |
Returns a view template by asking the user.
(if there is more than one template), displaying a list of valid views.
This function is used in a2dDocumentCommandProcessor::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.
a2dViewConnector::CreateView() also uses his function to present the templates a2dViewTemplate's associated with a a2dViewConnector, or if not to present all a2dViewTemplate from the a2dDocumentCommandProcessor itself.
| doc | the document to select a viewtype for. | |
| list | template list to choose a view template from | |
| viewTypeName | the name of the view, if empty a list is presented, else a check is done if the given name is indeed a view template. | |
| sort | If more than one template, then this parameter indicates whether the list of templates that the user will have to choose from is sorted or not when shown the choice box dialog. Default is false. | |
| mask | which view are allowed. |
Definition at line 1548 of file doccom.cpp.
| void a2dDocumentCommandProcessor::SetCurrentDocument | ( | a2dDocument * | document | ) |
set the current document, only needed in cases
where it was not set right already (rarely), and you need to have it set to be able to use a2dDocumentCommandProcessor to get to a document.
It also used internal, in order to sent the wxEVT_CHANGED_DOCUMENT event to the a2dEventDistributer. This event can be intercepted by other classes, when they need to know this.
Definition at line 1735 of file doccom.cpp.
| a2dDocument * a2dDocumentCommandProcessor::GetCurrentDocument | ( | ) | const |
Get the current Document, which is the document that was last accessed from a view.
The current document is the document that is set when: -When a view is activated (has focus in case of a wxWindow), via SetActive() -Last document added, but which does not have a view yet, via AddDocument() -When set from the outside with SetCurrentDocument()
When a a2dView is deactivated, and GetCurrentView() is set to NULL, the current document is not modified untill another/same view is activated. So you can still get to the document if the active view is deactivated. This happens for instance when a modeless dialog is activated.
also
Definition at line 1184 of file doccom.cpp.
| a2dCommandProcessor * a2dDocumentCommandProcessor::GetCurrentDocumentCommandProcessor | ( | ) | const |
get the command processor of the current document.
When the current document is set and it has a commandprocessor, this will be returned.
Definition at line 1192 of file doccom.cpp.
| void a2dDocumentCommandProcessor::SetMaxDocsOpen | ( | size_t | n | ) | [inline] |
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.
| void a2dDocumentCommandProcessor::AddDocument | ( | a2dDocument * | doc | ) |
Add a document to the manager's list.
The a2dCommandEvent of type wxEVT_ADD_DOCUMENT is sent to the a2dDocviewGlobals->GetEventDistributer(), this can be used to do some action after a new document is added. (e.g add to overview window of all open documents)
Definition at line 1664 of file doccom.cpp.
| void a2dDocumentCommandProcessor::RemoveDocument | ( | a2dDocument * | doc | ) |
remove a document from the manager's list
The a2dCommandEvent of type wxEVT_REMOVE_DOCUMENT is sent to the a2dDocviewGlobals->GetEventDistributer(), this can be used to do some action after a document is removed. (e.g remove from an overview window of all open documents)
Definition at line 1678 of file doccom.cpp.
| bool a2dDocumentCommandProcessor::CloseDocuments | ( | bool | force = true |
) |
closes all currently open documents
If force is true the closing of the document can not be vetod. If force is false only the documents which did not veto the close are Closed.
Definition at line 411 of file doccom.cpp.
| bool a2dDocumentCommandProcessor::Clear | ( | bool | force = true |
) |
Clear remaining documents and templates.
releases templates and documents, the documents are first closed, if vetod, the clearing of documents and templates is skipped, and return is false.
Definition at line 449 of file doccom.cpp.
| bool a2dDocumentCommandProcessor::Exit | ( | bool | force = true |
) |
Called to Exit the application properly.
Set m_busyExit, and next calls CleanUp() and Clear( true ).
One normally exits the main event loop (and the application) by deleting the top window. In that case this function is called automatically. But in case of a script command this function makes sure the top window is closed.
Definition at line 459 of file doccom.cpp.
| void a2dDocumentCommandProcessor::SetBusyExit | ( | bool | exitBusy | ) | [inline] |
| a2dView * a2dDocumentCommandProcessor::GetLastView | ( | ) | const |
return the one that was last made active, or NULL if not available anymore.
Use from modeless dialogs to get to view just before the dialog become active, and therefore the view inactive.
Definition at line 811 of file doccom.cpp.
| wxString a2dDocumentCommandProcessor::MakeFrameTitle | ( | a2dDocument * | doc, | |
| const wxString & | modifiedIndicator = wxT("") | |||
| ) | [virtual] |
Make a frame title (override this to do something different).
This method asks the document for its printable name and adds this and the application name to the returned string. If no document is given the returned string is the application name. The returned string will have a format like "Printable name - Application name"
| doc | The document to ask for the printable name or NULL | |
| modifiedIndicator | If set (i.e. a "*"), the indicator will be attached to the printable name if doc is modified |
Definition at line 1214 of file doccom.cpp.
| void a2dDocumentCommandProcessor::FileHistoryUseMenu | ( | wxMenu * | menu | ) | [virtual] |
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.
Definition at line 1272 of file doccom.cpp.
| void a2dDocumentCommandProcessor::SetActiveView | ( | a2dView * | view | ) |
called when a a2dView is activate or deacivated.
In general you will get two events, first for the view that is deactivated, and next for the new active view. m_currentView is set to the currently active view.
| view | if not NULL, the new active view is set to this view, else NULL. |
Definition at line 1693 of file doccom.cpp.
| void a2dDocumentCommandProcessor::CheckCurrentLastView | ( | a2dView * | view | ) |
Views do inform the document manager when a view will be destroyed.
The function sets the m_lastView and/or m_currentView to NULL, if eqaul to the view destroyed.
| view | if not NULL, set the m_lastView and/or m_currentView to NULL if equal view, else the m_lastView and m_currentView to NULL. |
Definition at line 1719 of file doccom.cpp.
| bool a2dDocumentCommandProcessor::ProcessEvent | ( | wxEvent & | event | ) | [virtual] |
process an event with a protection of repeated working in MDI by klion
| event | event that is to be processed by a2dDocumentCommandProcessor. |
Reimplemented from a2dEvtHandler.
Definition at line 1852 of file doccom.cpp.
| void a2dDocumentCommandProcessor::OnActivateView | ( | a2dViewEvent & | viewevent | ) | [protected] |
Views do inform the document manager.
when a view is (in) activated ( the window containing the view is in or out of focus ) The default handler sets the active view for the document manager. The current active view, is set to the last view which did sent an activate event with value true. If the view sending the event is the current and the event value is false, the current view is set to NULL. The last view that was m_currentView until now, is set inactive from here by calling a2dView::Activate().
Reimplemented in a2dCentralCanvasCommandProcessor.
Definition at line 1827 of file doccom.cpp.
| void a2dDocumentCommandProcessor::OnRemoveView | ( | a2dDocumentEvent & | viewevent | ) | [protected] |
Views do inform the document manager when a view will be removed.
The default handler sets the m_lastView and/or m_currentView to NULL, if eqaul to the view removed.
Definition at line 1841 of file doccom.cpp.