Esempio n. 1
0
void
BSlider::DrawFocusMark()
{
	if (!IsFocus())
		return;

	OffscreenView()->SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));

	BRect frame = ThumbFrame();

	if (fStyle == B_BLOCK_THUMB) {
		frame.left += 2.0f;
		frame.top += 2.0f;
		frame.right -= 3.0f;
		frame.bottom -= 3.0f;
		OffscreenView()->StrokeRect(frame);
	} else {
		if (fOrientation == B_HORIZONTAL) {
			OffscreenView()->StrokeLine(BPoint(frame.left, frame.bottom + 2.0f),
				BPoint(frame.right, frame.bottom + 2.0f));
		} else {
			OffscreenView()->StrokeLine(BPoint(frame.left - 2.0f, frame.top),
				BPoint(frame.left - 2.0f, frame.bottom));
		}
	}
}
Esempio n. 2
0
void APPosSlider::DrawThumb(void)
{
	BRect rect;
	BView *view;

	// Get the frame rectangle of the thumb
	// and the offscreen view
	rect = ThumbFrame();
	view = OffscreenView();

	// Draw the black shadow
	view->SetDrawingMode(B_OP_ALPHA);
	rgb_color c = BeDarkShadow;
	c.alpha = 128;
	view->SetHighColor(c);
	rect.top++;
	rect.left++;
	view->FillEllipse(rect);
	
	// Fill the inside of the thumb
	view->SetDrawingMode(B_OP_COPY);
	view->SetHighColor(BeButtonGrey);
	rect.OffsetBy(-1, -1);
	view->FillEllipse(rect);

	// Draw the dark grey edge
	view->SetHighColor(86, 86, 86, 255); // TODO : use an Haiku define to get that ?
	view->SetPenSize(1.2);
	view->StrokeEllipse(rect);


}
Esempio n. 3
0
void
BSlider::Draw(BRect updateRect)
{
	// clear out background
	BRegion background(updateRect);
	background.Exclude(BarFrame());
	bool drawBackground = true;
	if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) {
		// This view is embedded somewhere, most likely the Tracker Desktop
		// shelf.
		drawBackground = false;
	}

	// ToDo: the triangle thumb doesn't delete its background, so we still have
	// to do it Note, this also creates a different behaviour for subclasses,
	// depending on the thumb style - if possible this should be avoided.
	if (Style() == B_BLOCK_THUMB) {
		BRect thumbFrame = ThumbFrame();
		if (be_control_look != NULL) {
			// fill background where shadow will be...
			// TODO: Such drawint dependent behavior should be moved into
			// BControlLook of course.
			thumbFrame.right--;
			thumbFrame.bottom--;
		}
		background.Exclude(thumbFrame);
	}

#if USE_OFF_SCREEN_VIEW
	if (!fOffScreenBits)
		return;

	if (fOffScreenBits->Lock()) {
		fOffScreenView->SetViewColor(ViewColor());
		fOffScreenView->SetLowColor(LowColor());
#endif

		if (drawBackground && background.Frame().IsValid())
			OffscreenView()->FillRegion(&background, B_SOLID_LOW);

#if USE_OFF_SCREEN_VIEW
		fOffScreenView->Sync();
		fOffScreenBits->Unlock();
	}
