//===== // 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 "bbwtCommandButton.h" #include "bbwtPackage.h" #include "bbtkInterpreter.h" #include "bbtkExecuter.h" namespace bbwt { //--------------------------------------------------------------------------------- class CommandButtonWidget : public Wt::WContainerWidget { public: CommandButtonWidget(CommandButton* box, Wt::WContainerWidget *parent, Wt::WString label); ~CommandButtonWidget(); void OnCommandButton(); void SetLabel(Wt::WString nLabel); private: CommandButton* mBox; Wt::WPushButton *mwtPushButton; }; //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- CommandButtonWidget::CommandButtonWidget(CommandButton* box, Wt::WContainerWidget *parent, Wt::WString label) : Wt::WContainerWidget(parent), mBox(box) { Wt::WContainerWidget *container = this; mwtPushButton = new Wt::WPushButton(label,parent); mwtPushButton->setMinimumSize(170,30); mwtPushButton->clicked().connect(this, &CommandButtonWidget::OnCommandButton); container->addWidget(mwtPushButton); } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- CommandButtonWidget::~CommandButtonWidget() { } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- void CommandButtonWidget::OnCommandButton() { bbtk::Interpreter::Pointer I; bbtk::VirtualExec::Pointer E; if (mBox->bbGetParent() != 0) { bbtk::Factory::Pointer f = boost::dynamic_pointer_cast(mBox->bbGetParent()->bbGetDescriptor())->GetFactory(); if ((f != 0)&& (f->GetExecuter())) { E = f->GetExecuter(); I = E->GetInterpreter(); } } if (I==0) { // bbtkError("CommandButton::DoProcess() : could not find interpreter"); if (E==0) { // If no executer : create a totally independant interpreter I = bbtk::Interpreter::New(); } else { // If executer : create an interpreter using E I = bbtk::Interpreter::New(E); } } std::string commandstr(mBox->bbGetInputIn()); // bbtk::Interpreter::mGlobalInterpreter->InterpretLine( commandstr ); unsigned int i; bool ok=true; int pos1=0,pos2; pos2 = commandstr.find(";",pos1); std::string ccommand; while (ok==true) { if (pos2==-1) { ok=false; ccommand=commandstr.substr(pos1,commandstr.length()-pos1 ); } else { ccommand=commandstr.substr(pos1,pos2-pos1); } for ( i=0 ; i < ccommand.length() ; i++) { if (ccommand[i]==39) // ' { ccommand[i]=34; // " } } I->InterpretLine( ccommand ); pos1=pos2+1; pos2 = commandstr.find(";",pos2+1); } mBox->UpdateLabel(); mBox->bbSignalOutputModification(); } //-------------------------------------------------------------------------- //-------------------------------------------------------------------------- void CommandButtonWidget::SetLabel(Wt::WString nLabel) { mwtPushButton->setText(nLabel); } BBTK_ADD_BLACK_BOX_TO_PACKAGE(wt,CommandButton) BBTK_BLACK_BOX_IMPLEMENTATION(CommandButton,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 CommandButton::Process() { CommandButtonWidget* w = (CommandButtonWidget*)bbGetOutputWidget(); if (w) { UpdateLabel(); } } //===== // 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 CommandButton::CreateWidget(Wt::WContainerWidget* parent) { bbSetOutputWidget( new CommandButtonWidget(this, parent, bbtk::std2wt(bbGetInputLabel()) ) ); } //-------------------------------------------------------------------------------------- void CommandButton::UpdateLabel() { CommandButtonWidget* wtWidget = (CommandButtonWidget*)bbGetOutputWidget(); wtWidget->SetLabel( bbtk::std2wt( bbGetInputLabel() ) ); } //===== // 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 CommandButton::bbUserSetDefaultValues() { bbSetInputIn(""); bbSetInputLabel(""); bbSetOutputWidget(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 CommandButton::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 CommandButton::bbUserFinalizeProcessing() { } } // EO namespace bbwt