]> Creatis software - creaWT.git/blob - wt/bbtk_wt_PKG/src/bbwtCheckBox.cxx~
217132d4a981475c235931898d8bb490b024b1d8
[creaWT.git] / wt / bbtk_wt_PKG / src / bbwtCheckBox.cxx~
1 //===== 
2 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
3 //===== 
4 #include "bbwtCheckBox.h"
5 #include "bbwtPackage.h"
6 namespace bbwt
7 {
8
9         class CheckBoxWidget : public Wt::WContainerWidget
10         {
11                 public:
12                 /// Ctor with the two first params the parent window and the creator box
13     /// which must be passed to the WxBlackBoxWidget constructor.
14     /// The other params initialize the widget 
15                         CheckBoxWidget(CheckBox* box, Wt::WContainerWidget *parent,
16                                         Wt::WString title,
17                                         bool value, int reactiveOnKeyStroke
18                                         );
19                         ~CheckBoxWidget();
20         
21                         bool GetValue(){return mwtCheckBox->isChecked();}
22                         void SetValue(bool val);
23       void OnCheckBoxClick();
24
25                 private:
26                         CheckBox* mBox;
27                         Wt::WCheckBox *mwtCheckBox;
28                         int          _reactiveOnKeyStroke;
29                         bool val;
30
31         };
32
33   //------------------------------------------------------------------------
34   //------------------------------------------------------------------------
35   //------------------------------------------------------------------------
36
37         CheckBoxWidget::CheckBoxWidget(CheckBox* box, Wt::WContainerWidget *parent,
38                                         Wt::WString title,
39                                         bool value, int reactiveOnKeyStroke
40                                         )
41                         :
42                         Wt::WContainerWidget(parent),
43                         mBox(box),
44                         _reactiveOnKeyStroke(reactiveOnKeyStroke),
45                         val(value)
46         {
47
48         
49                 Wt::WContainerWidget * panel = this;
50                 panel->setPadding(2);
51                 panel->setContentAlignment(Wt::AlignCenter|Wt::AlignMiddle);
52     //The definition of wt checkbox determines that there is a possible tristate,               
53     mwtCheckBox = new Wt::WCheckBox(title,panel);
54     mwtCheckBox->clicked().connect(this,&CheckBoxWidget::OnCheckBoxClick);
55     
56                 
57         }
58   //-------------------------------------------------------------------------
59   
60
61   //-------------------------------------------------------------------------
62   void CheckBoxWidget::OnCheckBoxClick()
63   {
64           // When user clicks the box 
65           // we update the output of the box
66           mBox->bbSetOutputOut( mwtCheckBox->isChecked() );
67           mBox->bbSetInputIn( mwtCheckBox->isChecked() );
68           // and signal that the output has changed
69           //if(_reactiveOnKeyStroke==1){
70           mBox->bbSignalOutputModification(std::string("Out"));
71           //}
72   }
73
74   //-------------------------------------------------------------------------
75   
76
77   //-------------------------------------------------------------------------
78         CheckBoxWidget::~CheckBoxWidget()
79         {
80         }
81   //-------------------------------------------------------------------------
82   
83
84   //-------------------------------------------------------------------------
85         void CheckBoxWidget::SetValue(bool value)
86         {       
87       this->val=value;
88                   mwtCheckBox->setChecked(value);
89         }
90
91 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wt,CheckBox)
92 BBTK_BLACK_BOX_IMPLEMENTATION(CheckBox,bbtk::WtBlackBox);
93 //===== 
94 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
95 //===== 
96 void CheckBox::Process()
97 {
98
99   bbSetOutputOut( bbGetInputIn() );
100   
101 }
102 //===== 
103 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
104 //===== 
105 void CheckBox::CreateWidget(Wt::WContainerWidget* parent)
106 {
107
108   CheckBoxWidget *w = new CheckBoxWidget(this,
109                                                 parent,
110                               bbtk::std2wt( bbGetInputTitle() ),
111                                                 bbGetInputIn(),
112                                                 bbGetInputReactiveOnKeystroke()
113                                                 );
114         bbSetOutputWidget( w );
115 }
116 //===== 
117 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
118 //===== 
119 void CheckBox::bbUserSetDefaultValues()
120 {
121   
122   bbSetInputIn(false);
123   bbSetInputReactiveOnKeystroke(1);
124   bbSetOutputOut(false);
125 }
126 //===== 
127 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
128 //===== 
129 void CheckBox::bbUserInitializeProcessing()
130 {
131
132 }
133 //===== 
134 // Before editing this file, make sure it's a file of your own (i.e.: it wasn't generated from xml description; if so : your modifications will be lost)
135 //===== 
136 void CheckBox::bbUserFinalizeProcessing()
137 {
138
139 }
140 }
141 // EO namespace bbwt
142
143