#include <string>
#include <wx/choice.h>
+#include <wx/control.h>
+#include <wx/listbox.h>
namespace bbwx
{
{
public:
ComboBoxWidget( ComboBox* box, wxWindow *parent,
- int iSelection,
- std::string title,
- std::vector< std::string > lstIn );
-
+ int iSelection,
+ std::string title,
+ std::vector< std::string > lstIn,
+ int typeForm );
~ComboBoxWidget();
-
+ void OnComboBox(int iSelection);
void OnComboBox(wxEvent& event);
+ void FillItems( int iSelection, std::vector< std::string > lstIn);
private:
- ComboBox *mBox;
- wxChoice *wxchoice;
+ int mTypeForm;
+ ComboBox *mBox;
+ wxListBox *wxlistbox;
+ wxChoice *wxchoice;
};
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;
-
-
-
- //---------------------------------------------------------------------
- // 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;i<lstIn.size(); i++)
- {
- wxchoice->Append( bbtk::std2wx( lstIn[i] ) );
- } // for i
- wxchoice->SetSelection(iSelection);
+ wxPanel *panel = this;
+ wxlistbox = NULL;
+ wxchoice = NULL;
+ int i;
//---------------------------------------------------------------------
// 2) Insertion of the components in the window
{
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;i<lstIn.size(); i++)
+ {
+ wxlistbox->Append( 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;i<lstIn.size(); i++)
+ {
+ wxchoice->Append( bbtk::std2wx( lstIn[i] ) );
+ } // for i
+ wxchoice->SetSelection(iSelection);
+ sizer->Add( wxchoice,1,wxGROW );
+ }
// panel->SetAutoLayout(true);
// panel->Layout();
-
}
//-------------------------------------------------------------------------
{
}
+
//--------------------------------------------------------------------------
- void ComboBoxWidget::OnComboBox(wxEvent& event)
+ void ComboBoxWidget::OnComboBox(int iSelection)
{
-
- int iSelection = wxchoice->GetSelection();
mBox->bbSetInputSelection( iSelection );
-
mBox->bbSetOutputOut( iSelection );
mBox->bbSetOutputOutString( bbtk::wx2std( wxchoice->GetString(iSelection) ) );
mBox->bbSignalOutputModification("Out");
mBox->bbSignalOutputModification("OutString");
}
+ //--------------------------------------------------------------------------
+ void ComboBoxWidget::OnComboBox(wxEvent& event)
+ {
+ int iSelection;
+ if (mTypeForm==1)
+ {
+ iSelection = wxlistbox->GetSelection();
+ } else {
+ iSelection = wxchoice->GetSelection();
+ }
+ OnComboBox(iSelection);
+ }
+//--------------------------------------------------------------------------
+ void ComboBoxWidget::FillItems(
+ int iSelection,
+ std::vector< std::string > lstIn
+ )
+ {
+ int i;
+ if (mTypeForm==1)
+ {
+ wxlistbox->Clear();
+
+ for (i=0;i<lstIn.size(); i++)
+ {
+ wxlistbox->Append( bbtk::std2wx( lstIn[i] ) );
+ } // for i
+
+ wxlistbox->SetSelection(iSelection);
+ } else {
+ wxchoice->Clear();
+ for (i=0;i<lstIn.size(); i++)
+ {
+ wxchoice->Append( bbtk::std2wx( lstIn[i] ) );
+ } // for i
+ wxchoice->SetSelection(iSelection);
+ } // if
+ }
BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ComboBox)
BBTK_BLACK_BOX_IMPLEMENTATION(ComboBox,bbtk::WxBlackBox);
//=====
void ComboBox::Process()
{
+ int iSelection = bbGetInputSelection();
+ if (bbGetInputSelection() >= bbGetInputIn().size()) { iSelection=bbGetInputIn().size()-1; }
+ ComboBoxWidget *w = (ComboBoxWidget*)bbGetOutputWidget();
+ w->FillItems( iSelection, bbGetInputIn() );
+ bbSetInputSelection( iSelection );
+ bbSetOutputOut( iSelection );
+ bbSetOutputOutString( bbGetInputIn()[ iSelection ] );
+// bbSignalOutputModification("Out");
+// bbSignalOutputModification("OutString");
+
}
+
//=====
// 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)
//=====
ComboBoxWidget *w = new ComboBoxWidget(
this,
- parent,
+ parent,
bbGetInputSelection() ,
bbGetInputTitle(),
- bbGetInputIn() );
+ bbGetInputIn(),
+ bbGetInputForm() );
bbSetOutputOut( bbGetInputSelection() );
bbSetOutputOutString( bbGetInputIn()[ bbGetInputSelection() ] );
{
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)