00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #include "a2dprec.h"
00012
00013 #ifdef __BORLANDC__
00014 #pragma hdrstop
00015 #endif
00016
00017 #ifndef WX_PRECOMP
00018 #include "wx/wx.h"
00019 #endif
00020
00021 #include "wx/canextobj/canext.h"
00022 #include "wx/canvas/objlist.h"
00023 #include "wx/canvas/candoc.h"
00024 #include "wx/canvas/drawer.h"
00025 #include "wx/editor/editmod.h"
00026
00027 #include <math.h>
00028
00029
00030
00031
00032 IMPLEMENT_DYNAMIC_CLASS(a2dTextGroup, a2dCanvasObject)
00033 IMPLEMENT_DYNAMIC_CLASS(a2dDrawingFrame, a2dPolygonLClipper2)
00034
00035
00036
00037
00038
00039
00040
00041 a2dTextGroup::a2dTextGroup()
00042 : a2dCanvasObject()
00043 {
00044 }
00045
00046 a2dTextGroup::a2dTextGroup(double x, double y)
00047 : a2dCanvasObject()
00048 {
00049 m_lworld.Translate(x,y);
00050 }
00051
00052 a2dTextGroup::~a2dTextGroup()
00053 {
00054 }
00055
00056 a2dObject* a2dTextGroup::Clone( CloneOptions options ) const
00057 {
00058 return new a2dTextGroup( *this, options );
00059 };
00060
00061 a2dTextGroup::a2dTextGroup( const a2dTextGroup &other, CloneOptions options )
00062 :a2dCanvasObject( other, options )
00063 {
00064 }
00065
00066 void a2dTextGroup::RenderChildObjectsOneLayer( a2dIterC& ic, RenderChild& WXUNUSED(whichchilds), OVERLAP clipparent )
00067 {
00068 if ( m_childobjects == wxNullCanvasObjectList )
00069 return;
00070
00071
00072 a2dFill currentdrawer_fill = ic.GetDrawer2D()->GetDrawerFill();
00073 a2dStroke currentdrawer_stroke = ic.GetDrawer2D()->GetDrawerStroke();
00074
00075 forEachIn( a2dCanvasObjectList, m_childobjects )
00076 {
00077 a2dCanvasObject *obj = *iter;
00078
00079 int olayer=obj->GetLayer();
00080
00081 if ( olayer==ic.GetLayer() || ic.GetLayer()==wxLAYER_ALL || obj->GetChildObjectList() )
00082 {
00083
00084
00085
00086
00087 OVERLAP childclip = _IN;
00088 if ( clipparent != _IN )
00089 childclip = obj->GetClipStatus( ic, clipparent );
00090
00091
00092
00093 if ( childclip != _OUT )
00094 {
00095 obj->Render( ic, childclip );
00096 }
00097 }
00098 }
00099
00100 ic.GetDrawer2D()->SetDrawerFill( currentdrawer_fill );
00101 ic.GetDrawer2D()->SetDrawerStroke( currentdrawer_stroke );
00102 }
00103
00104
00105
00106
00107
00108
00109
00110 A2D_BEGIN_EVENT_TABLE(a2dDrawingFrame,a2dPolygonLClipper2)
00111 A2D_EVT_CANVASOBJECT_MOUSE_EVENT( a2dDrawingFrame::OnCanvasObjectMouseEvent )
00112 A2D_EVT_CHAR( a2dDrawingFrame::OnChar )
00113 A2D_END_EVENT_TABLE()
00114
00115 void a2dDrawingFrame::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
00116 {
00117 handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectStart );
00118 a2dPolygonLClipper2::DoWalker( parent, handler );
00119 handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectEnd );
00120 }
00121
00122 bool a2dDrawingFrame::DoStartEdit( wxUint16 editmode, wxEditStyle editstyle )
00123 {
00124 if ( m_flags.m_editable )
00125 {
00126 PROPID_IncludeChildren->SetPropertyToObject( this, false );
00127 PROPID_Allowrotation->SetPropertyToObject( this, false );
00128 PROPID_Allowskew->SetPropertyToObject( this, false );
00129
00130 return a2dPolygonLClipper2::DoStartEdit( editmode, editstyle );
00131 }
00132
00133 return false;
00134 }
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169 void a2dDrawingFrame::OnCanvasObjectMouseEvent( a2dCanvasObjectMouseEvent& event )
00170 {
00171 a2dIterC* ic = event.GetIterC();
00172
00173 if ( m_flags.m_editingCopy )
00174 {
00175
00176 double xw,yw;
00177 xw = event.GetX();
00178 yw = event.GetY();
00179
00180 a2dAffineMatrix atWorld = ic->GetTransform();
00181
00182 if ( event.GetMouseEvent().LeftDown() )
00183 {
00184 if ( event.GetMouseEvent().m_shiftDown )
00185 {
00186
00187 a2dDrawingFrame* original = wxStaticCast( PROPID_Original->GetPropertyValue( this ).Get(), a2dDrawingFrame );
00188 a2dIterCU cu( *ic, original );
00189
00190 a2dStToolContr* controller = wxStaticCast( PROPID_Controller->GetPropertyValue( this ).Get(), a2dStToolContr );
00191 ic->SetCorridorPath( true, NULL );
00192
00193
00194
00195
00196
00197 SetPending( true );
00198 ic->GetCanvasView()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_CROSS ) );
00199
00200
00201
00202
00203
00204
00205
00206
00207 }
00208 else if ( event.GetMouseEvent().m_controlDown )
00209 {
00210 a2dDrawingFrame* original = wxStaticCast( PROPID_Original->GetPropertyValue( this ).Get(), a2dDrawingFrame );
00211 a2dIterCU cu( *ic, original );
00212
00213 a2dStToolContr* controller = wxStaticCast( PROPID_Controller->GetPropertyValue( this ).Get(), a2dStToolContr );
00214 ic->SetCorridorPath( true, NULL );
00215 a2dDrawPolygonLTool* draw = new a2dDrawPolygonLTool( controller );
00216 controller->PushTool( draw );
00217 draw->SetEditAtEnd( true );
00218
00219 SetPending( true );
00220 ic->GetCanvasView()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_CROSS ) );
00221 }
00222 else
00223 {
00224 a2dHitEvent hitevent = a2dHitEvent( xw, yw, false );
00225 if ( IsHitWorld( *ic, hitevent ) )
00226 {
00227 a2dDrawingFrame* original = wxStaticCast( PROPID_Original->GetPropertyValue( this ).Get(), a2dDrawingFrame );
00228 a2dHitEvent hitinfo( xw, yw, false, a2dCANOBJHITOPTION_LAYERS );
00229 hitinfo.m_xyRelToChildren = true;
00230 a2dCanvasObject* curve = original->ChildIsHitWorld( *ic, hitinfo );
00231 if ( curve && curve->GetEditable() )
00232 {
00233 a2dIterCU cu2( *ic, original );
00234 a2dStToolContr* controller = wxStaticCast( PROPID_Controller->GetPropertyValue( this ).Get(), a2dStToolContr );
00235
00236 ic->SetCorridorPath( true, NULL );
00237 controller->StartEditingObject( curve, *ic );
00238
00239 SetPending( true );
00240 ic->GetCanvasView()->SetCursor( a2dCanvasGlobals->GetCursor( a2dCURSOR_CROSS ) );
00241 }
00242 else
00243 event.Skip();
00244 }
00245 else
00246 EndEdit();
00247 }
00248 }
00249 else if ( event.GetMouseEvent().LeftDClick() )
00250 {
00251 EndEdit();
00252 }
00253 else if ( event.GetMouseEvent().Moving() )
00254 {
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271 event.Skip();
00272 }
00273 else
00274 event.Skip();
00275 }
00276 else
00277 event.Skip();
00278 }
00279
00280 a2dDrawingFrame::a2dDrawingFrame( double x, double y, double width, double height ): a2dPolygonLClipper2()
00281 {
00282 Clear();
00283 AddPoint( 0, 0 );
00284 AddPoint( 0 , height );
00285 AddPoint( width , height );
00286 AddPoint( width , 0 );
00287
00288 m_lworld.Translate(x,y);
00289 }
00290
00291 a2dDrawingFrame::~a2dDrawingFrame()
00292 {
00293 }
00294
00295 a2dDrawingFrame::a2dDrawingFrame( const a2dDrawingFrame &other, CloneOptions options )
00296 :a2dPolygonLClipper2( other, options )
00297 {
00298 }
00299
00300 a2dObject* a2dDrawingFrame::Clone( CloneOptions options ) const
00301 {
00302 return new a2dDrawingFrame( *this, options );
00303 }
00304
00305 void a2dDrawingFrame::DoRender( a2dIterC& ic, OVERLAP clipparent )
00306 {
00307 a2dPolygonLClipper2::DoRender( ic, clipparent );
00308 }
00309
00310 bool a2dDrawingFrame::DoIsHitWorld( a2dIterC& WXUNUSED(ic), a2dHitEvent& hitEvent )
00311 {
00312 hitEvent.m_how = a2dHit::stock_fill;
00313 return true;
00314 }
00315
00316 #if wxART2D_USE_CVGIO
00317 void a2dDrawingFrame::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
00318 {
00319 a2dPolygonLClipper2::DoSave( parent, out, xmlparts, towrite );
00320 if ( xmlparts == a2dXmlSer_attrib )
00321 {
00322 }
00323 else
00324 {
00325 }
00326 }
00327
00328 void a2dDrawingFrame::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
00329 {
00330 a2dPolygonLClipper2::DoLoad( parent, parser, xmlparts );
00331 if ( xmlparts == a2dXmlSer_attrib )
00332 {
00333 }
00334 else
00335 {
00336 }
00337 }
00338 #endif //wxART2D_USE_CVGIO
00339