summaryrefslogtreecommitdiff
path: root/src/widget.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-06-03 20:00:33 +0000
committeralberth <alberth@openttd.org>2009-06-03 20:00:33 +0000
commit1ba3755aa7383c34042f781c85a28f76417962cd (patch)
treefe4f24c20a367e5f0d53e64b5107ea6a8d6c8446 /src/widget.cpp
parentcaf98238e3cffedbc80fc9f7aa0f485500f6913a (diff)
downloadopenttd-1ba3755aa7383c34042f781c85a28f76417962cd.tar.xz
(svn r16513) -Codechange: Add nested widgets root and array to Window, and NWidgetBase::FillNestedArray() to fill the array.
Diffstat (limited to 'src/widget.cpp')
-rw-r--r--src/widget.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/widget.cpp b/src/widget.cpp
index b3c53aeff..613ce6a2c 100644
--- a/src/widget.cpp
+++ b/src/widget.cpp
@@ -839,6 +839,13 @@ NWidgetBase::NWidgetBase(WidgetType tp) : ZeroedMemoryAllocator()
*/
/**
+ * @fn void FillNestedArray(NWidgetCore **array, uint length)
+ * Fill the Window::nested_array array with pointers to nested widgets in the tree.
+ * @param array Base pointer of the array.
+ * @param length Length of the array.
+ */
+
+/**
* Store size and position.
* @param sizing Type of resizing to perform.
* @param x Horizontal offset of the widget relative to the left edge of the window.
@@ -971,6 +978,11 @@ int NWidgetCore::SetupSmallestSize()
return this->index;
}
+void NWidgetCore::FillNestedArray(NWidgetCore **array, uint length)
+{
+ if (this->index >= 0 && (uint)(this->index) < length) array[this->index] = this;
+}
+
void NWidgetCore::StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl)
{
if (this->index < 0) return;
@@ -1046,6 +1058,13 @@ void NWidgetContainer::Add(NWidgetBase *wid)
}
}
+void NWidgetContainer::FillNestedArray(NWidgetCore **array, uint length)
+{
+ for (NWidgetBase *child_wid = this->head; child_wid != NULL; child_wid = child_wid->next) {
+ child_wid->FillNestedArray(array, length);
+ }
+}
+
/**
* Return the biggest possible size of a nested widget.
* @param base Base size of the widget.
@@ -1419,6 +1438,10 @@ int NWidgetSpacer::SetupSmallestSize()
return -1;
}
+void NWidgetSpacer::FillNestedArray(NWidgetCore **array, uint length)
+{
+}
+
void NWidgetSpacer::StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl)
{
/* Spacer widgets are never stored in the widget array. */
@@ -1518,6 +1541,12 @@ void NWidgetBackground::StoreWidgets(Widget *widgets, int length, bool left_movi
if (this->child != NULL) this->child->StoreWidgets(widgets, length, left_moving, top_moving, rtl);
}
+void NWidgetBackground::FillNestedArray(NWidgetCore **array, uint length)
+{
+ if (this->index >= 0 && (uint)(this->index) < length) array[this->index] = this;
+ if (this->child != NULL) this->child->FillNestedArray(array, length);
+}
+
/**
* Nested leaf widget.
* @param tp Type of leaf widget.