wxArt2D
docviewref.h
Go to the documentation of this file.
1 /*! \file wx/docview/docviewref.h
2  \brief Docview classes for document view, window and frame.
3 
4  All classes for a document view framework are placed in here. Only the controlling
5  a2dDocumentCommandProcessor is in doccom.h.
6 
7  One or more documents are used to stor the application data,
8  and views do display the data in the documents. ViewConnectors are used to couple views
9  to the windows in the application GUI. Either a connector generates new frames and windows
10  to achieve this or it used the existing frames or windows.
11 
12  The view connectors is the key factor for having a separate document view frame work besides
13  wxWidgets its own. wxDocview needed views which could live seperately from the GUI itself,
14  and even the application itself. Special designed views like the a2dCanvasView is designed
15  for displaying a2dCanvasDocument, and is placed in the library to be used where needed.
16  The view connectors made this possible.
17 
18  \author Julian Smart
19  \author Klaas Holwerda
20  \date Created 01/02/97
21 
22  Copyright: (c)
23 
24  Licence: wxWidgets licence
25 
26  Modified by: Klaas Holwerda
27 
28  RCS-ID: $Id: docviewref.h,v 1.67 2009/09/29 20:06:47 titato Exp $
29 */
30 
31 #ifndef _WX_DOCREFH__
32 #define _WX_DOCREFH__
33 
34 /*!
35  \defgroup docview Objects in docview frame work.
36 
37  Classes part of the docview framework.
38 */
39 
40 /*!
41  \defgroup docviewevents Events used in docview frame work.
42 
43  \ingroup docview events
44 */
45 
46 
47 #include "wx/defs.h"
48 #include "wx/list.h"
49 #include "wx/string.h"
50 #include "wx/frame.h"
51 #include "wx/filename.h"
52 #include <wx/splitter.h>
53 #include "wx/notebook.h"
54 
55 #include "sigslot.h"
56 using namespace sigslot;
57 using namespace std;
58 
59 
60 #if wxUSE_PRINTING_ARCHITECTURE
61 #include "wx/print.h"
62 #endif
63 
64 #include <wx/listimpl.cpp>
65 
66 #include "wx/general/genmod.h"
67 
68 #if wxART2D_USE_CVGIO
69 #include "wx/xmlparse/genxmlpars.h"
70 #endif //wxART2D_USE_CVGIO
71 
72 #if (defined(__WXMSW__) )
73 #ifdef A2DDOCVIEWMAKINGDLL
74 #define A2DDOCVIEWDLLEXP WXEXPORT
75 #define A2DDOCVIEWDLLEXP_DATA(type) WXEXPORT type
76 #define A2DDOCVIEWDLLEXP_CTORFN
77 #elif defined(WXDOCVIEW_USINGDLL)
78 #define A2DDOCVIEWDLLEXP WXIMPORT
79 #define A2DDOCVIEWDLLEXP_DATA(type) WXIMPORT type
80 #define A2DDOCVIEWDLLEXP_CTORFN
81 #else // not making nor using DLL
82 #define A2DDOCVIEWDLLEXP
83 #define A2DDOCVIEWDLLEXP_DATA(type) type
84 #define A2DDOCVIEWDLLEXP_CTORFN
85 #endif
86 #else // (defined(__WXMSW__) )not making nor using DLL
87 #define A2DDOCVIEWDLLEXP
88 #define A2DDOCVIEWDLLEXP_DATA(type) type
89 #define A2DDOCVIEWDLLEXP_CTORFN
90 #endif //(defined(__WXMSW__) )
91 
92 class A2DDOCVIEWDLLEXP a2dDocument;
93 class A2DDOCVIEWDLLEXP a2dView;
94 class A2DDOCVIEWDLLEXP a2dDocumentTemplate;
95 class A2DDOCVIEWDLLEXP a2dViewTemplate;
96 
97 
98 #if (defined(__WXMSW__) && defined(WXUSINGDLL) )
99 template class A2DDOCVIEWDLLEXP a2dSmrtPtr<a2dDocumentTemplate>;
100 template class A2DDOCVIEWDLLEXP a2dSmrtPtr<a2dViewTemplate>;
101 template class A2DDOCVIEWDLLEXP a2dSmrtPtr<a2dView>;
102 template class A2DDOCVIEWDLLEXP a2dSmrtPtr<a2dDocument>;
103 template class A2DDOCVIEWDLLEXP a2dSmrtPtr<a2dIOHandler>;
104 template class A2DDOCVIEWDLLEXP a2dSmrtPtr<a2dIOHandlerStrIn>;
105 template class A2DDOCVIEWDLLEXP a2dSmrtPtr<a2dIOHandlerStrOut>;
106 
107 template class A2DDOCVIEWDLLEXP std::allocator<class a2dSmrtPtr<class a2dDocument> >;
108 template class A2DDOCVIEWDLLEXP std::allocator< std::_List_nod<class a2dSmrtPtr<class a2dDocument>, std::allocator<class a2dSmrtPtr<class a2dDocument> > >::_Node >;
109 template class A2DDOCVIEWDLLEXP std::allocator< std::_List_ptr<class a2dSmrtPtr<class a2dDocument>, std::allocator<class a2dSmrtPtr<class a2dDocument> > >::_Nodeptr >;
110 template class A2DDOCVIEWDLLEXP std::list<class a2dSmrtPtr<class a2dDocument> >;
111 template class A2DDOCVIEWDLLEXP a2dlist<class a2dSmrtPtr<class a2dDocument> >;
112 template class A2DDOCVIEWDLLEXP a2dSmrtPtrList<a2dDocument>;
113 
114 template class A2DDOCVIEWDLLEXP std::allocator<class a2dSmrtPtr<class a2dView> >;
115 template class A2DDOCVIEWDLLEXP std::allocator< std::_List_nod<class a2dSmrtPtr<class a2dView>, std::allocator<class a2dSmrtPtr<class a2dView> > >::_Node >;
116 template class A2DDOCVIEWDLLEXP std::allocator< std::_List_ptr<class a2dSmrtPtr<class a2dView>, std::allocator<class a2dSmrtPtr<class a2dView> > >::_Nodeptr >;
117 template class A2DDOCVIEWDLLEXP std::list<class a2dSmrtPtr<class a2dView> >;
118 template class A2DDOCVIEWDLLEXP a2dlist<class a2dSmrtPtr<class a2dView> >;
119 template class A2DDOCVIEWDLLEXP a2dSmrtPtrList<a2dView>;
120 
121 template class A2DDOCVIEWDLLEXP std::allocator<class a2dSmrtPtr<class a2dDocumentTemplate> >;
122 template class A2DDOCVIEWDLLEXP std::allocator< std::_List_nod<class a2dSmrtPtr<class a2dDocumentTemplate>, std::allocator<class a2dSmrtPtr<class a2dDocumentTemplate> > >::_Node >;
123 template class A2DDOCVIEWDLLEXP std::allocator< std::_List_ptr<class a2dSmrtPtr<class a2dDocumentTemplate>, std::allocator<class a2dSmrtPtr<class a2dDocumentTemplate> > >::_Nodeptr >;
124 template class A2DDOCVIEWDLLEXP std::list<class a2dSmrtPtr<class a2dDocumentTemplate> >;
125 template class A2DDOCVIEWDLLEXP a2dlist<class a2dSmrtPtr<class a2dDocumentTemplate> >;
126 template class A2DDOCVIEWDLLEXP a2dSmrtPtrList<a2dDocumentTemplate>;
127 
128 template class A2DDOCVIEWDLLEXP std::allocator<class a2dSmrtPtr<class a2dViewTemplate> >;
129 template class A2DDOCVIEWDLLEXP std::allocator< std::_List_nod<class a2dSmrtPtr<class a2dViewTemplate>, std::allocator<class a2dSmrtPtr<class a2dViewTemplate> > >::_Node >;
130 template class A2DDOCVIEWDLLEXP std::allocator< std::_List_ptr<class a2dSmrtPtr<class a2dViewTemplate>, std::allocator<class a2dSmrtPtr<class a2dViewTemplate> > >::_Nodeptr >;
131 template class A2DDOCVIEWDLLEXP std::list<class a2dSmrtPtr<class a2dViewTemplate> >;
132 template class A2DDOCVIEWDLLEXP a2dlist<class a2dSmrtPtr<class a2dViewTemplate> >;
133 template class A2DDOCVIEWDLLEXP a2dSmrtPtrList<a2dViewTemplate>;
134 #endif
135 
136 //! document smart pointer
138 //! view smart pointer
140 //! a2dViewTemplate smart pointer
142 //! a2dDocumentTemplate smart pointer
144 
145 //! list of documents
147 //! list of views
149 //! list of document templates
151 //! list of view templates
153 
154 //! iterator for list of ...
155 typedef a2dDocumentList::iterator a2dDocumentListIter;
156 
157 //! iterator for list of ...
158 typedef a2dViewList::iterator a2dViewListIter;
159 
160 //! iterator for list of ...
161 typedef a2dDocumentTemplateList::iterator a2dDocumentTemplateListIter;
162 
163 //! iterator for list of ...
164 typedef a2dViewTemplateList::iterator a2dViewTemplateListIter;
165 
166 #if wxUSE_STD_IOSTREAM
167 #include "wx/ioswrap.h"
168 #if wxUSE_IOSTREAMH
169 #include <fstream.h>
170 #else
171 #include <fstream>
172 #endif
173 #else
174 #include "wx/wfstream.h"
175 #endif
176 
177 //! Document manager flags
179 {
180  a2dREFDOC_NON = 0x00000000, /*!< No flag */
181  a2dREFDOC_NEW = 0x00000001, /*!< create a New empty document */
182  a2dREFDOC_SILENT = 0x00000002, /*!< For adding a document by reading from file given a path as input */
183  a2dREFDOC_INIT = 0x00000004, /*!< to initialize new documents when added to the framework */
184  a2dREFDOC_ALL = 0xFFFFFFFF, /*!< For Xor ing and all set */
185  a2dDEFAULT_DOCUMENT_FLAGS = a2dREFDOC_NON /*!< */
186 };
187 
188 
189 //! mask flags for a2dDocument::UpdateAllViews()
191 {
192  a2dVIEW_UPDATE_ALL = 0x0004, /*!< total area displayed by drawer is added as pending to arealist
193  (removes all other pending areas) */
194 };
195 
196 //! mask of flags for a2dDocumentFlag
197 /*!
198  \ingroup docview
199 */
200 typedef unsigned int a2dDocumentFlagMask ;
201 
202 //! mask of flags for a2dTemplateFlag
203 /*!
204  \ingroup docview
205 */
206 typedef unsigned int a2dTemplateFlagMask;
207 
208 //! Template flags
209 /*!
210  \ingroup docview
211 
212  Used to test if a template is visble and for what purpose it is should be.
213  Mostly used to select appropriate templates from a list of templates.
214  The a2dDocumentTemplate and the a2dViewTemplate are both using this flags mask.
215 */
217 {
218 public:
219  static const a2dTemplateFlagMask NON; /*!< no flags set */
220  static const a2dTemplateFlagMask VISIBLE; /*!< is the template visible */
221  static const a2dTemplateFlagMask MARK; /*!< for general use to temporary mark a template*/
222  static const a2dTemplateFlagMask LOAD; /*!< a template for loading files*/
223  static const a2dTemplateFlagMask SAVE; /*!< a template for saving files*/
224  static const a2dTemplateFlagMask IMPORTING; /*!< a template for importing files*/
225  static const a2dTemplateFlagMask EXPORTING; /*!< a template for exporting files*/
226  static const a2dTemplateFlagMask ALL; /*!< all flags set */
227  static const a2dTemplateFlagMask DEFAULT; /*!< default */
228  static const a2dTemplateFlagMask LOAD_IMPORT; /*!< for load + import */
229  static const a2dTemplateFlagMask SAVE_EXPORT; /*!< for save + export */
230 
231 
232  a2dTemplateFlag( a2dTemplateFlagMask newmask = NON );
233 
234  //! Check if given mask matches (flags in mask, or at least set)
235  bool CheckMask( a2dTemplateFlagMask mask );
236 
237  void SetFlags( a2dTemplateFlagMask which );
238 
239  a2dTemplateFlagMask GetFlags() const;
240 
241  bool GetFlag( a2dTemplateFlagMask which ) const;
242 
243  //!template is visible
244  bool m_visible: 1;
245  //!template is marked
246  bool m_mark: 1;
247  //!template is for loading documents
248  bool m_load: 1;
249  //!template is for saving documents
250  bool m_save: 1;
251  //!template is for importing documents
252  bool m_import: 1;
253  //!template is for exporting documents
254  bool m_export: 1;
255 };
256 
257 #include <wx/listimpl.cpp>
258 
259 /**********************************************
260  New events Document and View events.
261 **********************************************/
262 BEGIN_DECLARE_EVENT_TYPES()
263 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_SIGNAL, 1 )
264 
265 //!see a2dDocumentEvent \ingroup eventid
266 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_SAVE_DOCUMENT, 1 )
267 //!see a2dDocumentEvent \ingroup eventid
268 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_SAVEAS_DOCUMENT, 1 )
269 //!see a2dDocumentEvent \ingroup eventid
270 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_IMPORT_DOCUMENT, 1 )
271 //!see a2dDocumentEvent \ingroup eventid
272 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_EXPORT_DOCUMENT, 1 )
273 //!see a2dDocumentEvent \ingroup eventid
274 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_CLOSE_DOCUMENT, 1 )
275 //!see a2dDocumentEvent \ingroup eventid
276 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_OPEN_DOCUMENT, 1 )
277 //!see a2dDocumentEvent \ingroup eventid
278 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_NEW_DOCUMENT, 1 )
279 //!see a2dDocumentEvent \ingroup eventid
280 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_CREATE_DOCUMENT, 1 )
281 //!see a2dDocumentEvent \ingroup eventid
282 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_ADD_VIEW, 1 )
283 //!see a2dDocumentEvent \ingroup eventid
284 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_REMOVE_VIEW, 1 )
285 //!see a2dDocumentEvent \ingroup eventid
286 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_DISCONNECT_ALLVIEWS, 1 )
287 //!see a2dDocumentEvent \ingroup eventid
288 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_UPDATE_VIEWS, 1 )
289 //!see a2dDocumentEvent \ingroup eventid
290 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_ENABLE_VIEWS, 1 )
291 //!see a2dDocumentEvent \ingroup eventid
292 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_REPORT_VIEWS, 1 )
293 //!see a2dDocumentEvent \ingroup eventid
294 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_CHANGEDFILENAME_DOCUMENT, 1 )
295 //!see a2dDocumentEvent \ingroup eventid
296 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_CHANGEDTITLE_DOCUMENT, 1 )
297 //!see a2dDocumentEvent \ingroup eventid
298 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_CHANGEDMODIFY_DOCUMENT, 1 )
299 //!see a2dDocumentEvent \ingroup eventid
300 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_POST_LOAD_DOCUMENT, 1 )
301 
302 //!see a2dViewEvent \ingroup eventid
303 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_ACTIVATE_VIEW, 1 )
304 //!see a2dViewEvent \ingroup eventid
305 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_ACTIVATE_VIEW_SENT_FROM_CHILD, 1 )
306 //!see a2dViewEvent \ingroup eventid
307 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_CLOSE_VIEW, 1 )
308 //!see a2dViewEvent \ingroup eventid
309 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_CREATE_VIEW, 1 )
310 //!see a2dViewEvent \ingroup eventid
311 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_SET_DOCUMENT, 1 )
312 //!see a2dViewEvent \ingroup eventid
313 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_ENABLE_VIEW, 1 )
314 //!see a2dViewEvent \ingroup eventid
315 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_CHANGEDFILENAME_VIEW, 1 )
316 
317 //! see a2dTemplateEvent \ingroup eventid
318 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_PRE_ADD_DOCUMENT, 1 )
319 //! see a2dTemplateEvent \ingroup eventid
320 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_POST_CREATE_DOCUMENT, 1 )
321 //! see a2dTemplateEvent \ingroup eventid
322 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_POST_CREATE_VIEW, 1 )
323 //!see a2dTemplateEvent \ingroup eventid
324 DECLARE_EXPORTED_EVENT_TYPE( A2DDOCVIEWDLLEXP, wxEVT_DISCONNECT_VIEW, 1 )
325 
326 END_DECLARE_EVENT_TYPES()
327 
328 //! a2dView close event
329 /*!
330  Sent when a view needs to be closed.
331  The event can be vetod.
332  The event travels up to the parent window, when it is sent to a wxWindow and not processed or skipped.
333  Therefore if the event is sent to the Display Window (m_display) of a view, the event can eventually
334  arrive in a wxFrame class containing the wxWindow.
335  At any place in this hierachy of wxWindows , one will take care of detaching the view from the windows.
336 
337  When via the a2dDocumentCommandProcessor a view is closed, one is able to also cleanup wxWindow and wxFrames
338  which use the particular a2dView, this is via a2dDocument.
339 
340  The a2dView sents this event to the display window, and this window should might directly sent it
341  back to the a2dView. In case it does, this is not a problem, since the a2dView disables
342  itself while sending those events.
343 
344  The event Object is a a2dView.
345  The type of the event is ::wxEVT_CLOSE_VIEW, and only generated in a2dView::Close().
346  The event is first sent to the a2dDocument of the a2dView.
347  If not vetod, it is next sent to the m_display of the a2dView.
348  And if not vetod, it will be sent to the a2dView itself.
349  If not vetod there, the a2dView will be removed from the a2dDocument
350  its view list, and released.
351 
352 
353  \ingroup docview docviewevents events
354 
355 */
356 class A2DDOCVIEWDLLEXP a2dCloseViewEvent : public a2dEvent
357 {
358  DECLARE_CLASS( a2dCloseViewEvent )
359 
360 public:
361 
362  //! Constructor for view event of type ::wxEVT_CLOSE_VIEW
363  a2dCloseViewEvent( int id = 0 )
364  : a2dEvent( id, wxEVT_CLOSE_VIEW ),
365  m_veto( false ), // should be false by default
366  m_canVeto( true )
367  {
368  m_isCommandEvent = true; //let it go up to parent object in case of a wxWindow.
369  }
370 
371  //! constructor
373  : a2dEvent( event ),
374  m_veto( event.m_veto ),
375  m_canVeto( event.m_canVeto )
376  {
377  }
378 
379  //! clone the event.
380  virtual wxEvent* Clone() const { return new a2dCloseViewEvent( *this ); }
381 
382  //! use to veto event when the closing of the view needs to be refused in a handler.
383  void Veto( bool veto = true )
384  {
385  // GetVeto() will return false anyhow...
386  wxCHECK_RET( m_canVeto,
387  wxT( "call to Veto() ignored (can't veto this event)" ) );
388 
389  m_veto = veto;
390  }
391 
392  //! If the event can not be vetod this is set to false.
393  void SetCanVeto( bool canVeto ) { m_canVeto = canVeto; }
394 
395  //! If the event can be vetod this is set
396  bool CanVeto() const { return m_canVeto; }
397 
398  //! If the event can be vetod this return true
399  bool GetVeto() const { return m_canVeto && m_veto; }
400 
401 protected:
402 
403  //! veto flags.
404  bool m_veto, m_canVeto;
405 
406 };
407 
408 
409 //! a2dView event, to report events in the a2dView class
410 /*!
411  The event Object is a a2dView.
412 
413  The event travels up to the parent window, when it is sent to a wxWindow and not processed or skipped.
414  Therefore if the event is sent to the Display Window (m_display) of a view, the event can eventually
415  arive in a wxFrame class containing the wxWindow.
416 
417  If a2dView sents this event to the display window, this window might directly sent it
418  back to the a2dView. In case it does, this is not a problem, since the a2dView disables
419  itself while sending those events upwards.
420 
421  \ingroup docview docviewevents events
422 
423 */
424 class A2DDOCVIEWDLLEXP a2dViewEvent : public a2dEvent
425 {
426  DECLARE_CLASS( a2dViewEvent )
427 
428 public:
429 
430  //! for event types
431  /*!
432  - ::wxEVT_SET_DOCUMENT
433  Is sent by the a2dView when a wxDocument is set for it.
434  Intercepts this to initialize your ( new or existing ) view for that document.
435 
436  - ::wxEVT_CREATE_VIEW
437  Is sent by the a2dViewTemplate to the a2dView when the view
438  was just created. But after the document was set.
439  Intercepts this to initialize your new view.
440  */
441  a2dViewEvent( wxEventType type, a2dDocumentFlagMask flags, int id )
442  : a2dEvent( id, type )
443  {
444  m_bAllow = true;
445  m_isCommandEvent = true; //let it go up to parent object in case of a wxWindow.
446  m_flags = flags;
447  m_activate = false;
448  m_enable = false;
449  }
450 
451  //! for event types
452  /*!
453  - ::wxEVT_ENABLE_VIEW
454  Sent to a2dView and DisplayWindow from a2dView::Enable() or from the a2dDocument.
455  The last functions is called from a2dView::SetDisplayWindow( wxWindow* display )
456  to disable the old display window, and enable the new display window.
457 
458  - ::wxEVT_ACTIVATE_VIEW
459  sent from a2dView::Activate() to the view, Register your wxEvtHandler to recieve it.
460  ( intercepted at least by a2dDocumentCommandProcessor to set the view as the active
461  view within the a2dDocumentCommandProcessor )
462  Only when the currently active a2dView within the docmanager is different
463  from this one, it will FIRST sent a second ::wxEVT_ACTIVATE_VIEW to the old active view
464  to disable it. This event is ignored in a2dDocumentCommandProcessor itself.
465  The ::wxEVT_ACTIVATE_VIEW is sent to the a2dView itself to disable it.
466  The ::wxEVT_ACTIVATE_VIEW is sent from the view when the view is set active.
467 
468  - ::wxEVT_ACTIVATE_VIEW_SENT_FROM_CHILD
469  event sent from view and its display up the parent chain. The main use is to set in a2dDocumentFrame
470  the current view, so events from the frame arrive (via a window) at the (new) view when sent down there.
471 
472  */
473  a2dViewEvent( wxEventType type, bool value, int id )
474  : a2dEvent( id, type )
475  {
476  m_bAllow = true;
477  m_isCommandEvent = true; //let it go up to parent object in case of a wxWindow.
478  m_flags = a2dREFDOC_NON;
479  m_activate = false;
480  m_enable = false;
481  if ( type == wxEVT_ACTIVATE_VIEW || type == wxEVT_ACTIVATE_VIEW_SENT_FROM_CHILD )
482  {
483  m_activate = value;
484  }
485  else if ( type == wxEVT_ENABLE_VIEW )
486  {
487  m_enable = value;
488  }
489  }
490 
491  //! constructor
492  a2dViewEvent( const a2dViewEvent& event )
493  : a2dEvent( event )
494  {
495  m_bAllow = event.m_bAllow;
496  m_flags = event.m_flags;
497  m_activate = event.m_activate;
498  m_enable = event.m_enable;
499  }
500 
501  //! veto the operation (usually it's allowed by default)
502  void Veto() { m_bAllow = false; }
503 
504  //! allow the operation if it was disabled by default
505  void Allow() { m_bAllow = true; }
506 
507  //! for implementation code only, testing result of handler: is the operation allowed?
508  bool IsAllowed() const { return m_bAllow; }
509 
510  //! clone the event
511  virtual wxEvent* Clone() const { return new a2dViewEvent( *this ); }
512 
513  //! for following event types, get document flags of the event.
514  /*!
515  - ::wxEVT_SET_DOCUMENT
516  - ::wxEVT_CREATE_VIEW
517  */
518  a2dDocumentFlagMask GetFlags() { return m_flags; }
519 
520  //! when ::wxEVT_ACTIVATE_VIEW get activation value of the event
521  bool GetActive() { return m_activate; }
522 
523  //! when ::wxEVT_ENABLE_VIEW get enable value of the event
524  bool GetEnable() { return m_enable; }
525 
526 private:
527 
528  //! to allow or not this event, initiated with true.
529  bool m_bAllow;
530 
531  //! document flags ( interesting after a ::wxEVT_CREATE_VIEW event )
532  a2dDocumentFlagMask m_flags;
533 
534  //! activate value ( interesting after a ::wxEVT_ACTIVATE_VIEW event )
535  bool m_activate;
536 
537  //! activate value ( interesting after a ::wxEVT_ENABLE_VIEW event )
538  bool m_enable;
539 };
540 
541 
542 //! sent to document before closing
543 /*!
544  The event Object is a a2dDocument.
545  The type of the event is ::wxEVT_CLOSE_DOCUMENT.
546  This event is sent form bool a2dDocument::Close( bool force ) to the
547  a2dDocument itself.
548 
549  The default handler is a2dDocument::OnCloseDocument().
550  Which, if not vetod, disconnects ( and maybe closes ) the views on the document using a2dDocument::DisconnectAllViews().
551  This will generate a ::wxEVT_DISCONNECT_ALLVIEWS event for the a2dDocument, and
552  the same event is sent the view itself. Register your wxEvtHandler to recieve it.
553  Views should either close or detach themselfs from the document.
554 
555  \ingroup docview docviewevents events
556 
557 */
558 class A2DDOCVIEWDLLEXP a2dCloseDocumentEvent : public wxCloseEvent
559 {
560 public:
561 
562  //! constructor
563  a2dCloseDocumentEvent( int id = 0 )
564  : wxCloseEvent( wxEVT_CLOSE_DOCUMENT, id )
565  {
566  }
567 
568  //! constructor
570  : wxCloseEvent( event )
571  {
572  }
573 
574  //! clone the event
575  virtual wxEvent* Clone() const { return new a2dCloseDocumentEvent( *this ); }
576 
577 private:
578  DECLARE_CLASS( a2dCloseDocumentEvent )
579 
580 };
581 
582 //! used to report a2dDocument events
583 /*!
584  The event Object is a a2dDocument.
585 
586  a2dDocument does often get this event from the a2dDocumentCommandProcessor.
587 
588  \ingroup docview docviewevents events
589 
590 */
591 class A2DDOCVIEWDLLEXP a2dDocumentEvent : public a2dEvent
592 {
593  DECLARE_CLASS( a2dDocumentEvent )
594 
595 public:
596 
597 
598  //! for event types
599  /*!
600  - ::wxEVT_SAVE_DOCUMENT
601  Sent from bool a2dDocument::Save()
602 
603  - ::wxEVT_SAVEAS_DOCUMENT
604  Sent from bool a2dDocument::SaveAs()
605 
606  - ::wxEVT_CREATE_DOCUMENT
607  Sent from a2dDocumentTemplate::CreateDocument() to a2dDocument() just after
608  it created a new document.
609 
610  - ::wxEVT_NEW_DOCUMENT
611  Sent from bool a2dDocumentCommandProcessor::CreateDocument() when creating a new document
612  from a a2dDocumentTemplate.
613 
614  - ::wxEVT_OPEN_DOCUMENT
615  Sent from bool a2dDocumentCommandProcessor::CreateDocument() after creating a new document
616  from a a2dDocumentTemplate, which needs to have its contents read from a file.
617 
618  - ::wxEVT_DISCONNECT_ALLVIEWS
619  Sent from bool a2dDocument::DisconnectAllViews()
620  Register your wxEvtHandler to recieve it.
621 
622  - ::wxEVT_CHANGEDFILENAME_DOCUMENT
623  Sent from document after a change in file.
624  Register your wxEvtHandler to recieve it.
625 
626  - ::wxEVT_CHANGEDTITLE_DOCUMENT
627  Sent from document after a change in title.
628  Register your wxEvtHandler to recieve it.
629 
630  */
631  a2dDocumentEvent( wxEventType type, const wxFileName& filename, a2dDocumentFlagMask flags = a2dREFDOC_NON, int id = 0 )
632  : a2dEvent( id, type )
633  {
634  m_bAllow = true;
635  m_error = a2dError_NoError;
636  m_filename = filename;
637  m_flags = flags;
638  m_view = NULL;
639  m_doctemplate = NULL;
640  m_updateHint = 0;
641  m_objectHint = NULL;
642  m_reportViews = NULL;
643  }
644 
645 
646  //! for event types
647  /*!
648  - ::wxEVT_IMPORT_DOCUMENT
649  Sent from a2dDocument::Import( a2dDocumentTemplate* doctemplate )
650  Intercept this event to actually implement the import.
651 
652  - ::wxEVT_EXPORT_DOCUMENT
653  Sent from a2dDocument::Export( a2dDocumentTemplate* doctemplate )
654  Intercept this event to actually implement the export.
655 
656  The a2dIOHandlers of the choosen template, should/can be used for
657  importing/exporting a file.
658  This is what the default handlers a2dDocument::OnExportDocument
659  and a2dDocument::OnImportDocument do use.
660 
661  \param type ::wxEVT_IMPORT_DOCUMENT or ::wxEVT_EXPORT_DOCUMENT
662  \param doctemplate template choosen for importing or exporting.
663  \param filename if not empty the file name of the document
664  \param flags docuemnt flags
665  \param id event id
666 
667  */
668  a2dDocumentEvent( wxEventType type, a2dDocumentTemplate* doctemplate, const wxFileName& filename = wxFileName( wxT( "" ) ), a2dDocumentFlagMask flags = a2dREFDOC_NON, int id = 0 )
669  : a2dEvent( id, type )
670  {
671  m_bAllow = true;
672  m_error = a2dError_NoError;
673  m_filename = filename;
674  m_flags = flags;
675  m_view = NULL;
676  m_doctemplate = doctemplate;
677  m_updateHint = 0;
678  m_objectHint = NULL;
679  m_reportViews = NULL;
680  }
681 
682  //! for event types
683  /*!
684  ::wxEVT_REPORT_VIEWS
685  Sent from a2dDocument to a2dView's. a2dView will add itself to the reportlist of the event, but only
686  when this document is indeed used by the a2dView.
687  Register your wxEvtHandler to recieve it.
688  */
689  a2dDocumentEvent( wxEventType WXUNUSED( type ), a2dViewList* reportlist )
690  : a2dEvent( 0, wxEVT_REPORT_VIEWS )
691  {
692  m_bAllow = true;
693  m_error = a2dError_NoError;
694  m_filename = wxFileName( wxT( "" ) );
695  m_flags = 0;
696  m_view = NULL;
697  m_doctemplate = NULL;
698  m_updateHint = 0;
699  m_objectHint = NULL;
700  m_reportViews = reportlist;
701  }
702 
703  //! for event types
704  /*!
705  Following event types:
706 
707  - ::wxEVT_ADD_VIEW
708  Sent to a2dDocument when a view is added to it.
709 
710  - ::wxEVT_REMOVE_VIEW
711  Sent to a2dDocument when a view is removed from it.
712 
713  - ::wxEVT_UPDATE_VIEWS ( view != NULL is not changed )
714  Sent from a2dDocument::UpdateAllViews()
715 
716  - ::wxEVT_ENABLE_VIEWS ( view != NULL is not changed )
717  Sent from a2dDocument::EnableAllViews()
718  */
719  a2dDocumentEvent( wxEventType type, a2dView* view = NULL, bool enable = true, int id = 0 )
720  : a2dEvent( id, type )
721  {
722  m_bAllow = true;
723  m_error = a2dError_NoError;
724  m_view = view;
725  m_filename = wxFileName( wxT( "" ) );
726  m_flags = a2dREFDOC_NON;
727  m_doctemplate = NULL;
728  m_updateHint = 0;
729  m_objectHint = NULL;
730  m_reportViews = NULL;
731  m_enable = enable;
732  }
733 
734  //! constructor
736  : a2dEvent( event )
737  {
738  m_bAllow = event.m_bAllow;
739  m_error = event.m_error;
740  m_filename = event.m_filename;
741  m_flags = event.m_flags;
742  m_view = event.m_view;
743  m_doctemplate = event.m_doctemplate;
744  m_updateHint = event.m_updateHint;
745  m_objectHint = event.m_objectHint;
746  m_reportViews = event.m_reportViews;
747  m_enable = event.m_enable;
748  }
749 
750  //! veto the operation (usually it's allowed by default)
751  void Veto() { m_bAllow = false; }
752 
753  //! allow the operation if it was disabled by default
754  void Allow() { m_bAllow = true; }
755 
756  //! for implementation code only: is the operation allowed?
757  bool IsAllowed() const { return m_bAllow; }
758 
759  //! set filename of file to open, before sending the event.
760  void SetFileName( const wxFileName& filename ) { m_filename = filename; }
761 
762  //! get filename of file to open
763  wxFileName& GetFileName() { return m_filename; }
764 
765  virtual wxEvent* Clone() const { return new a2dDocumentEvent( *this ); }
766 
767  //! gives the a2dDocumentFlagMask in case of event types concerning a document.
768  a2dDocumentFlagMask GetFlags() { return m_flags; }
769 
770  //! Gives the a2dView in case of event types concerning a view.
771  /*!
772  Used with ::wxEVT_ADD_VIEW and ::wxEVT_REMOVE_VIEW
773  */
774  a2dView* GetView() { return m_view; }
775 
776  //! Get the template choosen to import / export.
777  /*!
778  Used with ::wxEVT_IMPORT_DOCUMENT and ::wxEVT_EXPORT_DOCUMENT.
779  */
780  a2dDocumentTemplate* GetDocumentTemplate() { return m_doctemplate; }
781 
782  void SetUpdateHint( unsigned int updateHint ) { m_updateHint = updateHint; }
783 
784  unsigned int GetUpdateHint() { return m_updateHint; }
785 
786  void SetUpdateObject( wxObject* objectHint ) { m_objectHint = objectHint; }
787 
788  wxObject* GetUpdateObject() { return m_objectHint; }
789 
790  a2dViewList* GetReportList() { return m_reportViews; }
791 
792  //! when ::wxEVT_ENABLE_VIEWS get enable value of the event
793  bool GetEnable() { return m_enable; }
794 
795  //! in case of errors when sending an event, this is to know the reason of failure
796  a2dError GetError() { return m_error; }
797 
798  //! in case of errors when sending an event, this can be set to tell the reason of failure
799  void SetError( a2dError error ) { m_error = error; }
800 
801 private:
802 
803  //! list of reported views
804  a2dViewList* m_reportViews;
805 
806  //! to allow or not this event, initiated with true.
807  bool m_bAllow;
808 
809  //! ::wxEVT_ENABLE_VIEWS ( to enable or diable views )
810  bool m_enable;
811 
812  //! document flags ( interesting after a ::wxEVT_CREATE_VIEW event )
813  a2dDocumentFlagMask m_flags;
814 
815  //! see GetView()
816  a2dView* m_view;
817 
818  //! see GetFileName()
819  wxFileName m_filename;
820 
821  //! see GetDocumentTemplate()
822  a2dDocumentTemplate* m_doctemplate;
823 
824  //! return code in case of errors loading documents etc.
825  a2dError m_error;
826 
827  unsigned int m_updateHint;
828 
829  wxObject* m_objectHint;
830 };
831 
832 
833 //! event sent to a2dViewConnector
834 /*!
835 
836  The ::wxEVT_PRE_ADD_DOCUMENT is sent to a viewconnector, after a new document was created
837  from a a2dDocumentTemplate, but before it is added to the a2dDocumentCommandProcessor.
838  And also just before ::wxEVT_POST_CREATE_DOCUMENT is sent to the same connector.
839  If wxEVT_PRE_ADD_DOCUMENT allows you to merge or copy a new created document with an already existing
840  document. In that case the document will be closed in the event handler, and after return
841  the ::wxEVT_POST_CREATE_DOCUMENT will not be sent.
842  The ::wxEVT_PRE_ADD_DOCUMENT gets as input the newly created document, and if merged return in that
843  the document used for merge, or NULL if document is just closed.
844 
845  The two events are generated via this template class, when a2dDocumentCommandProcessor creates
846  new documents.
847 
848  The default handler a2dViewConnector::OnPostCreateDocument(), will select
849  a a2dViewTemplate via the a2dDocumentCommandProcessor, and create the first view on the document
850  using that template.
851 
852  The ::wxEVT_POST_CREATE_DOCUMENT is sent to a viewconnector, after a new document was created
853  from a a2dDocumentTemplate.
854  The default handler a2dViewConnector::OnPostCreateDocument(), will select
855  a a2dViewTemplate via the a2dDocumentCommandProcessor, and create the first view on the document
856  using that template.
857 
858  The ::wxEVT_POST_CREATE_VIEW is sent to the viewconnector, after a new view was created from a a2dViewTemplate
859  The default handler a2dViewConnector::OnPostCreateView() will tell you that you need
860  to intercept this event in a derived a2dViewConnector.
861  The a2dViewConnector does not know how to connect new views into frames or windows etc.
862  A derived a2dViewConnector should know!
863 
864  The ::wxEVT_DISCONNECT_VIEW
865  Is sent from a2dViews via a2dViewTemplate to a2dViewConnector, in order to disconnect a view.
866 
867  \ingroup docview docviewevents events
868 
869 */
870 class A2DDOCVIEWDLLEXP a2dTemplateEvent : public a2dEvent
871 {
872  DECLARE_CLASS( a2dTemplateEvent )
873 
874 public:
875 
876  //! constructor
877  a2dTemplateEvent( a2dDocument* doc, wxEventType type, a2dDocumentFlagMask flags = a2dREFDOC_NON, int id = 0 )
878  : a2dEvent( id, type )
879  {
880  m_doc = doc;
881  m_flags = flags;
882  m_mask = a2dTemplateFlag::DEFAULT;
883  }
884 
885  //! constructor
886  a2dTemplateEvent( wxEventType type, a2dView* view, a2dDocumentFlagMask flags = a2dREFDOC_NON, int id = 0 )
887  : a2dEvent( id, type )
888  {
889  m_view = view;
890  m_flags = flags;
891  }
892 
893  //! constructor
895  : a2dEvent( event )
896  {
897  m_doc = event.m_doc;
898  m_flags = event.m_flags;
899  m_mask = event.m_mask;
900  }
901 
902  //! the document created.
903  a2dDocument* GetDocument() { return m_doc; }
904 
905  void SetDocument( a2dDocument* doc ) { m_doc = doc; }
906 
907  //! the document flags as set by a2dDocumentTemplate::CreateDocument()
908  a2dDocumentFlagMask GetFlags() { return m_flags; }
909 
910  a2dTemplateFlagMask GetTemplateMaskFlags() { return m_mask; }
911 
912  //! clone the event
913  virtual wxEvent* Clone() const { return new a2dTemplateEvent( *this ); }
914 
915  //! Get the view created.
916  a2dView* GetView() { return m_view; }
917 
918  //! Set the view created
919  void SetView( a2dView* view ) { m_view = view; }
920 
921 private:
922 
923  //! see GetDocument()
924  a2dDocument* m_doc;
925 
926  //! see GetFlags()
927  a2dDocumentFlagMask m_flags;
928 
929  a2dTemplateFlagMask m_mask;
930 
931  //! see GetView()
932  a2dView* m_view;
933 };
934 
935 /*! \addtogroup eventhandlers
936 * @{
937 */
938 
939 
940 typedef void ( wxEvtHandler::*a2dDocumentCloseEventFunction )( a2dCloseDocumentEvent& );
941 typedef void ( wxEvtHandler::*a2dDocumentEventFunction )( a2dDocumentEvent& );
942 typedef void ( wxEvtHandler::*a2dViewCloseEventFunction )( a2dCloseViewEvent& );
943 typedef void ( wxEvtHandler::*a2dViewEventFunction )( a2dViewEvent& );
944 typedef void ( wxEvtHandler::*a2dTemplateEventFunction )( a2dTemplateEvent& );
945 //! \endcond
946 
947 #define a2dDocumentCloseEventHandler(func) \
948  (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(a2dDocumentCloseEventFunction, &func)
949 #define a2dDocumentEventHandler(func) \
950  (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(a2dDocumentEventFunction, &func)
951 #define a2dViewCloseEventHandler(func) \
952  (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(a2dViewCloseEventFunction, &func)
953 #define a2dViewEventHandler(func) \
954  (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(a2dViewEventFunction, &func)
955 #define a2dTemplateEventHandler(func) \
956  (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(a2dTemplateEventFunction, &func)
957 
958 //! event for document before all view are closed.
959 #define EVT_DISCONNECT_ALLVIEWS(func) wx__DECLARE_EVT0( wxEVT_DISCONNECT_ALLVIEWS, a2dDocumentEventHandler( func ))
960 //! event for document before a document will be closed ( can veto)
961 #define EVT_CLOSE_DOCUMENT(func) wx__DECLARE_EVT0( wxEVT_CLOSE_DOCUMENT, a2dDocumentCloseEventHandler( func ))
962 //! event for document when a document has been opened
963 #define EVT_OPEN_DOCUMENT(func) wx__DECLARE_EVT0( wxEVT_OPEN_DOCUMENT, a2dDocumentEventHandler( func ))
964 //! event for document when a document new document was created
965 #define EVT_NEW_DOCUMENT(func) wx__DECLARE_EVT0( wxEVT_NEW_DOCUMENT, a2dDocumentEventHandler( func ))
966 //! event sent to document from template when a document has been created
967 #define EVT_CREATE_DOCUMENT(func) wx__DECLARE_EVT0( wxEVT_CREATE_DOCUMENT, a2dDocumentEventHandler( func ))
968 //! event sent to document when a document needs to be saved
969 #define EVT_SAVE_DOCUMENT(func) wx__DECLARE_EVT0( wxEVT_SAVE_DOCUMENT, a2dDocumentEventHandler( func ))
970 //! event sent to document when a document needs to be saved in a different file
971 #define EVT_SAVEAS_DOCUMENT(func) wx__DECLARE_EVT0( wxEVT_SAVEAS_DOCUMENT, a2dDocumentEventHandler( func ))
972 //! event sent to document when a document is modified and the user may save or not
973 #define EVT_SAVE_MODIFIED_DIALOG_DOCUMENT(func) wx__DECLARE_EVT0( wxEVT_SAVE_MODIFIED_DIALOG_DOCUMENT, a2dDocumentEventHandler( func ))
974 //! event for document when a document will be exported
975 #define EVT_EXPORT_DOCUMENT(func) wx__DECLARE_EVT0( wxEVT_EXPORT_DOCUMENT, a2dDocumentEventHandler( func ))
976 //! event for document when a document will be imported
977 #define EVT_IMPORT_DOCUMENT(func) wx__DECLARE_EVT0( wxEVT_IMPORT_DOCUMENT, a2dDocumentEventHandler( func ))
978 //! event from a document when its views need to be updated
979 #define EVT_UPDATE_VIEWS(func) wx__DECLARE_EVT0( wxEVT_UPDATE_VIEWS, a2dDocumentEventHandler( func ))
980 //! event from a document when its views need to be enabled or disabled
981 #define EVT_ENABLE_VIEWS(func) wx__DECLARE_EVT0( wxEVT_ENABLE_VIEWS, a2dDocumentEventHandler( func ))
982 //! event from a document when its views need to reported
983 #define EVT_REPORT_VIEWS(func) wx__DECLARE_EVT0( wxEVT_REPORT_VIEWS, a2dDocumentEventHandler( func ))
984 //! event sent to view when the filename of a document has changed.
985 #define EVT_CHANGEDFILENAME_DOCUMENT(func) wx__DECLARE_EVT0( wxEVT_CHANGEDFILENAME_DOCUMENT, a2dDocumentEventHandler( func ))
986 //! event sent to view when the title of a document has changed.
987 #define EVT_CHANGEDTITLE_DOCUMENT(func) wx__DECLARE_EVT0( wxEVT_CHANGEDTITLE_DOCUMENT, a2dDocumentEventHandler( func ))
988 //! event send from a document when modified status changed.
989 #define EVT_CHANGEDMODIFY_DOCUMENT(func) wx__DECLARE_EVT0( wxEVT_CHANGEDMODIFY_DOCUMENT, a2dDocumentEventHandler( func ))
990 //! event send from a document just after a document was loaded from a file
991 #define EVT_POST_LOAD_DOCUMENT(func) wx__DECLARE_EVT0( wxEVT_POST_LOAD_DOCUMENT, a2dDocumentEventHandler( func ))
992 //! event sent to document and view when a view needs to be closed ( can veto)
993 #define EVT_CLOSE_VIEW(func) wx__DECLARE_EVT0( wxEVT_CLOSE_VIEW, a2dViewCloseEventHandler( func))
994 //! event sent to view from template when a view has been created
995 #define EVT_CREATE_VIEW(func) wx__DECLARE_EVT0( wxEVT_CREATE_VIEW, a2dViewEventHandler( func ))
996 //! event sent to view when a new document is ser for it.
997 #define EVT_SET_DOCUMENT(func) wx__DECLARE_EVT0( wxEVT_SET_DOCUMENT, a2dViewEventHandler( func ))
998 //! event sent to view and document manager
999 #define EVT_ACTIVATE_VIEW(func) wx__DECLARE_EVT0( wxEVT_ACTIVATE_VIEW, a2dViewEventHandler( func ))
1000 //! event sent from view and its display up the parent chain.
1001 #define EVT_ACTIVATE_VIEW_SENT_FROM_CHILD(func) wx__DECLARE_EVT0( wxEVT_ACTIVATE_VIEW_SENT_FROM_CHILD, a2dViewEventHandler( func ))
1002 //! event sent to connector to disable or enable for a certain view
1003 #define EVT_ENABLE_VIEW(func) wx__DECLARE_EVT0( wxEVT_ENABLE_VIEW, a2dViewEventHandler( func ))
1004 //! event sent to document when a view has been added to the document
1005 #define EVT_ADD_VIEW(func) wx__DECLARE_EVT0( wxEVT_ADD_VIEW, a2dDocumentEventHandler( func ))
1006 //! event sent to document when a view will be removed from the document
1007 #define EVT_REMOVE_VIEW(func) wx__DECLARE_EVT0( wxEVT_REMOVE_VIEW, a2dDocumentEventHandler( func ))
1008 //! sent from a doc template after it created a document
1009 #define EVT_PRE_ADD_DOCUMENT(func) wx__DECLARE_EVT0( wxEVT_PRE_ADD_DOCUMENT, a2dTemplateEventHandler( func ))
1010 //! sent from a doc template after it created a document
1011 #define EVT_POST_CREATE_DOCUMENT(func) wx__DECLARE_EVT0( wxEVT_POST_CREATE_DOCUMENT, a2dTemplateEventHandler( func ))
1012 //! sent from a view template after it created a view
1013 #define EVT_POST_CREATE_VIEW(func) wx__DECLARE_EVT0( wxEVT_POST_CREATE_VIEW, a2dTemplateEventHandler( func ))
1014 //! event sent to connector to disconnect a certain view from its document
1015 #define EVT_DISCONNECT_VIEW(func) wx__DECLARE_EVT0( wxEVT_DISCONNECT_VIEW, a2dTemplateEventHandler( func ))
1016 //! event sent from view upwards to display, when the filename of a document has changed.
1017 #define EVT_CHANGEDFILENAME_VIEW(func) wx__DECLARE_EVT0( wxEVT_CHANGEDFILENAME_VIEW, a2dViewEventHandler( func ))
1018 //! event sent from view upwards to display, when the title of a document has changed.
1019 #define EVT_CHANGEDTITLE_VIEW(func) wx__DECLARE_EVT0( wxEVT_CHANGEDTITLE_VIEW, a2dViewEventHandler( func ))
1020 
1021 //! @} eventhandlers
1022 
1023 class A2DDOCVIEWDLLEXP a2dIOHandlerXmlSerIn;
1024 class A2DDOCVIEWDLLEXP a2dIOHandlerXmlSerOut;
1025 
1026 //! The document class can be used to model an application's file-based data.
1027 /*! It is part of the document/view framework,
1028  and cooperates with the a2dView, a2dDocumentTemplate, a2dViewTemplate and a2dDocumentCommandProcessor classes.
1029 
1030  a2dDocument can also be used in a setting with just a2dView's and/or templates, so without
1031  a a2dDocumentCommandProcessor controlling most tasks. Most events coming from the document meant
1032  for the a2dView (e.g. Update events) will be received, since it is always registered to the document.
1033  For others register your wxEvtHandler to recieve events.
1034  Therefore if you just want to display the fixed data in the a2dDocument, a a2dDocumentCommandProcessor is not really
1035  needed.
1036  In the general case with several view and documents, it is best to use a a2dDocumentCommandProcessor.
1037 
1038 
1039  Events types which can be/are intercepted:
1040 
1041  - ::wxEVT_CLOSE_VIEW sent when a view wants to be closed ( may veto )
1042  - ::wxEVT_DISCONNECT_ALLVIEWS sent to document and document manager within DisconnectAllViews().
1043  - ::wxEVT_CLOSE_DOCUMENT sent to document just after calling Close()
1044  - ::wxEVT_ADD_VIEW sent to document just after a view was added to the document
1045  - ::wxEVT_REMOVE_VIEW sent to document just before a view is removed from the document
1046  - ::wxEVT_OPEN_DOCUMENT sent by docmanager when a document was created and opened from a file.
1047  Default handler loads the file.
1048  - ::wxEVT_NEW_DOCUMENT sent by docmanager when a document was created as new.
1049  See default handler.
1050  - ::wxEVT_CREATE_DOCUMENT sent after creation of document from a template.
1051  - ::wxEVT_SAVE_DOCUMENT sent to save document ( e.g from Save() )
1052  - ::wxEVT_SAVEAS_DOCUMENT sent to save document under a different name ( e.g from SaveAs() )
1053  - ::wxEVT_EXPORT_DOCUMENT sent to export a document ( e.g from Export())
1054  - ::wxEVT_IMPORT_DOCUMENT sent to export a document ( e.g from Import())
1055  - ::wxEVT_POST_LOAD_DOCUMENT sent just after a document was loaded from a file in LoadObject()
1056  - ::wxEVT_CHANGEDMODIFY_DOCUMENT sent just after a document its modify flag has changed in Modify()
1057  - ::wxEVT_REPORT_VIEWS sent to the event views, to assemble all a2dView using the document.
1058  - ::wxEVT_UPDATE_VIEWS sent when all view need to update them selfs ( e.g. after a change in the document )
1059  \see UpdateAllViews()
1060  - ::wxEVT_ENABLE_VIEWS sent from EnableAllViews(), to disable or enable all views on the document.
1061  - ::wxEVT_CHANGEDFILENAME_DOCUMENT sent from SetFilename(), when the document its fileinfo has changed.
1062  - ::wxEVT_CHANGEDTITLE_DOCUMENT sent from SetTitle(), when the document its title has changed.
1063 
1064  \ingroup docview
1065 */
1066 class A2DDOCVIEWDLLEXP a2dDocument : public a2dObject
1067 {
1068  DECLARE_ABSTRACT_CLASS( a2dDocument )
1069 
1070  DECLARE_EVENT_TABLE()
1071 
1072 public:
1073 
1074  //! Constructor.
1075  /*!
1076  The document may have a parent, so a hierachically structure of
1077  documents is possible.
1078 
1079  \remark
1080  Current implementation doesn't support a nice access to parent/child
1081  docs.
1082 
1083  \param parent The document's parent
1084  */
1085  a2dDocument( a2dDocument* parent = ( a2dDocument* ) NULL );
1086 
1087  //! destructor
1088  ~a2dDocument();
1089 
1090  //! constructor with other document
1091  a2dDocument( const a2dDocument& other );
1092 
1093  // accessors
1094 
1095  //!Sets the filename for this document. Usually called by the framework.
1096  /*!
1097  If notifyViews is true, a a2dDocumentEvent of type ::wxEVT_CHANGEDFILENAME_DOCUMENT.
1098  Register your wxEvtHandler to recieve it.
1099  */
1100  void SetFilename( const wxFileName& filename, bool notifyViews = false );
1101 
1102  //! Get the file name in use for this document.
1103  wxFileName GetFilename() const { return m_documentFile; }
1104 
1105  //!Sets the title for this document.
1106  /*!
1107  The document title is used for an associated frame (if any), and is usually
1108  constructed by the framework from the filename.
1109  The title may be changed by the programmer or set by an IOHandler
1110 
1111  \param title The title of the document.
1112  \param notifyViews If <code>true</code> a a2dDocumentEvent of type ::wxEVT_CHANGEDTITLE_DOCUMENT
1113  Register your wxEvtHandler to recieve it.
1114  */
1115  void SetTitle( const wxString& title, bool notifyViews = false );
1116 
1117  //! Returns the title for this document.
1118  wxString GetTitle() const { return m_documentTitle; }
1119 
1120  //!Sets the document type name for this document. See the comment for documentTypeName.
1121  void SetDocumentTypeName( const wxString& name ) { m_documentTypeName = name; };
1122 
1123  //!Gets the document type name of this document. See the comment for documentTypeName.
1124  wxString GetDocumentTypeName() const { return m_documentTypeName; }
1125 
1126  //! Returns if the document was saved after a modification.
1127  bool GetDocumentSaved() const { return m_savedYet; }
1128 
1129  //! Alias for a2dDocument::GetDocumentSaved
1130  bool IsDocumentSaved() const { return GetDocumentSaved(); }
1131 
1132  //! Sets the document saved flag.
1133  /*!
1134  The document saved flag is normally set by the framework,
1135  */
1136  void SetDocumentSaved( bool saved = true ) { m_savedYet = saved; }
1137 
1138  //! returns true when document is closed or busy closing.
1139  /*!
1140  Closing a document in general includes closing its views too.
1141  When busy closing a document, this function here can be used to prevent recursive calls elsewhere.
1142  You can savely call Close() anyway, but if other actions depends on the document being closed or not,
1143  you can check it with this here. A typical example is a closing a document and also releasing it from
1144  some higher order class.
1145  \see Close() for more.
1146  */
1147  bool IsClosed() { return m_isClosed; }
1148 
1149  //!Closes the document if not vetod.
1150  /*!Closing a document means that the application does not want the
1151  the document in memory anymore in order to view or modify it.
1152  This function prepares the document for deletion.
1153 
1154  Sents a ::wxEVT_CLOSE_DOCUMENT event.
1155  The default handler is OnCloseDocument( a2dCloseDocumentEvent& event ).
1156 
1157  Default calls SaveModifiedDialog(), to give the user a change to save his changes.
1158 
1159  This does not normally delete the document object, which only happens if the reference
1160  count reaches zero, indicating no more Owners do exist.
1161 
1162  \see OnCloseDocument
1163  \see SaveModifiedDialog
1164  */
1165  bool Close( bool force );
1166 
1167 
1168  //!Saves the document by sending a a2dDocumentEvent ::wxEVT_SAVE_DOCUMENT event.
1169  /*!
1170  The method first tests if the document is modified and not saved yet.
1171  If it is modified and not saved, the event is sent.
1172 
1173  \see OnSaveDocument
1174 
1175  \return true if the document could be saved
1176  */
1177  bool Save();
1178 
1179  //! Tries to save the document by sending a a2dDocumentEvent ::wxEVT_SAVEAS_DOCUMENT event.
1180  /*!
1181  The default handler asks for a file, to save the document into.
1182 
1183  \see OnSaveAsDocument
1184 
1185  \return true if the document could be saved
1186  */
1187  bool SaveAs( const wxFileName& fileTosaveTo = wxFileName( wxT( "" ) ), a2dDocumentFlagMask flags = a2dREFDOC_NON );
1188 
1189 
1190  //! Tries to save the document by sending a a2dDocumentEvent ::wxEVT_EXPORT_DOCUMENT event.
1191  /*!
1192  \see OnExportDocument
1193 
1194  \return true if the document could be saved
1195  */
1196  bool Export( a2dDocumentTemplate* doctemplate, const wxFileName& fileTosaveTo = wxFileName( wxT( "" ) ), a2dDocumentFlagMask flags = a2dREFDOC_NON );
1197 
1198  //! Tries to read a file into the document by sending a a2dDocumentEvent ::wxEVT_IMPORT_DOCUMENT event.
1199  /*!
1200  \see OnImportDocument
1201 
1202  \return true if the document could be read
1203  */
1204  bool Import( a2dDocumentTemplate* doctemplate, const wxFileName& fileToImport = wxFileName( wxT( "" ) ), a2dDocumentFlagMask flags = a2dREFDOC_NON );
1205 
1206  //! Normally should undo all changes by rereading the file again.
1207  /*!
1208  \todo
1209  make a default implementation which does do it
1210  ( unless already saved the changes sofar )
1211  */
1212  virtual bool Revert();
1213 
1214  //! handling loading of the document from a stream
1215  /*! The given handler is used to load the document from the stream.
1216 
1217  Override this function to implement your own version.
1218  LoadObject is called by the framework automatically when
1219  the document contents needs to be loaded.
1220 
1221  \note only one of these forms exists, depending on how wxWindows was configured.
1222  */
1223  virtual a2dDocumentInputStream& LoadObject( a2dDocumentInputStream& stream, a2dIOHandlerStrIn* handler );
1224 
1225  //! handling saving and exporting of the document to a stream
1226  /*! The a2dIOHandler given is used to save the document to the stream.
1227 
1228  Override this function to implement your own version.
1229  SaveObject is called by the framework automatically when
1230  the document contents need to be saved.
1231 
1232  \note only one of these forms exists, depending on how wxWindows was configured.
1233  */
1234  virtual a2dDocumentOutputStream& SaveObject( a2dDocumentOutputStream& stream, a2dIOHandlerStrOut* handler );
1235 
1236  //! can be set by a2dIOHandler's by e.g LoadObject().
1237  /*!
1238  If parsing a document from the stream is incorrect due to formating errors, the handler or LoadObject itself
1239  can set this error code, which result in veto-ing the event.
1240  */
1241  void SetLastError( a2dError lastError ) { m_lastError = lastError; }
1242 
1243  //! is set by a2dIOHandler's and is tested by LoadObject().
1244  /*!
1245  If parsing a document from the stream is incorrect due to formating errors, the handler or LoadObject itself
1246  can set this error code.
1247  */
1248  a2dError GetLastError() { return m_lastError; }
1249 
1250 #if wxART2D_USE_CVGIO
1251  //! used by CVG parser
1252  /*!
1253  \remark do not use directly
1254  */
1255  void Load( wxObject* parent, a2dIOHandlerXmlSerIn& parser );
1256 
1257  //! called from a2dIOHandlerXmlSerOut after a SaveObject.
1258  /*!
1259  \param parent parent object from which Save was called
1260  \param out CVG io handler
1261  \param towrite object to write later
1262  */
1263  void Save( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dObjectList* towrite );
1264 
1265  //! called from a2dIOHandlerXmlSerOut after a SaveObject.
1266  /*!
1267  \param out CVG io handler
1268  \param start start wrting from this object
1269  */
1270  void Save( a2dIOHandlerXmlSerOut& out, wxObject* start = NULL );
1271 #endif //wxART2D_USE_CVGIO
1272 
1273  //! dialog when the user needs to confirm saving a document
1274  /*!
1275  If the document has been modified, prompts the user to ask if the
1276  changes should be saved.
1277  If the user replies Yes, the Save function is called and return is wxYES.
1278  If No, the document is marked as unmodified and return is wxNO
1279  If Cancel return is wxCANCEL.
1280  If document was not modified, also wxYES is returned.
1281  */
1282  virtual int SaveModifiedDialog( bool canCancel = true );
1283 
1284  //! create a command processor and set it for the document.
1285  /*!
1286  If available the existing commandprocessor will be deleted.
1287  A new CommandProcessor will be created and set for the document.
1288 
1289  Override if you need a more application specific commandhandler.
1290  */
1291  virtual void CreateCommandProcessor();
1292 
1293  //!Returns a pointer to the command processor associated with this document
1294  a2dCommandProcessor* GetCommandProcessor() const { return m_commandProcessor; }
1295 
1296  //! Sets the command processor to be used for this document.
1297  /*!
1298  Use in case you need one a2dCommandProcessor to be used for several
1299  a2dDocument's,
1300  Make sure you set it to NULL before deleting the document itself,
1301  else the a2dDocument destructor will delete it ( leaving the others
1302  with dangling pointers ).
1303  */
1304  void SetCommandProcessor( a2dCommandProcessor* proc ) { m_commandProcessor = proc; }
1305 
1306  //! called when there is a need to clear the contents of the document.
1307  /*!
1308  Override this function to define the way to do this.
1309  */
1310  virtual void DeleteContents();
1311 
1312  //! Might be used to draw the contents of a document to a a2dView using a wxDc as the drawing context.
1313  /*!
1314  You need to override this method in derived class to do something usefull.
1315 
1316  \return default only returns true
1317  */
1318  virtual bool Draw( wxDC& context );
1319 
1320  //! Has the document been modified
1321  bool IsModified() const { return m_documentModified != 0; }
1322 
1323  //! set the docuent as modified or not
1324  /*!
1325  If the modified status changes an ::wxEVT_CHANGEDMODIFY_DOCUMENT event will
1326  be send.
1327 
1328  \param mod <code>true</code> to set document modified, else <code>false</code>
1329  */
1330  void Modify( bool mod );
1331 
1332  //! Ask to save when document is modified and last view is closed?
1333  /*!
1334  When there are still owners of the document, and the last view is closed
1335  it can either be saved or delayed until the application closes.
1336  Setting AskSaveWhenOwned delayes the saving of the data until later.
1337  */
1338  void AskSaveWhenOwned( bool askSaveWhenOwned ) { m_askSaveWhenOwned = askSaveWhenOwned; }
1339 
1340 
1341  //! sent Update events to all a2dView which display or use this document.
1342  /*!
1343  This function is typicaly called when the document its contents has changed,
1344  this in general will result in the a2dView displaying this new information.
1345  Understand that this only informs the views to update themselfs, how and what the view needs
1346  to update can be indicated by the hints, or in more complex situations the views will
1347  read the document contents to see what did change, and only update what changed in its view.
1348 
1349  \param sender which view did calls this function ( Non = NULL ).
1350  \param hint update will differ on the hint given and the implementation
1351  \param objecthint more complex way to deliver hints
1352 
1353  */
1354  virtual void UpdateAllViews( a2dView* sender = ( a2dView* ) NULL, unsigned int hint = a2dVIEW_UPDATE_ALL, wxObject* objecthint = ( wxObject* ) NULL );
1355 
1356 
1357  //! sents a ::wxEVT_REPORT_VIEWS to all views, via the a2dDocumentCommandProcessor.
1358  /*!
1359  The a2dView's using this document will report themself by adding
1360  itself to the allviews list.
1361  */
1362  void ReportViews( a2dViewList* allviews );
1363 
1364  //! calls Enable( true/false ) for each view.
1365  /*!
1366  Enables or disables all views. If sender is non-NULL, does NOT call it for this view.
1367  The disabling a a2dView means that it will not process any events, until enabled again.
1368  */
1369  void EnableAllViews( bool enable, a2dView* sender = ( a2dView* ) NULL );
1370 
1371  //! Disconnect a2dView's using this document.
1372  /*!
1373  It depends on the application if a disconnected view will be closed or not.
1374  In case the views will be resused for another document after disconnecting them,
1375  obviously they should not be closed. Typically thsi will be the case in a one frame application,
1376  where the frame has one or more fixed views, which will be used for the currently open document.
1377 
1378  Before starting to disconnect the views, a a2dDocumentEvent type ::wxEVT_DISCONNECT_ALLVIEWS is sent to
1379  this a2dDocument, which can be intercepted to do some general cleanup on the
1380  document.
1381 
1382  In case the a2dView::Close() is called on disconnection, .
1383  this generates a a2dCloseViewEvent (type ::wxEVT_CLOSE_VIEW ) sent to the
1384  document and the view. The event can not be vetod for this action.
1385  */
1386  void DisConnectAllViews();
1387 
1388  //! Gets a2dDocumentTemplate pointer which was used to create the a2dView
1389  a2dDocumentTemplate* GetDocumentTemplate() const { return m_documentTemplate; }
1390 
1391  //! Set a2dDocumentTemplate pointer
1392  void SetDocumentTemplate( a2dDocumentTemplate* temp ) { m_documentTemplate = temp; }
1393 
1394  //! Get title, or filename if no title, else [unnamed]
1395  wxString GetPrintableName() const;
1396 
1397  //! Returns a window that can be used as a parent for document-related dialogs. Override if necessary.
1398  virtual wxWindow* GetAssociatedWindow() const;
1399 
1400  //! Sets a time of last modification
1401  /*!
1402  \param datatime new modification time
1403  */
1404  void SetModificationTime( const wxDateTime& datatime ) { m_modificationtime = datatime; }
1405 
1406  //! Returns the time of last modification when the document was saved
1407  /*!
1408  \return time of last modification
1409  */
1410  wxDateTime& GetModificationTime() { return m_modificationtime; }
1411 
1412 protected:
1413 
1414  //!Clone document
1415  a2dObject* DoClone( a2dObject::CloneOptions options, a2dRefMap* refs ) const;
1416 
1417  //! default handler for ::wxEVT_CREATE_DOCUMENT, Called after creation of document from a template.
1418  /*! Called by framework if the documemt is created automatically by the default document
1419  manager (via a document template).
1420  This gives the document a chance to initialise.
1421 
1422  This Default handler does Nothing Yet.
1423  */
1424  void OnCreateDocument( a2dDocumentEvent& event );
1425 
1426  //! Called by wxWindows when a file needs to be saved
1427  /*!
1428  Default handler for a2dDocumentEvent of type ::wxEVT_SAVE_DOCUMENT.
1429 
1430  Save in the file filename of the document,
1431  or call SaveAs if the filename is not set.
1432 
1433  Constructs an output file stream for the given filename (which must not be empty),
1434  and calls SaveObject. If SaveObject returns true, the document is
1435  set to unmodified; otherwise, an error message box is displayed.
1436 
1437  event is set Allowed if the file could be opened and the document was saved.
1438 
1439  \remark the document its a2dDocumentTemplate is used to find the right a2dIOHandlerStrOut via
1440  a2dDocumentTemplate::GetDocumentIOHandlerForSave().
1441 
1442  */
1443  void OnSaveDocument( a2dDocumentEvent& event );
1444 
1445 
1446  //! default handler for a2dDocumentEvent of type ::wxEVT_SAVEAS_DOCUMENT
1447  /*!
1448  Prompts the user for a file to save to.
1449 
1450  Notifies the views that the filename has changes by sending ::wxEVT_CHANGEDFILENAME_DOCUMENT.
1451  Register your wxEvtHandler to receive it.
1452 
1453  \remark the document its a2dDocumentTemplate is used to find the right a2dIOHandlerStrOut via
1454  a2dDocumentTemplate::GetDocumentIOHandlerForSave().
1455 
1456  */
1457  void OnSaveAsDocument( a2dDocumentEvent& event );
1458 
1459  //! load a document from a file into this document
1460  /*!
1461  Default handler for a2dDocumentEvent of type ::wxEVT_OPEN_DOCUMENT.
1462 
1463  In the default handler SaveModifiedDialog() is called first, and if the document is modified
1464  the user is asked to save the changes. Cancel will not open the file into the document.
1465 
1466  Constructs an input file stream for the given filename (which must not be empty),
1467  and calls LoadObject. If LoadObject returns true, the document is set to unmodified; otherwise,
1468  an error message box is displayed. The document's views are notified that the filename has changed,
1469  to give windows an opportunity to update their titles.
1470  All of the document's views are then updated.
1471 
1472  \remark m_documentTemplate must be set for the default handler to work.
1473 
1474  \note only one of these forms exists, depending on how wxWindows was configured.
1475  */
1476  void OnOpenDocument( a2dDocumentEvent& event );
1477 
1478  //! called after creating a new document from a template , in order to initialize it.
1479  /*!
1480  called by:
1481  a2dDocumentCommandProcessor::CreateDocument()
1482  a2dDocumentCommandProcessor::AddCreatedDocument()
1483 
1484  Default handler for a2dDocumentEvent of type ::wxEVT_NEW_DOCUMENT.
1485 
1486  The default makes a default title for the document, and notifies the views that the filename
1487  (in fact, the title) has changed.
1488 
1489  The user can intercept the event to fill new documents if empty,
1490  but do Skip() the event for the base implementation to be called.
1491 
1492  Understand that views might already by open on the document.
1493  */
1494  void OnNewDocument( a2dDocumentEvent& event );
1495 
1496  //! called when document is closed
1497  /*!
1498  Default handler for a2dDocumentEvent of type ::wxEVT_CLOSE_DOCUMENT.
1499 
1500  The default implementation, calls SaveModifiedDialog(), and if not canceled,
1501  disconnects and/or closes all views using DisconnectAllViews().
1502  This leads to sending ::wxEVT_DISCONNECT_ALLVIEWS to the document and ::wxEVT_CLOSE_VIEW
1503  to each view. This enables the program to delete or detach views etc.
1504  Next empties the document by calling DeleteContents setting modified flag to false.
1505 
1506  Override this to supply additional behaviour
1507  when the document is closed with Close.
1508 
1509  e.g. In a single document and view approach, you very likely want
1510  to call DeleteContents and set the modified flag to false.
1511 
1512  Emptying a document while views are using it, is dangerous.
1513  Views may refer to or use objects in the document.
1514  Therefore the default:
1515  - closes all views ( holding and display parts of the document, else maybe dangling pointers )
1516  - clears the undo stack ( which may hold references to objects within the document )
1517  - empty the document
1518 
1519  \remark Remember a view also Owns a reference to a document, so certainly all views need to be gone
1520  to really get a document deleted.
1521  */
1522  void OnCloseDocument( a2dCloseDocumentEvent& event );
1523 
1524 
1525  //! Intercept to do cleanup/veto closing of a view
1526  /*!
1527  The handler function for EVT_CLOSE_VIEW, it is called when the program tries
1528  to close a View.
1529 
1530  The frame or window containing the view sent a EVT_CLOSE_WINDOW, this
1531  results in a EVT_CLOSE_VIEW being sent to the document and to the view.
1532  OR The a2dDocumentCommandProcessor is closing all documents plus views.
1533 
1534  The a2dCloseViewEvent is generated via the a2dView::Close function, so that
1535  the application can also invoke the handler programmatically.
1536 
1537  \sa a2dCloseViewEvent for the way the event is propegated to the several classes in
1538  the docview framework.
1539  If OnCloseView does not veto the close event, the a2dView will futher
1540  propegate the event.
1541 
1542  The Default implementation:
1543  Checks if the view is the last reference for the document; if so, asks user
1544  to confirm save data.
1545  If AskSaveWhenOwned() == true it will always ask to save the data.
1546  */
1547  void OnCloseView( a2dCloseViewEvent& event );
1548 
1549  //! what to do when a view using this document will stop using it.
1550  /*! When a view is switching its document to another document, or when a view is closed,
1551  this event is sent to the document just before a2dView releases the document.
1552  The default implementation asks to save the document if it was modified, but only if m_askSaveWhenOwned
1553  is true or m_refcount has reached 1, which is when only the view itself Own the document.
1554  In an application where this document is also controlled by a a2dDocumentCommandProcessor, the refcount
1555  would by two.
1556  When an application has a fixed set of views (per Frame) used by any document that is shown,
1557  it of course makes no sence to automatically close a document when the refcount reaches 1.
1558  In a standard "multi child frame+view + document", one can automatically close the document when
1559  a refcount of < 2 is reached. Which means when a document its last view is closed, and the document
1560  is only owned by the controlling a2dDocumentCommandProcessor.
1561  To make this happen intercept the ::wxEVT_REMOVE_VIEW, and implement whatever you need.
1562  In this case you should call a2dDocviewGlobals->GetDocviewCommandProcessor()->FileClose() in order
1563  to Close the document, which leads to the a2dDocumentCommandProcessor releasing the document.
1564  The very last release and therefore deletion will be done in a2dView after returning from the
1565  ::wxEVT_REMOVE_VIEW event.
1566  */
1567  void OnRemoveView( a2dDocumentEvent& event );
1568 
1569  //! what to do when a view starts using this document
1570  void OnAddView( a2dDocumentEvent& event );
1571 
1572  //! The default handler for ::wxEVT_EXPORT_DOCUMENT.
1573  /*!
1574  This method asks for a file, to export/save the document into,
1575  using the handler of the event its a2dDocumentTemplate.
1576  If a a2dDocumentTemplate was not given as part of the event, the document template
1577  of this document is used to search for possible templates to be used for exporting
1578  this document. The selection is based on GetDocumentTemplate()->GetDocumentTypeName().
1579  Next a file dialog is presented to select a file to export.
1580 
1581  If a filename is part of the event, this is used as initial file to export to in the save dialog.
1582  If a2dDocumentFlagMask contains a2dREFDOC_SILENT, no dialog will be presented.
1583  */
1584  void OnExportDocument( a2dDocumentEvent& event );
1585 
1586  //! The default handler for ::wxEVT_IMPORT_DOCUMENT.
1587  /*!
1588  This method asks for a file, to read the document from,
1589  using the handler of the event its a2dDocumentTemplate.
1590  If a a2dDocumentTemplate was not given as part of the event, the document template
1591  of this document is used to search for possible templates to be used for importing
1592  into this document. The selection is based on GetDocumentTemplate()->GetDocumentTypeName().
1593  Next a file dialog is presented to select a file to import.
1594 
1595  If as part of the event a path+path was already provided, that will be used.
1596  If a2dREFDOC_SILENT was set as flag in the event, no dialogs will appear, when a file+path is available.
1597  */
1598  void OnImportDocument( a2dDocumentEvent& event );
1599 
1600  //!Set when Owners become zero and document will be deleted. May also be overruled by user.
1602 
1603  //! Filename associated with this document ("" if none).
1604  wxFileName m_documentFile;
1605 
1606  //! last modification time when this document was stored.
1608 
1609  //!Document title.
1610  /*!
1611  The document title is used for an associated
1612  frame (if any), and is usually constructed by the framework from the filename.
1613  */
1615 
1616  //!The document type name given to the a2dDocumentTemplate constructor,
1617  /*!is copied to this variable when the document is created.
1618 
1619  In a2dDocumentCommandProcessor::AddCreatedDocument() first set this, to search an appropriate template.
1620 
1621  It is used later on to select Views from the a2dViewTemplate's.
1622  a2dViewTemplate uses the same documentTypeName as a2dDocumentTemplate's.
1623 
1624  The same a2dDocument derived class instances, can have a different m_documentTypeName.
1625 
1626  If several view templates are created that use the same document type,
1627  this variable is used in a2dDocumentCommandProcessor::CreateView to collate a list of
1628  alternative view types that can be used on this kind of document.
1629 
1630  */
1632 
1633  //!A pointer to the template from which this document was created
1635 
1636  //! modified flag
1638 
1639  //! parant document if set.
1641 
1642  //!A pointer to the command processor associated with this document.
1644 
1645  //! saved flag
1647 
1648  //! set true when document is closed or when busy closing document.
1650 
1651  //! This identifies the document in event processing
1652  /*! Not sure, if this is really used for something */
1653  wxUint32 m_id;
1654 
1655  //! error code used when LoadObject is returning.
1657 
1658 private:
1659 
1660  virtual a2dObject* SmrtPtrOwn();
1661  //!To release the object, it is not longer owned by the calling object.
1662  /*! the object itself will be deleted when not Owned (the reference count becomes zero)
1663 
1664  \remark AskSaveWhenOwned was false, and this document is not Owned by anyone,
1665  the user will now be asked to save the document (when it was modified).
1666  */
1667  virtual bool SmrtPtrRelease();
1668  friend class a2dSmrtPtrBase;
1669 };
1670 
1671 class A2DDOCVIEWDLLEXP a2dViewConnector;
1672 class A2DDOCVIEWDLLEXP a2dViewTemplate;
1673 
1674 #if (defined(__WXMSW__) && defined(WXUSINGDLL) )
1675 template class A2DDOCVIEWDLLEXP a2dSmrtPtr<a2dViewConnector>;
1676 #endif
1677 
1678 
1679 extern const a2dPrintWhat a2dPRINT_Print; //!< general print
1680 extern const a2dPrintWhat a2dPRINT_Preview; //!< general print preview
1681 extern const a2dPrintWhat a2dPRINT_PrintView; //!< print a2dView
1682 extern const a2dPrintWhat a2dPRINT_PreviewView; //!< preview print a2dView
1683 extern const a2dPrintWhat a2dPRINT_PrintDocument; //!< print a2dDocument
1684 extern const a2dPrintWhat a2dPRINT_PreviewDocument; //!< preview print a2dDocument
1685 extern const a2dPrintWhat a2dPRINT_PrintSetup;
1686 
1687 
1688 //! Holds a view on a a2dDocument.
1689 /*!
1690  A view is able to connect your documents to the windows in an application.
1691  It knows its document or documents, and it know where (which windows) the data from the document is displayed.
1692  This makes it possible to close or disconnect all views on a document, and indirectly its windows can be closed.
1693  For instance; closing the application, will close all its documents, and via the views,
1694  will close all windows/frames on the documents. But also closing just one frame, can delete one document via the
1695  frame its view. The view is like a two way bridge between the document and the GUI.
1696 
1697  A a2dView is indirectly used for displaying a (part of) a2dDocument its data.
1698  It may display this data in any form it wants to.
1699  Several a2dView's can exist on a a2dDocument, and they can be of different types.
1700  A a2dView organizes to display data stored in a2dDocument's.
1701  A document can be set for a view, and this will be used by the view
1702  to check if ::wxEVT_UPDATE_VIEWS events coming from the documents, are meant
1703  for the view or not.
1704  If a view wants to display the data of several documents, this can be arranged
1705  in a derived class.
1706 
1707  The views on a document, work independent of eachother.
1708  When using a a2dDocumentCommandProcessor class, this will know the currently active view.
1709  In general this is the view which has the focus. Meaning its display window
1710  has the focus.
1711 
1712  The a2dDocument class uses events to notify changes.
1713  The a2dView's connect themselfs to a a2dDocument to recieve specific events.
1714  Any wxEvtHandler derived class may be connected to the a2dDocument.
1715  The document does not know all this in advance, it just sents events to itself.
1716  The dynamically connected handlers, will receive those events too.
1717 
1718  Since a2dViews connects to specific events in a a2dDocument,
1719  one could think that the same can be done with wxWindow's etc. directly.
1720  But using a2dView, makes it easy to centralize the actions needed, independent from
1721  the application its windows and dialogs. A dedicated view, used to display data from
1722  a dedicated document, can be used for a wxFrame or a wxNotebook page at the same time.
1723  The view does not need to know about your application in terms of windows.
1724  Because of this, its functionality can be made part of a library, to be used by any application.
1725 
1726  The view may display the data from the document, directly to the device or in a
1727  delayed fashion. In which case it stores the data to display first locally,
1728  and as soon as possible this data is updated to the device ( e.g. a window. )
1729  If the device is a window, the m_display holds a pointer to it.
1730 
1731  Views display the data in a document, and therefore if the document data changes,
1732  the view might change because of that. The a2dDocument::UpdateAllViews() is
1733  sending ::wxEVT_UPDATE_VIEWS to the a2dDocument, and this sents
1734  the event to all connected a2dView's. a2dView::OnUpdate() will handle the event.
1735  It checks if it wants to process the event coming from that particular document,
1736  and if so updates its own data from that document.
1737  To update all views at every small change made to the document, is often not desired.
1738  Checking a "pending flag" inside the document when the program becomes idle is a better
1739  way to update the views.
1740 
1741  Often the view is a rectangular drawing area. The view can use a wxWindow derived class
1742  to display the data for a document. But this is not a must, a view may be stored anywhere.
1743  A view might also display parts of a document(s) via wxDialogs, or it might store it in a bitmap.
1744  How and what is displayed using a view depends on the derived class.
1745 
1746  The way to update what is displayed by the view needs to be defined in the handler
1747  for ::wxEVT_UPDATE_VIEWS event. The default OnUpdate, just calls refresh on the view its display window.
1748  Here the display window will redisplay the specific data from the document in the way it wants.
1749  Changes in the document need to result in calling OnUpdate for each view.
1750  OnUpdate may decide to directly redrawn on the device, or only store the view data locally.
1751  In the last case a flag is set to indicate that the view has changed.
1752  This flag is checked in idle time, resulting in an update of the device eventually.
1753  This is the principle behind calling m_display->Refresh() after
1754  changing a document or a view its display data.
1755  This will result in a wxPaintEvent, which will redraw the view data.
1756 
1757  When the display device is a window, the wxPaintEvent event handled in the window, may
1758  request a redraw of certain areas within the view. The view may do this by
1759  actually redrawing directly from the document, or in case of local stored data,
1760  return/redraw only this locally stored data directly on the window.
1761  In some cases the data displayed on the window, is actually stored locally within
1762  the window, and the window handles paint events itself, without asking the view to redisplay
1763  the damaged areas ( e.g. wxTextCtrl. etc. ). Still the window will need to check
1764  if the view or document did change, to keep its contents up to date.
1765  The member a2dView::OnDraw( wxDC* ) can be used by the display window, to have
1766  the view redraw itself on the window. But of course if not using wxDC based views,
1767  any other method can be used.
1768  The important thing to understand, is that the Updating of a a2dView can happen
1769  at time X, while the display of this updated view can happen at time Y.
1770  Therefore several updates on a view might take place before they are actually
1771  redisplayed.
1772 
1773  For printing the view in a2dView::OnPrint(wxDC *dc), you may use
1774  Ondraw to print the contents of a view to a wxDC.
1775  For that you should define a way to draw the view its data on a wxDC.
1776 
1777  Events which are sent to a2dView:
1778 
1779  a2dView is by default Registered to a2dDocument which is set to it. And will recieve all events from send there.
1780 
1781  In general all wxWindow events of m_display or the wxFrame containing the a2dView
1782  - ::wxEVT_SET_FOCUS ::wxEVT_KILL_FOCUS etc.
1783 
1784  View specific events.
1785  - a2dViewEvent -> type = ::wxEVT_CLOSE_VIEW
1786  - a2dViewEvent -> type = ::wxEVT_ACTIVATE_VIEW sent view itself from Activate()
1787  - a2dViewEvent -> type = ::wxEVT_ACTIVATE_VIEW_SENT_FROM_CHILD sent from view itself to m_display from Activate()
1788  - a2dViewEvent -> type = ::wxEVT_CREATE_VIEW sent to view from a2dViewTemplate::CreateView()
1789  Called by framework if created automatically by the default document
1790  manager class: gives view a chance to initialise
1791  e.g. void OnCreateView( a2dViewEvent* event );
1792  - a2dViewEvent -> type = ::wxEVT_SET_DOCUMENT sent to view itself when calling SetDocument()
1793  - a2dDocumentEvent -> type = ::wxEVT_CHANGEDFILENAME_DOCUMENT Recieved from the a2dDocument.
1794  - a2dDocumentEvent -> type = ::wxEVT_CLOSE_VIEWS
1795  - a2dViewEvent -> type = ::wxEVT_ENABLE_VIEW sent to m_display and up, when a view is enabled or disabled.
1796  - ::wxEVT_REMOVE_VIEW sent to document when a view is not using the document anymore. \see SetDocument()
1797  - ::wxEVT_ADD_VIEW sent to document when a view start using a document \see SetDocument()
1798 
1799  - ::wxEVT_CHANGEDFILENAME_VIEW See OnChangeFilename()
1800  - ::wxEVT_CHANGEDTITLE_VIEW See OnChangeTitle()
1801 
1802  \ingroup docview
1803 */
1804 class A2DDOCVIEWDLLEXP a2dView: public a2dObject
1805 {
1806  DECLARE_ABSTRACT_CLASS( a2dView )
1807 
1808  DECLARE_EVENT_TABLE()
1809 
1810 public:
1811  // a2dView(a2dDocument *doc = (a2dDocument *) NULL);
1812 
1813  //! constructor
1814  a2dView();
1815 
1816  //! destructor
1817  ~a2dView();
1818 
1819  //! construct with other view
1820  a2dView( const a2dView& other );
1821 
1822  //! A closed flag is set when a view is closed.
1823  /*! This flag is set just before the actual closing will take place.
1824  If the close is vetod, it will be reset at the end of the closing action,
1825  else it will stay true.
1826  The flag is a handy test for associated windows, to see if their
1827  view is already closed or not.
1828  */
1829  bool IsClosed() { return m_isClosed; }
1830 
1831  //! sets closed flag to true, and calls Release() view.
1832  /*!
1833  Normally Close() should be used, but in cases where a view is used temporarely and without
1834  a display window ( e.g using a view for rendering to bitmap ), this
1835  can be used to properly close a view without sending extra events.
1836  */
1837  void SetClosed();
1838 
1839  //! returns true if view was enabled/disabled, false if nothing done
1840  /*!
1841  Sets the view enabled or disabled, which means that no events will be processed,
1842  except ::wxEVT_ENABLE_VIEW and ::wxEVT_ENABLE_VIEWS.
1843 
1844  The ::wxEVT_ENABLE_VIEW event is sent to the view and the display window (if available).
1845  After that the new state is set.
1846 
1847  If the view is already in the requested state, nothing is done.
1848  */
1849  bool Enable( bool enable );
1850 
1851  //! return true if the view is enabled. See Enable()
1852  bool GetEnabled() { return m_viewEnabled; }
1853 
1854  //!Set the display window.
1855  /*!
1856  The display window can be used to display the view on a wxWindow.
1857  This is \b not a must, since a view might also be displayed into a bitmap etc.
1858  But in that case this needs to be arranged in a derived class.
1859  The default is using a display wxWindow.
1860 
1861  The window may be set in a derived view class.
1862  But often it is better to set it from a specialized a2dViewConnector.
1863  If needed in combination with a specialized a2dViewTemplate.
1864  This makes it easier to make general view classes, which can be used
1865  in several types of applications or display windows.
1866 
1867  \remark this function has only effect if the view its eventhandler is enabled.
1868  The reason is that some events like a2dCloseViewEvent are set up to the m_display window,
1869  during that time the event handler is disabled to prevent looping. But also the m_display
1870  should stay constant during that time.
1871  */
1872  virtual void SetDisplayWindow( wxWindow* display );
1873 
1874  //!Get the display window.
1875  wxWindow* GetDisplayWindow() { return m_display; }
1876 
1877  //! Get the id of the view (used for identification in event processing
1878  wxUint32 GetId() { return m_id; }
1879 
1880  //! get the document of the view
1881  /*! \return NULL if no document is set. */
1882  a2dDocument* GetDocument() const { return m_viewDocument; }
1883 
1884  //! Set the document for the view and add it to the document its viewlist.
1885  /*!
1886  Normally called by the framework.
1887 
1888  If the view already has a document set, the view is first removed from
1889  that document, sending a ::wxEVT_REMOVE_VIEW event to the old document,
1890  Can be received from the a2dDocument after Registering this class.
1891 
1892  See a2dDocumentCommandProcessor::OnRemoveView() where this event is used to reset the last active view.
1893 
1894  Next the new document will be set for the view, and added to the viewlist
1895  of the new document, sending a ::wxEVT_ADD_VIEW event to the new document.
1896 
1897  At last a a2dViewEvent event of type ::wxEVT_SET_DOCUMENT is sent to the a2dView.
1898  So if extra administrative tasks for the view are needed when setting a view to a document,
1899  intercept that event to do it.
1900  */
1901  void SetDocument( a2dDocument* doc );
1902 
1903  //! get type name of the view.
1904  /*!
1905  This name is used to couple document types to view types.
1906  See a2dViewTemplate.
1907  */
1908  wxString GetViewTypeName() const { return m_viewTypeName; }
1909 
1910  //! get the a2dViewTemplate with which this view was created
1911  /*!
1912  \see a2dViewTemplate.
1913  */
1914  a2dViewTemplate* GetViewTemplate() const { return m_viewTemplate; }
1915 
1916  //! to set the view template from which this view was created.
1917  void SetViewTemplate( a2dViewTemplate* viewtemplate ) { m_viewTemplate = viewtemplate; }
1918 
1919  //! set type name of the view.
1920  /*!
1921  This name is used to couple document types to view types.
1922  See a2dViewTemplate.
1923  */
1924  void SetViewTypeName( const wxString& name ) { m_viewTypeName = name; }
1925 
1926  //! force a2dDocumentEvent ::wxEVT_UPDATE_VIEWS event
1927  virtual void Update( unsigned int hint = 0, wxObject* hintObject = NULL );
1928 
1929  //! Close a view and remove the view from its document.
1930  /*!
1931  IMPORTANT there are two ways/paths through which a view can be closed.
1932  -# by closing the frame containing the view(s).
1933  -# by the docmanager closing a document and this one closing the views on the document.
1934 
1935  The first one will destroy the frames, and it must Close the view(s) it contains.
1936  The second one must make sure that the frames containing the views will be destroyed.
1937  This is why ::wxEVT_CLOSE_VIEW travels up in the hiearchy of windows, starting at m_display window.
1938 
1939  Close() generates a ::wxEVT_CLOSE_VIEW event, which is first redirected
1940  to the a2dDocument, and if not vetod there, to the m_display wxWindow.
1941  if not vetod there, the event is sent to a2dView itself.
1942 
1943  If not vetod in the ::wxEVT_CLOSE_VIEW handler of the view,
1944  the View Will be removed and released from the document.
1945  The view will be set Inactive.
1946  The m_display wxWindow will be disabled, to prevent it from sending more events.
1947 
1948  When the ::wxEVT_CLOSE_VIEW is sent to the m_display window, the
1949  a2dView itself is disabled for handling events, untill the event is
1950  (not)processed by the display and return.
1951  So event coming back to the view will not be handled during that time.
1952  The ::wxEVT_CLOSE_VIEW is sent to m_display, but the event is of the type
1953  that travels up to the parent window if not handled.
1954  So if not handled in the display window, it will go to the parent window.
1955  Eventually it arives in the wxFrame holding the windows.
1956  The idea is thay you do intercept ::wxEVT_CLOSE_VIEW event somewhere in the hierarchy
1957  of windows, and make sure the a2dView is correctly detached from the windows
1958  where it is used.
1959  In case the event is not vetod by the display
1960  window, it is a good habbit that it sets the display window
1961  of this/its view to NULL, this will prevent events coming from this view
1962  to the display window for sure.
1963 
1964  This is the clue to having view independent frames and windows.
1965  A specialized frame or window, can use different types of connectors to deal
1966  with different types of attached views.
1967 
1968  Always be aware of dangling pointers from the display window, which normally will/should
1969  have a pointer to the view. Also other classes having somehow a pointer to this view
1970  (which will be closed and released soon), should take care of this by intercepting the
1971  ::wxEVT_CLOSE_VIEW event. Therefore the display window, in such cases should
1972  redirect the ::wxEVT_CLOSE_VIEW event to such classes.
1973  Default the event will be redirected to the parent window, if not handled or skipped.
1974 
1975  When not vetod Close() \b the DisplayWindow m_display is set to NULL first.
1976  The reason for disabling the display window is to prevent it from
1977  sending more events to this view, which will be deleted soon.
1978 
1979  In any case the ::wxEVT_CLOSE_VIEW handler should check whether the view is being deleted forcibly,
1980  using a2dCloseViewEvent::CanVeto(). If so it needs to perform the nessecary cleanup.
1981  Else it may veto.
1982 
1983  Example:
1984 
1985  \code
1986 
1987  //the next class interecepts the ::wxEVT_CLOSE_VIEW
1988  void wxSomeClass::OnCloseView( a2dCloseViewEvent& event )
1989  {
1990  //test if the frame or windows where not already deleted
1991  //
1992  if ( event.GetForce() && GetViewFrame() )
1993  {
1994  event.GetView()->SetDisplayWindow( NULL );
1995  m_display->Disable();
1996  m_display->Destroy();
1997  m_display = NULL;
1998  }
1999  }
2000  \endcode
2001 
2002  Closing a view recursive, while its busy closing itself is not a problem.
2003  The owning objects may recursively call this function without problem, for that
2004  the m_isClosed flag is set at the beginning which prevents closing twice.
2005  the view object itself will be released only once in the end.
2006  The ::wxEVT_CLOSE_VIEW will be issued only once.
2007 
2008  If the view has a document set, the view is first removed from
2009  that document, sending a ::wxEVT_REMOVE_VIEW event to the old document.
2010  Can be received from the a2dDocument after Registering this class.
2011  See a2dDocumentCommandProcessor::OnRemoveView() where this event is used to reset the last active view.
2012 
2013  \remark a2dView is reference counted and will only be really deleted when it reaches zero
2014 
2015  \remark In wxWindows the handler function for ::wxEVT_CLOSE_WINDOW event is called when the user has tried
2016  to close a frame using the window manager (X) or system menu (Windows).
2017  The ::CLOSE_WINDOW event should normally be intercepted, and ask via
2018  calling a2dView::Close if it is oke to close the view. In a2dDocumentFrame this arranged.
2019 
2020  \remark You may call also a2dView::Close() directly, it will generate the same events.
2021 
2022  \return true is view was properly closed and not vetod else false
2023 
2024  */
2025  virtual bool Close( bool force = false );
2026 
2027  //! Extend event processing to search the view's event table
2028  /*! Some events are handled within the view as if the view is a window within a window.
2029  Therefore the wxWindow containing the view should redirect all its events to
2030  its view(s), when the view does not handle the event it will go to the window itself.
2031 
2032  Events handled how:
2033  - ::wxEVT_ENABLE_VIEW & ::wxEVT_ENABLE_VIEWS always processed, sent to GetEventHandler()
2034  - ::wxEVT_ACTIVATE sent from a2dDocumentFrame and derived classes, calls Activate()
2035  - ::wxEVT_SET_FOCUS sent to GetEventHandler() and calls Activate(true)
2036  - ::wxEVT_KILL_FOCUS sent to GetEventHandler() and calls Activate(false)
2037  - ::wxEVT_CLOSE_WINDOW sent from wxWindow containing the a2dView.
2038  calls Close( !closeevent.CanVeto() )
2039  - ::wxEVT_IDLE sent from wxWindow containing the a2dView, sent to GetEventHandler()
2040  and to the a2dDocument.
2041  */
2042  virtual bool ProcessEvent( wxEvent& event );
2043 
2044  //! is called via ProcessEvent() when the view becomes active
2045  /*!
2046  Generates a ::wxEVT_ACTIVATE_VIEW with active == activate.
2047  When recieved by a2dDocumentCommandProcessor::OnActivateView() this way,
2048  the last will deactivate its current active view, using this same function.
2049 
2050  The event ::wxEVT_ACTIVATE_VIEW_SENT_FROM_CHILD event is sent to the m_display window or frame.
2051  This is the event to catch in order to set the view in the containing frame/windows.
2052  For example a2dDocumentFrame uses this event to set the view to which it will sent window close events.
2053 
2054  Can also be called directly to notify the view that it should go (in)active.
2055 
2056  Normally Activate() sents the a2dViewEvent of type ::wxEVT_ACTIVATE_VIEW_SENT_FROM_CHILD to m_display.
2057 
2058  \sa a2dViewEvent.
2059  */
2060  void Activate( bool activate );
2061 
2062  //! return if the view is active/
2063  /*!
2064  a view is in general active when its m_display window has the focus or is selected.
2065  */
2066  bool GetActive() { return m_active; }
2067 
2068  //! needs to be implemented to print a view, also so used for simple redrawing of views.
2069  /*!
2070  Normal updating the data of a view, is via OnUpdate, called from the changed a2dDocument.
2071  Once the view its data is up to data, m_display->Refresh() results in a paint event.
2072  This in a2dDocumentViewScrolledWindow and a2dDocumentViewWindow directly leads to OnDraw(),
2073  redrawing the data of the view on the display window.
2074  In a2dDocumentViewScrolledWindow and a2dDocumentViewWindow the wxPaintEvent is intercepted
2075  and by default redirected via its OnDraw() to the view Ondraw() function here.
2076  If it is a clever implementation, the above refresh should only refresh the areas
2077  in the view which did change.
2078  In m_display->GetUpdateRegion() is where you should get those regions, while the paint
2079  event is being handled.
2080 
2081  A more complicated situation is as follows.
2082  Paint events are generated when a wxWindow becomes visible,
2083  or when you draw something to it. The regions needing an update, or reported by the
2084  Paint event.
2085  The view does not need to do a complete re-drawn, only the damaged regions.
2086  In such a case you should Handle the paint event Your self in the m_display
2087  window, and redirect it to the a2dView.
2088  In the a2dView you can iterate over the damaged regions, and only redraw
2089  the view its data in those regions.
2090  */
2091  virtual void OnDraw( wxDC* dc ) = 0;
2092 
2093 #if wxUSE_PRINTING_ARCHITECTURE
2094 
2095  //! called from the a2dDocumentCommandProcessor to create a wxPrintout are derived class
2096  /*! for printing a view
2097  If the printing framework is enabled in the library, this function returns a
2098  wxPrintout object for the purposes of printing.
2099  It should create a new object every time it is called;
2100  the framework will delete objects it creates.
2101  By default, this function returns an instance of wxDocPrintout,
2102  which prints and previews one page by calling wxView::OnDraw.
2103 
2104  Override to return an instance of a class other than wxDocPrintout.
2105 
2106  \param typeOfPrint When called from a2dDocumentCommandProcessor, the a2dPrintWhat that lead to this call.
2107  */
2108  virtual wxPrintout* OnCreatePrintout( a2dPrintWhat typeOfPrint, const wxPageSetupDialogData& pageSetupData );
2109 #endif
2110 
2111  //! called from a2dDocumentPrintout when printing a view.
2112  /*!
2113  Default calls OnDraw(wxDC *dc)
2114  */
2115  virtual void OnPrint( wxDC* dc, wxObject* info );
2116 
2117 protected:
2118 
2119  //! default handler for a2dDocumentEvent ::wxEVT_UPDATE_VIEWS
2120  /*!
2121  Updates the view data ( e.g the data that the view displays has changed in the document).
2122  The view may hold/display data which should change when the document(s) changes.
2123  Here this data can be updated, the internal data of the view can be updated.
2124  When the view will be redisplayed depends on the derived class.
2125  One can set a dirty flag after changing the view its data, and do the redisplay
2126  in idle time, where this flag is checked. But often there is no need
2127  to do this, since the view can directly update its Display window, or
2128  tell it that it needs to update itself.
2129  Therefore the default here simply calls m_display->Refresh(), which leads to a
2130  paint event on the display window, and that might/should call a2dView::Ondraw().
2131  */
2132  void OnUpdate( a2dDocumentEvent& event );
2133 
2134  //! default handler for a2dDocumentEvent of type ::wxEVT_ENABLE_VIEWS
2135  /*!
2136  This enable or disables the view by calling Enable( event.GetEnable() ).
2137  But only if the a2dDocument from which this document was sent, is the
2138  one the a2dView is using.
2139  If the view from which the event originated is specified in the event,
2140  that view will not process the event, all others will.
2141  */
2142  void OnEnableViews( a2dDocumentEvent& event );
2143 
2144  //! handler for the ::wxEVT_REPORT_VIEWS
2145  /*!
2146  The handlers adds this a2dView to the reportlist of the event, if
2147  it depends on the document sending the event. The default simply
2148  checks that the view its document is the one sending the event, and if so
2149  adds it. In case your view displays info of several documents, you should
2150  intercept this event to implement this behaviour.
2151  */
2152  void OnReport( a2dDocumentEvent& event );
2153 
2154  //! default handler for EVT_ENABLE_VIEW event.
2155  void OnEnable( a2dViewEvent& event );
2156 
2157  //! default handler for file changed event sent from a2dDocument with type wxEVT_CHANGEDFILENAME_DOCUMENT
2158  /*!
2159  Creates new event of type wxEVT_CHANGEDFILENAME_VIEW, which also knows the view now.
2160  Sends the event to the DisplayWindow, there or in its parent hiearchy it can be intercepted.
2161  */
2162  void OnChangeFilename( a2dDocumentEvent& event );
2163 
2164  //! default handler for file changed event sent from a2dDocument with type wxEVT_CHANGEDTITLE_DOCUMENT
2165  /*!
2166  Creates new event of type wxEVT_CHANGEDTITLE_VIEW, which also knows the view now.
2167  Sends the event to the DisplayWindow, there or in its parent hiearchy it can be intercepted.
2168  */
2169  void OnChangeTitle( a2dDocumentEvent& event );
2170 
2171  //! ::wxEVT_CLOSE_VIEW event handler to do cleanup/veto Close of the view.
2172  /*!
2173  The default handler does nothing yet.
2174 
2175  The Handler for ::wxEVT_CLOSE_VIEW, resulting from view close via
2176  a2dView:Close() ( either via a2dDocument or a wxFrame containing the view)
2177 
2178  One may intercept ::wxEVT_CLOSE_VIEW event in a derived class
2179  to Clean up and Destroy windows used for displaying the view.
2180  But it is often better to do this in a wxWindow derived class which contains the view.
2181  Therefore the ::wxEVT_CLOSE_VIEW is first sent to the m_display wxWindow of the a2dView.
2182 
2183  The best is to use a a2dViewConnector to create frames and windows to hold a view,
2184  and a2dDocumentFrame derived class to handle Closing of a2dView's.
2185  It will recieve the ::wxEVT_CLOSE_VIEW via the wxWindow
2186  containing the a2dView which is about to be closed.
2187  This makes it easy to use the same view class in other applications.
2188 
2189  On closing of a wxFrame, you may decide to Close the window by intercepting
2190  EVT_CLOSE, and from there call a2dView::Close.
2191  It depends on the application how the views are closed.
2192 
2193  In any case Windows should be Destroyed, not really deleted.
2194  Destroy only flags for deletion, this means that they will really
2195  be deleted in idle time by wxWindows.
2196  */
2197  void OnCloseView( a2dCloseViewEvent& event );
2198 
2199  //! handler for ::wxEVT_DISCONNECT_ALLVIEWS
2200  /*!
2201  The ::wxEVT_DISCONNECT_ALLVIEWS is generated by the a2dDocument when it disconnects all views.
2202  This can be when closing the document, or just to attach all views to another document.
2203  */
2204  void OnDisConnectView( a2dDocumentEvent& event );
2205 
2206  //! called on (de)activating (wxWindow) containing the view.
2207  //void OnActivate(wxActivateEvent& event);
2208 
2209  //! when a view gets the focus ( when only one view per window
2210  /*! that view gets the focus if the window gets the focus )
2211  Else the window getting the focus should decide which view gets the focus.
2212  */
2213  void OnSetFocus( wxFocusEvent& event );
2214 
2215  //! when a view goes out of focus ( when only one view per window
2216  /*! that view goes out of focus if the window goes out of focus )
2217  Else the window getting the focus should decide which view goes out of focus.
2218  */
2219  void OnKillFocus( wxFocusEvent& event );
2220 
2221  //! close flag, to indicate that the view is being closed are is closed.
2223 
2224  //! the document to which this view belongs.
2226 
2227  //! set via the a2dViewTemplate on generation of this view.
2228  wxString m_viewTypeName;
2229 
2230  //! view was created from this view template or if not used NULL
2232 
2233  //! true if this view is activated ( its display window has the focus and recieves mouse events )
2234  bool m_active;
2235 
2236  //! Is the view enabled?
2237  /*!
2238  true if this view is enabled and will process all events.
2239  else only ::wxEVT_ENABLE_VIEW and ::wxEVT_ENABLE_VIEWS will be processed.
2240  */
2242 
2243  //! In case of using a window for displaying the view, this holds the window.
2244  wxWindow* m_display;
2245 
2246  //! This identifies the view in event processing
2247  wxUint32 m_id;
2248 
2249  //! this is used to keep the view alive if no other references are there.
2250  //! This untill the view is closed by calling Close() or SetClosed()
2252 
2253 private:
2254 
2255  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const { return NULL; }
2256 
2257  virtual a2dObject* SmrtPtrOwn();
2258  virtual bool SmrtPtrRelease();
2259  friend class a2dSmrtPtrBase;
2260 };
2261 
2262 
2263 //! The a2dDocumentTemplate class is used to model the relationship between a document class and files
2264 /*!
2265  Next to that, a a2dViewConnector class pointer
2266  is used to generate new views for new documents, or whatever the a2dViewConnector finds
2267  appropriate to do when a new document is created by the a2dDocumentCommandProcessor via a a2dDocumentTemplate.
2268 
2269  Normally new views are created by the a2dViewConnector class via a a2dViewTemplate.
2270  When and where this new view will be displayed, is up to the a2dViewConnector.
2271 
2272  After CreateDocument created a new document,
2273  it sents a ::wxEVT_POST_CREATE_DOCUMENT event to the a2dViewConnector class m_connector.
2274  The a2dViewConnector derived class may intercept the event to
2275  created new a2dView's for the new a2dDocument.
2276  This is what the default handler ::wxEVT_POST_CREATE_DOCUMENT
2277  in a2dViewConnector::OnPostCreateDocument() does do.
2278  It first uses the a2dDocumentCommandProcessor to display the available a2dViewTemplate's
2279  for the new created document type.
2280  The user chooses one, and that a2dViewTemplate will be used
2281  to create the first view on the document with a2dViewTemplate::CreateView().
2282  But in other situations, one might prefer to hook the new document into an existing view.
2283  The existing view its current document is disconnected from the view, and the new one
2284  is connected to the view.
2285  a2dViewTemplate::CreateView() is what generates the ::wxEVT_POST_CREATE_VIEW which is also
2286  redirected to a a2dViewConnector. This event may or may no be handled by a connector.
2287  It depends on the application, how a connector wants to connect new views into the application.
2288 
2289  \remark It is possible that newly created documents do not need a view.
2290  Therefore the connector class pointer may be NULL.
2291 
2292  \sa a2dDocumentTemplateEvent
2293  \sa a2dViewTemplateEvent
2294 
2295  \ingroup docview
2296 */
2297 class A2DDOCVIEWDLLEXP a2dDocumentTemplate: public a2dObject
2298 {
2299 
2300  DECLARE_CLASS( a2dDocumentTemplate )
2301 
2302 public:
2303 
2304  //! Associate document and view types. They're for identifying what view is associated with what template/document type
2305  /*!
2306  Constructor. Create instances dynamically near the start of your
2307  application after creating a a2dDocumentCommandProcessor instance, and before doing
2308  any document or view operations.
2309 
2310  \param descr is a short description of what the template is for. This string
2311  will be displayed in the file filter list of Windows file selectors.
2312 
2313  \param filter is an appropriate file filter such as *.txt OR "*.cal;*.gds" for more the one.
2314 
2315  \param dir is the default directory to use for file selectors.
2316 
2317  \param ext is the default file extension (such as txt).
2318 
2319  \param docTypeName is a name that should be unique for a given type of document,
2320  used for gathering a list of views relevant to a particular document.
2321 
2322  \param docClassInfo is a pointer to the run-time document class information as returned
2323  by the CLASSINFO macro, e.g. CLASSINFO(MyDocumentClass). If this is not supplied,
2324  you will need to derive a new a2dDocumentTemplate class and override the CreateDocument
2325  member to return a new document instance on demand.
2326 
2327  \param connector connector to use to attach this type of template to GUI.
2328 
2329  \param flags is a bit list of the following:
2330 
2331  - a2dTemplateFlag::VISIBLE The template may be displayed to the user in dialogs.
2332  - wxREFTEMPLATE_INVISIBLE The template may not be displayed to the user in dialogs.
2333  - a2dTemplateFlag::DEFAULT Defined as a2dTemplateFlag::VISIBLE.
2334 
2335  \param handlerIn IO handler needed to read this type of files into the document.
2336  \param handlerOut IO handler needed to write this type of files from the document.
2337 
2338  */
2340  const wxString& descr,
2341  const wxString& filter,
2342  const wxString& dir,
2343  const wxString& ext,
2344  const wxString& docTypeName,
2345  wxClassInfo* docClassInfo = ( wxClassInfo* ) NULL,
2346  a2dViewConnector* connector = ( a2dViewConnector* ) NULL,
2347  long flags = a2dTemplateFlag::DEFAULT,
2348  a2dIOHandlerStrIn* handlerIn = NULL,
2349  a2dIOHandlerStrOut* handlerOut = NULL );
2350 
2351  //! Destructor.
2353 
2354  //! Creates a new document.
2355  /*!
2356  Creates a new instance of the associated document class.
2357  If you have not supplied a wxClassInfo parameter to the template constructor,
2358  you will need to override this function to return an appropriate document instance.
2359 
2360  After creating a new document two event are generated:
2361 
2362  - a2dDocumentEvent of type ::wxEVT_CREATE_DOCUMENT sent to document
2363  - a2dDocumentTemplateEvent of type ::wxEVT_POST_CREATE_DOCUMENT sent to a2dViewConnector.
2364  */
2365  virtual a2dDocument* CreateDocument( const wxFileName& path, a2dDocumentFlagMask flags = a2dREFDOC_NON );
2366 
2367  //! sents a wxEVT_PRE_ADD_DOCUMENT event to m_connector if available.
2368  /*!
2369  This event is sent to the m_connector a2dViewConnector of the template, and the sender/eventObject is this template.
2370  It is sent just before a new created document is added to the framework.
2371  The a2dViewConnector can react to this action by closings existing documents and disconnect frames and views.
2372  At this stage the a2dDocumentCommandProcessor() its current document has not changed yet.
2373 
2374  \param newDoc the new document which was created
2375  \param flags some flags telling for what purpose the new document was created. e.g a2dREFDOC_NEW
2376  */
2377  a2dDocument* SentPreAddCreatedDocumentEvent( a2dDocument* newDoc, a2dDocumentFlagMask flags );
2378 
2379  //! sents a wxEVT_POST_CREATE_DOCUMENT called in general from a2dDocumentCommandProcessor() when a new document was created.
2380  /*!
2381  This event is sent to the m_connector a2dViewConnector of the template, and the sender/eventObject is this template.
2382  The a2dViewConnector can react in several ways to this action:
2383  - create one or more new a2dView's ( if wanted a a2dViewTemplate can help to choose one )
2384  - use one or more existing a2dView's
2385  - create no a2dView at all
2386  - merge or copy the contents of the new a2dDocument, and directly close this new document, of course no new views generated then.
2387  - next to creating one or more a2dViews or re-using one or more a2dViews, also the a2dDocumentFrame's and/or
2388  a2dDocumentViewWindow's can be created or reused to connect the views into.
2389 
2390  The default implementation see a2dViewConnector::OnPostCreateDocument().
2391 
2392  In a derived a2dViewConnector you can implement your own handler, to treat the new document in ways more
2393  appropriate to your application.
2394 
2395  \param newDoc the new document which was created
2396  \param flags some flags telling for what purpose the new document was created. e.g a2dREFDOC_NEW
2397 
2398  */
2399  bool SentPostCreateDocumentEvent( a2dDocument* newDoc, a2dDocumentFlagMask flags );
2400 
2401  //! Returns the default file extension for the document data, as passed to the document template constructor.
2402  wxString GetDefaultExtension() const { return m_defaultExt; }
2403 
2404  //! Returns the text description of this template, as passed to the document template constructor
2405  wxString GetDescription() const { return m_description; }
2406 
2407  //! Returns the default directory, as passed to the document template constructor.
2408  wxString GetDirectory() const { return m_directory; }
2409 
2410  //! Returns the file filter, as passed to the document template constructor.
2411  wxString GetFileFilter() const { return m_fileFilter; }
2412 
2413  //! Returns the flags, as passed to the document template constructor.
2414  const a2dTemplateFlag& GetFlags() const { return m_flags; }
2415 
2416  //! Sets the internal document template flags (see the constructor description for more details).
2417  void SetFlags( a2dTemplateFlagMask flags ) { m_flags.SetFlags( flags ); }
2418 
2419  //! Sets the internal document template flags (see the constructor description for more details).
2420  void SetFlags( a2dTemplateFlag flags ) { m_flags = flags; }
2421 
2422  //! does template mask match
2423  bool CheckMask( a2dTemplateFlagMask mask ) { return m_flags.CheckMask( mask ); }
2424 
2425  //! Returns the document type name, as passed to the document template constructor.
2426  wxString GetDocumentTypeName() const { return m_docTypeName; }
2427 
2428  //! Sets the file filter.
2429  void SetFileFilter( const wxString& filter ) { m_fileFilter = filter; }
2430 
2431  //! Sets the default directory.
2432  void SetDirectory( const wxString& dir ) { m_directory = dir; }
2433 
2434  //! Sets the template description.
2435  void SetDescription( const wxString& descr ) { m_description = descr; }
2436 
2437  //! Sets the default file extension.
2438  void SetDefaultExtension( const wxString& ext ) { m_defaultExt = ext; }
2439 
2440  //! Returns true if the document template can be shown in user dialogs, false otherwise.
2441  void SetVisible( bool value ) { m_flags.SetFlags( a2dTemplateFlag::VISIBLE ); }
2442 
2443  //! Returns true if the document template is marked , false otherwise.
2444  void SetMarked( bool value ) { m_flags.SetFlags( a2dTemplateFlag::MARK ); }
2445 
2446  //! Returns true if the document template can be shown in user dialogs, false otherwise.
2447  bool IsVisible() const { return m_flags.GetFlag( a2dTemplateFlag::VISIBLE ); }
2448 
2449  //! Returns true if the document template is marked , false otherwise.
2450  bool IsMarked() const { return m_flags.GetFlag( a2dTemplateFlag::MARK ); }
2451 
2452  //! to test if a file that needs to be loaded, is suitable for this template.
2453  /*!
2454  The default implementation is testing the file extension of the template against the
2455  file extension in the path.
2456  When no extension is given in the file and a m_ioHandlerStrIn is set, the a2dIOHandler::CanLoad()
2457  is used to test the file contents for that io handler.
2458  At last the m_fileFilter is search for the path extension, if found return true.
2459  */
2460  virtual bool FileMatchesTemplate( const wxString& path );
2461 
2462  //! Get Input handler used to store the document using this template
2463  virtual a2dIOHandlerStrIn* GetDocumentIOHandlerStrIn() { return m_ioHandlerStrIn; }
2464 
2465  //! Get output handler used to save the document using this template
2466  virtual a2dIOHandlerStrOut* GetDocumentIOHandlerStrOut() { return m_ioHandlerStrOut; }
2467 
2468  //! if there is an io handler, and it can load the document of this template, return it
2469  virtual a2dIOHandlerStrIn* GetDocumentIOHandlerForLoad( a2dDocumentInputStream& stream, a2dDocument* document );
2470 
2471  //! if there is an io handler, and it can save the document of this template, return it
2472  /*!
2473  \param filename when not empty, it is/can be used to choose io handler also based on the extension of the filename.
2474  \param document the document that needs to be saved.
2475  */
2476  virtual a2dIOHandlerStrOut* GetDocumentIOHandlerForSave( const wxString& filename, a2dDocument* document );
2477 
2478  //! Set Inputhandler used to load the document using this template
2479  virtual void SetDocumentIOHandlerStrIn( a2dIOHandlerStrIn* handler ) { m_ioHandlerStrIn = handler; }
2480 
2481  //! Set output handler used to save the document using this template
2482  virtual void SetDocumentIOHandlerStrOut( a2dIOHandlerStrOut* handler ) { m_ioHandlerStrOut = handler; }
2483 
2484  //! return the a2dViewConnector that is used for sending the ::wxEVT_POST_CREATE_DOCUMENT too.
2485  a2dViewConnector* GetViewConnector() { return m_connector; }
2486 
2487 #if wxUSE_PRINTING_ARCHITECTURE
2488  wxPageSetupDialogData* GetPageSetupData( void ) const { return m_pageSetupData; }
2489  void SetPageSetupData( const wxPageSetupDialogData& pageSetupData ) { *m_pageSetupData = pageSetupData; }
2490  void SetPageSetupData( wxPageSetupDialogData* pageSetupData );
2491 #endif
2492 
2493  wxClassInfo* GetDocumentClassInfo() const { return m_docClassInfo; }
2494 
2495  //! if set this will be used instead of m_docClassInfo to initiate new documents
2496  a2dDocument* GetDocumentCreate() { return m_documentCreate; }
2497 
2498  //! if set this will be used instead of m_docClassInfo to initiate new documents
2499  /*!
2500  Id set a clone of this document will be used to create new documents through this
2501  a2dDocumentTemplate. This is handy when a document has a lot of initial settings which
2502  can now be set once here. So for each document type/purpose you can have unique settings.
2503 
2504  \remark m_docClassInfo still needs ot be set.
2505  */
2506  void SetDocumentCreate( a2dDocument* documentCreate ) { m_documentCreate = documentCreate; }
2507 
2508 protected:
2509 
2510  a2dObject* DoClone( a2dObject::CloneOptions options, a2dRefMap* refs ) const;
2511 
2512 #if wxART2D_USE_CVGIO
2513  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts, a2dObjectList* towrite );
2514  virtual void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
2515 #endif //wxART2D_USE_CVGIO
2516 
2517  //! The flags passed to the constructor.
2519 
2520  //! The file filter (such as *.txt) to be used in file selector dialogs.
2521  wxString m_fileFilter;
2522 
2523  //! The default directory for files of this type.
2524  wxString m_directory;
2525 
2526  //! A short description of this template
2527  wxString m_description;
2528 
2529  //! The default extension for files of this type
2530  wxString m_defaultExt;
2531 
2532  //! The named type of the document associated with this template.
2533  wxString m_docTypeName;
2534 
2535  //! Run-time class information that allows document instances to be constructed dynamically.
2536  wxClassInfo* m_docClassInfo;
2537 
2538  //! if set this will be used instead of m_docClassInfo to initiate new documents
2540 
2541  //! used for reading the document from streams.
2543 
2544  //! used for writing the document to streams.
2546 
2547  //! class used to connect new views with Frames and windows.
2549 
2550 #if wxUSE_PRINTING_ARCHITECTURE
2551  //! this is the printer page setup data for all documents with this template
2552  wxPageSetupDialogData* m_pageSetupData;
2553 #endif
2554 
2555 private:
2556 
2557  virtual a2dObject* SmrtPtrOwn();
2558  virtual bool SmrtPtrRelease();
2559  friend class a2dSmrtPtrBase;
2560 };
2561 
2562 
2563 //! Automatic template, which searches a suitable handler for the document.
2564 /*!
2565  a2dDocviewGlobals->GetDocviewCommandProcessor()->GetDocTemplates() is used
2566  to find a template which fits the document type of the template.
2567 
2568  An extra test is performed in GetDocumentIOHandlerForLoad() GetDocumentIOHandlerForSave(),
2569  to see if that template can be used for saving or loading the document.
2570 
2571  This template is handy in use when you what an All Files template.
2572  The document with this template, will automatically choose the right handler for files you choose.
2573  Extension is not important.
2574 
2575 */
2576 class A2DDOCVIEWDLLEXP a2dDocumentTemplateAuto: public a2dDocumentTemplate
2577 {
2578 
2579  DECLARE_CLASS( a2dDocumentTemplateAuto )
2580 
2581 public:
2582 
2584  const wxString& descr,
2585  const wxString& filter,
2586  const wxString& dir,
2587  const wxString& ext,
2588  const wxString& docTypeName,
2589  wxClassInfo* docClassInfo = ( wxClassInfo* ) NULL,
2590  a2dViewConnector* connector = ( a2dViewConnector* ) NULL,
2591  long flags = a2dTemplateFlag::DEFAULT );
2592 
2593  //! Destructor.
2595 
2596  //! if there is an io handler, and it can load the document of this template, return it
2597  virtual a2dIOHandlerStrIn* GetDocumentIOHandlerForLoad( a2dDocumentInputStream& stream, a2dDocument* document );
2598 
2599  //! if there is an io handler, and it can save the document of this template, return it
2600  /*!
2601  \param filename when not empty, it is/can be used to choose io handler also based on the extension of the filename.
2602  \param document the document that needs to be saved.
2603  */
2604  virtual a2dIOHandlerStrOut* GetDocumentIOHandlerForSave( const wxString& filename, a2dDocument* document );
2605 
2606 };
2607 
2608 //! The a2dViewTemplate class is used to model the relationship between a document class and a view class.
2609 /*!
2610  Next to that, a a2dViewConnector class pointer
2611  is used to connect new views and documents into a wxFrame and/or wxWindow.
2612  The a2dDocumentCommandProcessor can be used to display a dialog with a list of available
2613  a2dViewTemplate's for a certain document type.
2614  Using the choosen a2dViewTemplate, this template will then be used to create
2615  a view on the document. This happens in CreateView().
2616 
2617  When, how and where this new view will be displayed, is up to the a2dViewConnector.
2618 
2619  CreateView() sents two events:
2620  - ::wxEVT_CREATE_VIEW event sent to the new view.
2621  - ::wxEVT_POST_CREATE_VIEW event sent to the a2dViewConnector class m_connector.
2622 
2623  The a2dViewConnector derived class often intercepts the event to connect
2624  the created a2dView into (newly created or existing) Frames or Windows.
2625 
2626  It is possible that newly created view do not need to be plugged into any Window or Frame.
2627  Therefore the connector class pointer may be NULL.
2628 
2629  \see a2dDocumentTemplate
2630 
2631  \see a2dViewConnector
2632 
2633  \ingroup docview
2634 */
2635 class A2DDOCVIEWDLLEXP a2dViewTemplate: public a2dObject
2636 {
2637 
2638  DECLARE_CLASS( a2dViewTemplate )
2639 
2640 public:
2641 
2642 #if wxART2D_USE_CVGIO
2643  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts, a2dObjectList* towrite );
2644  virtual void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
2645 #endif //wxART2D_USE_CVGIO
2646 
2647  //! Associate document and view types. They're for identifying what view is associated with what template/document type
2648  /*!
2649  Constructor. Create instances dynamically near the start of your
2650  application after creating a a2dDocumentCommandProcessor instance, and before doing
2651  any document or view operations.
2652 
2653  \param descr is a short description of what the template is for. This string
2654  will be displayed in the file filter list of Windows file selectors.
2655 
2656  \param docTypeName is a name that should be unique for a given type of document,
2657  used for gathering a list of views relevant to a particular document.
2658 
2659  \param viewTypeName is a name that should be unique for a given view.
2660 
2661  \param viewClassInfo is a pointer to the run-time view class information as
2662  returned by the CLASSINFO macro, e.g. CLASSINFO(MyViewClass).
2663  If this is not supplied, you will need to derive a new a2dDocumentTemplate
2664  class and override the CreateView member to return a new view instance on demand.
2665 
2666  \param connector is a pointer to a a2dViewConnector class, which will be used in
2667  the default handler for the ::wxEVT_POST_CREATE_VIEW event, OnPostCreateView to redirect
2668  the event to the a2dViewConnector class. If NULL the new view is not plugged into anything.
2669 
2670  \param flags is a bit list of the following:
2671 
2672  - a2dTemplateFlag::VISIBLE The template may be displayed to the user in dialogs.
2673  - wxREFTEMPLATE_INVISIBLE The template may not be displayed to the user in dialogs.
2674  - a2dTemplateFlag::DEFAULT Defined as a2dTemplateFlag::VISIBLE.
2675 
2676  \param size size sets initial size for views generated from this template
2677 
2678  */
2680  const wxString& descr,
2681  const wxString& docTypeName,
2682  const wxString& viewTypeName,
2683  wxClassInfo* viewClassInfo = ( wxClassInfo* ) NULL,
2684  a2dViewConnector* connector = ( a2dViewConnector* ) NULL,
2685  long flags = a2dTemplateFlag::DEFAULT,
2686  const wxSize& size = wxSize( 0, 0 ) );
2687 
2688  //! Destructor.
2689  ~a2dViewTemplate();
2690 
2691  //! Creates a new view for the given document.
2692  /*!
2693  Creates a new instance of the associated view class. If you have not supplied a
2694  wxClassInfo parameter to the template constructor, you will
2695  need to override this function to return an appropriate view instance.
2696 
2697  After creating a new view using wxClassInfo two events are generated:
2698 
2699  - a2dViewEvent of type ::wxEVT_CREATE_VIEW
2700  - a2dViewTemplateEvent of type ::wxEVT_POST_CREATE_VIEW
2701  */
2702  virtual a2dView* CreateView( a2dDocument* doc, a2dDocumentFlagMask flags = a2dREFDOC_NON );
2703 
2704  //! Returns the text description of this template, as passed to the document template constructor
2705  wxString GetDescription() const { return m_description; }
2706 
2707  //! Sets the template description.
2708  void SetDescription( const wxString& descr ) { m_description = descr; };
2709 
2710  //! Returns the view type name, as passed to the document template constructor.
2711  wxString GetViewTypeName() const { return m_viewTypeName; }
2712 
2713  //! Returns the document type name, as passed to the document template constructor.
2714  wxString GetDocumentTypeName() const { return m_docTypeName; }
2715 
2716  //! Returns the flags, as passed to the document template constructor.
2717  const a2dTemplateFlag& GetFlags() const { return m_flags; }
2718 
2719  //! Sets the internal document template flags (see the constructor description for more details).
2720  void SetFlags( a2dTemplateFlagMask flags ) { m_flags.SetFlags( flags ); }
2721 
2722  //! Sets the internal document template flags (see the constructor description for more details).
2723  void SetFlags( a2dTemplateFlag flags ) { m_flags = flags; }
2724 
2725  //! does template mask match
2726  bool CheckMask( a2dTemplateFlagMask mask ) { return m_flags.CheckMask( mask ); }
2727 
2728  //! Returns true if the document template can be shown in user dialogs, false otherwise.
2729  void SetVisible( bool value ) { m_flags.SetFlags( a2dTemplateFlag::VISIBLE ); }
2730 
2731  //! Returns true if the document template is marked , false otherwise.
2732  void SetMarked( bool value ) { m_flags.SetFlags( a2dTemplateFlag::MARK ); }
2733 
2734  //! Returns true if the document template can be shown in user dialogs, false otherwise.
2735  bool IsVisible() const { return m_flags.GetFlag( a2dTemplateFlag::VISIBLE ); }
2736 
2737  //! Returns true if the document template is marked , false otherwise.
2738  bool IsMarked() const { return m_flags.GetFlag( a2dTemplateFlag::MARK ); }
2739 
2740  a2dViewConnector* GetViewConnector() { return m_connector; }
2741 
2742  //! set size to use for new created views
2743  void SetInitialSize( const wxSize& size ) { m_initialSize = size; }
2744 
2745  //! Get size used for new created views
2746  wxSize& GetInitialSize() { return m_initialSize; }
2747 
2748 #if wxUSE_PRINTING_ARCHITECTURE
2749  wxPageSetupDialogData* GetPageSetupData( void ) const { return m_pageSetupData; }
2750  void SetPageSetupData( const wxPageSetupDialogData& pageSetupData ) { *m_pageSetupData = pageSetupData; }
2751  void SetPageSetupData( wxPageSetupDialogData* pageSetupData );
2752 #endif
2753 
2754 protected:
2755 
2756  a2dObject* DoClone( a2dObject::CloneOptions options, a2dRefMap* refs ) const;
2757 
2758  //! size for new view
2760 
2761  //! The flags passed to the constructor.
2763 
2764  //! A short description of this template
2765  wxString m_description;
2766 
2767  //! The named type of the document associated with this template.
2768  wxString m_docTypeName;
2769 
2770  //! The named type of the view associated with this template.
2771  wxString m_viewTypeName;
2772 
2773  //! For dynamic creation of appropriate instances.
2774  wxClassInfo* m_viewClassInfo;
2775 
2776  //! class used to connect new views with Frames and windows.
2778 
2779 #if wxUSE_PRINTING_ARCHITECTURE
2780  //! this is the printer page setup data for all views with this template
2781  wxPageSetupDialogData* m_pageSetupData;
2782 #endif
2783 
2784 private:
2785 
2786  virtual a2dObject* SmrtPtrOwn();
2787  virtual bool SmrtPtrRelease();
2788  friend class a2dSmrtPtrBase;
2789 };
2790 
2791 //! This class is used to connect newly created a2dView's to a wxFrame and/or wxWindow
2792 /*!
2793  a2dDocumentTemplate generates new documents and a2dViewTemplate generate new views
2794  on a document. The new documents and views use the a2dViewConnector to link
2795  themselfs to the windows and/or frames of the application.
2796  The a2dViewConnector is an abstract class, so a new connector class needs
2797  to be derived. This derived class has complete freedom on how to organize new views
2798  into the application. It may decide to use existing frame or windows, or generate
2799  new frames and/or windows. In the end it must set one wxWindow pointer
2800  in the a2dView, which will be used by the view to display itself.
2801  The a2dViewConnector may also decide to use existing views for connecting the new document to.
2802  In that case no new views will be created.
2803 
2804  The approach to have a a2dViewConnector decide how to connect views to frames/windows,
2805  is good for making a2dView independent classes. In such clases, the views can be switched
2806  with other views.
2807  Think here of a complete graphical editor wxFrame derived class,
2808  which edits the view which has the focus.
2809  It has all the menu's and tools to do it, but does not know yet if there is one or many views
2810  inside itself. It only knows how to edit one a2dView which is part of the editor frame.
2811  Different types of views can be switched into the editor frame,
2812  where each view type can define a different manner of rendering a drawing.
2813  One might use the standard wxDC based API for drawing in one view type,
2814  and another using an antialiasing rendering engine. The editor does not need to know what
2815  view is used internal.
2816 
2817  The a2dViewConnector class is created before setting up a2dDocumentTemplate, and given as a pointer to
2818  a2dDocumentTemplate and a2dViewTemplate.
2819 
2820  a2dDocumentTemplate sents a ::wxEVT_POST_CREATE_DOCUMENT event after it created a new a2dDocument.
2821  This event should be catched by the a2dViewConnector.
2822  The default handler calls CreateView on a choosen a2dViewTemplate from a list,
2823  leading to a ::wxEVT_POST_CREATE_VIEW being sent to this or another a2dViewConnector class.
2824  The connector receives this event, and the new view can be plugged into/attached to a window etc.
2825 
2826  WxViewTemplateRef sents a ::wxEVT_POST_CREATE_VIEW event after it created a new a2dView.
2827  This event may be catched by the a2dViewConnector.
2828  One can handle this event in a derived a2dViewConnector class, and connect the new a2dView
2829  somehow into the application its wxFrame's or wxWindow's.
2830  The normal action should be to plug the new view into a wxFrame, and/or create a wxWindow
2831  for the a2dView to use as DisplayWindow.
2832  The wxFrame and DisplayWindow may already exist or will be created each time.
2833  This depends on the application and what a2dViewConnector is used.
2834 
2835  The new a2dView in the end will have a pointer set to its display window.
2836  It is up to the type of a2dViewConnector ( which the application uses ), to decide what to do
2837  with new a2dView's and/or new a2dDocument's.
2838 
2839  A different approach to connect new documents into the application, is to not intercept
2840  ::wxEVT_POST_CREATE_VIEW. The connector will either directly use newly created views or already
2841  existing views to connect the new document to. This should all be arranged in the handler
2842  for ::wxEVT_POST_CREATE_DOCUMENT. In a one wxFrame application with one or more subwindows containing
2843  a view, this is the better way to connect new documents into the application.
2844 
2845  The a2dView uses its DisplayWindow to redirect events ( e.g. ::wxEVT_CLOSE_VIEW ) to
2846  the window(s) and frame containing the view.
2847  A special a2dDocumentFrame can be used to interecept such events, and handle them correctly.
2848  But you can decide to use your own frame class.
2849 
2850  Events sent to this class:
2851 
2852  - ::wxEVT_POST_CREATE_DOCUMENT from template just after creation of a document
2853  - ::wxEVT_POST_CREATE_VIEW from template just after creation of a view
2854 
2855  \ingroup docview
2856 */
2857 class A2DDOCVIEWDLLEXP a2dViewConnector: public a2dObject
2858 {
2859 
2860  DECLARE_ABSTRACT_CLASS( a2dViewConnector )
2861  DECLARE_EVENT_TABLE()
2862 
2863 public:
2864 
2865  //! Constructor
2866  a2dViewConnector();
2867 
2868  //! destructor
2869  virtual ~a2dViewConnector() = 0;
2870 
2871  a2dViewConnector( const a2dViewConnector& other );
2872 
2873  //! set position to use for new created views or frames or windows
2874  void SetInitialPosition( const wxPoint& position ) { m_initialPos = position; }
2875 
2876  //! set size to use for new created views or frames or windows
2877  void SetInitialSize( const wxSize& size ) { m_initialSize = size; }
2878 
2879  //! set style to use for new created frames or windows
2880  void SetInitialStyle( long style ) { m_initialStyle = style; }
2881 
2882  //! Get position used for new created views or frames or windows
2883  wxPoint& GetInitialPosition() { return m_initialPos; }
2884 
2885  //! GGet size used for new created views or frames or windows
2886  wxSize& GetInitialSize() { return m_initialSize; }
2887 
2888  //! Get style used for new created a2dDocumentFrame
2889  long GetInitialStyle() { return m_initialStyle; }
2890 
2891  a2dViewTemplateList& GetViewTemplates() { return m_viewTemplates; }
2892 
2893  //! add a reference to a a2dViewTemplate to the wxViewTemplateReflist
2894  /*!
2895  When Associating a a2dViewTemplate, you are responsible for Disassociating that ViewTemplateRef.
2896  Not doing this will result in a memory leak, since instances of this class will not be deleted.
2897  The reason is that the ViewTemplateRef itself also Owns the connector, and therefore the reference count
2898  will never reach zero, if still associated ViewTemplateRef templates to exist.
2899  */
2900  void AssociateViewTemplate( a2dViewTemplate* temp );
2901 
2902  //! remove a reference to a a2dViewTemplate from the wxViewTemplateReflist
2903  void DisassociateViewTemplate( a2dViewTemplate* temp );
2904 
2905  //! remove All references to a a2dViewTemplate from the wxViewTemplateReflist
2906  void DisassociateViewTemplates();
2907 
2908  //! create a new view from a list of a2dViewTemplate's
2909  /*!
2910  Creates a a2dDocumentTemplateEvent of type ::wxEVT_POST_CREATE_DOCUMENT to be processed by this connector.
2911  This is handy when one already created/has a document, and wants to create a view for it.
2912  In general document are created via a2dDocumentTemplate.
2913 
2914  */
2915  virtual a2dView* CreateView( a2dDocument* doc, const wxString& viewTypeName = wxT( "" ),
2918 
2919  //! handler for ::wxEVT_DISCONNECT_VIEW
2920  /*!
2921  The ::wxEVT_DISCONNECT_ALLVIEWS is generated by the a2dDocument when it wants to disconnects all views.
2922  This can be when closing the document, or just to attach all views to another document.
2923  a2dView does intercept this event, and sents a ::wxEVT_DISCONNECT_VIEW via its a2dViewTemplate member to the
2924  a2dViewConnector of that specific template.
2925  In short the a2dViewTemplate and a2dViewConnetor which were used to generate the a2dView and connect the view
2926  into the GUI of the application, is also used to disconnect it later.
2927 
2928  Here the view connector is responsible for disconnecting view from documents, and if wanted to destroy
2929  the a2dView and/or the a2dDocumentFrame, a2dDocumentViewWindow, a2dDocumentViewScrolledWindow or whatever GUI
2930  interface was used to contain the view.
2931  */
2932  void OnDisConnectView( a2dTemplateEvent& event );
2933 
2934  //! when view is disconnected is called,
2935  //! the document is only disconnected from the document and kept alive
2936  void SetOnlyDisconnect( bool OnlyDisconnect ) { m_OnlyDisconnect = OnlyDisconnect; }
2937 
2938  //! When true, a2dView::OnDisConnectView() only disconnects view from document, and does not close it.
2939  bool GetOnlyDisconnect() { return m_OnlyDisconnect; }
2940 
2941 private:
2942 
2943  //! Default Handler Creates the first a2dView on the a2dDocument
2944  /*!
2945  Calls a2dDocumentCommandProcessor::SelectViewType() to choose a proper template for the new document.
2946  That uses the m_viewTemplates or the a2dDocviewGlobals->GetDocviewCommandProcessor()->GetViewTemplates()
2947  to display a list of view Templates for the given document.
2948  After that, the choosen view template is used to create a new a2dView via the a2dViewTemplate::CreateView() function.
2949  a2dViewTemplate::CreateView() uses its connector ( in general the same is the connector which created the document )
2950  to sent a wxEVT_POST_CREATE_VIEW to the connector. Eventually the connector will/can create/reuse windows and frames
2951  for the new views.
2952  */
2953  void OnPostCreateDocument( a2dTemplateEvent& event );
2954 
2955  //! Gives an error, telling the user to handle this event in a derived connector.
2956  //! default handler for ::wxEVT_POST_CREATE_VIEW
2957  void OnPostCreateView( a2dTemplateEvent& event );
2958 
2959  void OnCloseView( a2dCloseViewEvent& event );
2960 
2961 protected:
2962 
2963  a2dObject* DoClone( a2dObject::CloneOptions options, a2dRefMap* refs ) const
2964  {
2965  wxFAIL_MSG( wxT( "cannot clone a2dIOHandler" ) );
2966  return NULL;
2967  }
2968 
2969  //! position for new frames
2970  wxPoint m_initialPos;
2971 
2972  //! size for new frames
2974 
2975  //! style for new frames
2977 
2978  //! templates for views
2980 
2981  //! see SetOnlyDisconnect()
2983 
2984 };
2985 
2986 //! uses a wxFrame to hold new views or to create child wxFrame's to hold new views.
2987 /*!
2988 
2989  If createChildframe == true
2990  Creates for every new view reported by ::wxEVT_POST_CREATE_VIEW a new a2dDocumentFrame as child of GetDocFrame()
2991  else
2992  Switches every new view reported by ::wxEVT_POST_CREATE_VIEW into an existing a2dDocumentFrame GetDocFrame()
2993  The old a2dView for that a2dDocumentFrame stays on the wxDocument.
2994 
2995  GetFrame() / m_docframe can be the Top Frame in a window application or Any other Child Frame.
2996 */
2997 class A2DDOCVIEWDLLEXP a2dFrameViewConnector: public a2dViewConnector
2998 {
2999 
3000  DECLARE_ABSTRACT_CLASS( a2dFrameViewConnector )
3001 
3002 public:
3003 
3004  //! Constructor
3006 
3007  //! destructor
3009 
3011 
3012  //! The pointer m_docframe will be initialized.
3013  /*! An application can have only one Parent a2dDocumentFrame in the application, which is the Frame which
3014  other Child a2dDocumentFrame(s) have as Parent. The Parent Frame is in general created in
3015  bool wxApp::OnInit(void).
3016 
3017  Depending on the derived connector the a2dDocumentFrame may be used in a parent fashion
3018  or in a child fashion.
3019  The derived a2dFrameViewConnector may use the parent frame to generate new child frames for it.
3020  And in another derived a2dFrameViewConnector, the same frame may be used to switch views.
3021 
3022  The docframe can display a document using a a2dView.
3023 
3024  \param docframe The parent frame of the whole application OR a child frame
3025 
3026  \param createChildframe new views will get its own frame as child of m_docframe
3027  */
3028  void Init( wxFrame* docframe, bool createChildframe = true );
3029 
3030  //! get the frame
3031  wxFrame* GetFrame() { return m_docframe; }
3032 
3033  //! set the frame
3034  /*!
3035  The wxFrame can be the parent/top frame in the application or a Child Frame
3036  of this application. See a2dDocumentFrame how to create a parent or child frame.
3037  */
3038  void SetFrame( wxFrame* docframe ) { m_docframe = docframe; }
3039 
3040  void SetCreateChild( bool createChildframe ) { m_createChildframe = createChildframe; }
3041 
3042  bool GetCreateChild() { return m_createChildframe; }
3043 
3044 private:
3045 
3046  void OnPostCreateView( a2dTemplateEvent& event );
3047 
3048 protected:
3049 
3050  //! the frame which receives events and often redirect those to the document manager.
3051  wxFrame* m_docframe;
3052 
3053  bool m_createChildframe;
3054 };
3055 
3056 class A2DDOCVIEWDLLEXP a2dDocumentViewScrolledWindow;
3057 class A2DDOCVIEWDLLEXP a2dDocumentViewWindow;
3058 
3059 // ----------------------------------------------------------------------------
3060 // a2dWindowConnector
3061 // ----------------------------------------------------------------------------
3062 
3063 //! a connector which holds one pointer to a wxWindow derived class being the template parameter.
3064 /*!
3065  This connector connects new views to a wxWindow derived class which must have a Setview() member.
3066 
3067  ::wxEVT_POST_CREATE_VIEW is handled by a2dWindowConnector<Twindow>::OnPostCreateView(),
3068  and just sets the view to the m_display window.
3069 */
3070 template<class Twindow>
3072 {
3073  DECLARE_EVENT_TABLE()
3074 
3075 public:
3076  typedef Twindow TType;
3077 
3078  //! Constructor
3080 
3081  ~a2dWindowConnector() {};
3082 
3083  //! window used by view to display itself.
3084  Twindow* GetDisplayWindow() { return m_display; }
3085 
3086  //! get window used by view to display itself.
3087  void SetDisplayWindow( Twindow* window ) { m_display = window; }
3088 
3089 private:
3090 
3091  //! default handler for ::wxEVT_POST_CREATE_VIEW
3092  void OnPostCreateView( a2dTemplateEvent& event );
3093 
3094 protected:
3095 
3096  Twindow* m_display;
3097 };
3098 
3099 BEGIN_EVENT_TABLE_TEMPLATE1( a2dWindowConnector, a2dViewConnector, Twindow )
3100 EVT_POST_CREATE_VIEW( a2dWindowConnector<Twindow>::OnPostCreateView )
3101 END_EVENT_TABLE()
3102 
3103 template<class Twindow>
3105 {
3106  m_display = NULL;
3107 }
3108 
3109 template<class Twindow>
3111 {
3112  if ( !m_display )
3113  return; //view will not be connected to a window ( but document and view already are available).
3114 
3115  //next to what is done in base class, set the view to the display.
3116  a2dView* view = event.GetView();
3117 
3118  m_display->SetView( view );
3119  view->Update();
3120 }
3121 
3122 //! lua wrap
3124 
3125 //! extend a2dViewConnector to have a a2dDocumentViewScrolledWindow for each view.
3126 /*
3127 
3128 */
3130 {
3131  DECLARE_DYNAMIC_CLASS( a2dScrolledWindowViewConnector )
3132 };
3133 
3134 //! lua wrap
3136 
3137 //! extend a2dViewConnector to have a a2dDocumentViewScrolledWindow for each view.
3138 /*
3139 
3140 */
3142 {
3143  DECLARE_DYNAMIC_CLASS( a2dWindowViewConnector )
3144 };
3145 
3146 // ----------------------------------------------------------------------------
3147 // a2dSplitterConnector
3148 // ----------------------------------------------------------------------------
3149 
3150 //! extend wxSameFrameViewConnector to connect view into a splitter window
3151 /*!
3152  The two window of the splitter must be of type a2dDocumentViewScrolledWindow* or
3153  a2dDocumentViewWindow or one with equal event handling as those.
3154 */
3155 template<class Twindow>
3157 {
3158 
3159 public:
3160 
3161  //! Constructor
3163 
3165 
3166  void Init( wxSplitterWindow* splitter, Twindow* connecto );
3167 
3168  wxSplitterWindow* GetSplitter() { return m_splitter; }
3169 
3170 protected:
3171 
3172  wxSplitterWindow* m_splitter;
3173 };
3174 
3175 template<class Twindow>
3177 {
3178  m_splitter = ( wxSplitterWindow* ) NULL;
3179 }
3180 
3181 template<class Twindow>
3183 {
3184 }
3185 
3186 template<class Twindow>
3187 void a2dSplitterConnector<Twindow>::Init( wxSplitterWindow* splitter, Twindow* connecto )
3188 {
3189  m_splitter = splitter;
3190  wxASSERT_MSG( connecto == m_splitter->GetWindow1() || connecto == m_splitter->GetWindow2(), wxT( "wxDrawingConnector::OnCloseView Not a valid window in splitter" ) );
3191  this->SetDisplayWindow( connecto );
3192 }
3193 
3194 //----------------------------------------------------------------------------
3195 // wxNotebookConnector
3196 //----------------------------------------------------------------------------
3197 
3198 //! extend a2dWindowConnector to connect views into a wxNotebook window
3199 /*!
3200  Each new a2dView connects as a new page
3201 */
3202 template < class NoteBook, class Twindow, class Tview = a2dView >
3204 {
3205  //DECLARE_DYNAMIC_CLASS( wxNotebookConnector )
3206  //IMPLEMENT_DYNAMIC_CLASS( wxNotebookConnector, a2dScrolledWindowViewConnector )
3207 
3208  DECLARE_EVENT_TABLE()
3209 
3210 public:
3211 
3212  //! Constructor
3213  /*
3214  \param documentManager maintaining a pool of a2dDocumentTemplate's, a2dViewTemplate's
3215  a2dDocument's and their a2dView's
3216  */
3218 
3219  //! destructor
3221 
3222  //! return pointer to notebook type used
3223  wxNotebook* GetNotebook() { return m_notebook; }
3224 
3225  //! initialize with/to this notebook
3226  void Init( NoteBook* notebook );
3227 
3228 protected:
3229 
3230  //! what to do after document creation
3231  void OnPostCreateDocument( a2dTemplateEvent& event );
3232 
3233  //! what to do after view creation
3234  void OnPostCreateView( a2dTemplateEvent& event );
3235 
3236  //! the notebook to hook views into.
3237  NoteBook* m_notebook;
3238 };
3239 
3240 #define wxBEGIN_EVENT_TABLE_TEMPLATE3(theClass, baseClass, T1, T2, T3) \
3241  template<typename T1, typename T2, typename T3> \
3242  const wxEventTable theClass<T1, T2, T3>::sm_eventTable = \
3243  { &baseClass::sm_eventTable, &theClass<T1, T2, T3>::sm_eventTableEntries[0] }; \
3244  template<typename T1, typename T2, typename T3> \
3245  const wxEventTable *theClass<T1, T2, T3>::GetEventTable() const \
3246  { return &theClass<T1, T2, T3>::sm_eventTable; } \
3247  template<typename T1, typename T2, typename T3> \
3248  wxEventHashTable theClass<T1, T2, T3>::sm_eventHashTable(theClass<T1, T2, T3>::sm_eventTable); \
3249  template<typename T1, typename T2, typename T3> \
3250  wxEventHashTable &theClass<T1, T2, T3>::GetEventHashTable() const \
3251  { return theClass<T1, T2, T3>::sm_eventHashTable; } \
3252  template<typename T1, typename T2, typename T3> \
3253  const wxEventTableEntry theClass<T1, T2, T3>::sm_eventTableEntries[] = { \
3254 
3255 wxBEGIN_EVENT_TABLE_TEMPLATE3( wxNotebookConnector, a2dWindowConnector<Twindow>, NoteBook, Twindow, Tview )
3256 EVT_POST_CREATE_DOCUMENT( wxNotebookConnector::OnPostCreateDocument )
3257 EVT_POST_CREATE_VIEW( wxNotebookConnector::OnPostCreateView )
3258 END_EVENT_TABLE()
3259 
3260 template<class NoteBook, class Twindow, class Tview>
3261 wxNotebookConnector<NoteBook, Twindow, Tview>::wxNotebookConnector(): a2dWindowConnector<Twindow>()
3262 {
3263  m_notebook = ( NoteBook* ) NULL;
3264 }
3265 
3266 template<class NoteBook, class Twindow, class Tview>
3268 {
3269 }
3270 
3271 template<class NoteBook, class Twindow, class Tview>
3273 {
3274  m_notebook = notebook;
3275 }
3276 
3277 template<class NoteBook, class Twindow, class Tview>
3279 {
3280  event.GetDocument()->SetTitle( event.GetDocument()->GetFilename().GetFullName() );
3281  event.Skip(); //to baseclass
3282 }
3283 
3284 template<class NoteBook, class Twindow, class Tview>
3286 {
3287  //next to what is done in base class, set the view to the display.
3288  Tview* view = wxDynamicCast( event.GetView(), Tview );
3289 
3290  Twindow* outputwindow;
3291  outputwindow = new Twindow( view, m_notebook, -1, wxDefaultPosition, wxDefaultSize, wxNO_FULL_REPAINT_ON_RESIZE );
3292  m_notebook->AddPage( outputwindow, view->GetDocument()->GetPrintableName(), true );
3293 
3294  outputwindow->SetCursor( wxCURSOR_PENCIL );
3295  outputwindow->SetScrollbars( 20, 20, 50, 50 );
3296  outputwindow->SetBackgroundColour( wxColour( 0, 235, 235 ) );
3297  outputwindow->ClearBackground();
3298 
3299  view->Update();
3300 }
3301 
3302 // ----------------------------------------------------------------------------
3303 // Provide simple default printing facilities
3304 // ----------------------------------------------------------------------------
3305 
3306 #if wxUSE_PRINTING_ARCHITECTURE
3307 //! print a document
3308 /*!
3309  \ingroup docview
3310 */
3311 class A2DDOCVIEWDLLEXP a2dDocumentPrintout : public wxPrintout
3312 {
3313  DECLARE_DYNAMIC_CLASS( a2dDocumentPrintout )
3314 
3315 public:
3316  a2dDocumentPrintout( a2dView* view = ( a2dView* ) NULL, const wxString& title = wxT( "Printout" ) );
3317  bool OnPrintPage( int page );
3318  bool HasPage( int page );
3319  bool OnBeginDocument( int startPage, int endPage );
3320  void GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, int* selPageTo );
3321 
3322  virtual a2dView* GetView() { return m_printoutView; }
3323 
3324 protected:
3325  a2dView* m_printoutView;
3326 };
3327 #endif // wxUSE_PRINTING_ARCHITECTURE
3328 
3329 
3330 // ----------------------------------------------------------------------------
3331 // Special Frame for views in a frame.
3332 // ----------------------------------------------------------------------------
3333 
3334 
3335 //!The a2dDocumentFrame class provides a default frame for displaying documents
3336 /*!
3337  Can be parent or child frame.
3338 
3339  In case of a ::wxEVT_CLOSE_WINDOW event, it is first redirected to the frame, and
3340  if not vetod askes the view to close.
3341  In a multi frame application the View should Destroy its windows/frame, including this one.
3342  The View may Veto the Close.
3343 
3344  The view which belongs to this frame is either set directly when constructing, or
3345  it is set automatically by the view when a2dView::Activate() is sending the
3346  ::wxEVT_ACTIVATE_VIEW_SENT_FROM_CHILD event.
3347  Imagine that this frame would have 4 windows, each having a view on a 3D object. When clicking on one
3348  of those view, that views, its window will be activated, resulting in its view being activated, and that
3349  sents the wanted event. The frame will always know which view is active, and e.g. closing one view/window is
3350  via this chain.
3351 
3352  If this frame is the parent all other child frames will close also,
3353  else only the child frame.
3354 
3355  \ingroup docview
3356 */
3357 class A2DDOCVIEWDLLEXP a2dDocumentFrame : public wxFrame
3358 {
3359  DECLARE_CLASS( a2dDocumentFrame )
3360 
3361 public:
3362 
3363  //! Constructor for two step creation, call a2dDocumentFrame::Create later.
3364  a2dDocumentFrame();
3365 
3366  //! constructor
3367  /*!
3368  \param parentFrame set true if this is to be the parent frame in the application.
3369  \param frame the parent frame for this frame. If topwindow use <code>NULL</code>.
3370  \param view The view for the document ( can be <code>NULL</code> )
3371  \param id The window identifier.
3372  It may take a value of -1 to indicate a default value.
3373  \param title The caption to be displayed on the frame's title bar.
3374  \param pos The window position.
3375  \param size The window size.
3376  \param style Window style, please look into wxWindows docs for an overview.
3377  \param name The name of the window.
3378  */
3380  bool parentFrame,
3381  wxWindow* frame,
3382  a2dView* view = NULL,
3383  wxWindowID id = -1,
3384  const wxString& title = wxT( "a2dDocumentFrame" ),
3385  const wxPoint& pos = wxDefaultPosition,
3386  const wxSize& size = wxDefaultSize,
3387  long style = wxDEFAULT_FRAME_STYLE,
3388  const wxString& name = wxT( "frame" ) );
3389 
3390  //! wxFrame compatible constructor
3391  // YOU must set m_view and m_isParentFrame correctly.
3393  wxWindow* frame,
3394  wxWindowID id = -1,
3395  const wxString& title = wxT( "a2dDocumentFrame" ),
3396  const wxPoint& pos = wxDefaultPosition,
3397  const wxSize& size = wxDefaultSize,
3398  long style = wxDEFAULT_FRAME_STYLE,
3399  const wxString& name = wxT( "frame" ) );
3400 
3401 
3402  //! Constructor for two-step-creation (2nd step)
3403  /*!
3404  \param parentFrame set true if this is to be the parent frame in the application.
3405  \param frame the parent frame for this frame. If topwindow use <code>NULL</code>.
3406  \param view The view for the document ( can be <code>NULL</code> )
3407  \param id The window identifier.
3408  It may take a value of -1 to indicate a default value.
3409  \param title The caption to be displayed on the frame's title bar.
3410  \param pos The window position.
3411  \param size The window size.
3412  \param style Window style, please look into wxWindows docs for an overview.
3413  \param name The name of the window.
3414  */
3415  bool Create(
3416  bool parentFrame,
3417  wxWindow* frame,
3418  a2dView* view = NULL,
3419  wxWindowID id = -1,
3420  const wxString& title = wxT( "a2dDocumentFrame" ),
3421  const wxPoint& pos = wxDefaultPosition,
3422  const wxSize& size = wxDefaultSize,
3423  long style = wxDEFAULT_FRAME_STYLE,
3424  const wxString& name = wxT( "frame" ) );
3425 
3426  //! destructor
3427  ~a2dDocumentFrame();
3428 
3429  void SetDestroyOnCloseView( bool destroyOnCloseView ) { m_destroyOnCloseView = destroyOnCloseView; }
3430 
3431  //! set a pointer to a a2dView to sent view events to.
3432  /*!
3433  Normally set via OnActivateViewSentFromChild()
3434 
3435  The m_view is used to redirect the frame event for closing the window,
3436  and the activate event for the frame, to the view.
3437  Only if the m_view->GetDisplayWindow() is the a2dDocumentFrame itself, it will also be used for
3438  drawing the view ( See OnDraw() )
3439  */
3440  void SetView( a2dView* view );
3441 
3442  //! get the pointer to a a2dView to which view events are sent
3443  a2dView* GetView() { return m_view; }
3444 
3445  //! Modified event handler to also sent event to a2dView or wxDocviewCommonEvents
3446  /*!
3447  Events handled how:
3448  - ::wxEVT_CLOSE_WINDOW if this frame is a parent frame, and the event is not vetod by the frame
3449  itself, calls a2dDocviewGlobals->GetDocviewCommandProcessor()->Clear(), this will
3450  eventually close all document and close all child views. And a child view will
3451  sent a ::wxEVT_CLOSE_VIEW to its containing window, and this will end up in the child frame
3452  (if there). So closing the parent frame, will lead to closing the child frames.
3453  If this frame is a childframe, the event is only sent to the view, if not vetod by this frame.
3454  This will lead to calling a2dView::Close(), and this gives you the chance to clean up
3455  by intercepting the ::wxEVT_CLOSE_VIEW event which is generated in there.
3456 
3457  - ::wxEVT_ACTIVATE sent to view, and next to the frame itself.
3458  - all others first to frame itself, if not handled to view, and if not handled to
3459  a2dDocviewGlobals->GetDocviewCommonEvents()
3460 
3461  */
3462  bool ProcessEvent( wxEvent& event );
3463 
3464  bool ProcessConnectedEvent( wxEvent& event );
3465  void ConnectEvent( wxEventType type, wxEvtHandler* evtObject );
3466  bool DisconnectEvent( wxEventType type, wxEvtHandler* evtObject );
3467 
3468  bool GetIsParentFrame() { return m_isParentFrame; }
3469 
3470  void SetIsParentFrame( bool parentFrame ) { m_isParentFrame = parentFrame; }
3471 
3472  //! Override this function to draw the graphic (or just process EVT_PAINT)
3473  /*!
3474  The default handler for EVT_PAINT is OnPaint, and it calls OnDraw().
3475  OnDraw its default implementation is calling the m_view its OnDraw().
3476 
3477  If m_view its DisplayWindow, is the frame itself, the m_view->OnDraw() is called.
3478  If not the m_view, is only used for redirecting Close and activate events to the
3479  view which has the focus.
3480  */
3481  virtual void OnDraw( wxDC& dc );
3482 
3483  //! add items to toolbar using a predefined command ID.
3484  void AddCmdToToolbar( const a2dMenuIdItem& cmdId );
3485  void ConnectCmdId( const a2dMenuIdItem& cmdId );
3486 
3487  //! add a menu to the parent menu, and connect it to the eventhandler of the frame
3488  /*!
3489  Many commands which can be submitted to a commandprocessor in the following manner:
3490  \code
3491  commandprocessor->Submit( new a2dCommand_SomeCommand() )
3492  \endcode
3493 
3494  If a command does not make sense, but a function on the command handler must be called,
3495  it can be handled as described below too.
3496 
3497  Submitting a command makes it possible to undo the action.
3498  To issue such a command from a menu requires a menu Id, which is handled by wxWidgets
3499  its event system. e.g. a2dDocumentFrame and if not processed, try a2dDocumentCommandProcessor.
3500  The last in many cases submits a proper command based on the menu id.
3501 
3502  Therefore wxDocview defines many predefined
3503  menus items in the form of a2dMenuIdItem. They produce a unique Id to be handled in
3504  the commandprocessor. Like in:
3505  \code
3506  void a2dDocumentCommandProcessor::OnMenu( wxCommandEvent& event )
3507  \endcode
3508  Several modules in wxDocview extend the set of handled menu Id's in a derived a2dDocumentCommandProcessor.
3509  The OnMenu intercepts the menu event, and sets up a new a2dCommand to be submitted.
3510  Understand that a2dDocumentFrame and a2dDocumentMDIParentFrame already redirect non handled events to
3511  the commandprocessor of the application.
3512  An a2dMenuIdItem defined menu text and helpstring, therefore all you need to do to add a command to
3513  your application is AddCmdMenu().
3514  Many commands have parameters, and a a2dMenuIdItem its Id, can only be coupled to one a2dCommand with
3515  some predefined set of parameters.
3516  If you need a different implementation of the same command you can extend in the same manner
3517  in your derived commandprocessor. But you can always use the standard way of wxWidgets to add a menu,
3518  and add a handler in the frame. In the handler, you setup the a2dCommand and submit it.
3519  Exactly the same behaviour, only not predefined.
3520 
3521  \remark a2dMenuIdItem uses Id my name ready to be used by XRC files.
3522  */
3523  void AddCmdMenu( wxMenu* parentMenu, const a2dMenuIdItem& cmdId );
3524 
3525  //! same as for a2dMenuIdItem, Id in wxMenuItem must be a valid id from one a2dMenuIdItem
3526  //! used in XRC files
3527  void AddCmdMenu( wxMenu* parentMenu, wxMenuItem* item );
3528 
3529  //! remove a command menu from the parent menu.
3530  /*!
3531  See AddCmdMenu()
3532  */
3533  void RemoveCmdMenu( wxMenu* parentMenu, const a2dMenuIdItem& cmdId );
3534 
3535  //! called for dynamic added menu's via AddCommandToMenu()
3536  //! command will be submitted to a2dDocviewGlobals->GetDocviewCommandProcessor()
3537  void OnExecuteCommand( wxCommandEvent& event );
3538 
3539  //! used by AddCmdMenu() to dynamically connect menu to function.
3540  //! The function just Skipps the event, so it will be handled by a command processor in the end.
3541  void OnCmdMenuId( wxCommandEvent& event );
3542 
3543 protected:
3544 
3545 
3546  //! default handler for paint events, it calls OnDraw().
3547  void OnPaint( wxPaintEvent& event );
3548 
3549  //! default for closing a view in this frame
3550  /*!
3551  Close the view, if set, and destroy the frame.
3552  The view is closed even if it is displayed in a nested subwindow.
3553  Since it Destroys the frame ( if m_destroyOnCloseView is set ),
3554  that will automatically destroy the nested windows too.
3555 
3556  /remark m_view is set to the active view if there are more sub windows with
3557  views. So just closing the currently active view is not enough, if there are more.
3558  */
3559  void OnCloseView( a2dCloseViewEvent& event );
3560 
3561 
3562  //! default for closing this frame via close button.
3563  /*!
3564  default handler for wxEVT_CLOSE event.
3565  Give the Frame the right to veto.
3566  The default tries to close the view.
3567  That is the right thing to do if the frame has just a single view.
3568 
3569  If there are more views ( even in nested windows ), you need to
3570  handle that yourself.
3571 
3572  /remark m_view is set to the active view if there are more sub windows with
3573  views. So just closing the currently active view is not enough, if there are more.
3574  */
3575  void OnCloseWindow( wxCloseEvent& event );
3576 
3577  //! called by API and only handled if this is the Parent Frame
3578  void OnExit( wxCommandEvent& event );
3579 
3580  //! called by API and only handled if this is the Parent Frame
3581  void OnMRUFile( wxCommandEvent& event );
3582 
3583  //! default handler for file changed event sent from a2dView
3584  /*!
3585  Sents the event to the DisplayWindow, there or in its parent hiearchy it can be intercepted.
3586  */
3587  void OnChangeFilename( a2dViewEvent& event );
3588 
3589  //! sets m_view to the current active view, generate by a2dView::Activate()
3590  void OnActivateViewSentFromChild( a2dViewEvent& viewevent );
3591 
3592  //! used for redirecting close and activate events to the view which has the focus.
3593  //! See SetView()
3595 
3596  //! is this the docframe or not.
3598 
3599  //! when closing the view the frame will be destroyed.
3601 
3602  DECLARE_EVENT_TABLE()
3603 };
3604 
3605 
3606 
3607 //! specialized wxWindow derived template class to handle a2dView events
3608 /*!
3609  The following events are sent up from the a2dView to this window.
3610 
3611  ::wxEVT_CLOSE_VIEW
3612 
3613  Next one can be recieved from the a2dDocument after Registering this class.
3614 
3615  ::wxEVT_CHANGEDFILENAME_DOCUMENT
3616 
3617  When the a2dView sent this events it disables itself until return, to prevent looping.
3618 
3619  ::wxEVT_CLOSE_VIEW should be handled in a derived class, or in some/the parent window of this window.
3620  The handler must call a2dDocumentViewScrolledWindow::SetView( NULL )
3621  or set m_view to NULL and release it, this Detaches the view from the window,
3622  In case the window gets deleted via a Destroy() this will be done automatically.
3623 
3624  These event are of type commandevents, and travel up to the parent of this window if not handled here.
3625 
3626  All other events to the window are sent first to the a2dView and if not handled there,
3627  can be handled here.
3628 */
3629 template<class Twindow>
3630 class A2DDOCVIEWDLLEXP a2dViewWindow: public Twindow
3631 {
3632 
3633 public:
3634 
3635  //! Constructor for creation with view.
3636  /*!
3637  \param view The view for the document ( can be <code>NULL</code> )
3638  \param parent the parent window for this window
3639  \param id The window identifier.
3640  It may take a value of -1 to indicate a default value.
3641  \param pos The window position.
3642  \param size The window size.
3643  \param style Window style, please look into wxWindows docs for an overview.
3644  \param name The name of the window.
3645  */
3646  a2dViewWindow( a2dView* view,
3647  wxWindow* parent,
3648  wxWindowID id = -1,
3649  const wxPoint& pos = wxDefaultPosition,
3650  const wxSize& size = wxDefaultSize,
3651  long style = wxHSCROLL | wxVSCROLL,
3652  const wxString& name = wxT( "a2dViewWindow" ) );
3653 
3654  //! Constructor for creation without view.
3655  /*!
3656  \param parent the parent window for this window
3657  \param id The window identifier.
3658  It may take a value of -1 to indicate a default value.
3659  \param pos The window position.
3660  \param size The window size.
3661  \param style Window style, please look into wxWindows docs for an overview.
3662  \param name The name of the window.
3663  */
3664  a2dViewWindow( wxWindow* parent,
3665  wxWindowID id = -1,
3666  const wxPoint& pos = wxDefaultPosition,
3667  const wxSize& size = wxDefaultSize,
3668  long style = wxHSCROLL | wxVSCROLL,
3669  const wxString& name = wxT( "a2dViewWindow" ) );
3670 
3671  //! Destructor.
3672  ~a2dViewWindow();
3673 
3674  //! to switch the view in this window to another view
3675  /*!
3676  Default releases the old view and sets it display to NULL.
3677  Next it sets and owns the new view and sets the view its display to this window.
3678  Override this if more needs to be done to switch the view.
3679  */
3680  virtual void SetView( a2dView* view );
3681 
3682  //! get the current view
3683  a2dView* GetView() { return m_view; }
3684 
3685  //! Extend event processing to search the view's event table
3686  /*! Some events are handled within the view as if the view is a window within a window.
3687  Therefore the wxWindow containing the view should redirect all its events to
3688  its views, when the view does not handle the event it will go to the window itself.
3689 
3690  View events ::wxEVT_CLOSE_VIEW from the view are
3691  sent up to this window.
3692 
3693  Next one can be recieved from the a2dDocument after Registering this class.
3694 
3695  ::wxEVT_CHANGEDFILENAME_DOCUMENT
3696 
3697  */
3698  virtual bool ProcessEvent( wxEvent& event );
3699 
3700  //! Override this function to draw the graphic (or just process EVT_PAINT)
3701  virtual void OnDraw( wxDC& dc );
3702 
3703  //! resets view to NULL when view was closed and skips the event for the parent window/frame.
3704  void OnCloseView( a2dCloseViewEvent& event );
3705 
3706  //! calls OnDraw(dc);
3707  void OnPaint( wxPaintEvent& event );
3708 
3709 protected:
3710 
3711  //! the view that uses this window to display itself
3713 
3714 //private:
3715 
3716 };
3717 
3718 // Define a constructor for my canvas
3719 template<class Twindow>
3720 a2dViewWindow<Twindow>::a2dViewWindow( a2dView* view, wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, const long style, const wxString& name ):
3721  Twindow( parent, id, pos, size, style, name )
3722 {
3723 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
3724  m_view.m_owner = this;
3726 #endif
3727  m_view = view;
3728  if ( m_view )
3729  {
3730  //Attach the canvas as the window for the view to display its stuff
3731  m_view->SetDisplayWindow( this );
3732  }
3733  Twindow::Enable();
3734 }
3735 
3736 // Define a constructor for my canvas
3737 template<class Twindow>
3738 a2dViewWindow<Twindow>::a2dViewWindow( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size, const long style, const wxString& name ):
3739  Twindow( parent, id, pos, size, style, name )
3740 {
3741 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
3742  m_view.m_owner = this;
3744 #endif
3745  m_view = NULL;
3746 }
3747 
3748 template<class Twindow>
3750 {
3751  if ( m_view )
3752  {
3753  m_view->SetDisplayWindow( NULL );
3754  }
3755  m_view = NULL;
3756 }
3757 
3758 template<class Twindow>
3760 {
3761  if ( m_view )
3762  {
3763  m_view->SetDisplayWindow( NULL );
3764  }
3765 
3766  m_view = view;
3767 
3768  if ( m_view )
3769  {
3770  //Attach the canvas as the window for the view to display its stuff
3771  m_view->SetDisplayWindow( this );
3772  m_view->Activate( true );
3773  }
3774 }
3775 
3776 template<class Twindow>
3777 void a2dViewWindow<Twindow>::OnPaint( wxPaintEvent& WXUNUSED( event ) )
3778 {
3779  wxPaintDC dc( this );
3780  Twindow::PrepareDC( dc );
3781 
3782  OnDraw( dc );
3783 }
3784 
3785 // Define the repainting behaviour
3786 template<class Twindow>
3788 {
3789  if ( m_view )
3790  m_view->OnDraw( & dc );
3791 }
3792 
3793 template<class Twindow>
3795 {
3796  wxASSERT_MSG( m_view == event.GetEventObject(), wxT( "view in a2dCloseViewEvent not equal to m_view" ) );
3797 
3798  if ( m_view )
3799  {
3800  //we do not set the m_view->SetDisplayWindow( NULL );
3801  //This enables parent window to still find the display window via the a2dCloseViewEvent.
3802  //The view itself will set the m_display to NULL.
3803  m_view = NULL;
3804  }
3805 
3806  Twindow::Refresh();
3807  event.Skip(); //to parent window/frame
3808 }
3809 
3810 template<class Twindow>
3812 {
3813  //some wxViewEvents go upstream ( document -> view -> window -> frame )
3814  //These event are of the commandevent type, so they do get processed by the parent window
3815  //of this window ( when not processed here ).a
3816 
3817  // Extend event processing to search the view's event table
3818  if ( event.GetEventType() == wxEVT_ACTIVATE_VIEW_SENT_FROM_CHILD )
3819  {
3820  return wxEvtHandler::ProcessEvent( event );
3821  }
3822  else
3823  {
3824  // most events will be processed first by the view
3825  if ( m_view && !m_view->IsClosed() &&
3826  m_view->ProcessEvent( event ) )
3827  return true;
3828 
3829  return wxEvtHandler::ProcessEvent( event );
3830  }
3831  return false;
3832 }
3833 
3834 //! specialized wxScrolledWindow to handle a2dView events
3835 /*!
3836  The following events are sent up from the a2dView to this window.
3837 
3838  ::wxEVT_CLOSE_VIEW
3839 
3840  Next one can be recieved from the a2dDocument after Registering this class.
3841 
3842  ::wxEVT_CHANGEDFILENAME_DOCUMENT
3843 
3844  When the a2dView sent this events it disables itself until return, to prevent looping.
3845 
3846  ::wxEVT_CLOSE_VIEW should be handled in a derived class, or in some/the parent window of this window.
3847  The handler must call a2dDocumentViewScrolledWindow::SetView( NULL )
3848  or set m_view to NULL and release it, this Detaches the view from the window,
3849  In case the window gets deleted via a Destroy() this will be done automatically.
3850 
3851  These event are of type commandevents, and travel up to the parent of this window if not handled here.
3852 
3853  All other events to the window are sent first to the a2dView and if not handled there,
3854  can be handled here.
3855 */
3857 {
3858  DECLARE_EVENT_TABLE()
3859 
3860 public:
3861  //! Constructor for creation with view.
3862  /*!
3863  \param view The view for the document ( can be <code>NULL</code> )
3864  \param parent the parent window for this window
3865  \param id The window identifier.
3866  It may take a value of -1 to indicate a default value.
3867  \param pos The window position.
3868  \param size The window size.
3869  \param style Window style, please look into wxWindows docs for an overview.
3870  \param name The name of the window.
3871  */
3873  wxWindow* parent,
3874  wxWindowID id = -1,
3875  const wxPoint& pos = wxDefaultPosition,
3876  const wxSize& size = wxDefaultSize,
3877  long style = wxHSCROLL | wxVSCROLL,
3878  const wxString& name = wxT( "a2dDocumentViewScrolledWindow" ) );
3879 
3880  //! Constructor for creation without view.
3881  /*!
3882  \param parent the parent window for this window
3883  \param id The window identifier.
3884  It may take a value of -1 to indicate a default value.
3885  \param pos The window position.
3886  \param size The window size.
3887  \param style Window style, please look into wxWindows docs for an overview.
3888  \param name The name of the window.
3889  */
3890  a2dDocumentViewScrolledWindow( wxWindow* parent,
3891  wxWindowID id = -1,
3892  const wxPoint& pos = wxDefaultPosition,
3893  const wxSize& size = wxDefaultSize,
3894  long style = wxHSCROLL | wxVSCROLL,
3895  const wxString& name = wxT( "a2dDocumentViewScrolledWindow" ) );
3896 
3897  //! Destructor.
3899 
3900 private:
3901 
3902  DECLARE_CLASS( a2dDocumentViewScrolledWindow )
3903 };
3904 
3905 
3906 //! specialized wxWindow to handle a2dView events
3907 /*!
3908  The following events are sent up from the a2dView to this window.
3909 
3910  ::wxEVT_CLOSE_VIEW
3911 
3912  Next one can be recieved from the a2dDocument after Registering this class.
3913  ::wxEVT_CHANGEDFILENAME_DOCUMENT
3914 
3915  When the a2dView sent this events it disables itself until return, to prevent looping.
3916 
3917  ::wxEVT_CLOSE_VIEW should be handled in a derived class, or in some/the parent window of this window.
3918  The handler must call a2dDocumentViewScrolledWindow::SetView( NULL )
3919  or set m_view to NULL and release it, this Detaches the view from the window,
3920  In case the window gets deleted via a Destroy() this will be done automatically.
3921 
3922  These event are of type commandevents, and travel up to the parent of this window if not handled here.
3923 
3924  All other events to the window are sent first to the a2dView and if not handled there,
3925  can be handled here.
3926 */
3928 {
3929  DECLARE_EVENT_TABLE()
3930 
3931 public:
3932  //! Constructor for creation with view.
3933  /*!
3934  \param view The view for the document ( can be <code>NULL</code> )
3935  \param parent the parent window for this window
3936  \param id The window identifier.
3937  It may take a value of -1 to indicate a default value.
3938  \param pos The window position.
3939  \param size The window size.
3940  \param style Window style, please look into wxWindows docs for an overview.
3941  \param name The name of the window.
3942  */
3944  wxWindow* parent,
3945  wxWindowID id = -1,
3946  const wxPoint& pos = wxDefaultPosition,
3947  const wxSize& size = wxDefaultSize,
3948  long style = wxHSCROLL | wxVSCROLL,
3949  const wxString& name = wxT( "a2dDocumentViewWindow" ) );
3950 
3951 
3952  //! Constructor for creation without view.
3953  /*!
3954  \param parent the parent window for this window
3955  \param id The window identifier.
3956  It may take a value of -1 to indicate a default value.
3957  \param pos The window position.
3958  \param size The window size.
3959  \param style Window style, please look into wxWindows docs for an overview.
3960  \param name The name of the window.
3961  */
3962  a2dDocumentViewWindow( wxWindow* parent,
3963  wxWindowID id = -1,
3964  const wxPoint& pos = wxDefaultPosition,
3965  const wxSize& size = wxDefaultSize,
3966  long style = wxHSCROLL | wxVSCROLL,
3967  const wxString& name = wxT( "a2dDocumentViewWindow" ) );
3968 
3969  //! Destructor.
3971 
3972  DECLARE_CLASS( a2dDocumentViewWindow )
3973 };
3974 
3975 
3976 
3977 
3978 #endif /* _WX_DOCREFH__ */
3979 
3980 
Automatic template, which searches a suitable handler for the document.
Definition: docviewref.h:2576
a2dSmrtPtr< a2dCommandProcessor > m_commandProcessor
A pointer to the command processor associated with this document.
Definition: docviewref.h:1643
void Allow()
allow the operation if it was disabled by default
Definition: docviewref.h:754
virtual void SetDocumentIOHandlerStrIn(a2dIOHandlerStrIn *handler)
Set Inputhandler used to load the document using this template.
Definition: docviewref.h:2479
const a2dTemplateFlag & GetFlags() const
Returns the flags, as passed to the document template constructor.
Definition: docviewref.h:2717
a2dError m_lastError
error code used when LoadObject is returning.
Definition: docviewref.h:1656
wxString GetDocumentTypeName() const
Returns the document type name, as passed to the document template constructor.
Definition: docviewref.h:2714
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
Definition: gen.h:75
a2dDocument * m_documentParent
parant document if set.
Definition: docviewref.h:1640
a2dViewTemplateList::iterator a2dViewTemplateListIter
iterator for list of ...
Definition: docviewref.h:164
a2dCloseDocumentEvent(const a2dCloseDocumentEvent &event)
constructor
Definition: docviewref.h:569
bool IsModified() const
Has the document been modified.
Definition: docviewref.h:1321
void Init(NoteBook *notebook)
initialize with/to this notebook
Definition: docviewref.h:3272
a2dViewEvent(const a2dViewEvent &event)
constructor
Definition: docviewref.h:492
static const a2dTemplateFlagMask LOAD_IMPORT
Definition: docviewref.h:228
wxString m_documentTypeName
The document type name given to the a2dDocumentTemplate constructor,.
Definition: docviewref.h:1631
a2dCloseViewEvent(int id=0)
Constructor for view event of type ::wxEVT_CLOSE_VIEW.
Definition: docviewref.h:363
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
extend a2dViewConnector to have a a2dDocumentViewScrolledWindow for each view.
Definition: docviewref.h:3141
a2dSmrtPtrList< a2dDocumentTemplate > a2dDocumentTemplateList
list of document templates
Definition: docviewref.h:150
wxClassInfo * m_viewClassInfo
For dynamic creation of appropriate instances.
Definition: docviewref.h:2774
NoteBook * m_notebook
the notebook to hook views into.
Definition: docviewref.h:3237
a2dTemplateEvent(const a2dTemplateEvent &event)
constructor
Definition: docviewref.h:894
virtual wxEvent * Clone() const
clone the event
Definition: docviewref.h:511
The a2dViewTemplate class is used to model the relationship between a document class and a view class...
Definition: docviewref.h:2635
a2dSmrtPtr< a2dView > a2dViewPtr
view smart pointer
Definition: docviewref.h:139
a2dView * GetView()
Gives the a2dView in case of event types concerning a view.
Definition: docviewref.h:774
a2dSmrtPtrList< a2dDocument > a2dDocumentList
list of documents
Definition: docviewref.h:146
wxString GetDocumentTypeName() const
Gets the document type name of this document. See the comment for documentTypeName.
Definition: docviewref.h:1124
void SetDirectory(const wxString &dir)
Sets the default directory.
Definition: docviewref.h:2432
a2dDocumentEvent(wxEventType type, a2dView *view=NULL, bool enable=true, int id=0)
for event types
Definition: docviewref.h:719
void SetFlags(a2dTemplateFlag flags)
Sets the internal document template flags (see the constructor description for more details)...
Definition: docviewref.h:2420
static const a2dTemplateFlagMask SAVE
Definition: docviewref.h:223
wxString GetDirectory() const
Returns the default directory, as passed to the document template constructor.
Definition: docviewref.h:2408
const a2dPrintWhat a2dPRINT_Preview
general print preview
Definition: docviewref.cpp:191
bool m_isClosed
set true when document is closed or when busy closing document.
Definition: docviewref.h:1649
a2dDocumentTemplate * GetDocumentTemplate() const
Gets a2dDocumentTemplate pointer which was used to create the a2dView.
Definition: docviewref.h:1389
Ref Counted base object.
Definition: gen.h:1045
wxNotebook * GetNotebook()
return pointer to notebook type used
Definition: docviewref.h:3223
wxPageSetupDialogData * m_pageSetupData
this is the printer page setup data for all views with this template
Definition: docviewref.h:2781
a2dDocumentFlag
Document manager flags.
Definition: docviewref.h:178
virtual void SetDisplayWindow(wxWindow *display)
Set the display window.
static const a2dTemplateFlagMask DEFAULT
Definition: docviewref.h:227
const a2dError a2dError_NoError
a2dDocumentEvent(const a2dDocumentEvent &event)
constructor
Definition: docviewref.h:735
wxWindow * GetDisplayWindow()
Get the display window.
Definition: docviewref.h:1875
wxString m_directory
The default directory for files of this type.
Definition: docviewref.h:2524
wxOutputStream a2dDocumentOutputStream
output stream based wxStreams
Definition: gen.h:3458
bool IsMarked() const
Returns true if the document template is marked , false otherwise.
Definition: docviewref.h:2450
store a menu Id generated by XRCID( menuIdString ) plus a menustring and helpstring ...
Definition: comevt.h:1563
bool GetEnabled()
return true if the view is enabled. See Enable()
Definition: docviewref.h:1852
void SetError(a2dError error)
in case of errors when sending an event, this can be set to tell the reason of failure ...
Definition: docviewref.h:799
The a2dDocumentTemplate class is used to model the relationship between a document class and files...
Definition: docviewref.h:2297
static const a2dTemplateFlagMask SAVE_EXPORT
Definition: docviewref.h:229
a2dCommandProcessor * GetCommandProcessor() const
Returns a pointer to the command processor associated with this document.
Definition: docviewref.h:1294
void SetDefaultExtension(const wxString &ext)
Sets the default file extension.
Definition: docviewref.h:2438
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
wxString GetDescription() const
Returns the text description of this template, as passed to the document template constructor...
Definition: docviewref.h:2405
void OnPostCreateView(a2dTemplateEvent &event)
what to do after view creation
Definition: docviewref.h:3285
a2dDocumentPtr m_documentCreate
if set this will be used instead of m_docClassInfo to initiate new documents
Definition: docviewref.h:2539
bool GetEnable()
when ::wxEVT_ENABLE_VIEW get enable value of the event
Definition: docviewref.h:524
a2dSmrtPtr< a2dView > m_view
the view that uses this window to display itself
Definition: docviewref.h:3712
A trivial base class for a2dSmrtPtr. Non-template class, so that it can.
Definition: smrtptr.h:55
a2dView * GetView()
Get the view created.
Definition: docviewref.h:916
using a file stream for input, stream the file into a a2dDocument or other object ...
Definition: gen.h:3632
wxSize m_initialSize
size for new view
Definition: docviewref.h:2759
a2dSmrtPtr< a2dIOHandlerStrOut > m_ioHandlerStrOut
used for writing the document to streams.
Definition: docviewref.h:2545
a2dSmrtPtr< a2dViewTemplate > a2dViewTemplatePtr
a2dViewTemplate smart pointer
Definition: docviewref.h:141
bool CheckMask(a2dTemplateFlagMask mask)
does template mask match
Definition: docviewref.h:2423
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
void SetFlags(a2dTemplateFlagMask flags)
Sets the internal document template flags (see the constructor description for more details)...
Definition: docviewref.h:2417
bool m_askSaveWhenOwned
Set when Owners become zero and document will be deleted. May also be overruled by user...
Definition: docviewref.h:1601
This class is used to connect newly created a2dView&#39;s to a wxFrame and/or wxWindow.
Definition: docviewref.h:2857
wxPoint & GetInitialPosition()
Get position used for new created views or frames or windows.
Definition: docviewref.h:2883
specialized wxWindow to handle a2dView events
Definition: docviewref.h:3927
void SetMarked(bool value)
Returns true if the document template is marked , false otherwise.
Definition: docviewref.h:2444
bool m_veto
veto flags.
Definition: docviewref.h:404
a2dSmrtPtr< a2dView > m_keepalive
Definition: docviewref.h:2251
const a2dTemplateFlag & GetFlags() const
Returns the flags, as passed to the document template constructor.
Definition: docviewref.h:2414
void Allow()
allow the operation if it was disabled by default
Definition: docviewref.h:505
a2dSmrtPtr< a2dDocument > m_viewDocument
the document to which this view belongs.
Definition: docviewref.h:2225
Definition: gen.h:276
bool GetActive()
when ::wxEVT_ACTIVATE_VIEW get activation value of the event
Definition: docviewref.h:521
bool m_viewEnabled
Is the view enabled?
Definition: docviewref.h:2241
void AskSaveWhenOwned(bool askSaveWhenOwned)
Ask to save when document is modified and last view is closed?
Definition: docviewref.h:1338
void SetDescription(const wxString &descr)
Sets the template description.
Definition: docviewref.h:2708
a2dSmrtPtrList< a2dViewTemplate > a2dViewTemplateList
list of view templates
Definition: docviewref.h:152
a2dCloseViewEvent(const a2dCloseViewEvent &event)
constructor
Definition: docviewref.h:372
base command processor
Definition: comevt.h:829
a2dWindowConnector< a2dDocumentViewWindow > a2dWindowConnectorFora2dDocumentViewWindow
lua wrap
Definition: docviewref.h:3135
virtual void Update(unsigned int hint=0, wxObject *hintObject=NULL)
force a2dDocumentEvent ::wxEVT_UPDATE_VIEWS event
~wxNotebookConnector()
destructor
Definition: docviewref.h:3267
a2dDocumentEvent(wxEventType type, a2dDocumentTemplate *doctemplate, const wxFileName &filename=wxFileName(wxT("")), a2dDocumentFlagMask flags=a2dREFDOC_NON, int id=0)
for event types
Definition: docviewref.h:668
bool IsClosed()
A closed flag is set when a view is closed.
Definition: docviewref.h:1829
void SetCanVeto(bool canVeto)
If the event can not be vetod this is set to false.
Definition: docviewref.h:393
a2dSmrtPtr< a2dViewConnector > m_connector
class used to connect new views with Frames and windows.
Definition: docviewref.h:2548
Holds a view on a a2dDocument.
Definition: docviewref.h:1804
XML I/O classes which is Pull parser based for reading XML files.
bool IsVisible() const
Returns true if the document template can be shown in user dialogs, false otherwise.
Definition: docviewref.h:2735
wxString m_docTypeName
The named type of the document associated with this template.
Definition: docviewref.h:2533
Template flags.
Definition: docviewref.h:216
event sent to a2dViewConnector
Definition: docviewref.h:870
a2dView * GetView()
get the pointer to a a2dView to which view events are sent
Definition: docviewref.h:3443
a2dViewEvent(wxEventType type, a2dDocumentFlagMask flags, int id)
for event types
Definition: docviewref.h:441
void SetInitialPosition(const wxPoint &position)
set position to use for new created views or frames or windows
Definition: docviewref.h:2874
std list compatible list
Definition: a2dlist.h:42
wxDateTime m_modificationtime
last modification time when this document was stored.
Definition: docviewref.h:1607
a2dDocument * GetDocument()
the document created.
Definition: docviewref.h:903
The document class can be used to model an application&#39;s file-based data.
Definition: docviewref.h:1066
extend a2dViewConnector to have a a2dDocumentViewScrolledWindow for each view.
Definition: docviewref.h:3129
bool IsDocumentSaved() const
Alias for a2dDocument::GetDocumentSaved.
Definition: docviewref.h:1130
a2dDocumentEvent(wxEventType type, const wxFileName &filename, a2dDocumentFlagMask flags=a2dREFDOC_NON, int id=0)
for event types
Definition: docviewref.h:631
static const a2dTemplateFlagMask NON
Definition: docviewref.h:219
wxSize m_initialSize
size for new frames
Definition: docviewref.h:2973
void SetDocumentTemplate(a2dDocumentTemplate *temp)
Set a2dDocumentTemplate pointer.
Definition: docviewref.h:1392
void SetDescription(const wxString &descr)
Sets the template description.
Definition: docviewref.h:2435
wxString m_documentTitle
Document title.
Definition: docviewref.h:1614
virtual wxEvent * Clone() const
clone the event.
Definition: docviewref.h:380
void Veto()
veto the operation (usually it&#39;s allowed by default)
Definition: docviewref.h:751
wxUint16 a2dPrintWhat
defines what to print
Definition: gen.h:4052
Twindow * GetDisplayWindow()
window used by view to display itself.
Definition: docviewref.h:3084
const a2dPrintWhat a2dPRINT_PreviewDocument
preview print a2dDocument
Definition: docviewref.cpp:195
long m_documentModified
modified flag
Definition: docviewref.h:1637
a2dSmrtPtr< a2dDocumentTemplate > a2dDocumentTemplatePtr
a2dDocumentTemplate smart pointer
Definition: docviewref.h:143
bool IsAllowed() const
for implementation code only: is the operation allowed?
Definition: docviewref.h:757
void Veto()
veto the operation (usually it&#39;s allowed by default)
Definition: docviewref.h:502
The a2dDocumentFrame class provides a default frame for displaying documents.
Definition: docviewref.h:3357
bool m_isClosed
close flag, to indicate that the view is being closed are is closed.
Definition: docviewref.h:2222
void SetModificationTime(const wxDateTime &datatime)
Sets a time of last modification.
Definition: docviewref.h:1404
virtual wxEvent * Clone() const
clone the event
Definition: docviewref.h:575
a2dError GetError()
in case of errors when sending an event, this is to know the reason of failure
Definition: docviewref.h:796
#define EVT_POST_CREATE_VIEW(func)
sent from a view template after it created a view
Definition: docviewref.h:1013
virtual void OnDraw(wxDC &dc)
Override this function to draw the graphic (or just process EVT_PAINT)
Definition: docviewref.h:3787
virtual void SetDocumentIOHandlerStrOut(a2dIOHandlerStrOut *handler)
Set output handler used to save the document using this template.
Definition: docviewref.h:2482
a connector which holds one pointer to a wxWindow derived class being the template parameter...
Definition: docviewref.h:3071
wxString GetFileFilter() const
Returns the file filter, as passed to the document template constructor.
Definition: docviewref.h:2411
a2dSplitterConnector()
Constructor.
Definition: docviewref.h:3176
#define EVT_POST_CREATE_DOCUMENT(func)
sent from a doc template after it created a document
Definition: docviewref.h:1011
void Veto(bool veto=true)
use to veto event when the closing of the view needs to be refused in a handler.
Definition: docviewref.h:383
wxUint32 m_id
This identifies the view in event processing.
Definition: docviewref.h:2247
a2dSmrtPtr< a2dViewConnector > m_connector
class used to connect new views with Frames and windows.
Definition: docviewref.h:2777
void SetCommandProcessor(a2dCommandProcessor *proc)
Sets the command processor to be used for this document.
Definition: docviewref.h:1304
static const a2dTemplateFlagMask EXPORTING
Definition: docviewref.h:225
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
bool GetVeto() const
If the event can be vetod this return true.
Definition: docviewref.h:399
a2dDocumentList::iterator a2dDocumentListIter
iterator for list of ...
Definition: docviewref.h:155
a2dDocumentFlagMask GetFlags()
for following event types, get document flags of the event.
Definition: docviewref.h:518
wxClassInfo * m_docClassInfo
Run-time class information that allows document instances to be constructed dynamically.
Definition: docviewref.h:2536
void SetVisible(bool value)
Returns true if the document template can be shown in user dialogs, false otherwise.
Definition: docviewref.h:2729
void SetInitialStyle(long style)
set style to use for new created frames or windows
Definition: docviewref.h:2880
bool IsAllowed() const
for implementation code only, testing result of handler: is the operation allowed?
Definition: docviewref.h:508
void SetOnlyDisconnect(bool OnlyDisconnect)
Definition: docviewref.h:2936
uses a wxFrame to hold new views or to create child wxFrame&#39;s to hold new views.
Definition: docviewref.h:2997
void SetFlags(a2dTemplateFlag flags)
Sets the internal document template flags (see the constructor description for more details)...
Definition: docviewref.h:2723
virtual wxEvent * Clone() const
clone the event
Definition: docviewref.h:913
void SetFileName(const wxFileName &filename)
set filename of file to open, before sending the event.
Definition: docviewref.h:760
bool CheckMask(a2dTemplateFlagMask mask)
does template mask match
Definition: docviewref.h:2726
wxFrame * m_docframe
the frame which receives events and often redirect those to the document manager. ...
Definition: docviewref.h:3051
void SetMarked(bool value)
Returns true if the document template is marked , false otherwise.
Definition: docviewref.h:2732
static const a2dTemplateFlagMask IMPORTING
Definition: docviewref.h:224
a2dViewUpdateFlags
mask flags for a2dDocument::UpdateAllViews()
Definition: docviewref.h:190
wxDateTime & GetModificationTime()
Returns the time of last modification when the document was saved.
Definition: docviewref.h:1410
virtual void SetView(a2dView *view)
to switch the view in this window to another view
Definition: docviewref.h:3759
const a2dPrintWhat a2dPRINT_Print
general print
Definition: docviewref.cpp:190
a2dDocumentTemplate * GetDocumentTemplate()
Get the template choosen to import / export.
Definition: docviewref.h:780
~a2dViewWindow()
Destructor.
Definition: docviewref.h:3749
wxFileName GetFilename() const
Get the file name in use for this document.
Definition: docviewref.h:1103
a2dDocumentTemplateList::iterator a2dDocumentTemplateListIter
iterator for list of ...
Definition: docviewref.h:161
wxString m_description
A short description of this template.
Definition: docviewref.h:2765
wxString GetViewTypeName() const
Returns the view type name, as passed to the document template constructor.
Definition: docviewref.h:2711
a2dViewTemplatePtr m_viewTemplate
view was created from this view template or if not used NULL
Definition: docviewref.h:2231
using a file stream for output, stream a a2dDocument or other wxObject into a stream.
Definition: gen.h:3751
a2dViewConnector * GetViewConnector()
return the a2dViewConnector that is used for sending the ::wxEVT_POST_CREATE_DOCUMENT too...
Definition: docviewref.h:2485
long m_initialStyle
style for new frames
Definition: docviewref.h:2976
a2dDocumentFlagMask GetFlags()
gives the a2dDocumentFlagMask in case of event types concerning a document.
Definition: docviewref.h:768
bool m_savedYet
saved flag
Definition: docviewref.h:1646
bool GetDocumentSaved() const
Returns if the document was saved after a modification.
Definition: docviewref.h:1127
virtual ~a2dFrameViewConnector()
destructor
Definition: docviewref.h:3008
a2dDocumentFlagMask GetFlags()
the document flags as set by a2dDocumentTemplate::CreateDocument()
Definition: docviewref.h:908
void SetDisplayWindow(Twindow *window)
get window used by view to display itself.
Definition: docviewref.h:3087
void OnPostCreateDocument(a2dTemplateEvent &event)
what to do after document creation
Definition: docviewref.h:3278
void SetDocumentCreate(a2dDocument *documentCreate)
if set this will be used instead of m_docClassInfo to initiate new documents
Definition: docviewref.h:2506
a2dViewTemplate * GetViewTemplate() const
get the a2dViewTemplate with which this view was created
Definition: docviewref.h:1914
void SetLastError(a2dError lastError)
can be set by a2dIOHandler&#39;s by e.g LoadObject().
Definition: docviewref.h:1241
bool IsMarked() const
Returns true if the document template is marked , false otherwise.
Definition: docviewref.h:2738
a2dViewList::iterator a2dViewListIter
iterator for list of ...
Definition: docviewref.h:158
void OnCloseView(a2dCloseViewEvent &event)
resets view to NULL when view was closed and skips the event for the parent window/frame.
Definition: docviewref.h:3794
wxInputStream a2dDocumentInputStream
input stream based wxStreams
Definition: gen.h:3456
wxString m_description
A short description of this template.
Definition: docviewref.h:2527
static const a2dTemplateFlagMask MARK
Definition: docviewref.h:221
wxPoint m_initialPos
position for new frames
Definition: docviewref.h:2970
void SetInitialSize(const wxSize &size)
set size to use for new created views
Definition: docviewref.h:2743
a2dDocument * GetDocument() const
get the document of the view
Definition: docviewref.h:1882
general modules header files all together.
virtual a2dIOHandlerStrOut * GetDocumentIOHandlerStrOut()
Get output handler used to save the document using this template.
Definition: docviewref.h:2466
virtual bool ProcessEvent(wxEvent &event)
Extend event processing to search the view&#39;s event table.
Definition: docviewref.h:3811
wxFileName m_documentFile
Filename associated with this document (&quot;&quot; if none).
Definition: docviewref.h:1604
void SetFileFilter(const wxString &filter)
Sets the file filter.
Definition: docviewref.h:2429
long GetInitialStyle()
Get style used for new created a2dDocumentFrame.
Definition: docviewref.h:2889
wxUint32 GetId()
Get the id of the view (used for identification in event processing.
Definition: docviewref.h:1878
wxPageSetupDialogData * m_pageSetupData
this is the printer page setup data for all documents with this template
Definition: docviewref.h:2552
bool m_isParentFrame
is this the docframe or not.
Definition: docviewref.h:3597
a2dTemplateFlag m_flags
The flags passed to the constructor.
Definition: docviewref.h:2762
specialized wxScrolledWindow to handle a2dView events
Definition: docviewref.h:3856
a2dTemplateEvent(a2dDocument *doc, wxEventType type, a2dDocumentFlagMask flags=a2dREFDOC_NON, int id=0)
constructor
Definition: docviewref.h:877
wxFileName & GetFileName()
get filename of file to open
Definition: docviewref.h:763
a2dViewTemplateList m_viewTemplates
templates for views
Definition: docviewref.h:2979
wxString m_docTypeName
The named type of the document associated with this template.
Definition: docviewref.h:2768
print a document
Definition: docviewref.h:3311
void SetViewTypeName(const wxString &name)
set type name of the view.
Definition: docviewref.h:1924
void SetInitialSize(const wxSize &size)
set size to use for new created views or frames or windows
Definition: docviewref.h:2877
bool IsVisible() const
Returns true if the document template can be shown in user dialogs, false otherwise.
Definition: docviewref.h:2447
sent to document before closing
Definition: docviewref.h:558
a2dWindowConnector< a2dDocumentViewScrolledWindow > a2dWindowConnectorFora2dDocumentViewScrolledWindow
lua wrap
Definition: docviewref.h:3123
a2dViewEvent(wxEventType type, bool value, int id)
for event types
Definition: docviewref.h:473
const a2dPrintWhat a2dPRINT_PrintDocument
print a2dDocument
Definition: docviewref.cpp:194
bool IsClosed()
returns true when document is closed or busy closing.
Definition: docviewref.h:1147
bool GetActive()
return if the view is active/
Definition: docviewref.h:2066
a2dCloseDocumentEvent(int id=0)
constructor
Definition: docviewref.h:563
void SetFlags(a2dTemplateFlagMask flags)
Sets the internal document template flags (see the constructor description for more details)...
Definition: docviewref.h:2720
wxString m_defaultExt
The default extension for files of this type.
Definition: docviewref.h:2530
wxUint32 m_id
This identifies the document in event processing.
Definition: docviewref.h:1653
void SetFrame(wxFrame *docframe)
set the frame
Definition: docviewref.h:3038
see a2dDocumentEvent
Definition: docviewref.h:356
void SetDocumentSaved(bool saved=true)
Sets the document saved flag.
Definition: docviewref.h:1136
wxSize & GetInitialSize()
Get size used for new created views.
Definition: docviewref.h:2746
extend a2dWindowConnector to connect views into a wxNotebook window
Definition: docviewref.h:3203
bool m_active
true if this view is activated ( its display window has the focus and recieves mouse events ) ...
Definition: docviewref.h:2234
a2dSmrtPtrList< a2dView > a2dViewList
list of views
Definition: docviewref.h:148
used to report a2dDocument events
Definition: docviewref.h:591
static const a2dTemplateFlagMask LOAD
Definition: docviewref.h:222
void SetTitle(const wxString &title, bool notifyViews=false)
Sets the title for this document.
wxString m_fileFilter
The file filter (such as *.txt) to be used in file selector dialogs.
Definition: docviewref.h:2521
wxSize & GetInitialSize()
GGet size used for new created views or frames or windows.
Definition: docviewref.h:2886
bool GetOnlyDisconnect()
When true, a2dView::OnDisConnectView() only disconnects view from document, and does not close it...
Definition: docviewref.h:2939
void SetVisible(bool value)
Returns true if the document template can be shown in user dialogs, false otherwise.
Definition: docviewref.h:2441
wxString m_viewTypeName
The named type of the view associated with this template.
Definition: docviewref.h:2771
a2dDocument * GetDocumentCreate()
if set this will be used instead of m_docClassInfo to initiate new documents
Definition: docviewref.h:2496
a2dError GetLastError()
is set by a2dIOHandler&#39;s and is tested by LoadObject().
Definition: docviewref.h:1248
wxString GetDocumentTypeName() const
Returns the document type name, as passed to the document template constructor.
Definition: docviewref.h:2426
void SetDocumentTypeName(const wxString &name)
Sets the document type name for this document. See the comment for documentTypeName.
Definition: docviewref.h:1121
void OnPaint(wxPaintEvent &event)
calls OnDraw(dc);
Definition: docviewref.h:3777
const a2dPrintWhat a2dPRINT_PreviewView
preview print a2dView
Definition: docviewref.cpp:193
a2dViewWindow(a2dView *view, wxWindow *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxHSCROLL|wxVSCROLL, const wxString &name=wxT("a2dViewWindow"))
Constructor for creation with view.
Definition: docviewref.h:3720
a2dTemplateFlag m_flags
The flags passed to the constructor.
Definition: docviewref.h:2518
a2dSmrtPtr< a2dIOHandlerStrIn > m_ioHandlerStrIn
used for reading the document from streams.
Definition: docviewref.h:2542
static const a2dTemplateFlagMask VISIBLE
Definition: docviewref.h:220
specialized wxWindow derived template class to handle a2dView events
Definition: docviewref.h:3630
holds one error report.
Definition: gen.h:623
wxString GetDescription() const
Returns the text description of this template, as passed to the document template constructor...
Definition: docviewref.h:2705
const a2dPrintWhat a2dPRINT_PrintView
print a2dView
Definition: docviewref.cpp:192
wxWindow * m_display
In case of using a window for displaying the view, this holds the window.
Definition: docviewref.h:2244
wxString GetDefaultExtension() const
Returns the default file extension for the document data, as passed to the document template construc...
Definition: docviewref.h:2402
extend wxSameFrameViewConnector to connect view into a splitter window
Definition: docviewref.h:3156
a2dView * GetView()
get the current view
Definition: docviewref.h:3683
bool m_destroyOnCloseView
when closing the view the frame will be destroyed.
Definition: docviewref.h:3600
list of a2dObject&#39;s
Definition: gen.h:3157
virtual a2dIOHandlerStrIn * GetDocumentIOHandlerStrIn()
Get Input handler used to store the document using this template.
Definition: docviewref.h:2463
wxString m_viewTypeName
set via the a2dViewTemplate on generation of this view.
Definition: docviewref.h:2228
wxString GetTitle() const
Returns the title for this document.
Definition: docviewref.h:1118
a2dDocumentTemplatePtr m_documentTemplate
A pointer to the template from which this document was created.
Definition: docviewref.h:1634
CloneOptions
options for cloning
Definition: gen.h:1200
a2dSmrtPtr< a2dView > m_view
Definition: docviewref.h:3594
a2dSmrtPtr< a2dDocument > a2dDocumentPtr
document smart pointer
Definition: docviewref.h:95
void SetView(a2dView *view)
Set the view created.
Definition: docviewref.h:919
bool CanVeto() const
If the event can be vetod this is set.
Definition: docviewref.h:396
static const a2dTemplateFlagMask ALL
Definition: docviewref.h:226
bool GetEnable()
when ::wxEVT_ENABLE_VIEWS get enable value of the event
Definition: docviewref.h:793
a2dTemplateEvent(wxEventType type, a2dView *view, a2dDocumentFlagMask flags=a2dREFDOC_NON, int id=0)
constructor
Definition: docviewref.h:886
bool m_OnlyDisconnect
see SetOnlyDisconnect()
Definition: docviewref.h:2982
wxFrame * GetFrame()
get the frame
Definition: docviewref.h:3031
void SetViewTemplate(a2dViewTemplate *viewtemplate)
to set the view template from which this view was created.
Definition: docviewref.h:1917
unsigned int a2dDocumentFlagMask
mask of flags for a2dDocumentFlag
Definition: docviewref.h:200
wxString GetViewTypeName() const
get type name of the view.
Definition: docviewref.h:1908
docviewref.h Source File -- Sun Oct 12 2014 17:04:16 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation