コード例 #1
0
void
MonitorView::Draw(BRect updateRect)
{
	rgb_color darkColor = {160, 160, 160, 255};
	rgb_color blackColor = {0, 0, 0, 255};
	rgb_color redColor = {228, 0, 0, 255};
	rgb_color whiteColor = {255, 255, 255, 255};
	BRect outerRect = _MonitorBounds();

	SetHighColor(fBackgroundColor);
	FillRect(updateRect);

	SetDrawingMode(B_OP_OVER);

	// frame & background

	SetHighColor(darkColor);
	FillRoundRect(outerRect, 3.0, 3.0);

	SetHighColor(blackColor);
	StrokeRoundRect(outerRect, 3.0, 3.0);

	SetHighColor(fDesktopColor);

	BRect innerRect(outerRect.InsetByCopy(4, 4));
	FillRoundRect(innerRect, 2.0, 2.0);

	SetHighColor(blackColor);
	StrokeRoundRect(innerRect, 2.0, 2.0);

	SetDrawingMode(B_OP_COPY);

	// power light

	SetHighColor(redColor);
	BPoint powerPos(outerRect.left + 5, outerRect.bottom - 2);
	StrokeLine(powerPos, BPoint(powerPos.x + 2, powerPos.y));

	// DPI

	if (fDPI == 0)
		return;

	font_height fontHeight;
	GetFontHeight(&fontHeight);
	float height = ceilf(fontHeight.ascent + fontHeight.descent);

	char text[64];
	snprintf(text, sizeof(text), B_TRANSLATE("%ld dpi"), fDPI);

	float width = StringWidth(text);
	if (width > innerRect.Width() || height > innerRect.Height())
		return;

	SetLowColor(fDesktopColor);
	SetHighColor(whiteColor);

	DrawString(text, BPoint(innerRect.left + (innerRect.Width() - width) / 2,
		innerRect.top + fontHeight.ascent + (innerRect.Height() - height) / 2));
}
コード例 #2
0
ファイル: PreviewView.cpp プロジェクト: AmirAbrams/haiku
void
PreviewView::Draw(BRect updateRect)
{
	SetHighColor(184, 184, 184);
	FillRoundRect(scale2(0, 9, 0, 3, Bounds()), 4, 4);
		// outer shape
	FillRoundRect(scale2(2, 7, 3, 6, Bounds()), 2, 2);
		// control console outline

	SetHighColor(96, 96, 96);
	StrokeRoundRect(scale2(2, 7, 3, 6, Bounds()), 2, 2);
		// control console outline
	StrokeRoundRect(scale2(0, 9, 0, 3, Bounds()), 4, 4);
		// outline outer shape

	SetHighColor(0, 0, 0);
	FillRect(scale2(1, 8, 1, 2, Bounds()));

	SetHighColor(184, 184, 184);
	BRect outerShape = scale2(2, 7, 2, 6, Bounds());
	outerShape.InsetBy(1, 1);
	FillRoundRect(outerShape, 4, 4);
		// outer shape

	SetHighColor(0, 255, 0);
	FillRect(scale2(3, 4, 4, 5, Bounds()));
	SetHighColor(96, 96, 96);
	FillRect(scale2(5, 6, 4, 5, Bounds()));
}
コード例 #3
0
ファイル: ToolBar.cpp プロジェクト: HaikuArchives/Puri
void
ToolBar::MouseMoved(BPoint where, uint32 code, const BMessage* dragMessage)
{
    for (int i = 0; i < static_cast<int>(fButtonBounds.size()); ++i) {
        if (fButtonBounds[i].Contains(where)) {
            if (i == fButtonHighlight)
                return;

            if (fButtonHighlight >= 0)
                fButtonPressed = false;

            fButtonHighlight = i;
            FillRect(Bounds(), fGradient);
            SetHighColor(make_color(180, 180, 180, 255));
            StrokeRect(Bounds());

            SetHighColor(make_color(100, 100, 100, 255));

            if (fButtonPressed) {
                FillRoundRect(fButtonBounds[i], 4, 4, fGradientPressed);
                StrokeRoundRect(fButtonBounds[i].InsetByCopy(0, -0.1), 4, 4);
                StrokeRoundRect(fButtonBounds[i], 4, 4);
                SetHighColor(make_color(0, 0, 0, 255));

                for (int j = 0; j < static_cast<int>(fButtonBounds.size()); ++j) {
                    if (j == i) {
                        DrawBitmapAsync(fButtonIcon[j], fIconOffset[j] + BPoint(1, 1) );
                        DrawString(fButton[j], fTxtOffset[j] + BPoint(1, 1));
                    } else {
                        DrawBitmapAsync(fButtonIcon[j], fIconOffset[j]);
                        DrawString(fButton[j], fTxtOffset[j]);
                    }
                }
            } else {
                FillRoundRect(fButtonBounds[i], 4, 4, fGradientHighlight);
                StrokeRoundRect(fButtonBounds[i], 4, 4);
                SetHighColor(make_color(0, 0, 0, 255));

                for (int j = 0; j < static_cast<int>(fButtonBounds.size()); ++j) {
                    DrawBitmapAsync(fButtonIcon[j], fIconOffset[j]);
                    DrawString(fButton[j], fTxtOffset[j]);
                }
            }

            return;
        }
    }

    if (fButtonHighlight != -1)
        Invalidate();

    fButtonHighlight = -1;
    fButtonPressed = false;

    BView::MouseMoved(where, code, dragMessage);
}
コード例 #4
0
ファイル: TabManager.cpp プロジェクト: AmirAbrams/haiku
	virtual void DrawSymbol(BRect frame, const BRect& updateRect,
		const rgb_color& base)
	{
		SetHighColor(tint_color(base, B_DARKEN_4_TINT));
		float inset = 3;
		frame.InsetBy(2, 2);
		frame.top++;
		frame.left++;
		FillRoundRect(BRect(frame.left, frame.top + inset,
			frame.right, frame.bottom - inset), 1, 1);
		FillRoundRect(BRect(frame.left + inset, frame.top,
			frame.right - inset, frame.bottom), 1, 1);
	}
