]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/button.cxx
no message
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / creaButtonContainer / view / button.cxx
1 /*!
2  * @file button.cxx
3  * @brief Implements the Button class implementation.
4  * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
5  * @date  2011-06-02
6  */
7
8 #include "button.h"
9
10 namespace creaButtonContainer
11 {
12         namespace view
13         {
14                 // ----------------------------------------------------------------------------------
15                 Button::Button( wxWindow* parent, long id, ButtonPair* pair )           
16                 {
17                         this->m_ButtonPair                      = pair;
18                         StringType wXbuttonName         = this->m_ButtonPair->first->first;
19                         StringType wXiconPath           = this->m_ButtonPair->first->second;
20                         StringType wXdescription        = this->m_ButtonPair->second->first;
21                         wxString buttonName( wXbuttonName.c_str( ), wxConvUTF8 );
22                         wxString imageIcon( wXiconPath.c_str( ), wxConvUTF8 );
23                         wxString description( wXdescription.c_str( ), wxConvUTF8 );
24                         //creating the button.
25                         this->Create( parent, id,
26                             wxBitmap( wxImage( imageIcon, wxBITMAP_TYPE_ANY, -1 ) ),
27                             wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW, wxDefaultValidator,
28                             buttonName );
29                         this->SetToolTip( description );
30                 }
31                 
32                 // ----------------------------------------------------------------------------------
33                 Button::~Button( )
34                 {
35                 }
36                 
37                 // ----------------------------------------------------------------------------------
38                 StringType
39                 Button::GetButtonName( )
40                 {
41                         return ( this->m_ButtonPair->first->first );
42                 }
43                 
44                 // ----------------------------------------------------------------------------------
45                 StringType
46                 Button::GetIconPath( )
47                 {
48                         return ( this->m_ButtonPair->first->second );
49                 }
50                 
51                 // ----------------------------------------------------------------------------------
52                 StringType
53                 Button::GetDescription( )
54                 {
55                         return ( this->m_ButtonPair->second->first );
56                 }
57                 
58                 // ----------------------------------------------------------------------------------
59                 void
60                 Button::Execute( )
61                 {
62                         try
63                         {
64                                 TFunctor* vTable[ ] =
65                                 { this->m_ButtonPair->second->second };
66                                 vTable[ 0 ]->Call( this->m_ButtonPair->first->first );
67                         }//yrt
68                         catch ( const std::exception& e )
69                         {
70                                 std::cerr << "Button::Execute( ) exception: " << e.what( ) << std::endl;
71                         }//hctac
72                 }
73         // ----------------------------------------------------------------------------------
74         }//ecapseman
75 }//ecapseman