wxArt2D
canedit.cpp
Go to the documentation of this file.
1 /*! \file editor/src/canedit.cpp
2  \author Klaas Holwerda
3 
4  Copyright: 2000-2004 (c) Klaas Holwerda
5 
6  Licence: wxWidgets Licence
7 
8  RCS-ID: $Id: canedit.cpp,v 1.225 2009/09/30 19:17:00 titato Exp $
9 */
10 
11 #include "a2dprec.h"
12 
13 #ifdef __BORLANDC__
14 #pragma hdrstop
15 #endif
16 
17 #ifndef WX_PRECOMP
18 #include "wx/wx.h"
19 #endif
20 
21 #include "wx/colordlg.h"
22 
23 #if wxCHECK_VERSION(2, 5, 0)
24 #if !WXWIN_COMPATIBILITY_2_4
25 #include "wx/numdlg.h"
26 #endif
27 #endif
28 
29 #include <wx/wfstream.h>
30 #if wxUSE_XRC
31 #include <wx/xrc/xmlres.h>
32 #include <wx/docview/xh_a2dmenu.h>
33 #endif
34 
35 #include "wx/editor/editmod.h"
36 #include "wx/canextobj/sttoolext.h"
37 
38 #if wxART2D_USE_CANEXTOBJ
39 #include "wx/canextobj/canextmod.h"
40 #endif
41 
42 #if wxART2D_USE_GDSIO
43 #include "wx/gdsio/gdsio.h"
44 #endif //wxART2D_USE_GDSIO
45 
46 #include "images/smile.xpm"
47 #include "wx/docview/doccom.h"
48 
50 IMPLEMENT_DYNAMIC_CLASS( a2dEditorFrame, a2dDocumentFrame )
51 
52 
54  EVT_POST_CREATE_DOCUMENT( a2dEditorMultiFrameViewConnector::OnPostCreateDocument )
55  EVT_POST_CREATE_VIEW( a2dEditorMultiFrameViewConnector::OnPostCreateView )
56 END_EVENT_TABLE()
57 
58 a2dEditorMultiFrameViewConnector::a2dEditorMultiFrameViewConnector( wxClassInfo* EditorClassInfo )
60 {
61  m_editorClassInfo = EditorClassInfo;
62  m_initialStyle = a2dCanvasGlobals->m_initialDocChildFrameStyle;
63  m_initialPos = a2dCanvasGlobals->m_initialDocChildFramePos;
64  m_initialSize = a2dCanvasGlobals->m_initialDocChildFrameSize;
65 }
66 
67 
68 void a2dEditorMultiFrameViewConnector::OnPostCreateDocument( a2dTemplateEvent& event )
69 {
70  //a2dDocumentTemplate* templ = (a2dDocumentTemplate*) event.GetEventObject();
71  //a2dDocument *doc = event.GetDocument();
72 
73  a2dViewTemplate* viewtempl;
76 
77  if ( !viewtempl )
78  {
79  wxLogMessage( wxT( "No view available for this document in a2dEditorMultiFrameViewConnector" ) );
80  return;
81  }
82 
83  if ( !viewtempl->CreateView( event.GetDocument(), event.GetFlags() ) )
84  {
85  wxLogMessage( wxT( "a2dEditorMultiFrameViewConnector no view was created" ) );
86  return;
87  }
88 }
89 
90 
92 {
93  a2dCanvasView* drawer = ( a2dCanvasView* ) event.GetView();
94 
95  //a2dCanvasDocument* doc = (a2dCanvasDocument*) event.GetView()->GetDocument();
96 
97  if ( drawer->GetViewTypeName() == wxT( "Drawing View Frame" ) )
98  {
99  a2dEditorFrame* editorFrame;
100  if ( m_editorClassInfo )
101  {
102  editorFrame = ( a2dEditorFrame* ) m_editorClassInfo->CreateObject();
103  editorFrame->Create( false, false,
104  m_docframe,
106  GetInitialSize(),
108  );
109  a2dViewCanvas* canvas = new a2dViewCanvas( drawer, editorFrame, -1, GetInitialPosition(), GetInitialSize(), a2dCanvasGlobals->m_initialWorldCanvasStyle );
110  editorFrame->SetDrawingPart( canvas->GetDrawingPart() );
111  drawer->SetDisplayWindow( editorFrame->GetDrawingPart()->GetDisplayWindow() );
112  drawer->GetDrawingPart()->SetBufferSize( m_initialSize.GetWidth(), m_initialSize.GetHeight() );
113  editorFrame->Init();
114  }
115  else
116  {
117  drawer->GetDrawingPart()->SetBufferSize( m_initialSize.GetWidth(), m_initialSize.GetHeight() );
118  editorFrame = new a2dEditorFrame( false,
119  m_docframe,
121  GetInitialSize(),
123  );
124  drawer->SetDisplayWindow( editorFrame->GetDrawingPart()->GetDisplayWindow() );
125  editorFrame->Init();
126  }
127  editorFrame->Enable();
128  editorFrame->Show( true );
129  }
130  else if ( drawer->GetViewTypeName() == wxT( "Drawing Anti Aliased View Frame" ) )
131  {
132  a2dEditorFrame* editorFrame;
133  if ( m_editorClassInfo )
134  {
135  editorFrame = ( a2dEditorFrame* ) m_editorClassInfo->CreateObject();
136  editorFrame->Create( false,
137  false,
138  m_docframe,
140  GetInitialSize(),
142  );
144  a2dViewCanvas* canvas = new a2dViewCanvas( drawer, editorFrame, -1, GetInitialPosition(), GetInitialSize(), a2dCanvasGlobals->m_initialWorldCanvasStyle );
145  editorFrame->SetDrawingPart( canvas->GetDrawingPart() );
146  drawer->SetDisplayWindow( editorFrame->GetDrawingPart()->GetDisplayWindow() );
147  drawer->GetDrawingPart()->SetBufferSize( m_initialSize.GetWidth(), m_initialSize.GetHeight() );
148  drawer->GetDrawingPart()->SetShowObject( doc->GetDrawing()->GetRootObject() );
149  editorFrame->Init();
150  }
151  else
152  {
153  drawer->GetDrawingPart()->SetBufferSize( m_initialSize.GetWidth(), m_initialSize.GetHeight() );
154  editorFrame = new a2dEditorFrame( false,
155  m_docframe,
157  GetInitialSize(),
159  );
160  drawer->SetDisplayWindow( editorFrame->GetDrawingPart()->GetDisplayWindow() );
161  editorFrame->Init();
162  }
163  editorFrame->Enable();
164  editorFrame->Show( true );
165  }
166  else
167  wxLogMessage( wxT( "a2dEditorMultiFrameViewConnector not a -Drawing View Frame-, no view was created" ) );
168 
169  //this is the parent frame of all child frames, and keeps overview
170  m_docframe->Refresh();
171 }
172 
173 /********************************************************************
174 * a2dEditorFrame
175 *********************************************************************/
176 a2dEditorFrameEvent::a2dEditorFrameEvent( a2dEditorFrame* editorFrame, wxEventType type, int id )
177  : wxEvent( id, type )
178 {
179  SetEventObject( editorFrame );
180 }
181 
182 a2dEditorFrame* a2dEditorFrameEvent::GetEditorFrame() const
183 {
184  return wxDynamicCast( GetEventObject(), a2dEditorFrame );
185 }
186 
187 wxEvent* a2dEditorFrameEvent::Clone( void ) const
188 {
189  return new a2dEditorFrameEvent( GetEditorFrame(), m_eventType, m_id );
190 }
191 
192 DEFINE_EVENT_TYPE( a2dEVT_THEME_EVENT )
193 DEFINE_EVENT_TYPE( a2dEVT_INIT_EVENT )
194 
195 
196 const long TOOLOPTION_FIRST = wxNewId();
197 const long TOOLOPTION_ONTOP = TOOLOPTION_FIRST;
198 const long TOOLOPTION_RECTANGLE = wxNewId();
199 const long TOOLOPTION_REDRAW = wxNewId();
200 const long TOOLOPTION_COPY = wxNewId();
201 
202 const long TOOLOPTION_FILLED = wxNewId();
203 const long TOOLOPTION_WIRE = wxNewId();
204 const long TOOLOPTION_INVERT = wxNewId();
205 const long TOOLOPTION_WIRE_ZERO_WIDTH = wxNewId();
206 const long TOOLOPTION_INVERT_ZERO_WIDTH = wxNewId();
207 const long TOOLOPTION_LAST = TOOLOPTION_INVERT_ZERO_WIDTH;
208 
209 const long MSHOW_T = wxNewId();
210 const long MSHOW_FIRST = wxNewId();
211 const long MSHOW_LIBPOINTS = wxNewId();
212 const long MSHOW_LIB = wxNewId();
213 const long MSHOW_LAST = MSHOW_LIB;
214 
215 const long MSCREEN_T = wxNewId();
216 
217 //const long MTOOL_PlaceFromLibByRef= wxNewId();
218 //const long MTOOL_PlaceFromLibByCopy= wxNewId();
219 
220 const long Layer_view = wxNewId();
221 const long a2dShapeClipboard_Copy = wxNewId();
222 const long a2dShapeClipboard_Paste = wxNewId();
223 const long a2dShapeClipboard_Drag = wxNewId();
224 
225 BEGIN_EVENT_TABLE( a2dEditorFrame, a2dDocumentFrame )
226 
227  EVT_MENU( wxID_EXIT, a2dEditorFrame::Quit )
228 
229 // EVT_MENU(MTOOL_PlaceFromLibByRef,a2dEditorFrame::PlaceFromLibByRef)
230 // EVT_MENU(MTOOL_PlaceFromLibByCopy,a2dEditorFrame::PlaceFromLibByCopy)
231 
232  EVT_MENU( wxID_ABOUT, a2dEditorFrame::OnAbout )
233  EVT_MENU( wxID_UNDO, a2dEditorFrame::OnUndo )
234  EVT_MENU( wxID_REDO, a2dEditorFrame::OnRedo )
235  EVT_MENUSTRINGS( a2dEditorFrame::OnSetmenuStrings )
236 
237  EVT_DO( a2dEditorFrame::OnDoEvent )
238  EVT_UNDO( a2dEditorFrame::OnUndoEvent )
239 
240  EVT_COM_EVENT( a2dEditorFrame::OnComEvent )
241 
242  EVT_CLOSE( a2dEditorFrame::OnCloseWindow )
243 
244  EVT_ACTIVATE( a2dEditorFrame::OnActivate )
245 
246  EVT_THEME_EVENT( a2dEditorFrame::OnTheme )
247  EVT_INIT_EVENT( a2dEditorFrame::OnInit )
248 
249  EVT_MENU( MSCREEN_T, a2dEditorFrame::FillData )
250 
251  EVT_ACTIVATE_VIEW_SENT_FROM_CHILD( a2dEditorFrame::OnActivateViewSentFromChild )
252 
253  EVT_MENU( a2dShapeClipboard_Copy, a2dEditorFrame::OnCopyShape)
254  EVT_MENU( a2dShapeClipboard_Paste, a2dEditorFrame::OnPasteShape)
255  EVT_MENU( a2dShapeClipboard_Drag, a2dEditorFrame::OnDragSimulate)
256  EVT_UPDATE_UI( a2dShapeClipboard_Paste, a2dEditorFrame::OnUpdatePasteShape)
257  EVT_UPDATE_UI( a2dShapeClipboard_Copy, a2dEditorFrame::OnUpdateCopyShape)
258 
259 END_EVENT_TABLE()
260 
261 a2dEditorFrame::a2dEditorFrame()
262  : a2dDocumentFrame()
263 {
264  m_initialized = false;
265  m_drawingPart = NULL;
266 }
267 
268 a2dEditorFrame::a2dEditorFrame( bool isParent, wxFrame* parent, const wxPoint& pos, const wxSize& size, long style )
269  : a2dDocumentFrame()
270 {
271  m_initialized = false;
272  m_drawingPart = NULL;
273 
274  // create a canvas in Create, the first arg. is true.
275  Create( true, isParent, parent, pos, size, style );
276 }
277 
278 bool a2dEditorFrame::Create( bool createCanvas, bool isParent,
279  wxFrame* parent, const wxPoint& pos , const wxSize& size, long style )
280 {
281  m_drawingPart = NULL;
282  m_initialized = false;
283 
284  bool res = a2dDocumentFrame::Create( isParent, parent, NULL, -1, wxT( "canvas editor" ) , pos, size, style );
285 
286  if ( createCanvas )
287  {
288  a2dCanvas* canvas = new a2dCanvas( this, -1, pos, size, a2dCanvasGlobals->m_initialWorldCanvasStyle );
289  m_drawingPart = canvas->GetDrawingPart();
290  }
291 
292  // A control test, with editing.
293  //new wxButton(m_window,-1, _T("Show a button"),wxPoint(100,100),wxSize(200,110) );
294  return res;
295 }
296 
297 void a2dEditorFrame::OnInit( a2dEditorFrameEvent& initEvent )
298 {
299 #ifdef __WXMSW__
300  SetIcon( wxString( wxT( "chrt_icn" ) ) );
301 #endif
302 
303  m_editMenu = NULL;
304 
305  if ( m_drawingPart )
306  {
307  a2dFill backgr = a2dFill( wxColour( 255, 255, 255 ) );
308  m_drawingPart->SetBackgroundFill( backgr );
309 
310  m_drawingPart->SetGridStroke( a2dStroke( wxColour( 239, 5, 64 ), 0, a2dSTROKE_DOT ) );
311  //to show grid as lines
312  //m_drawingPart1->SetGridLines(true);
313 
314  m_drawingPart->SetGridSize( 2 );
315  m_drawingPart->SetGridX( 100 );
316  m_drawingPart->SetGridY( 100 );
317 
318  //show it?
319  m_drawingPart->SetGrid( false );
320  m_drawingPart->SetGridAtFront( true );
321  }
322  m_initialized = true;
323 }
324 
325 void a2dEditorFrame::OnTheme( a2dEditorFrameEvent& themeEvent )
326 {
327  a2dEditorFrame* ef = themeEvent.GetEditorFrame();
328  ef->Theme();
329 
330  wxUint16 lay = m_drawingPart->GetDrawing()->GetHabitat()->GetLayer();
331  SetStatusText( m_drawingPart->GetDrawing()->GetLayerSetup()->GetName( lay ), 1 );
332 }
333 
335 {
336  a2dCentralCanvasCommandProcessor* docmanager = a2dGetCmdh();
337  wxASSERT_MSG( docmanager, wxT( "a2dCentralCanvasCommandProcessor is needed by a2dEditorFrame" ) );
338 
339  if ( m_drawingPart )
340  {
341  m_contr = new a2dStToolContr( m_drawingPart, this, false );
342  //m_contr->SetCrossHair( true );
343 
344  //the next is handy, but as you prefer
345  m_contr->SetZoomFirst( true );
346  }
347 
348  wxPathList pathList;
349  pathList.Add( wxT( "../common/icons" ) );
350 
351  a2dEditorFrameEvent tevent( this, a2dEVT_INIT_EVENT );
352  ProcessEvent( tevent );
353 
354  a2dEditorFrameEvent ievent( this, a2dEVT_THEME_EVENT );
355  ProcessEvent( ievent );
356 }
357 
358 a2dEditorFrame::~a2dEditorFrame()
359 {
360 }
361 
362 void a2dEditorFrame::OnActivateViewSentFromChild( a2dViewEvent& viewevent )
363 {
364  a2dView* view = ( a2dView* ) viewevent.GetEventObject();
365  a2dCanvasView* canview = wxDynamicCast( view, a2dCanvasView );
366 
367  if ( canview != m_view )
368  //canview->GetDrawingPart() != m_drawingPart ||
369  //canview->GetDrawingPart()->GetDrawing() != m_drawingPart->GetDrawing() )
370  {
371  if ( viewevent.GetActive() )
372  {
373  m_drawingPart = canview->GetDrawingPart();
374  if ( m_drawingPart->GetDrawing() && m_drawingPart->GetDrawing()->GetCommandProcessor() )
375  {
376  m_drawingPart->GetDrawing()->DisconnectEvent( wxEVT_MENUSTRINGS, this );
377  m_drawingPart->GetDrawing()->DisconnectEvent( wxEVT_DO, this );
378  m_drawingPart->GetDrawing()->DisconnectEvent( wxEVT_UNDO, this );
379  }
380  m_view = view;
381  canview = wxDynamicCast( m_view.Get(), a2dCanvasView );
382  m_drawingPart = canview->GetDrawingPart();
383  m_contr = wxDynamicCast( m_drawingPart->GetCanvasToolContr(), a2dStToolContr );
384  if ( canview && m_drawingPart->GetDrawing() && m_drawingPart->GetDrawing()->GetCommandProcessor() )
385  {
386  m_drawingPart->GetDrawing()->ConnectEvent( wxEVT_MENUSTRINGS, this );
387  m_drawingPart->GetDrawing()->ConnectEvent( wxEVT_DO, this );
388  m_drawingPart->GetDrawing()->ConnectEvent( wxEVT_UNDO, this );
389  m_drawingPart->GetDrawing()->ConnectEvent( wxEVT_REDO, this );
390  }
391  }
392  else
393  {
394  m_drawingPart = canview->GetDrawingPart();
395  if ( m_drawingPart->GetDrawing() && m_drawingPart->GetDrawing()->GetCommandProcessor() )
396  {
397  m_drawingPart->GetDrawing()->DisconnectEvent( wxEVT_MENUSTRINGS, this );
398  m_drawingPart->GetDrawing()->DisconnectEvent( wxEVT_DO, this );
399  m_drawingPart->GetDrawing()->DisconnectEvent( wxEVT_UNDO, this );
400  m_drawingPart->GetDrawing()->DisconnectEvent( wxEVT_REDO, this );
401  }
402  m_view = view;
403  }
404  }
405  viewevent.Skip();
406 }
407 
408 void a2dEditorFrame::OnCloseWindow( wxCloseEvent& event )
409 {
410  wxTheClipboard->Clear();
411  if ( !event.CanVeto() )
412  {
413  }
414  event.Skip();
415 }
416 
417 void a2dEditorFrame::OnUndo( wxCommandEvent& WXUNUSED( event ) )
418 {
419  if ( !m_drawingPart )
420  return;
421 
422  if ( m_drawingPart->GetDrawing() && m_drawingPart->GetDrawing()->GetCommandProcessor() )
423  m_drawingPart->GetDrawing()->GetCommandProcessor()->Undo();
424 }
425 
426 void a2dEditorFrame::OnRedo( wxCommandEvent& WXUNUSED( event ) )
427 {
428  if ( !m_drawingPart )
429  return;
430 
431  if ( m_drawingPart->GetDrawing() && m_drawingPart->GetDrawing()->GetCommandProcessor() )
432  m_drawingPart->GetDrawing()->GetCommandProcessor()->Redo();
433 }
434 
435 void a2dEditorFrame::Update()
436 {
437  m_drawingPart->Update( a2dCANVIEW_UPDATE_ALL );
438 }
439 
440 void a2dEditorFrame::Quit( wxCommandEvent& WXUNUSED( event ) )
441 {
442  Close( true );
443 }
444 
445 void a2dEditorFrame::OnActivate( wxActivateEvent& event )
446 {
447  if ( !m_initialized )
448  {
449  event.Skip();
450  return;
451  }
452  event.Skip(); //skip to base OnActivate Handler which sets proper focus to child window(s)
453 }
454 
456 {
457  if ( !m_drawingPart )
458  return;
459 
460  if ( m_editMenu && m_drawingPart->GetDrawing() && event.GetEventObject() == m_drawingPart->GetDrawing()->GetCommandProcessor() )
461  {
462  m_editMenu->SetLabel( wxID_UNDO, event.GetUndoMenuLabel() );
463  m_editMenu->Enable( wxID_UNDO, event.CanUndo() );
464 
465  m_editMenu->SetLabel( wxID_REDO, event.GetRedoMenuLabel() );
466  m_editMenu->Enable( wxID_REDO, event.CanRedo() );
467  }
468 }
469 
470 void a2dEditorFrame::OnUndoEvent( a2dCommandProcessorEvent& WXUNUSED( event ) )
471 {
472 
473 }
474 
475 void a2dEditorFrame::OnDoEvent( a2dCommandProcessorEvent& event )
476 {
477  wxString cmdName = event.GetCommand()->GetName();
478 
479  if ( !m_drawingPart )
480  return;
481 
482  if ( m_drawingPart->GetDrawing() && event.GetEventObject() == m_drawingPart->GetDrawing()->GetCommandProcessor() )
483  {
484  }
485 }
486 
487 void a2dEditorFrame::OnComEvent( a2dComEvent& event )
488 {
489  if ( event.GetId() == a2dComEvent::sm_changedProperty )
490  {
491  a2dNamedProperty* property = event.GetProperty();
492  a2dObject* object = property->GetRefObjectNA();
493 
494  if ( 0 != wxDynamicCast( property, a2dStrokeProperty ) )
495  {
496  a2dStroke stroke = ( ( a2dStrokeProperty* )property )->GetValue();
497  }
498  else if ( 0 != wxDynamicCast( property, a2dFillProperty ) )
499  {
500  a2dFill fill = ( ( a2dFillProperty* )property )->GetValue();
501  }
502  else
503  event.Skip();
504  }
505  else if ( m_drawingPart && event.GetId() == a2dStToolContr::sm_showCursor && GetStatusBar() )
506  {
507  a2dStToolContr* contr = wxStaticCast( event.GetEventObject(), a2dStToolContr );
508  wxString str;
509 
510  SetStatusText( contr->GetStatusStrings()[0], 0 );
511  SetStatusText( contr->GetStatusStrings()[1], 1 );
512  SetStatusText( contr->GetStatusStrings()[2], 2 );
513  SetStatusText( contr->GetStatusStrings()[3], 3 );
514  SetStatusText( m_drawingPart->GetDrawing()->GetHabitat()->GetConnectionGenerator()->GetRouteMethodAsString(), 4 );
515 
516  wxUint16 lay = m_drawingPart->GetDrawing()->GetHabitat()->GetLayer();
517  SetStatusText( contr->GetDrawingPart()->GetDrawing()->GetLayerSetup()->GetName( lay ), 5 );
518 
519 /*
520  a2dStToolContr* contr = wxStaticCast( event.GetEventObject(), a2dStToolContr );
521 
522  wxPoint mpos = contr->GetMousePosition();
523 
524  double mouse_worldx, mouse_worldy;
525  contr->GetDrawingPart()->MouseToToolWorld( mpos.x, mpos.y, mouse_worldx, mouse_worldy );
526 
527  wxString unitmeasure = contr->GetDrawingPart()->GetDrawing()->GetUnits();
528  double scaleToMeters = contr->GetDrawingPart()->GetDrawing()->GetUnitsScale();
529 
530  double multi = 1;
531  a2dDoMu::GetMultiplierFromString( unitmeasure, multi );
532 
533  mouse_worldx *= scaleToMeters / multi;
534  mouse_worldy *= scaleToMeters / multi;
535 
536  wxString str;
537  str.Printf( _T( "%6.3f,%6.3f" ), mouse_worldx, mouse_worldy );
538 
539  if ( contr->GetFirstTool() )
540  str = str + _T( " " ) + unitmeasure + _T( " :" ) + contr->GetFirstTool()->GetClassInfo()->GetClassName();
541 
542 
543  SetStatusText( str );
544  wxUint16 lay = a2dCanvasGlobals->GetLayer();
545  if ( m_drawingPart )
546  {
547  wxUint16 lay = a2dCanvasGlobals->GetLayer();
548  SetStatusText( m_drawingPart->GetDrawing()->GetLayerSetup()->GetName( lay ), 1 );
549  }
550 */
551  }
552  else if ( event.GetId() == a2dHabitat::sig_changedLayer )
553  {
554  a2dStToolContr* contr = wxStaticCast( event.GetEventObject(), a2dStToolContr );
555  wxUint16 lay = m_drawingPart->GetDrawing()->GetHabitat()->GetLayer();
556  SetStatusText( contr->GetDrawingPart()->GetDrawing()->GetLayerSetup()->GetName( lay ), 5 );
557  }
558 
559  else
560  event.Skip();
561 }
562 
563 void a2dEditorFrame::OnMenu( wxCommandEvent& event )
564 {
565  if ( event.GetId() == Layer_view )
566  {
568  doc->SetDocumentTypeName( _T( "a2dCanvasDocument" ) );
569  doc->GetDrawing()->GetRootObject()->Append( m_drawingPart->GetDrawing()->GetLayerSetup() );
570 
571  a2dView* createdview;
572  createdview = a2dDocviewGlobals->GetDocviewCommandProcessor()->AddDocumentCreateView( doc, _T( "Drawing View Frame" ) );
573  }
574  else if ( event.GetId() == MSHOW_LIBPOINTS )
575  {
576  ConnectDocument( a2dGetCmdh()->GetLibraryPoints() );
577  m_contr->Zoomout();
578  }
579  else
580  event.Skip();
581 }
582 
583 /*
584 void a2dEditorFrame::PlaceFromLibByRef()
585 {
586  a2dCanvasObjectList total;
587 
588  m_library->CollectObjects( &total, _T("a2dNameReference"),a2dCANOBJ_ALL,_T(""), false );
589 
590  CanvasObjectsDialog objects(this,m_library,&total, true, (wxSTAY_ON_TOP |wxRESIZE_BORDER | wxCAPTION));
591  if (objects.ShowModal() == wxID_OK)
592  {
593  a2dCanvasObject* obj=((a2dNameReference*)objects.GetCanvasObject())->GetCanvasObject();
594  obj->SetPosXY(0,0);
595  a2dCanvasObjectReference* ref = new a2dCanvasObjectReference(0,0,obj);
596  m_drawingPart->GetShowObject()->Append(ref);
597  DOC->SetCanvasDocumentRecursive();
598  m_contr->Zoomout();
599  }
600 }
601 
602 void a2dEditorFrame::PlaceFromLibByCopy()
603 {
604  a2dCanvasObjectList total;
605 
606  m_library->CollectObjects( &total,_T("a2dNameReference"),a2dCANOBJ_ALL,_T(""), false );
607 
608  CanvasObjectsDialog objects(this,m_library,&total, true, (wxSTAY_ON_TOP |wxRESIZE_BORDER | wxCAPTION));
609  if (objects.ShowModal() == wxID_OK)
610  {
611  a2dCanvasObject* obj=((a2dNameReference*)objects.GetCanvasObject())->GetCanvasObject()->TClone();
612  obj->SetPosXY(0,0);
613  m_drawingPart->GetShowObject()->Append(obj);
614  DOC->SetCanvasDocumentRecursive();
615  m_contr->Zoomout();
616  }
617 }
618 */
619 
620 void a2dEditorFrame::SetToolDragingMode( wxCommandEvent& event )
621 {
622  m_menuBar->Check( TOOLOPTION_ONTOP, false );
623  m_menuBar->Check( TOOLOPTION_RECTANGLE, false );
624  m_menuBar->Check( TOOLOPTION_REDRAW, false );
625  m_menuBar->Check( TOOLOPTION_COPY, false );
626  if ( event.GetId() == TOOLOPTION_ONTOP )
627  {
629  m_menuBar->Check( TOOLOPTION_ONTOP, true );
630  }
631  if ( event.GetId() == TOOLOPTION_RECTANGLE )
632  {
634  m_menuBar->Check( TOOLOPTION_RECTANGLE, true );
635  }
636  if ( event.GetId() == TOOLOPTION_REDRAW )
637  {
639  m_menuBar->Check( TOOLOPTION_REDRAW, true );
640  }
641  if ( event.GetId() == TOOLOPTION_COPY )
642  {
644  m_menuBar->Check( TOOLOPTION_COPY, true );
645  }
646 }
647 
648 void a2dEditorFrame::SetToolDrawingMode( wxCommandEvent& event )
649 {
650  m_menuBar->Check( TOOLOPTION_FILLED, false );
651  m_menuBar->Check( TOOLOPTION_WIRE, false );
652  m_menuBar->Check( TOOLOPTION_INVERT, false );
653  m_menuBar->Check( TOOLOPTION_WIRE_ZERO_WIDTH, false );
654  m_menuBar->Check( TOOLOPTION_INVERT_ZERO_WIDTH, false );
655 
656  if ( event.GetId() == TOOLOPTION_FILLED )
657  {
658  m_contr->SetDrawMode( a2dFILLED );
659  m_menuBar->Check( TOOLOPTION_FILLED, true );
660  }
661  if ( event.GetId() == TOOLOPTION_WIRE )
662  {
663  m_contr->SetDrawMode( a2dWIREFRAME );
664  m_menuBar->Check( TOOLOPTION_WIRE, true );
665  }
666  if ( event.GetId() == TOOLOPTION_INVERT )
667  {
668  m_contr->SetDrawMode( a2dWIREFRAME_INVERT );
669  m_menuBar->Check( TOOLOPTION_INVERT, true );
670  }
671  if ( event.GetId() == TOOLOPTION_WIRE_ZERO_WIDTH )
672  {
673  m_contr->SetDrawMode( a2dWIREFRAME_ZERO_WIDTH );
674  m_menuBar->Check( TOOLOPTION_WIRE_ZERO_WIDTH, true );
675  }
676  if ( event.GetId() == TOOLOPTION_INVERT_ZERO_WIDTH )
677  {
678  m_contr->SetDrawMode( a2dWIREFRAME_INVERT_ZERO_WIDTH );
679  m_menuBar->Check( TOOLOPTION_INVERT_ZERO_WIDTH, true );
680  }
681 }
682 
683 void a2dEditorFrame::AddFunctionToMenu( int id, wxMenu* parentMenu, const wxString& text, const wxString& helpString, wxObjectEventFunctionM func, bool check )
684 {
685  Connect( id, wxEVT_COMMAND_MENU_SELECTED, ( wxObjectEventFunction ) wxStaticCastEvent( wxCommandEventFunction, func ) );
686  parentMenu->Append( id, text, helpString, check );
687 }
688 
689 void a2dEditorFrame::RemoveFromMenu( int id, wxMenu* parentMenu, wxObjectEventFunctionM func )
690 {
691  Disconnect( id, wxEVT_COMMAND_MENU_SELECTED, ( wxObjectEventFunction ) wxStaticCastEvent( wxCommandEventFunction, func ) );
692  parentMenu->Delete( id );
693 }
694 
695 void a2dEditorFrame::OnAbout( wxCommandEvent& WXUNUSED( event ) )
696 {
697  ( void )wxMessageBox( _T( "a2dEditorFrame\nKlaas Holwerda 2002" ),
698  _T( "About a2dEditorFrame" ), wxICON_INFORMATION | wxOK );
699 }
700 
701 void a2dEditorFrame::ConnectDocument( a2dCanvasDocument* doc, a2dCanvasView* drawer )
702 {
703  if ( !doc )
704  return;
705 
706 /*
707  a2dViewList allviews;
708  doc->ReportViews( &allviews );
709 
710  if ( !drawer || wxNOT_FOUND == allviews.IndexOf( drawer ) )
711  {
712  if ( m_drawingPart->GetDrawingPart() ) //document change means: this view will now belong to the new document
713  m_drawingPart->GetDrawingPart()->SetDocument( doc );
714  }
715  else
716  {
717  m_drawingPart->SetDrawingPart( drawer );
718  }
719 
720  //if ( !doc->GetFirstView() )
721  // a2dDocviewGlobals->GetDocviewCommandProcessor()CreateView(doc,"Drawing View" )->OnUpdate(NULL);
722 
723  if ( m_view )
724  {
725  m_view->SetDisplayWindow( NULL );
726  }
727 
728  m_view->SetDisplayWindow( m_drawingPart );
729  m_view->Update();
730  if ( m_view->GetDocument() )
731  {
732  //maybe something to change the title
733  }
734  m_view->Activate( true );
735 */
736 }
737 
738 /*
739 void a2dEditorFrame::FillLibrary()
740 {
741  //root group always at 0,0
742  m_library = new a2dCanvasDocument();
743  m_library->Own();
744 
745  //always add the commandprocessor
746  //this is needed for tools, so not strictly needed.
747  m_library->CreateCommandProcessor();
748 
749  {
750  a2dCircle* cire = new a2dCircle( -100,0, 70 );
751  cire->SetFill( wxColour(219,21,6),a2dFILL_HORIZONTAL_HATCH );
752  cire->SetStroke(wxColour(1,3,205 ),3.0);
753 
754  a2dLibraryReference* libobject = new a2dLibraryReference(0,0,cire,_T("circle"),100);
755  libobject->SetStroke(wxColour(229,5,64 ),0);
756  m_library->Append( libobject );
757  }
758 
759  {
760  wxBitmap bitmap( smile_xpm );
761  a2dImage* i=new a2dImage( bitmap.ConvertToImage(), 200,0,62,62 );
762 
763  a2dLibraryReference* libobject = new a2dLibraryReference(0,-200,i,_T("smilly"),100);
764  libobject->SetStroke(wxColour(229,5,64 ),0);
765  m_library->Append( libobject );
766  }
767 
768  {
769  wxBitmap bitmap2;
770  wxPathList pathList;
771  pathList.Add(_T("../common/images"));
772 
773  wxString path = pathList.FindValidPath(_T("image1.png"));
774 
775  a2dImage* im = new a2dImage( path,wxBITMAP_TYPE_PNG, -500,-265,382,332 );
776 
777  im->SetStroke(wxColour(229,255,244 ),40.0);
778  im->SetFill(wxColour(0,117,220),a2dFILL_VERTICAL_HATCH);
779 
780  a2dLibraryReference* libobject = new a2dLibraryReference(0,-400,im,_T("milkyway"),100);
781  libobject->SetStroke(wxColour(229,5,64 ),0);
782  m_library->Append( libobject );
783  }
784 
785  {
786  a2dRect* rec3 = new a2dRect(0,0,50,70);
787  rec3->SetFill(wxColour(0,12,240));
788  rec3->SetStroke(wxColour(252,54,25 ),3.0);
789  rec3->SetCanvasDocument( m_library );
790 
791  a2dLibraryReference* libobject = new a2dLibraryReference(0,-600,rec3,_T("rectangle"),100);
792  libobject->SetStroke(wxColour(229,5,64 ),0);
793  m_library->Append( libobject );
794  }
795 
796  m_library->SetCanvasDocumentRecursive();
797 }
798 */
799 
800 
801 void a2dEditorFrame::ShowLibs( wxCommandEvent& event )
802 {
803  if ( event.GetId() == MSHOW_LIBPOINTS )
804  {
805  ConnectDocument( a2dGetCmdh()->GetLibraryPoints() );
806  m_contr->Zoomout();
807  }
808 
809 }
810 
811 void a2dEditorFrame::CreateStatusBarThemed( const wxString& themeName )
812 {
813  CreateStatusBar( 6 );
814  int widths[] = { 80, 120, -1, -1 , -1, -1 };
815  SetStatusWidths( 6, widths );
816 }
817 
818 void a2dEditorFrame::Theme( const wxString& themeName )
819 {
820  if ( themeName == wxT( "test" ) )
821  CreateThemeTest();
822  if ( themeName == wxT( "default" ) )
823  CreateThemeDefault();
824 }
825 
826 void a2dEditorFrame::SetupToolbar()
827 {
828  //toolbar = CreateToolBar(wxTB_HORIZONTAL|wxTB_FLAT|wxTB_TEXT |wxTB_3DBUTTONS);
829  wxToolBar* toolbar = new wxToolBar( this, wxNewId(), wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL | wxTB_FLAT | wxTB_DOCKABLE );
830  toolbar->SetMargins( 2, 2 );
831  SetToolBar( toolbar );
832 
833 #ifndef __UNIX__
834  toolbar->SetToolBitmapSize( wxSize( 32, 32 ) );
835 #endif
836 
837  AddCmdToToolbar( CmdMenu_PushInto() );
838  AddCmdToToolbar( CmdMenu_PopOut() );
839  AddCmdToToolbar( CmdMenu_PushTool_Zoom() );
840  AddCmdToToolbar( CmdMenu_PushTool_Cameleon() );
841  AddCmdToToolbar( CmdMenu_PushTool_Port() );
842  AddCmdToToolbar( CmdMenu_Selected_CameleonSymbol() );
843  AddCmdToToolbar( CmdMenu_Selected_CameleonDiagram() );
844  AddCmdToToolbar( CmdMenu_PushTool_Cameleon() );
845  AddCmdToToolbar( CmdMenu_PushTool_Port() );
846  AddCmdToToolbar( CmdMenu_PushTool_CameleonInst() );
847  AddCmdToToolbar( CmdMenu_PushTool_CameleonInstDlg() );
848 
849  AddCmdToToolbar( CmdMenu_PushTool_DrawPolygonL() );
850  AddCmdToToolbar( CmdMenu_PushTool_DrawPolygonL_Splined() );
851  AddCmdToToolbar( CmdMenu_PushTool_DrawPolylineL() );
852  AddCmdToToolbar( CmdMenu_PushTool_DrawPolylineL_Splined() );
853  AddCmdToToolbar( CmdMenu_PushTool_DrawRectangle() );
854  AddCmdToToolbar( CmdMenu_PushTool_DrawCircle() );
855  AddCmdToToolbar( CmdMenu_PushTool_DrawEllipse() );
856  AddCmdToToolbar( CmdMenu_PushTool_DrawEllipticArc() );
857  AddCmdToToolbar( CmdMenu_PushTool_DrawEllipticArc_Chord() );
858  AddCmdToToolbar( CmdMenu_PushTool_DrawArc() );
859  AddCmdToToolbar( CmdMenu_PushTool_DrawArc_Chord() );
860  AddCmdToToolbar( CmdMenu_PushTool_DrawText() );
861  AddCmdToToolbar( CmdMenu_PushTool_Image() );
862  AddCmdToToolbar( CmdMenu_PushTool_Link() );
863  AddCmdToToolbar( CmdMenu_PushTool_Rotate() );
864  AddCmdToToolbar( CmdMenu_PushTool_Drag() );
865  AddCmdToToolbar( CmdMenu_PushTool_Copy() );
866  AddCmdToToolbar( CmdMenu_PushTool_Delete() );
867  AddCmdToToolbar( CmdMenu_PushTool_RecursiveEdit() );
868  AddCmdToToolbar( CmdMenu_PushTool_Select() );
869  AddCmdToToolbar( CmdMenu_PushTool_Select2() );
870  AddCmdToToolbar( CmdMenu_Selected_SelectAll() );
871  AddCmdToToolbar( CmdMenu_Selected_DeSelectAll() );
872  AddCmdToToolbar( CmdMenu_Selected_Delete() );
873  AddCmdToToolbar( CmdMenu_PushTool_DragMulti() );
874  AddCmdToToolbar( CmdMenu_PushTool_CopyMulti() );
875 
876  toolbar->Realize();
877 }
878 
879 void a2dEditorFrame::CreateThemeDefault()
880 {
881  CreateStatusBarThemed( wxT( "default" ) );
882 
883  m_menuBar = new wxMenuBar;
884  SetMenuBar( m_menuBar );
885 
886  //Centre(wxBOTH);
887 
888  //SETUP all menu dynamic, so can be removed too.
889  wxMenu* file_menu = new wxMenu;
890  AddCmdMenu( file_menu, CmdMenu_FileOpen() );
891  AddCmdMenu( file_menu, CmdMenu_FileClose() );
892  AddCmdMenu( file_menu, CmdMenu_FileSave() );
893  AddCmdMenu( file_menu, CmdMenu_FileSaveAs() );
894  AddCmdMenu( file_menu, CmdMenu_Print() );
895  file_menu->AppendSeparator();
896  AddCmdMenu( file_menu, CmdMenu_PrintView() );
897  AddCmdMenu( file_menu, CmdMenu_PreviewView() );
898  AddCmdMenu( file_menu, CmdMenu_PrintDocument() );
899  AddCmdMenu( file_menu, CmdMenu_PreviewDocument() );
900  AddCmdMenu( file_menu, CmdMenu_PrintSetup() );
901  file_menu->AppendSeparator();
902 
903  wxMenu* file_import = new wxMenu;
904  file_menu->Append( wxNewId(), wxT( "import file" ), file_import, _( "Import a file" ) );
905  AddCmdMenu( file_import, CmdMenu_FileImport() );
906 
907  wxMenu* file_export_as = new wxMenu;
908  file_menu->Append( wxNewId(), wxT( "Export As" ), file_export_as, _( "Export in other format" ) );
909  AddCmdMenu( file_export_as, CmdMenu_FileExport() );
910 
911  file_export_as->AppendSeparator();
912  AddCmdMenu( file_export_as, CmdMenu_ViewAsImage_Png() );
913  AddCmdMenu( file_export_as, CmdMenu_ViewAsImage_Bmp() );
914  AddCmdMenu( file_export_as, CmdMenu_DocumentAsImage_Png() );
915  AddCmdMenu( file_export_as, CmdMenu_DocumentAsImage_Bmp() );
916 #if wxART2D_USE_SVGIO
917  AddCmdMenu( file_export_as, CmdMenu_ViewAsSvg() );
918 #endif //wxART2D_USE_SVGIO
919  file_menu->AppendSeparator();
920 
921  if ( m_isParentFrame )
922  AddCmdMenu( file_menu, CmdMenu_Exit() );
923 
924  m_editMenu = new wxMenu;
925  m_editMenu->Append( wxID_UNDO, _( "&Undo" ) );
926  m_editMenu->Append( wxID_REDO, _( "&Redo" ) );
927 
928  Connect( MSHOW_FIRST, MSHOW_LAST, wxEVT_COMMAND_MENU_SELECTED, ( wxObjectEventFunction ) &a2dEditorFrame::ShowLibs );
929 
930  wxMenu* optionMenu = new wxMenu;
931  AddFunctionToMenu( TOOLOPTION_ONTOP, optionMenu, _( "Drag &OnTop" ), _( "Drag on top of other objects" ), &a2dEditorFrame::SetToolDragingMode, true );
932  AddFunctionToMenu( TOOLOPTION_RECTANGLE, optionMenu, _( "Drag &Rectangle" ), _( "Drag using a rectangle" ), &a2dEditorFrame::SetToolDragingMode, true );
933  AddFunctionToMenu( TOOLOPTION_REDRAW, optionMenu, _( "Drag Re &Draw" ), _( "Drag and redraw all objects all the time" ), &a2dEditorFrame::SetToolDragingMode, true );
934  AddFunctionToMenu( TOOLOPTION_COPY, optionMenu, _( "Drag &Copy" ), _( "Drag copy of original untill finished drag" ), &a2dEditorFrame::SetToolDragingMode, true );
935  AddFunctionToMenu( TOOLOPTION_FILLED, optionMenu, _( "Drag/Draw Filled" ), _( "Drag/Draw filled objects" ), &a2dEditorFrame::SetToolDragingMode, true );
936  AddFunctionToMenu( TOOLOPTION_WIRE, optionMenu, _( "Drag/Draw OutLine" ), _( "Drag/Draw an wireframe/outline of object" ), &a2dEditorFrame::SetToolDrawingMode, true );
937  AddFunctionToMenu( TOOLOPTION_INVERT, optionMenu, _( "Drag/Draw Invert" ), _( "Drag/Draw an inverted wireframe of object" ), &a2dEditorFrame::SetToolDrawingMode, true );
938  AddFunctionToMenu( TOOLOPTION_WIRE_ZERO_WIDTH, optionMenu, _( "Drag/Draw OutLine zero" ), _( "Drag/Draw zero width wireframe/outline of object" ), &a2dEditorFrame::SetToolDrawingMode, true );
939  AddFunctionToMenu( TOOLOPTION_INVERT_ZERO_WIDTH, optionMenu, _( "Drag/Draw Invert zero" ), _( "Drag/Draw a zero width inverted wireframe of object" ), &a2dEditorFrame::SetToolDrawingMode, true );
940  optionMenu->AppendSeparator();
941  AddCmdMenu( optionMenu, CmdMenu_Option_SplinePoly() );
942  AddCmdMenu( optionMenu, CmdMenu_Option_CursorCrosshair() );
943  AddCmdMenu( optionMenu, CmdMenu_Option_RescaleAtReSize() );
944  AddCmdMenu( optionMenu, CmdMenu_Option_ReverseLayers() );
945  AddCmdMenu( optionMenu, CmdMenu_SetYAxis() );
946 
947 
948  wxMenu* cameleonMenu = new wxMenu;
949  AddCmdMenu( cameleonMenu,CmdMenu_ShowDlgCameleonModal() );
950  AddCmdMenu( cameleonMenu,CmdMenu_ShowDiagram() );
951  AddCmdMenu( cameleonMenu,CmdMenu_ShowSymbol() );
952  AddCmdMenu( cameleonMenu,CmdMenu_ShowGui() );
953  AddCmdMenu( cameleonMenu,CmdMenu_Selected_CameleonSymbol() );
954  AddCmdMenu( cameleonMenu,CmdMenu_Selected_CameleonDiagram() );
955  AddCmdMenu( cameleonMenu,CmdMenu_Selected_CloneCameleonFromInst() );
956  AddCmdMenu( cameleonMenu,CmdMenu_Selected_FlattenCameleon() );
957  AddCmdMenu( cameleonMenu,CmdMenu_PushTool_CameleonInst() );
958  AddCmdMenu( cameleonMenu,CmdMenu_PushTool_CameleonInstDlg() );
959  AddCmdMenu( cameleonMenu,CmdMenu_PushTool_Cameleon() );
960  AddCmdMenu( cameleonMenu,CmdMenu_PushTool_Cameleon_BuildIn() );
961  AddCmdMenu( cameleonMenu,CmdMenu_PushTool_Port() );
962  AddCmdMenu( cameleonMenu,CmdMenu_PushTool_CameleonRefDlg() );
963  AddCmdMenu( cameleonMenu,CmdMenu_PushTool_CameleonRefDlg_Symbol() );
964  AddCmdMenu( cameleonMenu,CmdMenu_PushTool_CameleonRefDlg_Diagram() );
965 
966  wxMenu* toolMenu = new wxMenu;
967 
968  AddCmdMenu( toolMenu, CmdMenu_PushTool_FastSelect() );
969  AddCmdMenu( toolMenu, CmdMenu_PushTool_FastSelect2() );
970  AddCmdMenu( toolMenu, CmdMenu_PushTool_RecursiveEdit() );
971  AddCmdMenu( toolMenu, CmdMenu_PushTool_MultiEdit() );
972  AddCmdMenu( toolMenu, CmdMenu_PushTool_Drag() );
973  AddCmdMenu( toolMenu, CmdMenu_PushTool_Copy() );
974  AddCmdMenu( toolMenu, CmdMenu_PushTool_Rotate() );
975  AddCmdMenu( toolMenu, CmdMenu_PushTool_Delete() );
976  AddCmdMenu( toolMenu, CmdMenu_PushTool_DrawText() );
977  AddCmdMenu( toolMenu, CmdMenu_PushTool_Image() );
978  AddCmdMenu( toolMenu, CmdMenu_PushTool_Link() );
979  AddCmdMenu( toolMenu, CmdMenu_PushTool_FollowLinkDocDrawCam() );
980  AddCmdMenu( toolMenu, CmdMenu_PushTool_DrawRectangleFast() );
981  AddCmdMenu( toolMenu, CmdMenu_PushTool_DrawCircleFast() );
982  AddCmdMenu( toolMenu, CmdMenu_PushTool_DrawLine() );
983  AddCmdMenu( toolMenu, CmdMenu_PushTool_DrawLineScaledArrow() );
984  AddCmdMenu( toolMenu, CmdMenu_PushTool_DrawEllipse() );
985  AddCmdMenu( toolMenu, CmdMenu_PushTool_DrawEllipticArc() );
986  AddCmdMenu( toolMenu, CmdMenu_PushTool_DrawEllipticArc_Chord() );
987  AddCmdMenu( toolMenu, CmdMenu_PushTool_DrawArc() );
988  AddCmdMenu( toolMenu, CmdMenu_PushTool_DrawArc_Chord() );
989  AddCmdMenu( toolMenu, CmdMenu_PushTool_DrawPolylineLFast() );
990  AddCmdMenu( toolMenu, CmdMenu_PushTool_DrawPolygonLFast() );
991  AddCmdMenu( toolMenu, CmdMenu_PushTool_Property() );
992  AddCmdMenu( toolMenu, CmdMenu_PushTool_FastDragMulti() );
993  AddCmdMenu( toolMenu, CmdMenu_PushTool_FastCopyMulti() );
994  AddCmdMenu( toolMenu, CmdMenu_PushTool_Measure() );
995  AddCmdMenu( toolMenu, CmdMenu_PushTool_DrawWirePolylineL() );
996  AddCmdMenu( toolMenu, CmdMenu_PushTool_DrawVPath() );
997  AddCmdMenu( toolMenu, CmdMenu_PushTool_Port() );
998  AddCmdMenu( toolMenu, CmdMenu_PushTool_Cameleon() );
999 
1000  toolMenu->AppendSeparator();
1001  AddCmdMenu( toolMenu, CmdMenu_RotateObject90Left() );
1002  AddCmdMenu( toolMenu, CmdMenu_RotateObject90Right() );
1003  AddCmdMenu( toolMenu, CmdMenu_LineBegin() );
1004  AddCmdMenu( toolMenu, CmdMenu_LineEnd() );
1005  AddCmdMenu( toolMenu, CmdMenu_LineScale() );
1006  AddCmdMenu( toolMenu, CmdMenu_SetNormalizeFactor() );
1007 
1008  //toolMenu->Append(MTOOL_PlaceFromLibByRef, _("add ref to object from lib"), _(""));
1009  //toolMenu->Append(MTOOL_PlaceFromLibByCopy, _("add object from lib"), _(""));
1010 
1011 
1012  wxMenu* drawMenu = new wxMenu;
1013  AddCmdMenu( drawMenu, CmdMenu_ShowDlgStructure() );
1014  AddFunctionToMenu( MSHOW_LIBPOINTS, drawMenu, _( "Point Library" ), _( "a library used for end and begin points of lines" ), &a2dEditorFrame::OnMenu );
1015 
1016  wxMenu* refMenu = new wxMenu;
1017 
1018  AddCmdMenu( refMenu, CmdMenu_Refresh() );
1019  AddCmdMenu( refMenu, CmdMenu_PushInto() );
1020  AddCmdMenu( refMenu, CmdMenu_NewGroup() );
1021  AddCmdMenu( refMenu, CmdMenu_NewPin() );
1022 
1023  wxMenu* performMenu = new wxMenu;
1024  wxMenu* selected = new wxMenu;
1025  wxMenu* groups = new wxMenu;
1026 
1027  /////////////////////////////////////////
1028  // selected like operation
1029  /////////////////////////////////////////
1030  performMenu->Append( wxNewId(), wxT( "selected objects" ), selected, _( "operation on selected objects" ) );
1031 
1032  AddCmdMenu( selected, CmdMenu_Selected_SelectAll() );
1033  AddCmdMenu( selected, CmdMenu_Selected_DeSelectAll() );
1034  AddCmdMenu( selected, CmdMenu_Selected_Delete() );
1035  AddCmdMenu( selected, CmdMenu_Selected_MoveXY() );
1036  AddCmdMenu( selected, CmdMenu_Selected_MoveLayer() );
1037  AddCmdMenu( selected, CmdMenu_Selected_CopyXY() );
1038  AddCmdMenu( selected, CmdMenu_Selected_CopyLayer() );
1039  AddCmdMenu( selected, CmdMenu_Selected_Transform() );
1040  AddCmdMenu( selected, CmdMenu_Selected_Rotate() );
1041  AddCmdMenu( selected, CmdMenu_Selected_RotateObject90Right() );
1042  AddCmdMenu( selected, CmdMenu_Selected_RotateObject90Left() );
1043  AddCmdMenu( selected, CmdMenu_Selected_Align_MinX() );
1044  AddCmdMenu( selected, CmdMenu_Selected_Align_MaxX() );
1045  AddCmdMenu( selected, CmdMenu_Selected_Align_MinY() );
1046  AddCmdMenu( selected, CmdMenu_Selected_Align_MaxY() );
1047  AddCmdMenu( selected, CmdMenu_Selected_Align_MidX() );
1048  AddCmdMenu( selected, CmdMenu_Selected_Align_MidY() );
1049  AddCmdMenu( selected, CmdMenu_Selected_Group() );
1050  AddCmdMenu( selected, CmdMenu_Selected_ImageToRectangles() );
1051  AddCmdMenu( selected, CmdMenu_Selected_ToTop() );
1052  AddCmdMenu( selected, CmdMenu_Selected_ToBack() );
1053  AddCmdMenu( selected, CmdMenu_Selected_SetStyle() );
1054  AddCmdMenu( selected, CmdMenu_Selected_SetExtStyle() );
1055  AddCmdMenu( selected, CmdMenu_Selected_ConvertToPolygonPolylinesWithArcs() );
1056  AddCmdMenu( selected, CmdMenu_Selected_ConvertToPolygonPolylinesWithoutArcs() );
1057  AddCmdMenu( selected, CmdMenu_Selected_ConvertToPolylines() );
1058  AddCmdMenu( selected, CmdMenu_Selected_ConvertLinesArcs() );
1059  AddCmdMenu( selected, CmdMenu_Selected_ConvertPolygonToArcs() );
1060  AddCmdMenu( selected, CmdMenu_Selected_ConvertPolylineToArcs() );
1061  AddCmdMenu( selected, CmdMenu_Selected_ConvertToVPaths() );
1062  AddCmdMenu( selected, CmdMenu_Selected_UnGroup() );
1063  AddCmdMenu( selected, CmdMenu_Selected_UnGroupDeep() );
1064  AddCmdMenu( selected, CmdMenu_Selected_Merge() );
1065  AddCmdMenu( selected, CmdMenu_Selected_Offset() );
1066  AddCmdMenu( selected, CmdMenu_Selected_CreateRing() );
1067 
1068  wxMenu* ungroupObjects = new wxMenu;
1069  refMenu->Append( wxNewId(), wxT( "ungroup objects" ), ungroupObjects, _( "un-group selected objects" ) );
1070  AddCmdMenu( ungroupObjects, CmdMenu_Selected_UnGroup() );
1071  AddCmdMenu( ungroupObjects, CmdMenu_Selected_UnGroupDeep() );
1072 
1073 #if wxART2D_USE_KBOOL
1074  /////////////////////////////////////////
1075  // group like operation
1076  /////////////////////////////////////////
1077  performMenu->Append( wxNewId(), wxT( "layer groups" ), groups, _( "operation on objects in layer groups" ) );
1078  AddCmdMenu( groups, CmdMenu_ShowDlgGroups() );
1079  AddCmdMenu( groups, CmdMenu_GroupAB_Offset() );
1080  AddCmdMenu( groups, CmdMenu_GroupAB_Smooth() );
1081  AddCmdMenu( groups, CmdMenu_GroupAB_CreateRing() );
1082  AddCmdMenu( groups, CmdMenu_GroupAB_Delete() );
1083  AddCmdMenu( groups, CmdMenu_GroupAB_Move() );
1084  AddCmdMenu( groups, CmdMenu_GroupAB_Copy() );
1085  AddCmdMenu( groups, CmdMenu_GroupAB_ToArcs() );
1086 
1087  wxMenu* booleanObjects = new wxMenu;
1088  groups->Append( wxNewId(), wxT( "boolean objects" ), booleanObjects, _( "boolean group A-B objects" ) );
1089 
1090  //boolean operation based on group settings
1091  AddCmdMenu( booleanObjects, CmdMenu_GroupAB_Or() );
1092  AddCmdMenu( booleanObjects, CmdMenu_GroupAB_And() );
1093  AddCmdMenu( booleanObjects, CmdMenu_GroupAB_Exor() );
1094  AddCmdMenu( booleanObjects, CmdMenu_GroupAB_AsubB() );
1095  AddCmdMenu( booleanObjects, CmdMenu_GroupAB_BsubA() );
1096 
1097 #endif //wxART2D_USE_KBOOL
1098 
1099  AddCmdMenu( performMenu, CmdMenu_EmptyDocument() );
1100  AddCmdMenu( performMenu, CmdMenu_EmptyShownObject() );
1101 
1102  wxMenu* menuSettings = new wxMenu;
1103 
1104  AddCmdMenu( menuSettings, CmdMenu_ShowDlgStyle() );
1105  AddCmdMenu( menuSettings, CmdMenu_SetFont() );
1106  AddCmdMenu( menuSettings, CmdMenu_SetBackgroundStyle() );
1107  AddCmdMenu( menuSettings, CmdMenu_DrawGridLines() );
1108  AddCmdMenu( menuSettings, CmdMenu_DrawGridAtFront() );
1109  AddCmdMenu( menuSettings, CmdMenu_DrawGrid() );
1110  AddCmdMenu( menuSettings, CmdMenu_SetSnap() );
1111  AddCmdMenu( menuSettings, CmdMenu_SetDrawWireFrame() );
1112 
1113  wxMenu* menuLayers = new wxMenu;
1114 
1115  wxMenu* savelayersLoc = new wxMenu;
1116  menuLayers->Append( wxNewId(), wxT( "save layerfile" ), savelayersLoc, _( "save layer file to chosen location" ) );
1117  {
1118  AddCmdMenu( savelayersLoc, CmdMenu_SaveLayers() );
1119  AddCmdMenu( savelayersLoc, CmdMenu_SaveLayersHome() );
1120  AddCmdMenu( savelayersLoc, CmdMenu_SaveLayersLastDir() );
1121  AddCmdMenu( savelayersLoc, CmdMenu_SaveLayersCurrentDir() );
1122  }
1123  wxMenu* loadlayersLoc = new wxMenu;
1124  menuLayers->Append( wxNewId(), wxT( "load layerfile" ), loadlayersLoc, _( "load layer file from chosen location" ) );
1125  {
1126  AddCmdMenu( loadlayersLoc, CmdMenu_LoadLayers() );
1127  AddCmdMenu( loadlayersLoc, CmdMenu_LoadLayersHome() );
1128  AddCmdMenu( loadlayersLoc, CmdMenu_LoadLayersLastDir() );
1129  AddCmdMenu( loadlayersLoc, CmdMenu_LoadLayersCurrentDir() );
1130  }
1131  AddCmdMenu( menuLayers, CmdMenu_SetLayerDlg() );
1132  AddCmdMenu( menuLayers, CmdMenu_SetLayerDlgModeless() );
1133  AddCmdMenu( menuLayers, CmdMenu_SetTargetDlg() );
1134 
1135  AddFunctionToMenu( Layer_view, menuLayers, _( "Show layer view" ), _( "layers of this document" ), &a2dEditorFrame::OnMenu, true );
1136 
1137  wxMenu* layerDlgInit = new wxMenu;
1138  menuLayers->Append( wxNewId(), wxT( "LayerDlg" ), layerDlgInit, _( "Show LayerDlg" ) );
1139  AddCmdMenu( layerDlgInit, CmdMenu_ShowDlgLayersDocument() );
1140  AddCmdMenu( layerDlgInit, CmdMenu_ShowDlgLayersDrawing() );
1141  AddCmdMenu( layerDlgInit, CmdMenu_ShowDlgLayersGlobal() );
1142 
1143  wxMenu* orderDlgInit = new wxMenu;
1144  menuLayers->Append( wxNewId(), wxT( "OrderDlg" ), orderDlgInit, _( "Show OrderDlg" ) );
1145  AddCmdMenu( orderDlgInit, CmdMenu_ShowDlgLayerOrderDocument() );
1146  AddCmdMenu( orderDlgInit, CmdMenu_ShowDlgLayerOrderGlobal() );
1147 
1148  wxMenu* dlg_menu = new wxMenu;
1149 
1150  AddCmdMenu( dlg_menu, CmdMenu_ShowDlgPathSettings() );
1151  AddCmdMenu( dlg_menu, CmdMenu_ShowDlgSettings() );
1152  AddCmdMenu( dlg_menu, CmdMenu_ShowDlgTrans() );
1153  AddCmdMenu( dlg_menu, CmdMenu_ShowDlgTools() );
1154  AddCmdMenu( dlg_menu, CmdMenu_ShowDlgStyle() );
1155  AddCmdMenu( dlg_menu, CmdMenu_ShowDlgSnap() );
1156  AddCmdMenu( dlg_menu, CmdMenu_ShowDlgStructure() );
1157  AddCmdMenu( dlg_menu, CmdMenu_ShowDlgIdentify() );
1158  AddCmdMenu( dlg_menu, CmdMenu_ShowDlgMeasure() );
1159  AddCmdMenu( dlg_menu, CmdMenu_ShowDlgCoordEntry() );
1160 
1161  //AddCmdMenu( dlg_menu, CmdMenu_InsertGroupRef() );
1162  AddCmdMenu( dlg_menu, CmdMenu_ShowDlgLayersDocument() );
1163  AddCmdMenu( dlg_menu, CmdMenu_ShowDlgGroups() );
1164  AddCmdMenu( dlg_menu, CmdMenu_ShowDlgPropEdit() );
1165 
1166 #if defined(_DEBUG)
1167  wxMenu* drawTest = new wxMenu;
1168  drawTest->Append( MSCREEN_T, wxT( "test screen" ), wxT( "whatever" ) );
1169 #endif
1170 
1171  wxMenu* help_menu = new wxMenu;
1172  AddFunctionToMenu( wxID_ABOUT, help_menu, _( "&About" ), _( "&About" ), &a2dEditorFrame::OnAbout );
1173 
1174  m_menuBar->Append( file_menu, _( "&File" ) );
1175  m_menuBar->Append( m_editMenu, _( "&Edit" ) );
1176  m_menuBar->Append( optionMenu, _( "&Options" ) );
1177  m_menuBar->Append( cameleonMenu, _( "&Cameleons" ) );
1178  m_menuBar->Append( toolMenu, _( "&Tools" ) );
1179  m_menuBar->Append( drawMenu, _( "&Show" ) );
1180  m_menuBar->Append( refMenu, _( "&Action" ) );
1181  m_menuBar->Append( performMenu, _( "&Perform Operation" ) );
1182  m_menuBar->Append( menuSettings, _( "Settings" ) );
1183  m_menuBar->Append( menuLayers, _( "Layers" ) );
1184  m_menuBar->Append( dlg_menu, _( "&Dialogs" ) );
1185 #if defined(_DEBUG)
1186  m_menuBar->Append( drawTest, _( "&Test" ) );
1187 #endif
1188  m_menuBar->Append( help_menu, _( "&Help" ) );
1189 
1190  SetupToolbar();
1191 
1192  //FillLibraryPoints();
1193 
1194 }
1195 
1196 void a2dEditorFrame::CreateThemeXRC()
1197 {
1198  CreateStatusBarThemed( wxT( "default" ) );
1199 
1200  m_menuBar = new wxMenuBar;
1201  SetMenuBar( m_menuBar );
1202 
1203 #if wxUSE_XRC
1204  if( wxXmlResource::Get() )
1205  {
1206  wxXmlResource::Get()->InitAllHandlers();
1207  wxXmlResource::Get()->AddHandler( new a2dMenuBarXmlHandler );
1208  wxXmlResource::Get()->AddHandler( new a2dMenuXmlHandler );
1209  wxXmlResource::Get()->AddHandler( new a2dToolBarXmlHandler );
1210 
1211  wxString art2d = a2dGeneralGlobals->GetWxArt2DVar( true );
1212  art2d += wxT( "art/resources/" );
1213 
1214 // wxString aResName = wxString::Format(wxT("../resource/%s.xrc"),GetAppName().c_str());
1215  wxString aResName = wxT( "a2dEditorFrame.xrc" );
1216  if( !wxXmlResource::Get()->Load( art2d + aResName ) )
1217  wxMessageBox( wxString::Format( _( "Error load XRC-file '%s'.\nWorking directory is '%s'" ), aResName.c_str(), wxGetCwd().c_str() ) );
1218  }
1219 
1220  wxXmlResource::Get()->LoadObject( this, wxT( "frameMenu" ), wxT( "a2dMenuBar" ) );
1221  wxXmlResource::Get()->LoadObject( this, wxT( "toolbar" ), wxT( "a2dToolBar" ) );
1222 
1223  m_editMenu = m_menuBar->GetMenu( m_menuBar->FindMenu( wxT("Edit") ) );
1224 #endif
1225 }
1226 
1227 void a2dEditorFrame::CreateThemeTest()
1228 {
1229  /*
1230  wxString path = pathList.FindValidPath("pat36.bmp");
1231  wxBitmap mono;
1232  mono.LoadFile(path, wxBITMAP_TYPE_BMP);
1233  wxMask* mask25 = new wxMask(mono, *wxWHITE);
1234  // associate a monochrome mask with this bitmap
1235  mono.SetMask(mask25);
1236 
1237  a2dPatternFill* pFill = new a2dPatternFill( mono );
1238  pFill->SetStyle(a2dFILL_STIPPLE_MASK_OPAQUE);
1239  */
1240 
1241  CreateThemeDefault();
1242  //FillLibrary();
1243 }
1244 
1245 void a2dEditorFrame::OnUpdateUI( wxUpdateUIEvent& event )
1246 {
1247 }
1248 
1249 void a2dEditorFrame::FillData( wxCommandEvent& event )
1250 {
1251  a2dCanvasObject* datatree = m_drawingPart->GetShowObject();
1252 
1253  a2dRect* tr = new a2dRect( -500, 750, 900, 80 );
1254  tr->SetStroke( wxColour( 229, 5, 64 ), 0 );
1255  tr->SetFill( wxColour( 0, 117, 245 ) );
1256  datatree->Append( tr );
1257 
1258  a2dCanvasObjectReference* ref1 = new a2dCanvasObjectReference( 1500, -500, tr );
1259 // ref1->SetScale(2,3.2);
1260  ref1->SetRotation( 35 );
1261  datatree->Append( ref1 );
1262 
1263 
1264  a2dText* tt = new a2dText( _T( "Hello NON rotated text in a2dCanvas World" ), -500, 750,
1265  a2dFont( 80.0, wxDECORATIVE, wxITALIC ) );
1266  tt->SetFill( wxColour( 0, 10, 200 ) );
1267  tt->SetStroke( *wxGREEN );
1268  datatree->Append( tt );
1269 
1270  a2dText* tt2 = new a2dText( _T( "Hello NON rotated \ntext in\n a2dCanvas World" ), -500, 550,
1271  a2dFont( 50.0 , wxDECORATIVE, wxITALIC ) );
1272  tt2->SetFill( *a2dTRANSPARENT_FILL );
1273  tt2->SetStroke( *wxGREEN );
1274  datatree->Append( tt2 );
1275 
1276 
1277  a2dArc* aca2 = new a2dArc( -630.0, 350.0, -730.0, -200.0, -730.0, 250.0 );
1278  aca2->SetFill( *a2dTRANSPARENT_FILL );
1279  aca2->SetStroke( wxColour( 1, 215, 6 ), 10, a2dSTROKE_SOLID );
1280  datatree->Prepend( aca2 );
1281 
1282 
1283  m_drawingPart->SetMappingShowAll();
1284 }
1285 
1286 void a2dEditorFrame::OnDragSimulate(wxCommandEvent& event)
1287 {
1288  a2dDragTool* drag = new a2dDragTool( m_contr );
1289  drag->SetDropAndDrop( true );
1290  m_contr->PushTool( drag );
1291 
1292 }
1293 
1294 void a2dEditorFrame::OnCopyShape(wxCommandEvent& WXUNUSED(event))
1295 {
1296  a2dDrawingPart* part = m_drawingPart;
1297  a2dDnDCanvasObjectDataCVG* copied = new a2dDnDCanvasObjectDataCVG( part);
1298  copied->SetExportWidthHeightImage( 10000 );
1299  //a2dDnDCameleonData* copied = new a2dDnDCameleonData();
1300 
1301  if ( part && part->GetShowObject() && part->GetShowObject()->GetRoot() )
1302  {
1304  forEachIn( a2dCanvasObjectList, objects )
1305  {
1306  a2dCanvasObject* obj = *iter;
1307  if ( obj->GetRelease() || !obj->IsVisible() || !obj->GetSelected() )
1308  continue;
1309  copied->Append( obj );
1310  }
1311  copied->Reconnect();
1312 
1313  wxClipboardLocker clipLocker;
1314  if ( !clipLocker )
1315  {
1316  wxLogError(wxT("Can't open the clipboard"));
1317 
1318  return;
1319  }
1320 
1321  wxTheClipboard->AddData( copied );
1322  }
1323 }
1324 
1325 void a2dEditorFrame::OnPasteShape(wxCommandEvent& WXUNUSED(event))
1326 {
1327  wxClipboardLocker clipLocker;
1328  if ( !clipLocker )
1329  {
1330  wxLogError(wxT("Can't open the clipboard"));
1331  return;
1332  }
1333 
1334  a2dDrawingPart* part = m_drawingPart;
1335 
1336  if ( part && part->GetShowObject() && part->GetShowObject()->GetRoot() )
1337  {
1338  a2dDnDCanvasObjectDataCVG shapeDataObject( part);
1339  //a2dDnDCameleonData shapeDataObject(NULL);
1340  shapeDataObject.SetImportWidthHeightImage( 10000 );
1341  if ( wxTheClipboard->GetData(shapeDataObject) )
1342  {
1343  a2dDrawingPtr drawing = shapeDataObject.GetDrawing();
1344  a2dCanvasObjectPtr shape = drawing->GetRootObject();
1345  a2dCanvasObject* root = part->GetDrawing()->GetRootObject();
1346 
1348  setflags2.SetSkipNotRenderedInDrawing( true );
1349  setflags2.Start( part->GetShowObject(), false );
1351  shape->SetRoot( part->GetDrawing() );
1352  a2dBoundingBox box = shape->GetBbox();
1353  a2dPoint2D p = box.GetCentre();
1354  shape->Translate( -p.m_x, -p.m_y );
1355  shape->EliminateMatrix();
1356 
1357  // to test
1358  //root->Append( shape );
1359 
1360  if ( shape->GetChildObjectList()->size() )
1361  {
1362  a2dDragMultiNewTool* dragnew = new a2dDragMultiNewTool( (a2dStToolContr *) (part->GetCanvasToolContr()), shape->GetChildObjectList() );
1363  dragnew->SetOneShot();
1364  dragnew->SetStroke( a2dStroke( *wxRED, 1 ) );
1365  dragnew->SetFill( a2dFill( wxColour( 0xc0, 0xff, 0xff ) ) );
1366  (a2dStToolContr *) (part->GetCanvasToolContr())->PushTool( dragnew );
1367  }
1368  else
1369  {
1370  wxLogStatus(wxT("No shape on the clipboard"));
1371  }
1372  }
1373  else
1374  {
1375  wxLogStatus(wxT("No shape on the clipboard"));
1376  }
1377  }
1378 }
1379 
1380 void a2dEditorFrame::OnUpdatePasteShape( wxUpdateUIEvent& event )
1381 {
1382  a2dDrawingPart* part = m_drawingPart;
1383  a2dDnDCanvasObjectDataCVG shapeDataObject( part);
1384  wxDataFormat formats[10];
1385  shapeDataObject.GetAllFormats( formats );
1386  int nr = shapeDataObject.GetFormatCount();
1387 
1388  bool ret = false;
1389 
1390  for ( int i = 0 ; i < nr ; i++ )
1391  {
1392  ret |= wxTheClipboard->IsSupported( formats[i] );
1393  }
1394 
1395  event.Enable( ret );
1396 }
1397 
1398 void a2dEditorFrame::OnUpdateCopyShape( wxUpdateUIEvent& event )
1399 {
1400  bool ret = false;
1401  a2dDrawingPart* part = m_drawingPart;
1402  if ( part && part->GetShowObject() && part->GetShowObject()->GetRoot() )
1403  {
1405  forEachIn( a2dCanvasObjectList, objects )
1406  {
1407  a2dCanvasObject* obj = *iter;
1408  if ( obj->GetRelease() || !obj->IsVisible() || !obj->GetSelected() )
1409  continue;
1410  ret = true;
1411  break;
1412  }
1413  }
1414  event.Enable( ret );
1415 }
static const a2dCanvasObjectFlagsMask SELECTED2
Definition: candefs.h:181
Display Part of a a2dDrawing, in which a2dCanvasObjects are shown.
Definition: drawer.h:470
wxPoint2DDouble a2dPoint2D
this to define if coordinate numbers are integer or doubles
Definition: artglob.h:47
(In) Visible property that can be added to Docview Objects.
Definition: gen.h:1785
#define wxDynamicCast(obj, className)
Define wxDynamicCast so that it will give a compiler error for unrelated types.
Definition: gen.h:75
Base class for all types of strokes, understood by a2dDrawer2D classes.
Definition: stylebase.h:378
void SetRoot(a2dDrawing *root, bool recurse=true)
Sets this object to a a2dCanvasDocument.
Definition: canobj.cpp:5933
wxUint16 GetLayer() const
layer set for new objects.
Definition: canglob.h:930
a2dPoint2D GetCentre() const
get centre
Definition: bbox.cpp:277
a2dCanvasObjectReference is a reference to any a2dCanvasObject derived class.
Definition: recur.h:53
bool PushTool(a2dBaseTool *tool)
specialize to keep first tool on the stack active
Definition: sttool.cpp:451
static const a2dSignal sm_changedProperty
Definition: gen.h:381
a2dView * AddDocumentCreateView(a2dDocument *newDoc, const wxString &viewTypeName=wxT(""), a2dDocumentFlagMask documentflags=a2dREFDOC_NEW, a2dTemplateFlagMask docTemplateFlags=a2dTemplateFlag::VISIBLE, a2dTemplateFlagMask viewTemplateFlags=a2dTemplateFlag::VISIBLE)
adds the given document, and creates a view for it.
Definition: doccom.cpp:1447
void SetRotation(double rotation)
Sets a rotation of this object.
Definition: canobj.cpp:2609
View on a a2dCanvasDocument.
Definition: candoc.h:212
The a2dViewTemplate class is used to model the relationship between a document class and a view class...
Definition: docviewref.h:2635
wxClassInfo * m_editorClassInfo
For dynamic creation of appropriate instances.
Definition: canedit.h:43
void SetFill(const a2dFill &fill)
set fill if used inside a tool
Definition: tools.cpp:812
a2dCanvasObject * GetRootObject() const
get the root object, which holds the objects in the document
Definition: drawing.h:521
const a2dViewTemplateList & GetViewTemplates()
returns a reference to the a2dViewTemplateList, which contains all a2dViewTemplate&#39;s.
Definition: doccom.h:785
Ref Counted base object.
Definition: gen.h:1045
a2dDrawing * GetRoot() const
get a2dCanvasDocument of the object.
Definition: canobj.h:952
virtual void SetDisplayWindow(wxWindow *display)
Set the display window.
#define EVT_DO(func)
event sent from a2DocumentCommandProcessor when a command is initially done
Definition: comevt.h:795
void SetOneShot()
Only one action of the tool, after that it will ask the controller to stop this tool.
Definition: tools.h:430
virtual bool Update(UpdateMode mode)
Update the state of the object according to its current position etc.
Definition: canobj.cpp:5149
wxString & GetUndoMenuLabel()
by default this is a2dCommandProcessor::GetUndoMenuLabel()
Definition: comevt.h:762
Defines a font to be set to a2dDrawer2D or stored in a2dCanvsObject etc.
Definition: stylebase.h:779
void AddCmdToToolbar(const a2dMenuIdItem &cmdId)
add items to toolbar using a predefined command ID.
void OnActivate(wxActivateEvent &event)
intercepted to initialize redo and undo menu&#39;s
Definition: canedit.cpp:445
void SetBackgroundFill(const a2dFill &backgroundfill)
background fill for the canvas
Definition: drawer.cpp:3131
a2dDrawing * GetDrawing() const
get the root object, which holds the objects in the document.
Definition: candoc.h:418
void SetZoomFirst(bool zoomfirst)
first tool on the tool stack is the zoom tool.
Definition: sttool.cpp:293
void SetGrid(bool grid)
Set grid on/off.
Definition: drawer.h:905
a2dView * GetView()
Get the view created.
Definition: docviewref.h:916
a2dEditorFrame()
this makes dynamic creation possible ( e.g. a derived a2dEditorFrame )
Definition: canedit.cpp:261
a2dView event, to report events in the a2dView class
Definition: docviewref.h:424
a2dCanvasObject is the base class for Canvas Objects.
Definition: canobj.h:371
wxPoint & GetInitialPosition()
Get position used for new created views or frames or windows.
Definition: docviewref.h:2883
Docview framework its controlling class.
draw a rectangle the size of the bounding box of the object draged.
Definition: sttool.h:79
virtual void SetBufferSize(int w, int h)
sets buffersize ( if used ) for the a2dDrawer2D
Definition: drawer.cpp:755
a2dDrawingPart * GetDrawingPart()
Get the a2dDrawingPart object that the controller is plugged into.
Definition: tools.h:104
void Zoomout()
show all on canvas
Definition: sttool.cpp:378
a2dLayers * GetLayerSetup()
Get the layersettings for the canvas.
Definition: drawing.h:506
bool GetActive()
when ::wxEVT_ACTIVATE_VIEW get activation value of the event
Definition: docviewref.h:521
a2dCanvasObjectList * GetChildObjectList()
get the list where the child objects are stored in.
Definition: canobj.cpp:2551
#define EVT_MENUSTRINGS(func)
event sent to a2dCommandProcessorEvents to adjust menu strings (e.g. for current undo/redo command) ...
Definition: comevt.h:801
void OnPostCreateView(a2dTemplateEvent &event)
Creates a a2dEditorFrame and sets its its a2dCanvas as the DisplayWindow for the view.
Definition: canedit.cpp:91
bool GetSelected() const
is the object selected flag set
Definition: canobj.h:1603
void SetGridSize(wxUint16 gridsize)
set size of grid circle
Definition: drawer.h:887
bool IsVisible() const
get visibility (rendering depends on layer settings also)
Definition: canobj.h:1316
bool Create(bool createCanvas, bool isParent, wxFrame *parent, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE)
delayed creation of window.
Definition: canedit.cpp:278
Holds a view on a a2dDocument.
Definition: docviewref.h:1804
used to theme a a2dEditorFrame
Definition: canedit.h:85
void SetGridX(double gridx)
Set grid distance in X.
Definition: drawer.h:896
event sent to a2dViewConnector
Definition: docviewref.h:870
a2dText is an abstract base class.
Definition: cantext.h:93
void SetGridAtFront(bool gridatfront)
Set grid setting for drawing grid in front or back.
Definition: drawer.h:878
a2dDocument * GetDocument()
the document created.
Definition: docviewref.h:903
bool Create(bool parentFrame, wxWindow *frame, a2dView *view=NULL, wxWindowID id=-1, const wxString &title=wxT("a2dDocumentFrame"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_FRAME_STYLE, const wxString &name=wxT("frame"))
Constructor for two-step-creation (2nd step)
void AddCmdMenu(wxMenu *parentMenu, const a2dMenuIdItem &cmdId)
add a menu to the parent menu, and connect it to the eventhandler of the frame
wxSize m_initialSize
size for new frames
Definition: docviewref.h:2973
bool ProcessEvent(wxEvent &event)
Modified event handler to also sent event to a2dView or wxDocviewCommonEvents.
Interactive drag an object.
Definition: sttool.h:1012
#define forEachIn(listtype, list)
easy iteration for a2dlist
Definition: a2dlist.h:111
The a2dStToolContr is a Tool Controller specialized for working with a2dCanvasView.
Definition: sttool.h:485
#define EVT_COM_EVENT(func)
static wxEvtHandler for communication event
Definition: gen.h:564
The a2dDocumentFrame class provides a default frame for displaying documents.
Definition: docviewref.h:3357
Creates and Connect a wxEditorFrame + a2dCanvas with a view.
Definition: canedit.h:28
#define wxStaticCast(obj, className)
The wxWindows 2.4.2 wxStaticCast is buggy. It evaluates its argument twice.
Definition: gen.h:123
#define EVT_POST_CREATE_VIEW(func)
sent from a view template after it created a view
Definition: docviewref.h:1013
void SetDragMode(DRAGMODE mode)
drag mode used in drag tool (if used)
Definition: sttool.h:563
a2dCanvasObject * GetShowObject() const
return pointer of then currently shown object on the drawer.
Definition: drawer.h:680
A2DGENERALDLLEXP a2dSmrtPtr< a2dGeneralGlobal > a2dGeneralGlobals
a global pointer to get to global instance of important classes.
Definition: comevt.cpp:1148
a2dCanvas and a2dCanvasView meet eachother here.
Definition: candoc.h:774
void Translate(double x, double y)
relative translate the object to position x,y in world coordinates
Definition: canobj.h:569
#define EVT_POST_CREATE_DOCUMENT(func)
sent from a doc template after it created a document
Definition: docviewref.h:1011
#define EVT_ACTIVATE_VIEW_SENT_FROM_CHILD(func)
event sent from view and its display up the parent chain.
Definition: docviewref.h:1001
void Prepend(a2dCanvasObject *obj)
prepend a a2dCanvasObject to the childobjects
Definition: canobj.cpp:6209
static const a2dCanvasObjectFlagsMask SELECTED
Definition: candefs.h:180
bool CanRedo()
by default this is a2dCommandProcessor::CanRedo()
Definition: comevt.h:768
uses a wxFrame to hold new views or to create child wxFrame&#39;s to hold new views.
Definition: docviewref.h:2997
#define EVT_THEME_EVENT(func)
static wxEvtHandler for theme event, send from a2dEditorFrame
Definition: canedit.h:111
wxFrame * m_docframe
the frame which receives events and often redirect those to the document manager. ...
Definition: docviewref.h:3051
set a2dCanvasObjects flags in a hierarchy of a a2dCanvasDocument
Definition: algos.h:486
void OnSetmenuStrings(a2dCommandProcessorEvent &event)
handler for event to set undo redo menustrings
Definition: canedit.cpp:455
void Init()
initialize
Definition: canedit.cpp:334
a2dCanvas is used to display one of the a2dCanvasObjects which are part of a a2dCanvasDocument object...
Definition: canvas.h:68
std::vector< wxString > & GetStatusStrings()
Get the array containing statusbar strings.
Definition: sttool.h:637
wxMenu * m_editMenu
to hold undo redo menu&#39;s which are reinitialized at activation of view
Definition: canedit.h:251
object stay in document and it is redrawn while dragging, and so are all objects above and below it...
Definition: sttool.h:83
bool CanUndo()
by default this is a2dCommandProcessor::CanUndo()
Definition: comevt.h:766
All updates of these modes force an update (e.g. update non-pending valid bounding boxes) ...
Definition: canobj.h:1107
a2dCommandProcessor * GetCommandProcessor() const
Returns a pointer to the command processor associated with this document.
Definition: drawing.h:549
a2dDocument * GetDocument() const
get the document of the view
Definition: docviewref.h:1882
a2dDocviewGlobal * a2dDocviewGlobals
a global pointer to get to global instance of important classes.
Definition: doccom.cpp:2348
void SetStroke(const wxColour &strokecolor, double width=0, a2dStrokeStyle style=a2dSTROKE_SOLID)
Set a stroke for the object which will be used instead of the layer stroke.
Definition: canobj.cpp:2924
void SetGridY(double gridy)
Set grid distance in Y.
Definition: drawer.h:902
long GetInitialStyle()
Get style used for new created a2dDocumentFrame.
Definition: docviewref.h:2889
sepcialized Frame for editor of a2dCanvas
Definition: canedit.h:117
void SetGridStroke(const a2dStroke &gridstroke)
set stroke used for grid drawing
Definition: drawer.cpp:3137
void Theme(const wxString &themeName=wxT("default"))
setup menu
Definition: canedit.cpp:818
property to hold a a2dStroke type variable to be associated with a a2dObject
Definition: styleprop.h:98
Each a2dCanvasView needs to have a a2dCanvasDocument set in order to render data. ...
Definition: candoc.h:374
bool GetRelease() const
get release flag
Definition: gen.h:1350
bool m_isParentFrame
is this the docframe or not.
Definition: docviewref.h:3597
virtual a2dView * CreateView(a2dDocument *doc, a2dDocumentFlagMask flags=a2dREFDOC_NON)
Creates a new view for the given document.
a2dCanvasObject * SetShowObject(const wxString &name)
set object available in the a2dDrawing to be shown on the drawer
Definition: drawer.cpp:2947
void AddFunctionToMenu(int id, wxMenu *parentMenu, const wxString &text, const wxString &helpString, wxObjectEventFunctionM func, bool check=false)
add a menu which executes a function
Definition: canedit.cpp:683
void SetStroke(const a2dStroke &stroke)
set stroke if used inside a tool
Definition: tools.cpp:817
a2dViewTemplateList m_viewTemplates
templates for views
Definition: docviewref.h:2979
wxString & GetRedoMenuLabel()
by default this is a2dCommandProcessor::GetRedoMenuLabel()
Definition: comevt.h:764
Event sent to a2dCommandProcessor.
Definition: comevt.h:701
virtual bool EliminateMatrix()
reduce matrix to identity
Definition: canobj.cpp:6191
see a2dComEvent
Definition: gen.h:371
void OnCloseWindow(wxCloseEvent &event)
called on Close window
Definition: canedit.cpp:408
a2dDocumentCommandProcessor * GetDocviewCommandProcessor() const
Gets a2dDocumentCommandProcessor pointer.
Definition: doccom.h:1034
a2dRect
Definition: canprim.h:440
static const wxEventType sm_showCursor
Definition: sttool.h:791
The a2dBoundingBox class stores one a2dBoundingBox of a a2dCanvasObject.
Definition: bbox.h:39
wxSize & GetInitialSize()
GGet size used for new created views or frames or windows.
Definition: docviewref.h:2886
a2dDrawing * GetDrawing() const
get drawing via top object
Definition: drawer.cpp:726
a2dArc centered at x,y
Definition: canprim.h:823
void SetDocumentTypeName(const wxString &name)
Sets the document type name for this document. See the comment for documentTypeName.
Definition: docviewref.h:1121
a2dCanvasGlobal * a2dCanvasGlobals
global a2dCanvasGlobal to have easy access to global settings
Definition: canglob.cpp:1234
#define EVT_UNDO(func)
event sent from a2DocumentCommandProcessor when a command is undone
Definition: comevt.h:797
a command wrapper specially designed to work with wxArt2D docview classes and rest.
Definition: cancom.h:100
a clone is created which is draged in an outline mode, original stays at position until drag is finis...
Definition: sttool.h:85
all headers in the editor module
void Append(a2dCanvasObject *obj)
append a a2dCanvasObject to the childobjects
Definition: canobj.cpp:6224
virtual a2dViewTemplate * SelectViewType(a2dDocument *doc, const a2dViewTemplateList &list, const wxString &viewTypeName=wxT(""), bool sort=false, a2dTemplateFlagMask viewTemplateFlags=a2dTemplateFlag::VISIBLE)
Returns a view template by asking the user.
Definition: doccom.cpp:1949
GdsII format input and output.
property to hold a a2dFill type variable to be associated with a a2dObject
Definition: styleprop.h:44
seperate the object from the document, and layer, so it will be draged on top of all other objects...
Definition: sttool.h:81
bool DisconnectEvent(wxEventType type, wxEvtHandler *eventSink)
Definition: gen.cpp:902
a2dSmrtPtr< a2dView > m_view
Definition: docviewref.h:3594
a2dBoundingBox & GetBbox()
get boundingbox in world coordinates exclusive stroke width relative to its parent ...
Definition: canobj.cpp:3175
a2dSmrtPtr< a2dStToolContr > m_contr
tool controller to be defined by user
Definition: canedit.h:206
void SetFill(const a2dFill &fill)
Set a fill for the object which will be used instead of the layer fill.
Definition: canobj.cpp:2874
const a2dFill * a2dTRANSPARENT_FILL
global a2dFill stock object for TRANSPARENT filling
wxString GetViewTypeName() const
get type name of the view.
Definition: docviewref.h:1908
canedit.cpp Source File -- Sun Oct 12 2014 17:04:13 -- Sun Oct 12 2014 -- 1.8.5 -- wxArt2D -- . -- Main Page Reference Documentation