summaryrefslogtreecommitdiff
path: root/src/widget_type.h
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2009-06-04 12:46:37 +0000
committeralberth <alberth@openttd.org>2009-06-04 12:46:37 +0000
commit1a4934ef070aee3e506603707850de28c7f872cd (patch)
tree7a00edd951c0fbfc8b057822018f8f4509da56b7 /src/widget_type.h
parent5c9071fcffc54eb1bf32d671cf521fadd407491d (diff)
downloadopenttd-1a4934ef070aee3e506603707850de28c7f872cd.tar.xz
(svn r16515) -Codechange: Added scrollbar handling for nested widgets, and finding widgets by type or position in the tree.
Diffstat (limited to 'src/widget_type.h')
-rw-r--r--src/widget_type.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/widget_type.h b/src/widget_type.h
index 45da0f595..b62e82d97 100644
--- a/src/widget_type.h
+++ b/src/widget_type.h
@@ -153,6 +153,7 @@ enum SizingType {
/* Forward declarations. */
class NWidgetCore;
+struct Scrollbar;
/**
* Baseclass for nested widgets.
@@ -170,6 +171,9 @@ public:
virtual void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl) = 0;
virtual void FillNestedArray(NWidgetCore **array, uint length) = 0;
+ virtual NWidgetCore *GetWidgetFromPos(int x, int y) = 0;
+ virtual NWidgetBase *GetWidgetOfType(WidgetType tp) = 0;
+
/**
* Set additional space (padding) around the widget.
* @param top Amount of additional space above the widget.
@@ -284,6 +288,8 @@ public:
void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl);
/* virtual */ void FillNestedArray(NWidgetCore **array, uint length);
+ virtual Scrollbar *FindScrollbar(Window *w, bool allow_next = true) = 0;
+
NWidgetDisplay disp_flags; ///< Flags that affect display and interaction with the widget.
Colours colour; ///< Colour of this widget.
int index; ///< Index of the nested widget in the widget array of the window (\c -1 means 'not used').
@@ -335,6 +341,8 @@ public:
/** Return whether the container is empty. */
inline bool IsEmpty() { return head == NULL; };
+ /* virtual */ NWidgetBase *GetWidgetOfType(WidgetType tp);
+
protected:
NWidgetBase *head; ///< Pointer to first widget in container.
NWidgetBase *tail; ///< Pointer to last widget in container.
@@ -352,6 +360,7 @@ public:
void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl);
/* virtual */ void Draw(const Window *w);
+ /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
};
/** Container with pre/inter/post child space. */
@@ -362,6 +371,8 @@ public:
void SetPIP(uint8 pip_pre, uint8 pip_inter, uint8 pip_post);
/* virtual */ void Draw(const Window *w);
+ /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
+
protected:
uint8 pip_pre; ///< Amount of space before first widget.
uint8 pip_inter; ///< Amount of space between widgets.
@@ -416,6 +427,8 @@ public:
/* virtual */ void Draw(const Window *w);
/* virtual */ void Invalidate(const Window *w) const;
+ /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
+ /* virtual */ NWidgetBase *GetWidgetOfType(WidgetType tp);
};
/** Nested widget with a child.
@@ -435,6 +448,9 @@ public:
/* virtual */ void FillNestedArray(NWidgetCore **array, uint length);
/* virtual */ void Draw(const Window *w);
+ /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
+ /* virtual */ NWidgetBase *GetWidgetOfType(WidgetType tp);
+ /* virtual */ Scrollbar *FindScrollbar(Window *w, bool allow_next = true);
private:
NWidgetPIPContainer *child; ///< Child widget.
@@ -448,6 +464,9 @@ public:
/* virtual */ void Draw(const Window *w);
/* virtual */ void Invalidate(const Window *w) const;
+ /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
+ /* virtual */ NWidgetBase *GetWidgetOfType(WidgetType tp);
+ /* virtual */ Scrollbar *FindScrollbar(Window *w, bool allow_next = true);
};
Widget *InitializeNWidgets(NWidgetBase *nwid, bool rtl = false);