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_ActionCommnadsID.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, -1, _T("+ New Contour"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::CREATE_TOOL );
40 // _createContour_Button->SetToolTip(_T("CTRL-N"));
41 Connect( _createContour_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
43 _delete_Button = new wxButton( this, -1, _T("+ Delete"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::DELETE_TOOL );
44 _delete_Button->SetToolTip(_T("BACK SPACE or DELETE key"));
45 Connect( _delete_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
48 _hideContour_Button = new wxButton( this, -1, "Hide Contour", wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::HIDE_TOOL );
49 Connect( _hideContour_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
51 _show_Button = new wxButton( this, -1, _T("Show"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::SHOW_TOOL );
52 Connect( _show_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
54 _copy_Button = new wxButton( this, -1, _T("Copy"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::COPY_TOOL );
55 _copy_Button->SetToolTip(_T("CTRL-C"));
56 Connect( _copy_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
58 _paste_Button = new wxButton( this, -1, _T("Paste"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::PASTE_TOOL );
59 _paste_Button->SetToolTip(_T("CTRL-V"));
60 Connect( _paste_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
62 _change_Button = new wxButton( this, -1, _T(" <--> "), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::CHANGE_TOOL );
63 _change_Button->SetToolTip(_T("CTRL-K"));
64 Connect( _change_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
66 _save_Button = new wxButton( this, -1, _T("Save"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::SAVE_TOOL );
67 _save_Button->SetToolTip(_T("CTRL-S"));
68 Connect( _save_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
70 _open_Button = new wxButton( this, -1, _T("Open"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::OPEN_TOOL );
71 _open_Button->SetToolTip(_T("CTRL-O"));
72 Connect( _open_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
75 _spread_Button = new wxButton( this, -1, _T("+ Spread"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::SPREAD_TOOL );
76 // _spread_Button->SetToolTip(_T("CTRL-XXXXXXX"));
77 Connect( _spread_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
79 _automatiqueSegmentation_Button = new wxButton( this, -1, _T("+ Segmentation"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::AUTOMATIQUESEGMENTATION_TOOL );
80 // _automatiqueSegmentation_Button->SetToolTip(_T("CTRL-XXXXXXX"));
81 Connect( _automatiqueSegmentation_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
84 _informationContour_Button = new wxButton( this, -1, _T("+ Information"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::INFORMATIONCONTOUR_TOOL );
85 // _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
86 Connect( _informationContour_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
88 _interfaceConfiguration_Button = new wxButton( this, -1, _T("+ Configuration"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::INTERFACECONFIGURATION_TOOL );
89 // _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
90 Connect( _interfaceConfiguration_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
93 //Test button Methods A-B-C in Juan Carlos Prieto 22-09-08
94 _interfaceTest_Button = new wxButton( this, -1, _T("+ Test"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::TEST_TOOL );
95 // _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
96 Connect( _interfaceTest_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
100 _spread_Button = new wxButton( this, -1, _T("Spread"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::SPREAD_TOOL );
101 Connect( _spread_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
102 _select_Button = new wxButton( this, -1, _T("Select"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::SELECT_TOOL );
103 Connect( _select_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
105 _edit_Button = new wxButton( this, -1, _T("Edit"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::EDIT_TOOL );
106 Connect( _edit_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
108 _undo_Button = new wxButton( this, -1, _T("Undo"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::UNDO_TOOL );
109 Connect( _undo_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
111 _redo_Button = new wxButton( this, -1, _T("Redo"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommnadsID::REDO_TOOL );
112 Connect( _redo_Button->GetId(), wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed );
114 wxFlexGridSizer * panelSizer = new wxFlexGridSizer(9);
115 panelSizer -> Add( _createContour_Button, 1, wxGROW );
117 panelSizer -> Add( _hideContour_Button, 1, wxGROW );
118 panelSizer -> Add( _show_Button, 1, wxGROW );
120 panelSizer -> Add( _change_Button , 1, wxGROW );
121 panelSizer -> Add( _copy_Button , 1, wxGROW );
122 panelSizer -> Add( _paste_Button , 1, wxGROW );
123 panelSizer -> Add( _delete_Button , 1, wxGROW );
124 panelSizer -> Add( _save_Button , 1, wxGROW );
125 panelSizer -> Add( _open_Button , 1, wxGROW );
126 panelSizer -> Add( _spread_Button , 1, wxGROW );
127 panelSizer -> Add( _automatiqueSegmentation_Button , 1, wxGROW );
128 panelSizer -> Add( _informationContour_Button , 1, wxGROW );
129 panelSizer -> Add( _interfaceConfiguration_Button , 1, wxGROW );
130 panelSizer -> Add( _interfaceTest_Button , 1, wxGROW );
133 panelSizer -> Add( _select_Button, 1, wxGROW );
134 panelSizer -> Add( _edit_Button, 1, wxGROW );
135 panelSizer -> Add( _undo_Button, 1, wxGROW );
136 panelSizer -> Add( _redo_Button, 1, wxGROW );
139 SetSizer( panelSizer );
141 this->AddControl( _createContour_Button );
143 this->AddControl( _hideContour_Button );
145 SetSize( wxSize( 1500, 80));
146 this->SetAutoLayout( true );
150 wxContour_ButtonsBar :: ~wxContour_ButtonsBar( )
152 _eventHandler = NULL;
153 /*delete _createContour_Button;
154 delete _delete_Button;
155 delete _hideContour_Button;
158 delete _paste_Button;
159 delete _spread_Button;
160 delete _select_Button;
163 delete _redo_Button;*/
165 //------------------------------------------------------------------------------------------------------------
166 // Methods for capturing events
167 //------------------------------------------------------------------------------------------------------------
168 void wxContour_ButtonsBar :: onActionButtonPressed( wxCommandEvent& event )
170 if(_eventHandler!=NULL)
172 std::string theStr = std::string( ((wxButton *)event.GetEventObject())->GetName().ToAscii());
173 const char * toolCommand = theStr.c_str();
174 event.SetId( GetId() );
175 event.SetEventObject( this );
176 event.SetClientData( (void *) toolCommand);
177 _eventHandler->ProcessEvent( event );
181 //------------------------------------------------------------------------------------------------------------
182 // Methods for sending events
183 //------------------------------------------------------------------------------------------------------------
184 void wxContour_ButtonsBar :: sendEnvent( WXTYPE theEventType )
186 wxCommandEvent cevent( theEventType, GetId() );
187 cevent.SetEventObject( this );
188 _eventHandler->ProcessEvent( cevent );
192 //------------------------------------------------------------------------------------------------------------
193 // Attributes getters and setters
194 //------------------------------------------------------------------------------------------------------------
197 //------------------------------------------------------------------------------------------------------------
198 // Other functional methods
199 //------------------------------------------------------------------------------------------------------------
201 //------------------------------------------------------------------------------------------------------------
203 //------------------------------------------------------------------------------------------------------------
205 //------------------------------------------------------------------------------------------------------------
206 // Creational and initialization methods
207 //------------------------------------------------------------------------------------------------------------
209 void wxContour_ButtonsBar :: setWxEventHandler( wxEvtHandler * theEventHandler )
211 _eventHandler = theEventHandler;
214 //------------------------------------------------------------------------------------------------------------
216 //------------------------------------------------------------------------------------------------------------