Exemplo n.º 1
0
// constructor
PropertyListView::PropertyListView()
	: BView(BRect(0.0, 0.0, 100.0, 100.0), NULL, B_FOLLOW_NONE,
			B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE),
	  Scrollable(),
	  BList(20),
	  fClipboard(new BClipboard("icon-o-matic properties")),

	  fPropertyM(NULL),

	  fPropertyObject(NULL),
	  fSavedProperties(new PropertyObject()),

	  fLastClickedItem(NULL),
	  fSuspendUpdates(false),

	  fMouseWheelFilter(new MouseWheelFilter(this)),
	  fTabFilter(new TabFilter(this))
{
	SetLowColor(255, 255, 255, 255);
	SetHighColor(0, 0, 0, 255);
	SetViewColor(B_TRANSPARENT_32_BIT);
}
Exemplo n.º 2
0
StatusView::StatusView(BRect frame)
	: BView(BRect(frame.left, frame.bottom - STATUS_HEIGHT, frame.right, frame.bottom), "status",
			B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM, B_WILL_DRAW)
{
	BFont font(be_plain_font);
	font_height fh;

	font.GetHeight(&fh);
	while (fh.ascent + fh.leading > STATUS_HEIGHT - 2) {
		font.SetSize(font.Size() - 2);
		font.GetHeight(&fh);
	}

	SetFont(&font);

	SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR));
#ifdef __HAIKU__
	SetViewColor(B_TRANSPARENT_COLOR);
#else
	SetViewColor(LowColor());
