//===== // 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) //===== #include "bbwtComboBox.h" #include "bbwtPackage.h" namespace bbwt { class ComboBoxWidget : public Wt::WContainerWidget { public: ComboBoxWidget(ComboBox* box, Wt::WContainerWidget *parent, int iSelection, Wt::WString title, int typeForm); ~ComboBoxWidget(); void OnComboBox(); void SetItems( std::vector lstIn ); private: int mTypeForm; ComboBox *mBox; Wt::WComboBox *wtCmbBox; Wt::WSelectionBox *wtSlctBox; Wt::WComboBox *selection; //TODO choice }; //------------------------------------------------------------------------ //------------------------------------------------------------------------ //------------------------------------------------------------------------ ComboBoxWidget::ComboBoxWidget(ComboBox* box, Wt::WContainerWidget *parent, int iSelection, Wt::WString title, int typeForm) : Wt::WContainerWidget(parent), mBox(box), mTypeForm(typeForm) { Wt::WContainerWidget *panel = this; Wt::WBorderLayout *layout = new Wt::WBorderLayout(); int i; if(title!="") { layout->addWidget(new Wt::WText(title),Wt::WBorderLayout::North); } if(mTypeForm == 0) { wtCmbBox = new Wt::WComboBox(); selection = wtCmbBox; } else { wtSlctBox = new Wt::WSelectionBox(); // wtSlctBox->setSelectionMode(Wt::ExtendedSelection); selection = wtSlctBox; } selection->activated().connect(this,&ComboBoxWidget::OnComboBox); layout->addWidget(selection,Wt::WBorderLayout::Center); panel->setLayout(layout); } //------------------------------------------------------------------------- ComboBoxWidget::~ComboBoxWidget() { } //-------------------------------------------------------------------------- void ComboBoxWidget::OnComboBox() { mBox->bbSetInputSelection( selection->currentIndex() ); mBox->bbSetOutputOut( selection->currentIndex() ); mBox->bbSetOutputOutString( bbtk::wt2std( selection->valueText() ) ); mBox->bbSignalOutputModification("Out"); mBox->bbSignalOutputModification("OutString"); } //-------------------------------------------------------------------------- void ComboBoxWidget::SetItems( std::vector lstIn ) { int i; selection->clear(); for (i=0;iaddItem(bbtk::std2wt(lstIn[i])); } // for i } BBTK_ADD_BLACK_BOX_TO_PACKAGE(wt,ComboBox) BBTK_BLACK_BOX_IMPLEMENTATION(ComboBox,bbtk::WtBlackBox); //===== // 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) //===== void ComboBox::Process() { ComboBoxWidget *widget = (ComboBoxWidget *)bbGetOutputWidget(); widget->SetItems( bbGetInputIn() ); bbSetOutputOut( 0 ); if (bbGetInputIn().size()>0) { bbSetOutputOutString( bbGetInputIn()[0] ); } else { bbSetOutputOutString( "" ); } } //===== // 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) //===== void ComboBox::CreateWidget(Wt::WContainerWidget* parent) { ComboBoxWidget *w = new ComboBoxWidget( this, parent, bbGetInputSelection() , bbGetInputTitle(), // bbGetInputIn(), bbGetInputForm() ); 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) //===== void ComboBox::bbUserSetDefaultValues() { 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) //===== void ComboBox::bbUserInitializeProcessing() { } //===== // 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) //===== void ComboBox::bbUserFinalizeProcessing() { } } // EO namespace bbwt