Public Member Functions | Protected Member Functions

gcn::ToggleButton Class Reference

#include <togglebutton.h>

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_image Image displayed when the button isn't toggled
down_image Image displayed when the button is toggled
hover_file Image displayed when the mouse cursor is over button
caption Text to be displayed on button
group The group the button belongs to

Definition at line 45 of file togglebutton.cpp.

References adjustSize(), and setGroup().

gcn::ToggleButton::~ToggleButton (  ) 

Destructor

Definition at line 64 of file togglebutton.cpp.


Member Function Documentation

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

Toggle button when it is activated

Parameters:
actionEvent ActionEvent object

Definition at line 163 of file togglebutton.cpp.

void gcn::ToggleButton::adjustSize (  ) 

Adjust size to fit image and caption

Definition at line 167 of file togglebutton.cpp.

Referenced by ToggleButton().

Here is the caller graph for this function:

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

Draws the button

Definition at line 73 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 253 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 257 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 249 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 207 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:
image Image to be displayed

Definition at line 197 of file togglebutton.cpp.

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:
x Offset from left
y Offset from top
See also:
getDownXOffset
getDownYOffset

Definition at line 68 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:
group The name of the group.
See also:
getGroup

Definition at line 227 of file togglebutton.cpp.

Referenced by 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:
image Image to be displayed

Definition at line 202 of file togglebutton.cpp.

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

Sets the radio button to selected or not.

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

Definition at line 211 of file togglebutton.cpp.

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

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

Parameters:
image Image to be displayed

Definition at line 192 of file togglebutton.cpp.


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