#endif
}
Exemplo n.º 3
0
void
BStatusBar::AttachedToWindow()
{
	// resize so that the height fits
	float width, height;
	GetPreferredSize(&width, &height);
	ResizeTo(Bounds().Width(), height);

	SetViewColor(B_TRANSPARENT_COLOR);
	rgb_color lowColor = B_TRANSPARENT_COLOR;

	BView* parent = Parent();
	if (parent != NULL)
		lowColor = parent->ViewColor();

	if (lowColor == B_TRANSPARENT_COLOR)
		lowColor = ui_color(B_PANEL_BACKGROUND_COLOR);

	SetLowColor(lowColor);

	fTextDivider = Bounds().Width();
}
WonderBrushView::WonderBrushView(const BRect &frame, const char *name,
	uint32 resize, uint32 flags, TranslatorSettings *settings)
	:	BView(frame, name, resize, flags),
		fSettings(settings)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	SetLowColor(ViewColor());

	// figure out where the text ends
	font_height fh;
	be_bold_font->GetHeight(&fh);
	float xbold, ybold;
	xbold = fh.descent + 1;
	ybold = fh.ascent + fh.descent * 2 + fh.leading;

	font_height plainh;
	be_plain_font->GetHeight(&plainh);
	float yplain;
	yplain = plainh.ascent + plainh.descent * 2 + plainh.leading;

	ResizeToPreferred();
}
Exemplo n.º 5
0
void
BControl::AttachedToWindow()
{
	rgb_color color;

	BView* parent = Parent();
	if (parent != NULL) {
		// inherit the color from parent
		color = parent->ViewColor();
		if (color == B_TRANSPARENT_COLOR)
			color = ui_color(B_PANEL_BACKGROUND_COLOR);
	} else
		color = ui_color(B_PANEL_BACKGROUND_COLOR);

	SetViewColor(color);
	SetLowColor(color);

	if (!Messenger().IsValid())
		SetTarget(Window());

	BView::AttachedToWindow();
}
Exemplo n.º 6
0
void
BMenuField::DrawLabel(BRect bounds, BRect update)
{
	CALLED();

	_ValidateLayoutData();
	font_height& fh = fLayoutData->font_info;

	if (Label()) {
		SetLowColor(ViewColor());

		// horizontal alignment
		float x;
		switch (fAlign) {
			case B_ALIGN_RIGHT:
				x = fDivider - fLayoutData->label_width - 3.0;
				break;

			case B_ALIGN_CENTER:
				x = fDivider - fLayoutData->label_width / 2.0;
				break;

			default:
				x = 0.0;
				break;
		}

		// vertical alignment
		float y = Bounds().top
			+ (Bounds().Height() + 1 - fh.ascent - fh.descent) / 2
			+ fh.ascent;
		y = floor(y + 0.5);

		SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
			IsEnabled() ? B_DARKEN_MAX_TINT : B_DISABLED_LABEL_TINT));
		DrawString(Label(), BPoint(x, y));
	}
}
Exemplo n.º 7
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
	{
	}
}
Exemplo n.º 8
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);
}
Exemplo n.º 9
0
void WatchView::Draw(BRect updateRect)
{
	super::Draw(updateRect);

	char string[5];
	sprintf(string, "@%03" B_PRId32, GetInternetTime());
	
	font_height height;         // center the text horizontally
	GetFontHeight(&height);     // and vertically in the Deskbar
	BRect rect = Bounds();
	float width = StringWidth(string);
	float x = 1 + (rect.Width() - width)/2;
	float y = height.ascent
			    + (rect.Height() - (height.ascent + height.descent))/2;

	SetHighColor(Parent()->ViewColor());
	FillRect(updateRect);

	SetLowColor(Parent()->ViewColor());
	SetHighColor(COLOR_FOREGROUND);
	SetDrawingMode(B_OP_OVER);
	DrawString(string, BPoint(x, y));
}
Exemplo n.º 10
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);
	
}
Exemplo n.º 11
0
void AnalogView::InitObject(BRect rt, int cpu)
{
	rt.OffsetTo(B_ORIGIN);
	param.cpu = cpu;

	system_info		sysInfo;
	
	get_system_info(&sysInfo);
	oldActiveTime = sysInfo.cpu_infos[cpu].active_time; 
	oldSystemTime = system_time();
	nowCPUTime = 0;
	oldCPUTime = -1;

	param.panelLength = rt.Width() / 2 - 3 * 7;
	param.needle = (rt.Width() / 2 - 3 * 7) * 0.93;
	param.meterCenter.Set(rt.Width() / 2, param.panelLength + 3 * 8);
	makeTable();
	
	makePanel(rt);

	SetViewColor(216, 216, 216);
	SetLowColor(216, 216, 216);
	SetHighColor(0, 0, 0);
}
Exemplo n.º 12
0
// Draw
void
PopupSlider::Draw(BRect updateRect)
{
	bool enabled = IsEnabled();
	rgb_color background = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color black;
	if (enabled) {
		black = tint_color(background, B_DARKEN_MAX_TINT);
	} else {
		black = tint_color(background, B_DISABLED_LABEL_TINT);
	}
	// draw label
	BRect r(Bounds());
	r.right = fSliderButtonRect.left - 1.0;
	font_height fh;
	GetFontHeight(&fh);
	BPoint textPoint(0.0, (r.top + r.bottom) / 2.0 + fh.ascent / 2.0);
	SetLowColor(background);
	SetHighColor(black);
	FillRect(r, B_SOLID_LOW);
	DrawString(fLabel.String(), textPoint);
	// draw slider button
	DrawSlider(fSliderButtonRect, enabled);
}
Exemplo n.º 13
0
// Draw
void
TrackHeaderView::Draw(BRect updateRect)
{
	rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
	BRect r(Bounds());

	SetHighColor(tint_color(base, B_DARKEN_1_TINT));
	StrokeLine(r.LeftTop(), r.RightTop());
	r.top++;

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

	r.InsetBy(5, 0);

	font_height fh;
	GetFontHeight(&fh);

	BString truncatedName(fPlaylistName);
	be_bold_font->TruncateString(&truncatedName, B_TRUNCATE_MIDDLE, r.Width());
	SetHighColor(0, 0, 0);
	BPoint pos(r.left, r.top + (r.Height() + fh.ascent) / 2.0);
	DrawString(truncatedName.String(), pos);
}
Exemplo n.º 14
0
void
ActivityView::Draw(BRect updateRect)
{
	bool drawBackground = true;
	if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0)
		drawBackground = false;

	_DrawHistory(drawBackground);

	if (!fShowLegend)
		return;

	// draw legend
	BRect legendFrame = _LegendFrame();
	if (LowUIColor() == B_NO_COLOR)
		SetLowColor(fLegendBackgroundColor);

	if (drawBackground) {
		BRect backgroundFrame(legendFrame);
		backgroundFrame.bottom += kDraggerSize;
		FillRect(backgroundFrame, B_SOLID_LOW);
	}

	BAutolock _(fSourcesLock);

	font_height fontHeight;
	GetFontHeight(&fontHeight);

	for (int32 i = 0; i < fSources.CountItems(); i++) {
		DataSource* source = fSources.ItemAt(i);
		DataHistory* values = fValues.ItemAt(i);
		BRect frame = _LegendFrameAt(legendFrame, i);

		// draw color box
		BRect colorBox = _LegendColorFrameAt(legendFrame, i);
		BRect rect = colorBox;
		uint32 flags = BControlLook::B_BLEND_FRAME;
		be_control_look->DrawTextControlBorder(this, rect,
			rect, fLegendBackgroundColor, flags);
		SetHighColor(source->Color());
		FillRect(rect);

		// show current value and label
		float y = frame.top + ceilf(fontHeight.ascent);
		int64 value = values->ValueAt(values->End());
		BString text;
		source->Print(text, value);
		float width = StringWidth(text.String());

		BString label = source->Label();
		float possibleLabelWidth = frame.right - colorBox.right - 12 - width;
		// TODO: TruncateString() is broken... remove + 5 when fixed!
		if (ceilf(StringWidth(label.String()) + 5) > possibleLabelWidth)
			label = source->ShortLabel();
		TruncateString(&label, B_TRUNCATE_MIDDLE, possibleLabelWidth);

		if (drawBackground)
			SetHighColor(ui_color(B_PANEL_TEXT_COLOR));

		if (be_control_look == NULL) {
			DrawString(label.String(), BPoint(6 + colorBox.right, y));
			DrawString(text.String(), BPoint(frame.right - width, y));
		} else {
			be_control_look->DrawLabel(this, label.String(),
				Parent()->ViewColor(), 0, BPoint(6 + colorBox.right, y));
			be_control_look->DrawLabel(this, text.String(),
				Parent()->ViewColor(), 0, BPoint(frame.right - width, y));
		}
	}
}
Exemplo n.º 15
0
// ---------------------------------------------------------------
// Constructor
//
// Sets up the view settings
//
// Preconditions:
//
// Parameters:
//
// Postconditions:
//
// Returns:
// ---------------------------------------------------------------
TIFFView::TIFFView(const char *name, uint32 flags, TranslatorSettings *settings)
	:	BView(name, flags)
{
	fSettings = settings;

	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	SetLowColor(ViewColor());

	fTitle = new BStringView("title", "TIFF Image Translator");
	fTitle->SetFont(be_bold_font);

	char detail[100];
	sprintf(detail, "Version %d.%d.%d %s",
		static_cast<int>(B_TRANSLATION_MAJOR_VERSION(TIFF_TRANSLATOR_VERSION)),
		static_cast<int>(B_TRANSLATION_MINOR_VERSION(TIFF_TRANSLATOR_VERSION)),
		static_cast<int>(B_TRANSLATION_REVISION_VERSION(TIFF_TRANSLATOR_VERSION)),
		__DATE__);
	fDetail = new BStringView("detail", detail);

	int16 i = 1;
	fLibTIFF[0] = new BStringView(NULL, "TIFF Library:");
	char libtiff[] = TIFFLIB_VERSION_STR;
    char *tok = strtok(libtiff, "\n");
    while (i < 5 && tok) {
		fLibTIFF[i] = new BStringView(NULL, tok);
		tok = strtok(NULL, "\n");
		i++;
    }

	BPopUpMenu* menu = new BPopUpMenu("pick compression");

	uint32 currentCompression = fSettings->SetGetInt32(TIFF_SETTING_COMPRESSION);
	// create the menu items with the various compression methods
	add_menu_item(menu, COMPRESSION_NONE, "None", currentCompression);
	menu->AddSeparatorItem();
	add_menu_item(menu, COMPRESSION_PACKBITS, "RLE (Packbits)", currentCompression);
	add_menu_item(menu, COMPRESSION_DEFLATE, "ZIP (Deflate)", currentCompression);
	add_menu_item(menu, COMPRESSION_LZW, "LZW", currentCompression);

// TODO: the disabled compression modes are not configured in libTIFF
//	menu->AddSeparatorItem();
//	add_menu_item(menu, COMPRESSION_JPEG, "JPEG", currentCompression);
// TODO ? - strip encoding is not implemented in libTIFF for this compression
//	add_menu_item(menu, COMPRESSION_JP2000, "JPEG2000", currentCompression);

 	fCompressionMF = new BMenuField("Use Compression:", menu, NULL);
 
 	// Build the layout
 	SetLayout(new BGroupLayout(B_VERTICAL));
 
 	i = 0;
 	AddChild(BGroupLayoutBuilder(B_VERTICAL, 7)
 		.Add(fTitle)
 		.Add(fDetail)
 		.AddGlue()
 		.Add(fCompressionMF)
 		.AddGlue()
 		.Add(fLibTIFF[0])
 		.Add(fLibTIFF[1])
 		.Add(fLibTIFF[2])
 		.Add(fLibTIFF[3])
 			// Theses 4 adding above work because we know there are 4 strings
 			// but it's fragile: one string less in the library version and the application breaks
 		.AddGlue()
 		.SetInsets(5, 5, 5, 5)
 	);
 
 	BFont font;
 	GetFont(&font);
 	SetExplicitPreferredSize(BSize((font.Size() * 350)/12, (font.Size() * 200)/12));
}
Exemplo n.º 16
0
void
TrackMenu::Draw(BRect update)
{
	rgb_color dark = {20, 20, 20, 255};
	rgb_color light = {200, 200, 200, 255};
	BPoint pt1, pt2;

	// Draw the frame
	SetHighColor(dark);
	pt1.Set(0, 0);
	pt2 = Bounds().RightTop();
	StrokeLine(pt1, pt2);

	pt2.Set(0, Bounds().bottom);
	StrokeLine(pt1, pt2);

	SetHighColor(255,255,255);
	pt1 = Bounds().RightBottom();
	pt2.Set(Bounds().right, 1);
	StrokeLine(pt1, pt2);

	pt2.Set(1,Bounds().bottom);
	StrokeLine(pt1, pt2);

	// Draw the items
	BRect r(fItemRect);

	for (int32 i = 0; i < fCount; i++) {
		// Draw the item's frame
		if (i == fCurrentItem)
			SetHighColor(dark);
		else
			SetHighColor(light);

		pt1.Set(r.left, r.top);
		pt2.Set(r.right, r.top);
		StrokeLine(pt1, pt2);

		pt2.Set(r.left, r.bottom);
		StrokeLine(pt1, pt2);

		if (i == fCurrentItem) {
			SetHighColor(light);
			pt1.Set(r.right, r.bottom);
			pt2.Set(r.right, r.top + 1);
			StrokeLine(pt1, pt2);

			pt2.Set(r.left + 1, r.bottom);
			StrokeLine(pt1, pt2);

			SetHighColor(light);
			FillRect(r.InsetByCopy(1, 1));
			SetHighColor(dark);
		}
		else if (i == fCount - 1) {
			SetHighColor(light);
			pt1.Set(r.right, r.bottom);
			pt2.Set(r.right, r.top + 1);
			StrokeLine(pt1, pt2);
		}

		// Draw the label, center justified

		BString label;
		label << (i + 1);

		BPoint labelpt;
		labelpt.x = r.left + (r.Width() - StringWidth(label.String())) / 2 + 2;
		labelpt.y = r.bottom - (r.Height() - fFontHeight + 4) / 2;

		if (i == fCurrentItem) {
			SetHighColor(dark);
			SetLowColor(light);
		} else {
			SetHighColor(light);
			SetLowColor(dark);
		}
		DrawString(label.String(), labelpt);

		// Setup for next iteration
		r.OffsetBy(r.Width() + 1, 0);

		if (r.left > Bounds().right - 2) {
			ConstrainClippingRegion(NULL);
			break;
		}

		if (r.right > Bounds().right - 2) {
			r.right = Bounds().right - 2;
			BRegion reg(r);
			ConstrainClippingRegion(&reg);
		}
	}
}
Exemplo n.º 17
0
void
ActivityView::MessageReceived(BMessage* message)
{
	// if a color is dropped, use it as background
	if (message->WasDropped()) {
		rgb_color* color;
		ssize_t size;
		if (message->FindData("RGBColor", B_RGB_COLOR_TYPE, 0,
				(const void**)&color, &size) == B_OK
			&& size == sizeof(rgb_color)) {
			BPoint dropPoint = message->DropPoint();
			ConvertFromScreen(&dropPoint);

			if (_HistoryFrame().Contains(dropPoint)) {
				fHistoryBackgroundColor = *color;
				Invalidate(_HistoryFrame());
			} else {
				// check each legend color box
				BAutolock _(fSourcesLock);

				BRect legendFrame = _LegendFrame();
				for (int32 i = 0; i < fSources.CountItems(); i++) {
					BRect frame = _LegendColorFrameAt(legendFrame, i);
					if (frame.Contains(dropPoint)) {
						fSources.ItemAt(i)->SetColor(*color);
						Invalidate(_HistoryFrame());
						Invalidate(frame);
						return;
					}
				}

				if (dynamic_cast<ActivityMonitor*>(be_app) == NULL) {
					// allow background color change in the replicant only
					fLegendBackgroundColor = *color;
					SetLowColor(fLegendBackgroundColor);
					Invalidate(legendFrame);
				}
			}
			return;
		}
	}

	switch (message->what) {
		case B_ABOUT_REQUESTED:
		{
			BAboutWindow* window = new BAboutWindow(kAppName, kSignature);

			const char* authors[] = {
				"Axel Dörfler",
				NULL
			};

			window->AddCopyright(2008, "Haiku, Inc.");
			window->AddAuthors(authors);

			window->Show();

			break;
		}
		case kMsgUpdateResolution:
		{
			int32 resolution;
			if (message->FindInt32("resolution", &resolution) != B_OK)
				break;

			_UpdateResolution(resolution, false);
			break;
		}

		case kMsgTimeIntervalUpdated:
			bigtime_t interval;
			if (message->FindInt64("interval", &interval) != B_OK)
				break;

			if (interval < 10000)
				interval = 10000;

			atomic_set64(&fRefreshInterval, interval);
			break;

		case kMsgToggleDataSource:
		{
			int32 index;
			if (message->FindInt32("index", &index) != B_OK)
				break;

			const DataSource* baseSource = DataSource::SourceAt(index);
			if (baseSource == NULL)
				break;

			DataSource* source = FindDataSource(baseSource);
			if (source == NULL)
				AddDataSource(baseSource);
			else
				RemoveDataSource(baseSource);

			Invalidate();
			break;
		}

		case kMsgToggleLegend:
			fShowLegend = !fShowLegend;
			Invalidate();
			break;

		case B_MOUSE_WHEEL_CHANGED:
		{
			float deltaY = 0.0f;
			if (message->FindFloat("be:wheel_delta_y", &deltaY) != B_OK
				|| deltaY == 0.0f)
				break;

			int32 resolution = fDrawResolution;
			if (deltaY > 0)
				resolution *= 2;
			else
				resolution /= 2;

			_UpdateResolution(resolution);
			break;
		}

		default:
			BView::MessageReceived(message);
			break;
	}
}
Exemplo n.º 18
0
void
BButton::Draw(BRect updateRect)
{
	if (be_control_look != NULL) {
		BRect rect(Bounds());
		rgb_color background = LowColor();
		rgb_color base = background;
		uint32 flags = be_control_look->Flags(this);
		if (IsDefault())
			flags |= BControlLook::B_DEFAULT_BUTTON;
		be_control_look->DrawButtonFrame(this, rect, updateRect,
			base, background, flags);
		be_control_look->DrawButtonBackground(this, rect, updateRect,
			base, flags);

		// always leave some room around the label
		rect.InsetBy(3.0, 3.0);
		be_control_look->DrawLabel(this, Label(), rect, updateRect,
			base, flags, BAlignment(B_ALIGN_CENTER, B_ALIGN_MIDDLE));
		return;
	}

	font_height fh;
	GetFontHeight(&fh);

	const BRect bounds = Bounds();
	BRect rect = bounds;

	const bool enabled = IsEnabled();
	const bool pushed = Value() == B_CONTROL_ON;
	// Default indicator
	if (IsDefault())
		rect = _DrawDefault(rect, enabled);

	BRect fillArea = rect;
	fillArea.InsetBy(3.0, 3.0);

	BString text = Label();

#if 1
	// Label truncation
	BFont font;
	GetFont(&font);
	font.TruncateString(&text, B_TRUNCATE_END, fillArea.Width() - 4);
#endif

	// Label position
	const float stringWidth = StringWidth(text.String());
	const float x = (rect.right - stringWidth) / 2.0;
	const float labelY = bounds.top
		+ ((bounds.Height() - fh.ascent - fh.descent) / 2.0)
		+ fh.ascent + 1.0;
	const float focusLineY = labelY + fh.descent;

	/* speed trick:
	   if the focus changes but the button is not pressed then we can
	   redraw only the focus line,
	   if the focus changes and the button is pressed invert the internal rect
	   this block takes care of all the focus changes
	*/
	if (IsFocusChanging()) {
		if (pushed) {
			rect.InsetBy(2.0, 2.0);
			InvertRect(rect);
		} else {
			_DrawFocusLine(x, focusLineY, stringWidth, IsFocus()
				&& Window()->IsActive());
		}

		return;
	}

	// colors
	rgb_color panelBgColor = ui_color(B_PANEL_BACKGROUND_COLOR);
	rgb_color buttonBgColor = tint_color(panelBgColor, B_LIGHTEN_1_TINT);
	rgb_color lightColor;
	rgb_color maxLightColor;

	rgb_color dark1BorderColor;
	rgb_color dark2BorderColor;

	rgb_color bevelColor1;
	rgb_color bevelColor2;
	rgb_color bevelColorRBCorner;

	rgb_color borderBevelShadow;
	rgb_color borderBevelLight;

	if (enabled) {
		lightColor = tint_color(panelBgColor, B_LIGHTEN_2_TINT);
		maxLightColor = tint_color(panelBgColor, B_LIGHTEN_MAX_TINT);

		dark1BorderColor = tint_color(panelBgColor, B_DARKEN_3_TINT);
		dark2BorderColor = tint_color(panelBgColor, B_DARKEN_4_TINT);

		bevelColor1 = tint_color(panelBgColor, B_DARKEN_2_TINT);
		bevelColor2 = panelBgColor;

		if (IsDefault()) {
			borderBevelShadow = tint_color(dark1BorderColor,
				(B_NO_TINT + B_DARKEN_1_TINT) / 2);
			borderBevelLight = tint_color(dark1BorderColor, B_LIGHTEN_1_TINT);

			borderBevelLight.red = (borderBevelLight.red + panelBgColor.red)
				/ 2;
			borderBevelLight.green = (borderBevelLight.green
				+ panelBgColor.green) / 2;
			borderBevelLight.blue = (borderBevelLight.blue
				+ panelBgColor.blue) / 2;

			dark1BorderColor = tint_color(dark1BorderColor, B_DARKEN_3_TINT);
			dark2BorderColor = tint_color(dark1BorderColor, B_DARKEN_4_TINT);

			bevelColorRBCorner = borderBevelShadow;
		} else {
			borderBevelShadow = tint_color(panelBgColor,
				(B_NO_TINT + B_DARKEN_1_TINT) / 2);
			borderBevelLight = buttonBgColor;

			bevelColorRBCorner = dark1BorderColor;
		}
	} else {
		lightColor = tint_color(panelBgColor, B_LIGHTEN_2_TINT);
		maxLightColor = tint_color(panelBgColor, B_LIGHTEN_1_TINT);

		dark1BorderColor = tint_color(panelBgColor, B_DARKEN_1_TINT);
		dark2BorderColor = tint_color(panelBgColor, B_DARKEN_2_TINT);

		bevelColor1 = panelBgColor;
		bevelColor2 = buttonBgColor;

		if (IsDefault()) {
			borderBevelShadow = dark1BorderColor;
			borderBevelLight = panelBgColor;
			dark1BorderColor = tint_color(dark1BorderColor, B_DARKEN_1_TINT);
			dark2BorderColor = tint_color(dark1BorderColor, 1.16);

		} else {
			borderBevelShadow = panelBgColor;
			borderBevelLight = panelBgColor;
		}

		bevelColorRBCorner = tint_color(panelBgColor, 1.08);;
	}

	// fill the button area
	SetHighColor(buttonBgColor);
	FillRect(fillArea);

	BeginLineArray(22);
	// bevel around external border
	AddLine(BPoint(rect.left, rect.bottom),
			BPoint(rect.left, rect.top), borderBevelShadow);
	AddLine(BPoint(rect.left + 1, rect.top),
			BPoint(rect.right, rect.top), borderBevelShadow);

	AddLine(BPoint(rect.right, rect.top + 1),
			BPoint(rect.right, rect.bottom), borderBevelLight);
	AddLine(BPoint(rect.left + 1, rect.bottom),
			BPoint(rect.right - 1, rect.bottom), borderBevelLight);

	rect.InsetBy(1.0, 1.0);

	// external border
	AddLine(BPoint(rect.left, rect.bottom),
			BPoint(rect.left, rect.top), dark1BorderColor);
	AddLine(BPoint(rect.left + 1, rect.top),
			BPoint(rect.right, rect.top), dark1BorderColor);
	AddLine(BPoint(rect.right, rect.top + 1),
			BPoint(rect.right, rect.bottom), dark2BorderColor);
	AddLine(BPoint(rect.right - 1, rect.bottom),
			BPoint(rect.left + 1, rect.bottom), dark2BorderColor);

	rect.InsetBy(1.0, 1.0);

	// Light
	AddLine(BPoint(rect.left, rect.top),
			BPoint(rect.left, rect.top), buttonBgColor);
	AddLine(BPoint(rect.left, rect.top + 1),
			BPoint(rect.left, rect.bottom - 1), lightColor);
	AddLine(BPoint(rect.left, rect.bottom),
			BPoint(rect.left, rect.bottom), bevelColor2);
	AddLine(BPoint(rect.left + 1, rect.top),
			BPoint(rect.right - 1, rect.top), lightColor);
	AddLine(BPoint(rect.right, rect.top),
			BPoint(rect.right, rect.top), bevelColor2);
	// Shadow
	AddLine(BPoint(rect.left + 1, rect.bottom),
			BPoint(rect.right - 1, rect.bottom), bevelColor1);
	AddLine(BPoint(rect.right, rect.bottom),
			BPoint(rect.right, rect.bottom), bevelColorRBCorner);
	AddLine(BPoint(rect.right, rect.bottom - 1),
			BPoint(rect.right, rect.top + 1), bevelColor1);

	rect.InsetBy(1.0, 1.0);

	// Light
	AddLine(BPoint(rect.left, rect.top),
			BPoint(rect.left, rect.bottom - 1), maxLightColor);
	AddLine(BPoint(rect.left, rect.bottom),
			BPoint(rect.left, rect.bottom), buttonBgColor);
	AddLine(BPoint(rect.left + 1, rect.top),
			BPoint(rect.right - 1, rect.top), maxLightColor);
	AddLine(BPoint(rect.right, rect.top),
			BPoint(rect.right, rect.top), buttonBgColor);
	// Shadow
	AddLine(BPoint(rect.left + 1, rect.bottom),
			BPoint(rect.right, rect.bottom), bevelColor2);
	AddLine(BPoint(rect.right, rect.bottom - 1),
			BPoint(rect.right, rect.top + 1), bevelColor2);

	rect.InsetBy(1.0,1.0);

	EndLineArray();

	// Invert if clicked
	if (enabled && pushed) {
		rect.InsetBy(-2.0, -2.0);
		InvertRect(rect);
	}

	// Label color
	if (enabled) {
		if (pushed) {
			SetHighColor(maxLightColor);
			SetLowColor(255 - buttonBgColor.red,
						255 - buttonBgColor.green,
						255 - buttonBgColor.blue);
		} else {
			SetHighColor(ui_color(B_CONTROL_TEXT_COLOR));
			SetLowColor(buttonBgColor);
		}
	} else {
		SetHighColor(tint_color(panelBgColor, B_DISABLED_LABEL_TINT));
		SetLowColor(buttonBgColor);
	}

	// Draw the label
	DrawString(text.String(), BPoint(x, labelY));

	// Focus line
	if (enabled && IsFocus() && Window()->IsActive() && !pushed)
		_DrawFocusLine(x, focusLineY, stringWidth, true);
}
Exemplo n.º 19
0
void
CalcView::Draw(BRect updateRect)
{
	bool drawBackground = true;
	if (Parent() && (Parent()->Flags() & B_DRAW_ON_CHILDREN) != 0) {
		// CalcView is embedded somewhere, most likely the Tracker Desktop
		// shelf.
		drawBackground = false;
	}

	SetHighColor(fBaseColor);
	BRect expressionRect(_ExpressionRect());
	if (updateRect.Intersects(expressionRect)) {
		if (fOptions->keypad_mode == KEYPAD_MODE_COMPACT
			&& expressionRect.Height() >= fCalcIcon->Bounds().Height()) {
			// render calc icon
			expressionRect.left = fExpressionTextView->Frame().right + 2;
			if (drawBackground) {
				SetHighColor(fBaseColor);
				FillRect(updateRect & expressionRect);
			}

			if (fCalcIcon->ColorSpace() == B_RGBA32) {
				SetDrawingMode(B_OP_ALPHA);
				SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
			} else {
				SetDrawingMode(B_OP_OVER);
			}

			BPoint iconPos;
			iconPos.x = expressionRect.right - (expressionRect.Width()
				+ fCalcIcon->Bounds().Width()) / 2.0;
			iconPos.y = expressionRect.top + (expressionRect.Height()
				- fCalcIcon->Bounds().Height()) / 2.0;
			DrawBitmap(fCalcIcon, iconPos);

			SetDrawingMode(B_OP_COPY);
		}

		// render border around expression text view
		expressionRect = fExpressionTextView->Frame();
		expressionRect.InsetBy(-2, -2);
		if (fOptions->keypad_mode != KEYPAD_MODE_COMPACT && drawBackground) {
			expressionRect.InsetBy(-2, -2);
			StrokeRect(expressionRect);
			expressionRect.InsetBy(1, 1);
			StrokeRect(expressionRect);
			expressionRect.InsetBy(1, 1);
		}

		if (be_control_look != NULL) {
			uint32 flags = 0;
			if (!drawBackground)
				flags |= BControlLook::B_BLEND_FRAME;
			be_control_look->DrawTextControlBorder(this, expressionRect,
				updateRect, fBaseColor, flags);
		} else {
			BeginLineArray(8);

			rgb_color lightShadow = tint_color(fBaseColor, B_DARKEN_1_TINT);
			rgb_color darkShadow = tint_color(fBaseColor, B_DARKEN_3_TINT);

			AddLine(BPoint(expressionRect.left, expressionRect.bottom),
					BPoint(expressionRect.left, expressionRect.top),
					lightShadow);
			AddLine(BPoint(expressionRect.left + 1, expressionRect.top),
					BPoint(expressionRect.right, expressionRect.top),
					lightShadow);
			AddLine(BPoint(expressionRect.right, expressionRect.top + 1),
					BPoint(expressionRect.right, expressionRect.bottom),
					fLightColor);
			AddLine(BPoint(expressionRect.left + 1, expressionRect.bottom),
					BPoint(expressionRect.right - 1, expressionRect.bottom),
					fLightColor);

			expressionRect.InsetBy(1, 1);
			AddLine(BPoint(expressionRect.left, expressionRect.bottom),
					BPoint(expressionRect.left, expressionRect.top),
					darkShadow);
			AddLine(BPoint(expressionRect.left + 1, expressionRect.top),
					BPoint(expressionRect.right, expressionRect.top),
					darkShadow);
			AddLine(BPoint(expressionRect.right, expressionRect.top + 1),
					BPoint(expressionRect.right, expressionRect.bottom),
					fBaseColor);
			AddLine(BPoint(expressionRect.left + 1, expressionRect.bottom),
					BPoint(expressionRect.right - 1, expressionRect.bottom),
					fBaseColor);

			EndLineArray();
		}
	}

	if (fOptions->keypad_mode == KEYPAD_MODE_COMPACT)
		return;

	// calculate grid sizes
	BRect keypadRect(_KeypadRect());

	if (be_control_look != NULL) {
		if (drawBackground)
			StrokeRect(keypadRect);
		keypadRect.InsetBy(1, 1);
	}

	float sizeDisp = keypadRect.top;
	float sizeCol = (keypadRect.Width() + 1) / (float)fColumns;
	float sizeRow = (keypadRect.Height() + 1) / (float)fRows;

	if (!updateRect.Intersects(keypadRect))
		return;

	SetFontSize(min_c(sizeRow * kFontScaleY, sizeCol * kFontScaleX));

	if (be_control_look != NULL) {
		CalcKey* key = fKeypad;
		for (int row = 0; row < fRows; row++) {
			for (int col = 0; col < fColumns; col++) {
				BRect frame;
				frame.left = keypadRect.left + col * sizeCol;
				frame.right = keypadRect.left + (col + 1) * sizeCol - 1;
				frame.top = sizeDisp + row * sizeRow;
				frame.bottom = sizeDisp + (row + 1) * sizeRow - 1;

				if (drawBackground) {
					SetHighColor(fBaseColor);
					StrokeRect(frame);
				}
				frame.InsetBy(1, 1);

				uint32 flags = 0;
				if (!drawBackground)
					flags |= BControlLook::B_BLEND_FRAME;
				if (key->flags != 0)
					flags |= BControlLook::B_ACTIVATED;
				flags |= BControlLook::B_IGNORE_OUTLINE;

				be_control_look->DrawButtonFrame(this, frame, updateRect,
					fBaseColor, fBaseColor, flags);

				be_control_look->DrawButtonBackground(this, frame, updateRect,
					fBaseColor, flags);

				be_control_look->DrawLabel(this, key->label, frame, updateRect,
					fBaseColor, flags, BAlignment(B_ALIGN_HORIZONTAL_CENTER,
						B_ALIGN_VERTICAL_CENTER));

				key++;
			}
		}
		return;
	}

	// TODO: support pressed keys

	// paint keypad b/g
	SetHighColor(fBaseColor);
	FillRect(updateRect & keypadRect);

	// render key main grid
	BeginLineArray(((fColumns + fRows) << 1) + 1);

	// render cols
	AddLine(BPoint(0.0, sizeDisp),
			BPoint(0.0, fHeight),
			fLightColor);
	for (int col = 1; col < fColumns; col++) {
		AddLine(BPoint(col * sizeCol - 1.0, sizeDisp),
				BPoint(col * sizeCol - 1.0, fHeight),
				fDarkColor);
		AddLine(BPoint(col * sizeCol, sizeDisp),
				BPoint(col * sizeCol, fHeight),
				fLightColor);
	}
	AddLine(BPoint(fColumns * sizeCol, sizeDisp),
			BPoint(fColumns * sizeCol, fHeight),
			fDarkColor);

	// render rows
	for (int row = 0; row < fRows; row++) {
		AddLine(BPoint(0.0, sizeDisp + row * sizeRow - 1.0),
				BPoint(fWidth, sizeDisp + row * sizeRow - 1.0),
				fDarkColor);
		AddLine(BPoint(0.0, sizeDisp + row * sizeRow),
				BPoint(fWidth, sizeDisp + row * sizeRow),
				fLightColor);
	}
	AddLine(BPoint(0.0, sizeDisp + fRows * sizeRow),
			BPoint(fWidth, sizeDisp + fRows * sizeRow),
			fDarkColor);

	// main grid complete
	EndLineArray();

	// render key symbols
	float halfSizeCol = sizeCol * 0.5f;
	SetHighColor(fButtonTextColor);
	SetLowColor(fBaseColor);
	SetDrawingMode(B_OP_COPY);

	float baselineOffset = ((fHeight - sizeDisp) / (float)fRows)
							* (1.0 - kFontScaleY) * 0.5;
	CalcKey* key = fKeypad;
	for (int row = 0; row < fRows; row++) {
		for (int col = 0; col < fColumns; col++) {
			float halfSymbolWidth = StringWidth(key->label) * 0.5f;
			DrawString(key->label,
				BPoint(col * sizeCol + halfSizeCol - halfSymbolWidth,
				sizeDisp + (row + 1) * sizeRow - baselineOffset));
			key++;
		}
	}
}
Exemplo n.º 20
0
void
BStatusBar::Draw(BRect updateRect)
{
	rgb_color shineColor = ui_color(B_SHINE_COLOR);
	rgb_color shadowColor = ui_color(B_SHADOW_COLOR);
	rgb_color barColor = ui_color(B_STATUSBAR_COLOR);

	BFont font;
	font_height fontHeight;

	GetFont(&font);
	font.GetHeight(&fontHeight);
	float sHeight = fontHeight.ascent + fontHeight.descent;

	if (!IsEnabled()) {
		shineColor.disable(ViewColor());
		shadowColor.disable(ViewColor());
		barColor.disable(ViewColor());
	}

	BPoint penLocation;

	MovePenTo(B_ORIGIN);
	MovePenBy(0, fontHeight.ascent + 1);

	if (fLabel != NULL) {
		if (!IsEnabled()) MovePenBy(1, 1);
		penLocation = PenLocation();

		SetHighColor(IsEnabled() ? ui_color(B_PANEL_TEXT_COLOR) : ui_color(B_SHINE_COLOR).disable(ViewColor()));
		SetLowColor(ViewColor());
		DrawString(fLabel);

		if (!IsEnabled()) {
			SetHighColor(ui_color(B_SHADOW_COLOR).disable(ViewColor()));
			DrawString(fLabel, penLocation - BPoint(1, 1));
		}

		MovePenBy(font.Spacing() * font.Size(), 0);
	}

	if (fText != NULL) {
		if (!IsEnabled()) MovePenBy(1, 1);
		penLocation = PenLocation();

		SetHighColor(IsEnabled() ? ui_color(B_PANEL_TEXT_COLOR) : ui_color(B_SHINE_COLOR).disable(ViewColor()));
		SetLowColor(ViewColor());
		DrawString(fText);

		if (!IsEnabled()) {
			SetHighColor(ui_color(B_SHADOW_COLOR).disable(ViewColor()));
			DrawString(fText, penLocation - BPoint(1, 1));
		}
	}

	MovePenTo(Frame().Width(), 0);
	MovePenBy(0, fontHeight.ascent + 1);

	if (fTrailingLabel != NULL) {
		MovePenBy(-(font.StringWidth(fTrailingLabel) + 1), 0);
		if (!IsEnabled()) MovePenBy(1, 1);
		penLocation = PenLocation();

		SetHighColor(IsEnabled() ? ui_color(B_PANEL_TEXT_COLOR) : ui_color(B_SHINE_COLOR).disable(ViewColor()));
		SetLowColor(ViewColor());
		DrawString(fTrailingLabel);

		if (!IsEnabled()) {
			SetHighColor(ui_color(B_SHADOW_COLOR).disable(ViewColor()));
			penLocation -= BPoint(1, 1);
			DrawString(fTrailingLabel, penLocation);
		}

		MovePenTo(penLocation + BPoint(-(font.Spacing() * font.Size()), 0));
	}

	if (fTrailingText != NULL) {
		MovePenBy(-(font.StringWidth(fTrailingText) + 1), 0);
		if (!IsEnabled()) MovePenBy(1, 1);
		penLocation = PenLocation();

		SetHighColor(IsEnabled() ? ui_color(B_PANEL_TEXT_COLOR) : ui_color(B_SHINE_COLOR).disable(ViewColor()));
		SetLowColor(ViewColor());
		DrawString(fTrailingText);

		if (!IsEnabled()) {
			SetHighColor(ui_color(B_SHADOW_COLOR).disable(ViewColor()));
			DrawString(fTrailingText, penLocation - BPoint(1, 1));
		}
	}

	BRect rect = Frame().OffsetToSelf(B_ORIGIN);
	if (fLabel != NULL || fTrailingLabel != NULL || fText != NULL || fTrailingText != NULL) rect.top += sHeight + 5;
	if (rect.IsValid() == false) return;

	rect.bottom = rect.top + fBarHeight;
	SetHighColor(shineColor.mix_copy(0, 0, 0, 5));
	FillRect(rect);
	SetHighColor(shineColor);
	StrokeRect(rect);
	SetHighColor(shadowColor);
	StrokeLine(rect.LeftBottom(), rect.RightBottom());
	StrokeLine(rect.RightTop());

	rect.InsetBy(1, 1);
	if (rect.IsValid() == false) return;

	BRect barRect = rect;
	SetHighColor(barColor);
	if (fCurrentValue < fMaxValue) barRect.right = barRect.left + barRect.Width() * fCurrentValue / fMaxValue;
	FillRect(barRect);
}
Exemplo n.º 21
0
void
TermView::Draw(BRect updateRect)
{
	VTermRect updatedChars = _PixelsToGlyphs(updateRect);

	VTermPos pos;
	font_height height;
	GetFontHeight(&height);

	VTermPos cursorPos;
	vterm_state_get_cursorpos(vterm_obtain_state(fTerm), &cursorPos);

	for (pos.row = updatedChars.start_row; pos.row <= updatedChars.end_row;
			pos.row++) {
		int x = updatedChars.start_col * fFontWidth + kBorderSpacing;
		int y = pos.row * fFontHeight + (int)ceil(height.ascent)
			+ kBorderSpacing;
		MovePenTo(x, y);

		BString string;
		VTermScreenCell cell;
		int width = 0;
		bool isCursor = false;

		pos.col = updatedChars.start_col;
		_GetCell(pos, cell);

		for (pos.col = updatedChars.start_col;
				pos.col <= updatedChars.end_col;) {

			VTermScreenCell newCell;
			_GetCell(pos, newCell);

			// We need to start a new extent if:
			// - The attributes change
			// - The colors change
			// - The end of line is reached
			// - The current cell is under the cursor
			// - The current cell is right of the cursor
			if (*(uint32_t*)&cell.attrs != *(uint32_t*)&newCell.attrs
				|| !vterm_color_equal(cell.fg, newCell.fg)
				|| !vterm_color_equal(cell.bg, newCell.bg)
				|| pos.col >= updatedChars.end_col
				|| (pos.col == cursorPos.col && pos.row == cursorPos.row)
				|| (pos.col == cursorPos.col + 1 && pos.row == cursorPos.row)) {

				rgb_color foreground, background;
				foreground.red = cell.fg.red;
				foreground.green = cell.fg.green;
				foreground.blue = cell.fg.blue;
				foreground.alpha = 255;
				background.red = cell.bg.red;
				background.green = cell.bg.green;
				background.blue = cell.bg.blue;
				background.alpha = 255;

				// Draw the cursor by swapping foreground and background colors
				if (isCursor) {
					SetLowColor(foreground);
					SetViewColor(foreground);
					SetHighColor(background);
				} else {
					SetLowColor(background);
					SetViewColor(background);
					SetHighColor(foreground);
				}

				FillRect(BRect(x, y - ceil(height.ascent) + 1,
					x + width * fFontWidth - 1,
					y + ceil(height.descent) + ceil(height.leading)),
					B_SOLID_LOW);

				BFont font = be_fixed_font;
				if (cell.attrs.bold)
					font.SetFace(B_BOLD_FACE);
				if (cell.attrs.underline)
					font.SetFace(B_UNDERSCORE_FACE);
				if (cell.attrs.italic)
					font.SetFace(B_ITALIC_FACE);
				if (cell.attrs.blink) // FIXME make it actually blink
					font.SetFace(B_OUTLINED_FACE);
				if (cell.attrs.reverse)
					font.SetFace(B_NEGATIVE_FACE);
				if (cell.attrs.strike)
					font.SetFace(B_STRIKEOUT_FACE);

				// TODO handle "font" (alternate fonts), dwl and dhl (double size)

				SetFont(&font);
				DrawString(string);
				x += width * fFontWidth;

				// Prepare for next cell
				cell = newCell;
				string = "";
				width = 0;
			}

			if (pos.col == cursorPos.col && pos.row == cursorPos.row)
				isCursor = true;
			else
				isCursor = false;

			if (newCell.chars[0] == 0) {
				string += " ";
				pos.col ++;
				width += 1;
			} else {
				char buffer[VTERM_MAX_CHARS_PER_CELL];
				wcstombs(buffer, (wchar_t*)newCell.chars,
					VTERM_MAX_CHARS_PER_CELL);
				string += buffer;
				width += newCell.width;
				pos.col += newCell.width;
			}
		}
	}
}
Exemplo n.º 22
0
void TermView::Draw(BRect updateRect)
{
	VTermRect updatedChars = PixelsToGlyphs(updateRect);
	
	VTermPos pos;
	font_height height;
	GetFontHeight(&height);

	int availableRows, availableCols;
	vterm_get_size(fTerm, &availableRows, &availableCols);

	for (pos.row = updatedChars.start_row; pos.row <= updatedChars.end_row;
			pos.row++) {
		float x = updatedChars.start_col * fFontWidth + kBorderSpacing;
		float y = pos.row * fFontHeight + height.ascent + kBorderSpacing + 1;
		MovePenTo(x, y);

		for (pos.col = updatedChars.start_col;
				pos.col <= updatedChars.end_col;) {
			VTermScreenCell cell;

			if (pos.col < 0 || pos.row < 0 || pos.col >= availableCols 
					|| pos.row >= availableRows) {

				// All cells outside the used terminal area are drawn with the
				// same background color as the top-left one.
				VTermPos firstPos;
				firstPos.row = 0;
				firstPos.col = 0;
				vterm_screen_get_cell(fTermScreen, firstPos, &cell);
				cell.chars[0] = 0;
				cell.width = 1;
			} else
				vterm_screen_get_cell(fTermScreen, pos, &cell);

			rgb_color foreground, background;
			foreground.red = cell.fg.red;
			foreground.green = cell.fg.green;
			foreground.blue = cell.fg.blue;
			foreground.alpha = 255;
			background.red = cell.bg.red;
			background.green = cell.bg.green;
			background.blue = cell.bg.blue;
			background.alpha = 255;

			if(cell.attrs.reverse) {
				SetLowColor(foreground);
				SetViewColor(foreground);
				SetHighColor(background);
			} else {
				SetLowColor(background);
				SetViewColor(background);
				SetHighColor(foreground);
			}

			BPoint penLocation = PenLocation();
			FillRect(BRect(penLocation.x, penLocation.y - height.ascent,
				penLocation.x + cell.width * fFontWidth, penLocation.y + 1),
				B_SOLID_LOW);

			if (cell.chars[0] == 0) {
				DrawString(" ");
				pos.col ++;
			} else {
				char buffer[VTERM_MAX_CHARS_PER_CELL];
				wcstombs(buffer, (wchar_t*)cell.chars,
						VTERM_MAX_CHARS_PER_CELL);

				DrawString(buffer);
				pos.col += cell.width;
			}
		}
	}
}
Exemplo n.º 23
0
void TPictureCueEditorToolbar::Draw(BRect updateRect)
{
	// Setup environment
	PushState();

	BPoint startPt, endPt;

	// Fill background
	SetHighColor(kBlueGrey);
	FillRect(Bounds());

	// Frame it
	SetHighColor(kWhite);
	MovePenTo(Bounds().left, Bounds().top+1);
	endPt.Set( Bounds().right, Bounds().top+1 );
	StrokeLine(endPt);

	SetHighColor(kMediumGrey);
	MovePenTo(Bounds().left, Bounds().bottom-1);
	endPt.Set( Bounds().right, Bounds().bottom-1 );
	StrokeLine(endPt);

	SetHighColor(kBlack);
	MovePenTo(Bounds().left, Bounds().top);
	endPt.Set( Bounds().right, Bounds().top );
	StrokeLine(endPt);
	MovePenTo(Bounds().left, Bounds().bottom);
	endPt.Set( Bounds().right, Bounds().bottom );
	StrokeLine(endPt);

	// Draw text area
	SetHighColor(kBlack);
	FillRect(fDurationRect);
	BRect bounds = fDurationRect;

	SetHighColor(kTextHilite);
	startPt.Set(bounds.right, bounds.top);
	endPt.Set(bounds.right, bounds.bottom);
	StrokeLine(startPt, endPt);
	startPt.Set(bounds.right, bounds.bottom);
	endPt.Set(bounds.left+1, bounds.bottom);
	StrokeLine(startPt, endPt);
	SetHighColor(kTextShadow);
	startPt.Set(bounds.left, bounds.bottom);
	endPt.Set(bounds.left, bounds.top);
	StrokeLine(startPt, endPt);
	startPt.Set(bounds.left, bounds.top);
	endPt.Set(bounds.right-1, bounds.top);
	StrokeLine(startPt, endPt);

	// Draw text
	char durationStr[12];
	SetHighColor(kGreen);
	SetLowColor(kBlack);
	BFont font(be_plain_font);
	font.SetSize(12.0);
	SetFont(&font);
	BPoint textPt(fDurationRect.left+8, fDurationRect.top + (fDurationRect.Height()/2) + 4 );
	TimeToString(fCue->Duration(), GetCurrentTimeFormat(), durationStr, false);
	DrawString(durationStr, textPt);

	// Restore Environment
	PopState();
}
Exemplo n.º 24
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();
}
Exemplo n.º 25
0
StatusView::StatusView()
	:
	BView(NULL, B_WILL_DRAW),
	fCurrentFileInfo(NULL)
{
	SetViewColor(kPieBGColor);
	SetLowColor(kPieBGColor);

	fSizeView = new BStringView(NULL, kEmptyStr);
	fSizeView->SetExplicitMinSize(BSize(StringWidth("9999.99 GiB"),
		B_SIZE_UNSET));
	fSizeView->SetExplicitMaxSize(BSize(StringWidth("9999.99 GiB"),
		B_SIZE_UNSET));

	char testLabel[256];
	snprintf(testLabel, sizeof(testLabel), B_TRANSLATE_COMMENT("%d files",
		"For UI layouting only, use the longest plural form for your language"),
		999999);

	fCountView = new BStringView(NULL, kEmptyStr);
	float width, height;
	fCountView->GetPreferredSize(&width, &height);
	fCountView->SetExplicitMinSize(BSize(StringWidth(testLabel),
		B_SIZE_UNSET));
	fCountView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, height));

	fPathView = new BStringView(NULL, kEmptyStr);
	fPathView->GetPreferredSize(&width, &height);
	fPathView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, height));

	fRefreshBtn = new BButton(NULL, B_TRANSLATE("Scan"),
		new BMessage(kBtnRescan));

	fRefreshBtn->SetExplicitMaxSize(BSize(B_SIZE_UNSET, B_SIZE_UNLIMITED));

	BBox* divider1 = new BBox(BRect(), B_EMPTY_STRING, B_FOLLOW_ALL_SIDES,
		B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);

	BBox* divider2 = new BBox(BRect(), B_EMPTY_STRING, B_FOLLOW_ALL_SIDES,
		B_WILL_DRAW | B_FRAME_EVENTS, B_FANCY_BORDER);

	divider1->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, 1));
	divider2->SetExplicitMaxSize(BSize(1, B_SIZE_UNLIMITED));

	SetLayout(new BGroupLayout(B_VERTICAL));

	AddChild(BLayoutBuilder::Group<>(B_HORIZONTAL, 0)
		.AddGroup(B_VERTICAL, 0)
			.Add(fPathView)
			.Add(divider1)
			.AddGroup(B_HORIZONTAL, 0)
				.Add(fCountView)
				.Add(divider2)
				.Add(fSizeView)
				.End()
			.End()
		.AddStrut(kSmallHMargin)
		.Add(fRefreshBtn)
		.SetInsets(kSmallVMargin, kSmallVMargin, kSmallVMargin, kSmallVMargin)
	);
}
Exemplo n.º 26
0
//*****************************************************
void ValuesView::Draw(BRect rect)
{
	int conv[] = {0, 2, 4, 8, 8, 10, 10, 10, 20, 20, 20, 20};
	int height_div;
	BRect r = Bounds();
	char s[255];

	SetLowColor(Prefs.time_back_color);
	FillRect(r, B_SOLID_LOW);
	SetHighColor(64,64,64);
	StrokeLine(r.RightTop(), BPoint(r.right, r.bottom - TIMEBAR_HEIGHT));
	
	if (Pool.sample_type == NONE)	return;

	r.bottom -= TIMEBAR_HEIGHT;
	r.top += INDEXVIEW_HEIGHT;
	r.top += POINTER_BAR_HEIGHT;

	BFont font;
	GetFont(&font);
	font_height fh;
	font.GetHeight(&fh);
	
	SetHighColor(Prefs.time_text_color);
	DrawString("\%", BPoint(r.right - font.StringWidth("%"), INDEXVIEW_HEIGHT+POINTER_BAR_HEIGHT/2));

	switch(Pool.sample_type){
	case MONO:
		height_div = (int)ceil(r.Height()/(font.Size()*2)) & 0xfffffe;
		if (height_div>20)	height_div = 20;
		height_div = conv[height_div/2];

		for (int i=0; i<=height_div; i++){
			float y = i*r.Height()/height_div + r.top;
			if (i!=height_div){
				SetHighColor(Prefs.time_small_marks_color);
				for (int ii=1; ii<5; ii++){
					float yy = (ii*r.Height())/(height_div*5) + y;
					StrokeLine(BPoint(r.right-2, yy), BPoint(r.right-2, yy) );
				}
			}
			SetHighColor(Prefs.time_marks_color);
			StrokeLine(BPoint(r.right-5, y), BPoint(r.right-2, y) );
			sprintf(s, "%d", -(int)(ROUND((y-r.top)*200/r.Height()) - 100));
			SetHighColor(Prefs.time_text_color);
			DrawString(s, BPoint(r.right - font.StringWidth(s) - 8, y+font.Size()/2));
		}
		break;
	case STEREO:
		r.bottom = r.Height()/2.0f -0.0f +r.top;					// calc left area
		height_div = (int)ceil(r.Height()/(font.Size()*2)) & 0xfffffe;
		if (height_div>20)	height_div = 20;
		height_div = conv[height_div/2];

	for (int k=0; k<2; k++){
		for (int i=0; i<=height_div; i++){
			float y = i*r.Height()/height_div + r.top;
			if (i!=height_div){
				SetHighColor(Prefs.time_small_marks_color);
				for (int ii=1; ii<5; ii++){
					float yy = (ii*r.Height())/(height_div*5) + y;
					StrokeLine(BPoint(r.right-2, yy), BPoint(r.right-2, yy) );
				}
			}
			SetHighColor(Prefs.time_marks_color);
			StrokeLine(BPoint(r.right-5, y), BPoint(r.right-2, y) );
			if (i==height_div && k==0){}else{
				sprintf(s, "%d", -(int)(ROUND((y-r.top)*200/r.Height()) - 100));
				SetHighColor(Prefs.time_text_color);
				DrawString(s, BPoint(r.right - font.StringWidth(s) - 8, y+font.Size()/2));
			}
		}

		r.OffsetTo(0, r.bottom+0.0f);					// calc right area
		}	
	}
}
Exemplo n.º 27
0
//! Redraw the button depending on whether it's up or down
void
CPUButton::Draw(BRect rect)
{
    bool value = (bool)Value();
    SetHighColor(value ? fOnColor : fOffColor);

    if (!fReplicant) {
        SetLowColor(Parent()->LowColor());
        FillRect(Bounds(), B_SOLID_LOW);
    }

    BRect bounds = Bounds();
    if (fReplicant && !fReplicantInDeskbar) {
        bounds.bottom -= 4;
        bounds.right -= 4;
    } else if (!fReplicant) {
        bounds.bottom -= 7;
        bounds.right -= 7;
    }
    BRect color_rect(bounds);
    color_rect.InsetBy(2, 2);
    if (value) {
        color_rect.bottom -= 1;
        color_rect.right -= 1;
    }
    FillRect(bounds);

    if (value)
        SetHighColor(80, 80, 80);
    else
        SetHighColor(255, 255, 255);

    BPoint start(0, 0);
    BPoint end(bounds.right, 0);
    StrokeLine(start, end);
    end.Set(0, bounds.bottom);
    StrokeLine(start, end);

    if (value)
        SetHighColor(32, 32, 32);
    else
        SetHighColor(216, 216, 216);

    start.Set(1, 1);
    end.Set(bounds.right - 1, 1);
    StrokeLine(start, end);
    end.Set(1, bounds.bottom - 1);
    StrokeLine(start, end);

    if (value)
        SetHighColor(216, 216, 216);
    else
        SetHighColor(80, 80, 80);

    start.Set(bounds.left + 1, bounds.bottom - 1);
    end.Set(bounds.right - 1, bounds.bottom - 1);
    StrokeLine(start, end);
    start.Set(bounds.right - 1, bounds.top + 1);
    StrokeLine(start, end);

    if (value)
        SetHighColor(255, 255, 255);
    else
        SetHighColor(32, 32, 32);

    start.Set(bounds.left, bounds.bottom);
    end.Set(bounds.right, bounds.bottom);
    StrokeLine(start, end);
    start.Set(bounds.right, bounds.top);
    StrokeLine(start, end);

    if (value) {
        SetHighColor(0, 0, 0);
        start.Set(bounds.left + 2, bounds.bottom - 2);
        end.Set(bounds.right - 2, bounds.bottom - 2);
        StrokeLine(start, end);
        start.Set(bounds.right - 2, bounds.top + 2);
        StrokeLine(start, end);
    }

    // Try to keep the text centered
    BFont font;
    GetFont(&font);
    int label_width = (int)font.StringWidth(Label());
    int rect_width = bounds.IntegerWidth() - 1;
    int rect_height = bounds.IntegerHeight();
    font_height fh;
    font.GetHeight(&fh);
    int label_height = (int)fh.ascent;
    int x_pos = (int)(((double)(rect_width - label_width) / 2.0) + 0.5);
    int y_pos = (rect_height - label_height) / 2 + label_height;

    MovePenTo(x_pos, y_pos);
    SetHighColor(0, 0, 0);
    SetDrawingMode(B_OP_OVER);
    DrawString(Label());
}
Exemplo n.º 28
0
/**
 *	@brief	描画を行います。
 *	@param[in]	updateRect	描画をおこなうべき矩形
 */
