Public Types | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends

gui2::twidget Class Reference

Base class for all widgets. More...

#include <widget.hpp>

Inheritance diagram for gui2::twidget:
Inheritance graph
[legend]
Collaboration diagram for gui2::twidget:
Collaboration graph
[legend]

List of all members.

Public Types

enum  tvisible { VISIBLE, HIDDEN, INVISIBLE }
 

Visibility settings done by the user.

More...
enum  tdrawing_action { DRAWN, PARTLY_DRAWN, NOT_DRAWN }
 

Visibility set by the engine.

More...

Public Member Functions

 twidget ()
 twidget (const tbuilder_widget &builder)
 Constructor.
virtual ~twidget ()
virtual void layout_init (const bool full_initialization)
 How the layout engine works.
virtual void request_reduce_width (const unsigned maximum_width)=0
 Tries to reduce the width of a widget.
virtual void demand_reduce_width (const unsigned)
 Tries to reduce the width of a widget.
virtual void request_reduce_height (const unsigned)
 Tries to reduce the height of a widget.
virtual void demand_reduce_height (const unsigned)
 Tries to reduce the height of a widget.
tpoint get_best_size () const
 Gets the best size for the widget.
virtual bool can_wrap () const
 Can the widget wrap.
virtual void place (const tpoint &origin, const tpoint &size)
 Places the widget.
virtual void set_size (const tpoint &size)
 Sets the size of the widget.
virtual twidgetfind_at (const tpoint &coordinate, const bool must_be_active)
 Gets the widget at the wanted coordinates.
virtual const twidgetfind_at (const tpoint &coordinate, const bool must_be_active) const
 The const version of find_at.
virtual twidgetfind (const std::string &id, const bool)
 Gets a widget with the wanted id.
virtual const twidgetfind (const std::string &id, const bool) const
 The const version of find.
virtual bool has_widget (const twidget *widget) const
 Does the widget contain the widget.
twindowget_window ()
 Get the parent window.
const twindowget_window () const
 The const version of get_window().
tdialogdialog ()
 Returns the toplevel dialog.
virtual bool disable_click_dismiss () const =0
 Does the widget disable easy close?
virtual iterator::twalker_create_walker ()=0
 Creates a new walker object on the heap.
twidgetparent ()
void set_parent (twidget *parent)
const std::string & id () const
void set_id (const std::string &id)
unsigned get_width () const
unsigned get_height () const
tpoint get_size () const
 Returns the size of the widget.
tpoint get_origin () const
 Returns the screen origin of the widget.
SDL_Rect get_rect () const
 Gets the sizes in one rect structure.
SDL_Rect get_dirty_rect () const
 Gets the dirty rect of the widget.
virtual void set_origin (const tpoint &origin)
 Sets the origin of the widget.
virtual void move (const int x_offset, const int y_offset)
 Moves a widget.
int get_x () const
int get_y () const
void set_visible (const tvisible visible)
tvisible get_visible () const
tdrawing_action get_drawing_action () const
virtual void set_visible_area (const SDL_Rect &area)
 Sets the visible area for a widget.
void set_dirty (const bool dirty=true)
 Sets the widgets dirty state.
bool get_dirty () const
 Returns the dirty state for a widget, final function.
void set_debug_border_mode (const unsigned debug_border_mode)
void set_debug_border_color (const unsigned debug_border_color)
SDL_Rect calculate_blitting_rectangle (const int x_offset, const int y_offset)
 Calculates the blitting rectangle of the widget.
SDL_Rect calculate_clipping_rectangle (const int x_offset, const int y_offset)
 Calculates the clipping rectangle of the widget.
void draw_background (surface &frame_buffer)
 Draws the background of a widget.
void draw_background (surface &frame_buffer, int x_offset, int y_offset)
void draw_children (surface &frame_buffer)
 Draws the children of a widget.
void draw_children (surface &frame_buffer, int x_offset, int y_offset)
void draw_foreground (surface &frame_buffer)
 Draws the foreground of the widgt.
void draw_foreground (surface &frame_buffer, int x_offset, int y_offset)
virtual void layout_children ()
 Allows a widget to update its children.
void populate_dirty_list (twindow &caller, std::vector< twidget * > &call_stack)
 Adds a widget to the dirty list if it is dirty.
void set_linked_group (const std::string &linked_group)

Protected Member Functions

void set_layout_size (const tpoint &size)
const tpointlayout_size () const

Private Member Functions

virtual tpoint calculate_best_size () const =0
 Calculates the best size.
virtual void child_populate_dirty_list (twindow &, const std::vector< twidget * > &)
 Tries to add all children of a container to the dirty list.
void draw_debug_border (surface &frame_buffer)
void draw_debug_border (surface &frame_buffer, int x_offset, int y_offset)
virtual void impl_draw_background (surface &)
 See draw_background().
