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