Wt examples 3.3.12
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 ()
 
- Public Member Functions inherited from Wt::WApplication
 WApplication (const WEnvironment &environment)
 
 ~WApplication ()
 
const WEnvironmentenvironment () const
 
WContainerWidgetroot () const
 
WWidgetfindWidget (const std::string &name)
 
WCssStyleSheetstyleSheet ()
 
void useStyleSheet (const WLink &link, const std::string &media="all")
 
void useStyleSheet (const WLink &link, const std::string &condition, const std::string &media)
 
void useStyleSheet (const WCssStyleSheet &styleSheet, const std::string &condition="")
 
void removeStyleSheet (const WLink &link)
 
void setTheme (const WTheme *theme)
 
const WThemetheme () const
 
void setCssTheme (const std::string &name)
 
void setLayoutDirection (LayoutDirection direction)
 
LayoutDirection layoutDirection () const
 
void setBodyClass (const std::string &styleClass)
 
std::string bodyClass () const
 
void setHtmlClass (const std::string &styleClass)
 
std::string htmlClass () const
 
void setTitle (const WString &title)
 
const WStringtitle () const
 
const WStringcloseMessage () const
 
WLocalizedStringslocalizedStrings ()
 
WMessageResourceBundlebuiltinLocalizedStrings ()
 
void setLocalizedStrings (WLocalizedStrings *stringResolver)
 
WMessageResourceBundlemessageResourceBundle ()
 
void setLocale (const WLocale &locale)
 
const WLocalelocale () const
 
virtual void refresh ()
 
void bindWidget (WWidget *widget, const std::string &domId)
 
void enableUpdates (bool enabled=true)
 
bool updatesEnabled () const
 
void triggerUpdate ()
 
UpdateLock getUpdateLock ()
 
void attachThread (bool attach=true)
 
EventSignal< WKeyEvent > & globalKeyWentDown ()
 
EventSignal< WKeyEvent > & globalKeyPressed ()
 
EventSignal< WKeyEvent > & globalKeyWentUp ()
 
EventSignalglobalEnterPressed ()
 
EventSignalglobalEscapePressed ()
 
bool debug () const
 
void setFocus (const std::string &id, int selectionStart, int selectionEnd)
 
void loadJavaScript (const char *jsFile, const WJavaScriptPreamble &preamble)
 
bool javaScriptLoaded (const char *jsFile) const
 
void setConfirmCloseMessage (const WString &message)
 
void enableInternalPaths ()
 
void deferRendering ()
 
void resumeRendering ()
 
boost::function< void()> bind (const F &f)
 
std::string encodeUntrustedUrl (const std::string &url) const
 
void pushExposedConstraint (WWidget *w)
 
void popExposedConstraint (WWidget *w)
 
void addGlobalWidget (WWidget *w)
 
void removeGlobalWidget (WWidget *w)
 
WCssStyleSheetstyleSheet ()
 
void useStyleSheet (const WLink &link, const std::string &media="all")
 
void useStyleSheet (const WLink &link, const std::string &condition, const std::string &media)
 
void useStyleSheet (const WCssStyleSheet &styleSheet, const std::string &condition="")
 
void removeStyleSheet (const WLink &link)
 
void setTheme (const WTheme *theme)
 
const WThemetheme () const
 
void setCssTheme (const std::string &name)
 
void setLayoutDirection (LayoutDirection direction)
 
LayoutDirection layoutDirection () const
 
void setBodyClass (const std::string &styleClass)
 
std::string bodyClass () const
 
void setHtmlClass (const std::string &styleClass)
 
std::string htmlClass () const
 
void setTitle (const WString &title)
 
const WStringtitle () const
 
const WStringcloseMessage () const
 
WLocalizedStringslocalizedStrings ()
 
WMessageResourceBundlebuiltinLocalizedStrings ()
 
void setLocalizedStrings (WLocalizedStrings *stringResolver)
 
WMessageResourceBundlemessageResourceBundle ()
 
void setLocale (const WLocale &locale)
 
const WLocalelocale () const
 
virtual void refresh ()
 
void bindWidget (WWidget *widget, const std::string &domId)
 
std::string url (const std::string &internalPath=std::string()) const
 
virtual std::string makeAbsoluteUrl (const std::string &url) const
 
std::string resolveRelativeUrl (const std::string &url) const
 
std::string bookmarkUrl () const
 
std::string bookmarkUrl (const std::string &internalPath) const
 
void setInternalPath (const std::string &path, bool emitChange=false)
 
