本文整理汇总了C++中BFont::GetBoundingBoxesAsGlyphs方法的典型用法代码示例。如果您正苦于以下问题:C++ BFont::GetBoundingBoxesAsGlyphs方法的具体用法?C++ BFont::GetBoundingBoxesAsGlyphs怎么用?C++ BFont::GetBoundingBoxesAsGlyphs使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BFont
的用法示例。
在下文中一共展示了BFont::GetBoundingBoxesAsGlyphs方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: reply
//.........这里部分代码省略.........
free(string);
continue;
}
if (hasDelta) {
escapement_delta delta[length];
message.ReadList(delta, length);
offscreen->DrawString(string, point, delta);
} else
offscreen->DrawString(string, point);
free(string);
reply.Start(RP_DRAW_STRING_RESULT);
reply.Add(token);
reply.Add(offscreen->PenLocation());
reply.Flush();
font_height height;
offscreen->GetFontHeight(&height);
BRect bounds(point, offscreen->PenLocation());
bounds.top -= height.ascent;
bounds.bottom += height.descent;
invalidRegion.Include(bounds);
break;
}
case RP_DRAW_STRING_WITH_OFFSETS:
{
size_t length;
char *string;
message.ReadString(&string, length);
int32 count = UTF8CountChars(string, length);
BPoint offsets[count];
if (message.ReadList(offsets, count) != B_OK) {
free(string);
continue;
}
offscreen->DrawString(string, offsets, count);
free(string);
reply.Start(RP_DRAW_STRING_RESULT);
reply.Add(token);
reply.Add(offscreen->PenLocation());
reply.Flush();
BFont font;
offscreen->GetFont(&font);
BRect boxes[count];
font.GetBoundingBoxesAsGlyphs(string, count, B_SCREEN_METRIC,
boxes);
font_height height;
offscreen->GetFontHeight(&height);
for (int32 i = 0; i < count; i++) {
// TODO: validate
boxes[i].OffsetBy(offsets[i] + BPoint(0, -height.ascent));
invalidRegion.Include(boxes[i]);
}
break;
}
case RP_READ_BITMAP:
{
BRect bounds;
bool drawCursor;
message.Read(bounds);
if (message.Read(drawCursor) != B_OK)
continue;
// TODO: support the drawCursor flag
BBitmap bitmap(bounds, B_BITMAP_NO_SERVER_LINK, B_RGB32);
bitmap.ImportBits(fOffscreenBitmap, bounds.LeftTop(),
BPoint(0, 0), bounds.IntegerWidth() + 1,
bounds.IntegerHeight() + 1);
reply.Start(RP_READ_BITMAP_RESULT);
reply.Add(token);
reply.AddBitmap(&bitmap);
reply.Flush();
break;
}
default:
TRACE_ERROR("unknown protocol code: %u\n", code);
break;
}
if (syncDrawing) {
offscreen->Sync();
Invalidate(&invalidRegion);
}
}
}