/usr/lib/Wt/examples/hangman/LettersWidget.C is in witty-examples 3.3.0-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 | /*
* Copyright (C) 2011 Emweb bvba, Heverlee, Belgium
*
* See the LICENSE file for terms of use.
*/
#include "LettersWidget.h"
#include <Wt/WPushButton>
#include <Wt/WTable>
using namespace Wt;
LettersWidget::LettersWidget(WContainerWidget *parent)
: WCompositeWidget(parent)
{
setImplementation(impl_ = new WTable());
impl_->resize(13*30, WLength::Auto);
for (unsigned int i = 0; i < 26; ++i) {
std::string c(1, 'A' + i);
WPushButton *character = new WPushButton(c,
impl_->elementAt(i / 13, i % 13));
letterButtons_.push_back(character);
character->resize(WLength(30), WLength::Auto);
character->clicked().connect
(boost::bind(&LettersWidget::processButton, this, character));
}
}
void LettersWidget::processButton(WPushButton *b)
{
b->disable();
letterPushed_.emit(b->text().toUTF8()[0]);
}
void LettersWidget::reset()
{
for (unsigned int i = 0; i < letterButtons_.size(); ++i)
letterButtons_[i]->enable();
show();
}
|