]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/creaPanelButtonContainer.cxx
#2516 creaMaracasVisu Feature New Normal - creaPanelButtonContainer ListPanel with...
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / creaPanelButtonContainer / creaPanelButtonContainer.cxx
index c2b954ac41e0fa50e77841d1c12599095feb6591..a7a0fc1c689e98f9c4c75330042c4836793ee391 100644 (file)
@@ -1,8 +1,33 @@
+/*# ---------------------------------------------------------------------
+ #
+ # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
+ #                        pour la Sant�)
+ # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
+ # Previous Authors : Laurent Guigues, Jean-Pierre Roux
+ # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
+ #
+ #  This software is governed by the CeCILL-B license under French law and
+ #  abiding by the rules of distribution of free software. You can  use,
+ #  modify and/ or redistribute the software under the terms of the CeCILL-B
+ #  license as circulated by CEA, CNRS and INRIA at the following URL
+ #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
+ #  or in the file LICENSE.txt.
+ #
+ #  As a counterpart to the access to the source code and  rights to copy,
+ #  modify and redistribute granted by the license, users are provided only
+ #  with a limited warranty  and the software's author,  the holder of the
+ #  economic rights,  and the successive licensors  have only  limited
+ #  liability.
+ #
+ #  The fact that you are presently reading this means that you have had
+ #  knowledge of the CeCILL-B license and that you accept its terms.
+ # ------------------------------------------------------------------------ */
+
 /*!
  * @file creaPanelButtonContainer.h
  * @brief implements PanelButtonContainer class
  * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
- * @date  2011-05-28
+ * @date  2011-06-02
  */
 
 #include "creaPanelButtonContainer.h"
 namespace creaPanelButtonContainer
 {
        BEGIN_EVENT_TABLE(PanelButtonContainer,wxPanel)
-       //(*EventTable(ButtonContainerPanel)
-       //*)
+//EVT_LIST_ITEM_SELECTED(-1, ListWx::ListEvent)
+
+//(*EventTable(ButtonContainerPanel)
+//*)
        END_EVENT_TABLE()
-       // ----------------------------------------------------------------------------------
-       typedef creaButtonContainer::model::TConcreteFunctor< PanelButtonContainer >
-           TConcreteFunctor;
-       // ----------------------------------------------------------------------------------
-       PanelButtonContainer::PanelButtonContainer( wxWindow* parent,
-           ButtonContainerSettings* bcSettings ) :
-                   wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize,
-                       wxDEFAULT_FRAME_STYLE, _T("creaPanelButtonContainer") )
+// ----------------------------------------------------------------------------------
+       typedef creaButtonContainer::model::TConcreteFunctor< PanelButtonContainer > TConcreteFunctor;
+// ----------------------------------------------------------------------------------
+       PanelButtonContainer::PanelButtonContainer(wxWindow* parent,
+                       ButtonContainerSettings* bcSettings, int type)
+                       : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize,
+                                       wxDEFAULT_FRAME_STYLE, _T("creaPanelButtonContainer"))
        {
                this->m_ButtonContainerSettings = bcSettings;
-               this->m_ButtonPanel = new wxPanel( this );
 
-               //Class that manages the cartobutton event!!!
-               TConcreteFunctor* functor = new TConcreteFunctor( this,
-                   &PanelButtonContainer::GenericButtonEvent );
-               //end of the event definition
+               //Using AuiManager to Manage the Panels
+               this->m_AuiManager = new wxAuiManager(this, wxAUI_MGR_DEFAULT);
 
-               this->m_ButtonContainerPanel = new ButtonContainerPanel( this,
-                   this->m_ButtonContainerSettings->GetButtonGroupSettings( functor ) );
+               if (type == 0)
+               {
+                       //Class that manages the event!!!
+                       //EED 20/01/2012
+                       TConcreteFunctor* functor = new TConcreteFunctor(this,
+                                       &PanelButtonContainer::GenericButtonEvent);
+                       //end of the event definition
+                       this->m_EventPanel = new wxPanel(this);
+                       this->m_ButtonContainerPanel = new ButtonContainerPanel(this,
+                                       this->m_ButtonContainerSettings->GetButtonGroupSettings(functor));
+                       //Bottom Panel
+                       this->m_AuiManager->AddPane(this->m_EventPanel,
+                                       wxAuiPaneInfo().Name(_T("EventPanel")).Caption(_("EventPanel")).CaptionVisible(
+                                                       true).MinimizeButton().MaximizeButton().CloseButton(false).Center().Resizable(
+                                                       true));
+                       //Top Panel
+                       this->m_AuiManager->AddPane(this->m_ButtonContainerPanel,
+                                       wxAuiPaneInfo().Name(_T("ButtonContainerPanel")).DefaultPane().Caption(
+                                                       _("ButtonContainerPanel")).PinButton().CaptionVisible(true).CloseButton(
+                                                       false).Center().Resizable(true));
+               }
+               else if (type == 1)
+               {
+                       TConcreteFunctor* lFunctor = new TConcreteFunctor(this,
+                                       &PanelButtonContainer::GenericListEvent);
 
-               //Using AuiManager to Manage the Panels
-               this->m_AuiManager = new wxAuiManager( this, wxAUI_MGR_DEFAULT );
-
-               this->m_AuiManager->AddPane(
-                   this->m_ButtonPanel,
-                   wxAuiPaneInfo( ).Name( _T("ButtonPanel") ).Caption( _("Panel") ). CaptionVisible(
-                       true ).CloseButton( false ).Bottom( ).Resizable( true ) );
-               //CartoButtonPanel Management
-               this->m_AuiManager->AddPane(
-                   this->m_ButtonContainerPanel,
-                   wxAuiPaneInfo( ).Name( _T("creaButtonContainer") ).Caption(
-                       _("creaButtonContainer") ). CaptionVisible( false ).CloseButton(
-                       false ).Center( ).Resizable( true ) );
-               this->m_AuiManager->Update( );
+                       this->m_EventPanel = new wxPanel(this);
+                       std::cout << "tipo 1; new LIstWx" << std::endl;
+
+                       this->m_ListWxPanel = new ListWx(this, -1,
+                                       this->m_ButtonContainerSettings->GetItemsVector(), lFunctor);
+
+                       //Bottom Panel
+                       this->m_AuiManager->AddPane(this->m_EventPanel,
+                                       wxAuiPaneInfo().Name(_T("EventPanel")).Caption(_("EventPanel")).CaptionVisible(
+                                                       true).MinimizeButton().MaximizeButton().CloseButton(false).Center().Resizable(
+                                                       true));
+                       //Top Panel
+                       this->m_AuiManager->AddPane(this->m_ListWxPanel,
+                                       wxAuiPaneInfo().Name(_T("ListContainerPanel")).DefaultPane().Caption(
+                                                       _("ListContainerPanel")).PinButton().CaptionVisible(true).CloseButton(
+                                                       false).Center().Resizable(true));
+               }
+               else if (type == 2)
+               {
+                       TConcreteFunctor* lFunctor = new TConcreteFunctor(this,
+                                       &PanelButtonContainer::GenericListEvent);
+
+                       this->m_EventPanel = new wxPanel(this);
+
+                       this->m_PanelUp = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize,
+                                       wxTAB_TRAVERSAL, _T("ListConfigContainerPanel"));
+                       wxBoxSizer* mainSizer = new wxBoxSizer(wxHORIZONTAL);
+
+                       //=======
+                       wxBoxSizer* listSizer = new wxBoxSizer(wxVERTICAL);
+
+                       //Original List
+                       this->m_ListWxPanel = new ListWx(this->m_PanelUp, -1,
+                                       this->m_ButtonContainerSettings->GetItemsVector(), lFunctor);
+                       this->m_ListWxPanel->Show(false);
+                       //Configurable list
+                       this->m_CurrentWxPanel = new ListWx(this->m_PanelUp, -1, lFunctor);
+                       listSizer->Add(this->m_CurrentWxPanel, 0, wxEXPAND);
+                       listSizer->Add(this->m_ListWxPanel, 0, wxEXPAND);
+                       mainSizer->Add(listSizer, 0, wxEXPAND | wxALL, 7);
+
+                       //=======
+                       //todo change button to bitmap
+                       wxBoxSizer* buttonSizer = new wxBoxSizer(wxVERTICAL);
+
+                       this->m_ConfigButton = new wxButton(this->m_PanelUp, -1, _("Configurar"), wxDefaultPosition,
+                                       wxDefaultSize, 0, wxDefaultValidator, _("Configurar"));
+
+                       buttonSizer->Add(this->m_ConfigButton, 0, wxEXPAND);
+                       mainSizer->Add(buttonSizer, 0, wxEXPAND | wxALL, 14);
+                       //=======
+
+                       this->m_PanelUp->SetSizer(mainSizer);
+
+                       //Bottom Panel
+                       this->m_AuiManager->AddPane(this->m_EventPanel,
+                                       wxAuiPaneInfo().Name(_T("EventPanel")).Caption(_("EventPanel")).CaptionVisible(
+                                                       true).MinimizeButton().MaximizeButton().CloseButton(false).Center().Resizable(
+                                                       true));
+                       //Top Panel
+                       this->m_AuiManager->AddPane(this->m_PanelUp,
+                                       wxAuiPaneInfo().Name(_T("ListContainerPanel")).DefaultPane().Caption(
+                                                       _("ListContainerPanel")).PinButton().CaptionVisible(true).CloseButton(
+                                                       false).Center().Resizable(true));
+
+                       this->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
+                                                                                       wxCommandEventHandler(PanelButtonContainer::OnConfigButton));
+
+               }
+
+               //MLER
+
+               this->m_AuiManager->Update();
        }
