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 | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
gui::button Class Reference

#include <button.hpp>

Inheritance diagram for gui::button:
Inheritance graph

Classes

struct  error
 

Public Types

enum  TYPE {
  TYPE_PRESS, TYPE_CHECK, TYPE_TURBO, TYPE_IMAGE,
  TYPE_RADIO
}
 
enum  SPACE_CONSUMPTION { DEFAULT_SPACE, MINIMUM_SPACE }
 

Public Member Functions

 button (CVideo &video, const std::string &label, TYPE type=TYPE_PRESS, std::string button_image="", SPACE_CONSUMPTION spacing=DEFAULT_SPACE, const bool auto_join=true, std::string overlay_image="")
 
virtual ~button ()
 Default implementation, but defined out-of-line for efficiency reasons. More...
 
void set_check (bool check)
 
void set_active (bool active)
 
bool checked () const
 
void set_label (const std::string &val)
 
void set_image (const std::string &image_file_base)
 
void set_overlay (const std::string &image_file_base)
 
void set_image_path_suffix (const std::string &suffix)
 
bool pressed ()
 
bool hit (int x, int y) const
 
virtual void enable (bool new_val=true)
 
void release ()
 
- 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 draw ()
 
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 ()
 

Protected Attributes

TYPE type_
 
- Protected Attributes inherited from gui::widget
bool focus_
 

Private Types

enum  STATE {
  UNINIT, NORMAL, ACTIVE, PRESSED,
  PRESSED_ACTIVE, TOUCHED_NORMAL, TOUCHED_PRESSED
}
 

Private Member Functions

void load_images ()
 
void calculate_size ()
 

Private Attributes

std::string label_text_
 
surface image_
 
surface pressedImage_
 
surface activeImage_
 
surface pressedActiveImage_
 
surface touchedImage_
 
surface disabledImage_
 
surface pressedDisabledImage_
 
surface overlayImage_
 
surface overlayPressedImage_
 
surface overlayPressedDisabledImage_
 
surface overlayDisabledImage_
 
surface overlayActiveImage_
 
SDL_Rect textRect_
 
STATE state_
 
bool pressed_
 
SPACE_CONSUMPTION spacing_
 
int base_height_
 
int base_width_
 
std::string button_image_name_
 
std::string button_overlay_image_name_
 
std::string button_image_path_suffix_
 

Detailed Description

Definition at line 27 of file button.hpp.

Member Enumeration Documentation

Enumerator
DEFAULT_SPACE 
MINIMUM_SPACE 

Definition at line 38 of file button.hpp.

enum gui::button::STATE
private
Enumerator
UNINIT 
NORMAL 
ACTIVE 
PRESSED 
PRESSED_ACTIVE 
TOUCHED_NORMAL 
TOUCHED_PRESSED 

Definition at line 92 of file button.hpp.

Enumerator
TYPE_PRESS 
TYPE_CHECK 
TYPE_TURBO 
TYPE_IMAGE 
TYPE_RADIO 

Definition at line 36 of file button.hpp.

Constructor & Destructor Documentation

gui::button::button ( CVideo video,
const std::string label,
button::TYPE  type = TYPE_PRESS,
std::string  button_image = "",
SPACE_CONSUMPTION  spacing = DEFAULT_SPACE,
const bool  auto_join = true,
std::string  overlay_image = "" 
)

Definition at line 47 of file button.cpp.

References button_image_name_, load_images(), type_, TYPE_CHECK, TYPE_PRESS, TYPE_RADIO, and TYPE_TURBO.

gui::button::~button ( )
virtual

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

Definition at line 287 of file button.cpp.

Member Function Documentation