void TextDiffView::DiffPaneView::Draw(BRect updateRect)
{
	if (NULL == textDiffView ||
			TextDiffView::InvalidPane == paneIndex)
	{
		return;
	}

	BFont font;
	GetFont(&font);
	
	font_height fh;
	font.GetHeight(&fh);
	float lineHeight = static_cast<float>(ceil(fh.ascent + fh.descent + fh.leading));

	int lineBegin = static_cast<int>(floor(updateRect.top / lineHeight));
	if (lineBegin < 0)
	{
		lineBegin = 0;
	}
	int lineEnd = static_cast<int>(floor((updateRect.bottom + 1) / lineHeight)) + 1;
	if (static_cast<unsigned int>(lineEnd) > textDiffView->lineInfos.size())
	{
		lineEnd = textDiffView->lineInfos.size();
	}
	int line;
	for (line = lineBegin; line < lineEnd; line++)
	{
		rgb_color oldLowColor = LowColor();
		const LineInfo& linfo = textDiffView->lineInfos[line];
		
		// 背景色描画
		rgb_color bkColor;
		bool isDrawBackground = false;
		switch (linfo.op)
		{
		case DiffOperation::Inserted:
			if (paneIndex == TextDiffView::RightPane)
			{
				bkColor = colorInserted;
			}
			else
			{
				bkColor = colorEmpty;
			}
			isDrawBackground = true;
			break;
		case DiffOperation::Deleted:
			if (paneIndex == TextDiffView::LeftPane)
			{
				bkColor = colorDeleted;
			}
			else
			{
				bkColor = colorEmpty;
			}
			isDrawBackground = true;
			break;
		case DiffOperation::Modified:
			bkColor = colorModified;
			isDrawBackground = true;
			break;
		default:
			isDrawBackground = false;
			break;
		}
		if (isDrawBackground)
		{
			SetLowColor(bkColor);
			FillRect(BRect(updateRect.left, lineHeight * line, updateRect.right, lineHeight * (line + 1) - 1), B_SOLID_LOW);
		}
		
		// テキスト描画
		if (linfo.textIndex[paneIndex] >= 0)
		{
			const Substring& paneText = textDiffView->textData[paneIndex].GetLineAt(linfo.textIndex[paneIndex]);
			drawText(font, paneText, lineHeight * line + fh.ascent);
		}
		
		SetLowColor(oldLowColor);
	}
}
Exemplo n.º 29
0
void SnowView::Draw(BRect ur)
{
	int i;
	if (!fCachedParent) {
		if (!fShowClickMe) { /* show "drag me" */
			SetLowColor(ViewColor());
			SetHighColor(0,0,0);
			SetFontSize(12);
			DrawString(B_TRANSLATE("Drag me on your desktop"B_UTF8_ELLIPSIS),
				BPoint(15,25));
			BPoint arrowHead(Bounds().RightBottom() + BPoint(-10,-10));
			StrokeLine(arrowHead, arrowHead - BPoint(7,0));
			StrokeLine(arrowHead, arrowHead - BPoint(0,7));
			StrokeLine(arrowHead, arrowHead - BPoint(12,12));
			return;
		} else {
			SetLowColor(ViewColor());
			SetHighColor(0,0,0);
			SetFontSize(12);
			DrawString(B_TRANSLATE("Click me to remove BSnow"B_UTF8_ELLIPSIS),
				BPoint(15,25));
			return;
		}
	}
	//printf("Draw()\n");
	uint32 cw = fCurrentWorkspace;
	if (fFlakes[cw] == NULL)
		return;
	/* draw the snow already fallen */
//	BRect fallenRect(Bounds());
//	fallenRect.top = fallenRect.bottom - FALLEN_HEIGHT;
//	if (ur.Intersects(fallenRect)) {
		//if (fFallenBmp->Lock()) {
		//	DrawBitmap(fFallenBmp, fallenRect);
		//	fFallenBmp->Unlock();
		//}
		int32 cnt = fFallenReg->CountRects();
//		drawing_mode oldmode = DrawingMode();
//		SetDrawingMode(B_OP_ADD);

		for (i=0; i<cnt; i++) {
			BRect r = fFallenReg->RectAt(i);
//			SetHighColor(245, 245, 245, 200);
//			FillRect(r);
//			SetHighColor(255, 255, 255, 255);
//			r.InsetBy(1,1);
			FillRect(r);
		}
//		SetDrawingMode(oldmode);
//	}
	/* draw our flakes */
	for (i=0; i<fNumFlakes; i++) {
		int pat;
		if (!ur.Contains(BRect(fFlakes[cw][i].pos-BPoint(4,4), fFlakes[cw][i].pos+BPoint(4,4))))
			continue;
		if (fFlakes[cw][i].weight == 0)
			continue;
		pat = (fFlakes[cw][i].weight>3)?1:0;
		//FillRect(BRect(fFlakes[cw][i].pos-BPoint(PAT_HOTSPOT),fFlakes[cw][i].pos-BPoint(PAT_HOTSPOT)+BPoint(7,7)), gFlakePatterns[pat]);
/*
		StrokeLine(fFlakes[cw][i].pos+BPoint(-1,-1), 
				fFlakes[cw][i].pos+BPoint(1,1));
		StrokeLine(fFlakes[cw][i].pos+BPoint(-1,1), 
				fFlakes[cw][i].pos+BPoint(1,-1));
*/
		DrawBitmap(fFlakeBitmaps[pat], fFlakes[cw][i].pos-BPoint(PAT_HOTSPOT));
	}
}
Exemplo n.º 30
0
void VisualColorControl::Draw(BRect)
{
	// ramp height is COLOR_HEIGHT - 12 pixels that are required for controls
	int32 ramp_height = COLOR_HEIGHT - 12;

	// here draw the ramps
	BRect ramp_rect = BRect(ramp_left_edge+4,6,ramp_left_edge+RAMP_WIDTH+4,6+ramp_height-1);

	DrawBitmap(ramp1,ramp1->Bounds(),ramp_rect);
	ramp_rect.OffsetBy(0,COLOR_HEIGHT);
	DrawBitmap(ramp2,ramp2->Bounds(),ramp_rect);
	ramp_rect.OffsetBy(0,COLOR_HEIGHT);
	DrawBitmap(ramp3,ramp3->Bounds(),ramp_rect);
	ramp_rect.OffsetBy(0,COLOR_HEIGHT);
	DrawBitmap(ramp4,ramp4->Bounds(),ramp_rect);

	// draw the color-plate
	BRect a_rect = BRect(Bounds().Width()-PLATE_WIDTH+2,2,Bounds().Width()-2,Bounds().Height()-2);
	SetHighColor(0,0,0);
	StrokeRect(a_rect);


	rgb_color low = ValueAsColor();
	rgb_color high = low;

	float coeff = high.alpha / 255.0;
	low.red = (uint8)(coeff*low.red);
	low.green = (uint8)(coeff*low.green);
	low.blue = (uint8)(coeff*low.blue);
	low.alpha = 255;

	high.red = (uint8)(coeff*high.red + (1-coeff)*255);
	high.green = (uint8)(coeff*high.green + (1-coeff)*255);
	high.blue = (uint8)(coeff*high.blue + (1-coeff)*255);
	high.alpha = 255;

	SetHighColor(high);
	SetLowColor(low);
	a_rect.InsetBy(1,1);
	FillRect(a_rect,HS_2X2_BLOCKS);

	// clear the previous arrows and draw new arrows
	SetHighColor(ViewColor());
	BRect bg_rect = BRect(ramp_left_edge + 0,0,ramp_left_edge + RAMP_WIDTH+8,5);
	if (previous_value_at_1 != value_at_1())
		FillRect(bg_rect);

	bg_rect.OffsetBy(0,COLOR_HEIGHT);

	if (previous_value_at_2 != value_at_2())
		FillRect(bg_rect);

	bg_rect.OffsetBy(0,COLOR_HEIGHT);

	if (previous_value_at_3 != value_at_3())
		FillRect(bg_rect);

	bg_rect.OffsetBy(0,COLOR_HEIGHT);

	if (previous_value_at_4 != value_at_4())
		FillRect(bg_rect);

	DrawPicture(down_arrow,BPoint(ramp_left_edge + (float)((value_at_1()-min_value_at_1()))/(max_value_at_1()-min_value_at_1())*RAMP_WIDTH+4,5));
	DrawPicture(down_arrow,BPoint(ramp_left_edge + (float)((value_at_2()-min_value_at_2()))/(max_value_at_2()-min_value_at_2())*RAMP_WIDTH+4,COLOR_HEIGHT+5));
	DrawPicture(down_arrow,BPoint(ramp_left_edge + (float)((value_at_3()-min_value_at_3()))/(max_value_at_3()-min_value_at_3())*RAMP_WIDTH+4,2*COLOR_HEIGHT+5));
	DrawPicture(down_arrow,BPoint(ramp_left_edge + (float)((value_at_4()-min_value_at_4()))/(max_value_at_4()-min_value_at_4())*RAMP_WIDTH+4,3*COLOR_HEIGHT+5));
	Sync();

	previous_value_at_1 = value_at_1();
	previous_value_at_2 = value_at_2();
	previous_value_at_3 = value_at_3();
	previous_value_at_4 = value_at_4();


//	DrawPicture(down_arrow,BPoint(ramp_left_edge + (float)(value_at_2())/255.0*RAMP_WIDTH+4,COLOR_HEIGHT+5));
//	DrawPicture(down_arrow,BPoint(ramp_left_edge + (float)(value_at_3())/255.0*RAMP_WIDTH+4,2*COLOR_HEIGHT+5));
}