예제 #1
0
void TestView::Draw(BRect /*updateRect*/)
{
	ArpD(cdb << ADH << "TestView::Draw() " << Name() << endl);
	BRect frm = Bounds();
	StrokeRect(frm);
	StrokeLine(BPoint(frm.left,frm.top),
				BPoint(frm.right,frm.bottom));
	StrokeLine(BPoint(frm.right,frm.top),
				BPoint(frm.left,frm.bottom));
}
예제 #2
0
// Draw
void
SwatchValueView::Draw(BRect updateRect)
{
	BRect b(Bounds());
	if (BView* parent = Parent()) {
		SetLowColor(tint_color(parent->LowColor(), B_DARKEN_1_TINT));
		StrokeRect(b, B_SOLID_LOW);
		b.InsetBy(1.0, 1.0);
	}
	FillRect(b);
}
예제 #3
0
파일: MarginView.cpp 프로젝트: mariuz/haiku
/**
 * Draw
 *
 * @param BRect, the draw bounds
 * @return void
 */
void
MarginView::Draw(BRect rect)
{
	BBox::Draw(rect);

	float y_offset = (float)kOffsetY;
	float x_offset = (float)kOffsetX;
	BRect r;

	// Calculate offsets depending on orientation
	if (fPageWidth < fPageHeight) { // Portrait
		x_offset = (fMaxPageWidth/2 + kOffsetX) - fViewWidth/2;
	} else { // landscape
		y_offset = (fMaxPageHeight/2 + kOffsetY) - fViewHeight/2;
	}

	// draw the page
	SetHighColor(kWhite);
	r = BRect(0, 0, fViewWidth, fViewHeight);
	r.OffsetBy(x_offset, y_offset);
	FillRect(r);
	SetHighColor(kBlack);
	StrokeRect(r);

	// draw margin
	SetHighColor(kRed);
	SetLowColor(kWhite);
	r.top += fMargins.top;
	r.right -= fMargins.right;
	r.bottom -= fMargins.bottom;
	r.left += fMargins.left;
	StrokeRect(r, kDots);

	// draw the page size label
	SetHighColor(kBlack);
	SetLowColor(kGray);
	char str[kStringSize];
	sprintf(str, "%2.1f x %2.1f", fPageWidth/fUnitValue, fPageHeight/fUnitValue);
	SetFontSize(10);
	DrawString((const char *)str, BPoint(x_offset, fMaxPageHeight + 40));
}
예제 #4
0
void
CSelectionView::Draw(BRect /*updateRect*/)
{
	BRect frame(Bounds());
		
	SetHighColor(kB_GrayTable[14]);
	StrokeRect(Bounds());
	SetHighColor(kB_GrayTable[0]);
	
	frame.InsetBy(1.0, 1.0);
	FillRect3D(this, frame, FALSE, fWindowIsActive, fText);
}
예제 #5
0
void MainView::MouseUp(BPoint point)
{
	BPoint left_top, right_bottom;
	
	if(!track_mouse) return;
	
	h_ruler->ClearSelRect(); 
	v_ruler->ClearSelRect(); 
	h_ruler->DrawRuler(); h_ruler->UpdateSlider(point);
	v_ruler->DrawRuler(); v_ruler->UpdateSlider(point);
	//Correct sel rect
	if(drag_select) {
		//single click with no sel rect
		if(point == sel_rect.LeftTop()) {
			selectFieldByPoint(point);
		}
		//sel rect
		else {
#ifdef HAIKU
			SetHighColor(ViewColor());
			StrokeRect(sel_rect);
#endif
			if(point.x <= sel_rect.LeftTop().x) {
				if(point.y <= sel_rect.LeftTop().y) {
					sel_rect.SetRightBottom(sel_rect.LeftTop());
					sel_rect.SetLeftTop(point);
				}
				else {
					left_top.x = point.x; left_top.y = sel_rect.LeftTop().y;
					right_bottom.x = sel_rect.LeftTop().x; right_bottom.y = point.y;
					sel_rect.SetRightBottom(right_bottom);
					sel_rect.SetLeftTop(left_top);
				}
			}
			else {
				if(point.y <= sel_rect.LeftTop().y) {
					left_top.x = sel_rect.LeftTop().x; left_top.y = point.y;
					right_bottom.x = point.x; right_bottom.y = sel_rect.LeftTop().y;
					sel_rect.SetRightBottom(right_bottom);
					sel_rect.SetLeftTop(left_top);
				}
				else {
					sel_rect.SetRightBottom(point);
				}
			}
			selectFieldsByRect(sel_rect);
		}
	}
	
	drag_move = false;
	drag_select = false;
	this->EndRectTracking();	
}
예제 #6
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
	{
예제 #7
0
void
ColorGradientView::Draw(BRect updateRect)
{
	BRect rect(Bounds());

	BGradientLinear gradient(rect.LeftTop(), rect.RightBottom());
	rgb_color white = make_color(255, 255, 255);
	gradient.AddColor(white, 0.0);
	gradient.AddColor(fColor, 255.0);

	FillRect(rect, gradient);
	StrokeRect(rect);
}
예제 #8
0
void MovieLooperUI::ClipListView::Draw(BRect update)
{	
	// add a highlight if needed
	if (drawHighlight)
	{
		// inherited version first
		BListView::Draw(update);
		
		// then the highlight
		rgb_color highColor = HighColor();
		SetHighColor(highlightColor);
		StrokeRect(Bounds());
		SetHighColor(highColor);
	}
	else
	{
		// the "non-highlight" (takes care of erasing)
		StrokeRect(Bounds(), B_SOLID_LOW);
		// inherited version last
		BListView::Draw(update);
	}
}
예제 #9
0
void
TranslatorListView::MouseMoved(BPoint point, uint32 transit, const BMessage *dragMessage)
{
	if (dragMessage != NULL && transit == B_ENTERED_VIEW) {
		// Draw a red box around the inside of the view
		// to tell the user that this view accepts drops
		SetHighColor(220,0,0);
	 	SetPenSize(4);
		StrokeRect(Bounds());
	 	SetHighColor(0,0,0);
	} else if (dragMessage != NULL && transit == B_EXITED_VIEW)
		Invalidate();
}
예제 #10
0
void VSplitterView::Draw(BRect update)
{
	BRect r(Bounds());
	r.bottom = r.top = (r.bottom / 2);
	r.bottom += 25;
	r.top -= 25;
	r.left += 5;
	r.right -= 5;
	
	SetHighColor(tint_color(ViewColor(),B_DARKEN_4_TINT));
	FillRect(r,B_MIXED_COLORS);
	StrokeRect(r,B_SOLID_HIGH);
}
예제 #11
0
/***********************************************************
 * Draw
 ***********************************************************/
void
HCriteriaView::Draw(BRect /*updateRect*/)
{
	BRect rect = Bounds();
	if(!IsFocus())
		SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),B_DARKEN_3_TINT));
	else
	{
		rect.InsetBy(0,1);
		SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
	}
	StrokeRect(rect);
}
예제 #12
0
void CharView::Draw(BRect urect)
{
	BPoint		point;
	font_height	fheight;
	char		utf8Char[3];
	uint16		uniChar[1];

	urect = Bounds();

//	SetLowColor(def_viewcolor);
	SetDrawingMode(B_OP_COPY);
	SetHighColor(strokeColor);
	SetPenSize(1);
	StrokeRect(urect);

	urect.InsetBy(1, 1);
	SetHighColor(bgColor);
	FillRect(urect);
	SetLowColor(bgColor);
	SetHighColor(displayColor);

	if (drawmode) {
		font.SetSize(urect.Width() * 0.6);
		font.GetHeight(&fheight);

		//  Unicode to UTF8 Character encoding
		uniChar[0] = B_HOST_TO_BENDIAN_INT16(((mutf == 0) || (mutf == 65535)) ? 1 : mutf);
		int32 state = 0;
		int32 srcLen = 2;
		int32 destLen = sizeof(utf8Char);
		convert_to_utf8(B_UNICODE_CONVERSION, (const char*)uniChar, &srcLen,
						utf8Char, &destLen, &state);

		SetFont(&font);
	
		bool hasGlyph[1];
		font.GetHasGlyphs(utf8Char, 1, hasGlyph);

		if (hasGlyph[0]) {
			float choffset = (urect.right - urect.left - StringWidth(utf8Char, destLen)) / 2;
			float cvoffset = (urect.Height() - fheight.ascent - fheight.descent) / 2 + fheight.ascent;
			point.Set(choffset, cvoffset);
			DrawString(utf8Char, destLen, point);
		}
	}

/*	printf("\nCharView!\n");
	printf("utf8Char[0]: %x\n", utf8Char[0]);
	printf("utf8Char[1]: %x\n", utf8Char[1]);
	printf("utf8Char[2]: %x\n", utf8Char[2]);*/
}
예제 #13
0
void PatternMenuView::Draw (BRect /* updateRect */)
{
	if (fPMB)
	{
		PatternMenu *pm = fPMB->getMenu();
		int numitems = pm->CountItems();
		//printf ("numitems = %i, index = %i\n", numitems, index);
		extern ColorMenuButton *locolor, *hicolor;
		SetLowColor (locolor->color());
		for (int i = 0; i < numitems; i++)
		{
			PatternItem *pmi = pm->ItemAt(i);
			BRect frame = pmi->Frame();
			SetHighColor (hicolor->color());
			frame.left++;
			frame.top++;
			FillRect (frame, pmi->getPattern());
			frame.left--;
			frame.top--;
			SetHighColor (Black);
			StrokeRect (frame);
			if (pmi->IsMarked() || index == i)
			{
				frame.right--;
				frame.bottom--;
				SetHighColor (White);
				StrokeRect (frame);
				frame.InsetBy (1, 1);
				SetHighColor (Black);
				StrokeRect (frame);
			}
		}
		Sync();
	}
	else
	{
	}
}
예제 #14
0
void
PageView::Draw(BRect bounds)
{
	BRect frame(Frame());
	float totalWidth = frame.Width();
	float totalHeight = frame.Height();

	// fit page into available space
	// keeping the ratio fPageWidth : fPageHeight
	float pageWidth = totalWidth;
	float pageHeight = totalWidth * fPageHeight / fPageWidth;
	if (pageHeight > totalHeight) {
		pageHeight = totalHeight;
		pageWidth = totalHeight * fPageWidth / fPageHeight;
	}

	// center page
	BPoint offset(0, 0);
	offset.x = static_cast<int>((totalWidth - pageWidth) / 2);
	offset.y = static_cast<int>((totalHeight - pageHeight) / 2);

	// draw the page
	SetHighColor(kWhite);
	BRect r = BRect(0, 0, pageWidth, pageHeight);
	r.OffsetBy(offset);
	FillRect(r);
	SetHighColor(kBlack);
	StrokeRect(r);

	// draw margin
	SetHighColor(kRed);
	SetLowColor(kWhite);
	r.top += (fMargins.top / fPageHeight) * pageHeight;
	r.right -= (fMargins.right / fPageWidth) * pageWidth;
	r.bottom -= (fMargins.bottom / fPageHeight) * pageHeight;
	r.left += (fMargins.left / fPageWidth) * pageWidth;
	StrokeRect(r, kDots);
}
예제 #15
0
void
BMenuField::Draw(BRect update)
{
	BRect bounds(Bounds());
	bool active = IsFocus() && Window()->IsActive();

	DrawLabel(bounds, update);

	BRect frame(fMenuBar->Frame());

	if (be_control_look != NULL) {
		frame.InsetBy(-kVMargin, -kVMargin);
		rgb_color base = fMenuBar->LowColor();
		rgb_color background = LowColor();
		uint32 flags = 0;
		if (!fMenuBar->IsEnabled())
			flags |= BControlLook::B_DISABLED;
		if (active)
			flags |= BControlLook::B_FOCUSED;
		be_control_look->DrawMenuFieldFrame(this, frame, update, base,
			background, flags);
		return;
	}

	if (frame.InsetByCopy(-kVMargin, -kVMargin).Intersects(update)) {
		SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT));
		StrokeLine(BPoint(frame.left - 1.0f, frame.top - 1.0f),
			BPoint(frame.left - 1.0f, frame.bottom - 1.0f));
		StrokeLine(BPoint(frame.left - 1.0f, frame.top - 1.0f),
			BPoint(frame.right - 1.0f, frame.top - 1.0f));

		StrokeLine(BPoint(frame.left + 1.0f, frame.bottom + 1.0f),
			BPoint(frame.right + 1.0f, frame.bottom + 1.0f));
		StrokeLine(BPoint(frame.right + 1.0f, frame.top + 1.0f));

		SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_4_TINT));
		StrokeLine(BPoint(frame.left - 1.0f, frame.bottom),
			BPoint(frame.left - 1.0f, frame.bottom));
		StrokeLine(BPoint(frame.right, frame.top - 1.0f),
			BPoint(frame.right, frame.top - 1.0f));
	}

	if (active || fTransition) {
		SetHighColor(active ? ui_color(B_KEYBOARD_NAVIGATION_COLOR) :
			ViewColor());
		StrokeRect(frame.InsetByCopy(-kVMargin, -kVMargin));

		fTransition = false;
	}
}
예제 #16
0
void
DrawButton::Draw(BRect update)
{
	if (!IsEnabled()) {
		if (fDisabled)
			DrawBitmap(fDisabled, BPoint(0,0));
		else
			StrokeRect(Bounds());
		return;
	}
	
	if (Value() == B_CONTROL_ON) {
		if (fDown)
			DrawBitmap(fDown, BPoint(0,0));
		else
			StrokeRect(Bounds());
	} else {
		if (fUp)
			DrawBitmap(fUp, BPoint(0,0));
		else
			StrokeRect(Bounds());
	}
}
예제 #17
0
void
ImageView::Draw(BRect rect)
{
	if (HasImage()) {
		// Draw black rectangle around image
		StrokeRect(
			BRect(BORDER_WIDTH - PEN_SIZE,
				BORDER_HEIGHT - PEN_SIZE,
				fpbitmap->Bounds().Width() + BORDER_WIDTH + PEN_SIZE,
				fpbitmap->Bounds().Height() + BORDER_HEIGHT + PEN_SIZE));

		DrawBitmap(fpbitmap, BPoint(BORDER_WIDTH, BORDER_HEIGHT));
	}
}
예제 #18
0
// Draw
void
FontValueView::Draw(BRect updateRect)
{
	BRect b(Bounds());
	// focus indication
	if (IsFocus()) {
		SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
		StrokeRect(b);
		b.InsetBy(1.0, 1.0);
		BRegion clipping;
		clipping.Include(b);
		ConstrainClippingRegion(&clipping);
		b.left --;
	}
	// background
	FillRect(b, B_SOLID_LOW);

	rgb_color labelColor = LowColor();
	if (fEnabled)
		labelColor = tint_color(labelColor, B_DARKEN_MAX_TINT);
	else
		labelColor = tint_color(labelColor, B_DISABLED_LABEL_TINT);

	SetHighColor(labelColor);

	b.InsetBy(2.0, 1.0);

	float center = floorf(b.top + b.Height() / 2.0);

	BPoint arrow[3];
	arrow[0] = BPoint(b.left, center - 3.0);
	arrow[1] = BPoint(b.left, center + 3.0);
	arrow[2] = BPoint(b.left + 3.0, center);

	FillPolygon(arrow, 3);

	b.left += 6.0;

	BFont font;
	GetFont(&font);

	font_height fh;
	font.GetHeight(&fh);

	BString truncated(fCurrentFont);
	font.TruncateString(&truncated, B_TRUNCATE_END, b.Width());

	DrawString(truncated.String(),
			   BPoint(b.left, floorf(center + fh.ascent / 2.0)));
}
예제 #19
0
void
View::Draw(BRect updateRect)
{
	SetHighColor(100, 100, 100);
	StrokeRect(Bounds());

	// TODO: for now, we only test scaling functionality

	SetHighColor(42, 42, 242);
	StrokeRect(BRect(5, 5, 10, 10));
#ifdef __ANTARES__
	printf("scale 1: %g\n", Scale());
#endif

	SetScale(2.0);
	StrokeRect(BRect(5, 5, 10, 10));
#ifdef __ANTARES__
	printf("scale 2: %g\n", Scale());
#endif

	SetHighColor(42, 242, 42);
	PushState();
	StrokeRect(BRect(6, 6, 11, 11));
#ifdef __ANTARES__
	printf("scale 3: %g\n", Scale());
#endif

	SetHighColor(242, 42, 42);
	SetScale(2.0);
	StrokeRect(BRect(5, 5, 10, 10));
#ifdef __ANTARES__
	printf("scale 4: %g\n", Scale());
#endif

	PopState();
	SetScale(1.0);
}
예제 #20
0
void SpinButton::Draw(BRect updateRect)
{
    BRect rect = Bounds();

    if (IsFocus()) {
        SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
        StrokeRect(rect);
    }
    else {
        DrawButton(rect, kSpinButtonNone);
    }

    DrawButton(ButtonFrame(kSpinButtonUp), kSpinButtonUp);
    DrawButton(ButtonFrame(kSpinButtonDown), kSpinButtonDown);
}
예제 #21
0
파일: Painter.cpp 프로젝트: mmanley/Antares
// StrokeRect
BRect
Painter::StrokeRect(const BRect& r, const pattern& p) const
{
	BPoint a(r.left, r.top);
	BPoint b(r.right, r.bottom);
	_Transform(&a);
	_Transform(&b);

	// first, try an optimized version
	float penSize = _Transform(fPenSize);
	if (penSize == 1.0 &&
		(fDrawingMode == B_OP_COPY || fDrawingMode == B_OP_OVER)) {
// TODO: fix me
//		pattern p = *fPatternHandler->GetR5Pattern();
		if (p == B_SOLID_HIGH) {
			BRect rect(a, b);
			StrokeRect(rect,
					   fPatternHandler->HighColor().GetColor32());
			return _Clipped(rect);
		} else if (p == B_SOLID_LOW) {
			BRect rect(a, b);
			StrokeRect(rect,
					   fPatternHandler->LowColor().GetColor32());
			return _Clipped(rect);
		}
	}

	agg::path_storage path;
	path.move_to(a.x, a.y);
	path.line_to(b.x, a.y);
	path.line_to(b.x, b.y);
	path.line_to(a.x, b.y);
	path.close_polygon();

	return _StrokePath(path, p);
}
예제 #22
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);
}
예제 #23
0
//------------------------------------------------------------------------------
void BMenuField::Draw(BRect update)
{
	BRect bounds(Bounds());
	bool active = false;

	if (IsFocus())
		active = Window()->IsActive();

	/*
	SetHighColor(0, 255, 0);
	FillRect(bounds);
	*/

	DrawLabel(bounds, update);

	BRect frame(fMenuBar->Frame());
	//rgb_color color = HighColor();

	if (frame.InsetByCopy(-2, -2).Intersects(update))
	{
		SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_2_TINT));
		StrokeLine(BPoint(frame.left - 1.0f, frame.top - 1.0f),
			BPoint(frame.left - 1.0f, frame.bottom - 1.0f));
		StrokeLine(BPoint(frame.left - 1.0f, frame.top - 1.0f),
			BPoint(frame.right - 1.0f, frame.top - 1.0f));

		StrokeLine(BPoint(frame.left + 1.0f, frame.bottom + 1.0f),
			BPoint(frame.right + 1.0f, frame.bottom + 1.0f));
		StrokeLine(BPoint(frame.right + 1.0f, frame.top + 1.0f));

		SetHighColor(tint_color(ui_color(B_MENU_BACKGROUND_COLOR), B_DARKEN_4_TINT));
		StrokeLine(BPoint(frame.left - 1.0f, frame.bottom),
			BPoint(frame.left - 1.0f, frame.bottom));
		StrokeLine(BPoint(frame.right, frame.top - 1.0f),
			BPoint(frame.right, frame.top - 1.0f));

	}

	if (active || fTransition)
	{
		SetHighColor(active ? ui_color(B_KEYBOARD_NAVIGATION_COLOR) :
			ViewColor());
		StrokeRect(frame.InsetByCopy(-kVMargin, -kVMargin));

		fTransition = false;
	}
}
예제 #24
0
void PSplitter::Draw(BRect update)
{
	BRect b(Bounds());
	
	SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_2_TINT));
	StrokeRect(b);
	b.InsetBy(1, 1);
	
	SetHighColor(kWhite);
	StrokeLine(b.LeftTop(), b.RightTop());	b.top += 1;
	SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	StrokeLine(b.LeftTop(), b.RightTop());	b.top += 1;
	SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
	StrokeLine(b.LeftTop(), b.RightTop());	b.top += 1;
	SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_2_TINT));
	StrokeLine(b.LeftTop(), b.RightTop());
} /* PSplitter::Draw */
예제 #25
0
void
Renamer::Draw(BRect updateRect)
{
	BRect LittleRect = Bounds().InsetByCopy(1.0, 1.0);

	SetHighColor(170, 170, 190);
	MovePenTo(LittleRect.RightTop());
	StrokeLine(LittleRect.LeftTop());
	StrokeLine(LittleRect.LeftBottom());

	SetHighColor(220, 220, 225);
	StrokeLine(LittleRect.RightBottom());
	StrokeLine(LittleRect.RightTop());
	
	SetHighColor(60, 80, 150);
	StrokeRect(Bounds());
}
예제 #26
0
// This method is used by DeskbarPulseView as well
void MiniPulseView::Draw(BRect rect) {
	system_info sys_info;
	get_system_info(&sys_info);
	if (sys_info.cpu_count > B_MAX_CPU_COUNT || sys_info.cpu_count <= 0)
		return;
	
	BRect bounds(Bounds());
	SetDrawingMode(B_OP_COPY);

	int h = bounds.IntegerHeight() - 2;
	float top = 1, left = 1;
	float bottom = top + h;
	float bar_width = (bounds.Width()) / sys_info.cpu_count - 2;
	float right = bar_width + left;
	
	for (int x = 0; x < sys_info.cpu_count; x++) {
		int bar_height = (int)(cpu_times[x] * (h + 1));
		if (bar_height > h) bar_height = h;
		double rem = cpu_times[x] * (h + 1) - bar_height;

		rgb_color fraction_color;
		fraction_color.red = (uint8)(idle_color.red + rem 
			* (active_color.red - idle_color.red));
		fraction_color.green = (uint8)(idle_color.green + rem 
			* (active_color.green - idle_color.green));
		fraction_color.blue = (uint8)(idle_color.blue + rem 
			* (active_color.blue - idle_color.blue));
		fraction_color.alpha = 0xff;

		int idle_height = h - bar_height;
		SetHighColor(frame_color);
		StrokeRect(BRect(left - 1, top - 1, right + 1, bottom + 1));
		if (idle_height > 0) {
			SetHighColor(idle_color);
			FillRect(BRect(left, top, right, top + idle_height - 1));
		}
		SetHighColor(fraction_color);
		FillRect(BRect(left, bottom - bar_height, right, bottom - bar_height));
		if (bar_height > 0) {
			SetHighColor(active_color);
			FillRect(BRect(left, bottom - bar_height + 1, right, bottom));
		}
		left += bar_width + 2;
		right += bar_width + 2;
	}
}
예제 #27
0
void
AudioListView::Draw(BRect rect)
{
	SetHighColor(ui_color(B_CONTROL_BACKGROUND_COLOR));

	BRect bounds(Bounds());
	BRect itemFrame = ItemFrame(CountItems() - 1);
	bounds.top = itemFrame.bottom;
	FillRect(bounds);

	BListView::Draw(rect);

	if (fDropRect.IsValid()) {
		SetHighColor(255, 0, 0, 255);
		StrokeRect(fDropRect);
	}
}
예제 #28
0
void TStageMovieCue::DrawSelectionRect()
{
	rgb_color saveColor;
	saveColor = HighColor();
	
	SetHighColor(kRed);
	
	// Draw main selection rect 
	//BRect frame = Bounds();
	//frame.InsetBy(kBorder/2, kBorder/2);
	//StrokeRect(frame);	
	
	// Draw resizing handles
	//
	
	// Fill them first...
	SetHighColor(kWhite);	
	FillRect(m_TopLeftResize);
	FillRect(m_TopMiddleResize);
	FillRect(m_TopRightResize);
	FillRect(m_RightMiddleResize);
	FillRect(m_BottomRightResize);
	FillRect(m_BottomMiddleResize);
	FillRect(m_BottomLeftResize);
	FillRect(m_LeftMiddleResize);
	
	// Now stroke...	
	SetHighColor(kBlack);
	StrokeRect(m_TopLeftResize);
	StrokeRect(m_TopMiddleResize);
	StrokeRect(m_TopRightResize);
	StrokeRect(m_RightMiddleResize);
	StrokeRect(m_BottomRightResize);
	StrokeRect(m_BottomMiddleResize);
	StrokeRect(m_BottomLeftResize);
	StrokeRect(m_LeftMiddleResize);
				
}		
예제 #29
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);
}
예제 #30
0
void TToolTipView::Draw(BRect /* where */)
{
	char		*src_strings[1];
	char		*tmp_string;
	char		*truncated_strings[1];
	BFont		font;
	BRect		r = Bounds();
	font_height	finfo;

	// draw border around window
#ifdef kDRAW_WINDOW_FRAME
	SetHighColor(0, 0, 0, 255);
	StrokeRect(r);
	r.InsetBy(1, 1);
#endif
	SetHighColor(kLIGHT_VIEW_COLOR);
	StrokeLine(BPoint(r.left, r.bottom), BPoint(r.left, r.top));
	StrokeLine(BPoint(r.left + 1, r.top), BPoint(r.right - 1, r.top));
	SetHighColor(kDARK_VIEW_COLOR);
	StrokeLine(BPoint(r.right, r.top), BPoint(r.right, r.bottom));
	StrokeLine(BPoint(r.right - 1, r.bottom), BPoint(r.left + 1, r.bottom));

	// set pen position
	GetFont(&font);
	font.GetHeight(&finfo);
	MovePenTo(kHOR_MARGIN + 1, kVER_MARGIN + finfo.ascent);

	// truncate string if needed
	src_strings[0] = fString;
	tmp_string = (char *)malloc(strlen(fString) + 16);
	truncated_strings[0] = tmp_string;
	font.GetTruncatedStrings((const char **)src_strings, 1, B_TRUNCATE_END,
		Bounds().Width() - (2 * kHOR_MARGIN) + 1, truncated_strings);

	// draw string
	SetLowColor(kVIEW_COLOR);
	SetHighColor(kTEXT_COLOR);
	DrawString(tmp_string);
	free(tmp_string);
}