summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorrubidium <rubidium@openttd.org>2009-11-06 20:26:28 +0000
committerrubidium <rubidium@openttd.org>2009-11-06 20:26:28 +0000
commit0c005f9cfaf99d5c35a1a0a6b3a503fd740e7841 (patch)
tree38c964760fd34f68e2878338335a5d6f0bc1dc95 /src
parent8e9cceab4ea3e15302927b35585aebb16f4f6232 (diff)
downloadopenttd-0c005f9cfaf99d5c35a1a0a6b3a503fd740e7841.tar.xz
(svn r17984) -Codechange: make it possible to use MakeNWidgets using a custom container widget.
Diffstat (limited to 'src')
-rw-r--r--src/widget.cpp13
-rw-r--r--src/widget_type.h2
2 files changed, 8 insertions, 7 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index befc94da3..0f9232ac6 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -2680,17 +2680,18 @@ static int MakeWidgetTree(const NWidgetPart *parts, int count, NWidgetBase *pare
* @param parts Array with parts of the widgets.
* @param count Length of the \a parts array.
* @param biggest_index Pointer to biggest nested widget index collected in the tree.
+ * @param container Container to add the nested widgets to. In case it is NULL a vertical container is used.
* @return Root of the nested widget tree, a vertical container containing the entire GUI.
* @ingroup NestedWidgetParts
- * @precond \c biggest_index != NULL
- * @postcond \c *biggest_index contains the largest widget index of the tree and \c -1 if no index is used.
+ * @pre \c biggest_index != NULL
+ * @post \c *biggest_index contains the largest widget index of the tree and \c -1 if no index is used.
*/
-NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index)
+NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container)
{
*biggest_index = -1;
- NWidgetContainer *cont = new NWidgetVertical();
- MakeWidgetTree(parts, count, cont, biggest_index);
- return cont;
+ if (container == NULL) container = new NWidgetVertical();
+ MakeWidgetTree(parts, count, container, biggest_index);
+ return container;
}
/**
diff --git a/src/widget_type.h b/src/widget_type.h
index f273b2250..dab4fad32 100644
--- a/src/widget_type.h
+++ b/src/widget_type.h
@@ -829,7 +829,7 @@ static inline NWidgetPart NWidgetFunction(NWidgetFunctionType *func_ptr)
return part;
}
-NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index);
+NWidgetContainer *MakeNWidgets(const NWidgetPart *parts, int count, int *biggest_index, NWidgetContainer *container = NULL);
const Widget *InitializeWidgetArrayFromNestedWidgets(const NWidgetPart *parts, int parts_length, const Widget *orig_wid, Widget **wid_cache);