本文整理汇总了C++中nsIRenderingContext::Scale方法的典型用法代码示例。如果您正苦于以下问题:C++ nsIRenderingContext::Scale方法的具体用法?C++ nsIRenderingContext::Scale怎么用?C++ nsIRenderingContext::Scale使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsIRenderingContext
的用法示例。
在下文中一共展示了nsIRenderingContext::Scale方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PresContext
//------------------------------------------------------------------------------
void
nsSimplePageSequenceFrame::PaintPageSequence(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt) {
nsRect rect = aDirtyRect;
float scale = PresContext()->GetPrintPreviewScale();
aRenderingContext.PushState();
nsPoint framePos = aPt;
aRenderingContext.Translate(framePos.x, framePos.y);
rect -= framePos;
aRenderingContext.Scale(scale, scale);
rect.ScaleRoundOut(1.0f / scale);
// Now the rect and the rendering coordinates are are relative to this frame.
// Loop over the pages and paint them.
nsIFrame* child = GetFirstChild(nsnull);
while (child) {
nsPoint pt = child->GetPosition();
// The rendering context has to be translated before each call to PaintFrame
aRenderingContext.PushState();
aRenderingContext.Translate(pt.x, pt.y);
nsLayoutUtils::PaintFrame(&aRenderingContext, child,
nsRegion(rect - pt), NS_RGBA(0,0,0,0));
aRenderingContext.PopState();
child = child->GetNextSibling();
}
aRenderingContext.PopState();
}
示例2: clipRect
//------------------------------------------------------------------------------
void
nsPageFrame::PaintPageContent(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt) {
nsIFrame* pageContentFrame = mFrames.FirstChild();
nsRect rect = aDirtyRect;
float scale = PresContext()->GetPageScale();
aRenderingContext.PushState();
nsPoint framePos = aPt + pageContentFrame->GetOffsetTo(this);
aRenderingContext.Translate(framePos.x, framePos.y);
// aPt translates to coords relative to this, then margins translate to
// pageContentFrame's coords
rect -= framePos;
aRenderingContext.Scale(scale, scale);
rect.ScaleRoundOut(1.0f / scale);
// Make sure we don't draw where we aren't supposed to draw, especially
// when printing selection
nsRect clipRect(nsPoint(0, 0), pageContentFrame->GetSize());
// Note: this computation matches how we compute maxSize.height
// in nsPageFrame::Reflow
nscoord expectedPageContentHeight =
NSToCoordCeil((GetSize().height - mPD->mReflowMargin.TopBottom()) / scale);
if (clipRect.height > expectedPageContentHeight) {
// We're doing print-selection, with one long page-content frame.
// Clip to the appropriate page-content slice for the current page.
NS_ASSERTION(mPageNum > 0, "page num should be positive");
// Note: The pageContentFrame's y-position has been set such that a zero
// y-value matches the top edge of the current page. So, to clip to the
// current page's content (in coordinates *relative* to the page content
// frame), we just negate its y-position and add the top margin.
clipRect.y = NSToCoordCeil((-pageContentFrame->GetRect().y +
mPD->mReflowMargin.top) / scale);
clipRect.height = expectedPageContentHeight;
NS_ASSERTION(clipRect.y < pageContentFrame->GetSize().height,
"Should be clipping to region inside the page content bounds");
}
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
nsRect backgroundRect = nsRect(nsPoint(0, 0), pageContentFrame->GetSize());
nsCSSRendering::PaintBackground(PresContext(), aRenderingContext, this,
rect, backgroundRect,
nsCSSRendering::PAINTBG_SYNC_DECODE_IMAGES);
nsLayoutUtils::PaintFrame(&aRenderingContext, pageContentFrame,
nsRegion(rect), NS_RGBA(0,0,0,0),
nsLayoutUtils::PAINT_SYNC_DECODE_IMAGES);
aRenderingContext.PopState();
}
示例3: clipRect
//------------------------------------------------------------------------------
void
nsPageFrame::PaintPageContent(nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsPoint aPt) {
nsIFrame* pageContentFrame = mFrames.FirstChild();
nsRect rect = aDirtyRect;
float scale = PresContext()->GetPageScale();
aRenderingContext.PushState();
nsPoint framePos = aPt + pageContentFrame->GetOffsetTo(this);
aRenderingContext.Translate(framePos.x, framePos.y);
// aPt translates to coords relative to this, then margins translate to
// pageContentFrame's coords
rect -= framePos;
aRenderingContext.Scale(scale, scale);
rect.ScaleRoundOut(1.0f / scale);
// Make sure we don't draw where we aren't supposed to draw, especially
// when printing selection
nsRect clipRect(nsPoint(0, 0), pageContentFrame->GetSize());
// Note: this computation matches how we compute maxSize.height
// in nsPageFrame::Reflow
nscoord expectedPageContentHeight =
NSToCoordCeil((GetSize().height - mPD->mReflowMargin.TopBottom()) / scale);
if (clipRect.height > expectedPageContentHeight) {
// We're doing print-selection, with one long page-content frame.
// Clip to the appropriate page-content slice for the current page.
NS_ASSERTION(mPageNum > 0, "page num should be positive");
clipRect.y = expectedPageContentHeight * (mPageNum - 1);
clipRect.height = expectedPageContentHeight;
NS_ASSERTION(clipRect.y < pageContentFrame->GetSize().height,
"Should be clipping to region inside the page content bounds");
}
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
const nsStyleBorder* border = GetStyleBorder();
const nsStylePadding* padding = GetStylePadding();
nsRect backgroundRect = nsRect(nsPoint(0, 0), pageContentFrame->GetSize());
nsCSSRendering::PaintBackground(PresContext(), aRenderingContext, this,
rect, backgroundRect, *border, *padding,
PR_TRUE);
nsLayoutUtils::PaintFrame(&aRenderingContext, pageContentFrame,
nsRegion(rect), NS_RGBA(0,0,0,0));
aRenderingContext.PopState();
}