Wt examples  3.3.6
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, Wt::WContainerWidget *parent=0)
 
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,
Wt::WContainerWidget *  parent = 0 
)

Definition at line 15 of file ImagesWidget.C.

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 }
void showImage(int index)
Definition: ImagesWidget.C:38
std::vector< Wt::WImage * > images_
Definition: ImagesWidget.h:30

Member Function Documentation

◆ currentImage()

int ImagesWidget::currentImage ( ) const
inline

Definition at line 27 of file ImagesWidget.h.

27 { return image_; }

◆ image()

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

Definition at line 45 of file ImagesWidget.C.

46 {
47  return index == HURRAY ? images_.back() : images_[index];
48 }
std::vector< Wt::WImage * > images_
Definition: ImagesWidget.h:30
static const int HURRAY
Definition: ImagesWidget.h:18

◆ showImage()

void ImagesWidget::showImage ( int  index)

Definition at line 38 of file ImagesWidget.C.

39 {
40  image(image_)->hide();
41  image_ = index;
42  image(image_)->show();
43 }
Wt::WImage * image(int index) const
Definition: ImagesWidget.C:45

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:

Generated on Thu Jan 12 2017 for the C++ Web Toolkit (Wt) by doxygen 1.8.13