X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/11ed4f79aa6b24fa3a86beead18519f87a86d1ea..c9d9f242e45a5d8399d52f5709b560a63dd804fc:/src/generic/scrolwin.cpp diff --git a/src/generic/scrolwin.cpp b/src/generic/scrolwin.cpp index 40abc1a3d8..bdc9467d73 100644 --- a/src/generic/scrolwin.cpp +++ b/src/generic/scrolwin.cpp @@ -52,6 +52,8 @@ wxScrolledWindow::wxScrolledWindow(void) m_yScrollLines = 0; m_xScrollLinesPerPage = 0; m_yScrollLinesPerPage = 0; + m_scaleX = 1.0; + m_scaleY = 1.0; } bool wxScrolledWindow::Create(wxWindow *parent, wxWindowID id, @@ -70,6 +72,8 @@ bool wxScrolledWindow::Create(wxWindow *parent, wxWindowID id, m_yScrollLines = 0; m_xScrollLinesPerPage = 0; m_yScrollLinesPerPage = 0; + m_scaleX = 1.0; + m_scaleY = 1.0; return wxWindow::Create(parent, id, pos, size, style, name); } @@ -100,7 +104,7 @@ void wxScrolledWindow::SetScrollbars (int pixelsPerUnitX, int pixelsPerUnitY, m_yScrollPosition = yPos; m_xScrollLines = noUnitsX; m_yScrollLines = noUnitsY; - + AdjustScrollbars(); if (do_refresh && !noRefresh) Refresh(); @@ -155,14 +159,14 @@ void wxScrolledWindow::OnScroll(wxScrollEvent& event) if (orient == wxHORIZONTAL) { if (m_xScrollingEnabled) - ScrollWindow(-m_xScrollPixelsPerLine * nScrollInc, 0, NULL); + ScrollWindow(-m_xScrollPixelsPerLine * nScrollInc, 0, (const wxRect *) NULL); else Refresh(); } else { if (m_yScrollingEnabled) - ScrollWindow(0, -m_yScrollPixelsPerLine * nScrollInc, NULL); + ScrollWindow(0, -m_yScrollPixelsPerLine * nScrollInc, (const wxRect *) NULL); else Refresh(); } @@ -234,38 +238,44 @@ int wxScrolledWindow::CalcScrollInc(wxScrollEvent& event) } if (orient == wxHORIZONTAL) { - int w, h; - GetClientSize(&w, &h); - - int nMaxWidth = m_xScrollLines*m_xScrollPixelsPerLine; - int noPositions = (int) ( ((nMaxWidth - w)/(float)m_xScrollPixelsPerLine) + 0.5 ); - if (noPositions < 0) - noPositions = 0; - - if ( (m_xScrollPosition + nScrollInc) < 0 ) - nScrollInc = -m_xScrollPosition; // As -ve as we can go - else if ( (m_xScrollPosition + nScrollInc) > noPositions ) - nScrollInc = noPositions - m_xScrollPosition; // As +ve as we can go - - return nScrollInc; + if (m_xScrollPixelsPerLine > 0) { + int w, h; + GetClientSize(&w, &h); + + int nMaxWidth = m_xScrollLines*m_xScrollPixelsPerLine; + int noPositions = (int) ( ((nMaxWidth - w)/(float)m_xScrollPixelsPerLine) + 0.5 ); + if (noPositions < 0) + noPositions = 0; + + if ( (m_xScrollPosition + nScrollInc) < 0 ) + nScrollInc = -m_xScrollPosition; // As -ve as we can go + else if ( (m_xScrollPosition + nScrollInc) > noPositions ) + nScrollInc = noPositions - m_xScrollPosition; // As +ve as we can go + } + else + Refresh(); } else { - int w, h; - GetClientSize(&w, &h); - - int nMaxHeight = m_yScrollLines*m_yScrollPixelsPerLine; - int noPositions = (int) ( ((nMaxHeight - h)/(float)m_yScrollPixelsPerLine) + 0.5 ); - if (noPositions < 0) - noPositions = 0; - - if ( (m_yScrollPosition + nScrollInc) < 0 ) - nScrollInc = -m_yScrollPosition; // As -ve as we can go - else if ( (m_yScrollPosition + nScrollInc) > noPositions ) - nScrollInc = noPositions - m_yScrollPosition; // As +ve as we can go - - return nScrollInc; + if (m_yScrollPixelsPerLine > 0) { + int w, h; + GetClientSize(&w, &h); + + int nMaxHeight = m_yScrollLines*m_yScrollPixelsPerLine; + int noPositions = (int) ( ((nMaxHeight - h)/(float)m_yScrollPixelsPerLine) + 0.5 ); + if (noPositions < 0) + noPositions = 0; + + if ( (m_yScrollPosition + nScrollInc) < 0 ) + nScrollInc = -m_yScrollPosition; // As -ve as we can go + else if ( (m_yScrollPosition + nScrollInc) > noPositions ) + nScrollInc = noPositions - m_yScrollPosition; // As +ve as we can go + } + else + Refresh(); } + + return nScrollInc; } // Adjust the scrollbars - new version. @@ -329,7 +339,7 @@ void wxScrolledWindow::AdjustScrollbars(void) // Default OnSize resets scrollbars, if any void wxScrolledWindow::OnSize(wxSizeEvent& WXUNUSED(event)) { -#if USE_CONSTRAINTS +#if wxUSE_CONSTRAINTS if (GetAutoLayout()) Layout(); #endif @@ -352,6 +362,7 @@ void wxScrolledWindow::OnPaint(wxPaintEvent& WXUNUSED(event)) void wxScrolledWindow::PrepareDC(wxDC& dc) { dc.SetDeviceOrigin(- m_xScrollPosition * m_xScrollPixelsPerLine, - m_yScrollPosition * m_yScrollPixelsPerLine); + dc.SetUserScale(m_scaleX, m_scaleY); } #if WXWIN_COMPATIBILITY