Ejemplo n.º 1
0
void CHeaderDockPane::DrawAd(CPaintDC & dc)
{
	//CPaintDC dc(this); 
	//CDC pDC;
	//pDC.CreateCompatibleDC(&dc);

	CRect rect;
	GetClientRect(&rect);

	if(rect.right > 500)
	{
		CBrush bg;
		bg.CreateStockObject(RGB(0,0,0));
		CBrush fillBrush(RGB(250, 0, 0));
		CBrush *oldFillBrush = dc.SelectObject(&fillBrush);
		//rect = CRect( CPoint(rect.left, rect.top), CPoint(rect.right, rect.bottom - 2) );
		//rect = CRect( CPoint(200, 5), CPoint(400, 25) );
		//dc.FillRect(&rect, &bg);


		int height = 22;
		int progress_x = rect.right - 300 - 1;
		int progress_y = -22;
		CPoint prorgess_border_points[5];
		prorgess_border_points[0] = CPoint(progress_x, progress_y);
		prorgess_border_points[1] = CPoint(progress_x, progress_y + height);
		prorgess_border_points[2] = CPoint(progress_x+(rect.right - progress_x)-20 - 1, progress_y + height);
		prorgess_border_points[3] = CPoint(progress_x+(rect.right - progress_x)-20 - 1, progress_y);
		prorgess_border_points[4] = CPoint(progress_x, progress_y);
		CPen penOutline(PS_SOLID, 1, RGB(175, 175, 175));
		dc.SelectObject(&penOutline);
		dc.Polyline(prorgess_border_points, 5);

	}
}
Ejemplo n.º 2
0
void CHeaderDockPane::OnPaint()
{
	CPaintDC dc(this); 
	CDC pDC;
	pDC.CreateCompatibleDC(&dc);
	// device context for painting
	// TODO: Add your message handler code here
	// Do not call CDockablePane::OnPaint() for painting messages
	
	CRect rect;
	GetClientRect(&rect);
	//Manual BG repaint
	CBrush bg;
	bg.CreateStockObject(RGB(236,236,236));
	//CPen penFill(PS_NULL,0,RGB(250,0,0));
	//dc.SelectObject(&penFill);
	CBrush fillBrush(RGB(236, 236, 236));
	CBrush *oldFillBrush = dc.SelectObject(&fillBrush);
	dc.FillRect(&rect, &bg);
	//dc.Ellipse(&rect);
	
	//DrawAd(dc);

	//Invalidate();
}
void CComboColorPicker::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC dc;
	CBrush brushBlack;
	brushBlack.CreateStockObject(BLACK_BRUSH);
	
	if (!dc.Attach(lpDrawItemStruct->hDC))
		return;

	COLORREF rgbTextColor = dc.GetTextColor();
	COLORREF rgbBkColor = dc.GetBkColor();

	if (lpDrawItemStruct->itemAction & ODA_FOCUS)
	{
		dc.DrawFocusRect(&lpDrawItemStruct->rcItem);
	}
	else if (lpDrawItemStruct->itemAction & ODA_DRAWENTIRE)
	{
		if (lpDrawItemStruct->itemState & ODS_FOCUS)
			dc.DrawFocusRect(&lpDrawItemStruct->rcItem);
		else
			dc.ExtTextOut(0, 0, ETO_OPAQUE, &lpDrawItemStruct->rcItem, _T(""), 0, NULL);
	}

	if (0 <= (int)lpDrawItemStruct->itemID)	// Any item selected?
	{
		::InflateRect(&lpDrawItemStruct->rcItem, -2, -2);

		if( (COLORREF)lpDrawItemStruct->itemData == 0xFFFFFFFF )
		{
			CSize	textSize = dc.GetTextExtent( _T("default") );
			dc.FillSolidRect( &lpDrawItemStruct->rcItem, RGB( 0xFF, 0xFF, 0xFF ) );
			dc.FrameRect( &lpDrawItemStruct->rcItem, &brushBlack );

			dc.SetTextColor( RGB( 0x00, 0x00, 0x00 ) );
			dc.SetBkColor( RGB( 0xFF, 0xFF, 0xFF ) );
			dc.SetTextAlign( TA_CENTER | TA_TOP | TA_NOUPDATECP );
			dc.TextOut( 
				lpDrawItemStruct->rcItem.left + (lpDrawItemStruct->rcItem.right - lpDrawItemStruct->rcItem.left) / 2, 
				lpDrawItemStruct->rcItem.top +
					((lpDrawItemStruct->rcItem.bottom - lpDrawItemStruct->rcItem.top) / 2) -
					(textSize.cy / 2), 
				_T("default") );
		}
		else
		{
			dc.FillSolidRect(&lpDrawItemStruct->rcItem, (COLORREF)lpDrawItemStruct->itemData);
			dc.FrameRect(&lpDrawItemStruct->rcItem, &brushBlack);
		}
	}

	// Restore the DC state
	dc.SetTextColor(rgbTextColor);
	dc.SetBkColor(rgbBkColor);
	dc.Detach();
}
Ejemplo n.º 4
0
void CBigIcon::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	ASSERT(pDC != NULL);

	CRect rect;
	GetClientRect(rect);
	int cxClient = rect.Width();
	int cyClient = rect.Height();

	// load icon
	HICON hicon = AfxGetApp()->LoadIcon(ID_SYM_ICON_GDB);
	if (hicon == NULL)
		return;

	// draw icon into off-screen bitmap
	int cxIcon = ::GetSystemMetrics(SM_CXICON);
	int cyIcon = ::GetSystemMetrics(SM_CYICON);

	CBitmap bitmap;
	if (!bitmap.CreateCompatibleBitmap(pDC, cxIcon, cyIcon))
		return;
	CDC dcMem;
	if (!dcMem.CreateCompatibleDC(pDC))
		return;
	CBitmap* pBitmapOld = dcMem.SelectObject(&bitmap);
	if (pBitmapOld == NULL)
		return;

	// blt the bits already on the window onto the off-screen bitmap
	dcMem.StretchBlt(0, 0, cxIcon, cyIcon, pDC,
		2, 2, cxClient-CX_SHADOW-4, cyClient-CY_SHADOW-4, SRCCOPY);

	// draw the icon on the background
	dcMem.DrawIcon(0, 0, hicon);

	// draw border around icon
	CPen pen;
	pen.CreateStockObject(BLACK_PEN);
	CPen* pPenOld = pDC->SelectObject(&pen);
	pDC->Rectangle(0, 0, cxClient-CX_SHADOW, cyClient-CY_SHADOW);
	if (pPenOld)
		pDC->SelectObject(pPenOld);

	// draw shadows around icon
	CBrush br;
	br.CreateStockObject(DKGRAY_BRUSH);
	rect.SetRect(cxClient-CX_SHADOW, CY_SHADOW, cxClient, cyClient);
	pDC->FillRect(rect, &br);
	rect.SetRect(CX_SHADOW, cyClient-CY_SHADOW, cxClient, cyClient);
	pDC->FillRect(rect, &br);

	// draw the icon contents
	pDC->StretchBlt(2, 2, cxClient-CX_SHADOW-4, cyClient-CY_SHADOW-4,
		&dcMem, 0, 0, cxIcon, cyIcon, SRCCOPY);
}
Ejemplo n.º 5
0
void CQueView::OnDraw(CDC* pDC)
{
    CDrawDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);

    CBitmap bitmap;
    CBitmap *pOldBitmap;

    // only paint the rect that needs repainting
    CRect client;
    pDC->GetClipBox(client);
    CRect rect;
    GetClientRect(&rect);

    CDC bitmapDC;
    auto pDrawDC = pDC;
    // draw to offscreen bitmap for fast looking repaints
    if (bitmapDC.CreateCompatibleDC(pDC)) {
        if (bitmap.CreateCompatibleBitmap(pDC, rect.Width(), rect.Height())) {
            OnPrepareDC(&bitmapDC, nullptr);
            pDrawDC = &bitmapDC;

            // offset origin more because bitmap is just piece of the whole drawing
            //..,,	dc.OffsetViewportOrg(-rect.left, -rect.top);
            bitmapDC.OffsetViewportOrg(-rect.left, -rect.top);
            pOldBitmap = bitmapDC.SelectObject(&bitmap);

            // might as well clip to the same rectangle
            bitmapDC.IntersectClipRect(client);
        }
    }

    // paint background
    CBrush brush;
    if (!brush.CreateStockObject(WHITE_BRUSH))
        return;

    pDrawDC->FillRect(client, &brush);

    pDoc->DrawQue(pDrawDC, this);

    if (pDrawDC != pDC) {
        pDC->SetMapMode(MM_TEXT);
        bitmapDC.SetMapMode(MM_TEXT);
        pDC->BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), pDrawDC, 0, 0, SRCCOPY);
        bitmapDC.SelectObject(pOldBitmap);
    }
}
Ejemplo n.º 6
0
void CSimplexDlg::OnPaint()
{
	CPaintDC dc(this); // device context for painting
	// TODO:  在此处添加消息处理程序代码

	CPen pen; //定义画笔对象
	CBrush brush; //定义笔刷对象
	pen.CreatePen(PS_DASHDOT, 1, RGB(0, 0, 255)); //创建初始化画笔
	brush.CreateStockObject(NULL_BRUSH); //初始化实心的空画刷(没有背景颜色)
	dc.SelectObject(&brush); //将画刷选入dc
	dc.SelectObject(&pen);  //将画笔选入dc
	dc.SetBkMode(TRANSPARENT); //设置背景模式为透明,也可以使用SetBkColor设置背景色
	dc.Rectangle(15, 20, 500, 430); //创建一个透明的文本框

	// 不为绘图消息调用 CDialogEx::OnPaint()
}
Ejemplo n.º 7
0
void CChildView::OnPaint() 
{
	CPaintDC dc(this); // device context for painting

	CPen* oldpen = dc.GetCurrentPen();
	CBrush* oldbrush = dc.GetCurrentBrush();

	DrawTree(dc, false);

	//draw intersect test segment
	if (_intersectsegment.IsDefine())
	{
		CPen intersectPen(PS_SOLID, 1, RGB(255, 0, 0));
		CPen noneintersectPen(PS_SOLID, 1, RGB(0, 55, 55));

		dc.MoveTo(static_cast<int>(_intersectsegment.GetOrigin().x), static_cast<int>(_intersectsegment.GetOrigin().y));
		if (_intersecT != 0.0f && _intersecT < 1.0f)
		{
			dc.SelectObject(&intersectPen);
			Vector2Df intersectpoint = _intersectsegment.GetOrigin() + _intersectsegment.GetFullLengthDirection() * _intersecT;
			Vector2Di ip(static_cast<int>(intersectpoint.x), static_cast<int>(intersectpoint.y));
			dc.LineTo(ip.x, ip.y);
			int w = 3;
			dc.Ellipse(ip.x - w, ip.y - w, ip.x + w, ip.y + w);
		}

		dc.SelectObject(&noneintersectPen);
		Vector2Df endpoint = _intersectsegment.GetDestination();
		dc.LineTo(static_cast<int>(endpoint.x), static_cast<int>(endpoint.y));
	}

	//draw all obstacles
	CPen shapePen(PS_SOLID, 1, RGB(255, 0, 0));
	dc.SelectObject(&shapePen);

	CBrush brush;
	brush.CreateStockObject(NULL_BRUSH);
	dc.SelectObject(&brush);
	
	for_each(_obstacles.begin(), _obstacles.end(), [&dc](shared_ptr<CObstacle> o)	{ o->Draw(dc); });
	

	dc.SelectObject(oldpen);
	dc.SelectObject(oldbrush);
	// Do not call CWnd::OnPaint() for painting messages
}
Ejemplo n.º 8
0
void CSplitterCursor::DrawDrag(void)
{
	CDC* pDC = m_pWnd->GetDC();
	if (pDC != NULL)
	{
		CRect crRect;
		m_pWnd->GetClientRect(&crRect);
		crRect.left = m_nX-1;
		crRect.right = crRect.left+1;

		CBrush cbDrag;
		cbDrag.CreateStockObject(LTGRAY_BRUSH);
		pDC->SelectObject(&cbDrag);

		pDC->PatBlt(crRect.left, crRect.top, crRect.Width(), crRect.Height(), PATINVERT);

		m_pWnd->ReleaseDC(pDC);
	}
}
Ejemplo n.º 9
0
void CBigIcon::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);
	ASSERT(pDC != NULL);
	if (pDC != NULL)
	{
		CRect rect;
		GetClientRect(rect);
		int cxClient = rect.Width();
		int cyClient = rect.Height();

		// draw border around icon
		CPen pen;
		pen.CreateStockObject(BLACK_PEN);
		CPen* pPenOld = pDC->SelectObject(&pen);
		pDC->Rectangle(0, 0, cxClient-CX_SHADOW, cyClient-CY_SHADOW);
		if (pPenOld)
			pDC->SelectObject(pPenOld);

		// draw shadows around icon
		CBrush br;
		br.CreateStockObject(DKGRAY_BRUSH);
		rect.SetRect(cxClient-CX_SHADOW, CY_SHADOW, cxClient, cyClient);
		pDC->FillRect(rect, &br);
		rect.SetRect(CX_SHADOW, cyClient-CY_SHADOW, cxClient, cyClient);
		pDC->FillRect(rect, &br);

		// draw the bitmap contents
		CDC dcMem;
		if (!dcMem.CreateCompatibleDC(pDC))
			return;
		CBitmap* pBitmapOld = dcMem.SelectObject(&m_bitmap);
		if (pBitmapOld == NULL)
			return;

		pDC->BitBlt(2, 2, m_sizeBitmap.cx, m_sizeBitmap.cy, &dcMem, 0, 0, SRCCOPY);

		dcMem.SelectObject(pBitmapOld);
	}
}
Ejemplo n.º 10
0
void CUploadListCtrl::DrawFocusItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC* pDC = CDC::FromHandle(lpDrawItemStruct->hDC);

	CBrush brushObj;
	brushObj.CreateStockObject(WHITE_BRUSH);
	CBrush* pOldBrushObj = pDC->SelectObject(&brushObj);

	CPen penObj;
	penObj.CreatePen(PS_SOLID, 1, RGB(152, 181, 226));
	CPen* pOldPenObj = pDC->SelectObject(&penObj);

	pDC->Rectangle(&lpDrawItemStruct->rcItem);

	pDC->SelectObject(pOldBrushObj);
	pDC->SelectObject(pOldPenObj);

	penObj.DeleteObject();
	brushObj.DeleteObject();

	DrawItemInfo(lpDrawItemStruct);
}
Ejemplo n.º 11
0
void CTipDlg::OnPaint()
{
	CPaintDC dc(this); // device context for painting

	// Get paint area for the big static control
	CWnd* pStatic = GetDlgItem(IDC_BULB);
	CRect rect;
	pStatic->GetWindowRect(&rect);
	ScreenToClient(&rect);

	// Paint the background white.
	CBrush brush;
	brush.CreateStockObject(WHITE_BRUSH);
	dc.FillRect(rect, &brush);
	dc.FillSolidRect(rect, RGB(255, 255, 255));

	// Load bitmap and get dimensions of the bitmap
	CBitmap bmp;
	bmp.LoadBitmap(IDB_LIGHTBULB);
	BITMAP bmpInfo;
	bmp.GetBitmap(&bmpInfo);

	// Draw bitmap in top corner and validate only top portion of window
	CDC dcTmp;
	dcTmp.CreateCompatibleDC(&dc);
	dcTmp.SelectObject(&bmp);
	rect.bottom = bmpInfo.bmHeight + rect.top;
	dc.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), 
		&dcTmp, 0, 0, SRCCOPY);

	// Draw out "Did you know..." message next to the bitmap
	CString strMessage;
	VERIFY(strMessage.LoadString(CG_IDS_DIDYOUKNOW));
	rect.left += bmpInfo.bmWidth;
	dc.DrawText(strMessage, rect, DT_VCENTER | DT_SINGLELINE);

	// Do not call CDialog::OnPaint() for painting messages
}
Ejemplo n.º 12
0
void CMiniCADView::OnDraw(CDC* pDC)
{
	CMiniCADDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// TODO: add draw code for native data here
	
	//v1.1
	//char info[100] = "F1-Line  F2-Rect  F3-Circle  F4-Ellipse  F5-PencilPath";
	//pDC->TextOut(0, 0, info);

	CBrush brsn;
	brsn.CreateStockObject(NULL_BRUSH);
	CBrush *oldBrsh = pDC->SelectObject(&brsn);

	for (int i = 0; i < m_Graphic.GetSize(); ++i)
	{
		CGraphic *aGraphic = (CGraphic *)m_Graphic[i];
		aGraphic->drawGraphic(pDC);
	}
	
	brsn.DeleteObject();
	pDC->SelectObject(oldBrsh);
}
Ejemplo n.º 13
0
void CTipDlg::OnPaint()
{
	if (IsIconic())
	{
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);

		// Center icon in client rectangle
		int cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		GetClientRect(&rect);
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		if( cxIcon == 16 && cyIcon == 16 )
		{
			dc.DrawIcon( x, y, theApp.hMainIconSmall );
		}
		else
		{
			dc.DrawIcon( x, y, theApp.hMainIconBig );
		}
		return;
	}

	CPaintDC dc(this); // device context for painting

	// Get paint area for the big static control
	CWnd* pStatic = GetDlgItem(IDC_FRAME_INTERNAL);
	CRect rect;
	pStatic->GetWindowRect(&rect);
	ScreenToClient(&rect);

	// Paint the background white.
	CBrush brush;
	brush.CreateStockObject(WHITE_BRUSH);
	dc.FillRect(rect, &brush);

	// Load bitmap and get dimensions of the bitmap
	CBitmap bmp;
	bmp.LoadBitmap(IDB_LIGHTBULB);
	BITMAP bmpInfo;
	ZeroMemory( &bmpInfo, sizeof(bmpInfo) );
	bmp.GetBitmap(&bmpInfo);

	// Draw bitmap in top corner and validate only top portion of window
	CDC dcTmp;
	dcTmp.CreateCompatibleDC(&dc);
	dcTmp.SelectObject(&bmp);
	rect.bottom = bmpInfo.bmHeight + rect.top;
	dc.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(), 
		&dcTmp, 0, 0, SRCCOPY);

	// Draw out "Did you know..." message next to the bitmap
	CString strMessage;
	strMessage = LocLoadString(IDS_TIPS_DIDYOUKNOW);
	rect.left += bmpInfo.bmWidth;
	dc.SetBkMode( TRANSPARENT );
	dc.DrawText(strMessage, rect, DT_VCENTER | DT_SINGLELINE);

	// Do not call CDialog::OnPaint() for painting messages
}
Ejemplo n.º 14
0
void CMiniCADView::OnMouseMove(UINT nFlags, CPoint point) 
{
	// TODO: Add your message handler code here and/or call default
	CClientDC cldc(this);
	
	CBrush brsn;
	brsn.CreateStockObject(NULL_BRUSH);
	CBrush *oldBrsh = cldc.SelectObject(&brsn);
	
	if (nFlags)
	switch (m_GrphcType)
	{
	case LINE:
		{
			CPoint ptl;
			if (MK_SHIFT & nFlags)
			{
				CSize dp = point - m_ptBegin;
				if (abs(dp.cy) <= abs(dp.cx) / 2)
				{
					ptl.x = m_ptBegin.x + dp.cx;
					ptl.y = m_ptBegin.y;
				}
				else if(((abs(dp.cx) / 2) < abs(dp.cy)) && (abs(dp.cy) < (abs(dp.cx) * 2)))
				{
					int dy = (dp.cy >= 0) ? abs(dp.cx) : -abs(dp.cx);
					ptl.x = m_ptBegin.x + dp.cx;
					ptl.y = m_ptBegin.y + dy;
				}
				else if((abs(dp.cx) * 2) <= abs(dp.cy))
				{
					ptl.x = m_ptBegin.x;
					ptl.y = m_ptBegin.y + dp.cy;
				}
			}
			else
			{
				ptl = point;
			}
			{
				cldc.SetROP2(R2_NOT);
				
				cldc.MoveTo(m_ptBegin);
				cldc.LineTo(ptl);
				
				cldc.MoveTo(m_ptBegin);
				cldc.LineTo(m_ptEnd);
				m_ptEnd = ptl;
			}
		}
		break;

	case RECTANGLE:
		{
			cldc.SetROP2(R2_NOT);
			CPoint pntr;
			CSize dp = point - m_ptBegin;

			if (MK_SHIFT & nFlags)
			{
				int y = (dp.cy >= 0) ? abs(dp.cx) : -abs(dp.cx);
				pntr.x = m_ptBegin.x + dp.cx;
				pntr.y = m_ptBegin.y + y;
			}
			else
			{
				pntr = point;
			}

			cldc.Rectangle(m_ptBegin.x, m_ptBegin.y, pntr.x, pntr.y);

			cldc.Rectangle(m_ptBegin.x, m_ptBegin.y, m_ptEnd.x, m_ptEnd.y);
			m_ptEnd = pntr;
		}
		break;

	case ELLIPSE:
		{
			cldc.SetROP2(R2_NOT);
			
			if (MK_SHIFT & nFlags)
			{
				CSize dp1 = point - m_ptBegin;
				double r1 = sqrt((dp1.cx * dp1.cx) + (dp1.cy * dp1.cy));
				int x1 = m_ptBegin.x - r1;
				int y1 = m_ptBegin.y - r1;
				int x2 = m_ptBegin.x + r1;
				int y2 = m_ptBegin.y + r1;

				cldc.Ellipse(x1, y1, x2, y2);

				CSize dp2 = m_ptEnd - m_ptBegin;
				double r2 = sqrt((dp2.cx * dp2.cx) + (dp2.cy * dp2.cy));
				int x3 = m_ptBegin.x - r2;
				int y3 = m_ptBegin.y - r2;
				int x4 = m_ptBegin.x + r2;
				int y4 = m_ptBegin.y + r2;

				cldc.Ellipse(x3, y3, x4, y4);
			}
			else
			{
				cldc.Ellipse(m_ptBegin.x, m_ptBegin.y, point.x, point.y);

				cldc.Ellipse(m_ptBegin.x, m_ptBegin.y, m_ptEnd.x, m_ptEnd.y);
			}

			m_ptEnd = point;
		}
		break;

	case PENCILPATH:
		{
			cldc.MoveTo(m_ptPre);
			cldc.LineTo(point);
	
			m_ptPre = point;
			
			CPoint *pnt = new CPoint(point);
			m_PntArray.Add(pnt);
			m_ptEnd = point;
		}
		break;
	}


	/*
	//V1.0
	switch (nFlags)
	{
	case MK_LBUTTON:
		{
			cldc.SetROP2(R2_NOT);

			cldc.MoveTo(m_ptBegin);
			cldc.LineTo(point);

			cldc.MoveTo(m_ptBegin);
			cldc.LineTo(m_ptEnd);
		}
		break;
	case MK_RBUTTON:
		{
			cldc.SetROP2(R2_NOT);

			cldc.Rectangle(m_ptBegin.x, m_ptBegin.y, point.x, point.y);

			cldc.Rectangle(m_ptBegin.x, m_ptBegin.y, m_ptEnd.x, m_ptEnd.y);
		}
		break;
	case MK_MBUTTON:

		{
			cldc.MoveTo(m_ptPre);
			cldc.LineTo(point);
	
			m_ptPre = point;
			
			CPoint *pnt = new CPoint(point);
			m_PntArray.Add(pnt);
		}
		break;
	}
	*/

	brsn.DeleteObject();
	cldc.SelectObject(oldBrsh);

	CView::OnMouseMove(nFlags, point);
}
/////////////////////////////////////////////////////////////////////////////
// CCtlTipOfTheDayText message handlers
void CCtlTipOfTheDayText::OnPaint() 
{
	CPaintDC dc(this); // device context for painting
	
  // get rectangle of the text area inside dialog
  RECT rectWin;
  GetWindowRect(&rectWin);
  ScreenToClient(&rectWin);

  // calculate positions of the upper and left rectangle and separating line
  int iy, ix0, ix1;
  RECT rectUp;
  RECT rectDn;
  ix0 = rectUp.left = rectDn.left = rectWin.left;
  ix1 = rectUp.right = rectDn.right = rectWin.right;
  iy = rectUp.bottom = rectDn.top = int((rectWin.bottom+rectWin.top)*0.25f);
  rectUp.top = rectWin.top;
  rectDn.bottom = rectWin.bottom;
  InflateRect(&rectDn, -5,-10);
  InflateRect(&rectUp, -5,-10);
  OffsetRect(&rectDn, 0,5);
  OffsetRect(&rectUp, 0,5);

  // draw white rectangle with sunken edge
  CBrush brWhite;
  brWhite.CreateStockObject(WHITE_BRUSH);
  dc.FillRect(&rectWin, &brWhite);
  dc.DrawEdge(&rectWin, BDR_SUNKENOUTER, BF_RIGHT|BF_BOTTOM|BF_TOP);

  // draw separating line
  CBrush brGray;
  brGray.CreateStockObject(GRAY_BRUSH);
  dc.SelectObject(brGray);
  dc.MoveTo(ix0-1, iy);
  dc.LineTo(ix1, iy);

  // create two fonts, big and small
  LOGFONT lf;

  ::ZeroMemory (&lf, sizeof (lf));
  lf.lfHeight = 145;
  lf.lfWeight = FW_BOLD;
  lf.lfItalic = FALSE;
  wcscpy(lf.lfFaceName, L"Times New Roman");
  CFont fontBig;
  fontBig.CreatePointFontIndirect (&lf);

  ::ZeroMemory (&lf, sizeof (lf));
  lf.lfHeight = 100;
  lf.lfWeight = FW_NORMAL;
  lf.lfItalic = FALSE;
  wcscpy(lf.lfFaceName, L"Arial");
  CFont fontSmall;
  fontSmall.CreatePointFontIndirect (&lf);

  // print heading with big font
  dc.SelectObject(&fontBig);
  dc.DrawText("Did you know...", &rectUp, DT_VCENTER|DT_SINGLELINE);

  // print text with small font
  dc.SelectObject(&fontSmall);
  dc.DrawText(m_strTipText, &rectDn, DT_WORDBREAK);
}
Ejemplo n.º 16
0
void CColourPickerCB::DrawItem( LPDRAWITEMSTRUCT pDIStruct )
{
	CString strColour;
	CDC dcContext;
	CRect rItemRect( pDIStruct->rcItem );
	CRect rBlockRect( rItemRect );
	CRect rTextRect( rBlockRect );
	CBrush brFrameBrush;
	int iFourthWidth = 0;
	int iItem = pDIStruct->itemID;
	int iAction = pDIStruct->itemAction;
	int iState = pDIStruct->itemState;
	COLORREF crColour = NULL;
	COLORREF crNormal = GetSysColor( COLOR_WINDOW );
	COLORREF crSelected = GetSysColor( COLOR_HIGHLIGHT );
	COLORREF crText = GetSysColor( COLOR_WINDOWTEXT );

	if( !dcContext.Attach( pDIStruct->hDC ) )
	{
		return;
	}

	iFourthWidth = ( rBlockRect.Width() / 4 );
	brFrameBrush.CreateStockObject( BLACK_BRUSH );

	if( iState & ODS_SELECTED )
	{
		dcContext.SetTextColor(	( 0x00FFFFFF & ~( crText ) ) );
		dcContext.SetBkColor( crSelected );
		dcContext.FillSolidRect( &rBlockRect, crSelected );
	}
	else
	{
		dcContext.SetTextColor( crText );
		dcContext.SetBkColor( crNormal );
		dcContext.FillSolidRect( &rBlockRect, crNormal );
	}

	if( iState & ODS_FOCUS )
	{
		dcContext.DrawFocusRect( &rItemRect );
	}

	// calculate text area.
	rTextRect.left += ( iFourthWidth + 2 );
	rTextRect.top += 2;

	// calculate colour block area.
	rBlockRect.DeflateRect( CSize( 2, 2 ) );
	rBlockRect.right = iFourthWidth;

	// draw colour text and block.
	if( iItem != -1 )
	{
		GetLBText( iItem, strColour );

		if( iState & ODS_DISABLED )
		{
			crColour = GetSysColor( COLOR_INACTIVECAPTIONTEXT );
			dcContext.SetTextColor( crColour );
		}
		else
		{
			crColour = (COLORREF)GetItemData( iItem );
		}

		dcContext.SetBkMode( TRANSPARENT );
		dcContext.TextOut( rTextRect.left, rTextRect.top,	strColour );

		dcContext.FillSolidRect( &rBlockRect, crColour );
				
		dcContext.FrameRect( &rBlockRect, &brFrameBrush );
	}

	dcContext.Detach();
}
Ejemplo n.º 17
0
void CTipDlg::OnPaint()
{
    CPaintDC dc(this); // device context for painting

    // Get paint area for the big static control
//	CWnd* pStatic = GetDlgItem(IDC_BULB);
    CWnd* pFrame = GetDlgItem( IDC_TIPFRAME );
    CRect rect;
//	pStatic->GetWindowRect(&rect);
    pFrame->GetWindowRect( &rect );
    ScreenToClient(&rect);

    // Paint the background white.
    CBrush brush;
    brush.CreateStockObject(WHITE_BRUSH);
    dc.FillRect(rect, &brush);

    // Load bitmap and get dimensions of the bitmap
    CBitmap bmp;
    bmp.LoadBitmap(IDB_LIGHTBULB);
    BITMAP bmpInfo;
    bmp.GetBitmap(&bmpInfo);

    // Draw the dark gray band on the side
    CRect left;
    CopyRect( left, rect );
    left.right = bmpInfo.bmWidth + 30;
    brush.CreateStockObject(LTGRAY_BRUSH);
    dc.FillRect(left, &brush);

    // Draw bitmap in top corner and validate only top portion of window
//	CDC dcTmp;
//	dcTmp.CreateCompatibleDC(&dc);
//	dcTmp.SelectObject(&bmp);
    rect.bottom = bmpInfo.bmHeight + rect.top;
    HICON hIcon = AfxGetApp()->LoadIcon( IDI_LIGHTBULB );
    if ( hIcon != NULL )
        DrawIconEx( dc.GetSafeHdc(), rect.left + 10, rect.top + 10,
                    hIcon, 0, 0, NULL, NULL, DI_NORMAL );
//	dc.BitBlt(rect.left, rect.top, rect.Width(), rect.Height(),
//		&dcTmp, 0, 0, SRCCOPY);

    int mode = dc.GetBkMode();
    dc.SetBkMode( TRANSPARENT );

    // Draw out "Did you know..." message next to the bitmap
    CString strMessage;
    strMessage.LoadString(CG_IDS_DIDYOUKNOW);
    rect.left += bmpInfo.bmWidth + 20;
    COLORREF old = dc.SetTextColor( RGB( 200, 200, 200 ) );
    OffsetRect( &rect, 2, 2 );
    dc.DrawText(strMessage, rect, DT_VCENTER | DT_SINGLELINE);
    dc.SetTextColor( RGB( 0, 0, 255 ) );
    OffsetRect( &rect, -2, -2 );
    dc.DrawText(strMessage, rect, DT_VCENTER | DT_SINGLELINE);
    dc.SetTextColor( old );

    dc.SetBkMode( mode );

    // Do not call CDialog::OnPaint() for painting messages
}
Ejemplo n.º 18
0
void CDlgObj::PresentObj(CDC* pDC)
{
	CString str;

	m_pTmpDC->SelectObject(&m_BmpOut);
	m_pTmpDC2->SelectObject(&m_BmpBck);
	m_pTmpDC->BitBlt(0,0,width,height,m_pTmpDC2,0,0,SRCCOPY);
	static CPen PenCur(PS_SOLID,1,RGB(255,0,0));
	CPen PenObj[9];
	PenObj[1].CreatePen(PS_SOLID,3,RGB(255,0,0));//敌人
	PenObj[3].CreatePen(PS_SOLID,3,RGB(255,0,255));//BOSS
	PenObj[4].CreatePen(PS_SOLID,3,RGB(0,0,255));//道具
	PenObj[5].CreatePen(PS_SOLID,3,RGB(255,128,0));//特殊物件
	PenObj[6].CreatePen(PS_SOLID,3,RGB(0,255,0));
	PenObj[7].CreatePen(PS_SOLID,3,RGB(0,255,128));
	PenObj[8].CreatePen(PS_SOLID,3,RGB(128,0,255));//梅塔军队

	PenObj[0].CreatePen(PS_SOLID,3,RGB(0,0,0));
	PenObj[2].CreatePen(PS_SOLID,3,RGB(255,255,0));//高亮
	CBrush BrushNull;
	BrushNull.CreateStockObject(NULL_BRUSH);
	m_pTmpDC->SelectObject(&BrushNull);
	OBJ_DATA odt;
	for(u16 i=0;i<*pcount;i++)
	{
		if((*pobjlist)[i].is_folder==0)
		{
			odt=(*pobjlist)[i].o[0];
			m_pTmpDC->SelectObject(&PenObj[odt.class_id&0xFF]);
			if(i==cur_obj)m_pTmpDC->SelectObject(&PenObj[2]);
			DrawObj(odt.x,odt.y);
		}
		else
		{
			int folderpen=0;
			if(i==cur_obj && cur_subobj==0xFFFF)folderpen=2;
			m_pTmpDC->SelectObject(&PenObj[folderpen]);
			DrawObj((*pobjlist)[i].fx,(*pobjlist)[i].fy);
			for(u16 j=0;j<(*pobjlist)[i].len;j++)
			{
				odt=(*pobjlist)[i].o[j];
				m_pTmpDC->SelectObject(&PenObj[folderpen]);
				m_pTmpDC->MoveTo((*pobjlist)[i].fx,(*pobjlist)[i].fy);
				m_pTmpDC->LineTo(odt.x,odt.y);
				m_pTmpDC->SelectObject(&PenObj[odt.class_id&0xFF]);
				if(i==cur_obj && cur_subobj==j)m_pTmpDC->SelectObject(&PenObj[2]);
				DrawObj(odt.x,odt.y);
			}
		}
	}
	m_pTmpDC->SetBkMode(TRANSPARENT);
	CFont   MyFont; 
	MyFont.CreateFont( 
		12,6,
        0,0,FW_BOLD, 
        0,0,0, 
        DEFAULT_CHARSET, 
		OUT_CHARACTER_PRECIS, 
		CLIP_CHARACTER_PRECIS, 
		DEFAULT_QUALITY, 
		DEFAULT_PITCH|FF_DONTCARE, 
		_T("宋体")); 
	m_pTmpDC->SelectObject(MyFont); 
	for(u16 i=0;i<*pcount;i++)
	{
		if((*pobjlist)[i].is_folder==0)
		{
			str.Format(_T("%s"),CodeTran_Obj((*pobjlist)[i].o[0].class_id));
			m_pTmpDC->TextOut((*pobjlist)[i].o[0].x,(*pobjlist)[i].o[0].y,str.GetBuffer(),str.GetLength());
		}
	}
	
	if(x!=0xFFFF)
	{
		m_pTmpDC->SelectObject(&BrushNull);
		m_pTmpDC->SelectObject(&PenCur);
		m_pTmpDC->Rectangle((x/16)*16,(y/16)*16,(x/16)*16+16,(y/16)*16+16);
		
	}
	
	RECT hsrc,vsrc;
	int hsp=m_HScroll.GetScrollPos();
	int vsp=m_VScroll.GetScrollPos();
	m_HScroll.GetWindowRect(&hsrc);
	m_VScroll.GetWindowRect(&vsrc);
	ScreenToClient(&hsrc);
	ScreenToClient(&vsrc);
	pDC->BitBlt(hsrc.left,vsrc.top,
		hsrc.right-hsrc.left,vsrc.bottom-vsrc.top,m_pTmpDC,
		hsp,vsp,SRCCOPY);
}
Ejemplo n.º 19
0
void CSpiroView::OnLButtonDown(UINT nFlags, CPoint point) 
{
	if (m_bDrawingActive)
		return;

	if (m_bDroppingAnchor || m_bDroppingWheel)
	{
		ASSERT(!m_bDrawingDone);
		CWheel* pWheelDrop = NULL;
		CRing*	pRingDrop = NULL;
		CSpiroDoc* pDoc = GetDocument();
		ENSURE(pDoc != NULL);

		//convert the client coordinates to logical coordinates
		CDC* pDC = GetDC();
		ENSURE(pDC != NULL);
		OnPrepareDC(pDC);

		// Convert client coordinates to Logical coordinates
		CPoint pointScaled(point);
		pDC->DPtoLP(&pointScaled);
		point.x = pointScaled.x * m_nZoomDenom / m_nZoomNumer;  // undo scaling effects
		point.y = pointScaled.y * m_nZoomDenom / m_nZoomNumer;

		CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
		ENSURE(pFrame != NULL && pFrame->IsKindOf(RUNTIME_CLASS(CMainFrame)));

		if (m_bDroppingAnchor)
		{
			ASSERT(m_iPieceDropped >= 0 && m_iPieceDropped < TOTALRINGS);
			pRingDrop = new CRing(CRing::m_rgnRads[m_iPieceDropped] - RINGWIDTH,
				CRing::m_rgnRads[m_iPieceDropped],
				CRing::m_rgco[m_iPieceDropped], RGB(0, 0, 0));

			ENSURE(pRingDrop != NULL);  
			m_bDroppingAnchor = false;
			ENSURE(m_pAnchor == NULL);
			m_pAnchor = pRingDrop;
			m_pAnchor->SetPosition(point);
			m_dDataAnchorFirst = m_pAnchor->GetFigData();
		}
		else if (m_bDroppingWheel)
		{
			CBasePiece** ppPiece = (m_pAnchor == NULL? &m_pAnchor : &m_pWheel);
			ASSERT(m_iPieceDropped >= 0 && m_iPieceDropped < TOTALWHEELS);
			pWheelDrop = new CWheel(CWheel::m_rgnRads[m_iPieceDropped],
								CWheel::m_rgco[m_iPieceDropped],
								CWheel::m_rgcoPattern[m_iPieceDropped]);
								

			ENSURE(pWheelDrop != NULL);
			ENSURE(*ppPiece == NULL);
			*ppPiece = pWheelDrop;
			m_bDroppingWheel = false;
			(*ppPiece)->SetPosition(point);

			if (m_pWheel != NULL)
			{
				m_pWheel->SetWheelMode();

				// set the default pen location. pDC and zoom ration are dummies
				m_pWheel->SetPenLocation(this, pDC, CPoint(0, 0), 1, 1);

				ENSURE(m_pAnchor != NULL);

				CPoint ptContact;
				double dAngle;
				// Get contact position from the anchor and set wheel position
				// Decides if wheel is internal in case of being a ring
				m_pAnchor->GetContactPosition(pointScaled, m_nZoomNumer, 
										m_nZoomDenom, ptContact, dAngle);
			
				if (m_pWheel->GetPerimeter() >= m_pAnchor->GetPerimeter())
				{
					pointScaled.x = 0;
					pointScaled.y = 0;   // force the wheel out of the ring

					// get contact position again to make sure it's right
					m_pAnchor->GetContactPosition(pointScaled, m_nZoomNumer, 
											m_nZoomDenom, ptContact, dAngle);
				}

 				m_pWheel->SetPosition(ptContact, dAngle);
				m_dDataWheelFirst = m_pWheel->GetFigData();
				m_ptWheelPosFirst = m_pWheel->m_ptPos;
				PressButton(0);  // get the color settings for the new wheel
				CreateFigure();
			}

			m_iPieceDropped += TOTALRINGS + 1;
#ifdef _DEBUG
			int nID = pFrame->m_wndToolBarSpiro.GetItemID(m_iPieceDropped);
			ASSERT(nID >= ID_ENORMOUSWHEEL && nID <= ID_TINYWHEEL);
#endif
		}

		// uncheck the button used to select the piece in the toolbar
		UINT nButtonID = pFrame->m_wndToolBarSpiro.GetItemID(m_iPieceDropped);
		pFrame->m_wndToolBarSpiro.GetToolBarCtrl().CheckButton(nButtonID, FALSE);

		// invalidate the region holding the ring
		CRgn	rgn;  // region occupied by the piece
		(m_pWheel != NULL? m_pWheel : m_pAnchor)->GetDevPieceRgn(pDC,
									&rgn, m_nZoomNumer, m_nZoomDenom, false);

		InvalidateRgn(&rgn, FALSE);
		m_iPieceDropped = -1; // reset to keep control on values.
		ReleaseDC(pDC);
		return;
	}

	// check if the user wants to drag the pen position

	CDC* pDC = GetDC();
	ENSURE(pDC != NULL);
	OnPrepareDC(pDC);
	CPoint pointScaled(point);
	pDC->DPtoLP(&pointScaled);   // gets the logical coord point value with scale into account

	if (m_pWheel != NULL)
	{
		if (m_pWheel->HitTest(pDC, point, m_nZoomNumer, m_nZoomDenom) == HIT_PEN_LOCATION)  // start drag operation
		{
			MSG		msg;

			// if there is a WM_LBUTTONUP in the queue do not drag pencil location
			if (!::PeekMessage(&msg, m_hWnd, WM_LBUTTONUP, WM_LBUTTONUP, PM_NOREMOVE))
			{
				ClientToScreen(&point); // convert to screen coordinates
				CRect rectWindow;
				GetWindowRect(&rectWindow);
				point.x -= rectWindow.left;
				point.y -= rectWindow.top;  // point relative to windows corner

				CImageList& il = GetApp()->m_imageList;
				::ShowCursor(FALSE);
				il.BeginDrag(0, CPoint(0, 47));
				il.DragEnter(this, point);
				m_bMovingPencil = true;
				SetCapture();
			}
		}
	}

	for (;;) 
	{
		CRgn	rgn;
		MSG		msg;

		if (::PeekMessage(&msg, m_hWnd, WM_LBUTTONUP, WM_LBUTTONUP, PM_NOREMOVE))  // no drag is being requested
			break;

		if (m_pWheel != NULL)
		{
			m_pWheel->GetLogPieceRgn(&rgn, m_nZoomNumer, m_nZoomDenom);
			if (rgn.PtInRegion(pointScaled))  // clicked on wheel.  Don't do anything
				break;

			rgn.DeleteObject();
		}

		if (m_pAnchor != NULL)
		{
			m_pAnchor->GetLogPieceRgn(&rgn, m_nZoomNumer, m_nZoomDenom);
			if (rgn.PtInRegion(pointScaled))   // clicked on the anchor
				break;

			rgn.DeleteObject();
		}

		// find now if the user clicked on a Figure.  The current Figure cannot be dragged.  This is by design
		CSpiroDoc*	pDoc = GetDocument();
		INT_PTR		iPic;
		CFigure*	pFigure;
		CSpiroRect	rect;

		for (iPic = pDoc->m_arrPFigures.GetUpperBound(); iPic >= 0; iPic--)
		{
			pFigure = (CFigure*)pDoc->m_arrPFigures.GetAt(iPic);
			ENSURE(pFigure != NULL);
			pFigure->GetBoundingRect(&rect);
			rect.Scale(m_nZoomNumer, m_nZoomDenom);
			if (pointScaled.x < rect.left || pointScaled.x >= rect.right ||
					pointScaled.y > rect.top || pointScaled.y <= rect.bottom)
			{
				continue;
			}

			bool bCopy = (nFlags & MK_CONTROL) == MK_CONTROL;
			m_pFigureDrag = (bCopy? new CFigure(pFigure) : pFigure);

			if (!bCopy)
				pDoc->m_arrPFigures.RemoveAt(iPic);

			ENSURE(m_pILDragFigure == NULL);

			// First draw the Figure into a memery DC using an allocated bitmap
			CDC	dcMem;
			ENSURE(pDC != NULL);

			VERIFY(dcMem.CreateCompatibleDC(pDC));
			dcMem.SetMapMode(MM_SPIRO);
			dcMem.SetViewportOrg(0, 0);
			dcMem.SetWindowOrg(rect.left, rect.top);

			CSpiroRect	rectBitmap(rect);
			dcMem.LPtoDP(&rectBitmap);
			ASSERT(rectBitmap.left == 0 && rectBitmap.top == 0);

			int			nWidth = rectBitmap.right;
			int			nHeight = rectBitmap.bottom;

			CBitmap*	pbmOld = NULL;
			
			ASSERT(m_pBitmapDragFigure == NULL);
			m_pBitmapDragFigure = new CBitmap();
			m_pBitmapDragFigure->CreateCompatibleBitmap(pDC, nWidth, nHeight);
			pbmOld = dcMem.SelectObject(m_pBitmapDragFigure);

		//	dcMem.PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), WHITENESS);
			CBrush	brush;
			brush.CreateStockObject(WHITE_BRUSH);
			dcMem.FillRect(&rect, &brush);
			m_pFigureDrag->Draw(&dcMem, m_nZoomNumer, m_nZoomDenom, NULL, &rect);
			dcMem.SelectObject(pbmOld);
			// Then create an imagelist and add the bitmap to it
			ASSERT(m_pILDragFigure == NULL);
			m_pILDragFigure = new CImageList();				
			VERIFY(m_pILDragFigure->Create(nWidth, nHeight, ILC_COLOR | ILC_MASK, 1, 1));
			VERIFY(m_pILDragFigure->Add(m_pBitmapDragFigure, RGB(255, 255, 255)) == 0);

			m_bStartDrag = true;  // Enter the drag on first mouse move

			//calculate the hot spot for the figure
			m_ptHotSpotDragFigure.x = pointScaled.x - rect.left;
			m_ptHotSpotDragFigure.y = pointScaled.y - rect.bottom;
			pDC->SetWindowOrg(0, rect.top - rect.bottom);
			pDC->SetViewportOrg(0, 0);
			pDC->LPtoDP(&m_ptHotSpotDragFigure);
			m_pILDragFigure->BeginDrag(0, m_ptHotSpotDragFigure);
			SetCapture();
			break;
		}

		break;
	}

	ReleaseDC(pDC);
	CScrollView::OnLButtonDown(nFlags, point);
}
Ejemplo n.º 20
0
//CFont m_font;
BOOL CDlgOption::OnInitDialog() 
{
	CDialog::OnInitDialog();

	LoadSkin();
	LoadButton();
#if __VER >= 9 // __CSC_VER9_RESOLUTION
	IDirect3D9* pD3D9;
	int nSelect = 0;
	pD3D9 = Direct3DCreate9( D3D_SDK_VERSION );
	
	BOOL checkRes[11] = {FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE};

	D3DFORMAT allowedAdapterFormat = D3DFMT_X8R8G8B8;
	UINT numAdapterModes = pD3D9->GetAdapterModeCount( 0, allowedAdapterFormat );
	for (UINT mode = 0; mode < numAdapterModes; mode++)
	{
		D3DDISPLAYMODE displayMode;
		pD3D9->EnumAdapterModes( 0, allowedAdapterFormat, mode, &displayMode );
		if( !checkRes[0] && displayMode.Width == 800 && displayMode.Height == 600 )
		{
			if(m_cbRes.FindString(0, "800x600") == -1)
			{
				m_cbRes.InsertString( -1, "800x600" );
				checkRes[0] = TRUE;
				m_nNormalRCount++;
				if(m_bStartFullScreen && m_nResWidth == displayMode.Width && m_nResHeight == displayMode.Height)
					nSelect = m_nNormalRCount + m_nWideRCount - 1;
			}
		}
		else if( !checkRes[1] && displayMode.Width == 1024 && displayMode.Height == 768 )
		{
			if(m_cbRes.FindString(0, "1024x768") == -1)
			{
				m_cbRes.InsertString( -1, "1024x768" );
				checkRes[1] = TRUE;
				m_nNormalRCount++;
				if(m_bStartFullScreen && m_nResWidth == displayMode.Width && m_nResHeight == displayMode.Height)
					nSelect = m_nNormalRCount + m_nWideRCount - 1;
			}
		}
		else if( !checkRes[2] && displayMode.Width == 1280 && displayMode.Height == 1024 )
		{
			if(m_cbRes.FindString(0, "1280x1024") == -1)
			{
				m_cbRes.InsertString( -1, "1280x1024" );
				checkRes[2] = TRUE;
				m_nNormalRCount++;
				if(m_bStartFullScreen && m_nResWidth == displayMode.Width && m_nResHeight == displayMode.Height)
					nSelect = m_nNormalRCount + m_nWideRCount - 1;
			}
		}
		else if( !checkRes[3] && displayMode.Width == 1400 && displayMode.Height == 1050 )
		{
			if(m_cbRes.FindString(0, "1400x1050") == -1)
			{
				m_cbRes.InsertString( -1, "1400x1050" );
				checkRes[3] = TRUE;
				m_nNormalRCount++;
				if(m_bStartFullScreen && m_nResWidth == displayMode.Width && m_nResHeight == displayMode.Height)
					nSelect = m_nNormalRCount + m_nWideRCount - 1;
			}
		}
		else if( !checkRes[4] && displayMode.Width == 1600 && displayMode.Height == 1200 )
		{
			if(m_cbRes.FindString(0, "1600x1200") == -1)
			{
				m_cbRes.InsertString( -1, "1600x1200" );
				checkRes[4] = TRUE;
				m_nNormalRCount++;
				if(m_bStartFullScreen && m_nResWidth == displayMode.Width && m_nResHeight == displayMode.Height)
					nSelect = m_nNormalRCount + m_nWideRCount - 1;
			}
		}
		else if( !checkRes[5] && displayMode.Width == 1280 && displayMode.Height == 720 )
		{
#if __CURRENT_LANG == LANG_GER
			if(m_cbRes.FindString(0, "1280x720 (Breitbild)") == -1)
			{
				m_cbRes.InsertString( -1, "1280x720 (Breitbild)" );
#else // __CURRENT_LANG == LANG_GER
			if(m_cbRes.FindString(0, "1280x720 (Wide)") == -1)
			{
				m_cbRes.InsertString( -1, "1280x720 (Wide)" );
#endif // __CURRENT_LANG == LANG_GER
				checkRes[5] = TRUE;
				m_nWideRCount++;
				if(m_bStartFullScreen && m_nResWidth == displayMode.Width && m_nResHeight == displayMode.Height)
					nSelect = m_nNormalRCount + m_nWideRCount - 1;
			}
		}
		else if( !checkRes[6] && displayMode.Width == 1280 && displayMode.Height == 768 )
		{
#if __CURRENT_LANG == LANG_GER
			if(m_cbRes.FindString(0, "1280x768 (Breitbild)") == -1)
			{
				m_cbRes.InsertString( -1, "1280x768 (Breitbild)" );
#else // __CURRENT_LANG == LANG_GER
			if(m_cbRes.FindString(0, "1280x768 (Wide)") == -1)
			{
				m_cbRes.InsertString( -1, "1280x768 (Wide)" );
#endif // __CURRENT_LANG == LANG_GER
				checkRes[6] = TRUE;
				m_nWideRCount++;
				if(m_bStartFullScreen && m_nResWidth == displayMode.Width && m_nResHeight == displayMode.Height)
					nSelect = m_nNormalRCount + m_nWideRCount - 1;
			}
		}
		else if( !checkRes[7] && displayMode.Width == 1280 && displayMode.Height == 800 )
		{
#if __CURRENT_LANG == LANG_GER
			if(m_cbRes.FindString(0, "1280x800 (Breitbild)") == -1)
			{
				m_cbRes.InsertString( -1, "1280x800 (Breitbild)" );
#else // __CURRENT_LANG == LANG_GER
			if(m_cbRes.FindString(0, "1280x800 (Wide)") == -1)
			{
				m_cbRes.InsertString( -1, "1280x800 (Wide)" );
#endif // __CURRENT_LANG == LANG_GER
				checkRes[7] = TRUE;
				m_nWideRCount++;
				if(m_bStartFullScreen && m_nResWidth == displayMode.Width && m_nResHeight == displayMode.Height)
					nSelect = m_nNormalRCount + m_nWideRCount - 1;
			}
		}
		else if( !checkRes[8] && displayMode.Width == 1360 && displayMode.Height == 768 )
		{
#if __CURRENT_LANG == LANG_GER
			if(m_cbRes.FindString(0, "1360x768 (Breitbild)") == -1)
			{
				m_cbRes.InsertString( -1, "1360x768 (Breitbild)" );
#else // __CURRENT_LANG == LANG_GER
			if(m_cbRes.FindString(0, "1360x768 (Wide)") == -1)
			{
				m_cbRes.InsertString( -1, "1360x768 (Wide)" );
#endif // __CURRENT_LANG == LANG_GER
				checkRes[8] = TRUE;
				m_nWideRCount++;
				if(m_bStartFullScreen && m_nResWidth == displayMode.Width && m_nResHeight == displayMode.Height)
					nSelect = m_nNormalRCount + m_nWideRCount - 1;
			}
		}
		else if( !checkRes[9] && displayMode.Width == 1440 && displayMode.Height == 900 )
		{
#if __CURRENT_LANG == LANG_GER
			if(m_cbRes.FindString(0, "1440x900 (Breitbild)") == -1)
			{
				m_cbRes.InsertString( -1, "1440x900 (Breitbild)" );
#else // __CURRENT_LANG == LANG_GER
			if(m_cbRes.FindString(0, "1440x900 (Wide)") == -1)
			{
				m_cbRes.InsertString( -1, "1440x900 (Wide)" );
#endif // __CURRENT_LANG == LANG_GER
				checkRes[9] = TRUE;
				m_nWideRCount++;
				if(m_bStartFullScreen && m_nResWidth == displayMode.Width && m_nResHeight == displayMode.Height)
					nSelect = m_nNormalRCount + m_nWideRCount - 1;
			}
		}
		else if( !checkRes[10] && displayMode.Width == 1680 && displayMode.Height == 1050 )
		{
#if __CURRENT_LANG == LANG_GER
			if(m_cbRes.FindString(0, "1680x1050 (Breitbild)") == -1)
			{
				m_cbRes.InsertString( -1, "1680x1050 (Breitbild)" );
#else // __CURRENT_LANG == LANG_GER
			if(m_cbRes.FindString(0, "1680x1050 (Wide)") == -1)
			{
				m_cbRes.InsertString( -1, "1680x1050 (Wide)" );
#endif // __CURRENT_LANG == LANG_GER
				checkRes[10] = TRUE;
				m_nWideRCount++;
				if(m_bStartFullScreen && m_nResWidth == displayMode.Width && m_nResHeight == displayMode.Height)
					nSelect = m_nNormalRCount + m_nWideRCount - 1;
			}
		}
	}

#if __CURRENT_LANG == LANG_KOR
	m_cbRes.InsertString( -1, "800x600(창모드)" );
	m_cbRes.InsertString( -1, "1024x768(창모드)" );
	m_cbRes.InsertString( -1, "1280x1024(창모드)" );
	m_cbRes.InsertString( -1, "1400x1050(창모드)" );
	m_cbRes.InsertString( -1, "1280x720(W창모드)" );
	m_cbRes.InsertString( -1, "1280x768(W창모드)" );
	m_cbRes.InsertString( -1, "1280x800(W창모드)" );
	m_cbRes.InsertString( -1, "1360x768(W창모드)" );
	m_cbRes.InsertString( -1, "1440x900(W창모드)" );
#else // __CURRENT_LANG == LANG_KOR
	m_cbRes.InsertString( -1, "800x600 (Window)" );
	m_cbRes.InsertString( -1, "1024x768 (Window)" );
	m_cbRes.InsertString( -1, "1280x1024 (Window)" );
	m_cbRes.InsertString( -1, "1400x1050 (Window)" );
	m_cbRes.InsertString( -1, "1280x720 (W Window)" );
	m_cbRes.InsertString( -1, "1280x768 (W Window)" );
	m_cbRes.InsertString( -1, "1280x800 (W Window)" );
	m_cbRes.InsertString( -1, "1360x768 (W Window)" );
	m_cbRes.InsertString( -1, "1440x900 (W Window)" );
#endif // __CURRENT_LANG == LANG_KOR

	if(!m_bStartFullScreen)
	{
		int n = 0;
		switch(m_nResWidth) 
		{
			case 800:
				n = 0;
				break;
			case 1024:
				n = 1;
				break;
			case 1280:
				if(m_nResHeight == 1024)
					n = 2;
				else if(m_nResHeight == 720)
					n = 4;
				else if(m_nResHeight == 768)
					n = 5;
				else if(m_nResHeight == 800)
					n = 6;
				break;
			case 1400:
				n = 3;
				break;
			case 1360:
				n = 7;
				break;
			case 1440:
				n = 8;
				break;
		}
		nSelect = m_nNormalRCount + m_nWideRCount + n;
	}
	pD3D9->Release();
#else //__CSC_VER9_RESOLUTION
	m_cbRes.InsertString( -1, "800x600" );
	m_cbRes.InsertString( -1, "1024x768" );
	m_cbRes.InsertString( -1, "1280x1024" );
#if (__CURRENT_LANG == LANG_KOR)
	m_cbRes.InsertString( -1, "800x600(창모드)" );
	m_cbRes.InsertString( -1, "1024x768(창모드)" );
	m_cbRes.InsertString( -1, "1280x1024(창모드)" );
#elif (__CURRENT_LANG == LANG_GER  || __CURRENT_LANG == LANG_FRA)
	m_cbRes.InsertString( -1, "800x600(Window)" );
	m_cbRes.InsertString( -1, "1024x768(Window)" );
	m_cbRes.InsertString( -1, "1280x1024(Window)" );
#endif
#endif //__CSC_VER9_RESOLUTION

#if __VER < 9 // __CSC_VER9_RESOLUTION
	int nSelect = 0;
	switch( m_nResWidth )
	{
		case 800:	nSelect = 0;		break;
		case 1024:	nSelect = 1;		break;
		case 1280:	nSelect = 2;		break;
	}

#if (__CURRENT_LANG == LANG_KOR || __CURRENT_LANG == LANG_GER || __CURRENT_LANG == LANG_FRA)
	if( m_bStartFullScreen == FALSE )
		nSelect += 3;
#endif
#endif //__CSC_VER9_RESOLUTION
	
	m_cbRes.SetCurSel( nSelect );

	bool bFont = false;
	HFONT hFont = (HFONT)::GetStockObject(DEFAULT_GUI_FONT);
	//if (hFont == NULL)
	//	hFont = (HFONT)::GetStockObject(SYSTEM_FONT);
	if( hFont )
	{
		LOGFONT lf;
		if( ::GetObject(hFont, sizeof(LOGFONT), &lf) != 0)
		{
			if( m_font.CreateFontIndirect( &lf ) )
				bFont = true;
		}
	}

	struct POSINFO
	{
		UINT nID;
		int x, y;
		int nMsgID;
	};

	POSINFO posInfos[] =  
	{
		{IDC_STATIC,       40,  57,  IDS_RESOLUTION },
		{IDC_STATIC2,      39,  209, IDS_VIEW },
		{IDC_STATIC3,      210, 209, IDS_TEXTURE },
		{IDC_STATIC4,	   39,  281, IDS_SHADOW },
		{IDC_STATIC5,      212, 281, IDS_OBJECTDETAIL },
		{IDC_VIEW_RADIO1,  28,  237, IDS_FAR },
		{IDC_VIEW_RADIO2,  75,  237, IDS_MEDIUM },
		{IDC_VIEW_RADIO3,  124, 237, IDS_NEAR },
		{IDC_TQ_RADIO1,    205, 236, IDS_HIGH },
		{IDC_TQ_RADIO2,    257, 236, IDS_MEDIUM },
		{IDC_TQ_RADIO3,    305, 236, IDS_LOW },
		{IDC_SHD_RADIO1,   28,  308, IDS_HIGH },
		{IDC_SHD_RADIO2,   81,  308, IDS_MEDIUM },
		{IDC_SHD_RADIO3,   133, 308, IDS_LOW },
		{IDC_OD_RADIO1,    205, 305, IDS_HIGH },
		{IDC_OD_RADIO2,    257, 305, IDS_MEDIUM },
		{IDC_OD_RADIO3,    306, 305, IDS_LOW },
		{IDC_RES_COMBO,	   100, 50,  -1 },
		{IDOK,             65,  105, -1 },
		{IDCANCEL,         65,  130, -1 }
	};

	CString str;
	int n = sizeof(posInfos) / sizeof(posInfos[0]);
	for( int i=0; i<n; i++)
	{
		CWnd *pWnd = GetDlgItem( posInfos[i].nID );
		if( pWnd == NULL )
			continue;
		pWnd->SetWindowPos( NULL, posInfos[i].x, posInfos[i].y, 0, 0, SWP_NOREDRAW | SWP_NOZORDER | SWP_NOSIZE );
		if( posInfos[i].nMsgID != -1 )
		{
			str.LoadString(posInfos[i].nMsgID);
			SetDlgItemText( posInfos[i].nID, str );
		}

		if( bFont )
			pWnd->SetFont( &m_font, FALSE );
	}

	UpdateData(FALSE);		// 변수에서 컨트롤로.
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}

void CDlgOption::OnOK() 
{
	int nCurSel = m_cbRes.GetCurSel();
#if __VER >= 9 // __CSC_VER9_RESOLUTION
	CString text1, text2;
	BOOL bWide;
	m_cbRes.GetWindowText(text1);
	m_cbRes.GetWindowText(text2);
	int nNum = text1.Find("x", 0);
	int nSize = text1.GetLength();
	text1.Delete(nNum, nSize-nNum);

	if(nCurSel < m_nNormalRCount + m_nWideRCount)
	{
		int nWidth = atoi(text1);
		switch(nWidth) 
		{
			case 800:
				m_nResWidth = 800;	
				m_nResHeight = 600;
				break;
			case 1024:
				m_nResWidth = 1024;	
				m_nResHeight = 768;
				break;
			case 1280:
				{
					CString temp;
					m_cbRes.GetWindowText(temp);
					int num = temp.Find("Wide", 0);
					if(num > -1)
					{
						num = temp.Find("720", 0);
						if(num > -1)
						{
							m_nResWidth = 1280;	
							m_nResHeight = 720;
						}
						else
						{
							num = temp.Find("768", 0);
							if(num > -1)
							{
								m_nResWidth = 1280;	
								m_nResHeight = 768;
							}
							else
							{
								m_nResWidth = 1280;	
								m_nResHeight = 800;
							}
						}
					}
					else
					{
						m_nResWidth = 1280;	
						m_nResHeight = 1024;
					}
				}
				break;
			case 1400:
				m_nResWidth = 1400;	
				m_nResHeight = 1050;
				break;
			case 1600:
				m_nResWidth = 1600;	
				m_nResHeight = 1200;
				break;
			case 1360:
				m_nResWidth = 1360;	
				m_nResHeight = 768;
				break;
			case 1440:
				m_nResWidth = 1440;	
				m_nResHeight = 900;
				break;
			case 1680:
				m_nResWidth = 1680;	
				m_nResHeight = 1050;
				break;
		}
		m_bStartFullScreen = TRUE;
	}
	else if(nCurSel >= m_nNormalRCount + m_nWideRCount) //Windowed Mode
	{
		int nWidth = atoi(text1);
		if(nWidth == 1280)
		{
			text2.Delete(0, nNum+1);
			int nNum2 = text2.Find("(", 0);
			nSize = text2.GetLength();
			text2.Delete(nNum2, nSize-nNum2);
			if(atoi(text2) == 1024)
				bWide = FALSE;
			else
				bWide = TRUE;
		}

		switch(nWidth) 
		{
			case 800:
				m_nResWidth = 800;	
				m_nResHeight = 600;
				break;
			case 1024:
				m_nResWidth = 1024;	
				m_nResHeight = 768;
				break;
			case 1280:
				if(!bWide)
				{
					m_nResWidth = 1280;	
					m_nResHeight = 1024;
				}
				else
				{
					int nNum = text2.Find("720", 0);
					if(nNum > -1)
					{
						m_nResWidth = 1280;	
						m_nResHeight = 720;
					}
					else
					{
						nNum = text2.Find("768", 0);
						if(nNum > -1)
						{
							m_nResWidth = 1280;	
							m_nResHeight = 768;
						}
						else
						{
							m_nResWidth = 1280;	
							m_nResHeight = 800;
						}
					}
				}
				break;
			case 1360:
				m_nResWidth = 1360;	
				m_nResHeight = 768;
				break;
			case 1400:
				m_nResWidth = 1400;	
				m_nResHeight = 1050;
				break;
			case 1440:
				m_nResWidth = 1440;	
				m_nResHeight = 900;
				break;
		}
		m_bStartFullScreen = FALSE;
	}
#else //__CSC_VER9_RESOLUTION
	switch( nCurSel )
	{
	default:
	case 0:	// 800x600;
	case 3:	// 800x600;
		m_nResWidth = 800;	
		m_nResHeight = 600;	
		break;
	case 1:	// 1024x768
	case 4:	// 1024x768
		m_nResWidth = 1024;	
		m_nResHeight = 768;	
		break;
	case 2:	// 1280x1024
	case 5:	// 1280x1024
		m_nResWidth = 1280;	
		m_nResHeight = 1024;	
		break;
	}
	m_bStartFullScreen = (nCurSel < 3);
#endif //__CSC_VER9_RESOLUTION
	UpdateData(TRUE);	// 컨트롤에서 변수.
	CDialog::OnOK();
}

void CDlgOption::LoadSkin()
{
	m_pic.Load( IDC_BITMAP_OPTION );
	CSize size = m_pic.GetImageSize();
	SetWindowPos( NULL, 0, 0, size.cx, size.cy, SWP_NOZORDER | SWP_NOMOVE );

	HRGN hRgn = CreateRoundRectRgn( 0, 0, size.cx, size.cy, 18, 18 );
	::SetWindowRgn( m_hWnd, hRgn, FALSE );
}

BOOL CDlgOption::OnEraseBkgnd(CDC* pDC) 
{
	m_pic.Render( pDC );
	return TRUE;
}

HBRUSH CDlgOption::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
    CBrush B;
	// TODO__
    if (nCtlColor == CTLCOLOR_STATIC ) {
        B.CreateStockObject(NULL_BRUSH);
        pDC->SetBkMode(TRANSPARENT);
		return (HBRUSH) B;
	}

	return hbr;
}

void CDlgOption::LoadButton()
{
	m_BtnOK.SetBitmaps(IDB_BITMAP_OK00, RGB(255, 0, 255), IDB_BITMAP_OK01, RGB(255, 0, 255) );
	m_BtnOK.SetAlign(CButtonST::ST_ALIGN_OVERLAP, FALSE);
	m_BtnOK.SetPressedStyle(CButtonST::BTNST_PRESSED_LEFTRIGHT, FALSE);
	m_BtnOK.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(0, 0, 0));
	m_BtnOK.SetColor(CButtonST::BTNST_COLOR_FG_OUT, RGB(0, 0, 0));
	m_BtnOK.SizeToContent();
	m_BtnOK.DrawTransparent(TRUE);
	m_BtnOK.DrawBorder(FALSE, FALSE);
	m_BtnOK.SetBtnCursor(IDC_CURSOR1);
	
	m_BtnCANCEL.SetBitmaps(IDB_BITMAP_CANCEL00, RGB(255, 0, 255), IDB_BITMAP_CANCEL01, RGB(255, 0, 255) );
	m_BtnCANCEL.SetAlign(CButtonST::ST_ALIGN_OVERLAP, FALSE);
	m_BtnCANCEL.SetPressedStyle(CButtonST::BTNST_PRESSED_LEFTRIGHT, FALSE);
	m_BtnCANCEL.SetColor(CButtonST::BTNST_COLOR_FG_IN, RGB(0, 0, 0));
	m_BtnCANCEL.SetColor(CButtonST::BTNST_COLOR_FG_OUT, RGB(0, 0, 0));
	m_BtnCANCEL.SizeToContent();
	m_BtnCANCEL.DrawTransparent(TRUE);
	m_BtnCANCEL.DrawBorder(FALSE, FALSE);
	m_BtnCANCEL.SetBtnCursor(IDC_CURSOR1);
}

void CDlgOption::OnCancel() 
{
	CDialog::OnCancel();
}
Ejemplo n.º 21
0
void CGuiToolButton::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
	CDC*  pdc= CDC::FromHandle(lpDrawItemStruct->hDC);
	CRect rc=lpDrawItemStruct->rcItem;
	UINT  uState=lpDrawItemStruct->itemState;
	CBrush cb;
	
	if( uState & ODS_SELECTED) //the button is pressed
	{
		if(m_StyleDisplay==GUISTYLE_2003 || m_StyleDisplay == GUISTYLE_2003MENUBTN)
				cb.CreateSolidBrush(GuiDrawLayer::m_Theme? RGB(249,200,102):GuiDrawLayer::GetRGBPressBXP());
			else
				cb.CreateSolidBrush(GuiDrawLayer::GetRGBPressBXP());

	}	
	else
		if (m_bMouserOver)
		{
			if(m_StyleDisplay==GUISTYLE_2003 || m_StyleDisplay== GUISTYLE_2003MENUBTN)
				cb.CreateSolidBrush(GuiDrawLayer::m_Theme? RGB(252,230,186):GuiDrawLayer::GetRGBFondoXP());
			else
				cb.CreateSolidBrush(GuiDrawLayer::GetRGBFondoXP());

		}
		else
		{
		
			if(m_StyleDisplay==GUISTYLE_2003)
			{
				if (m_Transparent && m_StyleDisplay )
					cb.CreateStockObject(NULL_BRUSH);
				else
				{
					CGradient M(CSize(rc.Width(),rc.Height()+1));	
					M.PrepareReverseVertTab(pdc,m_StyleDisplay);
					M.Draw(pdc,rc.left,rc.top,0,0,rc.Width(),rc.Height(),SRCCOPY);	
				}
			}
			else
				if (m_StyleDisplay== GUISTYLE_2003MENUBTN)
					cb.CreateSolidBrush(GuiDrawLayer::GetRGBColorFace(m_StyleDisplay));
				else
					cb.CreateSolidBrush(m_clColor);
			
		}
	
	if (( uState & ODS_SELECTED) || m_bMouserOver )
	{
		pdc->Draw3dRect(rc,GuiDrawLayer::GetRGBCaptionXP(),GuiDrawLayer::GetRGBCaptionXP());
		rc.DeflateRect(1,1);
		
	}
	else if(m_ScrollButton || m_bSimple)
	{
		pdc->Draw3dRect(rc,GuiDrawLayer::GetRGBColorShadow(),GuiDrawLayer::GetRGBColorShadow());
		rc.DeflateRect(1,1);
	}

	if (m_Transparent )
		pdc->FillRect(rc,&cb);


	int calculodify;
	calculodify=rc.Height()-(m_SizeImage.cy);
	calculodify/=2;
	int nHeigh=calculodify+(m_bShowDark?1:0);
	int nWidth=m_ScrollButton?rc.Width()/2 :2;
	CPoint m_point=CPoint(nWidth,nHeigh);
	
	if (m_SizeImage.cx > 2)
	{
		if(m_bMouserOver == 1 && !(uState & ODS_DISABLED) && !(uState & ODS_SELECTED) && m_bShowDark)
		{
			CPoint p(m_point.x+1,m_point.y+1);
			pdc->DrawState(p,m_SizeImage,m_Icon,DSS_MONO,CBrush (GuiDrawLayer::GetRGBColorShadow()));
			m_point.x-=1; m_point.y-=1;
		}
		pdc->DrawState (m_point, m_SizeImage,m_Icon,
					(uState==ODS_DISABLED?DSS_DISABLED:DSS_NORMAL),(CBrush*)NULL);
	}
	if (m_SizeText.cx > 2)
	{
		int nMode = pdc->SetBkMode(TRANSPARENT);
		CRect rectletra=rc;
		int nt=m_ScrollButton?0:8;
		rectletra.left+=m_SizeImage.cx+nt;
		CPoint pt=CSize(rectletra.top,rectletra.left);
		if (uState & ODS_DISABLED)
			pdc->DrawState(pt, m_SizeText, m_szText, DSS_DISABLED, TRUE, 0, (CBrush*)NULL);
		else
		{
			if(m_bMouserOver != 1) 
				pdc->SetTextColor(m_clrFont);
			pdc->DrawText(m_szText,rectletra,DT_SINGLELINE|DT_LEFT|DT_VCENTER);
		}
		pdc->SetBkMode(nMode);
	}
	
	// TODO:  Add your code to draw the specified item
}