Wt examples 3.1.10
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 (WContainerWidget *parent)

Private Member Functions

void doLogin ()
void play (std::wstring user, Dictionary dictionary)
void showGame ()
void showHighScores ()

Private Attributes

WStackedWidgetMainStack
LoginWidgetLogin
HangmanWidgetGame
HighScoresWidgetScores
WTextBackToGameText
WTextScoresText

Detailed Description

Definition at line 25 of file HangmanGame.h.


Constructor & Destructor Documentation

HangmanGame::HangmanGame ( WContainerWidget parent)

Definition at line 18 of file HangmanGame.C.

                                                :
   WTable(parent)
{
   resize(WLength(100, WLength::Percentage), WLength::Auto);

   WText *title = new WText(L"A Witty game: Hangman", elementAt(0,0));
   title->decorationStyle().font().setSize(WFont::XXLarge);

   // Center the title horizontally.
   elementAt(0, 0)->setContentAlignment(AlignTop | AlignCenter);

   // Element (1,1) holds a stack of widgets with the main content.
   // This is where we switch between Login, Game, and Highscores widgets.
   MainStack = new WStackedWidget(elementAt(1, 0));
   MainStack->setPadding(20);

   MainStack->addWidget(Login = new LoginWidget());
   Login->loginSuccessful.connect(this, &HangmanGame::play);

   // Element (2,0) contains navigation buttons. Instead of WButton,
   // we use WText. WText inherits from WInteractWidget, and thus exposes
   // the click event.
   BackToGameText = new WText(L" Gaming Grounds ", elementAt(2, 0));
   BackToGameText->decorationStyle().setCursor(PointingHandCursor);
   BackToGameText->clicked().connect(this, &HangmanGame::showGame);

   ScoresText = new WText(L" Highscores ", elementAt(2, 0));
   ScoresText->decorationStyle().setCursor(PointingHandCursor);
   ScoresText->clicked().connect(this, &HangmanGame::showHighScores);
   // Center the buttons horizontally.
   elementAt(2, 0)->setContentAlignment(AlignTop | AlignCenter);

   doLogin();
}

Member Function Documentation

void HangmanGame::doLogin ( ) [private]

Definition at line 53 of file HangmanGame.C.

void HangmanGame::play ( std::wstring  user,
Dictionary  dictionary 
) [private]

Definition at line 60 of file HangmanGame.C.

{
   // Add a widget by passing MainStack as the parent, ...
   Game = new HangmanWidget(user, dict, MainStack);
   // ... or using addWidget
   MainStack->addWidget(Scores = new HighScoresWidget(user));

   BackToGameText->show();
   ScoresText->show();

   showGame();
}
void HangmanGame::showGame ( ) [private]

Definition at line 81 of file HangmanGame.C.

void HangmanGame::showHighScores ( ) [private]

Definition at line 73 of file HangmanGame.C.


Member Data Documentation

Definition at line 35 of file HangmanGame.h.

Definition at line 33 of file HangmanGame.h.

Definition at line 32 of file HangmanGame.h.

Definition at line 31 of file HangmanGame.h.

Definition at line 34 of file HangmanGame.h.

Definition at line 36 of file HangmanGame.h.


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

Generated on Mon Nov 14 2011 for the C++ Web Toolkit (Wt) by doxygen 1.7.4