本文整理汇总了C++中BFont::SetSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BFont::SetSize方法的具体用法?C++ BFont::SetSize怎么用?C++ BFont::SetSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BFont
的用法示例。
在下文中一共展示了BFont::SetSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ChooseFont
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 */
示例2: FontSize
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();
}
示例3: RetrieveBitmap
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();
}
}
示例4: p
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);
}
示例5: Read
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;
}
示例6: BStringView
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);
}
示例7: FontSize
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();
}
示例8: ShowAboutWindow
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();
}
示例9: BGroupLayout
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));
}
示例10: UpdateAttr
//
// 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="";
}
示例11: BAlert
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);
}
示例12: Name
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();
}
示例13: BPopUpMenu
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);
}
示例14: BWindow
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;
}
示例15: AboutText
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();
}