1 /*=========================================================================
3 Module: $RCSfile: bbwxCheckBox.cxx,v $
5 Date: $Date: 2009/05/15 14:58:03 $
6 Version: $Revision: 1.2 $
7 =========================================================================*/
9 /* ---------------------------------------------------------------------
11 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
12 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
14 * This software is governed by the CeCILL-B license under French law and
15 * abiding by the rules of distribution of free software. You can use,
16 * modify and/ or redistribute the software under the terms of the CeCILL-B
17 * license as circulated by CEA, CNRS and INRIA at the following URL
18 * http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
19 * or in the file LICENSE.txt.
21 * As a counterpart to the access to the source code and rights to copy,
22 * modify and redistribute granted by the license, users are provided only
23 * with a limited warranty and the software's author, the holder of the
24 * economic rights, and the successive licensors have only limited
27 * The fact that you are presently reading this means that you have had
28 * knowledge of the CeCILL-B license and that you accept its terms.
29 * ------------------------------------------------------------------------ */
33 * \brief Short description in one line
40 #ifdef _USE_WXWIDGETS_
42 #include "bbwxCheckBox.h"
43 #include "bbwxPackage.h"
44 #include "bbtkUtilities.h"
48 //--------------------------------------------------------------------------
49 // The widget created by the box
50 class CheckBoxWidget : public wxPanel
53 /// Ctor with the two first params the parent window and the creator box
54 /// which must be passed to the WxBlackBoxWidget constructor.
55 /// The other params initialize the widget
56 CheckBoxWidget(CheckBox* box, wxWindow *parent,
63 /// Called when the box is clicked
64 void OnCheckBoxClick(wxCommandEvent& event);
67 bool GetValue() { return mwxCheckBox->GetValue(); }
68 void SetValue(bool val);
69 // Update the texts which display the min/max/current values of the slider
73 wxCheckBox *mwxCheckBox;
77 //------------------------------------------------------------------------
78 //------------------------------------------------------------------------
79 //------------------------------------------------------------------------
83 //-------------------------------------------------------------------------
84 CheckBoxWidget::CheckBoxWidget(CheckBox* box, wxWindow *parent,
88 wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL),
92 wxPanel * panel = this;
95 sizeX = sizeY = -1; // just to see JPR
99 //---------------------------------------------------------------------
100 // 1) Creation of the components of the widget
101 // Any top level sub-widget must have the panel returned by panel
103 mwxCheckBox = new wxCheckBox( panel,
107 //wxSize(sizeX,sizeY),
109 wxCHK_2STATE | wxALIGN_RIGHT);
111 mwxCheckBox->SetValue(value);
113 // Connecting events to callbacks
114 Connect( mwxCheckBox->GetId(),
115 wxEVT_COMMAND_CHECKBOX_CLICKED,
116 (wxObjectEventFunction)
117 (void (wxPanel::*)(wxScrollEvent&))
118 &CheckBoxWidget::OnCheckBoxClick);
120 //---------------------------------------------------------------------
122 //---------------------------------------------------------------------
123 // 2) Insertion of the components in the window
125 // We use a FlexGridSizer
126 wxFlexGridSizer *sizer;
127 sizer = new wxFlexGridSizer(1);
128 // Insert the sizer in the main panel and refresh the layout
129 panel->SetSizer(sizer);
131 //-------------------------------------------------------------------------
134 //-------------------------------------------------------------------------
135 CheckBoxWidget::~CheckBoxWidget()
138 //-------------------------------------------------------------------------
141 //-------------------------------------------------------------------------
145 //-------------------------------------------------------------------------
146 void CheckBoxWidget::OnCheckBoxClick(wxCommandEvent& event)
148 // When user clicks the box
149 // we update the output of the box
150 mBox->bbSetOutputOut( mwxCheckBox->GetValue() );
151 mBox->bbSetInputIn( mwxCheckBox->GetValue() );
152 // and signal that the output has changed
153 mBox->bbSignalOutputModification(std::string("Out"));
155 //-------------------------------------------------------------------------
157 //-------------------------------------------------------------------------
160 //-------------------------------------------------------------------------
161 void CheckBoxWidget::SetValue(bool value)
164 mwxCheckBox->SetValue(value);
166 //-------------------------------------------------------------------------
169 //--------------------------------------------------------------------------
170 //-------------------------------------------------------------------------
171 // WxBlackBox implementation
172 //--------------------------------------------------------------------------
173 //--------------------------------------------------------------------------
175 //--------------------------------------------------------------------------
176 BBTK_BLACK_BOX_IMPLEMENTATION(CheckBox,bbtk::WxBlackBox);
177 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,CheckBox);
180 //-----------------------------------------------------------------
181 void CheckBox::bbUserSetDefaultValues()
184 bbSetOutputOut(false);
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() ),
212 bbSetOutputWidget( w );
218 #endif // _USE_WXWIDGETS_