Wt examples  3.2.2
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
JWtHome Class Reference

#include <JWtHome.h>

Inheritance diagram for JWtHome:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 JWtHome (const WEnvironment &env)

Protected Member Functions

virtual WWidgetexamples ()
virtual WWidgetcreateQuoteForm ()
virtual WWidgetsourceViewer (const std::string &deployPath)
virtual std::string filePrefix () const
WWidgetwrapView (WWidget *(JWtHome::*createFunction)())

Private Member Functions

WWidgetexample (const char *textKey, const std::string &sourceDir)
WWidgethelloWorldExample ()
WWidgetchartExample ()
WWidgetcomposerExample ()
WWidgettreeviewExample ()
WWidgetchatExample ()
WWidgetfigtreeExample ()
WWidgetwidgetGalleryExample ()

Private Attributes

std::string jwtExamplePath_

Detailed Description

Definition at line 16 of file JWtHome.h.


Constructor & Destructor Documentation

JWtHome::JWtHome ( const WEnvironment env)

Definition at line 27 of file JWtHome.C.

  : Home(env, 
      "JWt, Java Web Toolkit",
      "jwt-home", "css/jwt")
{
  addLanguage(Lang("en", "/", "en", "English"));

  char* jwtExamplePath  = getenv("JWT_EXAMPLE_PATH");
  if (jwtExamplePath)
    jwtExamplePath_ = jwtExamplePath;
  else
    jwtExamplePath_ = "/home/pieter/projects/jwt/wt-port/java/examples/";

  init();
}

Member Function Documentation

WWidget * JWtHome::chartExample ( ) [private]

Definition at line 119 of file JWtHome.C.

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

Definition at line 134 of file JWtHome.C.

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

Definition at line 129 of file JWtHome.C.

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

Implements Home.

Definition at line 92 of file JWtHome.C.

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

Definition at line 106 of file JWtHome.C.

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

Implements Home.

Definition at line 43 of file JWtHome.C.

{
  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(&JWtHome::helloWorldExample),
                        tr("hello-world"))->setPathComponent("");
  examplesMenu_->addTab(wrapView(&JWtHome::chartExample),
                        tr("charts"));
  examplesMenu_->addTab(wrapView(&JWtHome::treeviewExample),
                        tr("treeview"));
  examplesMenu_->addTab(wrapView(&JWtHome::composerExample),
                        tr("mail-composer"));
  examplesMenu_->addTab(wrapView(&JWtHome::chatExample),
                        tr("chat"));
  examplesMenu_->addTab(wrapView(&JWtHome::figtreeExample),
                        tr("figtree"));
  examplesMenu_->addTab(wrapView(&JWtHome::widgetGalleryExample),
                        tr("widget-gallery"));
  
  // Enable internal paths for the example menu
  examplesMenu_->setInternalPathEnabled("/examples");
  examplesMenu_->currentChanged().connect(this, &Home::googleAnalyticsLogger);

  return result;
}
WWidget * JWtHome::figtreeExample ( ) [private]

Definition at line 139 of file JWtHome.C.

{
  WContainerWidget *result = new WContainerWidget();
  WText *text = new WText(tr("home.examples.figtree"), result);
  text->setInternalPathEncoding(true);
  return result;
}
virtual std::string JWtHome::filePrefix ( ) const [inline, protected, virtual]

Implements Home.

Definition at line 25 of file JWtHome.h.

{ return "jwt-"; }
WWidget * JWtHome::helloWorldExample ( ) [private]

Definition at line 114 of file JWtHome.C.

{
  return example("home.examples.hello", "hello");
}
WWidget * JWtHome::sourceViewer ( const std::string &  deployPath) [protected, virtual]

Implements Home.

Definition at line 101 of file JWtHome.C.

{
  return new ExampleSourceViewer(deployPath, jwtExamplePath_ + "/", "JAVA");
}
WWidget * JWtHome::treeviewExample ( ) [private]

Definition at line 124 of file JWtHome.C.

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

Definition at line 147 of file JWtHome.C.

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

Definition at line 152 of file JWtHome.C.

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

Member Data Documentation

std::string JWtHome::jwtExamplePath_ [private]

Definition at line 40 of file JWtHome.h.


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

Generated on Fri Jul 27 2012 for the C++ Web Toolkit (Wt) by doxygen 1.7.5.1