int iSelection,
std::string title,
std::vector< std::string > lstIn,
- int typeForm );
+ int typeForm,
+ int sizeX, int sizeY );
~ComboBoxWidget();
void OnComboBoxSelection(int iSelection);
void OnComboBox(wxEvent& event);
private:
int mTypeForm;
ComboBox *mBox;
- wxListBox *wxlistbox;
- wxChoice *wxchoice;
+ wxItemContainer* itemcontainer;
};
//-------------------------------------------------------------------------
ComboBoxWidget::ComboBoxWidget( ComboBox* box,
- wxWindow *parent,
- int iSelection,
- std::string title,
- std::vector< std::string > lstIn,
- int typeForm)
+ wxWindow *parent,
+ int iSelection,
+ std::string title,
+ std::vector< std::string > lstIn,
+ int typeForm,
+ int sizeX,
+ int sizeY
+ )
:
wxPanel( parent, -1) ,
mBox(box),
mTypeForm(typeForm)
{
wxPanel *panel = this;
- wxlistbox = NULL;
- wxchoice = NULL;
+ itemcontainer = NULL;
int i;
//---------------------------------------------------------------------
}
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();
+ if (mTypeForm==1)
+ {
+ wxListBox *wxlistbox = new wxListBox ( panel , -1 , wxDefaultPosition,wxSize(sizeX,sizeY),0, NULL, wxLB_SINGLE );
+ itemcontainer=wxlistbox;
+ sizer->Add( wxlistbox,1,wxEXPAND );
+ Connect( wxlistbox->GetId(),
+ wxEVT_COMMAND_LISTBOX_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox );
+ } else if (mTypeForm==0) {
+ wxChoice *wxchoice = new wxChoice ( panel , -1 );
+ itemcontainer=wxchoice;
+ sizer->Add( wxchoice,1,wxGROW );
+ Connect( wxchoice->GetId(),
+ wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox );
+ }
+ for (i=0;i<lstIn.size(); i++)
+ {
+ itemcontainer->Append( bbtk::std2wx( lstIn[i] ) );
+ } // for i
+ itemcontainer->SetSelection(iSelection);
}
//-------------------------------------------------------------------------
//--------------------------------------------------------------------------
void ComboBoxWidget::OnComboBoxSelection(int iSelection)
{
- mBox->bbSetInputSelection( iSelection );
- mBox->bbSetOutputOut( iSelection );
- mBox->bbSetOutputOutString( bbtk::wx2std( wxchoice->GetString(iSelection) ) );
- mBox->bbSignalOutputModification("Out");
- mBox->bbSignalOutputModification("OutString");
+ if (iSelection>=0)
+ {
+ mBox->bbSetInputSelection( iSelection );
+ mBox->bbSetOutputOut( iSelection );
+ mBox->bbSetOutputOutString( bbtk::wx2std( itemcontainer->GetString(iSelection) ) );
+ mBox->bbSignalOutputModification("Out");
+ mBox->bbSignalOutputModification("OutString");
+ } // if iSelection
}
//--------------------------------------------------------------------------
void ComboBoxWidget::OnComboBox(wxEvent& event)
{
- int iSelection;
- if (mTypeForm==1)
- {
- iSelection = wxlistbox->GetSelection();
- } else {
- iSelection = wxchoice->GetSelection();
- }
- OnComboBoxSelection(iSelection);
+ OnComboBoxSelection( itemcontainer->GetSelection() );
}
//--------------------------------------------------------------------------
- void ComboBoxWidget::FillItems(
- int iSelection,
- std::vector< std::string > lstIn
- )
+ 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
+ itemcontainer->Clear();
+ for (i=0;i<lstIn.size(); i++)
+ {
+ itemcontainer->Append( bbtk::std2wx( lstIn[i] ) );
+ } // for i
+ itemcontainer->SetSelection(iSelection);
}
BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ComboBox)
{
bbSetOutputOutString( bbGetInputIn()[ iSelection ] );
}
-// bbSignalOutputModification("Out");
-// bbSignalOutputModification("OutString");
}
//=====
//=====
void ComboBox::CreateWidget(wxWindow* parent)
{
-
-// bbSetOutputWidget( new wxStaticText ( parent , -1 , _T("") ) );
-// bbSetOutputWidget( new wxComboBox ( parent , -1 , _T("ups") ) );
-// bbSetOutputWidget( new wxChoice ( parent , -1 ) );
-
ComboBoxWidget *w = new ComboBoxWidget(
this,
parent,
bbGetInputSelection() ,
bbGetInputTitle(),
bbGetInputIn(),
- bbGetInputForm() );
-
+ bbGetInputForm(),
+ bbGetInputWinWidth(), bbGetInputWinHeight() );
bbSetOutputOut( bbGetInputSelection() );
bbSetOutputOutString( bbGetInputIn()[ bbGetInputSelection() ] );
bbSetOutputWidget( w );
-
-
}
//=====
// 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)
bbSetInputSelection(0);
bbSetInputTitle("");
bbSetInputForm(0);
+ bbSetInputWinWidth(100);
+ bbSetInputWinHeight(200);
}
//=====
// 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)