Wt examples  3.3.1
Public Member Functions | Private Attributes | List of all members
Character Class Reference

A Matrix character that takes red and/or blue pills. More...

#include <Character.h>

Inheritance diagram for Character:
Inheritance graph
[legend]

Public Member Functions

 Character (const std::string &name, WContainerWidget *parent=0)
 Create a new character with the given name. More...
 
void dropEvent (WDropEvent event)
 React to a drop event. More...
 
- Public Member Functions inherited from Wt::WWidget
virtual void setPositionScheme (PositionScheme scheme)=0
 
virtual PositionScheme positionScheme () const =0
 
virtual void setOffsets (const WLength &offset, WFlags< Side > sides=All)=0
 
virtual WLength offset (Side side) const =0
 
virtual void resize (const WLength &width, const WLength &height)
 
virtual WLength width () const =0
 
virtual WLength height () const =0
 
virtual void setMinimumSize (const WLength &width, const WLength &height)=0
 
virtual WLength minimumWidth () const =0
 
virtual WLength minimumHeight () const =0
 
virtual void setMaximumSize (const WLength &width, const WLength &height)=0
 
virtual WLength maximumWidth () const =0
 
virtual WLength maximumHeight () const =0
 
virtual void setLineHeight (const WLength &height)=0
 
virtual WLength lineHeight () const =0
 
virtual void setFloatSide (Side s)=0
 
virtual Side floatSide () const =0
 
virtual void setClearSides (WFlags< Side > sides)=0
 
virtual WFlags< SideclearSides () const =0
 
virtual void setMargin (const WLength &margin, WFlags< Side > sides=All)=0
 
virtual WLength margin (Side side) const =0
 
virtual void setHiddenKeepsGeometry (bool enabled)=0
 
virtual bool hiddenKeepsGeometry () const =0
 
virtual void setHidden (bool hidden, const WAnimation &animation=WAnimation())=0
 
virtual bool isHidden () const =0
 
virtual bool isVisible () const =0
 
virtual void setDisabled (bool disabled)=0
 
virtual bool isDisabled () const =0
 
virtual bool isEnabled () const =0
 
virtual void setPopup (bool popup)=0
 
virtual bool isPopup () const =0
 
virtual void setInline (bool inlined)=0
 
virtual bool isInline () const =0
 
virtual void setDecorationStyle (const WCssDecorationStyle &style)=0
 
virtual WCssDecorationStyledecorationStyle ()=0
 
virtual void setStyleClass (const WString &styleClass)=0
 
virtual WString styleClass () const =0
 
virtual void addStyleClass (const WString &styleClass, bool force=false)=0
 
virtual void removeStyleClass (const WString &styleClass, bool force=false)=0
 
virtual bool hasStyleClass (const WString &styleClass) const =0
 
virtual void setVerticalAlignment (AlignmentFlag alignment, const WLength &length=WLength::Auto)=0
 
virtual AlignmentFlag verticalAlignment () const =0
 
virtual WLength verticalAlignmentLength () const =0
 
virtual void setToolTip (const WString &text, TextFormat textFormat=PlainText)=0
 
virtual const WStringtoolTip () const =0
 
virtual void refresh ()
 
virtual void setAttributeValue (const std::string &name, const WString &value)=0
 
virtual WString attributeValue (const std::string &name) const =0
 
virtual void setJavaScriptMember (const std::string &name, const std::string &value)=0
 
virtual std::string javaScriptMember (const std::string &name) const =0
 
virtual void callJavaScriptMember (const std::string &name, const std::string &args)=0
 
virtual void load ()=0
 
virtual bool loaded () const =0
 
virtual void setTabIndex (int index)=0
 
virtual int tabIndex () const =0
 
virtual void setId (const std::string &id)=0
 
virtual WWidgetfind (const std::string &name)=0
 
virtual void setSelectable (bool selectable)=0
 
virtual void doJavaScript (const std::string &js)=0
 

Private Attributes

std::string name_
 The name. More...
 
int redDrops_
 The current number of red pills. More...
 
int blueDrops_
 The current number of blue pills. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Wt::WWidget
virtual void enableAjax ()=0
 
virtual void propagateSetEnabled (bool enabled)=0
 
virtual void render (WFlags< RenderFlag > flags)
 

Detailed Description

A Matrix character that takes red and/or blue pills.

The Character class demonstrates how to accept and react to drop events.

Definition at line 24 of file Character.h.

Constructor & Destructor Documentation

Character::Character ( const std::string &  name,
WContainerWidget parent = 0 
)

Create a new character with the given name.

Definition at line 6 of file Character.C.

7  : WText(parent),
8  name_(name),
9  redDrops_(0),
10  blueDrops_(0)
11 {
12  setText(name_ + " got no pills");
13 
14  setStyleClass("character");
15 
16  /*
17  * Accept drops, and indicate this with a change in CSS style class.
18  */
19  acceptDrops("red-pill", "red-drop-site");
20  acceptDrops("blue-pill", "blue-drop-site");
21 
22  setInline(false);
23 }
std::string name_
The name.
Definition: Character.h:37
int redDrops_
The current number of red pills.
Definition: Character.h:40
virtual void setInline(bool inlined)=0
int blueDrops_
The current number of blue pills.
Definition: Character.h:43
virtual void setStyleClass(const WString &styleClass)=0

Member Function Documentation

void Character::dropEvent ( WDropEvent  event)

React to a drop event.

Definition at line 25 of file Character.C.

26 {
27  if (event.mimeType() == "red-pill")
28  ++redDrops_;
29  if (event.mimeType() == "blue-pill")
30  ++blueDrops_;
31 
32  std::string text = name_ + " got ";
33 
34  if (redDrops_ != 0)
35  text += boost::lexical_cast<std::string>(redDrops_) + " red pill";
36  if (redDrops_ > 1)
37  text += "s";
38 
39  if (redDrops_ != 0 && blueDrops_ != 0)
40  text += " and ";
41 
42  if (blueDrops_ != 0)
43  text += boost::lexical_cast<std::string>(blueDrops_) + " blue pill";
44  if (blueDrops_ > 1)
45  text += "s";
46 
47  setText(text);
48 }
std::string name_
The name.
Definition: Character.h:37
const std::string & mimeType() const
int redDrops_
The current number of red pills.
Definition: Character.h:40
int blueDrops_
The current number of blue pills.
Definition: Character.h:43

Member Data Documentation

int Character::blueDrops_
private

The current number of blue pills.

Definition at line 43 of file Character.h.

std::string Character::name_
private

The name.

Definition at line 37 of file Character.h.

int Character::redDrops_
private

The current number of red pills.

Definition at line 40 of file Character.h.


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

Generated on Wed Jun 11 2014 for the C++ Web Toolkit (Wt) by doxygen 1.8.7