#include #include #include #include #include #include #include #include #include "GWt_dialog.h" GWt_dialog::GWt_dialog( WString titre, WContainerWidget* wc, bool modal ): WDialog(titre+" ") { // change the title bar style titleBar()->decorationStyle().setBackgroundColor (WColor(70,180,220)); WContainerWidget* widgt = new WContainerWidget(contents()); vDialogLayout_ = new WVBoxLayout(); widgt->setLayout(vDialogLayout_); setClosable(true); setModal (modal); setResizable(true); show(); if (wc != NULL) { addVContent(wc); } } GWt_dialog::GWt_dialog( WString titre, WString message, iconType icon, bool modal, bool ok ): WDialog(titre) { // change the title bar style titleBar()->decorationStyle().setBackgroundColor (WColor(70,180,220)); WContainerWidget* widgt = new WContainerWidget(contents()); WHBoxLayout* hLayout = new WHBoxLayout(); WImage* tImg = new WImage("icons/error.png"); switch (icon) { case Warning: tImg->setImageLink ("icons/warning.png"); tImg->setMaximumSize (70,70); hLayout->addWidget(tImg); break; case Error: tImg->setImageLink ("icons/error.png"); tImg->setMaximumSize (70,70); hLayout->addWidget(tImg); break; case Info: tImg->setImageLink ("icons/info.png"); tImg->setMaximumSize (70,70); hLayout->addWidget(tImg); break; case Wait: tImg->setImageLink ("icons/patientez.gif"); tImg->setMaximumSize (70,70); hLayout->addWidget(tImg); break; case NoIcon: break; default: break; } WContainerWidget* right = new WContainerWidget(); WVBoxLayout* vLayout = new WVBoxLayout(); // changement des "\n" par des
size_t pos = message.toUTF8().find("\n", 0); while(pos != std::string::npos) { vLayout->addWidget(new Wt::WText(WString::fromUTF8(message.toUTF8 ().substr(0,pos)))); message = message.toUTF8 ().substr(pos+1); pos = message.toUTF8 ().find("\n"); vLayout->addWidget(new Wt::WBreak()); } vLayout->addWidget(new Wt::WText(message)); if (ok) { vLayout->addWidget(new Wt::WBreak); Wt::WPushButton *ok = new Wt::WPushButton("Ok"); vLayout->addWidget(ok); // this event will accept() the Dialog ok->clicked().connect(this, &Wt::WDialog::accept); } right->setLayout(vLayout); hLayout->addWidget(right); widgt->setLayout(hLayout); setClosable(true); setModal (modal); } void GWt_dialog::addVContent(WContainerWidget* wc) { if (vDialogLayout_) { vDialogLayout_->addWidget(wc); } }