OpenTTD Source 20241224-master-gf74b0cf984
dropdown_type.h File Reference

Types related to the drop down widget. More...

#include "window_type.h"
#include "gfx_func.h"
#include "gfx_type.h"
#include "palette_func.h"
#include "window_gui.h"

Go to the source code of this file.

Data Structures

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

Typedefs

typedef std::vector< std::unique_ptr< const DropDownListItem > > DropDownList
 A drop down list is a collection of drop down list items.
 

Functions

void ShowDropDownListAt (Window *w, DropDownList &&list, int selected, WidgetID button, Rect wi_rect, Colours wi_colour, bool instant_close=false, bool persist=false)
 Show a drop down list.
 
void ShowDropDownList (Window *w, DropDownList &&list, int selected, WidgetID button, uint width=0, bool instant_close=false, bool persist=false)
 Show a drop down list.
 
Dimension GetDropDownListDimension (const DropDownList &list)
 Determine width and height required to fully display a DropDownList.
 
void ReplaceDropDownList (Window *parent, DropDownList &&list)
 

Detailed Description

Types related to the drop down widget.

Definition in file dropdown_type.h.

Typedef Documentation

◆ DropDownList

typedef std::vector<std::unique_ptr<const DropDownListItem> > DropDownList

A drop down list is a collection of drop down list items.

Definition at line 50 of file dropdown_type.h.

Function Documentation

◆ GetDropDownListDimension()

Dimension GetDropDownListDimension ( const DropDownList list)

Determine width and height required to fully display a DropDownList.

Parameters
listThe list.
Returns
Dimension required to display the list.

Definition at line 363 of file dropdown.cpp.

References WidgetDimensions::dropdowntext, RectPadding::Horizontal(), and WidgetDimensions::scaled.

Referenced by DropdownWindow::UpdateSizeAndPosition(), BuildVehicleWindow::UpdateWidgetSize(), VehicleGroupWindow::UpdateWidgetSize(), GameOptionsWindow::UpdateWidgetSize(), and VehicleListWindow::UpdateWidgetSize().

◆ ReplaceDropDownList()

void ReplaceDropDownList ( Window parent,
DropDownList &&  list 
)

Definition at line 352 of file dropdown.cpp.

◆ ShowDropDownList()

void ShowDropDownList ( Window w,
DropDownList &&  list,
int  selected,
WidgetID  button,
uint  width,
bool  instant_close,
bool  persist 
)

Show a drop down list.

Parameters
wParent window for the list.
listPrepopulated DropDownList.
selectedThe initially selected list item.
buttonThe widget within the parent window that is used to determine the list's location.
widthOverride the minimum width determined by the selected widget and list contents.
instant_closeSet to true if releasing mouse button should close the list regardless of where the cursor is.
persistSet if this dropdown should stay open after an option is selected.

Definition at line 404 of file dropdown.cpp.

References _current_text_dir, NWidgetCore::colour, NWidgetCore::disp_flags, Window::GetWidget(), ND_DROPDOWN_ACTIVE, NWID_BUTTON_DROPDOWN, ScaleGUITrad(), NWidgetBase::SetDirty(), NWidgetCore::SetLowered(), ShowDropDownListAt(), TD_RTL, and NWidgetBase::type.

Referenced by BuildAirportWindow::OnClick(), ReplaceVehicleWindow::OnClick(), BuildVehicleWindow::OnClick(), GenerateLandscapeWindow::OnClick(), CreateScenarioWindow::OnClick(), VehicleGroupWindow::OnClick(), IndustryDirectoryWindow::OnClick(), IndustryCargoesWindow::OnClick(), MusicTrackSelectionWindow::OnClick(), NetworkStartServerWindow::OnClick(), NetworkClientListWindow::OnClick(), NewGRFWindow::OnClick(), OrdersWindow::OnClick(), GameOptionsWindow::OnClick(), GameSettingsWindow::OnClick(), CompanyStationsWindow::OnClick(), StoryBookWindow::OnClick(), TextfileWindow::OnClick(), VehicleListWindow::OnClick(), PopupMainToolbarMenu(), SetDateWindow::ShowDateDropDown(), ShowDropDownMenu(), and ToolbarOptionsClick().

◆ ShowDropDownListAt()

void ShowDropDownListAt ( Window w,
DropDownList &&  list,
int  selected,
WidgetID  button,
Rect  wi_rect,
Colours  wi_colour,
bool  instant_close,
bool  persist 
)

Show a drop down list.

Parameters
wParent window for the list.
listPrepopulated DropDownList.
selectedThe initially selected list item.
buttonThe widget which is passed to Window::OnDropdownSelect and OnDropdownClose. Unless you override those functions, this should be then widget index of the dropdown button.
wi_rectCoord of the parent drop down button, used to position the dropdown menu.
instant_closeSet to true if releasing mouse button should close the list regardless of where the cursor is.
persistSet if this dropdown should stay open after an option is selected.

Definition at line 386 of file dropdown.cpp.

References CloseWindowByClass(), and WC_DROPDOWN_MENU.

Referenced by GSConfigWindow::OnClick(), NewGRFParametersWindow::OnClick(), ScriptSettingsWindow::OnClick(), GameSettingsWindow::OnClick(), NetworkClientListWindow::OnClickClientAdmin(), NetworkClientListWindow::OnClickCompanyAdmin(), and ShowDropDownList().