Codechange: Expose `FindChildWindow()` as a method of `Window`.

This commit is contained in:
Peter Nelson 2023-11-11 21:51:39 +00:00 committed by Peter Nelson
parent 4c44e1eae0
commit ac44c001a4
2 changed files with 5 additions and 4 deletions

View File

@ -1020,10 +1020,10 @@ void Window::SetShaded(bool make_shaded)
* @param wc Window class of the window to remove; #WC_INVALID if class does not matter * @param wc Window class of the window to remove; #WC_INVALID if class does not matter
* @return a Window pointer that is the child of \a w, or \c nullptr otherwise * @return a Window pointer that is the child of \a w, or \c nullptr otherwise
*/ */
static Window *FindChildWindow(const Window *w, WindowClass wc) Window *Window::FindChildWindow(WindowClass wc) const
{ {
for (Window *v : Window::Iterate()) { for (Window *v : Window::Iterate()) {
if ((wc == WC_INVALID || wc == v->window_class) && v->parent == w) return v; if ((wc == WC_INVALID || wc == v->window_class) && v->parent == this) return v;
} }
return nullptr; return nullptr;
@ -1035,10 +1035,10 @@ static Window *FindChildWindow(const Window *w, WindowClass wc)
*/ */
void Window::CloseChildWindows(WindowClass wc) const void Window::CloseChildWindows(WindowClass wc) const
{ {
Window *child = FindChildWindow(this, wc); Window *child = this->FindChildWindow(wc);
while (child != nullptr) { while (child != nullptr) {
child->Close(); child->Close();
child = FindChildWindow(this, wc); child = this->FindChildWindow(wc);
} }
} }

View File

@ -545,6 +545,7 @@ public:
void DrawSortButtonState(WidgetID widget, SortButtonState state) const; void DrawSortButtonState(WidgetID widget, SortButtonState state) const;
static int SortButtonWidth(); static int SortButtonWidth();
Window *FindChildWindow(WindowClass wc = WC_INVALID) const;
void CloseChildWindows(WindowClass wc = WC_INVALID) const; void CloseChildWindows(WindowClass wc = WC_INVALID) const;
virtual void Close(int data = 0); virtual void Close(int data = 0);
static void DeleteClosedWindows(); static void DeleteClosedWindows();