The Battle for Wesnoth  1.17.8+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:

Classes

struct  error
 

Public Types

enum  PRESSED_STATE { LEFT, RIGHT, BOTH, NONE }
 

Public Member Functions

 tristate_button (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 texture &base, const texture &over=texture())
 
void set_item_id (const std::string &id)
 
- Public Member Functions inherited from gui::widget
const rectlocation () 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 queue_redraw ()
 Indicate that the widget should be redrawn. More...
 
void queue_redraw (const rect &)
 Indicate that a specific region of the screen should be redrawn. More...
 
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) override
 
virtual void process_tooltip_string (int mousex, int mousey) override
 
virtual void layout () override
 Called by draw_manager to validate layout. More...
 
virtual bool expose (const rect &region) override
 Called by draw_manager when it believes a redraw is necessary. More...
 
virtual rect screen_location () override
 The current draw location of the display, on the screen. More...
 
- Public Member Functions inherited from events::sdl_handler
virtual void handle_window_event (const SDL_Event &)
 
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
 
- Public Member Functions inherited from gui2::top_level_drawable
virtual void update ()
 Update state and any parameters that may effect layout, or any of the later stages. More...
 
virtual void render ()
 Perform any internal rendering necessary to prepare the drawable. More...
 

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 (const bool auto_join=true)
 
virtual ~widget ()
 
virtual void update_location (const SDL_Rect &)
 
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 ()
 
- Protected Member Functions inherited from gui2::top_level_drawable
 top_level_drawable ()
 
virtual ~top_level_drawable ()
 
 top_level_drawable (const top_level_drawable &)
 
top_level_drawableoperator= (const top_level_drawable &)
 
 top_level_drawable (top_level_drawable &&)
 
top_level_drawableoperator= (top_level_drawable &&)
 

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

texture baseImage_
 
texture touchedBaseImage_
 
texture activeBaseImage_
 
texture itemBaseImage_
 
texture itemOverlayImage_
 
texture pressedDownImage_
 
texture pressedUpImage_
 
texture pressedBothImage_
 
texture pressedBothActiveImage_
 
texture pressedDownActiveImage_
 
texture pressedUpActiveImage_
 
texture touchedDownImage_
 
texture touchedUpImage_
 
texture 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 27 of file tristate_button.hpp.

Member Enumeration Documentation

◆ PRESSED_STATE

Enumerator
LEFT 
RIGHT 
BOTH 
NONE 

Definition at line 38 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 92 of file tristate_button.hpp.

Constructor & Destructor Documentation

◆ tristate_button()

gui::tristate_button::tristate_button ( 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 105 of file tristate_button.cpp.

Member Function Documentation

◆ calculate_size()

void gui::tristate_button::calculate_size ( )
private

Referenced by set_item_id().

◆ 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 161 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 246 of file tristate_button.cpp.

References rect::contains(), and gui::widget::location().

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 408 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 326 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

◆ set_item_image()

void gui::tristate_button::set_item_image ( const texture base,
const texture over = texture() 
)
inline

Definition at line 59 of file tristate_button.hpp.

References itemBaseImage_, and itemOverlayImage_.

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

◆ set_pressed()

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

Member Data Documentation

◆ activeBaseImage_

texture gui::tristate_button::activeBaseImage_
private

Definition at line 82 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ base_height_

int gui::tristate_button::base_height_
private

Definition at line 104 of file tristate_button.hpp.

Referenced by tristate_button().

◆ base_width_

int gui::tristate_button::base_width_
private

Definition at line 104 of file tristate_button.hpp.

Referenced by tristate_button().

◆ baseImage_

texture gui::tristate_button::baseImage_
private

Definition at line 82 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 108 of file tristate_button.hpp.

Referenced by mouse_up(), and set_item_id().

◆ itemBaseImage_

texture gui::tristate_button::itemBaseImage_
private

Definition at line 82 of file tristate_button.hpp.

Referenced by draw_contents(), and set_item_image().

◆ itemOverlayImage_

texture gui::tristate_button::itemOverlayImage_
private

Definition at line 82 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 106 of file tristate_button.hpp.

Referenced by mouse_up().

◆ pressed_

bool gui::tristate_button::pressed_
private

Definition at line 102 of file tristate_button.hpp.

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

◆ pressedBothActiveImage_

texture gui::tristate_button::pressedBothActiveImage_
private

Definition at line 82 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ pressedBothImage_

texture gui::tristate_button::pressedBothImage_
private

Definition at line 82 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ pressedDownActiveImage_

texture gui::tristate_button::pressedDownActiveImage_
private

Definition at line 82 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ pressedDownImage_

texture gui::tristate_button::pressedDownImage_
private

Definition at line 82 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ pressedUpActiveImage_

texture gui::tristate_button::pressedUpActiveImage_
private

Definition at line 82 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ pressedUpImage_

texture gui::tristate_button::pressedUpImage_
private

Definition at line 82 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 90 of file tristate_button.hpp.

◆ touchedBaseImage_

texture gui::tristate_button::touchedBaseImage_
private

Definition at line 82 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ touchedBothImage_

texture gui::tristate_button::touchedBothImage_
private

Definition at line 82 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ touchedDownImage_

texture gui::tristate_button::touchedDownImage_
private

Definition at line 82 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().

◆ touchedUpImage_

texture gui::tristate_button::touchedUpImage_
private

Definition at line 82 of file tristate_button.hpp.

Referenced by draw_contents(), and tristate_button().


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