Leaf widget. More...
#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. | |
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. |
Leaf widget.
Definition at line 768 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 2051 of file widget.cpp.
References NWidgetResizeBase::min_y, NWID_BUTTON_DROPDOWN, NWidgetCore::SetDataTip(), NWidgetResizeBase::SetFill(), NWidgetCore::SetIndex(), NWidgetResizeBase::SetMinimalSize(), NWidgetResizeBase::SetResize(), WD_CAPTION_HEIGHT, WD_CLOSEBOX_WIDTH, WD_DEBUGBOX_TOP, WD_RESIZEBOX_WIDTH, WD_SHADEBOX_TOP, WD_STICKYBOX_WIDTH, 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.
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 2427 of file widget.cpp.
References _current_text_dir, NWidgetBase::pos_x, and TD_LTR.
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 2303 of file widget.cpp.
References _colour_gradient, _current_text_dir, AWV_DECREASE, AWV_INCREASE, AWV_LEFT, AWV_RIGHT, NWidgetCore::colour, NWidgetCore::disp_flags, DrawButtonDropdown(), DrawCaption(), DrawCloseBox(), DrawDebugBox(), DrawDropdown(), DrawFrameRect(), DrawImageButtons(), DrawLabel(), DrawMatrix(), DrawResizeBox(), DrawShadeBox(), DrawStickyBox(), DrawText(), Window::DrawWidget(), FILLRECT_CHECKER, Window::flags, FR_DARKENED, FR_LOWERED, GfxFillRect(), NWidgetCore::index, NWidgetCore::IsDisabled(), NWidgetCore::IsLowered(), Window::IsShaded(), ND_DROPDOWN_ACTIVE, NWID_BUTTON_DROPDOWN, Window::owner, NWidgetBase::pos_x, NWidgetBase::pos_y, Window::SetStringParameters(), TD_RTL, NWidgetBase::type, WF_SIZING, WF_STICKY, NWidgetCore::widget_data, Window::width, 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.
void NWidgetLeaf::InvalidateDimensionCache | ( | ) | [static] |
Reset the cached dimensions.
Definition at line 2028 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.
w | Window owning the widget. | |
init_array | Initialize the w->nested_array . |
Implements NWidgetBase.
Definition at line 2131 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_TOP, WD_CLOSEBOX_BOTTOM, WD_CLOSEBOX_LEFT, WD_CLOSEBOX_TOP, WD_DEBUGBOX_BOTTOM, WD_DEBUGBOX_LEFT, WD_DEBUGBOX_TOP, WD_DROPDOWNTEXT_BOTTOM, WD_DROPDOWNTEXT_LEFT, WD_DROPDOWNTEXT_TOP, WD_FRAMERECT_BOTTOM, WD_FRAMERECT_LEFT, WD_FRAMERECT_TOP, WD_IMGBTN_BOTTOM, WD_IMGBTN_LEFT, WD_IMGBTN_TOP, WD_MATRIX_BOTTOM, WD_MATRIX_LEFT, WD_MATRIX_TOP, WD_RESIZEBOX_BOTTOM, WD_RESIZEBOX_LEFT, WD_RESIZEBOX_TOP, WD_SHADEBOX_BOTTOM, WD_SHADEBOX_LEFT, WD_SHADEBOX_TOP, WD_STICKYBOX_BOTTOM, WD_STICKYBOX_LEFT, 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.