本文整理汇总了C++中CWindowGc::SetClippingRect方法的典型用法代码示例。如果您正苦于以下问题:C++ CWindowGc::SetClippingRect方法的具体用法?C++ CWindowGc::SetClippingRect怎么用?C++ CWindowGc::SetClippingRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CWindowGc
的用法示例。
在下文中一共展示了CWindowGc::SetClippingRect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
//Background drawing function
void CTestRectGc::Draw(CWindowGc& aGc, const CCoeControl& aControl, const TRect& aRect) const
{
if (iBmpBackground)
{
TPoint a = PositionRelativeToScreen();
TPoint b = aControl.PositionRelativeToScreen();
//The source rect of the background is the relationship between this control and the control being drawn (child)
//plus the subrect (aRect) to be drawn.
TRect SourceRect(b-a+aRect.iTl, aRect.Size());
aGc.SetDrawMode(CGraphicsContext::EDrawModePEN);
aGc.BitBlt(aRect.iTl, iBmpBackground, SourceRect);
aGc.SetDrawMode(CGraphicsContext::EDrawModePEN);
}
else
{
TRect rc;
aGc.SetClippingRect(aRect);
aGc.SetBrushStyle(CGraphicsContext::ESolidBrush);
aGc.SetBrushColor(iBrushColor);
aGc.SetBrushStyle(iBrushStyle);
aGc.DrawRect(rc);
aGc.CancelClippingRect();
}
}
示例2: Draw
/****************************************************************************\
| Function: CNumberedWindow::Draw
| Purpose: Redraws the contents of CNumberedWindow within a given
| rectangle. CNumberedWindow displays a number in the window.
| Input: aRect Rectangle that needs redrawing
| Output: None
\****************************************************************************/
void CNumberedWindow::Draw(const TRect& aRect)
{
const TBufC<1> strings[5] =
{
*&KString1, *&KString2, *&KString3, *&KString4, *&KString5
};
CWindowGc* gc = SystemGc(); // get a graphics context
gc->SetClippingRect(aRect); // clip outside the redraw area
gc->Clear(aRect); // clear the redraw area
TSize size = iWindow.Size();
TInt height = size.iHeight; // Need window height to calculate vertical text offset
TInt ascent = Font()->AscentInPixels();
TInt descent = Font()->DescentInPixels();
TInt offset = (height + (ascent + descent)) / 2; // Calculate vertical text offset
gc->SetPenColor(TRgb(0, 0, 0)); // Set pen to black
gc->UseFont(Font());
gc->DrawText(strings[iNumber], TRect(TPoint(0, 0), size), offset,
CGraphicsContext::ECenter);
gc->DiscardFont();
}