Пример #1
0
void WTableRow::toggleStyleClass(const WT_USTRING& style, bool add)
{
  if (add)
    addStyleClass(style);
  else
    removeStyleClass(style);
}
Пример #2
0
void WPanel::setAnimation(const WAnimation& transition)
{
  animation_ = transition;

  if (!animation_.empty())
    addStyleClass("Wt-animated");
}
Пример #3
0
terminal_display::terminal_display(/**/)
{
	auto _layout = new Wt::WVBoxLayout;
	_layout->setContentsMargins(5, 5, 5, 5);
	setLayout(_layout);

//	auto scroll = new Wt::WScrollArea{};
	m_console = new WPlainOutputConsole{};
//	scroll->setWidget(m_console);
//	_layout->addWidget(scroll, 1);
	_layout->addWidget(m_console, 1);

	m_cmdline = new WCommandLine{};
	m_cmdline->setTabIndex(0);
	_layout->addWidget(m_cmdline);

	m_console->clicked().connect(std::bind([this]
	{
		m_cmdline->setFirstFocus();
	}));

	m_cmdline->setFirstFocus();

	addStyleClass("terminal");
}
Пример #4
0
yearbookDownload::yearbookDownload(yearbookDB * ptr) : db(ptr), downloadFile(nullptr) {
  addStyleClass("well");
  setContentAlignment(Wt::AlignCenter | Wt::AlignMiddle);

  addWidget(new Wt::WText("<p>Genereer een nieuwe versie van de PDF.</p> <p><b>Let op: </b>Bij ongeldige invoer kan de PDF onvolledig zijn.</p>"));
  Wt::WPushButton * button = new Wt::WPushButton("Maak PDF");
  addWidget(button);
  button->clicked().connect(this, &yearbookDownload::generatePDF);

  downloadTitle = new Wt::WText("<h1>Download beschikbaar</h1>");
  downloadTitle->addStyleClass("page-header");
  addWidget(downloadTitle);
  downloadContainer = new Wt::WContainerWidget();
  downloadContainer->addStyleClass("well");
  downloadContainer->setContentAlignment(Wt::AlignCenter | Wt::AlignMiddle);
  addWidget(downloadContainer);

  downloadTitle->hide();
  downloadContainer->hide();

  downloadFile = new Wt::WFileResource(this);
  downloadFile->setFileName("yearbook_latex/main.pdf");
  downloadFile->setMimeType("application/pdf");

  downloadAnchor = new Wt::WAnchor(Wt::WLink(downloadFile), "Download");
  downloadAnchor->setTarget(Wt::TargetNewWindow);
  downloadContainer->addWidget(downloadAnchor);
}
Пример #5
0
void WWidget::toggleStyleClass(const WT_USTRING& styleClass, bool add,
                               bool force)
{
    if (add)
        addStyleClass(styleClass, force);
    else
        removeStyleClass(styleClass, force);
}
Пример #6
0
Wt::WMenuItem *WidgetGallery::addToMenu(Wt::WMenu *menu,
					const Wt::WString& name,
					std::unique_ptr<TopicWidget> topic)
{
  auto topic_ = topic.get();
  auto result = Wt::cpp14::make_unique<Wt::WContainerWidget>();

  auto pane = Wt::cpp14::make_unique<Wt::WContainerWidget>();
  auto pane_ = pane.get();

  auto vLayout = result->setLayout(Wt::cpp14::make_unique<Wt::WVBoxLayout>());
  vLayout->setContentsMargins(0, 0, 0, 0);
  vLayout->addWidget(std::move(topic));
  vLayout->addWidget(std::move(pane), 1);

  auto hLayout = pane_->setLayout(Wt::cpp14::make_unique<Wt::WHBoxLayout>());

  auto item = Wt::cpp14::make_unique<Wt::WMenuItem>(name, std::move(result));
  auto item_ = menu->addItem(std::move(item));

  auto subStack = Wt::cpp14::make_unique<Wt::WStackedWidget>();
  subStack->addStyleClass("contents");

  /*
  WAnimation animation(AnimationEffect::Fade,
                           TimingFunction::Linear,
			   100);
  subStack->setTransitionAnimation(animation, true);
  */

  auto subMenu = Wt::cpp14::make_unique<Wt::WMenu>(subStack.get());
  auto subMenu_ = subMenu.get();
  subMenu_->addStyleClass("nav-pills nav-stacked submenu");
  subMenu_->setWidth(200);

  hLayout->addWidget(std::move(subMenu));
  hLayout->addWidget(std::move(subStack),1);

  subMenu_->setInternalPathEnabled();
  subMenu_->setInternalBasePath("/" + item_->pathComponent());

  topic_->populateSubMenu(subMenu_);

  return item_;
}
Пример #7
0
WStackedWidget::WStackedWidget(WContainerWidget *parent)
  : WContainerWidget(parent),
    currentIndex_(-1)
{
  WT_DEBUG( setObjectName("WStackedWidget") );
  setJavaScriptMember(WT_RESIZE_JS, StdGridLayoutImpl::childrenResizeJS());

  addStyleClass("Wt-stack");
}
Пример #8
0
void WGroupBox::propagateSetEnabled(bool enabled)
{
  if (enabled)
    removeStyleClass("Wt-disabled");
  else
    addStyleClass("Wt-disabled");

  WInteractWidget::propagateSetEnabled(enabled);
}
Пример #9
0
WStackedWidget::WStackedWidget(WContainerWidget *parent)
  : WContainerWidget(parent),
    currentIndex_(-1),
    widgetsAdded_(false),
    javaScriptDefined_(false),
    loadAnimateJS_(false)
{
  addStyleClass("Wt-stack");
}
Пример #10
0
WStackedWidget::WStackedWidget(WContainerWidget *parent)
  : WContainerWidget(parent),
    currentIndex_(-1)
{
  WT_DEBUG( setObjectName("WStackedWidget") );

  addStyleClass("Wt-stack");

  javaScriptDefined_ = false;
}
Пример #11
0
WStackedWidget::WStackedWidget(WContainerWidget *parent)
  : WContainerWidget(parent),
    currentIndex_(-1),
    javaScriptDefined_(false),
    loadAnimateJS_(false)
{
  WT_DEBUG( setObjectName("WStackedWidget") );

  addStyleClass("Wt-stack");
}
Пример #12
0
 WForm::WForm(Type type, int labelColumns, WContainerWidget *parent) : WContainerWidget(parent), dptr(type, labelColumns)
 {
   static map<Type, string> typeClass {
     {Default, ""},
     {Horizontal, "form-horizontal"},
     {Inline, "form-inline"},
   };
   addStyleClass(typeClass[type]);
   setAttributeValue("role", "form");
 }
