]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxContour_ButtonsBar.cxx
Compiling under windows and linux
[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 #include <wx/wx.h>
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         std::string as = (char)wxContour_ActionCommandsID::CREATE_TOOL +"";
39         _createContour_Button = new wxButton( this, -1, _T("+ New Contour"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxString(as.c_str(),wxConvUTF8));
40 //              _createContour_Button->SetToolTip(_T("CTRL-N"));
41                 Connect( _createContour_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
42
43                 as = (char)wxContour_ActionCommandsID::DELETE_TOOL +"";
44                 _delete_Button = new wxButton( this, -1, _T("+ Delete"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
45                 _delete_Button->SetToolTip(_T("BACK SPACE or DELETE key"));
46                 Connect( _delete_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
47
48 /*              
49                 _hideContour_Button = new wxButton( this, -1, "Hide Contour", wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::HIDE_TOOL );
50                 Connect( _hideContour_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
51
52                 _show_Button = new wxButton( this, -1, _T("Show"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::SHOW_TOOL );
53                 Connect( _show_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
54 */
55                 as = (char)wxContour_ActionCommandsID::COPY_TOOL +"";
56                 _copy_Button = new wxButton( this, -1, _T("Copy"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
57                 _copy_Button->SetToolTip(_T("CTRL-C"));
58                 Connect( _copy_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
59
60                 as = (char)wxContour_ActionCommandsID::PASTE_TOOL +"";
61                 _paste_Button = new wxButton( this, -1, _T("Paste"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
62                 _paste_Button->SetToolTip(_T("CTRL-V"));
63                 Connect( _paste_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
64
65                 as = (char)wxContour_ActionCommandsID::CHANGE_TOOL +"";
66                 _change_Button = new wxButton( this, -1, _T("    <-->  "), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
67                 _change_Button->SetToolTip(_T("CTRL-K"));
68                 Connect( _change_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
69
70                 as = (char)wxContour_ActionCommandsID::SAVE_TOOL +"";
71                 _save_Button = new wxButton( this, -1, _T("Save"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
72                 _save_Button->SetToolTip(_T("CTRL-S"));
73                 Connect( _save_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
74
75                 as = (char)wxContour_ActionCommandsID::OPEN_TOOL +"";
76                 _open_Button = new wxButton( this, -1, _T("Open"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
77                 _open_Button->SetToolTip(_T("CTRL-O"));
78                 Connect( _open_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
79
80                 as = (char)wxContour_ActionCommandsID::SPREAD_TOOL +"";
81                 _spread_Button = new wxButton( this, -1, _T("+ Spread"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
82 //              _spread_Button->SetToolTip(_T("CTRL-XXXXXXX"));
83                 Connect( _spread_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
84
85                 as = (char)wxContour_ActionCommandsID::AUTOMATIQUESEGMENTATION_TOOL +"";
86                 _automatiqueSegmentation_Button = new wxButton( this, -1, _T("+ Segmentation"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
87 //              _automatiqueSegmentation_Button->SetToolTip(_T("CTRL-XXXXXXX"));
88                 Connect( _automatiqueSegmentation_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
89
90                 as = (char)wxContour_ActionCommandsID::INFORMATIONCONTOUR_TOOL +"";
91                 _informationContour_Button = new wxButton( this, -1, _T("+ Information"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
92 //              _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
93                 Connect( _informationContour_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
94
95                 as = (char)wxContour_ActionCommandsID::INTERFACECONFIGURATION_TOOL +"";
96                 _interfaceConfiguration_Button = new wxButton( this, -1, _T("+ Configuration"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
97 //              _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
98                 Connect( _interfaceConfiguration_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
99
100
101 //Test button Methods A-B-C in  Juan Carlos Prieto 22-09-08
102                 as = (char)wxContour_ActionCommandsID::TEST_TOOL +"";
103                 _interfaceTest_Button = new wxButton( this, -1, _T("+ Test"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
104 //              _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
105                 Connect( _interfaceTest_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
106
107
108 /*
109                 _spread_Button = new wxButton( this, -1, _T("Spread"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::SPREAD_TOOL );
110                 Connect( _spread_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
111                 _select_Button = new wxButton( this, -1, _T("Select"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::SELECT_TOOL );
112                 Connect( _select_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
113
114                 _edit_Button = new wxButton( this, -1, _T("Edit"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::EDIT_TOOL );
115                 Connect( _edit_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
116
117                 _undo_Button = new wxButton( this, -1, _T("Undo"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::UNDO_TOOL );
118                 Connect( _undo_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
119
120                 _redo_Button = new wxButton( this, -1, _T("Redo"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::REDO_TOOL );
121                 Connect( _redo_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
122 */
123                 wxFlexGridSizer * panelSizer = new wxFlexGridSizer(9);
124                 panelSizer -> Add( _createContour_Button, 1, wxGROW );
125 /*
126                 panelSizer -> Add( _hideContour_Button, 1, wxGROW );
127                 panelSizer -> Add( _show_Button, 1, wxGROW );
128 */
129                 panelSizer -> Add( _change_Button       , 1, wxGROW );
130                 panelSizer -> Add( _copy_Button         , 1, wxGROW );
131                 panelSizer -> Add( _paste_Button        , 1, wxGROW );
132                 panelSizer -> Add( _delete_Button       , 1, wxGROW );
133                 panelSizer -> Add( _save_Button         , 1, wxGROW );
134                 panelSizer -> Add( _open_Button         , 1, wxGROW );
135                 panelSizer -> Add( _spread_Button       , 1, wxGROW );
136                 panelSizer -> Add( _automatiqueSegmentation_Button      , 1, wxGROW );
137                 panelSizer -> Add( _informationContour_Button           , 1, wxGROW );
138                 panelSizer -> Add( _interfaceConfiguration_Button       , 1, wxGROW );
139                 panelSizer -> Add( _interfaceTest_Button        , 1, wxGROW );
140                 
141 /*
142                 panelSizer -> Add( _select_Button, 1, wxGROW );
143                 panelSizer -> Add( _edit_Button, 1, wxGROW );
144                 panelSizer -> Add( _undo_Button, 1, wxGROW );
145                 panelSizer -> Add( _redo_Button, 1, wxGROW );
146 */
147                 
148                 SetSizer( panelSizer );
149 /*
150                 this->AddControl( _createContour_Button );
151                 AddSeparator();
152                 this->AddControl( _hideContour_Button );
153 */
154                 SetSize( wxSize( 1500, 80));
155                 this->SetAutoLayout( true );
156                 this->Layout();         
157         }
158
159         wxContour_ButtonsBar :: ~wxContour_ButtonsBar(  )
160         {
161                 _eventHandler = NULL;
162                 /*delete        _createContour_Button;
163                 delete  _delete_Button;
164                 delete  _hideContour_Button;
165                 delete  _show_Button;
166                 delete  _copy_Button;
167                 delete  _paste_Button;
168                 delete  _spread_Button;
169                 delete  _select_Button;
170                 delete  _edit_Button;
171                 delete  _undo_Button;
172                 delete  _redo_Button;*/         
173         }
174         //------------------------------------------------------------------------------------------------------------
175         // Methods for capturing events
176         //------------------------------------------------------------------------------------------------------------
177         void wxContour_ButtonsBar :: onActionButtonPressed( wxCommandEvent& event )
178         {
179                 if(_eventHandler!=NULL)
180                 {
181                         std::string theStr = std::string( ((wxButton *)event.GetEventObject())->GetName().ToAscii());
182                         const char * toolCommand = theStr.c_str();
183                         event.SetId( GetId() );
184                         event.SetEventObject( this );
185                         event.SetClientData( (void *) toolCommand);
186                         _eventHandler->ProcessEvent( event );
187                 }
188         }               
189         
190         //------------------------------------------------------------------------------------------------------------
191         //  Methods for sending events
192         //------------------------------------------------------------------------------------------------------------
193         void wxContour_ButtonsBar :: sendEnvent( WXTYPE theEventType )
194         {
195                 wxCommandEvent cevent( theEventType, GetId() );
196                 cevent.SetEventObject( this );
197                 _eventHandler->ProcessEvent( cevent );
198         }
199
200
201         //------------------------------------------------------------------------------------------------------------
202         //  Attributes getters and setters
203         //------------------------------------------------------------------------------------------------------------
204
205         
206         //------------------------------------------------------------------------------------------------------------
207         //  Other functional methods
208         //------------------------------------------------------------------------------------------------------------
209
210         //------------------------------------------------------------------------------------------------------------
211         //  Private methods
212         //------------------------------------------------------------------------------------------------------------
213
214         //------------------------------------------------------------------------------------------------------------
215         // Creational and initialization methods
216         //------------------------------------------------------------------------------------------------------------
217
218         void wxContour_ButtonsBar :: setWxEventHandler( wxEvtHandler * theEventHandler )
219         {
220                 _eventHandler = theEventHandler;
221         }
222         
223         //------------------------------------------------------------------------------------------------------------
224         // Attributtes
225         //------------------------------------------------------------------------------------------------------------
226         
227