Add the has_widget() function.

This commit is contained in:
Mark de Wever 2008-05-12 15:39:23 +00:00
parent 5311b27df5
commit 4e3203ab38
4 changed files with 27 additions and 0 deletions

View file

@ -49,6 +49,10 @@ public:
return result ? result : grid_.get_widget_by_id(id);
}
/** Inherited from twidget.*/
bool has_widget(const twidget* widget) const
{ return grid_.has_widget(widget); }
/** Inherited from tcontrol. */
tpoint get_minimum_size() const { return grid_.get_minimum_size(); }

View file

@ -393,6 +393,18 @@ twidget* tgrid::get_widget_by_id(const std::string& id)
return twidget::get_widget_by_id(id);
}
bool tgrid::has_widget(const twidget* widget) const
{
for(std::vector<tchild>::const_iterator itor = children_.begin();
itor != children_.end(); ++itor) {
if(itor->widget() == widget) {
return true;
}
}
return false;
}
void tgrid::draw(surface& surface)
{
for(iterator itor = begin(); itor != end(); ++itor) {

View file

@ -103,6 +103,9 @@ public:
//! Override base class.
twidget* get_widget_by_id(const std::string& id);
/** Inherited from twidget.*/
bool has_widget(const twidget* widget) const;
//! Inherited from twidget.
void draw(surface& surface);

View file

@ -188,6 +188,14 @@ public:
virtual twidget* get_widget_by_id(const std::string& id)
{ return id_ == id ? this : 0; }
/**
* Does the widget contain the widget.
*
* This makes more sence in container classes.
*/
virtual bool has_widget(const twidget* widget) const
{ return widget == this; }
//! The toplevel item should always be a window if not null is returned
twindow* get_window();