diff options
author | frosch <frosch@openttd.org> | 2010-08-12 06:44:45 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2010-08-12 06:44:45 +0000 |
commit | 10339c60c0e53ccc90f0cc379763be6582d87bf2 (patch) | |
tree | 475be37fecf0ade3656700f0a7024a10bda48545 /src/widget_type.h | |
parent | 629b350a71c10b7675a70226d0ead657258f5cb6 (diff) | |
download | openttd-10339c60c0e53ccc90f0cc379763be6582d87bf2.tar.xz |
(svn r20452) -Codechange: Remove NWidgetCore::FindScrollbar() and associate scrollbar explicitly using a NWidgetPart via SetScrollbar().
Diffstat (limited to 'src/widget_type.h')
-rw-r--r-- | src/widget_type.h | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/src/widget_type.h b/src/widget_type.h index 39312dcba..da871df55 100644 --- a/src/widget_type.h +++ b/src/widget_type.h @@ -91,6 +91,7 @@ enum WidgetType { WPT_PIPSPACE, ///< Widget part for specifying pre/inter/post space for containers. WPT_ENDCONTAINER, ///< Widget part to denote end of a container. WPT_FUNCTION, ///< Widget part for calling a user function. + WPT_SCROLLBAR, ///< Widget part for attaching a scrollbar. /* Pushable window widget types. */ WWT_MASK = 0x7F, @@ -278,13 +279,12 @@ public: /* virtual */ void FillNestedArray(NWidgetBase **array, uint length); /* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y); - virtual Scrollbar *FindScrollbar(Window *w, bool allow_next = true) const = 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'). uint16 widget_data; ///< Data of the widget. @see Widget::data StringID tool_tip; ///< Tooltip of the widget. @see Widget::tootips + int scrollbar_index; ///< Index of an attached scrollbar. }; /** @@ -476,7 +476,6 @@ public: /* 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) const; private: NWidgetPIPContainer *child; ///< Child widget. @@ -497,7 +496,6 @@ public: /* virtual */ void SetupSmallestSize(Window *w, bool init_array); /* virtual */ void Draw(const Window *w); - /* virtual */ Scrollbar *FindScrollbar(Window *w, bool allow_next = true) const; void InitializeViewport(Window *w, uint32 follow_flags, ZoomLevel zoom); void UpdateViewportCoordinates(Window *w); @@ -513,7 +511,6 @@ public: /* virtual */ void SetupSmallestSize(Window *w, bool init_array); /* virtual */ void Draw(const Window *w); - /* virtual */ Scrollbar *FindScrollbar(Window *w, bool allow_next = true) const; bool ButtonHit(const Point &pt); @@ -812,6 +809,23 @@ static inline NWidgetPart SetPIP(uint8 pre, uint8 inter, uint8 post) } /** + * Attach a scrollbar to a widget. + * The scrollbar is controlled when using the mousewheel on the widget. + * Multipe widgets can refer to the same scrollbar to make the mousewheel work in all of them. + * @param index Widget index of the scrollbar. + * @ingroup NestedWidgetParts + */ +static inline NWidgetPart SetScrollbar(int index) +{ + NWidgetPart part; + + part.type = WPT_SCROLLBAR; + part.u.widget.index = index; + + return part; +} + +/** * Widget part function for starting a new 'real' widget. * @param tp Type of the new nested widget. * @param col Colour of the new widget. |