Allow wxSTCPopupWindow to move when its parent wxSTC moves
This commit is contained in:
parent
de0992ea3d
commit
0c953308de
@ -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)
|
||||
{
|
||||
|
@ -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;
|
||||
};
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user