int wxScrolledWindow::CalcScrollInc(wxScrollWinEvent& event) { int pos = event.GetPosition(); int orient = event.GetOrientation(); int nScrollInc = 0; if (event.GetEventType() == wxEVT_SCROLLWIN_TOP) { if (orient == wxHORIZONTAL) nScrollInc = - m_xScrollPosition; else nScrollInc = - m_yScrollPosition; } else if (event.GetEventType() == wxEVT_SCROLLWIN_BOTTOM) { if (orient == wxHORIZONTAL) nScrollInc = GetVirtualSize().GetWidth() / m_xScrollPixelsPerLine - m_xScrollPosition; else nScrollInc = GetVirtualSize().GetHeight() / m_yScrollPixelsPerLine - m_yScrollPosition; } else if (event.GetEventType() == wxEVT_SCROLLWIN_LINEUP) { nScrollInc = -1; } else if (event.GetEventType() == wxEVT_SCROLLWIN_LINEDOWN) { nScrollInc = 1; } else if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEUP) { if (orient == wxHORIZONTAL) nScrollInc = -GetScrollPageSize(wxHORIZONTAL); else nScrollInc = -GetScrollPageSize(wxVERTICAL); } else if (event.GetEventType() == wxEVT_SCROLLWIN_PAGEDOWN) { if (orient == wxHORIZONTAL) nScrollInc = GetScrollPageSize(wxHORIZONTAL); else nScrollInc = GetScrollPageSize(wxVERTICAL); } else if ((event.GetEventType() == wxEVT_SCROLLWIN_THUMBTRACK) || (event.GetEventType() == wxEVT_SCROLLWIN_THUMBRELEASE)) { if (orient == wxHORIZONTAL) nScrollInc = pos - m_xScrollPosition; else nScrollInc = pos - m_yScrollPosition; } if (orient == wxHORIZONTAL) { if (m_xScrollPixelsPerLine > 0) { int max = (int)(m_hAdjust->upper - m_hAdjust->page_size + 0.5); if (max < 0) max = 0; if ( (m_xScrollPosition + nScrollInc) < 0 ) nScrollInc = -m_xScrollPosition; // As -ve as we can go else if ( (m_xScrollPosition + nScrollInc) > max ) nScrollInc = max - m_xScrollPosition; // As +ve as we can go } else m_targetWindow->Refresh(); } else { if (m_yScrollPixelsPerLine > 0) { int max = (int)(m_vAdjust->upper - m_vAdjust->page_size + 0.5); if (max < 0) max = 0; if ( (m_yScrollPosition + nScrollInc) < 0 ) nScrollInc = -m_yScrollPosition; // As -ve as we can go else if ( (m_yScrollPosition + nScrollInc) > max ) nScrollInc = max - m_yScrollPosition; // As +ve as we can go } else m_targetWindow->Refresh(); } return nScrollInc; }
void EDA_DRAW_PANEL::OnScroll( wxScrollWinEvent& event ) { int id = event.GetEventType(); int x, y; int ppux, ppuy; int csizeX, csizeY; int unitsX, unitsY; GetViewStart( &x, &y ); GetScrollPixelsPerUnit( &ppux, &ppuy ); GetClientSize( &csizeX, &csizeY ); GetVirtualSize( &unitsX, &unitsY ); int tmpX = x; int tmpY = y; csizeX /= ppux; csizeY /= ppuy; unitsX /= ppux; unitsY /= ppuy; int dir = event.GetOrientation(); // wxHORIZONTAL or wxVERTICAL // On windows and on wxWidgets >= 2.9.5 and < 3.1, // there is a bug in mousewheel event which always generates 2 scroll events // (should be the case only for the default mousewheel event) // with id = wxEVT_SCROLLWIN_LINEUP or wxEVT_SCROLLWIN_LINEDOWN // so we skip these events. // Note they are here just in case, because they are not actually used // in Kicad #if wxCHECK_VERSION( 3, 1, 0 ) || !wxCHECK_VERSION( 2, 9, 5 ) || ( !defined (__WINDOWS__) && !defined (__WXMAC__) ) int maxX = unitsX - csizeX; int maxY = unitsY - csizeY; if( id == wxEVT_SCROLLWIN_LINEUP ) { if( dir == wxHORIZONTAL ) { x -= m_scrollIncrementX; if( x < 0 ) x = 0; } else { y -= m_scrollIncrementY; if( y < 0 ) y = 0; } } else if( id == wxEVT_SCROLLWIN_LINEDOWN ) { if( dir == wxHORIZONTAL ) { x += m_scrollIncrementX; if( x > maxX ) x = maxX; } else { y += m_scrollIncrementY; if( y > maxY ) y = maxY; } } else #endif if( id == wxEVT_SCROLLWIN_THUMBTRACK ) { if( dir == wxHORIZONTAL ) x = event.GetPosition(); else y = event.GetPosition(); } else { event.Skip(); return; } wxLogTrace( kicadTraceCoords, wxT( "Setting scroll bars ppuX=%d, ppuY=%d, unitsX=%d, unitsY=%d, posX=%d, posY=%d" ), ppux, ppuy, unitsX, unitsY, x, y ); double scale = GetParent()->GetScreen()->GetScalingFactor(); wxPoint center = GetParent()->GetScrollCenterPosition(); center.x += KiROUND( (double) ( x - tmpX ) / scale ); center.y += KiROUND( (double) ( y - tmpY ) / scale ); GetParent()->SetScrollCenterPosition( center ); Scroll( x, y ); event.Skip(); }
// ============================================================================ // uwHexCtrl - Events // ============================================================================ void uwHexCtrl::OnScroll( wxScrollWinEvent& event ) { Refresh(); event.Skip(); }
void wxSplitterScrolledWindow::OnScroll(wxScrollWinEvent& event) { // Ensure that events being propagated back up the window hierarchy // don't cause an infinite loop static bool inOnScroll = FALSE; if (inOnScroll) { event.Skip(); return; } inOnScroll = TRUE; int orient = event.GetOrientation(); int nScrollInc = CalcScrollInc(event); if (nScrollInc == 0) { inOnScroll = FALSE; return; } if (orient == wxHORIZONTAL) { inOnScroll = FALSE; event.Skip(); return; #if 0 int newPos = m_xScrollPosition + nScrollInc; SetScrollPos(wxHORIZONTAL, newPos, TRUE ); #endif } else { int newPos = m_yScrollPosition + nScrollInc; SetScrollPos(wxVERTICAL, newPos, TRUE ); } if (orient == wxHORIZONTAL) { m_xScrollPosition += nScrollInc; } else { m_yScrollPosition += nScrollInc; } // Find targets in splitter window and send the event to them wxNode* node = GetChildren().First(); while (node) { wxWindow* child = (wxWindow*) node->Data(); if (child->IsKindOf(CLASSINFO(wxSplitterWindow))) { wxSplitterWindow* splitter = (wxSplitterWindow*) child; if (splitter->GetWindow1()) splitter->GetWindow1()->ProcessEvent(event); if (splitter->GetWindow2()) splitter->GetWindow2()->ProcessEvent(event); break; } node = node->Next(); } #ifdef __WXMAC__ m_targetWindow->MacUpdateImmediately() ; #endif inOnScroll = FALSE; }
void view::OnVScroll(wxScrollWinEvent & event) { this->m_drawing_view.set_y_scroll_ratio( -(event.GetPosition() - 50 )/100.0); }
void DataListCtrl::OnScroll(wxScrollWinEvent& event) { EndEdit(false); event.Skip(true); }
void wxListCtrlEx::OnScrollEvent(wxScrollWinEvent& event) { event.Skip(); OnPreEmitPostScrollEvent(); }