wxArt2D
doccom.h
Go to the documentation of this file.
1 /*! \file wx/docview/doccom.h
2  \brief Docview framework its controlling class
3 
4  All classes in the document view framework are under control of the a2dDocumentCommandProcessor.
5  It sents events to documents, templates classes for new document and views are stored here.
6  At last the class is able to function as a central command processor for the whole framework.
7 
8  \author Klaas Holwerda
9  \date Created 05/07/03
10 
11  Copyright: (c)
12 
13  Licence: wxWidgets licence
14 
15  RCS-ID: $Id: doccom.h,v 1.55 2009/09/26 19:01:04 titato Exp $
16 */
17 
18 #ifndef _WX_DOCCOMH__
19 #define _WX_DOCCOMH__
20 
21 #include "wx/cmdproc.h"
22 
23 #if wxUSE_PRINTING_ARCHITECTURE
24 #include "wx/paper.h"
25 #include "wx/print.h"
26 #endif
27 
28 #include <wx/module.h>
29 
30 #include <wx/general/genmod.h>
31 #include <wx/docview.h>
32 #include <wx/docview/docviewref.h>
33 #include <wx/filedlg.h>
34 
35 //! find a parent wxWindow pointer to place a control into
36 extern wxWindow* wxFindSuitableParent();
37 
38 //! extra menu ideas for docview framework of wxDocview.
39 enum
40 {
41  wxID_ART2D_LOWEST = 5300, /*!< reserved range within total range used by wxWindows */
42 };
43 
44 class A2DDOCVIEWDLLEXP a2dDocumentCommandProcessor;
45 template class A2DDOCVIEWDLLEXP a2dSmrtPtr<a2dDocumentCommandProcessor>;
46 
47 /**********************************************
48  New events Document and View events.
49 **********************************************/
50 BEGIN_DECLARE_EVENT_TYPES()
51 //! see a2dCommandEvent \ingroup eventid
52 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_ADD_DOCUMENT, 1 )
53 //! see a2dCommandEvent \ingroup eventid
54 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_REMOVE_DOCUMENT, 1 )
55 //! see a2dCommandEvent \ingroup eventid
56 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_CHANGED_DOCUMENT, 1 )
57 //! see a2dCommandEvent \ingroup eventid
58 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_CANNOT_OPEN_DOCUMENT, 1 )
59 END_DECLARE_EVENT_TYPES()
60 
61 //! Event sent to/from a2dDocumentCommandProcessor
62 /*!
63  - ::wxEVT_ADD_DOCUMENT is sent from a2dDocumentCommandProcessor when a document is added.
64  - ::wxEVT_REMOVE_DOCUMENT is sent from a2dDocumentCommandProcessor when a document is removed.
65  - ::wxEVT_CHANGED_DOCUMENT is sent from a2dDocumentCommandProcessor when the current document has changed.
66  - ::wxEVT_DO is sent from a2dDocumentCommandProcessor or any other commandprocessor when a command is issued.
67  - ::wxEVT_UNDO is sent from a2dDocumentCommandProcessor or any other commandprocessor when a command is issued.
68  - ::wxEVT_REDO is sent from a2dDocumentCommandProcessor or any other commandprocessor when a command is issued.
69 
70  - ::wxEVT_MENUSTRINGS is sent from a2dCommandProcessor when menu string need to be updated after a command.
71 
72  - ::wxEVT_CANNOT_OPEN_DOCUMENT is sent by a2dDocumentCommandProcessor::CreateDocument() when a file could not be opened
73 
74  Use a2dObject::ConnectEvent to connect your own wxEvtHandler to the a2CommandProcessor
75  to receive them.
76 
77  \ingroup docview docviewevents
78 */
79 class A2DDOCVIEWDLLEXP a2dCommandEvent : public a2dCommandProcessorEvent
80 {
81 
82 public:
83 
84  //! constructor
85  /*!
86  type should be ::wxEVT_ADD_DOCUMENT or ::wxEVT_REMOVE_DOCUMENT or ::wxEVT_CHANGED_DOCUMENT
87  */
88  a2dCommandEvent( wxEventType type, a2dDocument* doc )
89  : a2dCommandProcessorEvent( type, 0 )
90  {
91  m_doc = doc;
92  }
93 
94  //! constructor
95  /*!
96  type should be ::wxEVT_MENUSTRINGS ::wxEVT_DO ::wxEVT_UNDO
97 
98  For ::wxEVT_MENUSTRINGS, you can use the following function, to get the info to set the menu string.
99  wxCommandProcessor::GetUndoMenuLabel()
100  wxCommandProcessor::GetRedoMenuLabel()
101  wxCommandProcessor::CanUndo()
102  wxCommandProcessor::CanRedo()
103  */
104  a2dCommandEvent( wxEventType type, a2dCommand* cmd, a2dDocument* doc = NULL )
105  : a2dCommandProcessorEvent( type, 0 )
106  {
107  m_doc = doc;
108  m_cmd = cmd;
109  }
110 
111  //! constructor
112  /*!
113  type ::wxEVT_MENUSTRINGS
114  */
116  const wxString& WXUNUSED( undoLabel ), bool WXUNUSED( canUndo ),
117  const wxString& WXUNUSED( redoLabel ), bool WXUNUSED( canRedo ),
118  a2dDocument* doc = NULL
119  )
120  : a2dCommandProcessorEvent( wxEVT_MENUSTRINGS, 0 )
121  {
122  m_doc = doc;
123  m_cmd = cmd;
124  }
125 
126  //! constructor
127  /*!
128  type ::wxEVT_RECORD
129  */
130  a2dCommandEvent( const wxString& record )
131  : a2dCommandProcessorEvent( wxEVT_RECORD, 0 )
132  {
133  m_doc = NULL;
134  m_cmd = NULL;
135  m_record = record;
136  }
137 
138  //! constructor
140  : a2dCommandProcessorEvent( event )
141  {
142  m_doc = event.m_doc;
143  m_cmd = event.m_cmd;
144  m_record = event.m_record;
145  }
146 
147  //! clone the event.
148  virtual wxEvent* Clone( bool WXUNUSED( deep ) = true ) const { return new a2dCommandEvent( *this ); }
149 
150  //! the document created/removed or on which the command was applied.
151  a2dDocument* GetDocument() { return m_doc; }
152 
153  //! the command ( if there was one ) that did it.
154  a2dCommand* GetCommand() { return m_cmd; }
155 
156  wxString& GetRecord() { return m_record; }
157 
158 private:
159 
160  //! see GetDocument()
161  a2dDocument* m_doc;
162 
163  wxString m_record;
164 };
165 
166 
167 //! internal event function for static event tables declaration
168 typedef void ( wxEvtHandler::*wxDocCommandProcessorEventFunction )( a2dCommandEvent& );
169 
170 /*! \addtogroup eventhandlers
171 * @{
172 */
173 
174 //! event sent to a2dDocumentCommandProcessor when a document has been added to the a2dDocumentCommandProcessor
175 #define EVT_ADD_DOCUMENT(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_ADD_DOCUMENT, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ),
176 //! event sent to a2dDocumentCommandProcessor when a document will be removed from the a2dDocumentCommandProcessor
177 #define EVT_REMOVE_DOCUMENT(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_REMOVE_DOCUMENT, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ),
178 //! event sent to a2dDocumentCommandProcessor when the current document has changed in the a2dDocumentCommandProcessor
179 #define EVT_CHANGED_DOCUMENT(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_CHANGED_DOCUMENT, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ),
180 //! event sent when a file could not be opened in the a2dDocumentCommandProcessor
181 #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 ),
182 //! event sent to a2dDocumentCommandProcessor when a document has been added to the a2dDocumentCommandProcessor
183 #define EVT_RECORD(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_RECORD, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxDocCommandProcessorEventFunction > (& func), (wxObject *) NULL ),
184 
185 
186 class A2DDOCVIEWDLLEXP a2dFileHistory;
187 class A2DDOCVIEWDLLEXP a2dFileHistoryItem;
188 
189 DECLARE_MENU_ITEMID( CmdMenu_Exit )
190 DECLARE_MENU_ITEMID( CmdMenu_FileClose )
191 DECLARE_MENU_ITEMID( CmdMenu_FileCloseAll )
192 DECLARE_MENU_ITEMID( CmdMenu_FileOpen )
193 DECLARE_MENU_ITEMID( CmdMenu_FileNew )
194 DECLARE_MENU_ITEMID( CmdMenu_FileSave )
195 DECLARE_MENU_ITEMID( CmdMenu_FileSaveAll )
196 DECLARE_MENU_ITEMID( CmdMenu_FileSaveAs )
197 DECLARE_MENU_ITEMID( CmdMenu_FileImport )
198 DECLARE_MENU_ITEMID( CmdMenu_FileExport )
199 DECLARE_MENU_ITEMID( CmdMenu_FileRevert )
200 DECLARE_MENU_ITEMID( CmdMenu_CreateView )
201 DECLARE_MENU_ITEMID( CmdMenu_Print )
202 DECLARE_MENU_ITEMID( CmdMenu_Preview )
203 DECLARE_MENU_ITEMID( CmdMenu_PrintView )
204 DECLARE_MENU_ITEMID( CmdMenu_PreviewView )
205 DECLARE_MENU_ITEMID( CmdMenu_PrintDocument )
206 DECLARE_MENU_ITEMID( CmdMenu_PreviewDocument )
207 DECLARE_MENU_ITEMID( CmdMenu_PrintSetup )
208 DECLARE_MENU_ITEMID( CmdMenu_EmptyDocument )
209 
210 //! @} eventhandlers
211 
212 //! One object of this class may be created in an application, to manage all the templates and documents.
213 /*!
214  Events not handled by a a2dDocumentFrame or derived class, are redirected to this class
215  Events in the Application Child frames are also routed to the Parent Frame and from there
216  to this class.
217  This is convenient for combining the event table that is used for menu's in child as well as
218  parent frames.
219 
220  The a2dDocumentCommandProcessor class is part of the document/view framework supported by wxDocview,
221  and cooperates with the a2dView, a2dDocument, a2dDocumentTemplate, a2dViewTemplate and
222  a2dViewConnector classes.
223 
224  All open documents and templates are maintained here, and functions to open new documents and views
225  ( via its templates ), are setup from within this class.
226  As such it is the communication class within the docview framework.
227 
228  It is derived from a2dCommandProcessor, in order to use it as a command interpreter.
229  Although not so much for Undo and Redo in this case. Much more to have a in between level for the
230  Graphical User Interfaces and the commands that open up new documents and views.
231  Defining your own docview commands in a derived a2dDocumentCommandProcessor, makes it easy
232  to implement macro recording to a file, and replay the same macro from a file.
233  Calling all member function of a2dDocumentCommandProcessor directly from the GUI, would make this
234  impractible.
235  So by issueing commands through the Submit() function, you will have a central point
236  for calling member functions on the a2dDocumentCommandProcessor. But you are still free to call all member function
237  directly.
238 
239  \ingroup docview
240 
241 */
242 class A2DDOCVIEWDLLEXP a2dDocumentCommandProcessor: public a2dCommandProcessor
243 {
244 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
245  a2dInitCurrentSmartPointerOwner m_initCurrentSmartPointerOwner;
246 #endif
247  DECLARE_DYNAMIC_CLASS( a2dDocumentCommandProcessor )
248 
249  DECLARE_EVENT_TABLE()
250 
251 public:
252 
253  //!Constructor.
254  /*!Create a document manager instance dynamically near the start of your application
255  before doing any document or view operations.
256 
257  \param flags is currently unused.
258 
259  \param initialize if true, the Initialize function will be called to create a default
260  history list object. If you derive from a2dDocumentCommandProcessor, you may wish to call the base
261  constructor with false, and then call Initialize in your own constructor, to allow your
262  own Initialize or OnCreateFileHistory functions to be called.
263 
264  \param maxCommands maximum of commands on the command stack, default -1 is unlimited.
265  */
266  a2dDocumentCommandProcessor( long flags = a2dDEFAULT_DOCUMENT_FLAGS,
267  bool initialize = true,
268  int maxCommands = -1 );
269 
270  //! construct and initilize based on other.
272 
273  //! destructor
275 
276  //! All menu's ( also using a2dMenuIdItem ) can be intercepted here
277  /*!
278  Calling functions like a2dDocumentFrame::AddCmdMenu(), will generate a menu event in
279  a2dDocumentFrame, but often the event is not handled there, but redirected to this command porcessor.
280  The idea is that the menu triggers a certain action. In case of an action on a a2dDocument, often
281  this is done by submitting a a2dCommand. That action can be undone, if implemented.
282  Other actions, only call a member function.
283  Having a central entry point for actions, instead of calling the function directly, makes it easy
284  to get a notification when an action was issued.
285  If you want to know about a menu/action that is taken, make a dynamic connect to this class
286  for the menu id in question. Do Skip the event in your handler, in order to continue processing here.
287  */
288  void OnMenu( wxCommandEvent& event );
289 
290  //! ask for a file using a file selector.
291  /*!
292  If your path contains internal variables, they will be expanded.
293  */
294  wxString AskFile( const wxString& message, const wxString& default_path = "",
295  const wxString& default_filename = "", const wxString& default_extension = "",
296  const wxString& wildcard = "*.*", int flags = 0,
297  int x = -1, int y = -1 )
298  {
299  wxWindow* parent = wxFindSuitableParent();
300 
301  wxString expandedPath = default_path;
302  a2dPathList path;
303  if ( !default_path.IsEmpty() && !path.ExpandPath( expandedPath ) )
304  {
305  a2dGeneralGlobals->ReportWarningF( a2dError_CouldNotEvaluatePath, _( "Could not expand %s" ), default_path.c_str() );
306  return wxT( "" );
307  }
308  return wxFileSelector( message, expandedPath, default_filename, default_extension, wildcard, flags, parent, x, y );
309  }
310 
311  //! Called by Exit()
312  /*!
313  Use e.g. to clean up modeless dialogs created from here.
314 
315  It is common practice to create ( via commands to this class ) tool dialogs, color dialogs modeless,
316  meaning without parent window. You can use this central command processor as owner of such dialogs,
317  by just storing them in a derived commands processor.
318  The trick is to destroy those dialogs when the application terminates. Implementing this can be done
319  by overriding this function here.
320  */
321  virtual void OnExit();
322 
323  //!Initializes data; currently just calls OnCreateFileHistory.
324  /*! Some data cannot always be initialized in the constructor
325  because the programmer must be given the opportunity
326  to override functionality. If OnCreateFileHistory was
327  called from the constructor, an overridden virtual OnCreateFileHistory
328  would not be called due to C++'s 'interesting' constructor semantics.
329  */
330  virtual void Initialize();
331 
332  //! redirect the command to the current document ( if available )
333  virtual bool SubmitToDocument( a2dCommand* command, bool storeIt = true );
334 
335  // Handlers for common user commands
336 
337  //!Closes and deletes the currently active document unless Close was vetod.
338  bool FileClose( bool force = true );
339 
340  //! Creates a document from a list of templates (if more than one template).
341  a2dError FileNew( a2dDocumentPtr& doc, a2dTemplateFlagMask docTemplateFlags = a2dTemplateFlag::VISIBLE );
342 
343  //! Return the preferred document template for Opening files.
344  a2dDocumentTemplate* GetPreferredOpenDocumentTemplate() { return m_preferredOpenTemplate; }
345 
346  //! Set the preferred document template for Opening files.
347  void SetPreferredOpenDocumentTemplate( a2dDocumentTemplate* docTemplate ) { m_preferredOpenTemplate = docTemplate; }
348 
349  //! Creates a new document and reads in the selected file.
350  /*!
351  CreateDocument() is called with an empty string as path, and therefore a
352  filedialog will be displayed, including the filters from templates, and
353  you need to choose a file like that.
354  If file is not empty, the file will silently be opened, using the right template
355  based on file extension or template IoHandler.
356 
357  \param doc returns pointer to document in smart pointer.
358  \param file specification for the file to load
359  \param docTemplateFlags flags for templates, default visible templates.
360  */
361  a2dError FileOpen( a2dDocumentPtr& doc, const wxFileName& file = wxFileName( wxT( "" ) ), a2dTemplateFlagMask docTemplateFlags = a2dTemplateFlag::VISIBLE | a2dTemplateFlag::LOAD );
362 
363  //! open one or more files using a file dialog
364  /*!
365  \param openPath default path to open the file dialog in.
366  \param dialogFlags flags for file dialog
367  \param docTemplateFlags flags for templates, default visible templates.
368  */
369  a2dError FilesOpen( const wxString& openPath = wxT( "" ), int dialogFlags = wxFD_MULTIPLE | wxFD_OPEN, a2dTemplateFlagMask docTemplateFlags = a2dTemplateFlag::VISIBLE | a2dTemplateFlag::LOAD );
370 
371  //! Return existing document, or open it from file
372  /*!
373  Check document list for this file.
374  If it not in the list, it will open the file.
375 
376  \param doc returns pointer to document in smart pointer.
377  \param file specification for the file to load
378  \param checkModification check if file on disk is newer
379  */
380  a2dError FileOpenCheck( a2dDocumentPtr& doc, const wxFileName& file, bool checkModification );
381 
382  //! revert the current document to the non saved document on disk.
383  /*!
384  Currently call Revert() on current document.
385  */
386  bool FileRevert();
387 
388  //! Saves the current document by calling wxDocument::Save for the current document.
389  bool FileSave();
390 
391  //! Saves the documents by calling wxDocument::Save for each document.
392  bool FileSaveAll();
393 
394  //! Calls wxDocument::SaveAs for the current document.
395  /*!
396  This to save a document to a file of the same type it was created with.
397 
398  \param file specification for the file to saveas
399  \param flags document flags e.g. a2dREFDOC_SILENT does not show dialog first.
400  */
401  bool FileSaveAs( const wxFileName& file = wxFileName( wxT( "" ) ), a2dDocumentFlagMask flags = a2dREFDOC_NON );
402 
403  //! Return the preferred document template for Exporting files.
404  a2dDocumentTemplate* GetPreferredExportDocumentTemplate() { return m_preferredExportTemplate; }
405 
406  //! Set the preferred document template for Exporting files.
407  void SetPreferredExportDocumentTemplate( a2dDocumentTemplate* docTemplate ) { m_preferredExportTemplate = docTemplate; }
408 
409  //! Calls a2dDocument::Export for the current document.
410  /*!
411  This to export a document to a file of the chosen type.
412  \param file specification for the file to export , no description means use file extension, if empty file path ask user.
413  \param description description of a2dDocumentTemplate to use, if empty use filename ext to search template.
414  \param flags for way of export a2dREFDOC_SILENT for saving without filedialog
415  */
416  bool FileExport( const wxFileName& file = wxFileName( wxT( "" ) ), const wxString& description = wxT( "" ), a2dDocumentFlagMask flags = a2dREFDOC_NON );
417 
418  //! Return the preferred document template for Importing files.
419  a2dDocumentTemplate* GetPreferredImportDocumentTemplate() { return m_preferredImportTemplate; }
420 
421  //! Set the preferred document template for Importing files.
422  void SetPreferredImportDocumentTemplate( a2dDocumentTemplate* docTemplate ) { m_preferredImportTemplate = docTemplate; }
423 
424  //! Calls a2dDocument::Import for the current document.
425  /*!
426  This to import into the current document the data stored in a file.
427  \param file specification for the file to import , no description means use file extension, if empty file path ask user.
428  \param description description of a2dDocumentTemplate to use, if empty use filename ext to search template.
429  \param flags for way of export a2dREFDOC_SILENT for saving without filedialog
430  */
431  bool FileImport( const wxFileName& file = wxFileName( wxT( "" ) ), const wxString& description = wxT( "" ), a2dDocumentFlagMask flags = a2dREFDOC_NON );
432 
433  //! print the current active view.
434  bool Print( a2dPrintWhat printWhat = a2dPRINT_Print );
435 
436  //! print preview of the current active view.
437  bool Preview( a2dPrintWhat printWhat = a2dPRINT_Preview );
438 
439  //! printer setup the current active document or central command processor.
440  bool PrintSetup( a2dPrintWhat printWhat );
441 
442  //! Return page setup data, as set in the current default printer.
443  wxPageSetupDialogData GetDefaultPrintSettings();
444 
445  //! get printer setup the current active view or document or the one from central command processor.
446  wxPageSetupDialogData* GetPrintSetup( a2dPrintWhat printWhat );
447 
448  //! default handler when a file could not be opened
449  /*!
450  The document is already created, and it depends on the document its a2dDocument::OnOpenDocument()
451  how much of the wrong file is stored in it. When nothing is done, to store this document here in the command
452  processor, it will automatically be released on return from this event.
453  If you decide to display what has bin stored in the doc sofar, it can be done here.
454 
455  The default implementation closes all views that were created on the document, delete its contents,
456  and generates an error log.
457  */
458  void OnCannotOpenDocument( a2dCommandEvent& event );
459 
460  //! Creates new documents in a manner determined by the flags parameter, which can be:
461  /*!
462  wxDOC_NEW Creates a fresh document.
463 
464  wxDOC_SILENT Silently loads the given document file.
465 
466  If wxDOC_NEW is present, a new document will be created and returned,
467  possibly after asking the user for a template to use if there is more
468  than one document template.
469 
470  If wxDOC_SILENT is present, a new document
471  will be created and the given file loaded into it, using the first template which fits
472  the file format to read, either based on extension or on the iohandler of the template.
473  See FindTemplateForPath().
474 
475  If neither of these flags is present, the user will be presented with a file selector for
476  the file to load, and the template to use will be determined by the
477  extension (Windows) or by popping up a template choice list (other platforms).
478 
479  When a new document is created and added to the document list the event
480  ::wxEVT_POST_CREATE_DOCUMENT is sent to the a2dDocumentTemplate::GetViewConnector().
481  It depends on the type of a2dViewConnector what happens, e.g one could create
482  an a2dView instance of the type chosen by the user from a list of a2dViewTemplates.
483  The actual a2dView is created by calling the a2dViewTemplate::CreateView().
484  And this last sents the ::wxEVT_POST_CREATE_VIEW event to the a2dViewConnector.
485  And that is the time to set the created view into a a2dDocumentViewWindow and
486  maybe create frames and windows first followed by setting the new view to one of its windows.
487  Another possibility is that the a2dViewConnector does not create new views, but instead of that uses
488  existing views. The things happing in responds to ::wxEVT_POST_CREATE_DOCUMENT, is what makes this
489  docview framework flexible. Replacing the a2dViewConnector is in general enough to swicth from
490  on type of application (MDI SDI etc. ) to another.
491 
492  If the maximum number of documents has been reached,
493  this function will delete the oldest currently loaded
494  document before creating a new one.
495 
496  \param path path to file in case of flags != wxDOC_NEW and flags == wxDOC_SILENT
497  \param documentflags Use at will
498  \param wantedDocTemplate if given, only use this template to create new documents
499  \param dialogflags if not a new document or creating silenet a document, this will be the flags towards the selection dialog
500  \param docTemplateFlags template mask for document template, to filter shown templates.
501 
502  \return a2dError
503  */
504  virtual a2dError CreateDocuments( const wxString& path,
505  a2dDocumentFlagMask documentflags = a2dREFDOC_NON,
506  a2dDocumentTemplate* wantedDocTemplate = NULL,
507  int dialogflags = wxFD_OPEN,
509  );
510 
511  //!adds the given document, and creates a view for it.
512  /*! If more than one view is allowed for the document
513  (by virtue of multiple templates mentioning the same document type),
514  a choice of view is presented to the user.
515 
516  \param newDoc document to add and for which to create a new view
517  \param viewTypeName is not empty, this type of view will be searched in the available templates
518  \param documentflags Use at will, default a2dREFDOC_NEW
519  \param docTemplateFlags template mask for document template, to filter shown templates.
520  \param viewTemplateFlags template mask for view template, to filter shown templates.
521  */
522  a2dView* AddDocumentCreateView( a2dDocument* newDoc,
523  const wxString& viewTypeName = wxT( "" ),
524  a2dDocumentFlagMask documentflags = a2dREFDOC_NEW,
527  );
528 
529  //! add a in memory created document, but do not create a view.
530  /*!
531  The first document template with the same GetDocumentTypeName() as the document,
532  is set to the document.
533  The sentPreAddCreatedDocumentEvent can be sent to the a2dViewConnector via the document template,
534  to take an action before the new document is add to the document list. For instance to close
535  other files or disconnect views to use them again for the new document.
536  The sentPostCreateDocumentEvent should be sent to use the a2dViewConnector system to
537  create new frames with views.
538 
539  \param newDoc The document to be added.
540  \param sentPreAddDocumentEvent if true this event is sent to document template
541  \param sentPostCreateDocumentEvent if true this event is sent to document template
542  \param documentflags Use at will, default a2dREFDOC_NEW
543  \param docTemplateFlags template mask for document template, to filter shown templates.
544 
545  \return a2dError
546  */
547  a2dError AddCreatedDocument( a2dDocument* newDoc, bool sentPreAddCreatedDocumentEvent = false,
548  bool sentPostCreateDocumentEvent = false,
549  a2dDocumentFlagMask documentflags = a2dREFDOC_NEW,
550  a2dTemplateFlagMask docTemplateFlags = a2dTemplateFlag::VISIBLE );
551 
552  //!Creates a new view for the given document.
553  /*! If more than one view is allowed for the document
554  (by virtue of multiple templates mentioning the same document type),
555  a choice of view is presented to the user.
556 
557  \param doc document for which to create a new view
558  \param viewTypeName is not empty, this type of view will be searched in the available templates
559  \param flags Document flags
560  \param mask mask for views to show.
561  */
562  virtual a2dView* CreateView( a2dDocument* doc, const wxString& viewTypeName = wxT( "" ),
564  a2dTemplateFlagMask viewTemplateFlags = a2dTemplateFlag::VISIBLE );
565 
566  //! remove/release a template
567  /*!
568  Keep in mind that templates or reference counted and placed in smart pointer lists.
569  So releasing it here, might keep it intact when placed/used somewhere else
570  ( e.g. a2dViewConnector ).
571  */
572  void ReleaseTemplate( a2dDocumentTemplate* temp, long flags = 0 );
573 
574  virtual bool FlushDoc( a2dDocument* doc );
575 
576  //! return template suitable for loading the file in path, using FindTemplateForPath.
577  a2dDocumentTemplate* MatchTemplate( const wxString& path );
578 
579  //! pops up a file selector with optional a list of filters
580  /*! corresponding to the document templates to choose from.
581 
582  Based on the list a2dDocumentTemplateList the list of file filters is setup.
583  Next a file dialog is displayed, to select one or more file, depending on the dialogflags.
584  In case of opening a file, it is checked for existence.
585 
586  The file dialog opens in path, after that
587  path is set to the directory from which the file(s) were selected.
588 
589  \param title title for the dialog
590  \param docTemplates the doctemplates which are used to present the file filters/types in the file dialog,
591  and/or which are used to test the file chosen against.
592  \param path initial directory where the dialog should be opened, returns chosen directory.
593  \param flags flags = a2dREFDOC_NON
594  \param selectedPaths the files choosen are stored in here
595  \param chosenTemplate The a2dDocumentTemplate corresponding to the selected file's extension/filter or its iohandler, is returned.
596  \param dialogflags may be a combination of wxFD_OPEN, wxFD_SAVE, wxFD_OVERWRITE_PROMPT, wxHIDE_READONLY, wxFD_FILE_MUST_EXIST.
597  \param docTemplateFlags use only templates matching this mask
598  \param preferedTemplate the template to show in the file selection dialog as default.
599 
600  \return a2dFileDialogReturn
601 
602  This function is used in a2dDocumentCommandProcessor::CreateDocument() and other locations, to
603  present a dialog for loading and saving a document according to document templates.
604  */
605  virtual a2dError SelectDocumentPath( const wxString& title, const a2dDocumentTemplateList& docTemplates,
606  wxString& path,
607  a2dDocumentFlagMask flags,
608  wxArrayString* selectedPaths,
609  a2dDocumentTemplate** chosenTemplate,
610  int dialogflags = wxFD_OPEN,
612  const a2dDocumentTemplate* preferedTemplate = NULL );
613 
614  //!Returns a document template by asking the user
615  /*!(if there is more than one template). This function is used in a2dDocumentCommandProcessor::CreateDocument.
616 
617  \param sort If more than one template
618  then this parameter indicates whether the list of templates that the user
619  will have to choose from is sorted or not when shown the choice box dialog.
620  Default is false.
621  \param docTemplateFlag template filter
622  */
623  virtual a2dDocumentTemplate* SelectDocumentType( bool sort = false,
624  a2dTemplateFlagMask docTemplateFlags = a2dTemplateFlag::VISIBLE );
625 
626  //! function used in CreateDocument() when a2dREFDOC_SILENT is used for creating it.
627  /*!
628  It iterates over the document templates, to find a template for the file
629  that is to be loaded. To test each template it uses a2dDocumentTemplate::FileMatchesTemplate()
630  The first matching template is returned. This is based on the file extension, or if not given on
631  the input iohandler of a template, which can load the file.
632 
633  \param docTemplates the templates to test the filepath against.
634  \param path input filename to an existing file, for which we want to find a template
635  \param docTemplateFlag template filter
636 
637  \return The first matching template is returned.
638  */
639  virtual a2dDocumentTemplate* FindTemplateForPath( const a2dDocumentTemplateList& docTemplates, const wxString& path, a2dTemplateFlagMask mask = a2dTemplateFlag::VISIBLE );
640 
641  //!Returns a view template by asking the user
642  /*!(if there is more than one template), displaying a list of valid views.
643 
644  This function is used in a2dDocumentCommandProcessor::CreateView. The dialog normally will
645  not appear because the array of templates only contains those relevant to the
646  document in question, and often there will only be one such.
647 
648  a2dViewConnector::CreateView() also uses his function to present the templates
649  a2dViewTemplate's associated with a a2dViewConnector, or if not to present all
650  a2dViewTemplate from the a2dDocumentCommandProcessor itself.
651 
652  \param doc the document to select a viewtype for.
653  \param list template list to choose a view template from
654  \param viewTypeName the name of the view, if empty a list is presented, else a check is done
655  if the given name is indeed a view template.
656 
657  \param sort If more than one template, then this parameter
658  indicates whether the list of templates that the user will have to choose from is
659  sorted or not when shown the choice box dialog. Default is false.
660  \param mask which view are allowed.
661  */
662  virtual a2dViewTemplate* SelectViewType( a2dDocument* doc,
663  const a2dViewTemplateList& list,
664  const wxString& viewTypeName = wxT( "" ),
665  bool sort = false,
666  a2dTemplateFlagMask viewTemplateFlags = a2dTemplateFlag::VISIBLE );
667 
668  //! add a reference to a a2dDocumentTemplate to the a2dDocumentTemplateList
669  void AssociateDocTemplate( a2dDocumentTemplate* temp );
670 
671  //! remove a reference to a a2dDocumentTemplate to the a2dDocumentTemplateList
672  void DisassociateDocTemplate( a2dDocumentTemplate* temp );
673 
674  //! add a reference to a a2dViewTemplate to the wxViewTemplateReflist
675  void AssociateViewTemplate( a2dViewTemplate* temp );
676 
677  //! remove a reference to a a2dViewTemplate to the wxViewTemplateReflist
678  void DisassociateViewTemplate( a2dViewTemplate* temp );
679 
680  //! set the current document, only needed in cases
681  /*! where it was not set right already (rarely), and you need to have it set
682  to be able to use a2dDocumentCommandProcessor to get to a document.
683 
684  It also used internal, in order to sent the ::wxEVT_CHANGED_DOCUMENT event.
685  This event can be intercepted by other classes, when they need to know this.
686  \see GetCurrentDocument()
687  */
688  void SetCurrentDocument( a2dDocument* document );
689 
690  //! Get the current Document, which is the document that was last accessed from a view.
691  /*!
692  The current document is the document that is set when:
693  -When a view is activated (has focus in case of a wxWindow), via SetActive()
694  -Last document added, but which does not have a view yet, via AddDocument()
695  -When set from the outside with SetCurrentDocument()
696 
697  When a a2dView is deactivated, the current document
698  is not modified until another view is activated. So you can still get to the document
699  if the active view is deactivated. This happens for instance when a modeless dialog is activated.
700 
701  The current document is used by a2dDocumentCommandProcessor to issue commands
702  on the document its private commandprocessor.
703  And only in very special cases you will need to set it yourself, normally it will
704  be set to the view which has the focus.
705  */
706  a2dDocument* GetCurrentDocument() const;
707 
708  //! get the command processor of the current document.
709  /*!
710  When the current document is set and it has a commandprocessor, this will be returned.
711  */
712  a2dCommandProcessor* GetCurrentDocumentCommandProcessor() const;
713 
714  //!Sets the maximum number of documents that can be open at a time.
715  /*!By default, this is 10,000. If you set it to 1, existing documents will be saved and
716  deleted when the user tries to open or create a new one (similar to the behaviour of
717  Windows Write, for example). Allowing multiple documents gives behaviour more akin to
718  MS Word and other Multiple Document Interface applications.
719  */
720  void SetMaxDocsOpen( size_t n ) { m_maxDocsOpen = n; }
721 
722  //!Gets the maximum number of documents that can be open at a time.
723  size_t GetMaxDocsOpen() const { return m_maxDocsOpen; }
724 
725  //! Add a document to the manager's list
726  /*!
727  The a2dCommandEvent of type ::wxEVT_ADD_DOCUMENT is sent, this can be used to do some action
728  after a new document is added. (e.g add to overview window of all open documents)
729  */
730  void AddDocument( a2dDocument* doc );
731 
732  //! remove a document from the manager's list
733  /*!
734  The a2dCommandEvent of type ::wxEVT_REMOVE_DOCUMENT is sent, this can be used to do some action
735  after a document is removed. (e.g remove from an overview window of all open documents)
736  */
737  void RemoveDocument( a2dDocument* doc );
738 
739  //! closes all currently open documents
740  /*!
741  If force is true the closing of the document can not be vetod.
742  If force is false only the documents which did not veto the close are Closed.
743 
744  \remark closing a document means its views are closed, by calling a2dView::Close()
745 
746  \return If Close of a document is vetod, returns false else true.
747 
748  */
749  bool CloseDocuments( bool force = true );
750 
751  //! Clear remaining documents and templates
752  /*!
753  releases templates and documents, the documents are first closed, if vetod,
754  the clearing of documents and templates is skipped, and return is false.
755  */
756  bool Clear( bool force = true );
757 
758  //! Called to Exit the application properly.
759  /*!
760  Set m_busyExit, and next calls CleanUp() and Clear( true ).
761 
762  One normally exits the main event loop (and the application) by deleting the top window.
763  In that case this function is called automatically.
764  But in case of a script command this function makes sure the top window is closed.
765  */
766  bool Exit( bool force = true );
767 
768  //! set this when you are exiting the application
769  //! When this class is destructed, it is set automatically.
770  void SetBusyExit( bool exitBusy ) { m_busyExit = exitBusy; }
771 
772  //! return true if the application is bussy exiting.
773  bool GetBusyExit() { return m_busyExit; }
774 
775  //! return the one that is active right now (e.g. has focus in case of a wxWindow), or NULL
776  a2dView* GetCurrentView() const;
777 
778  //! returns a reference to the a2dDocumentList, which contains all a2dDocument's that are open.
779  const a2dDocumentList& GetDocuments() const { return m_docs; }
780 
781  //! returns a reference to the a2dDocumentTemplateList, which contains all a2dDocumentTemplate's.
782  const a2dDocumentTemplateList& GetDocTemplates() { return m_docTemplates; }
783 
784  //! returns a reference to the a2dViewTemplateList, which contains all a2dViewTemplate's.
785  const a2dViewTemplateList& GetViewTemplates() { return m_viewTemplates; }
786 
787  //! Make a default document name
788  virtual bool MakeDefaultName( wxString& buf );
789 
790  //! Make a frame title (override this to do something different)
791  /*!
792  This method asks the document for its printable name and adds this
793  and the application name to the returned string.
794  If no document is given the returned string is the application name.
795  The returned string will have a format like "Printable name - Application name"
796 
797  \remark
798  If you use the modified indicator you've to update the frame title (call this
799  method again) if you save the document, otherwise the modified indicator will
800  stay at your frame.
801  You may want to catch the ::wxEVT_CHANGEDMODIFY_DOCUMENT event to update the frame title.
802 
803  \param doc The document to ask for the printable name or <code>NULL</code>
804  \param modifiedIndicator If set (i.e. a "*"), the indicator will be attached to the printable name if doc is modified
805  */
806  virtual wxString MakeFrameTitle( a2dDocument* doc, const wxString& modifiedIndicator = wxT( "" ) );
807 
808  //! A hook to allow a derived class to create a different type of file history. Called from Initialize.
809  virtual a2dFileHistory* OnCreateFileHistory();
810 
811  //! returns a pointer to the file history list
812  virtual a2dFileHistory* GetFileHistory() const { return m_fileHistory; }
813 
814  //! File history management
815  virtual void AddFileToHistory( const wxFileName& file, a2dDocumentTemplate* docTemplate = NULL, a2dViewTemplate* viewTemplate = NULL );
816 
817  //! Remove a file from history
818  virtual void RemoveFileFromHistory( size_t i );
819 
820  //! Return number fo files in history
821  virtual size_t GetHistoryFilesCount() const;
822 
823  //! return the a2dFileHistoryItem of the i'th file in the history
824  virtual a2dFileHistoryItem* GetHistoryFileItem( size_t i ) const;
825 
826  //! return the filename of the i'th file in the history
827  virtual wxString GetHistoryFile( size_t i ) const;
828 
829  //! Use this menu for appending recently-visited document filenames,
830  /*! for convenient access. Calling this function with a valid menu
831  pointer enables the history list functionality.
832 
833  Note that you can add multiple menus using this function,
834  to be managed by the file history object.
835  */
836  virtual void FileHistoryUseMenu( wxMenu* menu );
837 
838  //! Removes the given menu from the list of menus managed by the file history object.
839  virtual void FileHistoryRemoveMenu( wxMenu* menu );
840 
841 #if wxUSE_CONFIG
842  //! Loads the file history from a config object.
843  virtual void FileHistoryLoad( wxConfigBase& config );
844  //! Saves the file history into a config object. This must be called explicitly by the application.
845  virtual void FileHistorySave( wxConfigBase& config );
846 #endif // wxUSE_CONFIG
847 
848  //! Appends the files in the history list, to all menus managed by the file history object
849  virtual void FileHistoryAddFilesToMenu();
850 
851  //! Appends the files in the history list, to the given menu only.
852  virtual void FileHistoryAddFilesToMenu( wxMenu* menu );
853 
854  //! Gets the directory to be displayed to the user when opening a file. Initially this is empty.
855  inline wxString GetLastDirectory() const { return m_lastDirectory; }
856 
857  //! Sets the directory to be displayed to the user when opening a file. Initially this is empty.
858  inline void SetLastDirectory( const wxString& dir ) { m_lastDirectory = dir; }
859 
860  //! To set the curent view.
861  /*!
862  In general you will get two events, first for the view that is deactivated, and next
863  for the new active view.
864  m_currentView is set to the last activated or deactivated view.
865 
866  \param view if not NULL, the new active view is set to this view, else NULL.
867  */
868  virtual void SetCurrentView( a2dView* view );
869 
870  //! Views do inform the document manager when a view will be destroyed.
871  /*!
872  The function sets the m_currentView to NULL, if eqaul to the view destroyed.
873  \param view if not NULL, set the m_currentView to NULL if equal to view. If view is NULL set the m_currentView to NULL.
874  */
875  void CheckCurrentView( a2dView* view );
876 
877 #if wxUSE_PRINTING_ARCHITECTURE
878  wxPageSetupDialogData* GetPageSetupData( void ) const { return m_pageSetupData; }
879  void SetPageSetupData( const wxPageSetupDialogData& pageSetupData ) { *m_pageSetupData = pageSetupData; }
880  void SetPageSetupData( wxPageSetupDialogData* pageSetupData );
881 #endif
882 
883  //!process an event with a protection of repeated working in MDI by klion
884  //! .
885  /*!
886  \param event event that is to be processed by a2dDocumentCommandProcessor.
887  */
888  virtual bool ProcessEvent( wxEvent& event );
889 
890  //! set undo storage or not
891  void SetUndo( bool withUndo ) { m_withUndo = withUndo; }
892 
893  //! get undo storage setting
894  bool GetUndo() { return m_withUndo; }
895 
896 protected:
897 
898  //! default handler for GUI event with id wxID_UNDO
899  void OnUndo( wxCommandEvent& event );
900 
901  //! default handler for GUI event with id wxID_REDO
902  void OnRedo( wxCommandEvent& event );
903 
904 protected:
905  //! Handlers for UI update commands
906  void OnUpdateFileOpen( wxUpdateUIEvent& event );
907  //! Handlers for UI update commands
908  void OnUpdateFileClose( wxUpdateUIEvent& event );
909  //! Handlers for UI update commands
910  void OnUpdateFileCloseAll( wxUpdateUIEvent& event );
911  //! Handlers for UI update commands
912  void OnUpdateFileRevert( wxUpdateUIEvent& event );
913  //! Handlers for UI update commands
914  void OnUpdateFileNew( wxUpdateUIEvent& event );
915  //! Handlers for UI update commands
916  void OnUpdateFileSave( wxUpdateUIEvent& event );
917  //! Handlers for UI update commands
918  void OnUpdateFileSaveAll( wxUpdateUIEvent& event );
919  //! Handlers for UI update commands
920  void OnUpdateFileSaveAs( wxUpdateUIEvent& event );
921  //! Handlers for UI update commands
922  void OnUpdateCreateView( wxUpdateUIEvent& event );
923 
924  //! Handlers for UI update commands
925  void OnUpdateUndo( wxUpdateUIEvent& event );
926  //! Handlers for UI update commands
927  void OnUpdateRedo( wxUpdateUIEvent& event );
928 
929  //! Handlers for UI update commands
930  void OnUpdatePrint( wxUpdateUIEvent& event );
931  //! Handlers for UI update commands
932  void OnUpdatePrintSetup( wxUpdateUIEvent& event );
933  //! Handlers for UI update commands
934  void OnUpdatePreview( wxUpdateUIEvent& event );
935 
936  //! Views do inform the document manager
937  /*! when a view is (in) activated ( the window containing the view is in or out of focus )
938  The default handler sets the active view for the document manager.
939  The current active view, is set to the last view which did sent an activate event
940  with value true.
941  If the view sending the event is the current and the event value is false,
942  the current view is set to NULL.
943  The last view that was m_currentView until now, is set inactive from here
944  by calling a2dView::Activate().
945  */
946  void OnActivateView( a2dViewEvent& viewevent );
947 
948  //! Views do inform the document manager when a view will be removed.
949  /*!
950  The default handler sets the m_lastView and/or
951  m_currentView to NULL, if eqaul to the view removed.
952  */
953  void OnRemoveView( a2dDocumentEvent& viewevent );
954 
955  //!It works when a2dView::SetDocument() executing
956  void OnAddView( a2dDocumentEvent& docevent );
957 
958  //! user flags use at will ( not used internal )
959  long m_flags;
960 
961  //! to create unique new names for file
963 
964  //! the maximum of documents allowed open
966 
967  //! list of all that are open
969 
970  //! templates for documents
972 
973  //! templates for views
975 
976  //! the current view (active or inactive)
978 
979  //! the current active document
981 
982  //! the file history
983  a2dFileHistory* m_fileHistory;
984 
985  //! the last visited directory
986  wxString m_lastDirectory;
987 
988  //! preferred document template for Importing files.
990 
991  //! preferred document template for Exporting files.
993 
994  //! preferred document template for Opening files.
996 
997  //! if set, for commands which can undo, will be submitted like that.
999 
1000  //! set when terminating application
1002 
1003 #if wxUSE_PRINTING_ARCHITECTURE
1004  //! this is the global printer page setup data for printer
1005  wxPageSetupDialogData* m_pageSetupData;
1006 #endif
1007 
1008 };
1009 
1010 //! One Global instance of this class exists, in order to get to
1011 /*! the global a2dDocumentCommandProcessor.
1012 
1013  -a2dDocumentCommandProcessor handles commands for opening new a2dDocument's and a2dView's.
1014 
1015  The idea is that the a2dDocumentCommandProcessor is the central place for checking errors,
1016  and decide what to do with them.
1017 
1018  See base class for more.
1019 
1020  \ingroup docview global
1021 */
1022 class A2DDOCVIEWDLLEXP a2dDocviewGlobal : public a2dGeneralGlobal
1023 {
1024 
1025 public:
1026 
1027  //! constructor
1028  a2dDocviewGlobal();
1029 
1030  //! destructor
1031  ~a2dDocviewGlobal();
1032 
1033  //! Gets a2dDocumentCommandProcessor pointer
1034  a2dDocumentCommandProcessor* GetDocviewCommandProcessor() const { return m_docviewCommandProcessor.Get(); }
1035 
1036  //! Normally the docview commandprocessor is set in the constructor when creating new a2dDocviewGlobal
1037  void SetDocviewCommandProcessor( a2dDocumentCommandProcessor* docviewCommandProcessor );
1038 
1039  //! to sent a ::wxEVT_RECORD event
1040  /*!
1041  Record events or used for sending command strings, typical used for a commandline window or
1042  for recording macros to a file, which later can be replayed.
1043 
1044  The Format string is the sam as in Printf, but for %f %d the accuracy may be set internal.
1045  */
1046  virtual void RecordF( wxObject* sender, const wxChar* Format, ... );
1047 
1048  virtual void RecordF( const wxChar* Format, ... );
1049 
1050 private:
1051 
1052  //! the only docview CommandProcessor central to the application.
1053  a2dSmrtPtr<a2dDocumentCommandProcessor> m_docviewCommandProcessor;
1054 };
1055 
1056 //! global object to get to the only a2dDocviewGlobal
1058 
1059 // ----------------------------------------------------------------------------
1060 // File history management
1061 // ----------------------------------------------------------------------------
1062 
1063 //! holds one file for placing in history list
1064 /*!
1065  Next to the filename, also the template used for loading the file is stored here.
1066 */
1067 class A2DDOCVIEWDLLEXP a2dFileHistoryItem : public a2dObject
1068 {
1069 public:
1070  a2dFileHistoryItem( const wxFileName& filename, a2dDocumentTemplate* docTemplate, a2dViewTemplate* viewTemplate )
1071  {
1072  m_docTemplate = docTemplate;
1073  m_viewTemplate = viewTemplate;
1074  m_filename = filename;
1075  }
1076 
1077  a2dDocumentTemplatePtr m_docTemplate;
1078  a2dViewTemplatePtr m_viewTemplate;
1079  wxFileName m_filename;
1080 
1081 private:
1082 
1083  //! create an exact copy of this property
1084  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const
1085  { return new a2dFileHistoryItem( m_filename, m_docTemplate, m_viewTemplate ); };
1086 
1087 #if wxART2D_USE_CVGIO
1088  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite ) {}
1089  virtual void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts ) {}
1090 #endif //wxART2D_USE_CVGIO
1091 
1092 };
1093 
1095 
1096 //! list of a2dFileHistoryItem
1098 
1099 class A2DDOCVIEWDLLEXP a2dFileHistory : public wxObject
1100 {
1101 public:
1102  a2dFileHistory( size_t maxFiles = 9, wxWindowID idBase = wxID_FILE1 );
1103  virtual ~a2dFileHistory();
1104 
1105  // Operations
1106  virtual void AddFileToHistory( const wxFileName& file, a2dDocumentTemplate* docTemplate = NULL, a2dViewTemplate* viewTemplate = NULL );
1107  virtual void RemoveFileFromHistory( size_t i );
1108  virtual int GetMaxFiles() const { return ( int )m_fileMaxFiles; }
1109  virtual void UseMenu( wxMenu* menu );
1110 
1111  // Remove menu from the list (MDI child may be closing)
1112  virtual void RemoveMenu( wxMenu* menu );
1113 
1114 #if wxUSE_CONFIG
1115  virtual void Load( wxConfigBase& config );
1116  virtual void Save( wxConfigBase& config );
1117 #endif // wxUSE_CONFIG
1118 
1119  virtual void AddFilesToMenu();
1120  virtual void AddFilesToMenu( wxMenu* menu ); // Single menu
1121 
1122  // Accessors
1123  virtual wxString GetHistoryFile( size_t i ) const;
1124  a2dFileHistoryItem* GetHistoryFileItem( size_t i ) const;
1125  virtual size_t GetCount() const { return m_fileHistoryList.size(); }
1126 
1127  const wxList& GetMenus() const { return m_fileMenus; }
1128 
1129 #if wxABI_VERSION >= 20802
1130  // Set/get base id
1131  void SetBaseId( wxWindowID baseId ) { m_idBase = baseId; }
1132  wxWindowID GetBaseId() const { return m_idBase; }
1133 #endif // wxABI 2.8.2+
1134 
1135 protected:
1136 
1137  // file history list
1138  a2dFileHistoryItemList m_fileHistoryList;
1139 
1140  // Menus to maintain (may need several for an MDI app)
1141  wxList m_fileMenus;
1142  // Max files to maintain
1143  size_t m_fileMaxFiles;
1144 
1145 private:
1146  // The ID of the first history menu item (Doesn't have to be wxID_FILE1)
1147  wxWindowID m_idBase;
1148 
1149  DECLARE_DYNAMIC_CLASS( a2dFileHistory )
1150  DECLARE_NO_COPY_CLASS( a2dFileHistory )
1151 };
1152 
1153 
1154 //--------------------------------------------------------------------
1155 // a2dDocviewModule
1156 //--------------------------------------------------------------------
1157 
1158 //! A module to initialize the docview framework.
1159 /*!
1160  The docview framework uses one global class to get acces to the event distibuter and a central commandprocessor.
1161 
1162  It is called a2dDocviewGlobals and is the only global instance of a2dDocviewGlobal.
1163 
1164  \ingroup global
1165 */
1166 class A2DDOCVIEWDLLEXP a2dDocviewModule : public wxModule
1167 {
1168 public:
1169 
1170  //! constructor
1172  {
1173 #if wxUSE_PRINTING_ARCHITECTURE
1174  m_wxThePrintPaperDatabase = NULL;
1175 #endif
1176  }
1177 
1178  virtual bool OnInit();
1179  virtual void OnExit();
1180 
1181 
1182 private:
1183 
1184  DECLARE_DYNAMIC_CLASS( a2dDocviewModule )
1185 
1186 #if wxUSE_PRINTING_ARCHITECTURE
1187  wxPrintPaperDatabase* m_wxThePrintPaperDatabase;
1188 #endif
1189 };
1190 
1191 #endif // _WX_DOCCOMH__
1192 
1193 
1194 
wxString AskFile(const wxString &message, const wxString &default_path="", const wxString &default_filename="", const wxString &default_extension="", const wxString &wildcard="*.*", int flags=0, int x=-1, int y=-1)
ask for a file using a file selector.
Definition: doccom.h:294
a2dDocviewModule()
constructor
Definition: doccom.h:1171
a2dDocumentTemplate * m_preferredExportTemplate
preferred document template for Exporting files.
Definition: doccom.h:992
a2dDocumentTemplateList m_docTemplates
templates for documents
Definition: doccom.h:971
bool GetUndo()
get undo storage setting
Definition: doccom.h:894
void(wxEvtHandler::* wxDocCommandProcessorEventFunction)(a2dCommandEvent &)
internal event function for static event tables declaration
Definition: doccom.h:168
a2dDocumentTemplate * m_preferredImportTemplate
preferred document template for Importing files.
Definition: doccom.h:989
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
The a2dViewTemplate class is used to model the relationship between a document class and a view class...
Definition: docviewref.h:2635
const a2dError a2dError_CouldNotEvaluatePath
const a2dDocumentList & GetDocuments() const
returns a reference to the a2dDocumentList, which contains all a2dDocument&#39;s that are open...
Definition: doccom.h:779
One Global instance of this class exists, in order to get to global needed objects.
Definition: comevt.h:1099
const a2dPrintWhat a2dPRINT_Preview
general print preview
Definition: docviewref.cpp:191
void SetPreferredImportDocumentTemplate(a2dDocumentTemplate *docTemplate)
Set the preferred document template for Importing files.
Definition: doccom.h:422
const a2dViewTemplateList & GetViewTemplates()
returns a reference to the a2dViewTemplateList, which contains all a2dViewTemplate&#39;s.
Definition: doccom.h:785
Ref Counted base object.
Definition: gen.h:1045
The a2dDocumentTemplate class is used to model the relationship between a document class and files...
Definition: docviewref.h:2297
see a2dCommandEvent
Definition: doccom.h:79
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
Path searching.
Definition: gen.h:2926
virtual wxEvent * Clone(bool deep=true) const
clone the event.
Definition: doccom.h:148
bool m_busyExit
set when terminating application
Definition: doccom.h:1001
const a2dDocumentTemplateList & GetDocTemplates()
returns a reference to the a2dDocumentTemplateList, which contains all a2dDocumentTemplate&#39;s.
Definition: doccom.h:782
a2dCommandEvent(const a2dCommandEvent &event)
constructor
Definition: doccom.h:139
unsigned int a2dTemplateFlagMask
mask of flags for a2dTemplateFlag
Definition: docviewref.h:206
a2dView event, to report events in the a2dView class
Definition: docviewref.h:424
base command processor
Definition: comevt.h:829
void SetUndo(bool withUndo)
set undo storage or not
Definition: doccom.h:891
long m_flags
user flags use at will ( not used internal )
Definition: doccom.h:959
Holds a view on a a2dDocument.
Definition: docviewref.h:1804
The document class can be used to model an application&#39;s file-based data.
Definition: docviewref.h:1066
wxPageSetupDialogData * m_pageSetupData
this is the global printer page setup data for printer
Definition: doccom.h:1005
wxUint16 a2dPrintWhat
defines what to print
Definition: gen.h:4052
Docview classes for document view, window and frame.
One object of this class may be created in an application, to manage all the templates and documents...
Definition: doccom.h:242
virtual a2dFileHistory * GetFileHistory() const
returns a pointer to the file history list
Definition: doccom.h:812
size_t GetMaxDocsOpen() const
Gets the maximum number of documents that can be open at a time.
Definition: doccom.h:723
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
Definition: comevt.cpp:1148
a2dDocumentTemplate * GetPreferredExportDocumentTemplate()
Return the preferred document template for Exporting files.
Definition: doccom.h:404
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
a2dCommandEvent(wxEventType type, a2dCommand *cmd, a2dDocument *doc=NULL)
constructor
Definition: doccom.h:104
a2dFileHistory * m_fileHistory
the file history
Definition: doccom.h:983
const a2dPrintWhat a2dPRINT_Print
general print
Definition: docviewref.cpp:190
a2dSmrtPtrList< a2dFileHistoryItem > a2dFileHistoryItemList
list of a2dFileHistoryItem
Definition: doccom.h:1097
One Global instance of this class exists, in order to get to.
Definition: doccom.h:1022
a2dView * m_currentView
the current view (active or inactive)
Definition: doccom.h:977
a2dCommand * m_cmd
see GetCommand()
Definition: comevt.h:773
a2dDocumentList m_docs
list of all that are open
Definition: doccom.h:968
void SetPreferredExportDocumentTemplate(a2dDocumentTemplate *docTemplate)
Set the preferred document template for Exporting files.
Definition: doccom.h:407
a2dViewTemplateList m_viewTemplates
templates for views
Definition: doccom.h:974
general modules header files all together.
a2dDocviewGlobal * a2dDocviewGlobals
a global pointer to get to global instance of important classes.
Definition: doccom.cpp:2348
wxString GetLastDirectory() const
Gets the directory to be displayed to the user when opening a file. Initially this is empty...
Definition: doccom.h:855
void SetMaxDocsOpen(size_t n)
Sets the maximum number of documents that can be open at a time.
Definition: doccom.h:720
a2dCommand * GetCommand()
the command ( if there was one ) that did it.
Definition: doccom.h:154
void SetPreferredOpenDocumentTemplate(a2dDocumentTemplate *docTemplate)
Set the preferred document template for Opening files.
Definition: doccom.h:347
a2dCommandEvent(a2dCommand *cmd, const wxString &undoLabel, bool canUndo, const wxString &redoLabel, bool canRedo, a2dDocument *doc=NULL)
constructor
Definition: doccom.h:115
Event sent to a2dCommandProcessor.
Definition: comevt.h:701
bool m_withUndo
if set, for commands which can undo, will be submitted like that.
Definition: doccom.h:998
a2dDocumentCommandProcessor * GetDocviewCommandProcessor() const
Gets a2dDocumentCommandProcessor pointer.
Definition: doccom.h:1034
a2dCommandEvent(wxEventType type, a2dDocument *doc)
constructor
Definition: doccom.h:88
A module to initialize the docview framework.
Definition: doccom.h:1166
used to report a2dDocument events
Definition: docviewref.h:591
static const a2dTemplateFlagMask LOAD
Definition: docviewref.h:222
void SetBusyExit(bool exitBusy)
Definition: doccom.h:770
size_t m_maxDocsOpen
the maximum of documents allowed open
Definition: doccom.h:965
a2dDocumentTemplate * GetPreferredOpenDocumentTemplate()
Return the preferred document template for Opening files.
Definition: doccom.h:344
static const a2dTemplateFlagMask VISIBLE
Definition: docviewref.h:220
a2dDocumentTemplate * m_preferredOpenTemplate
preferred document template for Opening files.
Definition: doccom.h:995
holds one error report.
Definition: gen.h:623
int m_defaultDocumentNameCounter
to create unique new names for file
Definition: doccom.h:962
a2dDocumentTemplate * GetPreferredImportDocumentTemplate()
Return the preferred document template for Importing files.
Definition: doccom.h:419
A2DDOCVIEWDLLEXP_DATA(extern a2dDocviewGlobal *) a2dDocviewGlobals
global object to get to the only a2dDocviewGlobal
wxWindow * wxFindSuitableParent()
find a parent wxWindow pointer to place a control into
Definition: doccom.cpp:1739
list of a2dObject&#39;s
Definition: gen.h:3157
a2dCommandEvent(const wxString &record)
constructor
Definition: doccom.h:130
void SetLastDirectory(const wxString &dir)
Sets the directory to be displayed to the user when opening a file. Initially this is empty...
Definition: doccom.h:858
wxString m_lastDirectory
the last visited directory
Definition: doccom.h:986
CloneOptions
options for cloning
Definition: gen.h:1200
a2dDocument * m_currentDocument
the current active document
Definition: doccom.h:980
a2dDocument * GetDocument()
the document created/removed or on which the command was applied.
Definition: doccom.h:151
bool GetBusyExit()
return true if the application is bussy exiting.
Definition: doccom.h:773
holds one file for placing in history list
Definition: doccom.h:1067
unsigned int a2dDocumentFlagMask
mask of flags for a2dDocumentFlag
Definition: docviewref.h:200
a base command for the a2dCommandProcessor
Definition: comevt.h:140
doccom.h Source File -- Sun Oct 12 2014 17:04:15 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation