Wt examples  4.10.0
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
ImagesWidget Class Reference

#include <ImagesWidget.h>

Inheritance diagram for ImagesWidget:
[legend]

Public Member Functions

 ImagesWidget (int maxGuesses)
 
void showImage (int index)
 
int currentImage () const
 

Static Public Attributes

static const int HURRAY = -1
 

Private Member Functions

Wt::WImage * image (int index) const
 

Private Attributes

std::vector< Wt::WImage * > images_
 
int image_
 

Detailed Description

Definition at line 15 of file ImagesWidget.h.

Constructor & Destructor Documentation

◆ ImagesWidget()

ImagesWidget::ImagesWidget ( int  maxGuesses)
explicit

Definition at line 14 of file ImagesWidget.C.

15{
16 for (int i = 0; i <= maxGuesses; ++i) {
17 std::string fname = "icons/hangman";
18 fname += std::to_string(i) + ".jpg";
19 auto theImage = addNew<Wt::WImage>(fname);
20 images_.push_back(theImage);
21
22 // Although not necessary, we can avoid flicker (on konqueror)
23 // by presetting the image size.
24 theImage->resize(256, 256);
25 theImage->hide();
26 }
27
28 auto hurray = addNew<Wt::WImage>("icons/hangmanhurray.jpg");
29 hurray->hide();
30 images_.push_back(hurray);
31
32 image_ = 0;
33 showImage(maxGuesses);
34}
void showImage(int index)
std::vector< Wt::WImage * > images_

Member Function Documentation

◆ currentImage()

int ImagesWidget::currentImage ( ) const
inline

Definition at line 27 of file ImagesWidget.h.

27{ return image_; }

◆ image()

Wt::WImage * ImagesWidget::image ( int  index) const
private

Definition at line 43 of file ImagesWidget.C.

44{
45 return index == HURRAY ? images_.back() : images_[index];
46}
static const int HURRAY

◆ showImage()

void ImagesWidget::showImage ( int  index)

Definition at line 36 of file ImagesWidget.C.

37{
38 image(image_)->hide();
39 image_ = index;
40 image(image_)->show();
41}
Wt::WImage * image(int index) const

Member Data Documentation

◆ HURRAY

const int ImagesWidget::HURRAY = -1
static

Definition at line 18 of file ImagesWidget.h.

◆ image_

int ImagesWidget::image_
private

Definition at line 31 of file ImagesWidget.h.

◆ images_

std::vector<Wt::WImage*> ImagesWidget::images_
private

Definition at line 30 of file ImagesWidget.h.


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