Exemplo n.º 1
0
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;
}
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));
	}
}
Exemplo n.º 3
0
static void DrawFrame2(Graphics &g, RectI r)
{
    g.SetCompositingQuality(CompositingQualityHighQuality);
    g.SetSmoothingMode(SmoothingModeAntiAlias);
    g.SetPageUnit(UnitPixel);

    Font f(L"Impact", 40, FontStyleRegular);
    CalcLettersLayout(g, &f, r.dx);

    SolidBrush bgBrush(Color(0xff, 0xf2, 0));
    Rect r2(r.ToGdipRect());
    r2.Inflate(1, 1);
    g.FillRectangle(&bgBrush, r2);

    Font f2(L"Impact", 16, FontStyleRegular);
    DrawSumatraLetters(g, &f, &f2, 18.f);

    if (gShowOptions)
        return;

    REAL msgY = (REAL)(r.dy / 2);
    if (gMsg)
        msgY += DrawMessage(g, gMsg, msgY, (REAL)r.dx, gMsgColor) + 5;
    if (gMsgError)
        DrawMessage(g, gMsgError, msgY, (REAL)r.dx, COLOR_MSG_FAILED);
}
Exemplo n.º 4
0
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);
	}
}
Exemplo n.º 5
0
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);
}
Exemplo n.º 6
0
//原生GDI+ 绘制
void converDemo::drawOnNativeGdi(Graphics &graphics)
{

	GraphicsPath path;
	path.AddEllipse(10, 10, 100, 100);
	path.AddRectangle(RectF(100, 100, 200, 250));
	PathGradientBrush* brush = new PathGradientBrush(&path);
	Color colors[] = {
		Color(0, 0, 255), Color(0, 0, 0), Color(0, 255, 0), Color(255, 0, 0)
	};
	REAL reals[] = {
		0, 0.5, 0.8, 1
	};
	brush->SetInterpolationColors(colors, reals, 4);
	Matrix matrix;
	matrix.Translate(100, 0);
	matrix.Shear(0.15, 0.3);
	matrix.Scale(0.4, 0.2);
	matrix.Rotate(0.5);
//	brush->MultiplyTransform(&matrix, MatrixOrderAppend);
	RectF rect(convertQRectF2GpRectF(QRectF(100.0f, 100.0f, 200.0f, 400.0f)));
	graphics.FillRectangle(brush, rect);
	delete brush;

}
Exemplo n.º 7
0
Gridlay::Gridlay(ChildCore *core) : Layer(core,NULL)
{
	this->image = NULL;
	this->gridblock = NULL;
	this->pattern = NULL;
	this->x = 0;
	this->y = 0;
	this->oldx = 0;
	this->oldy = 0;
	this->width = 0;
	this->height = 0;

	this->rendered = false;

	SolidBrush *b = new SolidBrush(CLR_FRAME_LIGHT);

	this->image = new Bitmap(2 * GRDBGBLOCK,2 * GRDBGBLOCK,Core::getPixelFormat());
	Graphics *g = Graphics::FromImage(this->image);

	g->SetInterpolationMode(InterpolationModeNearestNeighbor);
	g->Clear(CLR_WHITE);
	g->FillRectangle(b,GRDBGBLOCK,0,GRDBGBLOCK,GRDBGBLOCK);
	g->FillRectangle(b,0,GRDBGBLOCK,GRDBGBLOCK,GRDBGBLOCK);

	delete b;
	delete g;

	g = Graphics::FromHWND(this->core->getWindowHandle());
	this->pattern = new CachedBitmap((Bitmap *)this->image,g);
	delete g;
}
Exemplo n.º 8
0
void DrawItemManagement::OnPaint(Graphics& g)
{
	//»­±³¾°É«
	g.FillRectangle(&SolidBrush(m_backgroundColor),getDrawRectF());

	m_strategy->OnPaint(g,m_allDrawItemList);
}
Exemplo n.º 9
0
void PlayControlWnd::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO: Add your message handler code here
	// Do not call CWnd::OnPaint() for painting messages
	Graphics graphics(dc.m_hDC);

	CRect rect;
	GetClientRect(&rect);
	Bitmap bmp(rect.right,rect.bottom);

	Graphics* memGraph = Graphics::FromImage(&bmp);

	SolidBrush brushBg(Color::Black);
	memGraph->FillRectangle(
		&brushBg,
		rect.left,
		rect.top,
		rect.Width(),
		rect.Height()
		);

	graphics.DrawImage(&bmp,rect.left,rect.top,rect.right,rect.bottom);
	
	delete memGraph;
}
Exemplo n.º 10
0
//QT转成GDI+绘制
void converDemo::drawOnTranslateQT(Graphics &graphics)
{
	Color color;
	QColor qcolor(100, 210, 207.5, 100);
	convertQColor2GpColor(qcolor, &color);

	RectF rect(convertQRectF2GpRectF(QRectF(0.0f, 0.0f, 200.0f, 400.0f)));
	Brush* brush = convertQBrush2GpBrush(newPathGradientBrush());
	graphics.FillRectangle(brush, rect);
	delete brush;

	brush = convertQBrush2GpBrush(creatQTextureBrush());
// 	Image* image = ((TextureBrush*)brush)->GetImage();
// 	graphics.DrawImage(image, 0, 0, image->GetWidth(), image->GetHeight());
	graphics.FillRectangle(brush, RectF(0, 200, 100, 400));
	delete brush;
}
Exemplo n.º 11
0
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);
}
Exemplo n.º 12
0
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);
}
Exemplo n.º 13
0
void CMainDlg::DoPaint(Graphics& g)
{
	CRect rcClient;
	GetClientRect(&rcClient);
	Rect rc(rcClient.left, rcClient.top, rcClient.Width(), rcClient.Height());

	SolidBrush br(Color::WhiteSmoke);
	g.FillRectangle(&br, rc);
}
Exemplo n.º 14
0
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);
}
/**
 *	Draws a gradient filling the rectangle specified by r
 *	in direction of nAngle (which is specified in tenth of degrees)
 *	using a linear shading from color crStart to crEnd
 */
