1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
27 * @file buttonContainerController.cxx
28 * @brief This contains the ButtonContainerController class implementation
29 * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
33 #include "buttonContainerController.h"
35 namespace creaButtonContainer
39 // ----------------------------------------------------------------------------------
40 ButtonContainerController::ButtonContainerController(BCPanel* panel)
42 this->m_BCPanel = panel;
44 // ----------------------------------------------------------------------------------
45 ButtonContainerController::~ButtonContainerController()
48 // ----------------------------------------------------------------------------------
49 void ButtonContainerController::AddEvents()
53 //Adding ButtonManagerEvents
54 for (GroupManagerList::iterator it =
55 this->m_BCPanel->m_GroupManagerList.begin();
56 it != this->m_BCPanel->m_GroupManagerList.end(); ++it)
58 this->Connect((*it).first, wxEVT_COMMAND_BUTTON_CLICKED,
59 (wxObjectEventFunction)
60 & ButtonContainerController::ButtonExpEvent);
64 for (ButtonGroupList::iterator it =
65 this->m_BCPanel->m_ButtonGroupList.begin();
66 it != this->m_BCPanel->m_ButtonGroupList.end(); ++it)
68 KeyList keylist = (*it)->GetButtonIdContainer();
69 for (KeyList::iterator it2 = keylist.begin(); it2 != keylist.end();
72 this->Connect((*it2), wxEVT_COMMAND_BUTTON_CLICKED,
73 (wxObjectEventFunction)
74 & ButtonContainerController::ButtonEvent);
78 catch (const std::exception& e)
80 std::cerr << "ButtonContainerController::AddEvents( ) exception: "
81 << e.what() << std::endl;
84 // ----------------------------------------------------------------------------------
85 void ButtonContainerController::ButtonExpEvent(wxCommandEvent& event)
87 long id = event.GetId();
91 //changing the button label when its clicked and then hide the buttons of the group.
92 if (this->m_BCPanel->m_GroupManagerList[id]->GetButton()->GetLabel().Cmp(
95 this->m_BCPanel->m_GroupManagerList[id]->GetButton()->SetLabel(
97 this->m_BCPanel->m_GroupManagerList[id]->HideSubPanel(false);
99 else if (this->m_BCPanel->m_GroupManagerList[id]->GetButton()->GetLabel().Cmp(
102 this->m_BCPanel->m_GroupManagerList[id]->GetButton()->SetLabel(
104 this->m_BCPanel->m_GroupManagerList[id]->HideSubPanel(true);
106 this->m_BCPanel->FitSizer();
108 catch (const std::exception& e)
111 << "ButtonContainerController::ButtonExpEvent( wxCommandEvent& event ) exception: "
112 << e.what() << std::endl;
115 // ----------------------------------------------------------------------------------
116 void ButtonContainerController::ButtonEvent(wxCommandEvent& event)
120 for (ButtonGroupList::iterator it =
121 this->m_BCPanel->m_ButtonGroupList.begin();
122 it != this->m_BCPanel->m_ButtonGroupList.end(); ++it)
124 if ((*it)->GetButton(event.GetId()) != NULL)
126 (*it)->GetButton(event.GetId())->Execute();
130 catch (const std::exception& e)
133 << "ButtonContainerController::ButtonEvent( wxCommandEvent& event ) exception: "
134 << e.what() << std::endl;
137 // ----------------------------------------------------------------------------------