FIFE 2008.0
|
#include <togglebutton.h>
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) |
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.
gcn::ToggleButton::ToggleButton | ( | Image * | up_image = 0 , |
Image * | down_image = 0 , |
||
Image * | hover_image = 0 , |
||
const std::string & | caption = "" , |
||
const std::string & | group = "" |
||
) |
Constructor
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 47 of file togglebutton.cpp.
References adjustSize(), and setGroup().
gcn::ToggleButton::~ToggleButton | ( | ) |
void gcn::ToggleButton::action | ( | const ActionEvent & | actionEvent | ) | [protected] |
Toggle button when it is activated
actionEvent | ActionEvent 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().
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.
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.
Definition at line 259 of file togglebutton.cpp.
const std::string & gcn::ToggleButton::getGroup | ( | ) | const |
Gets the group the toggle button belongs to.
Definition at line 251 of file togglebutton.cpp.
bool gcn::ToggleButton::isToggled | ( | ) | const |
Checks if the radio button is selected.
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
image | Image 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.
x | Offset from left |
y | Offset from top |
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.
group | The name of the group. |
Definition at line 229 of file togglebutton.cpp.
Referenced by ToggleButton(), and ~ToggleButton().
void gcn::ToggleButton::setHoverImage | ( | Image * | image | ) |
Sets the image which will be displayed when the mouse cursor is over the button
image | Image 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.
selected | True if the radio button should be selected, false otherwise. |
Definition at line 213 of file togglebutton.cpp.
Referenced by action().
void gcn::ToggleButton::setUpImage | ( | Image * | image | ) |
Sets the image that will be displayed when the button isn't toggled
image | Image to be displayed |
Definition at line 194 of file togglebutton.cpp.
References adjustSize().