本文整理汇总了C++中BStringView::StringWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ BStringView::StringWidth方法的具体用法?C++ BStringView::StringWidth怎么用?C++ BStringView::StringWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BStringView
的用法示例。
在下文中一共展示了BStringView::StringWidth方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AttachedToWindow
void VisualColorControl::AttachedToWindow()
{
BPoint *points = new BPoint[3];
points[0] = BPoint(0,0);
points[1] = BPoint(-4,-4);
points[2] = BPoint(4,-4);
// calculate the initial ramps
CalcRamps();
// create the arrow-pictures
BeginPicture(new BPicture());
SetHighColor(100,100,255);
FillPolygon(points,3);
SetHighColor(0,0,0);
StrokePolygon(points,3);
down_arrow = EndPicture();
if (Parent() != NULL)
SetViewColor(Parent()->ViewColor());
BStringView *sv = new BStringView(BRect(0,COLOR_HEIGHT/2,1,COLOR_HEIGHT/2),"label view",label1);
AddChild(sv);
float sv_width = sv->StringWidth(label1);
sv_width = max_c(sv_width,sv->StringWidth(label2));
sv_width = max_c(sv_width,sv->StringWidth(label3));
font_height fHeight;
sv->GetFontHeight(&fHeight);
sv->ResizeTo(sv_width,fHeight.ascent+fHeight.descent);
sv->MoveBy(0,-(fHeight.ascent+fHeight.descent)/2.0);
BRect sv_frame = sv->Frame();
sv_frame.OffsetBy(0,COLOR_HEIGHT);
sv->SetAlignment(B_ALIGN_CENTER);
sv = new BStringView(sv_frame,"label view",label2);
AddChild(sv);
sv->SetAlignment(B_ALIGN_CENTER);
sv_frame.OffsetBy(0,COLOR_HEIGHT);
sv = new BStringView(sv_frame,"label view",label3);
AddChild(sv);
sv->SetAlignment(B_ALIGN_CENTER);
sv_frame.OffsetBy(0,COLOR_HEIGHT);
sv = new BStringView(sv_frame,"label view",label4);
AddChild(sv);
sv->SetAlignment(B_ALIGN_CENTER);
ramp_left_edge = sv->Bounds().IntegerWidth()+2;
ResizeBy(ramp_left_edge,0);
delete[] points;
}