Wt examples  3.3.0
Public Member Functions | Private Attributes | List of all members
WordWidget Class Reference

#include <WordWidget.h>

Inheritance diagram for WordWidget:
Inheritance graph
[legend]

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_
 

Additional Inherited Members

- Protected Member Functions inherited from Wt::WWidget
virtual void enableAjax ()=0
 
virtual void propagateSetEnabled (bool enabled)=0
 
virtual void render (WFlags< RenderFlag > flags)
 

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.

14  :
15  WContainerWidget(parent)
16 {
17  addStyleClass("wordcontainer");
}

Member Function Documentation

bool WordWidget::guess ( wchar_t  c)

Definition at line 32 of file WordWidget.C.

33 {
34  bool correct = false;
35 
36  for(unsigned int i = 0; i < word_.size(); ++i) {
37  if(word_[i] == c) {
39  wordLetters_[i]->setText(std::wstring(1, c));
40  correct = true;
41  }
42  }
43 
44  return correct;
45 }
void WordWidget::init ( const std::wstring &  word)

Definition at line 19 of file WordWidget.C.

20 {
21  word_ = word;
23 
24  clear();
25  wordLetters_.clear();
26  for(unsigned int i = 0; i < word_.size(); ++i) {
27  WText *c = new WText("-", this);
28  wordLetters_.push_back(c);
29  }
30 }
bool WordWidget::won ( )

Definition at line 47 of file WordWidget.C.

48 {
49  return displayedLetters_ == word_.size();
50 }
std::wstring WordWidget::word ( ) const
inline

Definition at line 18 of file WordWidget.h.

18 { 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 May 31 2013 for the C++ Web Toolkit (Wt) by doxygen 1.8.3.1