本文整理汇总了C++中nsIRenderingContext::DrawLine方法的典型用法代码示例。如果您正苦于以下问题:C++ nsIRenderingContext::DrawLine方法的具体用法?C++ nsIRenderingContext::DrawLine怎么用?C++ nsIRenderingContext::DrawLine使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsIRenderingContext
的用法示例。
在下文中一共展示了nsIRenderingContext::DrawLine方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void DefaultArea::Draw(nsIFrame* aFrame, nsIRenderingContext& aRC)
{
if (mHasFocus) {
nsRect r = aFrame->GetRect();
r.MoveTo(0, 0);
nscoord x1 = r.x;
nscoord y1 = r.y;
const nscoord kOnePixel = nsPresContext::CSSPixelsToAppUnits(1);
nscoord x2 = r.XMost() - kOnePixel;
nscoord y2 = r.YMost() - kOnePixel;
// XXX aRC.DrawRect(r) result is ugly, that's why we use DrawLine.
aRC.DrawLine(x1, y1, x1, y2);
aRC.DrawLine(x1, y2, x2, y2);
aRC.DrawLine(x1, y1, x2, y1);
aRC.DrawLine(x2, y1, x2, y2);
}
}
示例2: PaintFocus
void nsComboboxControlFrame::PaintFocus(nsIRenderingContext& aRenderingContext,
nsPoint aPt)
{
/* Do we need to do anything? */
if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::disabled) ||
mFocused != this)
return;
aRenderingContext.PushState();
nsRect clipRect = mDisplayFrame->GetRect() + aPt;
aRenderingContext.SetClipRect(clipRect, nsClipCombine_kIntersect);
// REVIEW: Why does the old code paint mDisplayFrame again? We've
// already painted it in the children above. So clipping it here won't do
// us much good.
/////////////////////
// draw focus
aRenderingContext.SetLineStyle(nsLineStyle_kDotted);
aRenderingContext.SetColor(GetStyleColor()->mColor);
//aRenderingContext.DrawRect(clipRect);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
clipRect.width -= onePixel;
clipRect.height -= onePixel;
aRenderingContext.DrawLine(clipRect.x, clipRect.y,
clipRect.x+clipRect.width, clipRect.y);
aRenderingContext.DrawLine(clipRect.x+clipRect.width, clipRect.y,
clipRect.x+clipRect.width, clipRect.y+clipRect.height);
aRenderingContext.DrawLine(clipRect.x+clipRect.width, clipRect.y+clipRect.height,
clipRect.x, clipRect.y+clipRect.height);
aRenderingContext.DrawLine(clipRect.x, clipRect.y+clipRect.height,
clipRect.x, clipRect.y);
aRenderingContext.DrawLine(clipRect.x, clipRect.y+clipRect.height,
clipRect.x, clipRect.y);
aRenderingContext.PopState();
}
示例3: DisplaySelection
nsresult
nsTableCellFrame::DecorateForSelection(nsPresContext* aPresContext,
nsIRenderingContext& aRenderingContext,
const nsStyleBackground *aStyleColor)
{
PRInt16 displaySelection;
displaySelection = DisplaySelection(aPresContext);
if (displaySelection) {
PRBool isSelected =
(GetStateBits() & NS_FRAME_SELECTED_CONTENT) == NS_FRAME_SELECTED_CONTENT;
if (isSelected) {
nsIFrameSelection *frameSelection =
aPresContext->PresShell()->FrameSelection();
PRBool tableCellSelectionMode;
nsresult result =
frameSelection->GetTableCellSelection(&tableCellSelectionMode);
if (NS_SUCCEEDED(result) && tableCellSelectionMode) {
nscolor bordercolor;
if (displaySelection == nsISelectionController::SELECTION_DISABLED) {
bordercolor = NS_RGB(176,176,176);// disabled color
}
else {
aPresContext->LookAndFeel()->
GetColor(nsILookAndFeel::eColor_TextSelectBackground,
bordercolor);
}
PRInt16 t2p = (PRInt16) aPresContext->PixelsToTwips();
if ((mRect.width >(3*t2p)) && (mRect.height > (3*t2p)))
{
//compare bordercolor to ((nsStyleColor *)myColor)->mBackgroundColor)
bordercolor = EnsureDifferentColors(bordercolor, aStyleColor->mBackgroundColor);
//outerrounded
aRenderingContext.SetColor(bordercolor);
aRenderingContext.DrawLine(t2p, 0, mRect.width, 0);
aRenderingContext.DrawLine(0, t2p, 0, mRect.height);
aRenderingContext.DrawLine(t2p, mRect.height, mRect.width, mRect.height);
aRenderingContext.DrawLine(mRect.width, t2p, mRect.width, mRect.height);
//middle
aRenderingContext.DrawRect(t2p, t2p, mRect.width-t2p, mRect.height-t2p);
//shading
aRenderingContext.DrawLine(2*t2p, mRect.height-2*t2p, mRect.width-t2p, mRect.height- (2*t2p));
aRenderingContext.DrawLine(mRect.width - (2*t2p), 2*t2p, mRect.width - (2*t2p), mRect.height-t2p);
}
}
}
}
return NS_OK;
}