2 // 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)
4 #include "bbwxComboBox.h"
5 #include "bbwxPackage.h"
11 #include <wx/choice.h>
12 #include <wx/control.h>
13 #include <wx/listbox.h>
17 //--------------------------------------------------------------------------
18 // The widget created by the box
19 class ComboBoxWidget : public wxPanel
22 ComboBoxWidget( ComboBox* box, wxWindow *parent,
25 std::vector< std::string > lstIn,
30 void OnComboBox(wxEvent& event);
31 void FillItems( int iSelection, std::vector< std::string > lstIn);
43 //------------------------------------------------------------------------
44 //------------------------------------------------------------------------
45 //------------------------------------------------------------------------
47 //-------------------------------------------------------------------------
48 ComboBoxWidget::ComboBoxWidget( ComboBox* box,
52 std::vector< std::string > lstIn,
55 wxPanel( parent, -1) ,
59 wxPanel *panel = this;
66 //---------------------------------------------------------------------
67 // 2) Insertion of the components in the window
69 // We use a FlexGridSizer
70 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
73 sizer->Add( new wxStaticText(panel,-1, bbtk::std2wx(title) ) );
75 sizer->AddGrowableCol(0);
76 panel->SetSizer(sizer);
79 //---------------------------------------------------------------------
80 // 1) Creation de wxChoise widget
85 wxlistbox = new wxListBox ( panel , -1 );
86 Connect( wxlistbox->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox );
87 for (i=0;i<lstIn.size(); i++)
89 wxlistbox->Append( bbtk::std2wx( lstIn[i] ) );
91 wxlistbox->SetSelection(iSelection);
92 sizer->Add( wxlistbox,1,wxGROW );
96 wxchoice = new wxChoice ( panel , -1 );
97 Connect( wxchoice->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox );
98 for (i=0;i<lstIn.size(); i++)
100 wxchoice->Append( bbtk::std2wx( lstIn[i] ) );
102 wxchoice->SetSelection(iSelection);
103 sizer->Add( wxchoice,1,wxGROW );
107 // panel->SetAutoLayout(true);
111 //-------------------------------------------------------------------------
113 ComboBoxWidget::~ComboBoxWidget()
117 //--------------------------------------------------------------------------
118 void ComboBoxWidget::OnComboBox(wxEvent& event)
123 iSelection = wxlistbox->GetSelection();
125 iSelection = wxchoice->GetSelection();
128 mBox->bbSetInputSelection( iSelection );
129 mBox->bbSetOutputOut( iSelection );
130 mBox->bbSetOutputOutString( bbtk::wx2std( wxchoice->GetString(iSelection) ) );
131 mBox->bbSignalOutputModification("Out");
132 mBox->bbSignalOutputModification("OutString");
135 //--------------------------------------------------------------------------
136 void ComboBoxWidget::FillItems(
138 std::vector< std::string > lstIn
146 for (i=0;i<lstIn.size(); i++)
148 wxlistbox->Append( bbtk::std2wx( lstIn[i] ) );
151 wxlistbox->SetSelection(iSelection);
154 for (i=0;i<lstIn.size(); i++)
156 wxchoice->Append( bbtk::std2wx( lstIn[i] ) );
158 wxchoice->SetSelection(iSelection);
162 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ComboBox)
163 BBTK_BLACK_BOX_IMPLEMENTATION(ComboBox,bbtk::WxBlackBox);
165 // 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)
167 void ComboBox::Process()
169 ComboBoxWidget *w = (ComboBoxWidget*)bbGetOutputWidget();
170 w->FillItems( bbGetInputSelection(),bbGetInputIn() );
174 // 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)
176 void ComboBox::CreateWidget(wxWindow* parent)
179 // bbSetOutputWidget( new wxStaticText ( parent , -1 , _T("") ) );
180 // bbSetOutputWidget( new wxComboBox ( parent , -1 , _T("ups") ) );
181 // bbSetOutputWidget( new wxChoice ( parent , -1 ) );
183 ComboBoxWidget *w = new ComboBoxWidget(
186 bbGetInputSelection() ,
191 bbSetOutputOut( bbGetInputSelection() );
192 bbSetOutputOutString( bbGetInputIn()[ bbGetInputSelection() ] );
193 bbSetOutputWidget( w );
198 // 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)
200 void ComboBox::bbUserSetDefaultValues()
202 bbSetInputSelection(0);
207 // 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)
209 void ComboBox::bbUserInitializeProcessing()
214 // 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)
216 void ComboBox::bbUserFinalizeProcessing()