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.
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 debugbox_dimension = {0, 0}
 Cached size of a debugbox 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 726 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 2330 of file widget.cpp.

References _current_text_dir, NWidgetBase::current_x, NWidgetBase::pos_x, and TD_LTR.

void NWidgetLeaf::Draw ( const Window w  )  [virtual]
void NWidgetLeaf::InvalidateDimensionCache (  )  [static]

Reset the cached dimensions.

Definition at line 1934 of file widget.cpp.

References closebox_dimension, debugbox_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 2036 of file widget.cpp.

References _settings_client, NWidgetBase::fill_x, NWidgetBase::fill_y, GetSpriteSize(), GetStringBoundingBox(), ClientSettings::gui, NWidgetCore::index, Window::IsNewGRFInspectable(), max(), maxdim(), NWidgetResizeBase::min_x, NWidgetResizeBase::min_y, Window::nested_array, Window::nested_array_size, GUISettings::newgrf_developer_tools, 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_DEBUGBOX_BOTTOM, WD_DEBUGBOX_LEFT, WD_DEBUGBOX_RIGHT, WD_DEBUGBOX_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_ARROWBTN, WWT_CAPTION, WWT_CLOSEBOX, WWT_DEBUGBOX, WWT_DROPDOWN, WWT_EDITBOX, WWT_EMPTY, WWT_IMGBTN, WWT_IMGBTN_2, WWT_LABEL, WWT_MATRIX, WWT_RESIZEBOX, 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 Sun Jan 23 01:50:13 2011 for OpenTTD by  doxygen 1.6.1