]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/button.cxx
creaButtonContainer & creaPanelButtonContainer: Updates in doxygen documentation...
[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                 Button::~Button( )
33                 {
34                 }
35                 // ----------------------------------------------------------------------------------
36                 StringType
37                 Button::GetButtonName( )
38                 {
39                         return ( this->m_ButtonPair->first->first );
40                 }
41                 // ----------------------------------------------------------------------------------
42                 StringType
43                 Button::GetIconPath( )
44                 {
45                         return ( this->m_ButtonPair->first->second );
46                 }
47                 // ----------------------------------------------------------------------------------
48                 StringType
49                 Button::GetDescription( )
50                 {
51                         return ( this->m_ButtonPair->second->first );
52                 }
53                 // ----------------------------------------------------------------------------------
54                 void
55                 Button::Execute( )
56                 {
57                         try
58                         {
59                                 TFunctor* vTable[ ] =
60                                 { this->m_ButtonPair->second->second };
61                                 vTable[ 0 ]->Call( this->m_ButtonPair->first->first );
62                         }//yrt
63                         catch ( const std::exception& e )
64                         {
65                                 std::cerr << "Button::Execute( ) exception: " << e.what( ) << std::endl;
66                         }//hctac
67                 }
68         // ----------------------------------------------------------------------------------
69         }//ecapseman
70 }//ecapseman