Пример #13
0
void PaintedSlider::propagateSetEnabled(bool enabled)
{
  if (enabled) {
    removeStyleClass("Wt-disabled");
    slider_->removeStyleClass("Wt-disabled");
  } else {
    addStyleClass("Wt-disabled");
    slider_->addStyleClass("Wt-disabled");
  }

  WPaintedWidget::propagateSetEnabled(enabled);
}
Пример #14
0
void WMenuItem::renderSelected(bool selected)
{
  WApplication *app = WApplication::instance();

  std::string active = app->theme()->activeClass();

  if (active == "Wt-selected"){ // for CSS theme, our styles are messed up
    removeStyleClass(!selected ? "itemselected" : "item", true);
    addStyleClass(selected ? "itemselected" : "item", true);
  } else
    toggleStyleClass(active, selected, true);
}
Пример #15
0
void WStackedWidget::setTransitionAnimation(const WAnimation& animation,
					    bool autoReverse)
{
  if (WApplication::instance()->environment().supportsCss3Animations()) {
    if (!animation.empty())
      addStyleClass("Wt-animated");

    animation_ = animation;
    autoReverseAnimation_ = autoReverse;

    loadAnimateJS();
  }
}
Пример #16
0
void WStackedWidget::setTransitionAnimation(const WAnimation& animation,
					    bool autoReverse)
{
  if (loadAnimateJS()) {
    if (!animation.empty())
      addStyleClass("Wt-animated");

    animation_ = animation;
    autoReverseAnimation_ = autoReverse;

    setJavaScriptMember("wtAnimateChild", WT_CLASS ".WStackedWidget.animateChild");
    setJavaScriptMember("wtAutoReverse", autoReverseAnimation_ ? "true" : "false");
  }
}
Пример #17
0
void WStackedWidget::setTransitionAnimation(const WAnimation& animation,
					    bool autoReverse)
{
  if (loadAnimateJS()) {
    if (!animation.empty())
      addStyleClass("Wt-animated");

    animation_ = animation;
    autoReverseAnimation_ = autoReverse;

    if (isRendered()) {
      setJavaScriptMember("wtAnimateChild",
			  "$('#" + id() + "').data('obj').animateChild");
      setJavaScriptMember("wtAutoReverse",
			  autoReverseAnimation_ ? "true" : "false");
    }
  }
}
Пример #18
0
 UserListView(UserListModel* model, Wt::WContainerWidget* p = 0):
     Wt::WTableView(p) {
     setModel(model);
     resize(ULP::WIDTH, ULP::HEIGHT);
     setColumnWidth(UserListModel::NUMBER_COL, 40);
     setColumnWidth(UserListModel::NAME_COLUMN, 170);
     setColumnWidth(UserListModel::CLASSIFICATION_COLUMN, 150);
     setColumnWidth(UserListModel::ALL_COLUMN, 40);
     setColumnWidth(UserListModel::WINS_COLUMN, 40);
     setColumnWidth(UserListModel::DRAWS_COLUMN, 30);
     setColumnWidth(UserListModel::FAILS_COLUMN, 40);
     setColumnWidth(UserListModel::RATING_COLUMN, 40);
     setColumnWidth(UserListModel::ONLINE_TIME, 85);
     setColumnWidth(UserListModel::REGISTRATION_DATE, 75);
     setSortingEnabled(UserListModel::NUMBER_COL, false);
     setSortingEnabled(UserListModel::DRAWS_COLUMN, false);
     addStyleClass("thechess-user-list");
     setSelectable(true);
 }
