#include <widget_type.h>
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. | |
Scrollbar * | FindScrollbar (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. |
Definition at line 470 of file widget_type.h.
NWidgetLeaf::NWidgetLeaf | ( | WidgetType | tp, | |
Colours | colour, | |||
int | index, | |||
uint16 | data, | |||
StringID | tip | |||
) |
Nested leaf widget.
tp | Type of leaf widget. | |
colour | Colour of the leaf widget. | |
index | Index in the widget array used by the window system. | |
data | Data of the widget. | |
tip | Tooltip of the widget. |
Definition at line 1711 of file widget.cpp.
References NWidgetResizeBase::min_x, NWidgetResizeBase::min_y, NWID_BUTTON_ARROW, NWID_BUTTON_DROPDOWN, NWidgetCore::SetDataTip(), NWidgetResizeBase::SetFill(), NWidgetCore::SetIndex(), NWidgetResizeBase::SetMinimalSize(), NWidgetResizeBase::SetResize(), WD_CAPTION_HEIGHT, WD_CLOSEBOX_WIDTH, WD_DROPDOWN_HEIGHT, WD_HSCROLLBAR_HEIGHT, WD_RESIZEBOX_WIDTH, WD_SHADEBOX_TOP, WD_STICKYBOX_WIDTH, WD_VSCROLLBAR_WIDTH, 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.
Referenced by MakeNWidget().
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.
w | Window owning the widget. | |
init_array | Initialize the w->nested_array . |
Implements NWidgetBase.
Definition at line 1800 of file widget.cpp.
References NWidgetBase::fill_x, NWidgetBase::fill_y, GetSpriteSize(), GetStringBoundingBox(), Dimension::height, 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, Dimension::width, 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.
void NWidgetLeaf::Draw | ( | const Window * | w | ) | [virtual] |
Draw the widgets of the tree.
The function calls Window::DrawWidget for each widget with a non-negative index, after the widget itself is painted.
w | Window that owns the tree. |
Implements NWidgetBase.
Definition at line 1955 of file widget.cpp.
References _colour_gradient, _dynlang, AWV_DECREASE, AWV_INCREASE, AWV_LEFT, AWV_RIGHT, Rect::bottom, NWidgetCore::colour, NWidgetBase::current_x, NWidgetBase::current_y, NWidgetCore::disp_flags, DrawButtonDropdown(), DrawCaption(), DrawCloseBox(), DrawDropdown(), DrawFrameRect(), DrawHorizontalScrollbar(), DrawImageButtons(), DrawLabel(), DrawMatrix(), DrawResizeBox(), DrawShadeBox(), DrawStickyBox(), DrawText(), DrawVerticalScrollbar(), Window::DrawWidget(), FILLRECT_CHECKER, Window::flags4, FR_DARKENED, FR_LOWERED, GfxFillRect(), DrawPixelInfo::height, Window::hscroll, NWidgetCore::index, NWidgetCore::IsDisabled(), NWidgetCore::IsLowered(), Window::IsShaded(), DrawPixelInfo::left, Rect::left, ND_DROPDOWN_ACTIVE, NWID_BUTTON_ARROW, NWID_BUTTON_DROPDOWN, Window::owner, NWidgetBase::pos_x, NWidgetBase::pos_y, Rect::right, Window::SetStringParameters(), TD_RTL, DynamicLanguages::text_dir, DrawPixelInfo::top, Rect::top, NWidgetBase::type, Window::vscroll, Window::vscroll2, WF_SCROLL_DOWN, WF_SCROLL_MIDDLE, WF_SCROLL_UP, WF_SIZING, WF_STICKY, NWidgetCore::widget_data, Window::width, DrawPixelInfo::width, 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.
Find the scrollbar of the widget through the Window::nested_array.
w | Window containing the widgets and the scrollbar, | |
allow_next | Search may be extended to the next widget. |
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.
bool NWidgetLeaf::ButtonHit | ( | const Point & | pt | ) |
For a NWID_BUTTON_DROPDOWN, test whether pt refers to the button or to the drop-down.
pt | Point in the widget. |
Definition at line 2110 of file widget.cpp.
References _dynlang, NWidgetBase::current_x, NWidgetBase::pos_x, TD_LTR, DynamicLanguages::text_dir, and Point::x.
void NWidgetLeaf::InvalidateDimensionCache | ( | ) | [static] |
Reset the cached dimensions.
Definition at line 1690 of file widget.cpp.
References closebox_dimension, Dimension::height, resizebox_dimension, shadebox_dimension, stickybox_dimension, and Dimension::width.
Referenced by InitWindowSystem(), and ReInitAllWindows().