本文整理汇总了C++中BFont::GetHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ BFont::GetHeight方法的具体用法?C++ BFont::GetHeight怎么用?C++ BFont::GetHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BFont
的用法示例。
在下文中一共展示了BFont::GetHeight方法的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: Label
void
BTab::DrawLabel(BView *owner, BRect frame)
{
if (Label() == NULL)
return;
BString label = Label();
float frameWidth = frame.Width();
float width = owner->StringWidth(label.String());
font_height fh;
if (width > frameWidth) {
BFont font;
owner->GetFont(&font);
font.TruncateString(&label, B_TRUNCATE_END, frameWidth);
width = frameWidth;
font.GetHeight(&fh);
} else {
owner->GetFontHeight(&fh);
}
owner->SetDrawingMode(B_OP_OVER);
owner->SetHighColor(ui_color(B_CONTROL_TEXT_COLOR));
owner->DrawString(label.String(),
BPoint((frame.left + frame.right - width) / 2.0,
(frame.top + frame.bottom - fh.ascent - fh.descent) / 2.0
+ fh.ascent));
}
示例3: BWindow
/////////////////////////////////////////////////////////////////////
// makeKanBeWin
/////////////////////////////////////////////////////////////////////
void
kanBeApp::makeKanBeWin(void)
{
BFont aFont;
font_height h_info;
float h, w;
char basepath[B_FILE_NAME_LENGTH];
ReadSetting(basepath, &aFont);
setBasePath(basepath);
w = aFont.StringWidth(B_UTF8_HIROSHI); // kanji width
aFont.GetHeight(&h_info);
h = h_info.ascent + h_info.descent + h_info.leading;
mWindow = new BWindow(InitFrame(w, h), "kanBe ver. 0.52", B_TITLED_WINDOW,
B_NOT_RESIZABLE|B_NOT_CLOSABLE|B_NOT_MINIMIZABLE|B_NOT_ZOOMABLE);
mWindow->Lock();
mView = new FEPView(mWindow->Bounds());
mView->SetFont(&aFont);
mWindow->AddChild(mView);
mWindow->Unlock();
mWindow->Show();
}
示例4: GetTitleWidthAndPos
//: Returns width and postion of the title.
//!param: width - In this parameter the available space
//!param: for the title is returned.
//!param: pos - In this parameter the position for the
//!param: title is returned.
void CMDITitleView::GetTitleWidthAndPos(float &width, BPoint &pos)
{
BFont titleFont;
GetTitleFont(&titleFont);
font_height titleFontHeight;
titleFont.GetHeight(&titleFontHeight);
width = Bounds().Width() - distFromMaximizeBox - distFromCloseBox;
if(DisplayCloseButton()) {
pos.x = CloseButtonRect().right + distFromCloseBox;
width -= CloseButtonRect().right;
} else {
pos.x = distFromCloseBox;
}
if(DisplayMaximizeButton()) {
width -= MaximizeButtonRect().Width() - distFromRightBorder;
}
pos.y = titleFontHeight.ascent + 3;
}
示例5: 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);
}
示例6:
void
BTitledColumn::DrawString(const char* string, BView* parent, BRect rect)
{
float width = rect.Width() - (2 * kTEXT_MARGIN);
float y;
BFont font;
font_height finfo;
parent->GetFont(&font);
font.GetHeight(&finfo);
y = rect.top + ((rect.Height() - (finfo.ascent + finfo.descent + finfo.leading)) / 2)
+ (finfo.ascent + finfo.descent) - 2;
switch (Alignment()) {
default:
case B_ALIGN_LEFT:
parent->MovePenTo(rect.left + kTEXT_MARGIN, y);
break;
case B_ALIGN_CENTER:
parent->MovePenTo(rect.left + kTEXT_MARGIN + ((width - font.StringWidth(string)) / 2), y);
break;
case B_ALIGN_RIGHT:
parent->MovePenTo(rect.right - kTEXT_MARGIN - font.StringWidth(string), y);
break;
}
parent->DrawString(string);
}
示例7:
/*! \function CategoryListView::GetPreferredSize
* \brief Returns preferred width and height for this CategoryListView
* \param[out] width Preferred width
* \param[out] height Preferred height
*/
void CategoryListView::GetPreferredSize( float* width, float* height )
{
int numOfItems = this->CountItems();
font_height fh;
BFont font;
this->GetFont( &font );
font.GetHeight( &fh );
int heightOfSingleItem = fh.leading + fh.ascent + fh.descent;
*height = ( numOfItems == 0 ? heightOfSingleItem : heightOfSingleItem * numOfItems );
float currentWidth = 0;
*width = 0;
for ( int i = 0; i < numOfItems; ++i )
{
currentWidth = ( ( this->ItemAt( i ) )->Width() );
if ( currentWidth > *width )
{
*width = currentWidth;
}
}
width += ( heightOfSingleItem - 2 ) + 2 * SPACING;
} // <-- end of function "CategoryListView::GetPreferredSize"
示例8: DrawLabel
void YabTabView::DrawLabel(int32 current, BRect frame)
{
BString label = GetTabName(current);
if (label == NULL)
return;
float frameWidth = frame.Width();
float width = StringWidth(label.String());
font_height fh;
if (width > frameWidth) {
BFont font;
GetFont(&font);
font.TruncateString(&label, B_TRUNCATE_END, frameWidth);
width = frameWidth;
font.GetHeight(&fh);
} else {
GetFontHeight(&fh);
}
SetDrawingMode(B_OP_OVER);
SetHighColor(ui_color(B_CONTROL_TEXT_COLOR));
DrawString(label.String(),
BPoint((frame.left + frame.right - width) / 2.0,
(frame.top + frame.bottom - fh.ascent - fh.descent) / 2.0
+ fh.ascent));
}
示例9: ceilf
void
ExpanderWindow::_UpdateWindowSize(bool showContents)
{
float minWidth, maxWidth, minHeight, maxHeight;
GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
float bottom = fSizeLimit;
if (showContents) {
if (fPreviousHeight < 0.0) {
BFont font;
font_height fontHeight;
fListingText->GetFont(&font);
font.GetHeight(&fontHeight);
fLineHeight = ceilf(fontHeight.ascent + fontHeight.descent
+ fontHeight.leading);
fPreviousHeight = bottom + 10.0 * fLineHeight;
}
minHeight = bottom + 5.0 * fLineHeight;
maxHeight = 32767.0;
bottom = max_c(fPreviousHeight, minHeight);
} else {
minHeight = fSizeLimit;
maxHeight = fSizeLimit;
fPreviousHeight = Frame().Height();
}
SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);
ResizeTo(Frame().Width(), bottom);
}
示例10: b
// Draw
void
PropertyItemView::Draw(BRect updateRect)
{
const Property* property = GetProperty();
if (property && fParent) {
BRect b(Bounds());
// just draw background and label
rgb_color labelColor = LowColor();
if (fEnabled)
labelColor = tint_color(labelColor, B_DARKEN_MAX_TINT);
else
labelColor = tint_color(labelColor, B_DISABLED_LABEL_TINT);
SetHighColor(labelColor);
BFont font;
GetFont(&font);
BString truncated(name_for_id(property->Identifier()));
font.TruncateString(&truncated, B_TRUNCATE_MIDDLE, fLabelWidth - 10.0);
font_height fh;
font.GetHeight(&fh);
FillRect(BRect(b.left, b.top, b.left + fLabelWidth, b.bottom), B_SOLID_LOW);
DrawString(truncated.String(), BPoint(b.left + 5.0,
floorf(b.top + b.Height() / 2.0
+ fh.ascent / 2.0)));
// draw a "separator" line behind the label
SetHighColor(tint_color(LowColor(), B_DARKEN_1_TINT));
StrokeLine(BPoint(b.left + fLabelWidth - 1.0, b.top),
BPoint(b.left + fLabelWidth - 1.0, b.bottom), B_SOLID_HIGH);
}
}
示例11: Draw
/*------------------------------------------------------------------------------*\
( )
-
\*------------------------------------------------------------------------------*/
void BmCaption::Draw( BRect updateRect) {
BRect r = Bounds();
if (mHighlight) {
if (BeamOnDano)
SetLowColor( keyboard_navigation_color());
else {
rgb_color highlightCol = {255, 217, 121, 255};
SetLowColor( highlightCol);
}
}
else
SetLowColor( ui_color( B_PANEL_BACKGROUND_COLOR));
#ifndef __HAIKU__
FillRect( r.InsetByCopy(1.0, 1.0), B_SOLID_LOW);
#else
FillRect( BRect(r.top + 1, r.left + 1, r.right, r.bottom - 1), B_SOLID_LOW);
#endif
SetHighColor( ui_color( B_SHINE_COLOR));
StrokeLine( BPoint(0.0,1.0), BPoint(r.right,1.0));
StrokeLine( BPoint(0.0,1.0), r.LeftBottom());
SetHighColor( BmWeakenColor( B_SHADOW_COLOR, BeShadowMod));
if (BeamOnDano)
StrokeLine( r.RightTop(), r.RightBottom());
#ifndef __HAIKU__
else
// looks better on R5, as it blends with scrollbar:
StrokeLine( r.RightTop(), r.RightBottom(), B_SOLID_LOW);
#endif
StrokeLine( r.LeftTop(), r.RightTop());
StrokeLine( r.LeftBottom(), r.RightBottom());
SetHighColor( ui_color( B_PANEL_TEXT_COLOR));
font_height fInfo;
BFont captionFont;
GetFont(&captionFont);
captionFont.GetHeight( &fInfo);
float offset = (1.0f+r.Height()-(fInfo.ascent+fInfo.descent))/2.0f;
float freeWidth = r.Width();
if (mHighlight && mHighlightLabel.Length()) {
freeWidth -= StringWidth(mHighlightLabel.String())+2;
BPoint pos( 2.0, fInfo.ascent+offset);
DrawString( mHighlightLabel.String(), pos);
}
const char* text = mText.String();
float width;
while(1) {
width = StringWidth(text);
if (width+4.0 < freeWidth)
break;
text++;
while((*text & 0xc0) == 0x80)
text++; // skip UTF8 subsequence chars
if (!*text)
break;
}
BPoint pos( r.Width()-width-2.0f, fInfo.ascent+offset);
DrawString( text, pos);
}
示例12: Draw
//*****************************************************
void TimeBarView::Draw(BRect rect)
{
BRect r = Bounds();
char s[255];
SetLowColor(Prefs.time_back_color);
FillRect(r, B_SOLID_LOW);
if (Pool.size == 0) return;
SetHighColor(64,64,64);
StrokeLine(BPoint(r.left, r.top), BPoint(r.right, r.top));
if (Pool.sample_type == NONE) return;
int32 w = r.IntegerWidth();
int32 x = (int32)r.left;
float b;
BFont font;
GetFont(&font);
font_height fh;
font.GetHeight(&fh);
float fw = font.StringWidth(" 00:00.000 ");
// float t = floor( Pool.l_pointer/Pool.frequency);
float t = ( Pool.l_pointer/Pool.frequency);
float t_add = (Pool.r_pointer - Pool.l_pointer)/(Pool.frequency*w);
float t_marge = t_add * fw;
float t_small_marge = t_marge/5.0f;
float t_small_bound = t + t_small_marge;
float t_bound = t + t_marge;
while (w>0){
t += t_add;
if (t >= t_bound){
int time = (int)((t-(int)t)*1000);
int sec = (int)fmod(t,60);
int min = ((int)t)/60;
sprintf(s, "%d:%.2d.%.3d", min, sec, time);
t_bound += t_marge;
b = r.top + 5;
SetHighColor(Prefs.time_text_color);
DrawString(s, BPoint(x - font.StringWidth(s)/2.0f, r.bottom));
SetHighColor(Prefs.time_marks_color);
StrokeLine( BPoint( x, r.top+1 ), BPoint( x, b) );
}else if (t >= t_small_bound){
t_small_bound += t_small_marge;
SetHighColor(Prefs.time_small_marks_color);
b = r.top + 1;
StrokeLine( BPoint( x, r.top+1 ), BPoint( x, b) );
}
x ++;
w --;
}
}
示例13: r
void
Spinner::_InitObject(void)
{
SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
BRect r(Bounds());
if (r.Height() < B_H_SCROLL_BAR_HEIGHT * 2)
r.bottom = r.top + 1 + B_H_SCROLL_BAR_HEIGHT * 2;
ResizeTo(r.Width(),r.Height());
r.right -= B_V_SCROLL_BAR_WIDTH;
font_height fh;
BFont font;
font.GetHeight(&fh);
float textheight = fh.ascent + fh.descent + fh.leading;
r.top = 0;
r.bottom = textheight;
fTextControl = new BTextControl(r,"textcontrol",Label(),"0",
new BMessage(M_TEXT_CHANGED), B_FOLLOW_TOP |
B_FOLLOW_LEFT_RIGHT,
B_WILL_DRAW | B_NAVIGABLE);
AddChild(fTextControl);
fTextControl->ResizeTo(r.Width(), MAX(textheight, fTextControl->TextView()->LineHeight(0) + 4.0));
fTextControl->MoveTo(0,
((B_H_SCROLL_BAR_HEIGHT * 2) - fTextControl->Bounds().Height()) / 2);
fTextControl->SetDivider(StringWidth(Label()) + 5);
BTextView *tview = fTextControl->TextView();
tview->SetAlignment(B_ALIGN_LEFT);
tview->SetWordWrap(false);
BString string("QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,/qwertyuiop{}| "
"asdfghjkl:\"zxcvbnm<>[email protected]#$%^&*()-_=+`~\r");
for (int32 i = 0; i < string.CountChars(); i++) {
char c = string.ByteAt(i);
tview->DisallowChar(c);
}
r = Bounds();
r.left = r.right - B_V_SCROLL_BAR_WIDTH;
r.bottom = B_H_SCROLL_BAR_HEIGHT;
fUpButton = new SpinnerArrowButton(r.LeftTop(),"up",ARROW_UP);
AddChild(fUpButton);
r.OffsetBy(0,r.Height() + 1);
fDownButton = new SpinnerArrowButton(r.LeftTop(),"down",ARROW_DOWN);
AddChild(fDownButton);
fPrivateData = new SpinnerPrivateData;
fFilter = new SpinnerMsgFilter;
}
示例14: GetPreferredSize
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);
};
示例15: Draw
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);
}