The Battle for Wesnoth  1.15.2+dev
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
 
bool hit (int x, int y) const
 
virtual void enable (bool new_val=true) override
 
void release ()
 
void set_item_image (const surface &image)
 
void set_item_id (const std::string &id)
 
void draw () override
 
- Public Member Functions inherited from gui::widget
const SDL_Rect & location () const
 
virtual void set_location (const SDL_Rect &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::string & id () 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 ()
 
virtual bool has_joined ()
 
virtual bool has_joined_global ()
 
sdl_handleroperator= (sdl_handler &&)=delete
 Moving would require two instances' context membership to be handled, it's simpler to delete these and require the two instances to be separately constructed / destructed. More...
 
 sdl_handler (sdl_handler &&)=delete
 

Protected Member Functions

virtual void handle_event (const SDL_Event &event) override
 
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 () override
 
- Protected Member Functions inherited from gui::widget
 widget (CVideo &video, const bool auto_join=true)
 
virtual ~widget ()
 
void bg_register (const SDL_Rect &rect)
 
void bg_restore () const
 
void bg_restore (const SDL_Rect &rect) const
 
void bg_update ()
 
void bg_cancel ()
 
CVideovideo () const
 
virtual void update_location (const SDL_Rect &rect)
 
const SDL_Rect * clip_rect () const
 
virtual sdl_handler_vector member_handlers ()
 
virtual void handle_window_event (const SDL_Event &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)
 
 sdl_handler (const sdl_handler &)
 
sdl_handleroperator= (const sdl_handler &)
 
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

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

◆ PRESSED_STATE

Enumerator
LEFT 
RIGHT 
BOTH 
NONE 

Definition at line 36 of file tristate_button.hpp.

◆ STATE

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 94 of file tristate_button.hpp.

Constructor & Destructor Documentation

◆ tristate_button()

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

◆ ~tristate_button()

gui::tristate_button::~tristate_button ( )
virtual

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

Definition at line 90 of file tristate_button.cpp.

Member Function Documentation

◆ calculate_size()

void gui::tristate_button::calculate_size ( )
private

Referenced by draw().

◆ draw()

void gui::tristate_button::draw ( )
inlineoverridevirtual

◆ draw_contents()

void gui::tristate_button::draw_contents ( )
overrideprotectedvirtual

◆ enable()

void gui::tristate_button::enable ( bool  new_val = true)
overridevirtual

Reimplemented from gui::widget.

Definition at line 146 of file tristate_button.cpp.

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

◆ handle_event()

void gui::tristate_button::handle_event ( const SDL_Event &  event)
overrideprotectedvirtual

◆ hit()

bool gui::tristate_button::hit ( int  x,
int  y 
) const

Definition at line 237 of file tristate_button.cpp.

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

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

◆ mouse_down()

void gui::tristate_button::mouse_down ( const SDL_MouseButtonEvent &  event)
protectedvirtual

◆ mouse_motion()

void gui::tristate_button::mouse_motion ( const SDL_MouseMotionEvent &  event)
protectedvirtual

◆ mouse_up()

void gui::tristate_button::mouse_up ( const SDL_MouseButtonEvent &  event)
protectedvirtual

◆ pressed()

bool gui::tristate_button::pressed ( )

Definition at line 399 of file tristate_button.cpp.

References pressed_.

◆ pressed_state()

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

◆ release()

void gui::tristate_button::release ( )

Definition at line 317 of file tristate_button.cpp.

References draw_contents(), NORMAL, and state_.

◆ set_item_id()

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

Definition at line 63 of file tristate_button.hpp.

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

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

◆ set_item_image()

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

Definition at line 57 of file tristate_button.hpp.

References itemImage_.

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

◆ set_pressed()

void gui::tristate_button::set_pressed ( PRESSED_STATE  new_pressed_state)

Member Data Documentation

◆ activeBaseImage_

surface gui::tristate_button::activeBaseImage_
private

Definition at line 84 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ base_height_

int gui::tristate_button::base_height_
private

Definition at line 106 of file tristate_button.hpp.

Referenced by tristate_button().

◆ base_width_

int gui::tristate_button::base_width_
private

Definition at line 106 of file tristate_button.hpp.

Referenced by tristate_button().

◆ baseImage_

surface gui::tristate_button::baseImage_
private

Definition at line 84 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ item_id_

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

Definition at line 110 of file tristate_button.hpp.

Referenced by mouse_up(), and set_item_id().

◆ itemImage_

surface gui::tristate_button::itemImage_
private

Definition at line 84 of file tristate_button.hpp.

Referenced by draw_contents(), and set_item_image().

◆ palette_

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

Definition at line 108 of file tristate_button.hpp.

Referenced by mouse_up().

◆ pressed_

bool gui::tristate_button::pressed_
private

Definition at line 104 of file tristate_button.hpp.

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

◆ pressedBothActiveImage_

surface gui::tristate_button::pressedBothActiveImage_
private

Definition at line 84 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ pressedBothImage_

surface gui::tristate_button::pressedBothImage_
private

Definition at line 84 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ pressedDownActiveImage_

surface gui::tristate_button::pressedDownActiveImage_
private

Definition at line 84 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ pressedDownImage_

surface gui::tristate_button::pressedDownImage_
private

Definition at line 84 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ pressedUpActiveImage_

surface gui::tristate_button::pressedUpActiveImage_
private

Definition at line 84 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ pressedUpImage_

surface gui::tristate_button::pressedUpImage_
private

Definition at line 84 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ state_

STATE gui::tristate_button::state_
private

◆ textRect_

SDL_Rect gui::tristate_button::textRect_
private

Definition at line 92 of file tristate_button.hpp.

◆ touchedBaseImage_

surface gui::tristate_button::touchedBaseImage_
private

Definition at line 84 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ touchedBothImage_

surface gui::tristate_button::touchedBothImage_
private

Definition at line 84 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ touchedDownImage_

surface gui::tristate_button::touchedDownImage_
private

Definition at line 84 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ touchedUpImage_

surface gui::tristate_button::touchedUpImage_
private

Definition at line 84 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().


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