The Battle for Wesnoth  1.13.10+dev
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
gui2::widget Class Referenceabstract

Base class for all widgets. More...

#include <widget.hpp>

Inheritance diagram for gui2::widget:
Inheritance graph

Public Types

enum  visibility { visibility::visible, visibility::hidden, visibility::invisible }
 Visibility settings done by the user. More...
 
enum  redraw_action { redraw_action::full, redraw_action::partly, redraw_action::none }
 Visibility set by the engine. More...
 
- Public Types inherited from gui2::event::dispatcher
enum  event_queue_type { pre = 1, child = 2, post = 4 }
 
enum  queue_position {
  front_pre_child, back_pre_child, front_child, back_child,
  front_post_child, back_post_child
}
 The position where to add a new callback in the signal handler. More...
 
enum  mouse_behavior { all, hit, none }
 The behavior of the mouse events. More...
 

Public Member Functions

 widget (const widget &)=delete
 
widgetoperator= (const widget &)=delete
 
 widget ()
 
 widget (const builder_widget &builder)
 Constructor. More...
 
virtual ~widget () override
 
void set_id (const std::string &id)
 
const std::string & id () const
 
windowget_window ()
 Get the parent window. More...
 
const windowget_window () const
 The constant version of get_window. More...
 
gridget_parent_grid ()
 Get the parent grid. More...
 
dialogs::modal_dialogdialog ()
 Returns the top-level dialog. More...
 
void set_parent (widget *parent)
 
widgetparent ()
 
virtual void layout_initialize (const bool full_initialization)
 How the layout engine works. More...
 
virtual void request_reduce_width (const unsigned maximum_width)=0
 Tries to reduce the width of a widget. More...
 
virtual void demand_reduce_width (const unsigned maximum_width)
 Tries to reduce the width of a widget. More...
 
virtual void request_reduce_height (const unsigned maximum_height)
 Tries to reduce the height of a widget. More...
 
virtual void demand_reduce_height (const unsigned maximum_height)
 Tries to reduce the height of a widget. More...
 
point get_best_size () const
 Gets the best size for the widget. More...
 
virtual bool can_mouse_focus () const
 Whether the mouse move/click event go 'through' this widget. More...
 
virtual bool can_wrap () const
 Can the widget wrap. More...
 
virtual void set_origin (const point &origin)
 Sets the origin of the widget. More...
 
virtual void set_size (const point &size)
 Sets the size of the widget. More...
 
virtual void place (const point &origin, const point &size)
 Places the widget. More...
 
virtual void move (const int x_offset, const int y_offset)
 Moves a widget. More...
 
virtual void set_horizontal_alignment (const std::string &alignment)
 Sets the horizontal alignment of the widget within its parent grid. More...
 
virtual void set_vertical_alignment (const std::string &alignment)
 Sets the horizontal alignment of the widget within its parent grid. More...
 
virtual void layout_children ()
 Allows a widget to update its children. More...
 
point get_origin () const
 Returns the screen origin of the widget. More...
 
point get_size () const
 Returns the size of the widget. More...
 
SDL_Rect get_rectangle () const
 Gets the bounding rectangle of the widget on the screen. More...
 
int get_x () const
 
int get_y () const
 
unsigned get_width () const
 
unsigned get_height () const
 
void set_linked_group (const std::string &linked_group)
 
SDL_Rect calculate_blitting_rectangle (const int x_offset, const int y_offset)
 Calculates the blitting rectangle of the widget. More...
 
SDL_Rect calculate_clipping_rectangle (const int x_offset, const int y_offset)
 Calculates the clipping rectangle of the widget. More...
 
void draw_background (surface &frame_buffer, int x_offset, int y_offset)
 Draws the background of a widget. More...
 
void draw_children (surface &frame_buffer, int x_offset, int y_offset)
 Draws the children of a widget. More...
 
void draw_foreground (surface &frame_buffer, int x_offset, int y_offset)
 Draws the foreground of the widget. More...
 
void populate_dirty_list (window &caller, std::vector< widget * > &call_stack)
 Adds a widget to the dirty list if it is dirty. More...
 
SDL_Rect get_dirty_rectangle () const
 Gets the dirty rectangle of the widget. More...
 
virtual void set_visible_rectangle (const SDL_Rect &rectangle)
 Sets the visible rectangle for a widget. More...
 
void set_is_dirty (const bool is_dirty)
 
bool get_is_dirty () const
 
void set_visible (const visibility visible)
 
visibility get_visible () const
 
redraw_action get_drawing_action () const
 
void set_debug_border_mode (const unsigned debug_border_mode)
 
void set_debug_border_color (const color_t debug_border_color)
 
virtual widgetfind_at (const point &coordinate, const bool must_be_active)
 Returns the widget at the wanted coordinates. More...
 
virtual const widgetfind_at (const point &coordinate, const bool must_be_active) const
 The constant version of find_at. More...
 
virtual widgetfind (const std::string &id, const bool must_be_active)
 Returns a widget with the wanted id. More...
 
virtual const widgetfind (const std::string &id, const bool must_be_active) const
 The constant version of find. More...
 
virtual bool has_widget (const widget &widget) const
 Does the widget contain the widget. More...
 
virtual bool disable_click_dismiss () const =0
 Does the widget disable easy close? More...
 
virtual iteration::walker_basecreate_walker ()=0
 Creates a new walker object on the heap. More...
 
- Public Member Functions inherited from gui2::event_executor
 event_executor ()
 
virtual ~event_executor ()
 
void set_wants_mouse_hover (const bool hover=true)
 
bool wants_mouse_hover () const
 
void set_wants_mouse_left_double_click (const bool click=true)
 
bool wants_mouse_left_double_click () const
 
void set_wants_mouse_middle_double_click (const bool click=true)
 
bool wants_mouse_middle_double_click () const
 
event_executorset_wants_mouse_right_double_click (const bool click=true)
 
bool wants_mouse_right_double_click () const
 
- Public Member Functions inherited from gui2::event::dispatcher
 dispatcher ()
 
virtual ~dispatcher ()
 
void connect ()
 Connects the dispatcher to the event handler. More...
 
bool has_event (const ui_event event, const event_queue_type event_type)
 
bool fire (const ui_event event, widget &target)
 Fires an event which has no extra parameters. More...
 
