The Battle for Wesnoth  1.15.1+dev
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
gui::widget Class Reference

#include <widget.hpp>

Inheritance diagram for gui::widget:
Inheritance graph

Public Member Functions

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
 
virtual void enable (bool new_val=true)
 
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)
 
virtual void draw ()
 
- 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

 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 draw_contents ()
 
virtual void update_location (const SDL_Rect &rect)
 
const SDL_Rect * clip_rect () const
 
virtual sdl_handler_vector member_handlers ()
 
virtual void handle_event (const SDL_Event &)
 
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 ()
 

Protected Attributes

bool focus_
 

Private Types

enum  { UNINIT, HIDDEN, DIRTY, DRAWN }
 

Private Member Functions

void volatile_draw ()
 
void volatile_undraw ()
 
void hide_override (bool value=true)
 

Private Attributes

CVideovideo_
 
std::vector< surface_restorerrestorer_
 
SDL_Rect rect_
 
bool needs_restore_
 
enum gui::widget:: { ... }  state_
 
bool hidden_override_
 
bool enabled_
 
bool clip_
 
SDL_Rect clip_rect_
 
bool volatile_
 
std::string help_text_
 
std::string tooltip_text_
 
int help_string_
 
std::string id_
 
bool mouse_lock_local_
 

Static Private Attributes

static bool mouse_lock_ = false
 

Friends

class dialog
 

Detailed Description

Definition at line 26 of file widget.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
UNINIT 
HIDDEN 
DIRTY 
DRAWN 

Definition at line 113 of file widget.hpp.

Constructor & Destructor Documentation

◆ widget()

gui::widget::widget ( CVideo video,
const bool  auto_join = true 
)
protected

Definition at line 33 of file widget.cpp.

◆ ~widget()

gui::widget::~widget ( )
protectedvirtual

Definition at line 40 of file widget.cpp.

References bg_cancel(), and free_mouse_lock().

Member Function Documentation

◆ aquire_mouse_lock()

void gui::widget::aquire_mouse_lock ( )
protected

Definition at line 46 of file widget.cpp.

References mouse_lock_, and mouse_lock_local_.

◆ bg_cancel()

void gui::widget::bg_cancel ( )
protected

Definition at line 67 of file widget.cpp.

References i, and restorer_.

Referenced by set_location(), gui::scrollarea::test_scrollbar(), and ~widget().

◆ bg_register()

void gui::widget::bg_register ( const SDL_Rect &  rect)
protected

◆ bg_restore() [1/2]

void gui::widget::bg_restore ( ) const
protected

◆ bg_restore() [2/2]

void gui::widget::bg_restore ( const SDL_Rect &  rect) const
protected

Definition at line 253 of file widget.cpp.

References clip_, clip_rect_, i, restorer_, and video().

◆ bg_update()

void gui::widget::bg_update ( )
protected

Definition at line 234 of file widget.cpp.

References i, and restorer_.

Referenced by hide(), hide_override(), and volatile_draw().

◆ clip_rect()

const SDL_Rect * gui::widget::clip_rect ( ) const
protected

Definition at line 94 of file widget.cpp.

References clip_, and clip_rect_.

Referenced by gui::menu::draw(), and draw_contents().

◆ dirty()

bool gui::widget::dirty ( ) const

Definition at line 217 of file widget.cpp.

References DIRTY, and state_.

Referenced by draw(), and gui::menu::draw().

◆ draw()

void gui::widget::draw ( )
virtual

◆ draw_contents()

virtual void gui::widget::draw_contents ( )
inlineprotectedvirtual

◆ enable()

void gui::widget::enable ( bool  new_val = true)
virtual

Reimplemented in gui::button, and gui::tristate_button.

Definition at line 194 of file widget.cpp.

References enabled_, and set_dirty().

Referenced by gui::tristate_button::enable(), and gui::button::enable().

◆ enabled()

bool gui::widget::enabled ( ) const

◆ focus()

bool gui::widget::focus ( const SDL_Event *  event)

◆ free_mouse_lock()

void gui::widget::free_mouse_lock ( )
protected

Definition at line 53 of file widget.cpp.

References mouse_lock_, and mouse_lock_local_.

Referenced by ~widget().

◆ handle_event()

void gui::widget::handle_event ( const SDL_Event &  event)
protectedvirtual