virtual void impl_draw_background (surface &, int, int)
virtual void impl_draw_children (surface &)
 See draw_children.
virtual void impl_draw_children (surface &, int, int)
virtual void impl_draw_foreground (surface &)
 See draw_foreground.
virtual void impl_draw_foreground (surface &, int, int)
virtual bool is_at (const tpoint &coordinate) const
 (Will be) inherited from event::tdispatcher.
bool is_at (const tpoint &coordinate, const bool must_be_active) const
 Is the coordinate inside our area.

Private Attributes

std::string id_
 The id is the unique name of the widget in a certain context.
twidgetparent_
 The parent widget, if the widget has a parent it contains a pointer to the parent, else it's set to NULL.
int x_
 The x coordinate of the widget in the screen.
int y_
 The y coordinate of the widget in the screen.
unsigned w_
 The width of the widget.
unsigned h_
 The height of the widget.
bool dirty_
 Is the widget dirty? When a widget is dirty it needs to be redrawn at the next drawing cycle, setting it to dirty also need to set it's parent dirty so at so point the toplevel parent knows which item to redraw.
tvisible visible_
 Field for the status of the visibility.
tdrawing_action drawing_action_
 Field for the action to do on a drawing request.
SDL_Rect clip_rect_
 The clip rect is a widget is partly visible.
tpoint layout_size_
 The best size for the control.
std::string linked_group_
 The linked group the widget belongs to.
unsigned debug_border_mode_
 Mode for drawing the debug border.
unsigned debug_border_color_
 The color for the debug border.

Friends

class tdebug_layout_graph
class twindow

Detailed Description

Base class for all widgets.

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

Definition at line 49 of file widget.hpp.


Member Enumeration Documentation

Visibility set by the engine.

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

Enumerator:
DRAWN 

The widget is fully visible and should redrawn when set dirty.

PARTLY_DRAWN 

The widget is partly visible, in order to render it, it's clip rect needs to be used.

NOT_DRAWN 

The widget is not visible and should not be drawn if dirty.

Definition at line 109 of file widget.hpp.

Visibility settings done by the user.

Enumerator:
VISIBLE 

The user set the widget visible, that means: * widget is visible.

* find_at always 'sees' the widget (the active flag is tested later). * widget (if active) handles events (and sends events to children) * widget is drawn (and sends populate_dirty_list to children)

HIDDEN 

The user set the widget hidden, that means: * item is invisible but keeps its size.

* find_at 'sees' the widget if active is false. * item doesn't handle events (and doesn't send events to children). * item doesn't populate_dirty_list (nor does it send the request to its children).

INVISIBLE 

The user set the widget invisible, that means: * item is invisible and gridcell has size 0,0.

* find_at never 'sees' the widget. * item doesn't handle events (and doesn't send events to children). * item doesn't populate_dirty_list (nor does it send the request to its children).

Definition at line 75 of file widget.hpp.


Constructor & Destructor Documentation

gui2::twidget::twidget (  ) 
Deprecated:
use the second overload.

Definition at line 25 of file widget.cpp.

References DBG_GUI_LF.

Referenced by gui2::tcontrol::create_walker().

Here is the caller graph for this function:

gui2::twidget::twidget ( const tbuilder_widget builder  )  [explicit]

Constructor.

Parameters:
builder The builder object with the settings for the object.

Definition at line 49 of file widget.cpp.

References DBG_GUI_LF.

gui2::twidget::~twidget (  )  [virtual]

Definition at line 73 of file widget.cpp.

References DBG_GUI_LF, gui2::event::tdispatcher::fire(), get_window(), id_, linked_group_, gui2::event::NOTIFY_REMOVAL, and parent().

Here is the call graph for this function:


Member Function Documentation

