WtHome Class Reference

#include <WtHome.h>

Inheritance diagram for WtHome:

Inheritance graph
[legend]

List of all members.

Public Member Functions

 WtHome (const WEnvironment &env)

Protected Member Functions

virtual WWidgetexamples ()
virtual WWidgetdownload ()
virtual WWidgetsourceViewer (const std::string &internalPath)
virtual std::string filePrefix () const

Private Member Functions

WWidgetexample (const char *textKey, const std::string &sourceDir)
WWidgethelloWorldExample ()
WWidgetchartExample ()
WWidgethomepageExample ()
WWidgettreeviewExample ()
WWidgetgitExample ()
WWidgetchatExample ()
WWidgetcomposerExample ()
WWidgetwidgetGalleryExample ()
WWidgetwrapView (WWidget *(WtHome::*createFunction)())

Private Attributes

std::string wtExamplePath_


Detailed Description

Definition at line 16 of file WtHome.h.


Constructor & Destructor Documentation

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 }


Member Function Documentation

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]

Implements Home.

Definition at line 25 of file WtHome.h.

00025 { return "wt-"; }

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]

Definition at line 45 of file WtHome.C.

00046 {
00047   return example("home.examples.hello", "hello");
00048 }

WWidget * WtHome::chartExample (  )  [private]

Definition at line 50 of file WtHome.C.

00051 {
00052   return example("home.examples.chart", "charts");
00053 }

WWidget * WtHome::homepageExample (  )  [private]

Definition at line 55 of file WtHome.C.

00056 {
00057   return example("home.examples.wt", "wt-homepage");
00058 }

WWidget * WtHome::treeviewExample (  )  [private]

Definition at line 60 of file WtHome.C.

00061 {
00062   return example("home.examples.treeview", "treeview-dragdrop");
00063 }

WWidget * WtHome::gitExample (  )  [private]

Definition at line 65 of file WtHome.C.

00066 {
00067   return example("home.examples.git", "gitmodel");
00068 }

WWidget * WtHome::chatExample (  )  [private]

Definition at line 70 of file WtHome.C.

00071 {
00072   return example("home.examples.chat", "simplechat");
00073 }

WWidget * WtHome::composerExample (  )  [private]

Definition at line 75 of file WtHome.C.

00076 {
00077   return example("home.examples.composer", "composer");
00078 }

WWidget * WtHome::widgetGalleryExample (  )  [private]

Definition at line 80 of file WtHome.C.

00081 {
00082   return example("home.examples.widgetgallery", "widgetgallery");
00083 }

WWidget * WtHome::wrapView ( WWidget *(WtHome::*)()  createFunction  )  [private]

Definition at line 160 of file WtHome.C.

00161 {
00162   return makeStaticModel(boost::bind(createWidget, this));
00163 }


Member Data Documentation

std::string WtHome::wtExamplePath_ [private]

Definition at line 28 of file WtHome.h.


The documentation for this class was generated from the following files:

Generated on Thu May 20 18:14:58 2010 for Wt by doxygen 1.5.6