# NWidgetCore Class Reference
[Hierarchical widgets]

Base class for a 'real' widget. More...

`#include <widget_type.h>`

Inheritance diagram for NWidgetCore:

## Public Member Functions
| NWidgetCore (WidgetType tp, Colours colour, uint fill_x, uint fill_y, uint16 widget_data, StringID tool_tip)
| Initialization of a 'real' widget.
void | SetIndex (int index)
| Set index of the nested widget in the widget array.
void | SetDataTip (uint16 widget_data, StringID tool_tip)
| Set data and tool tip of the nested widget.
void | SetLowered (bool lowered)
| Lower or raise the widget.
bool | IsLowered () const
| Return whether the widget is lowered.
void | SetDisabled (bool disabled)
| Disable (grey-out) or enable the widget.
bool | IsDisabled () const
| Return whether the widget is disabled.
void | FillNestedArray (NWidgetBase **array, uint length)
NWidgetCore * | GetWidgetFromPos (int x, int y)
| Retrieve a widget by its position.
## Data Fields
NWidgetDisplay | disp_flags
| Flags that affect display and interaction with the widget.
Colours | colour
| Colour of this widget.
int | index
| Index of the nested widget in the widget array of the window (`-1` means 'not used').
uint16 | widget_data
| Data of the widget.
StringID | tool_tip
| Tooltip of the widget.
int | scrollbar_index
| Index of an attached scrollbar.

## Detailed Description

Base class for a 'real' widget.

Definition at line 274 of file widget_type.h.

## Constructor & Destructor Documentation

NWidgetCore::NWidgetCore | ( | WidgetType | tp,
|  | Colours | colour,
|  | uint | fill_x,
|  | uint | fill_y,
|  | uint16 | widget_data,
|  | StringID | tool_tip |
| ) |  |  |

Initialization of a 'real' widget.

Parameters:

  | tp | Type of the widget.
  | colour | Colour of the widget.
  | fill_x | Default horizontal filling.
  | fill_y | Default vertical filling.
  | widget_data | Data component of the widget.

See also:
  Widget::data

Parameters:

  | tool_tip | Tool tip of the widget.

See also:
  Widget::tootips

Definition at line 780 of file widget.cpp.

References index, and scrollbar_index.

## Member Function Documentation

NWidgetCore * NWidgetCore::GetWidgetFromPos | ( | int | x,
|  | int | y |
| ) |  |  | `[virtual]`

Retrieve a widget by its position.

Parameters:

  | x | Horizontal position relative to the left edge of the window.
  | y | Vertical position relative to the top edge of the window.

Returns:
  Returns the deepest nested widget that covers the given position, or `NULL` if no widget can be found.

Implements NWidgetBase.

Reimplemented in NWidgetBackground.

Definition at line 815 of file widget.cpp.

References NWidgetBase::current_x, NWidgetBase::current_y, IsInsideBS(), NWidgetBase::pos_x, and NWidgetBase::pos_y.

Referenced by NWidgetMatrix::GetWidgetFromPos(), NWidgetPIPContainer::GetWidgetFromPos(), NWidgetStacked::GetWidgetFromPos(), NWidgetToolbarContainer::GetWidgetFromPos(), NWidgetSmallmapDisplay::GetWidgetFromPos(), and NWidgetServerListHeader::GetWidgetFromPos().

bool NWidgetCore::IsDisabled | ( |  | ) | const`[inline]`

Return whether the widget is disabled.

Definition at line 322 of file widget_type.h.

References disp_flags, HasBit(), and NDB_DISABLED.

Referenced by DispatchLeftClickEvent(), NWidgetLeaf::Draw(), NWidgetScrollbar::Draw(), NWidgetBackground::Draw(), SelectCompanyManagerFaceWindow::DrawFaceStringLabel(), and AIDebugWindow::OnPaint().

bool NWidgetCore::IsLowered | ( |  | ) | const`[inline]`

Return whether the widget is lowered.

Definition at line 307 of file widget_type.h.

References disp_flags, HasBit(), and NDB_LOWERED.

Referenced by NWidgetLeaf::Draw(), and SelectCompanyManagerFaceWindow::DrawFaceStringLabel().

void NWidgetCore::SetDataTip | ( | uint16 | widget_data,
|  | StringID | tool_tip |
| ) |  |  |

Set data and tool tip of the nested widget.

Parameters:

  | widget_data | Data to use.
  | tool_tip | Tool tip string to use.

Definition at line 804 of file widget.cpp.

Referenced by CargoWidgets(), MakeCompanyButtonRows(), MakeNWidgetCompanyLines(), MakePerformanceDetailPanels(), NWidgetLeaf::NWidgetLeaf(), NWidgetScrollbar::NWidgetScrollbar(), and StationViewWindow::OnClick().

void NWidgetCore::SetDisabled | ( | bool | disabled | ) | `[inline]`

Disable (grey-out) or enable the widget.

Parameters:

  | disabled | Widget must be disabled.

Definition at line 316 of file widget_type.h.

References CLRBITS, disp_flags, ND_DISABLED, and SETBITS.

Referenced by AIDebugWindow::OnPaint().

void NWidgetCore::SetIndex | ( | int | index | ) |

Set index of the nested widget in the widget array.

Parameters:

  | index | Index to use.

Definition at line 793 of file widget.cpp.

Referenced by NWidgetBackground::NWidgetBackground(), NWidgetLeaf::NWidgetLeaf(), and NWidgetScrollbar::NWidgetScrollbar().

void NWidgetCore::SetLowered | ( | bool | lowered | ) | `[inline]`

Lower or raise the widget.

Parameters:

  | lowered | Widget must be lowered (drawn pressed down).

Definition at line 301 of file widget_type.h.

References CLRBITS, disp_flags, ND_LOWERED, and SETBITS.

Referenced by NWidgetMatrix::Draw(), and MakeCargoButtons().

## Field Documentation

StringID NWidgetCore::tool_tip

Tooltip of the widget.

See also:
  Widget::tootips

Definition at line 293 of file widget_type.h.

Referenced by DispatchHoverEvent(), DispatchRightClickEvent(), MakeCargoButtons(), and MakeNWidget().

uint16 NWidgetCore::widget_data

Data of the widget.

See also:
  Widget::data

Definition at line 292 of file widget_type.h.

Referenced by NWidgetLeaf::Draw(), NWidgetBackground::Draw(), MakeNWidget(), VehicleDetailsWindow::OnResize(), NewGRFParametersWindow::OnResize(), VehicleGroupWindow::OnResize(), DepotWindow::OnResize(), AISettingsWindow::OnResize(), AIListWindow::OnResize(), NWidgetLeaf::SetupSmallestSize(), and NWidgetBackground::SetupSmallestSize().

The documentation for this class was generated from the following files:

- src/widget_type.h
- src/widget.cpp