HangmanGame Class Reference

#include <HangmanGame.h>

Inherits Wt::WTable.

List of all members.

Public Member Functions

 HangmanGame (WContainerWidget *parent)

Private Slots

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

Private Member Functions

void doLogin ()

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.

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


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, slot]

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, slot]

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, slot]

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 40 of file HangmanGame.h.

Definition at line 38 of file HangmanGame.h.

Definition at line 37 of file HangmanGame.h.

Definition at line 36 of file HangmanGame.h.

Definition at line 39 of file HangmanGame.h.

Definition at line 41 of file HangmanGame.h.


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

Generated on Thu May 13 05:16:01 2010 for Wt by doxygen 1.6.3