本文整理汇总了C++中nsIRenderingContext::ThebesContext方法的典型用法代码示例。如果您正苦于以下问题:C++ nsIRenderingContext::ThebesContext方法的具体用法?C++ nsIRenderingContext::ThebesContext怎么用?C++ nsIRenderingContext::ThebesContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsIRenderingContext
的用法示例。
在下文中一共展示了nsIRenderingContext::ThebesContext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: textRect
void
nsTextBoxFrame::PaintTitle(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt)
{
if (mTitle.IsEmpty())
return;
nsRect textRect(CalcTextRect(aRenderingContext, aPt));
// Paint the text shadow before doing any foreground stuff
const nsStyleText* textStyle = GetStyleText();
if (textStyle->mTextShadow) {
// Text shadow happens with the last value being painted at the back,
// ie. it is painted first.
for (PRUint32 i = textStyle->mTextShadow->Length(); i > 0; --i) {
PaintOneShadow(aRenderingContext.ThebesContext(),
textRect,
textStyle->mTextShadow->ShadowAt(i - 1),
GetStyleColor()->mColor,
aDirtyRect);
}
}
DrawText(aRenderingContext, textRect, nsnull);
}
示例2: pt
void
nsTextBoxFrame::DrawText(nsIRenderingContext& aRenderingContext,
const nsRect& aTextRect,
const nscolor* aOverrideColor)
{
nsPresContext* presContext = PresContext();
// paint the title
nscolor overColor;
nscolor underColor;
nscolor strikeColor;
nsStyleContext* context = mStyleContext;
PRUint8 decorations = NS_STYLE_TEXT_DECORATION_NONE; // Begin with no decorations
PRUint8 decorMask = NS_STYLE_TEXT_DECORATION_UNDERLINE | NS_STYLE_TEXT_DECORATION_OVERLINE |
NS_STYLE_TEXT_DECORATION_LINE_THROUGH; // A mask of all possible decorations.
PRBool hasDecorations = context->HasTextDecorations();
do { // find decoration colors
const nsStyleTextReset* styleText = context->GetStyleTextReset();
if (decorMask & styleText->mTextDecoration) { // a decoration defined here
nscolor color = aOverrideColor ? *aOverrideColor : context->GetStyleColor()->mColor;
if (NS_STYLE_TEXT_DECORATION_UNDERLINE & decorMask & styleText->mTextDecoration) {
underColor = color;
decorMask &= ~NS_STYLE_TEXT_DECORATION_UNDERLINE;
decorations |= NS_STYLE_TEXT_DECORATION_UNDERLINE;
}
if (NS_STYLE_TEXT_DECORATION_OVERLINE & decorMask & styleText->mTextDecoration) {
overColor = color;
decorMask &= ~NS_STYLE_TEXT_DECORATION_OVERLINE;
decorations |= NS_STYLE_TEXT_DECORATION_OVERLINE;
}
if (NS_STYLE_TEXT_DECORATION_LINE_THROUGH & decorMask & styleText->mTextDecoration) {
strikeColor = color;
decorMask &= ~NS_STYLE_TEXT_DECORATION_LINE_THROUGH;
decorations |= NS_STYLE_TEXT_DECORATION_LINE_THROUGH;
}
}
if (0 != decorMask) {
context = context->GetParent();
if (context) {
hasDecorations = context->HasTextDecorations();
}
}
} while (context && hasDecorations && (0 != decorMask));
nsCOMPtr<nsIFontMetrics> fontMet;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet));
nscoord offset;
nscoord size;
nscoord ascent;
fontMet->GetMaxAscent(ascent);
nscoord baseline =
presContext->RoundAppUnitsToNearestDevPixels(aTextRect.y + ascent);
nsRefPtr<gfxContext> ctx = aRenderingContext.ThebesContext();
gfxPoint pt(presContext->AppUnitsToGfxUnits(aTextRect.x),
presContext->AppUnitsToGfxUnits(aTextRect.y));
gfxFloat width = presContext->AppUnitsToGfxUnits(aTextRect.width);
gfxFloat ascentPixel = presContext->AppUnitsToGfxUnits(ascent);
// Underlines are drawn before overlines, and both before the text
// itself, per http://www.w3.org/TR/CSS21/zindex.html point 7.2.1.4.1.1.
// (We don't apply this rule to the access-key underline because we only
// find out where that is as a side effect of drawing the text, in the
// general case -- see below.)
if (decorations & (NS_FONT_DECORATION_OVERLINE |
NS_FONT_DECORATION_UNDERLINE)) {
fontMet->GetUnderline(offset, size);
gfxFloat offsetPixel = presContext->AppUnitsToGfxUnits(offset);
gfxFloat sizePixel = presContext->AppUnitsToGfxUnits(size);
if (decorations & NS_FONT_DECORATION_UNDERLINE) {
nsCSSRendering::PaintDecorationLine(ctx, underColor,
pt, gfxSize(width, sizePixel),
ascentPixel, offsetPixel,
NS_STYLE_TEXT_DECORATION_UNDERLINE,
nsCSSRendering::DECORATION_STYLE_SOLID);
}
if (decorations & NS_FONT_DECORATION_OVERLINE) {
nsCSSRendering::PaintDecorationLine(ctx, overColor,
pt, gfxSize(width, sizePixel),
ascentPixel, ascentPixel,
NS_STYLE_TEXT_DECORATION_OVERLINE,
nsCSSRendering::DECORATION_STYLE_SOLID);
}
}
aRenderingContext.SetFont(fontMet);
CalculateUnderline(aRenderingContext);
aRenderingContext.SetColor(aOverrideColor ? *aOverrideColor : GetStyleColor()->mColor);
#ifdef IBMBIDI
nsresult rv = NS_ERROR_FAILURE;
if (mState & NS_FRAME_IS_BIDI) {
//.........这里部分代码省略.........