X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=packages%2Fwx%2Fsrc%2FbbwxComboBox.cxx;h=e76d44f4d54443769211b03cf167c709b15d7eae;hb=3dcc408acd2264664ca6431a501378ea64233dd6;hp=4d4ce175e4909edac78f638703e2b3a8822a4ee7;hpb=6bbede25055ab1e1ad6a1ac4777131bd59efaecc;p=bbtk.git diff --git a/packages/wx/src/bbwxComboBox.cxx b/packages/wx/src/bbwxComboBox.cxx index 4d4ce17..e76d44f 100644 --- a/packages/wx/src/bbwxComboBox.cxx +++ b/packages/wx/src/bbwxComboBox.cxx @@ -9,6 +9,8 @@ #include #include +#include +#include namespace bbwx { @@ -20,14 +22,17 @@ namespace bbwx ComboBoxWidget( ComboBox* box, wxWindow *parent, int iSelection, std::string title, - std::vector< std::string > lstIn ); + std::vector< std::string > lstIn, + int typeForm ); ~ComboBoxWidget(); void OnComboBox(wxEvent& event); private: - ComboBox *mBox; + int mTypeForm; + ComboBox *mBox; + wxListBox *wxlistbox; wxChoice *wxchoice; }; @@ -42,28 +47,19 @@ namespace bbwx wxWindow *parent, int iSelection, std::string title, - std::vector< std::string > lstIn ) + std::vector< std::string > lstIn, + int typeForm) : wxPanel( parent, -1) , - mBox(box) + mBox(box), + mTypeForm(typeForm) { - wxPanel *panel = this; + wxPanel *panel = this; + wxlistbox = NULL; + wxchoice = NULL; + int i; - - //--------------------------------------------------------------------- - // 1) Creation de wxChoise widget - - wxchoice = new wxChoice ( panel , -1 ); - - Connect( wxchoice->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); - - int i; - for (i=0;iAppend( bbtk::std2wx( lstIn[i] ) ); - } // for i - wxchoice->SetSelection(iSelection); //--------------------------------------------------------------------- // 2) Insertion of the components in the window @@ -74,10 +70,38 @@ namespace bbwx { sizer->Add( new wxStaticText(panel,-1, bbtk::std2wx(title) ) ); } - sizer->Add( wxchoice,1,wxGROW ); sizer->AddGrowableCol(0); panel->SetSizer(sizer); + + //--------------------------------------------------------------------- + // 1) Creation de wxChoise widget + + if (mTypeForm==1) + { + + wxlistbox = new wxListBox ( panel , -1 ); + Connect( wxlistbox->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); + for (i=0;iAppend( bbtk::std2wx( lstIn[i] ) ); + } // for i + wxlistbox->SetSelection(iSelection); + sizer->Add( wxlistbox,1,wxGROW ); + + } else { + + wxchoice = new wxChoice ( panel , -1 ); + Connect( wxchoice->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox ); + for (i=0;iAppend( bbtk::std2wx( lstIn[i] ) ); + } // for i + wxchoice->SetSelection(iSelection); + sizer->Add( wxchoice,1,wxGROW ); + } + + // panel->SetAutoLayout(true); // panel->Layout(); @@ -91,10 +115,15 @@ namespace bbwx //-------------------------------------------------------------------------- void ComboBoxWidget::OnComboBox(wxEvent& event) { + int iSelection; + if (mTypeForm==1) + { + iSelection = wxlistbox->GetSelection(); + } else { + iSelection = wxchoice->GetSelection(); + } - int iSelection = wxchoice->GetSelection(); mBox->bbSetInputSelection( iSelection ); - mBox->bbSetOutputOut( iSelection ); mBox->bbSetOutputOutString( bbtk::wx2std( wxchoice->GetString(iSelection) ) ); mBox->bbSignalOutputModification("Out"); @@ -125,7 +154,8 @@ void ComboBox::CreateWidget(wxWindow* parent) parent, bbGetInputSelection() , bbGetInputTitle(), - bbGetInputIn() ); + bbGetInputIn(), + bbGetInputForm() ); bbSetOutputOut( bbGetInputSelection() ); bbSetOutputOutString( bbGetInputIn()[ bbGetInputSelection() ] ); @@ -140,6 +170,7 @@ void ComboBox::bbUserSetDefaultValues() { bbSetInputSelection(0); bbSetInputTitle(""); + bbSetInputForm(0); } //===== // 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)