# widget_type.h File Reference

Definitions about widgets. More...

`#include "core/alloc_type.hpp"`
`#include "core/bitmath_func.hpp"`
`#include "strings_type.h"`
`#include "gfx_type.h"`
`#include "window_type.h"`

Go to the source code of this file.

## Data Structures
class | NWidgetBase
| Baseclass for nested widgets. More...
class | NWidgetResizeBase
| Base class for a resizable nested widget. More...
class | NWidgetCore
| Base class for a 'real' widget. More...
class | NWidgetContainer
| Baseclass for container widgets. More...
class | NWidgetStacked
| Stacked widgets, widgets all occupying the same space in the window. More...
class | NWidgetPIPContainer
| Container with pre/inter/post child space. More...
class | NWidgetHorizontal
| Horizontal container. More...
class | NWidgetHorizontalLTR
| Horizontal container that doesn't change the direction of the widgets for RTL languages. More...
class | NWidgetVertical
| Vertical container. More...
class | NWidgetSpacer
| Spacer widget. More...
class | NWidgetBackground
| Nested widget with a child. More...
class | NWidgetViewport
| Nested widget to display a viewport in a window. More...
class | NWidgetLeaf
| Leaf widget. More...
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...
## Typedefs
typedef NWidgetBase * | NWidgetFunctionType (int *biggest_index)
| Pointer to function returning a nested widget.
## Enumerations
enum | { WIDGET_LIST_END = -1 }
enum | MatrixWidgetValues { MAT_COL_START = 0, MAT_COL_BITS = 8, MAT_ROW_START = 8, MAT_ROW_BITS = 8 }
| Bits of the WWT_MATRIX widget data. More...
enum | ArrowWidgetValues { AWV_DECREASE, AWV_INCREASE, AWV_LEFT, AWV_RIGHT }
| Values for an arrow widget. More...
enum | WidgetType { WWT_EMPTY, WWT_PANEL, WWT_INSET, WWT_IMGBTN, WWT_IMGBTN_2, WWT_TEXTBTN, WWT_TEXTBTN_2, WWT_LABEL, WWT_TEXT, WWT_MATRIX, WWT_SCROLLBAR, WWT_FRAME, WWT_CAPTION, WWT_HSCROLLBAR, WWT_SHADEBOX, WWT_STICKYBOX, WWT_SCROLL2BAR, WWT_RESIZEBOX, WWT_CLOSEBOX, WWT_DROPDOWN, WWT_EDITBOX, WWT_LAST, NWID_HORIZONTAL, NWID_HORIZONTAL_LTR, NWID_VERTICAL, NWID_SPACER, NWID_SELECTION, NWID_VIEWPORT, NWID_BUTTON_DROPDOWN, NWID_BUTTON_ARROW, WPT_RESIZE, WPT_MINSIZE, WPT_MINTEXTLINES, WPT_FILL, WPT_DATATIP, WPT_PADDING, WPT_PIPSPACE, WPT_ENDCONTAINER, WPT_FUNCTION, WWT_MASK = 0x7F, WWB_PUSHBUTTON = 1 << 7, WWT_PUSHBTN = WWT_PANEL | WWB_PUSHBUTTON, WWT_PUSHTXTBTN = WWT_TEXTBTN | WWB_PUSHBUTTON, WWT_PUSHIMGBTN = WWT_IMGBTN | WWB_PUSHBUTTON }
| Window widget types, nested widget types, and nested widget part types. More...
enum | SizingType { ST_SMALLEST, ST_RESIZE }
| Different forms of sizing nested widgets, using NWidgetBase::AssignSizePosition(). More...
enum | NWidgetDisplay { NDB_LOWERED = 0, NDB_DISABLED = 1, NDB_NO_TRANSPARENCY = 2, NDB_SHADE_GREY = 3, NDB_SHADE_DIMMED = 4, NDB_DROPDOWN_ACTIVE = 5, ND_LOWERED = 1 << NDB_LOWERED, ND_DISABLED = 1 << NDB_DISABLED, ND_NO_TRANSPARENCY = 1 << NDB_NO_TRANSPARENCY, ND_SHADE_GREY = 1 << NDB_SHADE_GREY, ND_SHADE_DIMMED = 1 << NDB_SHADE_DIMMED, ND_DROPDOWN_ACTIVE = 1 << NDB_DROPDOWN_ACTIVE }
| Nested widget flags that affect display and interaction withe 'real' widgets. More...
enum | StackedZeroSizePlanes { SZSP_VERTICAL = INT_MAX / 2, SZSP_HORIZONTAL, SZSP_NONE, SZSP_BEGIN = SZSP_VERTICAL }
| Display planes with zero size for NWidgetStacked. More...
enum | NWidContainerFlags { NCB_EQUALSIZE = 0, NC_NONE = 0, NC_EQUALSIZE = 1 << NCB_EQUALSIZE }
| Nested widget container flags,. More...
## Functions
| DECLARE_ENUM_AS_BIT_SET (NWidgetDisplay)
| DECLARE_ENUM_AS_BIT_SET (NWidContainerFlags)
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 (uint16 data, StringID tip)
| Widget part function for setting the data and tooltip.
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 | 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.
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.

