#include <WtHome.h>
Public Member Functions | |
WtHome (const WEnvironment &env) | |
Protected Member Functions | |
virtual WWidget * | examples () |
virtual WWidget * | download () |
virtual WWidget * | sourceViewer (const std::string &internalPath) |
virtual std::string | filePrefix () const |
Private Member Functions | |
WWidget * | example (const char *textKey, const std::string &sourceDir) |
WWidget * | helloWorldExample () |
WWidget * | chartExample () |
WWidget * | homepageExample () |
WWidget * | treeviewExample () |
WWidget * | gitExample () |
WWidget * | chatExample () |
WWidget * | composerExample () |
WWidget * | widgetGalleryExample () |
WWidget * | wrapView (WWidget *(WtHome::*createFunction)()) |
Private Attributes | |
std::string | wtExamplePath_ |
Definition at line 16 of file WtHome.h.
WtHome::WtHome | ( | const WEnvironment & | env | ) |
Definition at line 22 of file WtHome.C.
00023 : Home(env, "Wt, C++ Web Toolkit", "wt-home", "css/wt") 00024 { 00025 addLanguage(Lang("en", "/", "en", "English")); 00026 addLanguage(Lang("cn", "/cn/", "汉语", "中文 (Chinese)")); 00027 00028 char* wtExamplePath = getenv("WT_EXAMPLE_PATH"); 00029 if (wtExamplePath) 00030 wtExamplePath_ = wtExamplePath; 00031 else 00032 wtExamplePath_ = "../"; 00033 00034 init(); 00035 }
WWidget * WtHome::examples | ( | ) | [protected, virtual] |
Implements Home.
Definition at line 85 of file WtHome.C.
00086 { 00087 WContainerWidget *result = new WContainerWidget(); 00088 00089 result->addWidget(new WText(tr("home.examples"))); 00090 00091 examplesMenu_ = new WTabWidget(AlignTop | AlignJustify, result); 00092 00093 /* 00094 * The following code is functionally equivalent to: 00095 * 00096 * examplesMenu_->addTab(helloWorldExample(), "Hello world"); 00097 * 00098 * However, we optimize here for memory consumption (it is a homepage 00099 * after all, and we hope to be slashdotted some day) 00100 * 00101 * Therefore, we wrap all the static content (including the tree 00102 * widgets), into WViewWidgets with static models. In this way the 00103 * widgets are not actually stored in memory on the server. 00104 */ 00105 00106 // The call ->setPathComponent() is to use "/examples/" instead of 00107 // "/examples/hello_world" as internal path 00108 examplesMenu_->addTab(wrapView(&WtHome::helloWorldExample), 00109 tr("hello-world"))->setPathComponent(""); 00110 examplesMenu_->addTab(wrapView(&WtHome::chartExample), 00111 tr("charts")); 00112 examplesMenu_->addTab(wrapView(&WtHome::homepageExample), 00113 tr("wt-homepage")); 00114 examplesMenu_->addTab(wrapView(&WtHome::treeviewExample), 00115 tr("treeview")); 00116 examplesMenu_->addTab(wrapView(&WtHome::gitExample), 00117 tr("git")); 00118 examplesMenu_->addTab(wrapView(&WtHome::chatExample), 00119 tr("chat")); 00120 examplesMenu_->addTab(wrapView(&WtHome::composerExample), 00121 tr("mail-composer")); 00122 examplesMenu_->addTab(wrapView(&WtHome::widgetGalleryExample), 00123 tr("widget-gallery")); 00124 00125 // Enable internal paths for the example menu 00126 examplesMenu_->setInternalPathEnabled("/examples"); 00127 examplesMenu_->currentChanged().connect(SLOT(this, Home::googleAnalyticsLogger)); 00128 00129 return result; 00130 }
WWidget * WtHome::download | ( | ) | [protected, virtual] |
Implements Home.
Definition at line 132 of file WtHome.C.
00133 { 00134 WContainerWidget *result = new WContainerWidget(); 00135 result->addWidget(new WText(tr("home.download"))); 00136 result->addWidget(new WText(tr("home.download.license"))); 00137 result->addWidget(new WText(tr("home.download.requirements"))); 00138 result->addWidget(new WText(tr("home.download.cvs"))); 00139 result->addWidget(new WText(tr("home.download.packages"))); 00140 00141 releases_ = new WTable(); 00142 readReleases(releases_); 00143 result->addWidget(releases_); 00144 00145 result->addWidget 00146 (new WText("<p>Older releases are still available at " 00147 + href("http://sourceforge.net/project/showfiles.php?" 00148 "group_id=153710#files", 00149 "sourceforge.net") 00150 + "</p>")); 00151 00152 return result; 00153 }
WWidget * WtHome::sourceViewer | ( | const std::string & | internalPath | ) | [protected, virtual] |
Implements Home.
Definition at line 155 of file WtHome.C.
00156 { 00157 return new ExampleSourceViewer(deployPath, wtExamplePath_ + "/", "CPP"); 00158 }
virtual std::string WtHome::filePrefix | ( | ) | const [inline, protected, virtual] |
WWidget * WtHome::example | ( | const char * | textKey, | |
const std::string & | sourceDir | |||
) | [private] |
Definition at line 37 of file WtHome.C.
00038 { 00039 WContainerWidget *result = new WContainerWidget(); 00040 new WText(tr(textKey), result); 00041 result->addWidget(linkSourceBrowser(sourceDir)); 00042 return result; 00043 }
WWidget * WtHome::helloWorldExample | ( | ) | [private] |
WWidget * WtHome::chartExample | ( | ) | [private] |
WWidget * WtHome::homepageExample | ( | ) | [private] |
WWidget * WtHome::treeviewExample | ( | ) | [private] |
WWidget * WtHome::gitExample | ( | ) | [private] |
WWidget * WtHome::chatExample | ( | ) | [private] |
WWidget * WtHome::composerExample | ( | ) | [private] |
WWidget * WtHome::widgetGalleryExample | ( | ) | [private] |
std::string WtHome::wtExamplePath_ [private] |