当前位置: 首页>>代码示例>>C++>>正文


C++ Graphics::DrawRectangle方法代码示例

本文整理汇总了C++中Graphics::DrawRectangle方法的典型用法代码示例。如果您正苦于以下问题:C++ Graphics::DrawRectangle方法的具体用法?C++ Graphics::DrawRectangle怎么用?C++ Graphics::DrawRectangle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Graphics的用法示例。


在下文中一共展示了Graphics::DrawRectangle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawSquare

void CRectangle::DrawSquare(Graphics& graph,CRect rc)
{
	Pen penDraw(m_crColor,(float)m_nWidth);
	if(m_bFinish)
	{
		graph.DrawRectangle(&penDraw,rc.left,rc.top,rc.Width(),rc.Height());
	}
	else
	{
		float fWidth = (float)min(rc.Width(),rc.Height());
		float fleft = 0,ftop = 0;
		if(m_ptary[0].X <= m_ptary[1].X)
		{
			fleft = m_ptary[0].X;
		}
		else 
		{
			fleft = m_ptary[0].X - fWidth;
		}
		if(m_ptary[0].Y <= m_ptary[1].Y)
		{
			ftop = m_ptary[0].Y;
		}
		else
		{
			ftop = m_ptary[0].Y - fWidth;
		}
		graph.DrawRectangle(&penDraw,fleft,ftop,fWidth,fWidth);
	}
}
开发者ID:lilingshui,项目名称:code-refrence,代码行数:30,代码来源:CRectangle.cpp

示例2: OnDraw

HRESULT CIGFrameControl::OnDraw(ATL_DRAWINFO& di)
{
	if (!m_spFrame)
		return S_OK;
	m_spFrame->Render (di.hdcDraw);
	RECT& rc = *(RECT*)di.prcBounds;
	Graphics graphics (di.hdcDraw);
	int nFramePosX = 0;
	int nFramePosY = 0;
	int nFramePosWidth = 0;
	int nFramePosHeight = 0;
	m_spFrame->GetFramePos (nFramePosX, nFramePosY, nFramePosWidth, nFramePosHeight);
	SolidBrush brushFrameOut (m_spFrame->GetSelected() ? IGFRAME_FRAMEOUT_SELECTED : IGFRAME_FRAMEOUT);
	graphics.FillRectangle (&brushFrameOut, Rect (2, 2,
											rc.right - rc.left - 4, nFramePosY - 2));
	graphics.FillRectangle (&brushFrameOut, Rect (2, nFramePosY,
											nFramePosX - 2, rc.bottom - rc.top - nFramePosY - 2));
	graphics.FillRectangle (&brushFrameOut, Rect (nFramePosX, nFramePosY + nFramePosHeight,
											nFramePosWidth, rc.bottom - rc.top - (nFramePosY + nFramePosHeight) - 2));
	graphics.FillRectangle (&brushFrameOut, Rect (nFramePosX + nFramePosWidth, nFramePosY,
											rc.right - rc.left - (nFramePosX + nFramePosWidth) - 2, rc.bottom - rc.top - nFramePosY - 2));
	Pen penFrameBorder (IGFRAME_FRAMEBORDER, 1);	
	graphics.DrawRectangle (&penFrameBorder, Rect (nFramePosX - 1, nFramePosY - 1,
											nFramePosWidth + 1, nFramePosHeight + 1));
	Pen penIn (m_spFrame->GetSelected() ? IGFRAME_BORDER_SELECTED : IGFRAME_BORDER_INCOLOR, 1);
	Pen penOut (m_spFrame->GetSelected() ? IGFRAME_BORDER_SELECTED : IGFRAME_BORDER_OUTCOLOR, 1);	
	graphics.DrawRectangle (&penOut, Rect (0, 0,
											rc.right - rc.left - 1, rc.bottom - rc.top - 1));
	graphics.DrawRectangle (&penIn, Rect (1, 1,
											rc.right - rc.left - 3, rc.bottom - rc.top - 3));
	return S_OK;
}
开发者ID:Bitlsoft,项目名称:Imagenius_SDK,代码行数:32,代码来源:IGFrameControl.cpp

