本文整理汇总了C++中nsIRenderingContext::FillRect方法的典型用法代码示例。如果您正苦于以下问题:C++ nsIRenderingContext::FillRect方法的具体用法?C++ nsIRenderingContext::FillRect怎么用?C++ nsIRenderingContext::FillRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsIRenderingContext
的用法示例。
在下文中一共展示了nsIRenderingContext::FillRect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: rect
void
nsPageFrame::PaintPrintPreviewBackground(nsIRenderingContext& aRenderingContext,
nsPoint aPt)
{
// fill page with White
aRenderingContext.SetColor(NS_RGB(255,255,255));
// REVIEW: this used to have rect's width and height be the
// mClipRect if specialClipIsSet ... but that seems completely bogus
// and inconsistent with the painting of the shadow below
nsRect rect(aPt, GetSize());
rect.width -= mPD->mShadowSize.width;
rect.height -= mPD->mShadowSize.height;
aRenderingContext.FillRect(rect);
// draw line around outside of page
aRenderingContext.SetColor(NS_RGB(0,0,0));
aRenderingContext.DrawRect(rect);
if (mPD->mShadowSize.width > 0 && mPD->mShadowSize.height > 0) {
aRenderingContext.SetColor(NS_RGB(51,51,51));
nsRect r(aPt.x,aPt.y, mRect.width, mRect.height);
nsRect shadowRect;
shadowRect.x = r.x + r.width - mPD->mShadowSize.width;
shadowRect.y = r.y + mPD->mShadowSize.height;
shadowRect.width = mPD->mShadowSize.width;
shadowRect.height = r.height - mPD->mShadowSize.height;
aRenderingContext.FillRect(shadowRect);
shadowRect.x = r.x + mPD->mShadowSize.width;
shadowRect.y = r.y + r.height - mPD->mShadowSize.height;
shadowRect.width = r.width - mPD->mShadowSize.width;
shadowRect.height = mPD->mShadowSize.height;
aRenderingContext.FillRect(shadowRect);
}
}
示例2: NSIntPixelsToTwips
NS_IMETHODIMP
nsPlaceholderFrame::Paint(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags)
{
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
float p2t;
p2t = aPresContext->PixelsToTwips();
aRenderingContext.SetColor(NS_RGB(0, 255, 255));
nscoord x = NSIntPixelsToTwips(-5, p2t);
aRenderingContext.FillRect(x, 0, NSIntPixelsToTwips(13, p2t),
NSIntPixelsToTwips(3, p2t));
nscoord y = NSIntPixelsToTwips(-10, p2t);
aRenderingContext.FillRect(0, y, NSIntPixelsToTwips(3, p2t),
NSIntPixelsToTwips(10, p2t));
}
DO_GLOBAL_REFLOW_COUNT_DSP("nsPlaceholderFrame", &aRenderingContext);
return NS_OK;
}
示例3: GetStyleColor
NS_IMETHODIMP
nsMathMLmsqrtFrame::Paint(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags)
{
/////////////
// paint the content we are square-rooting
nsresult rv = nsMathMLContainerFrame::Paint(aPresContext, aRenderingContext,
aDirtyRect, aWhichLayer);
/////////////
// paint the sqrt symbol
if (!NS_MATHML_HAS_ERROR(mPresentationData.flags)) {
mSqrChar.Paint(aPresContext, aRenderingContext,
aDirtyRect, aWhichLayer, this);
if (NS_FRAME_PAINT_LAYER_FOREGROUND == aWhichLayer &&
mStyleContext->GetStyleVisibility()->IsVisible() &&
!mBarRect.IsEmpty()) {
// paint the overline bar
const nsStyleColor* color = GetStyleColor();
aRenderingContext.SetColor(color->mColor);
aRenderingContext.FillRect(mBarRect);
}
#if defined(NS_DEBUG) && defined(SHOW_BOUNDING_BOX)
// for visual debug
if (NS_MATHML_PAINT_BOUNDING_METRICS(mPresentationData.flags)) {
nsRect rect;
mSqrChar.GetRect(rect);
nsBoundingMetrics bm;
mSqrChar.GetBoundingMetrics(bm);
aRenderingContext.SetColor(NS_RGB(255,0,0));
nscoord x = rect.x + bm.leftBearing;
nscoord y = rect.y;
nscoord w = bm.rightBearing - bm.leftBearing;
nscoord h = bm.ascent + bm.descent;
aRenderingContext.DrawRect(x,y,w,h);
}
#endif
}
return rv;
}
示例4: CalcBorderPadding
/*virtual*/ void
nsHTMLContainerFrame::PaintTextDecorationLines(
nsIRenderingContext& aRenderingContext,
nscolor aColor,
nscoord aOffset,
nscoord aAscent,
nscoord aSize)
{
nsMargin bp;
CalcBorderPadding(bp);
PRIntn skip = GetSkipSides();
NS_FOR_CSS_SIDES(side) {
if (skip & (1 << side)) {
bp.side(side) = 0;
}
}
aRenderingContext.SetColor(aColor);
nscoord innerWidth = mRect.width - bp.left - bp.right;
aRenderingContext.FillRect(bp.left,
bp.top + aAscent - aOffset, innerWidth, aSize);
}
示例5: pt
//.........这里部分代码省略.........
// 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) {
presContext->SetBidiEnabled();
nsBidiPresUtils* bidiUtils = presContext->GetBidiUtils();
if (bidiUtils) {
const nsStyleVisibility* vis = GetStyleVisibility();
nsBidiDirection direction = (NS_STYLE_DIRECTION_RTL == vis->mDirection) ? NSBIDI_RTL : NSBIDI_LTR;
if (mAccessKeyInfo && mAccessKeyInfo->mAccesskeyIndex != kNotFound) {
// We let the RenderText function calculate the mnemonic's
// underline position for us.
nsBidiPositionResolve posResolve;
posResolve.logicalIndex = mAccessKeyInfo->mAccesskeyIndex;
rv = bidiUtils->RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
presContext, aRenderingContext,
aTextRect.x, baseline,
&posResolve,
1);
mAccessKeyInfo->mBeforeWidth = posResolve.visualLeftTwips;
mAccessKeyInfo->mAccessWidth = posResolve.visualWidth;
}
else
{
rv = bidiUtils->RenderText(mCroppedTitle.get(), mCroppedTitle.Length(), direction,
presContext, aRenderingContext,
aTextRect.x, baseline);
}
}
}
if (NS_FAILED(rv) )
#endif // IBMBIDI
{
aRenderingContext.SetTextRunRTL(PR_FALSE);
if (mAccessKeyInfo && mAccessKeyInfo->mAccesskeyIndex != kNotFound) {
// In the simple (non-BiDi) case, we calculate the mnemonic's
// underline position by getting the text metric.
// XXX are attribute values always two byte?
if (mAccessKeyInfo->mAccesskeyIndex > 0)
aRenderingContext.GetWidth(mCroppedTitle.get(), mAccessKeyInfo->mAccesskeyIndex,
mAccessKeyInfo->mBeforeWidth);
else
mAccessKeyInfo->mBeforeWidth = 0;
}
aRenderingContext.DrawString(mCroppedTitle, aTextRect.x, baseline);
}
if (mAccessKeyInfo && mAccessKeyInfo->mAccesskeyIndex != kNotFound) {
aRenderingContext.FillRect(aTextRect.x + mAccessKeyInfo->mBeforeWidth,
aTextRect.y + mAccessKeyInfo->mAccessOffset,
mAccessKeyInfo->mAccessWidth,
mAccessKeyInfo->mAccessUnderlineSize);
}
// Strikeout is drawn on top of the text, per
// http://www.w3.org/TR/CSS21/zindex.html point 7.2.1.4.1.1.
if (decorations & NS_FONT_DECORATION_LINE_THROUGH) {
fontMet->GetStrikeout(offset, size);
gfxFloat offsetPixel = presContext->AppUnitsToGfxUnits(offset);
gfxFloat sizePixel = presContext->AppUnitsToGfxUnits(size);
nsCSSRendering::PaintDecorationLine(ctx, strikeColor,
pt, gfxSize(width, sizePixel), ascentPixel, offsetPixel,
NS_STYLE_TEXT_DECORATION_LINE_THROUGH,
nsCSSRendering::DECORATION_STYLE_SOLID);
}
}