本文整理汇总了C++中GetFontHeight函数的典型用法代码示例。如果您正苦于以下问题:C++ GetFontHeight函数的具体用法?C++ GetFontHeight怎么用?C++ GetFontHeight使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetFontHeight函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetFont
// ---------------------------------------------------------------
// Draw
//
// Draws information about the SlideShowConfigTranslator to this view.
//
// Preconditions:
//
// Parameters: area, not used
//
// Postconditions:
//
// Returns:
// ---------------------------------------------------------------
void
SlideShowConfigView::Draw(BRect area)
{
SetFont(be_bold_font);
font_height fh;
GetFontHeight(&fh);
float xbold, ybold;
xbold = fh.descent + 1;
ybold = fh.ascent + fh.descent * 2 + fh.leading;
char title[] = "SlideShow Screen Saver";
DrawString(title, BPoint(xbold, ybold));
SetFont(be_plain_font);
font_height plainh;
GetFontHeight(&plainh);
float yplain;
yplain = plainh.ascent + plainh.descent * 2 + plainh.leading;
char writtenby[] = "Written by Michael Wilber";
DrawString(writtenby, BPoint(xbold, yplain * 1 + ybold));
// Draw current folder
BString strFolder;
fSettings->GetString(SAVER_SETTING_DIRECTORY, strFolder);
strFolder.Prepend("Image folder: ");
DrawString(strFolder.String(), BPoint(10, yplain * 9 + ybold));
}
示例2: ui_color
// Draw
void
ListLabelView::Draw(BRect updateRect)
{
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
rgb_color lightenMax = tint_color(base, B_LIGHTEN_MAX_TINT);
rgb_color darken2 = tint_color(base, B_DARKEN_2_TINT);
BRect r(Bounds());
BeginLineArray(3);
AddLine(BPoint(r.left, r.bottom - 1),
BPoint(r.left, r.top), lightenMax);
AddLine(BPoint(r.right, r.top),
BPoint(r.right, r.bottom), darken2);
AddLine(BPoint(r.right - 1, r.bottom),
BPoint(r.left, r.bottom), darken2);
EndLineArray();
r.left += 1;
r.right -= 1;
r.bottom -= 1;
SetLowColor(base);
FillRect(r & updateRect, B_SOLID_LOW);
font_height fh;
GetFontHeight(&fh);
SetHighColor(0, 0, 0, 255);
BPoint labelPos;
labelPos.x = 5;
labelPos.y = r.top + floorf((r.Height() + fh.ascent) / 2.0);
DrawString(fLabel.String(), labelPos);
}
示例3: _MonitorBounds
void
MonitorView::Draw(BRect updateRect)
{
rgb_color darkColor = {160, 160, 160, 255};
rgb_color blackColor = {0, 0, 0, 255};
rgb_color redColor = {228, 0, 0, 255};
rgb_color whiteColor = {255, 255, 255, 255};
BRect outerRect = _MonitorBounds();
SetHighColor(fBackgroundColor);
FillRect(updateRect);
SetDrawingMode(B_OP_OVER);
// frame & background
SetHighColor(darkColor);
FillRoundRect(outerRect, 3.0, 3.0);
SetHighColor(blackColor);
StrokeRoundRect(outerRect, 3.0, 3.0);
SetHighColor(fDesktopColor);
BRect innerRect(outerRect.InsetByCopy(4, 4));
FillRoundRect(innerRect, 2.0, 2.0);
SetHighColor(blackColor);
StrokeRoundRect(innerRect, 2.0, 2.0);
SetDrawingMode(B_OP_COPY);
// power light
SetHighColor(redColor);
BPoint powerPos(outerRect.left + 5, outerRect.bottom - 2);
StrokeLine(powerPos, BPoint(powerPos.x + 2, powerPos.y));
// DPI
if (fDPI == 0)
return;
font_height fontHeight;
GetFontHeight(&fontHeight);
float height = ceilf(fontHeight.ascent + fontHeight.descent);
char text[64];
snprintf(text, sizeof(text), B_TRANSLATE("%ld dpi"), fDPI);
float width = StringWidth(text);
if (width > innerRect.Width() || height > innerRect.Height())
return;
SetLowColor(fDesktopColor);
SetHighColor(whiteColor);
DrawString(text, BPoint(innerRect.left + (innerRect.Width() - width) / 2,
innerRect.top + fontHeight.ascent + (innerRect.Height() - height) / 2));
}
示例4: GetFontHeight
BSize
BButton::_ValidatePreferredSize()
{
if (fPreferredSize.width < 0) {
// width
float width = 20.0f + (float)ceil(StringWidth(Label()));
if (width < 75.0f)
width = 75.0f;
if (fDrawAsDefault)
width += 6.0f;
fPreferredSize.width = width;
// height
font_height fontHeight;
GetFontHeight(&fontHeight);
fPreferredSize.height
= ceilf((fontHeight.ascent + fontHeight.descent) * 1.8)
+ (fDrawAsDefault ? 6.0f : 0);
ResetLayoutInvalidation();
}
return fPreferredSize;
}
示例5: DrawEditorInfoBox
//Kris:
//This is a new function which duplicates the older "yellow info boxes" that
//are common throughout the editor. This draws the yellow box with the indentation
//look.
void DrawEditorInfoBox( UINT16 *str, UINT32 uiFont, UINT16 x, UINT16 y, UINT16 w, UINT16 h )
{
UINT16 usFillColorDark, usFillColorLight, usFillColorBack;
UINT16 x2, y2;
UINT16 usStrWidth;
x2 = x + w;
y2 = y + h;
usFillColorDark = Get16BPPColor(FROMRGB(24, 61, 81));
usFillColorLight = Get16BPPColor(FROMRGB(136, 138, 135));
usFillColorBack = Get16BPPColor(FROMRGB(250, 240, 188));
ColorFillVideoSurfaceArea(ButtonDestBuffer, x, y, x2, y2, usFillColorDark);
ColorFillVideoSurfaceArea(ButtonDestBuffer, x + 1, y + 1, x2, y2, usFillColorLight);
ColorFillVideoSurfaceArea(ButtonDestBuffer, x + 1, y + 1, x2 - 1, y2 - 1, usFillColorBack);
usStrWidth = StringPixLength( str, uiFont );
if( usStrWidth > w )
{ //the string is too long, so use the wrapped method
y += 1;
DisplayWrappedString( x, y, w, 2, uiFont, FONT_BLACK, str, FONT_BLACK, TRUE, CENTER_JUSTIFIED );
return;
}
//center the string vertically and horizontally.
SetFont( uiFont );
SetFontForeground( FONT_BLACK );
SetFontShadow( FONT_BLACK );
x += (w - (UINT16)StringPixLength( str, uiFont )) / 2;
y += (h - (UINT16)GetFontHeight( uiFont)) / 2;
mprintf( x, y, L"%s", str );
InvalidateRegion( x, y, x2, y2 );
}
示例6: GetFontHeight
void
BRadioButton::Draw(BRect updateRect)
{
// its size depends on the text height
font_height fontHeight;
GetFontHeight(&fontHeight);
rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
uint32 flags = be_control_look->Flags(this);
if (fOutlined)
flags |= BControlLook::B_CLICKED;
BRect knobRect(_KnobFrame(fontHeight));
BRect rect(knobRect);
be_control_look->DrawRadioButton(this, rect, updateRect, base, flags);
BRect labelRect(Bounds());
labelRect.left = knobRect.right + 1
+ be_control_look->DefaultLabelSpacing();
const BBitmap* icon = IconBitmap(
B_INACTIVE_ICON_BITMAP | (IsEnabled() ? 0 : B_DISABLED_ICON_BITMAP));
be_control_look->DrawLabel(this, Label(), icon, labelRect, updateRect,
base, flags);
}
示例7: max_c
void
BIconButton::GetPreferredSize(float* width, float* height)
{
float minWidth = 0.0f;
float minHeight = 0.0f;
if (IsValid()) {
minWidth += fNormalBitmap->Bounds().IntegerWidth() + 1.0f;
minHeight += fNormalBitmap->Bounds().IntegerHeight() + 1.0f;
}
const float kMinSpace = 15.0f;
if (minWidth < kMinSpace)
minWidth = kMinSpace;
if (minHeight < kMinSpace)
minHeight = kMinSpace;
float hPadding = max_c(6.0f, ceilf(minHeight / 4.0f));
float vPadding = max_c(6.0f, ceilf(minWidth / 4.0f));
if (Label() != NULL && Label()[0] != '\0') {
font_height fh;
GetFontHeight(&fh);
minHeight += ceilf(fh.ascent + fh.descent) + vPadding;
minWidth += StringWidth(Label()) + vPadding;
}
if (width)
*width = minWidth + hPadding;
if (height)
*height = minHeight + vPadding;
}
示例8: _HasText
void
BStatusBar::_SetTextData(BString& text, const char* source,
const BString& combineWith, bool rightAligned)
{
if (source == NULL)
source = "";
// If there were no changes, we don't have to do anything
if (text == source)
return;
bool oldHasText = _HasText();
text = source;
BString newString;
if (rightAligned)
newString << text << combineWith;
else
newString << combineWith << text;
if (oldHasText != _HasText())
InvalidateLayout();
font_height fontHeight;
GetFontHeight(&fontHeight);
// Invalidate(BRect(position, 0, position + invalidateWidth,
// ceilf(fontHeight.ascent) + ceilf(fontHeight.descent)));
// TODO: redrawing the entire area takes care of the edge case
// where the left side string changes because of truncation and
// part of it needs to be redrawn as well.
Invalidate(BRect(0, 0, Bounds().right,
ceilf(fontHeight.ascent) + ceilf(fontHeight.descent)));
}
示例9: GetPreferredSize
void StaticString :: GetPreferredSize( float * w , float * h )
{
font_height fh ;
GetFontHeight( &fh ) ;
*h = fh.ascent + fh.descent + fh.leading ;
*w = StringWidth( Text() ) * 1.1 ;
}
示例10: Cls_OnAdvInitDialog
//.........................................................
BOOL Cls_OnAdvInitDialog(HWND hwnd, HWND hwndFocus, LPARAM lParam)
//WM_INITDIALOG handler
{
TCHAR fontName[80],
charSet[64];
LPPROPSHEETPAGE psp = (LPPROPSHEETPAGE)lParam;
LoadString(hInstance, IDS_TAB_FONT, fontName, SIZEOF_IN_CHAR(fontName));
LoadString(hInstance, IDS_CHAR_SET, charSet, SIZEOF_IN_CHAR(charSet));
hFont = CreateFont(GetFontHeight(hInstance, hwnd, IDS_FONT_HEIGHT), 0, 0, 0, FW_NORMAL,
FALSE, FALSE, 0,
CharSetFromString((LPTSTR)(const TCHAR *)charSet),
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY, TMPF_TRUETYPE | FF_DONTCARE,
(const TCHAR *)fontName);
hPeripheral = (HPERIPHERAL)psp->lParam;
hAdvanced = hwnd;
OnInitAdvancedDialog();
return TRUE;
}
示例11: memset
///////////////////////////////////////////////////////////////////////////////
// SetFont
void CXColorStatic::SetFont(LPCTSTR lpszFaceName,
int nPointSize,
BOOL bRedraw /*= TRUE*/)
{
// null face name is ok - we will use current font
LOGFONT lf;
memset(&lf, 0, sizeof(lf));
if (lpszFaceName == NULL)
{
CFont *pFont = GetFont();
ASSERT(pFont);
pFont->GetLogFont(&lf);
}
else
{
_tcsncpy(lf.lfFaceName, lpszFaceName, sizeof(lf.lfFaceName)/sizeof(TCHAR)-1);
}
m_nHeight = GetFontHeight(nPointSize);
lf.lfHeight = m_nHeight;
SetFont(&lf, bRedraw);
}
示例12: GetEntryHeight
void ListedTextItems::Repaint( const WidgetPainter &painter )
{
int entry_h = GetEntryHeight();
int font_h = GetFontHeight();
int shy = ( entry_h - font_h +1)/2;
if (!_items.Empty())
{
int shsel = (_shift<0)? (-_shift) : 0;
int shtxt = (_shift<0)? 0: _shift;
int i,n,y;
bool be_always_dirty = false;
for( i=0, n=_items.Size(), y=0; i<n; ++i )
{
__Item k = _items[i];
_skins.Select(k._state);
_skins.Paint( painter, Pos( shsel,y ), Rect(0,0,GetWidth(),entry_h)+Pos( shsel,y ) );
_fonts.Select(k._state);
_fonts.Paint( painter, k._caption, Pos(shtxt, y+shy) );
be_always_dirty |= IsAlwaysDirty();
y += entry_h;
}
BeAlwaysDirty( be_always_dirty);
}
}
示例13: GetFontHeight
void
BRadioButton::MouseDown(BPoint where)
{
if (!IsEnabled() || !QueryCurrentMouse(true, B_PRIMARY_MOUSE_BUTTON)) return;
#if 0
font_height fontHeight;
GetFontHeight(&fontHeight);
float sHeight = fontHeight.ascent + fontHeight.descent;
BRect rect = Frame().OffsetToSelf(B_ORIGIN);
rect.InsetBy(5, (rect.Height() - sHeight) / 2);
if (rect.IsValid() == false) return;
rect.right = rect.left + rect.Height();
if (rect.Contains(where) == false) return;
#endif
if ((Flags() &B_NAVIGABLE) && !IsFocus()) MakeFocus();
// SetValue((Value() == B_CONTROL_ON) ?B_CONTROL_OFF :B_CONTROL_ON);
if (Value() == B_CONTROL_ON) return;
SetValue(B_CONTROL_ON);
Invoke();
}
示例14: StringWidth
void
SButton::GetContentPreferredSize(float *width, float *height)
{
if(!width && !height) return;
float string_width = 0, string_height = 0;
if(label)
{
string_width = StringWidth(label);
font_height fheight;
GetFontHeight(&fheight);
string_height = fheight.ascent + fheight.descent + fheight.leading;
}
if(!bitmap)
{
if(width) *width = string_width;
if(height) *height = string_height;
}
else
{
if(label) string_width += 3;
if(width) *width = string_width + bitmap->Bounds().Width();
if(height) *height = MAX(string_height, bitmap->Bounds().Height());
}
}
示例15: min
void
DropDownBase::Init(UINT16 sX, UINT16 sY)
{
mfMouseRegionsCreated = FALSE;
musStartX = sX;
musStartY = sY;
mSelectedEntry = min(mSelectedEntry, mEntryVector.size() - 1);
mNumDisplayedEntries = min(DROPDOWN_REGIONS, mEntryVector.size() );
mFirstShownEntry = max(0, min(mFirstShownEntry, mEntryVector.size() - 1 - mNumDisplayedEntries));
musWidth = 0;
UINT8 size = mEntryVector.size();
for( UINT8 i = 0; i < size; ++i)
{
musWidth = max(musWidth, StringPixLength ( mEntryVector[i].second, DEF_DROPDOWN_FONT ));
}
// account for a bit of space let and right
musWidth += 2 * CITY_NAME_OFFSET;
musUpArrowX = musStartX + musWidth;
musUpArrowY = musStartY + 2;
musFontHeight = GetFontHeight( DEF_DROPDOWN_FONT ); // does not work on init of static objects, as the fonts do not yet exist!
}