summaryrefslogtreecommitdiff
path: root/src/widgets
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2008-04-09 23:00:12 +0000
committerrubidium <rubidium@openttd.org>2008-04-09 23:00:12 +0000
commit845c5d0a495e3ea0b05d1d223f9c569992de1e8a (patch)
tree31e91bb295634439e2d248e142cae0410d992fe4 /src/widgets
parent73392ba85e0fd9148b91f97cb7a108b3eea8a638 (diff)
downloadopenttd-845c5d0a495e3ea0b05d1d223f9c569992de1e8a.tar.xz
(svn r12644) -Codechange: rework the order gui a little to prepare it for some future changes.
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/dropdown.cpp12
-rw-r--r--src/widgets/dropdown_func.h2
-rw-r--r--src/widgets/dropdown_type.h3
3 files changed, 10 insertions, 7 deletions
diff --git a/src/widgets/dropdown.cpp b/src/widgets/dropdown.cpp
index 89e336a58..70eb81b64 100644
--- a/src/widgets/dropdown.cpp
+++ b/src/widgets/dropdown.cpp
@@ -201,7 +201,7 @@ static void DropDownMenuWndProc(Window *w, WindowEvent *e)
}
}
-void ShowDropDownList(Window *w, DropDownList *list, int selected, int button)
+void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, uint width)
{
bool is_dropdown_menu_shown = w->IsWidgetLowered(button);
@@ -246,17 +246,19 @@ void ShowDropDownList(Window *w, DropDownList *list, int selected, int button)
}
}
+ if (width == 0) width = wi->right - wi->left + 1;
+
Window *dw = AllocateWindow(
w->left + wi->left,
top,
- wi->right - wi->left + 1,
+ width,
height,
DropDownMenuWndProc,
WC_DROPDOWN_MENU,
_dropdown_menu_widgets);
dw->widget[0].color = wi->color;
- dw->widget[0].right = wi->right - wi->left;
+ dw->widget[0].right = width + 1;
dw->widget[0].bottom = height - 1;
dw->SetWidgetHiddenState(1, !scroll);
@@ -286,7 +288,7 @@ void ShowDropDownList(Window *w, DropDownList *list, int selected, int button)
WP(dw, dropdown_d).drag_mode = true;
}
-void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask)
+void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width)
{
/* Don't create a new list if we're just closing an existing menu */
if (w->IsWidgetLowered(button)) {
@@ -310,7 +312,7 @@ void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int butt
return;
}
- ShowDropDownList(w, list, selected, button);
+ ShowDropDownList(w, list, selected, button, width);
}
/**
diff --git a/src/widgets/dropdown_func.h b/src/widgets/dropdown_func.h
index dd6b430bc..ac0e0a906 100644
--- a/src/widgets/dropdown_func.h
+++ b/src/widgets/dropdown_func.h
@@ -4,7 +4,7 @@
#define WIDGETS_DROPDOWN_FUNC_H
/* Show drop down menu containing a fixed list of strings */
-void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask);
+void ShowDropDownMenu(Window *w, const StringID *strings, int selected, int button, uint32 disabled_mask, uint32 hidden_mask, uint width = 0);
/* Hide drop down menu of a parent window */
void HideDropDownMenu(Window *pw);
diff --git a/src/widgets/dropdown_type.h b/src/widgets/dropdown_type.h
index 419c6fbc2..29a40962c 100644
--- a/src/widgets/dropdown_type.h
+++ b/src/widgets/dropdown_type.h
@@ -60,7 +60,8 @@ typedef std::list<DropDownListItem *> DropDownList;
* @param selected The initially selected list item.
* @param button The widget within the parent window that is used to determine
* the list's location.
+ * @param width Override the width determined by the selected widget.
*/
-void ShowDropDownList(Window *w, DropDownList *list, int selected, int button);
+void ShowDropDownList(Window *w, DropDownList *list, int selected, int button, uint width = 0);
#endif /* WIDGETS_DROPDOWN_TYPE_H */