diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 84ac3c8adc..628ffbc2ec 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -2199,11 +2199,26 @@ PRectangle Window::GetMonitorRect(Point pt) { #endif // __WXOSX_COCOA__ -wxSTCPopupWindow::wxSTCPopupWindow(wxWindow* parent):wxSTCPopupBase(parent) +wxSTCPopupWindow::wxSTCPopupWindow(wxWindow* parent) + :wxSTCPopupBase(parent), m_initialPosition(wxDefaultPosition) { #if !wxSTC_POPUP_IS_CUSTOM Bind(wxEVT_SET_FOCUS, &wxSTCPopupWindow::OnFocus, this); #endif + + m_tlw = wxDynamicCast(wxGetTopLevelParent(parent), wxTopLevelWindow); + if ( m_tlw ) + { + m_tlw->Bind(wxEVT_MOVE, &wxSTCPopupWindow::OnParentMove, this); + } +} + +wxSTCPopupWindow::~wxSTCPopupWindow() +{ + if ( m_tlw ) + { + m_tlw->Unbind(wxEVT_MOVE, &wxSTCPopupWindow::OnParentMove, this); + } } bool wxSTCPopupWindow::Destroy() @@ -2230,6 +2245,10 @@ bool wxSTCPopupWindow::AcceptsFocus() const void wxSTCPopupWindow::DoSetSize(int x, int y, int width, int height, int flags) { + if ( m_initialPosition == wxDefaultPosition + && x != wxDefaultCoord && y != wxDefaultCoord ) + m_initialPosition = wxPoint(x, y); + // convert coords to screen coords since we're a top-level window if (x != wxDefaultCoord) GetParent()->ClientToScreen(&x, NULL); @@ -2240,6 +2259,13 @@ void wxSTCPopupWindow::DoSetSize(int x, int y, int width, int height, int flags) wxSTCPopupBase::DoSetSize(x, y, width, height, flags); } +void wxSTCPopupWindow::OnParentMove(wxMoveEvent& event) +{ + if ( m_initialPosition != wxDefaultPosition ) + SetPosition(m_initialPosition); + event.Skip(); +} + #if !wxSTC_POPUP_IS_CUSTOM void wxSTCPopupWindow::OnFocus(wxFocusEvent& event) { diff --git a/src/stc/PlatWX.h b/src/stc/PlatWX.h index 4f4d768918..9c9aaff038 100644 --- a/src/stc/PlatWX.h +++ b/src/stc/PlatWX.h @@ -130,15 +130,21 @@ class wxSTCPopupWindow:public wxSTCPopupBase { public: wxSTCPopupWindow(wxWindow*); + virtual ~wxSTCPopupWindow(); virtual bool Destroy() wxOVERRIDE; virtual bool AcceptsFocus() const wxOVERRIDE; protected: virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) wxOVERRIDE; + void OnParentMove(wxMoveEvent& event); #if !wxSTC_POPUP_IS_CUSTOM void OnFocus(wxFocusEvent& event); #endif + +private: + wxPoint m_initialPosition; + wxWindow* m_tlw; };