wxArt2D
gen.cpp
Go to the documentation of this file.
1 /*! \file general/src/gen.cpp
2  \author Klaas Holwerda
3 
4  Copyright: 2001-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: gen.cpp,v 1.154 2009/09/26 19:01:07 titato Exp $
9 */
10 
11 #include "wxartbaseprec.h"
12 
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16 
17 #ifndef WX_PRECOMP
18 #include <wx/tokenzr.h>
19 #include <wx/utils.h>
20 
21 
22 #include "wx/general/gen.h"
23 #include "wx/general/comevt.h"
24 
25 #if wxART2D_USE_CVGIO
26 #include "wx/xmlparse/genxmlpars.h"
27 #endif //wxART2D_USE_CVGIO
28 #endif
29 
30 #if defined(__WXMSW__) && defined(__MEMDEBUG__)
31 #include <wx/msw/msvcrt.h>
32 #endif
33 
34 
35 /*
36 // MSVC warning 4660 is quite stupid. It says that the template is already instantiated
37 // by using it, but it is not fully instantiated as required for a library
38 #ifdef _MSC_VER
39 #pragma warning(disable: 4660)
40 #endif
41 
42 // explicit template instantiations
43 template class a2dPropertyIdTyped<a2dObjectPtr, a2dProperty>;
44 
45 template class a2dSmrtPtrList<a2dObject>;
46 
47 #ifdef _MSC_VER
48 #pragma warning(default: 4660)
49 #endif
50 */
51 
52 //#include "wx/general/id.inl"
53 #include "wx/general/smrtptr.inl"
54 
55 a2dVersNo::a2dVersNo(const wxString& versionString)
56 {
57  long major=0, minor=0, micro=0;
58  wxStringTokenizer tokenizer( versionString, ".");
59  if ( tokenizer.HasMoreTokens() )
60  tokenizer.GetNextToken().ToLong( &major );
61  if ( tokenizer.HasMoreTokens() )
62  tokenizer.GetNextToken().ToLong( &minor );
63  if ( tokenizer.HasMoreTokens() )
64  tokenizer.GetNextToken().ToLong( &micro );
65  m_major = major;
66  m_minor = minor;
67  m_micro = micro;
68 }
69 
70 bool a2dVersNo::operator==( const a2dVersNo& rhs ) const
71 {
72  return (m_major == rhs.m_major) && (m_minor == rhs.m_minor) && (m_micro == rhs.m_micro);
73 }
74 
75 bool a2dVersNo::operator>( const a2dVersNo& rhs ) const
76 {
77  return (m_major > rhs.m_major) ||
78  ((m_major == rhs.m_major) && (m_minor > rhs.m_minor)) ||
79  ((m_major == rhs.m_major) && (m_minor == rhs.m_minor) && (m_micro > rhs.m_micro));
80 }
81 
82 bool a2dVersNo::operator>=( const a2dVersNo& rhs ) const
83 {
84  return (m_major > rhs.m_major) ||
85  ((m_major == rhs.m_major) && (m_minor > rhs.m_minor)) ||
86  ((m_major == rhs.m_major) && (m_minor == rhs.m_minor) && (m_micro >= rhs.m_micro));
87 }
88 
89 
90 static int wxGenIdCount = 0;
91 
92 A2DGENERALDLLEXP long wxGenNewId()
93 {
94  return ++ wxGenIdCount;
95 }
96 
97 A2DGENERALDLLEXP void wxGenRegisterId( long id )
98 {
99  wxGenIdCount = id;
100 }
101 
102 //!@{ \ingroup errorcodes
103 const a2dError a2dError_NoError( wxT( "a2dError_NoError" ), wxT( "All Oke" ) );
104 const a2dError a2dError_CommandError( wxT( "a2dError_CommandError" ), wxT( "" ) );
105 const a2dError a2dError_NotSpecified( wxT( "a2dError_NotSpecified" ), wxT( "" ) );
106 const a2dError a2dError_CanceledFileDialog( wxT( "a2dError_CanceledFileDialog" ), wxT( "" ) );
107 const a2dError a2dError_FileCouldNotOpen( wxT( "a2dError_FileCouldNotOpen" ), wxTRANSLATE( "Sorry, could not open file for saving" ) );
108 const a2dError a2dError_CouldNotCreateDocument( wxT( "a2dError_CouldNotCreateDocument" ), wxT( "" ) );
109 const a2dError a2dError_NoDocTemplateRef( wxT( "a2dError_NoDocTemplateRef" ), wxT( "" ) );
110 const a2dError a2dError_DocumentsOpened( wxT( "a2dError_DocumentsOpened" ), wxTRANSLATE( "No template defined in a2dDocument::OnSaveAsDocument" ) );
111 const a2dError a2dError_SetEnv( wxT( "a2dError_SetEnv" ), wxT( "" ) );
112 const a2dError a2dError_GetEnv( wxT( "a2dError_GetEnv" ), wxT( "" ) );
113 const a2dError a2dError_GetVar( wxT( "a2dError_GetVar" ), wxT( "" ) );
114 const a2dError a2dError_SaveFile( wxT( "a2dError_SaveFile" ), wxTRANSLATE( "Sorry, could not save document to file" ) );
115 const a2dError a2dError_LoadFile( wxT( "a2dError_LoadFile" ), wxTRANSLATE( "Sorry, could not load file into document" ) );
116 const a2dError a2dError_ExportFile( wxT( "a2dError_ExportFile" ), wxTRANSLATE( "Sorry, could not export document to file" ) );
117 const a2dError a2dError_ImportFile( wxT( "a2dError_ImportFile" ), wxTRANSLATE( "bad stream" ) );
118 const a2dError a2dError_IOHandler( wxT( "a2dError_IOHandler" ), wxTRANSLATE( "suitable template I/O handler for loading not available in document templates" ) );
119 const a2dError a2dError_SaveObject( wxT( "a2dError_SaveObject" ), wxTRANSLATE( "I/O handler cannot save document" ) );
120 const a2dError a2dError_LoadObject( wxT( "a2dError_LoadObject" ), wxTRANSLATE( "I/O handler cannot load document" ) );
121 const a2dError a2dError_FileHistory( wxT( "a2dError_FileHistory" ), wxT( "" ) );
122 const a2dError a2dError_ImportObject( wxT( "a2dError_ImportObject" ), wxT( "" ) );
123 const a2dError a2dError_XMLparse( wxT( "a2dError_XMLparse" ), wxT( "" ) );
124 const a2dError a2dError_FileVersion( wxT( "a2dError_FileVersion" ), wxTRANSLATE( "Version of file does not fit document" ) );
125 const a2dError a2dError_LoadLayers( wxT( "a2dError_LoadLayers" ), wxTRANSLATE( "Could not load layers" ) );
126 const a2dError a2dError_property( wxT( "a2dError_property" ), wxTRANSLATE( "problems on property" ) );
127 const a2dError a2dError_NoView( wxT( "a2dError_NoView" ), wxTRANSLATE( "Not a a2dCanvasView View" ) );
128 const a2dError a2dError_NoDocument( wxT( "a2dError_NoDocument" ), wxTRANSLATE( "No document set for a2dCanvasView in a2dCentralCanvasCommandProcessor::SetShowObject()" ) );
129 const a2dError a2dError_NoController( wxT( "a2dError_NoController" ), wxTRANSLATE( "No controller set for current view" ) );
130 const a2dError a2dError_NoTool( wxT( "a2dError_NoTool" ), wxTRANSLATE( "No tool available" ) );
131 const a2dError a2dError_LinkRef( wxT( "a2dError_LinkRef" ), wxT( "" ) );
132 const a2dError a2dError_NoWrapper( wxT( "a2dError_NoWrapper" ), wxT( "" ) );
133 const a2dError a2dError_LinkPin( wxT( "a2dError_LinkPin" ), wxT( "" ) );
134 const a2dError a2dError_NoPinClass( wxT( "a2dError_NoPinClass" ), wxT( "" ) );
135 const a2dError a2dError_CouldNotEvaluatePath( wxT( "a2dError_CouldNotEvaluatePath" ), wxT( "" ) );
136 const a2dError a2dError_Canceled( wxT( "a2dError_Canceled" ), wxT( "" ) );
137 const a2dError a2dError_CouldNotLoad( wxT( "a2dError_CouldNotLoad" ), wxTRANSLATE( "I/O handler error during loading this format." ) );
138 const a2dError a2dError_NoSelection( wxT( "a2dError_NoSelection" ), wxT( "" ) );
139 const a2dError a2dError_ToManyOpen( wxT( "a2dError_ToManyOpen" ), wxT( "" ) );
140 const a2dError a2dError_canvasObjectRelease( wxT( "a2dError_canvasObjectRelease" ), wxTRANSLATE( "could not release a2dCanvasObject in a2dCommand_ReleaseObject::Do" ) );
141 //!@}
142 
143 a2dErrorHash& a2dError::GetHashMap()
144 {
145  static a2dMemoryCriticalSectionHelper helper;
146  static a2dErrorHash ms_Name2Id;
147  return ms_Name2Id;
148 }
149 
150 
151 #if (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
152 // by using it, but it is not fully instantiated as required for a library
153 #ifdef _MSC_VER
154 #pragma warning(disable: 4660)
155 #endif
156 
157 // Explicit template instantiations for DLL
158 
159 #if (defined(__WXMSW__) && defined(WXUSINGDLL) )
160 template class A2DGENERALDLLEXP a2dSmrtPtr<a2dObject>;
161 template class A2DGENERALDLLEXP a2dPropertyIdTyped<a2dSmrtPtr<a2dObject>, a2dProperty>;
162 template class A2DGENERALDLLEXP a2dAutoZeroPtr<class a2dObject>;
163 template class A2DGENERALDLLEXP a2dPropertyIdTyped<a2dAutoZeroPtr<a2dObject>, a2dAutoZeroProperty>;
164 template class A2DGENERALDLLEXP a2dPropertyIdTyped<a2dPathList, a2dPathListProperty> ;
165 // template class A2DGENERALDLLEXP a2dSmrtPtr<a2dIOHandler>;
166 template class A2DGENERALDLLEXP a2dSmrtPtrList<a2dObject>;
167 template class A2DGENERALDLLEXP a2dlist<class a2dSmrtPtr<class a2dObject> >;
168 #endif
169 
170 #ifdef _MSC_VER
171 #pragma warning(default: 4660)
172 #endif
173 
174 #endif // (__GNUC__ < 3 || (__GNUC__ == 3 && __GNUC_MINOR__ < 4))
175 
176 IMPLEMENT_ABSTRACT_CLASS( a2dObject, wxObject )
177 IMPLEMENT_ABSTRACT_CLASS( a2dNamedProperty, a2dObject )
178 IMPLEMENT_DYNAMIC_CLASS( a2dProperty, a2dNamedProperty )
179 IMPLEMENT_DYNAMIC_CLASS( a2dAutoZeroProperty, a2dNamedProperty )
180 IMPLEMENT_DYNAMIC_CLASS( a2dBoolProperty, a2dNamedProperty )
181 IMPLEMENT_DYNAMIC_CLASS( a2dStringProperty, a2dNamedProperty )
182 IMPLEMENT_DYNAMIC_CLASS( a2dVoidPtrProperty, a2dNamedProperty )
183 IMPLEMENT_DYNAMIC_CLASS( a2dInt16Property, a2dNamedProperty )
184 IMPLEMENT_DYNAMIC_CLASS( a2dUint16Property, a2dNamedProperty )
185 IMPLEMENT_DYNAMIC_CLASS( a2dInt32Property, a2dNamedProperty )
186 IMPLEMENT_DYNAMIC_CLASS( a2dUint32Property, a2dNamedProperty )
187 IMPLEMENT_DYNAMIC_CLASS( a2dDoubleProperty, a2dNamedProperty )
188 IMPLEMENT_DYNAMIC_CLASS( a2dFloatProperty, a2dNamedProperty )
189 IMPLEMENT_DYNAMIC_CLASS( a2dArrayStringProperty, a2dNamedProperty )
190 IMPLEMENT_DYNAMIC_CLASS( a2dFileNameProperty, a2dNamedProperty )
191 IMPLEMENT_DYNAMIC_CLASS( a2dMenuProperty, a2dNamedProperty )
192 IMPLEMENT_DYNAMIC_CLASS( a2dUriProperty, a2dNamedProperty )
193 IMPLEMENT_DYNAMIC_CLASS( a2dWindowProperty, a2dNamedProperty )
194 IMPLEMENT_DYNAMIC_CLASS( a2dTipWindowProperty, a2dWindowProperty )
195 IMPLEMENT_DYNAMIC_CLASS( a2dDateTimeProperty, a2dNamedProperty )
196 IMPLEMENT_DYNAMIC_CLASS( a2dPathListProperty, a2dNamedProperty )
197 IMPLEMENT_DYNAMIC_CLASS( a2dColourProperty, a2dNamedProperty )
198 IMPLEMENT_DYNAMIC_CLASS( a2dObjectProperty, a2dNamedProperty )
199 
200 WX_DEFINE_LIST( a2dResolveIdList );
201 
202 //! initialize timestamp
203 long a2dEvent::ms_timestamp = 0;
204 
205 //----------------------------------------------------------------------------
206 // a2dResolveIdInfo
207 //----------------------------------------------------------------------------
208 
209 bool a2dResolveIdInfo::Assign( a2dObject* ptr )
210 {
211  switch ( m_mode )
212  {
213  case mode_a2dObjectSmrtPtr:
214  if( !ptr )
215  return false;
216  *m_storedHere.m_a2dObjectSmrtPtr = wxStaticCast( ptr, a2dObject );
217  return true;
218 
219  case mode_a2dObjectAutoZeroPtr:
220  if( !ptr )
221  return false;
222  *m_storedHere.m_a2dObjectAutoZeroPtr = wxStaticCast( ptr, a2dObject );
223  return true;
224 
225  case mode_link:
226  return m_storedHere.m_link->LinkReference( ptr );
227 
228  case mode_inform:
229  m_storedHere.m_inform->ResolveInform();
230  return true;
231 
232  default:
233  wxASSERT( 0 );
234  return false;
235  }
236 }
237 
238 //----------------------------------------------------------------------------
239 // a2dObject
240 //----------------------------------------------------------------------------
241 
242 #ifdef WXVALIDEVENTENTRY
243 
244 bool a2dObject::SearchDynamicEventTable( wxEvent& event )
245 {
246  wxCHECK_MSG( m_dynamicEvents, false,
247  wxT( "caller should check that we have dynamic events" ) );
248 
249  wxList::compatibility_iterator node = m_dynamicEvents->GetFirst();
250  while ( node )
251  {
252  wxDynamicEventTableEntry* entry = ( wxDynamicEventTableEntry* )node->GetData();
253  wxList::compatibility_iterator nodeerase = node;
254  node = node->GetNext();
255  if ( entry->m_disconnect )
256  {
257  // Remove connection from tracker node (wxEventConnectionRef)
258 #if wxCHECK_VERSION(2,9,0)
259  wxEvtHandler* eventSink = entry->m_fn->GetEvtHandler();
260  if ( eventSink && eventSink != this )
261  {
262  wxEventConnectionRef* evtConnRef = FindRefInTrackerList( eventSink );
263  if ( evtConnRef )
264  evtConnRef->DecRef();
265  }
266 #endif
267  if ( entry->m_callbackUserData )
268  delete entry->m_callbackUserData;
269  m_dynamicEvents->Erase( nodeerase );
270  delete entry;
271  }
272  else
273  entry->m_inIteration = true;
274  }
275 
276  // MAKE sure that the receiving handlers, will not be destroyed while receiving events
277  node = m_dynamicEvents->GetFirst();
278  while ( node )
279  {
280  wxDynamicEventTableEntry* entry = ( wxDynamicEventTableEntry* )node->GetData();
281  wxList::compatibility_iterator nodeerase = node;
282  node = node->GetNext();
283 #if wxCHECK_VERSION(2,9,0)
284  wxEvtHandler* eventSink = entry->m_fn->GetEvtHandler();
285 #else
286  wxEvtHandler* eventSink = entry->m_eventSink;
287 #endif
288  if ( eventSink && eventSink != this )
289  {
290  a2dObject* yes = wxDynamicCast( eventSink, a2dObject );
291  if ( yes )
292  yes->SmrtPtrOwn();
293  }
294  }
295 
296  node = m_dynamicEvents->GetFirst();
297  while ( node )
298  {
299 #if WXWIN_COMPATIBILITY_EVENT_TYPES
300  wxEventTableEntry* entry = ( wxEventTableEntry* )node->GetData();
301 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
302  wxDynamicEventTableEntry* entry = ( wxDynamicEventTableEntry* )node->GetData();
303 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
304 
305  // get next node before (maybe) calling the event handler as it could
306  // call Disconnect() invalidating the current node
307  wxList::compatibility_iterator nodeerase = node;
308  node = node->GetNext();
309 
310  if ( !entry->m_disconnect )
311  {
312 #if !wxCHECK_VERSION(2,9,0)
313  if ( ( event.GetEventType() == entry->m_eventType ) && ( entry->m_fn != 0 ) )
314  {
315  wxEvtHandler* handler =
316 #if !WXWIN_COMPATIBILITY_EVENT_TYPES
317  entry->m_eventSink ? entry->m_eventSink
318  :
319 #endif
320  this;
321 
322  if ( ProcessEventIfMatches( *entry, handler, event ) )
323  {
324  return true;
325  }
326  }
327 #else
328  if ( event.GetEventType() == entry->m_eventType )
329  {
330  wxEvtHandler* handler = entry->m_fn->GetEvtHandler();
331  if ( !handler )
332  handler = this;
333  if ( ProcessEventIfMatchesId( *entry, handler, event ) )
334  return true;
335  }
336 #endif
337  }
338  }
339 
340  // It is now save to destroy event handlers.
341  node = m_dynamicEvents->GetFirst();
342  while ( node )
343  {
344  wxDynamicEventTableEntry* entry = ( wxDynamicEventTableEntry* )node->GetData();
345  wxList::compatibility_iterator nodeerase = node;
346  node = node->GetNext();
347 
348 #if wxCHECK_VERSION(2,9,0)
349  wxEvtHandler* eventSink = entry->m_fn->GetEvtHandler();
350 #else
351  wxEvtHandler* eventSink = entry->m_eventSink;
352 #endif
353  if ( eventSink && eventSink != this )
354  {
355  a2dObject* yes = wxDynamicCast( eventSink, a2dObject );
356  if ( yes )
357  yes->SmrtPtrRelease();
358  }
359  }
360 
361 
362  // it looks this as already been done above, but processing the event,
363  // might disconnect more events.
364  node = m_dynamicEvents->GetFirst();
365  while ( node )
366  {
367  wxDynamicEventTableEntry* entry = ( wxDynamicEventTableEntry* )node->GetData();
368  wxList::compatibility_iterator nodeerase = node;
369  node = node->GetNext();
370  if ( entry->m_disconnect )
371  {
372 #if wxCHECK_VERSION(2,9,0)
373  // Remove connection from tracker node (wxEventConnectionRef)
374  wxEvtHandler* eventSink = entry->m_fn->GetEvtHandler();
375  if ( eventSink && eventSink != this )
376  {
377  wxEventConnectionRef* evtConnRef = FindRefInTrackerList( eventSink );
378  if ( evtConnRef )
379  evtConnRef->DecRef();
380  }
381 #endif
382  if ( entry->m_callbackUserData )
383  delete entry->m_callbackUserData;
384  m_dynamicEvents->Erase( nodeerase );
385  delete entry;
386  }
387  else
388  entry->m_inIteration = false;
389  }
390 
391  return false;
392 }
393 
394 #else //WXVALIDEVENTENTRY
395 
396 #if !wxCHECK_VERSION(2,9,0)
397 
398 bool a2dObject::ProcessEvent( wxEvent& event )
399 {
400  // allow the application to hook into event processing
401  if ( wxTheApp )
402  {
403  int rc = wxTheApp->FilterEvent( event );
404  if ( rc != -1 )
405  {
406  wxASSERT_MSG( rc == 1 || rc == 0,
407  _T( "unexpected wxApp::FilterEvent return value" ) );
408 
409  return rc != 0;
410  }
411  //else: proceed normally
412  }
413 
414  // An event handler can be enabled or disabled
415  if ( GetEvtHandlerEnabled() )
416  {
417  // if we have a validator, it has higher priority than our own event
418  // table
419  if ( TryValidator( event ) )
420  return true;
421 
422  // Handle per-instance dynamic event tables first
423  if ( m_dynamicEvents && SearchDynamicEventTable( event ) )
424  return true;
425 
426  // Then static per-class event tables
427  if ( GetEventHashTable().HandleEvent( event, this ) )
428  return true;
429  }
430 
431  // Try going down the event handler chain
432  if ( GetNextHandler() )
433  {
434  if ( GetNextHandler()->ProcessEvent( event ) )
435  return true;
436  }
437 
438  // Finally propagate the event upwards the window chain and/or to the
439  // application object as necessary
440  return TryParent( event );
441 }
442 #else
443 
444 bool a2dObject::ProcessEventLocally( wxEvent& event )
445 {
446  // Try the hooks which should be called before our own handlers and this
447  // handler itself first. Notice that we should not call ProcessEvent() on
448  // this one as we're already called from it, which explains why we do it
449  // here and not in DoTryChain()
450  return TryBeforeAndHere( event ) || DoTryChain( event );
451 }
452 
453 bool a2dObject::DoTryChain( wxEvent& event )
454 {
455  for ( wxEvtHandler* h = GetNextHandler(); h; h = h->GetNextHandler() )
456  {
457  wxEventProcessInHandlerOnly processInHandlerOnly( event, h );
458  if ( h->ProcessEvent( event ) )
459  {
460  event.Skip( false );
461 
462  return true;
463  }
464 
465  if ( !event.ShouldProcessOnlyIn( h ) )
466  {
467  event.Skip();
468 
469  return true;
470  }
471  }
472 
473  return false;
474 }
475 
476 
477 bool a2dObject::TryHereOnly( wxEvent& event )
478 {
479  // If the event handler is disabled it doesn't process any events
480  if ( !GetEvtHandlerEnabled() )
481  return false;
482 
483  // Handle per-instance dynamic event tables first
484  if ( m_dynamicEvents && SearchDynamicEventTable( event ) )
485  return true;
486 
487  // Then static per-class event tables
488  if ( GetEventHashTable().HandleEvent( event, this ) )
489  return true;
490 
491  // We don't have a handler for this event.
492  return false;
493 }
494 
495 bool a2dObject::ProcessEvent( wxEvent& event )
496 {
497  // The very first thing we do is to allow the application to hook into
498  // event processing in order to globally pre-process all events.
499  //
500  // Note that we should only do it if we're the first event handler called
501  // to avoid calling FilterEvent() multiple times as the event goes through
502  // the event handler chain and possibly upwards the window hierarchy.
503  if ( !event.WasProcessed() )
504  {
505  if ( wxTheApp )
506  {
507  int rc = wxTheApp->FilterEvent( event );
508  if ( rc != -1 )
509  {
510  wxASSERT_MSG( rc == 1 || rc == 0,
511  "unexpected wxApp::FilterEvent return value" );
512 
513  return rc != 0;
514  }
515  //else: proceed normally
516  }
517  }
518 
519  // Short circuit the event processing logic if we're requested to process
520  // this event in this handler only, see DoTryChain() for more details.
521  if ( event.ShouldProcessOnlyIn( this ) )
522  return TryBeforeAndHere( event );
523 
524 
525  // Try to process the event in this handler itself.
526  if ( ProcessEventLocally( event ) )
527  {
528  // It is possible that DoTryChain() called from ProcessEventLocally()
529  // returned true but the event was not really processed: this happens
530  // if a custom handler ignores the request to process the event in this
531  // handler only and in this case we should skip the post processing
532  // done in TryAfter() but still return the correct value ourselves to
533  // indicate whether we did or did not find a handler for this event.
534  return !event.GetSkipped();
535  }
536 
537  // If we still didn't find a handler, propagate the event upwards the
538  // window chain and/or to the application object.
539  if ( TryAfter( event ) )
540  return true;
541 
542 
543  // No handler found anywhere, bail out.
544  return false;
545 }
546 #endif
547 
548 bool a2dObject::SearchDynamicEventTable( wxEvent& event )
549 {
550  wxCHECK_MSG( m_dynamicEvents, false,
551  wxT( "caller should check that we have dynamic events" ) );
552 
553  bool returnval = false;
554  wxList::compatibility_iterator node = m_dynamicEvents->GetFirst();
555 /*
556  if ( !m_iteratorCount && m_pendingDisconnects )
557  {
558  while ( node )
559  {
560  a2dDynamicEventTableEntry* entry = ( a2dDynamicEventTableEntry* )node->GetData();
561  wxList::compatibility_iterator nodeerase = node;
562  node = node->GetNext();
563  if ( entry->m_disconnect )
564  {
565  // Remove connection from tracker node (wxEventConnectionRef)
566  #if wxCHECK_VERSION(2,9,0)
567  wxEvtHandler* eventSink = entry->m_fn->GetEvtHandler();
568  if ( eventSink && eventSink != this )
569  {
570  wxEventConnectionRef* evtConnRef = FindRefInTrackerList( eventSink );
571  if ( evtConnRef )
572  evtConnRef->DecRef();
573  }
574  #endif
575  if ( entry->m_callbackUserData )
576  delete entry->m_callbackUserData;
577  m_dynamicEvents->Erase( nodeerase );
578  delete entry;
579  }
580  }
581  m_pendingDisconnects = false;
582  }
583 */
584  // MAKE sure that the receiving handlers, will not be destroyed while receiving events
585  node = m_dynamicEvents->GetFirst();
586  while ( node )
587  {
588  a2dDynamicEventTableEntry* entry = ( a2dDynamicEventTableEntry* )node->GetData();
589  wxList::compatibility_iterator nodeerase = node;
590  node = node->GetNext();
591 #if wxCHECK_VERSION(2,9,0)
592  wxEvtHandler* eventSink = entry->m_fn->GetEvtHandler();
593 #else
594  wxEvtHandler* eventSink = entry->m_eventSink;
595 #endif
596  if ( eventSink && eventSink != this )
597  {
598  a2dObject* yes = wxDynamicCast( eventSink, a2dObject );
599  if ( yes )
600  yes->SmrtPtrOwn();
601  }
602  }
603 
604  m_iteratorCount++;
605  node = m_dynamicEvents->GetFirst();
606  while ( node )
607  {
608 #if WXWIN_COMPATIBILITY_EVENT_TYPES
609  wxEventTableEntry* entry = ( wxEventTableEntry* )node->GetData();
610 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
611  a2dDynamicEventTableEntry* entry = ( a2dDynamicEventTableEntry* )node->GetData();
612 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
613 
614  // get next node before (maybe) calling the event handler as it could
615  // call Disconnect() invalidating the current node
616  wxList::compatibility_iterator nodeerase = node;
617  node = node->GetNext();
618 
619  if ( !entry->m_disconnect )
620  {
621 #if !wxCHECK_VERSION(2,9,0)
622  if ( ( event.GetEventType() == entry->m_eventType ) && ( entry->m_fn != 0 ) )
623  {
624  wxEvtHandler* handler =
625 #if !WXWIN_COMPATIBILITY_EVENT_TYPES
626  entry->m_eventSink ? entry->m_eventSink
627  :
628 #endif
629  this;
630 
631  if ( ProcessEventIfMatches( *entry, handler, event ) )
632  {
633  returnval = true;
634  break;
635  }
636  }
637 #else
638  if ( event.GetEventType() == entry->m_eventType )
639  {
640  wxEvtHandler* handler = entry->m_fn->GetEvtHandler();
641  if ( !handler )
642  handler = this;
643  if ( ProcessEventIfMatchesId( *entry, handler, event ) )
644  {
645  returnval = true;
646  break;
647  }
648  }
649 #endif
650  }
651  }
652  m_iteratorCount--;
653 
654  // It is now save to destroy event handlers.
655  node = m_dynamicEvents->GetFirst();
656  while ( node )
657  {
658  a2dDynamicEventTableEntry* entry = ( a2dDynamicEventTableEntry* )node->GetData();
659  wxList::compatibility_iterator nodeerase = node;
660  node = node->GetNext();
661 
662 #if wxCHECK_VERSION(2,9,0)
663  wxEvtHandler* eventSink = entry->m_fn->GetEvtHandler();
664 #else
665  wxEvtHandler* eventSink = entry->m_eventSink;
666 #endif
667  if ( eventSink && eventSink != this )
668  {
669  a2dObject* yes = wxDynamicCast( eventSink, a2dObject );
670  if ( yes )
671  yes->SmrtPtrRelease();
672  }
673  }
674 
675 
676  // it looks this as already been done above, but processing the event,
677  // might disconnect more events.
678  if ( !m_iteratorCount && m_pendingDisconnects )
679  {
680  node = m_dynamicEvents->GetFirst();
681  while ( node )
682  {
683  a2dDynamicEventTableEntry* entry = ( a2dDynamicEventTableEntry* )node->GetData();
684  wxList::compatibility_iterator nodeerase = node;
685  node = node->GetNext();
686  if ( entry->m_disconnect )
687  {
688  #if wxCHECK_VERSION(2,9,0)
689  // Remove connection from tracker node (wxEventConnectionRef)
690  wxEvtHandler* eventSink = entry->m_fn->GetEvtHandler();
691  if ( eventSink && eventSink != this )
692  {
693  wxEventConnectionRef* evtConnRef = FindRefInTrackerList( eventSink );
694  if ( evtConnRef )
695  evtConnRef->DecRef();
696  }
697  #endif
698  if ( entry->m_callbackUserData )
699  delete entry->m_callbackUserData;
700  m_dynamicEvents->Erase( nodeerase );
701  delete entry;
702  }
703  }
704  m_pendingDisconnects = false;
705  }
706  return returnval;
707 }
708 
709 
710 #if !wxCHECK_VERSION(2,9,0)
711 
712 void a2dObject::Connect( int id, int lastId,
713  int eventType,
714  wxObjectEventFunction func,
715  wxObject* userData,
716  wxEvtHandler* eventSink )
717 {
718 #if WXWIN_COMPATIBILITY_EVENT_TYPES
719  wxEventTableEntry* entry = new wxEventTableEntry;
720  entry->m_eventType = eventType;
721  entry->m_id = id;
722  entry->m_lastId = lastId;
723  entry->m_fn = func;
724  entry->m_callbackUserData = userData;
725 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
727  new a2dDynamicEventTableEntry( eventType, id, lastId, func, userData, eventSink );
728 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
729 
730  if ( !m_dynamicEvents )
731  m_dynamicEvents = new wxList;
732 
733  // Insert at the front of the list so most recent additions are found first
734  m_dynamicEvents->Insert( ( wxObject* ) entry );
735 }
736 
737 bool a2dObject::Disconnect( int id, int lastId, wxEventType eventType,
738  wxObjectEventFunction func,
739  wxObject* userData,
740  wxEvtHandler* eventSink )
741 {
742  if ( !m_dynamicEvents )
743  return false;
744 
745  wxList::compatibility_iterator node = m_dynamicEvents->GetFirst();
746  while ( node )
747  {
748 #if WXWIN_COMPATIBILITY_EVENT_TYPES
749  wxEventTableEntry* entry = ( wxEventTableEntry* )node->GetData();
750 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
751  a2dDynamicEventTableEntry* entry = ( a2dDynamicEventTableEntry* )node->GetData();
752 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
753 
754  wxList::compatibility_iterator nodeerase = node;
755  node = node->GetNext();
756  if ( ( entry->m_id == id ) &&
757  ( ( entry->m_lastId == lastId ) || ( lastId == wxID_ANY ) ) &&
758  ( ( entry->m_eventType == eventType ) || ( eventType == wxEVT_NULL ) ) &&
759  ( ( entry->m_fn == func ) || ( func == ( wxObjectEventFunction )NULL ) ) &&
760  ( ( entry->m_eventSink == eventSink ) || ( eventSink == ( wxEvtHandler* )NULL ) ) &&
761  ( ( entry->m_callbackUserData == userData ) || ( userData == ( wxObject* )NULL ) ) )
762  {
763  entry->m_disconnect = true;
764 
765  if ( !m_iteratorCount )
766  {
767 #if wxCHECK_VERSION(2,9,0)
768  // Remove connection from tracker node (wxEventConnectionRef)
769  wxEvtHandler* eventSink = entry->m_fn->GetEvtHandler();
770  if ( eventSink && eventSink != this )
771  {
772  wxEventConnectionRef* evtConnRef = FindRefInTrackerList( eventSink );
773  if ( evtConnRef )
774  evtConnRef->DecRef();
775  }
776 #endif
777  if ( entry->m_callbackUserData )
778  delete entry->m_callbackUserData;
779  m_dynamicEvents->Erase( nodeerase );
780  delete entry;
781  }
782  else
783  m_pendingDisconnects = true;
784 
785  return true;
786  }
787  }
788  return false;
789 }
790 
791 #else
792 
793 void a2dObject::DoBind( int id,
794  int lastId,
795  wxEventType eventType,
796  wxEventFunctor* func,
797  wxObject* userData )
798 {
800  new a2dDynamicEventTableEntry( eventType, id, lastId, func, userData );
801 
802  if ( !m_dynamicEvents )
803  m_dynamicEvents = new wxList;
804 
805  // Insert at the front of the list so most recent additions are found first
806  m_dynamicEvents->Insert( ( wxObject* ) entry );
807 
808  // Make sure we get to know when a sink is destroyed
809  wxEvtHandler* eventSink = func->GetEvtHandler();
810  if ( eventSink && eventSink != this )
811  {
812  wxEventConnectionRef* evtConnRef = FindRefInTrackerList( eventSink );
813  if ( evtConnRef )
814  evtConnRef->IncRef( );
815  else
816  new wxEventConnectionRef( this, eventSink );
817  }
818 }
819 
820 bool
821 a2dObject::DoUnbind( int id,
822  int lastId,
823  wxEventType eventType,
824  const wxEventFunctor& func,
825  wxObject* userData )
826 {
827  if ( !m_dynamicEvents )
828  return false;
829 
830  wxList::compatibility_iterator node = m_dynamicEvents->GetFirst();
831  while ( node )
832  {
833  a2dDynamicEventTableEntry* entry = ( a2dDynamicEventTableEntry* )node->GetData();
834 
835  if ( ( entry->m_id == id ) &&
836  ( ( entry->m_lastId == lastId ) || ( lastId == wxID_ANY ) ) &&
837  ( ( entry->m_eventType == eventType ) || ( eventType == wxEVT_NULL ) ) &&
838  entry->m_fn->IsMatching( func ) &&
839  ( ( entry->m_callbackUserData == userData ) || !userData ) )
840  {
841  entry->m_disconnect = true;
842  m_pendingDisconnects = true;
843  return true;
844  }
845  node = node->GetNext();
846  }
847  return false;
848 }
849 
850 #endif
851 
852 #endif //WXVALIDEVENTENTRY
853 
854 
855 void a2dObject::ProcessConnectedEvent( wxEvent& event )
856 {
857  if ( a2dGeneralGlobals->GetLogConnectedEvents() )
858  wxLogDebug( wxT( "connect event: id: %d, type: %d on classname = %s" ), event.GetId(), event.GetEventType(), GetClassInfo()->GetClassName() );
859  if ( ProcessEvent( event ) )
860  {
861 
862  //even if the event was handled, and was not skipped,
863  //we want it to skip it here, so the next dynamic connected event
864  //in the calling wxEvtHandler::ProcessEventIfMatches, will be called too.
865  //The signal is typically distributed to all connected classes.
866  event.Skip( true );
867  if ( a2dGeneralGlobals->GetLogConnectedEvents() )
868  wxLogDebug( wxT( " event processed: id: %d, type: %d on classname = %s" ), event.GetId(), event.GetEventType(), GetClassInfo()->GetClassName() );
869  return;
870  }
871  if ( a2dGeneralGlobals->GetLogConnectedEvents() )
872  wxLogDebug( wxT( " event not processed: id: %d, type: %d on classname = %s" ), event.GetId(), event.GetEventType(), GetClassInfo()->GetClassName() );
873  event.Skip( true );
874 }
875 
876 void a2dObject::ConnectEvent( wxEventType type, wxEvtHandler* eventSink )
877 {
878  //check first, if not already there.
879  bool has = false;
880  if ( m_dynamicEvents )
881  {
882  wxList::compatibility_iterator node = m_dynamicEvents->GetFirst();
883  while ( node )
884  {
885  wxDynamicEventTableEntry* entry = ( wxDynamicEventTableEntry* )node->GetData();
886  if ( ( ( entry->m_eventType == type ) || ( type == wxEVT_NULL ) ) &&
887 #if !wxCHECK_VERSION(2,9,0)
888  ( ( entry->m_eventSink == eventSink ) || ( eventSink == ( wxEvtHandler* )NULL ) ) )
889 #else
890  ( eventSink == entry->m_fn->GetEvtHandler() || ( eventSink == ( wxEvtHandler* )NULL ) ) )
891 #endif
892  has = true;
893  node = node->GetNext();
894  }
895  }
896  if ( ! has )
897  Connect( wxID_ANY, wxID_ANY, type, wxObjectEventFunction( &a2dObject::ProcessConnectedEvent ), 0, eventSink );
898 }
899 
900 
901 #if !wxCHECK_VERSION(2,9,0)
902 bool a2dObject::DisconnectEvent( wxEventType eventType, wxEvtHandler* eventSink )
903 {
904  if ( !m_dynamicEvents )
905  return false;
906 
907  int id = wxID_ANY;
908  int lastId = wxID_ANY;
909  wxObjectEventFunction func = wxObjectEventFunction( &a2dObject::ProcessConnectedEvent );
910  wxObject* userData = 0;
911 
912  wxList::compatibility_iterator node = m_dynamicEvents->GetFirst();
913  while ( node )
914  {
915 #ifdef WXVALIDEVENTENTRY
916 
917 #if WXWIN_COMPATIBILITY_EVENT_TYPES
918  wxEventTableEntry* entry = ( wxEventTableEntry* )node->GetData();
919 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
920  wxDynamicEventTableEntry* entry = ( wxDynamicEventTableEntry* )node->GetData();
921 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
922 
923 #else //WXVALIDEVENTENTRY
924 
925 #if WXWIN_COMPATIBILITY_EVENT_TYPES
926  wxEventTableEntry* entry = ( wxEventTableEntry* )node->GetData();
927 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
928  a2dDynamicEventTableEntry* entry = ( a2dDynamicEventTableEntry* )node->GetData();
929 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
930 
931 #endif //WXVALIDEVENTENTRY
932 
933  wxList::compatibility_iterator nodeerase = node;
934  node = node->GetNext();
935  if ( ( entry->m_id == id ) &&
936  ( ( entry->m_lastId == lastId ) || ( lastId == wxID_ANY ) ) &&
937  ( ( entry->m_eventType == eventType ) || ( eventType == wxEVT_NULL ) ) &&
938  ( ( entry->m_fn == func ) || ( func == ( wxObjectEventFunction )NULL ) ) &&
939  ( ( entry->m_eventSink == eventSink ) || ( eventSink == ( wxEvtHandler* )NULL ) ) &&
940  ( ( entry->m_callbackUserData == userData ) || ( userData == ( wxObject* )NULL ) ) )
941  {
942  entry->m_disconnect = true;
943 
944  if ( !m_iteratorCount )
945  {
946 #if wxCHECK_VERSION(2,9,0)
947  // Remove connection from tracker node (wxEventConnectionRef)
948  wxEvtHandler* eventSink = entry->m_fn->GetEvtHandler();
949  if ( eventSink && eventSink != this )
950  {
951  wxEventConnectionRef* evtConnRef = FindRefInTrackerList( eventSink );
952  if ( evtConnRef )
953  evtConnRef->DecRef();
954  }
955 #endif
956  if ( entry->m_callbackUserData )
957  delete entry->m_callbackUserData;
958  m_dynamicEvents->Erase( nodeerase );
959  delete entry;
960  }
961  else
962  m_pendingDisconnects = true;
963 
964  return true;
965  }
966  }
967  return false;
968 }
969 
970 #else //!wxCHECK_VERSION(2,9,0)
971 bool a2dObject::DisconnectEvent( wxEventType eventType, wxEvtHandler* eventSink )
972 {
973  if ( !m_dynamicEvents )
974  return false;
975 
976  int id = wxID_ANY;
977  int lastId = wxID_ANY;
978  const wxEventFunctor& func = wxMakeEventFunctor( eventType, wxObjectEventFunction( &a2dObject::ProcessConnectedEvent ), eventSink );
979  wxObject* userData = 0;
980 
981  wxList::compatibility_iterator node = m_dynamicEvents->GetFirst(), node_nxt;
982  while ( node )
983  {
984  a2dDynamicEventTableEntry* entry = ( a2dDynamicEventTableEntry* )node->GetData();
985  node_nxt = node->GetNext();
986 
987  if ( ( entry->m_id == id ) &&
988  ( ( entry->m_lastId == lastId ) || ( lastId == wxID_ANY ) ) &&
989  ( ( entry->m_eventType == eventType ) || ( eventType == wxEVT_NULL ) ) &&
990  entry->m_fn->IsMatching( func ) &&
991  ( ( entry->m_callbackUserData == userData ) || !userData ) )
992  {
993  entry->m_disconnect = true;
994  if ( !m_iteratorCount )
995  {
996 #if wxCHECK_VERSION(2,9,0)
997  // Remove connection from tracker node (wxEventConnectionRef)
998  wxEvtHandler* eventSink = entry->m_fn->GetEvtHandler();
999  if ( eventSink && eventSink != this )
1000  {
1001  wxEventConnectionRef* evtConnRef = FindRefInTrackerList( eventSink );
1002  if ( evtConnRef )
1003  evtConnRef->DecRef();
1004  }
1005 #endif
1006  if ( entry->m_callbackUserData )
1007  delete entry->m_callbackUserData;
1008  m_dynamicEvents->Erase( node );
1009  delete entry;
1010  }
1011  else
1012  m_pendingDisconnects = true;
1013  return true;
1014  }
1015  node = node_nxt;
1016  }
1017  return false;
1018 }
1019 #endif //!wxCHECK_VERSION(2,9,0)
1020 
1021 bool a2dObject::DisconnectEventAll( wxEvtHandler* eventSink )
1022 {
1023  if ( !m_dynamicEvents )
1024  return false;
1025 
1026 #ifdef WXVALIDEVENTENTRY
1027 
1028  bool did = false;
1029 #if !wxCHECK_VERSION(2,9,0)
1030  wxList::compatibility_iterator node = m_dynamicEvents->GetFirst();
1031  while ( node )
1032  {
1033 #if WXWIN_COMPATIBILITY_EVENT_TYPES
1034  wxEventTableEntry* entry = ( wxEventTableEntry* )node->GetData();
1035 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
1036  wxDynamicEventTableEntry* entry = ( wxDynamicEventTableEntry* )node->GetData();
1037 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
1038 
1039  if ( ( entry->m_eventSink == eventSink ) || ( eventSink == ( wxEvtHandler* )NULL ) )
1040  {
1041  entry->m_disconnect = true;
1042  did = true;
1043  }
1044  node = node->GetNext();
1045  }
1046 #else
1047  wxList::compatibility_iterator node = m_dynamicEvents->GetFirst(), node_nxt;
1048  while ( node )
1049  {
1050  wxDynamicEventTableEntry* entry = ( wxDynamicEventTableEntry* )node->GetData();
1051  node_nxt = node->GetNext();
1052 
1053  if ( entry->m_fn->GetEvtHandler() == eventSink )
1054  {
1055  entry->m_disconnect = true;
1056  did = true;
1057  }
1058  node = node_nxt;
1059  }
1060 #endif
1061 
1062 #else //WXVALIDEVENTENTRY
1063 
1064  bool did = false;
1065 #if !wxCHECK_VERSION(2,9,0)
1066  wxList::compatibility_iterator node = m_dynamicEvents->GetFirst();
1067  while ( node )
1068  {
1069 #if WXWIN_COMPATIBILITY_EVENT_TYPES
1070  wxEventTableEntry* entry = ( wxEventTableEntry* )node->GetData();
1071 #else // !WXWIN_COMPATIBILITY_EVENT_TYPES
1072  a2dDynamicEventTableEntry* entry = ( a2dDynamicEventTableEntry* )node->GetData();
1073 #endif // WXWIN_COMPATIBILITY_EVENT_TYPES/!WXWIN_COMPATIBILITY_EVENT_TYPES
1074 
1075  wxList::compatibility_iterator nodeerase = node;
1076  node = node->GetNext();
1077  if ( ( entry->m_eventSink == eventSink ) || ( eventSink == ( wxEvtHandler* )NULL ) )
1078  {
1079  entry->m_disconnect = true;
1080  if ( !m_iteratorCount )
1081  {
1082 #if wxCHECK_VERSION(2,9,0)
1083  // Remove connection from tracker node (wxEventConnectionRef)
1084  wxEvtHandler* eventSink = entry->m_fn->GetEvtHandler();
1085  if ( eventSink && eventSink != this )
1086  {
1087  wxEventConnectionRef* evtConnRef = FindRefInTrackerList( eventSink );
1088  if ( evtConnRef )
1089  evtConnRef->DecRef();
1090  }
1091 #endif
1092  if ( entry->m_callbackUserData )
1093  delete entry->m_callbackUserData;
1094  m_dynamicEvents->Erase( nodeerase );
1095  delete entry;
1096  }
1097  else
1098  m_pendingDisconnects = true;
1099 
1100  did = true;
1101  }
1102  }
1103 #else
1104  wxList::compatibility_iterator node = m_dynamicEvents->GetFirst(), node_nxt;
1105  while ( node )
1106  {
1107  a2dDynamicEventTableEntry* entry = ( a2dDynamicEventTableEntry* )node->GetData();
1108  wxList::compatibility_iterator nodeerase = node;
1109  node_nxt = node->GetNext();
1110 
1111  if ( entry->m_fn->GetEvtHandler() == eventSink )
1112  {
1113  entry->m_disconnect = true;
1114  if ( !m_iteratorCount )
1115  {
1116 #if wxCHECK_VERSION(2,9,0)
1117  // Remove connection from tracker node (wxEventConnectionRef)
1118  wxEvtHandler* eventSink = entry->m_fn->GetEvtHandler();
1119  if ( eventSink && eventSink != this )
1120  {
1121  wxEventConnectionRef* evtConnRef = FindRefInTrackerList( eventSink );
1122  if ( evtConnRef )
1123  evtConnRef->DecRef();
1124  }
1125 #endif
1126  if ( entry->m_callbackUserData )
1127  delete entry->m_callbackUserData;
1128  m_dynamicEvents->Erase( node );
1129  delete entry;
1130  }
1131  else
1132  m_pendingDisconnects = true;
1133  did = true;
1134  }
1135  node = node_nxt;
1136  }
1137 #endif
1138 
1139 #endif //WXVALIDEVENTENTRY
1140 
1141  return did;
1142 }
1143 
1144 #ifdef _DEBUG
1145 // Here are two globals that can be used as registers in the debugger
1146 a2dObject* _dbro1 = 0;
1147 a2dObject* _dbro2 = 0;
1148 #endif
1149 
1150 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
1151 A2DGENERALDLLEXP_DATA ( wxObject* ) CurrentSmartPointerOwner = 0;
1152 #endif
1153 
1155 
1156 INITIALIZE_PROPERTIES_BASE( a2dObject )
1157 {
1158  PROPID_Check = new a2dPropertyIdBool( wxT( "Check" ),
1160  a2dPropertyIdBool::Get( &a2dObject::GetCheck ),
1161  a2dPropertyIdBool::Set( &a2dObject::SetCheck ) );
1162  AddPropertyId( PROPID_Check );
1164 /*
1165  PROPID_Name = new a2dPropertyIdString( wxT( "Name" ),
1166  a2dPropertyId::flag_isEditable | a2dPropertyId::flag_norender, wxT(""),
1167  a2dPropertyIdString::Get( &a2dObject::GetName ),
1168  a2dPropertyIdString::Set( &a2dObject::SetName ) );
1169  AddPropertyId( PROPID_Name );
1170 
1171 */
1173  A2D_PROPID_D( a2dPropertyIdVoidPtr, autozeroptrlist, 0 );
1174 
1175  return true;
1176 }
1177 
1180 a2dPropertyIdVoidPtr* a2dObject::PROPID_autozeroptrlist = NULL;
1181 
1182 const a2dSignal a2dObject::sm_Edit_properties = wxNewId();
1183 
1185 {
1186  m_refcount = 0;
1187  m_autozeroptrlist = 0;
1188  m_check = false;
1189  m_release = false;
1190  m_recursion_active = false;
1191  m_iteratorCount = 0;
1192  m_pendingDisconnects = false;
1193 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
1194  m_ownerlist = 0;
1195  CurrentSmartPointerOwner = this;
1196 #endif
1197 }
1198 
1200 {
1201  if ( refs ) //&& m_refcount > 1 ) //other do point to this object
1202  {
1203  int id = GetUniqueSerializationId();
1204  wxASSERT( id != 0 );
1205  wxString resolveKey;
1206  resolveKey << id;
1207 
1208  a2dHashMapIntToObject::iterator obj = refs->GetObjectHashMap().find( resolveKey );
1209 
1210  if( obj == refs->GetObjectHashMap().end() )
1211  {
1212  a2dObject* clone = DoClone( options, refs );
1213  refs->GetObjectHashMap()[resolveKey] = clone; //const_cast<a2dObject*>(this);
1214  return clone;
1215  }
1216 
1217  //the object referenced is already cloned return it.
1218  return wxDynamicCast( obj->second, a2dObject );
1219  }
1220  return DoClone( options, refs ); //new a2dObject( *this, options );
1221 }
1222 
1223 a2dObject::a2dObject( const a2dObject& other, CloneOptions options, a2dRefMap* refs )
1224 // private wxEvtHandler( other )
1225 {
1226  m_refcount = 0;
1227  m_autozeroptrlist = 0;
1228  m_check = false;
1229  m_release = false;
1230  m_recursion_active = false;
1231  m_iteratorCount = 0;
1232 
1233 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
1234  m_ownerlist = 0;
1235  CurrentSmartPointerOwner = this;
1236 #endif
1237 
1238  a2dNamedPropertyList::const_iterator iter;
1239  for( iter = other.m_propertylist.begin(); iter != other.m_propertylist.end(); ++iter )
1240  {
1241  const a2dNamedProperty* prop = *iter;
1242  //properties it self are not refcounted, but its data may be, therefore options are also needed there.
1243  m_propertylist.push_back( prop->Clone( options, refs ) );
1244  }
1245 
1246 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
1247  //klion: it is because the CurrentSmartPointerOwner can change in property->Clone()
1248  CurrentSmartPointerOwner = this;
1249 #endif
1250 }
1251 
1252 
1254 {
1255  wxASSERT_MSG( m_refcount == 0 || m_refcount == refcount_nondynamic, wxT( "deleting a2dObject while referenced" ) );
1256  m_autozeroptrlist->TargetDestructing();
1257 }
1258 
1259 void a2dObject:: operator = ( const a2dObject& WXUNUSED( other ) )
1260 {
1261  // m_refcount is not touched
1262  // m_autozerolist is not touched
1263  // m_ownerlist is not touched
1264  // m_recusionactive is not touched
1265  // m_check is not touched
1266 }
1267 
1268 //void a2dObject::operator delete(void* recordptr)
1269 //{
1270 // ::delete recordptr;
1271 //}
1272 
1273 #if wxUSE_STD_IOSTREAM && (defined(__WXDEBUG__) || wxUSE_DEBUG_CONTEXT)
1274 void a2dObject::Dump( wxSTD ostream& str )
1275 {
1276  str << GetUniqueSerializationId();
1277 }
1278 #endif
1279 
1281 {
1282  if ( m_refcount <= 0 )
1283  delete this;
1284 }
1285 
1286 bool a2dObject::SmrtPtrRelease()
1287 {
1288  m_refcount--;
1289  wxASSERT_MSG( m_refcount >= 0, wxT( "a2dObject Own/Release not matched (extra Release calls)" ) );
1290  if ( m_refcount <= 0 )
1291  {
1292  delete this;
1293  return true;
1294  }
1295  return false;
1296 }
1297 
1299 {
1300  wxASSERT_MSG( m_refcount == 0, wxT( "Setting a referenced a2dObject to non-dynamic" ) );
1301  m_refcount += refcount_nondynamic;
1302  return this;
1303 }
1304 
1305 void a2dObject::SetName( const wxString& name )
1306 {
1307  PROPID_Name->SetPropertyToObject( this, name );
1308 }
1309 
1310 wxString a2dObject::GetName() const
1311 {
1312  //first search if a reserved property exists
1313  const a2dNamedProperty* p = FindProperty( PROPID_Name );
1314  if ( p )
1315  return p->StringValueRepresentation();
1316  return wxString::Format( wxT( "%lld" ), GetUniqueSerializationId() );
1317 }
1318 
1319 #if wxART2D_USE_CVGIO
1320 
1322 {
1323  out.WriteStartDocument( wxT( "1.0" ), wxT( "UTF-8" ) , true );
1324 
1325  out.WriteStartElementAttributes( wxT( "cvg" ) );
1326  out.WriteEndAttributes();
1327 
1328  a2dObjectList towrite;
1329  towrite.push_back( this );
1330  a2dObjectList::iterator iter = towrite.begin();
1331  while ( towrite.size() )
1332  {
1333  a2dObject* obj = *iter;
1334  obj->Save( this, out, &towrite );
1335  towrite.erase( iter );
1336  iter = towrite.begin();
1337  }
1338 
1339  out.WriteEndElement();
1340  out.WriteEndDocument();
1341 }
1342 
1343 void a2dObject::Save( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dObjectList* towrite )
1344 {
1345  //only write once, if already written,
1346  if ( m_check == true )
1347  {
1348  //save this object as a reference to another by only writing one id attribute.
1349  out.WriteStartElementAttributes( wxT( "o" ) );
1350  out.WriteAttribute( wxT( "classname" ), GetClassInfo()->GetClassName() );
1351  out.WriteAttribute( wxT( "refid" ), GetUniqueSerializationId() );
1352  out.WriteEndAttributes();
1353  out.WriteEndElement();
1354  return;
1355  }
1356 
1357  if( IsTemporary_DontSave() )
1358  return;
1359 
1360  out.WriteStartElementAttributes( wxT( "o" ) );
1361  out.WriteAttribute( wxT( "classname" ), GetClassInfo()->GetClassName() );
1362  if( m_refcount > 1 || AlwaysWriteSerializationId() )
1363  out.WriteAttribute( wxT( "id" ), GetUniqueSerializationId() );
1364  //the default name is same as address of object, there is no need to save that.
1365  wxString idstr;
1366  idstr << GetUniqueSerializationId();
1367 
1368  if ( GetName() != idstr )
1369  {
1370  const a2dNamedProperty* p = FindProperty( PROPID_Name );
1371  if ( !p )
1372  out.WriteAttribute( wxT( "name" ), GetName() );
1373  }
1374 
1375  DoSave( parent, out, a2dXmlSer_attrib, towrite );
1376 
1377  out.WriteEndAttributes();
1378 
1379  DoSave( parent, out, a2dXmlSer_Content, towrite );
1380 
1381  out.WriteEndElement();
1382  m_check = true;
1383 }
1384 
1386 {
1387  parser.Next();
1388  parser.Require( START_TAG, wxT( "cvg" ) );
1389  parser.Next();
1390 
1391  Load( this, parser );
1392 
1393  parser.Require( END_TAG, wxT( "cvg" ) );
1394 }
1395 
1396 void a2dObject::Load( wxObject* parent, a2dIOHandlerXmlSerIn& parser )
1397 {
1398  parser.Require( START_TAG, wxT( "o" ) );
1399  parser.SetLastObjectLoadedId( wxT( "" ) );
1400 
1401  if ( parser.HasAttribute( wxT( "refid" ) ) )
1402  {
1403  // If the object has a refid, preserve refid in
1404  wxUint32 refId = parser.GetAttributeValueInt( wxT( "refid" ) );
1405 
1406  if ( refId )
1407  {
1408  wxString resolveKey;
1409  resolveKey << refId;
1410  parser.SetLastObjectLoadedId( resolveKey );
1411  }
1412  m_check = true;
1413 
1414  /* If this is needed again for some reason, that's wrong, only a reference id should be enough.
1415  So think twice:
1416  <o classname="a2dArc" refid="4660970"> </o>
1417 
1418  DoLoad( parent, parser, a2dXmlSer_attrib );
1419  parser.Next();
1420 
1421  DoLoad( parent, parser, a2dXmlSer_Content );
1422  */
1423  parser.Next();
1424  parser.Require( END_TAG, wxT( "o" ) );
1425  parser.Next();
1426 
1427  return;
1428  }
1429 
1430  if ( parser.HasAttribute( wxT( "id" ) ) )
1431  {
1432  // If the object has an id, insert the object into the object hash map
1433  int id = parser.GetAttributeValueInt( wxT( "id" ) );
1434  wxASSERT( id != 0 );
1435  wxString resolveKey;
1436  resolveKey << id;
1437  parser.GetObjectHashMap()[resolveKey] = this;
1438  }
1439 
1440  DoLoad( parent, parser, a2dXmlSer_attrib );
1441  parser.Next();
1442 
1443  DoLoad( parent, parser, a2dXmlSer_Content );
1444 
1445  parser.Require( END_TAG, wxT( "o" ) );
1446  parser.Next();
1447 }
1448 #endif //wxART2D_USE_CVGIO
1449 
1451 {
1452  return ( ( wxInt64 ) this ) >> 3;
1453 }
1454 
1456 {
1457  return false;
1458 }
1459 
1460 bool a2dObject::LinkReference( a2dObject* WXUNUSED( other ) )
1461 {
1462  // This should only happen, if the class has put a a2dResolveIdInfo in the list
1463  wxASSERT( 0 );
1464  return false;
1465 }
1466 
1468 {
1469  // This should only happen, if the class has put a a2dResolveIdInfo in the list
1470  wxASSERT( 0 );
1471 }
1472 
1473 void a2dObject::Walker( wxObject* parent, a2dWalkerIOHandler& handler )
1474 {
1475  if ( handler.GetUseCheck() && GetCheck() )
1476  return;
1477 
1478  handler.IncCurrentDepth();
1479 
1480  handler.WalkTask( parent, this, a2dWalker_a2dObjectStart );
1481 
1482  DoWalker( parent, handler );
1483 
1484  handler.WalkTask( parent, this, a2dWalker_a2dObjectEnd );
1485  handler.DecCurrentDepth();
1486 }
1487 
1488 void a2dObject::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
1489 {
1490  handler.WalkTask( parent, this, a2dWalker_a2dPropertyStart );
1491 
1492  if ( !handler.GetStopWalking() )
1493  {
1494  m_propertylist.Walker( this, handler );
1495  }
1496  handler.WalkTask( parent, this, a2dWalker_a2dPropertyEnd );
1497 }
1498 
1499 bool a2dObject::EditProperties( const a2dPropertyId* id, bool withUndo )
1500 {
1501  a2dNamedPropertyList allprops;
1502 
1503  CollectProperties2( &allprops, id, a2dPropertyId::flag_none );
1504 
1505  bool res = false;
1506 
1507  a2dPropertyEditEvent event( this, &allprops );
1508  event.SetEventObject( this );
1509 
1510  // first try the object itself, this makes object specific property editing possible.
1511  ProcessEvent( event );
1512 
1513  if ( event.GetEdited() && !allprops.empty() )
1514  {
1515  res = true;
1516  a2dNamedPropertyList::iterator iter;
1517  for( iter = allprops.begin(); iter != allprops.end(); ++iter )
1518  {
1519  a2dNamedProperty* prop = *iter;
1520  prop->SetToObject( this );
1521  }
1522  }
1523 
1524  return res;
1525 }
1526 
1528 {
1529  if ( !listOfIds )
1530  return;
1531 
1532  forEachIn( a2dPropertyIdList, listOfIds )
1533  {
1534  a2dPropertyId* id = *iter;
1535  a2dNamedProperty* property = from->GetProperty( id );
1536  if ( property )
1537  property->SetToObject( this );
1538  }
1539 }
1540 
1541 bool a2dObject::AddProperty( a2dNamedProperty* property )
1542 {
1543  m_propertylist.push_back( property );
1544  return true;
1545 }
1546 
1547 a2dNamedProperty* a2dObject::FindProperty( const a2dPropertyId* id, a2dPropertyId::Flags flags )
1548 {
1549  a2dNamedPropertyList::iterator iter;
1550  for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
1551  {
1552  a2dNamedProperty* prop = *iter;
1553  if ( id->CheckCollect( prop->GetId(), flags ) )
1554  return prop;
1555  }
1556 
1557  return NULL;
1558 }
1559 
1560 const a2dNamedProperty* a2dObject::FindProperty( const a2dPropertyId* id, a2dPropertyId::Flags flags ) const
1561 {
1562  a2dNamedPropertyList::const_iterator iter;
1563  for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
1564  {
1565  const a2dNamedProperty* prop = *iter;
1566  if ( id->CheckCollect( prop->GetId(), flags ) )
1567  return prop;
1568  }
1569 
1570  return NULL;
1571 }
1572 
1573 bool a2dObject::RemoveProperty( const a2dPropertyId* id, bool all )
1574 {
1575  if( m_propertylist.Remove( id, all ) )
1576  {
1577  OnPropertyChanged( id );
1578  return true;
1579  }
1580  else
1581  return false;
1582 }
1583 
1585 {
1587 }
1588 
1589 
1590 a2dNamedProperty* a2dObject::GetProperty( const a2dPropertyId* propertyId, a2dPropertyId::Flags flags ) const
1591 {
1592  static a2dNamedPropertyPtr returnproperty = NULL;
1593 
1594  // now assemble properties with this id, which is normally just one.
1595  a2dNamedPropertyList props;
1596  CollectProperties2( &props, propertyId, flags );
1597  // normally just one found with this specific Id.
1598  if( props.begin() != props.end() )
1599  returnproperty = *props.begin();
1600  else
1601  returnproperty = NULL;
1602  return returnproperty;
1603 }
1604 
1605 void a2dObject::SetProperty( a2dNamedProperty* propertyHolder, a2dPropertyId::SetFlags setflags )
1606 {
1607  wxASSERT( !m_recursion_active );
1608 
1609  propertyHolder->GetId()->SetNamedPropertyToObject( this, propertyHolder );
1610  OnPropertyChanged( propertyHolder->GetId() );
1611 }
1612 
1613 void a2dObject::SetProperty( const a2dNamedProperty& propertyHolder, a2dPropertyId::SetFlags setflags )
1614 {
1615  wxASSERT( !m_recursion_active );
1616 
1617  propertyHolder.GetId()->SetNamedPropertyToObject( this, const_cast<a2dNamedProperty*>( &propertyHolder ) );
1618  OnPropertyChanged( propertyHolder.GetId() );
1619 }
1620 
1621 bool a2dObject::HasProperty( const a2dPropertyId* id, const wxString& stringvalue ) const
1622 {
1623  if ( ! HasPropertyId( id ) )
1624  return false;
1625 
1626  bool ret = false;
1627  a2dNamedPropertyPtr prop = GetProperty( id );
1628  if ( prop && ! stringvalue.IsEmpty() )
1629  ret = prop->StringValueRepresentation() == stringvalue;
1630  else
1631  ret = prop.Get() != NULL;
1632  return ret;
1633 }
1634 
1636 {
1638  {
1639  a2dComEvent event( this, id, a2dComEvent::sm_changedProperty );
1640  event.SetEventObject( this );
1641  this->ProcessEvent( event );
1642  }
1643 }
1644 
1645 void a2dObject::SetURI( const wxURI& url )
1646 {
1647  PROPID_URI->SetPropertyToObject( this, url );
1648 }
1649 
1650 wxURI a2dObject::GetURI() const
1651 {
1652  return PROPID_URI->GetPropertyValue( this );
1653 }
1654 
1655 #if wxART2D_USE_CVGIO
1656 
1657 void a2dObject::DoSave( wxObject* WXUNUSED( parent ), a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts, a2dObjectList* towrite )
1658 {
1659  if ( xmlparts == a2dXmlSer_attrib )
1660  {
1661  }
1662  else
1663  {
1664  if ( !m_propertylist.empty() )
1665  {
1666  bool onlyTemp = true;
1667  a2dNamedPropertyList::iterator iter;
1668  for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
1669  {
1670  a2dNamedProperty* prop = *iter;
1671  if( !prop->GetId()->IsTemporary() )
1672  onlyTemp = false;
1673  }
1674 
1675  if ( !onlyTemp )
1676  {
1677  out.WriteNewLine();
1678  out.WriteStartElement( wxT( "properties" ) );
1679 
1680 
1681  a2dNamedPropertyList::iterator iter;
1682  for( iter = m_propertylist.begin(); iter != m_propertylist.end(); ++iter )
1683  {
1684  a2dNamedProperty* prop = *iter;
1685  // Don't store temporary properties
1686  if( !prop->GetId()->IsTemporary() )
1687  {
1688  prop->Save( this, out, towrite );
1689  }
1690  }
1691 
1692  out.WriteEndElement();
1693  out.WriteNewLine();
1694  }
1695  }
1696  }
1697 }
1698 
1699 void a2dObject::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
1700 {
1701  if ( xmlparts == a2dXmlSer_attrib )
1702  {
1703  }
1704  else
1705  {
1706  if ( parser.GetTagName() == wxT( "properties" ) )
1707  {
1708  parser.Next();
1709  while( parser.GetTagName() == wxT( "o" ) )
1710  {
1711  wxString classname = parser.GetAttributeValue( wxT( "classname" ) );
1712  wxObject* obj = parser.CreateObject( classname );
1713  a2dNamedPropertyPtr property = wxDynamicCast( obj, a2dNamedProperty );
1714  if ( !property )
1715  {
1716  a2dGeneralGlobals->ReportErrorF( a2dError_XMLparse, _( "could not create a2dNamedProperty %s, will be skipped line %d" ),
1717  classname.c_str(), parser.GetCurrentLineNumber() );
1718  parser.SkipSubTree();
1719  parser.Require( END_TAG, wxT( "o" ) );
1720  parser.Next();
1721  }
1722  else
1723  {
1724  property->Load( this, parser );
1725  property->SetToObject( this );
1726  }
1727  }
1728 
1729  parser.Require( END_TAG, wxT( "properties" ) );
1730  parser.Next();
1731  }
1732  }
1733 }
1734 
1735 #endif //wxART2D_USE_CVGIO
1736 
1737 //----------------------------------------------------------------------------
1738 // a2dNamedProperty
1739 //----------------------------------------------------------------------------
1740 #ifdef _DEBUG
1741 static int _debug_cnt;
1742 #endif
1743 
1744 #ifdef CLASS_MEM_MANAGEMENT
1745 a2dMemManager a2dNamedProperty::sm_memManager( wxT( "a2dNamedProperty memory manager" ) );
1746 #endif //CLASS_MEM_MANAGEMENT
1747 
1749  : m_refcount( 0 )
1750 {
1751 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
1752  m_ownerlist = NULL;
1753 #endif
1754 
1755  m_id = 0;
1756 
1757 #ifdef _DEBUG
1758  _debug_id = _debug_cnt++;
1759  // wxLogDebug( wxT("%p=%d"), this, _debug_id );
1760 #endif
1761 
1762 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
1763  CurrentSmartPointerOwner = this;
1764 #endif
1765 }
1766 
1768  : m_refcount( 0 )
1769 {
1770 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
1771  m_ownerlist = NULL;
1772 #endif
1773  m_id = id;
1774 
1775 #ifdef _DEBUG
1776  _debug_id = _debug_cnt++;
1777  // wxLogDebug( wxT("%p=%d"), this, _debug_id );
1778 #endif
1779 
1780 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
1781  CurrentSmartPointerOwner = this;
1782 #endif
1783 }
1784 
1785 a2dNamedProperty::a2dNamedProperty( const a2dNamedProperty& other )
1786  : wxObject( other ), m_refcount( 0 )
1787 {
1788 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
1789  m_ownerlist = NULL;
1790 #endif
1791  m_id = other.m_id;
1792 
1793 #ifdef _DEBUG
1794  _debug_id = _debug_cnt++;
1795  // wxLogDebug( wxT("%p=%d"), this, _debug_id );
1796 #endif
1797 
1798 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
1799  CurrentSmartPointerOwner = this;
1800 #endif
1801 }
1802 
1804 {
1805 }
1806 
1807 const a2dPropertyId* a2dNamedProperty::CreateId( a2dObject* parent, const wxString& name )
1808 {
1809  a2dPropertyId* propid = parent->HasPropertyId( name );
1810  if ( !propid )
1811  {
1812  wxString error;
1813  error.Printf( wxT( "Property with name: %s has no internal a2dPropertyId, binding this name to an internal property" ), name.c_str() );
1814  a2dGeneralGlobals->ReportErrorF( a2dError_XMLparse, error );
1815  //wxLogWarning(wxT("CVG : property type: %s is not implemented"), classname.c_str() );
1816  }
1817  return propid;
1818 }
1819 
1820 a2dNamedProperty* a2dNamedProperty::Clone( a2dObject::CloneOptions options, a2dRefMap* refs ) const
1821 {
1822  /*
1823  if ( m_refcount > 1 )
1824  {
1825  int id = 1;
1826  wxASSERT( id != 0 );
1827  wxString resolveKey;
1828  resolveKey << id;
1829  parser.GetObjectHashMap()[resolveKey] = this;
1830  }
1831  */
1832 
1833  return DoClone( options, refs );
1834 }
1835 
1836 #if wxART2D_USE_CVGIO
1837 void a2dNamedProperty::Save( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dObjectList* towrite )
1838 {
1839  if( m_id->IsTemporary() )
1840  return;
1841 
1842  out.WriteStartElementAttributes( wxT( "o" ) );
1843  out.WriteAttribute( wxT( "classname" ), GetClassInfo()->GetClassName() );
1844  out.WriteAttribute( wxT( "name" ), m_id->GetName() );
1845 
1846  DoSave( parent, out, a2dXmlSer_attrib, towrite );
1847 
1848  out.WriteEndAttributes();
1849 
1850  DoSave( parent, out, a2dXmlSer_Content, towrite );
1851 
1852  out.WriteEndElement();
1853 }
1854 
1855 
1856 void a2dNamedProperty::Load( wxObject* parent, a2dIOHandlerXmlSerIn& parser )
1857 {
1858  parser.Require( START_TAG, wxT( "o" ) );
1859 
1860  wxString classname;
1861  classname = parser.RequireAttributeValue( wxT( "classname" ) );
1862 
1863  wxString name;
1864  name = parser.RequireAttributeValue( wxT( "name" ) );
1865  a2dObject* propparent = wxStaticCast( parent, a2dObject );
1866 
1867  if ( propparent )
1868  {
1869  const a2dPropertyId* id = CreateId( propparent, name );
1870  if ( !id )
1871  {
1872  parser.SetLastError( a2dGeneralGlobals->GetLastError() );
1873  //wxLogWarning(wxT("CVG : property type: %s is not implemented"), classname.c_str() );
1874  }
1875  }
1876 
1877  DoLoad( parent, parser, a2dXmlSer_attrib );
1878 
1879  parser.Next();
1880 
1881  DoLoad( parent, parser, a2dXmlSer_Content );
1882 
1883  parser.Require( END_TAG, wxT( "o" ) );
1884  parser.Next();
1885 }
1886 #endif //wxART2D_USE_CVGIO
1887 
1888 #if wxART2D_USE_CVGIO
1889 void a2dNamedProperty::DoSave( wxObject* WXUNUSED( parent ), a2dIOHandlerXmlSerOut& WXUNUSED( out ), a2dXmlSer_flag WXUNUSED( xmlparts ), a2dObjectList* WXUNUSED( towrite ) )
1890 {
1891 }
1892 
1893 void a2dNamedProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
1894 {
1895  if ( xmlparts == a2dXmlSer_attrib )
1896  {
1897  wxString name = parser.RequireAttributeValue( wxT( "name" ) );
1898  m_id = wxStaticCast( parent, a2dObject )->HasPropertyId( name );
1899  }
1900  else
1901  {
1902  }
1903 }
1904 #endif //wxART2D_USE_CVGIO
1905 
1906 
1907 void a2dNamedProperty::Walker( wxObject* parent, a2dWalkerIOHandler& handler )
1908 {
1909  handler.WalkTask( parent, this, a2dWalker_a2dNamedPropertyStart );
1910  handler.IncCurrentDepth();
1911 
1912  DoWalker( parent, handler );
1913 
1914  handler.WalkTask( parent, this, a2dWalker_a2dNamedPropertyEnd );
1915  handler.DecCurrentDepth();
1916 }
1917 
1918 void a2dNamedProperty::DoWalker( wxObject* parent, a2dWalkerIOHandler& WXUNUSED( handler ) )
1919 {
1920 }
1921 
1923 {
1924  wxASSERT_MSG( 0, wxT( "Not derived from a2dStringProperty" ) );
1925  return wxT( "" );
1926 }
1927 
1929 {
1930  wxASSERT_MSG( 0, wxT( "Not derived from a2dDoubleProperty" ) );
1931  return 0.0;
1932 }
1933 
1935 {
1936  wxASSERT_MSG( 0, wxT( "Not derived from a2dFloatProperty" ) );
1937  return 0.0;
1938 }
1939 
1941 {
1942  wxASSERT_MSG( 0, wxT( "Not derived from a2dBoolProperty" ) );
1943  return false;
1944 }
1945 
1947 {
1948  wxASSERT_MSG( 0, wxT( "Not derived from a2dInt16Property" ) );
1949  return 0;
1950 }
1951 
1953 {
1954  wxASSERT_MSG( 0, wxT( "Not derived from a2dUint16Property" ) );
1955  return 0;
1956 }
1957 
1959 {
1960  wxASSERT_MSG( 0, wxT( "Not derived from a2dInt32Property" ) );
1961  return 0;
1962 }
1963 
1965 {
1966  wxASSERT_MSG( 0, wxT( "Not derived from a2dUint32Property" ) );
1967  return 0;
1968 }
1969 
1971 {
1972  wxASSERT_MSG( 0, wxT( "Not derived from a2dVoidPtrProperty" ) );
1973  return 0;
1974 }
1975 
1977 {
1978  wxASSERT_MSG( 0, wxT( "Not derived from a2dProperty" ) );
1979  return 0;
1980 }
1981 
1983 {
1984  return 0;
1985 }
1986 
1987 double a2dNamedProperty::ParseDouble( unsigned int& position )
1988 {
1989  const wxChar* buffer = StringValueRepresentation().c_str();
1990 
1991  const wxChar* start = buffer + position;
1992  wxChar* end;
1993  double val = wxStrtod( start, &end );
1994  position = end - buffer;
1995 
1996  if ( start == end )
1997  a2dGeneralGlobals->ReportErrorF( a2dError_NotSpecified, _( "Not a number while parsing string %s" ), start );
1998 
1999  return val;
2000 }
2001 
2002 void a2dNamedProperty::SkipCommaSpaces( unsigned int& position )
2003 {
2004  char current;
2005  for( ;; )
2006  {
2007  current = StringValueRepresentation()[position];
2008  switch ( current )
2009  {
2010  default:
2011  return;
2012  case wxT( ',' ): case 0x20: case 0x09: case 0x0D: case 0x0A:
2013  position++;
2014  break;
2015  }
2016  }
2017 }
2018 
2019 void a2dNamedProperty::SkipSpaces( unsigned int& position )
2020 {
2021  char current;
2022  for( ;; )
2023  {
2024  current = StringValueRepresentation()[position];
2025  switch ( current )
2026  {
2027  default:
2028  return;
2029  case 0x20: case 0x09: case 0x0D: case 0x0A:
2030  position++;
2031  break;
2032  }
2033  }
2034 }
2035 
2036 //----------------------------------------------------------------------------
2037 // a2dNamedPropertyList
2038 //----------------------------------------------------------------------------
2039 
2041 {
2042  // Copy the list of property object
2043 
2044  a2dNamedPropertyList::const_iterator iter;
2045  for( iter = other.begin(); iter != other.end(); ++iter )
2046  {
2047  a2dNamedProperty* obj = *iter;
2048  push_back( obj->Clone( a2dObject::clone_flat ) );
2049 
2050  }
2051 }
2052 
2054 {
2055 }
2056 
2057 bool a2dNamedPropertyList::Remove( const a2dPropertyId* id, bool all )
2058 {
2059  bool did = false;
2060 
2061  a2dNamedPropertyList::iterator iter = begin();
2062  while( iter != end() )
2063  {
2064  a2dNamedProperty* prop = *iter;
2065  if ( prop->GetId() == id )
2066  {
2067  iter = erase( iter );
2068  if ( !all )
2069  {
2070  return true;
2071  }
2072  else
2073  did = true;
2074  }
2075  else
2076  iter++;
2077  }
2078  return did;
2079 }
2080 
2082 {
2083  a2dNamedPropertyList::iterator iter = begin();
2084  while( iter != end() )
2085  {
2086  a2dNamedProperty* prop = *iter;
2087  if ( prop->GetId()->IsTemporary() )
2088  {
2089  iter = erase( iter );
2090  }
2091  else
2092  iter++;
2093  }
2094 }
2095 
2096 void a2dNamedPropertyList::Walker( wxObject* parent, a2dWalkerIOHandler& handler )
2097 {
2098  handler.WalkTask( parent, parent, a2dWalker_a2dNamedPropertyListStart );
2099 
2100  a2dNamedPropertyList::iterator iter = begin();
2101  iter = begin();
2102  while( iter != end() )
2103  {
2104  a2dNamedProperty* prop = *iter;
2105  prop->Walker( parent, handler );
2106  iter++;
2107  }
2108 
2109  handler.WalkTask( parent, parent, a2dWalker_a2dNamedPropertyListEnd );
2110 }
2111 
2112 //----------------------------------------------------------------------------
2113 // a2dBoolProperty
2114 //----------------------------------------------------------------------------
2115 
2116 a2dBoolProperty::a2dBoolProperty(): a2dNamedProperty()
2117 {
2118  m_value = true;
2119 }
2120 
2121 a2dBoolProperty::a2dBoolProperty( const a2dPropertyIdBool* id, bool value )
2122  : a2dNamedProperty( id )
2123 {
2124  m_value = value;
2125 }
2126 
2127 a2dBoolProperty::~a2dBoolProperty()
2128 {
2129 }
2130 
2131 a2dBoolProperty::a2dBoolProperty( const a2dBoolProperty& other, a2dObject::CloneOptions WXUNUSED( options ) )
2132  : a2dNamedProperty( other )
2133 {
2134  m_value = other.m_value;
2135 }
2136 
2137 a2dNamedProperty* a2dBoolProperty::DoClone( a2dObject::CloneOptions options, a2dRefMap* refs ) const
2138 {
2139  return new a2dBoolProperty( *this, options );
2140 };
2141 
2142 void a2dBoolProperty::Assign( const a2dNamedProperty& other )
2143 {
2144  a2dBoolProperty* propcast = wxStaticCast( &other, a2dBoolProperty );
2145  m_value = propcast->m_value;
2146 }
2147 
2148 a2dBoolProperty* a2dBoolProperty::CreatePropertyFromString( const a2dPropertyIdBool* id, const wxString& value )
2149 {
2150  // Remove leading/trailing spaces and convert to lowercase.
2151  wxString lower = value.Lower().Trim( true ).Trim( false );
2152  // Notice that _("yes") is different from wxT("yes"),since it allows for i18n, so it could read as wxT("ja").
2153  bool val = ( lower == wxT( "true" ) ) || ( lower == wxT( "yes" ) ) || ( lower == wxT( "y" ) ) || ( lower == wxT( "1" ) ) || ( lower == _( "yes" ) );
2154 
2155  return new a2dBoolProperty( id, val );
2156 }
2157 
2158 
2159 const a2dPropertyId* a2dBoolProperty::CreateId( a2dObject* parent, const wxString& name )
2160 {
2161  a2dPropertyIdBool* propid = ( a2dPropertyIdBool* ) parent->HasPropertyId( name );
2162  if ( !propid )
2163  {
2164  propid = new a2dPropertyIdBool( name, false, a2dPropertyId::flag_userDefined );
2165  parent->AddPropertyId( propid );
2166  }
2167  return propid;
2168 }
2169 
2170 #if wxART2D_USE_CVGIO
2171 void a2dBoolProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
2172 {
2173  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
2174  if ( xmlparts == a2dXmlSer_attrib )
2175  {
2176  out.WriteAttribute( wxT( "value" ), m_value );
2177  }
2178  else
2179  {
2180  }
2181 }
2182 
2183 void a2dBoolProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
2184 {
2185  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
2186  if ( xmlparts == a2dXmlSer_attrib )
2187  {
2188  m_value = parser.GetAttributeValueBool( wxT( "value" ), true );
2189  }
2190  else
2191  {
2192  }
2193 }
2194 #endif //wxART2D_USE_CVGIO
2195 
2196 void a2dBoolProperty::SetValue( bool value )
2197 {
2198  m_value = value;
2199 }
2200 
2202 {
2203  return m_value == true ? GetName() + wxT( "true" ) : GetName() + wxT( "false" );
2204 }
2205 
2207 {
2208  return m_value == true ? wxT( "true" ) : wxT( "false" );
2209 }
2210 
2211 //----------------------------------------------------------------------------
2212 // a2dStringProperty
2213 //----------------------------------------------------------------------------
2214 
2215 a2dStringProperty::a2dStringProperty(): a2dNamedProperty()
2216 {
2217  m_value = wxT( "" );
2218 }
2219 
2220 a2dStringProperty::a2dStringProperty( const a2dPropertyIdString* id, const wxString& value )
2221  : a2dNamedProperty( id )
2222 {
2223  m_value = value;
2224 }
2225 
2226 a2dStringProperty::~a2dStringProperty()
2227 {
2228 }
2229 
2230 a2dStringProperty::a2dStringProperty( const a2dStringProperty& other, a2dObject::CloneOptions WXUNUSED( options ) )
2231  : a2dNamedProperty( other )
2232 {
2233  m_value = other.m_value;
2234 }
2235 
2236 a2dNamedProperty* a2dStringProperty::DoClone( a2dObject::CloneOptions options, a2dRefMap* refs ) const
2237 {
2238  return new a2dStringProperty( *this, options );
2239 };
2240 
2241 void a2dStringProperty::Assign( const a2dNamedProperty& other )
2242 {
2243  a2dStringProperty* propcast = wxStaticCast( &other, a2dStringProperty );
2244  m_value = propcast->m_value;
2245 }
2246 
2247 a2dStringProperty* a2dStringProperty::CreatePropertyFromString( const a2dPropertyIdString* id, const wxString& value )
2248 {
2249  return new a2dStringProperty( id, value );
2250 }
2251 
2252 #if wxART2D_USE_CVGIO
2253 void a2dStringProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
2254 {
2255  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
2256  if ( xmlparts == a2dXmlSer_attrib )
2257  {
2258  out.WriteAttribute( wxT( "value" ), m_value );
2259  }
2260  else
2261  {
2262  }
2263 }
2264 
2265 void a2dStringProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
2266 {
2267  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
2268  if ( xmlparts == a2dXmlSer_attrib )
2269  {
2270  m_value = parser.GetAttributeValue( wxT( "value" ), wxT( "" ) );
2271  }
2272  else
2273  {
2274  }
2275 }
2276 #endif //wxART2D_USE_CVGIO
2277 
2278 void a2dStringProperty::SetValue( const wxString& value )
2279 {
2280  m_value = value;
2281 }
2282 
2283 const a2dPropertyId* a2dStringProperty::CreateId( a2dObject* parent, const wxString& name )
2284 {
2285  a2dPropertyIdString* propid = ( a2dPropertyIdString* ) parent->HasPropertyId( name );
2286  if ( !propid )
2287  {
2288  propid = new a2dPropertyIdString( name, wxT( "" ), a2dPropertyId::flag_userDefined );
2289  parent->AddPropertyId( propid );
2290  }
2291  return propid;
2292 }
2293 
2294 //----------------------------------------------------------------------------
2295 // a2dObjectProperty
2296 //----------------------------------------------------------------------------
2297 
2298 a2dObjectProperty::a2dObjectProperty(): a2dNamedProperty()
2299 {
2300 }
2301 
2302 a2dObjectProperty::a2dObjectProperty( const a2dPropertyIdObject* id, const wxObject& value )
2303  : a2dNamedProperty( id )
2304 {
2305  m_value = value;
2306 }
2307 
2308 a2dObjectProperty::~a2dObjectProperty()
2309 {
2310 }
2311 
2312 a2dObjectProperty::a2dObjectProperty( const a2dObjectProperty& other )
2313  : a2dNamedProperty( other )
2314 {
2315  m_value = other.m_value;
2316 }
2317 
2318 a2dNamedProperty* a2dObjectProperty::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
2319 {
2320  return new a2dObjectProperty( *this );
2321 };
2322 
2323 void a2dObjectProperty::Assign( const a2dNamedProperty& other )
2324 {
2325  a2dObjectProperty* propcast = wxStaticCast( &other, a2dObjectProperty );
2326  m_value = propcast->m_value;
2327 }
2328 
2329 void a2dObjectProperty::SetValue( const wxObject& value )
2330 {
2331  m_value = value;
2332 }
2333 
2334 //----------------------------------------------------------------------------
2335 // a2dVoidPtrProperty
2336 //----------------------------------------------------------------------------
2337 
2338 a2dVoidPtrProperty::a2dVoidPtrProperty(): a2dNamedProperty()
2339 {
2340  m_value = NULL;
2341 }
2342 
2343 a2dVoidPtrProperty::a2dVoidPtrProperty( const a2dPropertyIdVoidPtr* id, void* value )
2344  : a2dNamedProperty( id )
2345 {
2346  m_value = value;
2347 }
2348 
2349 a2dVoidPtrProperty::~a2dVoidPtrProperty()
2350 {
2351 }
2352 
2353 a2dVoidPtrProperty::a2dVoidPtrProperty( const a2dVoidPtrProperty& other )
2354  : a2dNamedProperty( other )
2355 {
2356  m_value = other.m_value;
2357 }
2358 
2359 a2dNamedProperty* a2dVoidPtrProperty::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
2360 {
2361  return new a2dVoidPtrProperty( *this );
2362 };
2363 
2364 void a2dVoidPtrProperty::Assign( const a2dNamedProperty& other )
2365 {
2366  a2dVoidPtrProperty* propcast = wxStaticCast( &other, a2dVoidPtrProperty );
2367  m_value = propcast->m_value;
2368 }
2369 
2370 a2dVoidPtrProperty* a2dVoidPtrProperty::CreatePropertyFromString( const a2dPropertyIdVoidPtr* WXUNUSED( id ), const wxString& WXUNUSED( value ) )
2371 {
2372  return 0;
2373 }
2374 
2375 #if wxART2D_USE_CVGIO
2376 void a2dVoidPtrProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
2377 {
2378  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
2379  if ( xmlparts == a2dXmlSer_attrib )
2380  {
2381  out.WriteAttribute( wxT( "value" ), wxT( "VOID" ) );
2382  }
2383  else
2384  {
2385  }
2386 }
2387 
2388 void a2dVoidPtrProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
2389 {
2390  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
2391  if ( xmlparts == a2dXmlSer_attrib )
2392  {
2393  m_value = NULL;
2394  }
2395  else
2396  {
2397  }
2398 }
2399 #endif //wxART2D_USE_CVGIO
2400 
2401 void a2dVoidPtrProperty::SetValue( void* value )
2402 {
2403  m_value = value;
2404 }
2405 
2407 {
2408  return m_value == 0 ? GetName() + wxT( "NULL" ) : GetName() + wxT( "VOID" );
2409 }
2410 
2412 {
2413  return m_value == 0 ? wxT( "NULL" ) : wxT( "VOID" );
2414 }
2415 
2416 //----------------------------------------------------------------------------
2417 // a2dProperty
2418 //----------------------------------------------------------------------------
2419 
2420 a2dProperty::a2dProperty(): a2dNamedProperty()
2421 {
2422  m_value = NULL;
2423 }
2424 
2425 a2dProperty::a2dProperty( const a2dPropertyIdRefObject* id, a2dObject* value )
2426  : a2dNamedProperty( id )
2427 {
2428  m_value = value;
2429 }
2430 
2431 a2dProperty::~a2dProperty()
2432 {
2433 }
2434 
2435 a2dProperty::a2dProperty( const a2dProperty& other, a2dObject::CloneOptions options )
2436  : a2dNamedProperty( other )
2437 {
2438  if ( options & a2dObject::clone_properties && m_id->IsCloneDeep() )
2439  {
2440  if ( other.m_value )
2441  m_value = other.m_value->Clone( options );
2442  }
2443  else
2444  m_value = other.m_value;
2445 
2446 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
2447  //klion: it is because the CurrentSmartPointerOwner can change in Clone ( )
2448  CurrentSmartPointerOwner = this;
2449 #endif
2450 }
2451 
2452 a2dNamedProperty* a2dProperty::DoClone( a2dObject::CloneOptions options, a2dRefMap* refs ) const
2453 {
2454  return new a2dProperty( *this, options );
2455 };
2456 
2457 void a2dProperty::Assign( const a2dNamedProperty& other )
2458 {
2459  a2dProperty* propcast = wxStaticCast( &other, a2dProperty );
2460  m_value = propcast->m_value;
2461 }
2462 
2463 a2dProperty* a2dProperty::CreatePropertyFromString( const a2dPropertyIdRefObject* WXUNUSED( id ), const wxString& WXUNUSED( value ) )
2464 {
2465  return 0;
2466 }
2467 
2468 #if wxART2D_USE_CVGIO
2469 void a2dProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
2470 {
2471  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
2472  if ( xmlparts == a2dXmlSer_attrib )
2473  {
2474  }
2475  else
2476  {
2477  if ( m_value )
2478  m_value->Save( parent, out, towrite );
2479  }
2480 }
2481 
2482 void a2dProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
2483 {
2484  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
2485  if ( xmlparts == a2dXmlSer_attrib )
2486  {
2487  m_value = NULL;
2488  }
2489  else
2490  {
2491  if ( parser.GetTagName() == wxT( "o" ) && parser.GetEventType() != END_TAG )
2492  {
2493  parser.Require( START_TAG, wxT( "o" ) );
2494 
2495  wxString classname = parser.GetAttributeValue( wxT( "classname" ) );
2496  m_value = wxDynamicCast( parser.CreateObject( classname ), a2dObject );
2497  if ( !m_value )
2498  {
2499  a2dGeneralGlobals->ReportErrorF( a2dError_XMLparse, _( "could not create a2dObject %s, will be skipped line %d" ),
2500  classname.c_str(), parser.GetCurrentLineNumber() );
2501  parser.SetLastError( a2dGeneralGlobals->GetLastError() );
2502 
2503  parser.SkipSubTree();
2504  parser.Require( END_TAG, wxT( "o" ) );
2505  parser.Next();
2506  }
2507  else
2508  {
2509  m_value->Load( this, parser );
2510  parser.ResolveOrAdd( &m_value );
2511  }
2512 
2513  }
2514  }
2515 }
2516 #endif //wxART2D_USE_CVGIO
2517 
2518 void a2dProperty::SetValue( a2dObject* value )
2519 {
2520  m_value = value;
2521 }
2522 
2524 {
2525  return m_value ? GetName() + wxT( "NULL" ) : GetName() + wxT( "RefObject" );
2526 }
2527 
2529 {
2530  return m_value ? wxT( "NULL" ) : wxT( "RefObject" );
2531 }
2532 
2533 //----------------------------------------------------------------------------
2534 // a2dAutoZeroProperty
2535 //----------------------------------------------------------------------------
2536 
2537 a2dAutoZeroProperty::a2dAutoZeroProperty(): a2dNamedProperty()
2538 {
2539  m_value = NULL;
2540 }
2541 
2542 a2dAutoZeroProperty::a2dAutoZeroProperty( const a2dPropertyIdRefObjectAutoZero* id, a2dObject* value )
2543  : a2dNamedProperty( id )
2544 {
2545  m_value = value;
2546 }
2547 
2548 a2dAutoZeroProperty::~a2dAutoZeroProperty()
2549 {
2550 }
2551 
2552 a2dAutoZeroProperty::a2dAutoZeroProperty( const a2dAutoZeroProperty& other, a2dObject::CloneOptions options )
2553  : a2dNamedProperty( other )
2554 {
2555  if ( options & a2dObject::clone_properties && m_id->IsCloneDeep() )
2556  {
2557  if ( other.m_value )
2558  m_value = other.m_value->Clone( options );
2559  }
2560  else
2561  m_value = other.m_value;
2562 
2563 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
2564  //klion: it is because the CurrentSmartPointerOwner can change in Clone ( )
2565  CurrentSmartPointerOwner = this;
2566 #endif
2567 }
2568 
2569 a2dNamedProperty* a2dAutoZeroProperty::DoClone( a2dObject::CloneOptions options, a2dRefMap* refs ) const
2570 {
2571  return new a2dAutoZeroProperty( *this, options );
2572 };
2573 
2574 void a2dAutoZeroProperty::Assign( const a2dNamedProperty& other )
2575 {
2576  a2dAutoZeroProperty* propcast = wxStaticCast( &other, a2dAutoZeroProperty );
2577  m_value = propcast->m_value;
2578 }
2579 
2580 a2dAutoZeroProperty* a2dAutoZeroProperty::CreatePropertyFromString( const a2dPropertyIdRefObjectAutoZero* WXUNUSED( id ), const wxString& WXUNUSED( value ) )
2581 {
2582  return 0;
2583 }
2584 
2585 #if wxART2D_USE_CVGIO
2586 void a2dAutoZeroProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
2587 {
2588  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
2589  if ( xmlparts == a2dXmlSer_attrib )
2590  {
2591  }
2592  else
2593  {
2594  if ( m_value )
2595  m_value->Save( parent, out, towrite );
2596  }
2597 }
2598 
2599 void a2dAutoZeroProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
2600 {
2601  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
2602  if ( xmlparts == a2dXmlSer_attrib )
2603  {
2604  m_value = NULL;
2605  }
2606  else
2607  {
2608  if ( parser.GetTagName() == wxT( "o" ) && parser.GetEventType() != END_TAG )
2609  {
2610  parser.Require( START_TAG, wxT( "o" ) );
2611 
2612  wxString classname = parser.GetAttributeValue( wxT( "classname" ) );
2613  m_value = wxStaticCast( parser.CreateObject( classname ), a2dObject );
2614  if ( !m_value )
2615  {
2616  a2dGeneralGlobals->ReportErrorF( a2dError_XMLparse, _( "could not create a2dObject %s, will be skipped line %d" ),
2617  classname.c_str(), parser.GetCurrentLineNumber() );
2618  parser.SkipSubTree();
2619  parser.Require( END_TAG, wxT( "o" ) );
2620  parser.Next();
2621  }
2622  else
2623  {
2624  m_value->Load( this, parser );
2625  parser.ResolveOrAdd( &m_value );
2626  }
2627 
2628  }
2629  }
2630 }
2631 #endif //wxART2D_USE_CVGIO
2632 
2633 void a2dAutoZeroProperty::SetValue( a2dObject* value )
2634 {
2635  m_value = value;
2636 }
2637 
2639 {
2640  return m_value ? GetName() + wxT( "NULL" ) : GetName() + wxT( "RefObject" );
2641 }
2642 
2644 {
2645  return m_value ? wxT( "NULL" ) : wxT( "RefObject" );
2646 }
2647 
2648 //----------------------------------------------------------------------------
2649 // a2dInt16Property
2650 //----------------------------------------------------------------------------
2651 
2652 a2dInt16Property::a2dInt16Property(): a2dNamedProperty()
2653 {
2654  m_value = 0;
2655 }
2656 
2657 a2dInt16Property::a2dInt16Property( const a2dPropertyIdInt16* id, wxInt16 value )
2658  : a2dNamedProperty( id )
2659 {
2660  m_value = value;
2661 }
2662 
2663 a2dInt16Property::~a2dInt16Property()
2664 {
2665 }
2666 
2667 a2dInt16Property::a2dInt16Property( const a2dInt16Property& other )
2668  : a2dNamedProperty( other )
2669 {
2670  m_value = other.m_value;
2671 }
2672 
2673 a2dNamedProperty* a2dInt16Property::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
2674 {
2675  return new a2dInt16Property( *this );
2676 };
2677 
2678 void a2dInt16Property::Assign( const a2dNamedProperty& other )
2679 {
2680  a2dInt16Property* propcast = wxStaticCast( &other, a2dInt16Property );
2681  m_value = propcast->m_value;
2682 }
2683 
2684 a2dInt16Property* a2dInt16Property::CreatePropertyFromString( const a2dPropertyIdInt16* id, const wxString& value )
2685 {
2686  long intval;
2687  value.ToLong( &intval , 10 );
2688  return new a2dInt16Property( id, intval );
2689 }
2690 
2691 #if wxART2D_USE_CVGIO
2692 void a2dInt16Property::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
2693 {
2694  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
2695  if ( xmlparts == a2dXmlSer_attrib )
2696  {
2697  out.WriteAttribute( wxT( "value" ), m_value );
2698  }
2699  else
2700  {
2701  }
2702 }
2703 
2704 void a2dInt16Property::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
2705 {
2706  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
2707  if ( xmlparts == a2dXmlSer_attrib )
2708  {
2709  m_value = parser. GetAttributeValueInt( wxT( "value" ), 0 );
2710  }
2711  else
2712  {
2713  }
2714 }
2715 #endif //wxART2D_USE_CVGIO
2716 
2717 void a2dInt16Property::SetValue( wxInt16 value )
2718 {
2719  m_value = value;
2720 }
2721 
2723 {
2724  wxString form;
2725  form.Printf( wxT( "%s = %d" ), GetName().c_str(), m_value );
2726  return form;
2727 }
2728 
2730 {
2731  wxString form;
2732  form.Printf( wxT( "%d" ), m_value );
2733  return form;
2734 }
2735 
2736 //----------------------------------------------------------------------------
2737 // a2dUint16Property
2738 //----------------------------------------------------------------------------
2739 
2740 a2dUint16Property::a2dUint16Property(): a2dNamedProperty()
2741 {
2742  m_value = 0;
2743 }
2744 
2745 a2dUint16Property::a2dUint16Property( const a2dPropertyIdUint16* id, wxUint16 value )
2746  : a2dNamedProperty( id )
2747 {
2748  m_value = value;
2749 }
2750 
2751 a2dUint16Property::~a2dUint16Property()
2752 {
2753 }
2754 
2755 a2dUint16Property::a2dUint16Property( const a2dUint16Property& other )
2756  : a2dNamedProperty( other )
2757 {
2758  m_value = other.m_value;
2759 }
2760 
2761 a2dNamedProperty* a2dUint16Property::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
2762 {
2763  return new a2dUint16Property( *this );
2764 };
2765 
2766 void a2dUint16Property::Assign( const a2dNamedProperty& other )
2767 {
2768  a2dUint16Property* propcast = wxStaticCast( &other, a2dUint16Property );
2769  m_value = propcast->m_value;
2770 }
2771 
2772 a2dUint16Property* a2dUint16Property::CreatePropertyFromString( const a2dPropertyIdUint16* id, const wxString& value )
2773 {
2774  unsigned long intval;
2775  value.ToULong( &intval , 10 );
2776  return new a2dUint16Property( id, intval );
2777 }
2778 
2779 #if wxART2D_USE_CVGIO
2780 void a2dUint16Property::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
2781 {
2782  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
2783  if ( xmlparts == a2dXmlSer_attrib )
2784  {
2785  out.WriteAttribute( wxT( "value" ), m_value );
2786  }
2787  else
2788  {
2789  }
2790 }
2791 
2792 void a2dUint16Property::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
2793 {
2794  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
2795  if ( xmlparts == a2dXmlSer_attrib )
2796  {
2797  m_value = parser. GetAttributeValueInt( wxT( "value" ), 0 );
2798  }
2799  else
2800  {
2801  }
2802 }
2803 #endif //wxART2D_USE_CVGIO
2804 
2805 void a2dUint16Property::SetValue( wxUint16 value )
2806 {
2807  m_value = value;
2808 }
2809 
2811 {
2812  wxString form;
2813  form.Printf( wxT( "%s = %d" ), GetName().c_str(), m_value );
2814  return form;
2815 }
2816 
2818 {
2819  wxString form;
2820  form.Printf( wxT( "%d" ), m_value );
2821  return form;
2822 }
2823 
2824 //----------------------------------------------------------------------------
2825 // a2dInt32Property
2826 //----------------------------------------------------------------------------
2827 
2828 a2dInt32Property::a2dInt32Property(): a2dNamedProperty()
2829 {
2830  m_value = 0;
2831 }
2832 
2833 a2dInt32Property::a2dInt32Property( const a2dPropertyIdInt32* id, wxInt32 value )
2834  : a2dNamedProperty( id )
2835 {
2836  m_value = value;
2837 }
2838 
2839 a2dInt32Property::~a2dInt32Property()
2840 {
2841 }
2842 
2843 a2dInt32Property::a2dInt32Property( const a2dInt32Property& other )
2844  : a2dNamedProperty( other )
2845 {
2846  m_value = other.m_value;
2847 }
2848 
2849 a2dNamedProperty* a2dInt32Property::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
2850 {
2851  return new a2dInt32Property( *this );
2852 };
2853 
2854 void a2dInt32Property::Assign( const a2dNamedProperty& other )
2855 {
2856  a2dInt32Property* propcast = wxStaticCast( &other, a2dInt32Property );
2857  m_value = propcast->m_value;
2858 }
2859 
2860 a2dInt32Property* a2dInt32Property::CreatePropertyFromString( const a2dPropertyIdInt32* id, const wxString& value )
2861 {
2862  long intval;
2863  value.ToLong( &intval , 10 );
2864  return new a2dInt32Property( id, intval );
2865 }
2866 
2867 #if wxART2D_USE_CVGIO
2868 void a2dInt32Property::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
2869 {
2870  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
2871  if ( xmlparts == a2dXmlSer_attrib )
2872  {
2873  out.WriteAttribute( wxT( "value" ), m_value );
2874  }
2875  else
2876  {
2877  }
2878 }
2879 
2880 void a2dInt32Property::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
2881 {
2882  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
2883  if ( xmlparts == a2dXmlSer_attrib )
2884  {
2885  m_value = parser. GetAttributeValueInt( wxT( "value" ), 0 );
2886  }
2887  else
2888  {
2889  }
2890 }
2891 #endif //wxART2D_USE_CVGIO
2892 
2893 void a2dInt32Property::SetValue( wxInt32 value )
2894 {
2895  m_value = value;
2896 }
2897 
2899 {
2900  wxString form;
2901  form.Printf( wxT( "%s = %d" ), GetName().c_str(), m_value );
2902  return form;
2903 }
2904 
2906 {
2907  wxString form;
2908  form.Printf( wxT( "%d" ), m_value );
2909  return form;
2910 }
2911 
2912 const a2dPropertyId* a2dInt32Property::CreateId( a2dObject* parent, const wxString& name )
2913 {
2914  a2dPropertyIdInt32* propid = ( a2dPropertyIdInt32* ) parent->HasPropertyId( name );
2915  if ( !propid )
2916  {
2917  propid = new a2dPropertyIdInt32( name, 0, a2dPropertyId::flag_userDefined );
2918  parent->AddPropertyId( propid );
2919  }
2920  return propid;
2921 }
2922 
2923 //----------------------------------------------------------------------------
2924 // a2dUint32Property
2925 //----------------------------------------------------------------------------
2926 
2927 a2dUint32Property::a2dUint32Property(): a2dNamedProperty()
2928 {
2929  m_value = 0;
2930 }
2931 
2932 a2dUint32Property::a2dUint32Property( const a2dPropertyIdUint32* id, wxUint32 value )
2933  : a2dNamedProperty( id )
2934 {
2935  m_value = value;
2936 }
2937 
2938 a2dUint32Property::~a2dUint32Property()
2939 {
2940 }
2941 
2942 a2dUint32Property::a2dUint32Property( const a2dUint32Property& other )
2943  : a2dNamedProperty( other )
2944 {
2945  m_value = other.m_value;
2946 }
2947 
2948 a2dNamedProperty* a2dUint32Property::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
2949 {
2950  return new a2dUint32Property( *this );
2951 };
2952 
2953 void a2dUint32Property::Assign( const a2dNamedProperty& other )
2954 {
2955  a2dUint32Property* propcast = wxStaticCast( &other, a2dUint32Property );
2956  m_value = propcast->m_value;
2957 }
2958 
2959 a2dUint32Property* a2dUint32Property::CreatePropertyFromString( const a2dPropertyIdUint32* id, const wxString& value )
2960 {
2961  unsigned long intval;
2962  value.ToULong( &intval , 10 );
2963  return new a2dUint32Property( id, intval );
2964 }
2965 
2966 #if wxART2D_USE_CVGIO
2967 void a2dUint32Property::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
2968 {
2969  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
2970  if ( xmlparts == a2dXmlSer_attrib )
2971  {
2972  out.WriteAttribute( wxT( "value" ), m_value );
2973  }
2974  else
2975  {
2976  }
2977 }
2978 
2979 void a2dUint32Property::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
2980 {
2981  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
2982  if ( xmlparts == a2dXmlSer_attrib )
2983  {
2984  m_value = parser. GetAttributeValueInt( wxT( "value" ), 0 );
2985  }
2986  else
2987  {
2988  }
2989 }
2990 #endif //wxART2D_USE_CVGIO
2991 
2992 void a2dUint32Property::SetValue( wxUint32 value )
2993 {
2994  m_value = value;
2995 }
2996 
2998 {
2999  wxString form;
3000  form.Printf( wxT( "%s = %d" ), GetName().c_str(), m_value );
3001  return form;
3002 }
3003 
3005 {
3006  wxString form;
3007  form.Printf( wxT( "%d" ), m_value );
3008  return form;
3009 }
3010 
3011 //----------------------------------------------------------------------------
3012 // a2dDoubleProperty
3013 //----------------------------------------------------------------------------
3014 
3015 a2dDoubleProperty::a2dDoubleProperty(): a2dNamedProperty()
3016 {
3017  m_value = 0.0;
3018 }
3019 
3020 a2dDoubleProperty::a2dDoubleProperty( const a2dPropertyIdDouble* id, double value )
3021  : a2dNamedProperty( id )
3022 {
3023  m_value = value;
3024 }
3025 
3026 a2dDoubleProperty::~a2dDoubleProperty()
3027 {
3028 }
3029 
3030 a2dDoubleProperty::a2dDoubleProperty( const a2dDoubleProperty& other )
3031  : a2dNamedProperty( other )
3032 {
3033  m_value = other.m_value;
3034 }
3035 
3036 a2dNamedProperty* a2dDoubleProperty::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
3037 {
3038  return new a2dDoubleProperty( *this );
3039 };
3040 
3041 void a2dDoubleProperty::Assign( const a2dNamedProperty& other )
3042 {
3043  a2dDoubleProperty* propcast = wxStaticCast( &other, a2dDoubleProperty );
3044  m_value = propcast->m_value;
3045 }
3046 
3047 a2dDoubleProperty* a2dDoubleProperty::CreatePropertyFromString( const a2dPropertyIdDouble* id, const wxString& value )
3048 {
3049  double doubleval;
3050  value.ToDouble( &doubleval );
3051  return new a2dDoubleProperty( id, doubleval );
3052 }
3053 
3054 #if wxART2D_USE_CVGIO
3055 void a2dDoubleProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
3056 {
3057  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
3058  if ( xmlparts == a2dXmlSer_attrib )
3059  {
3060  out.WriteAttribute( wxT( "value" ), m_value );
3061  }
3062  else
3063  {
3064  }
3065 }
3066 
3067 void a2dDoubleProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
3068 {
3069  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
3070  if ( xmlparts == a2dXmlSer_attrib )
3071  {
3072  m_value = parser. GetAttributeValueDouble( wxT( "value" ), 0 );
3073  }
3074  else
3075  {
3076  }
3077 }
3078 #endif //wxART2D_USE_CVGIO
3079 
3080 void a2dDoubleProperty::SetValue( double value )
3081 {
3082  m_value = value;
3083 }
3084 
3086 {
3087  wxString form;
3088  form.Printf( wxT( "%s = %6.3f" ), GetName().c_str(), m_value );
3089  return form;
3090 }
3091 
3093 {
3094  wxString form;
3095  //form.Printf( wxT("%6.3f"), m_value );
3096  form.Printf( wxT( "%g" ), m_value );
3097  return form;
3098 }
3099 
3100 //----------------------------------------------------------------------------
3101 // a2dFloatProperty
3102 //----------------------------------------------------------------------------
3103 
3104 a2dFloatProperty::a2dFloatProperty(): a2dNamedProperty()
3105 {
3106  m_value = 0.0;
3107 }
3108 
3109 a2dFloatProperty::a2dFloatProperty( const a2dPropertyIdFloat* id, float value )
3110  : a2dNamedProperty( id )
3111 {
3112  m_value = value;
3113 }
3114 
3115 a2dFloatProperty::~a2dFloatProperty()
3116 {
3117 }
3118 
3119 a2dFloatProperty::a2dFloatProperty( const a2dFloatProperty& other )
3120  : a2dNamedProperty( other )
3121 {
3122  m_value = other.m_value;
3123 }
3124 
3125 a2dNamedProperty* a2dFloatProperty::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
3126 {
3127  return new a2dFloatProperty( *this );
3128 };
3129 
3130 void a2dFloatProperty::Assign( const a2dNamedProperty& other )
3131 {
3132  a2dFloatProperty* propcast = wxStaticCast( &other, a2dFloatProperty );
3133  m_value = propcast->m_value;
3134 }
3135 
3136 a2dFloatProperty* a2dFloatProperty::CreatePropertyFromString( const a2dPropertyIdFloat* id, const wxString& value )
3137 {
3138  double doubleval;
3139  value.ToDouble( &doubleval );
3140  return new a2dFloatProperty( id, ( float ) doubleval );
3141 }
3142 
3143 #if wxART2D_USE_CVGIO
3144 void a2dFloatProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
3145 {
3146  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
3147  if ( xmlparts == a2dXmlSer_attrib )
3148  {
3149  out.WriteAttribute( wxT( "value" ), m_value );
3150  }
3151  else
3152  {
3153  }
3154 }
3155 
3156 void a2dFloatProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
3157 {
3158  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
3159  if ( xmlparts == a2dXmlSer_attrib )
3160  {
3161  m_value = parser. GetAttributeValueDouble( wxT( "value" ), 0 );
3162  }
3163  else
3164  {
3165  }
3166 }
3167 #endif //wxART2D_USE_CVGIO
3168 
3169 void a2dFloatProperty::SetValue( float value )
3170 {
3171  m_value = value;
3172 }
3173 
3175 {
3176  wxString form;
3177  form.Printf( wxT( "%s = %6.3f" ), GetName().c_str(), m_value );
3178  return form;
3179 }
3180 
3182 {
3183  wxString form;
3184  //form.Printf( wxT("%6.3f"), m_value );
3185  form.Printf( wxT( "%g" ), m_value );
3186  return form;
3187 }
3188 
3189 //----------------------------------------------------------------------------
3190 // a2dArrayStringProperty
3191 //----------------------------------------------------------------------------
3192 
3193 a2dArrayStringProperty::a2dArrayStringProperty(): a2dNamedProperty()
3194 {
3195  m_value = wxArrayString();
3196 }
3197 
3198 a2dArrayStringProperty::a2dArrayStringProperty( const a2dPropertyIdArrayString* id, const wxArrayString& value )
3199  : a2dNamedProperty( id )
3200 {
3201  m_value = value;
3202 }
3203 
3204 a2dArrayStringProperty::a2dArrayStringProperty( const a2dPropertyIdArrayString* id, const wxString& value )
3205  : a2dNamedProperty( id )
3206 {
3207  wxStringTokenizer args( value, wxT( "," ) );
3208  while ( args.HasMoreTokens() )
3209  {
3210  m_value.Add( args.GetNextToken() );
3211  }
3212 }
3213 
3214 a2dArrayStringProperty::~a2dArrayStringProperty()
3215 {
3216 }
3217 
3218 a2dArrayStringProperty::a2dArrayStringProperty( const a2dArrayStringProperty& other )
3219  : a2dNamedProperty( other )
3220 {
3221  m_value = other.m_value;
3222 }
3223 
3224 a2dNamedProperty* a2dArrayStringProperty::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
3225 {
3226  return new a2dArrayStringProperty( *this );
3227 };
3228 
3229 void a2dArrayStringProperty::Assign( const a2dNamedProperty& other )
3230 {
3231  a2dArrayStringProperty* propcast = wxStaticCast( &other, a2dArrayStringProperty );
3232  m_value = propcast->m_value;
3233 }
3234 
3235 a2dArrayStringProperty* a2dArrayStringProperty::CreatePropertyFromString( const a2dPropertyIdArrayString* id, const wxString& value )
3236 {
3237  wxArrayString valuenew;
3238  wxStringTokenizer args( value );
3239  while ( args.HasMoreTokens() )
3240  {
3241  valuenew.Add( args.GetNextToken() );
3242  }
3243  return new a2dArrayStringProperty( id, valuenew );
3244 }
3245 
3246 #if wxART2D_USE_CVGIO
3247 void a2dArrayStringProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
3248 {
3249  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
3250  if ( xmlparts == a2dXmlSer_attrib )
3251  {
3252  wxString attrib;
3253  size_t j;
3254  for ( j = 0; j < m_value.GetCount(); j++ )
3255  {
3256  attrib += m_value.Item( j );
3257  }
3258 
3259  out.WriteAttribute( wxT( "value" ), attrib );
3260  }
3261  else
3262  {
3263  }
3264 }
3265 
3266 void a2dArrayStringProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
3267 {
3268  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
3269  if ( xmlparts == a2dXmlSer_attrib )
3270  {
3271  wxStringTokenizer args( parser.GetAttributeValue( wxT( "value" ) ), wxT( "," ) );
3272  while ( args.HasMoreTokens() )
3273  {
3274  m_value.Add( args.GetNextToken() );
3275  }
3276  }
3277  else
3278  {
3279  }
3280 }
3281 #endif //wxART2D_USE_CVGIO
3282 
3283 void a2dArrayStringProperty::SetValue( const wxArrayString& value )
3284 {
3285  m_value = value;
3286 }
3287 
3288 void a2dArrayStringProperty::Add( const wxString& value )
3289 {
3290  m_value.Add( value );
3291 }
3292 
3294 {
3295  wxString attrib;
3296  size_t j;
3297  for ( j = 0; j < m_value.GetCount(); j++ )
3298  {
3299  attrib += m_value.Item( j );
3300  }
3301 
3302  wxString form;
3303  form.Printf( wxT( "%s = %s" ), GetName().c_str(), attrib.c_str() );
3304  return form;
3305 }
3306 
3308 {
3309  wxString attrib;
3310  size_t j;
3311  for ( j = 0; j < m_value.GetCount(); j++ )
3312  {
3313  attrib += m_value.Item( j );
3314  }
3315 
3316  wxString form;
3317  form.Printf( wxT( "%s" ), attrib.c_str() );
3318  return form;
3319 }
3320 
3321 //----------------------------------------------------------------------------
3322 // a2dFileNameProperty
3323 //----------------------------------------------------------------------------
3324 
3325 a2dFileNameProperty::a2dFileNameProperty(): a2dNamedProperty()
3326 {
3327  m_filenameObject = wxT( "" );
3328 }
3329 
3330 a2dFileNameProperty::a2dFileNameProperty( const a2dPropertyIdFileName* id, const wxFileName& filename )
3331  : a2dNamedProperty( id )
3332 {
3333  m_filenameObject = filename;
3334 }
3335 
3336 a2dFileNameProperty::~a2dFileNameProperty()
3337 {
3338 }
3339 
3340 a2dFileNameProperty::a2dFileNameProperty( const a2dFileNameProperty& other )
3341  : a2dNamedProperty( other )
3342 {
3343  m_filenameObject = other.m_filenameObject;
3344 }
3345 
3346 a2dNamedProperty* a2dFileNameProperty::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
3347 {
3348  return new a2dFileNameProperty( *this );
3349 };
3350 
3351 void a2dFileNameProperty::Assign( const a2dNamedProperty& other )
3352 {
3353  a2dFileNameProperty* propcast = wxStaticCast( &other, a2dFileNameProperty );
3354  m_filenameObject = propcast->m_filenameObject;
3355 }
3356 
3357 a2dFileNameProperty* a2dFileNameProperty::CreatePropertyFromString( const a2dPropertyIdFileName* id, const wxString& value )
3358 {
3359  wxFileName filenameval( value );
3360  return new a2dFileNameProperty( id, filenameval );
3361 }
3362 
3363 #if wxART2D_USE_CVGIO
3364 void a2dFileNameProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
3365 {
3366  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
3367  if ( xmlparts == a2dXmlSer_attrib )
3368  {
3369  //!todo write complete filename object
3370  out.WriteAttribute( wxT( "fullfilename" ), m_filenameObject.GetFullPath() );
3371  }
3372  else
3373  {
3374  }
3375 }
3376 
3377 void a2dFileNameProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
3378 {
3379  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
3380  if ( xmlparts == a2dXmlSer_attrib )
3381  {
3382  m_filenameObject = parser.GetAttributeValue( wxT( "fullfilename" ), wxT( "" ) );
3383  }
3384  else
3385  {
3386  }
3387 
3388  //!todo read complete filename object
3389 }
3390 #endif //wxART2D_USE_CVGIO
3391 
3392 void a2dFileNameProperty::SetValue( const wxFileName& filenameObject )
3393 {
3394  m_filenameObject = filenameObject;
3395 }
3396 
3397 void a2dFileNameProperty::SetFileName( const wxFileName& filenameObject )
3398 {
3399  m_filenameObject = filenameObject;
3400 }
3401 
3403 {
3404  wxString form;
3405  form.Printf( wxT( "%s = %s" ), GetName().c_str(), m_filenameObject.GetFullPath().c_str() );
3406  return form;
3407 }
3408 
3410 {
3411  wxString form;
3412  form.Printf( wxT( "%s" ), m_filenameObject.GetFullPath().c_str() );
3413  return form;
3414 }
3415 
3416 //----------------------------------------------------------------------------
3417 // a2dDateTimeProperty
3418 //----------------------------------------------------------------------------
3419 
3420 a2dDateTimeProperty::a2dDateTimeProperty(): a2dNamedProperty()
3421 {
3422  m_datetimeObject = wxDefaultDateTime;
3423 }
3424 
3425 a2dDateTimeProperty::a2dDateTimeProperty( const a2dPropertyIdDateTime* id, const wxDateTime& datetime )
3426  : a2dNamedProperty( id )
3427 {
3428  m_datetimeObject = datetime;
3429 }
3430 
3431 a2dDateTimeProperty::~a2dDateTimeProperty()
3432 {
3433 }
3434 
3435 a2dDateTimeProperty::a2dDateTimeProperty( const a2dDateTimeProperty& other )
3436  : a2dNamedProperty( other )
3437 {
3438  m_datetimeObject = other.m_datetimeObject;
3439 }
3440 
3441 a2dNamedProperty* a2dDateTimeProperty::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
3442 {
3443  return new a2dDateTimeProperty( *this );
3444 };
3445 
3446 void a2dDateTimeProperty::Assign( const a2dNamedProperty& other )
3447 {
3448  a2dDateTimeProperty* propcast = wxStaticCast( &other, a2dDateTimeProperty );
3449  m_datetimeObject = propcast->m_datetimeObject;
3450 }
3451 
3452 a2dDateTimeProperty* a2dDateTimeProperty::CreatePropertyFromString( const a2dPropertyIdDateTime* id, const wxString& value )
3453 {
3454  wxDateTime datetimeval;
3455  //datetimeval.ParseFormat( value, wxDefaultDateTimeFormat, NULL );
3456  datetimeval.ParseFormat( value, wxDefaultDateTimeFormat );
3457  return new a2dDateTimeProperty( id, datetimeval );
3458 }
3459 
3460 #if wxART2D_USE_CVGIO
3461 void a2dDateTimeProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
3462 {
3463  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
3464  if ( xmlparts == a2dXmlSer_attrib )
3465  {
3466  //!todo write complete datetime object
3467  out.WriteAttribute( wxT( "datetime" ), m_datetimeObject.Format() );
3468  }
3469  else
3470  {
3471  }
3472 }
3473 
3474 void a2dDateTimeProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
3475 {
3476  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
3477  if ( xmlparts == a2dXmlSer_attrib )
3478  {
3479  wxString dateTime = parser.GetAttributeValue( wxT( "datetime" ), wxT( "" ) );
3480  //m_datetimeObject.ParseFormat( dateTime, wxDefaultDateTimeFormat, NULL );
3481  m_datetimeObject.ParseFormat( dateTime, wxDefaultDateTimeFormat );
3482  }
3483  else
3484  {
3485  }
3486 
3487  //!todo read complete datetime object
3488 }
3489 #endif //wxART2D_USE_CVGIO
3490 
3491 void a2dDateTimeProperty::SetValue( const wxDateTime& datetimeObject )
3492 {
3493  m_datetimeObject = datetimeObject;
3494 }
3495 
3496 void a2dDateTimeProperty::SetDateTime( const wxDateTime& datetimeObject )
3497 {
3498  m_datetimeObject = datetimeObject;
3499 }
3500 
3502 {
3503  wxString form;
3504  form.Printf( wxT( "%s = %s" ), GetName().c_str(), m_datetimeObject.Format().c_str() );
3505  return form;
3506 }
3507 
3509 {
3510  wxString form;
3511  form.Printf( wxT( "%s" ), m_datetimeObject.Format().c_str() );
3512  return form;
3513 }
3514 
3515 //----------------------------------------------------------------------------
3516 // a2dMenuProperty
3517 //----------------------------------------------------------------------------
3518 
3519 a2dMenuProperty::a2dMenuProperty(): a2dNamedProperty()
3520 {
3521  m_menu = NULL;
3522 }
3523 
3524 a2dMenuProperty::a2dMenuProperty( const a2dPropertyIdMenu* id, wxMenu* menu )
3525  : a2dNamedProperty( id )
3526 {
3527  m_menu = menu;
3528 }
3529 
3530 a2dMenuProperty::~a2dMenuProperty()
3531 {
3532 }
3533 
3534 a2dMenuProperty::a2dMenuProperty( const a2dMenuProperty& other )
3535  : a2dNamedProperty( other )
3536 {
3537  m_menu = other.m_menu;
3538 }
3539 
3540 a2dNamedProperty* a2dMenuProperty::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
3541 {
3542  return new a2dMenuProperty( *this );
3543 };
3544 
3545 void a2dMenuProperty::Assign( const a2dNamedProperty& other )
3546 {
3547  a2dMenuProperty* propcast = wxStaticCast( &other, a2dMenuProperty );
3548  m_menu = propcast->m_menu;
3549 }
3550 
3551 #if wxART2D_USE_CVGIO
3552 void a2dMenuProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
3553 {
3554  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
3555  if ( xmlparts == a2dXmlSer_attrib )
3556  {
3557  }
3558  else
3559  {
3560  }
3561 }
3562 
3563 void a2dMenuProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
3564 {
3565  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
3566  if ( xmlparts == a2dXmlSer_attrib )
3567  {
3568  }
3569  else
3570  {
3571  }
3572 
3573  //!todo read complete menu object
3574 }
3575 #endif //wxART2D_USE_CVGIO
3576 
3577 void a2dMenuProperty::SetValue( wxMenu* menu )
3578 {
3579  m_menu = menu;
3580 }
3581 
3582 a2dMenuProperty* a2dMenuProperty::CreatePropertyFromString( const a2dPropertyIdMenu* id, const wxString& value )
3583 {
3584  return NULL;
3585 }
3586 
3587 //----------------------------------------------------------------------------
3588 // a2dWindowProperty
3589 //----------------------------------------------------------------------------
3590 
3591 a2dWindowProperty::a2dWindowProperty(): a2dNamedProperty()
3592 {
3593  m_window = NULL;
3594 }
3595 
3596 a2dWindowProperty::a2dWindowProperty( const a2dPropertyIdWindow* id, wxWindow* window )
3597  : a2dNamedProperty( id )
3598 {
3599  m_window = window;
3600 }
3601 
3602 a2dWindowProperty::~a2dWindowProperty()
3603 {
3604  if( m_window )
3605  m_window->Close();
3606 }
3607 
3608 a2dWindowProperty::a2dWindowProperty( const a2dWindowProperty& other )
3609  : a2dNamedProperty( other )
3610 {
3611  m_window = other.m_window;
3612 }
3613 
3614 a2dNamedProperty* a2dWindowProperty::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
3615 {
3616  return new a2dWindowProperty( *this );
3617 };
3618 
3619 void a2dWindowProperty::Assign( const a2dNamedProperty& other )
3620 {
3621  a2dWindowProperty* propcast = wxStaticCast( &other, a2dWindowProperty );
3622  m_window = propcast->m_window;
3623 }
3624 
3625 #if wxART2D_USE_CVGIO
3626 void a2dWindowProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
3627 {
3628  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
3629  if ( xmlparts == a2dXmlSer_attrib )
3630  {
3631  }
3632  else
3633  {
3634  }
3635 }
3636 
3637 void a2dWindowProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
3638 {
3639  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
3640  if ( xmlparts == a2dXmlSer_attrib )
3641  {
3642  }
3643  else
3644  {
3645  }
3646 
3647  //!todo read complete window object
3648 }
3649 #endif //wxART2D_USE_CVGIO
3650 
3651 void a2dWindowProperty::SetValue( wxWindow* window )
3652 {
3653  m_window = window;
3654 }
3655 
3656 a2dWindowProperty* a2dWindowProperty::CreatePropertyFromString( const a2dPropertyIdWindow* id, const wxString& value )
3657 {
3658  return NULL;
3659 }
3660 
3661 //----------------------------------------------------------------------------
3662 // a2dWindowProperty
3663 //----------------------------------------------------------------------------
3664 
3665 a2dTipWindowProperty::a2dTipWindowProperty(): a2dWindowProperty()
3666 {
3667  m_rectStay = wxRect( -20, -20, 40 , 40 );
3668 }
3669 
3670 a2dTipWindowProperty::a2dTipWindowProperty( const a2dPropertyIdWindow* id, wxTipWindow* window, const wxString& tipstring, bool useObjRect )
3671  : a2dWindowProperty( id, window )
3672 {
3673  m_useObjRect = useObjRect;
3674  m_tipstring = tipstring;
3675 }
3676 
3677 a2dTipWindowProperty::a2dTipWindowProperty( const a2dPropertyIdWindow* id, wxTipWindow* window, const wxString& tipstring, const wxRect& rect )
3678  : a2dWindowProperty( id, window )
3679 {
3680  m_rectStay = rect;
3681  m_useObjRect = false;
3682  m_tipstring = tipstring;
3683 }
3684 
3685 a2dTipWindowProperty::~a2dTipWindowProperty()
3686 {
3687  if( m_window )
3688  {
3689  wxTipWindow* tipwindow = wxDynamicCast( m_window, wxTipWindow );
3690  if( tipwindow )
3691  tipwindow->SetTipWindowPtr( NULL );
3692  }
3693 }
3694 
3695 a2dTipWindowProperty::a2dTipWindowProperty( const a2dTipWindowProperty& other )
3696  : a2dWindowProperty( other )
3697 {
3698  m_tipstring = other.m_tipstring;
3699 }
3700 
3701 a2dNamedProperty* a2dTipWindowProperty::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
3702 {
3703  return new a2dTipWindowProperty( *this );
3704 };
3705 
3706 void a2dTipWindowProperty::Assign( const a2dNamedProperty& other )
3707 {
3708  a2dTipWindowProperty* propcast = wxStaticCast( &other, a2dTipWindowProperty );
3709  m_window = propcast->m_window;
3710  m_tipstring = propcast->m_tipstring;
3711 }
3712 
3713 #if wxART2D_USE_CVGIO
3714 void a2dTipWindowProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
3715 {
3716  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
3717  if ( xmlparts == a2dXmlSer_attrib )
3718  {
3719  }
3720  else
3721  {
3722  }
3723 }
3724 
3725 void a2dTipWindowProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
3726 {
3727  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
3728  if ( xmlparts == a2dXmlSer_attrib )
3729  {
3730  }
3731  else
3732  {
3733  }
3734 
3735  //!todo read complete window object
3736 }
3737 #endif //wxART2D_USE_CVGIO
3738 
3739 void a2dTipWindowProperty::SetString( const wxString& tipstring )
3740 {
3741  m_tipstring = tipstring;
3742 }
3743 
3744 a2dTipWindowProperty* a2dTipWindowProperty::CreatePropertyFromString( const a2dPropertyIdWindow* id, const wxString& value )
3745 {
3746  return NULL;
3747 }
3748 
3749 //----------------------------------------------------------------------------
3750 // a2dPathListProperty
3751 //----------------------------------------------------------------------------
3752 
3753 a2dPathListProperty::a2dPathListProperty(): a2dNamedProperty()
3754 {
3755  m_pathlistObject = a2dPathList();
3756 }
3757 
3758 a2dPathListProperty::a2dPathListProperty( const a2dPropertyIdPathList* id, const a2dPathList& pathlist )
3759  : a2dNamedProperty( id )
3760 {
3761  m_pathlistObject = pathlist;
3762 }
3763 
3764 a2dPathListProperty::~a2dPathListProperty()
3765 {
3766 }
3767 
3768 a2dPathListProperty::a2dPathListProperty( const a2dPathListProperty& other )
3769  : a2dNamedProperty( other )
3770 {
3771  m_pathlistObject = other.m_pathlistObject;
3772 }
3773 
3774 a2dNamedProperty* a2dPathListProperty::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
3775 {
3776  return new a2dPathListProperty( *this );
3777 };
3778 
3779 void a2dPathListProperty::Assign( const a2dNamedProperty& other )
3780 {
3781  a2dPathListProperty* propcast = wxStaticCast( &other, a2dPathListProperty );
3782  m_pathlistObject = propcast->m_pathlistObject;
3783 }
3784 
3785 a2dPathListProperty* a2dPathListProperty::CreatePropertyFromString( const a2dPropertyIdPathList* id, const wxString& value )
3786 {
3787  a2dPathList a = a2dPathList();
3788  a.Add( value );
3789  return new a2dPathListProperty( id, a );
3790 }
3791 
3792 #if wxART2D_USE_CVGIO
3793 void a2dPathListProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
3794 {
3795  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
3796  if ( xmlparts == a2dXmlSer_attrib )
3797  {
3798  //!todo write complete filename object
3799  //out.WriteAttribute( wxT("fullfilename"), m_pathlistObject.GetFullPath() );
3800  }
3801  else
3802  {
3803  }
3804 }
3805 
3806 void a2dPathListProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
3807 {
3808  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
3809  if ( xmlparts == a2dXmlSer_attrib )
3810  {
3811  //!todo m_pathlistObject = parser.GetAttributeValue( wxT("fullfilename"), wxT("") );
3812  }
3813  else
3814  {
3815  }
3816 
3817  //!todo read complete filename object
3818 }
3819 #endif //wxART2D_USE_CVGIO
3820 
3821 void a2dPathListProperty::SetValue( const a2dPathList& pathlistObject )
3822 {
3823  m_pathlistObject = pathlistObject;
3824 }
3825 
3826 void a2dPathListProperty::SetFileName( const a2dPathList& pathlistObject )
3827 {
3828  m_pathlistObject = pathlistObject;
3829 }
3830 
3832 {
3833  wxString form;
3834  //!todo form.Printf( wxT("%s = %s"), GetName().c_str(), m_pathlistObject.GetFullPath().c_str() );
3835  return form;
3836 }
3837 
3839 {
3840  wxString form;
3841  //!todo form.Printf( wxT("%s"), m_pathlistObject.GetFullPath().c_str() );
3842  return form;
3843 }
3844 
3845 //----------------------------------------------------------------------------
3846 // a2dColourProperty
3847 //----------------------------------------------------------------------------
3848 
3849 A2DGENERALDLLEXP wxColour ParseSvgColour( wxString value )
3850 {
3851  wxColour colour;
3852  value.Trim( false ).Trim();
3853  if ( value.GetChar( 0 ) == _T( '#' ) )
3854  {
3855  colour = HexToColour( value.After( _T( '#' ) ) );
3856  }
3857  else if ( value.Mid( 0, 4 ).Lower() == _T( "rgb(" ) ) // Read values like RGB(0,0,0) / rgb(0,0,0)
3858  {
3859  long red, green, blue;
3860  value = value.Mid( 4 );
3861  value = value.BeforeLast( _T( ')' ) );
3862 
3863  wxStringTokenizer rgb( value, _T( "," ) );
3864  if ( rgb.CountTokens() != 3 )
3865  wxLogWarning( _( "Invalid RGB value" ) );
3866  if ( !rgb.GetNextToken().ToLong( &red ) )
3867  wxLogWarning( _( "Invalid RGB value" ) );
3868  if ( !rgb.GetNextToken().ToLong( &green ) )
3869  wxLogWarning( _( "Invalid RGB value" ) );
3870  if ( !rgb.GetNextToken().ToLong( &blue ) )
3871  wxLogWarning( _( "Invalid RGB value" ) );
3872 
3873  colour.Set( red, green, blue );
3874  }
3875  else
3876  {
3877  // if exactly 6 characters and all are 0..9,a..f, assume hex colour.
3878  bool ishex = ( value.Length() == 6 );
3879  for ( int i = 0; ishex && i < 6; i++ )
3880  ishex = ( wxIsxdigit( value.GetChar( i ) ) != 0 );
3881  if ( ishex )
3882  colour = HexToColour( value );
3883  else
3884  {
3885  // if three values separated by either comma, or space assume decimal rgb
3886  unsigned long red, green, blue;
3887  bool commavalue = true;
3888  wxStringTokenizer rgbcomma( value, _T( "," ), wxTOKEN_RET_EMPTY );
3889  if ( rgbcomma.CountTokens() != 3 )
3890  commavalue = false;
3891  if ( !rgbcomma.GetNextToken().ToULong( &red ) )
3892  commavalue = false;
3893  if ( !rgbcomma.GetNextToken().ToULong( &green ) )
3894  commavalue = false;
3895  if ( !rgbcomma.GetNextToken().ToULong( &blue ) )
3896  commavalue = false;
3897 
3898  if ( !commavalue )
3899  {
3900  commavalue = true;
3901  wxStringTokenizer rgbspace( value, _T( " " ) );
3902  if ( rgbspace.CountTokens() != 3 )
3903  commavalue = false;
3904  if ( !rgbspace.GetNextToken().ToULong( &red ) )
3905  commavalue = false;
3906  if ( !rgbspace.GetNextToken().ToULong( &green ) )
3907  commavalue = false;
3908  if ( !rgbspace.GetNextToken().ToULong( &blue ) )
3909  commavalue = false;
3910  }
3911  if ( commavalue )
3912  colour.Set( red, green, blue );
3913  else
3914  {
3915  // assume a colourname string.
3916  colour = wxTheColourDatabase->FindName( value );
3917  }
3918  }
3919  }
3920  return colour;
3921 }
3922 
3923 a2dColourProperty::a2dColourProperty(): a2dNamedProperty()
3924 {
3925  m_colour = wxT( "" );
3926 }
3927 
3928 a2dColourProperty::a2dColourProperty( const a2dPropertyIdColour* id, const wxColour& colour )
3929  : a2dNamedProperty( id )
3930 {
3931  m_colour = colour;
3932 }
3933 
3934 a2dColourProperty::~a2dColourProperty()
3935 {
3936 }
3937 
3938 a2dColourProperty::a2dColourProperty( const a2dColourProperty& other )
3939  : a2dNamedProperty( other )
3940 {
3941  m_colour = other.m_colour;
3942 }
3943 
3944 a2dNamedProperty* a2dColourProperty::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
3945 {
3946  return new a2dColourProperty( *this );
3947 };
3948 
3949 void a2dColourProperty::Assign( const a2dNamedProperty& other )
3950 {
3951  a2dColourProperty* propcast = wxStaticCast( &other, a2dColourProperty );
3952  m_colour = propcast->m_colour;
3953 }
3954 
3955 a2dColourProperty* a2dColourProperty::CreatePropertyFromString( const a2dPropertyIdColour* id, const wxString& value )
3956 {
3957  return new a2dColourProperty( id, ParseSvgColour( value ) );
3958 }
3959 
3960 #if wxART2D_USE_CVGIO
3961 void a2dColourProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
3962 {
3963  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
3964  if ( xmlparts == a2dXmlSer_attrib )
3965  {
3966  //!todo write complete filename object
3967  wxString form;
3968  form.Printf( wxT( "%d %d %d" ), m_colour.Red(), m_colour.Green(), m_colour.Blue() );
3969  out.WriteAttribute( wxT( "colour" ), form );
3970  }
3971  else
3972  {
3973  }
3974 }
3975 
3976 void a2dColourProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
3977 {
3978  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
3979  if ( xmlparts == a2dXmlSer_attrib )
3980  {
3981  wxString colstr = parser.GetAttributeValue( wxT( "colour" ), wxT( "" ) );
3982  m_colour = ParseSvgColour( colstr );
3983  }
3984  else
3985  {
3986  }
3987 
3988  //!todo read complete filename object
3989 }
3990 #endif //wxART2D_USE_CVGIO
3991 
3992 void a2dColourProperty::SetValue( const wxColour& colour )
3993 {
3994  m_colour = colour;
3995 }
3996 
3997 void a2dColourProperty::SetColour( const wxColour& colour )
3998 {
3999  m_colour = colour;
4000 }
4001 
4003 {
4004  wxString form;
4005  form.Printf( wxT( "%s = {%d %d %d}" ), GetName().c_str(), m_colour.Red(), m_colour.Green(), m_colour.Blue() );
4006 
4007  return form;
4008 }
4009 
4011 {
4012  wxString form;
4013  form.Printf( wxT( "{%d %d %d}" ), m_colour.Red(), m_colour.Green(), m_colour.Blue() );
4014  return form;
4015 }
4016 
4017 //----------------------------------------------------------------------------
4018 // a2dUriProperty
4019 //----------------------------------------------------------------------------
4020 
4021 a2dUriProperty::a2dUriProperty(): a2dNamedProperty()
4022 {
4023 }
4024 
4025 a2dUriProperty::a2dUriProperty( const a2dPropertyIdUri* id, const wxURI& uri )
4026  : a2dNamedProperty( id )
4027 {
4028  m_uri = uri;
4029 }
4030 
4031 a2dUriProperty::~a2dUriProperty()
4032 {
4033 }
4034 
4035 a2dUriProperty::a2dUriProperty( const a2dUriProperty& other )
4036  : a2dNamedProperty( other )
4037 {
4038  m_uri = other.m_uri;
4039 }
4040 
4041 a2dNamedProperty* a2dUriProperty::DoClone( a2dObject::CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
4042 {
4043  return new a2dUriProperty( *this );
4044 };
4045 
4046 void a2dUriProperty::Assign( const a2dNamedProperty& other )
4047 {
4048  a2dUriProperty* propcast = wxStaticCast( &other, a2dUriProperty );
4049  m_uri = propcast->m_uri;
4050 }
4051 
4052 #if wxART2D_USE_CVGIO
4053 void a2dUriProperty::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut& out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
4054 {
4055  a2dNamedProperty::DoSave( parent, out, xmlparts, towrite );
4056  if ( xmlparts == a2dXmlSer_attrib )
4057  {
4058  //!todo write complete filename object
4059  wxString uri = m_uri.BuildURI();
4060  out.WriteAttribute( wxT( "uri" ), uri );
4061  }
4062  else
4063  {
4064  }
4065 }
4066 
4067 void a2dUriProperty::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
4068 {
4069  a2dNamedProperty::DoLoad( parent, parser, xmlparts );
4070  if ( xmlparts == a2dXmlSer_attrib )
4071  {
4072  wxString uri = parser.GetAttributeValue( wxT( "uri" ), wxT( "" ) );
4073  m_uri = wxURI( uri );
4074  }
4075  else
4076  {
4077  }
4078 
4079  //!todo read complete uri object
4080 }
4081 #endif //wxART2D_USE_CVGIO
4082 
4083 void a2dUriProperty::SetValue( const wxURI& uri )
4084 {
4085  m_uri = uri;
4086 }
4087 
4088 a2dUriProperty* a2dUriProperty::CreatePropertyFromString( const a2dPropertyIdUri* id, const wxString& value )
4089 {
4090  return new a2dUriProperty( id, wxURI( value ) );
4091 }
4092 
4093 //----------------------------------------------------------------------------
4094 // a2dObjectList
4095 //----------------------------------------------------------------------------
4096 A2DGENERALDLLEXP_DATA( a2dObjectList* ) wxNullRefObjectList = 0;
4097 
4098 //IMPLEMENT_CLASS(a2dObjectList, wxRefObjectBaseList)
4099 
4101 {
4102 }
4103 
4104 a2dObjectList::~a2dObjectList()
4105 {
4106 }
4107 
4109 {
4110  for( a2dObjectList::iterator iter = begin(); iter != end(); ++iter )
4111  {
4112  a2dObject* obj = *iter;
4113  if ( obj && obj->GetOwnedBy() > 1 )
4114  {
4115  *iter = obj->Clone( a2dObject::clone_flat );
4116  }
4117  }
4118 }
4119 
4121 {
4122 
4123  if ( this == wxNullRefObjectList )
4124  return wxNullRefObjectList;
4125  else
4126  return new a2dObjectList( *this );
4127 }
4128 
4129 bool a2dObjectList::Release( const wxString& classname, bool all )
4130 {
4131  bool did = false;
4132 
4133  a2dObjectList::iterator iter = begin();
4134  while ( iter != end() )
4135  {
4136  a2dObject* obj = ( *iter );
4137  if ( classname.IsEmpty() || obj->GetClassInfo()->GetClassName() == classname )
4138  {
4139  did = true;
4140  iter = erase( iter );
4141  if ( !all )
4142  return did;
4143  }
4144  else
4145  iter++;
4146  }
4147 
4148  return did;
4149 }
4150 
4151 a2dObject* a2dObjectList::Find( const wxString& classname, const wxString& name )
4152 {
4153  for( a2dObjectList::iterator iter = begin(); iter != end(); ++iter )
4154  {
4155  a2dObject* cobj = *iter;
4156 
4157  if (
4158  ( classname.IsEmpty() || cobj->GetClassInfo()->GetClassName() == classname ) &&
4159  ( name.IsEmpty() || cobj->GetName() == name )
4160  )
4161  {
4162  return cobj;
4163  }
4164  }
4165 
4166  return ( a2dObject* ) NULL;
4167 }
4168 
4169 int a2dObjectList::CollectObjects( a2dObjectList* total, const wxString& propertyNameFilter, const wxString& classname )
4170 {
4171  int count = 0;
4172  for( a2dObjectList::iterator iter = begin(); iter != end(); ++iter )
4173  {
4174  a2dObject* cobj = *iter;
4175 
4176  if ( ( classname.IsEmpty() || cobj->GetClassInfo()->GetClassName() == classname ) &&
4177  ( propertyNameFilter.IsEmpty() || ( cobj->GetName().Matches( propertyNameFilter ) ) )
4178  )
4179  {
4180  if ( total && total != wxNullRefObjectList )
4181  total->push_back( cobj );
4182  count++;
4183  }
4184  }
4185 
4186  return count;
4187 }
4188 
4189 //----------------------------------------------------------------------------
4190 // a2dVariablesHash
4191 //----------------------------------------------------------------------------
4192 
4194 {
4195 }
4196 
4198  :
4199  a2dVariablesHashBase( other )
4200 {
4201  // all objects in here need to be cloned
4202  iterator i;
4203  for( i = begin(); i != end(); ++i )
4204  {
4205  i->second = i->second->Clone( a2dObject::clone_flat );
4206  }
4207 }
4208 
4210 {
4211  a2dVariablesHashBase::operator = ( other );
4212  // all objects in here need to be cloned
4213  iterator i;
4214  for( i = begin(); i != end(); ++i )
4215  {
4216  i->second = i->second->Clone( a2dObject::clone_flat );
4217  }
4218 }
4219 
4221 {
4222  iterator i;
4223  for( i = begin(); i != end(); ++i )
4224  {
4225  delete i->second;
4226  }
4227 }
4228 
4229 bool a2dVariablesHash::SetVariable( const wxString& variableName, a2dNamedProperty* property )
4230 {
4231  iterator iter = find( variableName );
4232  if( iter != end() )
4233  {
4234  delete iter->second;
4235  }
4236 
4237  ( *this )[ variableName ] = property;
4238 
4239  return iter != end();
4240 }
4241 
4242 bool a2dVariablesHash::SetVariableRefObject( const wxString& variableName, a2dObject* value )
4243 {
4244  iterator iter = find( variableName );
4245  if( iter != end() )
4246  {
4247  delete iter->second;
4248  }
4249 
4250  ( *this )[ variableName ] = new a2dProperty( a2dPropertyIdRefObject::GetDummy(), value );
4251 
4252  return iter != end();
4253 }
4254 
4255 bool a2dVariablesHash::SetVariableString( const wxString& variableName, const wxString& value )
4256 {
4257  iterator iter = find( variableName );
4258  if( iter != end() )
4259  {
4260  delete iter->second;
4261  }
4262 
4263  ( *this )[ variableName ] = new a2dStringProperty( a2dPropertyIdString::GetDummy(), value );
4264 
4265  return iter != end();
4266 }
4267 
4268 bool a2dVariablesHash::SetVariableDouble( const wxString& variableName, double value )
4269 {
4270  iterator iter = find( variableName );
4271  if( iter != end() )
4272  {
4273  delete iter->second;
4274  }
4275 
4276  ( *this )[ variableName ] = new a2dDoubleProperty( a2dPropertyIdDouble::GetDummy(), value );
4277 
4278  return iter != end();
4279 }
4280 
4281 bool a2dVariablesHash::SetVariableInt( const wxString& variableName, int value )
4282 {
4283  iterator iter = find( variableName );
4284  if( iter != end() )
4285  {
4286  delete iter->second;
4287  }
4288 
4289  ( *this )[ variableName ] = new a2dInt32Property( a2dPropertyIdInt32::GetDummy(), value );
4290 
4291  return iter != end();
4292 }
4293 
4294 const a2dNamedProperty* a2dVariablesHash::GetVariable( const wxString& variableName )
4295 {
4296  iterator iter = find( variableName );
4297  if( iter == end() )
4298  return NULL;// error, alias does not exist
4299 
4300  return iter->second;
4301 }
4302 
4303 a2dNamedProperty* a2dVariablesHash::GetVariableClone( const wxString& variableName )
4304 {
4305  iterator iter = find( variableName );
4306  if( iter == end() )
4307  return NULL;// error, alias does not exist
4308 
4309  return iter->second->Clone( a2dObject::clone_flat );
4310 }
4311 
4312 a2dObject* a2dVariablesHash::GetVariableRefObject( const wxString& variableName )
4313 {
4314  iterator iter = find( variableName );
4315  if( iter == end() )
4316  return NULL;// error, alias does not exist
4317 
4318  return iter->second->GetRefObjectNA();
4319 }
4320 
4321 wxString* a2dVariablesHash::GetVariableString( const wxString& variableName )
4322 {
4323  iterator iter = find( variableName );
4324  if( iter == end() )
4325  return NULL;// error, alias does not exist
4326 
4327  a2dStringProperty* prop = wxDynamicCast( iter->second, a2dStringProperty );
4328  if( prop )
4329  return prop->GetValuePtr();
4330  else
4331  return 0;
4332 }
4333 
4334 //----------------------------------------------------------------------------
4335 // a2dVariablesArray
4336 //----------------------------------------------------------------------------
4337 
4339 {
4340  m_nelements = 0;
4341  m_melements = 100;
4342  m_properties = new a2dNamedProperty*[m_melements];
4343 
4344  for( int i = 0; i < 100; i++ )
4345  {
4346  m_properties[i] = 0;
4347  }
4348 }
4349 
4351 {
4352  for( int i = 0; i < m_nelements; i++ )
4353  {
4354  delete m_properties[i];
4355  }
4356  delete [] m_properties;
4357 }
4358 
4360 {
4361  for( int i = 0; i < m_nelements; i++ )
4362  {
4363  delete m_properties[i];
4364  m_properties[i] = 0;
4365  }
4366  m_nelements = 0;
4367 }
4368 
4369 void a2dVariablesArray::AppendVariable( a2dNamedProperty* value )
4370 {
4371  SetMinSize( m_nelements + 1 );
4372  m_properties[ m_nelements++ ] = value;
4373 }
4374 
4376 {
4377  SetMinSize( m_nelements + 1 );
4378  m_properties[ m_nelements++ ] = new a2dProperty( a2dPropertyIdRefObject::GetDummy(), value );
4379 }
4380 
4381 void a2dVariablesArray::AppendVariableString( const wxString& value )
4382 {
4383  SetMinSize( m_nelements + 1 );
4384  m_properties[ m_nelements++ ] = new a2dStringProperty( a2dPropertyIdString::GetDummy(), value );
4385 }
4386 
4388 {
4389  SetMinSize( m_nelements + 1 );
4390  m_properties[ m_nelements++ ] = new a2dDoubleProperty( a2dPropertyIdDouble::GetDummy(), value );
4391 }
4392 
4394 {
4395  SetMinSize( m_nelements + 1 );
4396  m_properties[ m_nelements++ ] = new a2dInt32Property( a2dPropertyIdInt32::GetDummy(), value );
4397 }
4398 
4399 const a2dNamedProperty& a2dVariablesArray::GetVariable( int index )
4400 {
4401  wxASSERT( index < m_nelements && index >= 0 );
4402  return *m_properties[index];
4403 }
4404 
4405 a2dNamedProperty* a2dVariablesArray::GetVariableClone( int index )
4406 {
4407  wxASSERT( index < m_nelements && index >= 0 );
4408  return m_properties[index]->Clone( a2dObject::clone_flat );
4409 }
4410 
4412 {
4413  wxASSERT( index < m_nelements && index >= 0 );
4414  return m_properties[index]->GetRefObject();
4415 }
4416 
4418 {
4419  wxASSERT( index < m_nelements && index >= 0 );
4420  return m_properties[index]->GetString();
4421 }
4422 
4424 {
4425  wxASSERT( index < m_nelements && index >= 0 );
4426  return m_properties[index]->StringValueRepresentation();
4427 }
4428 
4430 {
4431  if( size > m_melements )
4432  {
4433  int i;
4434  if( size < m_melements * 2 )
4435  m_melements *= 2;
4436  else
4437  m_melements = size;
4438  a2dNamedProperty** newdata = new a2dNamedProperty*[m_melements];
4439 
4440  for( i = 0; i < m_nelements; i++ )
4441  {
4442  newdata[i] = m_properties[i];
4443  }
4444  for( ; i < m_melements; i++ )
4445  {
4446  newdata[i] = 0;
4447  }
4448  delete [] m_properties;
4449  m_properties = newdata;
4450  }
4451 }
4452 
4453 // ----------------------------------------------------------------------------
4454 // a2dPathList
4455 // ----------------------------------------------------------------------------
4456 #define PATHLENGTH 255 * 4
4457 
4458 // MT-FIXME: get rid of this horror and all code using it
4459 static wxChar wxFileFunctionsBuffer[PATHLENGTH];
4460 
4461 a2dPathList::a2dPathList()
4462 {
4463 }
4464 
4465 a2dPathList::~a2dPathList()
4466 {
4467  Clear();
4468 }
4469 
4471 {
4472  wxString ret;
4473 
4474 #if wxCHECK_VERSION(2,7,0)
4475  for ( wxPathList::iterator node = begin(); node != end(); node++ )
4476 #else
4477  for ( wxStringList::compatibility_iterator node = GetFirst(); node; node = node->GetNext() )
4478 #endif
4479  {
4480  wxString path = node->GetData();
4481  ret += wxPATH_SEP + path;
4482  }
4483  return ret;
4484 }
4485 
4486 wxString a2dPathList::FindValidPath ( const wxString& filename, bool reportError )
4487 {
4488  wxFileName ffile( filename );
4489  wxString filefull = ffile.GetFullPath();
4490 
4491  if ( ExpandPath( filefull ) && wxFileExists( filefull ) )
4492  return wxString( m_b );
4493 
4494  wxFileName fileobj = wxFileName( filefull );
4495 
4496  // relative ./whatdir/file.ext should also be searched for.
4497  wxString filenamefull = fileobj.IsAbsolute() ? fileobj.GetFullName() : fileobj.GetFullPath();
4498 
4499 #if wxCHECK_VERSION(2,7,0)
4500  for ( wxPathList::iterator node = begin(); node != end(); node++ )
4501 #else
4502  for ( wxStringList::compatibility_iterator node = GetFirst(); node; node = node->GetNext() )
4503 #endif
4504  {
4505  wxFileName filep( node->GetData() );
4506  wxString path = filep.GetFullPath();
4507  if ( !path.IsEmpty() )
4508  {
4509  wxChar ch = path[wxStrlen( path ) - 1];
4510  if ( ch != wxFileName::GetPathSeparator() )
4511  path += wxFileName::GetPathSeparator(wxPATH_UNIX);
4512  }
4513  path += filenamefull;
4514 
4515  if ( ExpandPath( path ) && wxFileExists( path ) )
4516  return wxString( m_b ); // Found!
4517  }
4518 
4519  if ( reportError )
4520  {
4521  wxString mess = GetAsString();
4522  /*
4523  for (wxStringList::compatibility_iterator node = GetFirst(); node; node = node->GetNext())
4524  {
4525  wxFileName filep( node->GetData() );
4526  wxString path = filep.GetFullPath();
4527  if ( !path.IsEmpty() )
4528  {
4529  wxChar ch = path[wxStrlen(path)-1];
4530  if ( ch != wxFileName::GetPathSeparator() )
4531  path += wxFileName::GetPathSeparator();
4532  }
4533  path += filenamefull;
4534 
4535  ExpandPath( path );
4536  mess += path + wxT("\n");
4537  }
4538  */
4539  a2dGeneralGlobals->ReportErrorF( a2dError_FileCouldNotOpen, _( "valid Path not found for: %s in path list: %s" ), filename.c_str(), mess.c_str() );
4540  //wxLogError( _T( "valid Path not found for: %s in path list: %s" ), filename.c_str(), mess.c_str() );
4541  //wxLog::GetActiveTarget()->Flush();
4542 
4543  }
4544  return wxEmptyString; //Not found
4545 }
4546 
4547 wxString a2dPathList::FindAbsoluteValidPath ( const wxString& file )
4548 {
4549  wxString f = FindValidPath( file );
4550  if ( f.empty() || wxIsAbsolutePath( f ) )
4551  return f;
4552 
4553  wxString buf = wxGetCwd();
4554 
4555  if ( !wxEndsWithPathSeparator( buf ) )
4556  {
4557  buf += wxFileName::GetPathSeparator();
4558  }
4559  buf += f;
4560 
4561  return buf;
4562 }
4563 
4564 void a2dPathList::IncC()
4565 {
4566  if ( m_c == 0 ) //get first character from buffer
4567  {
4568  //m_c = m_path.wchar_str();
4569  m_c = m_path.c_str();
4570  }
4571  else
4572  {
4573  if ( *m_c != wxT( '\0' ) )
4574  m_c++;
4575  }
4576  a = *m_c;
4577 }
4578 
4579 // <name> ::= { LETTER | DIGIT | UNDERSCORE | MINUS }*
4580 // Check Name specification
4581 bool a2dPathList::Name()
4582 {
4583  m_varref.Empty();
4584  if ( !( wxIsalnum( a ) || a == wxT( '_' ) || a == wxT( '-' ) ) )
4585  {
4586  m_error_mes = wxT( "wrong name" );
4587  return false; // invalid name (begin char)
4588  }
4589  m_varref += a;
4590  IncC();
4591  while( wxIsalnum( a ) || a == wxT( '_' ) )
4592  {
4593  m_varref += a;
4594  IncC();
4595  }
4596  return true; // name is validated
4597 }
4598 
4599 //<path>= { <aliasref> | <envref> | {CHAR}* }*
4600 bool a2dPathList::ExpandPath( wxString& pathToExpand, wxPathFormat format )
4601 {
4602  wxString result;
4603  m_path = pathToExpand;
4604  m_b.Clear();
4605  m_b.Alloc( PATHLENGTH );
4606 
4607  bool change = true;
4608  while ( change )
4609  {
4610  change = false;
4611  m_b.Clear();
4612  m_varref.Clear();
4613  m_error_mes.Clear();
4614  m_c = 0;
4615 
4616  IncC();
4617 
4618  while( a != wxT( '\t' ) && a != wxT( '\0' ) && a != wxT( '\n' ) && a != wxT( ';' ) )
4619  {
4620  /*
4621  if (a == wxT('\\') ) //take the next character
4622  { IncC();
4623  if ( a == wxT('\n') )
4624  IncC(); //treat it as if it was a space
4625 
4626  if ( a == wxT(' ') || a == wxT('\t') || a == wxT('\0') || a == wxT(';') )
4627  break; //treat it as word seperator
4628 
4629  //all other backslash character take them
4630  m_b += a;
4631  IncC();
4632  continue;
4633  }
4634  */
4635  if ( ( a == wxT( '$' ) ) || ( a == wxT( '%' ) ) || ( a == wxT( '@' ) ) )
4636  {
4637  if ( !VarRef( a ) )
4638  return false;
4639  change = true;
4640  continue;
4641  }
4642 
4643  //all other characters
4644  m_b += a;
4645  IncC();
4646  }
4647 
4648  m_path = m_b;
4649  }
4650 
4651  wxFileName ffile( m_b );
4652  pathToExpand = ffile.GetFullPath( format );
4653 
4654  return true;
4655 }
4656 
4657 // Get Alias value
4658 // <aliasref> ::= ('%') { <name> <blank> | ('{') <name> ('}') }
4659 // Get Environment string
4660 // <envstring> ::= ('$') { <name> <blank> | ('{') <name> ('}') }
4661 bool a2dPathList::VarRef( wxChar type )
4662 {
4663  if( a != type ) // '$' or '%' must be there
4664  {
4665  m_error_mes = wxT( "wrong environment $ or % or @ missing" );
4666  return false;
4667  }
4668 
4669  IncC();
4670  if( a == wxT( '{' ) ) // brace could be there
4671  {
4672  IncC();
4673  if( !Name() )
4674  return false; // error, wrong alias name
4675  if( a != '}' ) // brace must be there
4676  {
4677  m_error_mes = wxT( "wrong environment name, end brace missing" );
4678  return false; // error, wrong alias, endbrace missing or wrong name
4679  }
4680  IncC();
4681  }
4682  else
4683  {
4684  if( !Name() )
4685  return false; // error, wrong alias name
4686  }
4687 
4688  wxString evaluated;
4689  if ( type == wxT( '$' ) )
4690  {
4691  if ( m_varref.Len() == 0 )
4692  return false; // A name is needed
4693 
4694  if( !wxGetEnv( m_varref, &evaluated ) )
4695  {
4696  m_error_mes = wxT( "wrong environment Variable, environment does not exist" );
4697  return false;// error, alias does not exist
4698  }
4699  }
4700  else
4701  {
4702  a2dVariablesHash aliaslist = a2dGeneralGlobals->GetVariablesHash();
4703  const a2dNamedProperty* prop = a2dGeneralGlobals->GetVariablesHash().GetVariable( m_varref );
4704  if( !prop )
4705  {
4706  m_error_mes = wxT( "wrong Variable name, Variable does not exist" );
4707  return false;// error, alias does not exist
4708  }
4709  evaluated = prop->StringValueRepresentation();
4710  }
4711 
4712  m_b += evaluated;
4713  return true;
4714 }
4715 
4716 // ----------------------------------------------------------------------------
4717 // Definition of a2dRefMap
4718 // ----------------------------------------------------------------------------
4720 {
4721  m_refcount = 0;
4722  m_toResolve.DeleteContents( true );
4723  m_lastObjectId.Empty();
4724 }
4725 
4727 {
4728  wxASSERT_MSG( m_refcount == 0, wxT( "deleting a2dDocument while referenced" ) );
4729  m_objecthashmap.clear();
4730  m_objectCreate.clear();
4731  m_toResolve.Clear();
4732  m_lastObjectId.Empty();
4733 }
4734 
4735 a2dObject* a2dRefMap::DoClone( CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
4736 {
4737  wxFAIL_MSG( wxT( "cannot clone a2dRefMap" ) );
4738  return NULL;
4739 }
4740 
4741 #if wxART2D_USE_CVGIO
4742 void a2dRefMap::DoSave( wxObject* WXUNUSED( parent ), a2dIOHandlerXmlSerOut& WXUNUSED( out ), a2dXmlSer_flag WXUNUSED( xmlparts ), a2dObjectList* WXUNUSED( towrite ) )
4743 {
4744  wxFAIL_MSG( wxT( "cannot Save a2dRefMap" ) );
4745 }
4746 
4747 void a2dRefMap::DoLoad( wxObject* WXUNUSED( parent ), a2dIOHandlerXmlSerIn& WXUNUSED( parser ), a2dXmlSer_flag WXUNUSED( xmlparts ) )
4748 {
4749  wxFAIL_MSG( wxT( "cannot Load a2dRefMap" ) );
4750 }
4751 #endif //wxART2D_USE_CVGIO
4752 
4754 {
4755  m_objecthashmap.clear();
4756  m_toResolve.Clear();
4757  m_lastObjectId.Empty();
4758 }
4759 
4760 bool a2dRefMap::ResolveOrAdd( a2dSmrtPtr<a2dObject>* storedHere, const wxString& id )
4761 {
4762  if ( storedHere && ( !id.IsEmpty() || !m_lastObjectId.IsEmpty() ) )
4763  {
4764  a2dHashMapIntToObject::iterator obj = m_objecthashmap.find( id.IsEmpty() ? m_lastObjectId : id );
4765 
4766  if( obj == m_objecthashmap.end() )
4767  {
4768  a2dResolveIdInfo* a = new a2dResolveIdInfo( id.IsEmpty() ? m_lastObjectId : id, storedHere );
4769  m_toResolve.Append( a );
4770  if( id.IsEmpty() )
4771  m_lastObjectId.Empty();
4772  return false;
4773  }
4774 
4775  //the object referenced is already found, link it now.
4776  *storedHere = wxDynamicCast( obj->second, a2dObject );
4777  if( id.IsEmpty() )
4778  m_lastObjectId.Empty();
4779  return true;
4780  }
4781  return false;
4782 }
4783 
4784 bool a2dRefMap::ResolveOrAdd( a2dAutoZeroPtr<a2dObject>* storedHere, const wxString& id )
4785 {
4786  if ( storedHere && ( !id.IsEmpty() || !m_lastObjectId.IsEmpty() ) )
4787  {
4788  a2dHashMapIntToObject::iterator obj = m_objecthashmap.find( id.IsEmpty() ? m_lastObjectId : id );
4789 
4790  if( obj == m_objecthashmap.end() )
4791  {
4792  a2dResolveIdInfo* a = new a2dResolveIdInfo( id.IsEmpty() ? m_lastObjectId : id, storedHere );
4793  m_toResolve.Append( a );
4794  if( id.IsEmpty() )
4795  m_lastObjectId.Empty();
4796  return false;
4797  }
4798 
4799  //the object referenced is already found, link it now.
4800  *storedHere = wxDynamicCast( obj->second, a2dObject );
4801  if( id.IsEmpty() )
4802  m_lastObjectId.Empty();
4803  return true;
4804  }
4805  return false;
4806 }
4807 
4808 bool a2dRefMap::ResolveOrAddLink( a2dObject* owner, const wxString& id )
4809 {
4810  if ( owner && ( !id.IsEmpty() || !m_lastObjectId.IsEmpty() ) )
4811  {
4812  a2dHashMapIntToObject::iterator obj = m_objecthashmap.find( id.IsEmpty() ? m_lastObjectId : id );
4813 
4814  if( obj == m_objecthashmap.end() )
4815  {
4816  a2dResolveIdInfo* a = new a2dResolveIdInfo( id.IsEmpty() ? m_lastObjectId : id, owner );
4817  m_toResolve.Append( a );
4818  if( id.IsEmpty() )
4819  m_lastObjectId.Empty();
4820  return false;
4821  }
4822 
4823  //the object referenced is already found, link it now.
4824  owner->LinkReference( obj->second );
4825  if( id.IsEmpty() )
4826  m_lastObjectId.Empty();
4827  return true;
4828  }
4829  return false;
4830 }
4831 
4833 {
4834  a2dResolveIdInfo* a = new a2dResolveIdInfo( obj );
4835  m_toResolve.Append( a );
4836 }
4837 
4838 void a2dRefMap::SetLastObjectLoadedId( const wxString& lastid )
4839 {
4840  wxASSERT_MSG( m_lastObjectId.IsEmpty(), wxT( "last refid not resolved" ) );
4841  m_lastObjectId = lastid;
4842 }
4843 
4844 bool a2dRefMap::RemoveReference( const wxString& idToRemove )
4845 {
4846  a2dResolveIdList::compatibility_iterator node = m_toResolve.GetFirst();
4847  while ( node )
4848  {
4849  a2dResolveIdList::compatibility_iterator delnode = node;
4850  node = node->GetNext();
4851  a2dResolveIdInfo* linkinfo = delnode->GetData();
4852  wxString toLinkName = linkinfo->m_idStr;
4853  if( toLinkName == idToRemove )
4854  {
4855  m_toResolve.DeleteNode( delnode );
4856  return true;
4857  }
4858  }
4859  return false;
4860 }
4861 
4862 bool a2dRefMap::LinkReferences( bool ignoreNonResolved )
4863 {
4864  a2dResolveIdList::compatibility_iterator node = m_toResolve.GetFirst();
4865  while ( node )
4866  {
4867  a2dResolveIdList::compatibility_iterator delnode = node;
4868  node = node->GetNext();
4869  a2dResolveIdInfo* linkinfo = delnode->GetData();
4870  wxString toLinkName = linkinfo->m_idStr;
4871  a2dHashMapIntToObject::iterator obj = m_objecthashmap.find( toLinkName );
4872  if( obj != m_objecthashmap.end() )
4873  {
4874  delnode->GetData()->Assign( obj->second );
4875  m_toResolve.DeleteNode( delnode );
4876  }
4877  else if ( !ignoreNonResolved )
4878  {
4879  if ( linkinfo->m_mode == a2dResolveIdInfo::mode_a2dObjectSmrtPtr )
4880  {
4881  a2dSmrtPtr<a2dObject>* poin = linkinfo->m_storedHere.m_a2dObjectSmrtPtr;
4882  if ( *poin )
4883  wxLogWarning( wxT( "%s %s %s" ), _( "Reference not resolved: " ), (*poin)->GetClassInfo()->GetClassName(), toLinkName );
4884  else
4885  wxLogWarning( wxT( "%s%s" ), _( "Reference not resolved: " ), toLinkName );
4886  }
4887  else if ( linkinfo->m_mode == a2dResolveIdInfo::mode_link )
4888  {
4889  a2dObject* poin = linkinfo->m_storedHere.m_link;
4890  wxLogWarning( wxT( "%s %s %s" ), _( "Reference not resolved: " ), poin->GetClassInfo()->GetClassName(), toLinkName );
4891  }
4892  else
4893  wxLogWarning( wxT( "%s%s" ), _( "Reference not resolved: " ), toLinkName );
4894  }
4895  };
4896 
4897  return true;
4898 }
4899 
4900 // ----------------------------------------------------------------------------
4901 // Definition of a2dIOHandler
4902 // ----------------------------------------------------------------------------
4904 {
4905  m_refcount = 0;
4906  m_toResolve.DeleteContents( true );
4907  m_lastObjectId.Empty();
4908 }
4909 
4911 {
4912  wxASSERT_MSG( m_refcount == 0, wxT( "deleting a2dDocument while referenced" ) );
4913  m_objecthashmap.clear();
4914  m_objectCreate.clear();
4915  m_toResolve.Clear();
4916  m_lastObjectId.Empty();
4917 }
4918 
4919 a2dObject* a2dIOHandler::DoClone( CloneOptions WXUNUSED( options ), a2dRefMap* refs ) const
4920 {
4921  wxFAIL_MSG( wxT( "cannot clone a2dIOHandler" ) );
4922  return NULL;
4923 }
4924 
4925 #if wxART2D_USE_CVGIO
4926 void a2dIOHandler::DoSave( wxObject* WXUNUSED( parent ), a2dIOHandlerXmlSerOut& WXUNUSED( out ), a2dXmlSer_flag WXUNUSED( xmlparts ), a2dObjectList* WXUNUSED( towrite ) )
4927 {
4928  wxFAIL_MSG( wxT( "cannot Save a2dIOHandler" ) );
4929 }
4930 
4931 void a2dIOHandler::DoLoad( wxObject* WXUNUSED( parent ), a2dIOHandlerXmlSerIn& WXUNUSED( parser ), a2dXmlSer_flag WXUNUSED( xmlparts ) )
4932 {
4933  wxFAIL_MSG( wxT( "cannot Load a2dIOHandler" ) );
4934 }
4935 #endif //wxART2D_USE_CVGIO
4936 
4937 wxObject* a2dIOHandler::CreateObject( const wxString& symbolicName )
4938 {
4939  a2dHashMapCreateObject::iterator obj = m_objectCreate.find( symbolicName );
4940 
4941  if( obj == m_objectCreate.end() )
4942  {
4943  return wxCreateDynamicObject( symbolicName );
4944  }
4945  return wxCreateDynamicObject( obj->second );
4946 }
4947 
4948 // ----------------------------------------------------------------------------
4949 // Definition of a2dIOHandlerStrIn
4950 // ----------------------------------------------------------------------------
4951 a2dIOHandlerStrIn::a2dIOHandlerStrIn( wxMBConv& conv ): m_conv( conv )
4952 {
4953  m_mode = wxEOL_NATIVE;
4954  if ( m_mode == wxEOL_NATIVE )
4955  {
4956 #if defined(__WXMSW__) || defined(__WXPM__)
4957  m_mode = wxEOL_DOS;
4958 #elif defined(__WXMAC__) && !defined(__DARWIN__)
4959  m_mode = wxEOL_MAC;
4960 #else
4961  m_mode = wxEOL_UNIX;
4962 #endif
4963  }
4964 }
4965 
4967 {
4968  wxASSERT_MSG( m_refcount == 0, wxT( "deleting a2dDocument while referenced" ) );
4969 }
4970 
4972 {
4973  m_objecthashmap.clear();
4974  m_toResolve.Clear();
4975 }
4976 
4978 {
4979  m_objecthashmap.clear();
4980  m_toResolve.Clear();
4981 }
4982 
4984 {
4985 #if wxUSE_STD_IOSTREAM
4986  return m_streami->peek();
4987 #else
4988  return m_streami->Peek();
4989 #endif
4990 }
4991 
4993 {
4994 #if wxUSE_STD_IOSTREAM
4995  return m_streami->get();
4996 #else
4997  return m_streami->GetC();
4998 #endif
4999 }
5000 
5001 bool a2dIOHandlerStrIn::Eof() const
5002 {
5003 #if wxUSE_STD_IOSTREAM
5004  if ( m_streami->eof() )
5005 #else
5006  if ( m_streami->Eof() )
5007 #endif
5008  return true;
5009  return false;
5010 }
5011 
5012 bool a2dIOHandlerStrIn::IsOk() const
5013 {
5014 #if wxUSE_STD_IOSTREAM
5015  return ( m_streami->fail() || m_streami->bad() );
5016 #else
5017  return ( m_streami->IsOk() );
5018 #endif
5019 }
5020 
5022 {
5023 #if wxUSE_STD_IOSTREAM
5024  m_streami->clear(); // not interested in stream errors here
5025  m_streami->seekg( pos, wxSTD ios::beg );
5026 #else
5027  m_streami->SeekI( pos );
5028 #endif
5029  return *this;
5030 }
5031 /*
5032 size_t a2dIOHandlerStrIn::Read( wxChar* buffer, size_t size)
5033 {
5034 #if wxUSE_STD_IOSTREAM
5035  m_streami->read( buffer, size);
5036  size_t len = m_streami->gcount();
5037 #else
5038  size_t len = m_streami->Read( buffer, size).LastRead();
5039 #endif
5040  return len;
5041 }
5042 */
5043 
5044 //#if wxUSE_UNICODE
5045 size_t a2dIOHandlerStrIn::Read( char* buffer, size_t size )
5046 {
5047 #if wxUSE_STD_IOSTREAM
5048  m_streami->read( buffer, size );
5049  size_t len = m_streami->gcount();
5050 #else
5051  size_t len = m_streami->Read( buffer, size ).LastRead();
5052 #endif
5053  return len;
5054 }
5055 //#endif
5056 
5057 void a2dIOHandlerStrIn::SetMode( wxEOL mode )
5058 {
5059  m_mode = mode;
5060  if ( m_mode == wxEOL_NATIVE )
5061  {
5062 #if defined(__WXMSW__) || defined(__WXPM__)
5063  m_mode = wxEOL_DOS;
5064 #elif defined(__WXMAC__) && !defined(__DARWIN__)
5065  m_mode = wxEOL_MAC;
5066 #else
5067  m_mode = wxEOL_UNIX;
5068 #endif
5069  }
5070 }
5071 
5072 // ----------------------------------------------------------------------------
5073 // Definition of a2dIOHandlerStrOut
5074 // ----------------------------------------------------------------------------
5075 a2dIOHandlerStrOut::a2dIOHandlerStrOut( wxMBConv& conv ): m_conv( conv )
5076 {
5077  m_filename = wxFileName( "" );
5078  m_mode = wxEOL_NATIVE;
5079  if ( m_mode == wxEOL_NATIVE )
5080  {
5081 #if defined(__WXMSW__) || defined(__WXPM__)
5082  m_mode = wxEOL_DOS;
5083 #elif defined(__WXMAC__) && !defined(__DARWIN__)
5084  m_mode = wxEOL_MAC;
5085 #else
5086  m_mode = wxEOL_UNIX;
5087 #endif
5088  }
5089 }
5090 
5092 {
5093 }
5094 
5096 {
5097  m_objecthashmap.clear();
5098  m_toResolve.Clear();
5099 }
5100 
5102 {
5103  m_objecthashmap.clear();
5104  m_toResolve.Clear();
5105 }
5106 
5107 void a2dIOHandlerStrOut::WriteString( const wxString& string )
5108 {
5109  size_t len = string.length();
5110 
5111  wxString out;
5112  out.reserve( len );
5113 
5114  if ( m_mode != wxEOL_UNIX )
5115  {
5116  for ( size_t i = 0; i < len; i++ )
5117  {
5118  const wxChar c = string[i];
5119  if ( c == wxT( '\n' ) )
5120  {
5121  switch ( m_mode )
5122  {
5123  case wxEOL_DOS:
5124  out << _T( "\r\n" );
5125  continue;
5126 
5127  case wxEOL_MAC:
5128  out << _T( '\r' );
5129  continue;
5130 
5131  default:
5132  wxFAIL_MSG( _T( "unknown EOL mode in a2dIOHandlerStrOut" ) );
5133  // fall through
5134 
5135  case wxEOL_UNIX:
5136  // don't treat '\n' specially
5137  ;
5138  }
5139  }
5140 
5141  out << c;
5142  }
5143  }
5144  else
5145  out = string;
5146 
5147 #if wxUSE_STD_IOSTREAM
5148 
5149  // We must not write the trailing NULL here
5150  #if wxUSE_UNICODE
5151  #if !wxUSE_WSTREAM
5152  wxCharBuffer buffer = m_conv.cWC2MB( out );
5153  m_streamo->write( ( const char* ) buffer, strlen( ( const char* ) buffer ) );
5154  #else
5155  m_streamo->write( out, len );
5156  #endif
5157  #else
5158  m_streamo->write( out.c_str(), out.length() );
5159  #endif
5160 
5161 #else
5162  // We must not write the trailing NULL here
5163  #if wxUSE_UNICODE
5164  wxCharBuffer buffer = m_conv.cWC2MB( out );
5165  m_streamo->Write( ( const char* ) buffer, strlen( ( const char* ) buffer ) );
5166  #else
5167  //in memory converted to wide char unicode string with wxConvLocal, and convert with m_conv e.g UTF-8
5168  wxString str2( out.wc_str( wxConvLocal ), m_conv );
5169  m_streamo->Write( str2.mb_str(), str2.Len() );
5170  #endif
5171 
5172 #endif
5173 }
5174 
5176 {
5177  wxString str;
5178  str.Printf( wxT( "%u" ), i );
5179 
5180  WriteString( str );
5181 }
5182 
5184 {
5185  wxString str;
5186  str.Printf( wxT( "%u" ), i );
5187 
5188  WriteString( str );
5189 }
5190 
5192 {
5193  wxString str;
5194  str.Printf( wxT( "%u" ), i );
5195 
5196  WriteString( str );
5197 }
5198 
5200 {
5201  wxString str;
5202 
5203  str.Printf( wxT( "%f" ), d );
5204  WriteString( str );
5205 }
5206 
5208 {
5209 #if wxUSE_STD_IOSTREAM
5210  return ( m_streamo->fail() || m_streamo->bad() ) == 0;
5211 #else
5212  return ( m_streamo->IsOk() );
5213 #endif
5214 }
5215 
5217 {
5218  WriteString( wxString( &c, m_conv, 1 ) );
5219  return *this;
5220 }
5221 
5222 //----------------------------------------------------------------------------
5223 // a2dWalkerIOHandler
5224 //----------------------------------------------------------------------------
5225 
5226 IMPLEMENT_CLASS( a2dWalkerIOHandler, a2dIOHandler )
5227 
5228 extern a2dWalkEvent a2dWalker_a2dObjectStart = wxNewId();
5229 extern a2dWalkEvent a2dWalker_a2dObjectEnd = wxNewId();
5230 extern a2dWalkEvent a2dWalker_a2dPropertyStart = wxNewId();
5231 extern a2dWalkEvent a2dWalker_a2dPropertyEnd = wxNewId();
5235 extern a2dWalkEvent a2dWalker_a2dNamedPropertyEnd = wxNewId();
5236 
5237 extern a2dWalkEvent a2dWalker_a2dCanvasObjectStart = wxNewId();
5241 extern a2dWalkEvent a2dWalker_a2dCanvasObjectEnd = wxNewId();
5244 
5246 {
5247  m_useCheck = false;
5248  m_depthFirst = false;
5249  m_skipNotRenderedInDrawing = false;
5250  Initialize();
5251 }
5252 
5254 {
5255 }
5256 
5258 {
5259  m_currentDepth = 0;
5260  m_currentParent = NULL;
5261  m_stopWalking = false;
5262  m_result = false;
5263 }
5264 
5265 bool a2dWalkerIOHandler::WalkTask( wxObject* parent, wxObject* object, a2dWalkEvent event )
5266 {
5267  a2dObjectIOFn* function = m_register.find( object->GetClassInfo()->GetClassName() )->second;
5268 
5269  if ( function )
5270  {
5271  ( *function )( parent, object, event );
5272  return true;
5273  }
5274  return false;
5275 }
5276 
5277 
5278 // 3-digit hex to wxColour
5279 wxColour HexToColour( const wxString& hex )
5280 {
5281  if ( hex.Length() == 6 )
5282  {
5283  long r, g, b;
5284  r = g = b = 0;
5285  hex.Mid( 0, 2 ).ToLong( &r, 16 );
5286  hex.Mid( 2, 2 ).ToLong( &g, 16 );
5287  hex.Mid( 4, 2 ).ToLong( &b, 16 );
5288  return wxColour( r, g, b );
5289  }
5290  else
5291  return wxColour( 0, 0, 0 );
5292 }
5293 
5294 // RGB to 3-digit hex
5295 wxString ColourToHex( const wxColour& colour )
5296 {
5297  wxChar buf[7];
5298  unsigned int red = colour.Red();
5299  unsigned int green = colour.Green();
5300  unsigned int blue = colour.Blue();
5301 
5302  wxDecToHex( red, buf );
5303  wxDecToHex( green, buf + 2 );
5304  wxDecToHex( blue, buf + 4 );
5305 
5306  return wxString( buf );
5307 }
5308 
5309 
5310 //----------------------------------------------------------------------------
5311 // a2dComEvent
5312 //----------------------------------------------------------------------------
5313 const a2dSignal a2dComEvent::sm_changedProperty = wxNewId();
5314 const a2dSignal a2dComEvent::sm_changedRefObject = wxNewId();
5315 const a2dSignal a2dComEvent::sm_non = wxNewId();
5316 
5317 IMPLEMENT_DYNAMIC_CLASS( a2dComEvent, wxEvent )
5318 
5319 DEFINE_EVENT_TYPE( a2dEVT_COM_EVENT )
5320 
5321 a2dComEvent::a2dComEvent( wxObject* sender, a2dSignal id )
5322  : wxEvent( id, a2dEVT_COM_EVENT )
5323 {
5324  SetEventObject( sender );
5325  m_property = 0;
5326  m_ownProp = false;
5327  m_comReturn = sm_non;
5328  m_refcount = 0;
5329 }
5330 
5331 a2dComEvent::a2dComEvent( a2dObject* sender, const a2dPropertyId* propId, a2dSignal id )
5332  : wxEvent( id, a2dEVT_COM_EVENT )
5333 {
5334  SetEventObject( sender );
5335  m_property = sender->FindProperty( propId );
5336  m_ownProp = false;
5337  m_comReturn = sm_non;
5338  m_refcount = 0;
5339 }
5340 
5341 a2dComEvent::a2dComEvent( wxObject* sender, a2dNamedProperty* property, a2dSignal id, bool ownProp )
5342  : wxEvent( id, a2dEVT_COM_EVENT )
5343 {
5344  SetEventObject( sender );
5345  if ( ownProp )
5346  m_property = property->Clone( a2dObject::clone_flat );
5347  else
5348  m_property = property;
5349  m_ownProp = ownProp;
5350  m_comReturn = sm_non;
5351  m_refcount = 0;
5352 }
5353 
5354 a2dComEvent::a2dComEvent( wxObject* sender, const a2dNamedProperty& property, a2dSignal id )
5355  : wxEvent( id, a2dEVT_COM_EVENT )
5356 {
5357  SetEventObject( sender );
5358  m_property = property.Clone( a2dObject::clone_flat );
5359  m_ownProp = true;
5360  m_comReturn = sm_non;
5361  m_refcount = 0;
5362 }
5363 
5364 a2dComEvent::a2dComEvent( wxObject* sender, a2dObject* refObject, a2dSignal id )
5365  : wxEvent( id, a2dEVT_COM_EVENT )
5366 {
5367  SetEventObject( sender );
5368  m_property = new a2dProperty( a2dPropertyIdRefObject::GetDummy(), refObject );
5369  m_ownProp = true;
5370  m_comReturn = sm_non;
5371  m_refcount = 0;
5372 }
5373 
5374 a2dComEvent::a2dComEvent( wxObject* sender, const a2dPropertyIdRefObject* propId, a2dObject* refObject, a2dSignal id )
5375  : wxEvent( id, a2dEVT_COM_EVENT )
5376 {
5377  SetEventObject( sender );
5378  m_property = new a2dProperty( propId, refObject );
5379  m_ownProp = true;
5380  m_comReturn = sm_non;
5381  m_refcount = 0;
5382 }
5383 
5384 a2dComEvent::a2dComEvent( wxObject* sender, const a2dPropertyIdBool* propId, bool propertyValue, a2dSignal id )
5385  : wxEvent( id, a2dEVT_COM_EVENT )
5386 {
5387  SetEventObject( sender );
5388  m_property = new a2dBoolProperty( propId, propertyValue );
5389  m_ownProp = true;
5390  m_comReturn = sm_non;
5391  m_refcount = 0;
5392 }
5393 
5394 a2dComEvent::a2dComEvent( wxObject* sender, const a2dPropertyIdUint16* propId, wxUint16 propertyValue, a2dSignal id )
5395  : wxEvent( id, a2dEVT_COM_EVENT )
5396 {
5397  SetEventObject( sender );
5398  m_property = new a2dUint16Property( propId, propertyValue );
5399  m_ownProp = true;
5400  m_comReturn = sm_non;
5401  m_refcount = 0;
5402 }
5403 
5404 a2dComEvent::a2dComEvent( wxObject* sender, const a2dPropertyIdInt32* propId, wxInt32 propertyValue, a2dSignal id )
5405  : wxEvent( id, a2dEVT_COM_EVENT )
5406 {
5407  SetEventObject( sender );
5408  m_property = new a2dInt32Property( propId, propertyValue );
5409  m_ownProp = true;
5410  m_comReturn = sm_non;
5411  m_refcount = 0;
5412 }
5413 
5414 a2dComEvent::a2dComEvent( wxObject* sender, const a2dPropertyIdDouble* propId, double propertyValue, a2dSignal id )
5415  : wxEvent( id, a2dEVT_COM_EVENT )
5416 {
5417  SetEventObject( sender );
5418  m_property = new a2dDoubleProperty( propId, propertyValue );
5419  m_ownProp = true;
5420  m_comReturn = sm_non;
5421  m_refcount = 0;
5422 }
5423 
5424 a2dComEvent::a2dComEvent( wxObject* sender, const a2dPropertyIdString* propId, const wxString& propertyValue, a2dSignal id )
5425  : wxEvent( id, a2dEVT_COM_EVENT )
5426 {
5427  SetEventObject( sender );
5428  m_property = new a2dStringProperty( propId, propertyValue );
5429  m_ownProp = true;
5430  m_comReturn = sm_non;
5431  m_refcount = 0;
5432 }
5433 
5434 a2dComEvent::a2dComEvent( wxObject* sender, bool propertyValue, a2dSignal id )
5435  : wxEvent( id, a2dEVT_COM_EVENT )
5436 {
5437  SetEventObject( sender );
5438  m_property = new a2dBoolProperty( a2dPropertyIdBool::GetDummy(), propertyValue );
5439  m_ownProp = true;
5440  m_comReturn = sm_non;
5441  m_refcount = 0;
5442 }
5443 
5444 a2dComEvent::a2dComEvent( wxObject* sender, wxInt16 propertyValue, a2dSignal id )
5445  : wxEvent( id, a2dEVT_COM_EVENT )
5446 {
5447  SetEventObject( sender );
5448  m_property = new a2dInt16Property( a2dPropertyIdInt16::GetDummy(), propertyValue );
5449  m_ownProp = true;
5450  m_comReturn = sm_non;
5451  m_refcount = 0;
5452 }
5453 
5454 a2dComEvent::a2dComEvent( wxObject* sender, wxUint16 propertyValue, a2dSignal id )
5455  : wxEvent( id, a2dEVT_COM_EVENT )
5456 {
5457  SetEventObject( sender );
5458  m_property = new a2dUint16Property( a2dPropertyIdUint16::GetDummy(), propertyValue );
5459  m_ownProp = true;
5460  m_comReturn = sm_non;
5461  m_refcount = 0;
5462 }
5463 
5464 a2dComEvent::a2dComEvent( wxObject* sender, wxInt32 propertyValue, a2dSignal id )
5465  : wxEvent( id, a2dEVT_COM_EVENT )
5466 {
5467  SetEventObject( sender );
5468  m_property = new a2dInt32Property( a2dPropertyIdInt32::GetDummy(), propertyValue );
5469  m_ownProp = true;
5470  m_comReturn = sm_non;
5471  m_refcount = 0;
5472 }
5473 
5474 a2dComEvent::a2dComEvent( wxObject* sender, wxUint32 propertyValue, a2dSignal id )
5475  : wxEvent( id, a2dEVT_COM_EVENT )
5476 {
5477  SetEventObject( sender );
5478  m_property = new a2dUint32Property( a2dPropertyIdUint32::GetDummy(), propertyValue );
5479  m_ownProp = true;
5480  m_comReturn = sm_non;
5481  m_refcount = 0;
5482 }
5483 
5484 a2dComEvent::a2dComEvent( wxObject* sender, double propertyValue, a2dSignal id )
5485  : wxEvent( id, a2dEVT_COM_EVENT )
5486 {
5487  SetEventObject( sender );
5488  m_property = new a2dDoubleProperty( a2dPropertyIdDouble::GetDummy(), propertyValue );
5489  m_ownProp = true;
5490  m_comReturn = sm_non;
5491  m_refcount = 0;
5492 }
5493 
5494 a2dComEvent::a2dComEvent( wxObject* sender, const wxString& propertyValue, a2dSignal id )
5495  : wxEvent( id, a2dEVT_COM_EVENT )
5496 {
5497  SetEventObject( sender );
5498  m_property = new a2dStringProperty( a2dPropertyIdString::GetDummy(), propertyValue );
5499  m_ownProp = true;
5500  m_comReturn = sm_non;
5501  m_refcount = 0;
5502 }
5503 
5504 a2dComEvent::a2dComEvent()
5505  : wxEvent( sm_non, a2dEVT_COM_EVENT )
5506 {
5507  SetEventObject( 0 );
5508  m_ownProp = false;
5509  m_comReturn = sm_non;
5510  m_refcount = 0;
5511 }
5512 
5513 a2dComEvent::~a2dComEvent()
5514 {
5515  wxASSERT_MSG( m_refcount == 0, wxT( "deleting a2dComEvent while referenced" ) );
5516  if ( m_ownProp )
5517  delete m_property;
5518 }
5519 
5520 a2dComEvent::a2dComEvent( const a2dComEvent& other )
5521  : wxEvent( other )
5522 {
5523  m_property = other.m_property ? other.m_property->Clone( a2dObject::clone_flat ) : 0;
5524  m_ownProp = true;
5525  m_comReturn = other.m_comReturn;
5526 
5527 #if defined(_DEBUG) && defined (SMART_POINTER_DEBUG)
5528  //klion: it is because the CurrentSmartPointerOwner can change in Clone ( )
5529  CurrentSmartPointerOwner = this;
5530 #endif
5531  m_refcount = 0;
5532 }
5533 
5534 wxEvent* a2dComEvent::Clone( void ) const
5535 {
5536  return new a2dComEvent( *this );
5537 }
5538 
5539 const a2dPropertyId* a2dComEvent::GetPropertyId() const
5540 {
5541  return m_property ? m_property->GetId() : 0;
5542 }
5543 
virtual double GetDouble() const
when a2dDoubleProperty, return its value else assert
Definition: gen.cpp:1928
bool GetAttributeValueBool(const wxString &attrib, bool defaultv=false)
Returns the boolean value of an attribute.
Definition: genxmlpars.cpp:537
bool m_result
result of walk, set false at start, use at will.
Definition: gen.h:3984
a2dHashMapCreateObject m_objectCreate
This is used to find a classname using a symbolic name.
Definition: gen.h:3549
a2dNamedProperty * GetVariableClone(const wxString &variableName)
get an existing variable of unknown type (cloned)
Definition: gen.cpp:4303
const a2dError a2dError_LinkRef
property to hold an unsigned 4 byte integer type variable to be associated with a a2dObject ...
Definition: gen.h:2453
void SetLastError(a2dError error)
set last error encountered
Definition: gen.h:3541
a2dIOHandler()
constructor
Definition: gen.cpp:4903
(In) Visible property that can be added to Docview Objects.
Definition: gen.h:1785
virtual wxString GetString() const
when a2dStringProperty, return its value else assert
Definition: gen.cpp:1922
A2DGENERALDLLEXP long wxGenNewId()
This function is like wxNewId, but it has its own ID set.
Definition: gen.cpp:92
virtual wxString StringRepresentation() const
Definition: gen.cpp:4002
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:3545
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
Definition: gen.h:75
bool m_check
used for linking multiple referenced objects when serializing
Definition: gen.h:1567
~a2dNamedPropertyList()
Destructor.
Definition: gen.cpp:2053
virtual wxString StringRepresentation() const
Definition: gen.cpp:2997
static a2dArrayStringProperty * CreatePropertyFromString(const a2dPropertyIdArrayString *id, const wxString &value)
Definition: gen.cpp:3235
~a2dIOHandlerStrIn()
destructor
Definition: gen.cpp:4966
static a2dDateTimeProperty * CreatePropertyFromString(const a2dPropertyIdDateTime *id, const wxString &value)
Definition: gen.cpp:3452
static const a2dSignal sm_Edit_properties
edit properties event, see EditProperties()
Definition: gen.h:1606
const a2dError a2dError_CommandError
void SaveAsDocument(a2dIOHandlerXmlSerOut &out)
Save this object and all below as an XML document.
Definition: gen.cpp:1321
void SetURI(const wxURI &url)
quickly set a property PROPID_URI
Definition: gen.cpp:1645
const a2dError a2dError_NoDocTemplateRef
bool HasAttribute(const wxString &attrib)
Does the current tag have this attribute?
Definition: genxmlpars.cpp:560
virtual void InitializeLoad()
Inits the handler for reading.
Definition: gen.cpp:4971
static const a2dSignal sm_changedProperty
Definition: gen.h:381
wxColour A2DGENERALDLLEXP HexToColour(const wxString &hex)
3-digit hex to wxColour
Definition: gen.cpp:5279
virtual bool HasProperty(const a2dPropertyId *id, const wxString &stringvalue=wxEmptyString) const
Check if the object has a property with given id and string representation.
Definition: gen.cpp:1621
static a2dVoidPtrProperty * CreatePropertyFromString(const a2dPropertyIdVoidPtr *id, const wxString &value)
Definition: gen.cpp:2370
a2dComEvent(wxObject *sender, a2dSignal id)
for sending just an event id, m_property is not set
Definition: gen.cpp:5321
Simple Memory manager for some objects which often create and destroy to replace OS-system calls...
Definition: a2dmemmgr.h:20
virtual wxString GetName() const
Returns the name of this object, if no name is given the internal id will be returned.
Definition: gen.cpp:1310
fundamental classes used by all other modules.
virtual bool IsTemporary_DontSave() const
Check if this is a temporary object, which should not be saved.
Definition: gen.h:1258
wxString FindValidPath(const wxString &filename, bool reportError=true)
Find the first full path for which the file exists.
Definition: gen.cpp:4486
property to hold a a2dObject pointer type variable to be associated with a a2dObject ...
Definition: gen.h:2250
XMLeventType Next()
Walks to next element and returns event type.
Definition: genxmlpars.cpp:422
const a2dError a2dError_GetVar
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Definition: gen.cpp:3637
bool ResolveOrAdd(a2dSmrtPtr< a2dObject > *storedHere, const wxString &id=wxT(""))
try to resolve the object that is in storedHere when it is a reference.
Definition: gen.cpp:4760
class to map references to objects stored in XML, in order to make the connection later on...
Definition: gen.h:3462
wxString GetVariableString(int index)
get an existing wxString variable
Definition: gen.cpp:4417
static a2dUint16Property * CreatePropertyFromString(const a2dPropertyIdUint16 *id, const wxString &value)
Definition: gen.cpp:2772
virtual wxInt32 GetInt32() const
when a2dInt32Property, return its value else assert
Definition: gen.cpp:1958
virtual wxString GetName() const
Get the ids print and serialization name.
Definition: id.h:245
see a2dCommandProcessorEvent
Definition: comevt.h:649
void RemoveTemporaryProperties()
remove all temporary properties
Definition: gen.cpp:1584
void Walker(wxObject *parent, a2dWalkerIOHandler &handler)
walk a list of properties
Definition: gen.cpp:2096
void DecCurrentDepth()
Decrement recursion depth.
Definition: gen.h:3940
a2dPropertyIdTyped< wxString, a2dStringProperty > a2dPropertyIdString
property of this type
Definition: id.h:665
static a2dPropertyIdBool * PROPID_Check
used for linking multiple referenced objects when serializing
Definition: gen.h:1599
a2dAutoZeroPtr< a2dObject > * m_autozeroptrlist
this is a list of all a2dAutoZeroPtr object pointing to this object
Definition: gen.h:1580
bool m_recursion_active
this is used as a recursion stopper
Definition: gen.h:1573
const a2dError a2dError_CouldNotEvaluatePath
virtual wxString StringValueRepresentation() const
Definition: gen.cpp:2206
static a2dPropertyIdTyped< basetype, proptype > * GetDummy()
returns a dummy property id of this type, that can be used in non-id applications ...
Definition: id.inl:389
virtual void InitializeSave()
Inits the handler for writing.
Definition: gen.cpp:5095
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Definition: gen.cpp:3474
const a2dPropertyId * m_id
The property id object identifying this property.
Definition: gen.h:1945
void LoadFromDocument(a2dIOHandlerXmlSerIn &parser)
Load this object and all below from an XML document.
Definition: gen.cpp:1385
virtual void ResetSave()
Reset the object after saving.
Definition: gen.cpp:5101
virtual wxString StringRepresentation() const
Definition: gen.cpp:2722
void WriteStartElementAttributes(const wxString &name, bool newLine=true)
Writes start tag which has attributes.
Definition: genxmlpars.cpp:757
virtual void DoWalker(wxObject *parent, a2dWalkerIOHandler &handler)
iterate over this object and its children
Definition: gen.cpp:1488
Ref Counted base object.
Definition: gen.h:1045
virtual wxString StringRepresentation() const
Definition: gen.cpp:2898
Flags
Flags for property ids.
Definition: id.h:158
virtual wxString StringRepresentation() const
Definition: gen.cpp:3501
~a2dVariablesArray()
destructor
Definition: gen.cpp:4350
const a2dError a2dError_NoError
a2dIOHandler takes care of loading and/or saving data.
Definition: gen.h:3592
a2dObject()
constructor
Definition: gen.cpp:1184
a2dObject * Clone(CloneOptions options, a2dRefMap *refs=NULL) const
create an exact copy of this property
Definition: gen.cpp:1199
virtual bool AlwaysWriteSerializationId() const
If true, always write an id.
Definition: gen.cpp:1455
virtual void SetNamedPropertyToObject(a2dObject *obj, a2dNamedProperty *nprop, SetFlags setflags=set_none) const
Set the property in obj to value (not cloning value)
Definition: id.cpp:92
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:2457
property to hold a double type variable to be associated with a a2dObject
Definition: gen.h:2503
void DeleteAll()
delete all variables in the array
Definition: gen.cpp:4359
virtual int GetCurrentLineNumber()
where in the input was line the current tag
Definition: genxmlpars.cpp:349
void ConnectEvent(wxEventType type, wxEvtHandler *eventSink)
Definition: gen.cpp:876
a2dDocumentInputStream * m_streami
file or other string stream containing the format to parse.
Definition: gen.h:3734
int GetAttributeValueInt(const wxString &attrib, int defaultv=0)
Returns the integer value of an attribute.
Definition: genxmlpars.cpp:495
a2dPropertyIdTyped< wxInt32, a2dInt32Property > a2dPropertyIdInt32
property of this type
Definition: id.h:649
property to hold a bool type variable to be associated with a a2dObject
Definition: gen.h:2004
void IncCurrentDepth()
Increment recursion depth.
Definition: gen.h:3937
const a2dError a2dError_FileCouldNotOpen
bool IsCloneDeep() const
Test if this id identifies a property that needs to be cloned deep.
Definition: id.h:263
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:2766
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:3229
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:819
a2dNamedPropertyList m_propertylist
properties
Definition: gen.h:1561
Path searching.
Definition: gen.h:2926
wxString A2DGENERALDLLEXP ColourToHex(const wxColour &colour)
RGB to 3-digit hex.
Definition: gen.cpp:5295
virtual wxUint32 GetUint32() const
when a2dUint32Property, return its value else assert
Definition: gen.cpp:1964
A2DGENERALDLLEXP void wxGenRegisterId(long id)
see wxGenNewId(), use this to resrve a specific id
Definition: gen.cpp:97
bool SetVariableRefObject(const wxString &variableName, a2dObject *value)
set a new or replace an existing a2dObject variable
Definition: gen.cpp:4242
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dNamedPropertyEnd
id for a2dWalkEvent issued from within a2dWalkerIOHandler
const a2dError a2dError_NoTool
virtual void Initialize()
initialize mapping tables
Definition: gen.cpp:4753
a2dResolveIdList m_toResolve
refernces to object which have not bin resolved yet ( e.g not read yet, but already referenced ) ...
Definition: gen.h:3552
virtual wxString StringRepresentation() const
Definition: gen.cpp:3085
a2dPropertyIdTyped< bool, a2dBoolProperty > a2dPropertyIdBool
property of this type
Definition: id.h:655
property to hold a wxURI type variable to be associated with a a2dObject
Definition: gen.h:3095
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dNamedPropertyListStart
id for a2dWalkEvent issued from within a2dWalkerIOHandler
a2dNamedProperty * GetProperty(const a2dPropertyId *propertyId, a2dPropertyId::Flags flags=a2dPropertyId::flag_none) const
get property on this object
Definition: gen.cpp:1590
const a2dError a2dError_DocumentsOpened
void Write8(wxUint8 i)
write a 8 bits integer
Definition: gen.cpp:5191
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dCanvasObjectPreChild
id for a2dWalkEvent issued from within a2dWalkerIOHandler
using a file stream for input, stream the file into a a2dDocument or other object ...
Definition: gen.h:3632
virtual void * GetVoidPtr() const
when a2dVoidPtrProperty, return its value else assert
Definition: gen.cpp:1970
wxEOL m_mode
end of line mode
Definition: gen.h:3740
wxString GetName() const
Get the name of the a2dPropertyId object.
Definition: gen.h:1864
list of a2dNamedProperty objects
Definition: gen.h:804
void CheckReferences()
Check zero reference count and delete if count is 0.
Definition: gen.cpp:1280
see wx/general/smrtptr.h
a2dIOHandlerStrOut & PutChar(wxChar c)
write on character
Definition: gen.cpp:5216
void Walker(wxObject *parent, a2dWalkerIOHandler &handler)
This is used to recursively walk through an object tree.
Definition: gen.cpp:1907
int m_nelements
number of used elements in m_properties
Definition: gen.h:3414
bool IsTemporary() const
Test if this id identifies a temporary property.
Definition: id.h:265
const long a2dWalkEvent
Definition: gen.h:3842
~a2dWalkerIOHandler()
destructor
Definition: gen.cpp:5253
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:3779
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:2854
virtual const a2dPropertyId * CreateId(a2dObject *parent, const wxString &name)
creates an a2dPropertyId for this property, if it is not available.
Definition: gen.cpp:2159
property to hold a window type variable (for example wxTipWindow) to be associated with a a2dObject ...
Definition: gen.h:2806
const a2dError a2dError_LoadFile
wxEOL m_mode
end of line mode
Definition: gen.h:3828
property to hold a FileName type variable to be associated with a a2dObject
Definition: gen.h:3035
class A2DGENERALDLLEXP a2dVariablesHashBase
wxString keys plus a2dObject pointers
Definition: gen.h:3205
property to hold a a2dObjectPtr smart pointer type variable to be associated with a a2dObject ...
Definition: gen.h:2199
property to hold a wxArrayString type variable to be associated with a a2dObject
Definition: gen.h:2605
bool RemoveReference(const wxString &idToRemove)
remove given reference if from reference map.
Definition: gen.cpp:4844
static a2dPropertyIdUri * PROPID_URI
attach an URL to the object
Definition: gen.h:1601
no special flags set
Definition: id.h:161
void SetMinSize(int size)
set the minimum size for the array
Definition: gen.cpp:4429
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:3706
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dDerivedCanvasObjectStart
id for a2dWalkEvent issued from within a2dWalkerIOHandler
void TakeOverProperties(a2dObject *from, a2dPropertyIdList *listOfIds)
Properties in the id list are taken from the given object, en set to this.
Definition: gen.cpp:1527
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Definition: gen.cpp:3725
virtual a2dObject * GetRefObject() const
when a2dProperty, return its value else assert
Definition: gen.cpp:1976
Definition: gen.h:276
bool m_stopWalking
quit the iteration
Definition: gen.h:3993
virtual wxObject * CreateObject(const wxString &symbolicName)
Creates an specific object by name.
Definition: gen.cpp:4937
property to hold a 2 byte integer type variable to be associated with a a2dObject ...
Definition: gen.h:2301
a2dObject * GetVariableRefObject(int index)
get an existing a2dObject variable
Definition: gen.cpp:4411
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dNamedPropertyStart
id for a2dWalkEvent issued from within a2dWalkerIOHandler
void Write16(wxUint16 i)
write a 16 bits integer
Definition: gen.cpp:5183
virtual wxString StringRepresentation() const
Definition: gen.cpp:2406
a2dRefMap()
constructor
Definition: gen.cpp:4719
virtual void SetName(const wxString &name)
Creates the a2dStringProperty PROPID_Name.
Definition: gen.cpp:1305
void AppendVariableInt(int value)
add a new int variable
Definition: gen.cpp:4393
virtual wxString StringValueRepresentation() const
Definition: gen.cpp:4010
void WriteEndElement(bool newLine=true)
Writes correspondending end tag for the current start tag.
Definition: genxmlpars.cpp:862
const a2dNamedProperty * GetVariable(const wxString &variableName)
get an existing variable of unknown type (not cloned)
Definition: gen.cpp:4294
a2dObject * Find(const wxString &classname=wxT(""), const wxString &name=wxT(""))
Find object within the given property name and classname.
Definition: gen.cpp:4151
void AppendVariableRefObject(a2dObject *value)
add a new a2dObject variable
Definition: gen.cpp:4375
virtual wxString StringValueRepresentation() const
Definition: gen.cpp:3508
static a2dColourProperty * CreatePropertyFromString(const a2dPropertyIdColour *id, const wxString &value)
Construct a new property object from a string.
Definition: gen.cpp:3955
void SetProperty(a2dNamedProperty *propertyHolder, a2dPropertyId::SetFlags flags=a2dPropertyId::set_none)
Set the property to the this object.
Definition: gen.cpp:1605
const a2dError a2dError_FileHistory
const a2dError a2dError_CanceledFileDialog
const a2dError a2dError_IOHandler
void WriteStartDocument(const wxString &version, const wxString &encoding, bool standalone)
Writes the XML header declaration.
Definition: genxmlpars.cpp:723
bool m_release
when set object is treated as being deleted, and wil be deleted in idle time.
Definition: gen.h:1570
static a2dBoolProperty * CreatePropertyFromString(const a2dPropertyIdBool *id, const wxString &value)
Construct a new property object from a string.
Definition: gen.cpp:2148
const a2dNamedProperty & GetVariable(int index)
get an existing variable of unknown type (not cloned)
Definition: gen.cpp:4399
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:2241
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dObjectStart
id for a2dWalkEvent issued from within a2dWalkerIOHandler
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dCanvasObjectPostChild
id for a2dWalkEvent issued from within a2dWalkerIOHandler
const a2dError a2dError_CouldNotCreateDocument
static a2dStringProperty * CreatePropertyFromString(const a2dPropertyIdString *id, const wxString &value)
Definition: gen.cpp:2247
XML I/O classes which is Pull parser based for reading XML files.
const a2dError a2dError_NoSelection
void AppendVariableDouble(double value)
add a new double variable
Definition: gen.cpp:4387
property to hold a wxDateTime type variable to be associated with a a2dObject
Definition: gen.h:2710
virtual void OnPropertyChanged(const a2dPropertyId *id)
This function is called after a property changed.
Definition: gen.cpp:1635
a2dHashMapIntToObject m_objecthashmap
This is used to find multiple referenced objects by id.
Definition: gen.h:3546
SetFlags
Flags used for manipulating the way a property is set to a2dObject.
Definition: id.h:219
Io handler to iterate through a a2dDocument.
Definition: gen.h:3911
a2dIOHandlerStrIn & SeekI(wxFileOffset pos)
set stream at a position
Definition: gen.cpp:5021
property to hold a 2 byte integer type variable to be associated with a a2dObject ...
Definition: gen.h:2401
bool GetCheck() const
general flag use at will.
Definition: gen.h:1342
bool SetVariable(const wxString &variableName, a2dNamedProperty *property)
set a new or replace an existing variable of arbitrary type
Definition: gen.cpp:4229
wxObject * m_currentParent
parent object of current object
Definition: gen.h:3987
void RemoveTemporary()
Remove all temporrary properties from the list.
Definition: gen.cpp:2081
void WriteNewLine()
Writes a new line and takes care of indentation.
Definition: genxmlpars.cpp:890
bool SetVariableDouble(const wxString &variableName, double value)
set a new or replace an existing double variable
Definition: gen.cpp:4268
a2dIOHandlerStrIn(wxMBConv &conv=wxConvUTF8)
constructor
Definition: gen.cpp:4951
std list compatible list
Definition: a2dlist.h:42
A property id for a property which is editable.
Definition: id.h:210
bool(* a2dObjectIOFn)(wxObject *parent, wxObject *object, a2dWalkEvent)
a functions to store in a hash table
Definition: gen.h:3880
virtual bool EditProperties(const a2dPropertyId *id, bool withUndo=true)
edit properties of the object
Definition: gen.cpp:1499
const a2dError a2dError_SaveFile
static a2dFileNameProperty * CreatePropertyFromString(const a2dPropertyIdFileName *id, const wxString &value)
Definition: gen.cpp:3357
bool CheckFlags(Flags flags) const
check a flag mask (all given flags must be set)
Definition: id.h:282
void SkipSpaces(unsigned int &position)
parse whitespace and skip it form teh value string
Definition: gen.cpp:2019
virtual wxString StringRepresentation() const
Definition: gen.cpp:2201
#define forEachIn(listtype, list)
easy iteration for a2dlist
Definition: a2dlist.h:111
void SkipSubTree()
Skips all child elements / tags of current element / tag.
Definition: genxmlpars.cpp:652
static a2dInt16Property * CreatePropertyFromString(const a2dPropertyIdInt16 *id, const wxString &value)
Definition: gen.cpp:2684
virtual wxString StringValueRepresentation() const
Definition: gen.cpp:2817
void SetPropertyToObject(a2dObject *obj, const basetype &value, SetFlags setflags=set_none) const
Set the property in obj to value.
Definition: id.inl:238
void SetLastObjectLoadedId(const wxString &lastid)
set by RefObject when finding a reference id during loading.
Definition: gen.cpp:4838
void Walker(wxObject *parent, a2dWalkerIOHandler &handler)
This is used to recursively walk through an object tree.
Definition: gen.cpp:1473
virtual wxString StringRepresentation() const
Definition: gen.cpp:3402
property to hold a Menu type variable to be associated with a a2dObject
Definition: gen.h:2764
static a2dTipWindowProperty * CreatePropertyFromString(const a2dPropertyIdWindow *id, const wxString &value)
Definition: gen.cpp:3744
a2dNamedPropertyList()
Default constructor.
Definition: gen.h:808
virtual ~a2dObject()
destructor
Definition: gen.cpp:1253
const a2dError a2dError_XMLparse
const a2dError a2dError_NoWrapper
virtual bool GetBool() const
when a2dBoolProperty, return its value else assert
Definition: gen.cpp:1940
const a2dError a2dError_canvasObjectRelease
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
Definition: gen.h:123
const a2dError a2dError_CouldNotLoad
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Save settings.
Definition: gen.cpp:1657
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:3446
const a2dError a2dError_LinkPin
const a2dError a2dError_FileVersion
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:2364
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dNamedPropertyListEnd
id for a2dWalkEvent issued from within a2dWalkerIOHandler
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
Definition: comevt.cpp:1148
static const a2dSignal sm_non
Definition: gen.h:387
a2dNamedProperty * Clone(a2dObject::CloneOptions options, a2dRefMap *refs=NULL) const
Virtual copy constructor.
Definition: gen.cpp:1820
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dCanvasObjectProperties
id for a2dWalkEvent issued from within a2dWalkerIOHandler
virtual wxString StringRepresentation() const
Definition: gen.cpp:2523
const a2dPropertyId * GetId() const
Get the a2dPropertyId object identifying this property.
Definition: gen.h:1858
Holds internal variables to be used whereever needed.
Definition: gen.h:3223
a2dVariablesHash()
constructor
Definition: gen.cpp:4193
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Definition: gen.cpp:4053
const a2dError a2dError_LoadObject
~a2dRefMap()
destructor
Definition: gen.cpp:4726
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:2953
Input and output handler for the XmlSer format.
Definition: genxmlpars.h:862
const a2dError a2dError_SetEnv
static a2dUriProperty * CreatePropertyFromString(const a2dPropertyIdUri *id, const wxString &value)
Definition: gen.cpp:4088
a2dIOHandlerStrOut(wxMBConv &conv=wxConvUTF8)
constructor
Definition: gen.cpp:5075
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:2142
virtual wxUint16 GetUint16() const
when a2dUint16Property, return its value else assert
Definition: gen.cpp:1952
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Definition: gen.cpp:3563
void Write32(wxUint32 i)
write a 32 bits integer
Definition: gen.cpp:5175
bool IsOk() const
is the stream Oke to write
Definition: gen.cpp:5207
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dObjectEnd
id for a2dWalkEvent issued from within a2dWalkerIOHandler
bool GetEdited()
when properties where edited, this must become true
Definition: comevt.h:665
static const a2dSignal sm_changedRefObject
Definition: gen.h:384
virtual ~a2dNamedProperty()
Destructor.
Definition: gen.cpp:1803
wxString RequireAttributeValue(const wxString &attrib)
Forces an attribute and returns its string value.
Definition: genxmlpars.cpp:461
the property is temporary and never saved
Definition: id.h:163
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dPropertyStart
id for a2dWalkEvent issued from within a2dWalkerIOHandler
a2dHashMapIntToObject & GetObjectHashMap()
This is used to find multiple referenced objects by id.
Definition: gen.h:3479
void WriteEndAttributes(bool close=false)
&quot;Closes&quot; the start tag after writing all attributes (writes the &quot;&gt;&quot; or &quot;/&gt;&quot; bracket).
Definition: genxmlpars.cpp:837
wxURI GetURI() const
quick way to get to PROPID_URI property
Definition: gen.cpp:1650
wxString * GetVariableString(const wxString &variableName)
get an existing wxString variable
Definition: gen.cpp:4321
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dCanvasObjectStart
id for a2dWalkEvent issued from within a2dWalkerIOHandler
static a2dInt32Property * CreatePropertyFromString(const a2dPropertyIdInt32 *id, const wxString &value)
Definition: gen.cpp:2860
int m_refcount
how many references to this object do exist
Definition: gen.h:1564
property to hold a tip window type variable to be associated with a a2dObject
Definition: gen.h:2850
void SetCheck(bool check)
general flag use at will.
Definition: gen.h:1339
property to hold a wxString type variable to be associated with a a2dObject
Definition: gen.h:2066
wxString FindAbsoluteValidPath(const wxString &filename)
Definition: gen.cpp:4547
virtual wxString StringValueRepresentation() const
Definition: gen.cpp:2729
bool GetUseCheck()
see SetUseCheck
Definition: gen.h:3955
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:2574
a2dObjectList * Clone(a2dObject::CloneOptions options, a2dRefMap *refs=NULL) const
Clone everything ( Clones objects also) in a new created list.
Definition: gen.cpp:4120
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Definition: gen.cpp:3793
static a2dPropertyIdString * PROPID_Name
Name property, to return name of this object.
Definition: gen.h:1603
double ParseDouble(unsigned int &position)
parse a double from the value string
Definition: gen.cpp:1987
using a file stream for output, stream a a2dDocument or other wxObject into a stream.
Definition: gen.h:3751
A pointer class, that is automatically set to 0 if the target is deleted.
Definition: smrtptr.h:347
const a2dError a2dError_SaveObject
virtual a2dObject * GetRefObjectNA() const
when a2dProperty, return its value else return NULL
Definition: gen.cpp:1982
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Definition: gen.cpp:4067
virtual wxString StringValueRepresentation() const
Definition: gen.cpp:3092
const a2dError a2dError_ImportObject
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dCanvasObjectEnd
id for a2dWalkEvent issued from within a2dWalkerIOHandler
static a2dMenuProperty * CreatePropertyFromString(const a2dPropertyIdMenu *id, const wxString &value)
Definition: gen.cpp:3582
int m_currentDepth
contour to be used by algorithm, to decide on how deep recursing is to be.
Definition: gen.h:3996
virtual wxString StringValueRepresentation() const
Definition: gen.cpp:3004
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:3949
virtual wxString StringRepresentation() const
Definition: gen.cpp:3293
const a2dError a2dError_Canceled
virtual wxString StringValueRepresentation() const
Definition: gen.cpp:3307
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Load settings.
Definition: gen.cpp:1699
const a2dError a2dError_NoPinClass
virtual wxString StringValueRepresentation() const
Definition: gen.cpp:3409
virtual const a2dPropertyId * CreateId(a2dObject *parent, const wxString &name)
creates an a2dPropertyId for this property, if it is not available.
Definition: gen.cpp:2912
virtual wxString StringValueRepresentation() const
Definition: gen.cpp:2528
static a2dWindowProperty * CreatePropertyFromString(const a2dPropertyIdWindow *id, const wxString &value)
Definition: gen.cpp:3656
virtual float GetFloat() const
when a2dFloatProperty, return its value else assert
Definition: gen.cpp:1934
virtual a2dObject * SetNonDynamic()
Call to mark this object as non-dynamic (static/local/auto)
Definition: gen.cpp:1298
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:3130
class used in a2dResolveIdList to resolve references to other objects while readin in a file...
Definition: gen.h:734
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:2678
virtual const a2dPropertyId * CreateId(a2dObject *parent, const wxString &name)
creates an a2dPropertyId for this property, if it is not available.
Definition: gen.cpp:1807
virtual wxInt16 GetInt16() const
when a2dInt16Property, return its value else assert
Definition: gen.cpp:1946
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:3619
void ProcessConnectedEvent(wxEvent &event)
wxCHECK_VERSION(2,9,0)
Definition: gen.cpp:855
property to hold a FileName type variable to be associated with a a2dObject
Definition: gen.h:2976
static a2dProperty * CreatePropertyFromString(const a2dPropertyIdRefObject *id, const wxString &value)
Definition: gen.cpp:2463
virtual void Load(wxObject *parent, a2dIOHandlerXmlSerIn &parser)
load object from CVG file
Definition: gen.cpp:1396
property to hold a void pointer type variable to be associated with a a2dObject
Definition: gen.h:2117
wxString GetAttributeValue(const wxString &attrib, const wxString &defaultv=wxT(""))
Returns the value of an attribute.
Definition: genxmlpars.cpp:450
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dPropertyEnd
id for a2dWalkEvent issued from within a2dWalkerIOHandler
const a2dError a2dError_NoView
virtual wxString StringRepresentation() const
Definition: gen.cpp:3831
int GetOwnedBy()
like it to be protected, but this does not work with wxList macros
Definition: gen.h:1173
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:3351
bool SetVariableInt(const wxString &variableName, int value)
set a new or replace an existing int variable
Definition: gen.cpp:4281
virtual wxString StringValueRepresentation() const
Definition: gen.cpp:3181
static a2dFloatProperty * CreatePropertyFromString(const a2dPropertyIdFloat *id, const wxString &value)
Definition: gen.cpp:3136
a2dNamedProperty()
Default constructor.
Definition: gen.cpp:1748
virtual wxString StringValueRepresentation() const
Definition: gen.cpp:2905
void WriteEndDocument()
Checks if all open tags are closed.
Definition: genxmlpars.cpp:730
virtual bool AddProperty(a2dNamedProperty *property)
This function is called by a2dPropertyId to add a property to the list.
Definition: gen.cpp:1541
virtual void ResolveInform()
inform an object that reference resolution was done
Definition: gen.cpp:1467
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
XMLeventType GetEventType()
Returns the type of current event.
Definition: genxmlpars.cpp:606
void Require(const XMLeventType &type, wxString name)
Forces a special tag.
Definition: genxmlpars.cpp:390
const a2dError a2dError_LoadLayers
const a2dError a2dError_ImportFile
bool Release(const wxString &classname=wxT(""), bool all=false)
Definition: gen.cpp:4129
wxString GetTagName()
Returns name of the current XML tag.
Definition: genxmlpars.cpp:565
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Definition: gen.cpp:3806
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:4046
if set, clone properties (e.g. fill style), otherwise ref-copy them
Definition: gen.h:1205
static a2dUint32Property * CreatePropertyFromString(const a2dPropertyIdUint32 *id, const wxString &value)
Definition: gen.cpp:2959
void SetToObject(a2dObject *obj, a2dPropertyId::SetFlags setflags=a2dPropertyId::set_none)
Set this property to an object.
Definition: gen.h:1851
const a2dError a2dError_GetEnv
wxString GetVariableAsString(int index)
get an existing variable of any type as String
Definition: gen.cpp:4423
property to hold a wxObject variable to be associated with a a2dObject
Definition: gen.h:2164
a2dObject * GetVariableRefObject(const wxString &variableName)
get an existing a2dObject variable
Definition: gen.cpp:4312
virtual bool LinkReference(a2dObject *other)
link a reference in the object to the given value
Definition: gen.cpp:1460
command processor and intializing and event handling classes specific for wxDocview.
int CollectObjects(a2dObjectList *total, const wxString &propertyNameFilter=wxT(""), const wxString &classname=wxT(""))
Copy objects fitting the given filter to the total list.
Definition: gen.cpp:4169
virtual wxString StringRepresentation() const
Definition: gen.cpp:3174
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Definition: gen.cpp:3377
const a2dError a2dError_NotSpecified
virtual const a2dPropertyId * CreateId(a2dObject *parent, const wxString &name)
creates an a2dPropertyId for this property, if it is not available.
Definition: gen.cpp:2283
see a2dComEvent
Definition: gen.h:371
void SetMode(wxEOL mode=wxEOL_NATIVE)
define the line end mode for textual files
Definition: gen.cpp:5057
const a2dError a2dError_property
virtual wxString StringValueRepresentation() const
Definition: gen.h:1905
bool DisconnectEventAll(wxEvtHandler *eventSink)
Remove all dynamic events in classA, going to classB (eventSink)
Definition: gen.cpp:1021
static a2dDoubleProperty * CreatePropertyFromString(const a2dPropertyIdDouble *id, const wxString &value)
Definition: gen.cpp:3047
virtual wxString StringValueRepresentation() const
Definition: gen.cpp:3838
const a2dError a2dError_ToManyOpen
virtual void DoLoad(wxObject *parent, a2dIOHandlerXmlSerIn &parser, a2dXmlSer_flag xmlparts)
Definition: gen.cpp:3976
bool Remove(const a2dPropertyId *id, bool all=true)
Remove first/all properties with given id from the list.
Definition: gen.cpp:2057
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Definition: gen.cpp:3364
const a2dError a2dError_ExportFile
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Definition: gen.cpp:3961
const a2dError a2dError_NoDocument
virtual wxString StringRepresentation() const
Definition: gen.cpp:2638
virtual bool RemoveProperty(const a2dPropertyId *id, bool all=true)
This function is called by a2dPropertyId to remove a property from the list.
Definition: gen.cpp:1573
when set this type of property has no influence on rendering
Definition: id.h:204
virtual void Initialize()
to initialize a walker class, default does nothing.
Definition: gen.cpp:5257
A property id defined by user.
Definition: id.h:207
virtual bool WalkTask(wxObject *parent, wxObject *object, a2dWalkEvent event)
called from within a2dObject&#39;s and derived classes
Definition: gen.cpp:5265
wxString GetAsString()
Get all search paths as one string.
Definition: gen.cpp:4470
void operator=(const a2dVariablesHash &other)
assignment operator
Definition: gen.cpp:4209
basetype GetPropertyValue(const a2dObject *obj) const
Get the property value in obj.
Definition: id.inl:325
A2DGENERALDLLEXP a2dWalkEvent a2dWalker_a2dDerivedCanvasObjectEnd
id for a2dWalkEvent issued from within a2dWalkerIOHandler
int m_melements
number of elements in m_properties
Definition: gen.h:3416
virtual void Save(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dObjectList *towrite)
write all needed to an XML type of file called the CVG format
Definition: gen.cpp:1343
virtual a2dNamedProperty * FindProperty(const a2dPropertyId *id, a2dPropertyId::Flags flags=a2dPropertyId::flag_none)
Find a dynamic property with given id in the property list.
Definition: gen.cpp:1547
void SkipCommaSpaces(unsigned int &position)
parse comma, whitespace and skip it form teh value string
Definition: gen.cpp:2002
a2dNamedProperty * GetVariableClone(int index)
get an existing variable of unknown type (cloned)
Definition: gen.cpp:4405
bool GetStopWalking()
check for stop
Definition: gen.h:3934
This template class is for property ids with a known data type.
Definition: id.h:477
void operator=(const a2dObject &other)
assignment operator
Definition: gen.cpp:1259
void AppendVariable(a2dNamedProperty *property)
add a new variable of arbitrary type
Definition: gen.cpp:4369
holds one error report.
Definition: gen.h:623
wxMBConv & m_conv
unicode conversion
Definition: gen.h:3822
bool CheckCollect(const a2dPropertyId *id, Flags flags) const
check a property id and flags to see if the property shall be collected
Definition: id.h:284
virtual wxString StringRepresentation() const
Definition: gen.cpp:2810
a2dVariablesArray()
constructor
Definition: gen.cpp:4338
virtual void WriteDouble(double d)
write a double
Definition: gen.cpp:5199
Definition: gen.h:131
const a2dError a2dError_NoController
If a property with this id has changed its parent/holder will be notified.
Definition: id.h:213
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:2323
a2dIOHandlerCoupleHash m_register
coupling function to event and classname
Definition: gen.h:4010
a2dNamedProperty ** m_properties
this is the array of properties
Definition: gen.h:3412
property to hold a FileName type variable to be associated with a a2dObject
Definition: gen.h:2656
static a2dAutoZeroProperty * CreatePropertyFromString(const a2dPropertyIdRefObjectAutoZero *id, const wxString &value)
Definition: gen.cpp:2580
virtual wxString StringValueRepresentation() const
Definition: gen.cpp:2411
virtual wxString StringValueRepresentation() const
Definition: gen.cpp:2643
static a2dPathListProperty * CreatePropertyFromString(const a2dPropertyIdPathList *id, const wxString &value)
Definition: gen.cpp:3785
void AppendVariableString(const wxString &value)
add a new wxString variable
Definition: gen.cpp:4381
list of a2dObject&#39;s
Definition: gen.h:3157
virtual bool LinkReferences(bool ignoreNonResolved=false)
link references to their destination
Definition: gen.cpp:4862
property to hold a float type variable to be associated with a a2dObject
Definition: gen.h:2553
a2dDocumentOutputStream * m_streamo
file or other string stream containing the format to output to.
Definition: gen.h:3825
~a2dVariablesHash()
destructor
Definition: gen.cpp:4220
virtual void WriteString(const wxString &string)
write a string
Definition: gen.cpp:5107
virtual void DoSave(wxObject *parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts, a2dObjectList *towrite)
Definition: gen.cpp:3461
CloneOptions
options for cloning
Definition: gen.h:1200
bool DisconnectEvent(wxEventType type, wxEvtHandler *eventSink)
Definition: gen.cpp:902
virtual void ResetLoad()
Reset the handler after loading.
Definition: gen.cpp:4977
bool ResolveOrAddLink(a2dObject *obj, const wxString &id=wxT(""))
try to resolve an object referenced by obj using the LinkReference function
Definition: gen.cpp:4808
~a2dIOHandler()
destructor
Definition: gen.cpp:4910
wxInt64 GetUniqueSerializationId() const
return a unique id for this object
Definition: gen.cpp:1450
property to hold an unsigned 2 byte integer type variable to be associated with a a2dObject ...
Definition: gen.h:2351
~a2dIOHandlerStrOut()
destructor
Definition: gen.cpp:5091
virtual void Assign(const a2dNamedProperty &other)
Virtual assignment operator.
Definition: gen.cpp:3041
#define A2D_PROPID_D_F(type, propname, defaultval, flags)
to define a get set property more easily
Definition: id.h:714
void WriteStartElement(const wxString &name, bool newLine=true)
Writes start tag which has no attributes.
Definition: genxmlpars.cpp:738
void MakeUnique()
all with reference count &gt; 1 are cloned.
Definition: gen.cpp:4108
gen.cpp Source File -- Sun Oct 12 2014 17:04:20 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation