#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 45 of file togglebutton.cpp.
References adjustSize(), and setGroup().
gcn::ToggleButton::~ToggleButton | ( | ) |
Destructor
Definition at line 64 of file togglebutton.cpp.
void gcn::ToggleButton::action | ( | const ActionEvent & | actionEvent | ) | [protected] |
Toggle button when it is activated
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().
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.
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.
Definition at line 257 of file togglebutton.cpp.
const std::string & gcn::ToggleButton::getGroup | ( | ) | const |
Gets the group the toggle button belongs to.
Definition at line 249 of file togglebutton.cpp.
bool gcn::ToggleButton::isToggled | ( | ) | const |
Checks if the radio button is selected.
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
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.
x | Offset from left | |
y | Offset from top |
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.
group | The name of the group. |
Definition at line 227 of file togglebutton.cpp.
Referenced by 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 202 of file togglebutton.cpp.
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 211 of file togglebutton.cpp.
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 192 of file togglebutton.cpp.