1
0
Fork 0

Change: Add methods to close child windows with a specific window number.

pull/14213/head
Peter Nelson 2025-05-04 17:48:33 +01:00 committed by Peter Nelson
parent 0724b3cda8
commit dabf2ede67
2 changed files with 34 additions and 3 deletions

View File

@ -1024,9 +1024,8 @@ void Window::SetShaded(bool make_shaded)
/** /**
* Find the Window whose parent pointer points to this window * Find the Window whose parent pointer points to this window
* @param w parent Window to find child of * @param wc Window class of the window to find; #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 this window, or \c nullptr otherwise
* @return a Window pointer that is the child of \a w, or \c nullptr otherwise
*/ */
Window *Window::FindChildWindow(WindowClass wc) const Window *Window::FindChildWindow(WindowClass wc) const
{ {
@ -1037,6 +1036,21 @@ Window *Window::FindChildWindow(WindowClass wc) const
return nullptr; return nullptr;
} }
/**
* Find the Window whose parent pointer points to this window
* @param wc Window class of the window to find.
* @param number Window number of the window to find.
* @return a Window pointer that is the child of this window, or \c nullptr otherwise
*/
Window *Window::FindChildWindowById(WindowClass wc, WindowNumber number) const
{
for (Window *v : Window::Iterate()) {
if (wc == v->window_class && number == v->window_number && v->parent == this) return v;
}
return nullptr;
}
/** /**
* Close all children a window might have in a head-recursive manner * Close all children a window might have in a head-recursive manner
* @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
@ -1050,6 +1064,21 @@ void Window::CloseChildWindows(WindowClass wc) const
} }
} }
/**
* Close all children a window might have in a head-recursive manner
* @param wc Window class of the window to remove.
* @param number Window number of the window to remove.
*/
void Window::CloseChildWindowById(WindowClass wc, WindowNumber number) const
{
Window *child = this->FindChildWindowById(wc, number);
while (child != nullptr) {
child->Close();
child = this->FindChildWindowById(wc, number);
}
}
/** /**
* Hide the window and all its child windows, and mark them for a later deletion. * Hide the window and all its child windows, and mark them for a later deletion.
*/ */

View File

@ -546,7 +546,9 @@ public:
static int SortButtonWidth(); static int SortButtonWidth();
Window *FindChildWindow(WindowClass wc = WC_INVALID) const; Window *FindChildWindow(WindowClass wc = WC_INVALID) const;
Window *FindChildWindowById(WindowClass wc, WindowNumber number) const;
void CloseChildWindows(WindowClass wc = WC_INVALID) const; void CloseChildWindows(WindowClass wc = WC_INVALID) const;
void CloseChildWindowById(WindowClass wc, WindowNumber number) const;
virtual void Close(int data = 0); virtual void Close(int data = 0);
static void DeleteClosedWindows(); static void DeleteClosedWindows();