本文整理汇总了C++中GraphicsContext::drawHighlightForText方法的典型用法代码示例。如果您正苦于以下问题:C++ GraphicsContext::drawHighlightForText方法的具体用法?C++ GraphicsContext::drawHighlightForText怎么用?C++ GraphicsContext::drawHighlightForText使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GraphicsContext
的用法示例。
在下文中一共展示了GraphicsContext::drawHighlightForText方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintSelection
void EllipsisBoxPainter::paintSelection(GraphicsContext& context, const LayoutPoint& boxOrigin, const ComputedStyle& style, const Font& font)
{
Color textColor = m_ellipsisBox.getLineLayoutItem().resolveColor(style, CSSPropertyColor);
Color c = m_ellipsisBox.getLineLayoutItem().selectionBackgroundColor();
if (!c.alpha())
return;
// If the text color ends up being the same as the selection background, invert the selection
// background.
if (textColor == c)
c = Color(0xff - c.red(), 0xff - c.green(), 0xff - c.blue());
GraphicsContextStateSaver stateSaver(context);
LayoutUnit selectionBottom = m_ellipsisBox.root().selectionBottom();
LayoutUnit top = m_ellipsisBox.root().selectionTop();
LayoutUnit h = m_ellipsisBox.root().selectionHeight();
const int deltaY = roundToInt(m_ellipsisBox.getLineLayoutItem().styleRef().isFlippedLinesWritingMode() ? selectionBottom - m_ellipsisBox.logicalBottom() : m_ellipsisBox.logicalTop() - top);
const FloatPoint localOrigin(LayoutPoint(boxOrigin.x(), boxOrigin.y() - deltaY));
FloatRect clipRect(localOrigin, FloatSize(LayoutSize(m_ellipsisBox.logicalWidth(), h)));
context.clip(clipRect);
context.drawHighlightForText(font, constructTextRun(font, m_ellipsisBox.ellipsisStr(), style, TextRun::AllowTrailingExpansion), localOrigin, h, c);
}