Exemplo n.º 1
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);
}
Exemplo n.º 2
0
void TreeView::Draw (BRect updateRect)
{
	/* All-in-all drawing function (in transparent-alpha mode) */
	SetHighColor (ViewColor());
	FillRect (Bounds());
	
	SetDrawingMode (B_OP_ALPHA);
	if (isMidWay == true)
		DrawBitmapAsync (midwayBitmap);
	else	
		DrawBitmapAsync (isExpanded == false ? collapsedBitmap : expandedBitmap);	
	
	BView::Draw (updateRect);
}
Exemplo n.º 3
0
void
NetPulseView::Draw(BRect updateRect)
{
	if (fEnable) {
		SetDrawingMode(B_OP_OVER);
		if (fModemUpBitmap != NULL)
			DrawBitmapAsync(fModemUpBitmap, BPoint(0, 0));
	} else {
		SetHighColor(ViewColor());
		FillRect(updateRect);

		SetDrawingMode(B_OP_OVER);
		if (fModemDownBitmap != NULL)
			DrawBitmapAsync(fModemDownBitmap, BPoint(0, 0));
	}
}
Exemplo n.º 4
0
void
HTGAvatarView::Draw(BRect updateRect)
{
	if(avatarTweet == NULL)
		return;
	
	SetDrawingMode(B_OP_OVER);
	
	SetHighColor(000, 000, 000);
	MovePenTo(5, 17);
	DrawString("What's Happening, ");
	
	SetHighColor(051,102,152);
	DrawString(avatarTweet->getScreenName().c_str());
	
	SetHighColor(000, 000, 000);
	DrawString("?");
	
	//Draw avatar
	if(!avatarTweet->isDownloadingBitmap() && displayAvatar) {
		SetDrawingMode(B_OP_ALPHA);
		DrawBitmapAsync(avatarTweet->getBitmap(), _AvatarBounds());
		SetDrawingMode(B_OP_OVER);
	}
}
Exemplo n.º 5
0
//*****************************************************
void IndexView::Draw(BRect rect)
{
	LockLooper();

	BRect r = Bounds();
	if (Pool.update_index && !m_resized)
		CalculateCache(Bounds());

	if (m_resized)
	{
		acquire_sem(indexSem);
		// allocate offscreen bitmap here
		if (OffScreen)	{ delete OffScreen; OffScreen = NULL; }
		OffScreen = new BBitmap(r, B_RGB32);
		release_sem(indexSem);

		// recalculate caches for resized screen
		if (CalculateCache(r))
			m_resized = false;
	}

	DrawBitmapAsync( OffScreen, rect, rect);

	if (Pool.sample_type != NONE)
	{
		float x = Pool.last_pointer * Bounds().Width() / Pool.size;
		SetDrawingMode(B_OP_INVERT);
		StrokeLine( BPoint( x, 0), BPoint( x, r.bottom-1));//, B_MIXED_COLORS);
		SetDrawingMode(B_OP_COPY);
	}
	UnlockLooper();
}
Exemplo n.º 6
0
void
CPushOnButton::Draw(
	BRect updateRect)
{
	BRect r(Bounds());

	if (IsEnabled())
	{
		StdBevels::DrawBorderBevel(this, r, 
								   Value() ? StdBevels::DEPRESSED_BEVEL
								   		   : StdBevels::NORMAL_BEVEL);
	}
	else
	{
		StdBevels::DrawBorderBevel(this, r, StdBevels::DIMMED_BEVEL);
	}

	BBitmap *image = (Value() && m_glyphs[1]) ? m_glyphs[1] : m_glyphs[0];
	if (image != NULL)
	{
		BRect br(image->Bounds());

		SetDrawingMode(IsEnabled() ? B_OP_OVER : B_OP_BLEND);
		DrawBitmapAsync(image, BPoint((r.left + r.right - br.Width()) / 2,
									  (r.top + r.bottom - br.Height()) / 2));
		SetDrawingMode(B_OP_COPY);
	}
}
Exemplo n.º 7
0
	virtual void Draw(BRect updateRect)
	{
		if (fDimmedIcon) {
			SetDrawingMode(B_OP_ALPHA);
			SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
			SetHighColor(0, 0, 0, 100);
		}
		DrawBitmapAsync(&fIconBitmap);
	}
