GUI: Add method to know if a widget contains a given widget
This commit is contained in:
parent
47d339509f
commit
91125bcbcd
8 changed files with 41 additions and 0 deletions
|
@ -175,6 +175,15 @@ Widget *Widget::findWidgetInChain(Widget *w, const char *name) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool Widget::containsWidgetInChain(Widget *w, Widget *search) {
|
||||
while (w) {
|
||||
if (w == search || w->containsWidget(search))
|
||||
return true;
|
||||
w = w->_next;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Widget::setEnabled(bool e) {
|
||||
if ((_flags & WIDGET_ENABLED) != e) {
|
||||
if (e)
|
||||
|
@ -837,6 +846,10 @@ ContainerWidget::~ContainerWidget() {
|
|||
}
|
||||
}
|
||||
|
||||
bool ContainerWidget::containsWidget(Widget *w) const {
|
||||
return containsWidgetInChain(_firstWidget, w);
|
||||
}
|
||||
|
||||
Widget *ContainerWidget::findWidget(int x, int y) {
|
||||
return findWidgetInChain(_firstWidget, x, y);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue