WWidget *WtHome::example(const char *textKey, const std::string& sourceDir) { WContainerWidget *result = new WContainerWidget(); WText *w = new WText(tr(textKey), result); w->setInternalPathEncoding(true); result->addWidget(linkSourceBrowser(sourceDir)); return result; }
WWidget *Home::linkSourceBrowser(const std::string& example) { /* * Instead of using a WAnchor, which will not progress properly because * it is wrapped with wrapView() (-- should we not fix that?), we use * a WText which contains an anchor, and enable internal path encoding. */ std::string path = "#/" + SRC_INTERNAL_PATH + "/" + example; WText *a = new WText(tr("source-browser-link").arg(path)); a->setInternalPathEncoding(true); return a; }
WWidget *WtHome::examples() { WContainerWidget *result = new WContainerWidget(); WText *intro = new WText(tr("home.examples")); intro->setInternalPathEncoding(true); result->addWidget(intro); examplesMenu_ = new WTabWidget(result); WAnimation animation(WAnimation::SlideInFromRight, WAnimation::EaseIn); examplesMenu_->contentsStack()->setTransitionAnimation(animation, true); /* * The following code is functionally equivalent to: * * examplesMenu_->addTab(helloWorldExample(), "Hello world"); * * However, we optimize here for memory consumption (it is a homepage * after all, and we hope to be slashdotted some day) * * Therefore, we wrap all the static content (including the tree * widgets), into WViewWidgets with static models. In this way the * widgets are not actually stored in memory on the server. */ // The call ->setPathComponent() is to use "/examples/" instead of // "/examples/hello_world" as internal path examplesMenu_->addTab(wrapView(&WtHome::helloWorldExample), tr("hello-world"))->setPathComponent(""); examplesMenu_->addTab(wrapView(&WtHome::chartExample), tr("charts")); examplesMenu_->addTab(wrapView(&WtHome::homepageExample), tr("wt-homepage")); examplesMenu_->addTab(wrapView(&WtHome::treeviewExample), tr("treeview")); examplesMenu_->addTab(wrapView(&WtHome::gitExample), tr("git")); examplesMenu_->addTab(wrapView(&WtHome::chatExample), tr("chat")); examplesMenu_->addTab(wrapView(&WtHome::composerExample), tr("mail-composer")); examplesMenu_->addTab(wrapView(&WtHome::hangmanExample), tr("hangman")); examplesMenu_->addTab(wrapView(&WtHome::widgetGalleryExample), tr("widget-gallery")); // Enable internal paths for the example menu examplesMenu_->setInternalPathEnabled("/examples"); examplesMenu_->currentChanged().connect(this, &Home::googleAnalyticsLogger); return result; }
void BasePage::sidebar() { _sidebar->clear(); _sidebar->setId("sidebar"); //_sidebar->addWidget(new WText("Sidebar Menu")); WText *list; list=new WText( "<ul class='menu'>" "<li> <a href='#/rate'> rate </a> </li>" "<li> <a href='#/authors'> authors </a> </li>" "<li> <a href='#/genres'> genres </a> </li>" "<li> <a href='#/series'> series and cycles </a> </li>" "<li> <a href='#/newbook'> add new book </a> </li>" "<li> <a href='#/addmark'> add your mark </a> </li>" "</ul>" "<div class=\"footer\">" "<p> <font color='white'> copyright by Alexey 2016 </font> </p>" "<p> <a href='#/'> docs </a> |<a href='http://vk.com/id156854642'> myVk </a> </p>" "</div>" ); list->setInternalPathEncoding(true); _sidebar->addWidget(list); }
WWidget *Home::documentation() { WText *result = new WText(tr("home.documentation")); result->setInternalPathEncoding(true); return result; }