void WMenuItem::setChecked(bool checked) { if (isCheckable()) { WCheckBox *cb = dynamic_cast<WCheckBox *>(anchor()->widget(0)); cb->setChecked(checked); } }
bool WMenuItem::isChecked() const { if (isCheckable()) { WCheckBox *cb = dynamic_cast<WCheckBox *>(anchor()->widget(0)); return cb->isChecked(); } else return false; }
void CCheckBoxTreeView::ClearRightCellCheck() { TreeRightMap::iterator lRight; for(lRight =mGroupRightMap.begin();lRight !=mGroupRightMap.end();lRight ++) { WCheckBox *pCheckbox; pCheckbox =(WCheckBox *) lRight->second; if( pCheckbox->isChecked()) pCheckbox->setChecked(false); } for(lRight =mDeviceRightMap.begin();lRight !=mDeviceRightMap.end();lRight ++) { WCheckBox *pCheckbox; pCheckbox =(WCheckBox *) lRight->second; if( pCheckbox->isChecked()) pCheckbox->setChecked(false); } for(lRight =mMonitorRightMap.begin();lRight !=mMonitorRightMap.end();lRight ++) { OutputDebugString("Tree_DEVICE\n"); WCheckBox *pCheckbox; pCheckbox =(WCheckBox *) lRight->second; if( pCheckbox->isChecked()) pCheckbox->setChecked(false); } }
void AdsEditor::renderUI() { AdsApplication *app = AdsApplication::adsApplication(); cppdb::session &db = app->db_; clear(); WPushButton *btn = new WPushButton("Criar Anuncio", this); btn->clicked().connect(this, &AdsEditor::novoAnuncio); WPushButton *update = new WPushButton("Atualiza", this); update->clicked().connect(this, &AdsEditor::renderUI); new WBreak(this); new WBreak(this); new WText("<h3>Lista de Anuncios</h3>",this); Wt::WContainerWidget *w = new Wt::WContainerWidget(this); w->resize(600, WLength::Auto); WVBoxLayout *layout = new Wt::WVBoxLayout(); cppdb::result res = db << "select id, titulo, url, imagem, texto, ativo " " from anuncio"; while(res.next()) { WContainerWidget *cont = new WContainerWidget(); AdsAnuncio *anuncio = new AdsAnuncio(cont); res >> anuncio->id >> anuncio->titulo_ >> anuncio->link_ >> anuncio->imagem_ >> anuncio->texto_ >> anuncio->ativo_; WPushButton *tituloBtn = new WPushButton("Titulo",cont); tituloBtn->clicked().connect(anuncio, &AdsAnuncio::editarTitulo); WPushButton *urlBtn = new WPushButton("URL",cont); urlBtn->clicked().connect(anuncio, &AdsAnuncio::editarURL); WPushButton *imagemBtn = new WPushButton("Imagem",cont); imagemBtn->clicked().connect(anuncio, &AdsAnuncio::editarImagem); WPushButton *textoBtn = new WPushButton("Texto",cont); textoBtn->clicked().connect(anuncio, &AdsAnuncio::editarTexto); WCheckBox *ativoCheck = new Wt::WCheckBox("Ativo",cont); if(anuncio->ativo_ == 1) ativoCheck->setChecked(true); else ativoCheck->setChecked(false); ativoCheck->changed().connect(anuncio, &AdsAnuncio::changeAtiva); WPushButton *deletaBtn = new WPushButton("Deleta",cont); deletaBtn->clicked().connect(anuncio, &AdsAnuncio::deletaAnuncio); anuncio->renderUI(); layout->addWidget(cont); } w->setLayout(layout); }
GravatarApp(const WEnvironment& env): WApplication(env) { GravatarImage* gravatar = new GravatarImage("*****@*****.**", root()); new WBreak(root()); WLineEdit* email = new WLineEdit(root()); email->changed().connect(boost::bind(set_email, gravatar, email)); email->setText("*****@*****.**"); new WBreak(root()); WSlider* size = new WSlider(root()); size->setRange(1, 512); size->setValue(80); size->valueChanged().connect(boost::bind(set_size, gravatar, size)); new WBreak(root()); WButtonGroup* builtin = new WButtonGroup(this); builtin->addButton(new WRadioButton("default", root()), GravatarImage::DEFAULT); builtin->addButton(new WRadioButton("404", root()), GravatarImage::RETURN_404); builtin->addButton(new WRadioButton("mm", root()), GravatarImage::MM); builtin->addButton(new WRadioButton("identicon", root()), GravatarImage::IDENTICON); builtin->addButton(new WRadioButton("monsterid", root()), GravatarImage::MONSTERID); builtin->addButton(new WRadioButton("wavatar", root()), GravatarImage::WAVATAR); builtin->addButton(new WRadioButton("retro", root()), GravatarImage::RETRO); builtin->addButton(new WRadioButton("custom url", root()), 9000); WLineEdit* custom_url = new WLineEdit(root()); custom_url->setText("https://www.google.com/favicon.ico"); builtin->setCheckedButton(builtin->button(GravatarImage::DEFAULT)); builtin->checkedChanged().connect(boost::bind(set_default, gravatar, builtin, custom_url)); new WBreak(root()); WButtonGroup* rating = new WButtonGroup(this); rating->addButton(new WRadioButton("G", root()), GravatarImage::G); rating->addButton(new WRadioButton("PG", root()), GravatarImage::PG); rating->addButton(new WRadioButton("R", root()), GravatarImage::R); rating->addButton(new WRadioButton("X", root()), GravatarImage::X); rating->setCheckedButton(rating->button(GravatarImage::G)); rating->checkedChanged().connect(boost::bind(set_rating, gravatar, rating)); new WBreak(root()); WCheckBox* fd = new WCheckBox("Force default", root()); fd->checked().connect(boost::bind(&GravatarImage::set_force_default, gravatar, true)); fd->unChecked().connect(boost::bind(&GravatarImage::set_force_default, gravatar, false)); new WBreak(root()); WCheckBox* sr = new WCheckBox("Use https", root()); sr->setTristate(); sr->setCheckState(PartiallyChecked); sr->checked().connect(boost::bind(&GravatarImage::set_secure_requests, gravatar, GravatarImage::ALWAYS)); sr->unChecked().connect(boost::bind(&GravatarImage::set_secure_requests, gravatar, GravatarImage::NEVER)); }
void SimpleChatWidget::updateUsers() { if (userList_) { userList_->clear(); SimpleChatServer::UserSet users = server_.users(); UserMap oldUsers = users_; users_.clear(); for (SimpleChatServer::UserSet::iterator i = users.begin(); i != users.end(); ++i) { WCheckBox *w = new WCheckBox(escapeText(*i), userList_); w->setInline(false); UserMap::const_iterator j = oldUsers.find(*i); if (j != oldUsers.end()) w->setChecked(j->second); else w->setChecked(true); users_[*i] = w->isChecked(); w->changed().connect(this, &SimpleChatWidget::updateUser); if (*i == user_) w->setStyleClass("chat-self"); } } }
WWidget *FormWidgets::wCheckBox() { WContainerWidget *result = new WContainerWidget(); topic("WCheckBox", result); addText(tr("formwidgets-WCheckBox"), result); WCheckBox *cb = new WCheckBox("Check me!", result); cb->setChecked(true); ed_->showSignal(cb->checked(), "'Check me!' checked"); ed_->showSignal(cb->unChecked(), "'Check me!' unchecked"); new WBreak(result); cb = new WCheckBox("Check me too!", result); ed_->showSignal(cb->checked(), "'Check me too!' checked"); new WBreak(result); cb = new WCheckBox("Check me, I'm tristate!", result); cb->setTristate(); cb->setCheckState(PartiallyChecked); ed_->showSignal(cb->checked(), "'Check me, I'm tristate!' checked"); return result; }
void SimpleChatWidget::updateUser() { WCheckBox *b = dynamic_cast<WCheckBox *>(sender()); users_[b->text()] = b->isChecked(); }
void WBootstrapTheme::apply(WWidget *widget, DomElement& element, int elementRole) const { { WPopupWidget *popup = dynamic_cast<WPopupWidget *>(widget); if (popup) { WDialog *dialog = dynamic_cast<WDialog *>(widget); if (!dialog) element.addPropertyWord(PropertyClass, "dropdown-menu"); } } switch (element.type()) { case DomElement_A: if (dynamic_cast<WPushButton *>(widget)) element.addPropertyWord(PropertyClass, "btn"); break; case DomElement_BUTTON: { element.addPropertyWord(PropertyClass, "btn"); WPushButton *button = dynamic_cast<WPushButton *>(widget); if (button) { if (button->isDefault()) element.addPropertyWord(PropertyClass, "btn-primary"); if (button->menu()) { element.addPropertyWord(PropertyInnerHTML, "<span class=\"caret\"></span>"); } } break; } case DomElement_DIV: { WDialog *dialog = dynamic_cast<WDialog *>(widget); if (dialog) { element.addPropertyWord(PropertyClass, "modal"); return; } WPanel *panel = dynamic_cast<WPanel *>(widget); if (panel) { element.addPropertyWord(PropertyClass, "accordion-group"); return; } WProgressBar *bar = dynamic_cast<WProgressBar *>(widget); if (bar) { switch (elementRole) { case MainElementThemeRole: element.addPropertyWord(PropertyClass, "progress"); break; case ProgressBarBarRole: element.addPropertyWord(PropertyClass, "bar"); break; case ProgressBarLabelRole: element.addPropertyWord(PropertyClass, "bar-label"); } return; } WGoogleMap *map = dynamic_cast<WGoogleMap *>(widget); if (map) { element.addPropertyWord(PropertyClass, "Wt-googlemap"); return; } WAbstractItemView *itemView = dynamic_cast<WAbstractItemView *>(widget); if (itemView) { element.addPropertyWord(PropertyClass, "form-horizontal"); return; } } break; case DomElement_LABEL: { WCheckBox *cb = dynamic_cast<WCheckBox *>(widget); if (cb) { element.addPropertyWord(PropertyClass, "checkbox"); if (cb->isInline()) element.addPropertyWord(PropertyClass, "inline"); } else { WRadioButton *rb = dynamic_cast<WRadioButton *>(widget); if (rb) { element.addPropertyWord(PropertyClass, "radio"); if (rb->isInline()) element.addPropertyWord(PropertyClass, "inline"); } } } break; case DomElement_LI: { WMenuItem *item = dynamic_cast<WMenuItem *>(widget); if (item) { if (item->isSeparator()) element.addPropertyWord(PropertyClass, "divider"); if (item->isSectionHeader()) element.addPropertyWord(PropertyClass, "nav-header"); } } break; case DomElement_INPUT: { WAbstractSpinBox *spinBox = dynamic_cast<WAbstractSpinBox *>(widget); if (spinBox) { element.addPropertyWord(PropertyClass, "Wt-spinbox"); return; } WDateEdit *dateEdit = dynamic_cast<WDateEdit *>(widget); if (dateEdit) { element.addPropertyWord(PropertyClass, "Wt-dateedit"); return; } } break; case DomElement_UL: { WPopupMenu *popupMenu = dynamic_cast<WPopupMenu *>(widget); if (popupMenu) element.addPropertyWord(PropertyClass, "dropdown-menu"); else { WMenu *menu = dynamic_cast<WMenu *>(widget); if (menu) { element.addPropertyWord(PropertyClass, "nav"); WTabWidget *tabs = dynamic_cast<WTabWidget *>(menu->parent()->parent()); if (tabs) element.addPropertyWord(PropertyClass, "nav-tabs"); } else { WSuggestionPopup *suggestions = dynamic_cast<WSuggestionPopup *>(widget); if (suggestions) element.addPropertyWord(PropertyClass, "typeahead"); } } } case DomElement_SPAN: { WInPlaceEdit *inPlaceEdit = dynamic_cast<WInPlaceEdit *>(widget); if (inPlaceEdit) element.addPropertyWord(PropertyClass, "Wt-in-place-edit"); } break; default: break; } }
ChartSettings::ChartSettings(WCartesian3DChart *chart, WContainerWidget * parent) : WContainerWidget(parent), chart_(chart) { WTemplate* template_ = new WTemplate(Wt::WString::tr("chartconfig-template"), this); WCheckBox *autoRangeX_ = new WCheckBox(this); template_->bindWidget("xAuto", autoRangeX_); autoRangeX_->setCheckState(Wt::Checked); chart_->initLayout(); WLineEdit *xMin_ = new WLineEdit (Wt::asString(chart_->axis(XAxis_3D).minimum()), this); template_->bindWidget("xAxisMin", xMin_); xMin_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max())); xMin_->setEnabled(false); WLineEdit *xMax_ = new WLineEdit (Wt::asString(chart_->axis(XAxis_3D).maximum()), this); template_->bindWidget("xAxisMax", xMax_); xMax_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max())); xMax_->setEnabled(false); WCheckBox *autoRangeY_ = new WCheckBox(this); template_->bindWidget("yAuto", autoRangeY_); autoRangeY_->setCheckState(Wt::Checked); WLineEdit *yMin_ = new WLineEdit (Wt::asString(chart_->axis(YAxis_3D).minimum()), this); template_->bindWidget("yAxisMin", yMin_); yMin_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max())); yMin_->setEnabled(false); WLineEdit *yMax_ = new WLineEdit (Wt::asString(chart_->axis(YAxis_3D).maximum()), this); template_->bindWidget("yAxisMax", yMax_); yMax_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max())); yMax_->setEnabled(false); WCheckBox *autoRangeZ_ = new WCheckBox(this); template_->bindWidget("zAuto", autoRangeZ_); autoRangeZ_->setCheckState(Wt::Checked); WLineEdit *zMin_ = new WLineEdit (Wt::asString(chart_->axis(ZAxis_3D).minimum()), this); template_->bindWidget("zAxisMin", zMin_); zMin_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max())); zMin_->setEnabled(false); WLineEdit *zMax_ = new WLineEdit (Wt::asString(chart_->axis(ZAxis_3D).maximum()), this); template_->bindWidget("zAxisMax", zMax_); zMax_->setValidator(new Wt::WDoubleValidator(-std::numeric_limits<double>::max(), std::numeric_limits<double>::max())); zMax_->setEnabled(false); WLineEdit *title = new WLineEdit(this); template_->bindWidget("chartTitle", title); WCheckBox *enableLegend = new WCheckBox(this); template_->bindWidget("chartLegend", enableLegend); WComboBox *legendSide = new WComboBox(this); legendSide->addItem("Left"); legendSide->addItem("Right"); legendSide->addItem("Top"); legendSide->addItem("Bottom"); template_->bindWidget("legendside", legendSide); switch (chart_->legendSide()) { case Left: legendSide->setCurrentIndex(0); break; case Right: legendSide->setCurrentIndex(1); break; case Top: legendSide->setCurrentIndex(2); break; case Bottom: legendSide->setCurrentIndex(3); break; default: break; } WComboBox *legendAlignment = new WComboBox(this); legendAlignment->addItem("Left"); legendAlignment->addItem("Center"); legendAlignment->addItem("Right"); legendAlignment->addItem("Top"); legendAlignment->addItem("Middle"); legendAlignment->addItem("Bottom"); template_->bindWidget("legendalignment", legendAlignment); switch (chart_->legendAlignment()) { case AlignLeft: legendAlignment->setCurrentIndex(0); break; case AlignCenter: legendAlignment->setCurrentIndex(1); break; case AlignRight: legendAlignment->setCurrentIndex(2); break; case AlignTop: legendAlignment->setCurrentIndex(3); break; case AlignMiddle: legendAlignment->setCurrentIndex(4); break; case AlignBottom: legendAlignment->setCurrentIndex(5); break; default: break; } WCheckBox *enableGridLines = new WCheckBox(this); template_->bindWidget("gridlines", enableGridLines); WLineEdit *widgetWidth = new WLineEdit(Wt::asString(chart_->width().value()), this); widgetWidth->setValidator(new Wt::WIntValidator(1, 2000)); WLineEdit *widgetHeight = new WLineEdit(Wt::asString(chart_->height().value()), this); widgetHeight->setValidator(new Wt::WIntValidator(1, 2000)); template_->bindWidget("width", widgetWidth); template_->bindWidget("height", widgetHeight); WLineEdit *xAxisTitle = new WLineEdit(chart_->axis(XAxis_3D).title(), this); WLineEdit *yAxisTitle = new WLineEdit(chart_->axis(YAxis_3D).title(), this); WLineEdit *zAxisTitle = new WLineEdit(chart_->axis(ZAxis_3D).title(), this); template_->bindWidget("xTitle", xAxisTitle); template_->bindWidget("yTitle", yAxisTitle); template_->bindWidget("zTitle", zAxisTitle); // hook it up autoRangeX_->checked().connect(std::bind([=] () { chart_->axis(XAxis_3D).setAutoLimits(Chart::MinimumValue | Chart::MaximumValue); xMin_->setEnabled(false); xMax_->setEnabled(false); })); autoRangeX_->unChecked().connect(std::bind([=] () { xMin_->setEnabled(true); xMax_->setEnabled(true); chart_->axis(XAxis_3D).setRange(Wt::asNumber(xMin_->text()), Wt::asNumber(xMax_->text())); })); autoRangeY_->checked().connect(std::bind([=] () { chart_->axis(YAxis_3D).setAutoLimits(Chart::MinimumValue | Chart::MaximumValue); yMin_->setEnabled(false); yMax_->setEnabled(false); })); autoRangeY_->unChecked().connect(std::bind([=] () { yMin_->setEnabled(true); yMax_->setEnabled(true); chart_->axis(YAxis_3D).setRange(Wt::asNumber(yMin_->text()), Wt::asNumber(yMax_->text())); })); autoRangeZ_->checked().connect(std::bind([=] () { chart_->axis(ZAxis_3D).setAutoLimits(Chart::MinimumValue | Chart::MaximumValue); zMin_->setEnabled(false); zMax_->setEnabled(false); })); autoRangeZ_->unChecked().connect(std::bind([=] () { zMin_->setEnabled(true); zMax_->setEnabled(true); chart_->axis(ZAxis_3D).setRange(Wt::asNumber(zMin_->text()), Wt::asNumber(zMax_->text())); })); xMin_->changed().connect(std::bind([=] () { chart_->axis(XAxis_3D).setRange(Wt::asNumber(xMin_->text()), Wt::asNumber(xMax_->text())); })); xMax_->changed().connect(std::bind([=] () { chart_->axis(XAxis_3D).setRange(Wt::asNumber(xMin_->text()), Wt::asNumber(xMax_->text())); })); yMin_->changed().connect(std::bind([=] () { chart_->axis(YAxis_3D).setRange(Wt::asNumber(yMin_->text()), Wt::asNumber(yMax_->text())); })); yMax_->changed().connect(std::bind([=] () { chart_->axis(YAxis_3D).setRange(Wt::asNumber(yMin_->text()), Wt::asNumber(yMax_->text())); })); zMin_->changed().connect(std::bind([=] () { chart_->axis(ZAxis_3D).setRange(Wt::asNumber(zMin_->text()), Wt::asNumber(zMax_->text())); })); zMax_->changed().connect(std::bind([=] () { chart_->axis(ZAxis_3D).setRange(Wt::asNumber(zMin_->text()), Wt::asNumber(zMax_->text())); })); enableGridLines->checked().connect(std::bind([=]() { chart_->setGridEnabled(Wt::Chart::XY_Plane, Wt::Chart::XAxis_3D, true); chart_->setGridEnabled(Wt::Chart::XY_Plane, Wt::Chart::YAxis_3D, true); chart_->setGridEnabled(Wt::Chart::XZ_Plane, Wt::Chart::XAxis_3D, true); chart_->setGridEnabled(Wt::Chart::XZ_Plane, Wt::Chart::ZAxis_3D, true); chart_->setGridEnabled(Wt::Chart::YZ_Plane, Wt::Chart::YAxis_3D, true); chart_->setGridEnabled(Wt::Chart::YZ_Plane, Wt::Chart::ZAxis_3D, true); })); enableGridLines->unChecked().connect(std::bind([=]() { chart_->setGridEnabled(Wt::Chart::XY_Plane, Wt::Chart::XAxis_3D, false); chart_->setGridEnabled(Wt::Chart::XY_Plane, Wt::Chart::YAxis_3D, false); chart_->setGridEnabled(Wt::Chart::XZ_Plane, Wt::Chart::XAxis_3D, false); chart_->setGridEnabled(Wt::Chart::XZ_Plane, Wt::Chart::ZAxis_3D, false); chart_->setGridEnabled(Wt::Chart::YZ_Plane, Wt::Chart::YAxis_3D, false); chart_->setGridEnabled(Wt::Chart::YZ_Plane, Wt::Chart::ZAxis_3D, false); })); enableLegend->checked().connect(std::bind([=]() { chart_->setLegendEnabled(true); })); enableLegend->unChecked().connect(std::bind([=]() { chart_->setLegendEnabled(false); })); legendSide->changed().connect(std::bind([=]() { switch (legendSide->currentIndex()) { case 0: chart_->setLegendLocation(Left, chart_->legendAlignment()); break; case 1: chart_->setLegendLocation(Right, chart_->legendAlignment()); break; case 2: chart_->setLegendLocation(Top, chart_->legendAlignment()); break; case 3: chart_->setLegendLocation(Bottom, chart_->legendAlignment()); break; } })); legendAlignment->changed().connect(std::bind([=]() { switch (legendAlignment->currentIndex()) { case 0: chart_->setLegendLocation(chart_->legendSide(), AlignLeft); break; case 1: chart_->setLegendLocation(chart_->legendSide(), AlignCenter); break; case 2: chart_->setLegendLocation(chart_->legendSide(), AlignRight); break; case 3: chart_->setLegendLocation(chart_->legendSide(), AlignTop); break; case 4: chart_->setLegendLocation(chart_->legendSide(), AlignMiddle); break; case 5: chart_->setLegendLocation(chart_->legendSide(), AlignBottom); break; } })); title->changed().connect(std::bind([=] () { chart_->setTitle(Wt::asString(title->text())); })); widgetWidth->changed().connect(std::bind([=] () { chart_->resize(Wt::asNumber(widgetWidth->text()), Wt::asNumber(widgetHeight->text())); })); widgetHeight->changed().connect(std::bind([=] () { chart_->resize(Wt::asNumber(widgetWidth->text()), Wt::asNumber(widgetHeight->text())); })); xAxisTitle->changed().connect(std::bind([=]() { chart_->axis(XAxis_3D).setTitle(xAxisTitle->text()); })); yAxisTitle->changed().connect(std::bind([=]() { chart_->axis(YAxis_3D).setTitle(yAxisTitle->text()); })); zAxisTitle->changed().connect(std::bind([=]() { chart_->axis(ZAxis_3D).setTitle(zAxisTitle->text()); })); }
void WebGLDemo::eventChecked(){ drawGLWidget_->updateBools(chBox->isChecked()); drawGLWidget_->repaintGL(DrawGLWidget::PAINT_GL); }