## Detailed Description

Definitions about widgets.

Definition in file widget_type.h.

## Typedef Documentation

typedef NWidgetBase* NWidgetFunctionType(int *biggest_index)

Pointer to function returning a nested widget.

Parameters:

  | biggest_index | Pointer to storage for collecting the biggest index used in the nested widget.

Returns:
  Nested widget (tree).

Postcondition:
  `*biggest_index` must contain the value of the biggest index in the returned tree.

Definition at line 574 of file widget_type.h.

## Enumeration Type Documentation

anonymous enum

Enumerator:

  WIDGET_LIST_END | indicate the end of widgets' list for vararg functions

Definition at line 21 of file widget_type.h.

enum ArrowWidgetValues

Values for an arrow widget.

Enumerator:

  AWV_DECREASE | Arrow to the left or in case of RTL to the right.
  AWV_INCREASE | Arrow to the right or in case of RTL to the left.
  AWV_LEFT | Force the arrow to the left.
  AWV_RIGHT | Force the arrow to the right.

Definition at line 37 of file widget_type.h.

enum MatrixWidgetValues

Bits of the WWT_MATRIX widget data.

Enumerator:

  MAT_COL_START | Lowest bit of the number of columns.
  MAT_COL_BITS | Number of bits for the number of columns in the matrix.
  MAT_ROW_START | Lowest bit of the number of rows.
  MAT_ROW_BITS | Number of bits for the number of rows in the matrix.

Definition at line 26 of file widget_type.h.

enum NWidContainerFlags

Nested widget container flags,.

Enumerator:

  NCB_EQUALSIZE | Containers should keep all their (resizing) children equally large.
  NC_NONE | All flags cleared.
  NC_EQUALSIZE | Value of the NCB_EQUALSIZE flag.

Definition at line 355 of file widget_type.h.

enum NWidgetDisplay

Nested widget flags that affect display and interaction withe 'real' widgets.

Enumerator:

  NDB_LOWERED | Widget is lowered (pressed down) bit.
  NDB_DISABLED | Widget is disabled (greyed out) bit.
  NDB_NO_TRANSPARENCY | Viewport is never transparent.
  NDB_SHADE_GREY | Shade viewport to grey-scale.
  NDB_SHADE_DIMMED | Display dimmed colours in the viewport.
  NDB_DROPDOWN_ACTIVE | Dropdown menu of the button dropdown widget is active. See also: NWID_BUTTON_DRPDOWN
  ND_LOWERED | Bit value of the lowered flag.
  ND_DISABLED | Bit value of the disabled flag.
  ND_NO_TRANSPARENCY | Bit value of the 'no transparency' flag.
  ND_SHADE_GREY | Bit value of the 'shade to grey' flag.
  ND_SHADE_DIMMED | Bit value of the 'dimmed colours' flag.
  ND_DROPDOWN_ACTIVE | Bit value of the 'dropdown active' flag.

Definition at line 220 of file widget_type.h.

enum SizingType

Different forms of sizing nested widgets, using NWidgetBase::AssignSizePosition().

Enumerator:

  ST_SMALLEST | Initialize nested widget tree to smallest size. Also updates current_x and current_y.
  ST_RESIZE | Resize the nested widget tree.

Definition at line 107 of file widget_type.h.

enum StackedZeroSizePlanes

Display planes with zero size for NWidgetStacked.

Enumerator:

  SZSP_VERTICAL | Display plane with zero size horizontally, and filling and resizing vertically.
  SZSP_HORIZONTAL | Display plane with zero size vertically, and filling and resizing horizontally.
  SZSP_NONE | Display plane with zero size in both directions (none filling and resizing).
  SZSP_BEGIN | First zero-size plane.

Definition at line 318 of file widget_type.h.

enum WidgetType

Window widget types, nested widget types, and nested widget part types.

Enumerator:

  WWT_EMPTY | Empty widget, place holder to reserve space in widget array.
  WWT_PANEL | Simple depressed panel.
  WWT_INSET | Pressed (inset) panel, most commonly used as combo box _text_ area.
  WWT_IMGBTN | Button with image.
  WWT_IMGBTN_2 | Button with diff image when clicked.
  WWT_TEXTBTN | Button with text.
  WWT_TEXTBTN_2 | Button with diff text when clicked.
  WWT_LABEL | Centered label.
  WWT_TEXT | Pure simple text.
  WWT_MATRIX | Grid of rows and columns. See also: MatrixWidgetValues
  WWT_SCROLLBAR | Vertical scrollbar.
  WWT_FRAME | Frame.
  WWT_CAPTION | Window caption (window title between closebox and stickybox).
  WWT_HSCROLLBAR | Horizontal scrollbar.
  WWT_SHADEBOX | Shade box (at top-right of a window, between caption and stickybox).
  WWT_STICKYBOX | Sticky box (normally at top-right of a window).
  WWT_SCROLL2BAR | 2nd vertical scrollbar
  WWT_RESIZEBOX | Resize box (normally at bottom-right of a window).
  WWT_CLOSEBOX | Close box (at top-left of a window).
  WWT_DROPDOWN | Drop down list.
  WWT_EDITBOX | a textbox for typing
  WWT_LAST | Last Item. use WIDGETS_END to fill up padding!!
  NWID_HORIZONTAL | Horizontal container.
  NWID_HORIZONTAL_LTR | Horizontal container that doesn't change the order of the widgets for RTL languages.
  NWID_VERTICAL | Vertical container.
  NWID_SPACER | Invisible widget that takes some space.
  NWID_SELECTION | Stacked widgets, only one visible at a time (eg in a panel with tabs).
  NWID_VIEWPORT | Nested widget containing a viewport.
  NWID_BUTTON_DROPDOWN | Button with a drop-down.
  NWID_BUTTON_ARROW | Button with an arrow.
  WPT_RESIZE | Widget part for specifying resizing.
  WPT_MINSIZE | Widget part for specifying minimal size.
  WPT_MINTEXTLINES | Widget part for specifying minimal number of lines of text.
  WPT_FILL | Widget part for specifying fill.
  WPT_DATATIP | Widget part for specifying data and tooltip.
  WPT_PADDING | Widget part for specifying a padding.
  WPT_PIPSPACE | Widget part for specifying pre/inter/post space for containers.
  WPT_ENDCONTAINER | Widget part to denote end of a container.
  WPT_FUNCTION | Widget part for calling a user function.

Definition at line 47 of file widget_type.h.