#include <gui_button.hpp>
Public Types | |
enum | state { STATE_UP, STATE_DOWN, STATE_DISABLED } |
Public Member Functions | |
button (manager *pManager) | |
Constructor. | |
virtual | ~button () |
Destructor. | |
virtual std::string | serialize (const std::string &sTab) const |
Prints all relevant information about this widget in a string. | |
virtual void | create_glue () |
Creates the associated Lua glue. | |
virtual bool | can_use_script (const std::string &sScriptName) const |
Returns 'true' if this Button can use a script. | |
virtual void | on (const std::string &sScriptName, event *pEvent=nullptr) |
Calls a script. | |
virtual void | on_event (const event &mEvent) |
Calls the on_event script. | |
virtual void | copy_from (uiobject *pObj) |
Copies an uiobject's parameters into this Button (inheritance). | |
virtual void | set_text (const std::string &sText) |
Sets this button's text. | |
const std::string & | get_text () const |
Returns this button's text. | |
texture * | get_normal_texture () |
Returns this button's normal texture. | |
texture * | get_pushed_texture () |
Returns this button's pushed texture. | |
texture * | get_disabled_texture () |
Returns this button's disabled texture. | |
texture * | get_highlight_texture () |
Returns this button's highlight texture. | |
font_string * | get_normal_text () |
Returns this button's normal text. | |
font_string * | get_highlight_text () |
Returns this button's highlight text. | |
font_string * | get_disabled_text () |
Returns this button's disabled text. | |
font_string * | get_CurrentFontString () |
Returns the currently displayed text object. | |
void | set_normal_texture (texture *pTexture) |
Sets this button's normal texture. | |
void | set_pushed_texture (texture *pTexture) |
Sets this button's pushed texture. | |
void | set_disabled_texture (texture *pTexture) |
Sets this button's disabled texture. | |
void | set_highlight_texture (texture *pTexture) |
Sets this button's highlight texture. | |
void | set_normal_text (font_string *pFont) |
Sets this button's normal text. | |
void | set_highlight_text (font_string *pFont) |
Sets this button's highlight text. | |
void | set_disabled_text (font_string *pFont) |
Sets this button's disabled text. | |
virtual void | disable () |
Disables this Button. | |
virtual void | enable () |
Enables this Button. | |
bool | is_enabled () const |
Checks if this Button is enabled. | |
virtual void | push () |
Pushed this Button. | |
virtual void | release () |
Releases this Button. | |
virtual void | highlight () |
Highlights this Button. | |
virtual void | unlight () |
Unlights this Button. | |
state | get_button_state () const |
Returns this button's state. | |
void | lock_highlight () |
Locks this button's highlighting. | |
void | unlock_highlight () |
Unlocks this button's highlighting. | |
virtual void | set_pushed_text_offset (const std::array< int, 2 > &lOffset) |
Sets this button's pushed text offset. | |
const std::array< int, 2 > & | get_pushed_text_offset () const |
Returns this button's pushed text offset. | |
virtual void | parse_block (xml::block *pBlock) |
Parses data from an xml::block. | |
Static Public Member Functions | |
static void | register_glue (utils::wptr< lua::state > pLua) |
Registers this widget to the provided lua::state. | |
Protected Member Functions | |
texture * | create_normal_texture_ () |
texture * | create_pushed_texture_ () |
texture * | create_disabled_texture_ () |
texture * | create_highlight_texture_ () |
font_string * | create_normal_text_ () |
font_string * | create_highlight_text_ () |
font_string * | create_disabled_text_ () |
Protected Attributes | |
state | mState_ |
bool | bHighlighted_ |
bool | bLockHighlight_ |
std::string | sText_ |
texture * | pNormalTexture_ |
texture * | pPushedTexture_ |
texture * | pDisabledTexture_ |
texture * | pHighlightTexture_ |
font_string * | pNormalText_ |
font_string * | pHighlightText_ |
font_string * | pDisabledText_ |
font_string * | pCurrentFontString_ |
std::array< int, 2 > | lPushedTextOffset_ |
A simple button.
This class can handle three different states : "normal", "pushed" and "disabled". You can provide a different texture for each of these states, and two different fontstrings for "normal" and "disabled".
In addition, you can provide another texture/fontstring for the "highlight" state (when the mouse is over the button widget).
Note that there is no fontstring for the "pushed" state : in this case, the "normal" font is rendered with a slight offset that you'll have to define.
Definition at line 24 of file gui_button.hpp.
enum gui::button::state |
Definition at line 28 of file gui_button.hpp.
gui::button::button | ( | manager * | pManager | ) | [explicit] |
Constructor.
Definition at line 11 of file gui_button.cpp.
virtual gui::button::~button | ( | ) | [virtual] |
Destructor.
virtual bool gui::button::can_use_script | ( | const std::string & | sScriptName | ) | const [virtual] |
Returns 'true' if this Button can use a script.
sScriptName | The name of the script |
Reimplemented from gui::frame.
virtual void gui::button::copy_from | ( | uiobject * | pObj | ) | [virtual] |
Copies an uiobject's parameters into this Button (inheritance).
pObj | The uiobject to copy |
Reimplemented from gui::frame.
Reimplemented in gui::check_button.
font_string* gui::button::create_disabled_text_ | ( | ) | [protected] |
texture* gui::button::create_disabled_texture_ | ( | ) | [protected] |
virtual void gui::button::create_glue | ( | ) | [virtual] |
font_string* gui::button::create_highlight_text_ | ( | ) | [protected] |
texture* gui::button::create_highlight_texture_ | ( | ) | [protected] |
font_string* gui::button::create_normal_text_ | ( | ) | [protected] |
texture* gui::button::create_normal_texture_ | ( | ) | [protected] |
texture* gui::button::create_pushed_texture_ | ( | ) | [protected] |
virtual void gui::button::disable | ( | ) | [virtual] |
Disables this Button.
Reimplemented in gui::check_button.
virtual void gui::button::enable | ( | ) | [virtual] |
Enables this Button.
Reimplemented in gui::check_button.
state gui::button::get_button_state | ( | ) | const |
Returns this button's state.
font_string* gui::button::get_CurrentFontString | ( | ) |
font_string* gui::button::get_disabled_text | ( | ) |
texture* gui::button::get_disabled_texture | ( | ) |
font_string* gui::button::get_highlight_text | ( | ) |
texture* gui::button::get_highlight_texture | ( | ) |
font_string* gui::button::get_normal_text | ( | ) |
texture* gui::button::get_normal_texture | ( | ) |
& gui::button::get_pushed_text_offset | ( | ) | const |
Returns this button's pushed text offset.
Definition at line 671 of file gui_button.cpp.
texture* gui::button::get_pushed_texture | ( | ) |
const std::string& gui::button::get_text | ( | ) | const |
virtual void gui::button::highlight | ( | ) | [virtual] |
Highlights this Button.
bool gui::button::is_enabled | ( | ) | const |
Checks if this Button is enabled.
void gui::button::lock_highlight | ( | ) |
Locks this button's highlighting.
virtual void gui::button::on | ( | const std::string & | sScriptName, | |
event * | pEvent = nullptr | |||
) | [virtual] |
Calls a script.
sScriptName | The name of the script | |
pEvent | Stores scripts arguments |
Reimplemented from gui::frame.
virtual void gui::button::on_event | ( | const event & | mEvent | ) | [virtual] |
void gui::button::parse_block | ( | xml::block * | pBlock | ) | [virtual] |
Parses data from an xml::block.
pBlock | The button's xml::block |
Reimplemented from gui::frame.
Reimplemented in gui::check_button.
Definition at line 11 of file gui_button_parser.cpp.
virtual void gui::button::push | ( | ) | [virtual] |
Pushed this Button.
void gui::button::register_glue | ( | utils::wptr< lua::state > | pLua | ) | [static] |
Registers this widget to the provided lua::state.
Reimplemented in gui::check_button.
Definition at line 12 of file gui_button_glues.cpp.
virtual void gui::button::release | ( | ) | [virtual] |
Releases this Button.
Reimplemented in gui::check_button.
virtual std::string gui::button::serialize | ( | const std::string & | sTab | ) | const [virtual] |
Prints all relevant information about this widget in a string.
sTab | The offset to give to all lines |
Reimplemented from gui::frame.
Reimplemented in gui::check_button.
void gui::button::set_disabled_text | ( | font_string * | pFont | ) |
void gui::button::set_disabled_texture | ( | texture * | pTexture | ) |
void gui::button::set_highlight_text | ( | font_string * | pFont | ) |
void gui::button::set_highlight_texture | ( | texture * | pTexture | ) |
void gui::button::set_normal_text | ( | font_string * | pFont | ) |
void gui::button::set_normal_texture | ( | texture * | pTexture | ) |
virtual void gui::button::set_pushed_text_offset | ( | const std::array< int, 2 > & | lOffset | ) | [virtual] |
void gui::button::set_pushed_texture | ( | texture * | pTexture | ) |
virtual void gui::button::set_text | ( | const std::string & | sText | ) | [virtual] |
virtual void gui::button::unlight | ( | ) | [virtual] |
Unlights this Button.
void gui::button::unlock_highlight | ( | ) |
Unlocks this button's highlighting.
bool gui::button::bHighlighted_ [protected] |
Definition at line 239 of file gui_button.hpp.
bool gui::button::bLockHighlight_ [protected] |
Definition at line 240 of file gui_button.hpp.
std::array<int,2> gui::button::lPushedTextOffset_ [protected] |
Definition at line 254 of file gui_button.hpp.
state gui::button::mState_ [protected] |
Definition at line 238 of file gui_button.hpp.
font_string* gui::button::pCurrentFontString_ [protected] |
Definition at line 252 of file gui_button.hpp.
font_string* gui::button::pDisabledText_ [protected] |
Definition at line 251 of file gui_button.hpp.
texture* gui::button::pDisabledTexture_ [protected] |
Definition at line 246 of file gui_button.hpp.
font_string* gui::button::pHighlightText_ [protected] |
Definition at line 250 of file gui_button.hpp.
texture* gui::button::pHighlightTexture_ [protected] |
Definition at line 247 of file gui_button.hpp.
font_string* gui::button::pNormalText_ [protected] |
Definition at line 249 of file gui_button.hpp.
texture* gui::button::pNormalTexture_ [protected] |
Definition at line 244 of file gui_button.hpp.
texture* gui::button::pPushedTexture_ [protected] |
Definition at line 245 of file gui_button.hpp.
std::string gui::button::sText_ [protected] |
Definition at line 242 of file gui_button.hpp.