本文整理汇总了C++中BFont::GetEscapements方法的典型用法代码示例。如果您正苦于以下问题:C++ BFont::GetEscapements方法的具体用法?C++ BFont::GetEscapements怎么用?C++ BFont::GetEscapements使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BFont
的用法示例。
在下文中一共展示了BFont::GetEscapements方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: menuPrivate
void
BMenuItem::DrawContent()
{
MenuPrivate menuPrivate(fSuper);
menuPrivate.CacheFontInfo();
fSuper->MovePenBy(0, menuPrivate.Ascent());
BPoint lineStart = fSuper->PenLocation();
float labelWidth, labelHeight;
GetContentSize(&labelWidth, &labelHeight);
fSuper->SetDrawingMode(B_OP_OVER);
float frameWidth = fBounds.Width();
if (menuPrivate.State() == MENU_STATE_CLOSED) {
float rightMargin, leftMargin;
menuPrivate.GetItemMargins(&leftMargin, NULL, &rightMargin, NULL);
frameWidth = fSuper->Frame().Width() - (rightMargin + leftMargin);
}
// truncate if needed
if (frameWidth > labelWidth)
fSuper->DrawString(fLabel);
else {
char *truncatedLabel = new char[strlen(fLabel) + 4];
TruncateLabel(frameWidth, truncatedLabel);
fSuper->DrawString(truncatedLabel);
delete[] truncatedLabel;
}
if (fSuper->AreTriggersEnabled() && fTriggerIndex != -1) {
float escapements[fTriggerIndex + 1];
BFont font;
fSuper->GetFont(&font);
font.GetEscapements(fLabel, fTriggerIndex + 1, escapements);
for (int32 i = 0; i < fTriggerIndex; i++)
lineStart.x += escapements[i] * font.Size();
lineStart.x--;
lineStart.y++;
BPoint lineEnd(lineStart);
lineEnd.x += escapements[fTriggerIndex] * font.Size();
fSuper->StrokeLine(lineStart, lineEnd);
}
}
示例2: DrawContent
virtual void DrawContent()
{
BRect b = Frame();
BMenu *parent = Menu();
BPoint loc = parent->PenLocation();
enum {
W_CHAR = 0,
A_CHAR = 1,
OPEN_CHAR = 2,
CLOSE_CHAR = 3,
SPACE_CHAR = 4,
NUM_CHARS = 5
};
float escapements[NUM_CHARS];
BFont font;
parent->GetFont(&font);
font.GetEscapements("WA() ", NUM_CHARS, escapements);
for (int32 i=0; i<NUM_CHARS; i++) {
escapements[i] *= font.Size();
}
const float blockWidth = escapements[W_CHAR]+escapements[A_CHAR];
const rgb_color old_col = parent->HighColor();
font_height fh;
const bool showInitial = !CompareColors(fInitialColor, fColor);
b.InsetBy(1, 1);
b.bottom -= 1;
b.left = loc.x;
if (showInitial) {
parent->GetFontHeight(&fh);
parent->DrawString("(", BPoint(b.left, loc.y+fh.ascent));
}
b.left += escapements[OPEN_CHAR];
b.InsetBy(2, 2);
b.right = b.left + escapements[W_CHAR];
if (showInitial) {
parent->SetHighColor(fInitialColor);
parent->FillRect(b);
}
b.InsetBy(-1, -1);
if (showInitial) {
parent->SetHighColor(old_col);
parent->StrokeRect(b);
}
b.InsetBy(-1, -1);
if (showInitial) {
parent->DrawString(")", BPoint(b.right+1, loc.y+fh.ascent));
}
b.right += escapements[CLOSE_CHAR] + 1;
b.left = b.right + escapements[SPACE_CHAR];
b.right = b.left + blockWidth;
parent->SetHighColor(fColor);
parent->FillRect(b);
parent->SetHighColor(old_col);
b.InsetBy(-1, -1);
parent->StrokeRect(b);
parent->MovePenTo(b.right + escapements[SPACE_CHAR]*2 + 2, loc.y);
BMenuItem::DrawContent();
}