bool fire (const ui_event event, widget &target, const point &coordinate)
 Fires an event which takes a coordinate parameter. More...
 
bool fire (const ui_event event, widget &target, const SDL_Keycode key, const SDL_Keymod modifier, const utf8::string &unicode)
 Fires an event which takes keyboard parameters. More...
 
bool fire (const ui_event event, widget &target, const point &pos, const point &distance)
 Fires an event which takes touch parameters. More...
 
bool fire (const ui_event event, widget &target, void *)
 Fires an event which takes notification parameters. More...
 
bool fire (const ui_event event, widget &target, message &msg)
 Fires an event which takes message parameters. More...
 
bool fire (const ui_event event, widget &target, const SDL_Event &sdlevent)
 Fires an event that's a raw SDL event. More...
 
bool fire (const ui_event event, widget &target, const std::string &text, int32_t start, int32_t len)
 Fires an event which takes text input parameters. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event, E >::value > 
connect_signal (const signal_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event, E >::value > 
disconnect_signal (const signal_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_mouse, E >::value > 
connect_signal (const signal_mouse_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event_mouse. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_mouse, E >::value > 
disconnect_signal (const signal_mouse_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event_mouse. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_keyboard, E >
::value > 
connect_signal (const signal_keyboard_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event_keyboard. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_keyboard, E >
::value > 
disconnect_signal (const signal_keyboard_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event_keyboard. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_touch, E >::value > 
connect_signal (const signal_touch_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event_touch. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_touch, E >::value > 
disconnect_signal (const signal_touch_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event_touch. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_notification, E >
::value > 
connect_signal (const signal_notification_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event_notification. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_notification, E >
::value > 
disconnect_signal (const signal_notification_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event_notification. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_message, E >
::value > 
connect_signal (const signal_message_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_event_message. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_message, E >
::value > 
disconnect_signal (const signal_message_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_event_message. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_raw_event, E >
::value > 
connect_signal (const signal_raw_event_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_raw_event. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_raw_event, E >
::value > 
disconnect_signal (const signal_raw_event_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_raw_event. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_text_input, E >
::value > 
connect_signal (const signal_text_input_function &signal, const queue_position position=back_child)
 Connect a signal for callback in set_text_input. More...
 
template<ui_event E>
utils::enable_if_t< has_key
< set_event_text_input, E >
::value > 
disconnect_signal (const signal_text_input_function &signal, const queue_position position=back_child)
 Disconnect a signal for callback in set_text_input. More...
 
void capture_mouse ()
 Captures the mouse. More...
 
void release_mouse ()
 Releases the mouse capture. More...
 
void set_mouse_behavior (const mouse_behavior mouse_behavior)
 
mouse_behavior get_mouse_behavior () const
 
void set_want_keyboard_input (const bool want_keyboard_input)
 
bool get_want_keyboard_input () const
 
void register_hotkey (const hotkey::HOTKEY_COMMAND id, const hotkey_function &function)
 Registers a hotkey. More...
 
bool execute_hotkey (const hotkey::HOTKEY_COMMAND id)
 Executes a hotkey. More...
 

Protected Member Functions

void set_layout_size (const point &size)
 
const pointlayout_size () const
 
void clear_layout_size ()
 Throws away layout_size_. More...
 

Private Member Functions

virtual point calculate_best_size () const =0
 Calculates the best size. More...
 
virtual void impl_draw_background (surface &)
 See draw_background. More...
 
virtual void impl_draw_background (surface &, int, int)
 
virtual void impl_draw_children (surface &, int, int)
 See draw_children. More...
 
virtual void impl_draw_foreground (surface &, int, int)
 See draw_foreground. More...
 
virtual void child_populate_dirty_list (window &caller, const std::vector< widget * > &call_stack)
 Tries to add all children of a container to the dirty list. More...
 
void draw_debug_border ()
 
void draw_debug_border (int x_offset, int y_offset)
 
virtual bool is_at (const point &coordinate) const override
 See event::dispatcher::is_at. More...
 
bool is_at (const point &coordinate, const bool must_be_active) const
 Is the coordinate inside our area. More...
 
bool recursive_is_visible (const widget *widget, const bool must_be_active) const
 Is the widget and every single one of its parents visible? More...
 

Private Attributes

std::string id_
 The id is the unique name of the widget in a certain context. More...
 
widgetparent_
 The parent widget. More...
 
int x_
 The x-coordinate of the widget on the screen. More...
 
int y_
 The y-coordinate of the widget on the screen. More...
 
unsigned width_
 The width of the widget. More...
 
unsigned height_
 The height of the widget. More...
 
point layout_size_
 The best size for the widget. More...
 
std::string linked_group_
 The linked group the widget belongs to. More...
 
bool is_dirty_
 Is the widget dirty? More...
 
visibility visible_
 Field for the status of the visibility. More...
 
redraw_action redraw_action_
 Field for the action to do on a drawing request. More...
 
SDL_Rect clipping_rectangle_
 The clipping rectangle if a widget is partly visible. More...
 
unsigned debug_border_mode_
 Mode for drawing the debug border. More...
 
color_t debug_border_color_
 The color for the debug border. More...
 

Friends

class debug_layout_graph
 
class window
 

Detailed Description

Base class for all widgets.

From this abstract all other widgets should derive. It contains the minimal info needed for a real widget and some pure abstract functions which need to be implemented by classes deriving from this class.

Definition at line 48 of file widget.hpp.

Member Enumeration Documentation

Visibility set by the engine.

This state only will be used if visible_ is visibility::visible depending on this state the widget might not be visible after all.

Enumerator
full 

The widget is fully visible.

The widget should be drawn if dirty_ is true. The entire widget's rectangle should be redrawn.

partly 

The widget is partly visible.

The should be drawn if dirty_ is true. The rectangle to redraw in determined by clipping_rectangle_

none 

The widget is not visible.

The widget should not be drawn if dirty_ is true.

Definition at line 103 of file widget.hpp.

Visibility settings done by the user.

Enumerator
visible 

The user sets the widget visible, that means:

  • The widget is visible.
  • find_at always 'sees' the widget (the active flag is tested later).
  • The widget (if active) handles events (and sends events to its children).
  • The widget is drawn (and sends the call to populate_dirty_list to children).
hidden 

The user sets the widget hidden, that means:

  • The widget is invisible but keeps its size.
  • find_at 'sees' the widget if active is false.
  • The widget doesn't handle events (and doesn't send events to its children).
  • The widget doesn't add itself window::dirty_list_ when populate_dirty_list is called (nor does it send the request to its children).
invisible 

The user set the widget invisible, that means:

  • The widget is invisible and its grid cell has size 0,0.
  • find_at never 'sees' the widget.
  • The widget doesn't handle events (and doesn't send events to its children).
  • The widget doesn't add itself window::dirty_list_ when populate_dirty_list is called (nor does it send the request to its children).

Definition at line 58 of file widget.hpp.

Constructor & Destructor Documentation

gui2::widget::widget ( const widget )
delete
gui2::widget::widget ( )
gui2::widget::widget ( const builder_widget builder)
explicit

Constructor.

Parameters
builderThe builder object with the settings for the object.

Definition at line 52 of file widget.cpp.

References DBG_GUI_LF.

gui2::widget::~widget ( )
overridevirtual

Member Function Documentation

virtual point gui2::widget::calculate_best_size ( ) const
privatepure virtual

Calculates the best size.

This function calculates the best size and ignores the current values in the layout phase. Note containers can call the get_best_size() of their children since it is meant to update itself.

Returns
The best size for the widget.
Return values
0,0The best size is 0,0.

Implemented in gui2::policy::placement::independent, gui2::policy::placement::table, gui2::policy::placement::vertical_list, gui2::generator_base, gui2::tree_view_node, gui2::grid, gui2::policy::placement::horizontal_list, gui2::matrix, gui2::styled_widget, gui2::pane, gui2::scrollbar_container, gui2::container_base, gui2::viewport, gui2::image, gui2::drawing, gui2::size_lock, gui2::spacer, and gui2::slider.

Referenced by get_best_size().

SDL_Rect gui2::widget::calculate_blitting_rectangle ( const int  x_offset,
const int  y_offset 
)

Calculates the blitting rectangle of the widget.

The blitting rectangle is the entire widget rectangle, but offsetted for drawing position.

Parameters
x_offsetThe offset in the x-direction when drawn.
y_offsetThe offset in the y-direction when drawn.
Returns
The drawing rectangle.

Definition at line 355 of file widget.cpp.

References get_rectangle().

Referenced by draw_debug_border(), gui2::panel::impl_draw_background(), gui2::minimap::impl_draw_background(), gui2::styled_widget::impl_draw_background(), and gui2::panel::impl_draw_foreground().

SDL_Rect gui2::widget::calculate_clipping_rectangle ( const int  x_offset,
const int  y_offset 
)

Calculates the clipping rectangle of the widget.

The clipping rectangle is used then the redraw_action_ is redraw_action::partly. Since the drawing can be offsetted it also needs offset paramters.

Parameters
x_offsetThe offset in the x-direction when drawn.
y_offsetThe offset in the y-direction when drawn.
Returns
The clipping rectangle.

Definition at line 364 of file widget.cpp.

References clipping_rectangle_.

Referenced by draw_background(), draw_children(), draw_debug_border(), and draw_foreground().

virtual bool gui2::widget::can_mouse_focus ( ) const
inlinevirtual

Whether the mouse move/click event go 'through' this widget.

Reimplemented in gui2::grid, gui2::label, and gui2::image.

Definition at line 343 of file widget.hpp.

Referenced by gui2::event::mouse_motion::signal_handler_sdl_mouse_motion().

bool gui2::widget::can_wrap ( ) const
virtual

Can the widget wrap.

When a widget can wrap it can reduce its width by increasing its height. When a layout is too wide it should first try to wrap and if that fails it should check the vertical scrollbar status. After wrapping the height might (probably will) change so the layout engine needs to recalculate the height after wrapping.

Reimplemented in gui2::grid, gui2::scrollbar_container, gui2::container_base, gui2::scroll_label, and gui2::label.

Definition at line 219 of file widget.cpp.

Referenced by gui2::container_base::can_wrap(), gui2::grid::can_wrap(), gui2::styled_widget::get_best_text_size(), gui2::styled_widget::get_text_ellipse_mode(), gui2::styled_widget::request_reduce_width(), and gui2::text_box::update_canvas().

void gui2::widget::child_populate_dirty_list ( window caller,
const std::vector< widget * > &  call_stack 
)
privatevirtual

Tries to add all children of a container to the dirty list.

Note
The function is private since everybody should call populate_dirty_list instead.
Parameters
callerThe parent window, if dirty it should register itself to this window.
call_stackThe call-stack of widgets traversed to reach this function.

Reimplemented in gui2::scrollbar_container, gui2::generator_base, gui2::grid, gui2::listbox, gui2::matrix, gui2::container_base, gui2::pane, gui2::tree_view, and gui2::viewport.

Definition at line 443 of file widget.cpp.

Referenced by populate_dirty_list().

void gui2::widget::clear_layout_size ( )
inlineprotected

Throws away layout_size_.

Use with care: this function does not recurse to child widgets.

See Layout algorithm for more information.

Definition at line 469 of file widget.hpp.

References set_layout_size().

Referenced by gui2::container_base::container_base().

virtual iteration::walker_base* gui2::widget::create_walker ( )
pure virtual

Creates a new walker object on the heap.

Implemented in gui2::grid, gui2::matrix, gui2::container_base, gui2::tree_view_node, gui2::pane, gui2::styled_widget, and gui2::viewport.

void gui2::widget::demand_reduce_height ( const unsigned  maximum_height)
virtual

Tries to reduce the height of a widget.

This function does it more aggressively and should only be used when using scrollbars failed.

Todo:
Make pure virtual.

See Layout algorithm for more information.

Parameters
maximum_heightThe wanted maximum height.

Reimplemented in gui2::grid, and gui2::container_base.

Definition at line 191 of file widget.cpp.

void gui2::widget::demand_reduce_width ( const unsigned  maximum_width)
virtual

Tries to reduce the width of a widget.

This function does it more aggressively and should only be used when using scrollbars and wrapping failed.

Todo:
Make pure virtual.

See Layout algorithm for more information.

Parameters
maximum_widthThe wanted maximum width.

Reimplemented in gui2::grid, and gui2::container_base.

Definition at line 181 of file widget.cpp.

dialogs::modal_dialog * gui2::widget::dialog ( )

Returns the top-level dialog.

A window is most of the time created by a dialog, this function returns that dialog.

Deprecated:
The function was used to install callbacks to member functions of the dialog. Once all widgets are converted to signals this function will be removed.
Returns
The top-level dialog.
Return values
nullptrNo top-level window or the top-level window is not owned by a dialog.

Definition at line 152 of file widget.cpp.

References gui2::window::dialog(), and get_window().

Referenced by gui2::dialogs::dialog_callback().

virtual bool gui2::widget::disable_click_dismiss ( ) const
pure virtual
void gui2::widget::draw_background ( surface frame_buffer,
int  x_offset,
int  y_offset 
)

Draws the background of a widget.

Derived should override impl_draw_background instead of changing this function.

Parameters
frame_bufferThe surface to draw upon.
x_offsetThe offset in the x-direction in the frame_buffer to draw.
y_offsetThe offset in the y-direction in the frame_buffer to draw.

Definition at line 373 of file widget.cpp.

References calculate_clipping_rectangle(), draw_debug_border(), impl_draw_background(), partly, redraw_action_, visible, and visible_.

Referenced by gui2::viewport::impl_draw_children(), and gui2::grid::impl_draw_children().

void gui2::widget::draw_children ( surface frame_buffer,
int  x_offset,
int  y_offset 
)

Draws the children of a widget.

Containers should draw their children when they get this request.

Derived should override impl_draw_children instead of changing this function.

Parameters
frame_bufferThe surface to draw upon.
x_offsetThe offset in the x-direction in the frame_buffer to draw.
y_offsetThe offset in the y-direction in the frame_buffer to draw.

Definition at line 390 of file widget.cpp.

References calculate_clipping_rectangle(), impl_draw_children(), partly, redraw_action_, visible, and visible_.

Referenced by gui2::viewport::impl_draw_children(), gui2::pane::impl_draw_children(), gui2::container_base::impl_draw_children(), gui2::matrix::impl_draw_children(), gui2::tree_view_node::impl_draw_children(), gui2::grid::impl_draw_children(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::impl_draw_children().

void gui2::widget::draw_debug_border ( )
private
void gui2::widget::draw_debug_border ( int  x_offset,
int  y_offset 
)
private
void gui2::widget::draw_foreground ( surface frame_buffer,
int  x_offset,
int  y_offset 
)

Draws the foreground of the widget.

Some widgets e.g. panel and window have a back and foreground layer this function requests the drawing of the foreground.

Derived should override impl_draw_foreground instead of changing this function.

Parameters
frame_bufferThe surface to draw upon.
x_offsetThe offset in the x-direction in the frame_buffer to draw.
y_offsetThe offset in the y-direction in the frame_buffer to draw.

Definition at line 405 of file widget.cpp.

References calculate_clipping_rectangle(), impl_draw_foreground(), partly, redraw_action_, visible, and visible_.

Referenced by gui2::viewport::impl_draw_children(), and gui2::grid::impl_draw_children().

widget * gui2::widget::find ( const std::string &  id,
const bool  must_be_active 
)
virtual

Returns a widget with the wanted id.

Note
Since the id might not be unique inside a container there is no guarantee which widget is returned.
Parameters
idThe id of the widget to find.
must_be_activeThe widget should be active, not all widgets have an active flag, those who don't ignore flag.
Returns
The widget with the id.
Return values
nullptrNo widget with the id found (or not active if must_be_active was set).

Reimplemented in gui2::policy::placement::independent, gui2::grid, gui2::window, gui2::styled_widget, gui2::stacked_widget, gui2::tree_view_node, gui2::matrix, gui2::scrollbar_container, gui2::container_base, and gui2::viewport.

Definition at line 587 of file widget.cpp.

References id_.

Referenced by gui2::implementation::builder_instance::build(), gui2::grid_implementation::find(), gui2::matrix::find(), gui2::tree_view_node::find(), gui2::styled_widget::find(), find_widget(), and gui2::dialogs::lobby_player_info::pre_show().

const widget * gui2::widget::find ( const std::string &  id,
const bool  must_be_active 
) const
virtual
widget * gui2::widget::find_at ( const point coordinate,
const bool  must_be_active 
)
virtual
const widget * gui2::widget::find_at ( const point coordinate,
const bool  must_be_active 
) const
virtual
point gui2::widget::get_best_size ( ) const

Gets the best size for the widget.

During the layout phase a best size will be determined, several stages might change the best size. This function will return the currently best size as determined during the layout phase.

Returns
The best size for the widget.
Return values
0,0The best size is 0,0.

Definition at line 196 of file widget.cpp.

References calculate_best_size(), gui2::window::get_linked_size(), get_window(), invisible, layout_size_, linked_group_, visible_, gui2::point::x, and gui2::point::y.

Referenced by gui2::tree_view_node::add_child(), gui2::viewport::calculate_best_size(), gui2::container_base::calculate_best_size(), gui2::scrollbar_container::calculate_best_size(), gui2::matrix::calculate_best_size(), gui2::policy::placement::horizontal_list::calculate_best_size(), gui2::tree_view_node::calculate_best_size(), gui2::policy::placement::vertical_list::calculate_best_size(), gui2::policy::placement::table::calculate_best_size(), gui2::policy::placement::independent::calculate_best_size(), gui2::tree_view_node::get_folded_size(), gui2::tree_view_node::get_unfolded_size(), gui2::window_implementation::layout(), gui2::window::layout(), gui2::window::layout_linked_widgets(), gui2::viewport::place(), gui2::size_lock::place(), gui2::policy::placement::horizontal_list::place(), gui2::tree_view_node::place(), gui2::policy::placement::vertical_list::place(), gui2::grid::child::place(), gui2::policy::placement::table::place(), gui2::pane::place_children(), gui2::pane::place_or_set_origin_children(), gui2::pane::prepare_placement(), gui2::container_base::reduce_height(), gui2::grid::reduce_height(), gui2::container_base::reduce_width(), gui2::grid::reduce_width(), gui2::grid::request_placement(), gui2::container_base::request_reduce_height(), gui2::scrollbar_container::request_reduce_height(), gui2::styled_widget::request_reduce_height(), gui2::grid::request_reduce_height(), gui2::container_base::request_reduce_width(), gui2::scrollbar_container::request_reduce_width(), gui2::styled_widget::request_reduce_width(), gui2::grid::request_reduce_width(), gui2::listbox::resize_content(), gui2::listbox::set_content_size(), and gui2::pane::signal_handler_request_placement().

SDL_Rect gui2::widget::get_dirty_rectangle ( ) const

Gets the dirty rectangle of the widget.

Depending on the redraw_action_ it returns the rectangle this widget dirties while redrawing.

Returns
The dirty rectangle.

Definition at line 450 of file widget.cpp.

References clipping_rectangle_, full, get_rectangle(), and redraw_action_.

widget::redraw_action gui2::widget::get_drawing_action ( ) const

Definition at line 511 of file widget.cpp.

References height_, none, redraw_action_, and width_.

Referenced by gui2::grid::impl_draw_children(), and populate_dirty_list().

unsigned gui2::widget::get_height ( ) const
bool gui2::widget::get_is_dirty ( ) const

Definition at line 474 of file widget.cpp.

References is_dirty_.

point gui2::widget::get_origin ( ) const
grid * gui2::widget::get_parent_grid ( )

Get the parent grid.

Returns
Pointer to parent grid.
Return values
nullptrNo parent grid found.

Definition at line 142 of file widget.cpp.

References parent_.

Referenced by set_horizontal_alignment(), and set_vertical_alignment().

SDL_Rect gui2::widget::get_rectangle ( ) const
point gui2::widget::get_size ( ) const
widget::visibility gui2::widget::get_visible ( ) const

Definition at line 506 of file widget.cpp.

References visible_.

Referenced by gui2::scrollbar_container::calculate_best_size(), gui2::scrollbar_container::content_resize_height(), gui2::scrollbar_container::content_resize_request(), gui2::scrollbar_container::content_resize_width(), gui2::styled_widget::disable_click_dismiss(), gui2::grid::disable_click_dismiss(), gui2::viewport::impl_draw_children(), gui2::pane::impl_draw_children(), gui2::container_base::impl_draw_children(), gui2::scrollbar_container::impl_draw_children(), gui2::grid::impl_draw_children(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::impl_draw_children(), gui2::viewport::layout_initialize(), gui2::pane::layout_initialize(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::layout_initialize(), gui2::grid::child::place(), gui2::pane::place_children(), gui2::pane::place_or_set_origin_children(), gui2::pane::prepare_placement(), gui2::listbox::remove_row(), gui2::scrollbar_container::request_reduce_height(), gui2::scrollbar_container::request_reduce_width(), gui2::listbox::resize_content(), gui2::pane::set_origin_children(), gui2::set_scrollbar_mode(), gui2::pane::signal_handler_request_placement(), gui2::scrollbar_container::signal_handler_sdl_wheel_down(), gui2::scrollbar_container::signal_handler_sdl_wheel_left(), gui2::scrollbar_container::signal_handler_sdl_wheel_right(), gui2::scrollbar_container::signal_handler_sdl_wheel_up(), and gui2::listbox::update_content_size().

unsigned gui2::widget::get_width ( ) const
window * gui2::widget::get_window ( )

Get the parent window.

Returns
Pointer to parent window.
Return values
nullptrNo parent window found.

Definition at line 114 of file widget.cpp.

References parent_.

Referenced by gui2::dialogs::preferences_dialog::add_hotkey_callback(), gui2::addon_list::add_list_to_keyboard_chain(), gui2::scrollbar_container::content_resize_height(), gui2::scrollbar_container::content_resize_request(), gui2::scrollbar_container::content_resize_width(), gui2::text_box_base::cursor_timer_callback(), dialog(), gui2::dialogs::dialog_callback(), gui2::dialogs::game_load::filter_text_changed(), gui2::dialogs::unit_recall::filter_text_changed(), gui2::dialogs::unit_create::filter_text_changed(), gui2::policy::placement::horizontal_list::find_at(), gui2::policy::placement::vertical_list::find_at(), gui2::policy::placement::table::find_at(), gui2::policy::placement::independent::find_at(), get_best_size(), gui2::container_base::inject_linked_groups(), layout_initialize(), gui2::listbox::list_item_clicked(), gui2::dialogs::addon_manager::on_filtertext_changed(), gui2::unit_preview_pane::profile_button_callback(), gui2::scrollbar_base::recalculate(), gui2::grid::request_placement(), gui2::listbox::set_row_shown(), gui2::toggle_button::set_value(), gui2::toggle_panel::set_value(), set_visible(), gui2::button::signal_handler_left_button_click(), gui2::label::signal_handler_left_button_click(), gui2::menu_button::signal_handler_left_button_click(), gui2::multimenu_button::signal_handler_left_button_click(), gui2::toggle_button::signal_handler_left_button_double_click(), gui2::toggle_panel::signal_handler_left_button_double_click(), gui2::button::signal_handler_left_button_down(), gui2::scroll_label::signal_handler_left_button_down(), gui2::repeating_button::signal_handler_left_button_down(), gui2::menu_button::signal_handler_left_button_down(), gui2::tree_view::signal_handler_left_button_down(), gui2::multimenu_button::signal_handler_left_button_down(), gui2::text_box::signal_handler_left_button_down(), gui2::scrollbar_base::signal_handler_left_button_down(), gui2::slider::signal_handler_left_button_up(), gui2::scrollbar_base::signal_handler_left_button_up(), gui2::pane::signal_handler_request_placement(), gui2::label::signal_handler_right_button_click(), gui2::window::window_instance(), and ~widget().

const window * gui2::widget::get_window ( ) const

The constant version of get_window.

Definition at line 128 of file widget.cpp.

References parent_.

int gui2::widget::get_x ( ) const
int gui2::widget::get_y ( ) const
bool gui2::widget::has_widget ( const widget widget) const
virtual

Does the widget contain the widget.

Widgets can be containers which have more widgets inside them, this function will traverse in those child widgets and tries to find the wanted widget.

Parameters
widgetPointer to the widget to find.
Returns
Whether or not the widget was found.

Reimplemented in gui2::grid, and gui2::container_base.

Definition at line 598 of file widget.cpp.

Referenced by gui2::container_base::has_widget(), and gui2::grid::has_widget().

const std::string & gui2::widget::id ( ) const
virtual void gui2::widget::impl_draw_background ( surface )
inlineprivatevirtual

See draw_background.

Definition at line 607 of file widget.hpp.

Referenced by draw_background().

virtual void gui2::widget::impl_draw_background ( surface ,
int  ,
int   
)
inlineprivatevirtual
virtual void gui2::widget::impl_draw_children ( surface ,
int  ,
int   
)
inlineprivatevirtual
virtual void gui2::widget::impl_draw_foreground ( surface ,
int  ,
int   
)
inlineprivatevirtual

See draw_foreground.

Reimplemented in gui2::styled_widget, gui2::toggle_panel, and gui2::panel.

Definition at line 628 of file widget.hpp.

Referenced by draw_foreground().

bool gui2::widget::is_at ( const point coordinate) const
overrideprivatevirtual

See event::dispatcher::is_at.

Implements gui2::event::dispatcher.

Definition at line 603 of file widget.cpp.

Referenced by find_at().

bool gui2::widget::is_at ( const point coordinate,
const bool  must_be_active 
) const
private

Is the coordinate inside our area.

Helper for find_at so also looks at our visibility.

Parameters
coordinateThe coordinate which should be inside the widget.
must_be_activeThe widget should be active, not all widgets have an active flag, those who don't ignore flag.
Returns
Status.

Definition at line 622 of file widget.cpp.

References height_, recursive_is_visible(), width_, gui2::point::x, x_, gui2::point::y, and y_.

void gui2::widget::layout_children ( )
virtual

Allows a widget to update its children.

Before the window is populating the dirty list the widgets can update their content, which allows delayed initialization. This delayed initialization is only allowed if the widget resizes itself, not when being placed.

Reimplemented in gui2::scrollbar_container, gui2::grid, gui2::listbox, gui2::matrix, gui2::container_base, gui2::tree_view, gui2::size_lock, and gui2::stacked_widget.

Definition at line 298 of file widget.cpp.

Referenced by gui2::size_lock::layout_children(), and gui2::grid::layout_children().

void gui2::widget::layout_initialize ( const bool  full_initialization)
virtual

How the layout engine works.

Every widget has a member layout_size_ which holds the best size in the current layout phase. When the windows starts the layout phase it calls layout_initialize which resets this value.

Every widget has two function to get the best size. get_best_size tests whether layout_size_ is set and if so returns that value otherwise it calls calculate_best_size so the size can be updated.

During the layout phase some functions can modify layout_size_ so the next call to get_best_size returns the currently best size. This means that after the layout phase get_best_size still returns this value. Initialises the layout phase.

Clears the initial best size for the widgets.

See Layout algorithm for more information.

Parameters
full_initializationFor widgets with scrollbars it hides them unless the mode is scrollbar_mode::ALWAYS_VISIBLE. For other widgets this flag is a NOP.

Reimplemented in gui2::generator_base, gui2::tree_view_node, gui2::grid, gui2::styled_widget, gui2::matrix, gui2::scrollbar_container, gui2::pane, gui2::container_base, and gui2::viewport.

Definition at line 170 of file widget.cpp.

References gui2::window::add_linked_widget(), get_window(), invisible, layout_size_, linked_group_, and visible_.

Referenced by gui2::viewport::layout_initialize(), gui2::pane::layout_initialize(), gui2::styled_widget::layout_initialize(), gui2::grid::layout_initialize(), and gui2::tree_view_node::layout_initialize().

const point & gui2::widget::layout_size ( ) const
protected

Definition at line 343 of file widget.cpp.

References layout_size_.

Referenced by gui2::tree_view_node::add_child().

void gui2::widget::move ( const int  x_offset,
const int  y_offset 
)
virtual

Moves a widget.

This function can be used to move the widget without dirtying it.

Todo:
Implement the function to all derived classes.
Parameters
x_offsetThe amount of pixels to move the widget in the x-direction.
y_offsetThe amount of pixels to move the widget in the y-direction.

Definition at line 266 of file widget.cpp.

References x_, and y_.

widget& gui2::widget::operator= ( const widget )
delete
widget * gui2::widget::parent ( )
void gui2::widget::place ( const point origin,
const point size 
)
virtual
void gui2::widget::populate_dirty_list ( window caller,
std::vector< widget * > &  call_stack 
)

Adds a widget to the dirty list if it is dirty.

See window::dirty_list_ for more information regarding the dirty list.

If the widget is not dirty and has children it should add itself to the call_stack and call child_populate_dirty_list with the new call_stack.

Parameters
callerThe parent window, if dirty it should register itself to this window.
call_stackThe call-stack of widgets traversed to reach this function.

Definition at line 420 of file widget.cpp.

References gui2::window::add_to_dirty_list(), child_populate_dirty_list(), get_drawing_action(), is_dirty_, none, visible, and visible_.

Referenced by gui2::viewport::child_populate_dirty_list(), gui2::pane::child_populate_dirty_list(), gui2::container_base::child_populate_dirty_list(), gui2::matrix::child_populate_dirty_list(), gui2::listbox::child_populate_dirty_list(), gui2::grid::child_populate_dirty_list(), gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::child_populate_dirty_list(), gui2::window::draw(), and gui2::tree_view_node::impl_populate_dirty_list().

bool gui2::widget::recursive_is_visible ( const widget widget,
const bool  must_be_active 
) const
private

Is the widget and every single one of its parents visible?

Parameters
widgetWidget where to start the check.
must_be_activeThe widget should be active, not all widgets have an active flag, those who don't ignore flag.
Returns
Status.

Definition at line 608 of file widget.cpp.

References hidden, invisible, parent_, and visible_.

Referenced by is_at().

void gui2::widget::request_reduce_height ( const unsigned  maximum_height)
virtual

Tries to reduce the height of a widget.

This function tries to do it 'friendly' and only use scrollbars.

Todo:
Make pure virtual.

See Layout algorithm for more information.

Parameters
maximum_heightThe wanted maximum height.

Reimplemented in gui2::policy::placement::independent, gui2::policy::placement::table, gui2::policy::placement::vertical_list, gui2::generator_base, gui2::grid, gui2::policy::placement::horizontal_list, gui2::styled_widget, gui2::scrollbar_container, gui2::container_base, gui2::drawing, and gui2::spacer.

Definition at line 186 of file widget.cpp.

virtual void gui2::widget::request_reduce_width ( const unsigned  maximum_width)
pure virtual

Tries to reduce the width of a widget.

This function tries to do it 'friendly' and only use scrollbars or tries to wrap the widget.

See Layout algorithm for more information.

Parameters
maximum_widthThe wanted maximum width.

Implemented in gui2::policy::placement::independent, gui2::policy::placement::table, gui2::policy::placement::vertical_list, gui2::generator_base, gui2::tree_view_node, gui2::grid, gui2::policy::placement::horizontal_list, gui2::styled_widget, gui2::matrix, gui2::scrollbar_container, gui2::pane, gui2::container_base, gui2::viewport, gui2::drawing, and gui2::spacer.

void gui2::widget::set_debug_border_color ( const color_t  debug_border_color)

Definition at line 522 of file widget.cpp.

References debug_border_color_.

void gui2::widget::set_debug_border_mode ( const unsigned  debug_border_mode)

Definition at line 517 of file widget.cpp.

References debug_border_mode_.

void gui2::widget::set_horizontal_alignment ( const std::string &  alignment)
virtual

Sets the horizontal alignment of the widget within its parent grid.

Parameters
alignmentThe new alignment.

Definition at line 272 of file widget.cpp.

References gui2::implementation::get_h_align(), get_parent_grid(), gui2::grid::HORIZONTAL_MASK, and gui2::grid::set_child_alignment().

void gui2::widget::set_id ( const std::string &  id)
void gui2::widget::set_is_dirty ( const bool  is_dirty)

Definition at line 469 of file widget.cpp.

References is_dirty_.

Referenced by gui2::text_box_base::cursor_timer_callback(), gui2::event::sdl_event_handler::disconnect(), gui2::event::sdl_event_handler::draw(), gui2::dialogs::outro::draw_callback(), gui2::dialogs::story_viewer::draw_floating_image(), gui2::text_box_base::handle_editing(), gui2::text_box::handle_mouse_selection(), gui2::viewport::impl_draw_children(), gui2::grid::impl_draw_children(), gui2::dialogs::lua_interpreter::controller::input_keypress_callback(), gui2::text_box_base::insert_char(), lua_gui2::intf_set_dialog_canvas(), gui2::listbox::layout_children(), gui2::listbox::order_by(), gui2::text_box_base::paste_selection(), place(), gui2::tree_view::resize_content(), gui2::listbox::resize_content(), gui2::container_base::set_active(), gui2::slider::set_best_slider_length(), gui2::grid::set_column_grow_factor(), gui2::text_box_base::set_cursor(), gui2::styled_widget::set_label(), gui2::label::set_link_aware(), gui2::label::set_link_color(), gui2::minimap::set_map_data(), gui2::text_box_base::set_maximum_length(), gui2::progress_bar::set_percentage(), gui2::grid::set_row_grow_factor(), gui2::listbox::set_row_shown(), gui2::menu_button::set_selected(), gui2::text_box_base::set_selection_length(), gui2::text_box_base::set_selection_start(), set_size(), gui2::button::set_state(), gui2::repeating_button::set_state(), gui2::label::set_state(), gui2::toggle_button::set_state(), gui2::menu_button::set_state(), gui2::toggle_panel::set_state(), gui2::multimenu_button::set_state(), gui2::scrollbar_base::set_state(), gui2::text_box_base::set_state(), gui2::styled_widget::set_text_alignment(), gui2::label::set_text_alpha(), gui2::styled_widget::set_text_ellipse_mode(), gui2::styled_widget::set_use_markup(), gui2::toggle_button::set_value(), gui2::text_box_base::set_value(), gui2::toggle_panel::set_value(), gui2::menu_button::set_values(), gui2::multimenu_button::set_values(), gui2::window::set_variable(), set_visible(), gui2::toggle_button::update_canvas(), gui2::scrollbar_base::update_canvas(), gui2::listbox::update_content_size(), gui2::dialogs::debug_clock::update_time(), and gui2::dialogs::custom_tod::update_tod_display().

void gui2::widget::set_layout_size ( const point size)
protected
void gui2::widget::set_linked_group ( const std::string &  linked_group)

Definition at line 348 of file widget.cpp.

References linked_group_.

Referenced by gui2::builder_grid::build(), and gui2::styled_widget::set_members().

void gui2::widget::set_origin ( const point origin)
virtual

Sets the origin of the widget.

This function can be used to move the widget without dirtying it. The location is an absolute position, if a relative more is required use move.

Parameters
originThe new origin.

Reimplemented in gui2::policy::placement::independent, gui2::policy::placement::table, gui2::policy::placement::vertical_list, gui2::generator_base, gui2::tree_view_node, gui2::grid, gui2::policy::placement::horizontal_list, gui2::scrollbar_container, and gui2::container_base.

Definition at line 224 of file widget.cpp.

References gui2::point::x, x_, gui2::point::y, and y_.

Referenced by gui2::container_base::set_origin(), gui2::grid::set_origin(), gui2::tree_view_node::set_origin(), and gui2::generator< minimum_selection, maximum_selection, my_placement, select_action >::set_origin().

void gui2::widget::set_parent ( widget parent)
void gui2::widget::set_size ( const point size)
virtual

Sets the size of the widget.

This version is meant to resize a widget, since the origin isn't modified. This can be used if a widget needs to change its size and the layout will be fixed later.

Parameters
sizeThe size of the widget.

Definition at line 230 of file widget.cpp.

References height_, set_is_dirty(), width_, gui2::point::x, and gui2::point::y.

Referenced by gui2::tree_view_node::place(), gui2::tree_view::resize_content(), and gui2::listbox::resize_content().

void gui2::widget::set_vertical_alignment ( const std::string &  alignment)
virtual

Sets the horizontal alignment of the widget within its parent grid.

Parameters
alignmentThe new alignment.

Definition at line 285 of file widget.cpp.

References get_parent_grid(), gui2::implementation::get_v_align(), gui2::grid::set_child_alignment(), and gui2::grid::VERTICAL_MASK.

Referenced by gui2::dialogs::story_viewer::display_part().

void gui2::widget::set_visible ( const visibility  visible)

Definition at line 479 of file widget.cpp.

References gui2::event::dispatcher::fire(), get_size(), get_window(), gui2::window::invalidate_layout(), invisible, gui2::new_widgets, gui2::event::REQUEST_PLACEMENT, set_is_dirty(), visible, and visible_.

Referenced by gui2::chatbox::active_window_changed(), gui2::dialogs::mp_staging::add_side_node(), gui2::adjust_scrollbar_mode(), gui2::dialogs::gamestate_inspector::view::clear_stuff_list(), gui2::dialogs::story_viewer::display_part(), gui2::pane::filter(), gui2::chatbox::increment_waiting_messages(), gui2::chatbox::increment_waiting_whsipers(), gui2::dialogs::message_implementation::init_button(), lua_gui2::intf_set_dialog_visible(), gui2::window::layout(), gui2::scrollbar_container::layout_initialize(), gui2::dialogs::mp_staging::on_controller_select(), gui2::dialogs::preferences_dialog::post_build(), gui2::dialogs::transient_message::pre_show(), gui2::dialogs::mp_alerts_options::pre_show(), gui2::dialogs::lobby_player_info::pre_show(), gui2::dialogs::campaign_difficulty::pre_show(), gui2::dialogs::addon_manager::pre_show(), gui2::dialogs::wml_error::pre_show(), gui2::dialogs::game_version::pre_show(), gui2::dialogs::message::pre_show(), gui2::dialogs::wml_message_base::pre_show(), gui2::dialogs::file_dialog::pre_show(), gui2::scrollbar_container::request_reduce_height(), gui2::scrollbar_container::request_reduce_width(), gui2::chatbox::search_create_window(), gui2::policy::select_action::show::select(), gui2::addon_list::set_addons(), gui2::set_scrollbar_mode(), gui2::grid::swap_child(), gui2::tree_view_node::tree_view_node(), gui2::dialogs::gamestate_inspector::view::update(), and gui2::dialogs::mp_options_helper::update_status_label().

void gui2::widget::set_visible_rectangle ( const SDL_Rect &  rectangle)
virtual

Friends And Related Function Documentation

friend class debug_layout_graph
friend

Definition at line 50 of file widget.hpp.

friend class window
friend

Definition at line 51 of file widget.hpp.

Member Data Documentation

SDL_Rect gui2::widget::clipping_rectangle_
private

The clipping rectangle if a widget is partly visible.

Definition at line 726 of file widget.hpp.

Referenced by calculate_clipping_rectangle(), draw_debug_border(), get_dirty_rectangle(), and set_visible_rectangle().

color_t gui2::widget::debug_border_color_
private

The color for the debug border.

Definition at line 742 of file widget.hpp.

Referenced by draw_debug_border(), and set_debug_border_color().

unsigned gui2::widget::debug_border_mode_
private

Mode for drawing the debug border.

The debug border is a helper border to determine where a widget is placed. It is only intended for debugging purposes.

Possible values:

  • 0 no border
  • 1 single pixel border
  • 2 flood-filled rectangle

Definition at line 739 of file widget.hpp.

Referenced by draw_debug_border(), and set_debug_border_mode().

unsigned gui2::widget::height_
private

The height of the widget.

Definition at line 487 of file widget.hpp.

Referenced by get_drawing_action(), get_height(), get_size(), is_at(), place(), and set_size().

std::string gui2::widget::id_
private

The id is the unique name of the widget in a certain context.

This is needed for certain widgets so the engine knows which widget is which. E.g. it knows which button is pressed and thus which engine action is connected to the button. This doesn't mean that the id is unique in a window, e.g. a listbox can have the same id for every row.

Definition at line 169 of file widget.hpp.

Referenced by find(), id(), set_id(), and ~widget().

bool gui2::widget::is_dirty_
private

Is the widget dirty?

When a widget is dirty it needs to be redrawn at the next drawing cycle.

The top-level window will use populate_dirty_list and child_populate_dirty_list to find al dirty widgets, so the widget doesn't need to inform its parent regarding it being marked dirty.

Definition at line 717 of file widget.hpp.

Referenced by get_is_dirty(), populate_dirty_list(), and set_is_dirty().

point gui2::widget::layout_size_
private

The best size for the widget.

When 0,0 the real best size is returned, but in the layout phase a wrapping or a scrollbar might change the best size for that widget. This variable holds that best value.

If the widget size hasn't been changed from the default that calculate_best_size() returns, layout_size_ is (0,0).

Definition at line 499 of file widget.hpp.

Referenced by get_best_size(), layout_initialize(), layout_size(), and set_layout_size().

std::string gui2::widget::linked_group_
private

The linked group the widget belongs to.

Todo:
For now the linked group is initialized when the layout of the widget is initialized. The best time to set it would be upon adding the widget in the window. Need to look whether it is possible in a clean way. Maybe a signal just prior to showing a window where the widget can do some of it's on things, would also be nice for widgets that need a finalizer function.

Definition at line 523 of file widget.hpp.

Referenced by get_best_size(), layout_initialize(), set_linked_group(), and ~widget().

widget* gui2::widget::parent_
private

The parent widget.

If the widget has a parent it contains a pointer to the parent, else it is set to nullptr.

Definition at line 224 of file widget.hpp.

Referenced by get_parent_grid(), get_window(), parent(), recursive_is_visible(), and set_parent().

redraw_action gui2::widget::redraw_action_
private

Field for the action to do on a drawing request.

Definition at line 723 of file widget.hpp.

Referenced by draw_background(), draw_children(), draw_debug_border(), draw_foreground(), get_dirty_rectangle(), get_drawing_action(), and set_visible_rectangle().

visibility gui2::widget::visible_
private
unsigned gui2::widget::width_
private

The width of the widget.

Definition at line 484 of file widget.hpp.

Referenced by get_drawing_action(), get_size(), get_width(), is_at(), place(), and set_size().

int gui2::widget::x_
private

The x-coordinate of the widget on the screen.

Definition at line 478 of file widget.hpp.

Referenced by get_origin(), get_x(), is_at(), move(), place(), and set_origin().

int gui2::widget::y_
private

The y-coordinate of the widget on the screen.

Definition at line 481 of file widget.hpp.

Referenced by get_origin(), get_y(), is_at(), move(), place(), and set_origin().


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