#endif

	DrawSlider();
}
Esempio n. 4
0
void
BSlider::AttachedToWindow()
{
	ResizeToPreferred();

#if USE_OFF_SCREEN_VIEW
	BRect bounds(Bounds());

	if (!fOffScreenView) {
		fOffScreenView = new BView(bounds, "", B_FOLLOW_ALL, B_WILL_DRAW);

		BFont font;
		GetFont(&font);
		fOffScreenView->SetFont(&font);
	}

	if (!fOffScreenBits) {
		fOffScreenBits = new BBitmap(bounds, B_RGBA32, true, false);

		if (fOffScreenBits && fOffScreenView)
			fOffScreenBits->AddChild(fOffScreenView);

	} else if (fOffScreenView)
		fOffScreenBits->AddChild(fOffScreenView);
#endif // USE_OFF_SCREEN_VIEW

	BControl::AttachedToWindow();

	BView* view = OffscreenView();
	if (view && view->LockLooper()) {
		view->SetViewColor(B_TRANSPARENT_COLOR);
		view->SetLowColor(LowColor());
		view->UnlockLooper();
	}

	int32 value = Value();
	SetValue(value);
		// makes sure the value is within valid bounds
	_SetLocationForValue(Value());
		// makes sure the location is correct
	UpdateTextChanged();
}
Esempio n. 5
0
void APPosSlider::DrawFocusMark(void)
{
	BRect rect;
	BView *view;
	rgb_color color;

	if (IsFocus())
	{
		// Get the frame rectangle of the thumb
		// and the offscreen view
		rect = ThumbFrame();
		view = OffscreenView();

		// Get the color to use
		color = keyboard_navigation_color();
		view->SetHighColor(color);

		// Draw a circle inside the thumb
		rect.InsetBy(2.0f, 2.0f);
		view->StrokeEllipse(rect);
	}
}
Esempio n. 6
0
void
VolumeControl::DrawBar()
{
	BRect frame = BarFrame();
	BView* view = OffscreenView();

	if (be_control_look != NULL) {
		uint32 flags = be_control_look->Flags(this);
		rgb_color base = LowColor();
		rgb_color rightFillColor = (rgb_color){255, 109, 38, 255};
		rgb_color leftFillColor = (rgb_color){116, 224, 0, 255};

		int32 min, max;
		GetLimits(&min, &max);
		float position = (float)min / (min - max);

		be_control_look->DrawSliderBar(view, frame, frame, base, leftFillColor,
			rightFillColor, position, flags, Orientation());
		return;
	}

	BSlider::DrawBar();
}
Esempio n. 7
0
void
BSlider::DrawBar()
{
	BRect frame = BarFrame();
	BView *view = OffscreenView();

	if (be_control_look != NULL) {
		uint32 flags = be_control_look->Flags(this);
		rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
		rgb_color rightFillColor = fBarColor;
		rgb_color leftFillColor = fUseFillColor ? fFillColor : fBarColor;
		be_control_look->DrawSliderBar(view, frame, frame, base, leftFillColor,
			rightFillColor, Position(), flags, fOrientation);
		return;
	}

	rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color lightenmax;
	rgb_color darken1;
	rgb_color darken2;
	rgb_color darkenmax;

	rgb_color barColor;
	rgb_color fillColor;

	if (IsEnabled()) {
		lightenmax	= tint_color(no_tint, B_LIGHTEN_MAX_TINT);
		darken1		= tint_color(no_tint, B_DARKEN_1_TINT);
		darken2		= tint_color(no_tint, B_DARKEN_2_TINT);
		darkenmax	= tint_color(no_tint, B_DARKEN_MAX_TINT);
		barColor	= fBarColor;
		fillColor	= fFillColor;
	} else {
		lightenmax	= tint_color(no_tint, B_LIGHTEN_MAX_TINT);
		darken1		= no_tint;
		darken2		= tint_color(no_tint, B_DARKEN_1_TINT);
		darkenmax	= tint_color(no_tint, B_DARKEN_3_TINT);

		barColor.red	= (fBarColor.red + no_tint.red) / 2;
		barColor.green	= (fBarColor.green + no_tint.green) / 2;
		barColor.blue	= (fBarColor.blue + no_tint.blue) / 2;
		barColor.alpha	= 255;

		fillColor.red	= (fFillColor.red + no_tint.red) / 2;
		fillColor.green	= (fFillColor.green + no_tint.green) / 2;
		fillColor.blue	= (fFillColor.blue + no_tint.blue) / 2;
		fillColor.alpha	= 255;
	}

	// exclude the block thumb from the bar filling

	BRect lowerFrame = frame.InsetByCopy(1, 1);
	lowerFrame.top++;
	lowerFrame.left++;
	BRect upperFrame = lowerFrame;
	BRect thumbFrame;

	if (Style() == B_BLOCK_THUMB) {
		thumbFrame = ThumbFrame();

		if (fOrientation == B_HORIZONTAL) {
			lowerFrame.right = thumbFrame.left;
			upperFrame.left = thumbFrame.right;
		} else {
			lowerFrame.top = thumbFrame.bottom;
			upperFrame.bottom = thumbFrame.top;
		}
	} else if (fUseFillColor) {
		if (fOrientation == B_HORIZONTAL) {
			lowerFrame.right = floor(lowerFrame.left - 1 + Position()
				* (lowerFrame.Width() + 1));
			upperFrame.left = lowerFrame.right;
		} else {
			lowerFrame.top = floor(lowerFrame.bottom + 1 - Position()
				* (lowerFrame.Height() + 1));
			upperFrame.bottom = lowerFrame.top;
		}
	}

	view->SetHighColor(barColor);
	view->FillRect(upperFrame);

	if (Style() == B_BLOCK_THUMB || fUseFillColor) {
		if (fUseFillColor)
			view->SetHighColor(fillColor);
		view->FillRect(lowerFrame);
	}

	if (Style() == B_BLOCK_THUMB) {
		// We don't want to stroke the lines over the thumb

		PushState();

		BRegion region;
		GetClippingRegion(&region);
		region.Exclude(thumbFrame);
		ConstrainClippingRegion(&region);
	}

	view->SetHighColor(darken1);
	view->StrokeLine(BPoint(frame.left, frame.top),
					 BPoint(frame.left + 1.0f, frame.top));
	view->StrokeLine(BPoint(frame.left, frame.bottom),
					 BPoint(frame.left + 1.0f, frame.bottom));
	view->StrokeLine(BPoint(frame.right - 1.0f, frame.top),
					 BPoint(frame.right, frame.top));

	view->SetHighColor(darken2);
	view->StrokeLine(BPoint(frame.left + 1.0f, frame.top),
					 BPoint(frame.right - 1.0f, frame.top));
	view->StrokeLine(BPoint(frame.left, frame.bottom - 1.0f),
					 BPoint(frame.left, frame.top + 1.0f));

	view->SetHighColor(lightenmax);
	view->StrokeLine(BPoint(frame.left + 1.0f, frame.bottom),
					 BPoint(frame.right, frame.bottom));
	view->StrokeLine(BPoint(frame.right, frame.bottom - 1.0f),
					 BPoint(frame.right, frame.top + 1.0f));

	frame.InsetBy(1.0f, 1.0f);

	view->SetHighColor(darkenmax);
	view->StrokeLine(BPoint(frame.left, frame.bottom),
					 BPoint(frame.left, frame.top));
	view->StrokeLine(BPoint(frame.left + 1.0f, frame.top),
					 BPoint(frame.right, frame.top));

	if (Style() == B_BLOCK_THUMB)
		PopState();
}
Esempio n. 8
0
void
BSlider::_DrawTriangleThumb()
{
	BRect frame = ThumbFrame();
	BView *view = OffscreenView();

	if (be_control_look != NULL) {
		rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
		uint32 flags = be_control_look->Flags(this);
		be_control_look->DrawSliderTriangle(view, frame, frame, base, flags,
			fOrientation);
		return;
	}

	rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color lightenmax;
	rgb_color lighten1;
	rgb_color darken2;
	rgb_color darken3;
	rgb_color darkenmax;

	if (IsEnabled()) {
		lightenmax	= tint_color(no_tint, B_LIGHTEN_MAX_TINT);
		lighten1	= no_tint;
		darken2		= tint_color(no_tint, B_DARKEN_2_TINT);
		darken3		= tint_color(no_tint, B_DARKEN_3_TINT);
		darkenmax	= tint_color(no_tint, B_DARKEN_MAX_TINT);
	} else {
		lightenmax	= tint_color(no_tint, B_LIGHTEN_2_TINT);
		lighten1	= tint_color(no_tint, B_LIGHTEN_1_TINT);
		darken2		= tint_color(no_tint, (B_NO_TINT + B_DARKEN_1_TINT) / 2);
		darken3		= tint_color(no_tint, B_DARKEN_1_TINT);
		darkenmax	= tint_color(no_tint, B_DARKEN_3_TINT);
	}

	if (Orientation() == B_HORIZONTAL) {
		view->SetHighColor(lighten1);
		view->FillTriangle(
			BPoint(frame.left + 1, frame.bottom - 3),
			BPoint((frame.left + frame.right) / 2, frame.top + 1),
			BPoint(frame.right - 1, frame.bottom - 3));

		view->SetHighColor(no_tint);
		view->StrokeLine(BPoint(frame.right - 2, frame.bottom - 3),
			BPoint(frame.left + 3, frame.bottom - 3));

		view->SetHighColor(darkenmax);
		view->StrokeLine(BPoint(frame.left, frame.bottom - 1),
			BPoint(frame.right, frame.bottom - 1));
		view->StrokeLine(BPoint(frame.right, frame.bottom - 2),
			BPoint((frame.left + frame.right) / 2, frame.top));

		view->SetHighColor(darken2);
		view->StrokeLine(BPoint(frame.right - 1, frame.bottom - 2),
			BPoint(frame.left + 1, frame.bottom - 2));
		view->SetHighColor(darken3);
		view->StrokeLine(BPoint(frame.left, frame.bottom - 2),
			BPoint((frame.left + frame.right) / 2 - 1, frame.top + 1));

		view->SetHighColor(lightenmax);
		view->StrokeLine(BPoint(frame.left + 2, frame.bottom - 3),
			BPoint((frame.left + frame.right) / 2, frame.top + 1));

		// Shadow
		view->SetHighColor(0, 0, 0, IsEnabled() ? 80 : 40);
		view->SetDrawingMode(B_OP_ALPHA);
		view->StrokeLine(BPoint(frame.left + 1, frame.bottom),
			BPoint(frame.right, frame.bottom));
	} else {
		view->SetHighColor(lighten1);
		view->FillTriangle(
			BPoint(frame.left, (frame.top + frame.bottom) / 2),
			BPoint(frame.right - 1, frame.top + 1),
			BPoint(frame.right - 1, frame.bottom - 1));

		view->SetHighColor(darkenmax);
		view->StrokeLine(BPoint(frame.right - 1, frame.top),
			BPoint(frame.right - 1, frame.bottom));
		view->StrokeLine(BPoint(frame.right - 1, frame.bottom),
			BPoint(frame.right - 2, frame.bottom));

		view->SetHighColor(darken2);
		view->StrokeLine(BPoint(frame.right - 2, frame.top + 2),
			BPoint(frame.right - 2, frame.bottom - 1));
		view->StrokeLine(
			BPoint(frame.left, (frame.top + frame.bottom) / 2),
			BPoint(frame.right - 2, frame.top));
		view->SetHighColor(darken3);
		view->StrokeLine(
			BPoint(frame.left + 1, (frame.top + frame.bottom) / 2 + 1),
			BPoint(frame.right - 3, frame.bottom - 1));

		view->SetHighColor(lightenmax);
		view->StrokeLine(
			BPoint(frame.left + 1, (frame.top + frame.bottom) / 2),
			BPoint(frame.right - 2, frame.top + 1));

		// Shadow
		view->SetHighColor(0, 0, 0, IsEnabled() ? 80 : 40);
		view->SetDrawingMode(B_OP_ALPHA);
		view->StrokeLine(BPoint(frame.right, frame.top + 1),
			BPoint(frame.right, frame.bottom));
	}

	view->SetDrawingMode(B_OP_COPY);
}
Esempio n. 9
0
void
BSlider::_DrawBlockThumb()
{
	BRect frame = ThumbFrame();
	BView *view = OffscreenView();

	if (be_control_look != NULL) {
		rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
		uint32 flags = be_control_look->Flags(this);
		be_control_look->DrawSliderThumb(view, frame, frame, base, flags,
			fOrientation);
		return;
	}

	rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color lighten2;
	rgb_color lighten1;
	rgb_color darken2;
	rgb_color darken3;
	rgb_color darkenmax;

	if (IsEnabled()) {
		lighten2	= tint_color(no_tint, B_LIGHTEN_2_TINT);
		lighten1	= no_tint;
		darken2		= tint_color(no_tint, B_DARKEN_2_TINT);
		darken3		= tint_color(no_tint, B_DARKEN_3_TINT);
		darkenmax	= tint_color(no_tint, B_DARKEN_MAX_TINT);
	} else {
		lighten2	= tint_color(no_tint, B_LIGHTEN_2_TINT);
		lighten1	= tint_color(no_tint, B_LIGHTEN_1_TINT);
		darken2		= tint_color(no_tint, (B_NO_TINT + B_DARKEN_1_TINT) / 2.0);
		darken3		= tint_color(no_tint, B_DARKEN_1_TINT);
		darkenmax	= tint_color(no_tint, B_DARKEN_3_TINT);
	}

	// blank background for shadow
	// ToDo: this also draws over the hash marks (though it's not *that* noticeable)
	view->SetHighColor(no_tint);
	view->StrokeLine(BPoint(frame.left, frame.top),
					 BPoint(frame.left, frame.top));

	BRect barFrame = BarFrame();
	if (barFrame.right >= frame.right) {
		// leave out barFrame from shadow background clearing
		view->StrokeLine(BPoint(frame.right, frame.top),
						 BPoint(frame.right, barFrame.top - 1.0f));
		view->StrokeLine(BPoint(frame.right, barFrame.bottom + 1.0f),
						 BPoint(frame.right, frame.bottom));
	} else {
		view->StrokeLine(BPoint(frame.right, frame.top),
						 BPoint(frame.right, frame.bottom));
	}

	view->StrokeLine(BPoint(frame.left, frame.bottom),
					 BPoint(frame.right - 1.0f, frame.bottom));
	view->StrokeLine(BPoint(frame.left, frame.bottom - 1.0f),
					 BPoint(frame.left, frame.bottom - 1.0f));
	view->StrokeLine(BPoint(frame.right - 1.0f, frame.top),
					 BPoint(frame.right - 1.0f, frame.top));

	// Outline (top, left)
	view->SetHighColor(darken3);
	view->StrokeLine(BPoint(frame.left, frame.bottom - 2.0f),
					 BPoint(frame.left, frame.top + 1.0f));
	view->StrokeLine(BPoint(frame.left + 1.0f, frame.top),
					 BPoint(frame.right - 2.0f, frame.top));

	// Shadow
	view->SetHighColor(0, 0, 0, IsEnabled() ? 100 : 50);
	view->SetDrawingMode(B_OP_ALPHA);
	view->StrokeLine(BPoint(frame.right, frame.top + 2.0f),
					 BPoint(frame.right, frame.bottom - 1.0f));
	view->StrokeLine(BPoint(frame.left + 2.0f, frame.bottom),
					 BPoint(frame.right - 1.0f, frame.bottom));

	view->SetDrawingMode(B_OP_COPY);
	view->SetHighColor(darken3);
	view->StrokeLine(BPoint(frame.right - 1.0f, frame.bottom - 1.0f),
					 BPoint(frame.right - 1.0f, frame.bottom - 1.0f));


	// First bevel
	frame.InsetBy(1.0f, 1.0f);

	view->SetHighColor(darkenmax);
	view->StrokeLine(BPoint(frame.left, frame.bottom),
					 BPoint(frame.right - 1.0f, frame.bottom));
	view->StrokeLine(BPoint(frame.right, frame.bottom - 1.0f),
					 BPoint(frame.right, frame.top));

	view->SetHighColor(lighten2);
	view->StrokeLine(BPoint(frame.left, frame.top),
					 BPoint(frame.left, frame.bottom - 1.0f));
	view->StrokeLine(BPoint(frame.left + 1.0f, frame.top),
					 BPoint(frame.right - 1.0f, frame.top));

	frame.InsetBy(1.0f, 1.0f);

	view->FillRect(BRect(frame.left, frame.top, frame.right - 1.0f, frame.bottom - 1.0f));

	// Second bevel and center dots
	view->SetHighColor(darken2);
	view->StrokeLine(BPoint(frame.left, frame.bottom),
					 BPoint(frame.right, frame.bottom));
	view->StrokeLine(BPoint(frame.right, frame.bottom - 1.0f),
					 BPoint(frame.right, frame.top));

	if (Orientation() == B_HORIZONTAL) {
		view->StrokeLine(BPoint(frame.left + 6.0f, frame.top + 2.0f),
						 BPoint(frame.left + 6.0f, frame.top + 2.0f));
		view->StrokeLine(BPoint(frame.left + 6.0f, frame.top + 4.0f),
						 BPoint(frame.left + 6.0f, frame.top + 4.0f));
		view->StrokeLine(BPoint(frame.left + 6.0f, frame.top + 6.0f),
						 BPoint(frame.left + 6.0f, frame.top + 6.0f));
	} else {
		view->StrokeLine(BPoint(frame.left + 2.0f, frame.top + 6.0f),
						 BPoint(frame.left + 2.0f, frame.top + 6.0f));
		view->StrokeLine(BPoint(frame.left + 4.0f, frame.top + 6.0f),
						 BPoint(frame.left + 4.0f, frame.top + 6.0f));
		view->StrokeLine(BPoint(frame.left + 6.0f, frame.top + 6.0f),
						 BPoint(frame.left + 6.0f, frame.top + 6.0f));
	}

	frame.InsetBy(1.0f, 1.0f);

	// Third bevel
	view->SetHighColor(lighten1);
	view->StrokeLine(BPoint(frame.left, frame.bottom),
					 BPoint(frame.right, frame.bottom));
	view->StrokeLine(BPoint(frame.right, frame.bottom - 1.0f),
					 BPoint(frame.right, frame.top));
}
Esempio n. 10
0
void
BSlider::DrawText()
{
	BRect bounds(Bounds());
	BView *view = OffscreenView();

	rgb_color base = LowColor();
	uint32 flags = 0;
	if (be_control_look == NULL) {
		if (IsEnabled()) {
			view->SetHighColor(0, 0, 0);
		} else {
			view->SetHighColor(tint_color(LowColor(), B_DISABLED_LABEL_TINT));
		}
	} else
 		flags = be_control_look->Flags(this);

	font_height fontHeight;
	GetFontHeight(&fontHeight);
	if (Orientation() == B_HORIZONTAL) {
		if (Label()) {
			if (be_control_look == NULL) {
				view->DrawString(Label(),
					BPoint(0.0, ceilf(fontHeight.ascent)));
			} else {
				be_control_look->DrawLabel(view, Label(), base, flags,
					BPoint(0.0, ceilf(fontHeight.ascent)));
			}
		}

		// the update text is updated in SetValue() only
		if (fUpdateText != NULL) {
			if (be_control_look == NULL) {
				view->DrawString(fUpdateText, BPoint(bounds.right
					- StringWidth(fUpdateText), ceilf(fontHeight.ascent)));
			} else {
				be_control_look->DrawLabel(view, fUpdateText, base, flags,
					BPoint(bounds.right - StringWidth(fUpdateText),
						ceilf(fontHeight.ascent)));
			}
		}

		if (fMinLimitLabel) {
			if (be_control_look == NULL) {
				view->DrawString(fMinLimitLabel, BPoint(0.0, bounds.bottom
					- fontHeight.descent));
			} else {
				be_control_look->DrawLabel(view, fMinLimitLabel, base, flags,
					BPoint(0.0, bounds.bottom - fontHeight.descent));
			}
		}

		if (fMaxLimitLabel) {
			if (be_control_look == NULL) {
				view->DrawString(fMaxLimitLabel, BPoint(bounds.right
					- StringWidth(fMaxLimitLabel), bounds.bottom
					- fontHeight.descent));
			} else {
				be_control_look->DrawLabel(view, fMaxLimitLabel, base, flags,
					BPoint(bounds.right - StringWidth(fMaxLimitLabel),
						bounds.bottom - fontHeight.descent));
			}
		}
	} else {
		float lineHeight = ceilf(fontHeight.ascent) + ceilf(fontHeight.descent)
			+ ceilf(fontHeight.leading);
		float baseLine = ceilf(fontHeight.ascent);

		if (Label()) {
			if (be_control_look == NULL) {
				view->DrawString(Label(), BPoint((bounds.Width()
					- StringWidth(Label())) / 2.0, baseLine));
			} else {
				be_control_look->DrawLabel(view, Label(), base, flags,
					BPoint((bounds.Width() - StringWidth(Label())) / 2.0,
						baseLine));
			}
			baseLine += lineHeight;
		}

		if (fMaxLimitLabel) {
			if (be_control_look == NULL) {
				view->DrawString(fMaxLimitLabel, BPoint((bounds.Width()
					- StringWidth(fMaxLimitLabel)) / 2.0, baseLine));
			} else {
				be_control_look->DrawLabel(view, fMaxLimitLabel, base, flags,
					BPoint((bounds.Width()
						- StringWidth(fMaxLimitLabel)) / 2.0, baseLine));
			}
		}

		baseLine = bounds.bottom - ceilf(fontHeight.descent);

		if (fMinLimitLabel) {
			if (be_control_look == NULL) {
				view->DrawString(fMinLimitLabel, BPoint((bounds.Width()
					- StringWidth(fMinLimitLabel)) / 2.0, baseLine));
			} else {
				be_control_look->DrawLabel(view, fMinLimitLabel, base, flags,
					BPoint((bounds.Width()
						- StringWidth(fMinLimitLabel)) / 2.0, baseLine));
			}
			baseLine -= lineHeight;
		}

		if (fUpdateText != NULL) {
			if (be_control_look == NULL) {
				view->DrawString(fUpdateText, BPoint((bounds.Width()
					- StringWidth(fUpdateText)) / 2.0, baseLine));
			} else {
				be_control_look->DrawLabel(view, fUpdateText, base, flags,
					BPoint((bounds.Width()
						- StringWidth(fUpdateText)) / 2.0, baseLine));
			}
		}
	}
}
Esempio n. 11
0
void
BSlider::DrawHashMarks()
{
	if (fHashMarks == B_HASH_MARKS_NONE)
		return;

	BRect frame = HashMarksFrame();
	BView* view = OffscreenView();

	if (be_control_look) {
		rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
		uint32 flags = be_control_look->Flags(this);
		be_control_look->DrawSliderHashMarks(view, frame, frame, base,
			fHashMarkCount, fHashMarks, flags, fOrientation);
		return;
	}

	rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color lightenmax;
	rgb_color darken2;

	if (IsEnabled()) {
		lightenmax = tint_color(no_tint, B_LIGHTEN_MAX_TINT);
		darken2 = tint_color(no_tint, B_DARKEN_2_TINT);
	} else {
		lightenmax = tint_color(no_tint, B_LIGHTEN_2_TINT);
		darken2 = tint_color(no_tint, B_DARKEN_1_TINT);
	}

	float pos = _MinPosition();
	int32 hashMarkCount = max_c(fHashMarkCount, 2);
		// draw at least two hashmarks at min/max if
		// fHashMarks != B_HASH_MARKS_NONE
	float factor = (_MaxPosition() - pos) / (hashMarkCount - 1);

	if (fHashMarks & B_HASH_MARKS_TOP) {

		view->BeginLineArray(hashMarkCount * 2);

		if (fOrientation == B_HORIZONTAL) {
			for (int32 i = 0; i < hashMarkCount; i++) {
				view->AddLine(BPoint(pos, frame.top),
							  BPoint(pos, frame.top + 5), darken2);
				view->AddLine(BPoint(pos + 1, frame.top),
							  BPoint(pos + 1, frame.top + 5), lightenmax);

				pos += factor;
			}
		} else {
			for (int32 i = 0; i < hashMarkCount; i++) {
				view->AddLine(BPoint(frame.left, pos),
							  BPoint(frame.left + 5, pos), darken2);
				view->AddLine(BPoint(frame.left, pos + 1),
							  BPoint(frame.left + 5, pos + 1), lightenmax);

				pos += factor;
			}
		}

		view->EndLineArray();
	}

	pos = _MinPosition();

	if (fHashMarks & B_HASH_MARKS_BOTTOM) {

		view->BeginLineArray(hashMarkCount * 2);

		if (fOrientation == B_HORIZONTAL) {
			for (int32 i = 0; i < hashMarkCount; i++) {
				view->AddLine(BPoint(pos, frame.bottom - 5),
							  BPoint(pos, frame.bottom), darken2);
				view->AddLine(BPoint(pos + 1, frame.bottom - 5),
							  BPoint(pos + 1, frame.bottom), lightenmax);

				pos += factor;
			}
		} else {
			for (int32 i = 0; i < hashMarkCount; i++) {
				view->AddLine(BPoint(frame.right - 5, pos),
							  BPoint(frame.right, pos), darken2);
				view->AddLine(BPoint(frame.right - 5, pos + 1),
							  BPoint(frame.right, pos + 1), lightenmax);

				pos += factor;
			}
		}

		view->EndLineArray();
	}
}