本文整理汇总了C++中BView::SetFontSize方法的典型用法代码示例。如果您正苦于以下问题:C++ BView::SetFontSize方法的具体用法?C++ BView::SetFontSize怎么用?C++ BView::SetFontSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BView
的用法示例。
在下文中一共展示了BView::SetFontSize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: FrameResized
void CounterView::FrameResized (float width, float height)
{
BRect BitmapRect (0, 0, width, height);
char TempString [40];
m_BndRect = Bounds ();
m_MovingDotSize = (int) (height / 20);
if (m_MovingDotSize < 1)
m_MovingDotSize = 1;
m_MoveSpeed = m_MovingDotSize / 2.0;
// Resize the offscreen bitmap and its view.
if (m_BackingBitmap != NULL)
{
m_BackingBitmap->RemoveChild (&m_BackingView);
delete m_BackingBitmap;
m_BackingBitmap = NULL;
}
m_BackingView.ResizeTo (width, height);
m_BackingBitmap = new BBitmap (BitmapRect, B_RGBA32, true /* Accepts subviews */);
if (!m_BackingBitmap->IsValid ())
{
delete m_BackingBitmap;
m_BackingBitmap = NULL;
}
else
{
m_BackingBitmap->AddChild (&m_BackingView);
m_BackingBitmap->Lock ();
m_BackingView.SetDrawingMode (B_OP_ALPHA);
m_BackingView.SetFontSize (height * 0.8);
sprintf (TempString, "%d", m_CurrentCount);
m_TextStartPoint.x = width / 2 - m_BackingView.StringWidth (TempString) / 2;
m_TextStartPoint.y = height / 2 + height * 0.25;
m_BackingBitmap->Unlock ();
}
}
示例2: clipRect
// This function returns the number of pixels of the text that
// were clipped if the text does not fit into the clipping rect.
// If the text all fit, it returns 0.
int
BeOSCanvas::RenderText( int iFontHeight, Rect& oClipRect,
string& oText, AlignEnum eAlign,
Font* pFont, const Color& oColor,
bool bBold, bool bItalic, bool bUnderline )
{
Erase( oClipRect );
BView* v = m_pBufferBitmap->OffscreenView();
if ( !v ) return 0;
BBitmap* bitmap = m_pBufferBitmap->GetBBitmap();
assert( bitmap );
BFont font;
font_height fontHeight;
BRect clipRect( float(oClipRect.x1), float(oClipRect.y1),
float(oClipRect.x2-1), float(oClipRect.y2-1) );
BRegion clipRegion;
clipRegion.Set( clipRect );
if ( !bitmap->Lock() )
{
puts( "lock failed" );
return 0;
}
v->ConstrainClippingRegion( &clipRegion );
v->SetDrawingMode( B_OP_OVER );
if ( bBold )
{
v->SetFont( be_bold_font );
}
else
{
v->SetFont( be_plain_font );
}
v->SetFontSize( (float)iFontHeight - 1 );
v->GetFont( &font );
font.GetHeight( &fontHeight );
float width = v->StringWidth(oText.c_str(), oText.size());
if(eAlign == eCenter)
v->MovePenTo( float(oClipRect.x1) +
(float(oClipRect.x2 - oClipRect.x1) - width)/2,
float(oClipRect.y2-fontHeight.descent) );
else if (eAlign == eRight)
v->MovePenTo( float(oClipRect.x2) - width,
float(oClipRect.y2-fontHeight.descent) );
else
v->MovePenTo( float(oClipRect.x1),
float(oClipRect.y2-fontHeight.descent) );
v->DrawString( oText.c_str() );
v->Sync();
bitmap->Unlock();
Invalidate( oClipRect );
return (width < oClipRect.Width()) ? 0 : int(width - oClipRect.Width());
}