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));
39 _createContour_Button = new wxButton( this,
46 wxContour_ActionCommandsID::CREATE_TOOL );
48 // _createContour_Button->SetToolTip(_T("CTRL-N"));
49 Connect( _createContour_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
51 _delete_Button = new wxButton( this, -1, _T("+ Delete"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxContour_ActionCommandsID::DELETE_TOOL );
52 _delete_Button->SetToolTip(_T("BACK SPACE or DELETE key"));
53 Connect( _delete_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
56 _hideContour_Button = new wxButton( this, -1, "Hide Contour", wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::HIDE_TOOL );
57 Connect( _hideContour_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
59 _show_Button = new wxButton( this, -1, _T("Show"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::SHOW_TOOL );
60 Connect( _show_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
62 _copy_Button = new wxButton( this, -1, _T("Copy"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::COPY_TOOL );
63 _copy_Button->SetToolTip(_T("CTRL-C"));
64 Connect( _copy_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
66 _paste_Button = new wxButton( this, -1, _T("Paste"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxContour_ActionCommandsID::PASTE_TOOL );
67 _paste_Button->SetToolTip(_T("CTRL-V"));
68 Connect( _paste_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
70 _change_Button = new wxButton( this, -1, _T(" <--> "), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxContour_ActionCommandsID::CHANGE_TOOL );
71 _change_Button->SetToolTip(_T("CTRL-K"));
72 Connect( _change_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
74 _save_Button = new wxButton( this, -1, _T("Save"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxContour_ActionCommandsID::SAVE_TOOL );
75 _save_Button->SetToolTip(_T("CTRL-S"));
76 Connect( _save_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
78 _open_Button = new wxButton( this, -1, _T("Open"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxContour_ActionCommandsID::OPEN_TOOL );
79 _open_Button->SetToolTip(_T("CTRL-O"));
80 Connect( _open_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
83 _spread_Button = new wxButton( this, -1, _T("+ Spread"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::SPREAD_TOOL );
84 // _spread_Button->SetToolTip(_T("CTRL-XXXXXXX"));
85 Connect( _spread_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
87 _automatiqueSegmentation_Button = new wxButton( this, -1, _T("+ Segmentation"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::AUTOMATIQUESEGMENTATION_TOOL );
88 // _automatiqueSegmentation_Button->SetToolTip(_T("CTRL-XXXXXXX"));
89 Connect( _automatiqueSegmentation_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
92 _informationContour_Button = new wxButton( this, -1, _T("+ Information"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::INFORMATIONCONTOUR_TOOL );
93 // _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
94 Connect( _informationContour_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
96 _interfaceConfiguration_Button = new wxButton( this, -1, _T("+ Configuration"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::INTERFACECONFIGURATION_TOOL );
97 // _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
98 Connect( _interfaceConfiguration_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
101 //Test button Methods A-B-C in Juan Carlos Prieto 22-09-08
102 _interfaceTest_Button = new wxButton( this, -1, _T("+ Test"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::TEST_TOOL );
103 // _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
104 Connect( _interfaceTest_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
108 _spread_Button = new wxButton( this, -1, _T("Spread"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::SPREAD_TOOL );
109 Connect( _spread_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
110 _select_Button = new wxButton( this, -1, _T("Select"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::SELECT_TOOL );
111 Connect( _select_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
113 _edit_Button = new wxButton( this, -1, _T("Edit"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::EDIT_TOOL );
114 Connect( _edit_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
116 _undo_Button = new wxButton( this, -1, _T("Undo"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::UNDO_TOOL );
117 Connect( _undo_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
119 _redo_Button = new wxButton( this, -1, _T("Redo"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::REDO_TOOL );
120 Connect( _redo_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
122 wxFlexGridSizer * panelSizer = new wxFlexGridSizer(9);
123 panelSizer -> Add( _createContour_Button, 1, wxGROW );
125 panelSizer -> Add( _hideContour_Button, 1, wxGROW );
126 panelSizer -> Add( _show_Button, 1, wxGROW );
128 panelSizer -> Add( _change_Button , 1, wxGROW );
129 panelSizer -> Add( _copy_Button , 1, wxGROW );
130 panelSizer -> Add( _paste_Button , 1, wxGROW );
131 panelSizer -> Add( _delete_Button , 1, wxGROW );
132 panelSizer -> Add( _save_Button , 1, wxGROW );
133 panelSizer -> Add( _open_Button , 1, wxGROW );
134 panelSizer -> Add( _spread_Button , 1, wxGROW );
135 panelSizer -> Add( _automatiqueSegmentation_Button , 1, wxGROW );
136 panelSizer -> Add( _informationContour_Button , 1, wxGROW );
137 panelSizer -> Add( _interfaceConfiguration_Button , 1, wxGROW );
138 panelSizer -> Add( _interfaceTest_Button , 1, wxGROW );
141 panelSizer -> Add( _select_Button, 1, wxGROW );
142 panelSizer -> Add( _edit_Button, 1, wxGROW );
143 panelSizer -> Add( _undo_Button, 1, wxGROW );
144 panelSizer -> Add( _redo_Button, 1, wxGROW );
147 SetSizer( panelSizer );
149 this->AddControl( _createContour_Button );
151 this->AddControl( _hideContour_Button );
153 SetSize( wxSize( 1500, 80));
154 this->SetAutoLayout( true );
158 wxContour_ButtonsBar :: ~wxContour_ButtonsBar( )
160 _eventHandler = NULL;
161 /*delete _createContour_Button;
162 delete _delete_Button;
163 delete _hideContour_Button;
166 delete _paste_Button;
167 delete _spread_Button;
168 delete _select_Button;
171 delete _redo_Button;*/
173 //------------------------------------------------------------------------------------------------------------
174 // Methods for capturing events
175 //------------------------------------------------------------------------------------------------------------
176 void wxContour_ButtonsBar :: onActionButtonPressed( wxCommandEvent& event )
178 if(_eventHandler!=NULL)
180 std::string theStr = std::string( ((wxButton *)event.GetEventObject())->GetName().ToAscii());
181 const char * toolCommand = theStr.c_str();
182 event.SetId( GetId() );
183 event.SetEventObject( this );
184 event.SetClientData( (void *) toolCommand);
185 _eventHandler->ProcessEvent( event );
189 //------------------------------------------------------------------------------------------------------------
190 // Methods for sending events
191 //------------------------------------------------------------------------------------------------------------
192 void wxContour_ButtonsBar :: sendEnvent( WXTYPE theEventType )
194 wxCommandEvent cevent( theEventType, GetId() );
195 cevent.SetEventObject( this );
196 _eventHandler->ProcessEvent( cevent );
200 //------------------------------------------------------------------------------------------------------------
201 // Attributes getters and setters
202 //------------------------------------------------------------------------------------------------------------
205 //------------------------------------------------------------------------------------------------------------
206 // Other functional methods
207 //------------------------------------------------------------------------------------------------------------
209 //------------------------------------------------------------------------------------------------------------
211 //------------------------------------------------------------------------------------------------------------
213 //------------------------------------------------------------------------------------------------------------
214 // Creational and initialization methods
215 //------------------------------------------------------------------------------------------------------------
217 void wxContour_ButtonsBar :: setWxEventHandler( wxEvtHandler * theEventHandler )
219 _eventHandler = theEventHandler;
222 //------------------------------------------------------------------------------------------------------------
224 //------------------------------------------------------------------------------------------------------------