コード例 #5
0
ファイル: WidgetFrame.cpp プロジェクト: Barrett17/Faber
void
WidgetFrame::Draw(BRect rect)
{
	rect = Bounds();

	rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color shadowColor = {120,120,120};
	float lightTint = 1.6;

	rgb_color high = tint_color(background, lightTint);
	rgb_color black = {120,120,120};

	float x = 15;
	float y = 15;

	rect.left++;
	rect.top++;

	SetDrawingMode(B_OP_OVER);

	SetHighColor(shadowColor);

	SetDrawingMode(B_OP_ALPHA);
	BGradientRadialFocus frameGradient;
	frameGradient.AddColor(black, 0);
	frameGradient.AddColor(high, 255);
	frameGradient.AddColor(high, 0);

	FillRoundRect(rect, x, y, frameGradient);
}
コード例 #6
0
ファイル: GradientsView.cpp プロジェクト: mmanley/Antares
void
GradientsView::DrawLinear(BRect update)
{
	BGradientLinear gradient;
	rgb_color c;
	c.red = 255;
	c.green = 0;
	c.blue = 0;
	gradient.AddColor(c, 0);
	c.red = 0;
	c.green = 255;
	c.blue = 0;
	gradient.AddColor(c, 127);
	c.red = 0;
	c.green = 0;
	c.blue = 255;
	gradient.AddColor(c, 255);

	// RoundRect
	SetHighColor(0, 0, 0);
	FillRoundRect(BRect(10, 10, 110, 110), 5, 5);
	gradient.SetStart(BPoint(120, 10));
	gradient.SetEnd(BPoint(220, 110));
	FillRoundRect(BRect(120, 10, 220, 110), 5, 5, gradient);

	// Rect
	SetHighColor(0, 0, 0);
	FillRect(BRect(10, 120, 110, 220));
	gradient.SetStart(BPoint(120, 120));
	gradient.SetEnd(BPoint(220, 220));
	FillRect(BRect(120, 120, 220, 220), gradient);

	// Triangle
	SetHighColor(0, 0, 0);
	FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330));
	gradient.SetStart(BPoint(60, 230));
	gradient.SetEnd(BPoint(60, 330));
	FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330), 
		gradient);

	// Ellipse
	SetHighColor(0, 0, 0);
	FillEllipse(BPoint(60, 390), 50, 50);
	gradient.SetStart(BPoint(60, 340));
	gradient.SetEnd(BPoint(60, 440));
	FillEllipse(BPoint(170, 390), 50, 50, gradient);
}
コード例 #7
0
ファイル: GradientsView.cpp プロジェクト: mmanley/Antares
void
GradientsView::DrawRadialFocus(BRect update)
{
	BGradientRadialFocus gradient;
	rgb_color c;
	c.red = 255;
	c.green = 0;
	c.blue = 0;
	gradient.AddColor(c, 0);
	c.red = 0;
	c.green = 255;
	c.blue = 0;
	gradient.AddColor(c, 127);
	c.red = 0;
	c.green = 0;
	c.blue = 255;
	gradient.AddColor(c, 255);

	// RoundRect
	SetHighColor(0, 0, 0);
	FillRoundRect(BRect(10, 10, 110, 110), 5, 5);
	gradient.SetCenter(BPoint(170, 60));
	FillRoundRect(BRect(120, 10, 220, 110), 5, 5, gradient);

	// Rect
	SetHighColor(0, 0, 0);
	FillRect(BRect(10, 120, 110, 220));
	gradient.SetCenter(BPoint(170, 170));
	FillRect(BRect(120, 120, 220, 220), gradient);

	// Triangle
	SetHighColor(0, 0, 0);
	FillTriangle(BPoint(60, 230), BPoint(10, 330), BPoint(110, 330));
	gradient.SetCenter(BPoint(170, 280));
	FillTriangle(BPoint(170, 230), BPoint(120, 330), BPoint(220, 330), 
		gradient);

	// Ellipse
	SetHighColor(0, 0, 0);
	FillEllipse(BPoint(60, 390), 50, 50);
	gradient.SetCenter(BPoint(170, 390));
	FillEllipse(BPoint(170, 390), 50, 50, gradient);
}
コード例 #8
0
void PatternToolItem::Draw(BRect updateRect)
{
    BButton::Draw(updateRect);
    SetDrawingMode(B_OP_OVER);
    BRect buttonFrame=BRect(0,0,17,17);
    if (Value() != B_CONTROL_ON)
    {
        buttonFrame.OffsetTo(4,4);
    }
    else
    {
        buttonFrame.OffsetTo(5,5);
        buttonFrame.bottom -=2;
        buttonFrame.right -=2;
    }
    SetLowColor(255,255,255,255);
    SetHighColor(0,0,0,255);
    FillRoundRect(buttonFrame,4,4,value);
    SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
    StrokeRoundRect(buttonFrame,4,4);
}
コード例 #9
0
void PatternNrButton::MouseMoved( BPoint where, uint32 code, const BMessage *a_message) {

	int32 buttons;
	Window()->CurrentMessage()->FindInt32("buttons", &buttons);
	if (!buttons && fMousePressed) fMousePressed = false;
	
	if	(!Value() || !buttons || !IsEnabled() || !fMousePressed ) return;

	// Pattern wird über ein anderes gezogen
	if (a_message && a_message->what=='drpt') {
		int32	wo = FindButtonNr( where ) - 1;
		if ( wo!=fMarked ) {
			if ( wo > -1 && (wo+1)!=Value() ) {
				SetHighColor( 30, 30, 30, 150 );
				StrokeRoundRect( fBitmap[0][0]->Bounds().OffsetToCopy( wo * 17.0, 0.0 ), 3.0, 3.0 );
				SetHighColor( 128, 128, 128, 90 );
				FillRoundRect( fBitmap[0][0]->Bounds().OffsetToCopy( wo * 17.0, 0.0 ), 3.0, 3.0 );
			}
			if (fMarked>-1) DrawBitmap( fBitmap[fMarked][Value()-1 == fMarked ? 1 : 0], BPoint( fMarked * 17.0, 0.0 ) );

			fMarked = wo;
		}
	}
	
	// Keine Drop-Message -> Nummer wird herausgezogen
	else {

		BBitmap		*dragBitmap = new BBitmap( BRect( 0.0, 0.0, fBitmap[0][0]->Bounds().right + 1, fBitmap[0][0]->Bounds().bottom + 1 ), B_RGBA32, true );
		BView		view( dragBitmap->Bounds(), 0, 0, 0 );
		dragBitmap->Lock();
		dragBitmap->AddChild( &view );
		view.SetHighColor( B_TRANSPARENT_COLOR );
		view.FillRect( view.Bounds() );

		// Bitmap
		view.SetDrawingMode(B_OP_ALPHA);
		view.SetHighColor(255, 0, 0, 150); 
		view.SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_COMPOSITE);
		view.DrawBitmap( fBitmap[Value()-1][1], BPoint( 0.0, 0.0 ) );
		
		// Transparenz
		view.SetDrawingMode(B_OP_COPY);
		view.SetHighColor( B_TRANSPARENT_COLOR );
		BRect	bounds( Bounds() );
		bounds.right = 14; bounds.bottom--;
		view.SetPenSize( 2 );
		view.StrokeRoundRect( bounds.InsetByCopy( -2.0, -2.0), 5, 5 );
		bounds.InsetBy( -1.0, -1.0);
		view.StrokeLine( BPoint( bounds.right, bounds.bottom ), BPoint(bounds.right - 1, bounds.bottom - 1) );

		// Schatten
		view.SetHighColor( 0, 0, 0, 30 );
		view.SetPenSize( 1.0 );
		view.StrokeLine( BPoint( bounds.right, 4.0 ), BPoint( bounds.right, bounds.bottom - 3.0 ) );
		view.StrokeLine( BPoint( bounds.right - 3.0, bounds.bottom ) );
		view.StrokeLine( BPoint( 4.0, bounds.bottom) );

		bounds.right++; bounds.bottom++;
		view.SetHighColor( 0, 0, 0, 10 );
		view.StrokeLine( BPoint( bounds.right, 4.0 ), BPoint( bounds.right, bounds.bottom - 4.0 ) );
		view.StrokeLine( BPoint( bounds.right - 4.0, bounds.bottom ) );
		view.StrokeLine( BPoint( 4.0, bounds.bottom) );

		view.StrokeLine( BPoint( bounds.right, bounds.bottom - 2.0 ), BPoint( bounds.right - 2.0, bounds.bottom ) );

		dragBitmap->RemoveChild( &view );
		dragBitmap->Unlock();

		BMessage	drag_message('drpt');
		drag_message.AddInt32("source", Value() );
		drag_message.AddInt32("be:actions", B_TRASH_TARGET);

		DragMessage(&drag_message, dragBitmap, B_OP_ALPHA, BPoint( where.x - (Value() - 1) * 17.0, where.y ) );

	}
}
コード例 #10
0
void ACanvasSkia::FillRoundRect(int x1,int y1,int x2,int y2,int round)
{
	FillRoundRect(ARect(x1,y1,x2,y2),round);
}