示例3: drawButton

void CIGWorkspaceButtonPanel::drawButton (HWND hWnd, HDC hDC, IGLibrary::IGFrame *pCxButtonIcon)
{
	if (pCxButtonIcon)
	{
		pCxButtonIcon->LayerDrawAllInClearedCache (hDC, 0, 0, -1, -1, 0, false, false, false, RGB (0, 0, 0));

		// test if mouse is over the current button
		if ((m_eButtonState == IGBUTTON_MOUSEOVER)
			&& (hWnd == m_hOverButton))
		{
			Graphics graphics (hDC);
			int nButtonSize = pCxButtonIcon->GetWidth();
			Rect rcGdiButton = Rect (0, 0,
									nButtonSize - 1,
									nButtonSize - 1);
			// draw blue square in mouseover mode
			SolidBrush solBrushButton (IGWORKSPACE_COLOR_BUTTON);
			graphics.FillRectangle (&solBrushButton, rcGdiButton);
			Pen penButtonBorder (IGWORKSPACE_COLOR_BUTTONBORDER);
			graphics.DrawRectangle (&penButtonBorder, rcGdiButton);
		}

		// draw button icon
		if (m_eButtonState == IGBUTTON_MOUSEOVER)
			pCxButtonIcon->LayerDrawAllFromCache (hDC, 0, 0, IGWORKSPACEBUTTONPANEL_ALPHAOVER, RGB (0, 0, 0));
		else
			pCxButtonIcon->LayerDrawAllFromCache (hDC, 0, 0, IGWORKSPACEBUTTONPANEL_ALPHANORMAL, RGB (0, 0, 0));
	}
}
开发者ID:Bitlsoft,项目名称:Imagenius_SDK,代码行数:29,代码来源:IGWorkspace_ButtonPanel.cpp

示例4: gradationCenter

void CAguraDlgBlue::gradationCenter(Graphics& g, CRect rt, Color& color1, Color& color2, BOOL bLine, Color& color3)
{
	GraphicsPath gPath;

	int iHeight = rt.Width() / 4;
	int iWidth = rt.Width() / 4;

	RectF rtF((REAL)rt.left - iWidth, (REAL)rt.top - iHeight, (REAL)rt.Width() + iWidth * 2, (REAL)rt.Height() + iHeight * 2);
	gPath.AddEllipse(rtF);
	gPath.CloseFigure();

	PathGradientBrush PGB(&gPath);
	PGB.SetCenterColor(color1); //would be some shade of blue, following your example
	int colCount = 1;
	PGB.SetSurroundColors(&color2, &colCount); //same as your center color, but with the alpha channel set to 0

	//play with these numbers to get the glow effect you want
	REAL blendFactors[] = {0.0f, 0.1f, 0.3f, 1.0f};
	REAL blendPos[] = {0.0f, 0.4f, 0.6f, 1.0f};
	//sets how transition toward the center is shaped
	PGB.SetBlend(blendFactors, blendPos, 4);
	//sets the scaling on the center. you may want to have it elongated in the x-direction
	PGB.SetFocusScales(0.2f, 0.2f);

	RectF rtDraw((REAL)rt.left, (REAL)rt.top, (REAL)rt.Width(), (REAL)rt.Height());
	g.FillRectangle(&PGB, rtDraw);

	if (bLine == TRUE)
	{
		Pen pen(color3, 1);
		g.DrawRectangle(&pen, rtDraw);
	}
}
开发者ID:siprikorea,项目名称:framework,代码行数:33,代码来源:AguraDlgBlue.cpp

示例5: paint

