FIFE
|
An implementation of a toggleable button. More...
#include <togglebutton.h>
Inherits Button, and ActionListener.
Public Member Functions | |
ToggleButton (Image *up_image=0, Image *down_image=0, Image *hover_image=0, const std::string &caption="", const std::string &group="") | |
Constructor. More... | |
~ToggleButton () | |
Destructor. More... | |
void | draw (Graphics *graphics) |
Draws the button. More... | |
void | adjustSize () |
Adjust size to fit image and caption. More... | |
void | setUpImage (Image *image) |
Sets the image that will be displayed when the button isn't toggled. More... | |
void | setDownImage (Image *image) |
Sets the image that will be displayed when the button is toggled or pressed. More... | |
void | setHoverImage (Image *image) |
Sets the image which will be displayed when the mouse cursor is over the button. More... | |
void | setDownOffset (int32_t x, int32_t 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. More... | |
int32_t | 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. More... | |
int32_t | 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. More... | |
bool | isToggled () const |
Checks if the radio button is selected. More... | |
void | setToggled (bool toggled) |
Sets the radio button to selected or not. More... | |
void | setGroup (const std::string &group) |
Sets the group the toggle button should belong to. More... | |
const std::string & | getGroup () const |
Gets the group the toggle button belongs to. More... | |
Protected Member Functions | |
void | action (const ActionEvent &actionEvent) |
Toggle button when it is activated. More... | |
Private Types | |
typedef std::multimap < std::string, ToggleButton * > | GroupMap |
Typedef. More... | |
typedef GroupMap::iterator | GroupIterator |
Typedef. More... | |
Private Attributes | |
Image * | m_upImage |
Image * | m_downImage |
Image * | m_hoverImage |
int32_t | x_downoffset |
int32_t | y_downoffset |
bool | m_toggled |
Whether the button is toggled or not. More... | |
std::string | m_group |
Holds the group of the toggle button. More... | |
Static Private Attributes | |
static GroupMap | m_groupMap |
Holds all available toggle button groups. More... | |
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.
|
private |
Typedef.
Definition at line 204 of file togglebutton.h.
|
private |
Typedef.
Definition at line 199 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_image | 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 48 of file togglebutton.cpp.
References adjustSize(), m_group, m_hoverImage, m_toggled, and setGroup().
gcn::ToggleButton::~ToggleButton | ( | ) |
|
protected |
Toggle button when it is activated.
actionEvent | ActionEvent object |
Definition at line 169 of file togglebutton.cpp.
References m_toggled, and setToggled().
void gcn::ToggleButton::adjustSize | ( | ) |
Adjust size to fit image and caption.
Definition at line 173 of file togglebutton.cpp.
References m_downImage, m_hoverImage, and m_upImage.
Referenced by setDownImage(), setHoverImage(), setUpImage(), and ToggleButton().
void gcn::ToggleButton::draw | ( | Graphics * | graphics | ) |
Draws the button.
Definition at line 76 of file togglebutton.cpp.
References gcn::_log, FL_WARN, m_downImage, m_hoverImage, m_toggled, m_upImage, x_downoffset, and y_downoffset.
int32_t 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 259 of file togglebutton.cpp.
References x_downoffset.
int32_t 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 263 of file togglebutton.cpp.
References y_downoffset.
const std::string & gcn::ToggleButton::getGroup | ( | ) | const |
Gets the group the toggle button belongs to.
Definition at line 255 of file togglebutton.cpp.
References m_group.
bool gcn::ToggleButton::isToggled | ( | ) | const |
Checks if the radio button is selected.
Definition at line 213 of file togglebutton.cpp.
References m_toggled.
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 203 of file togglebutton.cpp.
References adjustSize(), and m_downImage.
void gcn::ToggleButton::setDownOffset | ( | int32_t | x, |
int32_t | 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 71 of file togglebutton.cpp.
References x_downoffset, and y_downoffset.
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 233 of file togglebutton.cpp.
References m_group, and m_groupMap.
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 208 of file togglebutton.cpp.
References adjustSize(), and m_hoverImage.
void gcn::ToggleButton::setToggled | ( | bool | toggled | ) |
Sets the radio button to selected or not.
toggled | True if the radio button should be selected, false otherwise. |
Definition at line 217 of file togglebutton.cpp.
References m_group, m_groupMap, and m_toggled.
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 198 of file togglebutton.cpp.
References adjustSize(), and m_upImage.
|
private |
Definition at line 175 of file togglebutton.h.
Referenced by adjustSize(), draw(), and setDownImage().
|
private |
Holds the group of the toggle button.
Definition at line 194 of file togglebutton.h.
Referenced by getGroup(), setGroup(), setToggled(), and ToggleButton().
|
staticprivate |
Holds all available toggle button groups.
Definition at line 209 of file togglebutton.h.
Referenced by setGroup(), and setToggled().
|
private |
Definition at line 178 of file togglebutton.h.
Referenced by adjustSize(), draw(), setHoverImage(), and ToggleButton().
|
private |
Whether the button is toggled or not.
Definition at line 188 of file togglebutton.h.
Referenced by action(), draw(), isToggled(), setToggled(), and ToggleButton().
|
private |
Definition at line 172 of file togglebutton.h.
Referenced by adjustSize(), draw(), and setUpImage().
|
private |
Definition at line 182 of file togglebutton.h.
Referenced by draw(), getDownXOffset(), and setDownOffset().
|
private |
Definition at line 183 of file togglebutton.h.
Referenced by draw(), getDownYOffset(), and setDownOffset().