mirror of
https://github.com/SoftFever/OrcaSlicer.git
synced 2025-07-23 22:54:08 -06:00

Change-Id: Ie1bffdd9ace2c6e05979743da9f75ca2c1e87cf4 (cherry picked from commit 7ddaf5260df19c76fca82e525caca26e55732fa9)
37 lines
866 B
C++
37 lines
866 B
C++
#include "PopupWindow.hpp"
|
|
|
|
static wxWindow *GetTopParent(wxWindow *pWindow)
|
|
{
|
|
wxWindow *pWin = pWindow;
|
|
while (pWin->GetParent()) {
|
|
pWin = pWin->GetParent();
|
|
if (auto top = dynamic_cast<wxNonOwnedWindow*>(pWin))
|
|
return top;
|
|
}
|
|
return pWin;
|
|
}
|
|
|
|
bool PopupWindow::Create(wxWindow *parent, int style)
|
|
{
|
|
if (!wxPopupTransientWindow::Create(parent, style))
|
|
return false;
|
|
#ifdef __WXGTK__
|
|
GetTopParent(parent)->Bind(wxEVT_ACTIVATE, &PopupWindow::topWindowActiavate, this);
|
|
#endif
|
|
return true;
|
|
}
|
|
|
|
PopupWindow::~PopupWindow()
|
|
{
|
|
#ifdef __WXGTK__
|
|
GetTopParent(this)->Unbind(wxEVT_ACTIVATE, &PopupWindow::topWindowActiavate, this);
|
|
#endif
|
|
}
|
|
|
|
#ifdef __WXGTK__
|
|
void PopupWindow::topWindowActiavate(wxActivateEvent &event)
|
|
{
|
|
event.Skip();
|
|
if (!event.GetActive() && IsShown()) DismissAndNotify();
|
|
}
|
|
#endif
|