Exemplo n.º 1
0
/*------------------------------------------------------------------------------*\
	( )
		-	
\*------------------------------------------------------------------------------*/
void BmCaption::Draw( BRect updateRect) {
	BRect r = Bounds();
	if (mHighlight) {
		if (BeamOnDano)
			SetLowColor( keyboard_navigation_color());
		else {
			rgb_color highlightCol = {255, 217, 121, 255};
			SetLowColor( highlightCol);
		}
	}
	else
		SetLowColor( ui_color( B_PANEL_BACKGROUND_COLOR));
#ifndef __HAIKU__
	FillRect( r.InsetByCopy(1.0, 1.0), B_SOLID_LOW);
#else
	FillRect( BRect(r.top + 1, r.left + 1, r.right, r.bottom - 1), B_SOLID_LOW);
#endif
	SetHighColor( ui_color( B_SHINE_COLOR));
	StrokeLine( BPoint(0.0,1.0), BPoint(r.right,1.0));
	StrokeLine( BPoint(0.0,1.0), r.LeftBottom());
	SetHighColor( BmWeakenColor( B_SHADOW_COLOR, BeShadowMod));
	if (BeamOnDano)
		StrokeLine( r.RightTop(), r.RightBottom());
#ifndef __HAIKU__
	else
		// looks better on R5, as it blends with scrollbar:
		StrokeLine( r.RightTop(), r.RightBottom(), B_SOLID_LOW);
#endif
	StrokeLine( r.LeftTop(), r.RightTop());
	StrokeLine( r.LeftBottom(), r.RightBottom());

	SetHighColor( ui_color( B_PANEL_TEXT_COLOR));
	font_height fInfo;
	BFont captionFont;
	GetFont(&captionFont);
	captionFont.GetHeight( &fInfo);
	float offset = (1.0f+r.Height()-(fInfo.ascent+fInfo.descent))/2.0f;
	float freeWidth = r.Width();
	if (mHighlight && mHighlightLabel.Length()) {
		freeWidth -= StringWidth(mHighlightLabel.String())+2;
		BPoint pos( 2.0, fInfo.ascent+offset);
		DrawString( mHighlightLabel.String(), pos);
	}
	const char* text = mText.String();
	float width;
	while(1) {
		width = StringWidth(text);
		if (width+4.0 < freeWidth)
			break;
		text++;
		while((*text & 0xc0) == 0x80)
			text++;		// skip UTF8 subsequence chars
		if (!*text)
			break;
	}
	BPoint pos( r.Width()-width-2.0f, fInfo.ascent+offset);
	DrawString( text, pos);
}
Exemplo n.º 2
0
void HColorControl::Draw(BRect /*updateRect*/)
{
	BRect r(Bounds());
	SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	
	font_height fh;
	BFont font;
	GetFont(&font);
	font.GetHeight(&fh);

	BPoint p(3, r.bottom - fh.descent);

	if (IsFocus())
	{
		SetHighColor(keyboard_navigation_color());
		StrokeLine(BPoint(p.x, p.y + 1), BPoint(p.x + StringWidth(fLabel), p.y + 1));
		SetHighColor(255, 255, 255);
		StrokeLine(BPoint(p.x, p.y + 2), BPoint(p.x + StringWidth(fLabel), p.y + 2));
		SetHighColor(0, 0, 0);
	}
	
	DrawString(fLabel, p);
	
	r.left = r.right - 32;
	r.bottom -= fh.descent - 2;
	r.top = r.bottom - 12;
	
	FillRect(r, B_SOLID_LOW);
	r.left += 2;
	r.top += 2;
	
	if (fDown)
	{
		SetHighColor(kBlack);
		StrokeRect(r);
		
		r.InsetBy(1, 1);
		rgb_color c = fColor;
		c.red >>= 1;
		c.green >>= 1;
		c.blue >>= 1;
		SetHighColor(c);
		FillRect(r);
		
		SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
		r.InsetBy(-1, -1);
		r.OffsetBy(-1, -1);
		StrokeLine(r.LeftBottom(), r.LeftTop());
		StrokeLine(r.LeftTop(), r.RightTop());
	}
	else
	{
Exemplo n.º 3
0
// Draw
void
YBScrollView::Draw(BRect updateRect)
{
	rgb_color keyboardFocus = keyboard_navigation_color();
	rgb_color light = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
								 B_LIGHTEN_MAX_TINT);
	rgb_color shadow = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
								  B_DARKEN_1_TINT);
	rgb_color darkShadow = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
								  B_DARKEN_2_TINT);
	rgb_color darkerShadow = tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
								  B_DARKEN_3_TINT);
	BRect bounds = Bounds();
	if (fWindowActive && Target() && Target()->IsFocus()) {
		BeginLineArray(4);
		AddLine(BPoint(bounds.left, bounds.bottom),
				BPoint(bounds.left, bounds.top), keyboardFocus);
		AddLine(BPoint(bounds.left + 1.0, bounds.top),
				BPoint(bounds.right, bounds.top), keyboardFocus);
		AddLine(BPoint(bounds.right, bounds.top + 1.0),
				BPoint(bounds.right, bounds.bottom), keyboardFocus);
		AddLine(BPoint(bounds.right - 1.0, bounds.bottom),
				BPoint(bounds.left + 1.0, bounds.bottom), keyboardFocus);
		EndLineArray();
	} else {
		BeginLineArray(4);
		AddLine(BPoint(bounds.left, bounds.bottom),
				BPoint(bounds.left, bounds.top), shadow);
		AddLine(BPoint(bounds.left + 1.0, bounds.top),
				BPoint(bounds.right, bounds.top), shadow);
		AddLine(BPoint(bounds.right, bounds.top + 1.0),
				BPoint(bounds.right, bounds.bottom), light);
		AddLine(BPoint(bounds.right - 1.0, bounds.bottom),
				BPoint(bounds.left + 1.0, bounds.bottom), light);
		EndLineArray();
	}
	bounds.InsetBy(1.0, 1.0);
	BeginLineArray(4);
	AddLine(BPoint(bounds.left, bounds.bottom),
			BPoint(bounds.left, bounds.top), darkerShadow);
	AddLine(BPoint(bounds.left + 1.0, bounds.top),
			BPoint(bounds.right, bounds.top), darkShadow);
	AddLine(BPoint(bounds.right, bounds.top + 1.0),
			BPoint(bounds.right, bounds.bottom), darkShadow);
	AddLine(BPoint(bounds.right - 1.0, bounds.bottom),
			BPoint(bounds.left + 1.0, bounds.bottom), darkShadow);
	EndLineArray();
}
Exemplo n.º 4
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);
	}
}
Exemplo n.º 5
0
Color focusRingColor()
{
    return Color(keyboard_navigation_color());
}
Exemplo n.º 6
0
void CColorSlider::Draw(BRect /* updateRect */)
{
	BRect r = Bounds();
	
	if (IsFocus())
	{
		SetHighColor(keyboard_navigation_color());
		StrokeRect(r);
	}
	else
	{
		SetHighColor(kB_GrayTable[13]);
		StrokeLine(r.LeftTop(), r.LeftBottom());
		StrokeLine(r.LeftTop(), r.RightTop());
		SetHighColor(kWhite);
		StrokeLine(r.LeftBottom(), r.RightBottom());
		StrokeLine(r.RightTop(), r.RightBottom());
	}

	r.InsetBy(1, 1);

	BRect knob;
	float m = std::min(r.Width(), r.Height()), a;
	knob.Set(1, 1, m + 1, m + 1);
	
	if (fHorizontal)
	{
		a = r.Width() - m;
		knob.OffsetBy(a * fValue, 0);
		
		BeginLineArray((int)a + 1);
		
		float x = r.left;
		for (;x <= r.right; x += 1)
		{
			float v = (x - 1) / a;
			rgb_color c = fMax;
			c.red = (int)((float)c.red * v);
			c.green = (int)((float)c.green * v);
			c.blue = (int)((float)c.blue * v);
			
			float X = x < knob.left ? x : x + knob.Width();
			
			AddLine(BPoint(X, r.top), BPoint(X, r.bottom), c);
		}
		
		EndLineArray();
	}
	else
	{
		a = r.Height() - m;
		knob.OffsetBy(0, a * (1.0 - fValue));
		
		BeginLineArray((int)a + 1);
		
		float y = r.top;
		for (;y <= r.bottom; y += 1)
		{
			float v = 1.0 - (y - 1) / a;
			rgb_color c = fMax;
			c.red = (int)((float)c.red * v);
			c.green = (int)((float)c.green * v);
			c.blue = (int)((float)c.blue * v);
			
			float Y = y < knob.top ? y : y + knob.Height();
			
			AddLine(BPoint(r.left, Y), BPoint(r.right, Y), c);
		}
		
		EndLineArray();
	}
	
	SetHighColor(kWhite);
	StrokeLine(knob.LeftTop(), knob.LeftBottom());
	StrokeLine(knob.LeftTop(), knob.RightTop());
	SetHighColor(kB_GrayTable[13]);
	StrokeLine(knob.LeftBottom(), knob.RightBottom());
	StrokeLine(knob.RightTop(), knob.RightBottom());
	
	SetHighColor(kGray);
	knob.InsetBy(1, 1);
	StrokeRect(knob);
	
	knob.InsetBy(1, 1);
	rgb_color c = fMax;
	c.red = (int)((float)c.red * fValue);
	c.green = (int)((float)c.green * fValue);
	c.blue = (int)((float)c.blue * fValue);
	SetHighColor(c);
	FillRect(knob);

	SetHighColor(kBlack);
	
	Sync();
} /* CColorSlider::Draw */