]> Creatis software - bbtk.git/commitdiff
#3234 BBTK Feature New Normal InputText with password option
authorEduardo DAVILA <davila@ei-ed-606.creatis.insa-lyon.fr>
Wed, 6 Mar 2019 15:37:42 +0000 (16:37 +0100)
committerEduardo DAVILA <davila@ei-ed-606.creatis.insa-lyon.fr>
Wed, 6 Mar 2019 15:37:42 +0000 (16:37 +0100)
packages/wx/src/bbwxInputText.cxx
packages/wx/src/bbwxInputText.h

index 3056f05f3abba7b24c9eb6071a1d81c139f83241..d64cfa54851d04b6ae32227c1331e9f24cbda3b4 100644 (file)
@@ -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
index 6eb1480e50ac953d155325a6f835809051cdf425..46bc6d563c9920e72e6823ec266386e7ea2c387e 100644 (file)
@@ -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,"");