diff options
author | alberth <alberth@openttd.org> | 2009-11-07 11:26:23 +0000 |
---|---|---|
committer | alberth <alberth@openttd.org> | 2009-11-07 11:26:23 +0000 |
commit | 81796f10e54cb5a0bec73e55992dbef57f286349 (patch) | |
tree | 48aa2387116eb2e5c7483283ffb87ffe06a2df96 /src | |
parent | 61576c3184e47b34f8ce126aee10a812b1313e81 (diff) | |
download | openttd-81796f10e54cb5a0bec73e55992dbef57f286349.tar.xz |
(svn r17992) -Codechange: Merge some parameters of the dropdown menu.
Diffstat (limited to 'src')
-rw-r--r-- | src/widgets/dropdown.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp index 5a484f9a8..15aec16b5 100644 --- a/src/widgets/dropdown.cpp +++ b/src/widgets/dropdown.cpp @@ -88,20 +88,26 @@ static const NWidgetPart _nested_dropdown_menu_widgets[] = { EndContainer(), }; +/** Drop-down menu window */ struct DropdownWindow : Window { WindowClass parent_wnd_class; ///< Parent window class. WindowNumber parent_wnd_num; ///< Parent window number. byte parent_button; ///< Parent widget number where the window is dropped from. - DropDownList *list; + DropDownList *list; ///< List with dropdown menu items. int selected_index; ///< Index of the selected item in the list. - byte click_delay; + byte click_delay; ///< Timer to delay selection. bool drag_mode; bool instant_close; - int scrolling; - - DropdownWindow(int x, int y, int width, int height, const Widget *widget) : Window(x, y, width, height, WC_DROPDOWN_MENU, widget) + int scrolling; ///< If non-zero, auto-scroll the item list (one time). + + /** Create a dropdown menu. + * @param pos Topleft position of the dropdown menu window. + * @param size Size of the dropdown menu window. + * @param widget Widgets of the dropdown menu window. + */ + DropdownWindow(const Point &pos, const Dimension &size, const Widget *widget) : Window(pos.x, pos.y, size.width, size.height + 4, WC_DROPDOWN_MENU, widget) { - this->FindWindowPlacementAndResize(width, height); + this->FindWindowPlacementAndResize(size.width, size.height + 4); } ~DropdownWindow() @@ -351,7 +357,9 @@ void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, u const Widget *wid = InitializeWidgetArrayFromNestedWidgets(_nested_dropdown_menu_widgets, lengthof(_nested_dropdown_menu_widgets), _dropdown_menu_widgets, &generated_dropdown_menu_widgets); - DropdownWindow *dw = new DropdownWindow(w->left + wi_rect.left, top, width, height + 4, wid); + Point dw_pos = {w->left + wi_rect.left, top}; + Dimension dw_size = {width, height}; + DropdownWindow *dw = new DropdownWindow(dw_pos, dw_size, wid); dw->widget[DDM_ITEMS].colour = wi_colour; dw->widget[DDM_ITEMS].right = width - 1; |