Wt examples  3.2.2
Public Member Functions | Private Attributes
WordWidget Class Reference

#include <WordWidget.h>

Inheritance diagram for WordWidget:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 WordWidget (Wt::WContainerWidget *parent=0)
std::wstring word () const
void init (const std::wstring &word)
bool guess (wchar_t c)
bool won ()

Private Attributes

std::vector< Wt::WText * > wordLetters_
std::wstring word_
unsigned displayedLetters_

Detailed Description

Definition at line 13 of file WordWidget.h.


Constructor & Destructor Documentation

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

Definition at line 13 of file WordWidget.C.

                                               :
  WContainerWidget(parent)
{
  addStyleClass("wordcontainer");
}

Member Function Documentation

bool WordWidget::guess ( wchar_t  c)

Definition at line 32 of file WordWidget.C.

{
  bool correct = false;

  for(unsigned int i = 0; i < word_.size(); ++i) {
    if(word_[i] == c) {
      displayedLetters_++;
      wordLetters_[i]->setText(std::wstring(1, c));
      correct = true;
    }
  }

  return correct;
}
void WordWidget::init ( const std::wstring &  word)

Definition at line 19 of file WordWidget.C.

{
  word_ = word;
  displayedLetters_ = 0;

  clear();
  wordLetters_.clear();
  for(unsigned int i = 0; i < word_.size(); ++i) {
    WText *c = new WText("-", this);
    wordLetters_.push_back(c);
  }
}
bool WordWidget::won ( )

Definition at line 47 of file WordWidget.C.

{
  return displayedLetters_ == word_.size();
}
std::wstring WordWidget::word ( ) const [inline]

Definition at line 18 of file WordWidget.h.

{ return word_; } 

Member Data Documentation

unsigned WordWidget::displayedLetters_ [private]

Definition at line 29 of file WordWidget.h.

std::wstring WordWidget::word_ [private]

Definition at line 27 of file WordWidget.h.

std::vector<Wt::WText *> WordWidget::wordLetters_ [private]

Definition at line 26 of file WordWidget.h.


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

Generated on Fri Jul 27 2012 for the C++ Web Toolkit (Wt) by doxygen 1.7.5.1