status_t
CanvasMessage::ReadFontState(BFont& font)
{
	uint8 encoding, spacing;
	uint16 face;
	uint32 flags, familyAndStyle;
	font_direction direction;
	float falseBoldWidth, rotation, shear, size;

	Read(direction);
	Read(encoding);
	Read(flags);
	Read(spacing);
	Read(shear);
	Read(rotation);
	Read(falseBoldWidth);
	Read(size);
	Read(face);
	status_t result = Read(familyAndStyle);
	if (result != B_OK)
		return result;

	font.SetFamilyAndStyle(familyAndStyle);
	font.SetEncoding(encoding);
	font.SetFlags(flags);
	font.SetSpacing(spacing);
	font.SetShear(shear);
	font.SetRotation(rotation);
	font.SetFalseBoldWidth(falseBoldWidth);
	font.SetSize(size);
	font.SetFace(face);
	return B_OK;
}
Beispiel #2
0
	PartitionView(const char* name, float weight, off_t offset,
			int32 level, partition_id id)
		:
		BView(name, B_WILL_DRAW | B_SUPPORTS_LAYOUT | B_FULL_UPDATE_ON_RESIZE),
		fID(id),
		fWeight(weight),
		fOffset(offset),
		fLevel(level),
		fSelected(false),
		fMouseOver(false),
		fGroupLayout(new BGroupLayout(B_HORIZONTAL, kLayoutInset))
	{
		SetLayout(fGroupLayout);

		SetViewColor(B_TRANSPARENT_COLOR);
		rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
		base = tint_color(base, B_LIGHTEN_2_TINT);
		base = tint_color(base, 1 + 0.13 * (level - 1));
		SetLowColor(base);
		SetHighColor(tint_color(base, B_DARKEN_1_TINT));

		BFont font;
		GetFont(&font);
		font.SetSize(ceilf(font.Size() * 0.85));
		font.SetRotation(90.0);
		SetFont(&font);

		fGroupLayout->SetInsets(kLayoutInset, kLayoutInset + font.Size(),
			kLayoutInset, kLayoutInset);

		SetExplicitMinSize(BSize(font.Size() + 6, 30));
	}
Beispiel #3
0
	virtual void Draw(BRect updateRect)
	{
		if (fMouseOver) {
			float tint = (B_NO_TINT + B_LIGHTEN_1_TINT) / 2.0;
			SetHighColor(tint_color(HighColor(), tint));
			SetLowColor(tint_color(LowColor(), tint));
		}

		BRect b(Bounds());
		if (fSelected) {
			SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
			StrokeRect(b, B_SOLID_HIGH);
			b.InsetBy(1, 1);
			StrokeRect(b, B_SOLID_HIGH);
			b.InsetBy(1, 1);
		} else if (fLevel > 0) {
			StrokeRect(b, B_SOLID_HIGH);
			b.InsetBy(1, 1);
		}

		FillRect(b, B_SOLID_LOW);

		// prevent the text from moving when border width changes
		if (!fSelected)
			b.InsetBy(1, 1);

		float width;
		BFont font;
		GetFont(&font);

		font_height fh;
		font.GetHeight(&fh);

		// draw the partition label, but only if we have no child partition
		// views
		BPoint textOffset;
		if (CountChildren() > 0) {
			font.SetRotation(0.0);
			SetFont(&font);
			width = b.Width();
			textOffset = b.LeftTop();
			textOffset.x += 3;
			textOffset.y += ceilf(fh.ascent);
		} else {
			width = b.Height();
			textOffset = b.LeftBottom();
			textOffset.x += ceilf(fh.ascent);
		}

		BString name(Name());
		font.TruncateString(&name, B_TRUNCATE_END, width);

		SetHighColor(tint_color(LowColor(), B_DARKEN_4_TINT));
		DrawString(name.String(), textOffset);
	}
Beispiel #4
0
// GetBFont
BFont
Font::GetBFont() const
{
	BFont font;
	font.SetFamilyAndStyle(fFamily.String(), fStyle.String());
	font.SetSize(fSize);
	font.SetRotation(fRotation);
	font.SetShear(fShear);
	font.SetSpacing(fSpacing);
	return font;
}
Beispiel #5
0
static void testFontRotation(BView* view, BRect frame)
{
	BFont font;
	view->GetFont(&font);
	
	font.SetRotation(90);
	view->SetFont(&font, B_FONT_ROTATION);
	view->DrawString("This is a test!", BPoint(frame.Width() / 2, frame.bottom - 3));
	
	view->GetFont(&font);
	if (font.Rotation() != 90.0)
		fprintf(stderr, "Error: Rotation is %f but should be 90.0\n", font.Rotation());
}