From: Eduardo DAVILA Date: Wed, 6 Mar 2019 15:37:42 +0000 (+0100) Subject: #3234 BBTK Feature New Normal InputText with password option X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=3f088371dd1b2558e08da80141f2c0d6da0f1413;p=bbtk.git #3234 BBTK Feature New Normal InputText with password option --- diff --git a/packages/wx/src/bbwxInputText.cxx b/packages/wx/src/bbwxInputText.cxx index 3056f05..d64cfa5 100644 --- a/packages/wx/src/bbwxInputText.cxx +++ b/packages/wx/src/bbwxInputText.cxx @@ -53,11 +53,12 @@ namespace bbwx { public: InputTextWidget(InputText* box, wxWindow *parent, - wxString In, wxString title); + wxString In, wxString title ); ~InputTextWidget(); std::string GetValue(); void SetValue(std::string value); + void SetWindowStyle(int style); void OnTextEnter(wxCommandEvent& event); void OnTextUpdate(wxCommandEvent& event); @@ -77,13 +78,16 @@ namespace bbwx InputTextWidget::InputTextWidget(InputText* box, wxWindow *parent, wxString In, - wxString title) + wxString title ) : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL), mBox(box) { wxPanel *panel = this; - - mwxTextCtrl = new wxTextCtrl( panel, -1, In,wxDefaultPosition, wxSize(800,20),wxTE_PROCESS_ENTER); + +//wxTE_PROCESS_ENTER +//wxTE_MULTILINE For multiple line you have to create an other box (EED). + + mwxTextCtrl = new wxTextCtrl( panel, -1, In,wxDefaultPosition, wxSize(800,40) , wxTE_PROCESS_ENTER); Connect( mwxTextCtrl->GetId(), wxEVT_COMMAND_TEXT_ENTER, (wxObjectEventFunction) (wxEventFunction) @@ -124,6 +128,14 @@ namespace bbwx mwxTitle->SetLabel(s); } + void InputTextWidget::SetWindowStyle(int style) + { + long wxstyle = wxTE_PROCESS_ENTER; + if (style==1) {wxstyle = wxTE_PASSWORD;} + mwxTextCtrl->SetWindowStyle(wxstyle); + } + + //------------------------------------------------------------------------- std::string InputTextWidget::GetValue() { @@ -173,6 +185,7 @@ namespace bbwx bbSetInputIn(""); bbSetOutputWidget(0); bbSetInputReactiveOnKeystroke(2); + bbSetInputStyle(0); } //----------------------------------------------------------------- @@ -197,6 +210,7 @@ namespace bbwx firsttime=false; w->SetValue( bbGetInputIn().c_str() ); } + w->SetWindowStyle( bbGetInputStyle() ); w->SetTitle( bbtk::std2wx ( bbGetInputTitle() ) ); bbSetOutputOut( w->GetValue() ); } else { @@ -209,10 +223,12 @@ namespace bbwx void InputText::CreateWidget(wxWindow* parent) { bbSetOutputWidget - ( (wxWindow*) new InputTextWidget(this, //bbGetWxParent(), - parent, - bbtk::std2wx ( bbGetInputIn() ) , - bbtk::std2wx ( bbGetInputTitle() ) ) ); + ( (wxWindow*) new InputTextWidget( this, //bbGetWxParent(), + parent, + bbtk::std2wx ( bbGetInputIn() ) , + bbtk::std2wx ( bbGetInputTitle() ) + ) + ); } }//namespace bbtk diff --git a/packages/wx/src/bbwxInputText.h b/packages/wx/src/bbwxInputText.h index 6eb1480..46bc6d5 100644 --- a/packages/wx/src/bbwxInputText.h +++ b/packages/wx/src/bbwxInputText.h @@ -68,6 +68,7 @@ namespace bbwx BBTK_BLACK_BOX_INTERFACE(InputText,bbtk::WxBlackBox); BBTK_DECLARE_INPUT(In,std::string); BBTK_DECLARE_INPUT(Title,std::string); + BBTK_DECLARE_INPUT(Style,int); BBTK_DECLARE_INPUT(ReactiveOnKeystroke,int); BBTK_DECLARE_OUTPUT(Out,std::string); BBTK_PROCESS(Process); @@ -91,6 +92,7 @@ namespace bbwx BBTK_INPUT(InputText,In,"Initial text (default '')",std::string,""); BBTK_INPUT(InputText,Title,"Title of the input zone (default '') ", std::string,""); + BBTK_INPUT(InputText,Style,"(default 0) 0:OneLine 1:Password ", int,""); BBTK_INPUT(InputText,ReactiveOnKeystroke,"0 not event generated, 1 Enter event genereated, 2 All keys, (default '2') ", int,""); BBTK_OUTPUT(InputText,Out,"Current text",std::string,"");