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/wfstream.h>
00022 #include <wx/module.h>
00023 #include <wx/clipbrd.h>
00024
00025 #include "wx/canvas/canobj.h"
00026 #include "wx/canvas/rectangle.h"
00027 #include "wx/canvas/canglob.h"
00028 #include "wx/canvas/vpath.h"
00029 #include "wx/canvas/candoc.h"
00030 #include "wx/canvas/cancom.h"
00031 #include "wx/canvas/drawer.h"
00032 #include "wx/canvas/canvas.h"
00033 #include "wx/canvas/wire.h"
00034 #include "wx/canvas/canwidget.h"
00035
00036 #if defined(__WXMSW__) && defined(__MEMDEBUG__)
00037 #include <wx/msw/msvcrt.h>
00038 #endif
00039
00040 IMPLEMENT_CLASS(a2dRectMM, a2dCanvasObject)
00041 IMPLEMENT_CLASS(a2dWindowMM, a2dRectMM)
00042 IMPLEMENT_CLASS(a2dRectWindowT2, a2dRectMM)
00043 IMPLEMENT_CLASS(a2dRectWindow, a2dRectMM)
00044
00045
00046
00047
00048
00049 A2D_BEGIN_EVENT_TABLE( a2dRectMM, a2dCanvasObject )
00050 A2D_EVT_CANVASHANDLE_MOUSE_EVENT( a2dRectMM::OnHandleEvent )
00051 A2D_END_EVENT_TABLE()
00052
00053 a2dRectMM::a2dRectMM()
00054 : a2dCanvasObject()
00055 {
00056 m_minx = 0;
00057 m_miny = 0;
00058 m_maxx = 0;
00059 m_maxy = 0;
00060 m_radius = 0;
00061 m_contourwidth = 0;
00062 m_border = 0;
00063 }
00064
00065 a2dRectMM::a2dRectMM( double x, double y, double w, double h , double radius, double contourwidth )
00066 : a2dCanvasObject( x, y )
00067 {
00068 m_minx = 0;
00069 m_miny = 0;
00070 m_maxx = w;
00071 m_maxy = h;
00072 m_radius = radius;
00073 m_contourwidth = contourwidth;
00074 m_border = 0;
00075 }
00076
00077 a2dRectMM::a2dRectMM( const a2dPoint2D& p1, const a2dPoint2D& p2, double radius, double contourwidth )
00078 : a2dCanvasObject( p1.m_x, p1.m_y )
00079 {
00080 m_minx = 0;
00081 m_miny = 0;
00082 m_maxx = p2.m_x - p1.m_x;
00083 m_maxy = p2.m_y - p1.m_y;
00084 m_radius = radius;
00085 m_contourwidth = contourwidth;
00086 m_border = 0;
00087 }
00088
00089 a2dRectMM::a2dRectMM( const a2dBoundingBox& bbox, double radius, double contourwidth )
00090 : a2dCanvasObject( bbox.GetMinX(), bbox.GetMinY() )
00091 {
00092 m_minx = bbox.GetMinX();
00093 m_miny = bbox.GetMinY();
00094 m_maxx = bbox.GetMaxX();
00095 m_maxy = bbox.GetMaxY();
00096 m_radius = radius;
00097 m_contourwidth = contourwidth;
00098 m_border = 0;
00099 }
00100
00101 a2dRectMM::~a2dRectMM()
00102 {
00103 }
00104
00105 a2dRectMM::a2dRectMM( const a2dRectMM &other, CloneOptions options )
00106 :a2dCanvasObject( other, options )
00107 {
00108 m_minx = other.m_minx;
00109 m_miny = other.m_miny;
00110 m_maxx = other.m_maxx;
00111 m_maxy = other.m_maxy;
00112 m_radius = other.m_radius;
00113 m_contourwidth = other.m_contourwidth;
00114 m_border = other.m_border;
00115 }
00116
00117 a2dObject* a2dRectMM::Clone( CloneOptions options ) const
00118 {
00119 return new a2dRectMM( *this, options );
00120 };
00121
00122 a2dVertexList* a2dRectMM::GetAsPolygon()
00123 {
00124 a2dVertexList* pointlist = new a2dVertexList();
00125
00126 a2dCanvasObjectList* vectorpaths = GetAsCanvasVpaths();
00127 a2dVpath* segments = wxStaticCast( vectorpaths->front().Get(), a2dVectorPath ) ->GetSegments();
00128 segments->ConvertToLines();
00129 a2dLineSegment* point;
00130 unsigned int i;
00131 for (i=0; i < segments->GetCount();i++)
00132 {
00133 a2dVpathSegment& seg = segments->Item(i);
00134 point = new a2dLineSegment(seg.m_x1, seg.m_y1);
00135 pointlist->push_back(point);
00136 }
00137
00138 delete vectorpaths;
00139
00140 return pointlist;
00141 }
00142
00143 a2dCanvasObjectList* a2dRectMM::GetAsCanvasVpaths( bool transform )
00144 {
00145 a2dAffineMatrix pworld;
00146 if ( transform )
00147 pworld = m_lworld;
00148
00149 a2dVpath* segments = new a2dVpath();
00150 a2dVectorPath* canpath = new a2dVectorPath( segments );
00151 canpath->SetStroke( this->GetStroke() );
00152 canpath->SetFill( this->GetFill() );
00153 canpath->SetLayer( m_layer );
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285 a2dCanvasObjectList* canpathlist = new a2dCanvasObjectList();
00286 canpathlist->push_back( canpath );
00287 return canpathlist;
00288 }
00289
00290
00291 bool a2dRectMM::DoStartEdit( wxUint16 editmode, wxEditStyle editstyle )
00292 {
00293 if ( m_flags.m_editable )
00294 {
00295 if ( editmode == 1 )
00296 {
00297 PROPID_Allowrotation->SetPropertyToObject( this, false );
00298 PROPID_Allowskew->SetPropertyToObject( this, false );
00299
00300 m_flags.m_visiblechilds = true;
00301 m_flags.m_childrenOnSameLayer = true;
00302
00303
00304 double rx = m_radius;
00305 if ( ( m_radius < 0 && m_maxx - m_minx < 0 ) || ( m_radius > 0 && m_maxx - m_minx > 0 ) )
00306 rx = -rx;
00307
00308 a2dHandle* handle = new a2dHandle( this, m_minx + rx , m_miny, wxT("__rounding__"),
00309 Round( a2dCanvasGlobals->GetHandle()->GetWidth()*1.5 ),
00310 Round( a2dCanvasGlobals->GetHandle()->GetHeight()*1.5 ) );
00311 Append(handle);
00312 handle->SetSpecificFlags( true, a2dCanvasOFlags::BIN2 );
00313 handle->SetLayer( m_layer );
00314
00315 double radius = m_radius;
00316 m_radius = 0;
00317 double x,y,w,h;
00318 x = m_minx;
00319 y = m_miny;
00320 w = m_maxx - m_minx;
00321 h = m_maxy - m_miny;
00322 m_radius = radius;
00323
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333 Append( handle = new a2dHandle( this, x, y, wxT("handle1") ));
00334 handle->SetLayer( m_layer );
00335 Append( handle = new a2dHandle( this, x, y+h, wxT("handle2") ));
00336 handle->SetLayer( m_layer );
00337 Append( handle = new a2dHandle( this, x+w, y+h , wxT("handle3") ));
00338 handle->SetLayer( m_layer );
00339 Append( handle = new a2dHandle( this, x+w, y, wxT("handle4") ));
00340 handle->SetLayer( m_layer );
00341 Append( handle = new a2dHandle( this, x, y+h/2 , wxT("handle12") ));
00342 handle->SetLayer( m_layer );
00343 Append( handle = new a2dHandle( this, x+w/2, y+h, wxT("handle23") ));
00344 handle->SetLayer( m_layer );
00345 Append( handle = new a2dHandle( this, x+w, y+h/2 , wxT("handle34") ));
00346 handle->SetLayer( m_layer );
00347 Append( handle = new a2dHandle( this, x+w/2, y, wxT("handle41") ));
00348
00349 m_childobjects->SetSpecificFlags( false, a2dCanvasOFlags::PRERENDERASCHILD, wxT("a2dHandle") );
00350 m_childobjects->SetSpecificFlags( true, a2dCanvasOFlags::BIN2, wxT("a2dHandle") );
00351
00352
00353
00354 Update( updatemask_force );
00355
00356 SetPending( true );
00357 return true;
00358 }
00359 else
00360 {
00361 PROPID_IncludeChildren->SetPropertyToObject( this, false );
00362 PROPID_Allowrotation->SetPropertyToObject( this, false );
00363 PROPID_Allowskew->SetPropertyToObject( this, false );
00364
00365 return a2dCanvasObject::DoStartEdit( editmode, editstyle );
00366 }
00367 }
00368
00369 return false;
00370 }
00371
00372 void a2dRectMM::OnHandleEvent(a2dHandleMouseEvent &event)
00373 {
00374 a2dIterC* ic = event.GetIterC();
00375
00376 if ( m_flags.m_editingCopy )
00377 {
00378 a2dRestrictionEngine *restrictEngine = a2dCanvasGlobals->GetRestrictionEngine();
00379 a2dHandle* draghandle = event.GetCanvasHandle();
00380
00381 wxUint16 editmode = PROPID_Editmode->GetPropertyValue( this );
00382
00383 if ( editmode == 1 )
00384 {
00385 double xw,yw;
00386 xw = event.GetX();
00387 yw = event.GetY();
00388
00389 a2dAffineMatrix atWorld = ic->GetTransform();
00390 a2dAffineMatrix inverse = ic->GetInverseTransform();
00391
00392 double xwi;
00393 double ywi;
00394 inverse.TransformPoint( xw, yw, xwi, ywi );
00395
00396 a2dRectMM* original = wxStaticCast( PROPID_Original->GetPropertyValue( this ).Get(), a2dRectMM );
00397
00398 double w,h;
00399 w = m_maxx - m_minx;
00400 h = m_maxy - m_miny;
00401
00402 a2dAffineMatrix origworld = m_lworld;
00403 double radius = m_radius;
00404 if ( event.GetMouseEvent().LeftDown() )
00405 {
00406 }
00407 else if (event.GetMouseEvent().LeftUp() )
00408 {
00409 if ( draghandle->GetName() == wxT("__rounding__") )
00410 {
00411 original->SetRadius( m_radius );
00412 }
00413 else
00414 {
00415 original->SetMin( m_minx, m_miny );
00416 original->SetMax( m_maxx, m_maxy );
00417 }
00418 }
00419 else if ( event.GetMouseEvent().Dragging() )
00420 {
00421 if (restrictEngine )
00422 restrictEngine->RestrictPoint( xw, yw );
00423 ic->GetInverseTransform().TransformPoint( xw, yw, xwi, ywi );
00424
00425 if ( draghandle->GetName() == wxT("__rounding__") )
00426 {
00427
00428 if ( ( m_maxx - m_minx < 0 && xwi < 0 ) || ( m_maxx - m_minx > 0 && xwi > 0 ) )
00429 {
00430 if ( fabs( xwi ) < fabs((m_maxx - m_minx)/2) && fabs( xwi ) < fabs((m_maxy - m_miny)/2) )
00431 {
00432 m_radius = -fabs( xwi );
00433 draghandle->SetPosXY( xwi, m_miny );
00434 SetPending( true );
00435 }
00436 }
00437 else
00438 {
00439 m_radius = fabs( xwi );
00440 draghandle->SetPosXY( xwi, m_miny );
00441 SetPending( true );
00442 }
00443 }
00444 else if ( draghandle->GetName() == wxT("handle1") )
00445 {
00446 m_minx = xwi;
00447 m_miny = ywi;
00448 }
00449 else if ( draghandle->GetName() == wxT("handle2") )
00450 {
00451 m_minx = xwi;
00452 m_maxy = ywi;
00453 }
00454 else if ( draghandle->GetName() == wxT("handle3") )
00455 {
00456 m_maxx = xwi;
00457 m_maxy = ywi;
00458 }
00459 else if ( draghandle->GetName() == wxT("handle4") )
00460 {
00461 m_maxx = xwi;
00462 m_miny = ywi;
00463 }
00464 else if ( draghandle->GetName() == wxT("handle12") )
00465 {
00466 m_minx = xwi;
00467 }
00468 else if ( draghandle->GetName() == wxT("handle23") )
00469 {
00470 m_maxy = ywi;
00471 }
00472 else if ( draghandle->GetName() == wxT("handle34") )
00473 {
00474 m_maxx = xwi;
00475 }
00476 else if ( draghandle->GetName() == wxT("handle41") )
00477 {
00478 m_miny = ywi;
00479 }
00480 else
00481 event.Skip();
00482
00483 SetHandlePos( wxT("__rounding__"), m_minx + m_radius, m_miny );
00484 SetHandlePos( wxT("handle1"), m_minx, m_miny );
00485 SetHandlePos( wxT("handle2"), m_minx, m_maxy );
00486 SetHandlePos( wxT("handle3"), m_maxx, m_maxy );
00487 SetHandlePos( wxT("handle4"), m_maxx, m_miny );
00488 SetHandlePos( wxT("handle12"), m_minx, m_miny + h/2 );
00489 SetHandlePos( wxT("handle23"), m_minx + w/2, m_maxy );
00490 SetHandlePos( wxT("handle34"), m_maxx, m_miny + h/2 );
00491 SetHandlePos( wxT("handle41"), m_minx + w/2, m_miny );
00492 SetPending( true );
00493 }
00494 }
00495 else
00496 {
00497 event.Skip();
00498 }
00499 }
00500 else
00501 {
00502 event.Skip();
00503 }
00504 }
00505
00506 a2dBoundingBox a2dRectMM::DoGetUnTransformedBbox( a2dBboxFlags flags ) const
00507 {
00508 a2dBoundingBox bbox;
00509 bbox.Expand( m_minx, m_miny );
00510 bbox.Expand( m_maxx, m_maxy );
00511
00512 if ( !(flags & a2dCANOBJ_BBOX_EDIT ) )
00513 {
00514 if (m_radius > 0)
00515 bbox.Enlarge( m_radius );
00516
00517 if (m_contourwidth > 0)
00518 bbox.Enlarge( m_contourwidth/2 );
00519 }
00520 return bbox;
00521 }
00522
00523 void a2dRectMM::DoRender( a2dIterC& ic, OVERLAP clipparent )
00524 {
00525 if ( m_contourwidth )
00526 {
00527 a2dCanvasObjectList* vectorpaths = GetAsCanvasVpaths( false );
00528
00529 forEachIn( a2dCanvasObjectList, vectorpaths )
00530 {
00531 a2dVectorPath* obj = wxStaticCast( (*iter).Get(), a2dVectorPath );
00532 obj->DoRender( ic, clipparent );
00533 }
00534 delete vectorpaths;
00535 }
00536 else
00537 {
00538 if (m_radius<=0)
00539 {
00540 ic.GetDrawer2D()->DrawRoundedRectangle( m_minx, m_miny, m_maxx - m_minx, m_maxy - m_miny, -m_radius);
00541 }
00542 else
00543 {
00544 ic.GetDrawer2D()->DrawRoundedRectangle( m_minx-m_radius, m_miny-m_radius, m_maxx - m_minx+2*m_radius, m_maxy - m_miny+2*m_radius, m_radius);
00545 }
00546 }
00547 }
00548
00549 #if wxART2D_USE_CVGIO
00550
00551 void a2dRectMM::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
00552 {
00553 a2dCanvasObject::DoSave( parent, out, xmlparts, towrite );
00554 if ( xmlparts == a2dXmlSer_attrib )
00555 {
00556 if (m_radius != 0.0)
00557 {
00558 out.WriteAttribute( wxT("minx"), m_minx );
00559 out.WriteAttribute( wxT("miny"), m_miny );
00560 out.WriteAttribute( wxT("maxx"), m_maxx );
00561 out.WriteAttribute( wxT("maxy"), m_maxy );
00562 out.WriteAttribute( wxT("radius"), m_radius );
00563 out.WriteAttribute( wxT("contourwidth"), m_contourwidth );
00564 }
00565 }
00566 else
00567 {
00568 }
00569 }
00570
00571 void a2dRectMM::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
00572 {
00573 a2dCanvasObject::DoLoad( parent, parser, xmlparts );
00574 if ( xmlparts == a2dXmlSer_attrib )
00575 {
00576 m_minx = parser.GetAttributeValueDouble( wxT("minx") );
00577 m_miny = parser.GetAttributeValueDouble( wxT("miny") );
00578 m_maxx = parser.GetAttributeValueDouble( wxT("maxx") );
00579 m_maxy = parser.GetAttributeValueDouble( wxT("maxy") );
00580 m_radius = parser.GetAttributeValueDouble( wxT("radius") );
00581 m_contourwidth = parser.GetAttributeValueDouble( wxT("contourwidth"), 0 );
00582 }
00583 else
00584 {
00585 }
00586 }
00587 #endif //wxART2D_USE_CVGIO
00588
00589 bool a2dRectMM::DoIsHitWorld( a2dIterC& ic, a2dHitEvent& hitEvent )
00590 {
00591 double margin = ic.GetTransformedHitMargin();
00592
00593 if (m_radius > 0)
00594 {
00595 m_minx -= m_radius;
00596 m_miny -= m_radius;
00597 m_maxx += m_radius;
00598 m_maxy += m_radius;
00599 }
00600
00601 hitEvent.m_how = HitTestRectangle( hitEvent.m_relx, hitEvent.m_rely, m_minx, m_miny, m_maxx, m_maxy, ic.GetWorldStrokeExtend() + margin + m_contourwidth );
00602
00603 return hitEvent.m_how.IsHit();
00604 }
00605
00606 void a2dRectMM::EditFeedback( a2dIterC& ic, const a2dFeedbackId *id, a2dCanvasObject *currentEdit, int depth, a2dCanvasObjectFlagsMask flags, double x, double y )
00607 {
00608 a2dCanvasObject::EditFeedback( ic, id, currentEdit, depth, flags, x, y );
00609 }
00610
00611 bool a2dRectMM::GeneratePins( a2dPinClass* toConnectTo, a2dConnectTask task, double WXUNUSED(x), double WXUNUSED(y) )
00612 {
00613 a2dPinClass* toCreate;
00614 if ( GetGeneratePins() && (toCreate = toConnectTo->GetPinClassForTask( task, this )) )
00615 {
00616 double width = m_maxx - m_minx;
00617 double height = m_maxy - m_miny;
00618 m_flags.m_visiblechilds = true;
00619 a2dPin *newPin = NULL;
00620 if ( !HasPinNamed( wxT("pinc*"), true) )
00621 {
00622 newPin = AddPin( wxT("pinc"), width/2, height/2, a2dPin::temporaryObjectPin, toCreate );
00623 newPin->SetInternal( true );
00624 }
00625 if ( !HasPinNamed( wxT("pin1"), true) )
00626 AddPin( wxT("pin1"), m_minx, m_miny, a2dPin::temporaryObjectPin, toCreate );
00627 if ( !HasPinNamed( wxT("pin2"), true) )
00628 AddPin( wxT("pin2"), m_minx, m_miny + height/2, a2dPin::temporaryObjectPin, toCreate );
00629 if ( !HasPinNamed( wxT("pin3"), true) )
00630 AddPin( wxT("pin3"), m_minx, m_maxy, a2dPin::temporaryObjectPin, toCreate );
00631 if ( !HasPinNamed( wxT("pin4"), true) )
00632 AddPin( wxT("pin4"), m_minx + width/2, m_maxy, a2dPin::temporaryObjectPin, toCreate );
00633 if ( !HasPinNamed( wxT("pin5"), true) )
00634 AddPin( wxT("pin5"), m_maxx, m_maxy, a2dPin::temporaryObjectPin, toCreate );
00635 if ( !HasPinNamed( wxT("pin6"), true) )
00636 AddPin( wxT("pin6"), m_maxx, m_miny + height/2 , a2dPin::temporaryObjectPin, toCreate );
00637 if ( !HasPinNamed( wxT("pin7"), true) )
00638 AddPin( wxT("pin7"), m_maxx, m_miny, a2dPin::temporaryObjectPin, toCreate );
00639 if ( !HasPinNamed( wxT("pin8"), true) )
00640 AddPin( wxT("pin8"), m_maxx + width/2, m_miny, a2dPin::temporaryObjectPin, toCreate );
00641
00642 wxASSERT( HasPins() );
00643 m_childobjects->SetSpecificFlags( false, a2dCanvasOFlags::PRERENDERASCHILD, wxT("a2dPin") );
00644 return true;
00645 }
00646 return false;
00647 }
00648
00649
00650 bool a2dRectMM::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
00651 {
00652 bool calc = false;
00653 if ( !m_bbox.GetValid() )
00654 {
00655 calc = a2dCanvasObject::DoUpdate( mode, childbox, clipbox, propbox );
00656
00657 if( m_flags.m_resizeToChilds && !m_flags.m_editingCopy)
00658 {
00659 m_minx = wxMin( childbox.GetMinX(), m_minx );
00660 m_miny = wxMin( childbox.GetMinY(), m_miny );
00661 m_maxx = wxMax( childbox.GetMaxX(), m_maxx );
00662 m_maxy = wxMax( childbox.GetMaxY(), m_maxy );
00663
00664
00665 m_minx = childbox.GetMinX() - m_border;
00666 m_miny = childbox.GetMinY() - m_border;
00667 m_maxx = childbox.GetMaxX() + m_border;
00668 m_maxy = childbox.GetMaxY() + m_border;
00669
00670 }
00671 }
00672 return calc;
00673 }
00674
00675
00676
00677
00678
00679 A2D_BEGIN_EVENT_TABLE( a2dWindowMM, a2dCanvasObject )
00680 A2D_EVT_CANVASHANDLE_MOUSE_EVENT( a2dWindowMM::OnHandleEvent )
00681 A2D_EVT_CANVASOBJECT_ENTER_EVENT( a2dWindowMM::OnEnterObject )
00682 A2D_EVT_CANVASOBJECT_LEAVE_EVENT( a2dWindowMM::OnLeaveObject )
00683 A2D_END_EVENT_TABLE()
00684
00685 a2dWindowMM::a2dWindowMM()
00686 : a2dRectMM()
00687 {
00688 Init();
00689 }
00690
00691 a2dWindowMM::a2dWindowMM( double x, double y, double w, double h )
00692 : a2dRectMM( x, y, w, h )
00693 {
00694 Init();
00695 }
00696
00697 a2dWindowMM::a2dWindowMM( const a2dPoint2D& p1, const a2dPoint2D& p2 )
00698 : a2dRectMM( p1, p2 )
00699 {
00700 Init();
00701 }
00702
00703 a2dWindowMM::a2dWindowMM( const a2dBoundingBox& bbox )
00704 : a2dRectMM( bbox )
00705 {
00706 Init();
00707 }
00708
00709 a2dWindowMM::~a2dWindowMM()
00710 {
00711 }
00712
00713 a2dWindowMM::a2dWindowMM( const a2dWindowMM &other, CloneOptions options )
00714 :a2dRectMM( other, options )
00715 {
00716 m_style = other.m_style;
00717 m_state = other.m_state;
00718
00719 m_backStroke = other.m_backStroke;
00720 m_darkStroke = other.m_darkStroke;
00721 m_lightStroke = other.m_lightStroke;
00722 m_whiteStroke = other.m_whiteStroke;
00723 m_blackStroke = other.m_blackStroke;
00724 m_hoverStroke = other.m_hoverStroke;
00725 }
00726
00727 a2dObject* a2dWindowMM::Clone( CloneOptions options ) const
00728 {
00729 return new a2dWindowMM( *this, options );
00730 };
00731
00732 void a2dWindowMM::Init()
00733 {
00734 m_style = RAISED;
00735 m_state = NON;
00736
00737 SetFill( a2dFill( wxColour(212,208,200), a2dFILL_SOLID ) );
00738 m_backStroke = a2dStroke( wxColour(212,208,200), a2dSTROKE_SOLID );
00739 m_darkStroke = a2dStroke( wxColour(64,64,64), 0, a2dSTROKE_SOLID );
00740 m_lightStroke = a2dStroke( wxColour(128,128,128), 0, a2dSTROKE_SOLID );
00741 m_hoverStroke = a2dStroke( wxColour(255,0,0), 0, a2dSTROKE_SOLID );
00742 m_whiteStroke = *a2dWHITE_STROKE;
00743 m_blackStroke = *a2dBLACK_STROKE;
00744 }
00745
00746 void a2dWindowMM::OnEnterObject(a2dCanvasObjectMouseEvent &event)
00747 {
00748 m_state |= HOVER;
00749 SetPending( true );
00750 event.Skip();
00751 }
00752
00753 void a2dWindowMM::OnLeaveObject(a2dCanvasObjectMouseEvent &event)
00754 {
00755 m_state &= ( ALL ^ HOVER );
00756 SetPending( true );
00757 event.Skip();
00758 }
00759
00760 void a2dWindowMM::DoRender( a2dIterC& ic, OVERLAP clipparent )
00761 {
00762 double oneP = ic.GetDrawer2D()->DeviceToWorldXRel( 1 );
00763
00764 ic.GetDrawer2D()->DrawRoundedRectangle( m_minx, m_miny, m_maxx - m_minx, m_maxy - m_miny, 0 );
00765
00766 ic.GetDrawer2D()->OverRuleFixedStyle();
00767 if ( m_style & SUNKEN )
00768 {
00769
00770 if ( m_state & FOCUS )
00771 {
00772 ic.GetDrawer2D()->SetDrawerStroke( m_lightStroke );
00773 ic.GetDrawer2D()->DrawLine( m_minx, m_miny + oneP, m_maxx, m_miny + oneP );
00774 ic.GetDrawer2D()->DrawLine( m_maxx - oneP, m_miny, m_maxx - oneP, m_maxy );
00775 ic.GetDrawer2D()->SetDrawerStroke( m_whiteStroke );
00776 ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_minx, m_maxy );
00777 ic.GetDrawer2D()->DrawLine( m_minx, m_maxy, m_minx, m_maxy );
00778 ic.GetDrawer2D()->SetDrawerStroke( m_darkStroke );
00779 ic.GetDrawer2D()->DrawLine( m_maxx, m_miny, m_maxx, m_maxy );
00780 ic.GetDrawer2D()->DrawLine( m_maxx, m_miny, m_minx, m_miny );
00781 }
00782 else
00783 {
00784 ic.GetDrawer2D()->SetDrawerStroke( m_backStroke );
00785 ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_minx, m_maxy );
00786 ic.GetDrawer2D()->DrawLine( m_minx, m_maxy, m_maxx, m_maxy );
00787
00788 ic.GetDrawer2D()->SetDrawerStroke( m_backStroke );
00789 ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_minx, m_maxy );
00790 ic.GetDrawer2D()->DrawLine( m_minx, m_maxy, m_maxx, m_maxy );
00791 ic.GetDrawer2D()->SetDrawerStroke( m_darkStroke );
00792 ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_miny + 2*oneP, m_minx + oneP, m_maxy );
00793 ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_maxy - oneP, m_maxx, m_maxy - oneP );
00794
00795 ic.GetDrawer2D()->SetDrawerStroke( m_lightStroke );
00796 ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_miny + oneP, m_maxx, m_miny + oneP );
00797 ic.GetDrawer2D()->DrawLine( m_maxx - oneP, m_miny + oneP, m_maxx - oneP, m_maxy );
00798 ic.GetDrawer2D()->SetDrawerStroke( m_whiteStroke );
00799 ic.GetDrawer2D()->DrawLine( m_maxx, m_miny, m_maxx, m_maxy );
00800 ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_maxx, m_miny );
00801 }
00802 }
00803 else
00804 {
00805 if ( m_state & FOCUS )
00806 {
00807 ic.GetDrawer2D()->SetDrawerStroke( m_blackStroke );
00808 ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_minx, m_maxy );
00809 ic.GetDrawer2D()->DrawLine( m_maxx, m_miny, m_maxx, m_maxy );
00810 ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_maxx, m_miny );
00811 ic.GetDrawer2D()->DrawLine( m_minx, m_maxy, m_maxx, m_maxy );
00812 ic.GetDrawer2D()->SetDrawerStroke( m_whiteStroke );
00813 ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_miny + 2*oneP, m_minx + oneP, m_maxy );
00814 ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_maxy - oneP, m_maxx, m_maxy - oneP );
00815
00816 ic.GetDrawer2D()->SetDrawerStroke( m_lightStroke );
00817 ic.GetDrawer2D()->DrawLine( m_minx + 2*oneP, m_miny + 2*oneP, m_maxx - oneP, m_miny + 2*oneP );
00818 ic.GetDrawer2D()->DrawLine( m_maxx - 2*oneP, m_miny + 2*oneP, m_maxx - 2*oneP, m_maxy - oneP );
00819
00820 ic.GetDrawer2D()->SetDrawerStroke( m_darkStroke );
00821 ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_miny + oneP, m_maxx, m_miny + oneP );
00822 ic.GetDrawer2D()->DrawLine( m_maxx - oneP, m_miny + oneP, m_maxx - oneP, m_maxy );
00823 }
00824 else
00825 {
00826 ic.GetDrawer2D()->SetDrawerStroke( m_backStroke );
00827 ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_minx, m_maxy );
00828 ic.GetDrawer2D()->DrawLine( m_minx, m_maxy, m_maxx, m_maxy );
00829
00830 ic.GetDrawer2D()->SetDrawerStroke( m_backStroke );
00831 ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_minx, m_maxy );
00832 ic.GetDrawer2D()->DrawLine( m_minx, m_maxy, m_maxx, m_maxy );
00833 ic.GetDrawer2D()->SetDrawerStroke( m_whiteStroke );
00834 ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_miny + 2*oneP, m_minx + oneP, m_maxy );
00835 ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_maxy - oneP, m_maxx, m_maxy - oneP );
00836
00837 ic.GetDrawer2D()->SetDrawerStroke( m_lightStroke );
00838 ic.GetDrawer2D()->DrawLine( m_minx + oneP, m_miny + oneP, m_maxx, m_miny + oneP );
00839 ic.GetDrawer2D()->DrawLine( m_maxx - oneP, m_miny + oneP, m_maxx - oneP, m_maxy );
00840 ic.GetDrawer2D()->SetDrawerStroke( m_darkStroke );
00841 ic.GetDrawer2D()->DrawLine( m_maxx, m_miny, m_maxx, m_maxy );
00842 ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_maxx, m_miny );
00843 }
00844 }
00845 ic.GetDrawer2D()->ReStoreFixedStyle();
00846
00847 if ( m_state &= HOVER )
00848 {
00849 ic.GetDrawer2D()->SetDrawerStroke( m_hoverStroke );
00850 ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_minx, m_maxy );
00851 ic.GetDrawer2D()->DrawLine( m_maxx, m_miny, m_maxx, m_maxy );
00852 ic.GetDrawer2D()->DrawLine( m_minx, m_miny, m_maxx, m_miny );
00853 ic.GetDrawer2D()->DrawLine( m_minx, m_maxy, m_maxx, m_maxy );
00854 }
00855 else
00856 {
00857
00858 }
00859 }
00860
00861 #if wxART2D_USE_CVGIO
00862
00863 void a2dWindowMM::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
00864 {
00865 a2dCanvasObject::DoSave( parent, out, xmlparts, towrite );
00866 if ( xmlparts == a2dXmlSer_attrib )
00867 {
00868 if (m_radius != 0.0)
00869 {
00870 }
00871 }
00872 else
00873 {
00874 }
00875 }
00876
00877 void a2dWindowMM::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
00878 {
00879 a2dCanvasObject::DoLoad( parent, parser, xmlparts );
00880 if ( xmlparts == a2dXmlSer_attrib )
00881 {
00882 }
00883 else
00884 {
00885 }
00886 }
00887 #endif //wxART2D_USE_CVGIO
00888
00889 bool a2dWindowMM::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
00890 {
00891 return a2dRectMM::DoUpdate( mode, childbox, clipbox, propbox );
00892 }
00893
00894
00895
00896
00897
00898 double a2dRectWindowT2::m_initialTitleHeight = 20;
00899
00900
00901 const long a2dCLOSE_BUTTON = wxNewId();
00902
00903 A2D_BEGIN_EVENT_TABLE( a2dRectWindowT2, a2dRectMM )
00904 A2D_EVT_CANVASHANDLE_MOUSE_EVENT( a2dRectWindowT2::OnHandleEvent )
00905 A2D_EVT_BUTTON( a2dCLOSE_BUTTON, a2dRectWindowT2::OnCloseWindow )
00906 A2D_END_EVENT_TABLE()
00907
00908 void a2dRectWindowT2::Init( a2dCanvasObject* parent )
00909 {
00910 m_flipIn = false;
00911 m_titleObj = new a2dCanvasObject( 0, 0 );
00912
00913 m_parent = parent;
00914 m_close = new a2dWidgetButton( this, a2dCLOSE_BUTTON, 0, 0, m_initialTitleHeight, m_initialTitleHeight, a2dWidgetButton::ScaledContentKeepAspect );
00915 m_close->SetHighLightStroke( a2dStroke( wxColour(10,222,215), a2dSTROKE_SOLID ) );
00916 m_close->SetHighLightFill( a2dFill( wxColour(255,102,102), a2dFILL_SOLID ) );
00917 m_close->SetFill( wxColour( 195,195,195) );
00918 m_close->SetStroke( wxColour( 195,0,0) );
00919 m_close->SetName( wxT("__CLOSE_BUTTON__") );
00920 m_close->SetDraggable( false );
00921
00922 a2dSLine* ll = new a2dSLine( 0,0,m_initialTitleHeight,m_initialTitleHeight );
00923 ll->SetStroke(wxColour(252,0,252 ),1.0);
00924 a2dSLine* ll2 = new a2dSLine( 0,m_initialTitleHeight,m_initialTitleHeight,0 );
00925 ll2->SetStroke(wxColour(252,0,252 ),1.0);
00926 a2dCanvasObject* cont = new a2dCanvasObject( 0,0 );
00927 cont->Append( ll );
00928 cont->Append( ll2 );
00929 m_close->SetContentObject( cont );
00930
00931
00932
00933
00934 m_titleFill = *a2dWHITE_FILL;
00935 m_titleStroke = *a2dBLACK_STROKE;
00936
00937 m_title = new a2dText( wxT(""), 0,0, a2dFont(m_initialTitleHeight, wxSWISS) );
00938 m_title->SetName( wxT("__TITLE__") );
00939 m_title->SetDraggable( false );
00940 m_title->SetSubEditAsChild( true );
00941
00942 m_titleObj->Append(m_close);
00943 m_titleObj->Append(m_title);
00944
00945 }
00946
00947
00948 a2dRectWindowT2::a2dRectWindowT2()
00949 : a2dRectMM()
00950 {
00951 Init( NULL );
00952 }
00953
00954 a2dRectWindowT2::a2dRectWindowT2( a2dCanvasObject* parent, double x, double y, double w, double h , double radius )
00955 : a2dRectMM( x, y, w, h, radius, 0 )
00956 {
00957 Init( parent );
00958 }
00959
00960 a2dRectWindowT2::a2dRectWindowT2( a2dCanvasObject* parent, const a2dPoint2D& p1, const a2dPoint2D& p2, double radius )
00961 : a2dRectMM( p1, p2, radius, 0 )
00962 {
00963 Init( parent );
00964 }
00965
00966 a2dRectWindowT2::a2dRectWindowT2( a2dCanvasObject* parent, const a2dBoundingBox& bbox, double radius )
00967 : a2dRectMM( bbox, radius, 0 )
00968 {
00969 Init( parent );
00970 }
00971
00972 a2dRectWindowT2::~a2dRectWindowT2()
00973 {
00974 }
00975
00976 a2dRectWindowT2::a2dRectWindowT2( const a2dRectWindowT2 &other, CloneOptions options )
00977 :a2dRectMM( other, options )
00978 {
00979 m_titleFill = other.m_titleFill;
00980 m_titleStroke = other.m_titleStroke;
00981 m_parent = other.m_parent;
00982 m_flipIn = other.m_flipIn;
00983 m_titleObj = other.m_titleObj->TClone( clone_flat );
00984
00985 m_title = (a2dText*) m_titleObj->Find( wxT("__TITLE__") );
00986 m_close = (a2dWidgetButton*) m_titleObj->Find( wxT("__CLOSE_BUTTON__") );
00987 m_close->SetParent( this );
00988 }
00989
00990 a2dObject* a2dRectWindowT2::Clone( CloneOptions options ) const
00991 {
00992 return new a2dRectWindowT2( *this, options );
00993 };
00994
00995 void a2dRectWindowT2::SetTitle( const wxString& title)
00996 {
00997 a2dText* textobj = (a2dText*) m_titleObj->Find( _T("__TITLE__") );
00998 if ( title.IsEmpty() )
00999 ReleaseChild( textobj );
01000 else
01001 {
01002 if ( !textobj )
01003 {
01004 textobj = new a2dText( title, 0, 0, a2dFont( 10, wxSWISS ), 0 );
01005 textobj->SetDraggable( false );
01006 Append(textobj);
01007 textobj->SetName( _T("__TITLE__") );
01008 }
01009 else
01010 textobj->SetText( title );
01011 }
01012 }
01013
01014 void a2dRectWindowT2::SetTitle( a2dText* textObj )
01015 {
01016 m_titleObj->ReleaseChild( m_title );
01017 m_title = textObj;
01018 m_titleObj->Append(m_title);
01019 m_title->SetName( _T("__TITLE__") );
01020 };
01021
01022 void a2dRectWindowT2::OnCloseWindow(wxCommandEvent &event)
01023 {
01024 if ( m_flags.m_editingCopy )
01025 {
01026 a2dCanvasObject* original = PROPID_Original->GetPropertyValue( this );
01027
01028 m_root->GetCanvasCommandProcessor()->Submit(
01029 new a2dCommand_ReleaseObject( m_parent, original, false )
01030 );
01031 EndEdit();
01032 }
01033 else
01034 {
01035 m_root->GetCanvasCommandProcessor()->Submit(
01036 new a2dCommand_ReleaseObject( m_parent, this, false )
01037 );
01038 }
01039 }
01040
01041 bool a2dRectWindowT2::DoStartEdit( wxUint16 editmode, wxEditStyle editstyle )
01042 {
01043 if ( m_flags.m_editable )
01044 {
01045 PROPID_IncludeChildren->SetPropertyToObject( this, false );
01046 PROPID_Allowrotation->SetPropertyToObject( this, false );
01047 PROPID_Allowskew->SetPropertyToObject( this, false );
01048
01049 return a2dRectMM::DoStartEdit( editmode, editstyle );
01050 }
01051
01052 return false;
01053 }
01054
01055 void a2dRectWindowT2::DoWalker( wxObject* parent, a2dWalkerIOHandler& handler )
01056 {
01057 handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectStart );
01058 a2dRectMM::DoWalker( parent, handler );
01059
01060 m_titleObj->Walker( this, handler );
01061
01062 handler.WalkTask( parent, this, a2dWalker_a2dDerivedCanvasObjectEnd );
01063 }
01064
01065 bool a2dRectWindowT2::ProcessCanvasObjectEvent( a2dIterC& ic, a2dHitEvent& hitEvent )
01066 {
01067 a2dRectMM::ProcessCanvasObjectEvent( ic, hitEvent );
01068 a2dIterCU cu( ic, m_lworld );
01069 m_titleObj->ProcessCanvasObjectEvent( ic, hitEvent );
01070 return hitEvent.m_processed;
01071 }
01072
01073 void a2dRectWindowT2::DoAddPending( a2dIterC& ic )
01074 {
01075 a2dRectMM::DoAddPending( ic );
01076 m_titleObj->AddPending( ic );
01077 }
01078
01079 bool a2dRectWindowT2::Update( a2dCanvasObject::UpdateMode mode )
01080 {
01081 m_titleObj->Update( mode );
01082 return a2dRectMM::Update( mode );
01083 }
01084
01085 void a2dRectWindowT2::Render( a2dIterC& ic, OVERLAP clipparent )
01086 {
01087 if ( !m_flipIn )
01088 a2dRectMM::Render( ic, clipparent );
01089
01090 a2dIterCU cu( ic, m_lworld );
01091 m_titleObj->Render( ic, clipparent );
01092 }
01093
01094 void a2dRectWindowT2::DoRender( a2dIterC& ic, OVERLAP clipparent )
01095 {
01096 a2dStroke current = ic.GetDrawer2D()->GetDrawerStroke();
01097 a2dFill fillcurrent = ic.GetDrawer2D()->GetDrawerFill();
01098
01099 ic.GetDrawer2D()->SetDrawerFill( m_titleFill );
01100 ic.GetDrawer2D()->SetDrawerStroke( m_titleStroke );
01101
01102 if (m_radius<=0)
01103 {
01104 ic.GetDrawer2D()->DrawRoundedRectangle( m_minx, m_maxy - m_titleheight, m_maxx - m_minx, m_titleheight,0);
01105 ic.GetDrawer2D()->SetDrawerStroke( current );
01106 if ( !m_flipIn )
01107 {
01108 ic.GetDrawer2D()->SetDrawerFill( fillcurrent );
01109 ic.GetDrawer2D()->DrawRoundedRectangle( m_minx, m_miny, m_maxx - m_minx, m_maxy - m_titleheight - m_miny, -m_radius);
01110 }
01111 }
01112 else
01113 {
01114 ic.GetDrawer2D()->DrawRoundedRectangle( m_minx, m_maxy - m_titleheight, m_maxx - m_minx, m_titleheight,0);
01115 ic.GetDrawer2D()->SetDrawerStroke( current );
01116 if ( !m_flipIn )
01117 {
01118 ic.GetDrawer2D()->SetDrawerFill( fillcurrent );
01119 ic.GetDrawer2D()->DrawRoundedRectangle( m_minx-m_radius, m_miny-m_radius, m_maxx - m_minx+2*m_radius, m_maxy - m_miny+2*m_radius, m_radius);
01120 }
01121 }
01122 }
01123
01124 #if wxART2D_USE_CVGIO
01125
01126 void a2dRectWindowT2::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
01127 {
01128 a2dRectMM::DoSave( parent, out, xmlparts, towrite );
01129 if ( xmlparts == a2dXmlSer_attrib )
01130 {
01131 }
01132 else
01133 {
01134 }
01135 }
01136
01137 void a2dRectWindowT2::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
01138 {
01139 a2dRectMM::DoLoad( parent, parser, xmlparts );
01140 if ( xmlparts == a2dXmlSer_attrib )
01141 {
01142 }
01143 else
01144 {
01145 }
01146 }
01147 #endif //wxART2D_USE_CVGIO
01148
01149 bool a2dRectWindowT2::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
01150 {
01151 bool calc = false;
01152 if ( !m_bbox.GetValid() )
01153 {
01154 calc = a2dRectMM::DoUpdate( mode, childbox, clipbox, propbox );
01155
01156 m_title->SetPosXY( m_minx, m_maxy );
01157 a2dBoundingBox titlebox = m_title->GetFont().GetTextExtent( m_title->GetText(), UNKNOWN_YAXIS, m_title->GetAlignment() );
01158 titlebox.Translate( m_title->GetPosX(), m_title->GetPosY() );
01159 m_title->Update( updatemask_normal );
01160 m_titleheight = titlebox.GetHeight();
01161 m_close->SetPosXY( m_maxx - m_close->GetWidth(), m_maxy - m_titleheight );
01162 m_close->SetHeight( m_titleheight );
01163
01164 if( m_flags.m_resizeToChilds && !m_flags.m_editingCopy)
01165 {
01166 m_minx = wxMin( childbox.GetMinX(), m_minx );
01167 m_miny = wxMin( childbox.GetMinY(), m_miny );
01168 m_maxx = wxMax( childbox.GetMaxX(), m_maxx );
01169 m_maxy = wxMax( childbox.GetMaxY(), m_maxy );
01170
01171
01172
01173
01174
01175
01176
01177 }
01178 }
01179 return calc;
01180 }
01181
01182
01183
01184
01185
01186
01187
01188
01189
01190
01191
01192
01193
01194
01195 double a2dRectWindow::m_initialTitleHeight = 20;
01196
01197 A2D_BEGIN_EVENT_TABLE( a2dRectWindow, a2dWindowMM )
01198 A2D_EVT_CANVASHANDLE_MOUSE_EVENT( a2dRectWindow::OnHandleEvent )
01199 A2D_EVT_BUTTON( a2dCLOSE_BUTTON, a2dRectWindow::OnCloseWindow )
01200 A2D_END_EVENT_TABLE()
01201
01202 void a2dRectWindow::Init( a2dCanvasObject* parent )
01203 {
01204 m_parent = parent;
01205 m_close = new a2dWidgetButton( this, a2dCLOSE_BUTTON, 0, 0, m_initialTitleHeight, m_initialTitleHeight );
01206 Append( m_close );
01207 m_close->SetHighLightStroke( a2dStroke( wxColour(10,222,215), a2dSTROKE_SOLID ) );
01208 m_close->SetHighLightFill( a2dFill( wxColour(255,102,102), a2dFILL_SOLID ) );
01209 m_close->SetFill( wxColour( 195,195,195) );
01210 m_close->SetStroke( wxColour( 195,0,0) );
01211 m_close->SetName( wxT("__CLOSE_BUTTON__") );
01212 m_close->SetDraggable( false );
01213
01214
01215
01216 m_titleFill = *a2dWHITE_FILL;
01217 m_titleFill = a2dFill( wxColour(0,202,202), a2dFILL_SOLID );
01218 m_titleStroke = *a2dBLACK_STROKE;
01219
01220 m_title = new a2dText( wxT(""), 0,0, a2dFont(m_initialTitleHeight, wxSWISS) );
01221 Append(m_title);
01222 m_title->SetName( wxT("__TITLE__") );
01223 m_title->SetDraggable( false );
01224 m_title->SetSubEditAsChild( true );
01225 m_title->SetMultiLine( false );
01226
01227 m_canvas = new a2dWindowMM( 0,0, 300, 310 );
01228 m_canvas->SetBorder(20);
01229 m_canvas->SetResizeOnChildBox( true );
01230 m_canvas->SetSubEdit( true );
01231 m_canvas->SetName( wxT("__CANVAS__") );
01232 m_canvas->SetSubEdit( true );
01233 m_canvas->SetSubEditAsChild( true );
01234 Append(m_canvas);
01235 }
01236
01237
01238 a2dRectWindow::a2dRectWindow()
01239 : a2dWindowMM()
01240 {
01241 Init( NULL );
01242 }
01243
01244 a2dRectWindow::a2dRectWindow( a2dCanvasObject* parent, double x, double y, double w, double h )
01245 : a2dWindowMM( x, y, w, h )
01246 {
01247 Init( parent );
01248 }
01249
01250 a2dRectWindow::a2dRectWindow( a2dCanvasObject* parent, const a2dPoint2D& p1, const a2dPoint2D& p2 )
01251 : a2dWindowMM( p1, p2 )
01252 {
01253 Init( parent );
01254 }
01255
01256 a2dRectWindow::a2dRectWindow( a2dCanvasObject* parent, const a2dBoundingBox& bbox )
01257 : a2dWindowMM( bbox )
01258 {
01259 Init( parent );
01260 }
01261
01262 a2dRectWindow::~a2dRectWindow()
01263 {
01264 }
01265
01266 a2dRectWindow::a2dRectWindow( const a2dRectWindow &other, CloneOptions options )
01267 :a2dWindowMM( other, options )
01268 {
01269 m_titleFill = other.m_titleFill;
01270 m_titleStroke = other.m_titleStroke;
01271 m_parent = other.m_parent;
01272
01273 m_title = (a2dText*) Find( wxT("__TITLE__") );
01274 m_close = (a2dWidgetButton*) Find( wxT("__CLOSE_BUTTON__") );
01275 m_close->SetParent( this );
01276 m_canvas = (a2dWindowMM*) Find( wxT("__CANVAS__") );
01277 m_canvas->SetSubEdit( true );
01278 m_canvas->SetSubEditAsChild( true );
01279 }
01280
01281 a2dObject* a2dRectWindow::Clone( CloneOptions options ) const
01282 {
01283 return new a2dRectWindow( *this, options );
01284 };
01285
01286 void a2dRectWindow::SetTitle( const wxString& title)
01287 {
01288 a2dText* textobj = (a2dText*) Find( _T("__TITLE__") );
01289 if ( title.IsEmpty() )
01290 ReleaseChild( textobj );
01291 else
01292 {
01293 if ( !textobj )
01294 {
01295 textobj = new a2dText( title, 0, 0, a2dFont( 10, wxSWISS ), 0 );
01296 textobj->SetDraggable( false );
01297 Append(textobj);
01298 textobj->SetName( _T("__TITLE__") );
01299 }
01300 else
01301 textobj->SetText( title );
01302 }
01303 }
01304
01305 void a2dRectWindow::SetTitle( a2dText* textObj )
01306 {
01307 ReleaseChild( m_title );
01308 m_title = textObj;
01309 Append(m_title);
01310 m_title->SetName( _T("__TITLE__") );
01311 };
01312
01313 void a2dRectWindow::SetCanvas( a2dWindowMM* canvas )
01314 {
01315 ReleaseChild( m_canvas );
01316 m_canvas = canvas;
01317 Append(m_canvas);
01318 m_canvas->SetName( _T("__CANVAS__") );
01319 };
01320
01321 void a2dRectWindow::OnCloseWindow(wxCommandEvent &event)
01322 {
01323 if ( m_flags.m_editingCopy )
01324 {
01325 a2dCanvasObject* original = PROPID_Original->GetPropertyValue( this );
01326
01327 m_root->GetCanvasCommandProcessor()->Submit(
01328 new a2dCommand_ReleaseObject( m_parent, original, false )
01329 );
01330 EndEdit();
01331 }
01332 else
01333 {
01334 m_root->GetCanvasCommandProcessor()->Submit(
01335 new a2dCommand_ReleaseObject( m_parent, this, false )
01336 );
01337 }
01338 }
01339
01340 bool a2dRectWindow::DoStartEdit( wxUint16 editmode, wxEditStyle editstyle )
01341 {
01342 if ( m_flags.m_editable )
01343 {
01344 PROPID_IncludeChildren->SetPropertyToObject( this, false );
01345 PROPID_Allowrotation->SetPropertyToObject( this, false );
01346 PROPID_Allowskew->SetPropertyToObject( this, false );
01347
01348 return a2dWindowMM::DoStartEdit( editmode, editstyle );
01349 }
01350
01351 return false;
01352 }
01353
01354 void a2dRectWindow::DoRender( a2dIterC& ic, OVERLAP clipparent )
01355 {
01356 a2dStroke current = ic.GetDrawer2D()->GetDrawerStroke();
01357 a2dFill fillcurrent = ic.GetDrawer2D()->GetDrawerFill();
01358
01359 ic.GetDrawer2D()->SetDrawerFill( m_titleFill );
01360 ic.GetDrawer2D()->SetDrawerStroke( m_titleStroke );
01361
01362 if (m_radius<=0)
01363 {
01364 ic.GetDrawer2D()->DrawRoundedRectangle( m_minx, m_maxy - m_titleheight, m_maxx - m_minx, m_titleheight,0);
01365 ic.GetDrawer2D()->SetDrawerStroke( current );
01366 ic.GetDrawer2D()->SetDrawerFill( fillcurrent );
01367 ic.GetDrawer2D()->DrawRoundedRectangle( m_minx, m_miny, m_maxx - m_minx, m_maxy - m_titleheight - m_miny, -m_radius);
01368 }
01369 else
01370 {
01371 ic.GetDrawer2D()->DrawRoundedRectangle( m_minx, m_maxy - m_titleheight, m_maxx - m_minx, m_titleheight,0);
01372 ic.GetDrawer2D()->SetDrawerStroke( current );
01373 ic.GetDrawer2D()->SetDrawerFill( fillcurrent );
01374 ic.GetDrawer2D()->DrawRoundedRectangle( m_minx-m_radius, m_miny-m_radius, m_maxx - m_minx+2*m_radius, m_maxy - m_miny+2*m_radius, m_radius);
01375 }
01376 }
01377
01378 #if wxART2D_USE_CVGIO
01379
01380 void a2dRectWindow::DoSave( wxObject* parent, a2dIOHandlerXmlSerOut &out, a2dXmlSer_flag xmlparts , a2dObjectList* towrite )
01381 {
01382 a2dWindowMM::DoSave( parent, out, xmlparts, towrite );
01383 if ( xmlparts == a2dXmlSer_attrib )
01384 {
01385 }
01386 else
01387 {
01388 }
01389 }
01390
01391 void a2dRectWindow::DoLoad( wxObject* parent, a2dIOHandlerXmlSerIn& parser, a2dXmlSer_flag xmlparts )
01392 {
01393 a2dWindowMM::DoLoad( parent, parser, xmlparts );
01394 if ( xmlparts == a2dXmlSer_attrib )
01395 {
01396 }
01397 else
01398 {
01399 }
01400 }
01401 #endif //wxART2D_USE_CVGIO
01402
01403 bool a2dRectWindow::DoUpdate( UpdateMode mode, const a2dBoundingBox& childbox, const a2dBoundingBox& clipbox, const a2dBoundingBox& propbox )
01404 {
01405 bool calc = false;
01406 if ( !m_bbox.GetValid() )
01407 {
01408 calc = a2dRectMM::DoUpdate( mode, childbox, clipbox, propbox );
01409
01410 m_title->SetPosXY( m_minx, m_maxy );
01411 a2dBoundingBox titlebox = m_title->GetFont().GetTextExtent( m_title->GetText(), UNKNOWN_YAXIS, m_title->GetAlignment() );
01412
01413 m_title->Update( updatemask_normal );
01414 m_titleheight = titlebox.GetHeight();
01415 m_close->SetHeight( m_titleheight );
01416
01417 a2dBoundingBox canvasbox = m_canvas->GetBbox();
01418
01419 if( m_flags.m_resizeToChilds && !m_flags.m_editingCopy)
01420 {
01421 m_minx = wxMin( canvasbox.GetMinX(), m_minx );
01422 m_miny = wxMin( canvasbox.GetMinY(), m_miny );
01423 m_maxx = wxMax( canvasbox.GetMaxX(), m_maxx );
01424 m_maxy = wxMax( canvasbox.GetMaxY(), m_maxy );
01425
01426 m_minx = canvasbox.GetMinX();
01427 m_miny = canvasbox.GetMinY();
01428 m_maxx = canvasbox.GetMaxX();
01429 m_maxy = canvasbox.GetMaxY() + m_titleheight;
01430
01431 m_title->SetPosXY( m_minx, m_maxy );
01432 m_close->SetPosXY( m_maxx - m_close->GetWidth(), m_maxy - m_titleheight );
01433
01434
01435
01436
01437
01438
01439
01440
01441
01442
01443
01444
01445
01446
01447 }
01448 }
01449 return calc;
01450 }