void CharacterWindow::_SetFont(const char* family, const char* style) { BFont font = fCharacterView->CharacterFont(); font.SetFamilyAndStyle(family, style); fCharacterView->SetCharacterFont(font); fGlyphView->SetFont(&font, B_FONT_FAMILY_AND_STYLE); }
void TeamDescriptionView::SetItem(TeamListItem* item) { fItem = item; if (item == NULL) { int32 styleStart = 0; int32 styleEnd = 0; BString text; text.SetToFormat(fInfoString, fSeconds); fInfoTextView->SetText(text); if (fRebootRunner != NULL && fSeconds < 4) { styleStart = text.FindLast('\n'); styleEnd = text.Length(); } if (styleStart != styleEnd && fInfoTextView != NULL) { BFont font; fInfoTextView->GetFont(&font); font.SetFace(B_BOLD_FACE); fInfoTextView->SetStylable(true); fInfoTextView->SetFontAndColor(styleStart, styleEnd, &font); } } else { fTeamName->SetText(item->Path()->Path()); if (item->IsSystemServer()) { if (fSysComponent->IsHidden(fSysComponent)) fSysComponent->Show(); } else { if (!fSysComponent->IsHidden(fSysComponent)) fSysComponent->Hide(); } if (item->IsRefusingToQuit()) { if (fQuitOverdue->IsHidden(fQuitOverdue)) fQuitOverdue->Show(); } else { if (!fQuitOverdue->IsHidden(fQuitOverdue)) fQuitOverdue->Hide(); } fIconView->SetIcon(item->Path()->Path()); } if (fLayout == NULL) return; if (item == NULL) fLayout->SetVisibleItem((int32)0); else fLayout->SetVisibleItem((int32)1); Invalidate(); }
bool Bookmark::Read(const char* name) { Scanner scnr(name); if (scnr.InitCheck() == B_OK) { BString s; float version; bool ok; ok = scnr.ReadName(&s) && scnr.ReadFloat(&version); if (!ok || strcmp(s.String(), "Bookmarks") != 0 || (version != 1.0 && version != 2.0) ) { REPORT(kError, 0, "Bookmarks (line %d, column %d): '%s' not a bookmarks file or wrong version!", scnr.Line(), scnr.Column(), name); return false; } while (!scnr.IsEOF()) { float level, size; bool expanded = false; BString family, style, expand; if (!(scnr.ReadFloat(&level) && level >= 1.0 && level <= 10.0)) { REPORT(kError, 0, "Bookmarks (line %d, column %d): Invalid level", scnr.Line(), scnr.Column()); return false; } if (!scnr.ReadString(&family)) { REPORT(kError, 0, "Bookmarks (line %d, column %d): Invalid font family", scnr.Line(), scnr.Column()); return false; } if (!scnr.ReadString(&style)) { REPORT(kError, 0, "Bookmarks (line %d, column %d): Invalid font style", scnr.Line(), scnr.Column()); return false; } if (!scnr.ReadFloat(&size)) { REPORT(kError, 0, "Bookmarks (line %d, column %d): Invalid font size", scnr.Line(), scnr.Column()); return false; } if (version == 2.0) { if (!scnr.ReadName(&expand) || (strcmp(expand.String(), "expanded") != 0 && strcmp(expand.String(), "collapsed") != 0)) { REPORT(kError, 0, "Bookmarks (line %d, column %d): Invalid expanded value", scnr.Line(), scnr.Column()); return false; } expanded = strcmp(expand.String(), "expanded") == 0; } if (Exists(family.String(), style.String())) { BFont font; font.SetFamilyAndStyle(family.String(), style.String()); font.SetSize(size); AddDefinition((int)level, &font, expanded); } else { REPORT(kWarning, 0, "Bookmarks (line %d, column %d): Font %s-%s not available!", scnr.Line(), scnr.Column(), family.String(), style.String()); } scnr.SkipSpaces(); } return true; } else { REPORT(kError, 0, "Bookmarks: Could not open bookmarks file '%d'", name); } return false; }
float BStringColumn::GetPreferredWidth(BField *_field, BView* parent) const { BStringField* field = static_cast<BStringField*>(_field); BFont font; parent->GetFont(&font); float width = font.StringWidth(field->String()) + 2 * kTEXT_MARGIN; float parentWidth = BTitledColumn::GetPreferredWidth(_field, parent); return max_c(width, parentWidth); }
/*static*/ int32 DataView::WidthForFontSize(float size) { BFont font = be_fixed_font; font.SetSize(size); float charWidth = font.StringWidth("w"); return (int32)ceilf(charWidth * (kBlockSize * 4 + kPositionLength + 6) + 2 * kHorizontalSpace); }
SmallButton(const char* label, BMessage* message = NULL) : BButton(label, message) { BFont font; GetFont(&font); float size = ceilf(font.Size() * 0.8); font.SetSize(max_c(8, size)); SetFont(&font, B_FONT_SIZE); }
void TSorterListItem::Update(BView *owner, const BFont *font) { // This is a cheap hack to get the height of the listItem set // properly. We aren't actually using a font this large. BFont theFont; owner->GetFont(&theFont); theFont.SetSize(kSorterFontSize + 6); BListItem::Update(owner, &theFont); }
void MultiLineStringView::GetPreferredSize(float *width, float *height) { BFont font; font_height fh; GetFont(&font); font.GetHeight(&fh); *width = fWidth; *height = (fLines.size() + 1) * (fh.ascent + fh.leading + fh.descent); };
void FieldView::Draw(BRect update) { if (fPauseMode) { SetHighColor(128,128,128); FillRect(Bounds()); SetHighColor(255,255,255); SetDrawingMode(B_OP_ALPHA); BFont font; font.SetSize(28.0); font_height fh; font.GetHeight(&fh); float width = font.StringWidth(B_TRANSLATE("PAUSED")); SetFont(&font); float y = (Bounds().Height() / 3) + fh.ascent; DrawString(B_TRANSLATE("PAUSED"),BPoint( (Bounds().Width() - width) / 2.0,y)); SetFont(be_plain_font); y += fh.descent + fh.leading + 10.0; width = be_plain_font->StringWidth(B_TRANSLATE("Click to resume")); DrawString(B_TRANSLATE("Click to resume"),BPoint( (Bounds().Width() - width) / 2.0,y)); } else { // The corresponding box numbers for the update rectangle uint16 leftx,rightx,topy,bottomy; BRect r = gGameStyle->TileSize(); // We have to do this because of a bug in BRect::Width()/Height() // A rect of (0,0,23,23) will return a Width/Height of 23, not 24. int32 tilewidth = r.IntegerWidth() + 1; int32 tileheight = r.IntegerHeight() + 1; leftx = uint16(update.left / tilewidth); rightx = uint16(update.right / tilewidth); topy = uint16(update.top / tileheight); bottomy = uint16(update.bottom / tileheight); for (uint16 y = topy; y <= bottomy; y++) for (uint16 x = leftx; x <= rightx; x++) { bool down = false; if (fTracking && fSelection.x == x && fSelection.y == y) down = true; DrawBox(x,y, down); } if (gGameState == GAME_OVER) { SetHighColor(64,64,64,72); FillRect(Bounds()); } } }
void MediaFileInfoView::Draw(BRect /*update*/) { font_height fh; GetFontHeight(&fh); BPoint p(2, fh.ascent + fh.leading); BFont font; GetFont(&font); font.SetFace(B_BOLD_FACE); font.SetSize(12); SetFont(&font); if (fMediaFile == NULL) { DrawString(NO_FILE_LABEL, p); return; } BString aFmt, vFmt, aDetails, vDetails, duration; _GetFileInfo(&aFmt, &vFmt, &aDetails, &vDetails, &duration); // draw filename DrawString(fRef.name, p); float lineHeight = fh.ascent + fh.descent + fh.leading; p.y += (float)ceil(lineHeight * 1.5); float durLen = StringWidth(DURATION_LABEL) + 5; float audLen = StringWidth(AUDIO_INFO_LABEL) + 5; float vidLen = StringWidth(VIDEO_INFO_LABEL) + 5; float maxLen = MAX(durLen, audLen); maxLen = MAX(maxLen, vidLen); // draw labels DrawString(AUDIO_INFO_LABEL, p + BPoint(maxLen - audLen, 0)); BPoint p2 = p; p2.x += maxLen + 4; p.y += lineHeight * 2; DrawString(VIDEO_INFO_LABEL, p + BPoint(maxLen - vidLen, 0)); p.y += lineHeight * 2; DrawString(DURATION_LABEL, p + BPoint(maxLen - durLen, 0)); // draw audio/video/duration info font.SetFace(B_REGULAR_FACE); font.SetSize(10); SetFont(&font); DrawString(aFmt.String(), p2); p2.y += lineHeight; DrawString(aDetails.String(), p2); p2.y += lineHeight; DrawString(vFmt.String(), p2); p2.y += lineHeight; DrawString(vDetails.String(), p2); p2.y += lineHeight; DrawString(duration.String(), p2); }
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; }
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); }
KouhoWindow::KouhoWindow( BFont *font, BLooper *looper ) :BWindow( DUMMY_RECT, "kouho", B_MODAL_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL, B_NOT_RESIZABLE | B_NOT_CLOSABLE | B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_AVOID_FOCUS | B_NOT_ANCHORED_ON_ACTIVATE ) { float fontHeight; BRect frame; BFont indexfont; cannaLooper = looper; kouhoFont = font; font_family family; font_style style; strcpy( family, "Haru" ); strcpy( style, "Regular" ); indexfont.SetFamilyAndStyle( family, style ); indexfont.SetSize( 10 ); #ifdef DEBUG SERIAL_PRINT(( "kouhoWindow: Constructor called.\n" )); #endif //setup main pane indexWidth = indexfont.StringWidth( "W" ) + INDEXVIEW_SIDE_MARGIN * 2; minimumWidth = indexfont.StringWidth( "ギリシャ 100/100" ); frame = Bounds(); frame.left = indexWidth + 2; frame.bottom -= INFOVIEW_HEIGHT; kouhoView = new KouhoView( frame ); BRect screenrect = BScreen( this ).Frame(); kouhoView->SetTextRect( screenrect ); //big enough kouhoView->SetFontAndColor( kouhoFont ); kouhoView->SetWordWrap( false ); AddChild( kouhoView ); fontHeight = kouhoView->LineHeight(); frame = Bounds(); frame.right = indexWidth; frame.bottom = frame.bottom - INFOVIEW_HEIGHT + 1; indexView = new KouhoIndexView( frame, fontHeight ); indexView->SetFont( &indexfont ); AddChild( indexView ); frame = Bounds(); frame.top = frame.bottom - INFOVIEW_HEIGHT + 1; infoView = new KouhoInfoView( frame ); infoView->SetFont( &indexfont ); infoView->SetAlignment( B_ALIGN_RIGHT ); AddChild( infoView ); }
// 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(); }
void BMenuItem::TruncateLabel(float maxWidth, char *newLabel) { BFont font; BString string(fLabel); font.TruncateString(&string, B_TRUNCATE_MIDDLE, maxWidth); string.CopyInto(newLabel, 0, string.Length()); newLabel[string.Length()] = '\0'; }
HVIFView::HVIFView(const char* name, uint32 flags, TranslatorSettings *settings) : BView(name, flags, new BGroupLayout(B_VERTICAL)), fSettings(settings) { BAlignment labelAlignment(B_ALIGN_LEFT, B_ALIGN_NO_VERTICAL); BStringView* title= new BStringView("title", B_TRANSLATE("Native Haiku icon format translator")); title->SetFont(be_bold_font); title->SetExplicitAlignment(labelAlignment); char versionString[256]; snprintf(versionString, sizeof(versionString), B_TRANSLATE("Version %d.%d.%d, %s"), int(B_TRANSLATION_MAJOR_VERSION(HVIF_TRANSLATOR_VERSION)), int(B_TRANSLATION_MINOR_VERSION(HVIF_TRANSLATOR_VERSION)), int(B_TRANSLATION_REVISION_VERSION(HVIF_TRANSLATOR_VERSION)), __DATE__); BStringView* version = new BStringView("version", versionString); version->SetExplicitAlignment(labelAlignment); BStringView* copyright = new BStringView("copyright", B_UTF8_COPYRIGHT"2009 Haiku Inc."); copyright->SetExplicitAlignment(labelAlignment); int32 renderSize = fSettings->SetGetInt32(HVIF_SETTING_RENDER_SIZE); BString label = B_TRANSLATE("Render size:"); label << " " << renderSize; fRenderSize = new BSlider("renderSize", label.String(), NULL, 1, 32, B_HORIZONTAL); fRenderSize->SetValue(renderSize / 8); fRenderSize->SetHashMarks(B_HASH_MARKS_BOTTOM); fRenderSize->SetHashMarkCount(16); fRenderSize->SetModificationMessage( new BMessage(HVIF_SETTING_RENDER_SIZE_CHANGED)); fRenderSize->SetExplicitAlignment(labelAlignment); float padding = 5.0f; BLayoutBuilder::Group<>(this, B_VERTICAL, padding) .SetInsets(padding) .Add(title) .Add(version) .Add(copyright) .Add(fRenderSize) .AddGlue(); BFont font; GetFont(&font); SetExplicitPreferredSize( BSize((font.Size() * 270) / 12, (font.Size() * 100) / 12)); }
// GetHeight void Font::GetHeight(font_height* fh) const { if (!fCachedFontHeightValid) { // TODO: BFont helper = GetBFont(); helper.GetHeight(&fCachedFontHeight); fCachedFontHeightValid = true; } *fh = fCachedFontHeight; }
void CProgramChangeMonitorView::ProgramChange( BString program) { BFont font; GetFont(&font); font.TruncateString(&program, B_TRUNCATE_END, Bounds().Width()); m_program = program; m_fresh = 15; }
static BCheckBox* create_check_box(const char* label, const char* name) { BMessage* message = new BMessage(MSG_FILTER_SELECTED); message->AddString("name", name); BCheckBox* checkBox = new BCheckBox(label, message); BFont font; checkBox->GetFont(&font); font.SetSize(ceilf(font.Size() * 0.75)); checkBox->SetFont(&font); return checkBox; }
void View::AttachedToWindow() { MakeFocus(this); BMessage update(kMsgUpdate); fRunner = new BMessageRunner(this, &update, 16667); BFont font; font.SetSize(72); SetFont(&font); }
TGAView::TGAView(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", B_TRANSLATE("TGA Image Translator")); fTitle->SetFont(be_bold_font); char detail[100]; sprintf(detail, B_TRANSLATE("Version %d.%d.%d %s"), static_cast<int>(B_TRANSLATION_MAJOR_VERSION(TGA_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_MINOR_VERSION(TGA_TRANSLATOR_VERSION)), static_cast<int>(B_TRANSLATION_REVISION_VERSION( TGA_TRANSLATOR_VERSION)), __DATE__); fDetail = new BStringView("detail", detail); fWrittenBy = new BStringView("writtenby", B_TRANSLATE("Written by the Haiku Translation Kit Team")); fpchkIgnoreAlpha = new BCheckBox(B_TRANSLATE("Ignore TGA alpha channel"), new BMessage(CHANGE_IGNORE_ALPHA)); int32 val = (fSettings->SetGetBool(TGA_SETTING_IGNORE_ALPHA)) ? 1 : 0; fpchkIgnoreAlpha->SetValue(val); fpchkIgnoreAlpha->SetViewColor(ViewColor()); fpchkRLE = new BCheckBox(B_TRANSLATE("Save with RLE Compression"), new BMessage(CHANGE_RLE)); val = (fSettings->SetGetBool(TGA_SETTING_RLE)) ? 1 : 0; fpchkRLE->SetValue(val); fpchkRLE->SetViewColor(ViewColor()); // Build the layout SetLayout(new BGroupLayout(B_HORIZONTAL)); AddChild(BGroupLayoutBuilder(B_VERTICAL, 7) .Add(fTitle) .Add(fDetail) .AddGlue() .Add(fpchkIgnoreAlpha) .Add(fpchkRLE) .AddGlue() .Add(fWrittenBy) .AddGlue() .SetInsets(5, 5, 5, 5) ); BFont font; GetFont(&font); SetExplicitPreferredSize(BSize((font.Size() * 333)/12, (font.Size() * 200)/12)); }
void TeamListItem::DrawItem(BView* owner, BRect frame, bool complete) { rgb_color kHighlight = { 140, 140, 140, 0 }; rgb_color kBlack = { 0, 0, 0, 0 }; rgb_color kBlue = { 0, 0, 255, 0 }; rgb_color kRed = { 255, 0, 0, 0 }; BRect r(frame); if (IsSelected() || complete) { rgb_color color; if (IsSelected()) color = kHighlight; else color = owner->ViewColor(); owner->SetHighColor(color); owner->SetLowColor(color); owner->FillRect(r); owner->SetHighColor(kBlack); } else { owner->SetLowColor(owner->ViewColor()); } frame.left += 4; BRect iconFrame(frame); iconFrame.Set(iconFrame.left, iconFrame.top + 1, iconFrame.left + 15, iconFrame.top + 16); owner->SetDrawingMode(B_OP_ALPHA); owner->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY); owner->DrawBitmap(&fMiniIcon, iconFrame); owner->SetDrawingMode(B_OP_COPY); frame.left += 16; if (fRefusingToQuit) owner->SetHighColor(kRed); else owner->SetHighColor(IsSystemServer() ? kBlue : kBlack); BFont font = be_plain_font; font_height finfo; font.GetHeight(&finfo); owner->SetFont(&font); owner->MovePenTo(frame.left + 8, frame.top + ((frame.Height() - (finfo.ascent + finfo.descent + finfo.leading)) / 2) + finfo.ascent); if (gLocalizedNamePreferred) owner->DrawString(fLocalizedName.String()); else owner->DrawString(fPath.Leaf()); }
void HColorControl::Draw(BRect /*updateRect*/) { BRect r(Bounds()); SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); font_height fh; BFont font; GetFont(&font); font.GetHeight(&fh); BPoint p(3, r.bottom - fh.descent); if (IsFocus()) { SetHighColor(keyboard_navigation_color()); StrokeLine(BPoint(p.x, p.y + 1), BPoint(p.x + StringWidth(fLabel), p.y + 1)); SetHighColor(255, 255, 255); StrokeLine(BPoint(p.x, p.y + 2), BPoint(p.x + StringWidth(fLabel), p.y + 2)); SetHighColor(0, 0, 0); } DrawString(fLabel, p); r.left = r.right - 32; r.bottom -= fh.descent - 2; r.top = r.bottom - 12; FillRect(r, B_SOLID_LOW); r.left += 2; r.top += 2; if (fDown) { SetHighColor(kBlack); StrokeRect(r); r.InsetBy(1, 1); rgb_color c = fColor; c.red >>= 1; c.green >>= 1; c.blue >>= 1; SetHighColor(c); FillRect(r); SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT)); r.InsetBy(-1, -1); r.OffsetBy(-1, -1); StrokeLine(r.LeftBottom(), r.LeftTop()); StrokeLine(r.LeftTop(), r.RightTop()); } else {
BRect URLView::GetTextRect() { // This function will return a BRect that contains only the text // and the underline, so the mouse can change and the link will // be activated only when the mouse is over the text itself, not // just within the view. // Note: We'll use bounding boxes, because they are the most // accurate, and since the user is interacting with the // view, off-by-one-pixel errors look bad. const char *textArray[1]; textArray[0] = Text(); escapement_delta delta; delta.nonspace = 0; delta.space = 0; escapement_delta escapements[1]; escapements[0] = delta; BRect returnMe; BRect rectArray[1]; rectArray[0] = returnMe; BFont font; GetFont( &font ); font.GetBoundingBoxesForStrings( textArray, 1, B_SCREEN_METRIC, escapements, rectArray ); BRect frame = Frame(); frame.OffsetTo( B_ORIGIN ); returnMe = rectArray[0]; // Get the height of the current font. font_height height; GetFontHeight( &height ); float descent = height.descent; // Account for rounding of the floats when drawn to avoid // one-pixel-off errors. float lowerBound = 0; if( (((int) descent) * 2) != ((int) (descent * 2)) ) lowerBound = 1; // Adjust the bounding box to reflect where the text is in the view. returnMe.bottom += 1; returnMe.OffsetTo( B_ORIGIN ); float rectHeight = returnMe.Height(); returnMe.bottom = frame.bottom - descent; returnMe.top = returnMe.bottom - rectHeight; returnMe.bottom += 1 + underlineThickness; returnMe.OffsetBy( 0.0, -(1 + lowerBound) ); return returnMe; }
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()); }
void AboutWindow::Show() { BAlert* alert = new BAlert("About" B_UTF8_ELLIPSIS, fText->String(), "Close"); BTextView* view = alert->TextView(); BFont font; view->SetStylable(true); view->GetFont(&font); font.SetFace(B_BOLD_FACE); font.SetSize(font.Size() * 1.7f); view->SetFontAndColor(0, fAppName->Length(), &font); alert->Go(); }
void SpecialModelMenuItem::DrawContent() { Menu()->PushState(); BFont font; Menu()->GetFont(&font); font.SetFace(B_ITALIC_FACE); Menu()->SetFont(&font); _inherited::DrawContent(); Menu()->PopState(); }
void HBox::Draw(BRect update) { BRect R(Bounds()); float l = R.left, t = R.top, r = R.right, b = R.bottom; if (Label()) { BFont font; GetFont(&font); font_height fh; font.GetHeight(&fh); float lh = fh.ascent + fh.descent, w = StringWidth(Label()) + 4; DrawString(Label(), BPoint(7, fh.ascent)); BeginLineArray(10); AddLine(BPoint(l, t + lh / 2), BPoint(l + 4, t + lh / 2), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT)); AddLine(BPoint(l + 1, t + lh / 2 + 1), BPoint(l + 5, t + lh / 2 + 1), kWhite); AddLine(BPoint(l + w + 4, t + lh / 2), BPoint(r, t + lh / 2), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT)); AddLine(BPoint(l + w + 4, t + lh / 2 + 1), BPoint(r - 1, t + lh / 2 + 1), kWhite); AddLine(BPoint(l, t + lh / 2), BPoint(l, b), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT)); AddLine(BPoint(l + 1, t + lh / 2 + 1), BPoint(l + 1, b - 2), kWhite); AddLine(BPoint(l, b - 1), BPoint(r - 1, b - 1), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT)); AddLine(BPoint(l, b), BPoint(r, b), kWhite); AddLine(BPoint(r - 1, b - 1), BPoint(r - 1, t + lh / 2), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT)); AddLine(BPoint(r, b), BPoint(r, t + lh / 2), kWhite); EndLineArray(); } else { BeginLineArray(8); AddLine(BPoint(l, t), BPoint(r - 1, t), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT)); AddLine(BPoint(l + 1, t + 1), BPoint(r - 2, t + 1), kWhite); AddLine(BPoint(l, t), BPoint(l, b - 1), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT)); AddLine(BPoint(l + 1, t + 1), BPoint(l + 1, b - 2), kWhite); AddLine(BPoint(l, b - 1), BPoint(r - 1, b - 1), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT)); AddLine(BPoint(l, b), BPoint(r, b), kWhite); AddLine(BPoint(r - 1, b - 1), BPoint(r - 1, t), tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT)); AddLine(BPoint(r, b), BPoint(r, t), kWhite); EndLineArray(); } } /* HBox::Draw */
// ------------------------------------------------------------------- // * Constructors & Destructor // ------------------------------------------------------------------- GDView::GDView(BRect frame, const char* title, uint32 mode, uint32 flags):BView(frame,title,mode,flags) { const float fView_ht = 20; // Add the display for the goodness of fit BRect fFrame(0,5,150,fView_ht); mFitView = new BStringView(fFrame,"Fit View",""); mFitView->SetFontSize(12); AddChild(mFitView); // Offset the frame to make room for the data display frame.OffsetTo(B_ORIGIN); BFont theFont; GetFont(&theFont); float width = theFont.StringWidth("Cubic Spline Fit "); frame.right -= width; frame.top += fView_ht; mGraph = new GDPolyPlot(&mData,frame); mGraph->SelectEnable(true); // Allow drag-rescaling mGraph->SetPlotMark(plotMark_plus); AddChild(mGraph); // Add the display for the parameters BRect dFrame(frame.right,0,Bounds().right,50); mDisp = new GDPolyDisp(&mData,dFrame); AddChild(mDisp); // Add the odometer mOdometer = new WGOdometer(mGraph); mOdometer->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM); AddChild(mOdometer); mOdometer->ResizeToPreferred(); BRect oFrame = mOdometer->Bounds(); frame = Bounds(); // Get parent's size mOdometer->MoveTo(frame.right - oFrame.Width(),frame.bottom - oFrame.Height() - 15); // See what these do... // SetFontSize(12); // GetFont(&theFont); // mGraph->SetGraphFont(&theFont); // rgb_color red = {255,100,100,0}; // rgb_color black = {0,0,0,0}; // mGraph->SetGraphColor(red); }
ShowImageStatusView::ShowImageStatusView(BRect rect, const char* name, uint32 resizingMode, uint32 flags) : BView(rect, name, resizingMode, flags) { SetViewColor(B_TRANSPARENT_32_BIT); SetLowColor(ui_color(B_PANEL_BACKGROUND_COLOR)); SetHighColor(0, 0, 0, 255); BFont font; GetFont(&font); font.SetSize(10.0); SetFont(&font); }