Ejemplo n.º 1
0
void TScrollBar::SetValue(int32 value)
{
	if (value < fMinimum)
		value = fMinimum;
	else if (value > fMaximum)
		value = fMaximum;

	if (value != fValue)
	{
		TRect	oldThumb;
		GetThumb(oldThumb);
		
		fValue = value;

		HandleCommand(this, this, kValueChangedCommandID);

		TRect	newThumb;
		GetThumb(newThumb);

		if (newThumb != oldThumb)
		{
			TDrawContext	context(this);
			TRect			rect;

			if (newThumb.left < oldThumb.left)
				rect.Set(newThumb.right, newThumb.top, oldThumb.right, newThumb.bottom);
			else if (newThumb.left > oldThumb.left)
				rect.Set(oldThumb.left, newThumb.top, newThumb.left, newThumb.bottom);

			if (newThumb.top < oldThumb.top)
				rect.Set(newThumb.left, newThumb.bottom, newThumb.right, oldThumb.bottom);
			else if (newThumb.top > oldThumb.top)
				rect.Set(newThumb.left, oldThumb.top, newThumb.right, newThumb.top);


			if (context.GetDepth() < 8)
			{
				context.SetStipple(TGraphicsUtils::GetGrayStipple());
				context.SetForeColor(kBlackColor);
				context.SetBackColor(kWhiteColor);
			}
			else
				context.SetForeColor(kMediumGrayColor);
			
			context.PaintRect(rect);
			DrawThumb(context);
		}
	}
}
Ejemplo n.º 2
0
ScrollBarPart TScrollBar::IdentifyPoint(const TPoint& point, TRect& outTrackingRect) const
{
	GetArrow1(outTrackingRect);
	if (outTrackingRect.Contains(point))
		return kArrow1;
	
	GetArrow2(outTrackingRect);
	if (outTrackingRect.Contains(point))
		return kArrow2;

	TRect thumb;
	GetThumb(thumb);
	if (thumb.Contains(point))
	{
		outTrackingRect = thumb;
		return kThumb;
	}

	TRect thumbArea;
	GetThumbArea(thumbArea);
	if (! thumbArea.Contains(point))
		return kNone;

	if (IsVertical())
	{
		outTrackingRect.Set(thumbArea.left, thumbArea.top, thumbArea.right, thumb.top);
		if (outTrackingRect.Contains(point))
			return kPageUp;
		else
		{
			outTrackingRect.top = thumb.bottom;
			outTrackingRect.bottom = thumbArea.bottom;
			return kPageDown;
		}
	}
	else
	{
		outTrackingRect.Set(thumbArea.left, thumbArea.top, thumb.left, thumbArea.bottom);
		if (outTrackingRect.Contains(point))
			return kPageUp;
		else
		{
			outTrackingRect.left = thumb.right;
			outTrackingRect.right = thumbArea.right;
			return kPageDown;
		}
	}
}