(svn r16961) -Codechange: Moving some methods up in the class hierarchy to avoid code duplication.

replace/41b28d7194a279bdc17475d4fbe2ea6ec885a466
alberth 15 years ago
parent 75ccf9de3a
commit 0081bb9a96

@ -973,7 +973,7 @@ void NWidgetBase::Invalidate(const Window *w) const
}
/**
* @fn NWidgetCore *GetWidgetFromPos(int x, int y)
* @fn NWidgetCore *NWidgetBase::GetWidgetFromPos(int x, int y)
* Retrieve a widget by its position.
* @param x Horizontal position relative to the left edge of the window.
* @param y Vertical position relative to the top edge of the window.
@ -981,11 +981,14 @@ void NWidgetBase::Invalidate(const Window *w) const
*/
/**
* @fn NWidgetBase *GetWidgetOfType(WidgetType tp)
* Retrieve a widget by its type.
* @param tp Widget type to search for.
* @return Returns the first widget of the specified type, or \c NULL if no widget can be found.
*/
NWidgetBase *NWidgetBase::GetWidgetOfType(WidgetType tp)
{
return (this->type == tp) ? this : NULL;
}
/**
* Constructor for resizable nested widgets.
@ -1109,6 +1112,11 @@ void NWidgetCore::StoreWidgets(Widget *widgets, int length, bool left_moving, bo
w->tooltips = this->tool_tip;
}
NWidgetCore *NWidgetCore::GetWidgetFromPos(int x, int y)
{
return (IsInsideBS(x, this->pos_x, this->current_x) && IsInsideBS(y, this->pos_y, this->current_y)) ? this : NULL;
}
/**
* @fn Scrollbar *NWidgetCore::FindScrollbar(Window *w, bool allow_next = true)
* Find the scrollbar of the widget through the Window::nested_array.
@ -1200,7 +1208,6 @@ static inline uint ComputeOffset(uint space, uint max_space)
return (max_space - space) / 2;
}
/**
* Widgets stacked on top of each other.
* @param tp Kind of stacking, must be either #NWID_SELECTION or #NWID_LAYERED.
@ -1615,11 +1622,6 @@ NWidgetCore *NWidgetSpacer::GetWidgetFromPos(int x, int y)
return NULL;
}
NWidgetBase *NWidgetSpacer::GetWidgetOfType(WidgetType tp)
{
return (this->type == tp) ? this : NULL;
}
/**
* Constructor parent nested widgets.
* @param tp Type of parent widget.
@ -2152,10 +2154,6 @@ void NWidgetLeaf::Invalidate(const Window *w) const
NWidgetBase::Invalidate(w);
}
NWidgetCore *NWidgetLeaf::GetWidgetFromPos(int x, int y)
{
return (IsInsideBS(x, this->pos_x, this->current_x) && IsInsideBS(y, this->pos_y, this->current_y)) ? this : NULL;
}
Scrollbar *NWidgetLeaf::FindScrollbar(Window *w, bool allow_next)
{
@ -2169,11 +2167,6 @@ Scrollbar *NWidgetLeaf::FindScrollbar(Window *w, bool allow_next)
return NULL;
}
NWidgetBase *NWidgetLeaf::GetWidgetOfType(WidgetType tp)
{
return (this->type == tp) ? this : NULL;
}
/**
* Intialize nested widget tree and convert to widget array.
* @param nwid Nested widget tree.

@ -182,7 +182,7 @@ public:
virtual void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl) = 0;
virtual NWidgetCore *GetWidgetFromPos(int x, int y) = 0;
virtual NWidgetBase *GetWidgetOfType(WidgetType tp) = 0;
virtual NWidgetBase *GetWidgetOfType(WidgetType tp);
/**
* Set additional space (padding) around the widget.
@ -295,6 +295,7 @@ public:
inline bool IsDisabled();
void StoreWidgets(Widget *widgets, int length, bool left_moving, bool top_moving, bool rtl);
/* virtual */ NWidgetCore *GetWidgetFromPos(int x, int y);
virtual Scrollbar *FindScrollbar(Window *w, bool allow_next = true) = 0;
@ -444,7 +445,6 @@ 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.
@ -480,8 +480,6 @@ public:
/* virtual */ void SetupSmallestSize(Window *w, bool init_array);
/* 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);
static void InvalidateDimensionCache();

Loading…
Cancel
Save