NWidgetLeaf Class Reference
[Hierarchical widgets]

Leaf widget. More...

#include <widget_type.h>

Inheritance diagram for NWidgetLeaf:
NWidgetCore NWidgetResizeBase NWidgetBase ZeroedMemoryAllocator

Public Member Functions

 NWidgetLeaf (WidgetType tp, Colours colour, int index, uint16 data, StringID tip)
 Nested leaf widget.
void SetupSmallestSize (Window *w, bool init_array)
 Compute smallest size needed by the widget.
void Draw (const Window *w)
 Draw the widgets of the tree.
ScrollbarFindScrollbar (Window *w, bool allow_next=true) const
 Find the scrollbar of the widget through the Window::nested_array.
bool ButtonHit (const Point &pt)
 For a NWID_BUTTON_DROPDOWN, test whether pt refers to the button or to the drop-down.

Static Public Member Functions

static void InvalidateDimensionCache ()
 Reset the cached dimensions.

Static Private Attributes

static Dimension shadebox_dimension = {0, 0}
 Cached size of a shadebox widget.
static Dimension stickybox_dimension = {0, 0}
 Cached size of a stickybox widget.
static Dimension resizebox_dimension = {0, 0}
 Cached size of a resizebox widget.
static Dimension closebox_dimension = {0, 0}
 Cached size of a closebox widget.

Detailed Description

Leaf widget.

Definition at line 470 of file widget_type.h.


Constructor & Destructor Documentation

NWidgetLeaf::NWidgetLeaf ( WidgetType  tp,
Colours  colour,
int  index,
uint16  data,
StringID  tip 
)

Member Function Documentation

bool NWidgetLeaf::ButtonHit ( const Point pt  ) 

For a NWID_BUTTON_DROPDOWN, test whether pt refers to the button or to the drop-down.

Parameters:
pt Point in the widget.
Returns:
The point refers to the button.
Note:
The magic constants are also used at DrawButtonDropdown.

Definition at line 2110 of file widget.cpp.

References _dynlang, NWidgetBase::current_x, NWidgetBase::pos_x, TD_LTR, and DynamicLanguages::text_dir.

void NWidgetLeaf::Draw ( const Window w  )  [virtual]
Scrollbar * NWidgetLeaf::FindScrollbar ( Window w,
bool  allow_next = true 
) const [virtual]

Find the scrollbar of the widget through the Window::nested_array.

Parameters:
w Window containing the widgets and the scrollbar,
allow_next Search may be extended to the next widget.
Todo:
This implementation uses the constraint that a scrollbar must be the next item in the Window::nested_array, and the scrollbar data is stored in the Window structure (Window::vscroll, Window::vscroll2, and Window::hscroll). Alternative light-weight implementations may be considered, eg by sub-classing a canvas-like widget, and/or by having an explicit link between the scrollbar and the widget being scrolled.

Implements NWidgetCore.

Definition at line 2087 of file widget.cpp.

References NWidgetCore::FindScrollbar(), Window::GetWidget(), NWidgetCore::index, Window::nested_array_size, NWidgetBase::type, Window::vscroll, Window::vscroll2, WWT_SCROLL2BAR, and WWT_SCROLLBAR.

void NWidgetLeaf::InvalidateDimensionCache (  )  [static]

Reset the cached dimensions.

Definition at line 1690 of file widget.cpp.

References closebox_dimension, resizebox_dimension, shadebox_dimension, and stickybox_dimension.

Referenced by InitWindowSystem(), and ReInitAllWindows().

void NWidgetLeaf::SetupSmallestSize ( Window w,
bool  init_array 
) [virtual]

Compute smallest size needed by the widget.

The smallest size of a widget is the smallest size that a widget needs to display itself properly. In addition, filling and resizing of the widget are computed. The function calls Window::UpdateWidgetSize for each leaf widget and background widget without child with a non-negative index.

Parameters:
w Window owning the widget.
init_array Initialize the w->nested_array.
Note:
After the computation, the results can be queried by accessing the smallest_x and smallest_y data members of the widget.

Implements NWidgetBase.

Definition at line 1800 of file widget.cpp.

References NWidgetBase::fill_x, NWidgetBase::fill_y, GetSpriteSize(), GetStringBoundingBox(), NWidgetCore::index, max(), maxdim(), NWidgetResizeBase::min_x, NWidgetResizeBase::min_y, Window::nested_array, Window::nested_array_size, NWID_BUTTON_ARROW, NWID_BUTTON_DROPDOWN, NWidgetBase::resize_x, NWidgetBase::resize_y, Window::SetStringParameters(), NWidgetBase::smallest_x, NWidgetBase::smallest_y, NWidgetBase::type, Window::UpdateWidgetSize(), WD_CAPTIONTEXT_BOTTOM, WD_CAPTIONTEXT_LEFT, WD_CAPTIONTEXT_RIGHT, WD_CAPTIONTEXT_TOP, WD_CLOSEBOX_BOTTOM, WD_CLOSEBOX_LEFT, WD_CLOSEBOX_RIGHT, WD_CLOSEBOX_TOP, WD_DROPDOWNTEXT_BOTTOM, WD_DROPDOWNTEXT_LEFT, WD_DROPDOWNTEXT_RIGHT, WD_DROPDOWNTEXT_TOP, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_RIGHT, WD_FRAMERECT_TOP, WD_IMGBTN_BOTTOM, WD_IMGBTN_LEFT, WD_IMGBTN_RIGHT, WD_IMGBTN_TOP, WD_MATRIX_BOTTOM, WD_MATRIX_LEFT, WD_MATRIX_RIGHT, WD_MATRIX_TOP, WD_RESIZEBOX_BOTTOM, WD_RESIZEBOX_LEFT, WD_RESIZEBOX_RIGHT, WD_RESIZEBOX_TOP, WD_SHADEBOX_BOTTOM, WD_SHADEBOX_LEFT, WD_SHADEBOX_RIGHT, WD_SHADEBOX_TOP, WD_STICKYBOX_BOTTOM, WD_STICKYBOX_LEFT, WD_STICKYBOX_RIGHT, WD_STICKYBOX_TOP, NWidgetCore::widget_data, WWT_CAPTION, WWT_CLOSEBOX, WWT_DROPDOWN, WWT_EDITBOX, WWT_EMPTY, WWT_HSCROLLBAR, WWT_IMGBTN, WWT_IMGBTN_2, WWT_LABEL, WWT_MATRIX, WWT_RESIZEBOX, WWT_SCROLL2BAR, WWT_SCROLLBAR, WWT_SHADEBOX, WWT_STICKYBOX, WWT_TEXT, WWT_TEXTBTN, and WWT_TEXTBTN_2.


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

Generated on Fri Apr 30 21:56:23 2010 for OpenTTD by  doxygen 1.6.1