From dabc0cd5c1c89f731d818d5d2cfa03bfff8a9db7 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 19 May 1999 01:00:57 +0000 Subject: [PATCH] ScreenToClient() implemented correctly git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2505 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/window.h | 9 ++------- include/wx/gtk1/window.h | 9 ++------- include/wx/msw/window.h | 9 ++------- include/wx/window.h | 25 +++++++++++++++++++++++-- src/gtk/window.cpp | 4 ++-- src/gtk1/window.cpp | 4 ++-- src/msw/window.cpp | 4 ++-- 7 files changed, 35 insertions(+), 29 deletions(-) diff --git a/include/wx/gtk/window.h b/include/wx/gtk/window.h index 4c6fc6fa8f..167d3bc338 100644 --- a/include/wx/gtk/window.h +++ b/include/wx/gtk/window.h @@ -86,13 +86,6 @@ public: const wxFont *theFont = (const wxFont *) NULL) const; - virtual void ClientToScreen( int *x, int *y ) const; - virtual void ScreenToClient( int *x, int *y ) const; - wxPoint ClientToScreen(const wxPoint& pt) const - { int x = pt.x; int y = pt.y; ClientToScreen(& x, & y); return wxPoint(x, y); } - wxPoint ScreenToClient(const wxPoint& pt) const - { int x = pt.x; int y = pt.y; ScreenToClient(& x, & y); return wxPoint(x, y); } - virtual bool PopupMenu( wxMenu *menu, int x, int y ); virtual void SetScrollbar( int orient, int pos, int thumbVisible, @@ -215,6 +208,8 @@ public: wxInsertChildFunction m_insertCallback; // implement the base class pure virtuals + virtual void DoClientToScreen( int *x, int *y ) const; + virtual void DoScreenToClient( int *x, int *y ) const; virtual void DoGetPosition( int *x, int *y ) const; virtual void DoGetSize( int *width, int *height ) const; virtual void DoGetClientSize( int *width, int *height ) const; diff --git a/include/wx/gtk1/window.h b/include/wx/gtk1/window.h index 4c6fc6fa8f..167d3bc338 100644 --- a/include/wx/gtk1/window.h +++ b/include/wx/gtk1/window.h @@ -86,13 +86,6 @@ public: const wxFont *theFont = (const wxFont *) NULL) const; - virtual void ClientToScreen( int *x, int *y ) const; - virtual void ScreenToClient( int *x, int *y ) const; - wxPoint ClientToScreen(const wxPoint& pt) const - { int x = pt.x; int y = pt.y; ClientToScreen(& x, & y); return wxPoint(x, y); } - wxPoint ScreenToClient(const wxPoint& pt) const - { int x = pt.x; int y = pt.y; ScreenToClient(& x, & y); return wxPoint(x, y); } - virtual bool PopupMenu( wxMenu *menu, int x, int y ); virtual void SetScrollbar( int orient, int pos, int thumbVisible, @@ -215,6 +208,8 @@ public: wxInsertChildFunction m_insertCallback; // implement the base class pure virtuals + virtual void DoClientToScreen( int *x, int *y ) const; + virtual void DoScreenToClient( int *x, int *y ) const; virtual void DoGetPosition( int *x, int *y ) const; virtual void DoGetSize( int *width, int *height ) const; virtual void DoGetClientSize( int *width, int *height ) const; diff --git a/include/wx/msw/window.h b/include/wx/msw/window.h index febe2c9b2e..73f3856f0d 100644 --- a/include/wx/msw/window.h +++ b/include/wx/msw/window.h @@ -110,13 +110,6 @@ public: const wxFont *theFont = (const wxFont *) NULL) const; - virtual void ClientToScreen( int *x, int *y ) const; - virtual void ScreenToClient( int *x, int *y ) const; - wxPoint ClientToScreen(const wxPoint& pt) const - { int x = pt.x; int y = pt.y; ClientToScreen(& x, & y); return wxPoint(x, y); } - wxPoint ScreenToClient(const wxPoint& pt) const - { int x = pt.x; int y = pt.y; ScreenToClient(& x, & y); return wxPoint(x, y); } - virtual bool PopupMenu( wxMenu *menu, int x, int y ); virtual void SetScrollbar( int orient, int pos, int thumbVisible, @@ -403,6 +396,8 @@ protected: wxButton *m_btnDefault; // implement the base class pure virtuals + virtual void DoClientToScreen( int *x, int *y ) const; + virtual void DoScreenToClient( int *x, int *y ) const; virtual void DoGetPosition( int *x, int *y ) const; virtual void DoGetSize( int *width, int *height ) const; virtual void DoGetClientSize( int *width, int *height ) const; diff --git a/include/wx/window.h b/include/wx/window.h index 99f192fc7e..8aa851a82a 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -489,8 +489,25 @@ public: const = 0; // translate to/from screen/client coordinates (pointers may be NULL) - virtual void ClientToScreen( int *x, int *y ) const = 0; - virtual void ScreenToClient( int *x, int *y ) const = 0; + void ClientToScreen( int *x, int *y ) const + { DoClientToScreen(x, y); } + void ScreenToClient( int *x, int *y ) const + { DoScreenToClient(x, y); } + wxPoint ClientToScreen(const wxPoint& pt) const + { + int x = pt.x, y = pt.y; + DoClientToScreen(&x, &y); + + return wxPoint(x, y); + } + + wxPoint ScreenToClient(const wxPoint& pt) const + { + int x = pt.x, y = pt.y; + DoScreenToClient(&x, &y); + + return wxPoint(x, y); + } // misc // ---- @@ -707,6 +724,10 @@ protected: // overloaded Something()s in terms of DoSomething() which will be the // only one to be virtual. + // coordinates translation + virtual void DoClientToScreen( int *x, int *y ) const = 0; + virtual void DoScreenToClient( int *x, int *y ) const = 0; + // retrieve the position/size of the window virtual void DoGetPosition( int *x, int *y ) const = 0; virtual void DoGetSize( int *width, int *height ) const = 0; diff --git a/src/gtk/window.cpp b/src/gtk/window.cpp index cff51e599d..1d6581c0bd 100644 --- a/src/gtk/window.cpp +++ b/src/gtk/window.cpp @@ -2129,7 +2129,7 @@ void wxWindow::DoGetPosition( int *x, int *y ) const if (y) (*y) = m_y; } -void wxWindow::ClientToScreen( int *x, int *y ) const +void wxWindow::DoClientToScreen( int *x, int *y ) const { wxCHECK_RET( (m_widget != NULL), _T("invalid window") ); @@ -2158,7 +2158,7 @@ void wxWindow::ClientToScreen( int *x, int *y ) const if (y) *y += org_y; } -void wxWindow::ScreenToClient( int *x, int *y ) const +void wxWindow::DoScreenToClient( int *x, int *y ) const { wxCHECK_RET( (m_widget != NULL), _T("invalid window") ); diff --git a/src/gtk1/window.cpp b/src/gtk1/window.cpp index cff51e599d..1d6581c0bd 100644 --- a/src/gtk1/window.cpp +++ b/src/gtk1/window.cpp @@ -2129,7 +2129,7 @@ void wxWindow::DoGetPosition( int *x, int *y ) const if (y) (*y) = m_y; } -void wxWindow::ClientToScreen( int *x, int *y ) const +void wxWindow::DoClientToScreen( int *x, int *y ) const { wxCHECK_RET( (m_widget != NULL), _T("invalid window") ); @@ -2158,7 +2158,7 @@ void wxWindow::ClientToScreen( int *x, int *y ) const if (y) *y += org_y; } -void wxWindow::ScreenToClient( int *x, int *y ) const +void wxWindow::DoScreenToClient( int *x, int *y ) const { wxCHECK_RET( (m_widget != NULL), _T("invalid window") ); diff --git a/src/msw/window.cpp b/src/msw/window.cpp index de806ac65f..88a43b6b33 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -1099,7 +1099,7 @@ void wxWindow::DoGetPosition(int *x, int *y) const *y = point.y; } -void wxWindow::ScreenToClient(int *x, int *y) const +void wxWindow::DoScreenToClient(int *x, int *y) const { POINT pt; if ( x ) @@ -1116,7 +1116,7 @@ void wxWindow::ScreenToClient(int *x, int *y) const *y = pt.y; } -void wxWindow::ClientToScreen(int *x, int *y) const +void wxWindow::DoClientToScreen(int *x, int *y) const { POINT pt; if ( x ) -- 2.45.2