OpenTTD Source 20241224-master-gee860a5c8e
DropDownString< TBase, TFs, TEnd > Class Template Reference

Drop down string component. More...

#include <dropdown_common_type.h>

Inheritance diagram for DropDownString< TBase, TFs, TEnd >:

Public Member Functions

template<typename... Args>
 DropDownString (StringID string, Args &&... args)
 
template<typename... Args>
 DropDownString (const std::string &string, Args &&... args)
 
void SetString (std::string &&string)
 
uint Height () const override
 
uint Width () const override
 
void Draw (const Rect &full, const Rect &r, bool sel, Colours bg_colour) const override
 

Static Public Member Functions

static bool NatSortFunc (std::unique_ptr< const DropDownListItem > const &first, std::unique_ptr< const DropDownListItem > const &second)
 Natural sorting comparator function for DropDownList::sort().
 

Private Attributes

std::string string
 String to be drawn.
 
Dimension dim
 Dimensions of string.
 

Detailed Description

template<class TBase, FontSize TFs = FS_NORMAL, bool TEnd = false>
class DropDownString< TBase, TFs, TEnd >

Drop down string component.

Template Parameters
TBaseBase component.
TFsFont size.
TEndPosition string at end if true, or start if false.

Definition at line 53 of file dropdown_common_type.h.

Constructor & Destructor Documentation

◆ DropDownString() [1/2]

template<class TBase , FontSize TFs = FS_NORMAL, bool TEnd = false>
template<typename... Args>
DropDownString< TBase, TFs, TEnd >::DropDownString ( StringID  string,
Args &&...  args 
)
inlineexplicit

Definition at line 58 of file dropdown_common_type.h.

◆ DropDownString() [2/2]

template<class TBase , FontSize TFs = FS_NORMAL, bool TEnd = false>
template<typename... Args>
DropDownString< TBase, TFs, TEnd >::DropDownString ( const std::string &  string,
Args &&...  args 
)
inlineexplicit

Definition at line 64 of file dropdown_common_type.h.

Member Function Documentation

◆ Draw()

template<class TBase , FontSize TFs = FS_NORMAL, bool TEnd = false>
void DropDownString< TBase, TFs, TEnd >::Draw ( const Rect full,
const Rect r,
bool  sel,
Colours  bg_colour 
) const
inlineoverride

Definition at line 83 of file dropdown_common_type.h.

◆ Height()

template<class TBase , FontSize TFs = FS_NORMAL, bool TEnd = false>
uint DropDownString< TBase, TFs, TEnd >::Height ( ) const
inlineoverride

Definition at line 76 of file dropdown_common_type.h.

◆ NatSortFunc()

template<class TBase , FontSize TFs = FS_NORMAL, bool TEnd = false>
static bool DropDownString< TBase, TFs, TEnd >::NatSortFunc ( std::unique_ptr< const DropDownListItem > const &  first,
std::unique_ptr< const DropDownListItem > const &  second 
)
inlinestatic

Natural sorting comparator function for DropDownList::sort().

Parameters
firstLeft side of comparison.
secondRight side of comparison.
Returns
true if first precedes second.
Warning
All items in the list need to be derivates of DropDownListStringItem.

Definition at line 97 of file dropdown_common_type.h.

References StrNaturalCompare().

◆ SetString()

template<class TBase , FontSize TFs = FS_NORMAL, bool TEnd = false>
void DropDownString< TBase, TFs, TEnd >::SetString ( std::string &&  string)
inline

Definition at line 70 of file dropdown_common_type.h.

◆ Width()

template<class TBase , FontSize TFs = FS_NORMAL, bool TEnd = false>
uint DropDownString< TBase, TFs, TEnd >::Width ( ) const
inlineoverride

Definition at line 81 of file dropdown_common_type.h.

Field Documentation

◆ dim

template<class TBase , FontSize TFs = FS_NORMAL, bool TEnd = false>
Dimension DropDownString< TBase, TFs, TEnd >::dim
private

Dimensions of string.

Definition at line 55 of file dropdown_common_type.h.

◆ string

template<class TBase , FontSize TFs = FS_NORMAL, bool TEnd = false>
std::string DropDownString< TBase, TFs, TEnd >::string
private

String to be drawn.

Definition at line 54 of file dropdown_common_type.h.


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