OpenTTD
|
Implementation of the dropdown widget. More...
#include "../stdafx.h"
#include "../window_gui.h"
#include "../string_func.h"
#include "../strings_func.h"
#include "../window_func.h"
#include "dropdown_type.h"
#include "dropdown_widget.h"
#include "../safeguards.h"
Go to the source code of this file.
Data Structures | |
struct | DropdownWindow |
Drop-down menu window. More... |
Functions | |
void | ShowDropDownListAt (Window *w, const DropDownList *list, int selected, int button, Rect wi_rect, Colours wi_colour, bool auto_width, bool instant_close) |
Show a drop down list. | |
void | ShowDropDownList (Window *w, const 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) |
Show a dropdown menu window near a widget of the parent window. | |
int | HideDropDownMenu (Window *pw) |
Delete the drop-down menu from window pw. |
Variables | |
static const NWidgetPart | _nested_dropdown_menu_widgets [] |
static WindowDesc | _dropdown_desc (WDP_MANUAL, NULL, 0, 0, WC_DROPDOWN_MENU, WC_NONE, WDF_NO_FOCUS, _nested_dropdown_menu_widgets, lengthof(_nested_dropdown_menu_widgets)) |
Implementation of the dropdown widget.
Definition in file dropdown.cpp.
int HideDropDownMenu | ( | Window * | pw | ) |
Delete the drop-down menu from window pw.
pw | Parent window of the drop-down menu window |
-1
if the window was not found. Definition at line 466 of file dropdown.cpp.
References DropdownWindow::parent_button, DropdownWindow::parent_wnd_class, DropdownWindow::parent_wnd_num, WC_DROPDOWN_MENU, Window::window_class, and Window::window_number.
Referenced by DispatchLeftClickEvent(), NewGRFParametersWindow::OnClick(), AISettingsWindow::OnClick(), OrdersWindow::OnClick(), GameSettingsWindow::OnClick(), VehicleGroupWindow::OnInvalidateData(), OrdersWindow::OnInvalidateData(), VehicleGroupWindow::OnPaint(), and VehicleListWindow::OnPaint().
void ShowDropDownList | ( | Window * | w, |
const DropDownList * | list, | ||
int | selected, | ||
int | button, | ||
uint | width, | ||
bool | auto_width, | ||
bool | instant_close | ||
) |
Show a drop down list.
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 401 of file dropdown.cpp.
References _current_text_dir, NWidgetCore::colour, NWidgetBase::current_x, NWidgetBase::current_y, NWidgetCore::disp_flags, Window::GetWidget(), Window::LowerWidget(), ND_DROPDOWN_ACTIVE, NWID_BUTTON_DROPDOWN, NWidgetBase::pos_x, NWidgetBase::pos_y, Window::SetWidgetDirty(), ShowDropDownListAt(), TD_RTL, and NWidgetBase::type.
Referenced by GameOptionsWindow::OnClick(), ReplaceVehicleWindow::OnClick(), BuildAirportWindow::OnClick(), GenerateLandscapeWindow::OnClick(), VehicleGroupWindow::OnClick(), StoryBookWindow::OnClick(), NewGRFWindow::OnClick(), CreateScenarioWindow::OnClick(), OrdersWindow::OnClick(), VehicleListWindow::OnClick(), GameSettingsWindow::OnClick(), IndustryCargoesWindow::OnClick(), PopupMainToolbMenu(), SetDateWindow::ShowDateDropDown(), ShowDropDownMenu(), and ToolbarOptionsClick().
void ShowDropDownListAt | ( | Window * | w, |
const DropDownList * | list, | ||
int | selected, | ||
int | button, | ||
Rect | wi_rect, | ||
Colours | wi_colour, | ||
bool | auto_width, | ||
bool | instant_close | ||
) |
Show a drop down list.
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 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 337 of file dropdown.cpp.
References _current_text_dir, SmallVector< T, S >::Begin(), DeleteWindowById(), SmallVector< T, S >::End(), GetMainViewBottom(), GetMainViewTop(), Window::left, SmallVector< T, S >::Length(), max(), TD_RTL, Window::top, and WC_DROPDOWN_MENU.
Referenced by NewGRFParametersWindow::OnClick(), AISettingsWindow::OnClick(), GameSettingsWindow::OnClick(), and ShowDropDownList().
void ShowDropDownMenu | ( | Window * | w, |
const StringID * | strings, | ||
int | selected, | ||
int | button, | ||
uint32 | disabled_mask, | ||
uint32 | hidden_mask, | ||
uint | width | ||
) |
Show a dropdown menu window near a widget of the parent window.
The result code of the items is their index in the strings list.
w | Parent window that wants the dropdown menu. |
strings | Menu list, end with INVALID_STRING_ID |
selected | Index of initial selected item. |
button | Button widget number of the parent window w that wants the dropdown menu. |
disabled_mask | Bitmask for disabled items (items with their bit set are displayed, but not selectable in the dropdown list). |
hidden_mask | Bitmask for hidden items (items with their bit set are not copied to the dropdown list). |
width | Width of the dropdown menu. If 0 , use the width of parent widget button. |
Definition at line 442 of file dropdown.cpp.
References SmallVector< T, S >::Append(), HasBit(), INVALID_STRING_ID, SmallVector< T, S >::Length(), and ShowDropDownList().
Referenced by DisplayVehicleSortDropDown(), BuildBridgeWindow::OnClick(), ReplaceVehicleWindow::OnClick(), CompanyStationsWindow::OnClick(), GenerateLandscapeWindow::OnClick(), VehicleGroupWindow::OnClick(), NetworkGameWindow::OnClick(), TownDirectoryWindow::OnClick(), NetworkStartServerWindow::OnClick(), OrdersWindow::OnClick(), BuildVehicleWindow::OnClick(), IndustryDirectoryWindow::OnClick(), VehicleListWindow::OnClick(), StationViewWindow::OnClick(), and VehicleDetailsWindow::OnClick().
|
static |
Definition at line 73 of file dropdown.cpp.