Wt examples  3.3.6
Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | List of all members
WtHome Class Reference

#include <WtHome.h>

Inheritance diagram for WtHome:
Inheritance graph
[legend]

Public Member Functions

 WtHome (const WEnvironment &env, Wt::Dbo::SqlConnectionPool &blogDb)
 
- Public Member Functions inherited from Home
 Home (const WEnvironment &env, Wt::Dbo::SqlConnectionPool &blogDb, const std::string &title, const std::string &resourceBundle, const std::string &cssPath)
 
virtual ~Home ()
 
void googleAnalyticsLogger ()
 

Protected Member Functions

virtual WWidget * examples ()
 
virtual WWidget * createQuoteForm ()
 
virtual WWidget * sourceViewer (const std::string &internalPath)
 
virtual std::string filePrefix () const
 
- Protected Member Functions inherited from Home
void init ()
 
void addLanguage (const Lang &l)
 
WWidget * linkSourceBrowser (const std::string &examplePath)
 
WString tr (const char *key)
 
std::string href (const std::string &url, const std::string &description)
 
void readReleases (WTable *releaseTable)
 

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 * hangmanExample ()
 
WWidget * wrapView (WWidget *(WtHome::*createFunction)())
 

Private Attributes

std::string wtExamplePath_
 

Additional Inherited Members

- Protected Attributes inherited from Home
WTabWidget * examplesMenu_
 
WTable * releases_
 

Detailed Description

Definition at line 16 of file WtHome.h.

Constructor & Destructor Documentation

◆ WtHome()

WtHome::WtHome ( const WEnvironment &  env,
Wt::Dbo::SqlConnectionPool &  blogDb 
)

Definition at line 27 of file WtHome.C.

28  : Home(env, blogDb, "Wt, C++ Web Toolkit", "wt-home", "css/wt")
29 {
30  addLanguage(Lang("en", "/", "en", "English"));
31  addLanguage(Lang("cn", "/cn/", "汉语", "中文 (Chinese)"));
32  addLanguage(Lang("ru", "/ru/", "ру", "Русский (Russian)"));
33 
34  char* wtExamplePath = getenv("WT_EXAMPLE_PATH");
35  if (wtExamplePath)
36  wtExamplePath_ = wtExamplePath;
37  else
38  wtExamplePath_ = "..";
39 
40  init();
41 }
Definition: Home.h:23
Home(const WEnvironment &env, Wt::Dbo::SqlConnectionPool &blogDb, const std::string &title, const std::string &resourceBundle, const std::string &cssPath)
Definition: Home.C:38
void init()
Definition: Home.C:62
std::string wtExamplePath_
Definition: WtHome.h:28
void addLanguage(const Lang &l)
Definition: Home.h:86

Member Function Documentation

◆ chartExample()

WWidget * WtHome::chartExample ( )
private

Definition at line 57 of file WtHome.C.

58 {
59  return example("home.examples.chart", "charts");
60 }
WWidget * example(const char *textKey, const std::string &sourceDir)
Definition: WtHome.C:43

◆ chatExample()

WWidget * WtHome::chatExample ( )
private

Definition at line 77 of file WtHome.C.

78 {
79  return example("home.examples.chat", "simplechat");
80 }
WWidget * example(const char *textKey, const std::string &sourceDir)
Definition: WtHome.C:43

◆ composerExample()

WWidget * WtHome::composerExample ( )
private

Definition at line 82 of file WtHome.C.

83 {
84  return example("home.examples.composer", "composer");
85 }
WWidget * example(const char *textKey, const std::string &sourceDir)
Definition: WtHome.C:43

◆ createQuoteForm()

WWidget * WtHome::createQuoteForm ( )
protectedvirtual

Implements Home.

Definition at line 151 of file WtHome.C.

152 {
153 #ifdef WT_EMWEB_BUILD
154  return new QuoteForm(QuoteForm::Wt);
155 #else
156  return 0;
157 #endif
158 }

◆ example()

WWidget * WtHome::example ( const char *  textKey,
const std::string &  sourceDir 
)
private

Definition at line 43 of file WtHome.C.

44 {
45  WContainerWidget *result = new WContainerWidget();
46  WText *w = new WText(tr(textKey), result);
47  w->setInternalPathEncoding(true);
48  result->addWidget(linkSourceBrowser(sourceDir));
49  return result;
50 }
WWidget * linkSourceBrowser(const std::string &examplePath)
Definition: Home.C:200
WString tr(const char *key)
Definition: Home.C:421

◆ examples()

WWidget * WtHome::examples ( )
protectedvirtual

Implements Home.

Definition at line 97 of file WtHome.C.

