int xPos = 0, int yPos = 0,
bool noRefresh = false);
virtual void AdjustScrollbars();
- virtual void Scroll(int x, int y);
protected:
// this does (each) half of AdjustScrollbars() work
}
// and this does the same for Scroll()
- void DoScroll(int orient,
- int pos,
- int pixelsPerLine,
- int *posOld);
+ void DoScrollOneDir(int orient,
+ int pos,
+ int pixelsPerLine,
+ int *posOld);
+
+ virtual void DoScroll(int x, int y);
private:
DECLARE_NO_COPY_CLASS(wxScrollHelperNative)
bool noRefresh = false );
// scroll to the given (in logical coords) position
- virtual void Scroll(int x, int y);
+ void Scroll(int x, int y) { DoScroll(x, y); }
+ void Scroll(const wxPoint& pt) { DoScroll(pt.x, pt.y); }
// get/set the page size for this orientation (wxVERTICAL/wxHORIZONTAL)
int GetScrollPageSize(int orient) const;
void SetScrollPageSize(int orient, int pageSize);
- // get the number of lines the window can scroll,
+ // get the number of lines the window can scroll,
// returns 0 if no scrollbars are there.
int GetScrollLines( int orient ) const;
virtual void EnableScrolling(bool x_scrolling, bool y_scrolling);
// Get the view start
- virtual void GetViewStart(int *x, int *y) const;
+ void GetViewStart(int *x, int *y) const { DoGetViewStart(x, y); }
+
+ wxPoint GetViewStart() const
+ {
+ wxPoint pt;
+ DoGetViewStart(&pt.x, &pt.y);
+ return pt;
+ }
// Set the scale factor, used in PrepareDC
void SetScale(double xs, double ys) { m_scaleX = xs; m_scaleY = ys; }
*h = size.y;
}
+ // implementation of public methods with the same name
+ virtual void DoGetViewStart(int *x, int *y) const;
+ virtual void DoScroll(int x, int y);
+
// implementations of various wxWindow virtual methods which should be
// forwarded to us (this can be done by WX_FORWARD_TO_SCROLL_HELPER())
bool ScrollLayout();
*/
void GetScrollPixelsPerUnit(int* xUnit, int* yUnit) const;
+ //@{
/**
Get the position at which the visible portion of the window starts.
have to multiply by the number of pixels per scroll
increment.
- @see SetScrollbars()
+ @see SetScrollbars(), Scroll()
*/
void GetViewStart(int* x, int* y) const;
+ wxPoint GetViewStart() const;
+ //@}
/**
Gets the size in device units of the scrollable window area (as
*/
void PrepareDC(wxDC& dc);
+ //@{
/**
Scrolls a window so the view start is at the given point.
@remarks The positions are in scroll units, not pixels, so to convert to
pixels you will have to multiply by the number of
- pixels per scroll increment. If either parameter is -1,
- that position will be ignored (no change in that
- direction).
+ pixels per scroll increment. If either parameter is
+ wxDefaultCoord (-1), that position will be ignored (no change
+ in that direction).
@see SetScrollbars(), GetScrollPixelsPerUnit()
*/
void Scroll(int x, int y);
+ void Scroll(const wxPoint& pt);
+ //@}
/**
Set the horizontal and vertical scrolling increment only. See the
{
m_inDoSync = true;
- int x, y;
- GetViewStart(&x, &y);
-
- m_winSync->Scroll(x, y);
+ m_winSync->Scroll(GetViewStart());
m_inDoSync = false;
}
{
wxLogMessage("Scrolling 2 units up.\n"
"The white square and the controls should move equally!");
- int x,y;
- GetViewStart( &x, &y );
- Scroll( wxDefaultCoord, y+2 );
+ Scroll( wxDefaultCoord, GetViewStart().y+2 );
}
// ----------------------------------------------------------------------------
{
pos.x /= m_fontW;
pos.y /= m_fontH;
- int vX, vY;
- GetViewStart(&vX, &vY);
- pos.x += vX;
- pos.y += vY;
+ pos += GetViewStart();
return pos;
}
wxPoint
MyAutoScrollingWindow::GraphicalCharToDeviceCoords(wxPoint pos) const
{
- int vX, vY;
- GetViewStart(&vX, &vY);
- pos.x -= vX;
- pos.y -= vY;
+ pos -= GetViewStart();
pos.x *= m_fontW;
pos.y *= m_fontH;
return pos;
/*
* Scroll to given position (scroll position, not pixel position)
*/
-void wxScrollHelper::Scroll( int x_pos, int y_pos )
+void wxScrollHelper::DoScroll( int x_pos, int y_pos )
{
if (!m_targetWindow)
return;
}
// Where the current view starts from
-void wxScrollHelper::GetViewStart (int *x, int *y) const
+void wxScrollHelper::DoGetViewStart (int *x, int *y) const
{
if ( x )
*x = m_xScrollPosition;
}
}
-void wxScrollHelperNative::DoScroll(int orient,
- int pos,
- int pixelsPerLine,
- int *posOld)
+void wxScrollHelperNative::DoScrollOneDir(int orient,
+ int pos,
+ int pixelsPerLine,
+ int *posOld)
{
if ( pos != -1 && pos != *posOld && pixelsPerLine )
{
}
}
-void wxScrollHelperNative::Scroll( int x_pos, int y_pos )
+void wxScrollHelperNative::DoScroll( int x_pos, int y_pos )
{
wxCHECK_RET( m_targetWindow != 0, _T("No target window") );
- DoScroll(wxHORIZONTAL, x_pos, m_xScrollPixelsPerLine, &m_xScrollPosition);
- DoScroll(wxVERTICAL, y_pos, m_yScrollPixelsPerLine, &m_yScrollPosition);
+ DoScrollOneDir(wxHORIZONTAL, x_pos, m_xScrollPixelsPerLine, &m_xScrollPosition);
+ DoScrollOneDir(wxVERTICAL, y_pos, m_yScrollPixelsPerLine, &m_yScrollPosition);
}