本文整理汇总了C++中GetFontHeight函数的典型用法代码示例。如果您正苦于以下问题:C++ GetFontHeight函数的具体用法?C++ GetFontHeight怎么用?C++ GetFontHeight使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetFontHeight函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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));
}
开发者ID:DonCN,项目名称:haiku,代码行数:41,代码来源:SlideShowConfigView.cpp
示例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);
}
开发者ID:stippi,项目名称:Clockwerk,代码行数:35,代码来源:ListLabelView.cpp
示例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));
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:60,代码来源:MonitorView.cpp
示例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;
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:27,代码来源:Button.cpp
示例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 );
}
开发者ID:lchsk,项目名称:jaggedalliance2,代码行数:37,代码来源:Editor+Taskbar+Utils.c
示例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);
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:27,代码来源:RadioButton.cpp
示例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;
}
开发者ID:Barrett17,项目名称:Faber,代码行数:31,代码来源:IconButton.cpp
示例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)));
}
开发者ID:jessicah,项目名称:haiku-private,代码行数:34,代码来源:StatusBar.cpp
示例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 ;
}
开发者ID:ModeenF,项目名称:OpenSumIt,代码行数:7,代码来源:StaticString.cpp
示例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;
}
开发者ID:mingpen,项目名称:OpenNT,代码行数:27,代码来源:advanced.c
示例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);
}
开发者ID:open2cerp,项目名称:Open2C-ERP,代码行数:27,代码来源:XColorStatic.cpp
示例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);
}
}
开发者ID:BackupTheBerlios,项目名称:utgs-svn,代码行数:30,代码来源:ListedTextItems.cpp
示例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();
}
开发者ID:D-os,项目名称:BeFree,代码行数:26,代码来源:RadioButton.cpp
示例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());
}
}
开发者ID:Haiku-cn,项目名称:BeCJK,代码行数:28,代码来源:Button.cpp
示例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!
}
开发者ID:RadekSimkanic,项目名称:JA2-1.13,代码行数:27,代码来源:DropDown.cpp
示例16: while
MsgView::MsgView(const string& text, va_list list)
: os::View(os::Rect(0,0,1,1), "MsgView", os::CF_FOLLOW_ALL)
{
const char* butName;
uint i=0;
while((butName = va_arg(list, const char*)) != NULL)
{
os::Button* button = new os::Button(os::Rect(0,0,1,1), butName, butName, new os::Message(i++));
buttons.push_back(button);
AddChild(button);
os::Point size = button->GetPreferredSize(false);
if(size.x > buttonSize.x)
{
buttonSize.x = size.x;
}
if(size.y > buttonSize.y)
{
buttonSize.y = size.y;
}
}
float width = (buttonSize.x + 5) * buttons.size();
int start = 0;
for(i=0;i<=text.size();++i)
{
if(i==text.size() || text[i]=='\n')
{
std::string line(text, start, i-start);
lines.push_back(line);
float strLen = GetStringWidth(line.c_str())+20;
if(strLen>width)
{
width=strLen;
}
start = i + 1;
}
}
os::font_height fontHeight;
GetFontHeight(&fontHeight);
lineHeight = fontHeight.ascender + fontHeight.descender + fontHeight.line_gap;
float height=lines.size()*lineHeight;
height+=buttonSize.y + 30;
float y=height - buttonSize.y - 5;
float x=width - buttons.size() * (buttonSize.x + 5) - 5;
for(i=0;i<buttons.size();++i)
{
buttons[i]->SetFrame(os::Rect(x, y, x+buttonSize.x-1, y+buttonSize.y-1));
x+=buttonSize.x+5;
}
minSize.x=width;
minSize.y=height;
}
开发者ID:PyroOS,项目名称:Pyro,代码行数:60,代码来源:Dialogs.cpp
示例17: AttachedToWindow
void FolderPanel :: AttachedToWindow( void )
{
BRect r ;
if( Parent() )
r = Parent()->Frame() ;
else
r = Window()->Frame() ;
font_height fh ;
GetFontHeight( &fh ) ;
r.top = 0 ;
r.right = r.Width() ;
r.left = 0 ;
r.bottom = 3 * (fh.ascent + fh.descent + fh.leading ) ;
MoveTo( 0,0 ) ;
ResizeTo( r.right, r.bottom ) ;
r.left = 25 ;
r.right = r.right - r.left ;
r.top = r.Height()/5 ;
r.bottom = r.bottom - r.top ;
fpFolderPU->MoveTo( r.left , r.top ) ;
fpFolderPU->ResizeTo( r.Width() , r.Height() ) ;
fpFolderPU->SetViewColor( ViewColor() ) ;
fpFolderPU->SetLowColor( ViewColor() ) ;
AddChild( fpFolderPU ) ;
}
开发者ID:HaikuArchives,项目名称:TraX,代码行数:32,代码来源:FolderPanel.cpp
示例18: BView
BTitleView::BTitleView(BPoseView* view)
:
BView("BTitleView", B_WILL_DRAW),
fPoseView(view),
fTitleList(10, true),
fHorizontalResizeCursor(B_CURSOR_ID_RESIZE_EAST_WEST),
fPreviouslyClickedColumnTitle(0),
fPreviousLeftClickTime(0),
fTrackingState(NULL)
{
SetHighUIColor(B_PANEL_BACKGROUND_COLOR);
SetLowUIColor(B_PANEL_BACKGROUND_COLOR);
#if APP_SERVER_CLEARS_BACKGROUND
SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
#else
SetViewColor(B_TRANSPARENT_COLOR);
#endif
BFont font(be_plain_font);
font.SetSize(floorf(be_plain_font->Size() * 0.75f));
SetFont(&font);
font_height height;
GetFontHeight(&height);
fPreferredHeight = ceilf(height.ascent + height.descent) + 2;
Reset();
}
开发者ID:bhanug,项目名称:haiku,代码行数:28,代码来源:TitleView.cpp
示例19: BControl
// --------------------------------------------------------------
CollapsableBox::CollapsableBox
(
BRect frame,
const char *name,
const char *label,
BMessage *msg,
uint32 resize_mask,
uint32 flags
)
: BControl(frame, name, label, msg, resize_mask,
flags | B_WILL_DRAW | B_FRAME_EVENTS | B_NAVIGABLE | B_NAVIGABLE_JUMP)
{
m_pressing = false;
font_height fh;
GetFontHeight(&fh);
float min_height = (float) ceil(6.0f + fh.ascent + fh.descent) + 2.0f;
if (Bounds().Height() < min_height)
ResizeTo(Bounds().Width(), min_height);
m_collapsed_rect = BRect(0, 0, Bounds().Width(), min_height);
m_expanded_rect = Bounds();
SetValue(B_CONTROL_ON);
}
开发者ID:diversys,项目名称:sanity,代码行数:26,代码来源:CollapsableBox.cpp
示例20: GetFontHeight
//------------------------------------------------------------------------------
void BMenuField::DrawLabel(BRect bounds, BRect update)
{
font_height fh;
GetFontHeight(&fh);
if (Label())
{
SetLowColor(ViewColor());
float y = (float)ceil(fh.ascent + fh.descent + fh.leading) + 2.0f;
float x;
switch (fAlign)
{
case B_ALIGN_RIGHT:
x = fDivider - StringWidth(Label()) - 3.0f;
break;
case B_ALIGN_CENTER:
x = fDivider - StringWidth(Label()) / 2.0f;
break;
default:
x = 3.0f;
break;
}
SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
IsEnabled() ? B_DARKEN_MAX_TINT : B_DISABLED_LABEL_TINT));
DrawString(Label(), BPoint(x, y));
}
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:33,代码来源:MenuField.cpp
注:本文中的GetFontHeight函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论