Wt examples: LettersWidget Class Reference

Wt examples 4.10.4

Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | List of all members
LettersWidget Class Reference

`#include <LettersWidget.h>`

Inheritance diagram for LettersWidget:
[legend]

## Public Member Functions
| LettersWidget ()
virtual | ~LettersWidget ()
void | reset ()
Wt::Signal< char > & | letterPushed ()

## Private Member Functions
void | processButton (Wt::WPushButton *b)
void | processButtonPushed (const Wt::WKeyEvent &e, Wt::WPushButton *b)

## Private Attributes
Wt::WTable * | impl_ = nullptr
std::vector< Wt::WPushButton * > | letterButtons_
std::vector< Wt::Signals::connection > | connections_
Wt::Signal< char > | letterPushed_

## Detailed Description

Definition at line 19 of file LettersWidget.h.

## Constructor & Destructor Documentation

## ◆ LettersWidget()

LettersWidget::LettersWidget | ( |  | ) |

Definition at line 16 of file LettersWidget.C.

17{
18 impl_ = setNewImplementation<WTable>();
19
20 impl_->resize(13*30, WLength::Auto);
21
22 for (unsigned int i = 0; i < 26; ++i) {
23 std::string c(1, 'A' + i);
24 auto character = impl_->elementAt(i / 13, i % 13)->addNew<WPushButton>(c);
25 letterButtons_.push_back(character);
26 character->resize(WLength(30), WLength::Auto);
27
28 character->clicked().connect
29 (std::bind(&LettersWidget::processButton, this, character));
30
31 connections_.push_back(WApplication::instance()->globalKeyPressed().connect
32 (std::bind(&LettersWidget::processButtonPushed, this, std::placeholders::_1, character)));
33 }
34}
LettersWidget::processButton
void processButton(Wt::WPushButton *b)
Definition LettersWidget.C:42
LettersWidget::letterButtons_
std::vector< Wt::WPushButton * > letterButtons_
Definition LettersWidget.h:31
LettersWidget::connections_
std::vector< Wt::Signals::connection > connections_
Definition LettersWidget.h:32
LettersWidget::impl_
Wt::WTable * impl_
Definition LettersWidget.h:30
LettersWidget::processButtonPushed
void processButtonPushed(const Wt::WKeyEvent &e, Wt::WPushButton *b)
Definition LettersWidget.C:48

## ◆ ~LettersWidget()

LettersWidget::~LettersWidget | ( |  | ) |
| virtual

Definition at line 36 of file LettersWidget.C.

37{
38 for (auto &connection : connections_)
39 connection.disconnect();
40}

## Member Function Documentation

## ◆ letterPushed()

Wt::Signal< char > & LettersWidget::letterPushed | ( |  | ) |
| inline

Definition at line 27 of file LettersWidget.h.

27{ return letterPushed_; }
LettersWidget::letterPushed_
Wt::Signal< char > letterPushed_
Definition LettersWidget.h:34

## ◆ processButton()

void LettersWidget::processButton | ( | Wt::WPushButton * | b | ) |
| private

Definition at line 42 of file LettersWidget.C.

43{
44 b->disable();
45 letterPushed_.emit(b->text().toUTF8()[0]);
46}

## ◆ processButtonPushed()

void LettersWidget::processButtonPushed | ( | const Wt::WKeyEvent & | e,
|  | Wt::WPushButton * | b )
| private

Definition at line 48 of file LettersWidget.C.

49{
50 if (isHidden())
51 return;
52
53 if(e.key() == static_cast<Key>(b->text().toUTF8()[0]))
54 processButton(b);
55}

## ◆ reset()

void LettersWidget::reset | ( |  | ) |

Definition at line 57 of file LettersWidget.C.

58{
59 for (auto& letterButton : letterButtons_)
60 letterButton->enable();
61
62 show();
63}

## Member Data Documentation

## ◆ connections_

std::vector<Wt::Signals::connection> LettersWidget::connections_
| private

Definition at line 32 of file LettersWidget.h.

## ◆ impl_

Wt::WTable* LettersWidget::impl_ = nullptr
| private

Definition at line 30 of file LettersWidget.h.

## ◆ letterButtons_

std::vector<Wt::WPushButton*> LettersWidget::letterButtons_
| private

Definition at line 31 of file LettersWidget.h.

## ◆ letterPushed_

Wt::Signal<char> LettersWidget::letterPushed_
| private

Definition at line 34 of file LettersWidget.h.

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

- hangman/LettersWidget.h
- hangman/LettersWidget.C