void OnScrollWinEvents(wxScrollWinEvent& e) { wxEventType scrollType(e.GetEventType()); bool horiz = e.GetOrientation() == wxHORIZONTAL; wxPoint pos(viewStart); if (scrollType == wxEVT_SCROLLWIN_THUMBTRACK || scrollType == wxEVT_SCROLLWIN_THUMBRELEASE) { if (horiz) pos.x = e.GetPosition(); else pos.y = e.GetPosition(); } else if (scrollType == wxEVT_SCROLLWIN_LINEDOWN) { if (horiz) pos.x += LINE_STEP; else pos.y += LINE_STEP; } else if (scrollType == wxEVT_SCROLLWIN_LINEUP) { if (horiz) pos.x -= LINE_STEP; else pos.y -= LINE_STEP; } else if (scrollType == wxEVT_SCROLLWIN_PAGEUP) { if (horiz) pos.x -= m_scrollView->visibleWidth() - PAGE_KEEP; else pos.y -= m_scrollView->visibleHeight() - PAGE_KEEP; } else if (scrollType == wxEVT_SCROLLWIN_PAGEDOWN) { if (horiz) pos.x += m_scrollView->visibleWidth() - PAGE_KEEP; else pos.y += m_scrollView->visibleHeight() - PAGE_KEEP; } else return e.Skip(); m_scrollView->setContentsPos(pos.x, pos.y); m_scrollView->update(); }
void OnScrollWinEvents(wxScrollWinEvent& e) { wxEventType scrollType(e.GetEventType()); bool horiz = e.GetOrientation() == wxHORIZONTAL; wxPoint pos(viewStart); if (scrollType == wxEVT_SCROLLWIN_THUMBTRACK || scrollType == wxEVT_SCROLLWIN_THUMBRELEASE) { if (horiz) pos.x = e.GetPosition(); else pos.y = e.GetPosition(); } else if (scrollType == wxEVT_SCROLLWIN_LINEDOWN) { if (horiz) pos.x += Scrollbar::pixelsPerLineStep(); else pos.y += Scrollbar::pixelsPerLineStep(); } else if (scrollType == wxEVT_SCROLLWIN_LINEUP) { if (horiz) pos.x -= Scrollbar::pixelsPerLineStep(); else pos.y -= Scrollbar::pixelsPerLineStep(); } else if (scrollType == wxEVT_SCROLLWIN_PAGEUP) { if (horiz) pos.x -= max<int>(m_scrollView->visibleWidth() * Scrollbar::minFractionToStepWhenPaging(), m_scrollView->visibleWidth() - Scrollbar::maxOverlapBetweenPages()); else pos.y -= max<int>(m_scrollView->visibleHeight() * Scrollbar::minFractionToStepWhenPaging(), m_scrollView->visibleHeight() - Scrollbar::maxOverlapBetweenPages()); } else if (scrollType == wxEVT_SCROLLWIN_PAGEDOWN) { if (horiz) pos.x += max<int>(m_scrollView->visibleWidth() * Scrollbar::minFractionToStepWhenPaging(), m_scrollView->visibleWidth() - Scrollbar::maxOverlapBetweenPages()); else pos.y += max<int>(m_scrollView->visibleHeight() * Scrollbar::minFractionToStepWhenPaging(), m_scrollView->visibleHeight() - Scrollbar::maxOverlapBetweenPages()); } else return e.Skip(); m_scrollView->setScrollPosition(IntPoint(pos.x, pos.y)); }