00001 /*! \file wx/docview/doccom.h 00002 \brief Docview framework its controlling class 00003 00004 All classes in the document view framework are under control of the a2dDocumentCommandProcessor. 00005 It sents events to documents, templates classes for new document and views are stored here. 00006 At last the class is able to function as a central command processor for the whole framework. 00007 00008 \author Klaas Holwerda 00009 \date Created 05/07/03 00010 00011 Copyright: (c) 00012 00013 Licence: wxWidgets licence 00014 00015 RCS-ID: $Id: doccom.h,v 1.55 2009/09/26 19:01:04 titato Exp $ 00016 */ 00017 00018 #ifndef _WX_DOCCOMH__ 00019 #define _WX_DOCCOMH__ 00020 00021 #include "wx/cmdproc.h" 00022 00023 #if wxUSE_PRINTING_ARCHITECTURE 00024 #include "wx/paper.h" 00025 #include "wx/print.h" 00026 #endif 00027 00028 #include <wx/module.h> 00029 00030 #include <wx/general/genmod.h> 00031 #include <wx/docview.h> 00032 #include <wx/docview/docviewref.h> 00033 #include <wx/filedlg.h> 00034 00035 //! find a parent wxWindow pointer to place a control into 00036 extern wxWindow* wxFindSuitableParent(); 00037 00038 //! extra menu ideas for docview framework of wxDocview. 00039 enum 00040 { 00041 wxID_ART2D_LOWEST = 5300, /*!< reserved range within total range used by wxWindows */ 00042 }; 00043 00044 class A2DDOCVIEWDLLEXP a2dDocumentCommandProcessor; 00045 template class A2DDOCVIEWDLLEXP a2dSmrtPtr<a2dDocumentCommandProcessor>; 00046 00047 /********************************************** 00048 New events Document and View events. 00049 **********************************************/ 00050 BEGIN_DECLARE_EVENT_TYPES() 00051 //! see a2dCommandEvent \ingroup eventid 00052 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_ADD_DOCUMENT, 1 ) 00053 //! see a2dCommandEvent \ingroup eventid 00054 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_REMOVE_DOCUMENT, 1 ) 00055 //! see a2dCommandEvent \ingroup eventid 00056 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_CHANGED_DOCUMENT, 1 ) 00057 //! see a2dCommandEvent \ingroup eventid 00058 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_RECORD, 1 ) 00059 //! see a2dCommandEvent \ingroup eventid 00060 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_CANNOT_OPEN_DOCUMENT, 1 ) 00061 END_DECLARE_EVENT_TYPES() 00062 00063 //! Event sent to/from a2dDocumentCommandProcessor or a2dEventDistributer 00064 /*! 00065 - ::wxEVT_ADD_DOCUMENT is sent from a2dDocumentCommandProcessor when a document is added. 00066 - ::wxEVT_REMOVE_DOCUMENT is sent from a2dDocumentCommandProcessor when a document is removed. 00067 - ::wxEVT_CHANGED_DOCUMENT is sent from a2dDocumentCommandProcessor when the current document has changed. 00068 - ::wxEVT_DO is sent from a2dDocumentCommandProcessor or any other commandprocessor when a command is issued. 00069 - ::wxEVT_UNDO is sent from a2dDocumentCommandProcessor or any other commandprocessor when a command is issued. 00070 00071 - ::wxEVT_MENUSTRINGS is sent from a2dCommandProcessor when menu string need to be updated after a command. 00072 00073 - ::wxEVT_CANNOT_OPEN_DOCUMENT is sent by a2dDocumentCommandProcessor::CreateDocument() when a file could not be opened 00074 00075 \ingroup docview docviewevents 00076 */ 00077 class A2DDOCVIEWDLLEXP a2dCommandEvent : public a2dCommandProcessorEvent 00078 { 00079 00080 public: 00081 00082 //! constructor 00083 /*! 00084 type should be ::wxEVT_ADD_DOCUMENT or ::wxEVT_REMOVE_DOCUMENT or ::wxEVT_CHANGED_DOCUMENT 00085 */ 00086 a2dCommandEvent( wxEventType type, a2dDocument* doc ) 00087 : a2dCommandProcessorEvent( type, 0 ) 00088 { 00089 m_doc = doc; 00090 } 00091 00092 //! constructor 00093 /*! 00094 type should be ::wxEVT_MENUSTRINGS ::wxEVT_DO ::wxEVT_UNDO 00095 00096 For ::wxEVT_MENUSTRINGS, you can use the following function, to get the info to set the menu string. 00097 wxCommandProcessor::GetUndoMenuLabel() 00098 wxCommandProcessor::GetRedoMenuLabel() 00099 wxCommandProcessor::CanUndo() 00100 wxCommandProcessor::CanRedo() 00101 */ 00102 a2dCommandEvent( wxEventType type, a2dCommand* cmd, a2dDocument* doc = NULL ) 00103 : a2dCommandProcessorEvent( type, 0 ) 00104 { 00105 m_doc = doc; 00106 m_cmd = cmd; 00107 } 00108 00109 //! constructor 00110 /*! 00111 type ::wxEVT_MENUSTRINGS 00112 */ 00113 a2dCommandEvent( a2dCommand *cmd, 00114 const wxString& WXUNUSED(undoLabel), bool WXUNUSED(canUndo), 00115 const wxString& WXUNUSED(redoLabel), bool WXUNUSED(canRedo), 00116 a2dDocument* doc = NULL 00117 ) 00118 : a2dCommandProcessorEvent( wxEVT_MENUSTRINGS, 0 ) 00119 { 00120 m_doc = doc; 00121 m_cmd = cmd; 00122 } 00123 00124 //! constructor 00125 /*! 00126 type ::wxEVT_RECORD 00127 */ 00128 a2dCommandEvent( const wxString& record ) 00129 : a2dCommandProcessorEvent( wxEVT_RECORD, 0 ) 00130 { 00131 m_doc = NULL; 00132 m_cmd = NULL; 00133 m_record = record; 00134 } 00135 00136 //! constructor 00137 a2dCommandEvent(const a2dCommandEvent & event) 00138 : a2dCommandProcessorEvent(event) 00139 { 00140 m_doc = event.m_doc; 00141 m_cmd = event.m_cmd; 00142 m_record = event.m_record; 00143 } 00144 00145 //! clone the event. 00146 virtual wxEvent *Clone( bool WXUNUSED(deep) = true ) const { return new a2dCommandEvent(*this); } 00147 00148 //! the document created/removed or on which the command was applied. 00149 a2dDocument* GetDocument() { return m_doc; } 00150 00151 //! the command ( if there was one ) that did it. 00152 a2dCommand* GetCommand() { return m_cmd; } 00153 00154 wxString& GetRecord() { return m_record; } 00155 00156 private: 00157 00158 //! see GetDocument() 00159 a2dDocument* m_doc; 00160 00161 wxString m_record; 00162 }; 00163 00164 00165 //! internal event function for static event tables declaration 00166 typedef void (a2dEvtHandler::*a2dDocCommandProcessorEventFunction)(a2dCommandEvent&); 00167 //! internal event function for static event tables declaration 00168 typedef void (wxEvtHandler::*wxDocCommandProcessorEventFunction)(a2dCommandEvent&); 00169 00170 /*! \addtogroup eventhandlers 00171 * @{ 00172 */ 00173 00174 //! event sent to a2dDocumentCommandProcessor when a document has been added to the a2dDocumentCommandProcessor 00175 #define A2D_EVT_ADD_DOCUMENT(func) A2D_DECLARE_EVENT_TABLE_ENTRY( wxEVT_ADD_DOCUMENT, wxID_ANY, wxID_ANY, (a2dObjectEventFunction) static_cast< a2dDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ), 00176 //! event sent to a2dDocumentCommandProcessor when a document will be removed from the a2dDocumentCommandProcessor 00177 #define A2D_EVT_REMOVE_DOCUMENT(func) A2D_DECLARE_EVENT_TABLE_ENTRY( wxEVT_REMOVE_DOCUMENT, wxID_ANY, wxID_ANY, (a2dObjectEventFunction) static_cast< a2dDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ), 00178 //! event sent to a2dDocumentCommandProcessor when the current document has changed in the a2dDocumentCommandProcessor 00179 #define A2D_EVT_CHANGED_DOCUMENT(func) A2D_DECLARE_EVENT_TABLE_ENTRY( wxEVT_CHANGED_DOCUMENT, wxID_ANY, wxID_ANY, (a2dObjectEventFunction) static_cast< a2dDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ), 00180 //! event sent when a file could not be opened in the a2dDocumentCommandProcessor 00181 #define A2D_EVT_CANNOT_OPEN_DOCUMENT(func) A2D_DECLARE_EVENT_TABLE_ENTRY( wxEVT_CANNOT_OPEN_DOCUMENT, wxID_ANY, wxID_ANY, (a2dObjectEventFunction) static_cast< a2dDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ), 00182 //! event sent to a2dDocumentCommandProcessor when a document has been added to the a2dDocumentCommandProcessor 00183 #define A2D_EVT_RECORD(func) A2D_DECLARE_EVENT_TABLE_ENTRY( wxEVT_RECORD, wxID_ANY, wxID_ANY, (a2dObjectEventFunction) static_cast< a2dDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ), 00184 00185 00186 //! event sent to a2dDocumentCommandProcessor when a document has been added to the a2dDocumentCommandProcessor 00187 #define EVT_ADD_DOCUMENT(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_ADD_DOCUMENT, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ), 00188 //! event sent to a2dDocumentCommandProcessor when a document will be removed from the a2dDocumentCommandProcessor 00189 #define EVT_REMOVE_DOCUMENT(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_REMOVE_DOCUMENT, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ), 00190 //! event sent to a2dDocumentCommandProcessor when the current document has changed in the a2dDocumentCommandProcessor 00191 #define EVT_CHANGED_DOCUMENT(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_CHANGED_DOCUMENT, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ), 00192 //! event sent when a file could not be opened in the a2dDocumentCommandProcessor 00193 #define EVT_CANNOT_OPEN_DOCUMENT(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_CANNOT_OPEN_DOCUMENT, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ), 00194 //! event sent to a2dDocumentCommandProcessor when a document has been added to the a2dDocumentCommandProcessor 00195 #define EVT_RECORD(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_RECORD, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ), 00196 00197 00198 class A2DDOCVIEWDLLEXP a2dFileHistory; 00199 class A2DDOCVIEWDLLEXP a2dFileHistoryItem; 00200 00201 extern const a2dMenuIdItem CmdMenu_Exit; 00202 extern const a2dMenuIdItem CmdMenu_FileClose; 00203 extern const a2dMenuIdItem CmdMenu_FileOpen; 00204 extern const a2dMenuIdItem CmdMenu_FileNew; 00205 extern const a2dMenuIdItem CmdMenu_FileSave; 00206 extern const a2dMenuIdItem CmdMenu_FileSaveAs; 00207 extern const a2dMenuIdItem CmdMenu_FileImport; 00208 extern const a2dMenuIdItem CmdMenu_FileExport; 00209 extern const a2dMenuIdItem CmdMenu_FileRevert; 00210 extern const a2dMenuIdItem CmdMenu_Print; 00211 extern const a2dMenuIdItem CmdMenu_Preview; 00212 extern const a2dMenuIdItem CmdMenu_PrintView; 00213 extern const a2dMenuIdItem CmdMenu_PreviewView; 00214 extern const a2dMenuIdItem CmdMenu_PrintDocument; 00215 extern const a2dMenuIdItem CmdMenu_PreviewDocument; 00216 extern const a2dMenuIdItem CmdMenu_PrintSetup; 00217 extern const a2dMenuIdItem CmdMenu_EmptyDocument; 00218 00219 //! @} eventhandlers 00220 00221 //! One object of this class may be created in an application, to manage all the templates and documents. 00222 /*! 00223 Events not handled by a a2dDocumentFrame or derived class, are redirected to this class 00224 Events in the Application Child frames are also routed to the Parent Frame and from there 00225 to this class. 00226 This is convenient for combining the event table that is used for menu's in child as well as 00227 parent frames. 00228 00229 The a2dDocumentCommandProcessor class is part of the document/view framework supported by wxDocview, 00230 and cooperates with the a2dView, a2dDocument, a2dDocumentTemplate, a2dViewTemplate and 00231 a2dViewConnector classes. 00232 00233 All open documents and templates are maintained here, and functions to open new documents and views 00234 ( via its templates ), are setup from within this class. 00235 As such it is the communication class within the docview framework. 00236 00237 It is derived from a2dCommandProcessor, in order to use it as a command interpreter. 00238 Although not so much for Undo and Redo in this case. Much more to have a in between level for the 00239 Graphical User Interfaces and the commands that open up new documents and views. 00240 Defining your own docview commands in a derived a2dDocumentCommandProcessor, makes it easy 00241 to implement macro recording to a file, and replay the same macro from a file. 00242 Calling all member function of a2dDocumentCommandProcessor directly from the GUI, would make this 00243 impractible. 00244 So by issueing commands through the Submit() function, you will have a central point 00245 for calling member functions on the a2dDocumentCommandProcessor. But you are still free to call all member function 00246 directly. 00247 00248 \ingroup docview 00249 00250 */ 00251 class A2DDOCVIEWDLLEXP a2dDocumentCommandProcessor: public a2dCommandProcessor 00252 { 00253 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG) 00254 a2dInitCurrentSmartPointerOwner m_initCurrentSmartPointerOwner; 00255 #endif 00256 DECLARE_DYNAMIC_CLASS(a2dDocumentCommandProcessor) 00257 00258 A2D_DECLARE_EVENT_TABLE() 00259 00260 public: 00261 00262 //!Constructor. 00263 /*!Create a document manager instance dynamically near the start of your application 00264 before doing any document or view operations. 00265 00266 \param flags is currently unused. 00267 00268 \param initialize if true, the Initialize function will be called to create a default 00269 history list object. If you derive from a2dDocumentCommandProcessor, you may wish to call the base 00270 constructor with false, and then call Initialize in your own constructor, to allow your 00271 own Initialize or OnCreateFileHistory functions to be called. 00272 00273 \param maxCommands maximum of commands on the command stack, default -1 is unlimited. 00274 */ 00275 a2dDocumentCommandProcessor(long flags = a2dDEFAULT_DOCUMENT_FLAGS, 00276 bool initialize = true, 00277 int maxCommands = -1 ); 00278 00279 //! construct and initilize based on other. 00280 a2dDocumentCommandProcessor( a2dDocumentCommandProcessor* other ); 00281 00282 //! destructor 00283 ~a2dDocumentCommandProcessor(); 00284 00285 //! All menu's a2dMenuIdItem using can be intercepted here 00286 void OnMenu( wxCommandEvent& event ); 00287 00288 //! Called by Exit() 00289 /*! 00290 Use e.g. to clean up modeless dialogs created from here. 00291 00292 It is common practice to create ( via commands to this class ) tool dialogs, color dialogs modeless, 00293 meaning without parent window. You can use this central command processor as owner of such dialogs, 00294 by just storing them in a derived commands processor. 00295 The trick is to destroy those dialogs when the application terminates. Implementing this can be done 00296 by overriding this function here. 00297 */ 00298 virtual void OnExit(); 00299 00300 //!Initializes data; currently just calls OnCreateFileHistory. 00301 /*! Some data cannot always be initialized in the constructor 00302 because the programmer must be given the opportunity 00303 to override functionality. If OnCreateFileHistory was 00304 called from the constructor, an overridden virtual OnCreateFileHistory 00305 would not be called due to C++'s 'interesting' constructor semantics. 00306 */ 00307 virtual void Initialize(); 00308 00309 //! redirect the command to the current document ( if available ) 00310 virtual bool SubmitToDocument( a2dCommand* command, bool storeIt = true ); 00311 00312 // Handlers for common user commands 00313 00314 //!Closes and deletes the currently active document unless Close was vetod. 00315 bool FileClose( bool force = true ); 00316 00317 //! Creates a document from a list of templates (if more than one template). 00318 a2dError FileNew( a2dDocumentPtr& doc, a2dTemplateFlagMask docTemplateFlags = a2dTemplateFlag::VISIBLE ); 00319 00320 //! Creates a new document and reads in the selected file. 00321 /*! 00322 CreateDocument() is called with an empty string as path, and therefore a 00323 filedialog will be displayed, including the filters from templates, and 00324 you need to choose a file like that. 00325 If file is not empty, the file will silently be opened, using the right template 00326 based on file extension or template IoHandler. 00327 00328 \param doc returns pointer to document in smart pointer. 00329 \param file specification for the file to load 00330 \param docTemplateFlags flags for templates, default visible templates. 00331 */ 00332 a2dError FileOpen( a2dDocumentPtr& doc, const wxFileName& file = wxFileName( wxT("") ), a2dTemplateFlagMask docTemplateFlags = a2dTemplateFlag::VISIBLE ); 00333 00334 //! open one or more files using a file dialog 00335 /*! 00336 \param openPath default path to open the file dialog in. 00337 \param dialogFlags flags for file dialog 00338 \param docTemplateFlags flags for templates, default visible templates. 00339 */ 00340 a2dError FilesOpen( const wxString& openPath = wxT(""), int dialogFlags = wxFD_MULTIPLE | wxFD_OPEN, a2dTemplateFlagMask docTemplateFlags = a2dTemplateFlag::VISIBLE ); 00341 00342 //! revert the current document to the non saved document on disk. 00343 /*! 00344 Currently call Revert() on current document. 00345 */ 00346 bool FileRevert(); 00347 00348 //! Saves the current document by calling wxDocument::Save for the current document. 00349 bool FileSave(); 00350 00351 //! Calls wxDocument::SaveAs for the current document. 00352 /*! 00353 This to save a document to a file of the same type it was created with. 00354 00355 \param file specification for the file to saveas 00356 \param flags document flags e.g. a2dREFDOC_SILENT does not show dialog first. 00357 */ 00358 bool FileSaveAs( const wxFileName& file = wxFileName( wxT("") ), a2dDocumentFlagMask flags = a2dREFDOC_NON ); 00359 00360 //! Calls a2dDocument::Export for the current document. 00361 /*! 00362 This to export a document to a file of the chosen type. 00363 \param file specification for the file to export , no description means use file extension, if empty file path ask user. 00364 \param description description of a2dDocumentTemplate to use, if empty use filename ext to search template. 00365 \param flags for way of export a2dREFDOC_SILENT for saving without filedialog 00366 */ 00367 bool FileExport( const wxFileName& file = wxFileName( wxT("") ), const wxString& description = wxT(""), a2dDocumentFlagMask flags = a2dREFDOC_NON ); 00368 00369 //! Calls a2dDocument::Import for the current document. 00370 /*! 00371 This to import into the current document the data stored in a file. 00372 \param file specification for the file to import , no description means use file extension, if empty file path ask user. 00373 \param description description of a2dDocumentTemplate to use, if empty use filename ext to search template. 00374 \param flags for way of export a2dREFDOC_SILENT for saving without filedialog 00375 */ 00376 bool FileImport( const wxFileName& file = wxFileName( wxT("") ), const wxString& description = wxT(""), a2dDocumentFlagMask flags = a2dREFDOC_NON ); 00377 00378 //! print the current active view. 00379 bool Print( a2dCommand* command ); 00380 00381 //! print preview of the current active view. 00382 bool Preview( a2dCommand* command ); 00383 00384 //! printer setup the current active document or central command processor. 00385 bool PrintSetup( a2dCommand* command ); 00386 00387 //! default handler when a file could not be opened 00388 /*! 00389 The document is already created, and it depends on the document its a2dDocument::OnOpenDocument() 00390 how much of the wrong file is stored in it. When nothing is done, to store this document here in the command 00391 processor, it will automatically be released on return from this event. 00392 If you decide to display what has bin stored in the doc sofar, it can be done here. 00393 00394 The default implementation closes all views that were created on the document, delete its contents, 00395 and generates an error log. 00396 */ 00397 void OnCannotOpenDocument( a2dCommandEvent& event ); 00398 00399 //! Creates new documents in a manner determined by the flags parameter, which can be: 00400 /*! 00401 wxDOC_NEW Creates a fresh document. 00402 00403 wxDOC_SILENT Silently loads the given document file. 00404 00405 If wxDOC_NEW is present, a new document will be created and returned, 00406 possibly after asking the user for a template to use if there is more 00407 than one document template. 00408 00409 If wxDOC_SILENT is present, a new document 00410 will be created and the given file loaded into it, using the first template which fits 00411 the file format to read, either based on extension or on the iohandler of the template. 00412 See FindTemplateForPath(). 00413 00414 If neither of these flags is present, the user will be presented with a file selector for 00415 the file to load, and the template to use will be determined by the 00416 extension (Windows) or by popping up a template choice list (other platforms). 00417 00418 When a new document is created and added to the document list the event 00419 ::wxEVT_POST_CREATE_DOCUMENT is sent to the a2dDocumentTemplate::GetViewConnector() or if not 00420 set to a2dDocviewGlobals->GetEventDistributer(). 00421 It depends on the type of a2dViewConnector what happens, e.g one could create 00422 an a2dView instance of the type chosen by the user from a list of a2dViewTemplates. 00423 The actual a2dView is created by calling the a2dViewTemplate::CreateView(). 00424 And this last sents the ::wxEVT_POST_CREATE_VIEW event to the a2dViewConnector. 00425 And that is the time to set the created view into a a2dDocumentViewWindow and 00426 maybe create frames and windows first followed by setting the new view to one of its windows. 00427 Another possibility is that the a2dViewConnector does not create new views, but instead of that uses 00428 existing views. The things happing in responds to ::wxEVT_POST_CREATE_DOCUMENT, is what makes this 00429 docview framework flexible. Replacing the a2dViewConnector is in general enough to swicth from 00430 on type of application (MDI SDI etc. ) to another. 00431 00432 If the maximum number of documents has been reached, 00433 this function will delete the oldest currently loaded 00434 document before creating a new one. 00435 00436 \param path path to file in case of flags != wxDOC_NEW and flags == wxDOC_SILENT 00437 \param documentflags Use at will 00438 \param wantedDocTemplate if given, only use this template to create new documents 00439 \param dialogflags if not a new document or creating silenet a document, this will be the flags towards the selection dialog 00440 \param docTemplateFlags template mask for document template, to filter shown templates. 00441 00442 \return a2dError 00443 */ 00444 virtual a2dError CreateDocuments( const wxString& path, 00445 a2dDocumentFlagMask documentflags = a2dREFDOC_NON, 00446 a2dDocumentTemplate* wantedDocTemplate = NULL, 00447 int dialogflags = wxFD_OPEN, 00448 a2dTemplateFlagMask docTemplateFlags = a2dTemplateFlag::VISIBLE 00449 ); 00450 00451 //!adds the given document, and creates a view for it. 00452 /*! If more than one view is allowed for the document 00453 (by virtue of multiple templates mentioning the same document type), 00454 a choice of view is presented to the user. 00455 00456 \param newDoc document to add and for which to create a new view 00457 \param viewTypeName is not empty, this type of view will be searched in the available templates 00458 \param documentflags Use at will, default a2dREFDOC_NEW 00459 \param docTemplateFlags template mask for document template, to filter shown templates. 00460 \param viewTemplateFlags template mask for view template, to filter shown templates. 00461 */ 00462 a2dView* AddDocumentCreateView( a2dDocument* newDoc, 00463 const wxString& viewTypeName = wxT(""), 00464 a2dDocumentFlagMask documentflags = a2dREFDOC_NEW, 00465 a2dTemplateFlagMask docTemplateFlags = a2dTemplateFlag::VISIBLE, 00466 a2dTemplateFlagMask viewTemplateFlags = a2dTemplateFlag::VISIBLE 00467 ); 00468 00469 //! add a in memory created document, but do not create a view. 00470 /*! 00471 The first document template with the same GetDocumentTypeName() as the document, 00472 is set to the document. 00473 The sentPreAddCreatedDocumentEvent can be sent to the a2dViewConnector via the document template, 00474 to take an action before the new document is add to the document list. For instance to close 00475 other files or disconnect views to use them again for the new document. 00476 The sentPostCreateDocumentEvent should be sent to use the a2dViewConnector system to 00477 create new frames with views. 00478 00479 \param newDoc The document to be added. 00480 \param sentPreAddDocumentEvent if true this event is sent to document template 00481 \param sentPostCreateDocumentEvent if true this event is sent to document template 00482 \param documentflags Use at will, default a2dREFDOC_NEW 00483 \param docTemplateFlags template mask for document template, to filter shown templates. 00484 */ 00485 void AddCreatedDocument( a2dDocument* newDoc, bool sentPreAddCreatedDocumentEvent = false, 00486 bool sentPostCreateDocumentEvent = false, 00487 a2dDocumentFlagMask documentflags = a2dREFDOC_NEW, 00488 a2dTemplateFlagMask docTemplateFlags = a2dTemplateFlag::VISIBLE ); 00489 00490 //!Creates a new view for the given document. 00491 /*! If more than one view is allowed for the document 00492 (by virtue of multiple templates mentioning the same document type), 00493 a choice of view is presented to the user. 00494 00495 \param doc document for which to create a new view 00496 \param viewTypeName is not empty, this type of view will be searched in the available templates 00497 \param flags Document flags 00498 \param mask mask for views to show. 00499 */ 00500 virtual a2dView *CreateView( a2dDocument *doc, const wxString& viewTypeName = wxT(""), 00501 a2dDocumentFlagMask flags = a2dREFDOC_NON, 00502 a2dTemplateFlagMask viewTemplateFlags = a2dTemplateFlag::VISIBLE ); 00503 00504 //! remove/release a template 00505 /*! 00506 Keep in mind that templates or reference counted and placed in smart pointer lists. 00507 So releasing it here, might keep it intact when placed/used somewhere else 00508 ( e.g. a2dViewConnector ). 00509 */ 00510 void ReleaseTemplate(a2dDocumentTemplate *temp, long flags = 0); 00511 00512 virtual bool FlushDoc(a2dDocument *doc); 00513 00514 //! return template suitable for loading the file in path, using FindTemplateForPath. 00515 a2dDocumentTemplate *MatchTemplate(const wxString& path); 00516 00517 //! pops up a file selector with optional a list of filters 00518 /*! corresponding to the document templates to choose from. 00519 00520 Based on the list a2dDocumentTemplateList the list of file filters is setup. 00521 Next a file dialog is displayed, to select one or more file, depending on the dialogflags. 00522 In case of opening a file, it is checked for existence. 00523 00524 The file dialog opens in m_lastDirectory, unless path is specified, after that 00525 m_lastDirectory directory is set to the directory from which the file(s) were selected. 00526 00527 \param docTemplates the doctemplates which are used to present the file filters/types in the file dialog, 00528 and/or which are used to test the file chosen against. 00529 \param path initial directory where the dialog should be opened 00530 \param flags flags = a2dREFDOC_NON 00531 \param selectedPaths the files choosen are stored in here 00532 \param chosenTemplate The a2dDocumentTemplate corresponding to the selected file's extension/filter or its iohandler, is returned. 00533 \param dialogflags may be a combination of wxFD_OPEN, wxFD_SAVE, wxFD_OVERWRITE_PROMPT, wxHIDE_READONLY, wxFD_FILE_MUST_EXIST. 00534 \param docTemplateFlags use only templates matching this mask 00535 \param preferedTemplate the template to show in the file selection dialog as default. 00536 00537 \return a2dFileDialogReturn 00538 00539 This function is used in a2dDocumentCommandProcessor::CreateDocument() and other locations, to 00540 present a dialog for loading and saving a document according to document templates. 00541 */ 00542 virtual a2dError SelectDocumentPath( const a2dDocumentTemplateList& docTemplates, 00543 const wxString& path, 00544 a2dDocumentFlagMask flags, 00545 wxArrayString* selectedPaths, 00546 a2dDocumentTemplate** chosenTemplate, 00547 int dialogflags = wxFD_OPEN, 00548 a2dTemplateFlagMask docTemplateFlags = a2dTemplateFlag::VISIBLE, 00549 const a2dDocumentTemplate* preferedTemplate = NULL ); 00550 00551 //!Returns a document template by asking the user 00552 /*!(if there is more than one template). This function is used in a2dDocumentCommandProcessor::CreateDocument. 00553 00554 \param sort If more than one template 00555 then this parameter indicates whether the list of templates that the user 00556 will have to choose from is sorted or not when shown the choice box dialog. 00557 Default is false. 00558 \param docTemplateFlag template filter 00559 */ 00560 virtual a2dDocumentTemplate *SelectDocumentType( bool sort = false, 00561 a2dTemplateFlagMask docTemplateFlags = a2dTemplateFlag::VISIBLE ); 00562 00563 //! function used in CreateDocument() when a2dREFDOC_SILENT is used for creating it. 00564 /*! 00565 It iterates over the document templates, to find a template for the file 00566 that is to be loaded. To test each template it uses a2dDocumentTemplate::FileMatchesTemplate() 00567 The first matching template is returned. This is based on the file extension, or if not given on 00568 the input iohandler of a template, which can load the file. 00569 00570 \param docTemplates the templates to test the filepath against. 00571 \param path input filename to an existing file, for which we want to find a template 00572 \param docTemplateFlag template filter 00573 00574 \return The first matching template is returned. 00575 */ 00576 virtual a2dDocumentTemplate *FindTemplateForPath( const a2dDocumentTemplateList& docTemplates, const wxString& path, a2dTemplateFlagMask mask = a2dTemplateFlag::VISIBLE ); 00577 00578 //!Returns a view template by asking the user 00579 /*!(if there is more than one template), displaying a list of valid views. 00580 00581 This function is used in a2dDocumentCommandProcessor::CreateView. The dialog normally will 00582 not appear because the array of templates only contains those relevant to the 00583 document in question, and often there will only be one such. 00584 00585 a2dViewConnector::CreateView() also uses his function to present the templates 00586 a2dViewTemplate's associated with a a2dViewConnector, or if not to present all 00587 a2dViewTemplate from the a2dDocumentCommandProcessor itself. 00588 00589 \param doc the document to select a viewtype for. 00590 \param list template list to choose a view template from 00591 \param viewTypeName the name of the view, if empty a list is presented, else a check is done 00592 if the given name is indeed a view template. 00593 00594 \param sort If more than one template, then this parameter 00595 indicates whether the list of templates that the user will have to choose from is 00596 sorted or not when shown the choice box dialog. Default is false. 00597 \param mask which view are allowed. 00598 */ 00599 virtual a2dViewTemplate *SelectViewType( a2dDocument* doc, 00600 const a2dViewTemplateList& list, 00601 const wxString& viewTypeName = wxT(""), 00602 bool sort = false, 00603 a2dTemplateFlagMask viewTemplateFlags = a2dTemplateFlag::VISIBLE ); 00604 00605 //! add a reference to a a2dDocumentTemplate to the a2dDocumentTemplateList 00606 void AssociateDocTemplate( a2dDocumentTemplate *temp ); 00607 00608 //! remove a reference to a a2dDocumentTemplate to the a2dDocumentTemplateList 00609 void DisassociateDocTemplate( a2dDocumentTemplate *temp ); 00610 00611 //! add a reference to a a2dViewTemplate to the wxViewTemplateReflist 00612 void AssociateViewTemplate( a2dViewTemplate *temp ); 00613 00614 //! remove a reference to a a2dViewTemplate to the wxViewTemplateReflist 00615 void DisassociateViewTemplate( a2dViewTemplate *temp ); 00616 00617 //! set the current document, only needed in cases 00618 /*! where it was not set right already (rarely), and you need to have it set 00619 to be able to use a2dDocumentCommandProcessor to get to a document. 00620 00621 It also used internal, in order to sent the ::wxEVT_CHANGED_DOCUMENT event to the a2dEventDistributer. 00622 This event can be intercepted by other classes, when they need to know this. 00623 \see GetCurrentDocument() 00624 */ 00625 void SetCurrentDocument( a2dDocument* document ); 00626 00627 //! Get the current Document, which is the document that was last accessed from a view. 00628 /*! 00629 The current document is the document that is set when: 00630 -When a view is activated (has focus in case of a wxWindow), via SetActive() 00631 -Last document added, but which does not have a view yet, via AddDocument() 00632 -When set from the outside with SetCurrentDocument() 00633 00634 When a a2dView is deactivated, and GetCurrentView() is set to NULL, the current document 00635 is not modified untill another/same view is activated. So you can still get to the document 00636 if the active view is deactivated. This happens for instance when a modeless dialog is activated. 00637 00638 also \see GetLastView() 00639 00640 The current document is used by a2dDocumentCommandProcessor to issue commands 00641 on the document its private commandprocessor. 00642 And only in very special cases you will need to set it yourself, normally it will 00643 be set to the view which has the focus. 00644 */ 00645 a2dDocument* GetCurrentDocument() const; 00646 00647 //! get the command processor of the current document. 00648 /*! 00649 When the current document is set and it has a commandprocessor, this will be returned. 00650 */ 00651 a2dCommandProcessor* GetCurrentDocumentCommandProcessor() const; 00652 00653 //!Sets the maximum number of documents that can be open at a time. 00654 /*!By default, this is 10,000. If you set it to 1, existing documents will be saved and 00655 deleted when the user tries to open or create a new one (similar to the behaviour of 00656 Windows Write, for example). Allowing multiple documents gives behaviour more akin to 00657 MS Word and other Multiple Document Interface applications. 00658 */ 00659 void SetMaxDocsOpen( size_t n) { m_maxDocsOpen = n; } 00660 00661 //!Gets the maximum number of documents that can be open at a time. 00662 size_t GetMaxDocsOpen() const { return m_maxDocsOpen; } 00663 00664 //! Add a document to the manager's list 00665 /*! 00666 The a2dCommandEvent of type ::wxEVT_ADD_DOCUMENT is sent to the 00667 a2dDocviewGlobals->GetEventDistributer(), this can be used to do some action 00668 after a new document is added. (e.g add to overview window of all open documents) 00669 */ 00670 void AddDocument(a2dDocument *doc); 00671 00672 //! remove a document from the manager's list 00673 /*! 00674 The a2dCommandEvent of type ::wxEVT_REMOVE_DOCUMENT is sent to the 00675 a2dDocviewGlobals->GetEventDistributer(), this can be used to do some action 00676 after a document is removed. (e.g remove from an overview window of all open documents) 00677 */ 00678 void RemoveDocument(a2dDocument *doc); 00679 00680 //! closes all currently open documents 00681 /*! 00682 If force is true the closing of the document can not be vetod. 00683 If force is false only the documents which did not veto the close are Closed. 00684 00685 \remark closing a document means its views are closed, by calling a2dView::Close() 00686 00687 \return If Close of a document is vetod, returns false else true. 00688 00689 */ 00690 bool CloseDocuments(bool force = true); 00691 00692 //! Clear remaining documents and templates 00693 /*! 00694 releases templates and documents, the documents are first closed, if vetod, 00695 the clearing of documents and templates is skipped, and return is false. 00696 */ 00697 bool Clear(bool force = true); 00698 00699 //! Called to Exit the application properly. 00700 /*! 00701 Set m_busyExit, and next calls CleanUp() and Clear( true ). 00702 00703 One normally exits the main event loop (and the application) by deleting the top window. 00704 In that case this function is called automatically. 00705 But in case of a script command this function makes sure the top window is closed. 00706 */ 00707 bool Exit( bool force = true ); 00708 00709 //! set this when you are exiting the application 00710 //! When this class is destructed, it is set automatically. 00711 void SetBusyExit( bool exitBusy ) { m_busyExit = exitBusy; } 00712 00713 //! return true if the application is bussy exiting. 00714 bool GetBusyExit() { return m_busyExit; } 00715 00716 //! return the one that is active right now (e.g. has focus in case of a wxWindow), or NULL 00717 a2dView *GetCurrentView() const; 00718 00719 //! return the one that was last made active, or NULL if not available anymore. 00720 /*! 00721 Use from modeless dialogs to get to view just before the dialog become active, 00722 and therefore the view inactive. 00723 */ 00724 a2dView *GetLastView() const; 00725 00726 //! returns a reference to the a2dDocumentList, which contains all a2dDocument's that are open. 00727 const a2dDocumentList& GetDocuments() const { return m_docs; } 00728 00729 //! returns a reference to the a2dDocumentTemplateList, which contains all a2dDocumentTemplate's. 00730 const a2dDocumentTemplateList& GetDocTemplates() { return m_docTemplates; } 00731 00732 //! returns a reference to the a2dViewTemplateList, which contains all a2dViewTemplate's. 00733 const a2dViewTemplateList& GetViewTemplates() { return m_viewTemplates; } 00734 00735 //! Make a default document name 00736 virtual bool MakeDefaultName(wxString& buf); 00737 00738 //! Make a frame title (override this to do something different) 00739 /*! 00740 This method asks the document for its printable name and adds this 00741 and the application name to the returned string. 00742 If no document is given the returned string is the application name. 00743 The returned string will have a format like "Printable name - Application name" 00744 00745 \remark 00746 If you use the modified indicator you've to update the frame title (call this 00747 method again) if you save the document, otherwise the modified indicator will 00748 stay at your frame. 00749 You may want to catch the ::wxEVT_CHANGEDMODIFY_DOCUMENT event to update the frame title. 00750 00751 \param doc The document to ask for the printable name or <code>NULL</code> 00752 \param modifiedIndicator If set (i.e. a "*"), the indicator will be attached to the printable name if doc is modified 00753 */ 00754 virtual wxString MakeFrameTitle(a2dDocument* doc, const wxString& modifiedIndicator = wxT("")); 00755 00756 //! A hook to allow a derived class to create a different type of file history. Called from Initialize. 00757 virtual a2dFileHistory *OnCreateFileHistory(); 00758 00759 //! returns a pointer to the file history list 00760 virtual a2dFileHistory *GetFileHistory() const { return m_fileHistory; } 00761 00762 //! File history management 00763 virtual void AddFileToHistory( const wxFileName& file, a2dDocumentTemplate* docTemplate = NULL, a2dViewTemplate* viewTemplate = NULL ); 00764 00765 //! Remove a file from history 00766 virtual void RemoveFileFromHistory(size_t i); 00767 00768 //! Return number fo files in history 00769 virtual size_t GetHistoryFilesCount() const; 00770 00771 //! return the a2dFileHistoryItem of the i'th file in the history 00772 virtual a2dFileHistoryItem* GetHistoryFileItem(size_t i) const; 00773 00774 //! return the filename of the i'th file in the history 00775 virtual wxString GetHistoryFile(size_t i) const; 00776 00777 //! Use this menu for appending recently-visited document filenames, 00778 /*! for convenient access. Calling this function with a valid menu 00779 pointer enables the history list functionality. 00780 00781 Note that you can add multiple menus using this function, 00782 to be managed by the file history object. 00783 */ 00784 virtual void FileHistoryUseMenu(wxMenu *menu); 00785 00786 //! Removes the given menu from the list of menus managed by the file history object. 00787 virtual void FileHistoryRemoveMenu(wxMenu *menu); 00788 00789 #if wxUSE_CONFIG 00790 //! Loads the file history from a config object. 00791 virtual void FileHistoryLoad(wxConfigBase& config); 00792 //! Saves the file history into a config object. This must be called explicitly by the application. 00793 virtual void FileHistorySave(wxConfigBase& config); 00794 #endif // wxUSE_CONFIG 00795 00796 //! Appends the files in the history list, to all menus managed by the file history object 00797 virtual void FileHistoryAddFilesToMenu(); 00798 00799 //! Appends the files in the history list, to the given menu only. 00800 virtual void FileHistoryAddFilesToMenu(wxMenu* menu); 00801 00802 //! Gets the directory to be displayed to the user when opening a file. Initially this is empty. 00803 inline wxString GetLastDirectory() const { return m_lastDirectory; } 00804 00805 //! Sets the directory to be displayed to the user when opening a file. Initially this is empty. 00806 inline void SetLastDirectory(const wxString& dir) { m_lastDirectory = dir; } 00807 00808 //! called when a a2dView is activate or deacivated. 00809 /*! 00810 In general you will get two events, first for the view that is deactivated, and next 00811 for the new active view. 00812 m_currentView is set to the currently active view. 00813 00814 \param view if not NULL, the new active view is set to this view, else NULL. 00815 */ 00816 void SetActiveView( a2dView* view ); 00817 00818 //! Views do inform the document manager when a view will be destroyed. 00819 /*! 00820 The function sets the m_lastView and/or 00821 m_currentView to NULL, if eqaul to the view destroyed. 00822 \param view if not NULL, set the m_lastView and/or m_currentView to NULL if equal view, 00823 else the m_lastView and m_currentView to NULL. 00824 */ 00825 void CheckCurrentLastView( a2dView* view ); 00826 00827 #if wxUSE_PRINTING_ARCHITECTURE 00828 wxPageSetupData* GetPageSetupData(void) const { return m_pageSetupData; } 00829 void SetPageSetupData(const wxPageSetupData& pageSetupData) { *m_pageSetupData = pageSetupData; } 00830 #endif 00831 00832 //!process an event with a protection of repeated working in MDI by klion 00833 //! . 00834 /*! 00835 \param event event that is to be processed by a2dDocumentCommandProcessor. 00836 */ 00837 virtual bool ProcessEvent(wxEvent& event); 00838 00839 //! set undo storage or not 00840 void SetUndo( bool withUndo ) { m_withUndo = withUndo; } 00841 00842 //! get undo storage setting 00843 bool GetUndo() { return m_withUndo; } 00844 00845 protected: 00846 00847 //! default handler for GUI event with id wxID_UNDO 00848 void OnUndo(wxCommandEvent& event); 00849 00850 //! default handler for GUI event with id wxID_REDO 00851 void OnRedo(wxCommandEvent& event); 00852 00853 protected: 00854 //! Handlers for UI update commands 00855 void OnUpdateFileOpen(wxUpdateUIEvent& event); 00856 //! Handlers for UI update commands 00857 void OnUpdateFileClose(wxUpdateUIEvent& event); 00858 //! Handlers for UI update commands 00859 void OnUpdateFileRevert(wxUpdateUIEvent& event); 00860 //! Handlers for UI update commands 00861 void OnUpdateFileNew(wxUpdateUIEvent& event); 00862 //! Handlers for UI update commands 00863 void OnUpdateFileSave(wxUpdateUIEvent& event); 00864 //! Handlers for UI update commands 00865 void OnUpdateFileSaveAs(wxUpdateUIEvent& event); 00866 //! Handlers for UI update commands 00867 void OnUpdateUndo(wxUpdateUIEvent& event); 00868 //! Handlers for UI update commands 00869 void OnUpdateRedo(wxUpdateUIEvent& event); 00870 00871 //! Handlers for UI update commands 00872 void OnUpdatePrint(wxUpdateUIEvent& event); 00873 //! Handlers for UI update commands 00874 void OnUpdatePrintSetup(wxUpdateUIEvent& event); 00875 //! Handlers for UI update commands 00876 void OnUpdatePreview(wxUpdateUIEvent& event); 00877 00878 //! Views do inform the document manager 00879 /*! when a view is (in) activated ( the window containing the view is in or out of focus ) 00880 The default handler sets the active view for the document manager. 00881 The current active view, is set to the last view which did sent an activate event 00882 with value true. 00883 If the view sending the event is the current and the event value is false, 00884 the current view is set to NULL. 00885 The last view that was m_currentView until now, is set inactive from here 00886 by calling a2dView::Activate(). 00887 */ 00888 void OnActivateView( a2dViewEvent& viewevent ); 00889 00890 //! Views do inform the document manager when a view will be removed. 00891 /*! 00892 The default handler sets the m_lastView and/or 00893 m_currentView to NULL, if eqaul to the view removed. 00894 */ 00895 void OnRemoveView( a2dDocumentEvent& viewevent ); 00896 00897 //!It works when a2dView::SetDocument() executing 00898 void OnAddView( a2dDocumentEvent& docevent ); 00899 00900 //! user flags use at will ( not used internal ) 00901 long m_flags; 00902 00903 //! to create unique new names for file 00904 int m_defaultDocumentNameCounter; 00905 00906 //! the maximum of documents allowed open 00907 size_t m_maxDocsOpen; 00908 00909 //! list of all that are open 00910 a2dDocumentList m_docs; 00911 00912 //! templates for documents 00913 a2dDocumentTemplateList m_docTemplates; 00914 00915 //! templates for views 00916 a2dViewTemplateList m_viewTemplates; 00917 00918 //! the current active view 00919 a2dView* m_currentView; 00920 00921 //! the current active document 00922 a2dDocument* m_currentDocument; 00923 00924 //! the view that was last active 00925 a2dView* m_lastView; 00926 00927 //! the file history 00928 a2dFileHistory* m_fileHistory; 00929 00930 //! the last visited directory 00931 wxString m_lastDirectory; 00932 00933 //! if set, for commands which can undo, will be submitted like that. 00934 bool m_withUndo; 00935 00936 //! set when terminating application 00937 bool m_busyExit; 00938 00939 #if wxUSE_PRINTING_ARCHITECTURE 00940 //! this is the global printer page setup data for printer 00941 wxPageSetupData* m_pageSetupData; 00942 #endif 00943 00944 }; 00945 00946 //! One Global instance of this class exists, in order to get to 00947 /*! the global a2dDocumentCommandProcessor, the a2dEventDistributer. 00948 00949 -a2dDocumentCommandProcessor handles commands for opening new a2dDocument's and a2dView's. 00950 00951 The idea is that the a2dDocumentCommandProcessor is the central place for checking errors, 00952 and decide what to do with them. 00953 00954 See base class for more. 00955 00956 \ingroup docview global 00957 */ 00958 class A2DDOCVIEWDLLEXP a2dDocviewGlobal : public a2dGeneralGlobal 00959 { 00960 00961 public: 00962 00963 //! constructor 00964 a2dDocviewGlobal(); 00965 00966 //! destructor 00967 ~a2dDocviewGlobal(); 00968 00969 //! Gets a2dDocumentCommandProcessor pointer 00970 a2dDocumentCommandProcessor* GetDocviewCommandProcessor() const { return m_docviewCommandProcessor.Get(); } 00971 00972 //! Normally the docview commandprocessor is set in the constructor when creating new a2dDocviewGlobal 00973 void SetDocviewCommandProcessor( a2dDocumentCommandProcessor* docviewCommandProcessor ); 00974 00975 //! to sent a ::wxEVT_RECORD event 00976 /*! 00977 Record events or used for sending command strings, typical used for a commandline window or 00978 for recording macros to a file, which later can be replayed. 00979 00980 The Format string is the sam as in Printf, but for %f %d the accuracy may be set internal. 00981 */ 00982 virtual void RecordF( wxObject* sender, const wxChar* Format, ... ); 00983 00984 virtual void RecordF( const wxChar* Format, ... ); 00985 00986 private: 00987 00988 //! the only docview CommandProcessor central to the application. 00989 a2dSmrtPtr<a2dDocumentCommandProcessor> m_docviewCommandProcessor; 00990 }; 00991 00992 //! global object to get to the only a2dDocviewGlobal 00993 A2DDOCVIEWDLLEXP_DATA(extern a2dDocviewGlobal*) a2dDocviewGlobals; 00994 00995 //-------------------------------------------------------------------- 00996 // commands implementation 00997 //-------------------------------------------------------------------- 00998 00999 #include <wx/docview/doccomimpl.h> 01000 01001 // ---------------------------------------------------------------------------- 01002 // File history management 01003 // ---------------------------------------------------------------------------- 01004 01005 //! holds one file for placing in history list 01006 /*! 01007 Next to the filename, also the template used for loading the file is stored here. 01008 */ 01009 class A2DDOCVIEWDLLEXP a2dFileHistoryItem : public a2dObject 01010 { 01011 public: 01012 a2dFileHistoryItem( const wxFileName& filename, a2dDocumentTemplate* docTemplate, a2dViewTemplate* viewTemplate ) 01013 { 01014 m_docTemplate = docTemplate; 01015 m_viewTemplate = viewTemplate; 01016 m_filename = filename; 01017 } 01018 01019 a2dDocumentTemplatePtr m_docTemplate; 01020 a2dViewTemplatePtr m_viewTemplate; 01021 wxFileName m_filename; 01022 01023 private: 01024 01025 //! create an exact copy of this property 01026 virtual a2dObject* Clone( CloneOptions options ) const { return new a2dFileHistoryItem( m_filename, m_docTemplate, m_viewTemplate ); }; 01027 01028 #if wxART2D_USE_CVGIO 01029 virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite ) {} 01030 virtual void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts ) {} 01031 #endif //wxART2D_USE_CVGIO 01032 01033 }; 01034 01035 typedef a2dSmrtPtr<a2dFileHistoryItem> a2dFileHistoryItemPtr; 01036 01037 //! list of a2dFileHistoryItem 01038 typedef a2dSmrtPtrList<a2dFileHistoryItem> a2dFileHistoryItemList; 01039 01040 class A2DDOCVIEWDLLEXP a2dFileHistory : public wxObject 01041 { 01042 public: 01043 a2dFileHistory(size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1); 01044 virtual ~a2dFileHistory(); 01045 01046 // Operations 01047 virtual void AddFileToHistory( const wxFileName& file, a2dDocumentTemplate* docTemplate = NULL, a2dViewTemplate* viewTemplate = NULL ); 01048 virtual void RemoveFileFromHistory(size_t i); 01049 virtual int GetMaxFiles() const { return (int)m_fileMaxFiles; } 01050 virtual void UseMenu(wxMenu *menu); 01051 01052 // Remove menu from the list (MDI child may be closing) 01053 virtual void RemoveMenu(wxMenu *menu); 01054 01055 #if wxUSE_CONFIG 01056 virtual void Load(wxConfigBase& config); 01057 virtual void Save(wxConfigBase& config); 01058 #endif // wxUSE_CONFIG 01059 01060 virtual void AddFilesToMenu(); 01061 virtual void AddFilesToMenu(wxMenu* menu); // Single menu 01062 01063 // Accessors 01064 virtual wxString GetHistoryFile(size_t i) const; 01065 a2dFileHistoryItem* GetHistoryFileItem(size_t i) const; 01066 virtual size_t GetCount() const { return m_fileHistoryList.size(); } 01067 01068 const wxList& GetMenus() const { return m_fileMenus; } 01069 01070 #if wxABI_VERSION >= 20802 01071 // Set/get base id 01072 void SetBaseId(wxWindowID baseId) { m_idBase = baseId; } 01073 wxWindowID GetBaseId() const { return m_idBase; } 01074 #endif // wxABI 2.8.2+ 01075 01076 protected: 01077 01078 // file history list 01079 a2dFileHistoryItemList m_fileHistoryList; 01080 01081 // Menus to maintain (may need several for an MDI app) 01082 wxList m_fileMenus; 01083 // Max files to maintain 01084 size_t m_fileMaxFiles; 01085 01086 private: 01087 // The ID of the first history menu item (Doesn't have to be wxID_FILE1) 01088 wxWindowID m_idBase; 01089 01090 DECLARE_DYNAMIC_CLASS(a2dFileHistory) 01091 DECLARE_NO_COPY_CLASS(a2dFileHistory) 01092 }; 01093 01094 01095 //-------------------------------------------------------------------- 01096 // a2dDocviewModule 01097 //-------------------------------------------------------------------- 01098 01099 //! A module to initialize the docview framework. 01100 /*! 01101 The docview framework uses one global class to get acces to the event distibuter and a central commandprocessor. 01102 01103 It is called a2dDocviewGlobals and is the only global instance of a2dDocviewGlobal. 01104 01105 \ingroup global 01106 */ 01107 class A2DDOCVIEWDLLEXP a2dDocviewModule : public wxModule 01108 { 01109 public: 01110 01111 //! constructor 01112 a2dDocviewModule() { 01113 #if wxUSE_PRINTING_ARCHITECTURE 01114 m_wxThePrintPaperDatabase = NULL; 01115 #endif 01116 } 01117 01118 virtual bool OnInit(); 01119 virtual void OnExit(); 01120 01121 01122 private: 01123 01124 DECLARE_DYNAMIC_CLASS(a2dDocviewModule) 01125 01126 #if wxUSE_PRINTING_ARCHITECTURE 01127 wxPrintPaperDatabase* m_wxThePrintPaperDatabase; 01128 #endif 01129 }; 01130 01131 #endif // _WX_DOCCOMH__ 01132 01133 01134