virtual tpoint gui2::twidget::calculate_best_size (  )  const [private, pure 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's meant to update itself.

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

Implemented in gui2::tcontainer_, gui2::tcontrol, gui2::tdrawing, gui2::tgenerator_, gui2::policy::placement::thorizontal_list, gui2::policy::placement::tvertical_list, gui2::policy::placement::tmatrix, gui2::policy::placement::tindependent, gui2::tgrid, gui2::tpane, gui2::tscrollbar_container, gui2::tspacer, gui2::ttree_view_node, and gui2::tviewport.

Referenced by get_best_size().

Here is the caller graph for this function:

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

Calculates the blitting rectangle of the widget.

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

Parameters:
x_offset The x offset when drawn.
y_offset The y offset when drawn.
Returns:
The drawing rectangle.

Definition at line 291 of file widget.cpp.

References get_rect().

Referenced by draw_debug_border(), gui2::tcontrol::impl_draw_background(), gui2::tpanel::impl_draw_background(), gui2::tminimap::impl_draw_background(), and gui2::tpanel::impl_draw_foreground().

Here is the call graph for this function:

Here is the caller graph for this function:

SDL_Rect gui2::twidget::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 drawing_action_ is PARTLY_DRAWN. Since the drawing can be offsetted it also needs offset paramters.

Parameters:
x_offset The x offset when drawn.
y_offset The y offset when drawn.
Returns:
The clipping rectangle.

Definition at line 301 of file widget.cpp.

References clip_rect_.

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

Here is the caller graph for this function:

virtual bool gui2::twidget::can_wrap (  )  const [inline, virtual]

Can the widget wrap.

When a widget can wrap it can reduce it's width by increasing it's 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.

Reimplemented in gui2::tcontainer_, gui2::tgrid, gui2::tlabel, and gui2::tscrollbar_container.

Definition at line 241 of file widget.hpp.

Referenced by gui2::tgrid::tchild::can_wrap(), gui2::tcontrol::get_best_text_size(), gui2::tcontrol::request_reduce_width(), gui2::tcontrol::update_canvas(), and gui2::ttext_box::update_canvas().

Here is the caller graph for this function:

virtual void gui2::twidget::child_populate_dirty_list ( twindow ,
const std::vector< twidget * > &   
) [inline, private, virtual]

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:
caller The parent window, if dirty it should register itself to this window.
call_stack The callstack of widgets traversed to reach this function.

Reimplemented in gui2::tcontainer_, gui2::tgenerator_, gui2::tgrid, gui2::tlistbox, gui2::tpane, gui2::tscrollbar_container, gui2::ttree_view, and gui2::tviewport.

Definition at line 573 of file widget.hpp.

Referenced by populate_dirty_list().

Here is the caller graph for this function:

virtual iterator::twalker_* gui2::twidget::create_walker (  )  [pure virtual]

Creates a new walker object on the heap.

Implemented in gui2::tcontainer_, gui2::tcontrol, gui2::tgrid, gui2::tpane, gui2::ttree_view_node, and gui2::tviewport.

virtual void gui2::twidget::demand_reduce_height ( const   unsigned  )  [inline, virtual]

Tries to reduce the height of a widget.

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

Todo:
Make pure virtual.
See also:
layout_algorihm for more information.
Parameters:
maximum_height The wanted maximum height.

Reimplemented in gui2::tcontainer_, and gui2::tgrid.

Definition at line 204 of file widget.hpp.

virtual void gui2::twidget::demand_reduce_width ( const   unsigned  )  [inline, virtual]

Tries to reduce the width of a widget.

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

Todo:
Make pure virtual.
See also:
layout_algorihm for more information.
Parameters:
maximum_width The wanted maximum width.

Reimplemented in gui2::tcontainer_, and gui2::tgrid.

Definition at line 177 of file widget.hpp.

tdialog * gui2::twidget::dialog (  ) 

Returns the toplevel 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 toplevel dialog.
Return values:
0 No toplevel window or the toplevel window is not owned by a dialog.

Definition at line 218 of file widget.cpp.

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

Referenced by gui2::dialog_callback(), and gui2::dialog_view_callback().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool gui2::twidget::disable_click_dismiss (  )  const [pure virtual]
void gui2::twidget::draw_background ( surface frame_buffer  ) 

Draws the background of a widget.

Subclasses should override impl_draw_background instead of changing this function.

Parameters:
frame_buffer The surface to draw upon.
x_offset The x offset in the frame_buffer to draw.
y_offset The y offset in the frame_buffer to draw.

Definition at line 311 of file widget.cpp.

References clip_rect_, draw_debug_border(), drawing_action_, impl_draw_background(), PARTLY_DRAWN, VISIBLE, and visible_.

Referenced by gui2::tviewport::impl_draw_children(), and gui2::tgrid::impl_draw_children().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::twidget::draw_background ( surface frame_buffer,
int  x_offset,
int  y_offset 
)

Definition at line 325 of file widget.cpp.

References calculate_clipping_rectangle(), draw_debug_border(), drawing_action_, impl_draw_background(), PARTLY_DRAWN, VISIBLE, and visible_.

Here is the call graph for this function:

void gui2::twidget::draw_children ( surface frame_buffer  ) 

Draws the children of a widget.

Containers should draw their children when they get this request.

Subclasses should override impl_draw_children instead of changing this function.

Parameters:
frame_buffer The surface to draw upon.
x_offset The x offset in the frame_buffer to draw.
y_offset The y offset in the frame_buffer to draw.

Definition at line 342 of file widget.cpp.

References clip_rect_, drawing_action_, impl_draw_children(), PARTLY_DRAWN, VISIBLE, and visible_.

Referenced by gui2::tviewport::impl_draw_children(), gui2::ttree_view_node::impl_draw_children(), gui2::tscrollbar_container::impl_draw_children(), gui2::tpane::impl_draw_children(), gui2::tgrid::impl_draw_children(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::impl_draw_children(), and gui2::tcontainer_::impl_draw_children().

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 354 of file widget.cpp.

References calculate_clipping_rectangle(), drawing_action_, impl_draw_children(), PARTLY_DRAWN, VISIBLE, and visible_.

Here is the call graph for this function:

void gui2::twidget::draw_debug_border ( surface frame_buffer  )  [private]

Definition at line 397 of file widget.cpp.

References clip_rect_, debug_border_color_, debug_border_mode_, draw_rectangle(), drawing_action_, get_rect(), PARTLY_DRAWN, and sdl_fill_rect().

Referenced by draw_background().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::twidget::draw_debug_border ( surface frame_buffer,
int  x_offset,
int  y_offset 
) [private]
void gui2::twidget::draw_foreground ( surface frame_buffer  ) 

Draws the foreground of the widgt.

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

Subclasses should override impl_draw_foreground instead of changing this function.

Parameters:
frame_buffer The surface to draw upon.
x_offset The x offset in the frame_buffer to draw.
y_offset The y offset in the frame_buffer to draw.

Definition at line 369 of file widget.cpp.

References clip_rect_, drawing_action_, impl_draw_foreground(), PARTLY_DRAWN, VISIBLE, and visible_.

Referenced by gui2::tviewport::impl_draw_children(), and gui2::tgrid::impl_draw_children().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::twidget::draw_foreground ( surface frame_buffer,
int  x_offset,
int  y_offset 
)

Definition at line 381 of file widget.cpp.

References calculate_clipping_rectangle(), drawing_action_, impl_draw_foreground(), PARTLY_DRAWN, VISIBLE, and visible_.

Here is the call graph for this function:

virtual twidget* gui2::twidget::find ( const std::string &  id,
const   bool 
) [inline, virtual]

Gets a widget with the wanted id.

Parameters:
id The id of the widget to find.
must_be_active The 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:
0 No widget with the id found (or not active if must_be_active was set).

Reimplemented in gui2::tcontainer_, gui2::tcontrol, gui2::policy::placement::tindependent, gui2::tgrid, gui2::tscrollbar_container, gui2::ttree_view_node, and gui2::tviewport.

Definition at line 299 of file widget.hpp.

References id_.

Referenced by gui2::tcontrol::find(), and find_widget().

Here is the caller graph for this function:

virtual const twidget* gui2::twidget::find ( const std::string &  id,
const   bool 
) const [inline, virtual]

The const version of find.

Reimplemented in gui2::tcontainer_, gui2::tcontrol, gui2::policy::placement::tindependent, gui2::tgrid, gui2::tscrollbar_container, gui2::ttree_view_node, and gui2::tviewport.

Definition at line 304 of file widget.hpp.

References id_.

twidget * gui2::twidget::find_at ( const tpoint coordinate,
const bool  must_be_active 
) [virtual]

Gets the widget at the wanted coordinates.

Parameters:
coordinate The coordinate which should be inside the widget.
must_be_active The 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:
0 No widget at the wanted coordinate found (or not active if must_be_active was set).

Reimplemented in gui2::tcontainer_, gui2::tcontrol, gui2::tgenerator_, gui2::policy::placement::thorizontal_list, gui2::policy::placement::tvertical_list, gui2::policy::placement::tmatrix, gui2::policy::placement::tindependent, gui2::tgrid, gui2::tpane, gui2::tscrollbar_container, gui2::ttree_view_node, and gui2::tviewport.

Definition at line 165 of file widget.cpp.

References is_at().

Referenced by gui2::tcontrol::find_at(), gui2::event::tmouse_button< sdl_button_down, sdl_button_up, button_down, button_up, button_click, button_double_click >::signal_handler_sdl_button_down(), and gui2::event::tmouse_button< sdl_button_down, sdl_button_up, button_down, button_up, button_click, button_double_click >::signal_handler_sdl_button_up().

Here is the call graph for this function:

Here is the caller graph for this function:

const twidget * gui2::twidget::find_at ( const tpoint coordinate,
const bool  must_be_active 
) const [virtual]
tpoint gui2::twidget::get_best_size (  )  const
bool gui2::twidget::get_dirty (  )  const [inline]

Returns the dirty state for a widget, final function.

Definition at line 445 of file widget.hpp.

References dirty_.

SDL_Rect gui2::twidget::get_dirty_rect (  )  const

Gets the dirty rect of the widget.

Depending on the drawing action it returns the rect this widget dirties while redrawing.

Returns:
The dirty rect.

Definition at line 177 of file widget.cpp.

References clip_rect_, drawing_action_, DRAWN, and get_rect().

Here is the call graph for this function:

twidget::tdrawing_action gui2::twidget::get_drawing_action (  )  const

Definition at line 271 of file widget.cpp.

References drawing_action_, h_, NOT_DRAWN, and w_.

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

Here is the caller graph for this function:

unsigned gui2::twidget::get_height (  )  const [inline]
tpoint gui2::twidget::get_origin (  )  const [inline]
SDL_Rect gui2::twidget::get_rect (  )  const [inline]
tpoint gui2::twidget::get_size (  )  const [inline]
tvisible gui2::twidget::get_visible (  )  const [inline]

Definition at line 421 of file widget.hpp.

References visible_.

Referenced by gui2::ttree_view_node::calculate_best_size(), gui2::tscrollbar_container::calculate_best_size(), gui2::tgrid_implementation::cell_request_reduce_height(), gui2::tgrid_implementation::cell_request_reduce_width(), gui2::tscrollbar_container::content_resize_height(), gui2::tscrollbar_container::content_resize_request(), gui2::tscrollbar_container::content_resize_width(), gui2::tgrid::disable_click_dismiss(), gui2::tcontrol::disable_click_dismiss(), gui2::tgrid::tchild::get_best_size(), gui2::ttree_view_node::get_current_size(), gui2::ttree_view_node::get_unfolded_size(), gui2::tviewport::impl_draw_children(), gui2::tscrollbar_container::impl_draw_children(), gui2::tpane::impl_draw_children(), gui2::tgrid::impl_draw_children(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::impl_draw_children(), gui2::tcontainer_::impl_draw_children(), gui2::tviewport::layout_init(), gui2::tpane::layout_init(), gui2::tgrid::tchild::layout_init(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::layout_init(), gui2::tgrid::tchild::place(), gui2::tpane::place_children(), gui2::tpane::place_or_set_origin_children(), gui2::tpane::prepare_placement(), gui2::tlistbox::remove_row(), gui2::tscrollbar_container::request_reduce_height(), gui2::tscrollbar_container::request_reduce_width(), gui2::tpane::set_origin_children(), gui2::tpane::signal_handler_request_placement(), gui2::tscrollbar_container::signal_handler_sdl_wheel_down(), gui2::tscrollbar_container::signal_handler_sdl_wheel_left(), gui2::tscrollbar_container::signal_handler_sdl_wheel_right(), gui2::tscrollbar_container::signal_handler_sdl_wheel_up(), and gui2::tlistbox::update_content_size().

Here is the caller graph for this function:

unsigned gui2::twidget::get_width (  )  const [inline]
twindow * gui2::twidget::get_window (  ) 
const twindow * gui2::twidget::get_window (  )  const

The const version of get_window().

Definition at line 204 of file widget.cpp.

References parent_.

int gui2::twidget::get_x (  )  const [inline]
int gui2::twidget::get_y (  )  const [inline]
virtual bool gui2::twidget::has_widget ( const twidget widget  )  const [inline, 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:
widget Pointer to the widget to find.
Returns:
Whether or not the widget was found.

Reimplemented in gui2::tcontainer_, and gui2::tgrid.

Definition at line 318 of file widget.hpp.

Referenced by gui2::tgrid::has_widget().

Here is the caller graph for this function:

const std::string& gui2::twidget::id (  )  const [inline]
virtual void gui2::twidget::impl_draw_background ( surface  )  [inline, private, virtual]

See draw_background().

Reimplemented in gui2::tcontrol, gui2::tminimap, gui2::tmulti_page, gui2::tpanel, and gui2::tspacer.

Definition at line 693 of file widget.hpp.

Referenced by draw_background().

Here is the caller graph for this function:

virtual void gui2::twidget::impl_draw_background ( surface ,
int  ,
int   
) [inline, private, virtual]

Reimplemented in gui2::tcontrol, gui2::tminimap, gui2::tmulti_page, gui2::tpanel, and gui2::tspacer.

Definition at line 694 of file widget.hpp.

virtual void gui2::twidget::impl_draw_children ( surface  )  [inline, private, virtual]

See draw_children.

Reimplemented in gui2::tcontainer_, gui2::tgenerator_, gui2::tgrid, gui2::tscrollbar_container, and gui2::ttree_view_node.

Definition at line 702 of file widget.hpp.

Referenced by draw_children().

Here is the caller graph for this function:

virtual void gui2::twidget::impl_draw_children ( surface ,
int  ,
int   
) [inline, private, virtual]
virtual void gui2::twidget::impl_draw_foreground ( surface ,
int  ,
int   
) [inline, private, virtual]

Reimplemented in gui2::tcontrol, and gui2::tpanel.

Definition at line 712 of file widget.hpp.

virtual void gui2::twidget::impl_draw_foreground ( surface  )  [inline, private, virtual]

See draw_foreground.

Reimplemented in gui2::tcontrol, and gui2::tpanel.

Definition at line 711 of file widget.hpp.

Referenced by draw_foreground().

Here is the caller graph for this function:

bool gui2::twidget::is_at ( const tpoint 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:
coordinate The coordinate which should be inside the widget.
must_be_active The widget should be active, not all widgets have an active flag, those who don't ignore flag.
Returns:
Status.

Definition at line 444 of file widget.cpp.

References h_, HIDDEN, INVISIBLE, visible_, w_, gui2::tpoint::x, x_, gui2::tpoint::y, and y_.

virtual bool gui2::twidget::is_at ( const tpoint coordinate  )  const [inline, private, virtual]

(Will be) inherited from event::tdispatcher.

Implements gui2::event::tdispatcher.

Definition at line 720 of file widget.hpp.

Referenced by find_at().

Here is the caller graph for this function:

virtual void gui2::twidget::layout_children (  )  [inline, 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::tcontainer_, gui2::tgrid, gui2::tlistbox, gui2::tscrollbar_container, gui2::tstacked_widget, and gui2::ttree_view.

Definition at line 542 of file widget.hpp.

Referenced by gui2::tgrid::layout_children().

Here is the caller graph for this function:

void gui2::twidget::layout_init ( 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_init() 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. Initializes the layout phase.

Clears the initial best size for the widgets.

See also:
layout_algorihm for more information.
Parameters:
full_initialization For widgets with scrollbars it hides them unless the mode is tscrollbar_mode::always_visible. For other widgets this flag is a NOP.

Reimplemented in gui2::tcontainer_, gui2::tcontrol, gui2::tgenerator_, gui2::tgrid, gui2::tpane, gui2::tscrollbar_container, and gui2::tviewport.

Definition at line 104 of file widget.cpp.

References gui2::twindow::add_linked_widget(), get_window(), INVISIBLE, layout_size_, linked_group_, and visible_.

Referenced by gui2::tviewport::layout_init(), and gui2::tgrid::tchild::layout_init().

Here is the call graph for this function:

Here is the caller graph for this function:

const tpoint& gui2::twidget::layout_size (  )  const [inline, protected]

Definition at line 579 of file widget.hpp.

References layout_size_.

void gui2::twidget::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 inherited classes.
Parameters:
x_offset The amount of pixels to move the widget in the x direction.
y_offset The amount of pixels to move the widget in the y direction.

Definition at line 184 of file widget.cpp.

References x_, and y_.

twidget* gui2::twidget::parent (  )  [inline]

Definition at line 360 of file widget.hpp.

References parent_.

Referenced by gui2::event::implementation::build_event_chain(), gui2::get_parent(), place(), and ~twidget().

Here is the caller graph for this function:

void gui2::twidget::place ( const tpoint origin,
const tpoint size 
) [virtual]

Places the widget.

This function is normally called by a layout function to do the placement of a widget.

Parameters:
origin The position of top left of the widget.
size The size of the widget.

Reimplemented in gui2::tcontainer_, gui2::tcontrol, gui2::tgenerator_, gui2::policy::placement::thorizontal_list, gui2::policy::placement::tvertical_list, gui2::policy::placement::tmatrix, gui2::policy::placement::tindependent, gui2::tgrid, gui2::tlistbox, gui2::tpane, gui2::tscrollbar_, gui2::tscrollbar_container, gui2::ttext_box, gui2::ttree_view_node, and gui2::tviewport.

Definition at line 130 of file widget.cpp.

References get_rect(), get_x(), get_y(), h_, id(), parent(), set_dirty(), w_, gui2::tpoint::x, x_, gui2::tpoint::y, and y_.

Referenced by gui2::tviewport::place(), and gui2::tgrid::tchild::place().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::twidget::populate_dirty_list ( twindow caller,
std::vector< twidget * > &  call_stack 
)

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

See twindow::dirty_list_ for more info on 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:
caller The parent window, if dirty it should register itself to this window.
call_stack The callstack of widgets traversed to reach this function.

Definition at line 224 of file widget.cpp.

References gui2::twindow::add_to_dirty_list(), child_populate_dirty_list(), dirty_, get_drawing_action(), VISIBLE, and visible_.

Referenced by gui2::tviewport::child_populate_dirty_list(), gui2::tscrollbar_container::child_populate_dirty_list(), gui2::tpane::child_populate_dirty_list(), gui2::tgrid::child_populate_dirty_list(), gui2::tgenerator< minimum_selection, maximum_selection, placement, select_action >::child_populate_dirty_list(), gui2::tcontainer_::child_populate_dirty_list(), gui2::tlistbox::child_populate_dirty_list(), gui2::twindow::draw(), and gui2::ttree_view_node::impl_populate_dirty_list().

Here is the call graph for this function:

Here is the caller graph for this function:

virtual void gui2::twidget::request_reduce_height ( const   unsigned  )  [inline, 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 also:
layout_algorihm for more information.
Parameters:
maximum_height The wanted maximum height.

Reimplemented in gui2::tcontainer_, gui2::tgenerator_, gui2::policy::placement::thorizontal_list, gui2::policy::placement::tvertical_list, gui2::policy::placement::tmatrix, gui2::policy::placement::tindependent, gui2::tgrid, and gui2::tscrollbar_container.

Definition at line 190 of file widget.hpp.

Referenced by gui2::tgrid_implementation::cell_request_reduce_height().

Here is the caller graph for this function:

virtual void gui2::twidget::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 wrapping of the widget.

See also:
layout_algorihm for more information.
Parameters:
maximum_width The wanted maximum width.

Implemented in gui2::tcontainer_, gui2::tcontrol, gui2::tgenerator_, gui2::policy::placement::thorizontal_list, gui2::policy::placement::tvertical_list, gui2::policy::placement::tmatrix, gui2::policy::placement::tindependent, gui2::tgrid, gui2::tpane, gui2::tscrollbar_container, gui2::ttree_view_node, and gui2::tviewport.

Referenced by gui2::tgrid_implementation::cell_request_reduce_width().

Here is the caller graph for this function:

void gui2::twidget::set_debug_border_color ( const unsigned  debug_border_color  )  [inline]

Definition at line 453 of file widget.hpp.

References debug_border_color_.

Referenced by gui2::implementation::tbuilder_control::init_control().

Here is the caller graph for this function:

void gui2::twidget::set_debug_border_mode ( const unsigned  debug_border_mode  )  [inline]

Definition at line 448 of file widget.hpp.

References debug_border_mode_.

Referenced by gui2::implementation::tbuilder_control::init_control().

Here is the caller graph for this function:

void gui2::twidget::set_dirty ( const bool  dirty = true  )  [inline]

Sets the widgets dirty state.

Todo:
test whether nobody redefines the function.

Definition at line 439 of file widget.hpp.

References dirty_.

Referenced by gui2::animate_logo(), gui2::ttext_box::handle_mouse_selection(), gui2::tviewport::impl_draw_children(), gui2::tgrid::impl_draw_children(), gui2::ttext_::insert_char(), gui2::tlistbox::layout_children(), gui2::ttext_::paste_selection(), place(), gui2::tpassword_box::post_function(), gui2::ttree_view::resize_content(), gui2::tlistbox::resize_content(), gui2::tscrollbar_container::scrollbar_moved(), gui2::tcontainer_::set_active(), gui2::tslider::set_best_slider_length(), gui2::tgrid::set_column_grow_factor(), gui2::ttext_::set_cursor(), gui2::tcontrol::set_label(), gui2::tminimap::set_map_data(), gui2::ttext_::set_maximum_length(), gui2::tgrid::set_row_grow_factor(), gui2::tlistbox::set_row_shown(), gui2::ttext_::set_selection_length(), gui2::ttext_::set_selection_start(), set_size(), gui2::ttext_::set_state(), gui2::tscrollbar_::set_state(), gui2::ttoggle_panel::set_state(), gui2::ttoggle_button::set_state(), gui2::trepeating_button::set_state(), gui2::tlabel::set_state(), gui2::tbutton::set_state(), gui2::tcontrol::set_text_alignment(), gui2::tcontrol::set_use_markup(), gui2::ttext_::set_value(), gui2::twindow::set_variable(), set_visible(), gui2::tdebug_clock::ttime::ttime(), gui2::tscrollbar_::update_canvas(), gui2::ttoggle_button::update_canvas(), gui2::tlistbox::update_content_size(), and gui2::teditor_settings::update_tod_display().

Here is the caller graph for this function:

void gui2::twidget::set_id ( const std::string &  id  ) 

Definition at line 91 of file widget.cpp.

References DBG_GUI_LF, and id_.

Referenced by add_widget(), BOOST_AUTO_TEST_CASE(), gui2::tbuilder_grid::build(), gui2::implementation::tbuilder_control::init_control(), and gui2::tcontrol::set_members().

Here is the caller graph for this function:

void gui2::twidget::set_layout_size ( const tpoint size  )  [inline, protected]
void gui2::twidget::set_linked_group ( const std::string &  linked_group  )  [inline]

Definition at line 583 of file widget.hpp.

References linked_group_.

Referenced by gui2::tbuilder_grid::build(), gui2::implementation::tbuilder_control::init_control(), and gui2::tcontrol::set_members().

Here is the caller graph for this function:

virtual void gui2::twidget::set_origin ( const tpoint origin  )  [inline, virtual]

Sets the origin of the widget.

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

Parameters:
origin The new origin.

Reimplemented in gui2::tcontainer_, gui2::tgenerator_, gui2::policy::placement::thorizontal_list, gui2::policy::placement::tvertical_list, gui2::policy::placement::tmatrix, gui2::policy::placement::tindependent, gui2::tgrid, gui2::tscrollbar_container, and gui2::ttree_view_node.

Definition at line 396 of file widget.hpp.

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

Referenced by gui2::tgrid::set_origin().

Here is the caller graph for this function:

void gui2::twidget::set_parent ( twidget parent  )  [inline]
void gui2::twidget::set_size ( const tpoint 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:
size The size of the widget.

Definition at line 154 of file widget.cpp.

References h_, set_dirty(), w_, gui2::tpoint::x, and gui2::tpoint::y.

Referenced by gui2::ttree_view_node::place(), gui2::ttree_view::resize_content(), and gui2::tlistbox::resize_content().

Here is the call graph for this function:

Here is the caller graph for this function:

void gui2::twidget::set_visible ( const tvisible  visible  ) 
void gui2::twidget::set_visible_area ( const SDL_Rect &  area  )  [virtual]

Sets the visible area for a widget.

This function sets the drawing_state_ and the clip_rect_.

Parameters:
area The visible area in screen coordinates.

Reimplemented in gui2::tcontainer_, gui2::tgenerator_, gui2::policy::placement::thorizontal_list, gui2::policy::placement::tvertical_list, gui2::policy::placement::tmatrix, gui2::policy::placement::tindependent, gui2::tgrid, gui2::tscrollbar_container, and gui2::ttree_view_node.

Definition at line 278 of file widget.cpp.

References clip_rect_, drawing_action_, get_rect(), and intersect_rects().

Referenced by gui2::tgrid::set_visible_area().

Here is the call graph for this function:

Here is the caller graph for this function:


Friends And Related Function Documentation

friend class tdebug_layout_graph [friend]
friend class twindow [friend]

Reimplemented in gui2::tcontrol.

Definition at line 55 of file widget.hpp.


Member Data Documentation

SDL_Rect gui2::twidget::clip_rect_ [private]

The clip rect is a widget is partly visible.

Definition at line 635 of file widget.hpp.

Referenced by calculate_clipping_rectangle(), draw_background(), draw_children(), draw_debug_border(), draw_foreground(), get_dirty_rect(), and set_visible_area().

The color for the debug border.

Definition at line 673 of file widget.hpp.

Referenced by draw_debug_border(), and set_debug_border_color().

Mode for drawing the debug border.

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

Possible values:

  • 0 no border
  • 1 single pixel border
  • 2 floodfilled rectangle

Definition at line 670 of file widget.hpp.

Referenced by draw_debug_border(), and set_debug_border_mode().

bool gui2::twidget::dirty_ [private]

Is the widget dirty? When a widget is dirty it needs to be redrawn at the next drawing cycle, setting it to dirty also need to set it's parent dirty so at so point the toplevel parent knows which item to redraw.

NOTE dirtying the parent might be inefficient and this behaviour might be optimized later on.

Definition at line 626 of file widget.hpp.

Referenced by get_dirty(), populate_dirty_list(), and set_dirty().

Field for the action to do on a drawing request.

Definition at line 632 of file widget.hpp.

Referenced by draw_background(), draw_children(), draw_debug_border(), draw_foreground(), get_dirty_rect(), get_drawing_action(), and set_visible_area().

unsigned gui2::twidget::h_ [private]

The height of the widget.

Definition at line 616 of file widget.hpp.

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

std::string gui2::twidget::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. Eg 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, eg a listbox can have the same id for every row.

Definition at line 598 of file widget.hpp.

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

The best size for the control.

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.

Definition at line 644 of file widget.hpp.

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

std::string gui2::twidget::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's 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 656 of file widget.hpp.

Referenced by layout_init(), set_linked_group(), and ~twidget().

The parent widget, if the widget has a parent it contains a pointer to the parent, else it's set to NULL.

Definition at line 604 of file widget.hpp.

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

Field for the status of the visibility.

Definition at line 629 of file widget.hpp.

Referenced by draw_background(), draw_children(), draw_foreground(), get_best_size(), get_visible(), is_at(), layout_init(), populate_dirty_list(), and set_visible().

unsigned gui2::twidget::w_ [private]

The width of the widget.

Definition at line 613 of file widget.hpp.

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

int gui2::twidget::x_ [private]

The x coordinate of the widget in the screen.

Definition at line 607 of file widget.hpp.

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

int gui2::twidget::y_ [private]

The y coordinate of the widget in the screen.

Definition at line 610 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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

Generated by doxygen 1.7.1 on Thu May 24 2012 01:23:47 for The Battle for Wesnoth
Gna! | Forum | Wiki | CIA | devdocs