OpenTTD Source 20260421-master-gc2fbc6fdeb
Button< T > Class Template Reference

Template version of Button, with callback support. More...

Inheritance diagram for Button< T >:
ButtonCommon

Public Member Functions

 Button (SpriteID sprite, StringID tooltip, Colours colour, T id, ButtonCallback proc, bool disabled=false)
 Create the button.
void OnClick (struct NetworkClientListWindow *w, Point pt) override
 OnClick handler for when the button is pressed.
Public Member Functions inherited from ButtonCommon
 ButtonCommon (SpriteID sprite, StringID tooltip, Colours colour, bool disabled=false)
 Create the button.
virtual ~ButtonCommon ()=default
 Ensure the destructor of the sub classes are called as well.

Private Types

typedef void(* ButtonCallback) (struct NetworkClientListWindow *w, Point pt, T id)
 Callback function to call on click.

Private Attributes

T id
 ID this button belongs to.
ButtonCallback proc
 Callback proc to call when button is pressed.

Additional Inherited Members

Data Fields inherited from ButtonCommon
SpriteID sprite
 The sprite to use on the button.
StringID tooltip
 The tooltip of the button.
Colours colour
 The colour of the button.
bool disabled
 Is the button disabled?
uint height
 Calculated height of the button.
uint width
 Calculated width of the button.

Detailed Description

template<typename T>
class Button< T >

Template version of Button, with callback support.

Definition at line 1393 of file network_gui.cpp.

Member Typedef Documentation

◆ ButtonCallback

template<typename T>
typedef void(* Button< T >::ButtonCallback) (struct NetworkClientListWindow *w, Point pt, T id)
private

Callback function to call on click.

Definition at line 1395 of file network_gui.cpp.

Constructor & Destructor Documentation

◆ Button()

template<typename T>
Button< T >::Button ( SpriteID sprite,
StringID tooltip,
Colours colour,
T id,
ButtonCallback proc,
bool disabled = false )
inline

Create the button.

Parameters
spriteThe sprite to draw on the button.
tooltipThe tooltip of the button.
colourThe colour of the button.
idThe identifier of the object this button belongs to.
procThe callback to call upon clicking.
disabledWhether the button is disabled or not.

Definition at line 1409 of file network_gui.cpp.

Member Function Documentation

◆ OnClick()

template<typename T>
void Button< T >::OnClick ( struct NetworkClientListWindow * w,
Point pt )
inlineoverridevirtual

OnClick handler for when the button is pressed.

Parameters
wThe window the click was in.
ptThe location the click was at.

Implements ButtonCommon.

Definition at line 1417 of file network_gui.cpp.

Field Documentation

◆ id

template<typename T>
T Button< T >::id
private

ID this button belongs to.

Definition at line 1396 of file network_gui.cpp.

◆ proc

template<typename T>
ButtonCallback Button< T >::proc
private

Callback proc to call when button is pressed.

Definition at line 1397 of file network_gui.cpp.

Referenced by Button< CompanyID >::OnClick().


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