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"
76 //-------------------------------------------------------------------------
77 CheckBoxWidget::CheckBoxWidget(CheckBox* box, wxWindow *parent,
79 bool value, int reactiveOnKeyStroke)
81 wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
83 _reactiveOnKeyStroke(reactiveOnKeyStroke),
86 wxPanel * panel = this;
89 sizeX = sizeY = -1; // just to see JPR
93 //---------------------------------------------------------------------
94 // 1) Creation of the components of the widget
95 // Any top level sub-widget must have the panel returned by panel
97 mwxCheckBox = new wxCheckBox( panel,
101 //wxSize(sizeX,sizeY),
103 wxCHK_2STATE | wxALIGN_RIGHT);
105 mwxCheckBox->SetValue(value);
107 // Connecting events to callbacks
108 Connect( mwxCheckBox->GetId(),
109 wxEVT_COMMAND_CHECKBOX_CLICKED,
110 (wxObjectEventFunction)
111 (void (wxPanel::*)(wxScrollEvent&))
112 &CheckBoxWidget::OnCheckBoxClick);
114 //---------------------------------------------------------------------
116 //---------------------------------------------------------------------
117 // 2) Insertion of the components in the window
119 // We use a FlexGridSizer
120 wxFlexGridSizer *sizer;
121 sizer = new wxFlexGridSizer(1);
122 // Insert the sizer in the main panel and refresh the layout
123 panel->SetSizer(sizer);
125 //-------------------------------------------------------------------------
128 //-------------------------------------------------------------------------
129 CheckBoxWidget::~CheckBoxWidget()
132 //-------------------------------------------------------------------------
135 //-------------------------------------------------------------------------
139 //-------------------------------------------------------------------------
140 void CheckBoxWidget::OnCheckBoxClick(wxCommandEvent& event)
144 //-------------------------------------------------------------------------
145 void CheckBoxWidget::OnCheckBoxClick_()
147 // When user clicks the box
148 // we update the output of the box
149 mBox->bbSetOutputOut( mwxCheckBox->GetValue() );
150 mBox->bbSetInputIn( mwxCheckBox->GetValue() );
151 // and signal that the output has changed
152 //if(_reactiveOnKeyStroke==1){
153 mBox->bbSignalOutputModification(std::string("Out"));
156 //-------------------------------------------------------------------------
159 //-------------------------------------------------------------------------
160 void CheckBoxWidget::SetValue(bool value)
163 mwxCheckBox->SetValue(value);
165 //-------------------------------------------------------------------------
168 //--------------------------------------------------------------------------
169 //-------------------------------------------------------------------------
170 // WxBlackBox implementation
171 //--------------------------------------------------------------------------
172 //--------------------------------------------------------------------------
174 //--------------------------------------------------------------------------
175 BBTK_BLACK_BOX_IMPLEMENTATION(CheckBox,bbtk::WxBlackBox);
176 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,CheckBox);
179 //-----------------------------------------------------------------
180 void CheckBox::bbUserSetDefaultValues()
183 bbSetOutputOut(false);
184 bbSetInputReactiveOnKeystroke(1);
187 //-----------------------------------------------------------------
188 void CheckBox::bbUserInitializeProcessing()
192 //-----------------------------------------------------------------
193 void CheckBox::bbUserFinalizeProcessing()
198 //--------------------------------------------------------------------------
199 void CheckBox::Process()
201 bbSetOutputOut( bbGetInputIn() );
204 void CheckBox::CreateWidget(wxWindow* parent)
207 CheckBoxWidget *w = new CheckBoxWidget(this,
209 bbtk::std2wx( bbGetInputTitle() ),
211 bbGetInputReactiveOnKeystroke()
213 bbSetOutputWidget( w );
219 #endif // _USE_WXWIDGETS_