gui::button Class Reference

A simple button. More...

#include <gui_button.hpp>

Inheritance diagram for gui::button:
gui::frame gui::event_receiver gui::region gui::uiobject gui::check_button

List of all members.

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.
textureget_normal_texture ()
 Returns this button's normal texture.
textureget_pushed_texture ()
 Returns this button's pushed texture.
textureget_disabled_texture ()
 Returns this button's disabled texture.
textureget_highlight_texture ()
 Returns this button's highlight texture.
font_stringget_normal_text ()
 Returns this button's normal text.
font_stringget_highlight_text ()
 Returns this button's highlight text.
font_stringget_disabled_text ()
 Returns this button's disabled text.
font_stringget_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

texturecreate_normal_texture_ ()
texturecreate_pushed_texture_ ()
texturecreate_disabled_texture_ ()
texturecreate_highlight_texture_ ()
font_stringcreate_normal_text_ ()
font_stringcreate_highlight_text_ ()
font_stringcreate_disabled_text_ ()

Protected Attributes

state mState_
bool bHighlighted_
bool bLockHighlight_
std::string sText_
texturepNormalTexture_
texturepPushedTexture_
texturepDisabledTexture_
texturepHighlightTexture_
font_stringpNormalText_
font_stringpHighlightText_
font_stringpDisabledText_
font_stringpCurrentFontString_
std::array< int, 2 > lPushedTextOffset_

Detailed Description

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.


Member Enumeration Documentation

Enumerator:
STATE_UP 
STATE_DOWN 
STATE_DISABLED 

Definition at line 28 of file gui_button.hpp.


Constructor & Destructor Documentation

gui::button::button ( manager pManager  )  [explicit]

Constructor.

Definition at line 11 of file gui_button.cpp.

virtual gui::button::~button (  )  [virtual]

Destructor.


Member Function Documentation

virtual bool gui::button::can_use_script ( const std::string &  sScriptName  )  const [virtual]

Returns 'true' if this Button can use a script.

Parameters:
sScriptName The name of the script
Note:
This method can be overriden if needed.

Reimplemented from gui::frame.

virtual void gui::button::copy_from ( uiobject pObj  )  [virtual]

Copies an uiobject's parameters into this Button (inheritance).

Parameters:
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]

Creates the associated Lua glue.

Reimplemented from gui::frame.

Reimplemented in gui::check_button.

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.

Note:
A disabled button doesn't receive any input.

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.

Returns:
This button's state (see ButtonState)
font_string* gui::button::get_CurrentFontString (  ) 

Returns the currently displayed text object.

Returns:
The currently displayed text object
font_string* gui::button::get_disabled_text (  ) 

Returns this button's disabled text.

Returns:
This button's disabled text
texture* gui::button::get_disabled_texture (  ) 

Returns this button's disabled texture.

Returns:
This button's disabled texture
font_string* gui::button::get_highlight_text (  ) 

Returns this button's highlight text.

Returns:
This button's highlight text
texture* gui::button::get_highlight_texture (  ) 

Returns this button's highlight texture.

Returns:
This button's highlight texture
font_string* gui::button::get_normal_text (  ) 

Returns this button's normal text.

Returns:
This button's normal text
texture* gui::button::get_normal_texture (  ) 

Returns this button's normal texture.

Returns:
This button's normal texture
& gui::button::get_pushed_text_offset (  )  const

Returns this button's pushed text offset.

Returns:
This button's pushed text offset

Definition at line 671 of file gui_button.cpp.

texture* gui::button::get_pushed_texture (  ) 

Returns this button's pushed texture.

Returns:
This button's pushed texture
const std::string& gui::button::get_text (  )  const

Returns this button's text.

Returns:
This button's text
virtual void gui::button::highlight (  )  [virtual]

Highlights this Button.

Note:
The Button will be highlighted even if the mouse is not over it. It will stop when the mouse leaves it.
bool gui::button::is_enabled (  )  const

Checks if this Button is enabled.

Returns:
'true' if this Button is enabled
void gui::button::lock_highlight (  ) 

Locks this button's highlighting.

Note:
The button will always be highlighted until you call unlock_highlight().
virtual void gui::button::on ( const std::string &  sScriptName,
event pEvent = nullptr 
) [virtual]

Calls a script.

Parameters:
sScriptName The name of the script
pEvent Stores scripts arguments

Reimplemented from gui::frame.

virtual void gui::button::on_event ( const event mEvent  )  [virtual]

Calls the on_event script.

Parameters:
mEvent The Event that occured

Reimplemented from gui::frame.

void gui::button::parse_block ( xml::block *  pBlock  )  [virtual]

Parses data from an xml::block.

Parameters:
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.

Note:
This function only has a visual impact : the OnClick() handler is not called.
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.

Note:
This function only has a visual impact : the OnClick() handler is not called.

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.

Parameters:
sTab The offset to give to all lines
Returns:
All relevant information about this widget

Reimplemented from gui::frame.

Reimplemented in gui::check_button.

void gui::button::set_disabled_text ( font_string pFont  ) 

Sets this button's disabled text.

Parameters:
pFont The new text object
void gui::button::set_disabled_texture ( texture pTexture  ) 

Sets this button's disabled texture.

Parameters:
pTexture The new texture
void gui::button::set_highlight_text ( font_string pFont  ) 

Sets this button's highlight text.

Parameters:
pFont The new text object
void gui::button::set_highlight_texture ( texture pTexture  ) 

Sets this button's highlight texture.

Parameters:
pTexture The new texture
void gui::button::set_normal_text ( font_string pFont  ) 

Sets this button's normal text.

Parameters:
pFont The new text object
void gui::button::set_normal_texture ( texture pTexture  ) 

Sets this button's normal texture.

Parameters:
pTexture The new texture
virtual void gui::button::set_pushed_text_offset ( const std::array< int, 2 > &  lOffset  )  [virtual]

Sets this button's pushed text offset.

Parameters:
lOffset The pused text offset
void gui::button::set_pushed_texture ( texture pTexture  ) 

Sets this button's pushed texture.

Parameters:
pTexture The new texture
virtual void gui::button::set_text ( const std::string &  sText  )  [virtual]

Sets this button's text.

Parameters:
sText The new text
virtual void gui::button::unlight (  )  [virtual]

Unlights this Button.

Note:
The Button will be unlighted even if the mouse is over it. It will highlight again when the mouse leaves then enters its region.
void gui::button::unlock_highlight (  ) 

Unlocks this button's highlighting.


Member Data Documentation

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.

Definition at line 238 of file gui_button.hpp.

Definition at line 252 of file gui_button.hpp.

Definition at line 251 of file gui_button.hpp.

Definition at line 246 of file gui_button.hpp.

Definition at line 250 of file gui_button.hpp.

Definition at line 247 of file gui_button.hpp.

Definition at line 249 of file gui_button.hpp.

Definition at line 244 of file gui_button.hpp.

Definition at line 245 of file gui_button.hpp.

std::string gui::button::sText_ [protected]

Definition at line 242 of file gui_button.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines

Generated on Tue Jan 1 21:58:12 2013 for gui by  doxygen 1.6.1