The Battle for Wesnoth  1.19.4+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_tooltip_string (const std::string &str)
 
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 tooltip_text_
 
std::string id_
 
bool mouse_lock_local_
 

Static Private Attributes

static bool mouse_lock_ = false
 

Friends

class dialog
 

Detailed Description

Definition at line 27 of file widget.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
UNINIT 
HIDDEN 
DIRTY 
DRAWN 

Definition at line 101 of file widget.hpp.

Constructor & Destructor Documentation

◆ widget()

gui::widget::widget ( 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 free_mouse_lock(), hidden(), and queue_redraw().

Member Function Documentation

◆ aquire_mouse_lock()

void gui::widget::aquire_mouse_lock ( )
protected

Definition at line 48 of file widget.cpp.

References mouse_lock_, and mouse_lock_local_.

◆ dirty()

bool gui::widget::dirty ( ) const

Definition at line 193 of file widget.cpp.

References DIRTY, and state_.

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

◆ draw()

void gui::widget::draw ( )
private

Definition at line 230 of file widget.cpp.

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

Referenced by expose().

◆ draw_contents()

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

◆ enable()

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

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

Definition at line 167 of file widget.cpp.

References enabled_, and queue_redraw().

Referenced by gui::button::enable(), and gui::tristate_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 220 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 55 of file widget.cpp.

References mouse_lock_, and mouse_lock_local_.

Referenced by ~widget().

◆ handle_event()

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

◆ height()

int gui::widget::height ( ) const

Definition at line 118 of file widget.cpp.

References rect_.

Referenced by gui::scrollarea::handle_event().

◆ 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_tooltip_string()

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

Reimplemented from events::sdl_handler.

Definition at line 251 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 210 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 79 of file widget.hpp.

References location().

◆ set_clip_rect()

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

Definition at line 154 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)

Definition at line 103 of file widget.cpp.

References h, rect_, and set_location().

Referenced by gui::button::calculate_size().

◆ set_id()

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

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

References rect_, and set_location().

◆ set_measurements()

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

Definition at line 108 of file widget.cpp.

References h, rect_, set_location(), and w.

Referenced by gui::textbox::textbox().

◆ set_tooltip_string()

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

◆ set_width()

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

Definition at line 98 of file widget.cpp.

References rect_, set_location(), and w.

Referenced by gui::button::calculate_size(), and gui::scrollbar::scrollbar().

◆ update_location()

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

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

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

Member Data Documentation

◆ clip_

bool gui::widget::clip_
private

Definition at line 103 of file widget.hpp.

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

◆ clip_rect_

rect gui::widget::clip_rect_
private

Definition at line 104 of file widget.hpp.

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

◆ enabled_

bool gui::widget::enabled_
private

Definition at line 102 of file widget.hpp.

Referenced by enable(), and enabled().

◆ focus_

bool gui::widget::focus_
protected

Definition at line 91 of file widget.hpp.

Referenced by focus(), gui::textbox::requires_event_focus(), and set_focus().

◆ id_

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

Definition at line 107 of file widget.hpp.

Referenced by id(), and set_id().

◆ mouse_lock_

bool gui::widget::mouse_lock_ = false
staticprivate

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

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

◆ rect_

rect gui::widget::rect_
private

◆ 

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

◆ tooltip_text_

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

Definition at line 106 of file widget.hpp.

Referenced by process_tooltip_string(), and set_tooltip_string().


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