本文整理汇总了C++中nsRenderingContext::DrawRect方法的典型用法代码示例。如果您正苦于以下问题:C++ nsRenderingContext::DrawRect方法的具体用法?C++ nsRenderingContext::DrawRect怎么用?C++ nsRenderingContext::DrawRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类nsRenderingContext
的用法示例。
在下文中一共展示了nsRenderingContext::DrawRect方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PresContext
void
nsTableCellFrame::DecorateForSelection(nsRenderingContext& aRenderingContext,
nsPoint aPt)
{
NS_ASSERTION(GetStateBits() & NS_FRAME_SELECTED_CONTENT,
"Should only be called for selected cells");
PRInt16 displaySelection;
nsPresContext* presContext = PresContext();
displaySelection = DisplaySelection(presContext);
if (displaySelection) {
nsRefPtr<nsFrameSelection> frameSelection =
presContext->PresShell()->FrameSelection();
if (frameSelection->GetTableCellSelection()) {
nscolor bordercolor;
if (displaySelection == nsISelectionController::SELECTION_DISABLED) {
bordercolor = NS_RGB(176,176,176);// disabled color
}
else {
bordercolor =
LookAndFeel::GetColor(LookAndFeel::eColorID_TextSelectBackground);
}
nscoord threePx = nsPresContext::CSSPixelsToAppUnits(3);
if ((mRect.width > threePx) && (mRect.height > threePx))
{
//compare bordercolor to ((nsStyleColor *)myColor)->mBackgroundColor)
bordercolor = EnsureDifferentColors(bordercolor,
GetStyleBackground()->mBackgroundColor);
nsRenderingContext::AutoPushTranslation
translate(&aRenderingContext, aPt);
nscoord onePixel = nsPresContext::CSSPixelsToAppUnits(1);
aRenderingContext.SetColor(bordercolor);
aRenderingContext.DrawLine(onePixel, 0, mRect.width, 0);
aRenderingContext.DrawLine(0, onePixel, 0, mRect.height);
aRenderingContext.DrawLine(onePixel, mRect.height, mRect.width, mRect.height);
aRenderingContext.DrawLine(mRect.width, onePixel, mRect.width, mRect.height);
//middle
aRenderingContext.DrawRect(onePixel, onePixel, mRect.width-onePixel,
mRect.height-onePixel);
//shading
aRenderingContext.DrawLine(2*onePixel, mRect.height-2*onePixel,
mRect.width-onePixel, mRect.height- (2*onePixel));
aRenderingContext.DrawLine(mRect.width - (2*onePixel), 2*onePixel,
mRect.width - (2*onePixel), mRect.height-onePixel);
}
}
}
}