Example #1
0
void CLibraryTileView::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* /*pScrollBar*/)
{
	CRect rc;
	GetClientRect( &rc );

	SetFocus();

	switch ( nSBCode )
	{
	case SB_BOTTOM:
		ScrollTo( 0xFFFFFF );
		break;
	case SB_LINEDOWN:
		ScrollBy( 32 );
		break;
	case SB_LINEUP:
		ScrollBy( -32 );
		break;
	case SB_PAGEDOWN:
		ScrollBy( rc.Height() );
		break;
	case SB_PAGEUP:
		ScrollBy( -rc.Height() );
		break;
	case SB_THUMBPOSITION:
	case SB_THUMBTRACK:
		ScrollTo( nPos );
		break;
	case SB_TOP:
		ScrollTo( 0 );
		break;
	}
}
BOOL CLibraryAlbumView::Select(DWORD nObject)
{
	CRect rcClient, rcItem;

	CLibraryAlbumTrack** pList = m_pList + m_nCount - 1;

	int nItem = m_nCount;
	for ( ; nItem ; nItem--, pList-- )
	{
		CLibraryAlbumTrack* pTrack = *pList;
		if ( pTrack->m_nIndex == nObject ) break;
	}

	if ( nItem == 0 ) return FALSE;

	m_pFocus = *pList;
	DeselectAll( m_pFocus );
	Select( m_pFocus );
	Invalidate();

	GetClientRect( &rcClient );
	GetItemRect( m_pFocus, &rcItem );

	if ( rcItem.top < rcClient.top )
		ScrollBy( rcItem.top - rcClient.top );
	else if ( rcItem.bottom > rcClient.bottom )
		ScrollBy( rcItem.bottom - rcClient.bottom );

	return TRUE;
}
void CBrowseTreeCtrl::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
	switch ( nSBCode )
	{
	case SB_BOTTOM:
		ScrollTo( 0xFFFFFFFF );
		break;
	case SB_LINEDOWN:
		ScrollBy( 1 );
		break;
	case SB_LINEUP:
		ScrollBy( -1 );
		break;
	case SB_PAGEDOWN:
		ScrollBy( m_nVisible );
		break;
	case SB_PAGEUP:
		ScrollBy( -m_nVisible );
		break;
	case SB_THUMBPOSITION:
	case SB_THUMBTRACK:
		ScrollTo( nPos );
		break;
	case SB_TOP:
		ScrollTo( 0 );
		break;
	}
}
Example #4
0
int ScrolledListView::TrackInsertionStep(BPoint point, int prevInsertionIndex)
{
	BRect bounds = Bounds();
	float itemHeight = ItemHeight();
	int32 numItems = NumItems();

	// autoscroll
	if (point.y < bounds.top) {
		if (bounds.top > 0) {
			ScrollBy(0, -itemHeight);
			bounds.OffsetBy(0, -itemHeight);
			}
		point.y = bounds.top;
		}
	else if (point.y > bounds.bottom) {
		if (bounds.bottom < numItems * itemHeight - 1) {
			ScrollBy(0, itemHeight);
			bounds.OffsetBy(0, itemHeight);
			}
		point.y = bounds.bottom + 1;	// need the +1 to let it get beyond the last item
		}

	// figure out where it is now
	int32 curInsertionIndex = (int) (point.y / itemHeight);
	if (curInsertionIndex < 0)
		curInsertionIndex = 0;
	else if (curInsertionIndex > numItems)	// can move beyond the last item
		curInsertionIndex = numItems;

	// draw
	if (curInsertionIndex != prevInsertionIndex) {
		// redraw items bordering old indicator, to clear it
		if (prevInsertionIndex >= 0) {
			if (prevInsertionIndex > 0)
				DrawItemAt(prevInsertionIndex - 1);
			if (prevInsertionIndex < numItems)
				DrawItemAt(prevInsertionIndex);
			else {
				// need to clean up bottom
				BRect bottomRect = bounds;
				bottomRect.top = prevInsertionIndex * itemHeight;
				FillRect(bottomRect, B_SOLID_LOW);
				}
			}

		// draw new indicator
		SetHighColor(insertionIndicatorColor);
		SetPenSize(2.0);
		float indicatorY = curInsertionIndex * itemHeight;
		StrokeLine(BPoint(bounds.left, indicatorY),
		           BPoint(bounds.right, indicatorY));
		SetPenSize(1.0);
		}

	Flush();

	return curInsertionIndex;
}
Example #5
0
void CLibraryTileView::Highlight(iterator pItem)
{
	CRect rcClient, rcItem;

	GetClientRect( &rcClient );
	GetItemRect( pItem, &rcItem );

	if ( rcItem.top < rcClient.top )
		ScrollBy( rcItem.top - rcClient.top );
	else if ( rcItem.bottom > rcClient.bottom )
		ScrollBy( rcItem.bottom - rcClient.bottom );
}
Example #6
0
	void CDXUIScrollBar::Update(float fDelta)
	{
		static float fTime = 0.0f;

		switch (m_ScrollStatus)
		{
		case DX_UISCROLLBAR_SCROLL_FOREWARD:
			fTime += fDelta;
			if (fTime >= DX_UISCROLLBAR_SCROLL_DELAY)
			{
				ScrollBy(1);
				m_ScrollStatus = DX_UISCROLLBAR_SCROLL_REPEAT_FOREWARD;
				fTime = 0;
			}
			break;

		case DX_UISCROLLBAR_SCROLL_BACKWARD:
			fTime += fDelta;
			if (fTime >= DX_UISCROLLBAR_SCROLL_DELAY)
			{
				ScrollBy(-1);
				m_ScrollStatus = DX_UISCROLLBAR_SCROLL_REPEAT_BACKWARD;
				fTime = 0;
			}
			break;

		case DX_UISCROLLBAR_SCROLL_REPEAT_FOREWARD:
			fTime += fDelta;
			if (fTime >= DX_UISCROLLBAR_SCROLL_REPEAT_DELAY)
			{
				ScrollBy(1);
				fTime = 0;
			}
			break;

		case DX_UISCROLLBAR_SCROLL_REPEAT_BACKWARD:
			fTime += fDelta;
			if (fTime >= DX_UISCROLLBAR_SCROLL_REPEAT_DELAY)
			{
				ScrollBy(-1);
				fTime = 0;
			}
			break;

		default:
			fTime = 0;
		}
	}
