void wxScrolledWindow::OnScroll(wxScrollWinEvent& event) { int orient = event.GetOrientation(); int nScrollInc = CalcScrollInc(event); if (nScrollInc == 0) return; if (orient == wxHORIZONTAL) { int newPos = m_xScrollPosition + nScrollInc; SetScrollPos(wxHORIZONTAL, newPos, TRUE ); } else { int newPos = m_yScrollPosition + nScrollInc; SetScrollPos(wxVERTICAL, newPos, TRUE ); } if (orient == wxHORIZONTAL) { m_xScrollPosition += nScrollInc; } else { m_yScrollPosition += nScrollInc; } if (orient == wxHORIZONTAL) { if (m_xScrollingEnabled) m_targetWindow->ScrollWindow(-m_xScrollPixelsPerLine * nScrollInc, 0, (const wxRect *) NULL); else m_targetWindow->Refresh(); } else { if (m_yScrollingEnabled) m_targetWindow->ScrollWindow(0, -m_yScrollPixelsPerLine * nScrollInc, (const wxRect *) NULL); else m_targetWindow->Refresh(); } }
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; }