From 8c2f37978674e79f0ffd8b41c46d6c698f90ccce Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Sun, 17 Mar 2002 14:13:14 +0000 Subject: [PATCH] added Calc(Un)ScrolledPosition taking wxPoint git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14657 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/gtk/scrolwin.h | 23 +++++++++++++++++++++-- include/wx/gtk1/scrolwin.h | 23 +++++++++++++++++++++-- include/wx/scrolwin.h | 22 ++++++++++++++++++++-- src/generic/scrlwing.cpp | 4 ++-- src/gtk/scrolwin.cpp | 4 ++-- src/gtk1/scrolwin.cpp | 4 ++-- 6 files changed, 68 insertions(+), 12 deletions(-) diff --git a/include/wx/gtk/scrolwin.h b/include/wx/gtk/scrolwin.h index 96688d1ab9..9d9c0d9a6e 100644 --- a/include/wx/gtk/scrolwin.h +++ b/include/wx/gtk/scrolwin.h @@ -98,8 +98,27 @@ public: // Actual size in pixels when scrolling is taken into account virtual void GetVirtualSize(int *x, int *y) const; - virtual void CalcScrolledPosition(int x, int y, int *xx, int *yy) const; - virtual void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const; + // translate between scrolled and unscrolled coordinates + void CalcScrolledPosition(int x, int y, int *xx, int *yy) const + { DoCalcScrolledPosition(x, y, xx, yy); } + wxPoint CalcScrolledPosition(const wxPoint& pt) const + { + wxPoint p2; + DoCalcScrolledPosition(pt.x, pt.y, &p2.x, &p2.y); + return p2; + } + + void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const + { DoCalcUnscrolledPosition(x, y, xx, yy); } + wxPoint CalcUnscrolledPosition(const wxPoint& pt) const + { + wxPoint p2; + DoCalcUnscrolledPosition(pt.x, pt.y, &p2.x, &p2.y); + return p2; + } + + virtual void DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const; + virtual void DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const; // Override this function to draw the graphic (or just process EVT_PAINT) virtual void OnDraw(wxDC& WXUNUSED(dc)) {} diff --git a/include/wx/gtk1/scrolwin.h b/include/wx/gtk1/scrolwin.h index 96688d1ab9..9d9c0d9a6e 100644 --- a/include/wx/gtk1/scrolwin.h +++ b/include/wx/gtk1/scrolwin.h @@ -98,8 +98,27 @@ public: // Actual size in pixels when scrolling is taken into account virtual void GetVirtualSize(int *x, int *y) const; - virtual void CalcScrolledPosition(int x, int y, int *xx, int *yy) const; - virtual void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const; + // translate between scrolled and unscrolled coordinates + void CalcScrolledPosition(int x, int y, int *xx, int *yy) const + { DoCalcScrolledPosition(x, y, xx, yy); } + wxPoint CalcScrolledPosition(const wxPoint& pt) const + { + wxPoint p2; + DoCalcScrolledPosition(pt.x, pt.y, &p2.x, &p2.y); + return p2; + } + + void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const + { DoCalcUnscrolledPosition(x, y, xx, yy); } + wxPoint CalcUnscrolledPosition(const wxPoint& pt) const + { + wxPoint p2; + DoCalcUnscrolledPosition(pt.x, pt.y, &p2.x, &p2.y); + return p2; + } + + virtual void DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const; + virtual void DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const; // Override this function to draw the graphic (or just process EVT_PAINT) virtual void OnDraw(wxDC& WXUNUSED(dc)) {} diff --git a/include/wx/scrolwin.h b/include/wx/scrolwin.h index 0894cd920b..2986a6c9c4 100644 --- a/include/wx/scrolwin.h +++ b/include/wx/scrolwin.h @@ -67,8 +67,26 @@ public: double GetScaleY() const { return m_scaleY; } // translate between scrolled and unscrolled coordinates - virtual void CalcScrolledPosition(int x, int y, int *xx, int *yy) const; - virtual void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const; + void CalcScrolledPosition(int x, int y, int *xx, int *yy) const + { DoCalcScrolledPosition(x, y, xx, yy); } + wxPoint CalcScrolledPosition(const wxPoint& pt) const + { + wxPoint p2; + DoCalcScrolledPosition(pt.x, pt.y, &p2.x, &p2.y); + return p2; + } + + void CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const + { DoCalcUnscrolledPosition(x, y, xx, yy); } + wxPoint CalcUnscrolledPosition(const wxPoint& pt) const + { + wxPoint p2; + DoCalcUnscrolledPosition(pt.x, pt.y, &p2.x, &p2.y); + return p2; + } + + virtual void DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const; + virtual void DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const; // Adjust the scrollbars virtual void AdjustScrollbars(void); diff --git a/src/generic/scrlwing.cpp b/src/generic/scrlwing.cpp index 1cef14d60f..b19d93d85b 100644 --- a/src/generic/scrlwing.cpp +++ b/src/generic/scrlwing.cpp @@ -814,7 +814,7 @@ void wxScrollHelper::GetViewStart (int *x, int *y) const *y = m_yScrollPosition; } -void wxScrollHelper::CalcScrolledPosition(int x, int y, int *xx, int *yy) const +void wxScrollHelper::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const { if ( xx ) *xx = x - m_xScrollPosition * m_xScrollPixelsPerLine; @@ -822,7 +822,7 @@ void wxScrollHelper::CalcScrolledPosition(int x, int y, int *xx, int *yy) const *yy = y - m_yScrollPosition * m_yScrollPixelsPerLine; } -void wxScrollHelper::CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const +void wxScrollHelper::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const { if ( xx ) *xx = x + m_xScrollPosition * m_xScrollPixelsPerLine; diff --git a/src/gtk/scrolwin.cpp b/src/gtk/scrolwin.cpp index 579d2b7b6d..175fb3494d 100644 --- a/src/gtk/scrolwin.cpp +++ b/src/gtk/scrolwin.cpp @@ -588,7 +588,7 @@ void wxScrolledWindow::GetViewStart (int *x, int *y) const *y = m_yScrollPosition; } -void wxScrolledWindow::CalcScrolledPosition(int x, int y, int *xx, int *yy) const +void wxScrolledWindow::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const { if ( xx ) *xx = x - m_xScrollPosition * m_xScrollPixelsPerLine; @@ -596,7 +596,7 @@ void wxScrolledWindow::CalcScrolledPosition(int x, int y, int *xx, int *yy) cons *yy = y - m_yScrollPosition * m_yScrollPixelsPerLine; } -void wxScrolledWindow::CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const +void wxScrolledWindow::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const { if ( xx ) *xx = x + m_xScrollPosition * m_xScrollPixelsPerLine; diff --git a/src/gtk1/scrolwin.cpp b/src/gtk1/scrolwin.cpp index 579d2b7b6d..175fb3494d 100644 --- a/src/gtk1/scrolwin.cpp +++ b/src/gtk1/scrolwin.cpp @@ -588,7 +588,7 @@ void wxScrolledWindow::GetViewStart (int *x, int *y) const *y = m_yScrollPosition; } -void wxScrolledWindow::CalcScrolledPosition(int x, int y, int *xx, int *yy) const +void wxScrolledWindow::DoCalcScrolledPosition(int x, int y, int *xx, int *yy) const { if ( xx ) *xx = x - m_xScrollPosition * m_xScrollPixelsPerLine; @@ -596,7 +596,7 @@ void wxScrolledWindow::CalcScrolledPosition(int x, int y, int *xx, int *yy) cons *yy = y - m_yScrollPosition * m_yScrollPixelsPerLine; } -void wxScrolledWindow::CalcUnscrolledPosition(int x, int y, int *xx, int *yy) const +void wxScrolledWindow::DoCalcUnscrolledPosition(int x, int y, int *xx, int *yy) const { if ( xx ) *xx = x + m_xScrollPosition * m_xScrollPixelsPerLine; -- 2.45.2