Beispiel #1
0
MainPage::MainPage(Wt::WApplication* app): WContainerWidget()
{
	app_ = app;
	contentsStack_ = new Wt::WStackedWidget();
	contentsStack_->setOverflow(WContainerWidget::OverflowAuto);
	contentsStack_->setStyleClass("contents");

	/*
	* Setup the menu (and submenus)
	*/
	Wt::WMenu *menu = new Wt::WMenu(contentsStack_, Wt::Vertical, 0);
	menu->setRenderAsList(true);
	menu->setStyleClass("menu");
	menu->setInternalPathEnabled();
	menu->setInternalBasePath("/");
	menu->itemSelected().connect(this, &MainPage::selectedMenuItem);
	
	Wt::WContainerWidget *w = new Wt::WContainerWidget(this);
	Wt::WBorderLayout *layout = new Wt::WBorderLayout();
	layout->addWidget(new Wt::WText("North-side is best"), Wt::WBorderLayout::North);
	layout->addWidget(new Wt::WText("South-side is best"), Wt::WBorderLayout::South);
	layout->addWidget(menu, Wt::WBorderLayout::West);
	layout->addWidget(contentsStack_, Wt::WBorderLayout::Center);

	// use layout but do not justify vertically
	w->setLayout(layout, Wt::AlignTop | Wt::AlignJustify);
	
	menu->addItem("Basics", new ClientsPage(this, &session_));
	menu->addItem("Form Widgets", new CommonPage(this, &session_));
	menu->addItem("Form Validators", new CommonPage(this, &session_));

	Wt::WSubMenuItem *smi = new Wt::WSubMenuItem("Sub menu", new CommonPage(this, &session_));
	Wt::WMenu *subMenu = new Wt::WMenu(contentsStack_, Wt::Vertical, 0);
	subMenu->setRenderAsList(true);

	smi->setSubMenu(subMenu);
	
	menu->addItem(smi);

	subMenu->setInternalPathEnabled();
	subMenu->setInternalBasePath("/" + smi->pathComponent());
	subMenu->setStyleClass("menu submenu");
	subMenu->itemSelected().connect(this, &MainPage::selectedMenuItem);
	
	subMenu->addItem("Sub Item 1", new CommonPage(this, &session_));
	subMenu->addItem("Sub Item 2", new CommonPage(this, &session_));
}
Beispiel #2
0
WidgetGallery::WidgetGallery()
  : WContainerWidget()
{
  setOverflow(OverflowHidden);

  navigation_ = new Wt::WNavigationBar();
  navigation_->addStyleClass("main-nav");
  navigation_->setTitle("Wt Widget Gallery",
			"https://www.webtoolkit.eu/widgets");
  navigation_->setResponsive(true);

  contentsStack_ = new Wt::WStackedWidget();

  Wt::WAnimation animation(Wt::WAnimation::Fade,
			   Wt::WAnimation::Linear,
			   200);
  contentsStack_->setTransitionAnimation(animation, true);

  /*
   * Setup the top-level menu
   */
  Wt::WMenu *menu = new Wt::WMenu(contentsStack_, 0);
  menu->setInternalPathEnabled();
  menu->setInternalBasePath("/");

  addToMenu(menu, "Layout", new Layout());
  addToMenu(menu, "Forms", new FormWidgets());
  addToMenu(menu, "Navigation", new Navigation());
  addToMenu(menu, "Trees & Tables", new TreesTables())
    ->setPathComponent("trees-tables");
  addToMenu(menu, "Graphics & Charts", new GraphicsWidgets())
    ->setPathComponent("graphics-charts");
  // addToMenu(menu, "Events", new EventsDemo());
  addToMenu(menu, "Media", new Media());

  navigation_->addMenu(menu);

  /*
   * Add it all inside a layout
   */
  Wt::WVBoxLayout *layout = new Wt::WVBoxLayout(this);
  layout->addWidget(navigation_);
  layout->addWidget(contentsStack_, 1);
  layout->setContentsMargins(0, 0, 0, 0);
}
Beispiel #3
0
Wt::WMenuItem *WidgetGallery::addToMenu(Wt::WMenu *menu,
					const Wt::WString& name,
					TopicWidget *topic)
{
  Wt::WContainerWidget *result = new Wt::WContainerWidget();

  Wt::WContainerWidget *pane = new Wt::WContainerWidget();

  Wt::WVBoxLayout *vLayout = new Wt::WVBoxLayout(result);
  vLayout->setContentsMargins(0, 0, 0, 0);
  vLayout->addWidget(topic);
  vLayout->addWidget(pane, 1);

  Wt::WHBoxLayout *hLayout = new Wt::WHBoxLayout(pane);

  Wt::WMenuItem *item = new Wt::WMenuItem(name, result);
  menu->addItem(item);

  Wt::WStackedWidget *subStack = new Wt::WStackedWidget();
  subStack->addStyleClass("contents");
  subStack->setOverflow(WContainerWidget::OverflowAuto);

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

  Wt::WMenu *subMenu = new Wt::WMenu(subStack);
  subMenu->addStyleClass("nav-pills nav-stacked");
  subMenu->setWidth(200);

  hLayout->addWidget(subMenu);
  hLayout->addWidget(subStack,1);

  subMenu->setInternalPathEnabled();
  subMenu->setInternalBasePath("/" + item->pathComponent());

  topic->populateSubMenu(subMenu);

  return item;
}