本文整理汇总了C++中nsIFrame::GetRect方法的典型用法代码示例。如果您正苦于以下问题:C++ nsIFrame::GetRect方法的具体用法?C++ nsIFrame::GetRect怎么用?C++ nsIFrame::GetRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsIFrame
的用法示例。
在下文中一共展示了nsIFrame::GetRect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: autoSpaceManager
//.........这里部分代码省略.........
nsHTMLReflowMetrics kidDesiredSize(aDesiredSize.mComputeMEW, aDesiredSize.mFlags);
// Reflow the frame
ReflowChild(mContentFrame, aPresContext, kidDesiredSize, kidReflowState,
borderPadding.left + kidReflowState.mComputedMargin.left,
borderPadding.top + mLegendSpace + kidReflowState.mComputedMargin.top,
0, aStatus);
// set the rect. make sure we add the margin back in.
contentRect.SetRect(borderPadding.left,borderPadding.top + mLegendSpace,kidDesiredSize.width ,kidDesiredSize.height);
if (aReflowState.mComputedHeight != NS_INTRINSICSIZE &&
borderPadding.top + mLegendSpace+kidDesiredSize.height > aReflowState.mComputedHeight) {
kidDesiredSize.height = aReflowState.mComputedHeight-(borderPadding.top + mLegendSpace);
}
FinishReflowChild(mContentFrame, aPresContext, &kidReflowState,
kidDesiredSize, contentRect.x, contentRect.y, 0);
if (aDesiredSize.mComputeMEW) {
aDesiredSize.mMaxElementWidth = kidDesiredSize.mMaxElementWidth;
if (eStyleUnit_Coord == aReflowState.mStylePosition->mWidth.GetUnit() &&
NS_INTRINSICSIZE != aReflowState.mComputedWidth)
aDesiredSize.mMaxElementWidth = aReflowState.mComputedWidth;
if (eStyleUnit_Percent == aReflowState.mStylePosition->mWidth.GetUnit())
aDesiredSize.mMaxElementWidth = 0;
aDesiredSize.mMaxElementWidth += borderPadding.left + borderPadding.right;
}
if (aDesiredSize.mFlags & NS_REFLOW_CALC_MAX_WIDTH) {
aDesiredSize.mMaximumWidth = kidDesiredSize.mMaximumWidth +
borderPadding.left + borderPadding.right;
}
NS_FRAME_TRACE_REFLOW_OUT("FieldSet::Reflow", aStatus);
} else {
// if we don't need to reflow just get the old size
contentRect = mContentFrame->GetRect();
const nsStyleMargin* marginStyle = mContentFrame->GetStyleMargin();
nsMargin m(0,0,0,0);
marginStyle->GetMargin(m);
contentRect.Inflate(m);
}
}
// use the computed width if the inner content does not fill it
if (aReflowState.mComputedWidth != NS_INTRINSICSIZE &&
aReflowState.mComputedWidth > contentRect.width) {
contentRect.width = aReflowState.mComputedWidth;
}
if (mLegendFrame) {
// if the content rect is larger then the legend we can align the legend
if (contentRect.width > mLegendRect.width) {
PRInt32 align = ((nsLegendFrame*)mLegendFrame)->GetAlign();
switch(align) {
case NS_STYLE_TEXT_ALIGN_RIGHT:
mLegendRect.x = contentRect.width - mLegendRect.width + borderPadding.left;
break;
case NS_STYLE_TEXT_ALIGN_CENTER:
float p2t;
p2t = aPresContext->PixelsToTwips();
mLegendRect.x = NSIntPixelsToTwips((nscoord) NSToIntRound((float)(contentRect.width/2 - mLegendRect.width/2 + borderPadding.left) / p2t),p2t);
break;
}
} else {
//otherwise make place for the legend
示例2: rect
// this is identical to nsHTMLContainerFrame::Paint except for the background and border.
NS_IMETHODIMP
nsFieldSetFrame::Paint(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsRect& aDirtyRect,
nsFramePaintLayer aWhichLayer,
PRUint32 aFlags)
{
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer) {
// Paint our background and border
PRBool isVisible;
if (NS_SUCCEEDED(IsVisibleForPainting(aPresContext, aRenderingContext, PR_TRUE, &isVisible)) &&
isVisible && mRect.width && mRect.height) {
PRIntn skipSides = GetSkipSides();
const nsStyleBorder* borderStyle = GetStyleBorder();
const nsStylePadding* paddingStyle = GetStylePadding();
nscoord topBorder = borderStyle->GetBorderWidth(NS_SIDE_TOP);
nscoord yoff = 0;
// if the border is smaller than the legend. Move the border down
// to be centered on the legend.
if (topBorder < mLegendRect.height)
yoff = (mLegendRect.height - topBorder)/2;
nsRect rect(0, yoff, mRect.width, mRect.height - yoff);
nsCSSRendering::PaintBackground(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyle,
*paddingStyle, PR_TRUE);
if (mLegendFrame) {
// Use the rect of the legend frame, not mLegendRect, so we draw our
// border under the legend's left and right margins.
const nsRect & legendRect = mLegendFrame->GetRect();
// we should probably use PaintBorderEdges to do this but for now just use clipping
// to achieve the same effect.
// draw left side
nsRect clipRect(rect);
clipRect.width = legendRect.x - rect.x;
clipRect.height = topBorder;
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);
aRenderingContext.PopState();
// draw right side
clipRect = rect;
clipRect.x = legendRect.x + legendRect.width;
clipRect.width -= (legendRect.x + legendRect.width);
clipRect.height = topBorder;
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);
aRenderingContext.PopState();
// draw bottom
clipRect = rect;
clipRect.y += topBorder;
clipRect.height = mRect.height - (yoff + topBorder);
aRenderingContext.PushState();
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect, rect, *borderStyle, mStyleContext, skipSides);
aRenderingContext.PopState();
} else {
nsCSSRendering::PaintBorder(aPresContext, aRenderingContext, this,
aDirtyRect,
nsRect(0,0,mRect.width, mRect.height),
*borderStyle, mStyleContext, skipSides);
}
}
}
PaintChildren(aPresContext, aRenderingContext, aDirtyRect, aWhichLayer);
#ifdef DEBUG
if ((NS_FRAME_PAINT_LAYER_DEBUG == aWhichLayer) && GetShowFrameBorders()) {
if (HasView()) {
aRenderingContext.SetColor(NS_RGB(0,0,255));
}
else {
aRenderingContext.SetColor(NS_RGB(255,0,0));
}
aRenderingContext.DrawRect(0, 0, mRect.width, mRect.height);
//.........这里部分代码省略.........