bool AsyncPanZoomController::DoFling(const TimeDuration& aDelta) {
  if (mState != FLING) {
    return false;
  }

  bool shouldContinueFlingX = mX.FlingApplyFrictionOrCancel(aDelta),
       shouldContinueFlingY = mY.FlingApplyFrictionOrCancel(aDelta);
  // If we shouldn't continue the fling, let's just stop and repaint.
  if (!shouldContinueFlingX && !shouldContinueFlingY) {
    RequestContentRepaint();
    mState = NOTHING;
    return false;
  }

  // We want to inversely scale it because when you're zoomed further in, a
  // larger swipe should move you a shorter distance.
  float inverseScale = 1 / mFrameMetrics.mResolution.width;

  ScrollBy(nsIntPoint(
    mX.GetDisplacementForDuration(inverseScale, aDelta),
    mY.GetDisplacementForDuration(inverseScale, aDelta)
  ));
  RequestContentRepaint();

  return true;
}
void AsyncPanZoomController::TrackTouch(const MultiTouchInput& aEvent) {
  TimeDuration timeDelta = TimeDuration().FromMilliseconds(aEvent.mTime - mLastEventTime);

  // Probably a duplicate event, just throw it away.
  if (timeDelta.ToMilliseconds() <= EPSILON) {
    return;
  }

  UpdateWithTouchAtDevicePoint(aEvent);

  {
    MonitorAutoLock monitor(mMonitor);

    // We want to inversely scale it because when you're zoomed further in, a
    // larger swipe should move you a shorter distance.
    float inverseScale = 1 / mFrameMetrics.mResolution.width;

    PRInt32 xDisplacement = mX.GetDisplacementForDuration(inverseScale, timeDelta);
    PRInt32 yDisplacement = mY.GetDisplacementForDuration(inverseScale, timeDelta);
    if (!xDisplacement && !yDisplacement) {
      return;
    }

    ScrollBy(nsIntPoint(xDisplacement, yDisplacement));
    ScheduleComposite();

    if (aEvent.mTime - mLastRepaint >= PAN_REPAINT_INTERVAL) {
      RequestContentRepaint();
      mLastRepaint = aEvent.mTime;
    }
  }
}
Example #9
0
void
BListView::_FixupScrollBar()
{
	BScrollBar* vertScroller = ScrollBar(B_VERTICAL);
	if (!vertScroller)
		return;

	BRect bounds = Bounds();
	int32 count = CountItems();

	float itemHeight = 0.0;

	if (CountItems() > 0)
		itemHeight = ItemAt(CountItems() - 1)->Bottom();

	if (bounds.Height() > itemHeight) {
		// no scrolling
		vertScroller->SetRange(0.0, 0.0);
		vertScroller->SetValue(0.0);
			// also scrolls ListView to the top
	} else {
		vertScroller->SetRange(0.0, itemHeight - bounds.Height() - 1.0);
		vertScroller->SetProportion(bounds.Height () / itemHeight);
		// scroll up if there is empty room on bottom
		if (itemHeight < bounds.bottom)
			ScrollBy(0.0, bounds.bottom - itemHeight);
	}

	if (count != 0)
		vertScroller->SetSteps(ceilf(FirstItem()->Height()), bounds.Height());
}
Example #10
0
/////////////////////////////////////////////////////////////////////
// TEditScroller::AutoScroll
// -------------------------
//
// This function is a copy of the original OWL function, but the
// auto-scrolling is done when the mouse is wihtin the client
// rect (less than 5 pixels from border).
//
// Original OWL comment:
// performs "auto-scrolling" (dragging the mouse from within the client
// client area of the Window to without results in auto-scrolling when
// the AutoMode data member of the Scroller is TRUE)
//
void TEditScroller::AutoScroll()
{
	// If ScrollLock enabled, don't do anything
	if (::GetKeyState(VK_SCROLL) & 0x0001)
		return;

	if (AutoMode && Window && ::AutoScroll)
	{
		TRect  clientRect;
		TPoint cursorPos;
		long  dx = 0, dy = 0;

		GetCursorPos(&cursorPos);
		Window->ScreenToClient(cursorPos);
		Window->GetClientRect(clientRect);

		if (cursorPos.y < 5)
			dy = min(-YLine, max(-YPage, -abs(cursorPos.y) / 10 * YLine));

		else if (cursorPos.y > clientRect.bottom - 5)
			dy = max(YLine, min(YPage, (-abs(cursorPos.y)-clientRect.bottom)/10 * YLine));

		if (cursorPos.x < 5)
			dx = min(-XLine, max(-XPage, -abs(cursorPos.x) / 10 * XLine));

		else if (cursorPos.x > clientRect.right - 5)
			dx = max(XLine, min(XPage, (-abs(cursorPos.x)-clientRect.right)/10 * XLine));

		ScrollBy(dx, dy);
	}
}
Example #11
0
void
TSigTextView::KeyDown(const char *key, int32 count)
{
	bool	up = false;
	int32	height;
	BRect	r;

	switch (key[0]) {
		case B_HOME:
			Select(0, 0);
			ScrollToSelection();
			break;

		case B_END:
			Select(TextLength(), TextLength());
			ScrollToSelection();
			break;

		case B_PAGE_UP:
			up = true;
		case B_PAGE_DOWN:
			r = Bounds();
			height = (int32)((up ? r.top - r.bottom : r.bottom - r.top) - 25);
			if ((up) && (!r.top))
				break;
			ScrollBy(0, height);
			break;

		default:
			BTextView::KeyDown(key, count);
	}
}
Example #12
0
//
/// Performs "auto-scrolling" (dragging the mouse from within the client
/// client area of the Window to without results in auto-scrolling when
/// the AutoMode data member of the Scroller is true)
///
/// Scrolls the owner window's display in response to the mouse being dragged from
/// inside to outside the window. The direction and the amount by which the display
/// is scrolled depend on the current position of the mouse.
//
void
TScroller::AutoScroll()
{
    PRECONDITION(Window);
    PRECONDITION(Window->GetHandle());

    if (AutoMode && Window) {
        TRect  clientRect;
        TPoint cursorPos;
        long  dx = 0, dy = 0;

        GetCursorPos(&cursorPos);
        Window->ScreenToClient(cursorPos);
        Window->GetClientRect(clientRect);

        if (cursorPos.y < 0)
            dy = std::min((long)-YLine, std::max((long)-YPage, long(cursorPos.y / 10 * YLine)));

        else if (cursorPos.y > clientRect.bottom)
            dy = std::max((long)YLine, std::min((long)YPage, long((cursorPos.y-clientRect.bottom)/10 * YLine)));

        if (cursorPos.x < 0)
            dx = std::min((long)-XLine, std::max((long)-XPage, long(cursorPos.x / 10 * XLine)));

        else if (cursorPos.x > clientRect.right)
            dx = std::max((long)XLine, std::min((long)XPage, (cursorPos.x-clientRect.right)/10 * XLine));

        ScrollBy(dx, dy);
    }
}
Example #13
0
int Scroller::OnEvent(Event* e)
{
	TouchData* t = (TouchData*)e->Data;
	switch (e->Type)
	{
		case Event::TouchDown:
			_dragy = t->y;	// Drag in progress
			break;

		case Event::TouchMove:
			if (_dragy != -1 && _dragy != (short)t->y)
			{
				int delta = -_dragy + t->y;
				if (delta >= -2 && delta <= 2)
					break;
				ScrollBy(delta);        // Also velocity
				_dragy = t->y;
				_velocity = delta << 4; // 12:4 fixed point
			}
			break;

		case Event::TouchUp:
			_dragy = -1;
			break;

		case Event::None:
			AutoScroll();
			break;

		default:;
	}
	return 0;
}
Example #14
0
void AsyncPanZoomController::TrackTouch(const MultiTouchEvent& event) {
  SingleTouchData& touch = GetTouchFromEvent(event);
  nsIntPoint point = touch.mScreenPoint;
  PRInt32 xPos = point.x, yPos = point.y, timeDelta = event.mTime - mLastEventTime;

  // Probably a duplicate event, just throw it away.
  if (!timeDelta) {
    return;
  }

  {
    ReentrantMonitorAutoEnter monitor(mReentrantMonitor);
    mX.UpdateWithTouchAtDevicePoint(xPos, timeDelta);
    mY.UpdateWithTouchAtDevicePoint(yPos, timeDelta);

    float scale = mFrameMetrics.mResolution.width;

    PRInt32 xDisplacement = mX.UpdateAndGetDisplacement(scale);
    PRInt32 yDisplacement = mY.UpdateAndGetDisplacement(scale);
    if (!xDisplacement && !yDisplacement) {
      return;
    }

    ScrollBy(nsIntPoint(xDisplacement, yDisplacement));
    ForceRepaint();

    if (event.mTime - mLastRepaint >= REPAINT_INTERVAL) {
      SendViewportChange();
      mLastRepaint = event.mTime;
    }
  }
}
BOOL CLibraryAlbumView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
	if ( CLibraryView::OnMouseWheel( nFlags, zDelta, pt ) )
		return TRUE;

	ScrollBy( zDelta * -m_szTrack.cy / WHEEL_DELTA * 5 );
	return TRUE;
}
Example #16
0
BOOL CLibraryTileView::OnMouseWheel(UINT nFlags, short zDelta, CPoint pt)
{
	if ( CLibraryView::OnMouseWheel( nFlags, zDelta, pt ) )
		return TRUE;

	ScrollBy( zDelta * -m_szBlock.cy / WHEEL_DELTA / 2 );
	return TRUE;
}
Example #17
0
// page up action
void 
BF_GUI_Text::Nav_PageUp()
{
	BRect	oRect = Bounds();
	
	if (oRect.top <= 0) return;

	if (2 * oRect.top - oRect.bottom > 0)
	{
		ScrollBy(0,-oRect.Height());
	}
	else
	{
		ScrollBy(0,-oRect.top);
	};
	ClearMatch();
}
Example #18
0
// Line down action
void 
BF_GUI_Text::Nav_LineDown()
{
	if (bFullPage)
	{
		ScrollBy(0,20);
		ClearMatch();
	};		
};
Example #19
0
void AudioDisplay::OnScrollTimer(wxTimerEvent &event)
{
	if (!audio_marker) return;

	int rel_x = RelativeXFromTime(audio_marker->GetPosition());
	int width = GetClientSize().GetWidth();

	// If the dragged object is outside the visible area, scroll it into
	// view with a 5% margin
	if (rel_x < 0)
	{
		ScrollBy(rel_x - width / 20);
	}
	else if (rel_x >= width)
	{
		ScrollBy(rel_x - width + width / 20);
	}
}
	void ScrollWindow::MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam)
	{
		// process wheel: Scroll
		if (iButton == C4MC_Button_Wheel)
		{
			short iDelta = (short)(dwKeyParam >> 16);
			ScrollBy(-iDelta);
			return;
		}
Example #21
0
// MouseMoved
void
TestView::MouseMoved(BPoint where, uint32 transit,
					 const BMessage* dragMessage)
{
	if (fTracking) {
		BPoint offset = fLastMousePos - where;
		ScrollBy(offset.x, offset.y);
		fLastMousePos = where + offset;
	}
}
Example #22
0
//
/// Responds to the specified horizontal scrollEvent by calling ScrollBy or ScrollTo.
/// The type of scroll event is identified by the corresponding SB_ constants.
/// The 16-bit thumbPos argument is ignored. The function retrieves the 32-bit value
/// directly from the scroll bar instead.
//
void
TScroller::HScroll(uint scrollEvent, int)
{
    switch (scrollEvent) {
    case SB_LINEDOWN:
        ScrollBy(XLine, 0);
        break;

    case SB_LINEUP:
        ScrollBy(-XLine, 0);
        break;

    case SB_PAGEDOWN:
        ScrollBy(XPage, 0);
        break;

    case SB_PAGEUP:
        ScrollBy(-XPage, 0);
        break;

    case SB_TOP:
        ScrollTo(0, YPos);
        break;

    case SB_BOTTOM:
        ScrollTo(XRange, YPos);
        break;

    case SB_THUMBPOSITION:
        ScrollTo(GetScrollTrackPos(SB_HORZ), YPos);
        break;

    case SB_THUMBTRACK:
    {
        int thumbPos32 = GetScrollTrackPos(SB_HORZ);
        if (TrackMode)
            ScrollTo(thumbPos32, YPos);
        if (Window && HasHScrollBar)
            SetScrollPos(SB_HORZ, thumbPos32, true);
        break;
    }
    }
}
Example #23
0
//
/// Responds to the specified vertical scrollEvent by calling ScrollBy or ScrollTo.
/// The type of scroll event is identified by the corresponding SB_ constants.
/// The 16-bit thumbPos argument is ignored. The function retrieves the 32-bit value
/// directly from the scroll bar instead.
//
void
TScroller::VScroll(uint scrollEvent, int)
{
    switch (scrollEvent) {
    case SB_LINEDOWN:
        ScrollBy(0, YLine);
        break;

    case SB_LINEUP:
        ScrollBy(0, -YLine);
        break;

    case SB_PAGEDOWN:
        ScrollBy(0, YPage);
        break;

    case SB_PAGEUP:
        ScrollBy(0, -YPage);
        break;

    case SB_TOP:
        ScrollTo(XPos, 0);
        break;

    case SB_BOTTOM:
        ScrollTo(XPos, YRange);
        break;

    case SB_THUMBPOSITION:
        ScrollTo(XPos, GetScrollTrackPos(SB_VERT));
        break;

    case SB_THUMBTRACK:
    {
        int thumbPos32 = GetScrollTrackPos(SB_VERT);
        if (TrackMode)
            ScrollTo(XPos, thumbPos32);
        if (Window && HasVScrollBar)
            SetScrollPos(SB_VERT, thumbPos32, true);
        break;
    }
    }
}
Example #24
0
// Line up action
void 
BF_GUI_Text::Nav_LineUp()
{
	BRect oRect = Bounds();
	
	if (oRect.top > 0)
	{
		ScrollBy(0,(oRect.top > 20) ? -20 : -oRect.top);
		ClearMatch();
	};		
};
Example #25
0
EActiveTimerReturnType STableViewBase::UpdateInertialScroll(double InCurrentTime, float InDeltaTime)
{
	bool bKeepTicking = false;
	if (ItemsPanel.IsValid())
	{
		if (IsRightClickScrolling())
		{
			bKeepTicking = true;

			// We sample for the inertial scroll on tick rather than on mouse/touch move so
			// that we still get samples even if the mouse has not moved.
			if (CanUseInertialScroll(TickScrollDelta))
			{
				InertialScrollManager.AddScrollSample(TickScrollDelta, InCurrentTime);
			}
		}
		else
		{
			InertialScrollManager.UpdateScrollVelocity(InDeltaTime);
			const float ScrollVelocity = InertialScrollManager.GetScrollVelocity();

			if (ScrollVelocity != 0.f)
			{
				if (CanUseInertialScroll(ScrollVelocity))
				{
					bKeepTicking = true;
					ScrollBy(CachedGeometry, ScrollVelocity * InDeltaTime, AllowOverscroll);
				}
				else
				{
					InertialScrollManager.ClearScrollVelocity();
				}
			}

			if (AllowOverscroll == EAllowOverscroll::Yes)
			{
				// If we are currently in overscroll, the list will need refreshing.
				// Do this before UpdateOverscroll, as that could cause GetOverscroll() to be 0
				if (Overscroll.GetOverscroll() != 0.0f)
				{
					bKeepTicking = true;
					RequestListRefresh();
				}

				Overscroll.UpdateOverscroll(InDeltaTime);
			}
		}

		TickScrollDelta = 0.f;
	}

	bIsScrollingActiveTimerRegistered = bKeepTicking;
	return bKeepTicking ? EActiveTimerReturnType::Continue : EActiveTimerReturnType::Stop;
}
Example #26
0
// Key left action
void 
BF_GUI_Text::Nav_LineLeft()
{
	BRect oRect = Bounds();
	
	if (oRect.left > 0)
	{
		ScrollBy(-10,0);
		ClearMatch();
	};
};
Example #27
0
void StringBrowser::GrabScroll (Event& e) {
    int y = e.y;
    Cursor* origCursor = GetCursor();
    SetCursor(handCursor);

    do {
        ScrollBy(0, y - e.y);
        y = e.y;
        Poll(e);
    } while (e.middlemouse);

    SetCursor(origCursor);
}
BOOL CBrowseTreeCtrl::Highlight(CBrowseTreeItem* pItem)
{
	CSingleLock lRoot( &m_csRoot, TRUE );

	m_pFocus = pItem;

	for ( CBrowseTreeItem* pParent = m_pFocus->m_pParent ; pParent ; pParent = pParent->m_pParent )
	{
		Expand( pParent, TS_TRUE, FALSE );

		pParent->m_bContract2 = pParent->m_bContract1;
		pParent->m_bContract1 = FALSE;
	}

	CollapseRecursive( m_pRoot );

	for ( CBrowseTreeItem* pParent = m_pFocus->m_pParent ; pParent ; pParent = pParent->m_pParent )
	{
		pParent->m_bContract1 = pParent->m_bContract2;
	}

	CRect rcItem, rcClient;

	if ( GetRect( m_pFocus, &rcItem ) )
	{
		GetClientRect( &rcClient );

		if ( rcItem.top <= rcClient.top )
			ScrollBy( rcItem.top - rcClient.top );
		else if ( rcItem.bottom > rcClient.bottom )
			ScrollBy( rcItem.bottom - rcClient.bottom );
	}

	UpdateScroll();
	Invalidate();

	return TRUE;
}
void CLibraryAlbumView::OnVScroll(UINT nSBCode, UINT /*nPos*/, CScrollBar* /*pScrollBar*/)
{
	CRect rc;
	GetClientRect( &rc );

	SetFocus();

	switch ( nSBCode )
	{
	case SB_BOTTOM:
		ScrollTo( 0xFFFFFF );
		break;
	case SB_LINEDOWN:
		ScrollBy( m_szTrack.cy );
		break;
	case SB_LINEUP:
		ScrollBy( -m_szTrack.cy );
		break;
	case SB_PAGEDOWN:
		ScrollBy( rc.Height() );
		break;
	case SB_PAGEUP:
		ScrollBy( -rc.Height() );
		break;
	case SB_THUMBPOSITION:
	case SB_THUMBTRACK:
		{
			SCROLLINFO pScroll = { sizeof( SCROLLINFO ), SIF_TRACKPOS };
			GetScrollInfo( SB_VERT, &pScroll );
			ScrollTo( pScroll.nTrackPos );
		}
		break;
	case SB_TOP:
		ScrollTo( 0 );
		break;
	}
}
Example #30
0
/*----------------------------------------------------------------------------------------------
	With no scroll bar, the only way this happens is when the user drags outside the window.
	We need to override because the superclass does nothing when there is no scroll bar.
----------------------------------------------------------------------------------------------*/
bool TssEdit::OnHScroll(int nSBCode, int nPos, HWND hwndSbar)
{
	// NB - DON'T use nPos; it has only a 16-bit range.
	int dxdPos = m_dxpScrollOffset; // Where the window thinks it is now.
	// ENHANCE JohnT: use actual resolution.
	int dxdLine = 30 * 96/72; // 30 points seems a useful size increment.

	switch (nSBCode)
	{
	case SB_LINELEFT:
		dxdPos -= dxdLine;
		break;
	case SB_LINERIGHT:
		dxdPos += dxdLine;
		break;
	default:
		dxdPos = 0;
		Assert(false); // others should not happen
		break;
	}
	// Try to stop it scrolling too far. This is unfortunately not easy to do. Try getting
	// the width of a selection of the whole thing and limit it to a bit more than that.
	IVwSelectionPtr qvwsel;
	CheckHr(m_qrootb->MakeSimpleSel(true, false, true, false, &qvwsel));
	HoldGraphics hg(this);
	Rect rdPrimary;
	Rect rdSecondary;
	ComBool fSplit;
	ComBool fEndBeforeAnchor;
	CheckHr(qvwsel->Location(hg.m_qvg, hg.m_rcSrcRoot, hg.m_rcDstRoot, &rdPrimary,
		&rdSecondary, &fSplit, &fEndBeforeAnchor));
	Rect rcClient;
	::GetClientRect(m_hwnd, &rcClient);
	int dxpMax = rdPrimary.Width() - rcClient.Width() + 20;
	if (dxdPos > dxpMax)
		dxdPos = dxpMax;

	// In this class we don't have to worry about a max.
	if (dxdPos < 0)
		dxdPos = 0;

	int dxdScrollBy = dxdPos - m_dxpScrollOffset;

	// Update the scroll position.
	m_dxpScrollOffset = dxdPos;

	ScrollBy(dxdScrollBy, 0);
	return true;
}