-       // ----------------------------------------------------------------------------------
-       PanelButtonContainer::~PanelButtonContainer( )
+// ----------------------------------------------------------------------------------
+       PanelButtonContainer::~PanelButtonContainer()
        {
        }
-       // ----------------------------------------------------------------------------------
-       void
-       PanelButtonContainer::UpdatePanel( const std::string &buttonName )
+// ----------------------------------------------------------------------------------
+       void PanelButtonContainer::UpdatePanel(const std::string &buttonName)
        {
                try
                {
                        //Hiding the last CartoSettingsPanel
-                       this->m_ButtonPanel->Show( false );
+                       this->m_EventPanel->Show(false);
                        //Finding the CartoSettingsPanel of the ButtonClicket
-                       this->m_ButtonPanel = this->m_ButtonContainerSettings->GetPanelButton(
-                           buttonName );
+                       this->m_EventPanel = this->m_ButtonContainerSettings->GetPanelButton(
+                                       buttonName);
                        //changing the parent of the panel!
-                       if ( this->m_ButtonPanel->GetParent( ) != this )
-                               this->m_ButtonPanel->Reparent( this );
-                       //CartoSettingsPanel Management
-                       this->m_AuiManager->GetPane( _T("ButtonPanel") ).window
-                           = this->m_ButtonPanel;
+                       if (this->m_EventPanel->GetParent() != this)
+                       {
+                               this->m_EventPanel->Reparent(this);
+                       }       //fi
+                               //Panel Management
+                       this->m_AuiManager->GetPane(_T("EventPanel")).window = this->m_EventPanel;
                        //Updating the manager
-                       this->m_AuiManager->Update( );
-               }//yrt
-               catch ( const std::exception& e )
+                       this->m_AuiManager->Update();
+               }                       //yrt
+               catch (const std::exception& e)
                {
                        std::cerr
-                           << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
-                           << "exception: " << e.what( ) << std::endl;
+                                       << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
+                                       << "exception: " << e.what() << std::endl;
                        std::cout << "Maybe the panel of the button is NULL" << std::endl;
-                       exit( 1 );
-               }//hctac
+                       exit(1);
+               }                       //hctac
+       }
+// ----------------------------------------------------------------------------------
+       void PanelButtonContainer::GenericButtonEvent(const std::string &buttonName)
+       {
+               this->UpdatePanel(buttonName);
        }
