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
00022 #include "wx/editor/styledialg.h"
00023 #include "wx/editor/edit.h"
00024 #include "wx/artbase/dcdrawer.h"
00025
00026 #if defined(__WXMSW__) && defined(__MEMDEBUG__)
00027 #include <wx/msw/msvcrt.h>
00028 #endif
00029
00030 BEGIN_EVENT_TABLE(a2dStyleDialog, wxDialog)
00031
00032 EVT_SPINCTRL( ID_RED, a2dStyleDialog::SetColor)
00033 EVT_SPINCTRL( ID_GREEN, a2dStyleDialog::SetColor)
00034 EVT_SPINCTRL( ID_BLUE, a2dStyleDialog::SetColor)
00035 EVT_TEXT ( ID_RED, a2dStyleDialog::OnSpinCtrlText )
00036 EVT_TEXT ( ID_GREEN, a2dStyleDialog::OnSpinCtrlText )
00037 EVT_TEXT ( ID_BLUE, a2dStyleDialog::OnSpinCtrlText )
00038 EVT_RADIOBOX( ID_COLOURS, a2dStyleDialog::ColorSelect )
00039 EVT_COMMAND_SCROLL( ID_SLIDER_RED, a2dStyleDialog::OnSliderUpdate )
00040 EVT_COMMAND_SCROLL( ID_SLIDER_GREEN, a2dStyleDialog::OnSliderUpdate )
00041 EVT_COMMAND_SCROLL( ID_SLIDER_BLUE, a2dStyleDialog::OnSliderUpdate )
00042 EVT_BUTTON ( ID_FILLCOLOR, a2dStyleDialog::OnColourBitmap )
00043 EVT_BUTTON ( ID_STROKECOLOR, a2dStyleDialog::OnColourBitmap )
00044 EVT_BUTTON ( ID_STIPPLEBITMAP, a2dStyleDialog::OnStippleBitmap )
00045 EVT_CHOICE ( ID_FILLSTYLE, a2dStyleDialog::OnFillStyle )
00046 EVT_CHOICE ( ID_STROKESTYLE, a2dStyleDialog::OnStrokeStyle )
00047 EVT_TEXT ( ID_PIXELWIDTH, a2dStyleDialog::OnPixelWidth )
00048 EVT_SPINCTRL( ID_PIXELWIDTH, a2dStyleDialog::OnPixelWidthSpin )
00049 EVT_CHECKBOX( ID_PIXELSTROKE, a2dStyleDialog::OnPixelStroke )
00050 EVT_CLOSE ( a2dStyleDialog::OnCloseWindow)
00051 EVT_ACTIVATE( a2dStyleDialog::OnActivate)
00052 EVT_COM_EVENT( a2dStyleDialog::OnComEvent )
00053 EVT_DO( a2dStyleDialog::OnDoEvent )
00054 EVT_UNDO( a2dStyleDialog::OnUndoEvent )
00055 EVT_SIZE( a2dStyleDialog::OnSize )
00056 EVT_BUTTON ( ID_MODEL_BUTTON_OK, a2dStyleDialog::CmOk)
00057 EVT_IDLE ( a2dStyleDialog::OnIdle )
00058 END_EVENT_TABLE()
00059
00060 a2dStyleDialog::a2dStyleDialog( wxWindow *parent, long style, bool modal ):
00061 wxDialog( parent,-1,_T("style dialog"),wxPoint(0,0),wxDefaultSize, style, _T("style dialog") )
00062 {
00063
00064 a2dDocviewGlobals->GetEventDistributer()->Register( this );
00065
00066 m_fillpatterns = new FillPatterns();
00067
00068 m_fillpatternmono = *m_fillpatterns->GetPattern(0);
00069
00070
00071
00072 m_cdata = new wxColourData();
00073 m_cdata->SetChooseFull(true);
00074
00075 m_cd = new wxColourDialog( this, m_cdata );
00076
00077 m_fillstippleb = wxBitmap( 34, 34, -1 );
00078
00079
00080 m_colorFill1 = wxColour(0,255,255);
00081 m_colorFill2 = wxColour(0,255,0);
00082 m_colorStroke = wxColour(0,0,255);
00083
00084
00085 m_color = &m_colorFill1;
00086
00087
00088 m_oneColFill = a2dFill( m_colorFill1, a2dFILL_SOLID );
00089 m_PattFill = a2dFill( m_fillpatternmono );
00090 m_hatchTwoColFill = a2dFill( m_colorFill1, m_colorFill2, a2dFILL_TWOCOL_BDIAGONAL_HATCH );
00091 m_linGrad = a2dFill( m_colorFill1, m_colorFill2, a2dFILL_GRADIENT_FILL_XY_LINEAR );
00092 m_radGrad = a2dFill( m_colorFill1, m_colorFill2, a2dFILL_GRADIENT_FILL_XY_RADIAL );
00093 m_dropGrad = a2dFill( m_colorFill1, m_colorFill2, a2dFILL_GRADIENT_FILL_XY_RADIAL );
00094 m_oneColStroke = a2dStroke( m_colorStroke, 1.0, a2dSTROKE_SOLID );
00095 m_pattStroke = a2dStroke( m_fillpatternmono );
00096
00097
00098 m_fill = m_oneColFill;
00099 m_stroke = m_oneColStroke;
00100
00101 wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
00102
00103 wxBoxSizer *item4 = new wxBoxSizer( wxVERTICAL );
00104
00105 wxBoxSizer *item5 = new wxBoxSizer( wxHORIZONTAL );
00106
00107 wxBoxSizer *item6 = new wxBoxSizer( wxVERTICAL );
00108
00109 wxBoxSizer *item7 = new wxBoxSizer( wxHORIZONTAL );
00110
00111 m_spinred = new wxSpinCtrl( this, ID_RED, _T("125"), wxDefaultPosition, wxSize(50,-1), wxSP_ARROW_KEYS, 0, 255, 122 );
00112 item7->Add( m_spinred, 0, wxALIGN_CENTRE|wxALL, 2 );
00113
00114 m_sliderred = new wxSlider( this, ID_SLIDER_RED, 125, 0, 255, wxDefaultPosition, wxSize(120,-1), 0 );
00115
00116 item7->Add( m_sliderred, 0, wxALIGN_CENTRE|wxALL, 2 );
00117
00118 item6->Add( item7, 0, wxALIGN_CENTER, 2 );
00119
00120 wxBoxSizer *item10 = new wxBoxSizer( wxHORIZONTAL );
00121
00122 m_spingreen = new wxSpinCtrl( this, ID_GREEN, _T("125"), wxDefaultPosition, wxSize(50,-1), wxSP_ARROW_KEYS, 0, 255, 122 );
00123 item10->Add( m_spingreen, 0, wxALIGN_CENTRE|wxALL, 2 );
00124
00125 m_slidergreen = new wxSlider( this, ID_SLIDER_GREEN, 125, 0, 255, wxDefaultPosition, wxSize(120,-1), 0 );
00126 item10->Add( m_slidergreen, 0, wxALIGN_CENTRE|wxLEFT|wxRIGHT|wxBOTTOM, 2 );
00127
00128 item6->Add( item10, 0, wxALIGN_CENTRE, 2 );
00129
00130 wxBoxSizer *item13 = new wxBoxSizer( wxHORIZONTAL );
00131
00132 m_spinblue = new wxSpinCtrl( this, ID_BLUE, _T("125"), wxDefaultPosition, wxSize(50,-1), wxSP_ARROW_KEYS, 0, 255, 122 );
00133 item13->Add( m_spinblue, 0, wxALIGN_CENTRE|wxALL, 2 );
00134
00135 m_sliderblue = new wxSlider( this, ID_SLIDER_BLUE, 125, 0, 255, wxDefaultPosition, wxSize(120,-1), 0 );
00136 item13->Add( m_sliderblue, 0, wxALIGN_CENTRE|wxALL, 2 );
00137
00138 item6->Add( item13, 0, wxALIGN_CENTRE, 2 );
00139
00140 wxBoxSizer *item63 = new wxBoxSizer( wxHORIZONTAL );
00141 wxString strs18[] =
00142 {
00143 _T("Stroke"),
00144 _T("Fill 1"),
00145 _T("Fill2")
00146 };
00147 wxRadioBox *item18 = new wxRadioBox( this, ID_COLOURS, _T("Colours"), wxDefaultPosition, wxDefaultSize, 3, strs18, 1, wxRA_SPECIFY_ROWS );
00148 item18->SetSelection(1);
00149 item63->Add( item18, 0, wxALIGN_CENTRE );
00150 item6->Add( item63, 0, wxALIGN_CENTRE, 2 );
00151
00152 wxBoxSizer *item32 = new wxBoxSizer( wxHORIZONTAL );
00153
00154 wxStaticText *item33 = new wxStaticText( this, -1, _T("stipple bitmap"), wxDefaultPosition, wxSize(60,-1), 0 );
00155 item33->SetForegroundColour( *wxRED );
00156 item33->SetBackgroundColour( *wxLIGHT_GREY );
00157 item32->Add( item33, 0, wxALIGN_CENTRE|wxALL, 2 );
00158 m_fillstipple = new wxBitmapButton( this, ID_STIPPLEBITMAP, m_fillstippleb, wxDefaultPosition, wxSize(34,34) );
00159 item32->Add( m_fillstipple, 0, wxALIGN_CENTRE|wxALL, 2 );
00160 item6->Add( item32, 0, wxALIGN_LEFT, 2 );
00161
00162 item5->Add( item6, 1, wxGROW|wxALIGN_CENTER_HORIZONTAL, 2 );
00163
00164 m_colourfillshow = new wxBitmapButton( this, ID_FILLCOLOR, wxBitmap( 100, 150 ), wxDefaultPosition, wxDefaultSize );
00165 item5->Add( m_colourfillshow, 0, wxALIGN_RIGHT | wxGROW, 1 );
00166
00167 m_colourstrokeshow = new wxBitmapButton( this, ID_STROKECOLOR, wxBitmap( 10, 150 ), wxDefaultPosition, wxDefaultSize );
00168 item5->Add( m_colourstrokeshow, 0, wxALIGN_RIGHT | wxGROW, 1 );
00169
00170 item4->Add( item5, 0, wxEXPAND | wxALIGN_RIGHT, 2 );
00171
00172 item0->Add( item4, 0, wxALIGN_CENTER_VERTICAL, 2 );
00173
00174
00175
00176 wxBoxSizer *item21 = new wxBoxSizer( wxVERTICAL );
00177
00178 wxBoxSizer *item22 = new wxBoxSizer( wxHORIZONTAL );
00179
00180 wxStaticText *item23 = new wxStaticText( this, ID_TEXT, _T("Fill Style"), wxDefaultPosition, wxSize(60,-1), wxST_NO_AUTORESIZE );
00181 item23->SetForegroundColour( *wxRED );
00182 item23->SetBackgroundColour( *wxLIGHT_GREY );
00183 item22->Add( item23, 0, wxALIGN_CENTER_VERTICAL|wxALIGN_LEFT | wxLEFT, 1 );
00184
00185 wxString fillstyles[] =
00186 {
00187 _T("Transparent (no fill)"),
00188 _T("Solid"),
00189 _T("Backward diagonal hatch"),
00190 _T("Cross-diagonal hatch"),
00191 _T("Forward diagonal hatch"),
00192 _T("Cross hatch"),
00193 _T("Horizontal hatch"),
00194 _T("Vertical hatch"),
00195 _T("Two Colour Backward diagonal hatch"),
00196 _T("Two Colour Cross-diagonal hatch"),
00197 _T("Two Colour Forward diagonal hatch"),
00198 _T("Two Colour Cross hatch"),
00199 _T("Two Colour Horizontal hatch"),
00200 _T("Two Colour Vertical hatch"),
00201 _T("wxSTIPPLE"),
00202 _T("wxSTIPPLE_MASK_OPAQUE"),
00203 _T("wxSTIPPLE_MASK_OPAQUE_TRANSPARENT"),
00204 _T("wxGRADIENT_FILL_XY_LINEAR"),
00205 _T("wxGRADIENT_FILL_XY_RADIAL"),
00206 _T("wxGRADIENT_FILL_XY_DROP"),
00207 _T("Inherit"),
00208 _T("Layer")
00209 };
00210
00211 m_fillstyles = new wxChoice( this, ID_FILLSTYLE, wxDefaultPosition, wxSize(70,-1), 22, fillstyles, 0 );
00212 item22->Add( m_fillstyles, 1, wxALIGN_CENTER_VERTICAL| wxALL, 2 );
00213
00214 item21->Add( item22, 0, wxEXPAND );
00215
00216 wxBoxSizer *item25 = new wxBoxSizer( wxHORIZONTAL );
00217
00218 wxStaticText *item26 = new wxStaticText( this, ID_TEXT, _T("stroke width"), wxDefaultPosition, wxSize(60,-1), wxST_NO_AUTORESIZE );
00219 item26->SetForegroundColour( *wxRED );
00220 item26->SetBackgroundColour( *wxLIGHT_GREY );
00221 item25->Add( item26, 0, wxALIGN_LEFT|wxLEFT, 1 );
00222
00223 m_pixelwidth = new wxSpinCtrl( this, ID_PIXELWIDTH, _T("0"), wxDefaultPosition, wxSize(60,-1), wxSP_ARROW_KEYS, 0, 1000, 0 );
00224 item25->Add( m_pixelwidth, 0, wxEXPAND );
00225
00226 m_pixelstroke = new wxCheckBox( this, ID_PIXELSTROKE, _T("Pixel stroke"), wxDefaultPosition, wxDefaultSize, 0 );
00227 item25->Add( m_pixelstroke, 0, wxALIGN_RIGHT|wxALL, 1 );
00228
00229 item21->Add( item25, 0, wxEXPAND );
00230
00231 item0->Add( item21, 0, wxEXPAND );
00232
00233 wxBoxSizer *item29 = new wxBoxSizer( wxHORIZONTAL );
00234
00235 wxStaticText *item30 = new wxStaticText( this, ID_TEXT, _T("StrokeStyle"), wxDefaultPosition, wxSize(60,-1), wxST_NO_AUTORESIZE );
00236 item30->SetForegroundColour( *wxRED );
00237 item30->SetBackgroundColour( *wxLIGHT_GREY );
00238 item29->Add( item30, 0, wxALIGN_LEFT|wxLEFT, 1 );
00239
00240 wxString strokestyles[] =
00241 {
00242 _T("Transparent"),
00243 _T("Solid style"),
00244 _T("Dotted style"),
00245 _T("Long dashed style"),
00246 _T("Short dashed style"),
00247 _T("Dot and dash style"),
00248 _T("User defined dash style"),
00249 _T("Backward diagonal hatch"),
00250 _T("Cross-diagonal hatch"),
00251 _T("Forward diagonal hatch"),
00252 _T("Cross hatch"),
00253 _T("Horizontal hatch"),
00254 _T("Vertical hatch"),
00255 _T("wxSTIPPLE"),
00256 _T("wxSTIPPLE_MASK_OPAQUE"),
00257
00258 _T("wxSTIPPLE_MASK_OPAQUE_TRANSPARENT"),
00259 _T("a2dSTROKE_OBJECTS"),
00260 _T("Inherit"),
00261 _T("Layer"),
00262 };
00263
00264 m_strokestyles = new wxChoice( this, ID_STROKESTYLE, wxDefaultPosition, wxSize(70,-1), 19, strokestyles, 0 );
00265 item29->Add( m_strokestyles, 1, wxALIGN_CENTER_VERTICAL|wxALL, 2 );
00266
00267 item0->Add( item29, 0, wxEXPAND | wxALIGN_CENTER_VERTICAL, 2 );
00268
00269 if ( modal )
00270 {
00271 item0->Add( new wxButton( this, ID_MODEL_BUTTON_OK,_T("Ok"),wxDefaultPosition,wxSize(55,20)) );
00272 m_modal = true;
00273 }
00274 else
00275 {
00276 m_modal = false;
00277 }
00278
00279 SetAutoLayout( true );
00280 SetSizer( item0 );
00281 item0->Fit( this );
00282 item0->SetSizeHints( this );
00283
00284 m_skipspinevent = false;
00285 m_doSentCommand = true;
00286
00287 m_needsUpdate = true;
00288 m_fillCommand = false;
00289 m_strokeCommand = false;
00290 }
00291
00292
00293 a2dStyleDialog::~a2dStyleDialog()
00294 {
00295 a2dDocviewGlobals->GetEventDistributer()->Unregister( this );
00296
00297 delete m_fillpatterns;
00298 delete m_cdata;
00299 delete m_cd;
00300 }
00301
00302 void a2dStyleDialog::SetColor( wxSpinEvent& spinevent )
00303 {
00304 unsigned char m_colorR = m_color->Red();
00305 unsigned char m_colorG = m_color->Green();
00306 unsigned char m_colorB = m_color->Blue();
00307
00308 switch ( spinevent.GetId() )
00309 {
00310 case ID_RED:
00311 {
00312 m_color->Set( spinevent.GetPosition(), m_colorG, m_colorB);
00313 }
00314 break;
00315 case ID_GREEN:
00316 {
00317 m_color->Set(m_colorR, spinevent.GetPosition(), m_colorB);
00318 }
00319 break;
00320 case ID_BLUE:
00321 {
00322 m_color->Set(m_colorR, m_colorG, spinevent.GetPosition());
00323 }
00324 break;
00325 default:
00326 break;
00327 }
00328
00329 m_needsUpdate = true;
00330
00331 if ( m_color == &m_colorStroke )
00332 SentStyle( false, true );
00333 else
00334 SentStyle( true, false );
00335 }
00336
00337 void a2dStyleDialog::OnPixelWidth( wxCommandEvent& WXUNUSED(event) )
00338 {
00339 m_stroke.SetWidth( m_pixelwidth->GetValue() );
00340 SentStyle( false, true );
00341 }
00342
00343 void a2dStyleDialog::OnPixelWidthSpin( wxSpinEvent& WXUNUSED(event) )
00344 {
00345 m_stroke.SetWidth( m_pixelwidth->GetValue() );
00346 SentStyle( false, true );
00347 }
00348
00349 void a2dStyleDialog::OnPixelStroke( wxCommandEvent& WXUNUSED(event) )
00350 {
00351 m_stroke.SetPixelStroke( m_pixelstroke->GetValue() );
00352 SentStyle( false, true );
00353 }
00354
00355
00356 void a2dStyleDialog::OnSpinCtrlText(wxCommandEvent& event)
00357 {
00358 if ( m_skipspinevent == true )
00359 {
00360 m_skipspinevent = false;
00361 return;
00362 }
00363
00364 unsigned char m_colorR = m_color->Red();
00365 unsigned char m_colorG = m_color->Green();
00366 unsigned char m_colorB = m_color->Blue();
00367
00368 switch ( event.GetId() )
00369 {
00370 case ID_RED:
00371 {
00372 m_color->Set( m_spinred->GetValue(), m_colorG, m_colorB );
00373 }
00374 break;
00375 case ID_GREEN:
00376 {
00377 m_color->Set( m_colorR, m_spingreen->GetValue(), m_colorB );
00378 }
00379 break;
00380 case ID_BLUE:
00381 {
00382 m_color->Set( m_colorR, m_colorG, m_spinblue->GetValue() );
00383 }
00384 break;
00385 default:
00386 break;
00387 }
00388
00389 m_needsUpdate = true;
00390
00391 if ( m_color == &m_colorStroke )
00392 SentStyle( false, true );
00393 else
00394 SentStyle( true, false );
00395 }
00396
00397 void a2dStyleDialog::OnSliderUpdate( wxScrollEvent &event )
00398 {
00399 unsigned char m_colorR = m_color->Red();
00400 unsigned char m_colorG = m_color->Green();
00401 unsigned char m_colorB = m_color->Blue();
00402
00403 switch ( event.GetId() )
00404 {
00405 case ID_SLIDER_RED:
00406 {
00407 m_color->Set( m_sliderred->GetValue(), m_colorG, m_colorB);
00408 }
00409 break;
00410 case ID_SLIDER_GREEN:
00411 {
00412 m_color->Set(m_colorR, m_slidergreen->GetValue(), m_colorB);
00413 }
00414 break;
00415 case ID_SLIDER_BLUE:
00416 {
00417 m_color->Set(m_colorR, m_colorG, m_sliderblue->GetValue());
00418 }
00419 break;
00420 default:
00421 break;
00422 }
00423
00424 m_needsUpdate = true;
00425
00426 if ( event.GetEventType() == wxEVT_SCROLL_THUMBRELEASE )
00427 {
00428 if ( m_color == &m_colorStroke )
00429 SentStyle( false, true );
00430 else
00431 SentStyle( true, false );
00432 }
00433 }
00434
00435
00436 void a2dStyleDialog::ColorSelect( wxCommandEvent &event )
00437 {
00438
00439 switch ( event.GetInt() )
00440 {
00441 case 0:
00442 {
00443 m_color = &m_colorStroke;
00444 }
00445 break;
00446 case 1:
00447 {
00448 m_color = &m_colorFill1;
00449 }
00450 break;
00451 case 2:
00452 {
00453 m_color = &m_colorFill2;
00454 }
00455 break;
00456 default:
00457 break;
00458 }
00459
00460 m_needsUpdate = true;
00461
00462 if ( m_color == &m_colorStroke )
00463 SentStyle( false, true );
00464 else
00465 SentStyle( true, false );
00466 }
00467
00468
00469 void a2dStyleDialog::OnColourBitmap( wxCommandEvent& event )
00470 {
00471 if (m_cd->ShowModal()==wxID_OK)
00472 {
00473 *m_cdata = m_cd->GetColourData();
00474 if ( event.GetId() == ID_STROKECOLOR )
00475 m_colorStroke = m_cdata->GetColour();
00476 else if ( event.GetId() == ID_FILLCOLOR )
00477 *m_color = m_cdata->GetColour();
00478 }
00479
00480 m_needsUpdate = true;
00481
00482 if ( m_color == &m_colorStroke )
00483 SentStyle( false, true );
00484 else
00485 SentStyle( true, false );
00486 }
00487
00488
00489 void a2dStyleDialog::OnStippleBitmap( wxCommandEvent& WXUNUSED(event) )
00490 {
00491 PatternDialog pattern(this,m_fillpatterns,_T("Patterns"),( wxDEFAULT_DIALOG_STYLE));
00492 int choosen=pattern.ShowModal();
00493
00494 m_fillpatternmono = *m_fillpatterns->GetPattern(choosen);
00495
00496 m_needsUpdate = true;
00497 SentStyle( true, false );
00498 }
00499
00500 void a2dStyleDialog::OnStrokeStyle( wxCommandEvent &event )
00501 {
00502 a2dStrokeStyle strokestyle = a2dSTROKE_SOLID;
00503
00504 switch( event.GetInt() )
00505 {
00506 case 0: strokestyle = a2dSTROKE_TRANSPARENT;
00507 break;
00508 case 1: strokestyle = a2dSTROKE_SOLID;
00509 break;
00510 case 2: strokestyle = a2dSTROKE_DOT;
00511 break;
00512 case 3: strokestyle = a2dSTROKE_LONG_DASH;
00513 break;
00514 case 4: strokestyle = a2dSTROKE_SHORT_DASH;
00515 break;
00516 case 5: strokestyle = a2dSTROKE_DOT_DASH;
00517 break;
00518 case 6: strokestyle = a2dSTROKE_USER_DASH;
00519 break;
00520 case 7: strokestyle = a2dSTROKE_BDIAGONAL_HATCH;
00521 break;
00522 case 8: strokestyle = a2dSTROKE_CROSSDIAG_HATCH;
00523 break;
00524 case 9: strokestyle = a2dSTROKE_FDIAGONAL_HATCH;
00525 break;
00526 case 10: strokestyle = a2dSTROKE_CROSS_HATCH;
00527 break;
00528 case 11: strokestyle = a2dSTROKE_HORIZONTAL_HATCH;
00529 break;
00530 case 12: strokestyle = a2dSTROKE_VERTICAL_HATCH;
00531 break;
00532 case 13: strokestyle = a2dSTROKE_STIPPLE ;
00533 break;
00534 case 14: strokestyle = a2dSTROKE_STIPPLE_MASK_OPAQUE;
00535 break;
00536 case 15: strokestyle = a2dSTROKE_STIPPLE_MASK_OPAQUE_TRANSPARENT;
00537 break;
00538 case 16: strokestyle = a2dSTROKE_OBJECTS;
00539 break;
00540 case 17: strokestyle = a2dSTROKE_INHERIT;
00541 break;
00542 case 18: strokestyle = a2dSTROKE_LAYER;
00543 break;
00544
00545 default: strokestyle = a2dSTROKE_SOLID;
00546 }
00547
00548 if ( strokestyle != m_stroke.GetStyle() )
00549 {
00550 if ( strokestyle == a2dSTROKE_LAYER)
00551 {
00552 m_stroke = *a2dNullSTROKE;
00553 }
00554 else if ( strokestyle == a2dSTROKE_INHERIT)
00555 {
00556 m_stroke = *a2dINHERIT_STROKE;
00557 }
00558 else if ( strokestyle == a2dSTROKE_STIPPLE_MASK_OPAQUE)
00559 {
00560 m_pattStroke.SetStyle(a2dSTROKE_STIPPLE_MASK_OPAQUE);
00561 m_stroke = m_pattStroke;
00562 }
00563 else if ( strokestyle == a2dSTROKE_STIPPLE_MASK_OPAQUE_TRANSPARENT)
00564 {
00565 m_pattStroke.SetStyle(a2dSTROKE_STIPPLE_MASK_OPAQUE_TRANSPARENT);
00566 m_stroke = m_pattStroke;
00567 }
00568 else if ( strokestyle == a2dSTROKE_STIPPLE)
00569 {
00570 m_pattStroke.SetStyle(a2dSTROKE_STIPPLE);
00571 m_stroke = m_pattStroke;
00572 }
00573 else
00574 m_stroke.SetStyle( strokestyle );
00575 }
00576
00577 m_needsUpdate = true;
00578 SentStyle( false, true );
00579 }
00580
00581 void a2dStyleDialog::OnFillStyle( wxCommandEvent &event )
00582 {
00583
00584 a2dFillStyle fillstyle = a2dFILL_SOLID;
00585 switch( event.GetInt() )
00586 {
00587 case 0: fillstyle = a2dFILL_TRANSPARENT;
00588 break;
00589 case 1: fillstyle = a2dFILL_SOLID;
00590 break;
00591 case 2: fillstyle = a2dFILL_BDIAGONAL_HATCH;
00592 break;
00593 case 3: fillstyle = a2dFILL_CROSSDIAG_HATCH;
00594 break;
00595 case 4: fillstyle = a2dFILL_FDIAGONAL_HATCH;
00596 break;
00597 case 5: fillstyle = a2dFILL_CROSS_HATCH;
00598 break;
00599 case 6: fillstyle = a2dFILL_HORIZONTAL_HATCH;
00600 break;
00601 case 7: fillstyle = a2dFILL_VERTICAL_HATCH;
00602 break;
00603 case 8: fillstyle = a2dFILL_TWOCOL_BDIAGONAL_HATCH;
00604 break;
00605 case 9: fillstyle = a2dFILL_TWOCOL_CROSSDIAG_HATCH;
00606 break;
00607 case 10: fillstyle = a2dFILL_TWOCOL_FDIAGONAL_HATCH;
00608 break;
00609 case 11: fillstyle = a2dFILL_TWOCOL_CROSS_HATCH;
00610 break;
00611 case 12: fillstyle = a2dFILL_TWOCOL_HORIZONTAL_HATCH;
00612 break;
00613 case 13: fillstyle = a2dFILL_TWOCOL_VERTICAL_HATCH;
00614 break;
00615 case 14: fillstyle = a2dFILL_STIPPLE;
00616 break;
00617 case 15: fillstyle = a2dFILL_STIPPLE_MASK_OPAQUE;
00618 break;
00619 case 16: fillstyle = a2dFILL_STIPPLE_MASK_OPAQUE_TRANSPARENT;
00620 break;
00621 case 17: fillstyle = a2dFILL_GRADIENT_FILL_XY_LINEAR;
00622 break;
00623 case 18: fillstyle = a2dFILL_GRADIENT_FILL_XY_RADIAL;
00624 break;
00625 case 19: fillstyle = a2dFILL_GRADIENT_FILL_XY_DROP;
00626 break;
00627 case 20: fillstyle = a2dFILL_INHERIT;
00628 break;
00629 case 21: fillstyle = a2dFILL_LAYER;
00630 break;
00631 default: fillstyle = a2dFILL_SOLID;
00632 }
00633
00634
00635
00636
00637
00638 if ( fillstyle != m_fill.GetStyle() )
00639 {
00640 if ( fillstyle == a2dFILL_LAYER)
00641 {
00642 m_fill = *a2dNullFILL;
00643 }
00644 else if ( fillstyle == a2dFILL_INHERIT)
00645 {
00646 m_fill = *a2dINHERIT_FILL;
00647 }
00648 else if ( fillstyle == a2dFILL_STIPPLE_MASK_OPAQUE)
00649 {
00650 m_PattFill.SetStyle(a2dFILL_STIPPLE_MASK_OPAQUE);
00651 m_fill = m_PattFill;
00652 }
00653 else if ( fillstyle == a2dFILL_STIPPLE_MASK_OPAQUE_TRANSPARENT)
00654 {
00655 m_PattFill.SetStyle(a2dFILL_STIPPLE_MASK_OPAQUE_TRANSPARENT);
00656 m_fill = m_PattFill;
00657 }
00658 else if ( fillstyle == a2dFILL_STIPPLE)
00659 {
00660 m_PattFill.SetStyle(a2dFILL_STIPPLE);
00661 m_fill = m_PattFill;
00662 }
00663 else if ( fillstyle == a2dFILL_GRADIENT_FILL_XY_LINEAR)
00664 {
00665 m_fill = m_linGrad;
00666 }
00667 else if ( fillstyle == a2dFILL_GRADIENT_FILL_XY_RADIAL)
00668 {
00669 m_fill = m_radGrad;
00670 }
00671 else if ( fillstyle == a2dFILL_GRADIENT_FILL_XY_DROP)
00672 {
00673 m_fill = m_dropGrad;
00674 }
00675 else if ( fillstyle >= a2dFIRST_TWOCOL_HATCH && fillstyle <= a2dLAST_TWOCOL_HATCH )
00676 {
00677 m_hatchTwoColFill.SetStyle( fillstyle );
00678 m_fill = m_hatchTwoColFill;
00679 }
00680 else if ( fillstyle >= a2dFIRST_HATCH && fillstyle <= a2dLAST_HATCH )
00681 {
00682 m_oneColFill.SetStyle( fillstyle );
00683 m_fill = m_oneColFill;
00684 }
00685 else
00686 {
00687 m_oneColFill.SetStyle( fillstyle );
00688 m_fill = m_oneColFill;
00689 }
00690 }
00691
00692 m_needsUpdate = true;
00693 SentStyle( true, false );
00694 }
00695
00696
00697 void a2dStyleDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event) )
00698 {
00699 if ( m_modal )
00700 EndModal(wxID_OK);
00701 else
00702 {
00703 SetReturnCode(wxID_OK);
00704 Show(false);
00705 }
00706 }
00707
00708 void a2dStyleDialog::OnActivate( wxActivateEvent& WXUNUSED(event) )
00709 {
00710
00711 }
00712
00713 void a2dStyleDialog::OnIdle( wxIdleEvent& WXUNUSED(idleEvent) )
00714 {
00715 if ( m_needsUpdate )
00716 {
00717 m_needsUpdate = false;
00718
00719 unsigned char m_colorR = m_color->Red();
00720 unsigned char m_colorG = m_color->Green();
00721 unsigned char m_colorB = m_color->Blue();
00722
00723 m_sliderred->SetValue( m_colorR );
00724 m_slidergreen->SetValue( m_colorG );
00725 m_sliderblue->SetValue( m_colorB );
00726
00727
00728
00729 m_skipspinevent = true;
00730 m_spinred->SetValue( m_colorR );
00731 m_spingreen->SetValue( m_colorG );
00732 m_spinblue->SetValue( m_colorB );
00733
00734 m_pixelwidth->SetValue( (int) m_stroke.GetWidth() );
00735 m_pixelstroke->SetValue( m_stroke.GetPixelStroke() );
00736
00737
00738 m_oneColFill.SetColour( m_colorFill1 );
00739 m_PattFill.SetColour( m_colorFill1 );
00740 m_PattFill.SetColour2( m_colorFill2 );
00741 m_linGrad.SetColour( m_colorFill1 );
00742 m_linGrad.SetColour2( m_colorFill2 );
00743 m_radGrad.SetColour( m_colorFill1 );
00744 m_radGrad.SetColour2( m_colorFill2 );
00745 m_dropGrad.SetColour( m_colorFill1 );
00746 m_dropGrad.SetColour2( m_colorFill2 );
00747 m_oneColStroke.SetColour( m_colorStroke );
00748 m_pattStroke.SetColour( m_colorStroke );
00749 m_hatchTwoColFill.SetColour( m_colorFill1 );
00750 m_hatchTwoColFill.SetColour2( m_colorFill2 );
00751
00752 m_fillstipple->Enable( false );
00753 int style;
00754 int curstyle = m_fill.GetStyle();
00755 switch( curstyle )
00756 {
00757 case a2dFILL_TRANSPARENT: style = 0;
00758 break;
00759 case a2dFILL_SOLID: style = 1;
00760 break;
00761 case a2dFILL_BDIAGONAL_HATCH: style = 2;
00762 break;
00763 case a2dFILL_CROSSDIAG_HATCH: style = 3;
00764 break;
00765 case a2dFILL_FDIAGONAL_HATCH: style = 4;
00766 break;
00767 case a2dFILL_CROSS_HATCH: style = 5;
00768 break;
00769 case a2dFILL_HORIZONTAL_HATCH: style = 6;
00770 break;
00771 case a2dFILL_VERTICAL_HATCH: style = 7;
00772 break;
00773 case a2dFILL_TWOCOL_BDIAGONAL_HATCH: style = 8;
00774 break;
00775 case a2dFILL_TWOCOL_CROSSDIAG_HATCH: style = 9;
00776 break;
00777 case a2dFILL_TWOCOL_FDIAGONAL_HATCH: style = 10;
00778 break;
00779 case a2dFILL_TWOCOL_CROSS_HATCH: style = 11;
00780 break;
00781 case a2dFILL_TWOCOL_HORIZONTAL_HATCH: style = 12;
00782 break;
00783 case a2dFILL_TWOCOL_VERTICAL_HATCH: style = 13;
00784 break;
00785 case a2dFILL_STIPPLE: style = 14;
00786 m_fillstipple->Enable( true );
00787 break;
00788 case a2dFILL_STIPPLE_MASK_OPAQUE: style = 15;
00789 m_fillstipple->Enable( true );
00790 break;
00791 case a2dFILL_STIPPLE_MASK_OPAQUE_TRANSPARENT: style = 16;
00792 m_fillstipple->Enable( true );
00793 break;
00794 case a2dFILL_GRADIENT_FILL_XY_LINEAR: style = 17;
00795 break;
00796 case a2dFILL_GRADIENT_FILL_XY_RADIAL: style = 18;
00797 break;
00798 case a2dFILL_GRADIENT_FILL_XY_DROP: style = 19;
00799 break;
00800 case a2dFILL_INHERIT: style = 20;
00801 break;
00802 case a2dFILL_LAYER: style = 21;
00803 break;
00804 default: style = 0;
00805 }
00806 m_fillstyles->SetSelection( style );
00807
00808 int strokestyle = 0;
00809 switch( m_stroke.GetStyle() )
00810 {
00811 case a2dSTROKE_TRANSPARENT: strokestyle = 0;
00812 break;
00813 case a2dSTROKE_SOLID: strokestyle = 1;
00814 break;
00815 case a2dSTROKE_DOT: strokestyle = 2;
00816 break;
00817 case a2dSTROKE_LONG_DASH: strokestyle = 3;
00818 break;
00819 case a2dSTROKE_SHORT_DASH: strokestyle = 4;
00820 break;
00821 case a2dSTROKE_DOT_DASH: strokestyle = 5;
00822 break;
00823 case a2dSTROKE_USER_DASH: strokestyle = 6;
00824 break;
00825 case a2dSTROKE_BDIAGONAL_HATCH: strokestyle = 7;
00826 break;
00827 case a2dSTROKE_CROSSDIAG_HATCH: strokestyle = 8;
00828 break;
00829 case a2dSTROKE_FDIAGONAL_HATCH: strokestyle = 9;
00830 break;
00831 case a2dSTROKE_CROSS_HATCH: strokestyle = 10;
00832 break;
00833 case a2dSTROKE_HORIZONTAL_HATCH: strokestyle = 11;
00834 break;
00835 case a2dSTROKE_VERTICAL_HATCH: strokestyle = 12;
00836 break;
00837 case a2dSTROKE_STIPPLE: strokestyle = 13;
00838 break;
00839 case a2dSTROKE_STIPPLE_MASK_OPAQUE: strokestyle = 14;
00840 break;
00841 case a2dSTROKE_STIPPLE_MASK_OPAQUE_TRANSPARENT: strokestyle = 15;
00842 break;
00843 case a2dSTROKE_OBJECTS: style = 16;
00844 break;
00845 case a2dSTROKE_INHERIT: style = 17;
00846 break;
00847 case a2dSTROKE_LAYER: style = 18;
00848 break;
00849 default: strokestyle = 0;
00850 }
00851
00852 m_strokestyles->SetSelection( strokestyle );
00853
00854
00855 wxMemoryDC dcmemtemp;
00856 dcmemtemp.SelectObject( m_fillstippleb );
00857 wxBrush brush;
00858 brush.SetColour(*wxBLACK);
00859 dcmemtemp.SetBackground(brush);
00860 dcmemtemp.Clear();
00861 dcmemtemp.SetPen(*wxTRANSPARENT_PEN);
00862
00863 dcmemtemp.SetTextBackground(m_PattFill.GetColour2());
00864 dcmemtemp.SetTextForeground(m_PattFill.GetColour());
00865 wxBrush brushbitm(m_fillpatternmono);
00866 dcmemtemp.SetBrush(brushbitm);
00867
00868 dcmemtemp.DrawRectangle(0,0,32,32);
00869 dcmemtemp.SelectObject(wxNullBitmap);
00870 m_fillstipple->SetBitmapLabel(m_fillstippleb);
00871 m_fillstipple->Refresh(true);
00872
00873
00874
00875
00876
00877
00878
00879
00880 if ( m_fill.GetStyle() == a2dFILL_STIPPLE_MASK_OPAQUE)
00881 {
00882 m_PattFill.SetStipple(m_fillpatternmono);
00883 m_PattFill.SetStyle(a2dFILL_STIPPLE_MASK_OPAQUE);
00884 m_fill = m_PattFill;
00885 }
00886 else if ( m_fill.GetStyle() == a2dFILL_STIPPLE_MASK_OPAQUE_TRANSPARENT)
00887 {
00888 m_PattFill.SetStipple(m_fillpatternmono);
00889 m_PattFill.SetStyle(a2dFILL_STIPPLE_MASK_OPAQUE_TRANSPARENT);
00890 m_fill = m_PattFill;
00891 }
00892 else if ( m_fill.GetStyle() == a2dFILL_STIPPLE)
00893 {
00894
00895 {
00896 wxBitmap fillpattern = wxBitmap( 32,32, -1 );
00897
00898 wxMemoryDC dcmemtemp2;
00899 dcmemtemp2.SelectObject(fillpattern);
00900
00901 wxBrush brush;
00902 brush.SetColour(*wxBLACK);
00903 dcmemtemp2.SetBackground(brush);
00904 dcmemtemp2.Clear();
00905 dcmemtemp2.SetPen(*wxTRANSPARENT_PEN);
00906
00907 dcmemtemp2.SetTextBackground(m_PattFill.GetColour2());
00908 dcmemtemp2.SetTextForeground(m_PattFill.GetColour());
00909 wxBrush brushbitm(m_fillpatternmono);
00910 dcmemtemp2.SetBrush(brushbitm);
00911
00912 dcmemtemp2.DrawRectangle(0,0,32,32);
00913 dcmemtemp2.SelectObject(wxNullBitmap);
00914 m_PattFill.SetStipple( fillpattern );
00915 }
00916
00917
00918 m_PattFill.SetStyle(a2dFILL_STIPPLE);
00919 m_fill = m_PattFill;
00920 }
00921 else if ( m_fill.GetType() == a2dFILL_HATCH_TWO_COLOUR )
00922 {
00923 m_fill = m_hatchTwoColFill;
00924 }
00925 else if ( m_fill.GetType() == a2dFILL_GRADIENT_FILL_LINEAR )
00926 {
00927 m_fill = m_linGrad;
00928 }
00929 else if ( m_fill.GetType() == a2dFILL_GRADIENT_FILL_RADIAL )
00930 {
00931 m_fill = m_radGrad;
00932 }
00933 else if ( m_fill.GetType() == a2dFILL_GRADIENT_FILL_RADIAL )
00934 {
00935 m_fill = m_radGrad;
00936 }
00937 {
00938
00939 int w = m_colourfillshow->GetBitmapLabel().GetWidth();
00940 int h = m_colourfillshow->GetBitmapLabel().GetHeight();
00941 a2dMemDcDrawer* drawer = new a2dMemDcDrawer( w, h );
00942 drawer->BeginDraw();
00943 drawer->SetDrawerFill( m_fill );
00944 drawer->DrawRoundedRectangle( 0, 0, w, h, 0 );
00945 drawer->EndDraw();
00946 m_colourfillshow->SetBitmapLabel( drawer->GetBuffer() );
00947 m_colourfillshow->Refresh(true);
00948 delete drawer;
00949
00950 }
00951
00952 int w = m_colourstrokeshow->GetBitmapLabel().GetWidth();
00953 int h = m_colourstrokeshow->GetBitmapLabel().GetHeight();
00954 a2dMemDcDrawer* drawer2 = new a2dMemDcDrawer( w, h );
00955 drawer2->BeginDraw();
00956 a2dStroke f = a2dStroke( m_colorStroke, (int) w, m_stroke.GetStyle() );
00957 drawer2->SetDrawerStroke( f );
00958 drawer2->DrawLine( w/2,0, w/2, h );
00959 drawer2->EndDraw();
00960 m_colourstrokeshow->SetBitmapLabel( drawer2->GetBuffer() );
00961 m_colourstrokeshow->Refresh(true);
00962 delete drawer2;
00963 }
00964
00965 if ( m_fillCommand )
00966 {
00967 m_fillCommand = false;
00968 a2dGetCmdh()->Submit( new a2dCommand_ChangeCentralStyle( a2dGetCmdh(), m_fill ));
00969 }
00970 if ( m_strokeCommand )
00971 {
00972 m_strokeCommand = false;
00973 a2dGetCmdh()->Submit( new a2dCommand_ChangeCentralStyle( a2dGetCmdh(), m_stroke ));
00974 }
00975 }
00976
00977 void a2dStyleDialog::SentStyle( bool fill, bool stroke )
00978 {
00979 m_fill.SetColour( m_colorFill1 );
00980 m_fill.SetColour2( m_colorFill2 );
00981 m_stroke.SetColour( m_colorStroke );
00982
00983 if ( !m_doSentCommand )
00984 return;
00985
00986 if ( m_modal )
00987 return;
00988
00989 m_fillCommand = fill;
00990 m_strokeCommand = stroke;
00991 }
00992
00993 void a2dStyleDialog::OnComEvent( a2dComEvent& event )
00994 {
00995 m_doSentCommand = false;
00996
00997 if ( event.GetEventComId() == &a2dRecursiveEditTool::sm_toolStartEditObject )
00998 {
00999 a2dRecursiveEditTool* tool = wxDynamicCast( event.GetEventObject(), a2dRecursiveEditTool );
01000 if ( tool && tool->GetActive() && tool->GetCanvasView() )
01001 {
01002 SetFill( tool->GetOriginal()->GetFill() );
01003 SetStroke( tool->GetOriginal()->GetStroke() );
01004 }
01005 }
01006 if ( event.GetEventComId() == &a2dComEvent::sm_changedProperty )
01007 {
01008 a2dNamedProperty *property = event.GetProperty();
01009 a2dObject *object = property->GetRefObjectNA();
01010
01011 if ( 0 != wxDynamicCast( property, a2dStrokeProperty ) )
01012 {
01013 a2dStroke stroke = ((a2dStrokeProperty*)property)->GetValue();
01014 SetStroke( stroke );
01015 }
01016 else if ( 0 != wxDynamicCast( property, a2dFillProperty ) )
01017 {
01018 a2dFill fill = ((a2dFillProperty*)property)->GetValue();
01019 SetFill( fill );
01020 }
01021 else
01022 event.Skip();
01023 }
01024
01025 m_doSentCommand = true;
01026 }
01027
01028 void a2dStyleDialog::OnUndoEvent( a2dCommandProcessorEvent& WXUNUSED(event) )
01029 {
01030 }
01031
01032 void a2dStyleDialog::OnDoEvent( a2dCommandProcessorEvent& WXUNUSED(event) )
01033 {
01034 }
01035
01036
01037 void a2dStyleDialog::OnSize(wxSizeEvent& WXUNUSED(event) )
01038 {
01039 Layout();
01040 }
01041
01042 void a2dStyleDialog::CmOk( wxCommandEvent& WXUNUSED(event) )
01043 {
01044 if ( m_modal )
01045 EndModal(wxID_OK);
01046 else
01047 {
01048 SetReturnCode(wxID_OK);
01049 Show(false);
01050 }
01051 }
01052
01053 void a2dStyleDialog::SetFill( const a2dFill& fill )
01054 {
01055 m_fill = fill;
01056 m_colorFill1 = m_fill.GetColour();
01057 m_colorFill2 = m_fill.GetColour2();
01058
01059 m_needsUpdate = true;
01060 }
01061
01062 void a2dStyleDialog::SetStroke( const a2dStroke& stroke )
01063 {
01064 m_stroke = stroke;
01065 m_colorStroke = m_stroke.GetColour();
01066
01067 m_needsUpdate = true;
01068 }