]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxContour_ButtonsBar.cxx
Some fixes for wxString vs std::string pb.
[creaContours.git] / lib / Interface_ManagerContour_NDimensions / wxContour_ButtonsBar.cxx
1
2 //----------------------------------------------------------------------------------------------------------------
3 // Class definition include
4 //----------------------------------------------------------------------------------------------------------------
5 #include "wxContour_ButtonsBar.h"
6
7 //----------------------------------------------------------------------------------------------------------------
8 // Class implementation
9 //----------------------------------------------------------------------------------------------------------------
10 /** @file wxConceptControl.cxx */
11
12
13 //------------------------------------------------------------------------------------------------------------
14 // Includes
15 //------------------------------------------------------------------------------------------------------------
16 #include "wxContour_ActionCommandsID.h"
17
18 #include "wx/toolbar.h"
19 #include "wx/log.h"
20 #include "wx/image.h"
21 #include "wx/filedlg.h"
22 #include "wx/spinctrl.h"
23 #include "wx/srchctrl.h"
24
25 //------------------------------------------------------------------------------------------------------------
26 // Generated events declaration and definition
27 //------------------------------------------------------------------------------------------------------------
28
29         //------------------------------------------------------------------------------------------------------------
30         // Constructors & Destructors
31         //------------------------------------------------------------------------------------------------------------
32
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)
36         {
37                 //SetToolBitmapSize(wxSize(16,16));
38         
39         
40         wxString string_create(wxContour_ActionCommandsID::TOOL_CODES[wxContour_ActionCommandsID::CREATE_TOOL] , wxConvUTF8);
41                 
42         _createContour_Button = new wxButton( this, 
43            -1, 
44            _T("+ New Contour"), 
45            wxDefaultPosition, 
46            wxDefaultSize, 
47            0, 
48            wxDefaultValidator, 
49            string_create );
50         
51 //              _createContour_Button->SetToolTip(_T("CTRL-N"));
52                 Connect( _createContour_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
53
54
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 ); 
59
60 /*              
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 ); 
63
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 ); 
66 */
67         wxString string_copy(wxContour_ActionCommandsID::TOOL_CODES[wxContour_ActionCommandsID::COPY_TOOL] , wxConvUTF8);
68
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 );
72                 
73         wxString string_paste(wxContour_ActionCommandsID::TOOL_CODES[wxContour_ActionCommandsID::PASTE_TOOL] , wxConvUTF8);              
74
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 ); 
78
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 ); 
83
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 );
88                 
89                 
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 ); 
94
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 ); 
99
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 ); 
104
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 ); 
109
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 ); 
114
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 ); 
120
121
122 /*
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 ); 
127
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 ); 
130
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 ); 
133
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 ); 
136 */
137                 wxFlexGridSizer * panelSizer = new wxFlexGridSizer(9);
138                 panelSizer -> Add( _createContour_Button, 1, wxGROW );
139 /*
140                 panelSizer -> Add( _hideContour_Button, 1, wxGROW );
141                 panelSizer -> Add( _show_Button, 1, wxGROW );
142 */
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 );
154                 
155 /*
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 );
160 */
161                 
162                 SetSizer( panelSizer );
163 /*
164                 this->AddControl( _createContour_Button );
165                 AddSeparator();
166                 this->AddControl( _hideContour_Button );
167 */
168                 SetSize( wxSize( 1500, 80));
169                 this->SetAutoLayout( true );
170                 this->Layout();         
171         }
172
173         wxContour_ButtonsBar :: ~wxContour_ButtonsBar(  )
174         {
175                 _eventHandler = NULL;
176                 /*delete        _createContour_Button;
177                 delete  _delete_Button;
178                 delete  _hideContour_Button;
179                 delete  _show_Button;
180                 delete  _copy_Button;
181                 delete  _paste_Button;
182                 delete  _spread_Button;
183                 delete  _select_Button;
184                 delete  _edit_Button;
185                 delete  _undo_Button;
186                 delete  _redo_Button;*/         
187         }
188         //------------------------------------------------------------------------------------------------------------
189         // Methods for capturing events
190         //------------------------------------------------------------------------------------------------------------
191         void wxContour_ButtonsBar :: onActionButtonPressed( wxCommandEvent& event )
192         {
193                 if(_eventHandler!=NULL)
194                 {
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 );
201                 }
202         }               
203         
204         //------------------------------------------------------------------------------------------------------------
205         //  Methods for sending events
206         //------------------------------------------------------------------------------------------------------------
207         void wxContour_ButtonsBar :: sendEnvent( WXTYPE theEventType )
208         {
209                 wxCommandEvent cevent( theEventType, GetId() );
210                 cevent.SetEventObject( this );
211                 _eventHandler->ProcessEvent( cevent );
212         }
213
214
215         //------------------------------------------------------------------------------------------------------------
216         //  Attributes getters and setters
217         //------------------------------------------------------------------------------------------------------------
218
219         
220         //------------------------------------------------------------------------------------------------------------
221         //  Other functional methods
222         //------------------------------------------------------------------------------------------------------------
223
224         //------------------------------------------------------------------------------------------------------------
225         //  Private methods
226         //------------------------------------------------------------------------------------------------------------
227
228         //------------------------------------------------------------------------------------------------------------
229         // Creational and initialization methods
230         //------------------------------------------------------------------------------------------------------------
231
232         void wxContour_ButtonsBar :: setWxEventHandler( wxEvtHandler * theEventHandler )
233         {
234                 _eventHandler = theEventHandler;
235         }
236         
237         //------------------------------------------------------------------------------------------------------------
238         // Attributtes
239         //------------------------------------------------------------------------------------------------------------
240         
241