summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2010-08-12 06:40:28 +0000
committerfrosch <frosch@openttd.org>2010-08-12 06:40:28 +0000
commit629b350a71c10b7675a70226d0ead657258f5cb6 (patch)
tree9224f20b204250bd4c2788e59fd096fc010839e1 /src/window.cpp
parentcfde445ec95f14d4358eb3dc32972f971f851dda (diff)
downloadopenttd-629b350a71c10b7675a70226d0ead657258f5cb6.tar.xz
(svn r20451) -Codechange: Add helper function Window::GetScrollbar() to get the Scrollbar belonging to a scrollbar widget.
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 3081bc268..a002de09b 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -131,6 +131,39 @@ void Scrollbar::SetCapacityFromWidget(Window *w, int widget, int padding)
}
/**
+ * Return the Scrollbar to a widget index.
+ * @param widnum Scrollbar widget index
+ * @return Scrollbar to the widget
+ */
+const Scrollbar *Window::GetScrollbar(uint widnum) const
+{
+ const NWidgetLeaf *wid = this->GetWidget<NWidgetLeaf>(widnum);
+ switch (wid->type) {
+ case WWT_HSCROLLBAR: return &this->hscroll;
+ case WWT_SCROLLBAR: return &this->vscroll;
+ case WWT_SCROLL2BAR: return &this->vscroll2;
+ default: NOT_REACHED();
+ }
+}
+
+/**
+ * Return the Scrollbar to a widget index.
+ * @param widnum Scrollbar widget index
+ * @return Scrollbar to the widget
+ */
+Scrollbar *Window::GetScrollbar(uint widnum)
+{
+ NWidgetLeaf *wid = this->GetWidget<NWidgetLeaf>(widnum);
+ switch (wid->type) {
+ case WWT_HSCROLLBAR: return &this->hscroll;
+ case WWT_SCROLLBAR: return &this->vscroll;
+ case WWT_SCROLL2BAR: return &this->vscroll2;
+ default: NOT_REACHED();
+ }
+}
+
+
+/**
* Set the window that has the focus
* @param w The window to set the focus on
*/