Wt examples  4.1.0
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:
Inheritance graph
[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

WImage * image (int index) const
 

Private Attributes

std::vector< WImage * > images_
 
int image_
 

Detailed Description

Definition at line 17 of file ImagesWidget.h.

Constructor & Destructor Documentation

◆ ImagesWidget()

ImagesWidget::ImagesWidget ( int  maxGuesses)

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  WImage *theImage = addWidget(cpp14::make_unique<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  WImage *hurray = addWidget(cpp14::make_unique<WImage>("icons/hangmanhurray.jpg"));
29  hurray->hide();
30  images_.push_back(hurray);
31 
32  image_ = 0;
33  showImage(maxGuesses);
34 }
void showImage(int index)
Definition: ImagesWidget.C:36
std::vector< WImage * > images_
Definition: ImagesWidget.h:32

Member Function Documentation

◆ currentImage()

int ImagesWidget::currentImage ( ) const
inline

Definition at line 29 of file ImagesWidget.h.

29 { return image_; }

◆ image()

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
Definition: ImagesWidget.h:20
std::vector< WImage * > images_
Definition: ImagesWidget.h:32

◆ 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 }
WImage * image(int index) const
Definition: ImagesWidget.C:43

Member Data Documentation

◆ HURRAY

const int ImagesWidget::HURRAY = -1
static

Definition at line 20 of file ImagesWidget.h.

◆ image_

int ImagesWidget::image_
private

Definition at line 33 of file ImagesWidget.h.

◆ images_

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

Definition at line 32 of file ImagesWidget.h.


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

Generated on Mon Aug 19 2019 for the C++ Web Toolkit (Wt) by doxygen 1.8.15