本文整理汇总了C++中BStringField::SetWidth方法的典型用法代码示例。如果您正苦于以下问题:C++ BStringField::SetWidth方法的具体用法?C++ BStringField::SetWidth怎么用?C++ BStringField::SetWidth使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BStringField
的用法示例。
在下文中一共展示了BStringField::SetWidth方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawField
void BStringColumn::DrawField(BField* _field, BRect rect, BView* parent)
{
float width = rect.Width() - (2 * kTEXT_MARGIN);
BStringField* field = static_cast<BStringField*>(_field);
if (width != field->Width())
{
BString out_string(field->String());
parent->TruncateString(&out_string, fTruncate, width + 2);
field->SetClippedString(out_string.String());
field->SetWidth(width);
}
DrawString(field->ClippedString(), parent, rect);
}
示例2: out_string
void
BStringColumn::DrawField(BField* _field, BRect rect, BView* parent)
{
float width = rect.Width() - (2 * kTEXT_MARGIN);
BStringField* field = static_cast<BStringField*>(_field);
float fieldWidth = field->Width();
bool updateNeeded = width != fieldWidth;
if (updateNeeded) {
BString out_string(field->String());
float preferredWidth = parent->StringWidth(out_string.String());
if (width < preferredWidth) {
parent->TruncateString(&out_string, fTruncate, width + 2);
field->SetClippedString(out_string.String());
} else
field->SetClippedString("");
field->SetWidth(width);
}
DrawString(field->HasClippedString() ? field->ClippedString()
: field->String(), parent, rect);
}
示例3: truncatedString
void
TeamsColumn::DrawField(BField* field, BRect rect, BView* parent)
{
BBitmapStringField* bitmapField
= dynamic_cast<BBitmapStringField*>(field);
BStringField* stringField = dynamic_cast<BStringField*>(field);
if (bitmapField) {
const BBitmap* bitmap = bitmapField->Bitmap();
// figure out the placement
float x = 0.0;
BRect r = bitmap ? bitmap->Bounds() : BRect(0, 0, 15, 15);
float y = rect.top + ((rect.Height() - r.Height()) / 2);
float width = 0.0;
switch (Alignment()) {
default:
case B_ALIGN_LEFT:
case B_ALIGN_CENTER:
x = rect.left + sTextMargin;
width = rect.right - (x + r.Width()) - (2 * sTextMargin);
r.Set(x + r.Width(), rect.top, rect.right - width, rect.bottom);
break;
case B_ALIGN_RIGHT:
x = rect.right - sTextMargin - r.Width();
width = (x - rect.left - (2 * sTextMargin));
r.Set(rect.left, rect.top, rect.left + width, rect.bottom);
break;
}
if (width != bitmapField->Width()) {
BString truncatedString(bitmapField->String());
parent->TruncateString(&truncatedString, fTruncateMode, width + 2);
bitmapField->SetClippedString(truncatedString.String());
bitmapField->SetWidth(width);
}
// draw the bitmap
if (bitmap) {
parent->SetDrawingMode(B_OP_ALPHA);
parent->DrawBitmap(bitmap, BPoint(x, y));
parent->SetDrawingMode(B_OP_OVER);
}
// draw the string
DrawString(bitmapField->ClippedString(), parent, r);
} else if (stringField) {
float width = rect.Width() - (2 * sTextMargin);
if (width != stringField->Width()) {
BString truncatedString(stringField->String());
parent->TruncateString(&truncatedString, fTruncateMode, width + 2);
stringField->SetClippedString(truncatedString.String());
stringField->SetWidth(width);
}
DrawString(stringField->ClippedString(), parent, rect);
}
}