// SetFont void Painter::SetFont(const BFont& font) { //fFont.SetFamilyAndStyle(font.GetFamily(), font.GetStyle()); fFont.SetSpacing(font.Spacing()); fFont.SetShear(font.Shear()); fFont.SetRotation(font.Rotation()); fFont.SetSize(font.Size()); _UpdateFont(); }
// constructor Font::Font(const BFont& font) : fFamily("") , fStyle("") , fSize(font.Size()) , fRotation(font.Rotation()) , fShear(font.Shear()) , fFalseBoldWidth(0.0) , fHinting(true) , fKerning(true) , fSpacing(font.Spacing()) , fCachedFontHeightValid(true) { font_family family; font_style style; font.GetFamilyAndStyle(&family, &style); fFamily = family; fStyle = style; font.GetHeight(&fCachedFontHeight); }
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); }