add convenient GetViewStart() and Scroll() overloads taking wxPoint instead of 2 int[ pointer]s
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57527 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -27,7 +27,6 @@ public:
|
||||
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
|
||||
@@ -60,11 +59,13 @@ protected:
|
||||
}
|
||||
|
||||
// and this does the same for Scroll()
|
||||
void DoScroll(int orient,
|
||||
void DoScrollOneDir(int orient,
|
||||
int pos,
|
||||
int pixelsPerLine,
|
||||
int *posOld);
|
||||
|
||||
virtual void DoScroll(int x, int y);
|
||||
|
||||
private:
|
||||
DECLARE_NO_COPY_CLASS(wxScrollHelperNative)
|
||||
};
|
||||
|
@@ -62,7 +62,8 @@ public:
|
||||
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;
|
||||
@@ -87,7 +88,14 @@ public:
|
||||
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; }
|
||||
@@ -191,6 +199,10 @@ protected:
|
||||
*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();
|
||||
|
@@ -251,6 +251,7 @@ public:
|
||||
*/
|
||||
void GetScrollPixelsPerUnit(int* xUnit, int* yUnit) const;
|
||||
|
||||
//@{
|
||||
/**
|
||||
Get the position at which the visible portion of the window starts.
|
||||
|
||||
@@ -268,9 +269,11 @@ public:
|
||||
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
|
||||
@@ -313,6 +316,7 @@ public:
|
||||
*/
|
||||
void PrepareDC(wxDC& dc);
|
||||
|
||||
//@{
|
||||
/**
|
||||
Scrolls a window so the view start is at the given point.
|
||||
|
||||
@@ -323,13 +327,15 @@ public:
|
||||
|
||||
@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
|
||||
|
@@ -493,10 +493,7 @@ private:
|
||||
{
|
||||
m_inDoSync = true;
|
||||
|
||||
int x, y;
|
||||
GetViewStart(&x, &y);
|
||||
|
||||
m_winSync->Scroll(x, y);
|
||||
m_winSync->Scroll(GetViewStart());
|
||||
|
||||
m_inDoSync = false;
|
||||
}
|
||||
@@ -771,9 +768,7 @@ void MyCanvas::OnScrollWin( wxCommandEvent &WXUNUSED(event) )
|
||||
{
|
||||
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 );
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -1059,20 +1054,14 @@ MyAutoScrollingWindow::DeviceCoordsToGraphicalChars(wxPoint pos) const
|
||||
{
|
||||
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;
|
||||
|
@@ -894,7 +894,7 @@ void wxScrollHelper::SetScrollPageSize(int orient, int pageSize)
|
||||
/*
|
||||
* 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;
|
||||
@@ -973,7 +973,7 @@ void wxScrollHelper::EnableScrolling (bool x_scroll, bool y_scroll)
|
||||
}
|
||||
|
||||
// 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;
|
||||
|
@@ -163,7 +163,7 @@ void wxScrollHelperNative::AdjustScrollbars()
|
||||
}
|
||||
}
|
||||
|
||||
void wxScrollHelperNative::DoScroll(int orient,
|
||||
void wxScrollHelperNative::DoScrollOneDir(int orient,
|
||||
int pos,
|
||||
int pixelsPerLine,
|
||||
int *posOld)
|
||||
@@ -181,10 +181,10 @@ void wxScrollHelperNative::DoScroll(int orient,
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
Reference in New Issue
Block a user