OpenTTD Source 20260208-master-g43af8e94d0
DropDownListItem Class Reference

Base list item class from which others are derived. More...

#include <dropdown_type.h>

Inheritance diagram for DropDownListItem:
DropDownDivider< DropDownListItem > DropDownString< DropDownListItem > DropDownIcon< DropDownString< DropDownListItem > > DropDownToggle< DropDownString< DropDownListItem > > DropDownListColourItem< TSprite > DropDownMover< DropDownToggle< DropDownString< DropDownListItem > > >

Public Member Functions

 DropDownListItem (int result, bool masked=false, bool shaded=false)
virtual bool Selectable () const
 Can this dropdown item be selected?
virtual uint Height () const
 The height of this item.
virtual uint Width () const
 The width of this item.
virtual int OnClick (const Rect &r, const Point &pt) const
 Callback when this item is clicked.
virtual void Draw (const Rect &full, const Rect &r, bool sel, int click_result, Colours bg_colour) const
 Callback for drawing this item.
TextColour GetColour (bool sel) const
 Get the colour of the text.

Data Fields

int result
 Result value to return to window on selection.
bool masked
 Masked and unselectable item.
bool shaded
 Shaded item, affects text colour.

Detailed Description

Base list item class from which others are derived.

Definition at line 23 of file dropdown_type.h.

Constructor & Destructor Documentation

◆ DropDownListItem()

DropDownListItem::DropDownListItem ( int result,
bool masked = false,
bool shaded = false )
inlineexplicit

Definition at line 29 of file dropdown_type.h.

Member Function Documentation

◆ Draw()

virtual void DropDownListItem::Draw ( const Rect & full,
const Rect & r,
bool sel,
int click_result,
Colours bg_colour ) const
inlinevirtual

Callback for drawing this item.

Parameters
fullThe full bounds of the item including padding.
rThe bounds to draw the item in.
selWhether the item is elected or not.
click_resultWhen selected, the previously set 'click_result' otherwise -1.
bg_colourThe background color for the item.

Definition at line 69 of file dropdown_type.h.

References FILLRECT_CHECKER, GetColourGradient(), GfxFillRect(), and Rect.

◆ GetColour()

TextColour DropDownListItem::GetColour ( bool sel) const
inline

Get the colour of the text.

Parameters
selWhether the item is selected or not.
Returns
The text colour.

Definition at line 79 of file dropdown_type.h.

References TC_NO_SHADE.

◆ Height()

virtual uint DropDownListItem::Height ( ) const
inlinevirtual

The height of this item.

Returns
The height.

Definition at line 42 of file dropdown_type.h.

◆ OnClick()

virtual int DropDownListItem::OnClick ( const Rect & r,
const Point & pt ) const
inlinevirtual

Callback when this item is clicked.

Parameters
rThe bounds of this item.
ptThe location within the bounds where the item is clicked.
Returns
The 'click_result' for the OnDropdownClose callback on the dropdown's parent.

Definition at line 56 of file dropdown_type.h.

References Point, and Rect.

◆ Selectable()

virtual bool DropDownListItem::Selectable ( ) const
inlinevirtual

Can this dropdown item be selected?

Returns
Whether this item can be selected.

Definition at line 36 of file dropdown_type.h.

◆ Width()

virtual uint DropDownListItem::Width ( ) const
inlinevirtual

The width of this item.

Returns
The width.

Definition at line 48 of file dropdown_type.h.

Field Documentation

◆ masked

bool DropDownListItem::masked

Masked and unselectable item.

Definition at line 26 of file dropdown_type.h.

◆ result

int DropDownListItem::result

Result value to return to window on selection.

Definition at line 25 of file dropdown_type.h.

◆ shaded

bool DropDownListItem::shaded

Shaded item, affects text colour.

Definition at line 27 of file dropdown_type.h.


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