summaryrefslogtreecommitdiff
path: root/src/widgets
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-05-04 18:42:49 +0000
committeralberth <alberth@openttd.org>2009-05-04 18:42:49 +0000
commit34066a60272e65bf6c8a966e50474ec69ccef374 (patch)
treeb940549066a0bdb6454708dfe1a3b3ffe0d08bc4 /src/widgets
parentefde51e4523b4e74f16b43579d7894ac3387dab0 (diff)
downloadopenttd-34066a60272e65bf6c8a966e50474ec69ccef374.tar.xz
(svn r16227) -Codechange: Added nested widgets for error windows, tooltip window, and dropdown window.
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dropdown.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index 3c3f4fb6a..6a0e015b8 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -69,6 +69,13 @@ static const Widget _dropdown_menu_widgets[] = {
{ WIDGETS_END},
};
+static const NWidgetPart _nested_dropdown_menu_widgets[] = {
+ NWidget(NWID_LAYERED),
+ NWidget(WWT_PANEL, COLOUR_END, 0), SetMinimalSize(1, 1), EndContainer(),
+ NWidget(WWT_SCROLLBAR, COLOUR_END, 1), SetMinimalSize(1, 1),
+ EndContainer(),
+};
+
struct DropdownWindow : Window {
WindowClass parent_wnd_class;
WindowNumber parent_wnd_num;
@@ -238,6 +245,8 @@ struct DropdownWindow : Window {
void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, uint width, bool auto_width, bool instant_close)
{
+ static Widget *generated_dropdown_menu_widgets = NULL;
+
DeleteWindowById(WC_DROPDOWN_MENU, 0);
w->LowerWidget(button);
@@ -302,12 +311,9 @@ void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, u
if (auto_width) width = max(width, max_item_width);
- DropdownWindow *dw = new DropdownWindow(
- w->left + wi->left,
- top,
- width,
- height + 4,
- _dropdown_menu_widgets);
+ 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->left, top, width, height + 4, wid);
dw->widget[0].colour = wi->colour;
dw->widget[0].right = width - 1;