Esempio n. 1
0
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()));
}
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));
}
Esempio n. 3
0
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);
}
void
AppGroupView::Draw(BRect updateRect)
{
	rgb_color menuColor = ViewColor();
	BRect bounds = Bounds();
	rgb_color hilite = tint_color(menuColor, B_DARKEN_1_TINT);
	rgb_color vlight = tint_color(menuColor, B_LIGHTEN_2_TINT);
	bounds.bottom = bounds.top + kHeaderSize;

	// Draw the header background
	SetHighColor(tint_color(menuColor, 1.22));
	SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	StrokeLine(bounds.LeftTop(), bounds.LeftBottom());
	uint32 borders = BControlLook::B_TOP_BORDER
		| BControlLook::B_BOTTOM_BORDER | BControlLook::B_RIGHT_BORDER;

	be_control_look->DrawButtonBackground(this, bounds, bounds, menuColor,
		0, borders);

	// Draw the buttons
	fCollapseRect.top = (kHeaderSize - kExpandSize) / 2;
	fCollapseRect.left = kEdgePadding * 2;
	fCollapseRect.right = fCollapseRect.left + 1.5 * kExpandSize;
	fCollapseRect.bottom = fCollapseRect.top + kExpandSize;

	fCloseRect = bounds;
	fCloseRect.top = (kHeaderSize - kExpandSize) / 2;
	fCloseRect.right -= kEdgePadding * 2;
	fCloseRect.left = fCloseRect.right - kCloseSize;
	fCloseRect.bottom = fCloseRect.top + kCloseSize;

	uint32 arrowDirection = fCollapsed
		? BControlLook::B_DOWN_ARROW : BControlLook::B_UP_ARROW;
	be_control_look->DrawArrowShape(this, fCollapseRect, fCollapseRect,
		LowColor(), arrowDirection, 0, B_DARKEN_3_TINT);

	SetPenSize(kPenSize);

	// Draw the dismiss widget
	BRect closeCross = fCloseRect;
	closeCross.InsetBy(kSmallPadding, kSmallPadding);
	rgb_color detailCol = ui_color(B_CONTROL_BORDER_COLOR);
	detailCol = tint_color(detailCol, B_LIGHTEN_2_TINT);

	StrokeRoundRect(fCloseRect, kSmallPadding, kSmallPadding);
	StrokeLine(closeCross.LeftTop(), closeCross.RightBottom());
	StrokeLine(closeCross.RightTop(), closeCross.LeftBottom());

	// Draw the label
	SetHighColor(ui_color(B_PANEL_TEXT_COLOR));
	BString label = fLabel;
	if (fCollapsed)
		label << " (" << fInfo.size() << ")";

	SetFont(be_bold_font);

	DrawString(label.String(), BPoint(fCollapseRect.right + 2 * kEdgePadding,
				fCloseRect.bottom));
}
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);
}
Esempio n. 6
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 ) );

	}
}
Esempio n. 7
0
void
NotificationView::Draw(BRect updateRect)
{
	BRect progRect;

	// Draw progress background
	if (fType == B_PROGRESS_NOTIFICATION) {
		PushState();

		font_height fh;
		be_plain_font->GetHeight(&fh);
		float fontHeight = fh.ascent + fh.descent + fh.leading;

		progRect = Bounds();
		progRect.InsetBy(kEdgePadding, kEdgePadding);
		progRect.top = progRect.bottom - (kSmallPadding * 2) - fontHeight;
		StrokeRect(progRect);

		BRect barRect = progRect;		
		barRect.InsetBy(1.0, 1.0);
		barRect.right *= fProgress;
		SetHighColor(ui_color(B_CONTROL_HIGHLIGHT_COLOR));
		FillRect(barRect);

		SetHighColor(ui_color(B_PANEL_TEXT_COLOR));

		BString label = "";
		label << (int)(fProgress * 100) << " %";

		float labelWidth = be_plain_font->StringWidth(label.String());
		float labelX = progRect.left + (progRect.IntegerWidth() / 2) - (labelWidth / 2);

		SetLowColor(B_TRANSPARENT_COLOR);
		SetDrawingMode(B_OP_ALPHA);
		DrawString(label.String(), label.Length(),
			BPoint(labelX, progRect.top + fh.ascent + fh.leading + kSmallPadding));

		PopState();
	}

	SetDrawingMode(B_OP_ALPHA);
	SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);

	// Icon size
	float iconSize = (float)fParent->IconSize();

	// Rectangle for icon and overlay icon
	BRect iconRect(0, 0, 0, 0);

	// Draw icon
	if (fBitmap) {
		LineInfo* appLine = fLines.back();
		font_height fh;
		appLine->font.GetHeight(&fh);

		float title_bottom = appLine->location.y + fh.descent;

		float ix = kEdgePadding;
		float iy = 0;
		if (fParent->Layout() == TitleAboveIcon)
			iy = title_bottom + kEdgePadding + (Bounds().Height() - title_bottom
				- kEdgePadding * 2 - iconSize) / 2;
		else
			iy = (Bounds().Height() - iconSize) / 2.0;

		if (fType == B_PROGRESS_NOTIFICATION)
			// Move icon up by half progress bar height if it's present
			iy -= (progRect.Height() + kEdgePadding) / 2.0;

		iconRect.left = ix;
		iconRect.top = iy;
		iconRect.right = ix + iconSize;
		iconRect.bottom = iy + iconSize;

		DrawBitmapAsync(fBitmap, fBitmap->Bounds(),
			iconRect, B_FILTER_BITMAP_BILINEAR);
	}

	// Draw content
	LineInfoList::iterator lIt;
	for (lIt = fLines.begin(); lIt != fLines.end(); lIt++) {
		LineInfo *l = (*lIt);
	
		SetFont(&l->font);
		DrawString(l->text.String(), l->text.Length(), l->location);
	}

	rgb_color detailCol = ui_color(B_CONTROL_BORDER_COLOR);
	detailCol = tint_color(detailCol, B_LIGHTEN_2_TINT);

	// Draw the close widget
	BRect closeRect = Bounds();
	closeRect.InsetBy(kEdgePadding, kEdgePadding);
	closeRect.left = closeRect.right - kCloseSize;
	closeRect.bottom = closeRect.top + kCloseSize;

	PushState();
		SetHighColor(detailCol);
		StrokeRoundRect(closeRect, kSmallPadding, kSmallPadding);
		BRect closeCross = closeRect.InsetByCopy(kSmallPadding, kSmallPadding);
		StrokeLine(closeCross.LeftTop(), closeCross.RightBottom());
		StrokeLine(closeCross.LeftBottom(), closeCross.RightTop());
	PopState();

	Sync();
}