Ejemplo n.º 1
0
MenuBar::MenuBar(WContainerWidget * parent) : WContainerWidget(parent)
{

  // create demo menu
  Wt::WComboBox *cb = new Wt::WComboBox(this);
  cb->addItem("Display a map");
  cb->addItem("Create and style clusters");
  cb->addItem("Change a map's style");
  cb->addItem("Create a heatmap from points");
  cb->addItem("Height Lines");
  cb->addItem("Raster Tiles");
  cb->addItem("Fit to Bounds");
  cb->addItem("Set Language");
  cb->addItem("Pitch and Bearing");
  cb->addItem("Change map colors");
  cb->addItem("Layer Order");
  cb->addItem("Add a GeoJSON line");
  cb->addItem("Add a GeoJSON polygon");
  cb->addItem("Draw GeoJSON points");
  cb->addItem("Get coordinates from mouse");
  cb->addItem("Display a Popup");
  cb->addItem("Get features below mouse pointer");
  cb->addItem("Get feature on click");
  cb->addItem("Info in Popup");
  cb->addItem("Mouse Highlight");
  cb->addItem("Data Driven Colors");
  cb->addItem("Add an image");
  cb->addItem("Add a video");
  cb->addItem("Realtime Data");
  cb->addItem("Add Controls");

  cb->setCurrentIndex(0);
  cb->setMargin(10);

  // add all demo's to stack
  Wt::WStackedWidget * stack = new Wt::WStackedWidget(this);
  stack->addWidget(new DisplayMap());
  stack->addWidget(new CreateClusters());
  stack->addWidget(new MapStyle());
  stack->addWidget(new Heatmap());
  stack->addWidget(new HeightLines());
  stack->addWidget(new RasterTiles());
  stack->addWidget(new FitBounds());
  stack->addWidget(new SetLanguage());
  stack->addWidget(new PitchAndBearing());
  stack->addWidget(new ChangeColors());
  stack->addWidget(new LayerOrder());
  stack->addWidget(new GeoJSONLine());
  stack->addWidget(new GeoJSONPoly());
  stack->addWidget(new GeoJSONPoint());
  stack->addWidget(new GetCoordinates());
  stack->addWidget(new DisplayPopup());
  stack->addWidget(new FeaturesBelowMouse());
  stack->addWidget(new FeatureOnClick());
  stack->addWidget(new InfoPopup());
  stack->addWidget(new MouseHighlight());
  stack->addWidget(new DataDrivenColors());
  stack->addWidget(new AddImage());
  stack->addWidget(new AddVideo());
  stack->addWidget(new RealtimeData());
  stack->addWidget(new AddControls());

  cb->changed().connect(std::bind([=]() {
    int choice = cb->currentIndex();
    if (choice < stack->count()) {
      ((Demo *)stack->currentWidget())->onHide();
      stack->setCurrentIndex(choice);
      ((Demo *)stack->currentWidget())->onShow();
    }
  }));

}
Ejemplo n.º 2
0
    // inline constructor
    UserFormView() {
        model_ = new UserFormModel(this);

        setTemplateText(tr("userForm-template"));
        addFunction("id", &WTemplate::Functions::id);

        /*
	 * First Name
	 */
	setFormWidget(UserFormModel::FirstNameField, new Wt::WLineEdit());

	/*
	 * Last Name
	 */
	setFormWidget(UserFormModel::LastNameField, new Wt::WLineEdit());

	/*
	 * Country
	 */
	Wt::WComboBox *countryCB = new Wt::WComboBox();
	countryCB->setModel(model_->countryModel());

	countryCB->activated().connect(std::bind([=] () {
	    std::string code = model_->countryCode(countryCB->currentIndex());
	    model_->updateCityModel(code);
	}));

	setFormWidget(UserFormModel::CountryField, countryCB,
            [=] () { // updateViewValue()
	        std::string code = boost::any_cast<std::string>
		    (model_->value(UserFormModel::CountryField));
		int row = model_->countryModelRow(code);
		countryCB->setCurrentIndex(row);
	    },

            [=] () { // updateModelValue()
	        std::string code = model_->countryCode(countryCB->currentIndex());
		model_->setValue(UserFormModel::CountryField, code);
            });

	/*
	 * City
	 */
	Wt::WComboBox *cityCB = new Wt::WComboBox();
	cityCB->setModel(model_->cityModel());
	setFormWidget(UserFormModel::CityField, cityCB);

	/*
	 * Birth Date
	 */
	Wt::WLineEdit *dateEdit = new Wt::WLineEdit();
	Wt::WDatePicker *birthDP = new Wt::WDatePicker(dateEdit);
	bindWidget("birth-dp", birthDP);

	setFormWidget(UserFormModel::BirthField, dateEdit,
	    [=] () { // updateViewValue()
	        Wt::WDate date = boost::any_cast<Wt::WDate>
		    (model_->value(UserFormModel::BirthField));
                birthDP->setDate(date);
	    }, 

            [=] () { // updateModelValue()
	        Wt::WDate date = birthDP->date();
                model_->setValue(UserFormModel::BirthField, date);
	    });

        /*
	 * Children
	 */ 
	setFormWidget(UserFormModel::ChildrenField, new Wt::WSpinBox());

	/*
	 * Remarks
	 */
	Wt::WTextArea *remarksTA = new Wt::WTextArea();
	remarksTA->setColumns(40);
	remarksTA->setRows(5);
	setFormWidget(UserFormModel::RemarksField, remarksTA);

	/*
	 * Title & Buttons
	 */
        Wt::WString title = Wt::WString("Create new user");
        bindString("title", title);

        Wt::WPushButton *button = new Wt::WPushButton("Save");
        bindWidget("submit-button", button);

        bindString("submit-info", Wt::WString());

        button->clicked().connect(this, &UserFormView::process);

        updateView(model_);
    }