Wt examples  3.2.0
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
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 WWidgetcreateQuoteForm ()
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 ()
WWidgethangmanExample ()
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 27 of file WtHome.C.

  : Home(env, "Wt, C++ Web Toolkit", "wt-home", "css/wt")
{
  addLanguage(Lang("en", "/", "en", "English"));
  addLanguage(Lang("cn", "/cn/", "汉语", "中文 (Chinese)"));
  addLanguage(Lang("ru", "/ru/", "ру", "Русский (Russian)"));

  char* wtExamplePath  = getenv("WT_EXAMPLE_PATH");
  if (wtExamplePath)
    wtExamplePath_ = wtExamplePath;
  else
    wtExamplePath_ = "../";

  init();
}

Member Function Documentation

WWidget * WtHome::chartExample ( ) [private]

Definition at line 57 of file WtHome.C.

{
  return example("home.examples.chart", "charts");
}
WWidget * WtHome::chatExample ( ) [private]

Definition at line 77 of file WtHome.C.

{
  return example("home.examples.chat", "simplechat");
}
WWidget * WtHome::composerExample ( ) [private]

Definition at line 82 of file WtHome.C.

{
  return example("home.examples.composer", "composer");
}
WWidget * WtHome::createQuoteForm ( ) [protected, virtual]

Implements Home.

Definition at line 151 of file WtHome.C.

{
#ifdef WT_EMWEB_BUILD
  return new QuoteForm(QuoteForm::Wt);
#else
  return 0;
#endif
}
WWidget * WtHome::example ( const char *  textKey,
const std::string &  sourceDir 
) [private]

Definition at line 43 of file WtHome.C.

{
  WContainerWidget *result = new WContainerWidget();
  WText *w = new WText(tr(textKey), result);
  w->setInternalPathEncoding(true);
  result->addWidget(linkSourceBrowser(sourceDir));
  return result;
}
WWidget * WtHome::examples ( ) [protected, virtual]

Implements Home.

Definition at line 97 of file WtHome.C.

{
  WContainerWidget *result = new WContainerWidget();

  WText *intro = new WText(tr("home.examples"));
  intro->setInternalPathEncoding(true);
  result->addWidget(intro);

  examplesMenu_ = new WTabWidget(AlignTop | AlignJustify, 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;
}
virtual std::string WtHome::filePrefix ( ) const [inline, protected, virtual]

Implements Home.

Definition at line 25 of file WtHome.h.

{ return "wt-"; }
WWidget * WtHome::gitExample ( ) [private]

Definition at line 72 of file WtHome.C.

{
  return example("home.examples.git", "gitmodel");
}
WWidget * WtHome::hangmanExample ( ) [private]

Definition at line 92 of file WtHome.C.

{
  return example("home.examples.hangman", "hangman");
}
WWidget * WtHome::helloWorldExample ( ) [private]

Definition at line 52 of file WtHome.C.

{
  return example("home.examples.hello", "hello");
}
WWidget * WtHome::homepageExample ( ) [private]

Definition at line 62 of file WtHome.C.

{
  return example("home.examples.wt", "wt-homepage");
}
WWidget * WtHome::sourceViewer ( const std::string &  internalPath) [protected, virtual]

Implements Home.

Definition at line 160 of file WtHome.C.

{
  return new ExampleSourceViewer(deployPath, wtExamplePath_ + "/", "CPP");
}
WWidget * WtHome::treeviewExample ( ) [private]

Definition at line 67 of file WtHome.C.

{
  return example("home.examples.treeview", "treeview-dragdrop");
}
WWidget * WtHome::widgetGalleryExample ( ) [private]

Definition at line 87 of file WtHome.C.

{
  return example("home.examples.widgetgallery", "widgetgallery");
}
WWidget * WtHome::wrapView ( WWidget *(WtHome::*)()  createFunction) [private]

Definition at line 165 of file WtHome.C.

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

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 Tue Nov 29 2011 for the C++ Web Toolkit (Wt) by doxygen 1.7.5.1