FIFE  2008.0
 All Classes Namespaces Functions Variables Enumerations Enumerator Pages
gcn::ToggleButton Class Reference

#include <togglebutton.h>

Collaboration diagram for gcn::ToggleButton:
Collaboration graph

List of all members.

Public Member Functions

 ToggleButton (Image *up_image=0, Image *down_image=0, Image *hover_image=0, const std::string &caption="", const std::string &group="")
 ~ToggleButton ()
void draw (Graphics *graphics)
void adjustSize ()
void setUpImage (Image *image)
void setDownImage (Image *image)
void setHoverImage (Image *image)
void setDownOffset (int x, int y)
int getDownXOffset () const
int getDownYOffset () const
bool isToggled () const
void setToggled (bool toggled)
void setGroup (const std::string &group)
const std::string & getGroup () const

Protected Member Functions

void action (const ActionEvent &actionEvent)

Detailed Description

An implementation of a toggleable button.

If the button is in a group, all other buttons in that group will be untoggled when a button gets toggled. If the button is already toggled, you can untoggle it by clicking on it.

Definition at line 47 of file togglebutton.h.


Constructor & Destructor Documentation

gcn::ToggleButton::ToggleButton ( Image *  up_image = 0,
Image *  down_image = 0,
Image *  hover_image = 0,
const std::string &  caption = "",
const std::string &  group = "" 
)

Constructor

Parameters:
up_imageImage displayed when the button isn't toggled
down_imageImage displayed when the button is toggled
hover_fileImage displayed when the mouse cursor is over button
captionText to be displayed on button
groupThe group the button belongs to

Definition at line 47 of file togglebutton.cpp.

References adjustSize(), and setGroup().

gcn::ToggleButton::~ToggleButton ( )

Destructor

Definition at line 66 of file togglebutton.cpp.

References setGroup().


Member Function Documentation

void gcn::ToggleButton::action ( const ActionEvent &  actionEvent)
protected

Toggle button when it is activated

Parameters:
actionEventActionEvent object

Definition at line 165 of file togglebutton.cpp.

References setToggled().

void gcn::ToggleButton::adjustSize ( )

Adjust size to fit image and caption

Definition at line 169 of file togglebutton.cpp.

Referenced by setDownImage(), setHoverImage(), setUpImage(), and ToggleButton().

Here is the caller graph for this function:

void gcn::ToggleButton::draw ( Graphics *  graphics)

Draws the button

Definition at line 75 of file togglebutton.cpp.

int gcn::ToggleButton::getDownXOffset ( ) const

Gets the number of pixels the image or text will be offset from the left of button when the button is pressed or toggled.

Returns:
Offset from left when button is pressed
See also:
setDownOffset

Definition at line 255 of file togglebutton.cpp.

int gcn::ToggleButton::getDownYOffset ( ) const

Gets the number of pixels the image or text will be offset from the top of button when the button is pressed or toggled.

Returns:
Offset from top when button is pressed
See also:
setDownOffset

Definition at line 259 of file togglebutton.cpp.

const std::string & gcn::ToggleButton::getGroup ( ) const

Gets the group the toggle button belongs to.

Returns:
The group the toggle button belongs to.
See also:
setGroup

Definition at line 251 of file togglebutton.cpp.

bool gcn::ToggleButton::isToggled ( ) const

Checks if the radio button is selected.

Returns:
True if the radio button is selecte, false otherwise.
See also:
setSelected

Definition at line 209 of file togglebutton.cpp.

void gcn::ToggleButton::setDownImage ( Image *  image)

Sets the image that will be displayed when the button is toggled or pressed

Parameters:
imageImage to be displayed

Definition at line 199 of file togglebutton.cpp.

References adjustSize().

void gcn::ToggleButton::setDownOffset ( int  x,
int  y 
)

Sets the number of pixels the image or text will be offset from the top left corner of button when the button is pressed or toggled.

Parameters:
xOffset from left
yOffset from top
See also:
getDownXOffset
getDownYOffset

Definition at line 70 of file togglebutton.cpp.

void gcn::ToggleButton::setGroup ( const std::string &  group)

Sets the group the toggle button should belong to. Note that a toggle button group is unique per application, not per Gui object as the group is stored in a static map.

Parameters:
groupThe name of the group.
See also:
getGroup

Definition at line 229 of file togglebutton.cpp.

Referenced by ToggleButton(), and ~ToggleButton().

Here is the caller graph for this function:

void gcn::ToggleButton::setHoverImage ( Image *  image)

Sets the image which will be displayed when the mouse cursor is over the button

Parameters:
imageImage to be displayed

Definition at line 204 of file togglebutton.cpp.

References adjustSize().

void gcn::ToggleButton::setToggled ( bool  toggled)

Sets the radio button to selected or not.

Parameters:
selectedTrue if the radio button should be selected, false otherwise.
See also:
isSelected

Definition at line 213 of file togglebutton.cpp.

Referenced by action().

Here is the caller graph for this function:

void gcn::ToggleButton::setUpImage ( Image *  image)

Sets the image that will be displayed when the button isn't toggled

Parameters:
imageImage to be displayed

Definition at line 194 of file togglebutton.cpp.

References adjustSize().


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