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)
4 #include "bbwtInputText.h"
5 #include "bbwtPackage.h"
8 //--------------------------------------------------------------------------
9 class InputTextWidget : public Wt::WContainerWidget
12 InputTextWidget(InputText* box,
13 Wt::WContainerWidget *parent,
19 std::string GetValue();
20 void SetValue(std::string value);
23 void OnTextUpdate(const Wt::WKeyEvent e);
25 void SetTitle(Wt::WString);
29 Wt::WLineEdit *mwtLineEdit;
33 //------------------------------------------------------------------------
34 //------------------------------------------------------------------------
35 //------------------------------------------------------------------------
37 InputTextWidget::InputTextWidget(InputText* box,
38 Wt::WContainerWidget *parent,
42 Wt::WContainerWidget(parent),
45 Wt::WContainerWidget *panel = this;
46 Wt::WBorderLayout *layout = new Wt::WBorderLayout();
49 mwtLineEdit = new Wt::WLineEdit();
51 mwtLineEdit->changed().connect(this,&InputTextWidget::OnTextEnter);
52 mwtLineEdit->keyWentUp().connect(this, &InputTextWidget::OnTextUpdate);
55 mwtTitle = new Wt::WText(title);
57 layout->addWidget(mwtTitle,Wt::WBorderLayout::North);
58 layout->addWidget(mwtLineEdit,Wt::WBorderLayout::Center);
60 panel->setLayout(layout);
63 //-------------------------------------------------------------------------
65 InputTextWidget::~InputTextWidget()
69 //-------------------------------------------------------------------------
72 void InputTextWidget::SetTitle(Wt::WString s)
77 //-------------------------------------------------------------------------
78 std::string InputTextWidget::GetValue()
80 return bbtk::wt2std ( mwtLineEdit->text() );
83 void InputTextWidget::SetValue(std::string value)
85 mwtLineEdit->setText( bbtk::std2wt(value) ) ;
88 //--------------------------------------------------------------------------
89 void InputTextWidget::OnTextEnter()
91 std::cout<<"bbwtInputText.cxx -> OnTextEnter pre if"<<std::endl;
92 if (mBox->bbGetInputReactiveOnKeystroke()==1)
94 std::cout<<"bbwtInputText.cxx -> OnTextEnter if"<<std::endl;
95 mBox->bbSetOutputOut( GetValue() );
96 mBox->bbSetInputIn( GetValue() );
97 mBox->bbSignalOutputModification("Out");
101 //--------------------------------------------------------------------------
102 void InputTextWidget::OnTextUpdate(const Wt::WKeyEvent e)
104 std::cout<<"bbwtInputText.cxx -> pre If ...OnTextUpdate VALUE : "<<GetValue()<<std::endl;
105 std::cout<<"bbwtInputText.cxx -> pre If ...OnTextUpdate presionado : "<<e.key()<<std::endl;
106 std::cout<<"bbwtInputText.cxx -> OnTextUpdate pre if"<<std::endl;
107 if ((mBox->bbGetInputReactiveOnKeystroke()==2 && e.key() != Wt::Key_Enter)||((mBox->bbGetInputReactiveOnKeystroke()==1 && e.key() == Wt::Key_Enter) ))
109 std::cout<<"bbwtInputText.cxx -> OnTextUpdate if"<<std::endl;
110 std::cout<<"bbwtInputText.cxx -> OnTextUpdate VALUE : "<<GetValue()<<std::endl;
111 mBox->bbSetOutputOut( GetValue() + bbtk::wt2std(e.text()) );
112 mBox->bbSetInputIn( GetValue() );
113 mBox->bbSignalOutputModification("Out");
119 //--------------------------------------------------------------------------
120 //-------------------------------------------------------------------------
121 //--------------------------------------------------------------------------
122 //--------------------------------------------------------------------------
123 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wt,InputText)
124 BBTK_BLACK_BOX_IMPLEMENTATION(InputText,bbtk::WtBlackBox);
126 // 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 void InputText::Process()
131 InputTextWidget *w=(InputTextWidget *)bbGetOutputWidget();
137 w->SetValue( bbGetInputIn().c_str() );
139 w->SetTitle( bbtk::std2wt ( bbGetInputTitle() ) );
140 bbSetOutputOut( w->GetValue() );
144 bbSetOutputOut( "<VOID>" );
148 // 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)
150 void InputText::CreateWidget(Wt::WContainerWidget* parent)
154 ( new InputTextWidget(this, //bbGetWxParent(),
156 bbtk::std2wt ( bbGetInputIn() ) ,
157 bbtk::std2wt ( bbGetInputTitle() ) ) );
161 // 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)
163 void InputText::bbUserSetDefaultValues()
168 bbSetOutputWidget(0);
169 bbSetInputReactiveOnKeystroke(2);
173 // 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)
175 void InputText::bbUserInitializeProcessing()
180 // 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)
182 void InputText::bbUserFinalizeProcessing()