◆ handle_window_event()

void gui::widget::handle_window_event ( const SDL_Event &  event)
protectedvirtual

Implements events::sdl_handler.

Definition at line 337 of file widget.cpp.

References set_dirty().

Referenced by member_handlers().

◆ height()

int gui::widget::height ( ) const

◆ hidden()

bool gui::widget::hidden ( ) const

◆ hide()

void gui::widget::hide ( bool  value = true)
virtual

◆ hide_override()

void gui::widget::hide_override ( bool  value = true)
private

Definition at line 167 of file widget.cpp.

References bg_restore(), bg_update(), DIRTY, DRAWN, hidden_override_, set_dirty(), and state_.

◆ id()

const std::string & gui::widget::id ( ) const

◆ location()

const SDL_Rect & gui::widget::location ( ) const

◆ member_handlers()

virtual sdl_handler_vector gui::widget::member_handlers ( )
inlineprotectedvirtual

Definition at line 92 of file widget.hpp.

References handle_event(), and handle_window_event().

◆ mouse_locked()

bool gui::widget::mouse_locked ( ) const
protected

◆ process_help_string()

void gui::widget::process_help_string ( int  mousex,
int  mousey 
)
virtual

◆ process_tooltip_string()

void gui::widget::process_tooltip_string ( int  mousex,
int  mousey 
)
virtual

Reimplemented from events::sdl_handler.

Definition at line 322 of file widget.cpp.

References tooltips::add_tooltip(), hidden(), sdl::point_in_rect(), rect_, and tooltip_text_.

◆ set_clip_rect()

void gui::widget::set_clip_rect ( const SDL_Rect &  rect)

Definition at line 181 of file widget.cpp.

References clip_, clip_rect_, and set_dirty().

◆ set_dirty()

void gui::widget::set_dirty ( bool  dirty = true)

Definition at line 207 of file widget.cpp.

References DIRTY, DRAWN, hidden_override_, needs_restore_, state_, and volatile_.

Referenced by help::help_browser::adjust_layout(), editor::palette_manager::adjust_size(), editor::location_palette::adjust_size(), gui::textbox::append_text(), gui::menu::change_item(), gui::textbox::clear(), gui::menu::do_sort(), draw(), gui::menu::draw(), editor::location_palette::draw_contents(), editor::palette_manager::draw_contents(), editor::editor_palette< overlay >::draw_contents(), enable(), gui::menu::erase_item(), gui::button::handle_event(), gui::tristate_button::handle_event(), gui::scrollbar::handle_event(), location_palette_item::handle_event(), handle_event(), gui::textbox::handle_event(), handle_window_event(), hide(), hide_override(), editor::palette_manager::restore_palette_bg(), help::help_text_area::scroll(), gui::textbox::scroll(), gui::menu::scroll(), editor::palette_manager::scroll_down(), editor::location_palette::scroll_down(), editor::palette_manager::scroll_up(), editor::unit_palette::select_bg_item(), editor::location_palette::select_item(), gui::button::set_active(), gui::button::set_check(), set_clip_rect(), gui::textbox::set_cursor_pos(), set_focus(), gui::scrollbar::set_full_size(), gui::menu::set_heading(), gui::button::set_image(), gui::menu::set_items(), gui::button::set_label(), set_location(), gui::button::set_overlay(), gui::scrollbar::set_position(), gui::tristate_button::set_pressed(), gui::textbox::set_selection(), gui::scrollbar::set_shown_size(), gui::textbox::set_text(), gui::textbox::set_wrap(), help::show_help(), help::help_text_area::show_topic(), gui::menu::sort_by(), and gui::textbox::update_location().

◆ set_focus()

void gui::widget::set_focus ( bool  focus)

◆ set_height()

void gui::widget::set_height ( int  h)

◆ set_help_string()

void gui::widget::set_help_string ( const std::string &  str)

Definition at line 299 of file widget.cpp.

References help_text_.

◆ set_id()

void gui::widget::set_id ( const std::string &  id)

Definition at line 227 of file widget.cpp.

References id(), and id_.

◆ set_location() [1/2]

void gui::widget::set_location ( const SDL_Rect &  rect)
virtual

◆ set_location() [2/2]

void gui::widget::set_location ( int  x,
int  y 
)

