Wt examples  3.2.0
/home/koen/project/wt/public-git/wt/examples/hangman/LettersWidget.C
Go to the documentation of this file.
00001 /* 
00002  * Copyright (C) 2011 Emweb bvba, Heverlee, Belgium
00003  *
00004  * See the LICENSE file for terms of use.
00005  */
00006 
00007 #include "LettersWidget.h"
00008 
00009 #include <Wt/WPushButton>
00010 #include <Wt/WTable>
00011 
00012 using namespace Wt;
00013 
00014 LettersWidget::LettersWidget(WContainerWidget *parent) :
00015   WCompositeWidget(parent)
00016 {
00017   setImplementation(impl_ = new WTable());
00018 
00019   // The default width of a table is 100%...
00020   impl_->resize(13*30, WLength::Auto);
00021 
00022   for(unsigned int i = 0; i < 26; ++i) {
00023     std::string c(1, 'A' + i);
00024     WPushButton *character =
00025       new WPushButton(c, impl_->elementAt(i / 13, i % 13));
00026     letterButtons_.push_back(character);
00027     character->resize(WLength(30), WLength::Auto);
00028 
00029     character
00030       ->clicked().connect(boost::bind(&LettersWidget::processButton, 
00031                                       this, 
00032                                       character));
00033   }
00034 }
00035 
00036 void LettersWidget::processButton(WPushButton *b)
00037 {
00038   b->disable();
00039   letterPushed_.emit(b->text().toUTF8()[0]);
00040 }
00041 
00042 void LettersWidget::init()
00043 {
00044   for(unsigned int i = 0; i < letterButtons_.size(); ++i)
00045     letterButtons_[i]->enable();
00046   show();
00047 }

Generated on Tue Nov 29 2011 for the C++ Web Toolkit (Wt) by doxygen 1.7.5.1