Пример #19
0
 CommentsView(CommentsModel* model, Wt::WContainerWidget* p=0):
     Wt::WTableView(p) {
     setModel(model);
     setSortingEnabled(false);
     resize(770, 450);
     if (model->deleted_column != -1) {
         setColumnWidth(model->deleted_column, 20);
     }
     setColumnWidth(model->index_column, 40);
     setColumnWidth(model->text_column, model->deleted_column != -1 ? 660 : 700);
     setHeaderHeight(0);
     setRowHeight(ROW_HEIGHT);
     if (model->deleted_column != -1) {
         setColumnAlignment(model->deleted_column, Wt::AlignRight | Wt::AlignTop);
     }
     setColumnAlignment(model->index_column, Wt::AlignRight | Wt::AlignTop);
     setColumnAlignment(model->text_column, Wt::AlignLeft | Wt::AlignTop);
     addStyleClass("facts-commentsview");
 }
Пример #20
0
LoginWindow::LoginWindow(WContainerWidget* parent) : MoreAwesomeTemplate(parent) {
    setTemplateText(tr("login-template"));
    addStyleClass("yui-gd dialog form"); // 1/3 + 2/3 style
    bindAndCreateField(_usernameLabel, _usernameEdit, "username");

    // Password
    bindAndCreateField(_passwordLabel, _passwordEdit, "password");
    _passwordEdit->setEchoMode(WLineEdit::Password);

    // Buttons
    bindWidget("btn-bar", _btnBar = new ButtonBar(tr("Login"), tr("Cancel")));
    _btnBar->btn1()->clicked().connect(this, &LoginWindow::handleOKHit);
    _btnBar->btn2()->clicked().connect(this, &LoginWindow::handleCancelHit);

    // Hook up accept and reject signals
    // All these do an accept
    _passwordEdit->enterPressed().connect(this, &LoginWindow::handleOKHit);    

    // These do reject
    _usernameEdit->escapePressed().connect(this, &LoginWindow::handleCancelHit);
    _passwordEdit->escapePressed().connect(this, &LoginWindow::handleCancelHit);
}
Пример #21
0
void WMediaPlayer::createDefaultGui()
{
  gui_ = 0;

  static const char *media[] = { "audio", "video" };

  WTemplate *ui = new WTemplate
    (tr(std::string("Wt.WMediaPlayer.defaultgui-") + media[mediaType_]));

  addAnchor(ui, Play, "play-btn", "jp-play");
  addAnchor(ui, Pause, "pause-btn", "jp-pause");
  addAnchor(ui, Stop, "stop-btn", "jp-stop");
  addAnchor(ui, VolumeMute, "mute-btn", "jp-mute");
  addAnchor(ui, VolumeUnmute, "unmute-btn", "jp-unmute");
  addAnchor(ui, VolumeMax, "volume-max-btn", "jp-volume-max");
  addAnchor(ui, RepeatOn, "repeat-btn", "jp-repeat");
  addAnchor(ui, RepeatOff, "repeat-off-btn", "jp-repeat-off");

  if (mediaType_ == Video) {
    addAnchor(ui, VideoPlay, "video-play-btn", "jp-video-play-icon", "play");
    addAnchor(ui, FullScreen, "full-screen-btn", "jp-full-screen");
    addAnchor(ui, RestoreScreen, "restore-screen-btn", "jp-restore-screen");
  }

  addText(ui, CurrentTime, "current-time", "jp-current-time");
  addText(ui, Duration, "duration", "jp-duration");
  addText(ui, Title, "title", std::string());

  addProgressBar(ui, Time, "progress-bar", "jp-seek-bar",
		 "jp-play-bar");
  addProgressBar(ui, Volume, "volume-bar", "jp-volume-bar",
		 "jp-volume-bar-value");

  ui->bindString("title-display", title_.empty() ? "none" : "");

  addStyleClass(mediaType_ == Video ? "jp-video" : "jp-audio");

  setControlsWidget(ui);
}
Пример #22
0
void WAbstractSpinBox::setup(bool useNative)
{
  if (useNative) {
    setValidator(createValidator());
  } else {
    defineJavaScript();

    addStyleClass("Wt-spinbox");

#ifdef WT_CNOR
    EventSignalBase& b = mouseMoved();
    EventSignalBase& c = keyWentDown();
#endif

    connectJavaScript(mouseMoved(), "mouseMove");
    connectJavaScript(mouseWentUp(), "mouseUp");
    connectJavaScript(mouseWentDown(), "mouseDown");
    connectJavaScript(mouseWentOut(), "mouseOut");
    connectJavaScript(keyWentDown(), "keyDown");
    connectJavaScript(keyWentUp(), "keyUp");

    setValidator(new SpinBoxValidator(this));
  }
}
Пример #23
0
WsBanners::WsBanners(WContainerWidget* parent)
  : WContainerWidget(parent)
{
  addStyleClass("WsBanners");
}
Пример #24
0
void WWidget::addStyleClass(const char *styleClass, bool force)
{
    addStyleClass(WString::fromUTF8(styleClass), force);
}
Пример #25
0
    GoogleMapExample()
        : WContainerWidget()
    {
        auto layout = setLayout(cpp14::make_unique<WHBoxLayout>());

	setHeight(400);

	auto map = cpp14::make_unique<WGoogleMap>(GoogleMapsVersion::v3);
	map_ = map.get();
	layout->addWidget(std::move(map), 1);

	map_->setMapTypeControl(MapTypeControl::Default);
	map_->enableScrollWheelZoom();

	auto controls =
	    cpp14::make_unique<WTemplate>(tr("graphics-GoogleMap-controls"));
	auto controls_ = controls.get();
	layout->addWidget(std::move(controls));

	auto zoomIn = cpp14::make_unique<WPushButton>("+");
	auto zoomIn_ = controls_->bindWidget("zoom-in", std::move(zoomIn));
	zoomIn_->addStyleClass("zoom");

	zoomIn_->clicked().connect([=] {
	    map_->zoomIn();
	});

	auto zoomOut = cpp14::make_unique<WPushButton>("-");
	auto zoomOut_ = controls_->bindWidget("zoom-out", std::move(zoomOut));
	zoomOut_->addStyleClass("zoom");

        zoomOut_->clicked().connect([=] {
            map_->zoomOut();
	});

	std::string cityNames[] = { "Brussels", "Lisbon", "Paris" };
	WGoogleMap::Coordinate cityCoords[] = {
	    WGoogleMap::Coordinate(50.85034,4.35171),
	    WGoogleMap::Coordinate(38.703731,-9.135475),
	    WGoogleMap::Coordinate(48.877474, 2.312579)
	};
	    
	for (unsigned i = 0; i < 3; ++i) {
	    auto city = cpp14::make_unique<WPushButton>(cityNames[i]);
	    auto city_ = controls_->bindWidget(cityNames[i], std::move(city));

	    WGoogleMap::Coordinate coord = cityCoords[i];
	    city_->clicked().connect([=] {
		map_->panTo(coord);
	    });
	}

	auto reset = cpp14::make_unique<WPushButton>("Reset");
	auto reset_ = controls_->bindWidget("emweb", std::move(reset));

        reset_->clicked().connect([=] {
            this->panToEmWeb();
        });

	auto savePosition =
	    cpp14::make_unique<WPushButton>("Save current position");
	auto savePosition_ = controls_->bindWidget("save-position", std::move(savePosition));

        savePosition_->clicked().connect([=] {
            this->savePosition();
        });

	auto returnToPosition = cpp14::make_unique<WPushButton>("Return to saved position");
	returnToPosition_ = controls_->bindWidget("return-to-saved-position", std::move(returnToPosition));
	returnToPosition_->setEnabled(false);

	returnToPosition_->clicked().connect([=] {
            map_->returnToSavedPosition();
        });

	mapTypeModel_ = std::make_shared<WStringListModel>();
	addMapTypeControl("No control", MapTypeControl::None);
	addMapTypeControl("Default", MapTypeControl::Default);
	addMapTypeControl("Menu", MapTypeControl::Menu);
	if (map_->apiVersion() == GoogleMapsVersion::v2)
	    addMapTypeControl("Hierarchical",
			      MapTypeControl::Hierarchical);
	if (map_->apiVersion() == GoogleMapsVersion::v3)
	    addMapTypeControl("Horizontal bar",
			      MapTypeControl::HorizontalBar);

	auto menuControls = cpp14::make_unique<WComboBox>();
	auto menuControls_ = controls_->bindWidget("control-menu-combo", std::move(menuControls));
	menuControls_->setModel(mapTypeModel_);
	menuControls_->setCurrentIndex(1);

        menuControls_->activated().connect([=] (int mapType) {
            this->setMapTypeControl(mapType);
        });

	auto draggingCB = cpp14::make_unique<WCheckBox>("Enable dragging");
	auto draggingCB_ = controls_->bindWidget("dragging-cb", std::move(draggingCB));
	draggingCB_->setChecked(true);
	map_->enableDragging();

        draggingCB_->checked().connect([=] {
            map_->enableDragging();
        });

        draggingCB_->unChecked().connect([=] {
            map_->disableDragging();
        });

        auto enableDoubleClickZoomCB =
            cpp14::make_unique<WCheckBox>("Enable double click zoom");
        auto enableDoubleClickZoomCB_ =
            controls_->bindWidget("double-click-zoom-cb", std::move(enableDoubleClickZoomCB));
        enableDoubleClickZoomCB_->setChecked(false);
	map_->disableDoubleClickZoom();

        enableDoubleClickZoomCB_->checked().connect([=] {
            map_->enableDoubleClickZoom();
	});

        enableDoubleClickZoomCB_->unChecked().connect([=] {
            map_->disableDoubleClickZoom();
        });

        auto enableScrollWheelZoomCB =
            cpp14::make_unique<WCheckBox>("Enable scroll wheel zoom");
        auto enableScrollWheelZoomCB_ =
            controls_->bindWidget("scroll-wheel-zoom-cb", std::move(enableScrollWheelZoomCB));
        enableScrollWheelZoomCB_->setChecked(true);
	map_->enableScrollWheelZoom();

        enableScrollWheelZoomCB_->checked().connect([=] {
            map_->enableScrollWheelZoom();
        });

        enableScrollWheelZoomCB_->unChecked().connect([=] {
            map_->disableScrollWheelZoom();
        });

        std::vector<WGoogleMap::Coordinate> road = roadDescription();

        map_->addPolyline(road, WColor(0, 191, 255));

	//Koen's favourite bar!
	map_->addMarker(WGoogleMap::Coordinate(50.885069,4.71958));

	map_->setCenter(road[road.size()-1]);

	map_->openInfoWindow(road[0],
           "<img src=\"http://www.emweb.be/css/emweb_small.jpg\" />"
           "<p><strong>Emweb office</strong></p>");

        map_->clicked().connect([=] (WGoogleMap::Coordinate c) {
            this->googleMapClicked(c);
        });

	map_->doubleClicked().connect([=] (WGoogleMap::Coordinate c) {
            this->googleMapDoubleClicked(c);
        });
    }
