]> Creatis software - bbtk.git/blob - packages/wx/src/bbwxCheckBox.h
5e8f9636e4cdc79eae4051517ffd283a81d9f213
[bbtk.git] / packages / wx / src / bbwxCheckBox.h
1 /*
2  # ---------------------------------------------------------------------
3  #
4  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5  #                        pour la SantÈ)
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
9  #
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.
16  #
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
21  #  liability.
22  #
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  # ------------------------------------------------------------------------ */
26
27
28 /*=========================================================================
29   Program:   bbtk
30   Module:    $RCSfile: bbwxCheckBox.h,v $
31   Language:  C++
32   Date:      $Date: 2012/11/16 08:52:14 $
33   Version:   $Revision: 1.4 $
34 =========================================================================*/
35
36 /* ---------------------------------------------------------------------
37
38 * Copyright (c) CREATIS-LRMN (Centre de Recherche en Imagerie Medicale)
39 * Authors : Eduardo Davila, Laurent Guigues, Jean-Pierre Roux
40 *
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.
47 *
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
52 *  liability. 
53 *
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 * ------------------------------------------------------------------------ */                                                                         
57
58 /**
59  * \file 
60  * \brief Short description in one line
61  * 
62  * Long description which 
63  * can span multiple lines
64 */
65
66 /**
67  * \class bbwx::CheckBox
68  * \brief 
69
70  * \class bbwx::CheckBoxWidget
71  * \brief 
72  */
73
74 #ifdef _USE_WXWIDGETS_
75
76 // Prevents multiple inclusions : use symbols of the form
77 // __FILENAME_INCLUDED__ 
78 // where FILENAME must be replaced by the actual file name
79 #ifndef __bbwxCheckBox_h_INCLUDED__
80 #define __bbwxCheckBox_h_INCLUDED__
81
82 // Include wxBlackBox definition
83 #include "bbtkWxBlackBox.h"
84
85 #include "bbwx_EXPORT.h"
86
87
88 // Namespace of the package "wx" is "bbwx" 
89 // Namespace associated to packages should be of the form :
90 // bbPACKAGENAME
91 namespace bbwx
92 {
93   
94   //------------------------------------------------------------------------
95   // The black box
96   class bbwx_EXPORT CheckBox : public bbtk::WxBlackBox
97   {
98     
99     BBTK_BLACK_BOX_INTERFACE(CheckBox,bbtk::WxBlackBox);
100     BBTK_DECLARE_INPUT(In,bool);
101     BBTK_DECLARE_INPUT(Title,std::string);
102     BBTK_DECLARE_INPUT(ReactiveOnKeystroke,int);
103     BBTK_DECLARE_OUTPUT(Out,bool);
104     BBTK_PROCESS(Process);
105     BBTK_CREATE_WIDGET(CreateWidget);
106     void Process();
107     void CreateWidget(wxWindow*);
108
109   protected:
110
111   };
112   
113   //--------------------------------------------------------------------------
114   // The widget created by the box 
115   class CheckBoxWidget : public wxPanel 
116   {
117   public:
118     /// Ctor with the two first params the parent window and the creator box
119     /// which must be passed to the WxBlackBoxWidget constructor.
120     /// The other params initialize the widget 
121     CheckBoxWidget(CheckBox* box, wxWindow *parent,
122                  wxString title,
123                  bool value, int reactiveOnKeyStroke
124                  );
125     /// Dtor
126     ~CheckBoxWidget();
127     /// Events callbacks
128     /// Called when the box is clicked
129     void OnCheckBoxClick(wxCommandEvent& event);
130     void OnCheckBoxClick_();
131
132     // Accessors
133     bool GetValue() { return mwxCheckBox->GetValue(); }
134     void SetValue(bool val);
135     // Update the texts which display the min/max/current values of the slider
136         
137   private:
138     CheckBox*    mBox;
139     wxCheckBox   *mwxCheckBox;
140     int          _reactiveOnKeyStroke;
141     bool         val;
142   };
143   //------------------------------------------------------------------------
144   //------------------------------------------------------------------------
145   //------------------------------------------------------------------------
146   //=================================================================
147  
148   //=================================================================
149   // the black box description
150   BBTK_BEGIN_DESCRIBE_BLACK_BOX(CheckBox,bbtk::WxBlackBox);
151   BBTK_NAME("CheckBox");
152   BBTK_AUTHOR("jpr@creatis.insa-lyon.fr");
153   // Already inserted for any WxBlackBox  BBTK_CATEGORY("widget");
154   BBTK_DESCRIPTION("CheckBox widget (wxCheckBox)");
155   BBTK_INPUT(CheckBox, In,   "Initial value of the CheckBox (default false)",bool,       "");
156   BBTK_INPUT(CheckBox, Title,"Title shown above the CheckBox (default '') ", std::string,"");
157   BBTK_OUTPUT(CheckBox,Out,  "Current value of the CheckBox",                bool,       "");
158   BBTK_INPUT(CheckBox,ReactiveOnKeystroke,"0: no event generated when the checkbox is clicked on, 1: event generated when the checkbox is clicked on (default 1) ", int,"");
159   BBTK_END_DESCRIBE_BLACK_BOX(CheckBox);
160   //=================================================================
161   
162
163
164 } //namespace bbwx
165
166 #endif  //__bbtkwxCheckBox_h_INCLUDED__
167
168 #endif //_USE_WXWIDGETS_