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/canvas/canmod.h"
00022 #include "wx/editor/styledialg.h"
00023 #include "wx/editor/doccancom.h"
00024
00025 #include <wx/statline.h>
00026
00027 #include "wx/editor/layerdlg.h"
00028
00029 #if defined(__WXMSW__) && defined(__MEMDEBUG__)
00030 #include <wx/msw/msvcrt.h>
00031 #endif
00032
00033 #define LPD_B_W 20
00034 #define LPD_B_H 20
00035
00036 #ifdef __UNIX__
00037 #define LPD_PATTERNBOX_W 50
00038 #else
00039 #define LPD_PATTERNBOX_W 30
00040 #endif
00041
00042 const int LAY_BUTTON_HIDE = wxID_HIGHEST + 4801 ;
00043
00044 const int LAY_BUTTON_CANCEL = wxID_HIGHEST + 4802 ;
00045
00046 const int LAY_BUTTON_VISIBLE = wxID_HIGHEST + 4803 ;
00047
00048 const int LAY_BUTTON_OUTLINE = wxID_HIGHEST + 5961 ;
00049
00050 const int LAY_BUTTON_READ = wxID_HIGHEST + 4804 ;
00051
00052 const int LAY_BUTTON_SELECT = wxID_HIGHEST + 4805 ;
00053
00054 const int LAY_BUTTON_PREV = wxID_HIGHEST + 4806 ;
00055
00056 const int LAY_BUTTON_NEXT = wxID_HIGHEST + 4807 ;
00057
00058 const int LAY_EDIT_NAME = wxID_HIGHEST + 4808 ;
00059
00060 const int LAY_BUTTON_RESTORE = wxID_HIGHEST + 4812 ;
00061
00062 const int LAY_BUTTON_SAVETOFILE = wxID_HIGHEST + 4813 ;
00063
00064 const int LAY_BUTTON_LOADFROMFILE = wxID_HIGHEST + 4814 ;
00065
00066 const int LAY_BUTTON_SORT = wxID_HIGHEST + 4815 ;
00067
00068 const int ID_AVAILABLE = wxID_HIGHEST + 5000;
00069 const int ID_LAYERNAME = wxID_HIGHEST + 5100;
00070 const int ID_VISIBLE = wxID_HIGHEST + 5200;
00071 const int ID_SELECTABLE = wxID_HIGHEST + 5300;
00072 const int ID_READ = wxID_HIGHEST + 5400;
00073 const int ID_OUTLINE = wxID_HIGHEST + 5450;
00074 const int ID_LAYERFILLCOLOR = wxID_HIGHEST + 5500;
00075 const int ID_LAYERSTROKECOLOR = wxID_HIGHEST + 5600;
00076 const int ID_LAYERPATTERN = wxID_HIGHEST + 5700;
00077 const int ID_INMAP = wxID_HIGHEST + 5800;
00078 const int ID_OUTMAP = wxID_HIGHEST + 5900;
00079 const int ID_NUMBER = wxID_HIGHEST + 5950;
00080 const int ID_AvailableTimer = wxID_HIGHEST + 5960;
00081
00082
00083 #define CHECKTIME 3000
00084
00085 BEGIN_EVENT_TABLE(LayerPropertiesDialog, wxDialog)
00086 EVT_CHANGED_DOCUMENT( LayerPropertiesDialog::OnChangedDocument )
00087
00088 EVT_TIMER( ID_AvailableTimer, LayerPropertiesDialog::OnTimerAvailable)
00089
00090 EVT_COM_EVENT( LayerPropertiesDialog::OnComEvent )
00091 EVT_DO( LayerPropertiesDialog::OnDoEvent )
00092
00093 EVT_BUTTON (LAY_BUTTON_SORT, LayerPropertiesDialog::CmSort)
00094
00095 EVT_BUTTON (LAY_BUTTON_HIDE, LayerPropertiesDialog::CmHide)
00096
00097 EVT_BUTTON (LAY_BUTTON_CANCEL, LayerPropertiesDialog::CmCancel)
00098
00099 EVT_BUTTON (LAY_BUTTON_RESTORE, LayerPropertiesDialog::CmRestore)
00100
00101 EVT_BUTTON (LAY_BUTTON_SAVETOFILE, LayerPropertiesDialog::CmSaveToFile)
00102
00103 EVT_BUTTON (LAY_BUTTON_LOADFROMFILE, LayerPropertiesDialog::CmLoadFromFile)
00104
00105 EVT_BUTTON (LAY_BUTTON_VISIBLE, LayerPropertiesDialog::CmVisible)
00106
00107 EVT_BUTTON (LAY_BUTTON_READ, LayerPropertiesDialog::CmRead)
00108
00109 EVT_BUTTON (LAY_BUTTON_OUTLINE, LayerPropertiesDialog::CmOutLine)
00110
00111 EVT_BUTTON (LAY_BUTTON_SELECT, LayerPropertiesDialog::CmSelect)
00112
00113 EVT_BUTTON (LAY_BUTTON_PREV, LayerPropertiesDialog::CmPrev)
00114
00115 EVT_BUTTON (LAY_BUTTON_NEXT, LayerPropertiesDialog::CmNext)
00116
00117 EVT_CUSTOM_RANGE(wxEVT_COMMAND_TEXT_ENTER, ID_LAYERNAME, ID_LAYERNAME + 9, LayerPropertiesDialog::Cm_LayerName )
00118
00119 EVT_CUSTOM_RANGE(wxEVT_COMMAND_BUTTON_CLICKED, ID_NUMBER, ID_NUMBER + 9, LayerPropertiesDialog::Cm_NumberBox )
00120
00121 EVT_CUSTOM_RANGE(wxEVT_COMMAND_CHECKBOX_CLICKED , ID_VISIBLE, ID_VISIBLE + 9, LayerPropertiesDialog::Cm_VisibleBox )
00122 EVT_CUSTOM_RANGE(wxEVT_COMMAND_CHECKBOX_CLICKED , ID_SELECTABLE, ID_SELECTABLE + 9, LayerPropertiesDialog::Cm_SelectBox)
00123 EVT_CUSTOM_RANGE(wxEVT_COMMAND_CHECKBOX_CLICKED , ID_READ, ID_READ + 9, LayerPropertiesDialog::Cm_ReadBox)
00124 EVT_CUSTOM_RANGE(wxEVT_COMMAND_CHECKBOX_CLICKED , ID_OUTLINE, ID_OUTLINE + 9, LayerPropertiesDialog::Cm_OutLineBox)
00125
00126 EVT_CUSTOM_RANGE(wxEVT_COMMAND_BUTTON_CLICKED, ID_LAYERFILLCOLOR, ID_LAYERFILLCOLOR + 9, LayerPropertiesDialog::Cm_F_BitB)
00127 EVT_CUSTOM_RANGE(wxEVT_COMMAND_BUTTON_CLICKED, ID_LAYERSTROKECOLOR, ID_LAYERSTROKECOLOR + 9, LayerPropertiesDialog::Cm_B_BitB)
00128 EVT_CUSTOM_RANGE(wxEVT_COMMAND_BUTTON_CLICKED, ID_LAYERPATTERN, ID_LAYERPATTERN + 9, LayerPropertiesDialog::Cm_P_BitB)
00129
00130 EVT_CUSTOM_RANGE(wxEVT_COMMAND_TEXT_ENTER , ID_INMAP, ID_INMAP + 9, LayerPropertiesDialog::Cm_InMap)
00131 EVT_CUSTOM_RANGE(wxEVT_COMMAND_TEXT_ENTER , ID_OUTMAP, ID_OUTMAP + 9, LayerPropertiesDialog::Cm_OutMap)
00132
00133 EVT_CHAR(LayerPropertiesDialog::OnChar)
00134 EVT_CHAR_HOOK(LayerPropertiesDialog::OnCharHook)
00135
00136 EVT_CLOSE(LayerPropertiesDialog::OnCloseWindow)
00137
00138 END_EVENT_TABLE()
00139
00140
00141
00142
00143 a2dLayerInfo* LayerPropertiesDialog::GetLocalLayerInfo( int i )
00144 {
00145 if ( m_onorder )
00146 return m_controlslayersetup->GetOrderIndex()[i];
00147 else
00148 return m_controlslayersetup->GetLayerIndex()[i];
00149 }
00150
00151 a2dLayerInfo* LayerPropertiesDialog::GetDocLayerInfo( int i )
00152 {
00153 if ( m_onorder )
00154 return m_layersetup->GetOrderIndex()[i];
00155 else
00156 return m_layersetup->GetLayerIndex()[i];
00157 }
00158
00159
00160
00161
00162 LayerPropertiesDialog::LayerPropertiesDialog( wxFrame* parent, a2dLayers* layersetup, const wxString& title, long style, const wxString& name ):
00163 wxDialog(parent,-1,title,wxDefaultPosition,wxDefaultSize,style,name)
00164
00165 {
00166 SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
00167
00168 m_dialogLastUpdate = wxDateTime::Now();
00169 m_timerAvailable = new wxTimer( this, ID_AvailableTimer );
00170 m_timerAvailable->Start( CHECKTIME, wxTIMER_CONTINUOUS );
00171
00172 a2dDocviewGlobals->GetEventDistributer()->Register( this );
00173
00174 m_fillpatterns = new FillPatterns();
00175
00176 m_parent = parent;
00177
00178 m_brush = new wxBrush();
00179 m_onorder = false;
00180
00181
00182
00183 m_cdata = new wxColourData();
00184 m_cdata->SetChooseFull(true);
00185
00186 long style_noresize;
00187 #ifdef __UNIX__
00188 style_noresize = (wxCAPTION);
00189 #else
00190 style_noresize = (wxSYSTEM_MENU | wxCAPTION);
00191 #endif
00192
00193
00194 m_cd = new wxColourDialog( this, m_cdata );
00195
00196 wxFlexGridSizer *alllayerline = new wxFlexGridSizer( 11 );
00197 alllayerline->AddGrowableCol(1);
00198 wxSizer *all = new wxBoxSizer( wxVERTICAL );
00199 all->Add( alllayerline, 0, wxGROW );
00200
00201 m_numberlabel = new wxStaticText(this,-1, _T("Nr") );
00202 alllayerline->Add( m_numberlabel, 0, wxALIGN_CENTRE );
00203 m_namelabel = new wxStaticText(this,-1, _T("Name"));
00204 alllayerline->Add( m_namelabel, 0, wxALIGN_CENTRE|wxALL, 2 );
00205 m_visiblelabel = new wxStaticText(this,-1, _T("Vis"));
00206 alllayerline->Add( m_visiblelabel, 0, wxALIGN_CENTRE|wxALL, 2 );
00207 m_selectablelabel = new wxStaticText(this,-1, _T("Sel"));
00208 alllayerline->Add( m_selectablelabel, 0, wxALIGN_CENTRE|wxALL, 2 );
00209 m_outlinelabel = new wxStaticText(this,-1, _T("OutL"));
00210 alllayerline->Add( m_outlinelabel, 0, wxALIGN_CENTRE|wxALL, 2 );
00211 m_readlayerlabel = new wxStaticText(this,-1, _T("Read"));
00212 alllayerline->Add( m_readlayerlabel, 0, wxALIGN_CENTRE|wxALL, 2 );
00213 m_filllabel = new wxStaticText(this,-1, _T("Fill"));
00214 alllayerline->Add( m_filllabel, 0, wxALIGN_CENTRE|wxALL, 2 );
00215 m_borderlabel = new wxStaticText(this,-1, _T("Stroke"));
00216 alllayerline->Add( m_borderlabel, 0, wxALIGN_CENTRE|wxALL, 2 );
00217 m_patternlabel = new wxStaticText(this,-1, _T("Pattern"));
00218 alllayerline->Add( m_patternlabel, 0, wxALIGN_CENTRE|wxALL, 2 );
00219 m_mappinglabel = new wxStaticText(this,-1, _T("inMap"));
00220 alllayerline->Add( m_mappinglabel, 0, wxALIGN_CENTRE|wxALL, 2 );
00221 m_mappinglabel = new wxStaticText(this,-1, _T("outMap"));
00222 alllayerline->Add( m_mappinglabel, 0, wxALIGN_CENTRE|wxALL, 2 );
00223
00224
00225 for (int i = 0; i < 10; i++)
00226 {
00227 wxString nrbuf;
00228
00229 nrbuf.Printf( _T("%03d"),i+1 );
00230
00231 m_numberbox[i] = new wxButton( this, ID_NUMBER + i, nrbuf, wxDefaultPosition, wxSize(25,20), wxBU_EXACTFIT );
00232 alllayerline->Add( m_numberbox[i], 0, wxALIGN_CENTER_VERTICAL |wxALIGN_CENTRE|wxGROW );
00233
00234 m_namebox[i] = new wxTextCtrl( this, ID_LAYERNAME + i, _T(""), wxDefaultPosition, wxSize(50,20), wxTE_PROCESS_ENTER );
00235 alllayerline->Add( m_namebox[i], 0, wxALIGN_CENTRE|wxALL|wxGROW, 0 );
00236 m_namebox[i]->SetToolTip(_("Layer name"));
00237
00238 m_visiblebox[i] = new wxCheckBox( this, ID_VISIBLE + i, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
00239 alllayerline->Add( m_visiblebox[i], 0, wxALIGN_CENTRE|wxALL, 1 );
00240
00241 m_selectablebox[i] = new wxCheckBox( this, ID_SELECTABLE + i, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
00242 alllayerline->Add( m_selectablebox[i], 0, wxALIGN_CENTRE|wxALL, 1 );
00243
00244 m_outlinebox[i] = new wxCheckBox( this, ID_OUTLINE + i, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
00245 alllayerline->Add( m_outlinebox[i], 0, wxALIGN_CENTRE|wxALL, 1 );
00246
00247 m_readlayerbox[i] = new wxCheckBox( this, ID_READ + i, _T(""), wxDefaultPosition, wxDefaultSize, 0 );
00248 alllayerline->Add( m_readlayerbox[i], 0, wxALIGN_CENTRE|wxALL, 1 );
00249
00250 m_fillbut[i] = new wxButton( this, ID_LAYERFILLCOLOR + i, _T(""), wxDefaultPosition, wxSize(20,20),wxSIMPLE_BORDER );
00251 alllayerline->Add( m_fillbut[i], 0, wxALIGN_CENTRE|wxALL, 1 );
00252
00253 m_borderbut[i] = new wxButton( this, ID_LAYERSTROKECOLOR + i, _T(""), wxDefaultPosition, wxSize(20,20),wxSIMPLE_BORDER );
00254 alllayerline->Add( m_borderbut[i], 0, wxALIGN_CENTRE|wxALL, 1 );
00255
00256 m_p_bitm[i] = new wxBitmap(LPD_PATTERNBOX_W,LPD_B_H,-1);
00257 m_patternbut[i] = new wxBitmapButton( this, ID_LAYERPATTERN + i, *m_p_bitm[i], wxDefaultPosition, wxSize(40,20),wxSIMPLE_BORDER );
00258 alllayerline->Add( m_patternbut[i], 0, wxALIGN_CENTRE|wxALL, 1 );
00259 m_patterns[i] = 0;
00260
00261 m_gdsinmap[i] = new wxTextCtrl( this, ID_INMAP + i, _T(""), wxDefaultPosition, wxSize(30,-1),wxTE_PROCESS_ENTER );
00262 alllayerline->Add( m_gdsinmap[i], 0, wxALIGN_CENTRE|wxALL, 1 );
00263
00264 m_gdsoutmap[i] = new wxTextCtrl( this, ID_OUTMAP + i, _T(""), wxDefaultPosition, wxSize(30,-1),wxTE_PROCESS_ENTER );
00265 alllayerline->Add( m_gdsoutmap[i], 0, wxALIGN_CENTRE|wxALL, 1 );
00266 }
00267
00268 wxStaticBox *item1 = new wxStaticBox( this, -1, _T("") );
00269 wxSizer *botline = new wxStaticBoxSizer( item1, wxVERTICAL );
00270
00271 wxSizer *botline1 = new wxBoxSizer( wxHORIZONTAL );
00272 botline->Add( botline1 );
00273
00274 m_buttonSORT = new wxButton(this,LAY_BUTTON_SORT, _T("Sort Order"),wxDefaultPosition,wxDefaultSize,wxBU_EXACTFIT );
00275 botline1->Add( m_buttonSORT, 0, wxALIGN_CENTRE|wxALL, 0 );
00276
00277 m_buttonVISIBLE = new wxButton(this,LAY_BUTTON_VISIBLE, _T("Hide All"),wxDefaultPosition,wxDefaultSize,wxBU_EXACTFIT );
00278 botline1->Add( m_buttonVISIBLE, 0, wxALIGN_CENTRE|wxALL, 0 );
00279 m_buttonSELECT = new wxButton(this,LAY_BUTTON_SELECT, _T("None Selectable"),wxDefaultPosition,wxDefaultSize,wxBU_EXACTFIT );
00280 botline1->Add( m_buttonSELECT, 0, wxALIGN_CENTRE|wxALL, 0 );
00281 m_buttonREAD = new wxButton(this,LAY_BUTTON_READ, _T("Read Non"),wxDefaultPosition,wxDefaultSize,wxBU_EXACTFIT );
00282 botline1->Add( m_buttonREAD, 0, wxALIGN_CENTRE|wxALL, 0 );
00283 m_buttonOutLine = new wxButton(this,LAY_BUTTON_OUTLINE, _T("OutLine"),wxDefaultPosition,wxDefaultSize,wxBU_EXACTFIT );
00284 botline1->Add( m_buttonOutLine, 0, wxALIGN_CENTRE|wxALL, 0 );
00285
00286 botline->Add( new wxStaticLine( this, -1, wxDefaultPosition, wxSize(200,2), wxLI_HORIZONTAL ) , 0, wxALIGN_CENTER_VERTICAL | wxALIGN_LEFT|wxALL, 2);
00287
00288 wxSizer *botline2 = new wxBoxSizer( wxHORIZONTAL );
00289 botline->Add( botline2 );
00290
00291 m_buttonHIDE = new wxButton(this,LAY_BUTTON_HIDE, _T("Hide"),wxDefaultPosition,wxDefaultSize,wxBU_EXACTFIT );
00292 botline2->Add( m_buttonHIDE, 0, wxALIGN_CENTRE|wxALL, 0 );
00293 m_buttonCANCEL = new wxButton(this,LAY_BUTTON_CANCEL, _T("Cancel"),wxDefaultPosition,wxDefaultSize,wxBU_EXACTFIT);
00294 botline2->Add( m_buttonCANCEL, 0, wxALIGN_CENTRE|wxALL, 0 );
00295
00296 botline2->Add( new wxStaticLine( this, -1, wxDefaultPosition, wxSize(2,20), wxLI_VERTICAL ) , 0, wxALIGN_CENTRE|wxALL, 2);
00297
00298 m_buttonPREV = new wxButton(this,LAY_BUTTON_PREV, _T("< Previous"), wxDefaultPosition,wxDefaultSize,wxBU_EXACTFIT);
00299 botline2->Add( m_buttonPREV, 0, wxALIGN_CENTRE|wxALL, 0 );
00300 m_buttonNEXT = new wxButton(this,LAY_BUTTON_NEXT, _T("Next >"), wxDefaultPosition,wxDefaultSize,wxBU_EXACTFIT);
00301 botline2->Add( m_buttonNEXT, 0, wxALIGN_CENTRE|wxALL, 0 );
00302 m_buttonRESTORE = new wxButton(this,LAY_BUTTON_RESTORE, _T("Restore"), wxDefaultPosition,wxDefaultSize,wxBU_EXACTFIT);
00303
00304 wxSizer *botline3 = new wxBoxSizer( wxHORIZONTAL );
00305 botline->Add( botline3 );
00306 botline3->Add( m_buttonRESTORE, 0, wxALIGN_CENTRE|wxALL, 0 );
00307 m_buttonSAVETOFILE = new wxButton(this,LAY_BUTTON_SAVETOFILE, _T("Save File"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
00308 botline3->Add( m_buttonSAVETOFILE, 0, wxALIGN_CENTRE|wxALL, 0 );
00309 m_buttonLOADFROMFILE = new wxButton(this,LAY_BUTTON_LOADFROMFILE, _T("Load File"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT);
00310 botline3->Add( m_buttonLOADFROMFILE, 0, wxALIGN_CENTRE|wxALL, 0 );
00311
00312 all->Add( botline );
00313
00314 SetSizer( all );
00315
00316 all->Fit( this );
00317 SetAutoLayout( true );
00318
00319 all->SetSizeHints( this );
00320
00321 m_startvalue = 0;
00322
00323 a2dCanvasDocument* doc = (a2dCanvasDocument*) a2dDocviewGlobals->GetDocviewCommandProcessor()->GetCurrentDocument();
00324 if ( doc && layersetup )
00325 layersetup->SetAvailable( doc );
00326
00327 if ( layersetup )
00328 Init( layersetup );
00329 else
00330 Init( a2dCanvasGlobals->GetLayerSetup() );
00331
00332 Centre(wxBOTH);
00333 Layout();
00334
00335 }
00336
00337 LayerPropertiesDialog::~LayerPropertiesDialog()
00338 {
00339 a2dDocviewGlobals->GetEventDistributer()->Unregister( this );
00340
00341 delete m_fillpatterns;
00342 delete m_brush;
00343
00344 delete m_cdata;
00345 delete m_cd;
00346
00347 delete m_timerAvailable;
00348
00349 for (int i = 0; i < 10; i++)
00350 {
00351 delete m_p_bitm[i];
00352 }
00353 }
00354
00355 void LayerPropertiesDialog::OnTimerAvailable( wxTimerEvent &event )
00356 {
00357 a2dCanvasDocument* doc = (a2dCanvasDocument*) a2dDocviewGlobals->GetDocviewCommandProcessor()->GetCurrentDocument();
00358 if ( doc && doc->IsModified() && doc->GetInternalChangedTime() > m_dialogLastUpdate )
00359 {
00360 m_controlslayersetup->SetAvailable( doc->GetLayerSetup() );
00361 m_dialogLastUpdate = wxDateTime::Now();
00362 }
00363 }
00364
00365 void LayerPropertiesDialog::OnChangedDocument( a2dCommandEvent& event )
00366 {
00367 a2dCanvasDocument* doc = (a2dCanvasDocument*) event.GetDocument();
00368 if ( doc && doc->GetLayerSetup() != m_layersetup )
00369 {
00370 doc->GetLayerSetup()->SetAvailable( doc );
00371 Init( doc->GetLayerSetup() );
00372 }
00373 }
00374
00375 void LayerPropertiesDialog::Init( a2dLayers* layersetup )
00376 {
00377 m_backuplayersetup = wxStaticCast( layersetup->Clone(a2dObject::clone_deep) , a2dLayers );
00378 m_controlslayersetup = wxStaticCast( layersetup->Clone(a2dObject::clone_deep) , a2dLayers );
00379 m_layersetup = layersetup;
00380
00381 m_buttonPREV->Enable();
00382 m_buttonNEXT->Enable();
00383
00384 if (m_startvalue <= 0)
00385 m_buttonPREV->Disable();
00386
00387 if (m_startvalue + 10 >= wxMAXLAYER-1)
00388 m_buttonNEXT->Disable();
00389
00390 FillControls(m_startvalue);
00391 }
00392
00393 void LayerPropertiesDialog::OnComEvent( a2dComEvent& event )
00394 {
00395 if ( GetEvtHandlerEnabled() )
00396 {
00397 a2dCanvasDocument* doc = (a2dCanvasDocument*) a2dDocviewGlobals->GetDocviewCommandProcessor()->GetCurrentDocument();
00398
00399 if ( !doc )
00400 return;
00401
00402 int layer = a2dGetCmdh()->GetLayer();
00403 a2dLayerInfo* layerinfo = GetLocalLayerInfo(layer);
00404
00405 if ( event.GetEventComId() == &a2dComEvent::sm_changedProperty )
00406 {
00407 a2dNamedProperty *property = event.GetProperty();
00408 a2dObject *object = property->GetRefObjectNA();
00409
00410 if ( 0 != wxDynamicCast( property, a2dStrokeProperty ) )
00411 {
00412 a2dStroke stroke = ((a2dStrokeProperty*)property)->GetValue();
00413 if ( layerinfo->GetStroke() != stroke )
00414 layerinfo->SetStroke( stroke );
00415 FillControls(m_startvalue);
00416 }
00417 else if ( 0 != wxDynamicCast( property, a2dFillProperty ) )
00418 {
00419 a2dFill fill = ((a2dFillProperty*)property)->GetValue();
00420 if ( layerinfo->GetFill() != fill )
00421 layerinfo->SetFill( fill );
00422 FillControls(m_startvalue);
00423 }
00424 else if ( property->GetId() == a2dCanvasObject::PROPID_Layer )
00425 {
00426 layerinfo->SetLayer( property->GetUint16() );
00427 FillControls(m_startvalue);
00428 }
00429 else
00430 event.Skip();
00431 }
00432 else if ( event.GetEventComId() == &a2dCanvasView::sm_changedLayers )
00433 {
00434 Init( doc->GetLayerSetup() );
00435 }
00436 else if ( event.GetEventComId() == &a2dCanvasDocument::sm_layersetupChanged )
00437 {
00438 Init( doc->GetLayerSetup() );
00439 }
00440
00441 }
00442 }
00443
00444 void LayerPropertiesDialog::OnDoEvent( a2dCommandProcessorEvent& event )
00445 {
00446 if ( GetEvtHandlerEnabled() )
00447 {
00448 a2dCanvasDocument* doc = (a2dCanvasDocument*) a2dDocviewGlobals->GetDocviewCommandProcessor()->GetCurrentDocument();
00449
00450 if ( !doc )
00451 return;
00452
00453 if ( event.GetCommand()->GetCommandId() == &a2dCommand_SetLayer::Id )
00454 {
00455 FillControls(m_startvalue);
00456 }
00457 }
00458 }
00459
00460 void LayerPropertiesDialog::FillControls(int start)
00461 {
00462 wxColour kleurtje;
00463 wxColour kleurtje2;
00464
00465 int All_Hided = true;
00466 int All_Read = true;
00467 int All_Outline = true;
00468
00469 int currentInsertLayer = a2dGetCmdh()->GetLayer();
00470
00471 for (int i = start; i < start+10; i++)
00472 {
00473 wxString buf;
00474 int x = i - m_startvalue;
00475
00476 a2dLayerInfo* layerinfo = GetLocalLayerInfo(i);
00477
00478 bool available = layerinfo->GetAvailable();
00479
00480 buf.Printf( wxT("%i"), layerinfo->GetLayer() );
00481 m_numberbox[x]->SetBackgroundColour( currentInsertLayer == i ? wxColour(184,232,241) : wxColour(255,255,255) );
00482 m_numberbox[x]->SetForegroundColour( available ? wxColour(255,0,0) : wxColour(0,0,0) );
00483 m_numberbox[x]->SetLabel(buf);
00484
00485 m_namebox[x]->SetBackgroundColour( currentInsertLayer == i ? wxColour(184,232,241) : wxColour(255,255,255) );
00486 m_namebox[x]->SetForegroundColour( available ? wxColour(255,0,0) : wxColour(0,0,0) );
00487 m_namebox[x]->SetValue( layerinfo->GetName() );
00488 m_namebox[x]->SetToolTip( layerinfo->GetFeature() );
00489
00490 if (layerinfo->GetVisible())
00491 All_Hided = false;
00492
00493 m_visiblebox[x]->SetValue( layerinfo->GetVisible() ? true : false);
00494 m_selectablebox[x]->SetValue( layerinfo->GetSelectable() ? true : false );
00495
00496 if ( !layerinfo->GetFill().GetFilling() )
00497 All_Outline = false;
00498 m_outlinebox[x]->SetValue( !layerinfo->GetFill().GetFilling() ? true : false );
00499
00500 if (! layerinfo->GetRead())
00501 m_readlayerbox[x]->SetValue(false);
00502 else
00503 {
00504 All_Read = false;
00505 m_readlayerbox[x]->SetValue(true);
00506 }
00507
00508
00509 kleurtje = layerinfo->GetFillColour();
00510 m_fillbut[x]->SetBackgroundColour(kleurtje);
00511
00512
00513 kleurtje = layerinfo->GetStrokeColour();
00514 m_borderbut[x]->SetBackgroundColour(kleurtje);
00515
00516 {
00517
00518 int w = m_patternbut[x]->GetBitmapLabel().GetWidth();
00519 int h = m_patternbut[x]->GetBitmapLabel().GetHeight();
00520 a2dMemDcDrawer* drawer = new a2dMemDcDrawer( w, h );
00521 drawer->BeginDraw();
00522 drawer->SetDrawerFill( layerinfo->GetFill() );
00523 drawer->SetDrawerStroke( layerinfo->GetStroke() );
00524 drawer->DrawRoundedRectangle( 0, 0, w, h, 0 );
00525 drawer->EndDraw();
00526 m_patternbut[x]->SetBitmapLabel( drawer->GetBuffer() );
00527 m_patternbut[x]->Refresh(true);
00528 delete drawer;
00529
00530 }
00531
00532 buf.Printf( wxT("%i"), layerinfo->GetInMapping() );
00533 m_gdsinmap[x]->SetValue(buf);
00534
00535 buf.Printf( wxT("%i"), layerinfo->GetOutMapping() );
00536 m_gdsoutmap[x]->SetValue(buf);
00537
00538 m_fillbut[x]->Refresh();
00539 m_borderbut[x]->Refresh();
00540 m_patternbut[x]->Refresh();
00541 }
00542
00543 if (All_Hided)
00544 {
00545 m_buttonVISIBLE->SetLabel( _T("Show All"));
00546 m_buttonSELECT->SetLabel( _T("All Selectable"));
00547 }
00548
00549 if (m_onorder)
00550 m_buttonSORT->SetLabel( _T("Sort Layer"));
00551 else
00552 m_buttonSORT->SetLabel( _T("Sort Order"));
00553
00554 if (All_Outline)
00555 m_buttonOutLine->SetLabel(_T("Outline All"));
00556 else
00557 m_buttonOutLine->SetLabel(_T("Outline Non"));
00558
00559 if (All_Read)
00560 m_buttonREAD->SetLabel(_T("Read All"));
00561
00562
00563 Refresh(true);
00564 }
00565
00566 void LayerPropertiesDialog::StoreControls( unsigned int start, unsigned int nrLayers )
00567 {
00568 bool changed = false;
00569
00570 SetEvtHandlerEnabled( false );
00571
00572
00573
00574 unsigned int i;
00575 for ( i = start; i < start + nrLayers; i++)
00576 {
00577 int x = i - m_startvalue;
00578
00579 a2dLayerInfo* layerinfo = GetLocalLayerInfo(i);
00580
00581 layerinfo->SetName( m_namebox[x]->GetValue() );
00582 layerinfo->SetVisible((bool)m_visiblebox[x]->GetValue() );
00583 layerinfo->SetSelectable((bool)m_selectablebox[x]->GetValue() );
00584 layerinfo->SetRead((bool)(m_readlayerbox[x]->GetValue()));
00585 layerinfo->SetStrokeColour( m_borderbut[x]->GetBackgroundColour() );
00586 layerinfo->SetFillColour( m_fillbut[x]->GetBackgroundColour() );
00587
00588
00589 if ( m_patterns[x] != 0 && m_patterns[x] != 1 )
00590 {
00591 a2dFill pfill = layerinfo->GetFill();
00592 pfill.SetStipple( *(m_fillpatterns->GetPattern( m_patterns[x] )) );
00593 pfill.SetColour( m_fillbut[x]->GetBackgroundColour() );
00594 pfill.SetColour2( m_fillbut[x]->GetBackgroundColour() );
00595 }
00596 else
00597 {
00598 a2dFill fill = a2dFill( m_fillbut[x]->GetBackgroundColour() );
00599 layerinfo->SetFill( fill );
00600 }
00601
00602 long t;
00603 m_gdsinmap[x]->GetValue().ToLong( &t );
00604 layerinfo->SetInMapping( t );
00605 m_gdsoutmap[x]->GetValue().ToLong( &t );
00606 layerinfo->SetOutMapping( t );
00607
00608
00609 a2dLayerInfo* layerinfodoc = GetDocLayerInfo(i);
00610
00611
00612 if ( layerinfo->GetName() != layerinfodoc->GetName() )
00613 {
00614 changed = true;
00615 if ( a2dGetCmdh()->GetDocCmdh() )
00616 a2dGetCmdh()->GetDocCmdh()->Submit( new a2dCommand_SetProperty( layerinfodoc, a2dLayerInfo::PROPID_layerName, layerinfo->GetName().c_str() ));
00617 else
00618 a2dLayerInfo::PROPID_layerName->SetPropertyToObject( layerinfodoc, layerinfo->GetName().c_str() );
00619 }
00620
00621 if ( layerinfo->GetVisible() != layerinfodoc->GetVisible())
00622 {
00623 changed = true;
00624 if ( a2dGetCmdh()->GetDocCmdh() )
00625 a2dGetCmdh()->GetDocCmdh()->Submit( new a2dCommand_SetProperty( layerinfodoc, a2dLayerInfo::PROPID_layerVisible, layerinfo->GetVisible() ));
00626 else
00627 a2dLayerInfo::PROPID_layerVisible->SetPropertyToObject( layerinfodoc, layerinfo->GetVisible() );
00628 }
00629
00630 if ( layerinfo->GetSelectable() != layerinfodoc->GetSelectable())
00631 {
00632 changed = true;
00633 if ( a2dGetCmdh()->GetDocCmdh() )
00634 a2dGetCmdh()->GetDocCmdh()->Submit( new a2dCommand_SetProperty( layerinfodoc, a2dLayerInfo::PROPID_layerSelectable, layerinfo->GetSelectable()));
00635 else
00636 a2dLayerInfo::PROPID_layerSelectable->SetPropertyToObject( layerinfodoc, layerinfo->GetSelectable() );
00637 }
00638
00639 if ( layerinfo->GetRead() != layerinfodoc->GetRead())
00640 {
00641 changed = true;
00642 a2dGetCmdh()->GetDocCmdh()->Submit( new a2dCommand_SetProperty( layerinfodoc, a2dLayerInfo::PROPID_readlayer, layerinfo->GetRead() ));
00643 }
00644
00645 if ( layerinfo->GetStroke().GetColour() != layerinfodoc->GetStroke().GetColour() )
00646 {
00647 changed = true;
00648 if ( a2dGetCmdh()->GetDocCmdh() )
00649 a2dGetCmdh()->GetDocCmdh()->Submit( new a2dCommand_SetProperty( layerinfodoc, a2dLayerInfo::PROPID_StrokeColour, layerinfo->GetStroke().GetColour() ));
00650 else
00651 a2dLayerInfo::PROPID_StrokeColour->SetPropertyToObject( layerinfodoc, layerinfo->GetStroke().GetColour() );
00652 }
00653 if ( layerinfo->GetFill().GetColour() != layerinfodoc->GetFill().GetColour() )
00654 {
00655 changed = true;
00656 if ( a2dGetCmdh()->GetDocCmdh() )
00657 a2dGetCmdh()->GetDocCmdh()->Submit( new a2dCommand_SetProperty( layerinfodoc, a2dLayerInfo::PROPID_FillColour, layerinfo->GetFill().GetColour() ));
00658 else
00659 a2dLayerInfo::PROPID_FillColour->SetPropertyToObject( layerinfodoc, layerinfo->GetFill().GetColour() );
00660
00661 }
00662
00663 if ( &layerinfo->GetFill().GetStipple() != &layerinfodoc->GetFill().GetStipple() )
00664 {
00665 changed = true;
00666
00667
00668
00669 a2dLayerInfo::PROPID_Fill->SetPropertyToObject( layerinfodoc, layerinfo->GetFill());
00670 }
00671
00672 if ( layerinfo->GetInMapping() != layerinfodoc->GetInMapping() )
00673 {
00674 changed = true;
00675 if ( a2dGetCmdh()->GetDocCmdh() )
00676 a2dGetCmdh()->GetDocCmdh()->Submit( new a2dCommand_SetProperty( layerinfodoc, a2dLayerInfo::PROPID_inmap, layerinfo->GetInMapping() ));
00677 else
00678 a2dLayerInfo::PROPID_inmap->SetPropertyToObject( layerinfodoc, layerinfo->GetInMapping() );
00679 }
00680
00681 if ( layerinfo->GetOutMapping() != layerinfodoc->GetOutMapping() )
00682 {
00683 changed = true;
00684 if ( a2dGetCmdh()->GetDocCmdh() )
00685 a2dGetCmdh()->GetDocCmdh()->Submit( new a2dCommand_SetProperty( layerinfodoc, a2dLayerInfo::PROPID_outmap, layerinfo->GetOutMapping() ));
00686 else
00687 a2dLayerInfo::PROPID_outmap->SetPropertyToObject( layerinfodoc, layerinfo->GetOutMapping() );
00688 }
00689 }
00690
00691
00692 if ( changed )
00693 {
00694 a2dComEvent changedlayer( m_layersetup->GetCanvasDocument(), m_layersetup ,&a2dCanvasDocument::sm_layersetupChanged );
00695 a2dDocviewGlobals->GetEventDistributer()->ProcessEvent( changedlayer );
00696 }
00697
00698 SetEvtHandlerEnabled( true );
00699 }
00700
00701 void LayerPropertiesDialog::CmHide(wxCommandEvent &)
00702 {
00703 Show(false);
00704
00705 a2dCanvasDocument* doc = (a2dCanvasDocument*) a2dDocviewGlobals->GetDocviewCommandProcessor()->GetCurrentDocument();
00706 if ( doc && doc->GetLayerSetup() )
00707 doc->GetLayerSetup()->SetPending( true );
00708 }
00709
00710 void LayerPropertiesDialog::CmCancel( wxCommandEvent& event)
00711 {
00712 m_layersetup = wxStaticCast( m_backuplayersetup->Clone(a2dObject::clone_deep) , a2dLayers );
00713 m_controlslayersetup = wxStaticCast( m_backuplayersetup->Clone(a2dObject::clone_deep) , a2dLayers );
00714
00715 FillControls(m_startvalue);
00716 StoreControls( m_startvalue, m_startvalue + 10 );
00717
00718 CmHide( event );
00719 }
00720
00721 void LayerPropertiesDialog::CmRestore( wxCommandEvent& WXUNUSED(event) )
00722 {
00723 m_layersetup = wxStaticCast( m_backuplayersetup->Clone(a2dObject::clone_deep) , a2dLayers );
00724 m_controlslayersetup = wxStaticCast( m_backuplayersetup->Clone(a2dObject::clone_deep) , a2dLayers );
00725
00726 FillControls(m_startvalue);
00727 a2dCanvasDocument* doc = (a2dCanvasDocument*) a2dDocviewGlobals->GetDocviewCommandProcessor()->GetCurrentDocument();
00728
00729 if ( !doc )
00730 return;
00731
00732 SetEvtHandlerEnabled( false );
00733 doc->SetLayerSetup( m_layersetup );
00734 SetEvtHandlerEnabled( true );
00735 }
00736
00737 void LayerPropertiesDialog::CmSaveToFile( wxCommandEvent& WXUNUSED(event) )
00738 {
00739 wxString fullname = _( "Mywxart2dlayers.cvg" );
00740
00741 wxString* layerfiledir = a2dGeneralGlobals->GetVariablesHash().GetVariableString( wxT("lastLayerFileSavePath") );
00742
00743 if ( !layerfiledir )
00744 layerfiledir = a2dDocviewGlobals->GetVariablesHash().GetVariableString( wxT("layerFileSavePath") );
00745
00746 wxFileDialog fileDialog( this,
00747 _("Choose layer file to load"),
00748 layerfiledir ? *layerfiledir: wxT(""),
00749 fullname,
00750 wxT("*.cvg"),
00751 wxFD_SAVE | wxFD_OVERWRITE_PROMPT
00752 );
00753
00754 if ( fileDialog.ShowModal() != wxID_OK )
00755 return;
00756
00757 fullname = fileDialog.GetPath();
00758
00759 a2dGeneralGlobals->GetVariablesHash().SetVariableString( wxT("lastLayerFileSavePath"), wxPathOnly(fullname) );
00760
00761 SetEvtHandlerEnabled( false );
00762
00763 SetCursor( wxCURSOR_WAIT );
00764 m_layersetup->SaveLayers( fullname );
00765
00766 SetEvtHandlerEnabled( true );
00767 SetCursor( wxCURSOR_ARROW );
00768 }
00769
00770 void LayerPropertiesDialog::CmLoadFromFile( wxCommandEvent& WXUNUSED(event) )
00771 {
00772 wxString fullname;
00773
00774 wxString* path = a2dGeneralGlobals->GetVariablesHash().GetVariableString( wxT("lastLayerFileSavePath") );
00775
00776 wxFileDialog fileDialog( this,
00777 _("Choose layer file to load"),
00778 path ? *path: wxT(""),
00779 fullname,
00780 wxT("*.cvg"),
00781 wxFD_OPEN | wxFD_FILE_MUST_EXIST
00782 );
00783
00784 if ( fileDialog.ShowModal() != wxID_OK )
00785 return;
00786
00787 fullname = fileDialog.GetPath();
00788
00789 a2dGeneralGlobals->GetVariablesHash().SetVariableString( wxT("lastLayerFileSavePath"), wxPathOnly(fullname) );
00790
00791 SetCursor( wxCURSOR_WAIT );
00792 #if wxART2D_USE_CVGIO
00793
00794 a2dLayers* layersetup = new a2dLayers();
00795 layersetup->LoadLayers( fullname );
00796 a2dCanvasDocument* doc = (a2dCanvasDocument*) a2dDocviewGlobals->GetDocviewCommandProcessor()->GetCurrentDocument();
00797 if ( !doc )
00798 return;
00799 doc->SetLayerSetup( layersetup );
00800 #else
00801 wxFAIL_MSG( wxT("wxART2D_USE_CVGIO is needed to load object from a file CVG file") );
00802 #endif //wxART2D_USE_CVGIO
00803
00804
00805 SetEvtHandlerEnabled( false );
00806 Init( layersetup);
00807 SetEvtHandlerEnabled( true );
00808 FillControls(m_startvalue);
00809 SetCursor( wxCURSOR_ARROW );
00810 }
00811
00812
00813 void LayerPropertiesDialog::OnCloseWindow(wxCloseEvent& WXUNUSED(event) )
00814 {
00815 Show(false);
00816
00817 a2dCanvasDocument* doc = (a2dCanvasDocument*) a2dDocviewGlobals->GetDocviewCommandProcessor()->GetCurrentDocument();
00818 if ( doc && doc->GetLayerSetup() )
00819 doc->GetLayerSetup()->SetPending( true );
00820 }
00821
00822 void LayerPropertiesDialog::CmSort( wxCommandEvent& )
00823 {
00824 wxString buf;
00825 buf = m_buttonSORT->GetLabel();
00826 if ( buf == wxT("Sort Layer") )
00827 m_onorder = false;
00828 else
00829 m_onorder = true;
00830
00831 FillControls(m_startvalue);
00832 }
00833
00834 void LayerPropertiesDialog::CmVisible( wxCommandEvent& )
00835 {
00836 wxString buf;
00837 bool onoff = false;
00838 buf = m_buttonVISIBLE->GetLabel();
00839 if ( buf == wxT("Hide All") )
00840 {
00841 onoff = false;
00842 m_buttonVISIBLE->SetLabel( wxT("Show All") );
00843 }
00844 else
00845 {
00846 onoff = true;
00847 m_buttonVISIBLE->SetLabel(wxT("Hide All"));
00848 }
00849
00850 m_controlslayersetup->SetAll_Layers_Visible( onoff );
00851
00852 a2dCommand_SetLayersProperty* command = new a2dCommand_SetLayersProperty( onoff, a2dCommand_SetLayersProperty::visible );
00853 a2dGetCmdh()->Submit( command );
00854
00855 FillControls(m_startvalue);
00856 }
00857
00858 void LayerPropertiesDialog::CmRead(wxCommandEvent &)
00859 {
00860 wxString buf;
00861 bool onoff = false;
00862 buf = m_buttonREAD->GetLabel();
00863 if ( buf == wxT("Read Non") )
00864 {
00865 onoff = false;
00866 m_buttonREAD->SetLabel(_T("Read All"));
00867 }
00868 else
00869 {
00870 onoff = true;
00871 m_buttonREAD->SetLabel(wxT("Read Non"));
00872 }
00873
00874 m_controlslayersetup->SetAll_Layers_Read( onoff );
00875
00876 a2dCommand_SetLayersProperty* command = new a2dCommand_SetLayersProperty( onoff, a2dCommand_SetLayersProperty::readable );
00877 a2dGetCmdh()->Submit( command );
00878
00879 FillControls(m_startvalue);
00880 }
00881
00882 void LayerPropertiesDialog::CmOutLine(wxCommandEvent &)
00883 {
00884 wxString buf;
00885 bool onoff = false;
00886 buf = m_buttonOutLine->GetLabel();
00887 if ( buf == wxT("Outline Non") )
00888 {
00889 onoff = false;
00890 m_buttonOutLine->SetLabel(_T("Outline All"));
00891 }
00892 else
00893 {
00894 onoff = true;
00895 m_buttonOutLine->SetLabel(wxT("Outline Non"));
00896 }
00897
00898 m_controlslayersetup->SetAll_Layers_Outline( onoff );
00899
00900 a2dCommand_SetLayersProperty* command = new a2dCommand_SetLayersProperty( !onoff, a2dCommand_SetLayersProperty::filling );
00901 a2dGetCmdh()->Submit( command );
00902
00903 FillControls(m_startvalue);
00904 }
00905
00906 void LayerPropertiesDialog::CmSelect(wxCommandEvent &)
00907 {
00908 wxString buf;
00909 bool onoff = false;
00910 buf = m_buttonSELECT->GetLabel();
00911 if ( buf == wxT("All Selectable") )
00912 {
00913 onoff = true;
00914 m_buttonSELECT->SetLabel(_T("None Selectable"));
00915 }
00916 else
00917 {
00918 onoff = false;
00919 m_buttonSELECT->SetLabel(_T("All Selectable"));
00920 }
00921
00922 m_controlslayersetup->SetAll_Layers_Selectable( onoff );
00923
00924 a2dCommand_SetLayersProperty* command = new a2dCommand_SetLayersProperty( onoff, a2dCommand_SetLayersProperty::selectable );
00925 a2dGetCmdh()->Submit( command );
00926
00927 FillControls(m_startvalue);
00928 }
00929
00930 void LayerPropertiesDialog::CmPrev(wxCommandEvent &)
00931 {
00932 m_buttonNEXT->Enable();
00933 if (m_startvalue - 10 >= 0)
00934 {
00935 m_startvalue -= 10;
00936 FillControls(m_startvalue);
00937 }
00938
00939 if (m_startvalue <= 0)
00940 m_buttonPREV->Disable();
00941 SetFocus();
00942 Show(true);
00943 Refresh();
00944 }
00945
00946 void LayerPropertiesDialog::CmNext( wxCommandEvent& )
00947 {
00948 m_buttonPREV->Enable();
00949 if (m_startvalue + 10 < wxMAXLAYER )
00950 {
00951 m_startvalue += 10;
00952 FillControls(m_startvalue);
00953 }
00954
00955 if (m_startvalue + 10 >= wxMAXLAYER-1)
00956 m_buttonNEXT->Disable();
00957 SetFocus();
00958 Show(true);
00959 Refresh();
00960 }
00961
00962 void LayerPropertiesDialog::Cm_F_BitB(wxEvent& event)
00963 {
00964 if (m_cd->ShowModal()==wxID_OK)
00965 {
00966 wxColour col;
00967 *m_cdata = m_cd->GetColourData();
00968 col = m_cdata->GetColour();
00969 int x = event.GetId() - ID_LAYERFILLCOLOR;
00970 int i = x + m_startvalue;
00971
00972 a2dLayerInfo* layerinfo = GetLocalLayerInfo(i);
00973 a2dLayerInfo* layerinfodoc = GetDocLayerInfo(i);
00974
00975 layerinfo->SetFillColour( col );
00976
00977 if ( layerinfo->GetFill().GetColour() != layerinfodoc->GetFill().GetColour() )
00978 {
00979 if ( a2dGetCmdh()->GetDocCmdh() )
00980 a2dGetCmdh()->GetDocCmdh()->Submit( new a2dCommand_SetProperty( layerinfodoc, a2dLayerInfo::PROPID_FillColour, layerinfo->GetFill().GetColour() ));
00981 else
00982 a2dLayerInfo::PROPID_FillColour->SetPropertyToObject( layerinfodoc, layerinfo->GetFill().GetColour() );
00983 }
00984 FillControls(m_startvalue);
00985 }
00986 SetFocus();
00987 Show(true);
00988 Refresh(true);
00989 }
00990
00991 void LayerPropertiesDialog::Cm_B_BitB(wxEvent& event)
00992 {
00993 if (m_cd->ShowModal()==wxID_OK)
00994 {
00995 wxColour col;
00996 *m_cdata = m_cd->GetColourData();
00997 col = m_cdata->GetColour();
00998
00999 int x = event.GetId() - ID_LAYERSTROKECOLOR;
01000 int i = x + m_startvalue;
01001
01002 a2dLayerInfo* layerinfo = GetLocalLayerInfo(i);
01003 a2dLayerInfo* layerinfodoc = GetDocLayerInfo(i);
01004 layerinfo->SetStrokeColour( col );
01005 if ( layerinfo->GetStroke().GetColour() != layerinfodoc->GetStroke().GetColour() )
01006 {
01007 if ( a2dGetCmdh()->GetDocCmdh() )
01008 a2dGetCmdh()->GetDocCmdh()->Submit( new a2dCommand_SetProperty( layerinfodoc, a2dLayerInfo::PROPID_StrokeColour, layerinfo->GetStroke().GetColour() ));
01009 else
01010 a2dLayerInfo::PROPID_StrokeColour->SetPropertyToObject( layerinfodoc, layerinfo->GetStroke().GetColour() );
01011 }
01012 FillControls(m_startvalue);
01013 }
01014 SetFocus();
01015 Show(true);
01016 Refresh();
01017 }
01018
01019 void LayerPropertiesDialog::Cm_P_BitB(wxEvent& event)
01020 {
01021
01022 int x = event.GetId() - ID_LAYERPATTERN;
01023 int i = x + m_startvalue;
01024
01025 PatternDialog patternDialog(this,m_fillpatterns, wxT("Patterns"),(wxSYSTEM_MENU | wxCAPTION));
01026 int choosen = patternDialog.ShowModal();
01027 patternDialog.Close();
01028
01029 wxBitmap pat = *(m_fillpatterns->GetPattern( choosen ));
01030
01031 a2dLayerInfo* layerinfo = GetLocalLayerInfo(i);
01032 a2dLayerInfo* layerinfodoc = GetDocLayerInfo(i);
01033
01034
01035 if ( choosen != 0 && choosen != 1 )
01036 {
01037 a2dFillStyle style = layerinfo->GetFill().GetStyle();
01038 a2dFill pfill = a2dFill( pat );
01039
01040 if ( style != a2dFILL_STIPPLE_MASK_OPAQUE &&
01041 style != a2dFILL_STIPPLE_MASK_OPAQUE_TRANSPARENT &&
01042 style != a2dFILL_STIPPLE )
01043
01044 pfill.SetStyle( a2dFILL_STIPPLE_MASK_OPAQUE_TRANSPARENT );
01045 else if ( style == a2dFILL_STIPPLE )
01046 pfill.SetStyle( a2dFILL_STIPPLE_MASK_OPAQUE_TRANSPARENT );
01047 else
01048 pfill.SetStyle( style );
01049 pfill.SetColour( layerinfo->GetFill().GetColour() );
01050 pfill.SetColour2( layerinfo->GetFill().GetColour2() );
01051 layerinfo->SetFill( pfill );
01052 }
01053 else
01054 {
01055 if ( choosen == 0 )
01056 {
01057 a2dFill fill = a2dFill( layerinfo->GetFill().GetColour(), a2dFILL_TRANSPARENT );
01058 layerinfo->SetFill( fill );
01059 }
01060 else
01061 {
01062 a2dFill fill = a2dFill( layerinfo->GetFill().GetColour(), a2dFILL_SOLID );
01063 layerinfo->SetFill( fill );
01064 }
01065 }
01066
01067
01068
01069
01070
01071
01072 layerinfodoc->SetFill( layerinfo->GetFill() );
01073 FillControls(m_startvalue);
01074
01075 SetFocus();
01076 Show(true);
01077 Refresh();
01078 }
01079
01080 void LayerPropertiesDialog::Cm_LayerName(wxEvent& event )
01081 {
01082 int x = event.GetId() - ID_LAYERNAME;
01083 int i = x + m_startvalue;
01084 a2dLayerInfo* layerinfo = GetLocalLayerInfo(i);
01085 a2dLayerInfo* layerinfodoc = GetDocLayerInfo(i);
01086 layerinfo->SetName( m_namebox[x]->GetValue() );
01087 layerinfodoc->SetName( m_namebox[x]->GetValue() );
01088 }
01089
01090 void LayerPropertiesDialog::Cm_InMap(wxEvent& event )
01091 {
01092 int x = event.GetId() - ID_INMAP;
01093 int i = x + m_startvalue;
01094 a2dLayerInfo* layerinfo = GetLocalLayerInfo(i);
01095 a2dLayerInfo* layerinfodoc = GetDocLayerInfo(i);
01096 long t;
01097 m_gdsinmap[x]->GetValue().ToLong( &t );
01098 layerinfo->SetInMapping( t );
01099 layerinfodoc->SetInMapping( t );
01100 }
01101
01102 void LayerPropertiesDialog::Cm_OutMap(wxEvent& event )
01103 {
01104 int x = event.GetId() - ID_OUTMAP;
01105 int i = x + m_startvalue;
01106 long t;
01107 m_gdsoutmap[x]->GetValue().ToLong( &t );
01108 a2dLayerInfo* layerinfo = GetLocalLayerInfo(i);
01109 a2dLayerInfo* layerinfodoc = GetDocLayerInfo(i);
01110 layerinfo->SetOutMapping( t );
01111 layerinfodoc->SetOutMapping( t );
01112 }
01113
01114 void LayerPropertiesDialog::Cm_NumberBox(wxEvent& event)
01115 {
01116
01117 int dlayer = event.GetId() - ID_NUMBER;
01118
01119 int currentInsertLayer = a2dGetCmdh()->GetLayer();
01120
01121 if ( currentInsertLayer != m_startvalue + dlayer )
01122 {
01123 a2dGetCmdh()->Submit( new a2dCommand_SetLayer( m_startvalue + dlayer, true ) );
01124
01125 m_numberbox[ dlayer ]->SetBackgroundColour( wxColour(184,232,241) );
01126 m_namebox[ dlayer ]->SetBackgroundColour( wxColour(184,232,241) );
01127 m_numberbox[ dlayer ]->Refresh();
01128 m_namebox[ dlayer ]->Refresh();
01129 }
01130 }
01131
01132 void LayerPropertiesDialog::Cm_VisibleBox(wxEvent& event)
01133 {
01134 int x = event.GetId() - ID_VISIBLE;
01135 int i = x + m_startvalue;
01136
01137 a2dLayerInfo* layerinfo = GetLocalLayerInfo(i);
01138 layerinfo->SetVisible( (bool)m_visiblebox[ x ]->GetValue() );
01139
01140 a2dCanvasDocument* doc = (a2dCanvasDocument*) a2dDocviewGlobals->GetDocviewCommandProcessor()->GetCurrentDocument();
01141 if ( !doc )
01142 return;
01143 a2dLayers* layers = doc->GetLayerSetup();
01144 if ( !layers )
01145 return;
01146 a2dLayerInfo* layerinfodoc = layers->GetLayerIndex()[ i ];
01147
01148 a2dCommand_SetCanvasProperty* command = new a2dCommand_SetCanvasProperty( layerinfodoc, a2dLayerInfo::PROPID_layerVisible, layerinfo->GetVisible() );
01149 a2dGetCmdh()->Submit( command );
01150 }
01151
01152 void LayerPropertiesDialog::Cm_OutLineBox(wxEvent& event)
01153 {
01154
01155 int x = event.GetId() - ID_OUTLINE;
01156 int i = m_startvalue + x;
01157
01158 a2dLayerInfo* layerinfo = GetDocLayerInfo(i);
01159 a2dFill fill = layerinfo->GetFill();
01160 fill.SetFilling( ! (bool)m_outlinebox[ x ]->GetValue() );
01161 layerinfo->SetFill( fill );
01162
01163 a2dCanvasDocument* doc = (a2dCanvasDocument*) a2dDocviewGlobals->GetDocviewCommandProcessor()->GetCurrentDocument();
01164 if ( !doc )
01165 return;
01166 a2dLayers* layers = doc->GetLayerSetup();
01167 if ( !layers )
01168 return;
01169 a2dLayerInfo* layerinfodoc = layers->GetLayerIndex()[ i ];
01170
01171 layerinfodoc->SetFill( fill );
01172
01173
01174
01175 }
01176
01177 void LayerPropertiesDialog::Cm_SelectBox(wxEvent& event)
01178 {
01179
01180 int x = event.GetId() - ID_SELECTABLE;
01181 int i = m_startvalue + x;
01182
01183 a2dLayerInfo* layerinfo = GetDocLayerInfo(i);
01184 layerinfo->SetSelectable( (bool)m_selectablebox[ x ]->GetValue() );
01185
01186 a2dCanvasDocument* doc = (a2dCanvasDocument*) a2dDocviewGlobals->GetDocviewCommandProcessor()->GetCurrentDocument();
01187 if ( !doc )
01188 return;
01189 a2dLayers* layers = doc->GetLayerSetup();
01190 if ( !layers )
01191 return;
01192 a2dLayerInfo* layerinfodoc = layers->GetLayerIndex()[ i ];
01193
01194 a2dCommand_SetCanvasProperty* command = new a2dCommand_SetCanvasProperty( layerinfodoc, a2dLayerInfo::PROPID_layerSelectable, layerinfo->GetSelectable() );
01195 a2dGetCmdh()->Submit( command );
01196 }
01197
01198 void LayerPropertiesDialog::Cm_ReadBox(wxEvent& event)
01199 {
01200
01201 int x = event.GetId() - ID_READ;
01202 int i = m_startvalue + x;
01203
01204 a2dLayerInfo* layerinfo = GetDocLayerInfo(i);
01205 layerinfo->SetRead( (bool)m_readlayerbox[ x ]->GetValue() );
01206
01207 a2dCanvasDocument* doc = (a2dCanvasDocument*) a2dDocviewGlobals->GetDocviewCommandProcessor()->GetCurrentDocument();
01208 if ( !doc )
01209 return;
01210 a2dLayers* layers = doc->GetLayerSetup();
01211 if ( !layers )
01212 return;
01213 a2dLayerInfo* layerinfodoc = layers->GetLayerIndex()[ i ];
01214
01215 a2dCommand_SetCanvasProperty* command = new a2dCommand_SetCanvasProperty( layerinfodoc, a2dLayerInfo::PROPID_readlayer, layerinfo->GetRead() );
01216 a2dGetCmdh()->Submit( command );
01217 }
01218
01219 void LayerPropertiesDialog::OnChar( wxKeyEvent& event )
01220 {
01221 if ( event.GetKeyCode() == WXK_RETURN )
01222 {
01223 }
01224 else if ( event.GetKeyCode() == WXK_PAGEDOWN)
01225 {
01226 wxCommandEvent eventc;
01227 CmNext( eventc );
01228 }
01229 else if ( event.GetKeyCode() == WXK_PAGEUP)
01230 {
01231 wxCommandEvent eventc;
01232 CmPrev( eventc );
01233 }
01234 else
01235 {
01236
01237
01238
01239
01240 event.Skip();
01241 }
01242 }
01243
01244 void LayerPropertiesDialog::OnCharHook(wxKeyEvent& event)
01245 {
01246 if ( event.GetKeyCode() == WXK_RETURN )
01247 {
01248 event.Skip();
01249 }
01250 else if ( event.GetKeyCode() == WXK_PAGEDOWN)
01251 {
01252 wxCommandEvent eventc;
01253 CmNext( eventc );
01254 }
01255 else if ( event.GetKeyCode() == WXK_PAGEUP)
01256 {
01257 wxCommandEvent eventc;
01258 CmPrev( eventc );
01259 }
01260 else
01261 {
01262
01263
01264
01265
01266 event.Skip();
01267 }
01268 }
01269
01270