diff --git a/src/slic3r/CMakeLists.txt b/src/slic3r/CMakeLists.txt index 2b6f05204d..5ef69d32f4 100644 --- a/src/slic3r/CMakeLists.txt +++ b/src/slic3r/CMakeLists.txt @@ -28,6 +28,8 @@ set(SLIC3R_GUI_SOURCES GUI/Widgets/SideMenuPopup.cpp GUI/Widgets/DropDown.cpp GUI/Widgets/DropDown.hpp + GUI/Widgets/PopupWindow.cpp + GUI/Widgets/PopupWindow.hpp GUI/Widgets/Label.cpp GUI/Widgets/Label.hpp GUI/Widgets/Scrollbar.cpp diff --git a/src/slic3r/GUI/AmsMappingPopup.cpp b/src/slic3r/GUI/AmsMappingPopup.cpp index a4ea07c7be..aa4f0e9194 100644 --- a/src/slic3r/GUI/AmsMappingPopup.cpp +++ b/src/slic3r/GUI/AmsMappingPopup.cpp @@ -207,7 +207,7 @@ void MaterialItem::doRender(wxDC &dc) } AmsMapingPopup::AmsMapingPopup(wxWindow *parent) - :wxPopupTransientWindow(parent, wxBORDER_NONE) + : PopupWindow(parent, wxBORDER_NONE) { SetSize(wxSize(FromDIP(360), -1)); SetMinSize(wxSize(FromDIP(360), -1)); @@ -504,7 +504,7 @@ void AmsMapingPopup::OnDismiss() bool AmsMapingPopup::ProcessLeftDown(wxMouseEvent &event) { - return wxPopupTransientWindow::ProcessLeftDown(event); + return PopupWindow::ProcessLeftDown(event); } void AmsMapingPopup::paintEvent(wxPaintEvent &evt) @@ -639,7 +639,7 @@ void MappingItem::doRender(wxDC &dc) } AmsMapingTipPopup::AmsMapingTipPopup(wxWindow *parent) - :wxPopupTransientWindow(parent, wxBORDER_NONE) + :PopupWindow(parent, wxBORDER_NONE) { SetBackgroundColour(*wxWHITE); wxBoxSizer *m_sizer_main = new wxBoxSizer(wxVERTICAL); @@ -739,11 +739,11 @@ void AmsMapingTipPopup::paintEvent(wxPaintEvent &evt) void AmsMapingTipPopup::OnDismiss() {} bool AmsMapingTipPopup::ProcessLeftDown(wxMouseEvent &event) { - return wxPopupTransientWindow::ProcessLeftDown(event); } + return PopupWindow::ProcessLeftDown(event); } AmsHumidityTipPopup::AmsHumidityTipPopup(wxWindow* parent) - :wxPopupTransientWindow(parent, wxBORDER_NONE) + :PopupWindow(parent, wxBORDER_NONE) { SetBackgroundColour(*wxWHITE); @@ -857,11 +857,11 @@ void AmsHumidityTipPopup::paintEvent(wxPaintEvent& evt) void AmsHumidityTipPopup::OnDismiss() {} bool AmsHumidityTipPopup::ProcessLeftDown(wxMouseEvent& event) { - return wxPopupTransientWindow::ProcessLeftDown(event); + return PopupWindow::ProcessLeftDown(event); } AmsTutorialPopup::AmsTutorialPopup(wxWindow* parent) -:wxPopupTransientWindow(parent, wxBORDER_NONE) +:PopupWindow(parent, wxBORDER_NONE) { Bind(wxEVT_PAINT, &AmsTutorialPopup::paintEvent, this); SetBackgroundColour(*wxWHITE); @@ -959,12 +959,12 @@ void AmsTutorialPopup::paintEvent(wxPaintEvent& evt) void AmsTutorialPopup::OnDismiss() {} bool AmsTutorialPopup::ProcessLeftDown(wxMouseEvent& event) { - return wxPopupTransientWindow::ProcessLeftDown(event); + return PopupWindow::ProcessLeftDown(event); } AmsIntroducePopup::AmsIntroducePopup(wxWindow* parent) -:wxPopupTransientWindow(parent, wxBORDER_NONE) +:PopupWindow(parent, wxBORDER_NONE) { Bind(wxEVT_PAINT, &AmsIntroducePopup::paintEvent, this); SetBackgroundColour(*wxWHITE); @@ -1044,7 +1044,7 @@ void AmsIntroducePopup::paintEvent(wxPaintEvent& evt) void AmsIntroducePopup::OnDismiss() {} bool AmsIntroducePopup::ProcessLeftDown(wxMouseEvent& event) { - return wxPopupTransientWindow::ProcessLeftDown(event); + return PopupWindow::ProcessLeftDown(event); } diff --git a/src/slic3r/GUI/AmsMappingPopup.hpp b/src/slic3r/GUI/AmsMappingPopup.hpp index 1e461710a3..d4e0796431 100644 --- a/src/slic3r/GUI/AmsMappingPopup.hpp +++ b/src/slic3r/GUI/AmsMappingPopup.hpp @@ -34,6 +34,7 @@ #include "Widgets/CheckBox.hpp" #include "Widgets/ComboBox.hpp" #include "Widgets/ScrolledWindow.hpp" +#include "Widgets/PopupWindow.hpp" #include #include @@ -113,7 +114,7 @@ public: void doRender(wxDC &dc); }; -class AmsMapingPopup : public wxPopupTransientWindow +class AmsMapingPopup : public PopupWindow { public: AmsMapingPopup(wxWindow *parent); @@ -146,7 +147,7 @@ public: std::vector parse_ams_mapping(std::map amsList); }; -class AmsMapingTipPopup : public wxPopupTransientWindow +class AmsMapingTipPopup : public PopupWindow { public: AmsMapingTipPopup(wxWindow *parent); @@ -166,7 +167,7 @@ public: wxStaticText * m_tip_disable_ams; }; -class AmsHumidityTipPopup : public wxPopupTransientWindow +class AmsHumidityTipPopup : public PopupWindow { public: AmsHumidityTipPopup(wxWindow* parent); @@ -186,7 +187,7 @@ public: Button* m_button_confirm; }; -class AmsTutorialPopup : public wxPopupTransientWindow +class AmsTutorialPopup : public PopupWindow { public: Label* text_title; @@ -208,7 +209,7 @@ public: }; -class AmsIntroducePopup : public wxPopupTransientWindow +class AmsIntroducePopup : public PopupWindow { public: bool is_enable_ams = {false}; diff --git a/src/slic3r/GUI/CameraPopup.cpp b/src/slic3r/GUI/CameraPopup.cpp index 42f1792ab4..fbf0450a96 100644 --- a/src/slic3r/GUI/CameraPopup.cpp +++ b/src/slic3r/GUI/CameraPopup.cpp @@ -12,9 +12,9 @@ namespace Slic3r { namespace GUI { -wxIMPLEMENT_CLASS(CameraPopup, wxPopupTransientWindow); +wxIMPLEMENT_CLASS(CameraPopup, PopupWindow); -wxBEGIN_EVENT_TABLE(CameraPopup, wxPopupTransientWindow) +wxBEGIN_EVENT_TABLE(CameraPopup, PopupWindow) EVT_MOUSE_EVENTS(CameraPopup::OnMouse ) EVT_SIZE(CameraPopup::OnSize) EVT_SET_FOCUS(CameraPopup::OnSetFocus ) @@ -29,7 +29,7 @@ wxDEFINE_EVENT(EVT_SDCARD_ABSENT_HINT, wxCommandEvent); const wxColour TEXT_COL = wxColour(43, 52, 54); CameraPopup::CameraPopup(wxWindow *parent, MachineObject* obj) - : wxPopupTransientWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS), + : PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS), m_obj(obj) { #ifdef __WINDOWS__ @@ -165,7 +165,7 @@ void CameraPopup::Popup(wxWindow *WXUNUSED(focus)) this->SetPosition(curr_position); if (!m_is_in_interval) - wxPopupTransientWindow::Popup(); + PopupWindow::Popup(); } wxWindow* CameraPopup::create_item_radiobox(wxString title, wxWindow* parent, wxString tooltip, int padding_left) @@ -347,7 +347,7 @@ void CameraPopup::rescale() m_panel->Layout(); main_sizer->Fit(m_panel); SetClientSize(m_panel->GetSize()); - wxPopupTransientWindow::Update(); + PopupWindow::Update(); } void CameraPopup::OnLeftUp(wxMouseEvent &event) @@ -409,18 +409,18 @@ void CameraPopup::stop_interval(wxTimerEvent& event) } void CameraPopup::OnDismiss() { - wxPopupTransientWindow::OnDismiss(); + PopupWindow::OnDismiss(); this->start_interval(); } bool CameraPopup::ProcessLeftDown(wxMouseEvent &event) { - return wxPopupTransientWindow::ProcessLeftDown(event); + return PopupWindow::ProcessLeftDown(event); } bool CameraPopup::Show(bool show) { - return wxPopupTransientWindow::Show(show); + return PopupWindow::Show(show); } void CameraPopup::OnSize(wxSizeEvent &event) diff --git a/src/slic3r/GUI/CameraPopup.hpp b/src/slic3r/GUI/CameraPopup.hpp index fde8ffa5ca..bab08850cd 100644 --- a/src/slic3r/GUI/CameraPopup.hpp +++ b/src/slic3r/GUI/CameraPopup.hpp @@ -13,6 +13,7 @@ #include #include "Widgets/SwitchButton.hpp" #include "Widgets/RadioBox.hpp" +#include "Widgets/PopupWindow.hpp" namespace Slic3r { namespace GUI { @@ -20,13 +21,13 @@ namespace GUI { wxDECLARE_EVENT(EVT_VCAMERA_SWITCH, wxMouseEvent); wxDECLARE_EVENT(EVT_SDCARD_ABSENT_HINT, wxCommandEvent); -class CameraPopup : public wxPopupTransientWindow +class CameraPopup : public PopupWindow { public: CameraPopup(wxWindow *parent, MachineObject* obj = nullptr); virtual ~CameraPopup() {} - // wxPopupTransientWindow virtual methods are all overridden to log them + // PopupWindow virtual methods are all overridden to log them virtual void Popup(wxWindow *focus = NULL) wxOVERRIDE; virtual void OnDismiss() wxOVERRIDE; virtual bool ProcessLeftDown(wxMouseEvent &event) wxOVERRIDE; diff --git a/src/slic3r/GUI/Search.cpp b/src/slic3r/GUI/Search.cpp index 03eeeabd72..f4965cb9f5 100644 --- a/src/slic3r/GUI/Search.cpp +++ b/src/slic3r/GUI/Search.cpp @@ -522,7 +522,7 @@ static const std::map icon_idxs = { }; SearchDialog::SearchDialog(OptionsSearcher *searcher, Preset::Type type, wxWindow *parent, TextInput *input, wxWindow *search_btn) - : wxPopupTransientWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS), searcher(searcher) + : PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS), searcher(searcher) { m_event_tag = parent; search_line = input; @@ -622,7 +622,7 @@ void SearchDialog::Popup(wxPoint position /*= wxDefaultPosition*/) search_line->GetTextCtrl()->SetValue(wxString("")); //const std::string &line = searcher->search_string(); //searcher->search(into_u8(line), true); - wxPopupTransientWindow::Popup(); + PopupWindow::Popup(); search_line->SetFocus(); update_list(); } @@ -649,7 +649,7 @@ void SearchDialog::Dismiss() void SearchDialog::Die() { - wxPopupTransientWindow::Dismiss(); + PopupWindow::Dismiss(); wxCommandEvent event(wxCUSTOMEVT_EXIT_SEARCH); wxPostEvent(search_line, event); } diff --git a/src/slic3r/GUI/Search.hpp b/src/slic3r/GUI/Search.hpp index 52ac6b35fb..6331609ca5 100644 --- a/src/slic3r/GUI/Search.hpp +++ b/src/slic3r/GUI/Search.hpp @@ -20,6 +20,7 @@ #include "libslic3r/Preset.hpp" #include "Widgets/ScrolledWindow.hpp" #include "Widgets/TextInput.hpp" +#include "Widgets/PopupWindow.hpp" namespace Slic3r { @@ -175,7 +176,7 @@ public: // SearchDialog //------------------------------------------ class SearchListModel; -class SearchDialog : public wxPopupTransientWindow +class SearchDialog : public PopupWindow { public: wxString search_str; diff --git a/src/slic3r/GUI/SelectMachine.cpp b/src/slic3r/GUI/SelectMachine.cpp index 6d434d3013..320cd0fccb 100644 --- a/src/slic3r/GUI/SelectMachine.cpp +++ b/src/slic3r/GUI/SelectMachine.cpp @@ -387,7 +387,7 @@ void MachineObjectPanel::on_mouse_left_up(wxMouseEvent &evt) } SelectMachinePopup::SelectMachinePopup(wxWindow *parent) - : wxPopupTransientWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS), m_dismiss(false) + : PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS), m_dismiss(false) { #ifdef __WINDOWS__ SetDoubleBuffered(true); @@ -481,7 +481,7 @@ void SelectMachinePopup::Popup(wxWindow *WXUNUSED(focus)) } wxPostEvent(this, wxTimerEvent()); - wxPopupTransientWindow::Popup(); + PopupWindow::Popup(); } void SelectMachinePopup::OnDismiss() @@ -507,7 +507,7 @@ void SelectMachinePopup::OnDismiss() } bool SelectMachinePopup::ProcessLeftDown(wxMouseEvent &event) { - return wxPopupTransientWindow::ProcessLeftDown(event); + return PopupWindow::ProcessLeftDown(event); } bool SelectMachinePopup::Show(bool show) { @@ -522,7 +522,7 @@ bool SelectMachinePopup::Show(bool show) { m_other_list_machine_panel[j]->mPanel->Hide(); } } - return wxPopupTransientWindow::Show(show); + return PopupWindow::Show(show); } wxWindow *SelectMachinePopup::create_title_panel(wxString text) diff --git a/src/slic3r/GUI/SelectMachine.hpp b/src/slic3r/GUI/SelectMachine.hpp index 1b5fe23469..0b141ee950 100644 --- a/src/slic3r/GUI/SelectMachine.hpp +++ b/src/slic3r/GUI/SelectMachine.hpp @@ -37,6 +37,7 @@ #include "Widgets/CheckBox.hpp" #include "Widgets/ComboBox.hpp" #include "Widgets/ScrolledWindow.hpp" +#include "Widgets/PopupWindow.hpp" #include #include @@ -179,13 +180,13 @@ public: class ThumbnailPanel; -class SelectMachinePopup : public wxPopupTransientWindow +class SelectMachinePopup : public PopupWindow { public: SelectMachinePopup(wxWindow *parent); ~SelectMachinePopup(); - // wxPopupTransientWindow virtual methods are all overridden to log them + // PopupWindow virtual methods are all overridden to log them virtual void Popup(wxWindow *focus = NULL) wxOVERRIDE; virtual void OnDismiss() wxOVERRIDE; virtual bool ProcessLeftDown(wxMouseEvent &event) wxOVERRIDE; diff --git a/src/slic3r/GUI/SliceInfoPanel.cpp b/src/slic3r/GUI/SliceInfoPanel.cpp index 5119081aa0..ddf9eb647a 100644 --- a/src/slic3r/GUI/SliceInfoPanel.cpp +++ b/src/slic3r/GUI/SliceInfoPanel.cpp @@ -11,9 +11,9 @@ namespace GUI { #define ICON_SIZE (wxSize(FromDIP(16), FromDIP(16))) #define PRINT_ICON_SIZE (wxSize(FromDIP(18), FromDIP(18))) -wxIMPLEMENT_CLASS(SliceInfoPopup, wxPopupTransientWindow); +wxIMPLEMENT_CLASS(SliceInfoPopup, PopupWindow); -wxBEGIN_EVENT_TABLE(SliceInfoPopup, wxPopupTransientWindow) +wxBEGIN_EVENT_TABLE(SliceInfoPopup, PopupWindow) EVT_MOUSE_EVENTS( SliceInfoPopup::OnMouse ) EVT_SIZE(SliceInfoPopup::OnSize) EVT_SET_FOCUS( SliceInfoPopup::OnSetFocus ) @@ -53,7 +53,7 @@ static wxColour decode_color(const std::string &color) SliceInfoPopup::SliceInfoPopup(wxWindow *parent, wxBitmap bmp, BBLSliceInfo *info) - : wxPopupTransientWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS) + : PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS) { #ifdef __WINDOWS__ SetDoubleBuffered(true); @@ -139,20 +139,20 @@ SliceInfoPopup::SliceInfoPopup(wxWindow *parent, wxBitmap bmp, BBLSliceInfo *inf } void SliceInfoPopup::Popup(wxWindow *WXUNUSED(focus)) { - wxPopupTransientWindow::Popup(); + PopupWindow::Popup(); } void SliceInfoPopup::OnDismiss() { - wxPopupTransientWindow::OnDismiss(); + PopupWindow::OnDismiss(); } bool SliceInfoPopup::ProcessLeftDown(wxMouseEvent &event) { - return wxPopupTransientWindow::ProcessLeftDown(event); + return PopupWindow::ProcessLeftDown(event); } bool SliceInfoPopup::Show(bool show) { - return wxPopupTransientWindow::Show(show); + return PopupWindow::Show(show); } void SliceInfoPopup::OnSize(wxSizeEvent &event) diff --git a/src/slic3r/GUI/SliceInfoPanel.hpp b/src/slic3r/GUI/SliceInfoPanel.hpp index 05a853001d..8f1710022b 100644 --- a/src/slic3r/GUI/SliceInfoPanel.hpp +++ b/src/slic3r/GUI/SliceInfoPanel.hpp @@ -9,17 +9,18 @@ #include #include #include +#include "Widgets/PopupWindow.hpp" namespace Slic3r { namespace GUI { -class SliceInfoPopup : public wxPopupTransientWindow +class SliceInfoPopup : public PopupWindow { public: SliceInfoPopup(wxWindow *parent, wxBitmap bmp= wxNullBitmap, BBLSliceInfo* info=nullptr); virtual ~SliceInfoPopup() {} - // wxPopupTransientWindow virtual methods are all overridden to log them + // PopupWindow virtual methods are all overridden to log them virtual void Popup(wxWindow *focus = NULL) wxOVERRIDE; virtual void OnDismiss() wxOVERRIDE; virtual bool ProcessLeftDown(wxMouseEvent &event) wxOVERRIDE; diff --git a/src/slic3r/GUI/StatusPanel.cpp b/src/slic3r/GUI/StatusPanel.cpp index 740b753679..f4c976b842 100644 --- a/src/slic3r/GUI/StatusPanel.cpp +++ b/src/slic3r/GUI/StatusPanel.cpp @@ -2840,9 +2840,9 @@ void StatusPanel::on_switch_speed(wxCommandEvent &event) } #if __WXOSX__ // MacOS has focus problem - wxPopupTransientWindow *popUp = new wxPopupTransientWindow(nullptr); + PopupWindow *popUp = new PopupWindow(nullptr); #else - wxPopupTransientWindow *popUp = new wxPopupTransientWindow(m_switch_speed); + PopupWindow *popUp = new PopupWindow(m_switch_speed); #endif popUp->SetBackgroundColour(StateColor::darkModeColorFor(0xeeeeee)); StepCtrl *step = new StepCtrl(popUp, wxID_ANY); diff --git a/src/slic3r/GUI/Widgets/DropDown.cpp b/src/slic3r/GUI/Widgets/DropDown.cpp index d7a3f4a066..8f0b390ac6 100644 --- a/src/slic3r/GUI/Widgets/DropDown.cpp +++ b/src/slic3r/GUI/Widgets/DropDown.cpp @@ -5,7 +5,7 @@ wxDEFINE_EVENT(EVT_DISMISS, wxCommandEvent); -BEGIN_EVENT_TABLE(DropDown, wxPopupTransientWindow) +BEGIN_EVENT_TABLE(DropDown, PopupWindow) EVT_LEFT_DOWN(DropDown::mouseDown) EVT_LEFT_UP(DropDown::mouseReleased) @@ -50,7 +50,7 @@ DropDown::DropDown(wxWindow * parent, void DropDown::Create(wxWindow * parent, long style) { - wxPopupTransientWindow::Create(parent, wxPU_CONTAINS_CONTROLS); + PopupWindow::Create(parent, wxPU_CONTAINS_CONTROLS); SetBackgroundStyle(wxBG_STYLE_PAINT); SetBackgroundColour(*wxWHITE); state_handler.attach({&border_color, &text_color, &selector_border_color, &selector_background_color}); @@ -62,7 +62,7 @@ void DropDown::Create(wxWindow * parent, // BBS set default font SetFont(Label::Body_14); #ifdef __WXOSX__ - // wxPopupTransientWindow releases mouse on idle, which may cause various problems, + // PopupWindow releases mouse on idle, which may cause various problems, // such as losting mouse move, and dismissing soon on first LEFT_DOWN event. Bind(wxEVT_IDLE, [] (wxIdleEvent & evt) {}); #endif diff --git a/src/slic3r/GUI/Widgets/DropDown.hpp b/src/slic3r/GUI/Widgets/DropDown.hpp index b2b7eaa73e..e2a6cb4930 100644 --- a/src/slic3r/GUI/Widgets/DropDown.hpp +++ b/src/slic3r/GUI/Widgets/DropDown.hpp @@ -4,6 +4,7 @@ #include #include "../wxExtensions.hpp" #include "StateHandler.hpp" +#include "PopupWindow.hpp" #define DD_NO_CHECK_ICON 0x0001 #define DD_NO_TEXT 0x0002 @@ -11,7 +12,7 @@ wxDECLARE_EVENT(EVT_DISMISS, wxCommandEvent); -class DropDown : public wxPopupTransientWindow +class DropDown : public PopupWindow { std::vector & texts; std::vector & icons; diff --git a/src/slic3r/GUI/Widgets/FanControl.cpp b/src/slic3r/GUI/Widgets/FanControl.cpp index 8a3e05a3a4..e2fea459de 100644 --- a/src/slic3r/GUI/Widgets/FanControl.cpp +++ b/src/slic3r/GUI/Widgets/FanControl.cpp @@ -499,7 +499,7 @@ void FanControl::post_event(wxCommandEvent&& event) Description:FanControlPopup **************************************************/ FanControlPopup::FanControlPopup(wxWindow* parent) - :wxPopupTransientWindow(parent, wxBORDER_NONE) + :PopupWindow(parent, wxBORDER_NONE) { this->SetSizeHints(wxDefaultSize, wxDefaultSize); @@ -628,7 +628,7 @@ void FanControlPopup::post_event(int fan_type, wxString speed) bool FanControlPopup::ProcessLeftDown(wxMouseEvent& event) { - return wxPopupTransientWindow::ProcessLeftDown(event); + return PopupWindow::ProcessLeftDown(event); } void FanControlPopup::on_show(wxShowEvent& evt) diff --git a/src/slic3r/GUI/Widgets/FanControl.hpp b/src/slic3r/GUI/Widgets/FanControl.hpp index 9e9d3dd950..ec5c686d27 100644 --- a/src/slic3r/GUI/Widgets/FanControl.hpp +++ b/src/slic3r/GUI/Widgets/FanControl.hpp @@ -5,6 +5,7 @@ #include "StaticBox.hpp" #include "StepCtrl.hpp" #include "Button.hpp" +#include "PopupWindow.hpp" #include "../DeviceManager.hpp" #include "slic3r/GUI/Event.hpp" #include @@ -137,7 +138,7 @@ public: /************************************************* Description:FanControlPopup **************************************************/ -class FanControlPopup : public wxPopupTransientWindow +class FanControlPopup : public PopupWindow { public: FanControlPopup(wxWindow* parent); diff --git a/src/slic3r/GUI/Widgets/PopupWindow.cpp b/src/slic3r/GUI/Widgets/PopupWindow.cpp new file mode 100644 index 0000000000..135802c83e --- /dev/null +++ b/src/slic3r/GUI/Widgets/PopupWindow.cpp @@ -0,0 +1,37 @@ +#include "PopupWindow.hpp" + +static wxWindow *GetTopParent(wxWindow *pWindow) +{ + wxWindow *pWin = pWindow; + while (pWin->GetParent()) { + pWin = pWin->GetParent(); + if (auto top = dynamic_cast(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 diff --git a/src/slic3r/GUI/Widgets/PopupWindow.hpp b/src/slic3r/GUI/Widgets/PopupWindow.hpp new file mode 100644 index 0000000000..88993de88e --- /dev/null +++ b/src/slic3r/GUI/Widgets/PopupWindow.hpp @@ -0,0 +1,24 @@ +#ifndef slic3r_GUI_PopupWindow_hpp_ +#define slic3r_GUI_PopupWindow_hpp_ + +#include + +class PopupWindow : public wxPopupTransientWindow +{ +public: + PopupWindow() {} + + ~PopupWindow(); + + PopupWindow(wxWindow *parent, int style = wxBORDER_NONE) + { Create(parent, style); } + + bool Create(wxWindow *parent, int flags = wxBORDER_NONE); + +private: +#ifdef __WXGTK__ + void topWindowActiavate(wxActivateEvent &event); +#endif +}; + +#endif // !slic3r_GUI_PopupWindow_hpp_ diff --git a/src/slic3r/GUI/Widgets/SideMenuPopup.cpp b/src/slic3r/GUI/Widgets/SideMenuPopup.cpp index 21faf613bd..b50ed6b605 100644 --- a/src/slic3r/GUI/Widgets/SideMenuPopup.cpp +++ b/src/slic3r/GUI/Widgets/SideMenuPopup.cpp @@ -6,12 +6,12 @@ -wxBEGIN_EVENT_TABLE(SidePopup,wxPopupTransientWindow) +wxBEGIN_EVENT_TABLE(SidePopup,PopupWindow) EVT_PAINT(SidePopup::paintEvent) wxEND_EVENT_TABLE() SidePopup::SidePopup(wxWindow* parent) - :wxPopupTransientWindow(parent, + :PopupWindow(parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS) { @@ -28,16 +28,16 @@ SidePopup::~SidePopup() void SidePopup::OnDismiss() { Slic3r::GUI::wxGetApp().set_side_menu_popup_status(false); - wxPopupTransientWindow::OnDismiss(); + PopupWindow::OnDismiss(); } bool SidePopup::ProcessLeftDown(wxMouseEvent& event) { - return wxPopupTransientWindow::ProcessLeftDown(event); + return PopupWindow::ProcessLeftDown(event); } bool SidePopup::Show( bool show ) { - return wxPopupTransientWindow::Show(show); + return PopupWindow::Show(show); } void SidePopup::Popup(wxWindow* focus) @@ -66,7 +66,7 @@ void SidePopup::Popup(wxWindow* focus) Position(pos, {0, focus->GetSize().y + 12}); } Slic3r::GUI::wxGetApp().set_side_menu_popup_status(true); - wxPopupTransientWindow::Popup(); + PopupWindow::Popup(); } void SidePopup::Create() diff --git a/src/slic3r/GUI/Widgets/SideMenuPopup.hpp b/src/slic3r/GUI/Widgets/SideMenuPopup.hpp index 52f3066640..09f756a5eb 100644 --- a/src/slic3r/GUI/Widgets/SideMenuPopup.hpp +++ b/src/slic3r/GUI/Widgets/SideMenuPopup.hpp @@ -9,8 +9,9 @@ #include "../wxExtensions.hpp" #include "StateHandler.hpp" #include "SideButton.hpp" +#include "PopupWindow.hpp" -class SidePopup : public wxPopupTransientWindow +class SidePopup : public PopupWindow { private: std::vector btn_list; diff --git a/src/slic3r/GUI/Widgets/TempInput.cpp b/src/slic3r/GUI/Widgets/TempInput.cpp index b9d4bdbbe2..fb848afdca 100644 --- a/src/slic3r/GUI/Widgets/TempInput.cpp +++ b/src/slic3r/GUI/Widgets/TempInput.cpp @@ -1,5 +1,6 @@ #include "TempInput.hpp" #include "Label.hpp" +#include "PopupWindow.hpp" #include "../I18N.hpp" #include #include "../GUI.hpp" @@ -190,7 +191,7 @@ void TempInput::Warning(bool warn, WarningType type) if (warning_mode) { if (wdialog == nullptr) { - wdialog = new wxPopupTransientWindow(this); + wdialog = new PopupWindow(this); wdialog->SetBackgroundColour(wxColour(0xFFFFFF)); wdialog->SetSizeHints(wxDefaultSize, wxDefaultSize); diff --git a/src/slic3r/GUI/wxExtensions.cpp b/src/slic3r/GUI/wxExtensions.cpp index 406698f213..d93c2840a6 100644 --- a/src/slic3r/GUI/wxExtensions.cpp +++ b/src/slic3r/GUI/wxExtensions.cpp @@ -1048,9 +1048,9 @@ void BlinkingBitmap::blink() } -wxIMPLEMENT_CLASS(ImageTransientPopup,wxPopupTransientWindow); +wxIMPLEMENT_CLASS(ImageTransientPopup,PopupWindow); -wxBEGIN_EVENT_TABLE(ImageTransientPopup,wxPopupTransientWindow) +wxBEGIN_EVENT_TABLE(ImageTransientPopup,PopupWindow) EVT_MOUSE_EVENTS( ImageTransientPopup::OnMouse ) EVT_SIZE( ImageTransientPopup::OnSize ) EVT_SET_FOCUS( ImageTransientPopup::OnSetFocus ) @@ -1058,7 +1058,7 @@ wxBEGIN_EVENT_TABLE(ImageTransientPopup,wxPopupTransientWindow) wxEND_EVENT_TABLE() ImageTransientPopup::ImageTransientPopup( wxWindow *parent, bool scrolled, wxBitmap bmp) - :wxPopupTransientWindow( parent, + :PopupWindow( parent, wxBORDER_NONE | wxPU_CONTAINS_CONTROLS ) { @@ -1115,21 +1115,21 @@ void ImageTransientPopup::SetImage(wxBitmap bmp) void ImageTransientPopup::Popup(wxWindow* WXUNUSED(focus)) { - wxPopupTransientWindow::Popup(); + PopupWindow::Popup(); } void ImageTransientPopup::OnDismiss() { - wxPopupTransientWindow::OnDismiss(); + PopupWindow::OnDismiss(); } bool ImageTransientPopup::ProcessLeftDown(wxMouseEvent& event) { - return wxPopupTransientWindow::ProcessLeftDown(event); + return PopupWindow::ProcessLeftDown(event); } bool ImageTransientPopup::Show( bool show ) { - return wxPopupTransientWindow::Show(show); + return PopupWindow::Show(show); } void ImageTransientPopup::OnSize(wxSizeEvent &event) diff --git a/src/slic3r/GUI/wxExtensions.hpp b/src/slic3r/GUI/wxExtensions.hpp index 1a9ebf607f..e890d30ae3 100644 --- a/src/slic3r/GUI/wxExtensions.hpp +++ b/src/slic3r/GUI/wxExtensions.hpp @@ -16,6 +16,7 @@ #include #include +#include "Widgets/PopupWindow.hpp" #ifdef __WXMSW__ void msw_rescale_menu(wxMenu* menu); @@ -392,7 +393,7 @@ private: // ImageTransientPopup // ---------------------------------------------------------------------------- -class ImageTransientPopup : public wxPopupTransientWindow +class ImageTransientPopup : public PopupWindow { public: ImageTransientPopup( wxWindow *parent, bool scrolled, wxBitmap bmp); @@ -400,7 +401,7 @@ class ImageTransientPopup : public wxPopupTransientWindow void SetImage(wxBitmap bmp); - // wxPopupTransientWindow virtual methods are all overridden to log them + // PopupWindow virtual methods are all overridden to log them virtual void Popup(wxWindow *focus = NULL) wxOVERRIDE; virtual void OnDismiss() wxOVERRIDE; virtual bool ProcessLeftDown(wxMouseEvent& event) wxOVERRIDE;