void Component::paint( Graphics& g )
{
	if ( needsOwnerDraw() == FALSE ) return; 

	if ( isLightWeight() == FALSE )
	
		mSize = getSize();

	// default paiting code for leight-weight components

	wxBrush br( wxColour( 255, 255, 255 ), wxSOLID );
	wxPen pen ( wxColour( 255,   0,   0 ), 1, wxSOLID );

	g.SetBrush( br );
	g.SetPen( pen );

	g.DrawRectangle( 0,0, mSize.width, mSize.height );

	if ( mName != "" ) 
	{
		g.SetClippingRegion( 2,2, mSize.width-4, mSize.height-4 );

		long w = 0, h = 0;
		g.GetTextExtent( mName, &w, &h );

		g.DrawText( mName, ( mSize.width  - w ) / 2, 
						   ( mSize.height - h ) / 2  );

		g.DestroyClippingRegion();
	}
}
开发者ID:stahta01,项目名称:wxCode_components,代码行数:31,代码来源:awt_emul.cpp

示例6: while

void
MFCInstanceView::Draw(Graphics &dc, CRect &clipBox)
{
// !!!??? need to clip properly for short instances with long names
	Pen			blackPen(AlphaColor(250, rgb_black), 1);
	Pen			redPen(AlphaColor(250, rgb_red), 1);
	SolidBrush	blueBrush(AlphaColor(100, rgb_blue));
	SolidBrush	blackBrush(AlphaColor(100, rgb_black));

	CRect		clipBounds = bounds;
	if (clipBox.left > bounds.left) clipBounds.left = clipBox.left-1;
	if (clipBox.right < bounds.right) clipBounds.right = clipBox.right+1;

	cerr << "ondraw instance view " << clipBox.left << ", " << clipBox.right << endl;
	dc.FillRectangle(&blueBrush,
			bounds.left, bounds.top, bounds.right-bounds.left, bounds.bottom-bounds.top);
	dc.DrawRectangle(selected?&redPen:&blackPen,
			bounds.left, bounds.top, clipBounds.right-bounds.left, bounds.bottom-bounds.top);
	Font	labelFont(L"Arial", 8.0, FontStyleRegular, UnitPoint, NULL);
	wstring nm;
	const char *cp = instance->sym->uniqueName();
	while (*cp) { nm.push_back(*cp++); }
	float lbx = bounds.left+2;
#define LBLSEP 200
	if (clipBox.left > lbx) {
		int nld = clipBox.left - lbx;
		nld = nld/LBLSEP;
//		if (nld > 2) lbx += (nld-2)*LBLSEP;
	}
	PointF	p(lbx, clipBounds.top);
	do {
		dc.DrawString(nm.c_str(), -1, &labelFont, p, &blackBrush);
		p.X += LBLSEP;
	} while (p.X < clipBounds.right);
}
开发者ID:dakyri,项目名称:qua,代码行数:35,代码来源:MFCArrangeView.cpp

示例7: DrawBackground

void CIGPropertyManager::DrawBackground (const RECT& rcWnd, Graphics& graphics)
{
	static SolidBrush backgroundBrush (IGPROPERTYMANAGER_COLOR_BACKGROUND);
	Rect rectBackgroundItem (0, 0,
		rcWnd.right - rcWnd.left - 1, rcWnd.bottom - rcWnd.top - 1);
	graphics.FillRectangle (&backgroundBrush, rectBackgroundItem);
	Pen penBorder (IGPROPERTYMANAGER_COLOR_BORDER);
	graphics.DrawRectangle (&penBorder, rectBackgroundItem);
}
开发者ID:Bitlsoft,项目名称:Imagenius_SDK,代码行数:9,代码来源:IGPropertyManager.cpp

示例8: Draw

void CRectView::Draw(CDC* pDC, const std::vector<CElement*>& selection, CElement* highlight)
{
	Pen pen(ColorToDraw(selection, highlight), penWidth);
	SolidBrush brush(fillColor);

	Graphics g = pDC->GetSafeHdc();
	g.FillRectangle(&brush, *this);
	g.DrawRectangle(&pen, *this);
}
开发者ID:hlobit,项目名称:SimPetri,代码行数:9,代码来源:RectView.cpp

示例9: DrawZone

