Allow wxSTCPopupWindow to move when its parent wxSTC moves
This commit is contained in:
@@ -2199,11 +2199,26 @@ PRectangle Window::GetMonitorRect(Point pt) {
|
|||||||
|
|
||||||
#endif // __WXOSX_COCOA__
|
#endif // __WXOSX_COCOA__
|
||||||
|
|
||||||
wxSTCPopupWindow::wxSTCPopupWindow(wxWindow* parent):wxSTCPopupBase(parent)
|
wxSTCPopupWindow::wxSTCPopupWindow(wxWindow* parent)
|
||||||
|
:wxSTCPopupBase(parent), m_initialPosition(wxDefaultPosition)
|
||||||
{
|
{
|
||||||
#if !wxSTC_POPUP_IS_CUSTOM
|
#if !wxSTC_POPUP_IS_CUSTOM
|
||||||
Bind(wxEVT_SET_FOCUS, &wxSTCPopupWindow::OnFocus, this);
|
Bind(wxEVT_SET_FOCUS, &wxSTCPopupWindow::OnFocus, this);
|
||||||
#endif
|
#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()
|
bool wxSTCPopupWindow::Destroy()
|
||||||
@@ -2230,6 +2245,10 @@ bool wxSTCPopupWindow::AcceptsFocus() const
|
|||||||
|
|
||||||
void wxSTCPopupWindow::DoSetSize(int x, int y, int width, int height, int flags)
|
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
|
// convert coords to screen coords since we're a top-level window
|
||||||
if (x != wxDefaultCoord)
|
if (x != wxDefaultCoord)
|
||||||
GetParent()->ClientToScreen(&x, NULL);
|
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);
|
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
|
#if !wxSTC_POPUP_IS_CUSTOM
|
||||||
void wxSTCPopupWindow::OnFocus(wxFocusEvent& event)
|
void wxSTCPopupWindow::OnFocus(wxFocusEvent& event)
|
||||||
{
|
{
|
||||||
|
@@ -130,15 +130,21 @@ class wxSTCPopupWindow:public wxSTCPopupBase
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxSTCPopupWindow(wxWindow*);
|
wxSTCPopupWindow(wxWindow*);
|
||||||
|
virtual ~wxSTCPopupWindow();
|
||||||
virtual bool Destroy() wxOVERRIDE;
|
virtual bool Destroy() wxOVERRIDE;
|
||||||
virtual bool AcceptsFocus() const wxOVERRIDE;
|
virtual bool AcceptsFocus() const wxOVERRIDE;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void DoSetSize(int x, int y, int width, int height,
|
virtual void DoSetSize(int x, int y, int width, int height,
|
||||||
int sizeFlags = wxSIZE_AUTO) wxOVERRIDE;
|
int sizeFlags = wxSIZE_AUTO) wxOVERRIDE;
|
||||||
|
void OnParentMove(wxMoveEvent& event);
|
||||||
#if !wxSTC_POPUP_IS_CUSTOM
|
#if !wxSTC_POPUP_IS_CUSTOM
|
||||||
void OnFocus(wxFocusEvent& event);
|
void OnFocus(wxFocusEvent& event);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
private:
|
||||||
|
wxPoint m_initialPosition;
|
||||||
|
wxWindow* m_tlw;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user