OpenTTD Source: src/widgets/dropdown_type.h File Reference

OpenTTD Source 12.2

Data Structures | Typedefs | Functions
dropdown_type.h File Reference
`#include "../window_type.h"`
`#include "../gfx_func.h"`
`#include "../core/smallvec_type.hpp"`
`#include "table/strings.h"`

Go to the source code of this file.

## Data Structures
class | DropDownListItem
| Base list item class from which others are derived. More...
class | DropDownListStringItem
| Common string list item. More...
class | DropDownListParamStringItem
| String list item with parameters. More...
class | DropDownListCharStringItem
| List item containing a C char string. More...
class | DropDownListIconItem
| List item with icon and string. 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, int button, Rect wi_rect, Colours wi_colour, bool auto_width=false, bool instant_close=false)
| Show a drop down list. More...
void | ShowDropDownList (Window *w, DropDownList &&list, int selected, int button, uint width=0, bool auto_width=false, bool instant_close=false)
| Show a drop down list. More...

## Detailed Description

Types related to the drop down widget.

Definition in file dropdown_type.h.

## Function Documentation

## ◆ ShowDropDownList()

void ShowDropDownList | ( | Window * | w,
|  | DropDownList && | list,
|  | int | selected,
|  | int | button,
|  | uint | width,
|  | bool | auto_width,
|  | bool | instant_close
| ) |  |

Show a drop down list.

Parameters

  w | Parent window for the list.
  list | Prepopulated DropDownList.
  selected | The initially selected list item.
  button | The widget within the parent window that is used to determine the list's location.
  width | Override the width determined by the selected widget.
  auto_width | Maximum width is determined by the widest item in the list.
  instant_close | Set to true if releasing mouse button should close the list regardless of where the cursor is.

Definition at line 443 of file dropdown.cpp.

References NWidgetCore::colour, Window::GetWidget(), and NWidgetBase::type.

Referenced by BuildAirportWindow::OnClick(), ReplaceVehicleWindow::OnClick(), GenerateLandscapeWindow::OnClick(), StoryBookWindow::OnClick(), CreateScenarioWindow::OnClick(), NetworkClientListWindow::OnClick(), GameSettingsWindow::OnClick(), PopupMainToolbMenu(), and ShowDropDownMenu().

## ◆ ShowDropDownListAt()

void ShowDropDownListAt | ( | Window * | w,
|  | DropDownList && | list,
|  | int | selected,
|  | int | button,
|  | Rect | wi_rect,
|  | Colours | wi_colour,
|  | bool | auto_width,
|  | bool | instant_close
| ) |  |

Show a drop down list.

Parameters

  w | Parent window for the list.
  list | Prepopulated DropDownList.
  selected | The initially selected list item.
  button | The 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_rect | Coord of the parent drop down button, used to position the dropdown menu.
  auto_width | The width is determined by the widest item in the list, in this case only one of left or right is used (depending on text direction).
  instant_close | Set to true if releasing mouse button should close the list regardless of where the cursor is.

Definition at line 356 of file dropdown.cpp.

References CloseWindowById(), GetMainViewBottom(), GetMainViewTop(), Window::top, and WC_DROPDOWN_MENU.