void CZoneView::DrawZone(CDC* pDC, const std::vector<CElement*>& selection, CElement* highlight) const
{
	Graphics g = pDC->GetSafeHdc();
	Pen pen(ColorToDraw(selection, highlight), 1);
	//Arrondir les angles avec GDI+, possible ?
	SolidBrush brush(Color::MakeARGB(100, fillColor.GetR(), fillColor.GetG(), fillColor.GetB()));
	Rect visibleRect(*this);
	visibleRect.Inflate(-3, -3);
	g.FillRectangle(&brush, visibleRect);
	g.DrawRectangle(&pen, visibleRect);
}
开发者ID:hlobit,项目名称:SimPetri,代码行数:11,代码来源:ZoneView.cpp

示例10:

void
MFCEditorItemView::Draw(Graphics &dc, CRect &clipBox)
{
// !!!??? need to clip properly for short instances with long names
	Pen			blackPen(Color(250, 0,0,0), 1);
	Pen			redPen(Color(250, 160, 10, 10), 1);
	SolidBrush	blueBrush(Color(100, 10, 10, 160));
	SolidBrush	blackBrush(Color(100, 0,0,0));

//	fprintf(stderr, "drawing instance view %d\n", bounds.right-bounds.left);
	dc.FillRectangle(&blueBrush, bounds.left, bounds.top, bounds.right-bounds.left, bounds.bottom-bounds.top);
	dc.DrawRectangle(selected?&redPen:&blackPen, bounds.left, bounds.top, bounds.right-bounds.left, bounds.bottom-bounds.top);
}
开发者ID:dakyri,项目名称:qua,代码行数:13,代码来源:MFCDataEditor.cpp

示例11: onPaintFrame

void UIButton::onPaintFrame(Graphics& graphics, Rect rect)
{
    Pen pen(m_button.m_frameColor, m_button.m_frameWidth);
    switch (m_buttonType)
    {
    case UITYPE_BUTTON_RECTANGLE:
        graphics.DrawRectangle(&pen, rect);
        break;
    case UITYPE_BUTTON_CIRCLE:
        graphics.DrawEllipse(&pen, rect);
        break;
    default:
        break;
    }
}
开发者ID:smithLiLi,项目名称:dev,代码行数:15,代码来源:UIComomCtrls.cpp

示例12: drawListBoxItem

void CIGImageLibrary::drawListBoxItem (HDC hDC, int nItemId)
{
	RECT rcItem;
	::ZeroMemory (&rcItem, sizeof (RECT));
	::SendMessageW (m_hListBox, (UINT)LB_GETITEMRECT, (WPARAM)nItemId, (LPARAM)&rcItem);  
	if ((rcItem.right > 0) && (rcItem.left < IGIMAGELIBRARY_LISTBOXWIDTH))
	{
		HBITMAP hBmp = (HBITMAP)::SendMessageW (m_hListBox, (UINT)LB_GETITEMDATA, (WPARAM)nItemId, 0);  
		if (!hBmp)
			return;
		BITMAP bitmapInfo;
		::ZeroMemory (&bitmapInfo, sizeof (BITMAP));
		::GetObject (hBmp, sizeof (BITMAP), &bitmapInfo);
		HBITMAP hBmpItem = ::CreateCompatibleBitmap (hDC, 
														bitmapInfo.bmWidth, 
														bitmapInfo.bmHeight); 
		HBITMAP hOldBmp = (HBITMAP)::SelectObject (hDC, hBmpItem);

		HDC hdcCompatible = ::CreateCompatibleDC (hDC); 
		::SelectObject (hdcCompatible, hBmp);
		int nItemPosX = (IGIMAGELIBRARY_ITEMWIDTH - bitmapInfo.bmWidth) / 2;
		int nItemPosY = (IGIMAGELIBRARY_ITEMHEIGHT - bitmapInfo.bmHeight) / 2;

		::BitBlt (hDC, 
				   rcItem.left + nItemPosX, rcItem.top + nItemPosY, 
				   bitmapInfo.bmWidth, bitmapInfo.bmHeight, 
				   hdcCompatible, 
				   0, 0, 
				   SRCCOPY);
		::SelectObject (hDC, hOldBmp);
		::DeleteDC (hdcCompatible);
		::DeleteObject (hBmpItem);

		int nIsSelected = (int)::SendMessageW (m_hListBox, (UINT)LB_GETSEL, (WPARAM)nItemId, 0);  
		if (nIsSelected > 0)
		{
			Graphics graphics (hDC);
			SolidBrush selectItemBrush (IGIMAGELIBRARY_COLOR_SELECTITEM);
			int nBmpMaxSize = bitmapInfo.bmWidth > bitmapInfo.bmHeight ? bitmapInfo.bmWidth : bitmapInfo.bmHeight;
			Rect rectItem (rcItem.left + (IGIMAGELIBRARY_ITEMHEIGHTSEPARATOR) / 2
							, rcItem.top + (IGIMAGELIBRARY_ITEMHEIGHTSEPARATOR) / 2
							, nBmpMaxSize, nBmpMaxSize);
			graphics.FillRectangle (&selectItemBrush, rectItem);
			Pen penBorder (IGIMAGELIBRARY_COLOR_BORDERSELECTITEM);
			graphics.DrawRectangle (&penBorder, rectItem);			
		}
	}
}
开发者ID:Bitlsoft,项目名称:Imagenius_SDK,代码行数:48,代码来源:IGImageLibrary_oldstyle.cpp

