Wt examples 3.3.12
ImagesWidget.C
Go to the documentation of this file.
1/*
2 * Copyright (C) 2011 Emweb bvba, Heverlee, Belgium
3 *
4 * See the LICENSE file for terms of use.
5 */
6
7#include "ImagesWidget.h"
8
9#include <Wt/WImage>
10
11using namespace Wt;
12
13const int ImagesWidget::HURRAY = -1;
14
16 : WContainerWidget(parent)
17{
18 for (int i = 0; i <= maxGuesses; ++i) {
19 std::string fname = "icons/hangman";
20 fname += boost::lexical_cast<std::string>(i) + ".jpg";
21 WImage *theImage = new WImage(fname, this);
22 images_.push_back(theImage);
23
24 // Although not necessary, we can avoid flicker (on konqueror)
25 // by presetting the image size.
26 theImage->resize(256, 256);
27 theImage->hide();
28 }
29
30 WImage *hurray = new WImage("icons/hangmanhurray.jpg", this);
31 hurray->hide();
32 images_.push_back(hurray);
33
34 image_ = 0;
35 showImage(maxGuesses);
36}
37
39{
40 image(image_)->hide();
41 image_ = index;
42 image(image_)->show();
43}
44
45WImage *ImagesWidget::image(int index) const
46{
47 return index == HURRAY ? images_.back() : images_[index];
48}
ImagesWidget(int maxGuesses, Wt::WContainerWidget *parent=0)
std::vector< Wt::WImage * > images_
void showImage(int index)
static const int HURRAY
Wt::WImage * image(int index) const
virtual void resize(const WLength &width, const WLength &height)

Generated on Fri May 17 2024 for the C++ Web Toolkit (Wt) by doxygen 1.9.8