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.

00018                                                 :
00019    WTable(parent)
00020 {
00021    resize(WLength(100, WLength::Percentage), WLength::Auto);
00022 
00023    WText *title = new WText(L"A Witty game: Hangman", elementAt(0,0));
00024    title->decorationStyle().font().setSize(WFont::XXLarge);
00025 
00026    // Center the title horizontally.
00027    elementAt(0, 0)->setContentAlignment(AlignTop | AlignCenter);
00028 
00029    // Element (1,1) holds a stack of widgets with the main content.
00030    // This is where we switch between Login, Game, and Highscores widgets.
00031    MainStack = new WStackedWidget(elementAt(1, 0));
00032    MainStack->setPadding(20);
00033 
00034    MainStack->addWidget(Login = new LoginWidget());
00035    Login->loginSuccessful.connect(SLOT(this, HangmanGame::play));
00036 
00037    // Element (2,0) contains navigation buttons. Instead of WButton,
00038    // we use WText. WText inherits from WInteractWidget, and thus exposes
00039    // the click event.
00040    BackToGameText = new WText(L" Gaming Grounds ", elementAt(2, 0));
00041    BackToGameText->decorationStyle().setCursor(PointingHandCursor);
00042    BackToGameText->clicked().connect(SLOT(this, HangmanGame::showGame));
00043 
00044    ScoresText = new WText(L" Highscores ", elementAt(2, 0));
00045    ScoresText->decorationStyle().setCursor(PointingHandCursor);
00046    ScoresText->clicked().connect(SLOT(this, HangmanGame::showHighScores));
00047    // Center the buttons horizontally.
00048    elementAt(2, 0)->setContentAlignment(AlignTop | AlignCenter);
00049 
00050    doLogin();
00051 }


Member Function Documentation

void HangmanGame::doLogin (  )  [private]

Definition at line 53 of file HangmanGame.C.

00054 {
00055    MainStack->setCurrentWidget(Login);
00056    BackToGameText->hide();
00057    ScoresText->hide();
00058 }

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

Definition at line 60 of file HangmanGame.C.

00061 {
00062    // Add a widget by passing MainStack as the parent, ...
00063    Game = new HangmanWidget(user, dict, MainStack);
00064    // ... or using addWidget
00065    MainStack->addWidget(Scores = new HighScoresWidget(user));
00066 
00067    BackToGameText->show();
00068    ScoresText->show();
00069 
00070    showGame();
00071 }

void HangmanGame::showGame (  )  [private]

Definition at line 81 of file HangmanGame.C.

00082 {
00083    MainStack->setCurrentWidget(Game);
00084    BackToGameText->decorationStyle().font().setWeight(WFont::Bold);
00085    ScoresText->decorationStyle().font().setWeight(WFont::NormalWeight);
00086 }

void HangmanGame::showHighScores (  )  [private]

Definition at line 73 of file HangmanGame.C.

00074 {
00075    MainStack->setCurrentWidget(Scores);
00076    Scores->update();
00077    BackToGameText->decorationStyle().font().setWeight(WFont::NormalWeight);
00078    ScoresText->decorationStyle().font().setWeight(WFont::Bold);
00079 }


Member Data Documentation

Definition at line 31 of file HangmanGame.h.

Definition at line 32 of file HangmanGame.h.

Definition at line 33 of file HangmanGame.h.

Definition at line 34 of file HangmanGame.h.

Definition at line 35 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 Thu May 20 18:14:57 2010 for Wt by doxygen 1.5.6