Definition at line 104 of file widget.cpp.

References rect_, and set_location().

◆ set_measurements()

void gui::widget::set_measurements ( int  w,
int  h 
)

Definition at line 119 of file widget.cpp.

References rect_, set_location(), and w.

Referenced by help::help_browser::help_browser(), gui::textbox::textbox(), and gui::menu::update_size().

◆ set_tooltip_string()

void gui::widget::set_tooltip_string ( const std::string &  str)

◆ set_volatile()

void gui::widget::set_volatile ( bool  val = true)

Definition at line 262 of file widget.cpp.

References DIRTY, DRAWN, state_, and volatile_.

◆ set_width()

void gui::widget::set_width ( int  w)

◆ update_location()

void gui::widget::update_location ( const SDL_Rect &  rect)
protectedvirtual

◆ video()

CVideo& gui::widget::video ( ) const
inlineprotected

◆ volatile_draw()

void gui::widget::volatile_draw ( )
privatevirtual

Reimplemented from events::sdl_handler.

Definition at line 283 of file widget.cpp.

References bg_update(), DIRTY, draw(), DRAWN, hidden_override_, state_, and volatile_.

◆ volatile_undraw()

void gui::widget::volatile_undraw ( )
privatevirtual

Reimplemented from events::sdl_handler.

Definition at line 292 of file widget.cpp.

References bg_restore(), and volatile_.

◆ width()

int gui::widget::width ( ) const

Friends And Related Function Documentation

◆ dialog

friend class dialog
friend

Definition at line 129 of file widget.hpp.

Member Data Documentation

◆ clip_

bool gui::widget::clip_
private

Definition at line 116 of file widget.hpp.

Referenced by bg_restore(), clip_rect(), draw(), hidden(), and set_clip_rect().

◆ clip_rect_

SDL_Rect gui::widget::clip_rect_
private

Definition at line 117 of file widget.hpp.

Referenced by bg_restore(), clip_rect(), draw(), hidden(), and set_clip_rect().

◆ enabled_

bool gui::widget::enabled_
private

Definition at line 115 of file widget.hpp.

Referenced by enable(), and enabled().

◆ focus_

bool gui::widget::focus_
protected

◆ help_string_

int gui::widget::help_string_
private

Definition at line 123 of file widget.hpp.

Referenced by process_help_string().

◆ help_text_

std::string gui::widget::help_text_
private

Definition at line 121 of file widget.hpp.

Referenced by process_help_string(), and set_help_string().

◆ hidden_override_

bool gui::widget::hidden_override_
private

Definition at line 114 of file widget.hpp.

Referenced by hidden(), hide(), hide_override(), set_dirty(), and volatile_draw().

◆ id_

std::string gui::widget::id_
private

Definition at line 124 of file widget.hpp.

Referenced by id(), and set_id().

◆ mouse_lock_

bool gui::widget::mouse_lock_ = false
staticprivate

Definition at line 127 of file widget.hpp.

Referenced by aquire_mouse_lock(), free_mouse_lock(), and mouse_locked().

◆ mouse_lock_local_

bool gui::widget::mouse_lock_local_
private

Definition at line 126 of file widget.hpp.

Referenced by aquire_mouse_lock(), free_mouse_lock(), and mouse_locked().

◆ needs_restore_

bool gui::widget::needs_restore_
mutableprivate

Definition at line 111 of file widget.hpp.

Referenced by bg_restore(), and set_dirty().

◆ rect_

SDL_Rect gui::widget::rect_
private

◆ restorer_

std::vector< surface_restorer > gui::widget::restorer_
private

Definition at line 109 of file widget.hpp.

Referenced by bg_cancel(), bg_register(), bg_restore(), and bg_update().

◆ state_

enum { ... } gui::widget::state_

◆ tooltip_text_

std::string gui::widget::tooltip_text_
private

Definition at line 122 of file widget.hpp.

Referenced by process_tooltip_string(), and set_tooltip_string().

◆ video_

CVideo* gui::widget::video_
private

Definition at line 108 of file widget.hpp.

Referenced by video().

◆ volatile_

bool gui::widget::volatile_
private

Definition at line 119 of file widget.hpp.

Referenced by set_dirty(), set_volatile(), volatile_draw(), and volatile_undraw().


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