void setInternalPathDefaultValid (bool valid)
 
bool internalPathDefaultValid () const
 
void setInternalPathValid (bool valid)
 
bool internalPathValid () const
 
std::string internalPath () const
 
std::string internalPathNextPart (const std::string &path) const
 
std::string internalSubPath (const std::string &path) const
 
bool internalPathMatches (const std::string &path) const
 
Signal< std::string > & internalPathChanged ()
 
Signal< std::string > & internalPathInvalid ()
 
void redirect (const std::string &url)
 
std::string docRoot () const
 
void setConnectionMonitor (const std::string &jsObject)
 
std::string sessionId () const
 
void changeSessionId ()
 
WebSession * session () const
 
void enableUpdates (bool enabled=true)
 
bool updatesEnabled () const
 
void triggerUpdate ()
 
UpdateLock getUpdateLock ()
 
void attachThread (bool attach=true)
 
void doJavaScript (const std::string &javascript, bool afterLoaded=true)
 
void addAutoJavaScript (const std::string &javascript)
 
void declareJavaScriptFunction (const std::string &name, const std::string &function)
 
bool require (const std::string &url, const std::string &symbol=std::string())
 
bool requireJQuery (const std::string &url)
 
bool customJQuery () const
 
void setJavaScriptClass (const std::string &className)
 
std::string javaScriptClass ()
 
void processEvents ()
 
virtual void waitForEvent ()
 
void setAjaxMethod (AjaxMethod method)
 
AjaxMethod ajaxMethod () const
 
WContainerWidgetdomRoot () const
 
WContainerWidgetdomRoot2 () const
 
std::string encodeObject (WObject *object)
 
WObjectdecodeObject (const std::string &objectId) const
 
virtual void initialize ()
 
virtual void finalize ()
 
void setTwoPhaseRenderingThreshold (int size)
 
void setCookie (const std::string &name, const std::string &value, int maxAge, const std::string &domain="", const std::string &path="", bool secure=false)
 
void setCookie (const std::string &name, const std::string &value, const WDateTime &expires, const std::string &domain="", const std::string &path="", bool secure=false)
 
void removeCookie (const std::string &name, const std::string &domain="", const std::string &path="")
 
void addMetaLink (const std::string &href, const std::string &rel, const std::string &media, const std::string &hreflang, const std::string &type, const std::string &sizes, bool disabled)
 
void removeMetaLink (const std::string &href)
 
void addMetaHeader (const std::string &name, const WString &content, const std::string &lang="")
 
void addMetaHeader (MetaHeaderType type, const std::string &name, const WString &content, const std::string &lang="")
 
WString metaHeader (MetaHeaderType type, const std::string &name) const
 
void removeMetaHeader (MetaHeaderType type, const std::string &name="")
 
WLogEntry log (const std::string &type) const
 
void setLoadingIndicator (WLoadingIndicator *indicator)
 
WLoadingIndicatorloadingIndicator () const
 
std::string onePixelGifUrl ()
 
std::string docType () const
 
void quit ()
 
void quit (const WString &restartMessage)
 
bool isQuited () const
 
bool hasQuit () const
 
::int64_t maximumRequestSize () const
 
Signal< ::int64_t > & requestTooLarge ()
 
bool isConnected () const
 
- Public Member Functions inherited from Wt::WObject
 WObject (WObject *parent=0)
 
virtual ~WObject ()
 
virtual const std::string id () const
 
virtual void setObjectName (const std::string &name)
 
virtual std::string objectName () const
 
void resetLearnedSlots ()
 
void resetLearnedSlot (void(T::*method)())
 
WStatelessSlot * implementStateless (void(T::*method)())
 
WStatelessSlot * implementStateless (void(T::*method)(), void(T::*undoMethod)())
 
void isNotStateless ()
 
WStatelessSlot * implementJavaScript (void(T::*method)(), const std::string &jsCode)
 
void addChild (WObject *child)
 
virtual void removeChild (WObject *child)
 
const std::vector< WObject * > & children () const
 
WObjectparent () const
 

Protected Member Functions

virtual WWidgetexamples ()
 
virtual WWidgetcreateQuoteForm ()
 
virtual WWidgetsourceViewer (const std::string &internalPath)
 
virtual std::string filePrefix () const
 
- Protected Member Functions inherited from Home
void init ()
 
void addLanguage (const Lang &l)
 
WWidgetlinkSourceBrowser (const std::string &examplePath)
 
WString tr (const char *key)
 
std::string href (const std::string &url, const std::string &description)
 
void readReleases (WTable *releaseTable)
 
- Protected Member Functions inherited from Wt::WApplication
virtual void notify (const WEvent &e)
 
virtual bool isExposed (WWidget *w) const
 
virtual void enableAjax ()
 
virtual void unload ()
 
virtual void idleTimeout ()
 
virtual void handleJavaScriptError (const std::string &errorText)
 
- Protected Member Functions inherited from Wt::WObject
virtual WStatelessSlot * getStateless (Method method)
 

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_
 

Additional Inherited Members

- Public Types inherited from Wt::WApplication
enum  AjaxMethod
 
typedef Wt::ApplicationCreator ApplicationCreator
 
typedef boost::function< WApplication *(const WEnvironment &)> ApplicationCreator
 
- Public Types inherited from Wt::WObject
typedef void(WObject::* Method) ()
 
- Static Public Member Functions inherited from Wt::WApplication
static WApplicationinstance ()
 
static bool pathMatches (const std::string &path, const std::string &query)
 
static std::string resourcesUrl ()
 
static std::string relativeResourcesUrl ()
 
static std::string appRoot ()
 
static bool readConfigurationProperty (const std::string &name, std::string &value)
 
- Public Attributes inherited from Wt::WApplication
 XMLHttpRequest
 
 DynamicScriptTag
 
- Static Protected Member Functions inherited from Wt::WObject
static WObjectsender ()
 
- Protected Attributes inherited from Home
WTabWidgetexamplesMenu_
 
WTablereleases_
 

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:68
void addLanguage(const Lang &l)
Definition Home.h:86
void init()
Definition Home.C:62
std::string wtExamplePath_
Definition WtHome.h:28
WEnvironment & env()
Definition Home.h:23

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}

◆ composerExample()

WWidget * WtHome::composerExample ( )
private

Definition at line 82 of file WtHome.C.

83{
84 return example("home.examples.composer", "composer");
85}

◆ 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);
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
virtual void addWidget(WWidget *widget)
void setInternalPathEncoding(bool enabled)

◆ 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
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
147
148 return result;
149}
WTabWidget * examplesMenu_
Definition Home.h:89
void googleAnalyticsLogger()
Definition Home.C:426
WWidget * homepageExample()
Definition WtHome.C:62
WWidget * chatExample()
Definition WtHome.C:77
WWidget * wrapView(WWidget *(WtHome::*createFunction)())
Definition WtHome.C:165
WWidget * helloWorldExample()
Definition WtHome.C:52
WWidget * treeviewExample()
Definition WtHome.C:67
WWidget * chartExample()
Definition WtHome.C:57
WWidget * gitExample()
Definition WtHome.C:72
WWidget * hangmanExample()
Definition WtHome.C:92
WWidget * widgetGalleryExample()
Definition WtHome.C:87
WWidget * composerExample()
Definition WtHome.C:82
virtual Wt::Signals::connection connect(WObject *target, WObject::Method method)
virtual void setPathComponent(const std::string &path)
void setTransitionAnimation(const WAnimation &animation, bool autoReverse=false)
void setInternalPathEnabled(const std::string &basePath="")
WMenuItem * addTab(WWidget *child, const WString &label, LoadPolicy=LazyLoading)
Signal< int > & currentChanged()
WStackedWidget * contentsStack() const

◆ 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}

◆ hangmanExample()

WWidget * WtHome::hangmanExample ( )
private

Definition at line 92 of file WtHome.C.

93{
94 return example("home.examples.hangman", "hangman");
95}

◆ helloWorldExample()

WWidget * WtHome::helloWorldExample ( )
private

Definition at line 52 of file WtHome.C.

53{
54 return example("home.examples.hello", "hello");
55}

◆ homepageExample()

WWidget * WtHome::homepageExample ( )
private

Definition at line 62 of file WtHome.C.

63{
64 return example("home.examples.wt", "wt-homepage");
65}

◆ 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.

◆ treeviewExample()

WWidget * WtHome::treeviewExample ( )
private

Definition at line 67 of file WtHome.C.

68{
69 return example("home.examples.treeview", "treeview-dragdrop");
70}

◆ widgetGalleryExample()

WWidget * WtHome::widgetGalleryExample ( )
private

Definition at line 87 of file WtHome.C.

88{
89 return example("home.examples.widgetgallery", "widgetgallery");
90}

◆ 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 Fri May 17 2024 for the C++ Web Toolkit (Wt) by doxygen 1.9.8