Ejemplo n.º 1
0
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;
}
Ejemplo n.º 2
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;
}
Ejemplo n.º 3
0
/***********************************************************
 * DrawString
 ***********************************************************/
void
HToolbarButton::DrawString(BView *view ,const char* label,bool downState,bool enabled)
{
	BRect bounds = view->Bounds();
	if(NORMAL_WIDTH == bounds.Width())
		return;
	int32 x,y;
	
	BFont font;
	font.SetFamilyAndStyle("Swis721 BT","Roman");
	font.SetSize(10);
	font.SetSpacing(B_BITMAP_SPACING);
	font_height height;
	font.GetHeight(&height);
	
	float h = height.ascent + height.descent;
	y = (int32)(bounds.bottom - h + 4);
	
	float w = view->StringWidth(label);
	if(w > bounds.Width())
		x = 1;
	else{
		x = (int32)(bounds.Width() - w)/2;
	}
	
	if(downState)
	{
		x ++;
		y ++;
	}
	view->SetLowColor(bgcolor);
	/*
	if(enabled && !downState)
	{
		view->SetHighColor(237,237,237);
	
		view->SetDrawingMode(B_OP_COPY);
		font.SetFace(B_BOLD_FACE);
		view->SetFont(&font);
		view->DrawString(label,BPoint(x+1,y+1));
	}
	*/
	if(enabled)
	{
		if(!downState)	
			view->SetHighColor(Black);
		else
			view->SetHighColor(255,0,0);
	}else
		view->SetHighColor(BeDarkShadow);
	font.SetFace(B_REGULAR_FACE);
	view->SetFont(&font);
	view->DrawString(label,BPoint(x,y));
}
Ejemplo n.º 4
0
TrackMenu::TrackMenu(const BRect &frame, const char *name, BMessage *msg,
	const int32 &resize, const int32 &flags)
	: BView(frame, name, resize, flags), BInvoker(msg, NULL),
 	fCurrentItem(-1),
 	fCount(0),
 	fIsTracking(false)
{
	SetViewColor(20, 20, 20);
	
	fItemRect.Set(1, 1, 1 + StringWidth("00") + 3, Bounds().bottom - 1);
	
	BFont font;
	font.SetSize(11);
	font.SetSpacing(B_STRING_SPACING);
	SetFont(&font);
	
	font_height fh;
	GetFontHeight(&fh);
	
	fFontHeight = fh.ascent + fh.descent + fh.leading;
}