mirror of https://github.com/OpenTTD/OpenTTD
Change: Add methods to close child windows with a specific window number.
parent
0724b3cda8
commit
dabf2ede67
|
@ -1024,9 +1024,8 @@ void Window::SetShaded(bool make_shaded)
|
|||
|
||||
/**
|
||||
* 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 remove; #WC_INVALID if class does not matter
|
||||
* @return a Window pointer that is the child of \a w, or \c nullptr otherwise
|
||||
* @param wc Window class of the window to find; #WC_INVALID if class does not matter
|
||||
* @return a Window pointer that is the child of this window, or \c nullptr otherwise
|
||||
*/
|
||||
Window *Window::FindChildWindow(WindowClass wc) const
|
||||
{
|
||||
|
@ -1037,6 +1036,21 @@ Window *Window::FindChildWindow(WindowClass wc) const
|
|||
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
|
||||
* @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.
|
||||
*/
|
||||
|
|
|
@ -546,7 +546,9 @@ public:
|
|||
static int SortButtonWidth();
|
||||
|
||||
Window *FindChildWindow(WindowClass wc = WC_INVALID) const;
|
||||
Window *FindChildWindowById(WindowClass wc, WindowNumber number) const;
|
||||
void CloseChildWindows(WindowClass wc = WC_INVALID) const;
|
||||
void CloseChildWindowById(WindowClass wc, WindowNumber number) const;
|
||||
virtual void Close(int data = 0);
|
||||
static void DeleteClosedWindows();
|
||||
|
||||
|
|
Loading…
Reference in New Issue