Wt examples  3.3.0
Public Member Functions | Private Member Functions | Private Attributes | List of all members
HangmanGame Class Reference

#include <HangmanGame.h>

Inheritance diagram for HangmanGame:
Inheritance graph
[legend]

Public Member Functions

 HangmanGame (Wt::WContainerWidget *parent=0)
 
void handleInternalPath (const std::string &internalPath)
 

Private Member Functions

void onAuthEvent ()
 
void showGame ()
 
void showHighScores ()
 

Private Attributes

Wt::WStackedWidgetmainStack_
 
HangmanWidgetgame_
 
HighScoresWidgetscores_
 
Wt::WContainerWidgetlinks_
 
Wt::WAnchorbackToGameAnchor_
 
Wt::WAnchorscoresAnchor_
 
Session session_
 

Additional Inherited Members

- Protected Member Functions inherited from Wt::WWidget
virtual void enableAjax ()=0
 
virtual void propagateSetEnabled (bool enabled)=0
 
virtual void render (WFlags< RenderFlag > flags)
 

Detailed Description

Definition at line 24 of file HangmanGame.h.

Constructor & Destructor Documentation

HangmanGame::HangmanGame ( Wt::WContainerWidget parent = 0)

Definition at line 21 of file HangmanGame.C.

22  :
23  WContainerWidget(parent),
24  game_(0),
25  scores_(0)
26 {
28 
30  session_.users(), this);
32  authModel->addOAuth(Session::oAuth());
33 
34  Auth::AuthWidget *authWidget = new Auth::AuthWidget(session_.login());
35  authWidget->setModel(authModel);
36  authWidget->setRegistrationEnabled(true);
37 
38  WText *title = new WText("<h1>A Witty game: Hangman</h1>");
39  addWidget(title);
40 
41  addWidget(authWidget);
42 
43  mainStack_ = new WStackedWidget();
44  mainStack_->setStyleClass("gamestack");
45  addWidget(mainStack_);
46 
47  links_ = new WContainerWidget();
48  links_->setStyleClass("links");
49  links_->hide();
50  addWidget(links_);
51 
52  backToGameAnchor_ = new WAnchor("/play", "Gaming Grounds", links_);
53  backToGameAnchor_->setLink(WLink(WLink::InternalPath, "/play"));
54 
55  scoresAnchor_ = new WAnchor("/highscores", "Highscores", links_);
56  scoresAnchor_->setLink(WLink(WLink::InternalPath, "/highscores"));
57 
58  WApplication::instance()->internalPathChanged()
59  .connect(this, &HangmanGame::handleInternalPath);
60 
61  authWidget->processEnvironment();
}

Member Function Documentation

void HangmanGame::handleInternalPath ( const std::string &  internalPath)

Definition at line 76 of file HangmanGame.C.

77 {
78  if (session_.login().loggedIn()) {
79  if (internalPath == "/play")
80  showGame();
81  else if (internalPath == "/highscores")
83  else
84  WApplication::instance()->setInternalPath("/play", true);
85  }
86 }
void HangmanGame::onAuthEvent ( )
private

Definition at line 63 of file HangmanGame.C.

64 {
65  if (session_.login().loggedIn()) {
66  links_->show();
67  handleInternalPath(WApplication::instance()->internalPath());
68  } else {
69  mainStack_->clear();
70  game_ = 0;
71  scores_ = 0;
72  links_->hide();
73  }
74 }
void HangmanGame::showGame ( )
private

Definition at line 100 of file HangmanGame.C.

101 {
102  if (!game_) {
105  }
106 
108 
109  backToGameAnchor_->addStyleClass("selected-link");
110  scoresAnchor_->removeStyleClass("selected-link");
111 }
void HangmanGame::showHighScores ( )
private

Definition at line 88 of file HangmanGame.C.

89 {
90  if (!scores_)
92 
94  scores_->update();
95 
96  backToGameAnchor_->removeStyleClass("selected-link");
97  scoresAnchor_->addStyleClass("selected-link");
98 }

Member Data Documentation

Wt::WAnchor* HangmanGame::backToGameAnchor_
private

Definition at line 36 of file HangmanGame.h.

HangmanWidget* HangmanGame::game_
private

Definition at line 33 of file HangmanGame.h.

Wt::WContainerWidget* HangmanGame::links_
private

Definition at line 35 of file HangmanGame.h.

Wt::WStackedWidget* HangmanGame::mainStack_
private

Definition at line 32 of file HangmanGame.h.

HighScoresWidget* HangmanGame::scores_
private

Definition at line 34 of file HangmanGame.h.

Wt::WAnchor* HangmanGame::scoresAnchor_
private

Definition at line 37 of file HangmanGame.h.

Session HangmanGame::session_
private

Definition at line 39 of file HangmanGame.h.


The documentation for this class was generated from the following files:
Generated on Fri May 31 2013 for the C++ Web Toolkit (Wt) by doxygen 1.8.3.1