void CSelectionView::ChooseFont() { CFontMetrics metrics = gFontSizeTable[fCellView->BorderFontID()]; BFont myFont = metrics.Font(); font_height fi; do { myFont.GetHeight(&fi); if (fi.ascent + fi.descent <= Bounds().Height()) break; float size = myFont.Size(); myFont.SetSize(size - 1); myFont.GetHeight(&fi); if (fi.ascent + fi.descent <= Bounds().Height()) break; myFont.SetSize(size - 2); myFont.GetHeight(&fi); if (fi.ascent + fi.descent <= Bounds().Height()) break; myFont = be_plain_font; myFont.GetHeight(&fi); if (fi.ascent + fi.descent <= Bounds().Height()) break; // uh, oh, trouble... } while (false); SetFont(&myFont); Invalidate(); } /* CSelectionView::ChooseFont */
void DataView::FrameResized(float width, float height) { if (fFitFontSize) { // adapt the font size to fit in the view's bounds float oldSize = FontSize(); BFont font = be_fixed_font; float steps = 0.5f; float size; for (size = 1.f; size < 100; size += steps) { font.SetSize(size); float charWidth = font.StringWidth("w"); if (charWidth * (kBlockSize * 4 + fPositionLength + 6) + 2 * kHorizontalSpace > width) break; if (size > 6) steps = 1.0f; } size -= steps; font.SetSize(size); if (oldSize != size) { SetFont(&font); Invalidate(); } } UpdateScroller(); }
void ProxyView::DrawSadTab(const char *error) { BBitmap *sadTab = RetrieveBitmap(kSadTabBitmap, BRect(0, 0, 255, 255)); if (Window()->Lock()) { MovePenTo(Bounds().Width() / 2 - 127, Bounds().Height() / 2 - 177); DrawBitmap(sadTab); MovePenTo(Bounds().Width() / 2 - 45, Bounds().Height() / 2 + 55); BFont font; GetFont(&font); font.SetSize(18.0); font.SetFace(B_BOLD_FACE); SetFont(&font, B_FONT_SIZE | B_FONT_FACE); SetLowColor(0, 0, 0); SetHighColor(255, 255, 255); DrawString("Aw, Snap!"); MovePenTo(Bounds().Width() / 2 - 90, Bounds().Height() / 2 + 70); font.SetSize(12.0); font.SetFace(B_REGULAR_FACE); SetFont(&font, B_FONT_SIZE | B_FONT_FACE); DrawString(error); Window()->Unlock(); } }
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; }
quadruplet<BTextControl*, BPopUpMenu*, BMenuField*, BStringView*> CheckView::MakeField(uint16 width, string name, uint16* xpos, uint16* ypos) { BStringView* sv = new BStringView(BRect((*xpos), (*ypos), (*xpos) + width, (*ypos) + 10), (name + "Text").c_str(), name.c_str()); BFont font; sv->GetFont(&font); font.SetSize(10); sv->SetFont(&font); AddChild(sv); BTextControl* tc = new BTextControl(BRect((*xpos) - 5, (*ypos) + 10, (*xpos) + width, (*ypos) + 10), (name + "Field").c_str(), "", "", 0); (*xpos) += width; tc->SetDivider(0); AddChild(tc); BPopUpMenu* pu = new BPopUpMenu("", true, false); BMenuField* mf = new BMenuField(BRect((*xpos) + 2, (*ypos) + 9, (*xpos) + 2, (*ypos) + 9), (name + "Menu").c_str(), "", pu); mf->SetDivider(0); AddChild(mf); (*xpos) += 30; return quadruplet<BTextControl*, BPopUpMenu*, BMenuField*, BStringView*>(tc, pu, mf, sv); }
void DataView::FrameResized(float width, float height) { if (fFitFontSize) { // adapt the font size to fit in the view's bounds float oldSize = FontSize(); float steps = 0.5f; float size; for (size = 1.f; size < 100; size += steps) { int32 preferredWidth = WidthForFontSize(size); if (preferredWidth > width) break; if (size > 6) steps = 1.0f; } size -= steps; if (oldSize != size) { BFont font = be_fixed_font; font.SetSize(size); SetFont(&font); Invalidate(); } } UpdateScroller(); }
void ShowAboutWindow(void) { char str[512]; sprintf(str, "Basilisk II\nVersion %d.%d\n\n" "Copyright " B_UTF8_COPYRIGHT " 1997-2008 Christian Bauer et al.\n" "E-mail: [email protected]\n" "http://www.uni-mainz.de/~bauec002/B2Main.html\n\n" "Basilisk II comes with ABSOLUTELY NO\n" "WARRANTY. This is free software, and\n" "you are welcome to redistribute it\n" "under the terms of the GNU General\n" "Public License.\n", VERSION_MAJOR, VERSION_MINOR ); BAlert *about = new BAlert("", str, GetString(STR_OK_BUTTON), NULL, NULL, B_WIDTH_FROM_LABEL); BTextView *theText = about->TextView(); if (theText) { theText->SetStylable(true); theText->Select(0, 11); BFont ourFont; theText->SetFontAndColor(be_bold_font); theText->GetFontAndColor(2, &ourFont, NULL); ourFont.SetSize(24); theText->SetFontAndColor(&ourFont); } about->Go(); }
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)); }
// // appends 'line' to output widget with proper attributes void ydpDictionary::UpdateAttr(int newattr) { if (line.Length() == 0) return; rgb_color *colour; BFont myfont = cnf->currentFont; colour = &cnf->colour; if (newattr & A_SUPER) { myfont.SetSize(10.0); } if (newattr & A_BOLD) { myfont.SetFace(B_BOLD_FACE); } if (newattr & A_ITALIC) { myfont.SetFace(B_ITALIC_FACE); } if (newattr & A_COLOR0) { colour = &cnf->colour0; } if (newattr & A_COLOR1) { colour = &cnf->colour1; } if (newattr & A_COLOR2) { colour = &cnf->colour2; } outputView->SetFontAndColor(&myfont,B_FONT_ALL,colour); line = ConvertToUtf(line.String()); outputView->Insert(textlen,line.String(),line.Length()); textlen+=line.Length(); line=""; }
void WorkspacesView::_AboutRequested() { BString text = B_TRANSLATE("Workspaces\n" "written by %1, and %2.\n\n" "Copyright %3, Haiku.\n\n" "Send windows behind using the Option key. " "Move windows to front using the Control key.\n"); text.ReplaceFirst("%1", "François Revol, Axel Dörfler"); text.ReplaceFirst("%2", "Matt Madia"); text.ReplaceFirst("%3", "2002-2008"); BAlert *alert = new BAlert("about", text.String(), B_TRANSLATE("OK")); BTextView *view = alert->TextView(); BFont font; view->SetStylable(true); view->GetFont(&font); font.SetSize(18); font.SetFace(B_BOLD_FACE); view->SetFontAndColor(0, 10, &font); alert->Go(); }
void PulseApp::ShowAbout(bool asApplication) { // static version to be used in replicant mode BString name; if (asApplication) name = B_TRANSLATE_SYSTEM_NAME("Pulse"); else name = B_TRANSLATE("Pulse"); BString message = B_TRANSLATE( "%s\n\nBy David Ramsey and Arve Hjønnevåg\n" "Revised by Daniel Switkin\n"); message.ReplaceFirst("%s", name); BAlert *alert = new BAlert(B_TRANSLATE("Info"), message.String(), B_TRANSLATE("OK")); BTextView* view = alert->TextView(); BFont font; view->SetStylable(true); view->GetFont(&font); font.SetSize(18); font.SetFace(B_BOLD_FACE); view->SetFontAndColor(0, name.Length(), &font); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); // Use the asynchronous version so we don't block the window's thread alert->Go(NULL); }
void FontSelectionView::SetDefaults() { font_family family; font_style style; float size; const char* fontName; if (strcmp(Name(), "menu") == 0) fontName = "plain"; else fontName = Name(); if (_get_system_default_font_(fontName, family, style, &size) != B_OK) { Revert(); return; } BFont defaultFont; defaultFont.SetFamilyAndStyle(family, style); defaultFont.SetSize(size); if (defaultFont == fCurrentFont) return; _SelectCurrentFont(false); fCurrentFont = defaultFont; _UpdateFontPreview(); _SelectCurrentFont(true); _SelectCurrentSize(); }
PieView::PieView(BVolume* volume) : BView(NULL, B_WILL_DRAW | B_FULL_UPDATE_ON_RESIZE | B_SUBPIXEL_PRECISE), fWindow(NULL), fScanner(NULL), fVolume(volume), fMouseOverInfo(), fClicked(false), fDragging(false), fUpdateFileAt(false) { fMouseOverMenu = new BPopUpMenu(kEmptyStr, false, false); fMouseOverMenu->AddItem(new BMenuItem(B_TRANSLATE("Get Info"), NULL), kIdxGetInfo); fMouseOverMenu->AddItem(new BMenuItem(B_TRANSLATE("Open"), NULL), kIdxOpen); fFileUnavailableMenu = new BPopUpMenu(kEmptyStr, false, false); BMenuItem* item = new BMenuItem(B_TRANSLATE("file unavailable"), NULL); item->SetEnabled(false); fFileUnavailableMenu->AddItem(item); BFont font; GetFont(&font); font.SetSize(ceilf(font.Size() * 1.33)); font.SetFace(B_BOLD_FACE); SetFont(&font); struct font_height fh; font.GetHeight(&fh); fFontHeight = ceilf(fh.ascent) + ceilf(fh.descent) + ceilf(fh.leading); }
Tearoff::Tearoff(BRect frame, const char *name, MainWindow *parent, MenuName menu_name, int idx) : BWindow(frame, name, B_FLOATING_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE, 0) { int y = 0; BFont font; BMenu *menu; this->parent = parent; menu = parent->GetMenu(menu_name); menu->GetFont(&font); for(int i = 1; i < menu->CountItems(); i++) { BMenuItem *item = menu->ItemAt(i); if(item->Message()) { BButton *b = new BButton(BRect(0, y, frame.IntegerWidth(), y + TEAROFF_BUTTON_HEIGHT), "", item->Label(), new BMessage(item->Message()->what), B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW); font.SetSize(TEAROFF_FONT_SIZE); b->SetFont(&font); AddChild(b); y = y + TEAROFF_BUTTON_HEIGHT; } } this->ResizeTo(frame.IntegerWidth(), y); this->SetTitle(menu->Name()); this->index = idx; delete menu; }
void HWindow::AboutRequested() { const char* aboutText = AboutText(); if (aboutText == NULL) return; BAlert *about = new BAlert("About", aboutText, "Cool"); BTextView *v = about->TextView(); if (v) { rgb_color red = {255, 0, 51, 255}; rgb_color blue = {0, 102, 255, 255}; v->SetStylable(true); char *text = (char*)v->Text(); char *s = text; // set all Be in blue and red while ((s = strstr(s, "Be")) != NULL) { int32 i = s - text; v->SetFontAndColor(i, i+1, NULL, 0, &blue); v->SetFontAndColor(i+1, i+2, NULL, 0, &red); s += 2; } // first text line s = strchr(text, '\n'); BFont font; v->GetFontAndColor(0, &font); font.SetSize(12); // font.SetFace(B_OUTLINED_FACE); v->SetFontAndColor(0, s-text+1, &font, B_FONT_SIZE); }; about->SetFlags(about->Flags() | B_CLOSE_ON_ESCAPE); about->Go(); }
status_t ScreenSaver::StartSaver(BView *view, bool preview) { // save view dimensions and preview mode fIsPreview = preview; fSizeX = view->Bounds().Width(); fSizeY = view->Bounds().Height(); // set a new font, about 1/8th of view height, and bold BFont font; view->GetFont(&font); font.SetSize(fSizeY / 8); font.SetFace(B_BOLD_FACE); view->SetFont(&font); // find out space needed for text display BRect rect; escapement_delta delta; delta.nonspace = 0; delta.space = 0; font.GetBoundingBoxesForStrings(&fText, 1, B_SCREEN_METRIC, &delta, &rect); fTextHeight = rect.Height(); fTextWith = rect.Width(); // seed the random number generator srand((int)system_time()); return B_OK; }
void DrumsetDropField::AttachedToWindow() { BFont font; font.SetFamilyAndStyle("Swis721 BT","Roman"); font.SetSize( 8.0 ); SetFont(&font); SetLowColor( 66, 99, 132 ); SetHighColor( 210, 220, 230 ); BeginPicture( new BPicture() ); DrawBitmap(((App *)be_app)->FetchResourceBitmap("dropfield"), BPoint(0.0, 0.0)); DrawString("Drop instrument here!", BPoint(6.0, 12.0)); fNormalBitmap = EndPicture(); BeginPicture( new BPicture() ); DrawBitmap(((App *)be_app)->FetchResourceBitmap("dropfield"), BPoint(0.0, 0.0)); SetDrawingMode(B_OP_ALPHA); SetHighColor(0,0,0,80); FillRect(Bounds().InsetByCopy(1.0, 1.0)); SetHighColor( 255, 255, 255 ); DrawString("Drop instrument here!", BPoint(7.0, 13.0)); fActiveBitmap = EndPicture(); SetTarget(Parent()); }
void SyslogDaemon::AboutRequested() { BPath path; find_directory(B_SYSTEM_LOG_DIRECTORY, &path); path.Append("syslog"); BString name(B_TRANSLATE("Syslog Daemon")); BString message; snprintf(message.LockBuffer(512), 512, B_TRANSLATE("%s\n\nThis daemon is responsible for collecting " "all system messages and write them to the system-wide log " "at \"%s\".\n\n"), name.String(), path.Path()); message.UnlockBuffer(); BAlert *alert = new BAlert(name.String(), message.String(), B_TRANSLATE("OK")); BTextView *view = alert->TextView(); BFont font; view->SetStylable(true); view->GetFont(&font); font.SetSize(21); font.SetFace(B_BOLD_FACE); view->SetFontAndColor(0, name.Length(), &font); alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE); alert->Go(NULL); }
void TermWindow::_GetPreferredFont(BFont& font) { // Default to be_fixed_font font = be_fixed_font; const char* family = PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY); const char* style = PrefHandler::Default()->getString(PREF_HALF_FONT_STYLE); const char* size = PrefHandler::Default()->getString(PREF_HALF_FONT_SIZE); font.SetFamilyAndStyle(family, style); font.SetSize(atoi(size)); // mark the font size menu item for (int32 i = 0; i < fFontSizeMenu->CountItems(); i++) { BMenuItem* item = fFontSizeMenu->ItemAt(i); if (item == NULL) continue; item->SetMarked(false); if (strcmp(item->Label(), size) == 0) item->SetMarked(true); } }
void AccListItem::DrawItem(BView *owner, BRect frame, bool complete) { if (disabled) return; if (IsSelected()) { rgb_color c = cm.ColorNumber(((BListView*)owner)->CurrentSelection()); owner->SetHighColor(c); owner->SetLowColor(c); } else { owner->SetHighColor(255, 255, 255); owner->SetLowColor(255, 255, 255); } owner->FillRect(frame); if (IsSelected()) { owner->SetHighColor(156, 156, 156); owner->StrokeRect(frame); } if (IsEnabled()) owner->SetHighColor(0, 0, 0); else owner->SetHighColor(222, 222, 222); BFont font; owner->GetFont(&font); font.SetFace(B_BOLD_FACE); font.SetSize(11); owner->SetFont(&font); owner->DrawString(acc->name.c_str(), BPoint(frame.left + 5, frame.top + 14)); font.SetFace(B_REGULAR_FACE); font.SetSize(10); owner->SetFont(&font); if (!acc->traS.empty()) { string text = "Balance = "; text += prefs->currencyToString((*acc->traS.rbegin())->balFol); owner->DrawString(text.c_str(), BPoint(frame.left + 5, frame.top + 26)); text = "Rec.Bal. = "; text += prefs->currencyToString((*acc->traS.rbegin())->recBalFol); owner->DrawString(text.c_str(), BPoint(frame.left + 5, frame.top + 38)); } }
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; }
/*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 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()); } } }
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 ); }
/*********************************************************** * 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)); }
BString BStatusView::_StatusString(float availableSpace, float fontSize, float* _width) { BFont font; GetFont(&font); float oldSize = font.Size(); font.SetSize(fontSize); SetFont(&font, B_FONT_SIZE); BString status; if (sShowSpeed) { status = _SpeedStatusString(availableSpace, _width); } else status = _TimeStatusString(availableSpace, _width); font.SetSize(oldSize); SetFont(&font, B_FONT_SIZE); return status; }
// 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; }