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
145 for (i=0;i<lstIn.size(); i++)
147 wxlistbox->Append( bbtk::std2wx( lstIn[i] ) );
149 wxlistbox->SetSelection(iSelection);
152 for (i=0;i<lstIn.size(); i++)
154 wxchoice->Append( bbtk::std2wx( lstIn[i] ) );
156 wxchoice->SetSelection(iSelection);
160 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ComboBox)
161 BBTK_BLACK_BOX_IMPLEMENTATION(ComboBox,bbtk::WxBlackBox);
163 // 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)
165 void ComboBox::Process()
167 ComboBoxWidget *w = (ComboBoxWidget*)bbGetOutputWidget();
168 w->FillItems( bbGetInputSelection(),bbGetInputIn() );
172 // 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)
174 void ComboBox::CreateWidget(wxWindow* parent)
177 // bbSetOutputWidget( new wxStaticText ( parent , -1 , _T("") ) );
178 // bbSetOutputWidget( new wxComboBox ( parent , -1 , _T("ups") ) );
179 // bbSetOutputWidget( new wxChoice ( parent , -1 ) );
181 ComboBoxWidget *w = new ComboBoxWidget(
184 bbGetInputSelection() ,
189 bbSetOutputOut( bbGetInputSelection() );
190 bbSetOutputOutString( bbGetInputIn()[ bbGetInputSelection() ] );
191 bbSetOutputWidget( w );
196 // 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)
198 void ComboBox::bbUserSetDefaultValues()
200 bbSetInputSelection(0);
205 // 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)
207 void ComboBox::bbUserInitializeProcessing()
212 // 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)
214 void ComboBox::bbUserFinalizeProcessing()