]> Creatis software - creaContours.git/blob - lib/Interface_ManagerContour_NDimensions/wxContour_ButtonsBar.cxx
*** empty log message ***
[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_ActionCommnadsID.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         _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 ); 
42
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 ); 
46
47 /*              
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 ); 
50
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 ); 
53 */
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 ); 
57
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 ); 
61
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 ); 
65
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 ); 
69
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 ); 
73
74
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 ); 
78
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 ); 
82
83
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 ); 
87
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 ); 
91
92
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 ); 
97
98
99 /*
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 ); 
104
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 ); 
107
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 ); 
110
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 ); 
113 */
114                 wxFlexGridSizer * panelSizer = new wxFlexGridSizer(9);
115                 panelSizer -> Add( _createContour_Button, 1, wxGROW );
116 /*
117                 panelSizer -> Add( _hideContour_Button, 1, wxGROW );
118                 panelSizer -> Add( _show_Button, 1, wxGROW );
119 */
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 );
131                 
132 /*
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 );
137 */
138                 
139                 SetSizer( panelSizer );
140 /*
141                 this->AddControl( _createContour_Button );
142                 AddSeparator();
143                 this->AddControl( _hideContour_Button );
144 */
145                 SetSize( wxSize( 1500, 80));
146                 this->SetAutoLayout( true );
147                 this->Layout();         
148         }
149
150         wxContour_ButtonsBar :: ~wxContour_ButtonsBar(  )
151         {
152                 _eventHandler = NULL;
153                 /*delete        _createContour_Button;
154                 delete  _delete_Button;
155                 delete  _hideContour_Button;
156                 delete  _show_Button;
157                 delete  _copy_Button;
158                 delete  _paste_Button;
159                 delete  _spread_Button;
160                 delete  _select_Button;
161                 delete  _edit_Button;
162                 delete  _undo_Button;
163                 delete  _redo_Button;*/         
164         }
165         //------------------------------------------------------------------------------------------------------------
166         // Methods for capturing events
167         //------------------------------------------------------------------------------------------------------------
168         void wxContour_ButtonsBar :: onActionButtonPressed( wxCommandEvent& event )
169         {
170                 if(_eventHandler!=NULL)
171                 {
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 );
178                 }
179         }               
180         
181         //------------------------------------------------------------------------------------------------------------
182         //  Methods for sending events
183         //------------------------------------------------------------------------------------------------------------
184         void wxContour_ButtonsBar :: sendEnvent( WXTYPE theEventType )
185         {
186                 wxCommandEvent cevent( theEventType, GetId() );
187                 cevent.SetEventObject( this );
188                 _eventHandler->ProcessEvent( cevent );
189         }
190
191
192         //------------------------------------------------------------------------------------------------------------
193         //  Attributes getters and setters
194         //------------------------------------------------------------------------------------------------------------
195
196         
197         //------------------------------------------------------------------------------------------------------------
198         //  Other functional methods
199         //------------------------------------------------------------------------------------------------------------
200
201         //------------------------------------------------------------------------------------------------------------
202         //  Private methods
203         //------------------------------------------------------------------------------------------------------------
204
205         //------------------------------------------------------------------------------------------------------------
206         // Creational and initialization methods
207         //------------------------------------------------------------------------------------------------------------
208
209         void wxContour_ButtonsBar :: setWxEventHandler( wxEvtHandler * theEventHandler )
210         {
211                 _eventHandler = theEventHandler;
212         }
213         
214         //------------------------------------------------------------------------------------------------------------
215         // Attributtes
216         //------------------------------------------------------------------------------------------------------------
217         
218