# dropdown.cpp File Reference

Implementation of the dropdown widget. More...

`#include "../stdafx.h"`
`#include "../window_gui.h"`
`#include "../strings_func.h"`
`#include "../gfx_func.h"`
`#include "../window_func.h"`
`#include "../core/math_func.hpp"`
`#include "dropdown_type.h"`
`#include "table/strings.h"`

Go to the source code of this file.

## Data Structures

struct | DropdownWindow

## Functions

static void | DeleteDropDownList (DropDownList *list)
| Delete all items of a drop down list and the list itself.
void | ShowDropDownList (Window *w, DropDownList *list, int selected, int button, uint width, bool auto_width, bool instant_close)
| Show a drop down list.
void | ShowDropDownMenu (Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width)
int | HideDropDownMenu (Window *pw)
| Delete the drop-down menu from window pw.

## Variables

static const Widget | _dropdown_menu_widgets []

## Detailed Description

Implementation of the dropdown widget.

Definition in file dropdown.cpp.

## Function Documentation

static void DeleteDropDownList | ( | DropDownList * | list | ) | `[static]`

Delete all items of a drop down list and the list itself.

Parameters:

  | list | List to delete.

Definition at line 56 of file dropdown.cpp.

int HideDropDownMenu | ( | Window * | pw | ) |

Delete the drop-down menu from window pw.

Parameters:

  | pw | Parent window of the drop-down menu window

Definition at line 368 of file dropdown.cpp.

References Window::window_class, and Window::window_number.

Referenced by DispatchLeftClickEvent(), and VehicleListWindow::OnPaint().

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.

Parameters:

  | w | Parent window for the list.
  | list | Prepopulated DropDownList. Will be deleted when the list is closed.
  | 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 237 of file dropdown.cpp.

References Widget::bottom, Widget::colour, DeleteWindowById(), FindWindowById(), Window::height, DropDownListItem::Height(), Window::InvalidateWidget(), Window::left, Widget::left, Window::LowerWidget(), max(), Widget::right, Widget::top, Window::top, WDF_DEF_WIDGET, Window::widget, DropDownListItem::Width(), Window::window_class, and Window::window_number.

Referenced by NewGRFWindow::OnClick(), ReplaceVehicleWindow::OnClick(), PopupMainCompanyToolbMenu(), PopupMainToolbMenu(), ShowGroupActionDropdown(), and ShowTownnameDropdown().

## Variable Documentation

const Widget _dropdown_menu_widgets[]`[static]`

Initial value:

     {
    {      WWT_PANEL,   RESIZE_NONE,  COLOUR_END,     0, 0,     0, 0, 0x0, STR_NULL},
    {  WWT_SCROLLBAR,   RESIZE_NONE,  COLOUR_END,     0, 0,     0, 0, 0x0, STR_0190_SCROLL_BAR_SCROLLS_LIST},
    {   WIDGETS_END},
    }

Definition at line 65 of file dropdown.cpp.