From: Eduardo DAVILA Date: Fri, 20 Apr 2018 09:43:04 +0000 (+0200) Subject: #3189 BBTK Bug New Normal - Refresh RadioButton Box X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?p=bbtk.git;a=commitdiff_plain;h=ba3bbbeabbf48058d3453a402cca7b55d49c66cb #3189 BBTK Bug New Normal - Refresh RadioButton Box --- diff --git a/packages/wx/src/bbwxRadioButton.cxx b/packages/wx/src/bbwxRadioButton.cxx index ce0f36b..8ff7751 100644 --- a/packages/wx/src/bbwxRadioButton.cxx +++ b/packages/wx/src/bbwxRadioButton.cxx @@ -65,11 +65,14 @@ namespace bbwx int GetValue(); void OnRadioButton(wxEvent& event); + void AddElements(std::vector lstIn, int In, wxString title); private: RadioButton *mBox; int MAX_RADIOBUTTON; wxRadioButton *mwxRadioButton[10]; + + wxFlexGridSizer *sizer; }; //------------------------------------------------------------------------ @@ -86,8 +89,10 @@ namespace bbwx wxPanel( parent, -1) , mBox(box) { - wxPanel *panel = this; + +/* MAX_RADIOBUTTON = lstIn.size(); + wxPanel *panel = this; int i; long style=wxRB_GROUP; for (i=0;iSetValue(true); - } - else - { + } else { mwxRadioButton[i]->SetValue(false); } Connect( mwxRadioButton[i]->GetId(), @@ -113,18 +116,20 @@ namespace bbwx (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&)) &RadioButtonWidget::OnRadioButton ); - } - else - { + } else { mwxRadioButton[i]=NULL; - } - } + } // if + } // for //--------------------------------------------------------------------- // 2) Insertion of the components in the window // We use a FlexGridSizer - wxFlexGridSizer *sizer = new wxFlexGridSizer(1); + +//EED 2018-04-18 +// wxFlexGridSizer *sizer = new wxFlexGridSizer(1); + sizer = new wxFlexGridSizer(1); + if (title!=_T("")) { sizer->Add( new wxStaticText(panel,-1, title ) ); @@ -141,6 +146,7 @@ namespace bbwx // panel->SetAutoLayout(true); // panel->Layout(); +*/ } //------------------------------------------------------------------------- @@ -176,6 +182,73 @@ namespace bbwx mBox->bbSignalOutputModification("Out"); } + + //-------------------------------------------------------------------------- + void RadioButtonWidget::AddElements( std::vector lstIn ,int In, wxString title) + { + DestroyChildren(); + + MAX_RADIOBUTTON = lstIn.size(); + wxPanel *panel = this; + int i; + long style=wxRB_GROUP; + for (i=0;iSetValue(true); + } else { + mwxRadioButton[i]->SetValue(false); + } + Connect( mwxRadioButton[i]->GetId(), + wxEVT_COMMAND_RADIOBUTTON_SELECTED, + (wxObjectEventFunction) + (void (wxPanel::*)(wxEvent&)) + &RadioButtonWidget::OnRadioButton ); + } else { + mwxRadioButton[i]=NULL; + } // if + } // for + + //--------------------------------------------------------------------- + // 2) Insertion of the components in the window + + // We use a FlexGridSizer + +//EED 2018-04-18 +// wxFlexGridSizer *sizer = new wxFlexGridSizer(1); + sizer = new wxFlexGridSizer(1); + + if (title!=_T("")) + { + sizer->Add( new wxStaticText(panel,-1, title ) ); + } + for (i=0;iAdd( mwxRadioButton[i],1,wxGROW ); + } + } + sizer->AddGrowableCol(0); + panel->SetSizer(sizer); + +// panel->SetAutoLayout(true); +// panel->Layout(); + + + + } + + //-------------------------------------------------------------------------- //------------------------------------------------------------------------- //-------------------------------------------------------------------------- @@ -216,6 +289,24 @@ namespace bbwx { bbtkDebugMessageInc("Core",9,"RadioButton::Process()"< lstIn; + lstIn.push_back( bbtk::std2wx(bbGetInputIn0()) ); + lstIn.push_back( bbtk::std2wx(bbGetInputIn1()) ); + lstIn.push_back( bbtk::std2wx(bbGetInputIn2()) ); + lstIn.push_back( bbtk::std2wx(bbGetInputIn3()) ); + lstIn.push_back( bbtk::std2wx(bbGetInputIn4()) ); + lstIn.push_back( bbtk::std2wx(bbGetInputIn5()) ); + lstIn.push_back( bbtk::std2wx(bbGetInputIn6()) ); + lstIn.push_back( bbtk::std2wx(bbGetInputIn7()) ); + lstIn.push_back( bbtk::std2wx(bbGetInputIn8()) ); + lstIn.push_back( bbtk::std2wx(bbGetInputIn9()) ); + + + ( (RadioButtonWidget*)bbGetOutputWidget() )->AddElements(lstIn, bbGetInputIn() , bbtk::std2wx(bbGetInputTitle()) ); + + } /** @@ -241,7 +332,7 @@ namespace bbwx RadioButtonWidget *w = new RadioButtonWidget( this, // bbGetWxParent(), - parent, + parent, bbGetInputIn() , bbtk::std2wx(bbGetInputTitle()), lstIn );