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);
41 //------------------------------------------------------------------------
42 //------------------------------------------------------------------------
43 //------------------------------------------------------------------------
45 //-------------------------------------------------------------------------
46 ComboBoxWidget::ComboBoxWidget( ComboBox* box,
50 std::vector< std::string > lstIn,
53 wxPanel( parent, -1) ,
57 wxPanel *panel = this;
64 //---------------------------------------------------------------------
65 // 2) Insertion of the components in the window
67 // We use a FlexGridSizer
68 wxFlexGridSizer *sizer = new wxFlexGridSizer(1);
71 sizer->Add( new wxStaticText(panel,-1, bbtk::std2wx(title) ) );
73 sizer->AddGrowableCol(0);
74 panel->SetSizer(sizer);
77 //---------------------------------------------------------------------
78 // 1) Creation de wxChoise widget
83 wxlistbox = new wxListBox ( panel , -1 );
84 Connect( wxlistbox->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox );
85 for (i=0;i<lstIn.size(); i++)
87 wxlistbox->Append( bbtk::std2wx( lstIn[i] ) );
89 wxlistbox->SetSelection(iSelection);
90 sizer->Add( wxlistbox,1,wxGROW );
94 wxchoice = new wxChoice ( panel , -1 );
95 Connect( wxchoice->GetId(), wxEVT_COMMAND_CHOICE_SELECTED, (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))&ComboBoxWidget::OnComboBox );
96 for (i=0;i<lstIn.size(); i++)
98 wxchoice->Append( bbtk::std2wx( lstIn[i] ) );
100 wxchoice->SetSelection(iSelection);
101 sizer->Add( wxchoice,1,wxGROW );
105 // panel->SetAutoLayout(true);
109 //-------------------------------------------------------------------------
111 ComboBoxWidget::~ComboBoxWidget()
115 //--------------------------------------------------------------------------
116 void ComboBoxWidget::OnComboBox(wxEvent& event)
121 iSelection = wxlistbox->GetSelection();
123 iSelection = wxchoice->GetSelection();
126 mBox->bbSetInputSelection( iSelection );
127 mBox->bbSetOutputOut( iSelection );
128 mBox->bbSetOutputOutString( bbtk::wx2std( wxchoice->GetString(iSelection) ) );
129 mBox->bbSignalOutputModification("Out");
130 mBox->bbSignalOutputModification("OutString");
134 BBTK_ADD_BLACK_BOX_TO_PACKAGE(wx,ComboBox)
135 BBTK_BLACK_BOX_IMPLEMENTATION(ComboBox,bbtk::WxBlackBox);
137 // 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)
139 void ComboBox::Process()
143 // 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)
145 void ComboBox::CreateWidget(wxWindow* parent)
148 // bbSetOutputWidget( new wxStaticText ( parent , -1 , _T("") ) );
149 // bbSetOutputWidget( new wxComboBox ( parent , -1 , _T("ups") ) );
150 // bbSetOutputWidget( new wxChoice ( parent , -1 ) );
152 ComboBoxWidget *w = new ComboBoxWidget(
155 bbGetInputSelection() ,
160 bbSetOutputOut( bbGetInputSelection() );
161 bbSetOutputOutString( bbGetInputIn()[ bbGetInputSelection() ] );
162 bbSetOutputWidget( w );
167 // 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)
169 void ComboBox::bbUserSetDefaultValues()
171 bbSetInputSelection(0);
176 // 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)
178 void ComboBox::bbUserInitializeProcessing()
183 // 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)
185 void ComboBox::bbUserFinalizeProcessing()