Wt examples
3.7.1
public-git
wt
examples
hangman
ImagesWidget.C
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2011 Emweb bv, Herent, Belgium
3
*
4
* See the LICENSE file for terms of use.
5
*/
6
7
#include "
ImagesWidget.h
"
8
9
#include <Wt/WImage>
10
11
using namespace
Wt
;
12
13
const
int
ImagesWidget::HURRAY
= -1;
14
15
ImagesWidget::ImagesWidget
(
int
maxGuesses,
WContainerWidget
*parent)
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
38
void
ImagesWidget::showImage
(
int
index)
39
{
40
image
(
image_
)->
hide
();
41
image_
= index;
42
image
(
image_
)->
show
();
43
}
44
45
WImage
*
ImagesWidget::image
(
int
index)
const
46
{
47
return
index ==
HURRAY
?
images_
.back() :
images_
[index];
48
}
ImagesWidget.h
Wt::WWidget::show
void show()
Wt::WWidget::hide
void hide()
ImagesWidget::showImage
void showImage(int index)
Definition:
ImagesWidget.C:38
ImagesWidget::images_
std::vector< Wt::WImage * > images_
Definition:
ImagesWidget.h:30
ImagesWidget::HURRAY
static const int HURRAY
Definition:
ImagesWidget.h:18
Wt::WImage
ImagesWidget::image
Wt::WImage * image(int index) const
Definition:
ImagesWidget.C:45
ImagesWidget::image_
int image_
Definition:
ImagesWidget.h:31
Wt
Wt::WContainerWidget
ImagesWidget::ImagesWidget
ImagesWidget(int maxGuesses, Wt::WContainerWidget *parent=0)
Definition:
ImagesWidget.C:15
Generated on Tue Dec 15 2020 for
the C++ Web Toolkit (Wt)
by
1.8.13