98 {
99  WContainerWidget *result = new WContainerWidget();
100 
101  WText *intro = new WText(tr("home.examples"));
102  intro->setInternalPathEncoding(true);
103  result->addWidget(intro);
104 
105  examplesMenu_ = new WTabWidget(result);
106 
107  WAnimation animation(WAnimation::SlideInFromRight, WAnimation::EaseIn);
108  examplesMenu_->contentsStack()->setTransitionAnimation(animation, true);
109 
110  /*
111  * The following code is functionally equivalent to:
112  *
113  * examplesMenu_->addTab(helloWorldExample(), "Hello world");
114  *
115  * However, we optimize here for memory consumption (it is a homepage
116  * after all, and we hope to be slashdotted some day)
117  *
118  * Therefore, we wrap all the static content (including the tree
119  * widgets), into WViewWidgets with static models. In this way the
120  * widgets are not actually stored in memory on the server.
121  */
122 
123  // The call ->setPathComponent() is to use "/examples/" instead of
124  // "/examples/hello_world" as internal path
126  tr("hello-world"))->setPathComponent("");
128  tr("widget-gallery"));
130  tr("charts"));
132  tr("wt-homepage"));
134  tr("treeview"));
136  tr("git"));
138  tr("chat"));
140  tr("mail-composer"));
142  tr("hangman"));
143 
144  // Enable internal paths for the example menu
145  examplesMenu_->setInternalPathEnabled("/examples");
146  examplesMenu_->currentChanged().connect(this, &Home::googleAnalyticsLogger);
147 
148  return result;
149 }
WWidget * helloWorldExample()
Definition: WtHome.C:52
WWidget * chatExample()
Definition: WtHome.C:77
WWidget * homepageExample()
Definition: WtHome.C:62
WWidget * widgetGalleryExample()
Definition: WtHome.C:87
WWidget * composerExample()
Definition: WtHome.C:82
WString tr(const char *key)
Definition: Home.C:421
WWidget * gitExample()
Definition: WtHome.C:72
WWidget * chartExample()
Definition: WtHome.C:57
WWidget * treeviewExample()
Definition: WtHome.C:67
WTabWidget * examplesMenu_
Definition: Home.h:89
WWidget * hangmanExample()
Definition: WtHome.C:92
WWidget * wrapView(WWidget *(WtHome::*createFunction)())
Definition: WtHome.C:165
void googleAnalyticsLogger()
Definition: Home.C:426

◆ filePrefix()

virtual std::string WtHome::filePrefix ( ) const
inlineprotectedvirtual

Implements Home.

Definition at line 25 of file WtHome.h.

25 { return "wt-"; }

◆ gitExample()

WWidget * WtHome::gitExample ( )
private

Definition at line 72 of file WtHome.C.

73 {
74  return example("home.examples.git", "gitmodel");
75 }
WWidget * example(const char *textKey, const std::string &sourceDir)
Definition: WtHome.C:43

◆ hangmanExample()

WWidget * WtHome::hangmanExample ( )
private

Definition at line 92 of file WtHome.C.

93 {
94  return example("home.examples.hangman", "hangman");
95 }
WWidget * example(const char *textKey, const std::string &sourceDir)
Definition: WtHome.C:43

◆ helloWorldExample()

WWidget * WtHome::helloWorldExample ( )
private

Definition at line 52 of file WtHome.C.

53 {
54  return example("home.examples.hello", "hello");
55 }
WWidget * example(const char *textKey, const std::string &sourceDir)
Definition: WtHome.C:43

◆ homepageExample()

WWidget * WtHome::homepageExample ( )
private

Definition at line 62 of file WtHome.C.

63 {
64  return example("home.examples.wt", "wt-homepage");
65 }
WWidget * example(const char *textKey, const std::string &sourceDir)
Definition: WtHome.C:43

◆ sourceViewer()

WWidget * WtHome::sourceViewer ( const std::string &  internalPath)
protectedvirtual

Implements Home.

Definition at line 160 of file WtHome.C.

161 {
162  return new ExampleSourceViewer(deployPath, wtExamplePath_ + "/", "CPP");
163 }
A simple widget to visualise a set of example source files.
std::string wtExamplePath_
Definition: WtHome.h:28

◆ treeviewExample()

WWidget * WtHome::treeviewExample ( )
private

Definition at line 67 of file WtHome.C.

68 {
69  return example("home.examples.treeview", "treeview-dragdrop");
70 }
WWidget * example(const char *textKey, const std::string &sourceDir)
Definition: WtHome.C:43

◆ widgetGalleryExample()

WWidget * WtHome::widgetGalleryExample ( )
private

Definition at line 87 of file WtHome.C.

88 {
89  return example("home.examples.widgetgallery", "widgetgallery");
90 }
WWidget * example(const char *textKey, const std::string &sourceDir)
Definition: WtHome.C:43

◆ wrapView()

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

Definition at line 165 of file WtHome.C.

166 {
167  return makeStaticModel(boost::bind(createWidget, this));
168 }
WApplication * createWidget(const WEnvironment &env, SimpleChatServer &server)
Definition: simpleChat.C:145

Member Data Documentation

◆ wtExamplePath_

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 Jan 12 2017 for the C++ Web Toolkit (Wt) by doxygen 1.8.13