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

Public Member Functions

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

 widget (const bool auto_join=true)
 
virtual ~widget ()
 
virtual void draw_contents ()
 
virtual void update_location (const SDL_Rect &)
 
virtual void handle_event (const SDL_Event &) override
 
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 &&)
 

Protected Attributes

bool focus_
 

Private Types

enum  { UNINIT, HIDDEN, DIRTY, DRAWN }
 

Private Member Functions

void draw ()
 

Private Attributes

rect rect_
 
enum gui::widget:: { ... }  state_
 
bool enabled_
 
bool clip_
 
rect clip_rect_
 
std::string help_text_
 
std::string tooltip_text_
 
bool has_help_
 
std::string id_
 
bool mouse_lock_local_
 

Static Private Attributes

static bool mouse_lock_ = false
 

Friends

class dialog
 

Detailed Description

Definition at line 28 of file widget.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
UNINIT 
HIDDEN 
DIRTY 
DRAWN 

Definition at line 104 of file widget.hpp.

Constructor & Destructor Documentation

◆ widget()

gui::widget::widget ( const bool  auto_join = true)
protected

Definition at line 34 of file widget.cpp.

◆ ~widget()

gui::widget::~widget ( )
protectedvirtual

Definition at line 41 of file widget.cpp.

References free_mouse_lock(), hidden(), and queue_redraw().

Member Function Documentation

◆ aquire_mouse_lock()

void gui::widget::aquire_mouse_lock ( )
protected

Definition at line 49 of file widget.cpp.

References mouse_lock_, and mouse_lock_local_.

Referenced by handle_event().

◆ dirty()

bool gui::widget::dirty ( ) const

Definition at line 194 of file widget.cpp.

References DIRTY, and state_.

Referenced by editor::location_palette::layout(), and editor::palette_manager::layout().

◆ draw()

void gui::widget::draw ( )
private

Definition at line 231 of file widget.cpp.

References clip_, clip_rect_, draw_contents(), hidden(), draw::reduce_clip(), and set_dirty().

Referenced by expose(), and screen_location().

◆ 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 168 of file widget.cpp.

References enabled_, and queue_redraw().

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

◆ enabled()

bool gui::widget::enabled ( ) const

◆ expose()

bool gui::widget::expose ( const rect region)
overridevirtual

Called by draw_manager when it believes a redraw is necessary.

Implements gui2::top_level_drawable.

Definition at line 221 of file widget.cpp.

References clip_, clip_rect_, draw(), hidden(), rect::overlaps(), and rect_.

◆ focus()

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

◆ free_mouse_lock()

void gui::widget::free_mouse_lock ( )
protected

Definition at line 56 of file widget.cpp.

References mouse_lock_, and mouse_lock_local_.

Referenced by handle_event(), and ~widget().

◆ handle_event()

virtual void gui::widget::handle_event ( const SDL_Event &  )
inlineoverrideprotectedvirtual

◆ height()

int gui::widget::height ( ) const

◆ hidden()

bool gui::widget::hidden ( ) const

◆ hide()

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

◆ id()

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

◆ layout()

void gui::widget::layout ( )
overridevirtual

◆ location()

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

◆ mouse_locked()

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

◆ process_help_string()

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

Reimplemented from events::sdl_handler.

Reimplemented in gui::menu.

Definition at line 257 of file widget.cpp.

References font::clear_help_string(), rect::contains(), has_help_, help_text_, hidden(), rect_, and font::set_help_string().

◆ process_tooltip_string()

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

Reimplemented from events::sdl_handler.

Definition at line 271 of file widget.cpp.

References tooltips::add_tooltip(), rect::contains(), hidden(), rect_, and tooltip_text_.

◆ queue_redraw() [1/2]

void gui::widget::queue_redraw ( )

◆ queue_redraw() [2/2]

void gui::widget::queue_redraw ( const rect r)

Indicate that a specific region of the screen should be redrawn.

This is in absolute drawing coordinates, and is not clipped.

Definition at line 211 of file widget.cpp.

References draw_manager::invalidate_region().

◆ screen_location()

virtual rect gui::widget::screen_location ( )
inlineoverridevirtual

The current draw location of the display, on the screen.

Implements gui2::top_level_drawable.

Definition at line 82 of file widget.hpp.

References draw(), and location().

◆ set_clip_rect()

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

Definition at line 155 of file widget.cpp.

References clip_, clip_rect_, queue_redraw(), and draw::rect().

◆ set_dirty()

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

◆ 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 247 of file widget.cpp.

References help_text_.

◆ set_id()

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

Definition at line 204 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 94 of file widget.cpp.

References rect_, and set_location().

◆ set_measurements()

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

Definition at line 109 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_width()

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

◆ update_location()

virtual void gui::widget::update_location ( const SDL_Rect &  )
inlineprotectedvirtual

Reimplemented in gui::textbox, help::help_browser, and gui::scrollarea.

Definition at line 91 of file widget.hpp.

Referenced by set_location().

◆ width()

int gui::widget::width ( ) const

Friends And Related Function Documentation

◆ dialog

friend class dialog
friend

Definition at line 117 of file widget.hpp.

Member Data Documentation

◆ clip_

bool gui::widget::clip_
private

Definition at line 106 of file widget.hpp.

Referenced by draw(), expose(), hidden(), and set_clip_rect().

◆ clip_rect_

rect gui::widget::clip_rect_
private

Definition at line 107 of file widget.hpp.

Referenced by draw(), expose(), hidden(), and set_clip_rect().

◆ enabled_

bool gui::widget::enabled_
private

Definition at line 105 of file widget.hpp.

Referenced by enable(), and enabled().

◆ focus_

bool gui::widget::focus_
protected

◆ has_help_

bool gui::widget::has_help_
private

Definition at line 111 of file widget.hpp.

Referenced by process_help_string().

◆ help_text_

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

Definition at line 109 of file widget.hpp.

Referenced by process_help_string(), and set_help_string().

◆ id_

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

Definition at line 112 of file widget.hpp.

Referenced by id(), and set_id().

◆ mouse_lock_

bool gui::widget::mouse_lock_ = false
staticprivate

Definition at line 115 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 114 of file widget.hpp.

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

◆ rect_

rect gui::widget::rect_
private

◆ state_

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

◆ tooltip_text_

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

Definition at line 110 of file widget.hpp.

Referenced by process_tooltip_string(), and set_tooltip_string().


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