Exemplo n.º 8
0
void
VolumeSlider::Draw(BRect updateRect)
{
	SetHighColor(189,186,189);
	StrokeLine(BPoint(11,1), BPoint(fRight,1));
	SetHighColor(0,0,0);
	StrokeLine(BPoint(11,2), BPoint(fRight,2));
	SetHighColor(255,255,255);
	StrokeLine(BPoint(11,14), BPoint(fRight,14));
	SetHighColor(231,227,231);
	StrokeLine(BPoint(11,15), BPoint(fRight,15));
	
	SetLowColor(ViewColor());

	SetDrawingMode(B_OP_OVER);

	DrawBitmapAsync(&fLeftBitmap, BPoint(5,1));
	DrawBitmapAsync(&fRightBitmap, BPoint(fRight + 1,1));

	float position = 11 + (fRight - 11) * (fSoundPlayer ? fSoundPlayer->Volume() / RATIO : 0);
	SetHighColor(102,152,102);
	FillRect(BRect(11,3,position,4));
	SetHighColor(152,203,152);
	FillRect(BRect(11,5,position,13));
	
	if (fSoundPlayer)
		SetHighColor(152,152,152);
	else
		SetHighColor(200,200,200);
	FillRect(BRect(position,3,fRight,13));
	
	SetHighColor(102,152,102);
	for (int i=15; i<=fRight + 1; i+=5) {
		if (i>position)
			SetHighColor(128,128,128);
		StrokeLine(BPoint(i,8), BPoint(i,9));
	}		
		
	DrawBitmapAsync(&fButtonBitmap, BPoint(position-5,3));
	
	Sync();
	
	SetDrawingMode(B_OP_COPY);
}
Exemplo n.º 9
0
void
PatchView::Draw(BRect /* updateRect */)
{
	// draw producer icons
	SetDrawingMode(B_OP_OVER);
	int32 index = 0;
	for (list<EndpointInfo>::const_iterator i = fProducers.begin();
		i != fProducers.end(); i++) {
			const BBitmap* bitmap = (i->Icon()) ? i->Icon() : fUnknownDeviceIcon;
			DrawBitmapAsync(bitmap, RowIconFrameAt(index++).LeftTop());
	}
			
	// draw consumer icons
	index = 0;
	for (list<EndpointInfo>::const_iterator i = fConsumers.begin();
		i != fConsumers.end(); i++) {
			const BBitmap* bitmap = (i->Icon()) ? i->Icon() : fUnknownDeviceIcon;
			DrawBitmapAsync(bitmap, ColumnIconFrameAt(index++).LeftTop());
	}
}
Exemplo n.º 10
0
void
ImageView::Draw(BRect updateRect)
{
	if (fSuccess)
		DrawBitmapAsync(fImage, Bounds());
	else {
		float length = StringWidth(B_TRANSLATE("Image not loaded correctly"));
		DrawString(B_TRANSLATE("Image not loaded correctly"),
			BPoint((Bounds().Width() - length) / 2.0f, 30.0f));
	}
}
Exemplo n.º 11
0
void
SLoadingModulesView::Draw(BRect updateRect)
{
	if(bitmap)
	{
		SAutolock<BBitmap> autolock(bitmap);
		PushState();
		SetDrawingMode(B_OP_COPY);
		DrawBitmapAsync(bitmap, updateRect, updateRect);
		PopState();
	}

	DrawAfterChildren(updateRect);
}
Exemplo n.º 12
0
void
KeyboardLayoutView::Draw(BRect updateRect)
{
	if (fOldSize != BSize(Bounds().Width(), Bounds().Height())) {
		_InitOffscreen();
		_LayoutKeyboard();
	}

	BView* view;
	if (fOffscreenBitmap != NULL) {
		view = fOffscreenView;
		view->LockLooper();
	} else
		view = this;

	// Draw background

	if (Parent())
		view->SetLowColor(Parent()->ViewColor());
	else
		view->SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	view->FillRect(updateRect, B_SOLID_LOW);

	// Draw keys

	for (int32 i = 0; i < fLayout->CountKeys(); i++) {
		Key* key = fLayout->KeyAt(i);

		_DrawKey(view, updateRect, key, _FrameFor(key),
			_IsKeyPressed(key->code));
	}

	// Draw LED indicators

	for (int32 i = 0; i < fLayout->CountIndicators(); i++) {
		Indicator* indicator = fLayout->IndicatorAt(i);

		_DrawIndicator(view, updateRect, indicator, _FrameFor(indicator->frame),
			(fModifiers & indicator->modifier) != 0);
	}

	if (fOffscreenBitmap != NULL) {
		view->Sync();
		view->UnlockLooper();

		DrawBitmapAsync(fOffscreenBitmap, BPoint(0, 0));
	}
}
Exemplo n.º 13
0
void
TAlertView::Draw(BRect updateRect)
{
	// Here's the fun stuff
	if (fIconBitmap) {
		BRect stripeRect = Bounds();
		stripeRect.right = kIconStripeWidth;
		SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
		FillRect(stripeRect);

		SetDrawingMode(B_OP_ALPHA);
		DrawBitmapAsync(fIconBitmap, BPoint(18, 6));
		SetDrawingMode(B_OP_COPY);
	}
}
Exemplo n.º 14
0
void ArpTwoStateButton::Draw(BRect clip)
{
	inherited::Draw(clip);
	drawing_mode	mode = DrawingMode();
	SetDrawingMode(B_OP_ALPHA);
	SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_COMPOSITE);

	bool	state = (mDrawFromSwitched) ? mSwitched : mPressed;
	if( state && mBmPressed ) {
		BRect	r( clip );
		BRect	b( mBmPressed->Bounds() );
		if( r.right > b.right ) r.right = b.right;
		if( r.bottom > b.bottom ) r.bottom = b.bottom;
		DrawBitmapAsync( mBmPressed, r, r );
	} else if( !state && mBmNormal ) {
		BRect	r( clip );
		BRect	b( mBmNormal->Bounds() );
		if( r.right > b.right ) r.right = b.right;
		if( r.bottom > b.bottom ) r.bottom = b.bottom;
		DrawBitmapAsync( mBmNormal, r, r );
	}
	if (Window()) Sync();
	SetDrawingMode(mode);
}
Exemplo n.º 15
0
void
ToolBar::Draw(BRect updateRect)
{
    BView::Draw(updateRect);
    BRect rect = Bounds().InsetBySelf(0, 0);
    FillRect(rect, fGradient);

    for (uint i = 0; i < fButtonBounds.size(); ++i) {
        DrawBitmapAsync(fButtonIcon[i], fIconOffset[i]);
        SetHighColor(make_color(0, 0, 0, 255));
        DrawString(fButton[i], fTxtOffset[i]);
    }

    SetHighColor(make_color(180, 180, 180, 255));
    StrokeRect(rect);
}
Exemplo n.º 16
0
void
SLoadingModulesViewLight::Draw(BRect updateRect)
{
	BBitmap *bitmap = (is_red ? red_bitmap : green_bitmap);

	if(bitmap)
	{
		SAutolock<BBitmap> autolock(bitmap);
		PushState();
		SetDrawingMode(B_OP_COPY);
		DrawBitmapAsync(bitmap, updateRect, updateRect);
		PopState();
	}

	DrawAfterChildren(updateRect);
}
Exemplo n.º 17
0
void Slider::Draw (BRect rect)
{
	BRect label = BRect (0, 0, sep, height);
	if (rect.Intersects (label))	// Label needs to be redrawn
	{
		SetLowColor (LightGrey);
		SetHighColor (Black);
		FillRect (label, B_SOLID_LOW);
		DrawString (name, BPoint (0, label.bottom - 5));
	}
	offslid->Lock ();
	offview->SetHighColor (Grey21);
	offview->FillRect (bounds);
	offview->SetHighColor (Grey30);
	offview->StrokeLine (bounds.RightTop (), bounds.RightBottom ());
	offview->StrokeLine (bounds.LeftBottom ());
	offview->SetHighColor (Grey14);
	offview->StrokeLine (bounds.LeftTop ());
	offview->StrokeLine (bounds.RightTop ());
	knobpos = BPoint (float (value - min)/(max - min)*(width - knobsize), 1);
	knob = BRect (knobpos.x + 1, knobpos.y + 1, knobpos.x + knobsize - 2, knobpos.y + height - 2);
	offview->SetHighColor (Grey27);
	offview->FillRect (knob);
	offview->SetHighColor (Black);
	offview->SetLowColor (Grey27);
	offview->SetFont (be_plain_font);
	char val[KNOBVAL];
	sprintf (val, fmt, value);
	offview->DrawString (val, BPoint (knobpos.x + (knobsize - StringWidth (val))/2 + 1, knobpos.y + 12));
	offview->SetHighColor (Grey30);
	offview->StrokeLine (BPoint (knobpos.x + knobsize - 1, knobpos.y), BPoint (knobpos.x + 1, knobpos.y));
	offview->StrokeLine (BPoint (knobpos.x + 1, knobpos.y + height - 2));
	offview->SetHighColor (Grey13);
	offview->StrokeLine (BPoint (knobpos.x + knobsize - 1, knobpos.y + height - 2));
	offview->StrokeLine (BPoint (knobpos.x + knobsize - 1, knobpos.y));
	if (IsFocus())
	{
		// printf ("%s focused!\n", Name());
		BRect k (knobpos.x, knobpos.y - 1, knobpos.x + knobsize - 1, knobpos.y + height - 2);
		k.InsetBy (1, 1);
		offview->SetHighColor (ui_color (B_KEYBOARD_NAVIGATION_COLOR));
		offview->StrokeRect (k);
	}
	offview->Sync ();
	offslid->Unlock ();
	DrawBitmapAsync (offslid, BPoint (sep, 0));
}
Exemplo n.º 18
0
void
GearsView::Draw(BRect updateRect)
{
	SetHighColor(ViewColor());
	FillRect(updateRect);

	BRect stripeRect = Bounds();
	stripeRect.right = kStripeWidth;
	SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
	FillRect(stripeRect);

	if (fGears == NULL)
		return;

	SetDrawingMode(B_OP_ALPHA);
	SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
	DrawBitmapAsync(fGears, BPoint(5.0, 10.0));
}
Exemplo n.º 19
0
void
TAlertView::Draw(BRect updateRect)
{
	if (fIconBitmap == NULL)
		return;

	// Here's the fun stuff
	BRect stripeRect = Bounds();
	int32 iconLayoutScale = icon_layout_scale();
	stripeRect.right = kIconStripeWidth * iconLayoutScale;
	SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
	FillRect(stripeRect);

	SetDrawingMode(B_OP_ALPHA);
	SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
	DrawBitmapAsync(fIconBitmap, BPoint(18 * iconLayoutScale,
		6 * iconLayoutScale));
}
Exemplo n.º 20
0
void
ConflictView::Draw(BRect updateRect)
{
	// Draw background
	if (Parent())
		SetLowColor(Parent()->ViewColor());
	else
		SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	FillRect(updateRect, B_SOLID_LOW);

	if (fIcon == NULL)
		return;

	// Draw icon
	SetDrawingMode(B_OP_ALPHA);
	SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
	DrawBitmapAsync(fIcon, BPoint(0, 0));
}
Exemplo n.º 21
0
void
TransportButton::Draw(BRect)
{
    DrawBitmapAsync(bitmaps->GetBitmap(ModeMask()));
}
Exemplo n.º 22
0
void BochsView::Draw(BRect rect)
{
  DrawBitmapAsync(backing_store, rect, rect);
}
Exemplo n.º 23
0
void _AmInfoAdornment::DrawDepressedBackground(BRect r)
{
	if( prop_off_image )
		DrawBitmapAsync( prop_off_image, BPoint(0, 0) );
}
Exemplo n.º 24
0
void _AmInfoAdornment::DrawExtrudedBackground(BRect r)
{
	if( prop_on_image )
		DrawBitmapAsync( prop_on_image, BPoint(0, 0) );
}
Exemplo n.º 25
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));
}
Exemplo n.º 26
0
void AnalogView::Draw( BRect updateRect )
{
	BAutolock lock(Window());
	if(lock.IsLocked())
		DrawBitmapAsync(panel, BPoint(0, 0));
}
Exemplo n.º 27
0
void
NotificationView::Draw(BRect updateRect)
{
	BRect progRect;

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

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

	BRect stripeRect = Bounds();
	stripeRect.right = kIconStripeWidth;
	SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
		B_DARKEN_1_TINT));
	FillRect(stripeRect);

	SetHighColor(fStripeColor);
	stripeRect.right = 2;
	FillRect(stripeRect);

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

	// Draw icon
	if (fBitmap) {
		float ix = 18;
		float iy = (Bounds().Height() - iconSize) / 4.0;
			// Icon is vertically centered in view

		if (fNotification->Type() == B_PROGRESS_NOTIFICATION)
		{
			// Move icon up by half progress bar height if it's present
			iy -= (progRect.Height() + kEdgePadding);
		}

		iconRect.Set(ix, iy, ix + iconSize - 1.0, iy + iconSize - 1.0);
		DrawBitmapAsync(fBitmap, fBitmap->Bounds(), iconRect);
	}

	// Draw content
	LineInfoList::iterator lIt;
	for (lIt = fLines.begin(); lIt != fLines.end(); lIt++) {
		LineInfo *l = (*lIt);

		SetFont(&l->font);
		// Truncate the string. We have already line-wrapped the text but if
		// there is a very long 'word' we can only truncate it.
		TruncateString(&(l->text), B_TRUNCATE_END,
			Bounds().Width() - l->location.x);
		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);

	AppGroupView* groupView = dynamic_cast<AppGroupView*>(Parent());
	if (groupView != NULL && groupView->ChildrenCount() > 1)
		_DrawCloseButton(updateRect);

	SetHighColor(tint_color(ViewColor(), B_DARKEN_1_TINT));
	BPoint left(Bounds().left, Bounds().top);
	BPoint right(Bounds().right, Bounds().top);
	StrokeLine(left, right);

	Sync();
}
Exemplo n.º 28
0
void ToolbarView::Draw(BRect clip) {
	BRect 	r;
	int 	i;
	
	drawing_mode oldmode = DrawingMode();	
	SetDrawingMode(B_OP_ALPHA);
	for (i=0; i<item_count; i++) {
		r = items[i].rect;
		if (items[i].bitmap && r.Intersects(clip)) 
		{
			// We're dawing with alpha, so we need to overdraw the old bitmap
			// with the toolbar's colour, or they 'overlay' each other.
			SetHighColor(216,216,216);
			FillRect(r);
			
			if ((items[i].state & ENABLED_MASK)) {
				DrawBitmapAsync(items[i].bitmap, BPoint(r.left, r.top));
			} else {
				// Disabled icons should be greyed out.
				// We build a heavily alpha blended grey version of the icon.
				BBitmap greyedBitmap(items[i].bitmap->Bounds(), B_RGBA32);
				rgb_color *bitsFrom = static_cast<rgb_color *>(items[i].bitmap->Bits());
				rgb_color *bitsTo = static_cast<rgb_color *>(greyedBitmap.Bits());
				
				int pixels = items[i].bitmap->BitsLength()/4;
				int count;
				for(count=0; count<pixels; count++)
				{
					unsigned char shade = (bitsFrom[count].red/3) +
										  (bitsFrom[count].green/3) +
										  (bitsFrom[count].blue/3); 
					bitsTo[count].red = shade;
					bitsTo[count].green = shade;
					bitsTo[count].blue = shade;
					bitsTo[count].alpha = bitsFrom[count].alpha/4;
				}
				
				// We can't use DrawBitmapAsync, bacause the greyed bitmap is deallocated before it's
				// drawn.  We should really store they greyed versions somewhere permanent.
				DrawBitmap(&greyedBitmap, BPoint(r.left, r.top));
			}

			// Pressed icons should look like they are pressed (ie down)
			if (items[i].state & PRESSED_MASK) {
				HighLightItem(i, 2);
			}
		}
		else if (items[i].type == SEPERATOR) {
			HighLightItem(i, 1);
		}
	}
	
	// Draw a nice BeOSey border around the toolbar.
	r = Bounds();
	
	rgb_color dark={154,154,154};
	rgb_color light_dark={186,186,186};
	rgb_color light={241,241,241};

	SetDrawingMode(B_OP_COPY);

	BeginLineArray(4);
	AddLine(BPoint(r.left, r.top), BPoint(r.right, r.top), light);
	AddLine(BPoint(r.left, r.top), BPoint(r.left, r.bottom), light);
	AddLine(BPoint(r.left, r.bottom-1), BPoint(r.right, r.bottom-1), light_dark);
	AddLine(BPoint(r.left, r.bottom), BPoint(r.right, r.bottom), dark);
	
	EndLineArray();
	
	SetDrawingMode(oldmode);
}
Exemplo n.º 29
0
void
GameView::Draw(BRect rect)
{
	SetDrawingMode(B_OP_ALPHA);
	
	// Draw slots
	BPoint deckPoints[]={ BPoint(-80,4),BPoint(-80,116),BPoint(0,116),
		BPoint(0,4)};
	BPolygon* deck;
	
	for (int i=0;i<8;i++) {
		if (i==4) {
			for (int j=0;j<4;j++) {
				deckPoints[j].x+=80+4;
			}
		}
		for (int j=0;j<4;j++) {
			deckPoints[j].x+=80+4;
		}
		deck=new BPolygon(deckPoints,4);
		
		StrokePolygon(deck);
		
		if (board[i]!=NULL) {
			DrawBitmap(board[i]->img,deck->Frame());
		}
	}
	// Draw cards
	short row=0;
	short stack=0;
	
	for (short i=8;i<200;i++) {
		BBitmap* img=NULL;
		if (board[i]!=NULL) {
			img=board[i]->img;
		}
		BPoint pt(85*(stack+1),40*(row+4));
		DrawBitmapAsync(img,pt);
		row++;
		if (row==26) {
			row=0;
			stack++;
		}
	}
	Sync();
	
	// Draw Points
	
	BString movesText="";
	movesText << moves;
	
	BFont bigFont;
	bigFont.SetFace(B_BOLD_FACE);
	bigFont.SetSize(18);
	
	BFont smallFont;
	smallFont.SetSize(12);
	
	SetHighColor(255,255,255);

	SetFont(&bigFont);
	DrawString(movesText, BPoint((width+10 - bigFont.StringWidth(movesText)) / 2, height-15));

	SetFont(&smallFont);
	DrawString("Moves", BPoint((width+10   - smallFont.StringWidth("Moves")) / 2, height));
}
Exemplo n.º 30
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();
}