/home/koen/project/wt/cvs/wt/examples/hangman/HangmanWidget.h

Go to the documentation of this file.
00001 /* this is a -*-C++-*- file
00002  *
00003  * Copyright (C) 2005 Wim Dumon
00004  *
00005  * See the LICENSE file for terms of use.
00006  */
00007 
00008 #ifndef HANGMANWIDGET_H_
00009 #define HANGMANWIDGET_H_
00010 
00011 #include <WContainerWidget>
00012 #include <WText>
00013 #include <WPushButton>
00014 #include <vector>
00015 
00016 #include "Dictionary.h"
00017 
00018 namespace Wt {
00019   class WPushButton;
00020   class WImage;
00021   class WLineEdit;
00022   class WPushButton;
00023   class WTable;
00024 }
00025 
00026 using namespace Wt;
00027 
00028 class HangmanWidget: public WContainerWidget
00029 {
00030    public:
00031       HangmanWidget(std::wstring user, Dictionary dict,
00032                     WContainerWidget *parent = 0);
00033 
00034    private:
00035       WText                     *Title;
00036       WTable                    *LetterButtonLayout;
00037       std::vector<WPushButton *> LetterButtons;
00038       std::vector<WImage *>      HangmanImages;
00039       WImage                    *HurrayImage;
00040       WContainerWidget          *WordContainer;
00041       WText                     *StatusText;
00042       std::vector<WText *>       WordLetters;
00043       WPushButton               *NewGameButton;
00044       
00045       const unsigned int MaxGuesses;
00046       unsigned int       BadGuesses;
00047       unsigned int       DisplayedLetters;
00048       std::wstring       Word;
00049       std::wstring       User;
00050       Dictionary         Dict;
00051 
00052       // constructor helpers
00053       void createAlphabet(WContainerWidget *parent);
00054       void createHangmanImages(WContainerWidget *parent);
00055 
00056       // other helpers
00057       void resetImages();
00058       void resetButtons();
00059       void registerBadGuess();
00060       void registerCorrectGuess(wchar_t c);
00061 
00062    private slots:
00063       void processButton(WPushButton *button);
00064       void newGame();
00065 };
00066 
00067 #endif

Generated on Mon Apr 14 15:15:04 2008 for Wt by doxygen 1.5.3