From b9f2926155e550191fd91ec45943382e4252365a Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Wed, 19 Sep 2001 22:45:14 +0000 Subject: [PATCH] fixes to client area origin handling git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11652 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/frame.h | 2 ++ include/wx/gtk1/frame.h | 2 ++ src/gtk/window.cpp | 24 +++++++++++++++++++----- src/gtk1/window.cpp | 24 +++++++++++++++++++----- 4 files changed, 42 insertions(+), 10 deletions(-) diff --git a/include/wx/gtk/frame.h b/include/wx/gtk/frame.h index ec5261621e..5240e7b884 100644 --- a/include/wx/gtk/frame.h +++ b/include/wx/gtk/frame.h @@ -73,6 +73,8 @@ public: const wxString& name = wxToolBarNameStr); void SetToolBar(wxToolBar *toolbar); #endif // wxUSE_TOOLBAR + + wxPoint GetClientAreaOrigin() const { return wxPoint(0, 0); } // implementation from now on // -------------------------- diff --git a/include/wx/gtk1/frame.h b/include/wx/gtk1/frame.h index ec5261621e..5240e7b884 100644 --- a/include/wx/gtk1/frame.h +++ b/include/wx/gtk1/frame.h @@ -73,6 +73,8 @@ public: const wxString& name = wxToolBarNameStr); void SetToolBar(wxToolBar *toolbar); #endif // wxUSE_TOOLBAR + + wxPoint GetClientAreaOrigin() const { return wxPoint(0, 0); } // implementation from now on // -------------------------- diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index 866d2b4f8b..1c2d765a7e 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2690,10 +2690,12 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags if (m_resizing) return; /* I don't like recursions */ m_resizing = TRUE; - if (x == -1) - x = m_x; + int currentX, currentY; + GetPosition(¤tX, ¤tY); + if (x == -1) + x = currentX; if (y == -1) - y = m_y; + y = currentY; AdjustForParentClientOrigin(x, y, sizeFlags); if (m_parent->m_wxwindow == NULL) /* i.e. wxNotebook */ @@ -2986,9 +2988,21 @@ void wxWindowGTK::DoGetPosition( int *x, int *y ) const dx = pizza->xoffset; dy = pizza->yoffset; } + + int nx = m_x - dx; + int ny = m_y - dy; + + if ( !IsTopLevel() && m_parent ) + { + // We may be faking the client origin. So a window that's really at (0, + // 30) may appear (to wxWin apps) to be at (0, 0). + wxPoint pt(m_parent->GetClientAreaOrigin()); + nx -= pt.x; + ny -= pt.y; + } - if (x) (*x) = m_x - dx; - if (y) (*y) = m_y - dy; + if (x) (*x) = nx; + if (y) (*y) = ny; } void wxWindowGTK::DoClientToScreen( int *x, int *y ) const diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index 866d2b4f8b..1c2d765a7e 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -2690,10 +2690,12 @@ void wxWindowGTK::DoSetSize( int x, int y, int width, int height, int sizeFlags if (m_resizing) return; /* I don't like recursions */ m_resizing = TRUE; - if (x == -1) - x = m_x; + int currentX, currentY; + GetPosition(¤tX, ¤tY); + if (x == -1) + x = currentX; if (y == -1) - y = m_y; + y = currentY; AdjustForParentClientOrigin(x, y, sizeFlags); if (m_parent->m_wxwindow == NULL) /* i.e. wxNotebook */ @@ -2986,9 +2988,21 @@ void wxWindowGTK::DoGetPosition( int *x, int *y ) const dx = pizza->xoffset; dy = pizza->yoffset; } + + int nx = m_x - dx; + int ny = m_y - dy; + + if ( !IsTopLevel() && m_parent ) + { + // We may be faking the client origin. So a window that's really at (0, + // 30) may appear (to wxWin apps) to be at (0, 0). + wxPoint pt(m_parent->GetClientAreaOrigin()); + nx -= pt.x; + ny -= pt.y; + } - if (x) (*x) = m_x - dx; - if (y) (*y) = m_y - dy; + if (x) (*x) = nx; + if (y) (*y) = ny; } void wxWindowGTK::DoClientToScreen( int *x, int *y ) const -- 2.47.2