Пример #26
0
void WTreeNode::create()
{
  setImplementation(layout_ = new WTemplate(tr("Wt.WTreeNode.template")));
  setStyleClass("Wt-tree");
  layout_->setSelectable(false);

  layout_->bindEmpty("cols-row");
  layout_->bindEmpty("trunk-class");

  implementStateless(&WTreeNode::doExpand, &WTreeNode::undoDoExpand);
  implementStateless(&WTreeNode::doCollapse, &WTreeNode::undoDoCollapse);

  WApplication *app = WApplication::instance();

  /*
   * Children
   */
  WContainerWidget *children = new WContainerWidget();
  children->setList(true);
  children->hide();
  layout_->bindWidget("children", children);

  /*
   * Expand icon
   */
  if (WApplication::instance()->layoutDirection() == RightToLeft)
    expandIcon_
      = new WIconPair(app->theme()->resourcesUrl() + imagePlusRtl_,
		      app->theme()->resourcesUrl() + imageMinRtl_);
  else
    expandIcon_
      = new WIconPair(app->theme()->resourcesUrl() + imagePlus_,
		      app->theme()->resourcesUrl() + imageMin_);
  expandIcon_->setStyleClass("Wt-ctrl Wt-expand");
  noExpandIcon_ = new WText();
  noExpandIcon_->setStyleClass("Wt-ctrl Wt-noexpand");
  layout_->bindWidget("expand", noExpandIcon_);
  addStyleClass("Wt-trunk");

  /*
   * Label
   */
  layout_->bindWidget("label-area", new WContainerWidget());

  if (labelText_)
    labelText_->setStyleClass("Wt-label");

  childCountLabel_ = 0;

  if (labelIcon_) {
    labelArea()->addWidget(labelIcon_);
    labelIcon_->setVerticalAlignment(AlignMiddle);
  }

  if (labelText_)
    labelArea()->addWidget(labelText_);

  childrenLoaded_ = false;

  setLoadPolicy(LazyLoading);
}