wxArt2D
comevt.h
Go to the documentation of this file.
1 /*! \file wx/general/comevt.h
2  \brief command processor and intializing and event handling classes specific for wxDocview.
3 
4  wxDocview has its own event handling classes which are almost equal to the wxWidgets ones.
5  But had to be duplicated to be able to have a a2dObject at the top the class tree.
6  So things like an a2dCanvasObject can be serialized, even if it can handle events.
7 
8  a2dGeneralGlobal is the class for storing basic stuff like error messages and application wide
9  variables.
10 
11  a2dCommandProcessor is the basic class on which command processing is based.
12 
13  \author Klaas Holwerda
14  \date Created 05/07/03
15 
16  Copyright: 2001-2004 (C) Klaas Holwerda
17 
18  Licence: wxWidgets licence
19 
20  RCS-ID: $Id: comevt.h,v 1.76 2009/08/23 19:49:38 titato Exp $
21 */
22 
23 #ifndef _COMEVTH__
24 #define _COMEVTH__
25 
26 #include "wx/list.h"
27 #include "wx/event.h"
28 #include "wx/cmdproc.h"
29 #include <wx/module.h>
30 
31 #if wxCHECK_VERSION(2,9,0)
32 #include "wx/chartype.h"
33 #include "wx/strvararg.h"
34 #endif
35 
36 #include "wx/general/a2dlist.h"
37 #include "wx/general/gen.h"
38 
39 // ============================================================================
40 // event handler and related classes
41 // ============================================================================
42 
43 //! wxEvtHandler macro
44 #define EVT_BUTTON_ANY(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_BUTTON_CLICKED, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast < wxCommandEventFunction > ( & func ), (wxObject *) NULL ),
45 
46 //! wxEvthandler macro
47 #define EVT_CHOICE_ANY(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_COMMAND_CHOICE_SELECTED, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast < wxCommandEventFunction > ( & func ), (wxObject *) NULL ),
48 
49 //! @} eventhandlers
50 
51 #if defined(WXDOCVIEW_USINGDLL)
52 template class A2DGENERALDLLEXP a2dSmrtPtr<a2dObject>;
53 #endif
54 
55 
56 
57 class A2DGENERALDLLEXP a2dCommandProcessor;
58 #if (defined(__WXMSW__) && defined(WXUSINGDLL) )
59 template class A2DGENERALDLLEXP a2dSmrtPtr<a2dCommandProcessor>;
60 #endif
61 
62 class A2DGENERALDLLEXP a2dCommandId;
63 
64 class A2DGENERALDLLEXP a2dHashMapCommandIds;
65 class A2DGENERALDLLEXP a2dHashMapCommandIds_wxImplementation_HashTable;
66 class A2DGENERALDLLEXP a2dHashMapCommandIds_wxImplementation_KeyEx;
67 
68 //! This hash table is used for a2dCommandId with name
69 WX_DECLARE_HASH_MAP_WITH_DECL( wxString, a2dCommandId*, wxStringHash, wxStringEqual, a2dHashMapCommandIds, class A2DGENERALDLLEXP );
70 //#if (defined(__WXMSW__) && defined(WXUSINGDLL) )
71 //template class A2DGENERALDLLEXP a2dHashMap<wxString,a2dCommandId*>::wxhash;
72 //template class A2DGENERALDLLEXP a2dHashMap<wxString,a2dCommandId*>;
73 //#endif
74 
75 //! Each a2dCommand is given a command id at construction.
76 /*!
77  The command id used to test for a specific commandId when intercepting command events.
78 
79 <code>
80  EVT_REDO( a2dObjectDerivedClass::OnComEvent )
81 
82  void a2dObjectDerivedClass::OnComEvent( a2dComEvent& event )
83  {
84  // now you can test what the command was.
85  event.GetCommand()->GetCommandId()
86  }
87 
88  EVT_REDO( wxEvtHandlerDerivedClass::OnComEvent )
89 
90  void wxEvtHandlerDerivedClass::OnComEvent( a2dComEvent& event )
91  {
92  // now you can test what the command was.
93  event.GetCommand()->GetCommandId()
94  }
95 </code>
96 
97  \ingroup commands commandid
98 */
99 class A2DGENERALDLLEXP a2dCommandId
100 {
101 public:
102 
103  //! constructor
104  a2dCommandId( const wxString& commandName );
105 
106  //! destructor
107  virtual ~a2dCommandId() {};
108 
109  //! get name of class
110  virtual wxString GetIdClassName() { return wxT( "a2dCommandId" ); }
111 
112  //! get name
113  wxString GetName() const { return m_name; }
114 
115  //! search Id given the name of the command
116  static const a2dCommandId& GetCommandByName( const wxString& commandName );
117 
118  //! return hash of commands
119  static a2dHashMapCommandIds& GetHashMap();
120 
121 private:
122 
123  //! name of command
124  wxString m_name;
125 };
126 
127 //! a base command for the a2dCommandProcessor
128 /*!
129  When a2dCommandProcessor gets this command submitted, it will set itself
130  to the command. The command will be added to the undo stack, and if it can be undone, the information
131  to make this happen is part of the this command stored on the undo stack.
132  So normally for each command one derives from a2dCommand, in order to have the derived command
133  class store the right information for undoing an action, and define how to Do() and Undo() this action.
134 
135  To makes things a bit more flexible, this class is derived from a2dObject, therefore it can have a2dProperty's.
136  This can be used to add extra information on a command.
137 
138  \ingroup commands
139 */
140 class A2DGENERALDLLEXP a2dCommand: public a2dObject
141 {
142 
143 public:
144 
145  //! property for command id
147  //! property for type of command id
149  //! property for group command id
151 
152  //! constructor
153  /*!
154  \param canUndo can this command be undone
155  \param commandId Id of the command
156  \param commandTypeId Type Id of the command belong to a group of commands
157  \param menuString command is associated with a menu string
158  */
159  a2dCommand( bool canUndo = false,
160  const a2dCommandId& commandId = sm_noCommandId,
161  const a2dCommandId& commandTypeId = sm_noCommandTypeId,
162  const wxString& menuString = wxEmptyString
163  );
164 
165  //! destructor
166  ~a2dCommand( void );
167 
168  inline a2dCommand* TClone( CloneOptions options = clone_deep, a2dRefMap* refs = NULL ) { return ( a2dCommand* ) Clone( options, refs ); }
169 
170  //! return command name
171  //! if m_menuName is set this will be used for menu Undo/Redo labels, else the m_commandId its name is used.
172  virtual wxString GetName() const;
173 
174  //! a specific id for this command.
175  /*!
176  A command can have an id set to it, to easily identify it.
177  This can be done by m_commandName comparison, but id's are saver.
178  */
179  const a2dCommandId* GetCommandId() { return m_commandId; }
180 
181  //! used to identify groups of simular commands
182  const a2dCommandId* GetCommandTypeId() { return m_commandTypeId; }
183 
184  //! Copy and instantiate the command
185  /*! This is usefull for commands that are used as command templates in widgets.
186  The widget owns a command template, that is not bound to an object. This
187  function clones the command object and binds it to the given object.
188 
189  \\param object for which the command is to be generated.
190  */
191  virtual a2dCommand* CloneAndBind( a2dObject* object );
192 
193  //! Override this to perform a command
194  virtual bool Do() = 0;
195 
196  //! Override this to undo a command
197  virtual bool Undo() = 0;
198 
199  //! Override this to perform a dependency action before command is done.
200  virtual bool PreDo() { return true; }
201 
202  //! Override this to perform a dependency action after command is done.
203  virtual bool PostDo() { return true; }
204 
205  virtual bool CanUndo() const { return m_canUndo; }
206 
207  //! Override this to redo a command
208  //! Default is the same as do
209  virtual bool Redo();
210 
211  //! If this command changes the object such that it needs to flagged as modified (e.g. document )
212  //! Some command like selecting objects on the canvas, do not need to be saved to the document.
213  //! and in such a situation the command action can be undone, but the document is not flagged modified.
214  bool Modifies() { return m_modifies; }
215 
216  //! set when submitting this command via a2dCommandProcessor
217  void SetCommandProcessor( a2dCommandProcessor* cmp ) { m_cmp = cmp; }
218 
219  a2dCommandProcessor* GetCommandProcessor() { return m_cmp; }
220 
221  //! Hierarchically clear all commands after current command
222  /*!
223  When storing commands, normally when no undo or redo is done yet, the command will be stored
224  at the end of the undo stack. But if several Undo have bin done, the currentcommand is not pointing
225  to the end of the stack. When at that moment a new command is submitted, this will be added after
226  the current command, BUT first all commands after the current command will be cleared.
227  As a result on can Redo all Undo's sofar as long as no new command is submitted yet.
228  */
229  virtual bool ClearAfterCurrentCommand( a2dCommand* current );
230 
231  //! This is like a wxDynamicCast, but much faster
232  virtual class a2dCommandGroup* IsCommandGroup() { return 0; }
233 
234  //! Find the previous command of the given command
235  virtual a2dCommand* FindPrevious( a2dCommand* current ) const;
236 
237  //! Find the next command of the given command
238  virtual a2dCommand* FindNext( a2dCommand* current ) const;
239 
240  //! Remove the given command
241  virtual bool Remove( a2dCommand* command );
242 
243  //! return true if this command/group are nested group contains the given command
244  virtual bool ContainsCommand( a2dCommand* command );
245 
246  virtual void DistributeEvent( wxEventType eventType );
247 
248 protected:
249 
250 
251  //!Clone this object and return a pointer to the new object
252  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
253 
254 #if wxART2D_USE_CVGIO
255  void DoSave( wxObject* WXUNUSED( parent ), a2dIOHandlerXmlSerOut& WXUNUSED( out ), a2dXmlSer_flag WXUNUSED( xmlparts ), a2dObjectList* WXUNUSED( towrite ) )
256  {
257  wxLogMessage( _( "Not implemented" ) );
258  }
259 
260  void DoLoad( wxObject* WXUNUSED( parent ), a2dIOHandlerXmlSerIn& WXUNUSED( parser ), a2dXmlSer_flag WXUNUSED( xmlparts ) )
261  {
262  wxLogMessage( _( "Not implemented" ) );
263  }
264 
265 #endif //wxART2D_USE_CVGIO
266 
267  //! can this command be undone
268  bool m_canUndo;
269 
270  bool m_modifies;
271 
272  //! can be used to identify the command
274 
275  //! if set can be used to identify groups of commands
277 
278  //! allows commands to get to the command processor that submitted the command.
280 
281  //! if set this will be used for menu Undo/Redo labels, else the m_commandId its name is used.
282  wxString m_menuString;
283 
284  //!this is a not implemented copy constructor that avoids automatic creation of one
285  a2dCommand( const a2dCommand& other );
286 };
287 
289 
290 //! For exceptions thrown from commands
291 /*!
292  \ingroup commands commandid
293 */
295 {
296 
297 public:
298  //! Constructor.
299  a2dCommandException( const wxString& exMessage ): m_message( exMessage ) {}
300 
301  //! Copy constructor.
303  { m_message = other.m_message; }
304 
305  a2dCommandException& operator=( const a2dCommandException& other )
306  {
307  if ( &other != this )
308  {
309  m_message = other.m_message;
310  }
311 
312  return *this;
313  }
314 
315  virtual ~a2dCommandException() {}
316 
317  wxString getMessage() const { return m_message; }
318  void setMessage( const wxString& exMessage ) { m_message = exMessage; }
319 
320 protected:
321 
322  wxString m_message;
323 };
324 
325 //! a list of commands used by the command processor or command groups
326 
327 #if (defined(__WXMSW__) && defined(WXUSINGDLL) )
328 template class A2DGENERALDLLEXP a2dSmrtPtr<a2dCommand>;
329 template class A2DGENERALDLLEXP std::allocator<class a2dSmrtPtr<class a2dCommand> >;
330 template class A2DGENERALDLLEXP std::allocator< std::_List_nod<class a2dSmrtPtr<class a2dCommand>, std::allocator<class a2dSmrtPtr<class a2dCommand> > >::_Node >;
331 template class A2DGENERALDLLEXP std::allocator< std::_List_ptr<class a2dSmrtPtr<class a2dCommand>, std::allocator<class a2dSmrtPtr<class a2dCommand> > >::_Nodeptr >;
332 template class A2DGENERALDLLEXP std::list<class a2dSmrtPtr<class a2dCommand> >;
333 template class A2DGENERALDLLEXP a2dlist<class a2dSmrtPtr<class a2dCommand> >;
334 template class A2DGENERALDLLEXP a2dSmrtPtrList<class a2dCommand >;
335 #endif
336 
337 typedef class A2DGENERALDLLEXP a2dSmrtPtrList< a2dCommand > a2dCommandList;
338 
339 //! a group of commands, used to group commands together for undo/redo
340 /*!
341  A group can be recorded distributed across the application, you start a command group, and you end it.
342  See CommandGroupBegin() CommandGroupEnd().
343  All command submitted in between become part of the group. This is very handy when commands lead to
344  other commands indirectly. Like when moving objects connected with wires: moving an object will create
345  a move command, but the wires will be re-routed, generating extra move commands for all moved wires.
346  Combining those in a group, will Undo this as a whole, which is what a user does expect.
347  Same for a polygon which is drawn vertex by vertex, while bussy doing this, an Undo action should remove
348  the last added vertex. But when finishing a polygon, and drawing several more, the Undo should remove the
349  polygon as a whole in one Undo action. This behaviour is all handled within a2dCommandProcessor(), it
350  knows which group is currently active, and commands in nested groups are undone/redone at once, while single commands in the active
351  group are undone one by one. Undo-ing/redo-ing a group, means it will undo/redo all seperate nested commands, but to the users it is
352  as if it is one action.
353 
354  Another application of groups is simple to assemble a group of commands, which can be submitted as a new command.
355  A group gets a unique a2dCommandId at construction.
356  The group of commands is submitted in one row in Do().
357 
358  \ingroup commands
359 */
360 class A2DGENERALDLLEXP a2dCommandGroup: public a2dCommand
361 {
362 public:
363 
364  //! constructor
365  /*!
366  \param name name of this command
367  \param parent of this group
368  */
369  a2dCommandGroup( const wxString& name, a2dCommandGroup* parent = NULL );
370 
372  a2dCommandGroup* parent,
373  const a2dCommandId& commandId = sm_noCommandId,
374  const a2dCommandId& commandTypeId = sm_noCommandTypeId,
375  const wxString& menuString = wxEmptyString
376  );
377 
378  //! destructor
379  ~a2dCommandGroup( void );
380 
381  inline a2dCommand* TClone( CloneOptions options = clone_deep, a2dRefMap* refs = NULL ) { return ( a2dCommand* ) Clone( options, refs ); }
382 
383  //! return command name
384  virtual wxString GetGroupName() const { return m_groupName; }
385 
386  //! erase commands with a certain id, starting at fromcommand
387  bool ClearCommandsById( const a2dCommandId& commandId, a2dCommand* fromcommand = NULL );
388 
389  //! Hierarchically clear all commands after current
390  virtual bool ClearAfterCurrentCommand( a2dCommand* current );
391 
392  //! This is like a wxDynamicCast, but much faster
393  virtual class a2dCommandGroup* IsCommandGroup() { return this; }
394 
395  //! Find the previous command of the given command
396  virtual a2dCommand* FindPrevious( a2dCommand* current ) const;
397 
398  //! Find the next command of the given command
399  virtual a2dCommand* FindNext( a2dCommand* current ) const;
400 
401  //! Remove the given command in this group or a subgroup
402  virtual bool Remove( a2dCommand* command );
403 
404  //! add a command to the group
405  void Add( a2dCommand* command );
406 
407  //! return true if this command/group are nested group contains the given command
408  virtual bool ContainsCommand( a2dCommand* command );
409 
410  //! return the parent group of this group
411  a2dCommandGroup* GetParentGroup() { return m_parentGroup; }
412 
413  //! set the parent group of this group
414  void SetParentGroup( a2dCommandGroup* parent ) { m_parentGroup = parent; }
415 
416 public:
417  // Base class overloads
418  virtual bool Do();
419  virtual bool Undo();
420  virtual bool Redo();
421 
422 protected:
423 
424  //!Clone this object and return a pointer to the new object
425  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
426 
427  //! this is the parent group of this group
429 
430  //! name of group of commands
431  wxString m_groupName;
432 
433  bool m_ownId;
434 
435  //! If true, this command group is not yet closed and may still receive commands
436  bool m_active;
437  //! the list of subcommands
438  a2dCommandList m_subcommands;
439  //! a2DocumentCommandProcessor may access the list directly
440  friend class a2dCommandProcessor;
441 };
442 
443 #if (defined(__WXMSW__) && defined(WXUSINGDLL) )
444 template class A2DGENERALDLLEXP a2dAutoZeroPtr< a2dObject >;
445 #endif
446 
447 //! used to change a property on objects
448 /*!
449  A a2dObject property is set on the a2dObject, and the first property
450  on the a2dObject with the same name is used for undo.
451  Properties with the starting with __M_ are wrapped properties, and or often used to set member variables
452  of classes.
453  Special name properties starting with just __ are used to set predefined properties.
454  Both these type of properties can be set by this command.
455  If the property was not yet set for the object, in Undo the new property is just removed, else
456  the old value is restored.
457 
458  \ingroup commands
459 */
460 class A2DGENERALDLLEXP a2dCommand_SetProperty: public a2dCommand
461 {
462  DECLARE_DYNAMIC_CLASS( a2dCommand_SetProperty )
463 
464 public:
465 
466  //!
467  /*! \ingroup commandid
468  */
469  static const a2dCommandId Id;
470 
471  //! for dynamic creation
473 
474  //! Set property on object
475  /*!
476  The property its name is used for undo, and restore the old value if available.
477 
478  \param object the canvas object to set the property on.
479  \param property the property to set
480  */
481  a2dCommand_SetProperty( a2dObject* object, a2dNamedProperty* property );
482 
483  //! Set property on object
484  /*!
485  The property its name is used for undo, and restore the old value if available.
486 
487  \param object the canvas object to set the property on.
488  \param id the a2dPropertyId of the property to set.
489  \param value the value to set the property to.
490  */
492 
493  //! Set property on object
494  /*!
495  The property its name is used for undo, and restore the old value if available.
496 
497  \param object the canvas object to set the property on.
498  \param id the a2dPropertyId of the property to set.
499  \param value the value to set the property to.
500  */
501  a2dCommand_SetProperty( a2dObject* object, const a2dPropertyIdObject* id, const wxObject& value );
502 
503  //! Set property on object
504  /*!
505  The property its name is used for undo, and restore the old value if available.
506 
507  \param object the canvas object to set the property on.
508  \param id the a2dPropertyId of the property to set.
509  \param value the value to set the property to.
510  */
511  a2dCommand_SetProperty( a2dObject* object, const a2dPropertyIdString* id, const wxString& value );
512 
513  //! Set property on object
514  /*!
515  The property its name is used for undo, and restore the old value if available.
516 
517  \param object the canvas object to set the property on.
518  \param id the a2dPropertyId of the property to set.
519  \param value the value to set the property to.
520  */
521  a2dCommand_SetProperty( a2dObject* object, const a2dPropertyIdBool* id, bool value );
522 
523  a2dCommand_SetProperty( a2dObject* object, const a2dPropertyIdBool* id, const wxString& value );
524 
525  //! Set property on object
526  /*!
527  The property its name is used for undo, and restore the old value if available.
528 
529  \param object the canvas object to set the property on.
530  \param id the a2dPropertyId of the property to set.
531  \param value the value to set the property to.
532  */
533  a2dCommand_SetProperty( a2dObject* object, const a2dPropertyIdInt16* id, wxInt16 value );
534 
535  //! Set property on object
536  /*!
537  The property its name is used for undo, and restore the old value if available.
538 
539  \param object the canvas object to set the property on.
540  \param id the a2dPropertyId of the property to set.
541  \param value the value to set the property to.
542  */
543  a2dCommand_SetProperty( a2dObject* object, const a2dPropertyIdUint16* id, wxUint16 value );
544 
545  //! Set property on object
546  /*!
547  The property its name is used for undo, and restore the old value if available.
548 
549  \param object the canvas object to set the property on.
550  \param id the a2dPropertyId of the property to set.
551  \param value the value to set the property to.
552  */
553  a2dCommand_SetProperty( a2dObject* object, const a2dPropertyIdInt32* id, wxInt32 value );
554 
555  //! Set property on object
556  /*!
557  The property its name is used for undo, and restore the old value if available.
558 
559  \param object the canvas object to set the property on.
560  \param id the a2dPropertyId of the property to set.
561  \param value the value to set the property to.
562  */
563  a2dCommand_SetProperty( a2dObject* object, const a2dPropertyIdUint32* id, wxUint32 value );
564 
565  //! Set property on object
566  /*!
567  The property its name is used for undo, and restore the old value if available.
568 
569  \param object the canvas object to set the property on.
570  \param id the a2dPropertyId of the property to set.
571  \param value the value to set the property to.
572  */
573  a2dCommand_SetProperty( a2dObject* object, const a2dPropertyIdDouble* id, double value );
574 
575  //! Set property on object
576  /*!
577  The property its name is used for undo, and restore the old value if available.
578 
579  \param object the canvas object to set the property on.
580  \param id the a2dPropertyId of the property to set.
581  \param colour the value to set the property to.
582  */
583  a2dCommand_SetProperty( a2dObject* object, const a2dPropertyIdColour* id, const wxColour& colour );
584 
585  ~a2dCommand_SetProperty( void );
586 
587  //! copy constructor
589 
590 
591  //! property that is set packed as a2dNamedProperty.
592  a2dNamedProperty* GetProperty() { return m_property; }
593 
594  //! property that is set packed as a2dNamedProperty.
595  const a2dPropertyId* GetPropertyId() { return m_id; }
596 
597  a2dObject* GetObject() { return m_propRefObject.Get(); }
598 
599  bool Do();
600  bool Undo();
601 
602 protected:
603  //! this is for derived classes and derived properties
604  a2dCommand_SetProperty( a2dObject* object, const a2dPropertyId* id );
605 
606  //! all property references will be set NULL when this object, having the property, will be deleted.
607  a2dAutoZeroPtr< a2dObject > m_propRefObject;
608 
609  //! property set to the object.
611 
612  //! id of the property that is set.
614 };
615 
616 
617 /**********************************************
618  New events Document and View events.
619 **********************************************/
620 BEGIN_DECLARE_EVENT_TYPES()
621 //! see a2dCommandProcessorEvent \ingroup eventid
622 DECLARE_EXPORTED_EVENT_TYPE( A2DGENERALDLLEXP, wxEVT_BEGINBUSY, 1 )
623 //! see a2dCommandProcessorEvent \ingroup eventid
624 DECLARE_EXPORTED_EVENT_TYPE( A2DGENERALDLLEXP, wxEVT_ENDBUSY, 1 )
625 //! see a2dCommandProcessorEvent \ingroup eventid
626 DECLARE_EXPORTED_EVENT_TYPE( A2DGENERALDLLEXP, wxEVT_DO, 1 )
627 //! see a2dCommandProcessorEvent \ingroup eventid
628 DECLARE_EXPORTED_EVENT_TYPE( A2DGENERALDLLEXP, wxEVT_UNDO, 1 )
629 //! see a2dCommandProcessorEvent \ingroup eventid
630 DECLARE_EXPORTED_EVENT_TYPE( A2DGENERALDLLEXP, wxEVT_REDO, 1 )
631 //! see a2dCommandProcessorEvent \ingroup eventid
632 DECLARE_EXPORTED_EVENT_TYPE( A2DGENERALDLLEXP, wxEVT_MENUSTRINGS, 1 )
633 //! see a2dPropertyEditEvent \ingroup eventid
634 DECLARE_EXPORTED_EVENT_TYPE( A2DGENERALDLLEXP, a2dEVT_PROPOBJECT_EDITPROPERTIES_EVENT, 1 )
635 DECLARE_EXPORTED_EVENT_TYPE( A2DGENERALDLLEXP, wxEVT_RECORD, 1 )
636 END_DECLARE_EVENT_TYPES()
637 
638 
639 //! sent from a2dObject::EditProperties().
640 /*!
641  This event is sent, you intercept it and do the editing of the supplied properties there.
642 
643  Currently the following Id's:
644 
645  - ::a2dEVT_PROPOBJECT_EDITPROPERTIES_EVENT sent when a2dObject::EditProperties() requires editing of properties.
646 
647  \ingroup events
648 */
649 class A2DGENERALDLLEXP a2dPropertyEditEvent: public a2dEvent
650 {
651 public:
652 
653  //! constructor
654  a2dPropertyEditEvent( a2dObject* object, a2dNamedPropertyList* properties = NULL );
655 
656  //! constructor
658 
659  //! clone the event
660  virtual wxEvent* Clone() const { return new a2dPropertyEditEvent( *this ); }
661 
662  a2dNamedPropertyList* GetPropertyList() { return m_properties; }
663 
664  //! when properties where edited, this must become true
665  bool GetEdited() { return m_edited; }
666 
667  //! set to signal that properties where edited.
668  void SetEdited( bool edited ) { m_edited = edited; }
669 
670 private:
671 
672  a2dNamedPropertyList* m_properties;
673 
674  bool m_edited;
675 };
676 
677 //! event function for a2dPropertyEditEvent
678 typedef void ( wxEvtHandler::*a2dPropertyEditEventFunctionEvt )( a2dPropertyEditEvent& );
679 
680 /*! \addtogroup eventhandlers
681 * @{
682 */
683 
684 //! static event table macro for NON a2dCanvasObject when editing properties for wxEvtHandler
685 #define EVT_PROPOBJECT_EDITPROPERTIES_EVENT(func) DECLARE_EVENT_TABLE_ENTRY( a2dEVT_PROPOBJECT_EDITPROPERTIES_EVENT, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast < a2dPropertyEditEventFunctionEvt > ( & func ), (wxObject *) NULL ),
686 
687 //! @} eventhandlers
688 
689 //! Event sent to a2dCommandProcessor
690 /*!
691  - ::wxEVT_DO is sent from a2CommandProcessor or any other commandprocessor when a command is issued.
692  - ::wxEVT_UNDO is sent from a2CommandProcessor or any other commandprocessor when a command is issued.
693 
694  - ::wxEVT_MENUSTRINGS is sent from a2dCommandProcessor when menu string need to be updated after a command.
695 
696  Use a2dObject::ConnectEvent to connect your own wxEvtHandler to the a2CommandProcessor
697  to receive them.
698 
699  \ingroup commands events
700 */
701 class A2DGENERALDLLEXP a2dCommandProcessorEvent : public a2dEvent
702 {
703 
704 public:
705 
706  //! constructor
707  /*!
708  type should ::wxEVT_DO ::wxEVT_UNDO
709 
710  */
711  a2dCommandProcessorEvent( wxEventType type, a2dCommand* cmd )
712  : a2dEvent( 0, type )
713  {
714  m_cmd = cmd;
715  m_undoLabel = wxT( "" );
716  m_redoLabel = wxT( "" );
717  m_canUndo = false;
718  m_canRedo = false;
719  }
720 
721  //! constructor
722  /*!
723  type ::wxEVT_MENUSTRINGS
724 
725  For ::wxEVT_MENUSTRINGS, you can use the following function, to get the info to set the menu string.
726  -wxCommandProcessor::GetUndoMenuLabel()
727  -wxCommandProcessor::GetRedoMenuLabel()
728  -wxCommandProcessor::CanUndo()
729  -wxCommandProcessor::CanRedo()
730  */
732  const wxString& undoLabel, bool canUndo,
733  const wxString& redoLabel, bool canRedo
734  )
735  : a2dEvent( 0, wxEVT_MENUSTRINGS )
736  {
737  m_cmd = cmd;
738  m_undoLabel = undoLabel;
739  m_redoLabel = redoLabel;
740  m_canUndo = canUndo;
741  m_canRedo = canRedo;
742  }
743 
744  //! constructor
746  : a2dEvent( event )
747  {
748  m_cmd = event.m_cmd;
749  m_undoLabel = event.m_undoLabel;
750  m_redoLabel = event.m_redoLabel;
751  m_canUndo = event.m_canUndo;
752  m_canRedo = event.m_canRedo;
753  }
754 
755  //! clone the event.
756  virtual wxEvent* Clone() const { return new a2dCommandProcessorEvent( *this ); }
757 
758  //! the command ( if there was one ) that did it.
759  a2dCommand* GetCommand() { return m_cmd; }
760 
761  //! by default this is a2dCommandProcessor::GetUndoMenuLabel()
762  wxString& GetUndoMenuLabel() { return m_undoLabel; }
763  //! by default this is a2dCommandProcessor::GetRedoMenuLabel()
764  wxString& GetRedoMenuLabel() { return m_redoLabel; }
765  //! by default this is a2dCommandProcessor::CanUndo()
766  bool CanUndo() { return m_canUndo; }
767  //! by default this is a2dCommandProcessor::CanRedo()
768  bool CanRedo() { return m_canRedo; }
769 
770 protected:
771 
772  //! see GetCommand()
774 
775  //! used for wxEVT_MENUSTRINGS event
776  wxString m_undoLabel;
777 
778  //! used for wxEVT_MENUSTRINGS event
779  bool m_canUndo;
780 
781  //! used for wxEVT_MENUSTRINGS event
782  wxString m_redoLabel;
783 
784  //! used for wxEVT_MENUSTRINGS event
785  bool m_canRedo;
786 };
787 
788 /*! \addtogroup eventhandlers
789 * @{
790 */
791 
792 typedef void ( wxEvtHandler::*wxCommandProcessorEventFunction )( a2dCommandProcessorEvent& );
793 
794 //! event sent from a2DocumentCommandProcessor when a command is initially done
795 #define EVT_DO(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_DO, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxCommandProcessorEventFunction > (& func), (wxObject *) NULL ),
796 //! event sent from a2DocumentCommandProcessor when a command is undone
797 #define EVT_UNDO(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_UNDO, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxCommandProcessorEventFunction > (& func), (wxObject *) NULL ),
798 //! event sent from a2DocumentCommandProcessor when a command is redone
799 #define EVT_REDO(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_REDO, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxCommandProcessorEventFunction > (& func), (wxObject *) NULL ),
800 //! event sent to a2dCommandProcessorEvents to adjust menu strings (e.g. for current undo/redo command)
801 #define EVT_MENUSTRINGS(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MENUSTRINGS, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxCommandProcessorEventFunction > (& func), (wxObject *) NULL ),
802 //! event sent to a2dCommandProcessorEvents to set modified flag of a document or drawing flag.
803 #define EVT_MODIFIES(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_MODIFIES, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxCommandProcessorEventFunction > (& func), (wxObject *) NULL ),
804 
805 //! event sent from a2DocumentCommandProcessor when a command submit/execute is starting
806 #define EVT_BEGINBUSY(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_BEGINBUSY, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxCommandProcessorEventFunction > (& func), (wxObject *) NULL ),
807 //! event sent from a2DocumentCommandProcessor when a command submit/execute is ending
808 #define EVT_ENDBUSY(func) DECLARE_EVENT_TABLE_ENTRY( wxEVT_ENDBUSY, wxID_ANY, wxID_ANY, (wxObjectEventFunction) static_cast< wxCommandProcessorEventFunction > (& func), (wxObject *) NULL ),
809 
810 //! @} eventhandlers
811 
812 // ----------------------------------------------------------------------------
813 // a2dCommandProcessor
814 // ----------------------------------------------------------------------------
815 
816 //! base command processor
817 /*!
818  a2dCommand commands submitted to this class, are stored on a stack.
819  Because commands can be nested, the command processor actually has not a stack, but a tree of nested
820  commands. The tree is implemented by nesting a2dDocviewCommand's.
821 
822  One can have a command stack for the whole application, and sub command stacks for documents.
823  So undo can be called seperate for all documents, or even parts of documents.
824 
825  See a2dCommand for how to organize undo information.
826 
827  \ingroup commands events
828 */
829 class A2DGENERALDLLEXP a2dCommandProcessor : public a2dObject
830 {
831 public:
832 
833  //!Constructor.
834  /*!
835  \param maxCommands maximum of commands on the command stack, default -1 is unlimited.
836  */
837  a2dCommandProcessor( int maxCommands = -1 );
838 
839  //! destructor
840  virtual ~a2dCommandProcessor();
841 
842  //! next to the base class submit, it sets a2DocumentCommandProcessor for a2dCommand
843  /*
844  Pass a command to the processor. The processor calls Do(); if
845  successful, is appended to the command history unless storeIt is false.
846 
847  Internal sents a a2dDocumentCommandEvent with id ::wxEVT_DO
848  */
849  virtual bool Submit( a2dCommand* command, bool storeIt = true );
850 
851  //! just store the command without executing it
852  virtual void Store( a2dCommand* command );
853 
854  //! Undo one command or command group
855  virtual bool Undo();
856  //! Redo one command or command group
857  virtual bool Redo();
858  //! Are there commands to undo and can they be undone ?
859  virtual bool CanUndo() const;
860  //! Are there commands to redo and can they be redone ?
861  virtual bool CanRedo() const;
862 
863  //! Initialises the current command and menu strings.
864  virtual void Initialize();
865 
866  //! does sent an event to update menu strings after a command
867  /*
868  Use a2dObject::ConnectEvent to connect your own wxEvtHandler to the a2CommandProcessor
869  to receive them.
870 
871  Sets the Undo/Redo menu strings somewhere the application intercepts this event.
872  Sents ::wxEVT_MENUSTRINGS the application should react by setting menu strings.
873 
874  In event tables use like:
875  <code>
876  BEGIN_EVENT_TABLE( classX, baseclassX )
877  EVT_MENUSTRINGS( classX::OnSetMenuStrings )
878  END_EVENT_TABLE()
879  </code>
880 
881  Assuming you have in classX this:
882 
883  <code>
884  m_edit_menu = new wxMenu;
885  m_edit_menu->Append(wxID_UNDO, _("&Undo"));
886  m_edit_menu->Append(wxID_REDO, _("&Redo"));
887  </code>
888 
889  In OnSetMenuStrings do this:
890 
891  <code>
892  void classX::OnSetMenuStrings( a2dCommandProcessorEvent& event )
893  {
894  if ( event.GetEventObject() == m_view->GetDocument()->GetCommandProcessor() )
895  {
896  m_edit_menu->SetLabel(wxID_UNDO, event.GetUndoMenuLabel());
897  m_edit_menu->Enable(wxID_UNDO, event.CanUndo());
898 
899  m_edit_menu->SetLabel(wxID_REDO, event.GetRedoMenuLabel());
900  m_edit_menu->Enable(wxID_REDO, event.CanRedo());
901  }
902  }
903  </code>
904 
905  \remark overide this function in derived class, if you need other labels etc.
906  */
907  virtual void SetMenuStrings();
908 
909  //! Gets the current Undo menu label.
910  wxString GetUndoMenuLabel() const;
911 
912  //! Gets the current Undo menu label.
913  wxString GetRedoMenuLabel() const;
914 
915  //! command list access
917  {
918  return m_currentCommand;
919  }
920 
921  //! get the limit on number of commands to store
922  int GetMaxCommands() const { return m_maxNoCommands; }
923 
924  //! return top/startgroup
925  a2dCommandGroup* GetRootGroup() const { return m_rootGroup; }
926 
927  //! return current group
928  a2dCommandGroup* GetCurrentGroup() const { return m_currentGroup; }
929 
930  //! set current group
931  /*!
932  When a derived a2dCommandGroup, is Submitted, its Do(0 member will normally gather the sub commands for the group.
933  In this case, the group itself is already Submitted, and will be stored, only make sure using this function
934  that the subcommands that are submitted, end up in this group.
935  */
936  void SetCurrentGroup( a2dCommandGroup* group );
937 
938  //! remove all commands stored
939  virtual void ClearCommands();
940 
941  //! By default, the accelerators are "\tCtrl+Z" and "\tCtrl+Y"
942  const wxString& GetUndoAccelerator() const { return m_undoAccelerator; }
943  //! By default, the accelerators are "\tCtrl+Z" and "\tCtrl+Y"
944  const wxString& GetRedoAccelerator() const { return m_redoAccelerator; }
945 
946  //! By default, the accelerators are "\tCtrl+Z" and "\tCtrl+Y"
947  void SetUndoAccelerator( const wxString& accel ) { m_undoAccelerator = accel; }
948  //! By default, the accelerators are "\tCtrl+Z" and "\tCtrl+Y"
949  void SetRedoAccelerator( const wxString& accel ) { m_redoAccelerator = accel; }
950 
951  //! set a named property to the given object
952  /*! \remark This function should only be used if the id comes as string from the user or a file.
953  The id must be in the id list and the type is derived from the found id.
954  \param propRefObject object to set the property to.
955  \param name the name of the property to add.
956  \param value the value to set the property to.
957  \param withUndo if true the setting of this property can be undone.
958  */
959  virtual bool SetOrAddPropertyToObject( a2dObject* propRefObject, const wxString& name, const wxString& value = wxT( "" ), bool withUndo = true );
960 
961  //! set a named property to the given object
962  /*!
963  \param propRefObject object to set the property to.
964  \param property the property (id and value) to add.
965  \param withUndo if true the setting of this property can be undone.
966  */
967  virtual bool SetOrAddPropertyToObject( a2dObject* propRefObject, a2dNamedProperty* property, bool withUndo = true );
968 
969  //! Start a new command group
970  /*! The return value is given to CommandGroupEnd. */
971  a2dCommandGroup* CommandGroupBegin( const wxString& name );
972 
973  //! Start a new command group
974  void CommandGroupBegin( a2dCommandGroup* group );
975 
976  //! End a command group
977  /* \param group the return value of the matching CommandGroupBegin */
978  void CommandGroupEnd( a2dCommandGroup* group );
979 
980  //! when releasing this, release first all command, since they may hold commands referencing this
981  //! command processor, so it would never be deleted.
982  bool SmrtPtrRelease();
983 
984 protected:
985 
986  //! sents a a2dCommandProcessorEvent event( wxEVT_BEGINBUSY, command )
987  //! or a2dCommandProcessorEvent event( wxEVT_ENDBUSY, command )
988  //! to this class. This is done before and after executing/submitting a command.
989  //! You can intercept this event to set e.g a busy cursor.
990  //! - EVT_BEGINBUSY( a2dCentralCanvasCommandProcessor::OnBusyBegin )
991  //! - EVT_ENDBUSY( a2dCentralCanvasCommandProcessor::OnBusyEnd )
992  void SentBusyEvent( bool start, a2dCommand* command );
993 
994  //! find the currently active command group
995  a2dCommandGroup* FindActiveGroup();
996 
997  //! Set the current command to the last command in the active group
998  void SetCurrentToLastActive();
999 
1000  // for further flexibility, command processor doesn't call a2dCommand::Do()
1001  // and Undo() directly but uses these functions which can be overridden in
1002  // the derived class
1003 
1004  //! Called before doing the actual command
1005  virtual bool DoPreCommand( a2dCommand& cmd );
1006 
1007  //! Called after doing the actual command
1008  virtual bool DoPostCommand( a2dCommand& cmd );
1009 
1010  //! sents a a2dCommandProcessorEvent with id ::wxEVT_DO
1011  virtual bool DoCommand( a2dCommand& cmd );
1012 
1013  //! sents a a2dCommandProcessorEvent with id ::wxEVT_UNDO
1014  virtual bool UndoCommand( a2dCommand& cmd );
1015 
1016  //! sents a a2dCommandProcessorEvent with id ::wxEVT_REDO
1017  virtual bool RedoCommand( a2dCommand& cmd );
1018 
1019  //! maximum number of commands to store
1021  //! this is the root of the command group tree
1023 
1024  //! this is the parent group of the current command ( which may be a group itself )
1026 
1027  //! this is the tree-trace to the currently active command
1028  a2dCommandPtr m_currentCommand;
1029 
1030  //! associated undo accelerator attached to menu
1032  //! associated redo accelerator
1034 
1035 private:
1036 
1037  //!Clone this object and return a pointer to the new object
1038  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
1039 
1040  DECLARE_DYNAMIC_CLASS( a2dCommandProcessor )
1041 };
1042 
1043 //! help class which makes it possible to store a smart pointer as a wxObject*
1044 /*!
1045  If a class X has a member wxObject* m_obj, this pointer can normally not be used for storing a
1046  a2dSmrtPtr which is a template class not derived from wxObject.
1047  This class here is wxObject derived, and the smart pointer is maintained within.
1048  On deletion of this class it will delete the smart pointer, releasing the object pointed to.
1049 
1050  \ingroup general
1051 */
1052 template<class T>
1053 class a2dSmrtPtrWrap: public wxObject
1054 {
1055 public:
1056 
1057  a2dSmrtPtrWrap( T* caller )
1058  {
1059  m_smrtP = caller;
1060  }
1061 
1062  ~a2dSmrtPtrWrap()
1063  {
1064  }
1065 
1066  a2dSmrtPtr<T> m_smrtP;
1067 };
1068 
1069 #if (defined(__WXMSW__) && defined(WXUSINGDLL) )
1070 template class A2DGENERALDLLEXP a2dSmrtPtrWrap< a2dCommand >;
1071 #endif
1072 
1073 //! used to connect a command to a wxObject
1074 //! The wxObject derived class, holds a smart pointer to a command. The wxObject can be stored as m_callbackUserData in events.
1075 typedef a2dSmrtPtrWrap< a2dCommand > a2dCommandStore;
1076 
1077 #if (defined(__WXMSW__) && defined(WXUSINGDLL) )
1078 template class A2DGENERALDLLEXP std::allocator< wxEventType >;
1079 template class A2DGENERALDLLEXP std::allocator< std::_List_nod< wxEventType, std::allocator< wxEventType > >::_Node >;
1080 template class A2DGENERALDLLEXP std::allocator< std::_List_ptr< wxEventType, std::allocator< wxEventType > >::_Nodeptr >;
1081 template class A2DGENERALDLLEXP std::list< wxEventType >;
1082 template class A2DGENERALDLLEXP a2dlist< wxEventType >;
1083 #endif
1084 
1085 //! One Global instance of this class exists, in order to get to global needed objects.
1086 /*!
1087  Error from within the docview frame work and derived applications/libraries,
1088  use this class to report errors and warning too.
1089  They are maintained in a list, and in each a2dError, you will find the error code, and the
1090  message that went with it.
1091 
1092  Default error messages will be reported to wxLogError, if m_directlog is false, they will only be stored.
1093 
1094  From this class several other are derived, and they will share the same static information.
1095  Like the errors reported, and the user variables etc.
1096 
1097  \ingroup global general
1098 */
1099 class A2DGENERALDLLEXP a2dGeneralGlobal : public a2dObject
1100 {
1101 
1102  DECLARE_CLASS( a2dGeneralGlobal )
1103 
1104 public:
1105 
1106  a2dGeneralGlobal();
1107 
1108  virtual ~a2dGeneralGlobal();
1109 
1110  //! reset the error report to empty.
1111  /*!
1112  All erros in the error list are cleared.
1113  */
1114  virtual void ResetErrors();
1115 
1116  //! concatenate to the the error report the given error.
1117  virtual void ReportError( const a2dError& error, const wxString& errorstr = wxEmptyString );
1118 
1119  //! concatenate to the the error report the given error.
1120 #if !wxCHECK_VERSION(2,9,0)
1121  virtual void ReportErrorF( const a2dError& error, const wxChar* Format, ... );
1122 #else
1123  WX_DEFINE_VARARG_FUNC_VOID( ReportErrorF, 2, ( const a2dError&, const wxFormatString& ), DoPrintfWchar, DoPrintfUtf8 )
1124 #endif
1125  //! concatenate to the error report the given warning.
1126  virtual void ReportWarning( const a2dError& error, const wxString& errorstr );
1127 
1128  //! concatenate to the error report the given warning.
1129 #if !wxCHECK_VERSION(2,9,0)
1130  virtual void ReportWarningF( const a2dError& error, const wxChar* Format, ... );
1131 #else
1132  WX_DEFINE_VARARG_FUNC_VOID( ReportWarningF, 2, ( const a2dError&, const wxFormatString& ), DoPrintfWcharWarn, DoPrintfUtf8Warn )
1133 #endif
1134 
1135  //! get the errors found sofar.
1136  static a2dErrorVector& GetErrors() { return m_errors; }
1137 
1138  //! concatenate all errors found into one string.
1139  wxString GetErrorsAsString();
1140 
1141  //! all stored errors and warning are sent to log target using wxLogError()
1142  /*!
1143  Specific use is when m_directlog is false, but still errors or assembled,
1144  calling this function will sent to the logging target anyway.
1145  One can ignore all errors with ResetErrors().
1146  */
1147  void SendToLogTarget();
1148 
1149  //! code of the last warning or error
1150  a2dErrorWarningCode GetLastErrorCode() const;
1151 
1152  a2dError GetLastError() const;
1153 
1154  virtual void RecordF( wxObject* sender, const wxChar* Format, ... );
1155 
1156  virtual void RecordF( const wxChar* Format, ... );
1157 
1158  //! Set logging to wxLog target on or off
1159  void SetDoLog( bool onOff ) { m_directlog = onOff; }
1160 
1161  //! Is logging to wxLog target on or off?
1162  bool GetDoLog() { return m_directlog; }
1163 
1164  //! Add an error to the list of ignored errors
1165  void IgnoreError( unsigned int id );
1166 
1167  //! aliases list for setting internal variables
1168  a2dVariablesHash& GetVariablesHash() { return m_variableList; }
1169 
1170  //! get a variable from the internal aliases list
1171  wxString* GetVariableString( const wxString& variablename );
1172 
1173  //! Path(s) for configuration file(s) in an application
1174  a2dPathList& GetConfigPathList() { return m_configpath; }
1175 
1176  //! Get a reference to the central list of dynamic created property id's.
1177  a2dPropertyIdList& GetPropertyIdList() { return m_dynamicIdList; }
1178 
1179  wxString GetWxArt2DVar( bool withSep = true ) const;
1180 
1181  wxString GetWxArt2DArtVar( bool withSep = true, bool silent = false ) const;
1182 
1183  void SetLogConnectedEvents( bool logConnectedEvents ) { m_logConnectedEvents = logConnectedEvents; }
1184 
1185  bool GetLogConnectedEvents() { return m_logConnectedEvents; }
1186 
1187 protected:
1188 
1189 #if wxCHECK_VERSION(2,9,0)
1190 #if !wxUSE_UTF8_LOCALE_ONLY
1191  virtual void DoPrintfWchar( const a2dError&, const wxChar* format, ... );
1192  virtual void DoPrintfWcharWarn( const a2dError&, const wxChar* format, ... );
1193 #endif
1194 #if wxUSE_UNICODE_UTF8
1195  virtual void DoPrintfUtf8( const a2dError&, const char* format, ... );
1196  virtual void DoPrintfUtf8Warn( const a2dError&, const char* format, ... );
1197 #endif
1198 #endif
1199 
1200  //! Path(s) for configuration file(s) in an application
1202 
1203  //! logging to wxLog target on or off
1204  static bool m_directlog;
1205 
1206  //! list of all possible errors
1207  static a2dErrorVector m_errors;
1208 
1209  //! list of error id's to be ignored.
1210  static wxArrayInt m_ignoredErrorIds;
1211 
1212  //! aliaslist containing internal variables
1214 
1215  static a2dPropertyIdList m_dynamicIdList;
1216 
1217  bool m_logConnectedEvents;
1218 
1219 private:
1220 
1221  //!Clone this object and return a pointer to the new object
1222  virtual a2dObject* DoClone( CloneOptions options, a2dRefMap* refs ) const;
1223 
1224 #if wxART2D_USE_CVGIO
1225  virtual void DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts, a2dObjectList* towrite );
1226  virtual void DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts );
1227 #endif //wxART2D_USE_CVGIO
1228 
1229 };
1230 
1231 //! initializes the general module
1232 /*!
1233  The global variable a2dGeneralGlobals is set here.
1234 
1235  \ingroup global
1236  \ingroup general
1237 */
1238 class A2DGENERALDLLEXP a2dGeneralModule : public wxModule
1239 {
1240 public:
1241 
1242  a2dGeneralModule() {}
1243 
1244  virtual bool OnInit();
1245  virtual void OnExit();
1246 
1247 private:
1248 
1249  DECLARE_DYNAMIC_CLASS( a2dGeneralModule )
1250 };
1251 
1252 #if (defined(__WXMSW__) && defined(WXUSINGDLL) )
1253 template class A2DGENERALDLLEXP a2dSmrtPtr<a2dGeneralGlobal>;
1254 #endif
1255 
1256 //! only instance of a2dGeneralGlobal, to get to settings for dynamic variables and errors.
1257 A2DGENERALDLLEXP_DATA ( extern a2dSmrtPtr<a2dGeneralGlobal> ) a2dGeneralGlobals;
1258 //A2DGENERALDLLEXP_DATA (extern a2dGeneralGlobal* ) a2dGeneralGlobals;
1259 
1260 
1261 
1262 
1263 
1264 
1265 #define A2D_ARGUMENT_SETTER( TYPE, ARGUMENT_NAME ) \
1266  Args & \
1267  ARGUMENT_NAME( const TYPE& arg) { \
1268  this->argValue.ARGUMENT_NAME = arg; \
1269  this->argSet.ARGUMENT_NAME = true; \
1270  return *this; \
1271  }
1272 
1273 //! Set a string variable inside wxDocview
1274 /*!
1275  \ingroup commands
1276 */
1277 class A2DGENERALDLLEXP a2dCommand_SetVariable: public a2dCommand
1278 {
1279  DECLARE_DYNAMIC_CLASS( a2dCommand_SetVariable )
1280 
1281 public:
1282 
1283  //! Set a string variable inside wxDocview
1284  /*! \ingroup commandid
1285  */
1286  static const a2dCommandId Id;
1287 
1288  class A2DGENERALDLLEXP Args
1289  {
1290  public:
1291  Args()
1292  {
1293  argSet.varname = false;
1294  argSet.varvalue = false;
1295  }
1296 
1297  ~Args()
1298  {
1299  }
1300 
1301  A2D_ARGUMENT_SETTER( wxString, varname )
1302  A2D_ARGUMENT_SETTER( wxString, varvalue )
1303 
1304  struct argValuet
1305  {
1306  wxString varname; wxString varvalue;
1307  } argValue;
1308 
1309  struct argSett
1310  {
1311  bool varname, varvalue;
1312  } argSet;
1313  };
1314 
1315  a2dCommand_SetVariable( const Args& args = Args() )
1316  {
1317  m_args.argValue.varname = args.argSet.varname ? args.argValue.varname : wxString( wxEmptyString ); //error throw
1318  m_args.argValue.varvalue = args.argSet.varvalue ? args.argValue.varvalue : wxString( wxEmptyString );
1319  }
1320 
1321 private:
1322 
1323  Args m_args;
1324 
1325  virtual bool Do()
1326  {
1327  a2dGeneralGlobals->GetVariablesHash().SetVariableString( m_args.argValue.varname, m_args.argValue.varvalue );
1328  return true;
1329  }
1330  virtual bool Undo()
1331  {
1332  return false;
1333  }
1334 };
1335 
1336 //! Set a environment variable
1337 /*!
1338  \ingroup commands
1339 */
1340 class A2DGENERALDLLEXP a2dCommand_SetEnvironmentVariable: public a2dCommand
1341 {
1342  DECLARE_DYNAMIC_CLASS( a2dCommand_SetEnvironmentVariable )
1343 
1344 public:
1345 
1346  //! Set a string environment variable
1347  /*! \ingroup commandid
1348  */
1349  static const a2dCommandId Id;
1350 
1351  class A2DGENERALDLLEXP Args
1352  {
1353  public:
1354  Args()
1355  {
1356  argSet.varname = false;
1357  argSet.varvalue = false;
1358  }
1359 
1360  ~Args()
1361  {
1362  }
1363 
1364  A2D_ARGUMENT_SETTER( wxString, varname )
1365  A2D_ARGUMENT_SETTER( wxString, varvalue )
1366 
1367  struct argValuet
1368  {
1369  wxString varname; wxString varvalue;
1370  } argValue;
1371 
1372  struct argSett
1373  {
1374  bool varname, varvalue;
1375  } argSet;
1376  };
1377 
1378  a2dCommand_SetEnvironmentVariable( const Args& args = Args() )
1379  {
1380  m_args.argValue.varname = args.argSet.varname ? args.argValue.varname : wxString( wxEmptyString ); //error throw
1381  m_args.argValue.varvalue = args.argSet.varvalue ? args.argValue.varvalue : wxString( wxEmptyString );
1382  }
1383 
1384 private:
1385 
1386  Args m_args;
1387 
1388  virtual bool Do()
1389  {
1390  if ( wxSetEnv( m_args.argValue.varname, m_args.argValue.varvalue ) )
1391  return true;
1392 
1393 #if wxCHECK_VERSION(2,9,0)
1394  a2dGeneralGlobals->ReportErrorF( a2dError_SetEnv, _( " SetEnv() Error: Could not set Environment variable %s = %s\n" ),
1395  m_args.argValue.varname, m_args.argValue.varvalue );
1396 #else
1397  a2dGeneralGlobals->ReportErrorF( a2dError_SetEnv, _( " SetEnv() Error: Could not set Environment variable %s = %s\n" ),
1398  m_args.argValue.varname.c_str(), m_args.argValue.varvalue.c_str() );
1399 #endif
1400  return true;
1401  }
1402  virtual bool Undo()
1403  {
1404  return false;
1405  }
1406 };
1407 
1408 //! Get internal variable
1409 /*!
1410  \ingroup commands
1411 */
1412 class A2DGENERALDLLEXP a2dCommand_GetVariable: public a2dCommand
1413 {
1414  DECLARE_DYNAMIC_CLASS( a2dCommand_GetVariable )
1415 
1416 public:
1417 
1418  //! Set a string environment variable
1419  /*! \ingroup commandid
1420  */
1421  static const a2dCommandId Id;
1422 
1423  class A2DGENERALDLLEXP Args
1424  {
1425  public:
1426  Args()
1427  {
1428  argSet.varname = false;
1429  argSet.varvalue = false;
1430  }
1431 
1432  ~Args()
1433  {
1434  }
1435 
1436 
1437  A2D_ARGUMENT_SETTER( wxString, varname )
1438  A2D_ARGUMENT_SETTER( wxString, varvalue )
1439 
1440  struct argValuet
1441  {
1442  wxString varname; wxString varvalue;
1443  } argValue;
1444 
1445  struct argSett
1446  {
1447  bool varname, varvalue;
1448  } argSet;
1449  };
1450 
1451  a2dCommand_GetVariable( const Args& args = Args() )
1452  {
1453  m_args.argValue.varname = args.argSet.varname ? args.argValue.varname : wxString( wxEmptyString );
1454  m_args.argValue.varvalue = args.argSet.varvalue ? args.argValue.varvalue : wxString( wxEmptyString );
1455  }
1456 
1457 private:
1458 
1459  Args m_args;
1460 
1461  virtual bool Do()
1462  {
1463  const a2dNamedProperty* propfound = a2dGeneralGlobals->GetVariablesHash().GetVariable( m_args.argValue.varname );
1464  if( !propfound )
1465  {
1466  a2dGeneralGlobals->ReportError( a2dError_GetVar, _( "wrong variable name, variable does not exist" ) );
1467  return false;
1468  }
1469 
1470  m_args.argSet.varvalue = true;
1471  m_args.argValue.varvalue = propfound->StringValueRepresentation();
1472  return true;
1473  }
1474  virtual bool Undo()
1475  {
1476  return false;
1477  }
1478 };
1479 
1480 //! Get internal variable
1481 /*!
1482  \ingroup commands
1483 */
1484 class A2DGENERALDLLEXP a2dCommand_GetEnvVariable: public a2dCommand
1485 {
1486 
1487  DECLARE_DYNAMIC_CLASS( a2dCommand_GetEnvVariable )
1488 
1489 public:
1490 
1491  //! Set a string environment variable
1492  /*! \ingroup commandid
1493  */
1494  static const a2dCommandId Id;
1495 
1496  class A2DGENERALDLLEXP Args
1497  {
1498  public:
1499  Args()
1500  {
1501  argSet.varname = false;
1502  argSet.varvalue = false;
1503  }
1504 
1505  ~Args()
1506  {
1507  }
1508 
1509 
1510  A2D_ARGUMENT_SETTER( wxString, varname )
1511  A2D_ARGUMENT_SETTER( wxString, varvalue )
1512 
1513  struct argValuet
1514  {
1515  wxString varname; wxString varvalue;
1516  } argValue;
1517 
1518  struct argSett
1519  {
1520  bool varname, varvalue;
1521  } argSet;
1522  };
1523 
1524  a2dCommand_GetEnvVariable( const Args& args = Args() )
1525  {
1526  m_args.argValue.varname = args.argSet.varname ? args.argValue.varname : wxString( wxEmptyString );
1527  if ( !args.argSet.varname || m_args.argValue.varname.IsEmpty() )
1528  a2dGeneralGlobals->ReportError( a2dError_GetEnv, _( "wrong variable name, variable may not be empty" ) );
1529  }
1530 
1531 private:
1532 
1533  Args m_args;
1534 
1535  virtual bool Do()
1536  {
1537  wxString envValue;
1538  if( !wxGetEnv( m_args.argValue.varname, &envValue ) )
1539  {
1540  a2dGeneralGlobals->ReportError( a2dError_GetEnv, _( "environment variable does not exist" ) );
1541  return false; // Environment name not found
1542  }
1543 
1544  m_args.argSet.varvalue = true;
1545  m_args.argValue.varvalue = envValue;
1546  return true;
1547  }
1548  virtual bool Undo()
1549  {
1550  return false;
1551  }
1552 };
1553 
1554 
1555 #include <map>
1556 class A2DGENERALDLLEXP a2dMenuIdItem;
1557 typedef std::map< wxString, a2dMenuIdItem* > a2dMenuIdItemMap;
1558 
1559 //! store a menu Id generated by XRCID( menuIdString ) plus a menustring and helpstring
1560 /*!
1561  The class instance can be used to add directly to a menu
1562 */
1563 class A2DGENERALDLLEXP a2dMenuIdItem : public wxObject
1564 {
1565 public:
1566 
1567  DECLARE_CLASS( a2dMenuIdItem )
1568 
1569  //! constant to defined non valid id.
1570  static const a2dMenuIdItem sm_noCmdMenuId;
1571 
1572  //! constructor
1573  a2dMenuIdItem( const wxString& menuIdName = wxEmptyString,
1574  const wxString& text = wxEmptyString,
1575  const wxString& help = wxEmptyString, wxItemKind kind = wxITEM_NORMAL );
1576  //! destructor
1577  virtual ~a2dMenuIdItem() {};
1578 
1579  //! set id
1580  void SetId( int itemid ) { m_id = itemid; }
1581 
1582  //! get id
1583  int GetId() const { return m_id; }
1584 
1585  //! check if same id.
1586  bool SameId( const a2dMenuIdItem& other ) const { return m_id == other.m_id; }
1587 
1588  // the item's text (or name)
1589  //
1590  // NB: the item's text includes the accelerators and mnemonics info (if
1591  // any), i.e. it may contain '&' or '_' or "\t..." and thus is
1592  // different from the item's label which only contains the text shown
1593  // in the menu
1594  virtual void SetText( const wxString& str );
1595 
1596  //! get label text
1597  wxString GetLabel() const { return GetLabelText( m_text ); }
1598  //! get plain text for menu
1599  const wxString& GetText() const { return m_text; }
1600 
1601  //! get the label from text (implemented in platform-specific code)
1602  static wxString GetLabelText( const wxString& text );
1603 
1604  //! what kind of menu item we are
1605  wxItemKind GetKind() const { return m_kind; }
1606  void SetKind( wxItemKind kind ) { m_kind = kind; }
1607 
1608  //! set if menu is checkable
1609  virtual void SetCheckable( bool checkable ) { m_kind = checkable ? wxITEM_CHECK : wxITEM_NORMAL; }
1610 
1611  //! get if menu is checkable
1612  bool IsCheckable() const
1613  { return m_kind == wxITEM_CHECK || m_kind == wxITEM_RADIO; }
1614 
1615  //! initial state of menu
1616  virtual void Enable( bool enable = true ) { m_isEnabled = enable; }
1617  //! initial state of menu
1618  virtual bool IsEnabled() const { return m_isEnabled; }
1619 
1620  //! set initial check state of menu
1621  virtual void Check( bool check = true ) { m_isChecked = check; }
1622  //! get initial check state of menu
1623  virtual bool IsChecked() const { return m_isChecked; }
1624  //! toggel initial check state of menu
1625  void Toggle() { Check( !m_isChecked ); }
1626 
1627  // set help string (displayed in the status bar by default)
1628  void SetHelp( const wxString& str );
1629  // get help string (displayed in the status bar by default)
1630  const wxString& GetHelp() const { return m_help; }
1631 
1632  void SetBitmaps( const wxBitmap& bmpChecked,
1633  const wxBitmap& bmpUnchecked = wxNullBitmap );
1634  void SetBitmap( const wxBitmap& bmp ) { SetBitmaps( bmp ); }
1635  const wxBitmap& GetBitmap( bool checked = true ) const
1636  { return checked ? m_bmpChecked : m_bmpUnchecked; }
1637 
1638  void SetDisabledBitmap( const wxBitmap& bmpDisabled )
1639  { m_bmpDisabled = bmpDisabled; }
1640  const wxBitmap& GetDisabledBitmap() const
1641  { return m_bmpDisabled; }
1642 
1643 #if wxUSE_ACCEL
1644  // get our accelerator or NULL (caller must delete the pointer)
1645  virtual wxAcceleratorEntry* GetAccel() const;
1646 
1647  // set the accel for this item - this may also be done indirectly with
1648  // SetText()
1649  virtual void SetAccel( wxAcceleratorEntry* accel );
1650 #endif // wxUSE_ACCEL
1651 
1652  //! name of the menu coupled to unique id
1653  wxString GetIdName() const { return m_name; }
1654 
1655  //! search Id given the name of the command
1656  static const a2dMenuIdItem& GetItemByName( const wxString& menuIdName );
1657 
1658  //! stored map of names to get id
1659  static a2dMenuIdItemMap& GetHashMap();
1660 
1661  //! initialize bitmaps associated with found a2dMenuIdItem's from files
1662  static void InitializeBitmaps();
1663 
1664  //! Are the bitmaps for button bar etc. initlialized?
1665  static bool GetInitialized() { return m_bitmapinitialized; }
1666 
1667 private:
1668 
1669  int m_id; // numeric id of the item >= 0 or wxID_ANY or wxID_SEPARATOR
1670  wxString m_text, // label of the item
1671  m_help; // the help string for the item
1672  wxItemKind m_kind; // separator/normal/check/radio item?
1673  bool m_isChecked; // is checked?
1674  bool m_isEnabled; // is enabled?
1675 
1676  // the bitmaps (may be invalid, then they're not used)
1677  wxBitmap m_bmpChecked,
1678  m_bmpUnchecked,
1679  m_bmpDisabled;
1680 
1681  //! name of menu id
1682  wxString m_name;
1683 
1684  // were bitmaps already initialized?
1685  static bool m_bitmapinitialized;
1686 };
1687 
1688 #define DECLARE_MENU_ITEMID( menuName ) extern a2dMenuIdItem& menuName() ;
1689 
1690 #define DEFINE_MENU_ITEMID( menuName, menuText, menuHelp ) a2dMenuIdItem& menuName() \
1691 { \
1692  static a2dMenuIdItem item( wxT(#menuName), menuText, menuHelp ); \
1693  return item; \
1694 }
1695 
1696 #define DEFINE_MENU_ITEMID_KIND( menuName, menuText, menuHelp, kind ) a2dMenuIdItem& menuName () \
1697 { \
1698  static a2dMenuIdItem item( wxT(#menuName), menuText, menuHelp, (kind) ); \
1699  return item; \
1700 }
1701 
1702 #define DECLARE_EXPORTED_EVTIDFUNC( expdecl, eventName ) \
1703  DECLARE_EXPORTED_EVENT_TYPE( expdecl, eventName, 1 ) \
1704  extern wxEventType& GETID_##eventName();
1705 
1706 
1707 #define DECLARE_EVTIDFUNC( eventName ) \
1708  DECLARE_EVENT_TYPE( eventName, 1 ) \
1709  extern wxEventType& GETID_##eventName();
1710 
1711 #define DEFINE_EVTIDFUNC( eventName ) \
1712 wxEventType& GETID_##eventName() \
1713 { \
1714  static wxEventType type = wxNewEventType(); \
1715  return type; \
1716 } \
1717 const wxEventType eventName = GETID_##eventName();
1718 
1719 
1720 #endif // _COMEVTH__
wxString m_menuString
if set this will be used for menu Undo/Redo labels, else the m_commandId its name is used...
Definition: comevt.h:282
void SetCommandProcessor(a2dCommandProcessor *cmp)
set when submitting this command via a2dCommandProcessor
Definition: comevt.h:217
a2dNamedProperty * GetProperty()
property that is set packed as a2dNamedProperty.
Definition: comevt.h:592
(In) Visible property that can be added to Docview Objects.
Definition: gen.h:1785
const a2dPropertyId * GetPropertyId()
property that is set packed as a2dNamedProperty.
Definition: comevt.h:595
static const a2dCommandId Id
Set a string environment variable.
Definition: comevt.h:1349
static a2dVariablesHash m_variableList
aliaslist containing internal variables
Definition: comevt.h:1213
virtual bool PostDo()
Override this to perform a dependency action after command is done.
Definition: comevt.h:203
virtual wxString GetGroupName() const
return command name
Definition: comevt.h:384
static const a2dCommandId Id
Set a string environment variable.
Definition: comevt.h:1494
a2dCommandGroup * GetRootGroup() const
return top/startgroup
Definition: comevt.h:925
static a2dPathList m_configpath
Path(s) for configuration file(s) in an application.
Definition: comevt.h:1201
virtual void Enable(bool enable=true)
initial state of menu
Definition: comevt.h:1616
virtual wxEvent * Clone() const
clone the event.
Definition: comevt.h:756
const wxString & GetRedoAccelerator() const
By default, the accelerators are &quot;\tCtrl+Z&quot; and &quot;\tCtrl+Y&quot;.
Definition: comevt.h:944
a2dCommandException(const a2dCommandException &other)
Copy constructor.
Definition: comevt.h:302
bool IsCheckable() const
get if menu is checkable
Definition: comevt.h:1612
fundamental classes used by all other modules.
const a2dError a2dError_GetVar
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
see a2dCommandProcessorEvent
Definition: comevt.h:649
a2dAutoZeroPtr< a2dObject > m_propRefObject
all property references will be set NULL when this object, having the property, will be deleted...
Definition: comevt.h:607
a2dCommand * GetCommand()
the command ( if there was one ) that did it.
Definition: comevt.h:759
a2dSmrtPtrWrap< a2dCommand > a2dCommandStore
Definition: comevt.h:1075
const wxString & GetUndoAccelerator() const
By default, the accelerators are &quot;\tCtrl+Z&quot; and &quot;\tCtrl+Y&quot;.
Definition: comevt.h:942
bool SameId(const a2dMenuIdItem &other) const
check if same id.
Definition: comevt.h:1586
One Global instance of this class exists, in order to get to global needed objects.
Definition: comevt.h:1099
a2dCommandProcessorEvent(a2dCommand *cmd, const wxString &undoLabel, bool canUndo, const wxString &redoLabel, bool canRedo)
constructor
Definition: comevt.h:731
Ref Counted base object.
Definition: gen.h:1045
int a2dErrorWarningCode
error codes generated in docview framework.
Definition: gen.h:259
store a menu Id generated by XRCID( menuIdString ) plus a menustring and helpstring ...
Definition: comevt.h:1563
wxString & GetUndoMenuLabel()
by default this is a2dCommandProcessor::GetUndoMenuLabel()
Definition: comevt.h:762
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
Path searching.
Definition: gen.h:2926
static const a2dCommandId Id
Set a string environment variable.
Definition: comevt.h:1421
const wxString & GetText() const
get plain text for menu
Definition: comevt.h:1599
wxString m_redoAccelerator
associated redo accelerator
Definition: comevt.h:1033
bool m_canRedo
used for wxEVT_MENUSTRINGS event
Definition: comevt.h:785
bool m_canUndo
can this command be undone
Definition: comevt.h:268
a2dCommandProcessor * m_cmp
allows commands to get to the command processor that submitted the command.
Definition: comevt.h:279
wxString m_groupName
name of group of commands
Definition: comevt.h:431
list of a2dNamedProperty objects
Definition: gen.h:804
int GetMaxCommands() const
get the limit on number of commands to store
Definition: comevt.h:922
void SetRedoAccelerator(const wxString &accel)
By default, the accelerators are &quot;\tCtrl+Z&quot; and &quot;\tCtrl+Y&quot;.
Definition: comevt.h:949
const a2dCommandId * m_commandId
can be used to identify the command
Definition: comevt.h:273
void SetUndoAccelerator(const wxString &accel)
By default, the accelerators are &quot;\tCtrl+Z&quot; and &quot;\tCtrl+Y&quot;.
Definition: comevt.h:947
void SetParentGroup(a2dCommandGroup *parent)
set the parent group of this group
Definition: comevt.h:414
Definition: gen.h:276
static const a2dCommandId sm_groupCommandId
property for group command id
Definition: comevt.h:150
a2dCommandException(const wxString &exMessage)
Constructor.
Definition: comevt.h:299
bool m_canUndo
used for wxEVT_MENUSTRINGS event
Definition: comevt.h:779
const a2dNamedProperty * GetVariable(const wxString &variableName)
get an existing variable of unknown type (not cloned)
Definition: gen.cpp:4294
base command processor
Definition: comevt.h:829
a2dCommandPtr m_currentCommand
this is the tree-trace to the currently active command
Definition: comevt.h:1028
Set a environment variable.
Definition: comevt.h:1340
a group of commands, used to group commands together for undo/redo
Definition: comevt.h:360
void SetId(int itemid)
set id
Definition: comevt.h:1580
void Toggle()
toggel initial check state of menu
Definition: comevt.h:1625
static a2dErrorVector & GetErrors()
get the errors found sofar.
Definition: comevt.h:1136
const a2dPropertyId * m_id
id of the property that is set.
Definition: comevt.h:613
virtual class a2dCommandGroup * IsCommandGroup()
This is like a wxDynamicCast, but much faster.
Definition: comevt.h:393
bool m_active
If true, this command group is not yet closed and may still receive commands.
Definition: comevt.h:436
a2dCommandGroup * GetCurrentGroup() const
return current group
Definition: comevt.h:928
std list compatible list
Definition: a2dlist.h:42
a2dCommandGroup * m_parentGroup
this is the parent group of this group
Definition: comevt.h:428
wxString m_undoLabel
used for wxEVT_MENUSTRINGS event
Definition: comevt.h:776
virtual class a2dCommandGroup * IsCommandGroup()
This is like a wxDynamicCast, but much faster.
Definition: comevt.h:232
static const a2dCommandId sm_noCommandTypeId
property for type of command id
Definition: comevt.h:148
void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Save settings.
Definition: comevt.h:255
virtual void ReportError(const a2dError &error, const wxString &errorstr=wxEmptyString)
concatenate to the the error report the given error.
Definition: comevt.cpp:1221
wxUint32 m_maxNoCommands
maximum number of commands to store
Definition: comevt.h:1020
void(wxEvtHandler::* a2dPropertyEditEventFunctionEvt)(a2dPropertyEditEvent &)
event function for a2dPropertyEditEvent
Definition: comevt.h:678
a2dSmrtPtr< a2dCommandGroup > m_currentGroup
this is the parent group of the current command ( which may be a group itself )
Definition: comevt.h:1025
const a2dCommandId * GetCommandId()
a specific id for this command.
Definition: comevt.h:179
const a2dCommandId * GetCommandTypeId()
used to identify groups of simular commands
Definition: comevt.h:182
wxString m_undoAccelerator
associated undo accelerator attached to menu
Definition: comevt.h:1031
int GetId() const
get id
Definition: comevt.h:1583
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
Definition: comevt.cpp:1148
Set a string variable inside wxDocview.
Definition: comevt.h:1277
Holds internal variables to be used whereever needed.
Definition: gen.h:3223
static const a2dCommandId Id
Set a string variable inside wxDocview.
Definition: comevt.h:1286
a2dCommand * GetCurrentCommand() const
command list access
Definition: comevt.h:916
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
virtual bool IsEnabled() const
initial state of menu
Definition: comevt.h:1618
const a2dError a2dError_SetEnv
virtual bool PreDo()
Override this to perform a dependency action before command is done.
Definition: comevt.h:200
a2dVariablesHash & GetVariablesHash()
aliases list for setting internal variables
Definition: comevt.h:1168
bool CanRedo()
by default this is a2dCommandProcessor::CanRedo()
Definition: comevt.h:768
help class which makes it possible to store a smart pointer as a wxObject*
Definition: comevt.h:1053
a2dCommandList m_subcommands
the list of subcommands
Definition: comevt.h:438
bool GetEdited()
when properties where edited, this must become true
Definition: comevt.h:665
bool GetDoLog()
Is logging to wxLog target on or off?
Definition: comevt.h:1162
virtual wxString GetIdClassName()
get name of class
Definition: comevt.h:110
Each a2dCommand is given a command id at construction.
Definition: comevt.h:99
a2dSmrtPtr< a2dCommandGroup > m_rootGroup
this is the root of the command group tree
Definition: comevt.h:1022
basic list class based on STL containers.
virtual bool IsChecked() const
get initial check state of menu
Definition: comevt.h:1623
static a2dErrorVector m_errors
list of all possible errors
Definition: comevt.h:1207
a2dCommand * m_cmd
see GetCommand()
Definition: comevt.h:773
static wxArrayInt m_ignoredErrorIds
list of error id&#39;s to be ignored.
Definition: comevt.h:1210
void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load settings.
Definition: comevt.h:260
bool CanUndo()
by default this is a2dCommandProcessor::CanUndo()
Definition: comevt.h:766
wxItemKind GetKind() const
what kind of menu item we are
Definition: comevt.h:1605
a2dPropertyIdList & GetPropertyIdList()
Get a reference to the central list of dynamic created property id&#39;s.
Definition: comevt.h:1177
virtual wxEvent * Clone() const
clone the event
Definition: comevt.h:660
bool Modifies()
Definition: comevt.h:214
wxString GetIdName() const
name of the menu coupled to unique id
Definition: comevt.h:1653
void SetDoLog(bool onOff)
Set logging to wxLog target on or off.
Definition: comevt.h:1159
wxString m_redoLabel
used for wxEVT_MENUSTRINGS event
Definition: comevt.h:782
virtual ~a2dCommandId()
destructor
Definition: comevt.h:107
wxString GetLabel() const
get label text
Definition: comevt.h:1597
a2dPathList & GetConfigPathList()
Path(s) for configuration file(s) in an application.
Definition: comevt.h:1174
const a2dCommandId * m_commandTypeId
if set can be used to identify groups of commands
Definition: comevt.h:276
This is the base class for all kinds of property id&#39;s for a2dObject.
Definition: id.h:154
bool SetVariableString(const wxString &variableName, const wxString &value)
set a new or replace an existing wxString variable
Definition: gen.cpp:4255
static bool m_directlog
logging to wxLog target on or off
Definition: comevt.h:1204
a2dNamedPropertyPtr m_property
property set to the object.
Definition: comevt.h:610
virtual void ReportErrorF(const a2dError &error, const wxChar *Format,...)
concatenate to the the error report the given error.
Definition: comevt.cpp:1312
a2dCommandGroup * GetParentGroup()
return the parent group of this group
Definition: comevt.h:411
const a2dError a2dError_GetEnv
A list class for reference counted objects.
Definition: smrtptr.h:653
wxString & GetRedoMenuLabel()
by default this is a2dCommandProcessor::GetRedoMenuLabel()
Definition: comevt.h:764
Event sent to a2dCommandProcessor.
Definition: comevt.h:701
Get internal variable.
Definition: comevt.h:1412
virtual wxString StringValueRepresentation() const
Definition: gen.h:1905
void SetEdited(bool edited)
set to signal that properties where edited.
Definition: comevt.h:668
a2dCommandProcessorEvent(wxEventType type, a2dCommand *cmd)
constructor
Definition: comevt.h:711
virtual void SetCheckable(bool checkable)
set if menu is checkable
Definition: comevt.h:1609
This template class is for property ids with a known data type.
Definition: id.h:477
initializes the general module
Definition: comevt.h:1238
holds one error report.
Definition: gen.h:623
friend class a2dCommandProcessor
a2DocumentCommandProcessor may access the list directly
Definition: comevt.h:440
static bool GetInitialized()
Are the bitmaps for button bar etc. initlialized?
Definition: comevt.h:1665
list of a2dObject&#39;s
Definition: gen.h:3157
WX_DECLARE_HASH_MAP_WITH_DECL(wxString, a2dCommandId *, wxStringHash, wxStringEqual, a2dHashMapCommandIds, class A2DGENERALDLLEXP)
This hash table is used for a2dCommandId with name.
wxString GetName() const
get name
Definition: comevt.h:113
CloneOptions
options for cloning
Definition: gen.h:1200
static const a2dCommandId sm_noCommandId
property for command id
Definition: comevt.h:146
For exceptions thrown from commands.
Definition: comevt.h:294
used to change a property on objects
Definition: comevt.h:460
virtual void Check(bool check=true)
set initial check state of menu
Definition: comevt.h:1621
a2dCommandProcessorEvent(const a2dCommandProcessorEvent &event)
constructor
Definition: comevt.h:745
Get internal variable.
Definition: comevt.h:1484
class A2DGENERALDLLEXP a2dSmrtPtrList< a2dCommand > a2dCommandList
a list of commands used by the command processor or command groups
Definition: comevt.h:337
a base command for the a2dCommandProcessor
Definition: comevt.h:140
comevt.h Source File -- Sun Oct 12 2014 17:04:15 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation