The Battle for Wesnoth  1.13.4+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Classes | Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
gui::tristate_button Class Reference

#include <tristate_button.hpp>

Inheritance diagram for gui::tristate_button:
Inheritance graph

Classes

struct  error
 

Public Types

enum  PRESSED_STATE { LEFT, RIGHT, BOTH, NONE }
 

Public Member Functions

 tristate_button (CVideo &video, editor::tristate_palette *palette, std::string button_image="", const bool auto_join=true)
 
virtual ~tristate_button ()
 Default implementation, but defined out-of-line for efficiency reasons. More...
 
void set_pressed (PRESSED_STATE new_pressed_state)
 
bool pressed ()
 
PRESSED_STATE pressed_state () const
 
void set_label (const std::string &val)
 
bool hit (int x, int y) const
 
virtual void enable (bool new_val=true)
 
void release ()
 
void set_item_image (const surface &image)
 
void set_item_id (const std::string &id)
 
void draw ()
 
- Public Member Functions inherited from gui::widget
SDL_Rect const & location () const
 
virtual void set_location (SDL_Rect const &rect)
 
void set_location (int x, int y)
 
void set_width (int w)
 
void set_height (int h)
 
void set_measurements (int w, int h)
 
int width () const
 
int height () const
 
bool focus (const SDL_Event *event)
 
void set_focus (bool focus)
 
virtual void hide (bool value=true)
 
bool hidden () const
 
bool enabled () const
 
void set_clip_rect (const SDL_Rect &rect)
 
void set_volatile (bool val=true)
 
void set_dirty (bool dirty=true)
 
bool dirty () const
 
const std::stringid () const
 
void set_id (const std::string &id)
 
void set_help_string (const std::string &str)
 
void set_tooltip_string (const std::string &str)
 
virtual void process_help_string (int mousex, int mousey)
 
virtual void process_tooltip_string (int mousex, int mousey)
 
- Public Member Functions inherited from events::sdl_handler
virtual void process_event ()
 
virtual bool requires_event_focus (const SDL_Event *=nullptr) const
 
virtual void join ()
 
virtual void join (context &c)
 
virtual void join_same (sdl_handler *parent)
 
virtual void leave ()
 
virtual void join_global ()
 
virtual void leave_global ()
 

Protected Member Functions

virtual void handle_event (const SDL_Event &event)
 
virtual void mouse_motion (const SDL_MouseMotionEvent &event)
 
virtual void mouse_down (const SDL_MouseButtonEvent &event)
 
virtual void mouse_up (const SDL_MouseButtonEvent &event)
 
virtual void draw_contents ()
 
- Protected Member Functions inherited from gui::widget
 widget (widget const &o)
 
 widget (CVideo &video, const bool auto_join=true)
 
virtual ~widget ()
 
void bg_register (SDL_Rect const &rect)
 
void bg_restore () const
 
void bg_restore (SDL_Rect const &rect) const
 
void bg_update ()
 
void bg_cancel ()
 
CVideovideo () const
 
virtual void update_location (SDL_Rect const &rect)
 
const SDL_Rect * clip_rect () const
 
virtual sdl_handler_vector member_handlers ()
 
virtual void handle_window_event (SDL_Event const &event)
 
bool mouse_locked () const
 
void aquire_mouse_lock ()
 
void free_mouse_lock ()
 
- Protected Member Functions inherited from events::sdl_handler
 sdl_handler (const bool auto_join=true)
 
virtual ~sdl_handler ()
 
virtual std::vector
< sdl_handler * > 
handler_members ()
 

Private Types

enum  STATE {
  UNINIT, NORMAL, ACTIVE, PRESSED_ACTIVE_LEFT,
  PRESSED_ACTIVE_RIGHT, PRESSED_ACTIVE_BOTH, TOUCHED_RIGHT, TOUCHED_BOTH_RIGHT,
  TOUCHED_BOTH_LEFT, TOUCHED_LEFT, PRESSED_LEFT, PRESSED_RIGHT,
  PRESSED_BOTH
}
 

Private Member Functions

void calculate_size ()
 

Private Attributes

std::string label_
 
surface baseImage_
 
surface touchedBaseImage_
 
surface activeBaseImage_
 
surface itemImage_
 
surface pressedDownImage_
 
surface pressedUpImage_
 
surface pressedBothImage_
 
surface pressedBothActiveImage_
 
surface pressedDownActiveImage_
 
surface pressedUpActiveImage_
 
surface touchedDownImage_
 
surface touchedUpImage_
 
surface touchedBothImage_
 
SDL_Rect textRect_
 
STATE state_
 
bool pressed_
 
int base_height_
 
int base_width_
 
editor::tristate_palettepalette_
 
std::string item_id_
 

Additional Inherited Members

- Protected Attributes inherited from gui::widget
bool focus_
 

Detailed Description

Definition at line 25 of file tristate_button.hpp.

Member Enumeration Documentation

Enumerator
LEFT 
RIGHT 
BOTH 
NONE 

Definition at line 36 of file tristate_button.hpp.

Enumerator
UNINIT 
NORMAL 
ACTIVE 
PRESSED_ACTIVE_LEFT 
PRESSED_ACTIVE_RIGHT 
PRESSED_ACTIVE_BOTH 
TOUCHED_RIGHT 
TOUCHED_BOTH_RIGHT 
TOUCHED_BOTH_LEFT 
TOUCHED_LEFT 
PRESSED_LEFT 
PRESSED_RIGHT 
PRESSED_BOTH 

Definition at line 98 of file tristate_button.hpp.

Constructor & Destructor Documentation

gui::tristate_button::tristate_button ( CVideo video,
editor::tristate_palette palette,
std::string  button_image = "",
const bool  auto_join = true 
)
gui::tristate_button::~tristate_button ( )
virtual

Default implementation, but defined out-of-line for efficiency reasons.

Definition at line 99 of file tristate_button.cpp.

Member Function Documentation

void gui::tristate_button::calculate_size ( )
private
void gui::tristate_button::draw ( )
inlinevirtual

Reimplemented from gui::widget.

Definition at line 69 of file tristate_button.hpp.

References gui::widget::draw().

Referenced by editor::editor_palette< Item >::draw_contents().

void gui::tristate_button::draw_contents ( )
protectedvirtual
void gui::tristate_button::enable ( bool  new_val = true)
virtual

Reimplemented from gui::widget.

Definition at line 155 of file tristate_button.cpp.

References gui::widget::enable(), gui::widget::enabled(), NORMAL, pressed_, and state_.

void gui::tristate_button::handle_event ( const SDL_Event &  event)
protectedvirtual
bool gui::tristate_button::hit ( int  x,
int  y 
) const

Definition at line 275 of file tristate_button.cpp.

References gui::widget::location(), and sdl::point_in_rect().

Referenced by mouse_down(), mouse_motion(), and mouse_up().

void gui::tristate_button::mouse_down ( const SDL_MouseButtonEvent &  event)
protectedvirtual
void gui::tristate_button::mouse_motion ( const SDL_MouseMotionEvent &  event)
protectedvirtual
void gui::tristate_button::mouse_up ( const SDL_MouseButtonEvent &  event)
protectedvirtual
bool gui::tristate_button::pressed ( )

Definition at line 437 of file tristate_button.cpp.

References pressed_.

tristate_button::PRESSED_STATE gui::tristate_button::pressed_state ( ) const
void gui::tristate_button::release ( )

Definition at line 355 of file tristate_button.cpp.

References draw_contents(), NORMAL, and state_.

void gui::tristate_button::set_item_id ( const std::string id)
inline

Definition at line 65 of file tristate_button.hpp.

References gui::widget::id(), and item_id_.

Referenced by editor::editor_palette< Item >::draw_contents().

void gui::tristate_button::set_item_image ( const surface image)
inline

Definition at line 59 of file tristate_button.hpp.

References itemImage_.

Referenced by editor::editor_palette< Item >::draw_contents().

void gui::tristate_button::set_label ( const std::string val)
void gui::tristate_button::set_pressed ( PRESSED_STATE  new_pressed_state)

Member Data Documentation

surface gui::tristate_button::activeBaseImage_
private

Definition at line 88 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

int gui::tristate_button::base_height_
private

Definition at line 110 of file tristate_button.hpp.

Referenced by tristate_button().

int gui::tristate_button::base_width_
private

Definition at line 110 of file tristate_button.hpp.

Referenced by tristate_button().

surface gui::tristate_button::baseImage_
private

Definition at line 88 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

std::string gui::tristate_button::item_id_
private

Definition at line 114 of file tristate_button.hpp.

Referenced by mouse_up(), and set_item_id().

surface gui::tristate_button::itemImage_
private

Definition at line 88 of file tristate_button.hpp.

Referenced by draw_contents(), and set_item_image().

std::string gui::tristate_button::label_
private

Definition at line 86 of file tristate_button.hpp.

Referenced by draw_contents().

editor::tristate_palette* gui::tristate_button::palette_
private

Definition at line 112 of file tristate_button.hpp.

Referenced by mouse_up().

bool gui::tristate_button::pressed_
private

Definition at line 108 of file tristate_button.hpp.

Referenced by enable(), mouse_up(), and pressed().

surface gui::tristate_button::pressedBothActiveImage_
private

Definition at line 88 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

surface gui::tristate_button::pressedBothImage_
private

Definition at line 88 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

surface gui::tristate_button::pressedDownActiveImage_
private

Definition at line 88 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

surface gui::tristate_button::pressedDownImage_
private

Definition at line 88 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

surface gui::tristate_button::pressedUpActiveImage_
private

Definition at line 88 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

surface gui::tristate_button::pressedUpImage_
private

Definition at line 88 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

STATE gui::tristate_button::state_
private
SDL_Rect gui::tristate_button::textRect_
private

Definition at line 96 of file tristate_button.hpp.

Referenced by draw_contents().

surface gui::tristate_button::touchedBaseImage_
private

Definition at line 88 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

surface gui::tristate_button::touchedBothImage_
private

Definition at line 88 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

surface gui::tristate_button::touchedDownImage_
private

Definition at line 88 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

surface gui::tristate_button::touchedUpImage_
private

Definition at line 88 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().


The documentation for this class was generated from the following files: