Public Member Functions | Data Fields

NWidgetCore Class Reference
[Hierarchical widgets]

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

#include <widget_type.h>

Inheritance diagram for NWidgetCore:
NWidgetResizeBase NWidgetBase ZeroedMemoryAllocator NWidgetBackground NWidgetLeaf NWidgetScrollbar NWidgetViewport

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)
NWidgetCoreGetWidgetFromPos (int x, int y)
 Retrieve a widget by its position.
bool IsHighlighted () const
 Return whether the widget is highlighted.
TextColour GetHighlightColour () const
 Return the colour of the highlight.
void SetHighlighted (TextColour highlight_colour)
 Highlight the widget or not.

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.
TextColour highlight_colour
 Colour of highlight.

Detailed Description

Base class for a 'real' widget.

Definition at line 281 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 824 of file widget.cpp.

References index, and scrollbar_index.


Member Function Documentation

TextColour NWidgetCore::GetHighlightColour (  )  const [inline, virtual]

Return the colour of the highlight.

Reimplemented from NWidgetBase.

Definition at line 325 of file widget_type.h.

References highlight_colour.

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 859 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 355 of file widget_type.h.

References disp_flags, HasBit(), and NDB_DISABLED.

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

bool NWidgetCore::IsHighlighted (  )  const [inline, virtual]

Return whether the widget is highlighted.

Reimplemented from NWidgetBase.

Definition at line 319 of file widget_type.h.

References disp_flags, HasBit(), and NDB_HIGHLIGHT.

bool NWidgetCore::IsLowered (  )  const [inline]

Return whether the widget is lowered.

Definition at line 340 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 848 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 349 of file widget_type.h.

References CLRBITS, disp_flags, ND_DISABLED, and SETBITS.

void NWidgetCore::SetHighlighted ( TextColour  highlight_colour  )  [inline, virtual]

Highlight the widget or not.

Parameters:
higlighted Widget must be highlighted (blink).

Reimplemented from NWidgetBase.

Definition at line 312 of file widget_type.h.

References CLRBITS, disp_flags, ND_HIGHLIGHT, and SETBITS.

void NWidgetCore::SetIndex ( int  index  ) 

Set index of the nested widget in the widget array.

Parameters:
index Index to use.

Definition at line 837 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 334 of file widget_type.h.

References CLRBITS, disp_flags, ND_LOWERED, and SETBITS.

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


Field Documentation

Tooltip of the widget.

See also:
Widget::tootips

Definition at line 303 of file widget_type.h.

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


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