Beispiel #1
0
// Draw
void
IconBar::Draw(BRect updateRect)
{
	rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color lightenMax = tint_color(base, B_LIGHTEN_MAX_TINT);
	rgb_color darken1 = tint_color(base, (B_NO_TINT + B_DARKEN_1_TINT) / 2.0);
	rgb_color darken2 = tint_color(base, B_DARKEN_2_TINT);

	BRect r(Bounds());

	if (fOrientation == B_HORIZONTAL) {
		BeginLineArray(2);
			AddLine(BPoint(r.left, r.top + 1),
					BPoint(r.right, r.top + 1), lightenMax);
			AddLine(BPoint(r.left, r.top),
					BPoint(r.right, r.top), darken2);
		EndLineArray();
	
		r.top += 2;
	} else {
		BeginLineArray(2);
			AddLine(BPoint(r.right, r.top),
					BPoint(r.right, r.bottom), darken2);
			AddLine(BPoint(r.right - 1, r.top),
					BPoint(r.right - 1, r.bottom), darken1);
		EndLineArray();
	
		r.right -= 2;
	}

	r = r & updateRect;
	SetHighColor(base);
	FillRect(r);
}
Beispiel #2
0
void
ColorPreview::Draw(BRect update)
{
	rgb_color color;
	if (is_enabled)
		color = currentcol;
	else
		color = disabledcol;

	if (is_rect) {
		if (is_enabled) {
			rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
			rgb_color shadow = tint_color(background, B_DARKEN_1_TINT);
			rgb_color darkShadow = tint_color(background, B_DARKEN_3_TINT);
			rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT);

			BRect bounds(Bounds());

			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), darkShadow);
			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), background);
			AddLine(BPoint(bounds.right - 1.0, bounds.bottom),
			BPoint(bounds.left + 1.0, bounds.bottom), background);
			EndLineArray();
			bounds.InsetBy(1.0, 1.0);

			SetHighColor(color);
			FillRect(bounds);
		} else {
			SetHighColor(color);
			FillRect(Bounds());
		}
	} else {
		// fill background
		SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
		FillRect(update);

		SetHighColor(color);
		FillEllipse(Bounds());
		if (is_enabled)
			StrokeEllipse(Bounds(), B_SOLID_LOW);
	}
}
Beispiel #3
0
void HBox::Draw(BRect update)
{
	BRect R(Bounds());
	float l = R.left, t = R.top, r = R.right, b = R.bottom;
	
	if (Label())
	{
		BFont font;
		GetFont(&font);
		font_height fh;
		font.GetHeight(&fh);
		float lh = fh.ascent + fh.descent, w = StringWidth(Label()) + 4;
		
		DrawString(Label(), BPoint(7, fh.ascent));
		
		BeginLineArray(10);
		AddLine(BPoint(l, t + lh / 2), BPoint(l + 4, t + lh / 2), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
		AddLine(BPoint(l + 1, t + lh / 2 + 1), BPoint(l + 5, t + lh / 2 + 1), kWhite);
		
		AddLine(BPoint(l + w + 4, t + lh / 2), BPoint(r, t + lh / 2), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
		AddLine(BPoint(l + w + 4, t + lh / 2 + 1), BPoint(r - 1, t + lh / 2 + 1), kWhite);
		
		AddLine(BPoint(l, t + lh / 2), BPoint(l, b), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
		AddLine(BPoint(l + 1, t + lh / 2 + 1), BPoint(l + 1, b - 2), kWhite);
		
		AddLine(BPoint(l, b - 1), BPoint(r - 1, b - 1), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
		AddLine(BPoint(l, b), BPoint(r, b), kWhite);
				
		AddLine(BPoint(r - 1, b - 1), BPoint(r - 1, t + lh / 2), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
		AddLine(BPoint(r, b), BPoint(r, t + lh / 2), kWhite);
		
		EndLineArray();
	}
	else
	{
		BeginLineArray(8);
		AddLine(BPoint(l, t), BPoint(r - 1, t), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
		AddLine(BPoint(l + 1, t + 1), BPoint(r - 2, t + 1), kWhite);
		
		AddLine(BPoint(l, t), BPoint(l, b - 1), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
		AddLine(BPoint(l + 1, t + 1), BPoint(l + 1, b - 2), kWhite);
		
		AddLine(BPoint(l, b - 1), BPoint(r - 1, b - 1), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
		AddLine(BPoint(l, b), BPoint(r, b), kWhite);
				
		AddLine(BPoint(r - 1, b - 1), BPoint(r - 1, t), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
		AddLine(BPoint(r, b), BPoint(r, t), kWhite);
		
		EndLineArray();
	}
} /* HBox::Draw */
Beispiel #4
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();
}
Beispiel #5
0
// DrawSlider
void
PopupSlider::DrawSlider(BRect frame, bool enabled)
{
	rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color lightShadow;
	rgb_color darkShadow;
	if (enabled) {
		lightShadow = tint_color(background, B_DARKEN_2_TINT);
		darkShadow = tint_color(background, B_DARKEN_4_TINT);
	} else {
		lightShadow = tint_color(background, B_DARKEN_1_TINT);
		darkShadow = tint_color(background, B_DARKEN_2_TINT);
	}

	BeginLineArray(4);
		AddLine(BPoint(frame.left, frame.bottom),
				BPoint(frame.left, frame.top), lightShadow);
		AddLine(BPoint(frame.left + 1.0, frame.top),
				BPoint(frame.right, frame.top), lightShadow);
		AddLine(BPoint(frame.right, frame.top + 1.0),
				BPoint(frame.right, frame.bottom), darkShadow);
		AddLine(BPoint(frame.right - 1.0, frame.bottom),
				BPoint(frame.left + 1.0, frame.bottom), darkShadow);
	EndLineArray();

	frame.InsetBy(1.0, 1.0);
	SliderView::DrawSliderButton(this, frame, Value(), FormatString(), enabled);
}
Beispiel #6
0
void HDlogView::Draw(BRect update)
{
	BView::Draw(update);

	if (fLines.size() > 0)
	{
		vector<BRect>::iterator ri;
		
		BeginLineArray(fLines.size() * 2);
		for (ri = fLines.begin(); ri != fLines.end(); ri++)
		{
			BRect r = *ri;
			if (r.Width() > r.Height())
			{
				AddLine(r.LeftTop(), r.RightTop(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
				AddLine(r.LeftBottom(), r.RightBottom(), kWhite);
			}
			else
			{
				AddLine(r.LeftTop(), r.LeftBottom(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
				AddLine(r.RightTop(), r.RightBottom(), kWhite);
			}
		}
		EndLineArray();
	}
} /* HDlogView::Draw */
Beispiel #7
0
void BarView :: Draw( BRect r )
{
	r = Bounds() ;
	BeginLineArray( 4 ) ;

	AddLine( r.LeftTop() ,
	         ( fOrientation == B_VERTICAL ? r.LeftBottom() : r.RightTop() ) ,
	         Colours::Grey40 ) ;
	AddLine( r.RightBottom() ,
	         ( fOrientation == B_VERTICAL ? r.RightTop() : r.LeftBottom() ) ,
	         Colours::Grey40 ) ;

	if( fOrientation == B_VERTICAL )
		r.InsetBy(1,0) ;
	else
		r.InsetBy(0,1) ;
	
	AddLine( r.LeftTop() ,
	         ( fOrientation == B_VERTICAL ? r.LeftBottom() : r.RightTop() ) ,
	         Colours::White ) ;
	AddLine( r.RightBottom() ,
	         ( fOrientation == B_VERTICAL ? r.RightTop() : r.LeftBottom() ) ,
	         Colours::Grey25 ) ;
	
	EndLineArray() ;
}
void ToolbarView::HighLightItem(int index, int state) {
	BRect r = items[index].rect;
	rgb_color colortouse;
	rgb_color dark = { 154, 154, 154, 255 };
	rgb_color light = { 241, 241, 241, 255 };
	rgb_color back = { 216, 216, 216, 255 };
	Window()->Lock();
	if (state == 0) 
		colortouse=back;
	if (state == 1)				//UP look
		colortouse=dark;
	else if (state == 2)		//DOWN look
		colortouse=light;
	BeginLineArray(8);
	AddLine(BPoint(r.left, r.bottom), BPoint(r.right, r.bottom),colortouse);
	AddLine(BPoint(r.left+1, r.bottom-1), BPoint(r.right-1, r.bottom-1),colortouse);
	AddLine(BPoint(r.right, r.top), BPoint(r.right, r.bottom),colortouse);
	AddLine(BPoint(r.right-1, r.top+1), BPoint(r.right-1, r.bottom-1),colortouse);
	if (state == 1)
		colortouse=light;
	else if (state == 2)
		colortouse=dark;
	AddLine(BPoint(r.left, r.bottom), BPoint(r.left, r.top),colortouse);
	AddLine(BPoint(r.left+1, r.bottom-1), BPoint(r.left+1, r.top+1),colortouse);
	AddLine(BPoint(r.left, r.top), BPoint(r.right, r.top),colortouse);
	AddLine(BPoint(r.left+1, r.top+1), BPoint(r.right-1, r.top+1),colortouse);
	EndLineArray();
	Window()->Sync();
	Window()->Unlock();
}
void ArpConfigureView::Draw(BRect )
{
	BeginLineArray(6);
	const rgb_color bgcolor = ViewColor();
	
	if( mMakeDefaultButton ) {
		BRect revFrame(mMakeDefaultButton->Frame());
		const float left = revFrame.right + floor((mSpaceWidth*3)/2);
		AddLine( BPoint(left, revFrame.top),
				 BPoint(left, revFrame.bottom),
				 tint_color(bgcolor, B_DARKEN_4_TINT) );
		AddLine( BPoint(left+1, revFrame.top),
				 BPoint(left+1, revFrame.bottom),
				 tint_color(bgcolor, .2) );
	}
	
	BRect bnd(Bounds());
	BRect panFrame(mPanel->Frame());
	AddLine( BPoint(bnd.left, bnd.bottom),
			 BPoint(bnd.left, panFrame.bottom+1),
			 tint_color(bgcolor, .2) );
	AddLine( BPoint(bnd.left, panFrame.bottom+1),
			 BPoint(bnd.right, panFrame.bottom+1),
			 tint_color(bgcolor, .2) );
	AddLine( BPoint(bnd.right, panFrame.bottom+1),
			 BPoint(bnd.right, bnd.bottom),
			 tint_color(bgcolor, B_DARKEN_4_TINT) );
	AddLine( BPoint(bnd.right, bnd.bottom),
			 BPoint(bnd.left, bnd.bottom),
			 tint_color(bgcolor, B_DARKEN_4_TINT) );
	
	EndLineArray();
}
	virtual void Draw(BRect updateRect)
	{
		BRect r = Bounds();
		if (fAnticipateDrop) {
			SetHighColor(0, 150, 50);
			StrokeRect(r);
			r.InsetBy(1, 1);
			StrokeRect(r);
			r.InsetBy(1, 1);
		} else {
			rgb_color lighten2 = tint_color(LowColor(), B_LIGHTEN_2_TINT);
			rgb_color darken1 = tint_color(LowColor(), B_DARKEN_1_TINT);
			BeginLineArray(4);
				AddLine(BPoint(r.left, r.bottom),
					BPoint(r.left, r.top), lighten2);
				AddLine(BPoint(r.left + 1, r.top),
					BPoint(r.right, r.top), lighten2);
				AddLine(BPoint(r.right, r.top + 1),
					BPoint(r.right, r.bottom), darken1);
				AddLine(BPoint(r.right - 1, r.bottom),
					BPoint(r.left + 1, r.bottom), darken1);
			EndLineArray();
			r.InsetBy(1, 1);
		}
		FillRect(r, B_SOLID_LOW);
	}
Beispiel #11
0
// Draw
void
ListLabelView::Draw(BRect updateRect)
{
	rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color lightenMax = tint_color(base, B_LIGHTEN_MAX_TINT);
	rgb_color darken2 = tint_color(base, B_DARKEN_2_TINT);

	BRect r(Bounds());

	BeginLineArray(3);
		AddLine(BPoint(r.left, r.bottom - 1),
				BPoint(r.left, r.top), lightenMax);
		AddLine(BPoint(r.right, r.top),
				BPoint(r.right, r.bottom), darken2);
		AddLine(BPoint(r.right - 1, r.bottom),
				BPoint(r.left, r.bottom), darken2);
	EndLineArray();

	r.left += 1;
	r.right -= 1;
	r.bottom -= 1;

	SetLowColor(base);
	FillRect(r & updateRect, B_SOLID_LOW);

	font_height fh;
	GetFontHeight(&fh);

	SetHighColor(0, 0, 0, 255);
	BPoint labelPos;
	labelPos.x = 5;
	labelPos.y = r.top + floorf((r.Height() + fh.ascent) / 2.0);
	DrawString(fLabel.String(), labelPos);
}
Beispiel #12
0
void SpinButton::DrawButton(BRect rect, int32 button)
{
    rgb_color color = ViewColor();

    rgb_color topColor = tint_color(color,
                                    button == kSpinButtonNone ?
                                    (IsEnabled() ? B_DARKEN_2_TINT : B_DARKEN_2_TINT) :
                                    (button == fButton ? B_DARKEN_1_TINT : B_LIGHTEN_MAX_TINT));

    rgb_color bottomColor = tint_color(color,
                                       button == kSpinButtonNone ?
                                       (IsEnabled() ? B_DARKEN_4_TINT : B_DARKEN_3_TINT) :
                                       (button == fButton ? B_LIGHTEN_2_TINT : B_DARKEN_1_TINT));

    BeginLineArray(4);

    AddLine(rect.LeftBottom(), rect.LeftTop(), topColor);
    AddLine(rect.LeftTop(), rect.RightTop(), topColor);

    AddLine(rect.RightTop(), rect.RightBottom(), bottomColor);
    AddLine(rect.RightBottom(), rect.LeftBottom(), bottomColor);

    EndLineArray();

    if (button != kSpinButtonNone) {
        rect.InsetBy(1, 1);
        SetHighColor(tint_color(color, B_LIGHTEN_1_TINT));
        FillRect(rect);

        BPoint point(0.5f * (rect.left + rect.right) - 2.0f,
                     0.5f * (rect.top + rect.bottom) - 0.25f +
                     (button == kSpinButtonUp ? 1.0f : -1.0f) +
                     (button == fButton ? 1.0f : 0.0f));

        rgb_color arrowColor = tint_color(color,
                                          IsEnabled() ? B_DARKEN_4_TINT : B_DISABLED_LABEL_TINT);

        BeginLineArray(3);

        for (int32 delta = 0; delta < 3; delta++) {
            AddLine(point, point + BPoint(4 - delta - delta, 0), arrowColor);
            point += BPoint(1, button == kSpinButtonUp ? -1 : 1);
        }

        EndLineArray();
    }
}
Beispiel #13
0
void OptionsPanel :: Draw( BRect r )
{
	inherited::Draw( r ) ;
	
	r = Bounds() ;
	BeginLineArray( 1 ) ;
	AddLine( r.LeftTop()    , r.RightTop()    , Colours::Grey85 ) ;
	EndLineArray( ) ;
}
Beispiel #14
0
void FolderPanel :: Draw( BRect r )
{
	inherited::Draw( r ) ;
	
	r = Bounds() ;
	BeginLineArray( 1 ) ;
	AddLine( r.LeftBottom() , r.RightBottom() , Colours::White ) ;
	EndLineArray( ) ;
}
Beispiel #15
0
void
SeekSlider::_StrokeFrame(BRect r, rgb_color left, rgb_color top,
                         rgb_color right, rgb_color bottom)
{
    BeginLineArray(4);
    AddLine(BPoint(r.left, r.bottom), BPoint(r.left, r.top), left);
    AddLine(BPoint(r.left + 1.0, r.top), BPoint(r.right, r.top), top);
    AddLine(BPoint(r.right, r.top + 1.0), BPoint(r.right, r.bottom), right);
    AddLine(BPoint(r.right - 1.0, r.bottom), BPoint(r.left + 1.0, r.bottom), bottom);
    EndLineArray();
}
Beispiel #16
0
void 
BNavigator::Draw(BRect)
{
	// Draws a beveled smooth border
	BeginLineArray(4);
	AddLine(Bounds().LeftTop(), Bounds().RightTop(), kShineColor);
	AddLine(Bounds().LeftTop(), Bounds().LeftBottom() - BPoint(0, 1), kShineColor);
	AddLine(Bounds().LeftBottom() - BPoint(-1, 1), Bounds().RightBottom() - BPoint(0, 1), kHalfDarkColor);
	AddLine(Bounds().LeftBottom(), Bounds().RightBottom(), kDarkColor);
	EndLineArray();
}
Beispiel #17
0
void DCCConnect::Draw(BRect)
{
	BView* top(Window()->ChildAt(0));

	if (this != top) {
		BeginLineArray(2);
		AddLine(Bounds().LeftTop(), Bounds().RightTop(), tint_color(ViewColor(), B_DARKEN_2_TINT));

		AddLine(Bounds().LeftTop() + BPoint(0.0, 1.0), Bounds().RightTop() + BPoint(0.0, 1.0),
				tint_color(ViewColor(), B_LIGHTEN_MAX_TINT));
		EndLineArray();
	}
}
void
ColorPreview::Draw(BRect updateRect)
{
	rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color shadow = tint_color(background, B_DARKEN_1_TINT);
	rgb_color darkShadow = tint_color(background, B_DARKEN_3_TINT);
	rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT);

	BRect bounds(Bounds());

	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), darkShadow);
	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), background);
	AddLine(BPoint(bounds.right - 1.0, bounds.bottom),
		BPoint(bounds.left + 1.0, bounds.bottom), background);
	EndLineArray();
	bounds.InsetBy(1.0, 1.0);

	SetHighColor(fColor);
	FillRect(bounds);
}
Beispiel #19
0
void
PaneSwitch::Draw(BRect)
{
	BRect bounds(Bounds());

	// Draw the label, if any
	const char* label = fLabelOff;
	if (fLabelOn != NULL && Value() == B_CONTROL_ON)
		label = fLabelOn;

	if (label != NULL) {
		BPoint point;
		float labelDist = sLatchSize + ceilf(sLatchSize / 2.0);
		if (fLeftAligned)
			point.x = labelDist;
		else
			point.x = bounds.right - labelDist - StringWidth(label);

		SetHighUIColor(B_PANEL_TEXT_COLOR);
		font_height fontHeight;
		GetFontHeight(&fontHeight);
		point.y = (bounds.top + bounds.bottom
			- ceilf(fontHeight.ascent) - ceilf(fontHeight.descent)) / 2
			+ ceilf(fontHeight.ascent);

		DrawString(label, point);
	}

	// draw the latch
	if (fPressing)
		DrawInState(kPressed);
	else if (Value())
		DrawInState(kExpanded);
	else
		DrawInState(kCollapsed);

	// ...and the focus indication
	if (!IsFocus() || !Window()->IsActive())
		return;

	rgb_color markColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);

	BeginLineArray(2);
	AddLine(BPoint(bounds.left + 2, bounds.bottom - 1),
		BPoint(bounds.right - 2, bounds.bottom - 1), markColor);
	AddLine(BPoint(bounds.left + 2, bounds.bottom),
		BPoint(bounds.right - 2, bounds.bottom), kWhite);
	EndLineArray();
}
Beispiel #20
0
void
_MediaBar_::Draw(
	BRect	updateRect)
{
	BRect		bounds = Bounds();
	rgb_color	viewColor = ViewColor();
	rgb_color	light = {255, 255, 255, 255};
	rgb_color	dark = tint_color(viewColor, B_DARKEN_3_TINT);

	BeginLineArray(4);
	AddLine(bounds.RightTop(), bounds.RightBottom(), dark);
	AddLine(bounds.RightBottom(), bounds.LeftBottom(), dark);
	AddLine(bounds.LeftBottom(), bounds.LeftTop(), light);
	AddLine(bounds.LeftTop(), bounds.RightTop(), light);
	EndLineArray();
}
Beispiel #21
0
// Draw
void
TestView::Draw(BRect updateRect)
{
printf("TestView::Draw(");
updateRect.PrintToStream();
	BRect r(Bounds());

	rgb_color light = tint_color(ViewColor(), B_LIGHTEN_2_TINT);
	rgb_color shadow = tint_color(ViewColor(), B_DARKEN_2_TINT);

	BeginLineArray(4);
		AddLine(r.LeftTop(), r.RightTop(), light);
		AddLine(r.RightTop(), r.RightBottom(), shadow);
		AddLine(r.RightBottom(), r.LeftBottom(), shadow);
		AddLine(r.LeftBottom(), r.LeftTop(), light);
	EndLineArray();
}
Beispiel #22
0
/*------------------------------------------------------------------------------*\
	( )
		-	
\*------------------------------------------------------------------------------*/
void BmToolbarButton::Draw( BRect updateRect) {
	BView::Draw( updateRect);

	BRect rect(Bounds());
#ifdef __HAIKU__
	if (be_control_look && mHighlighted && IsEnabled()) {
		// draw higlighting border
		uint32 flags = 0;
		if (Value())
			flags |= BControlLook::B_ACTIVATED;
		rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
		be_control_look->DrawButtonFrame(this, rect, updateRect, base, base,
			flags);
		be_control_look->DrawButtonBackground(this, rect, updateRect, base,
			flags);
	}
#endif // __HAIKU__

	BPicture* pic = NULL;
	if (!IsEnabled())
		pic = DisabledOff();
	else
		pic = Value() ? EnabledOn() : EnabledOff();
	if (pic)
		DrawPicture(pic, BPoint(0, 0));

#ifndef __HAIKU__
	if (mHighlighted && IsEnabled()) {
		// draw higlighting border
		BeginLineArray(4);
		AddLine( rect.LeftBottom(), rect.LeftTop(), 
					ui_color( B_SHINE_COLOR));
		AddLine( rect.LeftTop(), rect.RightTop(), 
					ui_color( B_SHINE_COLOR));
		AddLine( rect.LeftBottom(), rect.RightBottom(), 
					BmWeakenColor(B_SHADOW_COLOR, BeShadowMod));
		AddLine( rect.RightBottom(), rect.RightTop(), 
					BmWeakenColor(B_SHADOW_COLOR, BeShadowMod));
		EndLineArray();
	}
#endif
}
Beispiel #23
0
void PaneSwitch::Draw(BRect)
{
	if (fPressing)
		DrawInState(kPressed);
	else if (Value())
		DrawInState(kExpanded);
	else
		DrawInState(kCollapsed);

	rgb_color markColor = ui_color(B_KEYBOARD_NAVIGATION_COLOR);
	
	bool focused = IsFocus() && Window()->IsActive();
	BRect bounds(Bounds());
	BeginLineArray(2);
	AddLine(BPoint(bounds.left + 2, bounds.bottom - 1),
		BPoint(bounds.right - 2, bounds.bottom - 1), focused ? markColor : ViewColor());
	AddLine(BPoint(bounds.left + 2, bounds.bottom),
		BPoint(bounds.right - 2, bounds.bottom), focused ? kWhite : ViewColor());
	EndLineArray();
}
Beispiel #24
0
void
TOSMagnify::DrawGrid(int32 width, int32 height, BRect destRect, int32 pixelSize)
{
	// draw grid
	if (fParent->ShowGrid() && fParent->PixelSize() > 2) {
		BeginLineArray(width * height);

		// horizontal lines
		for (int32 i = pixelSize; i < (height * pixelSize); i += pixelSize)
			AddLine(BPoint(0, i), BPoint(destRect.right, i), kGridGray);

		// vertical lines
		for (int32 i = pixelSize; i < (width * pixelSize); i += pixelSize)
			AddLine(BPoint(i, 0), BPoint(i, destRect.bottom), kGridGray);

		EndLineArray();
	}

	SetHighColor(kGridGray);
	StrokeRect(destRect);
}
Beispiel #25
0
void
RadialLinesView::Draw(BRect updateRect)
{
	const rgb_color black = { 0, 0, 0, 255 };
	const int angleStep = 4;

	BRect rect(Bounds());
	float size = rect.Width();
	if (size > rect.Height())
		size = rect.Height();
	size *= 0.45; // leave 10% of margin

	BPoint center(rect.Width() / 2, rect.Height() / 2);

	BeginLineArray(360 / angleStep);
	for (int i = 0; i < 360; i += angleStep) {
		double angle = i * M_PI / 180;
		BPoint pt(size * cos(angle), size * sin(angle));
		AddLine(center, center + pt, black);
	}
	EndLineArray();
}
Beispiel #26
0
void
BBox::_DrawPlain(BRect labelBox)
{
	BRect rect = Bounds();
	rect.top += TopBorderOffset();

	float lightTint;
	float shadowTint;
	if (be_control_look != NULL) {
		lightTint = B_LIGHTEN_1_TINT;
		shadowTint = B_DARKEN_1_TINT;
	} else {
		lightTint = B_LIGHTEN_MAX_TINT;
		shadowTint = B_DARKEN_3_TINT;
	}

	if (rect.Height() == 0.0 || rect.Width() == 0.0) {
		// used as separator
		rgb_color shadow = tint_color(ViewColor(), B_DARKEN_2_TINT);

		SetHighColor(shadow);
		StrokeLine(rect.LeftTop(),rect.RightBottom());
	} else {
		// used as box
		rgb_color light = tint_color(ViewColor(), lightTint);
		rgb_color shadow = tint_color(ViewColor(), shadowTint);

		BeginLineArray(4);
			AddLine(BPoint(rect.left, rect.bottom),
					BPoint(rect.left, rect.top), light);
			AddLine(BPoint(rect.left + 1.0f, rect.top),
					BPoint(rect.right, rect.top), light);
			AddLine(BPoint(rect.left + 1.0f, rect.bottom),
					BPoint(rect.right, rect.bottom), shadow);
			AddLine(BPoint(rect.right, rect.bottom - 1.0f),
					BPoint(rect.right, rect.top + 1.0f), shadow);
		EndLineArray();
	}
}
Beispiel #27
0
void
ShowImageStatusView::Draw(BRect updateRect)
{
	rgb_color darkShadow = tint_color(LowColor(), B_DARKEN_2_TINT);
	rgb_color shadow = tint_color(LowColor(), B_DARKEN_1_TINT);
	rgb_color light = tint_color(LowColor(), B_LIGHTEN_MAX_TINT);

	BRect b(Bounds());

	BeginLineArray(5);
		AddLine(BPoint(b.left, b.top),
				BPoint(b.right, b.top), darkShadow);
		b.top += 1.0;
		AddLine(BPoint(b.left, b.top),
				BPoint(b.right, b.top), light);
		AddLine(BPoint(b.right, b.top + 1.0),
				BPoint(b.right, b.bottom), shadow);
		AddLine(BPoint(b.right - 1.0, b.bottom),
				BPoint(b.left + 1.0, b.bottom), shadow);
		AddLine(BPoint(b.left, b.bottom),
				BPoint(b.left, b.top + 1.0), light);
	EndLineArray();

	b.InsetBy(1.0, 1.0);

	// Truncate and layout text
	BString truncated(fText);
	BFont font;
	GetFont(&font);
	font.TruncateString(&truncated, B_TRUNCATE_MIDDLE, b.Width() - 4.0);
	font_height fh;
	font.GetHeight(&fh);

	FillRect(b, B_SOLID_LOW);
	SetDrawingMode(B_OP_OVER);
	DrawString(truncated.String(), BPoint(b.left + 2.0,
		floorf(b.top + b.Height() / 2.0 + fh.ascent / 2.0)));
}
Beispiel #28
0
void HTabSheet::Draw(BRect update)
{
	BRect f;
	BPoint p;

	font_height fh;
	be_plain_font->GetHeight(&fh);

	f = fClientArea;
	f.top = fListArea.top;
	f.bottom = ceil(fClientArea.top - 8 * gFactor);

	f.InsetBy(2, 2);
	
	SetLowColor(0x77, 0xdd, 0xdd);
	FillRect(f, B_SOLID_LOW);

	p.x = f.left + 4;
	p.y = f.bottom - fh.descent;
	DrawString((char *)fDescs.ItemAt(fCurrent), p);
	SetLowColor(ViewColor());

	BeginLineArray(8);

	f.InsetBy(-2, -2);
	AddLine(f.LeftTop(), f.RightTop(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
	AddLine(f.LeftTop(), f.LeftBottom(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
	AddLine(f.RightTop(), f.RightBottom(), kWhite);
	AddLine(f.LeftBottom(), f.RightBottom(), kWhite);
	
	f.InsetBy(1, 1);
	AddLine(f.LeftTop(), f.RightTop(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_2_TINT));
	AddLine(f.LeftTop(), f.LeftBottom(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_2_TINT));
	AddLine(f.RightTop(), f.RightBottom(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
	AddLine(f.LeftBottom(), f.RightBottom(), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
	
	EndLineArray();
} /* HTabSheet::Draw */
Beispiel #29
0
/**
	Draws space between child views.
*/
void SplitView::DrawSplitter(BRect frame, bool active)
{
	// Do not cache ui_color values, they may change anytime.
	rgb_color back = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color hi = tint_color(back, B_LIGHTEN_1_TINT);
	rgb_color lo = tint_color(back, B_DARKEN_1_TINT);

	// Border
	BeginLineArray(4);
	AddLine(frame.LeftTop(), frame.RightTop(), hi);
	AddLine(frame.LeftTop(), frame.LeftBottom(), hi);
	AddLine(frame.RightBottom(), frame.LeftBottom(), lo);
	AddLine(frame.RightBottom(), frame.RightTop(), lo);
	EndLineArray();

	// Background
	frame.InsetBy(1,1);
	SetLowColor(back);
	SetHighColor(tint_color(back, B_LIGHTEN_MAX_TINT));
	//SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
	FillRect(frame, active ? B_MIXED_COLORS : B_SOLID_LOW);
	
}
Beispiel #30
0
// Draw
void
VolumeSlider::Draw(BRect updateRect)
{
	if (!IsValid()) {
		fprintf(stderr, "VolumeSlider::Draw() - Error: no valid bitmaps!");
		SetHighColor(255, 0, 0);
		FillRect(updateRect);
		return;
	}

	BRect r(Bounds());
	float sliderSideWidth = kVolumeSliderBitmapWidth;
	float sliderStart = (r.left + sliderSideWidth);
	float sliderEnd = (r.right - sliderSideWidth);
	float knobPos = sliderStart
					+ (sliderEnd - sliderStart - 1.0) * (Value() - fMinValue)
					/ (fMaxValue - fMinValue);
	// draw both sides (the original from Be doesn't seem
	// to make a difference for enabled/disabled state)
	DrawBitmapAsync(fLeftSideBits, r.LeftTop());
	DrawBitmapAsync(fRightSideBits, BPoint(sliderEnd + 1.0, r.top));
	// colors for the slider area between the two bitmaps
	rgb_color background = kBackground;//ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color shadow = tint_color(background, B_DARKEN_2_TINT);
	rgb_color softShadow = tint_color(background, B_DARKEN_1_TINT);
	rgb_color darkShadow = tint_color(background, B_DARKEN_4_TINT);
	rgb_color midShadow = tint_color(background, B_DARKEN_3_TINT);
	rgb_color light = tint_color(background, B_LIGHTEN_MAX_TINT);
	rgb_color softLight = tint_color(background, B_LIGHTEN_1_TINT);
	rgb_color green = kGreen;
	rgb_color greenShadow = kGreenShadow;
	rgb_color black = kBlack;
	rgb_color dotGrey = midShadow;
	rgb_color dotGreen = greenShadow;
	// make dimmed version of colors if we're disabled
	if (!IsEnabled()) {
		shadow = (rgb_color){ 200, 200, 200, 255 };
		softShadow = dimmed_color_cmap8(softShadow, background, DIM_LEVEL);
		darkShadow = dimmed_color_cmap8(darkShadow, background, DIM_LEVEL);
		midShadow = shadow;
		light = dimmed_color_cmap8(light, background, DIM_LEVEL);
		softLight = dimmed_color_cmap8(softLight, background, DIM_LEVEL);
		green = dimmed_color_cmap8(green, background, DIM_LEVEL);
		greenShadow = dimmed_color_cmap8(greenShadow, background, DIM_LEVEL);
		black = dimmed_color_cmap8(black, background, DIM_LEVEL);
		dotGreen = dotGrey;
	} else if (fMuted) {
		green = tint_color(kBackground, B_DARKEN_3_TINT);
		greenShadow = tint_color(kBackground, B_DARKEN_4_TINT);
		dotGreen = greenShadow;
	}
	// draw slider edges between bitmaps
	BeginLineArray(7);
		AddLine(BPoint(sliderStart, r.top),
				BPoint(sliderEnd, r.top), softShadow);
		AddLine(BPoint(sliderStart, r.bottom),
				BPoint(sliderEnd, r.bottom), softLight);
		r.InsetBy(0.0, 1.0);
		AddLine(BPoint(sliderStart, r.top),
				BPoint(sliderEnd, r.top), black);
		AddLine(BPoint(sliderStart, r.bottom),
				BPoint(sliderEnd, r.bottom), light);
		r.top++;
		AddLine(BPoint(sliderStart, r.top),
				BPoint(knobPos, r.top), greenShadow);
		AddLine(BPoint(knobPos, r.top),
				BPoint(sliderEnd, r.top), midShadow);
		r.top++;
		AddLine(BPoint(sliderStart, r.top),
				BPoint(knobPos, r.top), greenShadow);
	EndLineArray();
	// fill rest inside of slider
	r.InsetBy(0.0, 1.0);
	r.left = sliderStart;
	r.right = knobPos;
	SetHighColor(green);
	FillRect(r, B_SOLID_HIGH);
	r.left = knobPos + 1.0;
	r.right = sliderEnd;
	r.top -= 1.0;
	SetHighColor(shadow);
	FillRect(r, B_SOLID_HIGH);
	// draw little dots inside
	int32 dotCount = (int32)((sliderEnd - sliderStart) / 5.0);
	BPoint dotPos;
	dotPos.y = r.top + 4.0;
	for (int32 i = 0; i < dotCount; i++) {
		dotPos.x = sliderStart + i * 5.0 + 4.0;
		SetHighColor(dotPos.x < knobPos ? dotGreen : dotGrey);
		StrokeLine(dotPos, BPoint(dotPos.x, dotPos.y + 1.0));
	}
	// draw knob
	r.top -= 1.0;
	SetDrawingMode(B_OP_OVER); // part of knob is transparent
	DrawBitmapAsync(fKnobBits, BPoint(knobPos - kVolumeSliderKnobWidth / 2, r.top));
}