void gui::button::calculate_size ( )
private
bool gui::button::checked ( ) const
void gui::button::draw_contents ( )
protectedvirtual
void gui::button::enable ( bool  new_val = true)
virtual
void gui::button::handle_event ( const SDL_Event &  event)
protectedvirtual
bool gui::button::hit ( int  x,
int  y 
) const
void gui::button::load_images ( )
private
void gui::button::mouse_down ( const SDL_MouseButtonEvent &  event)
protectedvirtual
void gui::button::mouse_motion ( const SDL_MouseMotionEvent &  event)
protectedvirtual
void gui::button::mouse_up ( const SDL_MouseButtonEvent &  event)
protectedvirtual
bool gui::button::pressed ( )
void gui::button::release ( )

Definition at line 684 of file button.cpp.

References draw_contents(), NORMAL, and state_.

Referenced by storyscreen::part_ui::handle_interface().

void gui::button::set_active ( bool  active)

Definition at line 370 of file button.cpp.

References ACTIVE, NORMAL, gui::widget::set_dirty(), and state_.

void gui::button::set_check ( bool  check)
void gui::button::set_image ( const std::string image_file_base)
void gui::button::set_image_path_suffix ( const std::string suffix)
inline

Definition at line 54 of file button.hpp.

References button_image_path_suffix_, and load_images().

void gui::button::set_label ( const std::string val)
void gui::button::set_overlay ( const std::string image_file_base)

Member Data Documentation

surface gui::button::activeImage_
private

Definition at line 85 of file button.hpp.

Referenced by draw_contents(), and load_images().

int gui::button::base_height_
private

Definition at line 99 of file button.hpp.

Referenced by calculate_size(), and load_images().

int gui::button::base_width_
private

Definition at line 99 of file button.hpp.

Referenced by calculate_size(), and load_images().

std::string gui::button::button_image_name_
private

Definition at line 101 of file button.hpp.

Referenced by button(), load_images(), and set_image().

std::string gui::button::button_image_path_suffix_
private

Definition at line 103 of file button.hpp.

Referenced by load_images(), and set_image_path_suffix().

std::string gui::button::button_overlay_image_name_
private

Definition at line 102 of file button.hpp.

Referenced by load_images(), and set_overlay().

surface gui::button::disabledImage_
private

Definition at line 85 of file button.hpp.

Referenced by draw_contents(), and load_images().

surface gui::button::image_
private

Definition at line 85 of file button.hpp.

Referenced by calculate_size(), draw_contents(), and load_images().

std::string gui::button::label_text_
private

Definition at line 76 of file button.hpp.

Referenced by calculate_size(), draw_contents(), load_images(), and set_label().

surface gui::button::overlayActiveImage_
private

Definition at line 85 of file button.hpp.

Referenced by draw_contents(), and load_images().

surface gui::button::overlayDisabledImage_
private

Definition at line 85 of file button.hpp.

Referenced by draw_contents(), and load_images().

surface gui::button::overlayImage_
private

Definition at line 85 of file button.hpp.

Referenced by draw_contents(), and load_images().

surface gui::button::overlayPressedDisabledImage_
private

Definition at line 85 of file button.hpp.

Referenced by draw_contents(), and load_images().

surface gui::button::overlayPressedImage_
private

Definition at line 85 of file button.hpp.

Referenced by draw_contents(), and load_images().

bool gui::button::pressed_
private

Definition at line 95 of file button.hpp.

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

surface gui::button::pressedActiveImage_
private

Definition at line 85 of file button.hpp.

Referenced by draw_contents(), and load_images().

surface gui::button::pressedDisabledImage_
private

Definition at line 85 of file button.hpp.

Referenced by draw_contents(), and load_images().

surface gui::button::pressedImage_
private

Definition at line 85 of file button.hpp.

Referenced by draw_contents(), and load_images().

SPACE_CONSUMPTION gui::button::spacing_
private

Definition at line 97 of file button.hpp.

Referenced by calculate_size().

STATE gui::button::state_
private
SDL_Rect gui::button::textRect_
private

Definition at line 90 of file button.hpp.

Referenced by calculate_size(), and draw_contents().

surface gui::button::touchedImage_
private

Definition at line 85 of file button.hpp.

Referenced by draw_contents(), and load_images().

TYPE gui::button::type_
protected

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