]> Creatis software - creaMaracasVisu.git/blob
7477a38afb1abb3f9d5969b9792188218238a2fc
[creaMaracasVisu.git] /
1 /*!
2  * @file creaPanelButtonContainer.h
3  * @brief implements PanelButtonContainer class
4  * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
5  * @date  2011-06-02
6  */
7
8 #include "creaPanelButtonContainer.h"
9
10 namespace creaPanelButtonContainer
11 {
12         BEGIN_EVENT_TABLE(PanelButtonContainer,wxPanel)
13         //(*EventTable(ButtonContainerPanel)
14         //*)
15         END_EVENT_TABLE()
16         // ----------------------------------------------------------------------------------
17         typedef creaButtonContainer::model::TConcreteFunctor< PanelButtonContainer >
18             TConcreteFunctor;
19         // ----------------------------------------------------------------------------------
20         PanelButtonContainer::PanelButtonContainer( wxWindow* parent,
21             ButtonContainerSettings* bcSettings ) :
22                     wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize,
23                         wxDEFAULT_FRAME_STYLE, _T("creaPanelButtonContainer") )
24         {
25                 this->m_ButtonContainerSettings = bcSettings;
26                 this->m_ButtonPanel = new wxPanel( this );
27
28                 //Class that manages the event!!!
29                 TConcreteFunctor* functor = new TConcreteFunctor( this,
30                     &PanelButtonContainer::GenericButtonEvent );
31                 //end of the event definition
32
33                 this->m_ButtonContainerPanel = new ButtonContainerPanel( this,
34                     this->m_ButtonContainerSettings->GetButtonGroupSettings( functor ) );
35
36                 //Using AuiManager to Manage the Panels
37                 this->m_AuiManager = new wxAuiManager( this, wxAUI_MGR_DEFAULT );
38
39                 this->m_AuiManager->AddPane(
40                     this->m_ButtonPanel,
41                     wxAuiPaneInfo( ).Name( _T("ButtonPanel") ).Caption( _("Panel") ). CaptionVisible(
42                         true ).CloseButton( false ).Bottom( ).Resizable( true ) );
43                 //CartoButtonPanel Management
44                 this->m_AuiManager->AddPane(
45                     this->m_ButtonContainerPanel,
46                     wxAuiPaneInfo( ).Name( _T("creaButtonContainer") ).Caption(
47                         _("creaButtonContainer") ). CaptionVisible( false ).CloseButton(
48                         false ).Center( ).Resizable( true ) );
49                 this->m_AuiManager->Update( );
50         }
51         // ----------------------------------------------------------------------------------
52         PanelButtonContainer::~PanelButtonContainer( )
53         {
54         }
55         // ----------------------------------------------------------------------------------
56         void
57         PanelButtonContainer::UpdatePanel( const std::string &buttonName )
58         {
59                 try
60                 {
61                         //Hiding the last CartoSettingsPanel
62                         this->m_ButtonPanel->Show( false );
63                         //Finding the CartoSettingsPanel of the ButtonClicket
64                         this->m_ButtonPanel = this->m_ButtonContainerSettings->GetPanelButton(
65                             buttonName );
66                         //changing the parent of the panel!
67                         if ( this->m_ButtonPanel->GetParent( ) != this )
68                         {
69                                 this->m_ButtonPanel->Reparent( this );
70                         }//fi
71                         //CartoSettingsPanel Management
72                         this->m_AuiManager->GetPane( _T("ButtonPanel") ).window
73                             = this->m_ButtonPanel;
74                         //Updating the manager
75                         this->m_AuiManager->Update( );
76                 }//yrt
77                 catch ( const std::exception& e )
78                 {
79                         std::cerr
80                             << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
81                             << "exception: " << e.what( ) << std::endl;
82                         std::cout << "Maybe the panel of the button is NULL" << std::endl;
83                         exit( 1 );
84                 }//hctac
85         }
86         // ----------------------------------------------------------------------------------
87         void
88         PanelButtonContainer::GenericButtonEvent( const std::string &buttonName )
89         {
90                 this->UpdatePanel( buttonName );
91         }
92 // ----------------------------------------------------------------------------------
93 }//ecapseman
94
95