示例13: OnBackgroundPaint

LRESULT CIGHistoryManager::OnBackgroundPaint (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	RECT rcWnd;
	GetWindowRect (&rcWnd);
	PAINTSTRUCT ps;
	HDC hDC = ::BeginPaint (m_hWnd, &ps);
	Graphics graphics (hDC);	
	static SolidBrush backgroundBrush (IGHISTORYMANAGER_COLOR_BACKGROUND);
	Rect rectBackgroundItem (0, 0,
							rcWnd.right - rcWnd.left - 1, rcWnd.bottom - rcWnd.top - 1);
	graphics.FillRectangle (&backgroundBrush, rectBackgroundItem);
	static Pen penBorder (IGHISTORYMANAGER_COLOR_BORDER);
	graphics.DrawRectangle (&penBorder, rectBackgroundItem);
	::EndPaint (m_hWnd, &ps);
	bHandled = TRUE;
	return 0L;
}
开发者ID:Bitlsoft,项目名称:Imagenius_SDK,代码行数:17,代码来源:IGHistoryManager.cpp

示例14: DrawHotShape

void CToolRegularRuler::DrawHotShape(Graphics& graph)
{
	SolidBrush sbrush(Color::Green);
	Pen penDraw(Color::Blue, 2);
	penDraw.SetDashStyle(DashStyleDot);

	PointF pt((m_ptary[0].X + m_ptary[1].X) / 2, m_ptary[0].Y);
	
	graph.DrawLine(&penDraw, pt, m_HotPts.ptRotate);
	graph.FillEllipse(&sbrush, m_HotPts.ptRotate.X - HOTINTERVAL,
					  m_HotPts.ptRotate.Y - HOTINTERVAL,
					  2.0 * HOTINTERVAL, 2.0 * HOTINTERVAL);

	penDraw.SetDashStyle(DashStyleDash);
	penDraw.SetColor(Color::Red);

	graph.DrawRectangle(&penDraw, m_rcGrip.left, m_rcGrip.top, m_rcGrip.Width(), m_rcGrip.Height());
}
开发者ID:lilingshui,项目名称:code-refrence,代码行数:18,代码来源:CToolRegularRuler.cpp

示例15: DrawRect

void DrawRect(LPRECT prc, HDC hdcPaint, DashStyle dashStyle, Color clr, REAL width)
{
    Pen*         myPen;
    Graphics*    myGraphics;
    myPen = new Pen(clr, width);
    if(myPen)
    {
        myPen->SetDashStyle(dashStyle);
        myGraphics = new Graphics(hdcPaint);
        if(myGraphics)
        {
            myGraphics->DrawRectangle(myPen, prc->left, prc->top, 
                prc->right - 1 - prc->left, prc->bottom - 1 - prc->top);
            delete myGraphics;
        }
        delete myPen;
    }
}
开发者ID:sakbhav,项目名称:PassWd_Mgr,代码行数:18,代码来源:aerosubc.cpp


注:本文中的Graphics::DrawRectangle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。