Public Member Functions | Private Member Functions | Private Attributes

HangmanGame Class Reference

#include <HangmanGame.h>

Inheritance diagram for HangmanGame:
Inheritance graph
[legend]

List of all members.

Public Member Functions

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

Private Member Functions

void onLogin ()
void showLogin ()
void showGame ()
void showHighScores ()

Private Attributes

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

Detailed Description

Definition at line 25 of file HangmanGame.h.


Constructor & Destructor Documentation

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

Definition at line 21 of file HangmanGame.C.

                                                :
  WContainerWidget(parent),
  game_(0),
  scores_(0)
{
  WVBoxLayout *layout = new WVBoxLayout();
  layout->setContentsMargins(0, 0, 0, 0);
  this->setLayout(layout);
  
  WText *title = new WText("<h1>A Witty game: Hangman</h1>");
  layout->addWidget(title);

  mainStack_ = new WStackedWidget(this);
  mainStack_->setStyleClass("gamestack");
  layout->addWidget(mainStack_, 1, AlignJustify | AlignMiddle);
  
  mainStack_->addWidget(login_ = new LoginWidget(&session_));
  login_->loggedIn().connect(this, &HangmanGame::onLogin);

  WContainerWidget *links = new WContainerWidget();
  links->setStyleClass("links");
  layout->addWidget(links);

  backToGameAnchor_ = new WAnchor("/play", "Gaming Grounds", links);
  backToGameAnchor_->setRefInternalPath("/play");
  backToGameAnchor_->setStyleClass("link");

  scoresAnchor_ = new WAnchor("/highscores", "Highscores", links);
  scoresAnchor_->setRefInternalPath("/highscores");
  scoresAnchor_->setStyleClass("link");

  WApplication::instance()->internalPathChanged()
    .connect(this, &HangmanGame::handleInternalPath);

  showLogin();
}

Member Function Documentation

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

Definition at line 58 of file HangmanGame.C.

{
  if (internalPath == "/play" && session_.user())
    showGame();
  else if (internalPath == "/highscores")
    showHighScores();
  else
    showLogin();
}
void HangmanGame::onLogin (  ) [private]

Definition at line 90 of file HangmanGame.C.

{
  WApplication *app = WApplication::instance();

  std::string path = app->internalPath();
  if (path != "/highscores" && path != "/play")
    app->setInternalPath("/play", true);
  else
    handleInternalPath(path);
}
void HangmanGame::showGame (  ) [private]
void HangmanGame::showHighScores (  ) [private]
void HangmanGame::showLogin (  ) [private]

Member Data Documentation

Definition at line 37 of file HangmanGame.h.

Definition at line 35 of file HangmanGame.h.

Definition at line 34 of file HangmanGame.h.

Definition at line 33 of file HangmanGame.h.

Definition at line 36 of file HangmanGame.h.

Definition at line 38 of file HangmanGame.h.

Definition at line 40 of file HangmanGame.h.


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

Generated on Fri Sep 23 2011 for the C++ Web Toolkit (Wt) by doxygen 1.7.2