00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #include "a2dprec.h"
00014
00015 #ifdef __BORLANDC__
00016 #pragma hdrstop
00017 #endif
00018
00019 #ifndef WX_PRECOMP
00020 #include "wx/wx.h"
00021 #endif
00022
00023
00024
00025
00026 #include "wx/editor/pathsettings.h"
00027 #include "wx/editor/edit.h"
00028 #include "wx/canvas/canmod.h"
00029
00030 #define ID_WIDTH 10002
00031 #define ID_UNITS 10005
00032 #define ID_Rounded 10001
00033 #define ID_Rectangle 10003
00034 #define ID_RectangleExt 10004
00035 #define ID_HIDE 10006
00036 #define ID_APPLY 10007
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 IMPLEMENT_DYNAMIC_CLASS( a2dPathSettings, wxDialog )
00047
00048
00049
00050
00051
00052
00053 BEGIN_EVENT_TABLE( a2dPathSettings, wxDialog )
00054 EVT_COM_EVENT( a2dPathSettings::OnComEvent )
00055 EVT_TEXT_ENTER( ID_WIDTH, a2dPathSettings::OnWidthEnter )
00056 EVT_CHOICE( ID_UNITS, a2dPathSettings::OnUnitsSelected )
00057 EVT_RADIOBUTTON( ID_Rounded, a2dPathSettings::OnRoundedSelected )
00058 EVT_RADIOBUTTON( ID_Rectangle, a2dPathSettings::OnRectangleSelected )
00059 EVT_RADIOBUTTON( ID_RectangleExt, a2dPathSettings::OnRectangleExtSelected )
00060 EVT_BUTTON( ID_HIDE, a2dPathSettings::OnHideClick )
00061 EVT_BUTTON( ID_APPLY, a2dPathSettings::OnApplyClick )
00062 END_EVENT_TABLE()
00063
00064
00065
00066
00067
00068
00069 a2dPathSettings::a2dPathSettings()
00070 {
00071 a2dDocviewGlobals->GetEventDistributer()->Register( this );
00072 Init();
00073 }
00074
00075 a2dPathSettings::a2dPathSettings( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00076 {
00077 a2dDocviewGlobals->GetEventDistributer()->Register( this );
00078 Init();
00079 Create(parent, id, caption, pos, size, style);
00080 }
00081
00082
00083
00084
00085
00086
00087 bool a2dPathSettings::Create( wxWindow* parent, wxWindowID id, const wxString& caption, const wxPoint& pos, const wxSize& size, long style )
00088 {
00089
00090 SetExtraStyle(wxWS_EX_BLOCK_EVENTS);
00091 wxDialog::Create( parent, id, caption, pos, size, style );
00092
00093 CreateControls();
00094 if (GetSizer())
00095 {
00096 GetSizer()->SetSizeHints(this);
00097 }
00098 Centre();
00099
00100 return true;
00101 }
00102
00103
00104
00105
00106
00107
00108 a2dPathSettings::~a2dPathSettings()
00109 {
00110 a2dDocviewGlobals->GetEventDistributer()->Unregister( this );
00111 }
00112
00113
00114
00115
00116
00117
00118 void a2dPathSettings::Init()
00119 {
00120 m_width = NULL;
00121 m_units = NULL;
00122 m_rounded = NULL;
00123 m_rectangular = NULL;
00124 m_extRectangular = NULL;
00125 m_hide = NULL;
00126 m_apply = NULL;
00127 m_pathtype = a2dGetCmdh()->GetPathType();
00128 m_contourWidth = a2dGetCmdh()->GetContourWidth();
00129 }
00130
00131
00132
00133
00134
00135
00136 void a2dPathSettings::CreateControls()
00137 {
00138 a2dPathSettings* itemDialog1 = this;
00139
00140 wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
00141 itemDialog1->SetSizer(itemBoxSizer2);
00142
00143 wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxHORIZONTAL);
00144 itemBoxSizer2->Add(itemBoxSizer3, 1, wxGROW|wxALL, 2);
00145
00146 wxStaticText* itemStaticText4 = new wxStaticText( itemDialog1, wxID_STATIC, _("Width"), wxDefaultPosition, wxDefaultSize, 0 );
00147 itemStaticText4->SetHelpText(_("width of polylines and lines"));
00148 if (a2dPathSettings::ShowToolTips())
00149 itemStaticText4->SetToolTip(_("width of polylines and lines"));
00150 itemBoxSizer3->Add(itemStaticText4, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
00151
00152 m_width = new wxTextCtrl( itemDialog1, ID_WIDTH, _("0"), wxDefaultPosition, wxSize(100, -1), wxTE_PROCESS_ENTER );
00153 m_width->SetHelpText(_("Width of polyline"));
00154 if (a2dPathSettings::ShowToolTips())
00155 m_width->SetToolTip(_("Width of polyline"));
00156 m_width->SetName(_T("width"));
00157 itemBoxSizer3->Add(m_width, 2, wxALIGN_CENTER_VERTICAL|wxALL, 1);
00158
00159 m_unitsStrings.Add( wxT("pm") );
00160 m_unitsStrings.Add( wxT("nm") );
00161 m_unitsStrings.Add( wxT("um") );
00162 m_unitsStrings.Add( wxT("mm") );
00163 m_unitsStrings.Add( wxT("cm") );
00164 m_unitsStrings.Add( wxT("dm") );
00165 m_unitsStrings.Add( wxT("m") );
00166 m_unitsStrings.Add( wxT("mil") );
00167 m_unitsStrings.Add( wxT("inch") );
00168 m_unitsStrings.Add( wxT("foot") );
00169
00170 m_units = new wxChoice( itemDialog1, ID_UNITS, wxDefaultPosition, wxSize(40, -1), m_unitsStrings, 0 );
00171 m_units->SetStringSelection(_("um"));
00172 m_units->SetHelpText(_("Units in which width is given"));
00173 if (a2dPathSettings::ShowToolTips())
00174 m_units->SetToolTip(_("Units in which width is given"));
00175 m_units->SetName(_T("Units"));
00176 itemBoxSizer3->Add(m_units, 1, wxALIGN_CENTER_VERTICAL|wxALL, 1);
00177
00178 m_rounded = new wxRadioButton( itemDialog1, ID_Rounded, _("Rounded"), wxDefaultPosition, wxDefaultSize, 0 );
00179 m_rounded->SetValue(true);
00180 m_rounded->SetHelpText(_("end of lines will be rounded"));
00181 if (a2dPathSettings::ShowToolTips())
00182 m_rounded->SetToolTip(_("end of lines will be rounded"));
00183 m_rounded->SetName(_T("rounded"));
00184 itemBoxSizer2->Add(m_rounded, 0, wxALIGN_LEFT|wxALL, 2);
00185
00186 m_rectangular = new wxRadioButton( itemDialog1, ID_Rectangle, _("Rectangular"), wxDefaultPosition, wxDefaultSize, 0 );
00187 m_rectangular->SetValue(false);
00188 m_rectangular->SetHelpText(_("end of lines will be rectangular"));
00189 if (a2dPathSettings::ShowToolTips())
00190 m_rectangular->SetToolTip(_("end of lines will be rectangular"));
00191 m_rectangular->SetName(_T("rectangular"));
00192 itemBoxSizer2->Add(m_rectangular, 0, wxALIGN_LEFT|wxALL, 2);
00193
00194 m_extRectangular = new wxRadioButton( itemDialog1, ID_RectangleExt, _("Extended Rectangular"), wxDefaultPosition, wxDefaultSize, 0 );
00195 m_extRectangular->SetValue(false);
00196 m_extRectangular->SetHelpText(_("end of lines will be extended rectangular"));
00197 if (a2dPathSettings::ShowToolTips())
00198 m_extRectangular->SetToolTip(_("end of lines will be extended rectangular"));
00199 m_extRectangular->SetName(_T("extended"));
00200 itemBoxSizer2->Add(m_extRectangular, 0, wxALIGN_LEFT|wxALL, 2);
00201
00202 wxBoxSizer* itemBoxSizer10 = new wxBoxSizer(wxHORIZONTAL);
00203 itemBoxSizer2->Add(itemBoxSizer10, 1, wxGROW|wxALL, 2);
00204
00205 m_hide = new wxButton( itemDialog1, ID_HIDE, _("Hide"), wxDefaultPosition, wxDefaultSize, 0 );
00206 m_hide->SetHelpText(_("hide and NOT execute commands"));
00207 if (a2dPathSettings::ShowToolTips())
00208 m_hide->SetToolTip(_("hide and NOT execute commands"));
00209 m_hide->SetName(_T("hide"));
00210 itemBoxSizer10->Add(m_hide, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1);
00211
00212 m_apply = new wxButton( itemDialog1, ID_APPLY, _("Apply"), wxDefaultPosition, wxDefaultSize, 0 );
00213 m_apply->SetHelpText(_("execute commands"));
00214 if (a2dPathSettings::ShowToolTips())
00215 m_apply->SetToolTip(_("execute commands"));
00216 m_apply->SetName(_T("apply"));
00217 itemBoxSizer10->Add(m_apply, 0, wxALIGN_CENTER_VERTICAL|wxALL, 1);
00218
00219 }
00220
00221
00222
00223
00224
00225
00226 bool a2dPathSettings::ShowToolTips()
00227 {
00228 return true;
00229 }
00230
00231
00232
00233
00234
00235 void a2dPathSettings::OnWidthEnter( wxCommandEvent& event )
00236 {
00237 double value;
00238 m_width->GetValue().ToDouble( &value );
00239 m_contourWidth = a2dDoMu( value, m_unitsStrings[m_units->GetSelection()] );
00240 }
00241
00242
00243
00244
00245
00246 void a2dPathSettings::OnUnitsSelected( wxCommandEvent& event )
00247 {
00248 event.Skip();
00249 }
00250
00251
00252
00253
00254
00255 void a2dPathSettings::OnRoundedSelected( wxCommandEvent& event )
00256 {
00257 m_pathtype = a2dPATH_END_ROUND;
00258 }
00259
00260
00261
00262
00263
00264
00265 void a2dPathSettings::OnRectangleSelected( wxCommandEvent& event )
00266 {
00267 m_pathtype = a2dPATH_END_SQAURE;
00268 }
00269
00270
00271
00272
00273
00274
00275 void a2dPathSettings::OnRectangleExtSelected( wxCommandEvent& event )
00276 {
00277 m_pathtype = a2dPATH_END_SQAURE_EXT;
00278 }
00279
00280
00281
00282
00283
00284
00285 void a2dPathSettings::OnHideClick( wxCommandEvent& event )
00286 {
00287 Show( false );
00288 }
00289
00290
00291
00292
00293
00294
00295 void a2dPathSettings::OnApplyClick( wxCommandEvent& event )
00296 {
00297 double value;
00298 m_width->GetValue().ToDouble( &value );
00299 m_contourWidth = a2dDoMu( value, m_unitsStrings[m_units->GetSelection()] );
00300
00301 a2dSmrtPtr<a2dCommand_SetContourWidth> command = new a2dCommand_SetContourWidth( m_contourWidth );
00302 a2dGetCmdh()->Submit( command );
00303 a2dSmrtPtr<a2dCommand_SetPathType> command2 = new a2dCommand_SetPathType( m_pathtype );
00304 a2dGetCmdh()->Submit( command2 );
00305 }
00306
00307 void a2dPathSettings::OnComEvent( a2dComEvent& event )
00308 {
00309 bool baseContinue = true;
00310 if ( event.GetEventComId() == &a2dRecursiveEditTool::sm_toolStartEditObject )
00311 {
00312 a2dObjectEditTool* editTool = wxDynamicCast( event.GetEventObject(), a2dObjectEditTool );
00313 if ( editTool )
00314 {
00315 m_contourWidth = editTool->GetContourWidth();
00316 m_width->SetValue( m_contourWidth.GetNumberString());
00317 m_units->SetStringSelection( m_contourWidth.GetMultiplierString() );
00318
00319 a2dPolylineL* poly = wxDynamicCast( editTool->GetOriginal(), a2dPolylineL );
00320 if ( poly )
00321 m_pathtype = poly->GetPathType();
00322 a2dSLine* line = wxDynamicCast( editTool->GetOriginal(), a2dSLine );
00323 if ( line )
00324 m_pathtype = line->GetPathType();
00325
00326 switch ( m_pathtype )
00327 {
00328 case a2dPATH_END_ROUND : m_rounded->SetValue(true); break;
00329 case a2dPATH_END_SQAURE : m_rectangular->SetValue(true); break;
00330 case a2dPATH_END_SQAURE_EXT : m_extRectangular->SetValue(true); break;
00331 }
00332 }
00333 }
00334 }