wxContour_ButtonsBar.cxx

Go to the documentation of this file.
00001 
00002 //----------------------------------------------------------------------------------------------------------------
00003 // Class definition include
00004 //----------------------------------------------------------------------------------------------------------------
00005 #include "wxContour_ButtonsBar.h"
00006 
00007 //----------------------------------------------------------------------------------------------------------------
00008 // Class implementation
00009 //----------------------------------------------------------------------------------------------------------------
00013 //------------------------------------------------------------------------------------------------------------
00014 // Includes
00015 //------------------------------------------------------------------------------------------------------------
00016 #include "wxContour_ActionCommandsID.h"
00017 
00018 #include <string>
00019 #include "wx/toolbar.h"
00020 #include "wx/log.h"
00021 #include "wx/image.h"
00022 #include "wx/filedlg.h"
00023 #include "wx/spinctrl.h"
00024 #include "wx/srchctrl.h"
00025 #include <wx/wx.h>
00026 //------------------------------------------------------------------------------------------------------------
00027 // Generated events declaration and definition
00028 //------------------------------------------------------------------------------------------------------------
00029 
00030         //------------------------------------------------------------------------------------------------------------
00031         // Constructors & Destructors
00032         //------------------------------------------------------------------------------------------------------------
00033 
00034         wxContour_ButtonsBar :: wxContour_ButtonsBar( wxWindow* parent, wxWindowID id, const wxPoint& pos , const wxSize& size, long style, const wxString& name )
00035         //:wxToolBar(parent, id, pos, size, style, name)
00036         :wxPanel( parent, id)//, pos, size, style, name)
00037         {
00038                 //SetToolBitmapSize(wxSize(16,16));
00039         std::string as = (char)wxContour_ActionCommandsID::CREATE_TOOL +"";
00040         _createContour_Button = new wxButton( this, -1, _T("+ New Contour"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxString(as.c_str(),wxConvUTF8));
00041 //              _createContour_Button->SetToolTip(_T("CTRL-N"));
00042                 Connect( _createContour_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00043 
00044                 as = (char)wxContour_ActionCommandsID::DELETE_TOOL +"";
00045                 _delete_Button = new wxButton( this, -1, _T("+ Delete"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
00046                 _delete_Button->SetToolTip(_T("BACK SPACE or DELETE key"));
00047                 Connect( _delete_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00048 
00049 /*              
00050                 _hideContour_Button = new wxButton( this, -1, "Hide Contour", wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::HIDE_TOOL );
00051                 Connect( _hideContour_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00052 
00053                 _show_Button = new wxButton( this, -1, _T("Show"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::SHOW_TOOL );
00054                 Connect( _show_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00055 */
00056                 as = (char)wxContour_ActionCommandsID::COPY_TOOL +"";
00057                 _copy_Button = new wxButton( this, -1, _T("Copy"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
00058                 _copy_Button->SetToolTip(_T("CTRL-C"));
00059                 Connect( _copy_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00060 
00061                 as = (char)wxContour_ActionCommandsID::PASTE_TOOL +"";
00062                 _paste_Button = new wxButton( this, -1, _T("Paste"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
00063                 _paste_Button->SetToolTip(_T("CTRL-V"));
00064                 Connect( _paste_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00065 
00066                 as = (char)wxContour_ActionCommandsID::CHANGE_TOOL +"";
00067                 _change_Button = new wxButton( this, -1, _T("    <-->  "), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
00068                 _change_Button->SetToolTip(_T("CTRL-K"));
00069                 Connect( _change_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00070 
00071                 as = (char)wxContour_ActionCommandsID::SAVE_TOOL +"";
00072                 _save_Button = new wxButton( this, -1, _T("Save"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
00073                 _save_Button->SetToolTip(_T("CTRL-S"));
00074                 Connect( _save_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00075 
00076                 as = (char)wxContour_ActionCommandsID::OPEN_TOOL +"";
00077                 _open_Button = new wxButton( this, -1, _T("Open"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
00078                 _open_Button->SetToolTip(_T("CTRL-O"));
00079                 Connect( _open_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00080 
00081                 as = (char)wxContour_ActionCommandsID::SPREAD_TOOL +"";
00082                 _spread_Button = new wxButton( this, -1, _T("+ Spread"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
00083 //              _spread_Button->SetToolTip(_T("CTRL-XXXXXXX"));
00084                 Connect( _spread_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00085 
00086                 as = (char)wxContour_ActionCommandsID::AUTOMATIQUESEGMENTATION_TOOL +"";
00087                 _automatiqueSegmentation_Button = new wxButton( this, -1, _T("+ Segmentation"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
00088 //              _automatiqueSegmentation_Button->SetToolTip(_T("CTRL-XXXXXXX"));
00089                 Connect( _automatiqueSegmentation_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00090 
00091                 as = (char)wxContour_ActionCommandsID::INFORMATIONCONTOUR_TOOL +"";
00092                 _informationContour_Button = new wxButton( this, -1, _T("+ Information"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
00093 //              _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
00094                 Connect( _informationContour_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00095 
00096                 as = (char)wxContour_ActionCommandsID::INTERFACECONFIGURATION_TOOL +"";
00097                 _interfaceConfiguration_Button = new wxButton( this, -1, _T("+ Configuration"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
00098 //              _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
00099                 Connect( _interfaceConfiguration_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00100 
00101 
00102 //Test button Methods A-B-C in  Juan Carlos Prieto 22-09-08
00103                 as = (char)wxContour_ActionCommandsID::TEST_TOOL +"";
00104                 _interfaceTest_Button = new wxButton( this, -1, _T("+ Test"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator,  wxString(as.c_str(),wxConvUTF8));
00105 //              _informationContour_Button->SetToolTip(_T("CTRL-XXXXXXX"));
00106                 Connect( _interfaceTest_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00107 
00108 
00109 /*
00110                 _spread_Button = new wxButton( this, -1, _T("Spread"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::SPREAD_TOOL );
00111                 Connect( _spread_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00112                 _select_Button = new wxButton( this, -1, _T("Select"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::SELECT_TOOL );
00113                 Connect( _select_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00114 
00115                 _edit_Button = new wxButton( this, -1, _T("Edit"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::EDIT_TOOL );
00116                 Connect( _edit_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00117 
00118                 _undo_Button = new wxButton( this, -1, _T("Undo"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::UNDO_TOOL );
00119                 Connect( _undo_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00120 
00121                 _redo_Button = new wxButton( this, -1, _T("Redo"), wxDefaultPosition, wxDefaultSize, 0,wxDefaultValidator, wxContour_ActionCommandsID::REDO_TOOL );
00122                 Connect( _redo_Button->GetId(),   wxEVT_COMMAND_BUTTON_CLICKED , (wxObjectEventFunction) &wxContour_ButtonsBar:: onActionButtonPressed ); 
00123 */
00124                 wxFlexGridSizer * panelSizer = new wxFlexGridSizer(9);
00125                 panelSizer -> Add( _createContour_Button, 1, wxGROW );
00126 /*
00127                 panelSizer -> Add( _hideContour_Button, 1, wxGROW );
00128                 panelSizer -> Add( _show_Button, 1, wxGROW );
00129 */
00130                 panelSizer -> Add( _change_Button       , 1, wxGROW );
00131                 panelSizer -> Add( _copy_Button         , 1, wxGROW );
00132                 panelSizer -> Add( _paste_Button        , 1, wxGROW );
00133                 panelSizer -> Add( _delete_Button       , 1, wxGROW );
00134                 panelSizer -> Add( _save_Button         , 1, wxGROW );
00135                 panelSizer -> Add( _open_Button         , 1, wxGROW );
00136                 panelSizer -> Add( _spread_Button       , 1, wxGROW );
00137                 panelSizer -> Add( _automatiqueSegmentation_Button      , 1, wxGROW );
00138                 panelSizer -> Add( _informationContour_Button           , 1, wxGROW );
00139                 panelSizer -> Add( _interfaceConfiguration_Button       , 1, wxGROW );
00140                 panelSizer -> Add( _interfaceTest_Button        , 1, wxGROW );
00141                 
00142 /*
00143                 panelSizer -> Add( _select_Button, 1, wxGROW );
00144                 panelSizer -> Add( _edit_Button, 1, wxGROW );
00145                 panelSizer -> Add( _undo_Button, 1, wxGROW );
00146                 panelSizer -> Add( _redo_Button, 1, wxGROW );
00147 */
00148                 
00149                 SetSizer( panelSizer );
00150 /*
00151                 this->AddControl( _createContour_Button );
00152                 AddSeparator();
00153                 this->AddControl( _hideContour_Button );
00154 */
00155                 SetSize( wxSize( 1500, 80));
00156                 this->SetAutoLayout( true );
00157                 this->Layout();         
00158         }
00159 
00160         wxContour_ButtonsBar :: ~wxContour_ButtonsBar(  )
00161         {
00162                 _eventHandler = NULL;
00163                 /*delete        _createContour_Button;
00164                 delete  _delete_Button;
00165                 delete  _hideContour_Button;
00166                 delete  _show_Button;
00167                 delete  _copy_Button;
00168                 delete  _paste_Button;
00169                 delete  _spread_Button;
00170                 delete  _select_Button;
00171                 delete  _edit_Button;
00172                 delete  _undo_Button;
00173                 delete  _redo_Button;*/         
00174         }
00175         //------------------------------------------------------------------------------------------------------------
00176         // Methods for capturing events
00177         //------------------------------------------------------------------------------------------------------------
00178         void wxContour_ButtonsBar :: onActionButtonPressed( wxCommandEvent& event )
00179         {
00180                 if(_eventHandler!=NULL)
00181                 {
00182                         std::string theStr = std::string( ((wxButton *)event.GetEventObject())->GetName().ToAscii());
00183                         const char * toolCommand = theStr.c_str();
00184                         event.SetId( GetId() );
00185                         event.SetEventObject( this );
00186                         event.SetClientData( (void *) toolCommand);
00187                         _eventHandler->ProcessEvent( event );
00188                 }
00189         }               
00190         
00191         //------------------------------------------------------------------------------------------------------------
00192         //  Methods for sending events
00193         //------------------------------------------------------------------------------------------------------------
00194         void wxContour_ButtonsBar :: sendEnvent( WXTYPE theEventType )
00195         {
00196                 wxCommandEvent cevent( theEventType, GetId() );
00197                 cevent.SetEventObject( this );
00198                 _eventHandler->ProcessEvent( cevent );
00199         }
00200 
00201 
00202         //------------------------------------------------------------------------------------------------------------
00203         //  Attributes getters and setters
00204         //------------------------------------------------------------------------------------------------------------
00205 
00206         
00207         //------------------------------------------------------------------------------------------------------------
00208         //  Other functional methods
00209         //------------------------------------------------------------------------------------------------------------
00210 
00211         //------------------------------------------------------------------------------------------------------------
00212         //  Private methods
00213         //------------------------------------------------------------------------------------------------------------
00214 
00215         //------------------------------------------------------------------------------------------------------------
00216         // Creational and initialization methods
00217         //------------------------------------------------------------------------------------------------------------
00218 
00219         void wxContour_ButtonsBar :: setWxEventHandler( wxEvtHandler * theEventHandler )
00220         {
00221                 _eventHandler = theEventHandler;
00222         }
00223         
00224         //------------------------------------------------------------------------------------------------------------
00225         // Attributtes
00226         //------------------------------------------------------------------------------------------------------------
00227         
00228 

Generated on Wed Jun 27 23:28:32 2012 for creaContours_lib by  doxygen 1.5.7.1