2 //----------------------------------------------------------------------------------------------------------------
3 // Class definition include
4 //----------------------------------------------------------------------------------------------------------------
5 #include "wxContour_ButtonsBar.h"
7 //----------------------------------------------------------------------------------------------------------------
8 // Class implementation
9 //----------------------------------------------------------------------------------------------------------------
10 /** @file wxConceptControl.cxx */
13 //------------------------------------------------------------------------------------------------------------
15 //------------------------------------------------------------------------------------------------------------
16 #include "wxContour_ActionCommandsID.h"
18 #include "wx/toolbar.h"
21 #include "wx/filedlg.h"
22 #include "wx/spinctrl.h"
23 #include "wx/srchctrl.h"
25 //------------------------------------------------------------------------------------------------------------
26 // Generated events declaration and definition
27 //------------------------------------------------------------------------------------------------------------
29 //------------------------------------------------------------------------------------------------------------
30 // Constructors & Destructors
31 //------------------------------------------------------------------------------------------------------------
33 wxContour_ButtonsBar :: wxContour_ButtonsBar( wxWindow* parent, wxWindowID id, const wxPoint& pos , const wxSize& size, long style, const wxString& name )
34 //:wxToolBar(parent, id, pos, size, style, name)
35 :wxPanel( parent, id)//, pos, size, style, name)
37 //SetToolBitmapSize(wxSize(16,16));
40 wxString string_create(wxContour_ActionCommandsID::TOOL_CODES[wxContour_ActionCommandsID::CREATE_TOOL] , wxConvUTF8);
42 _createContour_Button = new wxButton( this,
51 // _createContour_Button->SetToolTip(_T("CTRL-N"));
52 Connect( _createContour_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
55 wxString string_delete(wxContour_ActionCommandsID::TOOL_CODES[wxContour_ActionCommandsID::DELETE_TOOL] , wxConvUTF8);
56 _delete_Button = new wxButton( this, -1, _T("+ Delete"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, string_delete );
57 _delete_Button->SetToolTip(_T("BACK SPACE or DELETE key"));
58 Connect( _delete_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
61 _hideContour_Button = new wxButton( this, -1, "Hide Contour", wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::HIDE_TOOL );
62 Connect( _hideContour_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
64 _show_Button = new wxButton( this, -1, _T("Show"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::SHOW_TOOL );
65 Connect( _show_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
67 wxString string_copy(wxContour_ActionCommandsID::TOOL_CODES[wxContour_ActionCommandsID::COPY_TOOL] , wxConvUTF8);
69 _copy_Button = new wxButton( this, -1, _T("Copy"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, string_copy );
70 _copy_Button->SetToolTip(_T("CTRL-C"));
71 Connect( _copy_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
73 wxString string_paste(wxContour_ActionCommandsID::TOOL_CODES[wxContour_ActionCommandsID::PASTE_TOOL] , wxConvUTF8);
75 _paste_Button = new wxButton( this, -1, _T("Paste"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, string_paste );
76 _paste_Button->SetToolTip(_T("CTRL-V"));
77 Connect( _paste_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
79 wxString string_change(wxContour_ActionCommandsID::TOOL_CODES[wxContour_ActionCommandsID::CHANGE_TOOL] , wxConvUTF8);
80 _change_Button = new wxButton( this, -1, _T(" <--> "), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, string_change );
81 _change_Button->SetToolTip(_T("CTRL-K"));
82 Connect( _change_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
84 wxString string_save(wxContour_ActionCommandsID::TOOL_CODES[wxContour_ActionCommandsID::SAVE_TOOL] , wxConvUTF8);
85 _save_Button = new wxButton( this, -1, _T("Save"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, string_save );
86 _save_Button->SetToolTip(_T("CTRL-S"));
87 Connect( _save_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
90 wxString string_open(wxContour_ActionCommandsID::TOOL_CODES[wxContour_ActionCommandsID::OPEN_TOOL] , wxConvUTF8);
91 _open_Button = new wxButton( this, -1, _T("Open"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, string_open );
92 _open_Button->SetToolTip(_T("CTRL-O"));
93 Connect( _open_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
95 wxString string_spread(wxContour_ActionCommandsID::TOOL_CODES[wxContour_ActionCommandsID::SPREAD_TOOL] , wxConvUTF8);
96 _spread_Button = new wxButton( this, -1, _T("+ Spread"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, string_spread );
97 // _spread_Button->SetToolTip(_T("CTRL-XXXXXXX"));
98 Connect( _spread_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
100 wxString string_automatiqueSegmentation(wxContour_ActionCommandsID::TOOL_CODES[wxContour_ActionCommandsID::AUTOMATIQUESEGMENTATION_TOOL] , wxConvUTF8);
101 _automatiqueSegmentation_Button = new wxButton( this, -1, _T("+ Segmentation"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, string_automatiqueSegmentation );
102 // _automatiqueSegmentation_Button->SetToolTip(_T("CTRL-XXXXXXX"));
103 Connect( _automatiqueSegmentation_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
105 wxString string_informationcontour(wxContour_ActionCommandsID::TOOL_CODES[wxContour_ActionCommandsID::INFORMATIONCONTOUR_TOOL] , wxConvUTF8);
106 _informationContour_Button = new wxButton( this, -1, _T("+ Information"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, string_informationcontour );
107 // _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
108 Connect( _informationContour_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
110 wxString string_interfaceconfiguration(wxContour_ActionCommandsID::TOOL_CODES[wxContour_ActionCommandsID::INTERFACECONFIGURATION_TOOL] , wxConvUTF8);
111 _interfaceConfiguration_Button = new wxButton( this, -1, _T("+ Configuration"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, string_interfaceconfiguration );
112 // _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
113 Connect( _interfaceConfiguration_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
115 wxString string_test(wxContour_ActionCommandsID::TOOL_CODES[wxContour_ActionCommandsID::TEST_TOOL] , wxConvUTF8);
116 //Test button Methods A-B-C in Juan Carlos Prieto 22-09-08
117 _interfaceTest_Button = new wxButton( this, -1, _T("+ Test"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, string_test );
118 // _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
119 Connect( _interfaceTest_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
123 _spread_Button = new wxButton( this, -1, _T("Spread"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::SPREAD_TOOL );
124 Connect( _spread_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
125 _select_Button = new wxButton( this, -1, _T("Select"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::SELECT_TOOL );
126 Connect( _select_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
128 _edit_Button = new wxButton( this, -1, _T("Edit"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::EDIT_TOOL );
129 Connect( _edit_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
131 _undo_Button = new wxButton( this, -1, _T("Undo"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::UNDO_TOOL );
132 Connect( _undo_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
134 _redo_Button = new wxButton( this, -1, _T("Redo"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::REDO_TOOL );
135 Connect( _redo_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
137 wxFlexGridSizer * panelSizer = new wxFlexGridSizer(9);
138 panelSizer -> Add( _createContour_Button, 1, wxGROW );
140 panelSizer -> Add( _hideContour_Button, 1, wxGROW );
141 panelSizer -> Add( _show_Button, 1, wxGROW );
143 panelSizer -> Add( _change_Button , 1, wxGROW );
144 panelSizer -> Add( _copy_Button , 1, wxGROW );
145 panelSizer -> Add( _paste_Button , 1, wxGROW );
146 panelSizer -> Add( _delete_Button , 1, wxGROW );
147 panelSizer -> Add( _save_Button , 1, wxGROW );
148 panelSizer -> Add( _open_Button , 1, wxGROW );
149 panelSizer -> Add( _spread_Button , 1, wxGROW );
150 panelSizer -> Add( _automatiqueSegmentation_Button , 1, wxGROW );
151 panelSizer -> Add( _informationContour_Button , 1, wxGROW );
152 panelSizer -> Add( _interfaceConfiguration_Button , 1, wxGROW );
153 panelSizer -> Add( _interfaceTest_Button , 1, wxGROW );
156 panelSizer -> Add( _select_Button, 1, wxGROW );
157 panelSizer -> Add( _edit_Button, 1, wxGROW );
158 panelSizer -> Add( _undo_Button, 1, wxGROW );
159 panelSizer -> Add( _redo_Button, 1, wxGROW );
162 SetSizer( panelSizer );
164 this->AddControl( _createContour_Button );
166 this->AddControl( _hideContour_Button );
168 SetSize( wxSize( 1500, 80));
169 this->SetAutoLayout( true );
173 wxContour_ButtonsBar :: ~wxContour_ButtonsBar( )
175 _eventHandler = NULL;
176 /*delete _createContour_Button;
177 delete _delete_Button;
178 delete _hideContour_Button;
181 delete _paste_Button;
182 delete _spread_Button;
183 delete _select_Button;
186 delete _redo_Button;*/
188 //------------------------------------------------------------------------------------------------------------
189 // Methods for capturing events
190 //------------------------------------------------------------------------------------------------------------
191 void wxContour_ButtonsBar :: onActionButtonPressed( wxCommandEvent& event )
193 if(_eventHandler!=NULL)
195 std::string theStr = std::string( ((wxButton *)event.GetEventObject())->GetName().ToAscii());
196 const char * toolCommand = theStr.c_str();
197 event.SetId( GetId() );
198 event.SetEventObject( this );
199 event.SetClientData( (void *) toolCommand);
200 _eventHandler->ProcessEvent( event );
204 //------------------------------------------------------------------------------------------------------------
205 // Methods for sending events
206 //------------------------------------------------------------------------------------------------------------
207 void wxContour_ButtonsBar :: sendEnvent( WXTYPE theEventType )
209 wxCommandEvent cevent( theEventType, GetId() );
210 cevent.SetEventObject( this );
211 _eventHandler->ProcessEvent( cevent );
215 //------------------------------------------------------------------------------------------------------------
216 // Attributes getters and setters
217 //------------------------------------------------------------------------------------------------------------
220 //------------------------------------------------------------------------------------------------------------
221 // Other functional methods
222 //------------------------------------------------------------------------------------------------------------
224 //------------------------------------------------------------------------------------------------------------
226 //------------------------------------------------------------------------------------------------------------
228 //------------------------------------------------------------------------------------------------------------
229 // Creational and initialization methods
230 //------------------------------------------------------------------------------------------------------------
232 void wxContour_ButtonsBar :: setWxEventHandler( wxEvtHandler * theEventHandler )
234 _eventHandler = theEventHandler;
237 //------------------------------------------------------------------------------------------------------------
239 //------------------------------------------------------------------------------------------------------------