OpenTTD
|
To make nested widgets easier to enter, nested widget parts have been created. More...
Data Structures | |
struct | NWidgetPartDataTip |
Widget part for storing data and tooltip information. More... | |
struct | NWidgetPartWidget |
Widget part for storing basic widget information. More... | |
struct | NWidgetPartPaddings |
Widget part for storing padding. More... | |
struct | NWidgetPartPIP |
Widget part for storing pre/inter/post spaces. More... | |
struct | NWidgetPartTextLines |
Widget part for storing minimal text line data. More... | |
struct | NWidgetPart |
Partial widget specification to allow NWidgets to be written nested. More... |
Functions | |
NWidgetContainer * | MakeNWidgets (const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container) |
Construct a nested widget tree from an array of parts. | |
NWidgetContainer * | MakeWindowNWidgetTree (const NWidgetPart *parts, int count, int *biggest_index, NWidgetStacked **shade_select) |
Make a nested widget tree for a window from a parts array. | |
static NWidgetPart | SetResize (int16 dx, int16 dy) |
Widget part function for setting the resize step. | |
static NWidgetPart | SetMinimalSize (int16 x, int16 y) |
Widget part function for setting the minimal size. | |
static NWidgetPart | SetMinimalTextLines (uint8 lines, uint8 spacing, FontSize size=FS_NORMAL) |
Widget part function for setting the minimal text lines. | |
static NWidgetPart | SetFill (uint fill_x, uint fill_y) |
Widget part function for setting filling. | |
static NWidgetPart | EndContainer () |
Widget part function for denoting the end of a container (horizontal, vertical, WWT_FRAME, WWT_INSET, or WWT_PANEL). | |
static NWidgetPart | SetDataTip (uint32 data, StringID tip) |
Widget part function for setting the data and tooltip. | |
static NWidgetPart | SetMatrixDataTip (uint8 cols, uint8 rows, StringID tip) |
Widget part function for setting the data and tooltip of WWT_MATRIX widgets. | |
static NWidgetPart | SetPadding (uint8 top, uint8 right, uint8 bottom, uint8 left) |
Widget part function for setting additional space around a widget. | |
static NWidgetPart | SetPadding (uint8 padding) |
Widget part function for setting a padding. | |
static NWidgetPart | SetPIP (uint8 pre, uint8 inter, uint8 post) |
Widget part function for setting a pre/inter/post spaces. | |
static NWidgetPart | SetScrollbar (int index) |
Attach a scrollbar to a widget. | |
static NWidgetPart | NWidget (WidgetType tp, Colours col, int16 idx=-1) |
Widget part function for starting a new 'real' widget. | |
static NWidgetPart | NWidget (WidgetType tp, NWidContainerFlags cont_flags=NC_NONE) |
Widget part function for starting a new horizontal container, vertical container, or spacer widget. | |
static NWidgetPart | NWidgetFunction (NWidgetFunctionType *func_ptr) |
Obtain a nested widget (sub)tree from an external source. |
To make nested widgets easier to enter, nested widget parts have been created.
They allow the tree to be defined in a flat array of parts.
NWidgetContainer* MakeNWidgets | ( | const NWidgetPart * | parts, |
int | count, | ||
int * | biggest_index, | ||
NWidgetContainer * | container | ||
) |
Construct a nested widget tree from an array of parts.
parts | Array with parts of the widgets. |
count | Length of the parts array. |
biggest_index | Pointer to biggest nested widget index collected in the tree. |
container | Container to add the nested widgets to. In case it is NULL a vertical container is used. |
biggest_index
!= NULL *biggest_index
contains the largest widget index of the tree and -1
if no index is used. Definition at line 2782 of file widget.cpp.
References MakeWidgetTree().
Referenced by MakeWindowNWidgetTree(), and NewGRFDisplay().
NWidgetContainer* MakeWindowNWidgetTree | ( | const NWidgetPart * | parts, |
int | count, | ||
int * | biggest_index, | ||
NWidgetStacked ** | shade_select | ||
) |
Make a nested widget tree for a window from a parts array.
Besides loading, it inserts a shading selection widget between the title bar and the window body if the first widget in the parts array looks like a title bar (it is a horizontal container with a caption widget) and has a shade box widget.
parts | Array with parts of the widgets. | |
count | Length of the parts array. | |
biggest_index | Pointer to biggest nested widget index collected in the tree. | |
[out] | shade_select | Pointer to the inserted shade selection widget (NULL if not unserted). |
biggest_index
!= NULL *biggest_index
contains the largest widget index of the tree and -1
if no index is used. Definition at line 2804 of file widget.cpp.
References NWidgetContainer::Add(), NWidgetContainer::GetWidgetOfType(), MakeNWidgets(), MakeWidgetTree(), max(), WWT_CAPTION, and WWT_SHADEBOX.
Referenced by Window::CreateNestedTree().
|
inlinestatic |
Widget part function for starting a new 'real' widget.
tp | Type of the new nested widget. |
col | Colour of the new widget. |
idx | Index of the widget in the widget array. |
Definition at line 1114 of file widget_type.h.
References NWidgetPartWidget::colour, NWidgetPartWidget::index, NWidgetPart::type, and NWidgetPart::widget.
|
inlinestatic |
Widget part function for starting a new horizontal container, vertical container, or spacer widget.
tp | Type of the new nested widget, #NWID_HORIZONTAL(_LTR), NWID_VERTICAL, NWID_SPACER, NWID_SELECTION, and NWID_MATRIX. |
cont_flags | Flags for the containers (#NWID_HORIZONTAL(_LTR) and NWID_VERTICAL). |
Definition at line 1131 of file widget_type.h.
References NWidgetPart::cont_flags, and NWidgetPart::type.
|
inlinestatic |
Obtain a nested widget (sub)tree from an external source.
func_ptr | Pointer to function that returns the tree. |
Definition at line 1146 of file widget_type.h.
References NWidgetPart::func_ptr, NWidgetPart::type, and WPT_FUNCTION.
|
inlinestatic |
Widget part function for setting the data and tooltip.
data | Data of the widget. |
tip | Tooltip of the widget. |
Definition at line 1014 of file widget_type.h.
References NWidgetPartDataTip::data, NWidgetPart::data_tip, NWidgetPartDataTip::tooltip, NWidgetPart::type, and WPT_DATATIP.
Referenced by GameOptionsWindow::OnInvalidateData(), SetMatrixDataTip(), SmallMapWindow::SetupWidgetData(), DepotWindow::SetupWidgetData(), and WaypointWindow::WaypointWindow().
|
inlinestatic |
Widget part function for setting filling.
fill_x | Horizontal filling step from minimal size. |
fill_y | Vertical filling step from minimal size. |
Definition at line 983 of file widget_type.h.
References NWidgetPart::type, WPT_FILL, and NWidgetPart::xy.
|
inlinestatic |
Widget part function for setting the data and tooltip of WWT_MATRIX widgets.
cols | Number of columns. 0 means to use draw columns with width according to the resize step size. |
rows | Number of rows. 0 means to use draw rows with height according to the resize step size. |
tip | Tooltip of the widget. |
Definition at line 1032 of file widget_type.h.
References MAT_COL_START, MAT_ROW_START, and SetDataTip().
|
inlinestatic |
Widget part function for setting the minimal size.
x | Horizontal minimal size. |
y | Vertical minimal size. |
Definition at line 947 of file widget_type.h.
References NWidgetPart::type, WPT_MINSIZE, and NWidgetPart::xy.
|
inlinestatic |
Widget part function for setting the minimal text lines.
lines | Number of text lines. |
spacing | Extra spacing required. |
size | Font size of text. |
Definition at line 965 of file widget_type.h.
References NWidgetPartTextLines::lines, NWidgetPartTextLines::size, NWidgetPartTextLines::spacing, NWidgetPart::text_lines, NWidgetPart::type, and WPT_MINTEXTLINES.
|
inlinestatic |
Widget part function for setting additional space around a widget.
Parameters start above the widget, and are specified in clock-wise direction.
top | The padding above the widget. |
right | The padding right of the widget. |
bottom | The padding below the widget. |
left | The padding left of the widget. |
Definition at line 1046 of file widget_type.h.
References NWidgetPartPaddings::left, NWidgetPart::padding, NWidgetPart::type, and WPT_PADDING.
Referenced by SetPadding().
|
inlinestatic |
Widget part function for setting a padding.
padding | The padding to use for all directions. |
Definition at line 1064 of file widget_type.h.
References SetPadding().
|
inlinestatic |
Widget part function for setting a pre/inter/post spaces.
pre | The amount of space before the first widget. |
inter | The amount of space between widgets. |
post | The amount of space after the last widget. |
Definition at line 1076 of file widget_type.h.
References NWidgetPart::pip, NWidgetPartPIP::post, NWidgetPart::type, and WPT_PIPSPACE.
|
inlinestatic |
Widget part function for setting the resize step.
dx | Horizontal resize step. 0 means no horizontal resizing. |
dy | Vertical resize step. 0 means no vertical resizing. |
Definition at line 930 of file widget_type.h.
References NWidgetPart::type, WPT_RESIZE, and NWidgetPart::xy.
|
inlinestatic |
Attach a scrollbar to a widget.
The scrollbar is controlled when using the mousewheel on the widget. Multiple widgets can refer to the same scrollbar to make the mousewheel work in all of them.
index | Widget index of the scrollbar. |
Definition at line 1095 of file widget_type.h.
References NWidgetPartWidget::index, NWidgetPart::type, NWidgetPart::widget, and WPT_SCROLLBAR.