Wt examples  3.3.6
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_
 

Detailed Description

Definition at line 13 of file WordWidget.h.

Constructor & Destructor Documentation

§ WordWidget()

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

Definition at line 13 of file WordWidget.C.

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

Member Function Documentation

§ guess()

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 }
std::vector< Wt::WText * > wordLetters_
Definition: WordWidget.h:26
std::wstring word_
Definition: WordWidget.h:27
unsigned displayedLetters_
Definition: WordWidget.h:29

§ init()

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 }
std::vector< Wt::WText * > wordLetters_
Definition: WordWidget.h:26
std::wstring word() const
Definition: WordWidget.h:18
std::wstring word_
Definition: WordWidget.h:27
unsigned displayedLetters_
Definition: WordWidget.h:29

§ won()

bool WordWidget::won ( )

Definition at line 47 of file WordWidget.C.

48 {
49  return displayedLetters_ == word_.size();
50 }
std::wstring word_
Definition: WordWidget.h:27
unsigned displayedLetters_
Definition: WordWidget.h:29

§ word()

std::wstring WordWidget::word ( ) const
inline

Definition at line 18 of file WordWidget.h.

18 { return word_; }
std::wstring word_
Definition: WordWidget.h:27

Member Data Documentation

§ displayedLetters_

unsigned WordWidget::displayedLetters_
private

Definition at line 29 of file WordWidget.h.

§ word_

std::wstring WordWidget::word_
private

Definition at line 27 of file WordWidget.h.

§ wordLetters_

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 Thu Jan 12 2017 for the C++ Web Toolkit (Wt) by doxygen 1.8.12