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; }
void ToolBar::SetFontSize(int const& fontSize) { fFontSize = fontSize; BFont font; GetFont(&font); font.SetSize(fFontSize); font.SetFlags(Flags() | B_FORCE_ANTIALIASING); font.SetFace(B_CONDENSED_FACE /*| B_BOLD_FACE*/); SetFont(&font); GetFontHeight(&fFontHeight); fMargin.Set(5, 3, 5, 0); fButtonMargin.Set(5, 0, 5, 2); float height = ceilf(fFontHeight.ascent + 2 * fFontHeight.descent + fMargin.top + fMargin.bottom + fButtonMargin.top + fButtonMargin.bottom); fIconWidth = height - fMargin.top - fMargin.bottom - fButtonMargin.top - fButtonMargin.bottom - fFontHeight.descent - 2; SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, height)); SetExplicitMinSize(BSize(0, height)); fGradient.SetStart(0, 0); fGradient.SetEnd(0, height); fGradient.AddColor(make_color(230, 230, 255, 255), 0); fGradient.AddColor(make_color(180, 180, 255, 255), 255); fGradientHighlight.SetStart(0, 0); fGradientHighlight.SetEnd(0, height); fGradientHighlight.AddColor(make_color(210, 210, 255, 255), 0); fGradientHighlight.AddColor(make_color(150, 150, 255, 255), 255); fGradientPressed.SetStart(0, 0); fGradientPressed.SetEnd(0, height); fGradientPressed.AddColor(make_color(180, 180, 255, 255), 0); fGradientPressed.AddColor(make_color(130, 130, 255, 255), 255); Invalidate(); }