+
        // ----------------------------------------------------------------------------------
-       void
-       PanelButtonContainer::GenericButtonEvent( const std::string &buttonName )
+       //MLER
+       void PanelButtonContainer::GenericListEvent(const std::string &buttonName)
        {
-               this->UpdatePanel( buttonName );
+               this->UpdateListPanel(buttonName);
        }
+
+       // ----------------------------------------------------------------------------------
+       void PanelButtonContainer::UpdateListPanel(const std::string &buttonName)
+       {
+               try
+               {
+                       this->m_EventPanel->Show(false);
+                       this->m_EventPanel = this->m_ButtonContainerSettings->GetPanelList(
+                                       buttonName);
+
+                       if (this->m_EventPanel->GetParent() != this)
+                       {
+                               this->m_EventPanel->Reparent(this);
+                       }       //fi
+                               //Panel Management
+                       this->m_AuiManager->GetPane(_T("EventPanel")).window = this->m_EventPanel;
+                       //Updating the manager
+                       this->m_AuiManager->Update();
+
+               } catch (const std::exception& e)
+               {
+                       std::cerr
+                                       << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
+                                       << "exception: " << e.what() << std::endl;
+                       std::cout << "Maybe the panel of the list is NULL" << std::endl;
+                       exit(1);
+               }                                                       //hctac
+       }
+
 // ----------------------------------------------------------------------------------
-}//ecapseman
+       void
+               PanelButtonContainer::OnConfigButton ( wxCommandEvent& event )
+               {
+
+                       this->m_ListConfigDialog = new ListConfigDialog(this,-1,_("Config"), this->m_ListWxPanel, this->m_CurrentWxPanel);
 
+                       std::cout<< "Button Event"<<std::endl;
+
+                       this->m_ListConfigDialog->ShowModal();//Show Dialog
+                       this->m_CurrentWxPanel->Reparent(this->m_PanelUp);
+                       this->m_CurrentWxPanel->Show(true);
+                       this->m_CurrentWxPanel->SetFunctorEnabled(true);
+                       this->m_CurrentWxPanel->Update();
+                       this->m_AuiManager->Update( );
+                       this->m_EventPanel->Show(false);
+               }
+       // ----------------------------------------------------------------------------------
+
+}//ecapseman