2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------ */
28 /*=========================================================================
30 Module: $RCSfile: bbwxCheckBox.cxx,v $
32 Date: $Date: 2012/11/16 08:52:14 $
33 Version: $Revision: 1.5 $
34 =========================================================================*/
36 /* ---------------------------------------------------------------------
38 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
39 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
41 * This software is governed by the CeCILL-B license under French law and
42 * abiding by the rules of distribution of free software. You can use,
43 * modify and/ or redistribute the software under the terms of the CeCILL-B
44 * license as circulated by CEA, CNRS and INRIA at the following URL
45 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
46 * or in the file LICENSE.txt.
48 * As a counterpart to the access to the source code and rights to copy,
49 * modify and redistribute granted by the license, users are provided only
50 * with a limited warranty and the software's author, the holder of the
51 * economic rights, and the successive licensors have only limited
54 * The fact that you are presently reading this means that you have had
55 * knowledge of the CeCILL-B license and that you accept its terms.
56 * ------------------------------------------------------------------------ */
60 * \brief Short description in one line
67 #ifdef _USE_WXWIDGETS_
69 #include "bbwxCheckBox.h"
70 #include "bbwxPackage.h"
71 #include "bbtkUtilities.h"
75 //--------------------------------------------------------------------------
76 // The widget created by the box
77 class CheckBoxWidget : public wxPanel
80 /// Ctor with the two first params the parent window and the creator box
81 /// which must be passed to the WxBlackBoxWidget constructor.
82 /// The other params initialize the widget
83 CheckBoxWidget(CheckBox* box, wxWindow *parent,
85 bool value, int reactiveOnKeyStroke
90 /// Called when the box is clicked
91 void OnCheckBoxClick(wxCommandEvent& event);
94 bool GetValue() { return mwxCheckBox->GetValue(); }
95 void SetValue(bool val);
96 // Update the texts which display the min/max/current values of the slider
100 wxCheckBox *mwxCheckBox;
101 int _reactiveOnKeyStroke;
104 //------------------------------------------------------------------------
105 //------------------------------------------------------------------------
106 //------------------------------------------------------------------------
110 //-------------------------------------------------------------------------
111 CheckBoxWidget::CheckBoxWidget(CheckBox* box, wxWindow *parent,
113 bool value, int reactiveOnKeyStroke)
115 wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
117 _reactiveOnKeyStroke(reactiveOnKeyStroke),
120 wxPanel * panel = this;
123 sizeX = sizeY = -1; // just to see JPR
127 //---------------------------------------------------------------------
128 // 1) Creation of the components of the widget
129 // Any top level sub-widget must have the panel returned by panel
131 mwxCheckBox = new wxCheckBox( panel,
135 //wxSize(sizeX,sizeY),
137 wxCHK_2STATE | wxALIGN_RIGHT);
139 mwxCheckBox->SetValue(value);
141 // Connecting events to callbacks
142 Connect( mwxCheckBox->GetId(),
143 wxEVT_COMMAND_CHECKBOX_CLICKED,
144 (wxObjectEventFunction)
145 (void (wxPanel::*)(wxScrollEvent&))
146 &CheckBoxWidget::OnCheckBoxClick);
148 //---------------------------------------------------------------------
150 //---------------------------------------------------------------------
151 // 2) Insertion of the components in the window
153 // We use a FlexGridSizer
154 wxFlexGridSizer *sizer;
155 sizer = new wxFlexGridSizer(1);
156 // Insert the sizer in the main panel and refresh the layout
157 panel->SetSizer(sizer);
159 //-------------------------------------------------------------------------
162 //-------------------------------------------------------------------------
163 CheckBoxWidget::~CheckBoxWidget()
166 //-------------------------------------------------------------------------
169 //-------------------------------------------------------------------------
173 //-------------------------------------------------------------------------
174 void CheckBoxWidget::OnCheckBoxClick(wxCommandEvent& event)
176 // When user clicks the box
177 // we update the output of the box
178 mBox->bbSetOutputOut( mwxCheckBox->GetValue() );
179 mBox->bbSetInputIn( mwxCheckBox->GetValue() );
180 // and signal that the output has changed
181 //if(_reactiveOnKeyStroke==1){
182 mBox->bbSignalOutputModification(std::string("Out"));
185 //-------------------------------------------------------------------------
187 //-------------------------------------------------------------------------
190 //-------------------------------------------------------------------------
191 void CheckBoxWidget::SetValue(bool value)
194 mwxCheckBox->SetValue(value);
196 //-------------------------------------------------------------------------
199 //--------------------------------------------------------------------------
200 //-------------------------------------------------------------------------
201 // WxBlackBox implementation
202 //--------------------------------------------------------------------------
203 //--------------------------------------------------------------------------
205 //--------------------------------------------------------------------------
206 BBTK_BLACK_BOX_IMPLEMENTATION(CheckBox,bbtk::WxBlackBox);
207 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,CheckBox);
210 //-----------------------------------------------------------------
211 void CheckBox::bbUserSetDefaultValues()
214 bbSetOutputOut(false);
215 bbSetInputReactiveOnKeystroke(1);
218 //-----------------------------------------------------------------
219 void CheckBox::bbUserInitializeProcessing()
223 //-----------------------------------------------------------------
224 void CheckBox::bbUserFinalizeProcessing()
229 //--------------------------------------------------------------------------
230 void CheckBox::Process()
232 bbSetOutputOut( bbGetInputIn() );
235 void CheckBox::CreateWidget(wxWindow* parent)
238 CheckBoxWidget *w = new CheckBoxWidget(this,
240 bbtk::std2wx( bbGetInputTitle() ),
242 bbGetInputReactiveOnKeystroke()
244 bbSetOutputWidget( w );
250 #endif // _USE_WXWIDGETS_