00001
00002
00003
00004
00005 #include "wxContour_ButtonsBar.h"
00006
00007
00008
00009
00013
00014
00015
00016 #include "wxContour_ActionCommandsID.h"
00017
00018 #include <string>
00019 #include "wx/toolbar.h"
00020 #include "wx/log.h"
00021 #include "wx/image.h"
00022 #include "wx/filedlg.h"
00023 #include "wx/spinctrl.h"
00024 #include "wx/srchctrl.h"
00025 #include <wx/wx.h>
00026
00027
00028
00029
00030
00031
00032
00033
00034 wxContour_ButtonsBar :: wxContour_ButtonsBar( wxWindow* parent, wxWindowID id, const wxPoint& pos , const wxSize& size, long style, const wxString& name )
00035
00036 :wxPanel( parent, id)
00037 {
00038
00039 std::string as = (char)wxContour_ActionCommandsID::CREATE_TOOL +"";
00040 _createContour_Button = new wxButton( this, -1, _T("+ New Contour"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxString(as.c_str(),wxConvUTF8));
00041
00042 Connect( _createContour_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
00043
00044 as = (char)wxContour_ActionCommandsID::DELETE_TOOL +"";
00045 _delete_Button = new wxButton( this, -1, _T("+ Delete"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxString(as.c_str(),wxConvUTF8));
00046 _delete_Button->SetToolTip(_T("BACK SPACE or DELETE key"));
00047 Connect( _delete_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
00048
00049
00050
00051
00052
00053
00054
00055
00056 as = (char)wxContour_ActionCommandsID::COPY_TOOL +"";
00057 _copy_Button = new wxButton( this, -1, _T("Copy"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxString(as.c_str(),wxConvUTF8));
00058 _copy_Button->SetToolTip(_T("CTRL-C"));
00059 Connect( _copy_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
00060
00061 as = (char)wxContour_ActionCommandsID::PASTE_TOOL +"";
00062 _paste_Button = new wxButton( this, -1, _T("Paste"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxString(as.c_str(),wxConvUTF8));
00063 _paste_Button->SetToolTip(_T("CTRL-V"));
00064 Connect( _paste_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
00065
00066 as = (char)wxContour_ActionCommandsID::CHANGE_TOOL +"";
00067 _change_Button = new wxButton( this, -1, _T(" <--> "), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxString(as.c_str(),wxConvUTF8));
00068 _change_Button->SetToolTip(_T("CTRL-K"));
00069 Connect( _change_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
00070
00071 as = (char)wxContour_ActionCommandsID::SAVE_TOOL +"";
00072 _save_Button = new wxButton( this, -1, _T("Save"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxString(as.c_str(),wxConvUTF8));
00073 _save_Button->SetToolTip(_T("CTRL-S"));
00074 Connect( _save_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
00075
00076 as = (char)wxContour_ActionCommandsID::OPEN_TOOL +"";
00077 _open_Button = new wxButton( this, -1, _T("Open"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxString(as.c_str(),wxConvUTF8));
00078 _open_Button->SetToolTip(_T("CTRL-O"));
00079 Connect( _open_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
00080
00081 as = (char)wxContour_ActionCommandsID::SPREAD_TOOL +"";
00082 _spread_Button = new wxButton( this, -1, _T("+ Spread"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxString(as.c_str(),wxConvUTF8));
00083
00084 Connect( _spread_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
00085
00086 as = (char)wxContour_ActionCommandsID::AUTOMATIQUESEGMENTATION_TOOL +"";
00087 _automatiqueSegmentation_Button = new wxButton( this, -1, _T("+ Segmentation"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxString(as.c_str(),wxConvUTF8));
00088
00089 Connect( _automatiqueSegmentation_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
00090
00091 as = (char)wxContour_ActionCommandsID::INFORMATIONCONTOUR_TOOL +"";
00092 _informationContour_Button = new wxButton( this, -1, _T("+ Information"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxString(as.c_str(),wxConvUTF8));
00093
00094 Connect( _informationContour_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
00095
00096 as = (char)wxContour_ActionCommandsID::INTERFACECONFIGURATION_TOOL +"";
00097 _interfaceConfiguration_Button = new wxButton( this, -1, _T("+ Configuration"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxString(as.c_str(),wxConvUTF8));
00098
00099 Connect( _interfaceConfiguration_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
00100
00101
00102
00103 as = (char)wxContour_ActionCommandsID::TEST_TOOL +"";
00104 _interfaceTest_Button = new wxButton( this, -1, _T("+ Test"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxString(as.c_str(),wxConvUTF8));
00105
00106 Connect( _interfaceTest_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 wxFlexGridSizer * panelSizer = new wxFlexGridSizer(9);
00125 panelSizer -> Add( _createContour_Button, 1, wxGROW );
00126
00127
00128
00129
00130 panelSizer -> Add( _change_Button , 1, wxGROW );
00131 panelSizer -> Add( _copy_Button , 1, wxGROW );
00132 panelSizer -> Add( _paste_Button , 1, wxGROW );
00133 panelSizer -> Add( _delete_Button , 1, wxGROW );
00134 panelSizer -> Add( _save_Button , 1, wxGROW );
00135 panelSizer -> Add( _open_Button , 1, wxGROW );
00136 panelSizer -> Add( _spread_Button , 1, wxGROW );
00137 panelSizer -> Add( _automatiqueSegmentation_Button , 1, wxGROW );
00138 panelSizer -> Add( _informationContour_Button , 1, wxGROW );
00139 panelSizer -> Add( _interfaceConfiguration_Button , 1, wxGROW );
00140 panelSizer -> Add( _interfaceTest_Button , 1, wxGROW );
00141
00142
00143
00144
00145
00146
00147
00148
00149 SetSizer( panelSizer );
00150
00151
00152
00153
00154
00155 SetSize( wxSize( 1500, 80));
00156 this->SetAutoLayout( true );
00157 this->Layout();
00158 }
00159
00160 wxContour_ButtonsBar :: ~wxContour_ButtonsBar( )
00161 {
00162 _eventHandler = NULL;
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174 }
00175
00176
00177
00178 void wxContour_ButtonsBar :: onActionButtonPressed( wxCommandEvent& event )
00179 {
00180 if(_eventHandler!=NULL)
00181 {
00182 std::string theStr = std::string( ((wxButton *)event.GetEventObject())->GetName().ToAscii());
00183 const char * toolCommand = theStr.c_str();
00184 event.SetId( GetId() );
00185 event.SetEventObject( this );
00186 event.SetClientData( (void *) toolCommand);
00187 _eventHandler->ProcessEvent( event );
00188 }
00189 }
00190
00191
00192
00193
00194 void wxContour_ButtonsBar :: sendEnvent( WXTYPE theEventType )
00195 {
00196 wxCommandEvent cevent( theEventType, GetId() );
00197 cevent.SetEventObject( this );
00198 _eventHandler->ProcessEvent( cevent );
00199 }
00200
00201
00202
00203
00204
00205
00206
00207
00208
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219 void wxContour_ButtonsBar :: setWxEventHandler( wxEvtHandler * theEventHandler )
00220 {
00221 _eventHandler = theEventHandler;
00222 }
00223
00224
00225
00226
00227
00228