void CGradientRenderer::DrawGradient(CDC* pDC, HANDLE hndPrinter, CRect r, int nAngle, COLORREF crStart, COLORREF crEnd, CPreviewDC* pDCPreview)
{
	Graphics graphics (pDC->GetSafeHdc (), hndPrinter);
	graphics.SetPageUnit (UnitPixel);
	graphics.SetSmoothingMode (SmoothingModeHighQuality);
	graphics.SetInterpolationMode (InterpolationModeHighQualityBicubic);
	graphics.SetPixelOffsetMode (PixelOffsetModeHighQuality);

	Brush* pBrush = CGradient::CreateLinearGradientBrush (r, deg2rad (nAngle), crStart, crEnd);
	graphics.FillRectangle (pBrush, r.left, r.top, r.Width (), r.Height ());
}
Exemplo n.º 16
0
void CIGPropertyManager::DrawProperty (const pair<wstring,wstring>& prop, const RectF& rcfNameProp, const RectF& rcfValueProp, Graphics& graphics)
{
	static FontFamily fontFamily (L"Times New Roman");
	static Font fontRegular (&fontFamily, 12, FontStyleRegular, UnitPixel);
	static Font fontItalic (&fontFamily, 12, FontStyleItalic, UnitPixel);
	static SolidBrush backgroundBrush (IGPROPERTYMANAGER_COLOR_BACKGROUND);
	static SolidBrush  solidFontBrush (IGPROPERTYMANAGER_COLOR_FONT);
	static StringFormat	format (StringFormat::GenericDefault());
	graphics.FillRectangle (&backgroundBrush, Rect (Point ((int)rcfNameProp.X, (int)rcfNameProp.Y), Size ((int)(rcfNameProp.Width + rcfValueProp.Width), (int)rcfNameProp.Height)));
	graphics.DrawString (prop.first.c_str(), -1, &fontItalic, rcfNameProp, &format, &solidFontBrush);
	graphics.DrawString (prop.second.c_str(), -1, &fontRegular, rcfValueProp, &format, &solidFontBrush);
}
Exemplo n.º 17
0
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);
}
Exemplo n.º 18
0
LRESULT CIGMultiFrame::OnEraseBkgnd(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	if (m_spFrameMgr->GetNbVisibleFrames() <= 0)
	{
		RECT rc;
		GetWindowRect (&rc);
		int nRcWidth = rc.right - rc.left;
		int nRcHeight = rc.bottom - rc.top;
		int nLogoWidth = m_cxLogo.GetWidth ();
		int nLogoHeight = m_cxLogo.GetHeight ();
		int nLogoPosX = nRcWidth / 2 - nLogoWidth / 2;
		int nLogoPosY = nRcHeight / 2 - nLogoHeight / 2;
		Graphics graphics ((HDC)wParam);
		SolidBrush solBrush (IGMULTIFRAME_COLOR_BACKGROUND);	
		graphics.FillRectangle (&solBrush, Rect (0, 0, nRcWidth, nLogoPosY));
		graphics.FillRectangle (&solBrush, Rect (0, nLogoPosY, nLogoPosX, nRcHeight - nLogoPosY));
		graphics.FillRectangle (&solBrush, Rect (nLogoPosX, nLogoPosY + nLogoHeight, nLogoWidth, nRcHeight - (nLogoPosY + nLogoHeight)));
		graphics.FillRectangle (&solBrush, Rect (nLogoPosX + nLogoWidth, nLogoPosY, nRcWidth - (nLogoPosX + nLogoWidth), nRcHeight - nLogoPosY));
		m_cxLogo.LayerDrawAllFromCache ((HDC)wParam, nLogoPosX, nLogoPosY);
	}
	bHandled = TRUE;
	return TRUE;
}
void CGradientRenderer::DrawGradient (CDC* pDC, HANDLE hndPrinter, CRect r, LINEARGRADIENTDATA* pLgd, CPreviewDC* pDCPreview)
{
	// normalize angle
	pLgd->dAngle = normalize_rad (pLgd->dAngle);

	Graphics graphics (pDC->GetSafeHdc (), hndPrinter);
	graphics.SetPageUnit (UnitPixel);
	graphics.SetSmoothingMode (SmoothingModeHighQuality);
	graphics.SetInterpolationMode (InterpolationModeHighQualityBicubic);
	graphics.SetPixelOffsetMode (PixelOffsetModeHighQuality);

	if ((pLgd->type != Linear) && (pLgd->type != Rectangular) && (pLgd->type != Radial_TopLeft))
	{
		Color color;
		color.SetFromCOLORREF (pLgd->colors[0]);
		Rect rect (r.left, r.top, r.Width (), r.Height ());
		LinearGradientBrush brush (rect, color, color, 0.0f);
		graphics.FillRectangle (&brush, rect);
	}

	GraphicsPath* pPath = NULL;
	Brush* pBrush = CGradient::CreateGradientBrush (r, *pLgd, &pPath);

	if (pPath == NULL)
		graphics.FillRectangle (pBrush, r.left, r.top, r.Width (), r.Height ());
	else
	{
		if (pLgd->type == Radial_TopLeft)
			graphics.FillRectangle (pBrush, r.left, r.top, r.Width (), r.Height ());
		else
			graphics.FillPath (pBrush, pPath);

		delete pPath;
	}

	delete pBrush;
}
Exemplo n.º 20
0
void UIButton::onPaintBkg(Graphics& graphics, Rect rect)
{
    SolidBrush brush(m_color);
    switch (m_buttonType)
    {
    case UITYPE_BUTTON_RECTANGLE:
        graphics.FillRectangle(&brush, rect);
        break;
    case UITYPE_BUTTON_CIRCLE:
        graphics.FillEllipse(&brush, rect);
        break;
    default:
        break;
    }
}
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);			
		}
	}
}
Exemplo n.º 22
0
void CGIFControl::DrawBorder(Graphics& g)
{
    if(!m_bBorderEnable)
    {
        return;
    }

    CRect rcClient;
    GetClientRect(&rcClient);

    //准备绘制
    Rect rcDraw(rcClient.left,rcClient.top,rcClient.Width(),rcClient.Height());

    SolidBrush bs(m_cBorder);
    g.FillRectangle(&bs,rcDraw);
}
Exemplo n.º 23
0
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;
}
Exemplo n.º 24
0
void IGTabBar::drawTab (HDC hdc, UINT nSize, bool bSelected, bool bOver, const wchar_t *pcwTitle)
{
	Graphics graphics (hdc);
	Color colBackground (Color (GetRValue (m_cBackGround), GetGValue (m_cBackGround), GetBValue (m_cBackGround)));
	SolidBrush solBrushBackground (colBackground);
	graphics.FillRectangle (&solBrushBackground, Rect (0, 0, nSize, BUTTON_HEIGHT - 1));

	SolidBrush solBrushTab (bSelected ? IGTAB_COLORBACKGND : IGTAB_COLOR_UNSELECTED);
	GraphicsPath pathBorder;
	pathBorder.StartFigure();
	pathBorder.AddArc (Rect (0, 0, IGTAB_CORNERDIAM, IGTAB_CORNERDIAM), 180.0f, 90.0f);
	pathBorder.AddArc (Rect (nSize - IGTAB_CORNERDIAM, 0, IGTAB_CORNERDIAM, IGTAB_CORNERDIAM), -90.0f, 90.0f);
	pathBorder.AddLine (Point (nSize, BUTTON_HEIGHT + (bSelected ? 1 : 0)), Point (0, BUTTON_HEIGHT + (bSelected ? 1 : 0)));
	graphics.FillPath (&solBrushTab, &pathBorder);

	if (bOver)
	{
		PathGradientBrush pthGrBrush (&pathBorder);
		pthGrBrush.SetCenterPoint (PointF (0.7f * (float)nSize,
										  0.3f * (float)BUTTON_HEIGHT));
		pthGrBrush.SetCenterColor (IGTAB_COLOR_FRAMEIN);
		Color colors[] = {IGTAB_COLOR_FRAMEOUT};
		int count = 1;
		pthGrBrush.SetSurroundColors (colors, &count);
		graphics.FillPath (&pthGrBrush, &pathBorder);
	}

	FontFamily fontFamily(L"Times New Roman");
	Font font(&fontFamily, 16, FontStyleRegular, UnitPixel);
	PointF      pointF(20.0f, 5.0f);
	SolidBrush  solidFontBrush (bSelected ? IGTAB_COLOR_FONTENABLED : IGTAB_COLOR_FONTDISABLED);
	StringFormat	format(StringFormat::GenericDefault());
	format.SetAlignment (StringAlignmentCenter);
	graphics.DrawString (pcwTitle, -1, &font, RectF (0.0f, 0.0f, (float)nSize, (float)BUTTON_HEIGHT),
							&format, &solidFontBrush);

	Pen penBorder (IGTAB_COLORBORDER, 1);
	GraphicsPath pathBorderOut;
	pathBorderOut.StartFigure();
	pathBorderOut.AddArc (Rect (0, 0, IGTAB_CORNERDIAM + 1, IGTAB_CORNERDIAM + 1), 180.0f, 90.0f);
	pathBorderOut.AddArc (Rect (nSize - IGTAB_CORNERDIAM - 2, 0, IGTAB_CORNERDIAM + 1, IGTAB_CORNERDIAM + 1), -90.0f, 90.0f);
	pathBorderOut.AddLine (Point (nSize - 1, BUTTON_HEIGHT + (bSelected ? 1 : 0)), Point (0, BUTTON_HEIGHT + (bSelected ? 1 : 0)));
	pathBorderOut.CloseFigure();
	graphics.DrawPath (&penBorder, &pathBorderOut);
}
Exemplo n.º 25
0
HRESULT CMainWindow::DrawBackground(
    Graphics &graphics,
    const RectF &rectPaint
    )
{
    // Get the RGB animation variable values

    INT32 red;
    HRESULT hr = m_pAnimationVariableRed->GetIntegerValue(
        &red
        );
    if (SUCCEEDED(hr))
    {
        INT32 green;
        hr = m_pAnimationVariableGreen->GetIntegerValue(
            &green
            );
        if (SUCCEEDED(hr))
        {
            INT32 blue;
            hr = m_pAnimationVariableBlue->GetIntegerValue(
                &blue
                );
            if (SUCCEEDED(hr))
            {
                // Set the RGB of the background brush to the new animated value

                SolidBrush brushBackground(Color(
                    static_cast<BYTE>(red),
                    static_cast<BYTE>(green),
                    static_cast<BYTE>(blue)
                    ));

                // Paint the background

                hr = HrFromStatus(graphics.FillRectangle(
                    &brushBackground,
                    rectPaint
                    ));
            }
        }
    }
    
    return hr;
}
Exemplo n.º 26
0
void FillRect(LPRECT prc, HDC hdcPaint, Color clr)
{
    Graphics*    myGraphics;
    SolidBrush *pBrush = new SolidBrush(clr);

    if(pBrush)
    {
        myGraphics = new Graphics(hdcPaint);
        if(myGraphics)
        {
            myGraphics->FillRectangle(pBrush, prc->left, prc->top, 
                prc->right - 1 - prc->left, prc->bottom - 1 - prc->top);

            delete myGraphics;
        }
        delete pBrush;
    }
}
Exemplo n.º 27
0
void View::Redraw(ControlPtr c)
{		
	if (_hWnd == NULL)
		return;

	HDC hdc = GetDC(_hWnd);
	Graphics g(hdc);

	Graphics *gg = Graphics::FromImage(_gbuf);

	SolidBrush b(_backcolor);
	gg->FillRectangle(&b, c->_dirty_rect);
	if (_bmp)
	{
		gg->DrawImage(_bmp, 
		c->_dirty_rect.X, c->_dirty_rect.Y,
		c->_dirty_rect.X, c->_dirty_rect.Y,
		c->_dirty_rect.Width, c->_dirty_rect.Height,
		UnitPixel);
	}

	for (ClstPtr cc = _cl.begin(); cc != _cl.end(); cc++)
		if ((*cc)->_dirty_rect.IntersectsWith(c->_dirty_rect))
		{   
			if (*cc != c)
				(*cc)->OnDraw(gg);
		}

	c->OnDraw(gg);

	delete gg;

	g.DrawImage(_gbuf, 
		c->_dirty_rect.X, c->_dirty_rect.Y,
		c->_dirty_rect.X, c->_dirty_rect.Y,
		c->_dirty_rect.Width, c->_dirty_rect.Height,
		UnitPixel
		);

	ReleaseDC(_hWnd, hdc);
	c->_repaint = false;
}
//重绘状态栏 , 状态栏的大小会根据窗体的大小变动;
void CMyStatusbarCtrl::DrawStatusBar(HDC my_hdc)
{
	Graphics *mygraphics;
	mygraphics = new Graphics(status_hMemDC);
	mygraphics->SetSmoothingMode(SmoothingModeAntiAlias);
	Pen *myRectangle_pen;
	SolidBrush *BlackBrush;
	SolidBrush *CharacterblkBrush;
	SolidBrush *ProgressblkBrush;
	SolidBrush *HealthGreenBrush;
	SolidBrush *HealthRedBrush;

	SolidBrush  Font_brush(Color(255,0,0,0));
	FontFamily  StaticfontFamily(_T("Arial"));
	Gdiplus::Font        character_font(&StaticfontFamily, 12, FontStyleRegular, UnitPixel);
	PointF      staticpointF(0, 0);

	HealthGreenBrush = new SolidBrush(Color(255,38,182,69));
	HealthRedBrush = new SolidBrush(Color(255,255,0,0));
	ProgressblkBrush = new SolidBrush(Color(255,0,211,39));
	CharacterblkBrush =new SolidBrush(Color(255,183,183,183));
	BlackBrush =new SolidBrush(Color(255,228,228,228));
	mygraphics->FillRectangle(BlackBrush,0,0,status_myRect.right,status_myRect.bottom);


	myRectangle_pen = new Pen(Color(255,0,0,0),1.0f);
	mygraphics->DrawRectangle(myRectangle_pen,1,0,add_width,window_height);
	mygraphics->DrawRectangle(myRectangle_pen,1,0,STATUS_CHARACTER_WIDTH,window_height);
	mygraphics->FillRectangle(CharacterblkBrush,1,0,STATUS_CHARACTER_WIDTH,window_height);

	mygraphics->DrawRectangle(myRectangle_pen,tx_start_pos,0,tx_width,window_height);
	mygraphics->DrawRectangle(myRectangle_pen,tx_start_pos,0,STATUS_CHARACTER_WIDTH,window_height);
	mygraphics->FillRectangle(CharacterblkBrush,tx_start_pos,0,STATUS_CHARACTER_WIDTH,window_height);

	mygraphics->DrawRectangle(myRectangle_pen,rx_start_pos,0,rx_width,window_height);
	mygraphics->DrawRectangle(myRectangle_pen,rx_start_pos,0,STATUS_CHARACTER_WIDTH,window_height);
	mygraphics->FillRectangle(CharacterblkBrush,rx_start_pos,0,STATUS_CHARACTER_WIDTH,window_height);

	mygraphics->DrawRectangle(myRectangle_pen,err_start_pos,0,err_width,window_height);
	mygraphics->DrawRectangle(myRectangle_pen,err_start_pos,0,STATUS_CHARACTER_WIDTH,window_height);
	mygraphics->FillRectangle(CharacterblkBrush,err_start_pos,0,STATUS_CHARACTER_WIDTH,window_height);

	mygraphics->DrawRectangle(myRectangle_pen,health_start_pos,0,health_width,window_height);
	mygraphics->DrawRectangle(myRectangle_pen,health_start_pos,0,STATUS_HEALTH_CHARACTER_WIDTH,window_height);
	mygraphics->FillRectangle(CharacterblkBrush,health_start_pos,0,STATUS_HEALTH_CHARACTER_WIDTH,window_height);

	mygraphics->DrawRectangle(myRectangle_pen,progress_start_pos,0,progress_width - STATUS_ALARM_ICON_WIDTH,window_height);

	CString temp_value;

	

	staticpointF.X = 1;
	staticpointF.Y = 1 ;
	mygraphics->DrawString(_T("Add"), -1, &character_font, staticpointF,&Font_brush);

	staticpointF.X = add_start_pos + STATUS_CHARACTER_VALUE_OFFSET;
	mygraphics->DrawString(Statuspanel, -1, &character_font, staticpointF,&Font_brush);

	

	staticpointF.X = tx_start_pos + 1;
	mygraphics->DrawString(_T("Tx"), -1, &character_font, staticpointF,&Font_brush);

	staticpointF.X = tx_start_pos + STATUS_CHARACTER_VALUE_OFFSET;
	temp_value.Format(_T("%u"),g_llTxCount);
	mygraphics->DrawString(temp_value, -1, &character_font, staticpointF,&Font_brush);


	staticpointF.X = rx_start_pos + 1;
	mygraphics->DrawString(_T("Rx"), -1, &character_font, staticpointF,&Font_brush);

	staticpointF.X = rx_start_pos + STATUS_CHARACTER_VALUE_OFFSET;
	temp_value.Format(_T("%u"),g_llRxCount);
	mygraphics->DrawString(temp_value, -1, &character_font, staticpointF,&Font_brush);


	staticpointF.X = err_start_pos + 1;
	mygraphics->DrawString(_T("Err"), -1, &character_font, staticpointF,&Font_brush);

	staticpointF.X = err_start_pos + STATUS_CHARACTER_VALUE_OFFSET;

	//这一段主要是处理有些命令是设备多余回复出来的,例如 发一条,设备回复两条,这样就不太好计算 error 的个数;
	static int n_err_show_count = 0;
	if(++n_err_show_count == 50)
	{
		n_err_show_count = 0;
		if(g_llTxCount - g_llRxCount < 0)
		{
			g_llRxCount = g_llTxCount;
			g_llerrCount = 0;
		}
		else if(g_llTxCount  < g_llerrCount + g_llRxCount)
		{
			g_llRxCount = g_llTxCount - g_llerrCount;
		}
		else
		{
			g_llerrCount = g_llTxCount - g_llRxCount;
		}
	}
	temp_value.Format(_T("%u"),g_llerrCount);
	mygraphics->DrawString(temp_value, -1, &character_font, staticpointF,&Font_brush);


	if(bac_select_device_online)
	{
		mygraphics->FillRectangle(HealthGreenBrush,health_start_pos + STATUS_HEALTH_CHARACTER_WIDTH + 1,1,health_width - STATUS_HEALTH_CHARACTER_WIDTH - 2,window_height - 2);
		staticpointF.X = health_start_pos + STATUS_HEALTH_VALUE_OFFSET;
		mygraphics->DrawString(_T("100%"),-1, &character_font,staticpointF,&Font_brush);
	}
	else
	{
		mygraphics->FillRectangle(HealthRedBrush,health_start_pos + STATUS_HEALTH_CHARACTER_WIDTH + 1,1,health_width - STATUS_HEALTH_CHARACTER_WIDTH - 2,window_height - 2);
		staticpointF.X = health_start_pos + STATUS_HEALTH_VALUE_OFFSET;
		mygraphics->DrawString(_T("0%"),-1, &character_font,staticpointF,&Font_brush);
	}

	staticpointF.X = health_start_pos + 1;
	mygraphics->DrawString(_T("Health"), -1, &character_font, staticpointF,&Font_brush);

	if(g_progress_persent != 0)
	{
		unsigned int temp_width = (progress_width - STATUS_ALARM_ICON_WIDTH) * g_progress_persent / 100 ;
		CString temp_persent_value;
		temp_persent_value.Format(_T("%d%%"),g_progress_persent);
		mygraphics->FillRectangle(ProgressblkBrush,progress_start_pos,0,temp_width,window_height);
		staticpointF.X = progress_start_pos + progress_width - 60;
		mygraphics->DrawString(temp_persent_value, -1, &character_font, staticpointF,&Font_brush);
		if( g_progress_persent >= 98)
			g_progress_persent = 0;
		//progress_width
	}
	else
	{
		mygraphics->DrawRectangle(myRectangle_pen,progress_start_pos,0,progress_width - STATUS_ALARM_ICON_WIDTH,window_height);
	}

	if(!cs_show_status_info.IsEmpty())
	{
		staticpointF.X = progress_start_pos + 1;
		mygraphics->DrawString(cs_show_status_info, -1, &character_font, staticpointF,&Font_brush);
	}

	

	delete mygraphics;
	delete myRectangle_pen;

	delete BlackBrush;
	delete CharacterblkBrush;
	delete ProgressblkBrush;
}
//
// 윈도우 프로시져 함수 ( 메시지 큐에서 받아온 메시지를 처리한다 )
//
LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
	PAINTSTRUCT ps;
	HDC hdc;

	switch (msg)
	{
	case WM_PAINT: // 화면이 갱신될 때 호출된다.
		{
			hdc = BeginPaint(hWnd, &ps);

			Graphics *graph = Graphics::FromImage(g_bmp);

			RECT cr;
			GetClientRect(hWnd, &cr);
			Rect wndSize(cr.left, cr.top, cr.right, cr.bottom);

			graph->DrawImage(g_image, wndSize);

			graph->FillRectangle(g_yellowBrush, g_block);
			graph->FillRectangle(g_yellowBrush, g_block2);


			graph->DrawImage(g_image2, g_bullet, 
				g_bulletSrc.X, g_bulletSrc.Y, g_bulletSrc.Width, g_bulletSrc.Height,
				UnitPixel);


			float fBlend = 1.f; //set the alpha value
			ColorMatrix BitmapMatrix = {
				1.0f, 0.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 1.0f, 0.0f, 0.0f, 0.0f,
				0.0f, 0.0f, 1.0f, 0.0f, 0.0f,
				0.0f, 0.0f, 0.0f, fBlend, 0.0f,
				0.0f, 0.0f, 0.0f, 0.0f, 1.0f
			};

			ImageAttributes ImgAttr;
			ImgAttr.SetColorMatrix(&BitmapMatrix,
				ColorMatrixFlagsDefault,
				ColorAdjustTypeBitmap);

			//graph->SetCompositingMode(CompositingModeSourceCopy);
			if (g_isCollision)
			{
				graph->DrawImage(g_image3, g_bullet, 
					g_explosion.X, g_explosion.Y, g_explosion.Width, g_explosion.Height,
					UnitPixel, &ImgAttr);
			}

//			graph->DrawImage(g_image3, g_bullet, 
//				g_explosion.X, g_explosion.Y, g_explosion.Width, g_explosion.Height,
//				UnitPixel);


			DrawString(graph, 50, 0, frameStr);

			g_graphics->DrawImage(g_bmp, wndSize);


			EndPaint(hWnd, &ps);
		}
		break;

//	case WM_ERASEBKGND:
//		return 0;

	case WM_LBUTTONDOWN:
		{
			g_IsClick = true;
			g_mouseClickPos = Point(LOWORD(lParam), HIWORD(lParam));
		}
		break;

	case WM_LBUTTONUP:
		{
			g_IsClick = false;
		}
		break;

	case WM_MOUSEMOVE:
		{
		}
		break;

	case WM_KEYDOWN:
		switch (wParam)
		{
		case VK_LEFT:
		case VK_UP:
			++g_hatchStyle;
			break;

		case VK_RIGHT:
		case VK_DOWN:
			--g_hatchStyle;
			break;
		}
		break;

	case WM_TIMER:
		{
			if (wParam == 1)
			{
				int a = 0;
			}
			else if (wParam == 2)
			{
				int a = 0;
			}
		}
		break;

	case WM_DESTROY: //윈도우가 파괴된다면..
		PostQuitMessage(0);	//프로그램 종료 요청 ( 메시지 루프를 빠져나가게 된다 )
		break;
	}

	return DefWindowProc( hWnd, msg, wParam, lParam ); // 기본적인 메세지 처리를 담당한다.
}
Exemplo n.º 30
0
unsigned int tabs_impl_win32::draw_tab(Graphics &g, unsigned int a_X, unsigned int a_Y, unsigned int a_Index){
	if(a_X > get_size().m_Width) return a_X;

	Color c = Color(255, 44, 61, 91);

	if(m_ActiveTab == a_Index) c = Color(255, 255, 232, 166);
	else if(m_HoverTab == a_Index) c = Color(255, 100, 110, 117);

	SolidBrush b(c);
	SolidBrush t(m_ActiveTab == a_Index ? Color(255, 255, 248, 225) : c);
	SolidBrush black(Color(255, 0, 0, 0));
	SolidBrush white(Color(255, 255, 255, 255));
	SolidBrush closeDark(Color(255, 117, 99, 61));
	SolidBrush closeLight(Color(255, 206, 212, 221));
	Pen p(Color(255, 0, 0, 0));
	Font font(L"Tahoma", 10);
	PointF origin(a_X + 5, a_Y + 3), originX(a_X + 10, a_Y + 5);

	RectF bb, close;

	std::string s = this->get_child_name(a_Index);
	std::wstring w(s.begin(), s.end());

	// draw tab
	g.MeasureString(w.c_str(), w.size(), &font, origin, &bb);
	bb.Height = 25;
	originX.X += bb.Width + 5;
	close = RectF(originX.X, originX.Y, 15.f, 15.f);
	RectF::Union(bb, bb, close);

	GraphicsPath gp;

	// draw header
	int x = a_X; int y = a_Y;
	int headerHeight = get_size().m_Height / 2;
	int arcSize = 10;
	int width = bb.Width;

	// top part = arc
	gp.AddLine(x, y + headerHeight + arcSize / 2, x, y + arcSize / 2);
	gp.AddArc(x, y, arcSize, arcSize, 180.f, 90.f);
	gp.AddArc(x + width, y, arcSize, arcSize, 270.f, 90.f);
	gp.AddLine(x + width + arcSize, y + arcSize / 2, x + width + arcSize, y + headerHeight + arcSize / 2);

	g.FillPath(&t, &gp);

	bb.Width += arcSize;

	// bottom = rect
	g.FillRectangle(&b, a_X, a_Y + headerHeight, bb.Width, 10.f);

	g.DrawString(w.c_str(), w.size(), &font, origin, m_ActiveTab == a_Index ? &black : &white);

	// draw close button
	if(m_ActiveTab == a_Index || m_HoverTab == a_Index){
		SolidBrush closeBrush(Color(190, 40, 30));
		
		Pen hoverPen(Color::White, 2);
		Pen regularPen(Color(20, 20, 20), 2);

		Pen *p = &regularPen;

		float shrink = 4;

		RectF lines = close;
		lines.X += shrink;
		lines.Y += shrink;
		lines.Width -= shrink * 2;
		lines.Height -= shrink * 2;

		// just get mouse position here instead of passing it through
		// from wm_mousemove
		POINT mouse;
		GetCursorPos(&mouse);
		ScreenToClient(m_hWndTabs, &mouse);
		if(close.Contains(mouse.x, mouse.y)) {
			g.FillEllipse(&closeBrush, close);
			p = &hoverPen;
		}

		g.DrawLine(p, lines.X, lines.Y, lines.X + lines.Width, lines.Y + lines.Height);
		g.DrawLine(p, lines.X + lines.Width, lines.Y, lines.X, lines.Y + lines.Height);
	}

	m_VisibleTabs[a_Index].m_BoundingBox = bb;
	m_VisibleTabs[a_Index].m_CloseBox    = close;

	return bb.Width;
}