Ejemplo n.º 1
0
void CBall::Draw(HDC dc)
{
	HBRUSH hOldBrush;
	hOldBrush = SelectBrush(dc, hBrush);
	Ellipse(dc, 10, 10, 30, 30);
	SelectBrush(dc, hOldBrush);
}
Ejemplo n.º 2
0
void DrawFigure() //Draw next figure
{
	HDC dc = GetDC(g_hFigure);
	RECT	rectWndFigure;
	HBRUSH  hOldBrach;
	HBRUSH	hBrash = CreateSolidBrush(RGB(100, 100, 100));
	HBRUSH	hBlackBrash = GetStockBrush(BLACK_BRUSH);

	GetWindowRect(g_hFigure, &rectWndFigure);
	int x = (rectWndFigure.right - rectWndFigure.left) / 4;
	int y = (rectWndFigure.bottom - rectWndFigure.top) / 4;
	for (int i = 0; i<4; i++)
	for (int j = 0; j<4; j++)
	{
		if (g_bNextFigur[i][j])
		{
			hOldBrach = SelectBrush(dc, hBrash);
			Rectangle(dc, i*x, j*y, ((i + 1)*x) + x, (j*y) + y);
			hBrash = SelectBrush(dc, hOldBrach);
		}
		else
		{
			hOldBrach = SelectBrush(dc, hBlackBrash);
			Rectangle(dc, i*x, j*y, ((i + 1)*x) + x, (j*y) + y);
			SelectBrush(dc, hOldBrach);
		}
	}
	DeleteBrush(SelectBrush(dc, hOldBrach));
	ReleaseDC(g_hFigure, dc);
	ValidateRect(g_hFigure, &rectWndFigure);
}
Ejemplo n.º 3
0
/// <param name="list">list of points</param>
/// <param name="count">number of points</param>
/// <param name="width">pen width for drawing line</param>
/// <param name="color">pen color</param>
/// <param name="fill">polygon fill color</param>
void Canvas::DrawPolygon(const rect_t &rect, const rect_t &box, point_t list[], size_t count, meter_t width, color_t color, color_t fill)
{
	CPen pen;
	CBrush brush;
	std::vector<POINT> pts;
	POINT pt = {0};

	for (size_t i = 0; i < count; i++)
	{
		pt.x = list[i].x - box.x + rect.x;
		pt.y = list[i].y - box.y + rect.y;
		pts.push_back(pt);
	}
	CRgn region;
	region.CreateRectRgn(rect.x, rect.y, rect.x + rect.wide, rect.y + rect.high);
	SelectClipRgn(region);

	brush.CreateSolidBrush(fill);
	pen.CreatePen(PS_SOLID, width, color);
	HPEN hSavePen = SelectPen(pen);
	HBRUSH hSaveBrush = SelectBrush(brush);
	Polygon(&pts[0], pts.size());

	SelectPen(hSavePen);
	SelectBrush(hSaveBrush);
	SelectClipRgn(NULL);
}
Ejemplo n.º 4
0
BOOL CUserControlList::ProcessMessages(UINT Msg,WPARAM wParam,LPARAM lParam)
{
	//проверить, что сообщение относитс¤ именно к этому списку
	if(wParam!=mControlID) return FALSE;

	//выбор по сообщению
	switch(Msg)
	{
	case WM_DRAWITEM:				//рисование
		{
			//получить структуру с информацией о рисовании
			DRAWITEMSTRUCT* pDrawItem=(DRAWITEMSTRUCT*)lParam;
			//если элементов нет, закончить
			if(pDrawItem->itemID==LB_ERR) return TRUE;

			//кэшировать некоторые параметры
			HDC hdc=pDrawItem->hDC;
			RECT Rect=pDrawItem->rcItem;

			//указать шрифт
			HFONT hLastFont=SelectFont(hdc,gApplication.mhFontCode);
			//установить режим прозрачности
			SetBkMode(hdc,TRANSPARENT);
			//выделить перо и кисть в контекст
			HPEN hLastPen=SelectPen(hdc,gApplication.mhPenSelect);
			HBRUSH hLastBrush=SelectBrush(hdc,gApplication.mhBrushSelect);

			//если элемент выделен
			if(pDrawItem->itemState & ODS_SELECTED)
				//нарисовать выдел¤ющий пр¤моугольник
				Rectangle(hdc,Rect.left,Rect.top,Rect.right,Rect.bottom);
			//иначе очистить пр¤моугольник
			else
				FillRect(hdc,&Rect,GetStockBrush(WHITE_BRUSH));

			//нарисовать элемент
			((CUserControlListElement*)pDrawItem->itemData)->Draw(hdc,&Rect);

			//вернуть прежние перо и кисть
			SelectPen(hdc,hLastPen);
			SelectBrush(hdc,hLastBrush);
			//вернуть шрифт
			SelectFont(hdc,hLastFont);
		}
		return TRUE;
	case WM_MEASUREITEM:		//создание элементов
		{
			//получить структуру
			MEASUREITEMSTRUCT* pMeasureItem=(MEASUREITEMSTRUCT*)lParam;
			//указать высоту элемента
			pMeasureItem->itemHeight=((CUserControlListElement*)pMeasureItem->itemData)->GetHeight();
		}
		return TRUE;
	}
	//сообщение не обработано
	return FALSE;
}
Ejemplo n.º 5
0
//Draw clock face.
static void DrawClockFace(HANDLE hWnd)
{
	HANDLE hDC = NULL;
	__RECT rect;       //Window client area's rect.
	HANDLE hPen = NULL;
	HANDLE hBrush = NULL;
	HANDLE hOldBrush = NULL;
	HANDLE hOldPen = NULL;
	int cx,cy,r;

	hDC = GetClientDC(hWnd);
	if(!GetWindowRect(hWnd,&rect,GWR_INDICATOR_CLIENT))
	{
		goto __TERMINAL;
	}
	//Calculate the circle's center coordinate and radius.
	cx = (rect.right - rect.left) / 2;
	cy = (rect.bottom - rect.top) / 2;
	r  = cx > cy ? cy : cx;
	r -= 10;  //Keep 10 pixel space between circle and window frame.

	//Create the pen and brush object used to draw circle.
	hPen = CreatePen(0,1,CLK_SCALE_COLOR);
	if(NULL == hPen)
	{
		goto __TERMINAL;
	}
	hBrush = CreateBrush(FALSE,CLK_FACE_COLOR);
	if(NULL == hBrush)
	{
		goto __TERMINAL;
	}
	hOldPen = SelectPen(hDC,hPen);
	hOldBrush = SelectBrush(hDC,hBrush);
	//Draw the clock face circle now.
	DrawCircle(hDC,cx,cy,r,FALSE);
	DrawCircle(hDC,cx,cy,r - 1,FALSE);
	DrawCircle(hDC,cx,cy,r - 2,FALSE);
	DrawCircle(hDC,cx,cy,r - 3,TRUE);
	DrawClockScale(hDC,cx,cy,r);  //Draw clock's scale.
	//Restore original pen and brush for this window's DC.
	SelectPen(hDC,hOldPen);
	SelectBrush(hDC,hOldBrush);

__TERMINAL:
	if(hPen)
	{
		DestroyPen(hPen);
	}
	if(hBrush)
	{
		DestroyBrush(hBrush);
	}
	return;
}
Ejemplo n.º 6
0
// Draws the bitmap in a disabled appearance. This routine assumes the
// bitmap has already been selected into the memory DC
static void NEAR
DisabledBitBlt(HDC hDestDC, RECT &r, HDC hMemDC)
{
	HDC			hMonoDC;
	HBITMAP		hMonoBitmap, hOldBitmap;
	HBRUSH		hOldBrush;
	int			nWidth = r.right - r.left;
	int			nHeight = r.bottom - r.top;
#ifndef _WIN32
	HBRUSH		hShadowBrush = CreateSolidBrush(GetSysColor(COLOR_BTNSHADOW));
#endif

	// Create a monochrome bitmap and HDC
	hMonoBitmap = CreateBitmap(nWidth, nHeight, 1, 1, NULL);
	hMonoDC = CreateCompatibleDC(NULL);
	hOldBitmap = SelectBitmap(hMonoDC, hMonoBitmap);

	// Create a mask where the button face color is 1 and everything else is 0
	SetBkColor(hMemDC, GetSysColor(COLOR_BTNFACE));
	BitBlt(hMonoDC, 0, 0, nWidth, nHeight, hMemDC, 0, 0, SRCCOPY);

	SetTextColor(hDestDC, 0L);                  // 0's in mono -> 0 (for ROP)
	SetBkColor(hDestDC, (COLORREF)0x00FFFFFFL); // 1's in mono -> 1
	
	// Every place the mask has a 0 pixel draw with button highlight color
#ifdef _WIN32
	hOldBrush = SelectBrush(hDestDC, GetSysColorBrush(COLOR_BTNHILIGHT));
#else
	hOldBrush = SelectBrush(hDestDC, GetStockObject(WHITE_BRUSH));
#endif
	BitBlt(hDestDC, r.left + 1, r.top + 1, nWidth - 1, nHeight - 1, hMonoDC,
		0, 0, ROP_PSDPxax);

	// Every place the mask has a 0 pixel draw with button shadow color
#ifdef _WIN32
	SelectBrush(hDestDC, GetSysColorBrush(COLOR_BTNSHADOW));
#else
	SelectBrush(hDestDC, hShadowBrush);
#endif
	BitBlt(hDestDC, r.left, r.top, nWidth, nHeight, hMonoDC,
		0, 0, ROP_PSDPxax);

	// Restore the destination HDC
	SelectBrush(hDestDC, hOldBrush);
#ifndef _WIN32
	DeleteObject(hShadowBrush);
#endif

	// Destroy the GDI objects
	SelectBitmap(hMonoDC, hOldBitmap);
	DeleteBitmap(hMonoBitmap);
	DeleteDC(hMonoDC);
}
Ejemplo n.º 7
0
long	UPSF::hBrush_To_UBit(
	HGLOBAL&	hUniv,
	long&			univSize,
	HBRUSH		hBrush,
	long			natvLen)

	{
	if(natvLen != (long)sizeof(HBRUSH))
		return AUPSF_SIZEERROR;

	HDC	hDC = CreateIC("DISPLAY", NULL, NULL, NULL);
	HDC hDCMem = CreateCompatibleDC(hDC);
	HBITMAP hBitmap = CreateBitmap(BRUSH_WIDTH, BRUSH_HEIGHT, 1, 1, NULL);
	SelectObject(hDCMem, hBitmap);
	HBRUSH	hBrushOld = SelectBrush(hDCMem, hBrush);

  // draw the brush in the region
	RECT	rect = {0, 0, BRUSH_WIDTH, BRUSH_HEIGHT};
  FillRect(hDCMem, &rect, hBrush);

	SelectBrush(hDCMem, hBrushOld);
	DeleteDC(hDCMem);
	DeleteDC(hDC);

	// we are left with the bitmap with the brush pattern
	BITMAP	bitmap;
	GetObject(hBitmap, sizeof(BITMAP), (LPSTR)&bitmap);

  long		bitmapSize = (long)bitmap.bmHeight * (long)bitmap.bmWidthBytes * (long)bitmap.bmPlanes;
	HGLOBAL	hBits = GlobalAlloc(MEMFLAGS, bitmapSize);
	if(!hBits)
		{
  	DeleteObject(hBitmap);
		return AUPSF_MEMORYERROR;
    }

	bitmap.bmBits = GlobalLock(hBits);
	if(!bitmap.bmBits)
		{
  	DeleteObject(hBitmap);
		return AUPSF_MEMORYERROR;
    }

	long ret = BITMAP_To_UBit(hUniv, univSize, bitmap, hBitmap);

	// clean up and exit
  DeleteObject(hBitmap);
	GlobalUnlock(hBits);
	GlobalFree(hBits);  
	return ret;
	}
Ejemplo n.º 8
0
void CColorPalette::DrawSelRect(HDC hdc,int Sel,bool fSel)
{
	HPEN hpen,hpenOld;
	HBRUSH hbrOld;
	RECT rc;

	hpen=CreatePen(PS_SOLID,1,GetSysColor(fSel?COLOR_HIGHLIGHT:COLOR_3DFACE));
	hpenOld=SelectPen(hdc,hpen);
	hbrOld=SelectBrush(hdc,GetStockObject(NULL_BRUSH));
	GetItemRect(Sel,&rc);
	Rectangle(hdc,rc.left,rc.top,rc.right,rc.bottom);
	SelectPen(hdc,hpenOld);
	SelectBrush(hdc,hbrOld);
	DeleteObject(hpen);
}
Ejemplo n.º 9
0
//A local helper routine,to draw weeks title.
static VOID DrawWeekTitle(HANDLE hWnd)
{
    static TCHAR* Weeks[7] = {
        "SUN",
        "MON",
        "TUES",
        "WED",
        "THUR",
        "FRI",
        "SAT"
    };
    HANDLE hDC = GetClientDC(hWnd);
    __RECT rect;
    HANDLE hBrush,hOldBrush;
    HANDLE hPen,hOldPen;
    int txtx,txty;  //Text start position.

    hBrush = CreateBrush(FALSE,COLOR_CYAN);
    if(NULL == hBrush)
    {
        return;
    }
    hPen = CreatePen(0,1,COLOR_WHITE);
    if(NULL == hPen)
    {
        DestroyBrush(hBrush);
        return;
    }
    hOldBrush = SelectBrush(hDC,hBrush);
    hOldPen   = SelectPen(hDC,hPen);

    for(int i = 0; i < 7; i ++)
    {
        rect.left = i * DAY_RECT_WIDTH;
        rect.right = rect.left + DAY_RECT_WIDTH;
        rect.top = DAY_RECT_HEIGHT;  //Reserve the space for year/month/time window.
        rect.bottom = rect.top + DAY_RECT_HEIGHT;
        DrawRectangle(hDC,rect);
        txtx = rect.left + 8;
        txty = rect.top + 9;
        TextOut(hDC,txtx,txty,Weeks[i]);
    }
    SelectBrush(hDC,hOldBrush);
    SelectPen(hDC,hOldPen);
    DestroyPen(hPen);
    DestroyBrush(hBrush);
    return;
}
Ejemplo n.º 10
0
static void genopt_window_callback_drawMsgRadioButton(int identifier, LPDRAWITEMSTRUCT lpDrawItem)
{
	int index, button;
	
	if ((identifier & 0xF0) == 0x00)
	{
		index = (identifier & 0x0F) / 4;
		button = (identifier & 0x0F) % 4;
	}
	else if ((identifier & 0xF0) == 0x10)
	{
		index = 2;
		button = (identifier & 0x0F);
	}
	else
	{
		// Unknown button set.
		return;
	}
	
	HDC hDC = lpDrawItem->hDC;
	RECT itemRect = lpDrawItem->rcItem;
	
	if (index < 2)
		FillRect(hDC, &itemRect, brushOSD[button][0]);
	else //if (index == 2)
		FillRect(hDC, &itemRect, brushIntroEffect[button][0]);
	
	// Check if the radio button is checked.
	if (state_optColor[index] == button)
	{
		// Checked. Draw a circle in the middle of the box.
		
		if (index < 2)
		{
			SelectBrush(hDC, brushOSD[button][1]);
			SelectPen(hDC, penOSD[button][1]);
		}
		else //if (index == 2)
		{
			SelectBrush(hDC, brushIntroEffect[button][1]);
			SelectPen(hDC, penIntroEffect[button][1]);
		}
		
		Ellipse(hDC, itemRect.left + 4, itemRect.top + 4,
			     itemRect.right - 4, itemRect.bottom - 4);
	}
}
Ejemplo n.º 11
0
static void Create_MapHDD(HDC DC)                            //Карта занятости HDD
{
   if(Map == NULL) return;                                   //Нет карты HDD
   int y = 1;
   int x = 1;
   for(int i=0,j=1; i<numBl; i++,j++)
   {  COLORREF Col = Col_P;                                  //Цвет частично занятого/свободдного блока
      if(*(Map + i) == NumCl_Bl) Col = ColFu;                //Цвет полностью занятого блока
      if(*(Map + i) == 0)        Col = ColFr;                //Цвет полностью свободного блока
      if(*(Map + i) == -1)       Col = ColEr;                //Цвет блока с ошибкой
#if defined TEST_FAT1                                        //Проверка FAT1
      if(*(Map + i) != 0)        Col = ColEr;                //Не нулевой блок это ошибка
#endif
      HPEN Pen = CreatePen(PS_SOLID, 1, Col);
      HPEN OldPen = SelectPen(DC, Pen);
      HBRUSH FBrush = CreateSolidBrush(Col);
      HBRUSH OldBrush = SelectBrush(DC, FBrush);
      Rectangle(DC, x, y, x+xM, y+yM);
      SelectObject(DC, OldBrush);                            //Восстановили старую кисть
      DeleteObject(FBrush);                                  //Удалили новую кисть
      SelectPen(DC, OldPen);                                 //Восстановили старое перо
      DeleteObject(Pen);                                     //Удалили новое перо
      x += xM + 1;
      if(j == nG)
      {  j = 0;
         x = 1;
         y += yM + 1;
      }
   }
}
Ejemplo n.º 12
0
void GUI::RefreshPalettes(Map* m, bool usedefault)
{
	for(PaletteList::iterator piter = palettes.begin(); piter != palettes.end(); ++piter) {
		(*piter)->OnUpdate(m? m : (usedefault? (IsEditorOpen()? &GetCurrentMap() : nullptr): nullptr));
	}
	SelectBrush();
}
Ejemplo n.º 13
0
/// Function name  : utilSetDeviceContextBrush
// Description     : Selects a brush into a device context
// 
// DC_STATE*  pPrevState : [in] DeviceContextState
// HBRUSH     hBrush     : [in] New brush to select
//
UtilityAPI 
VOID  utilSetDeviceContextBrush(DC_STATE*  pPrevState, HBRUSH  hBrush)
{
   /// [BRUSH] Change mode and update state
   pPrevState->hOldBrush = SelectBrush(pPrevState->hDC, hBrush);
   pPrevState->eState   |= DCC_BRUSH;
}
Ejemplo n.º 14
0
void CircuitSquare::clear(HDC hdc, RECT rt){
	HPEN hPen = CreatePen(PS_SOLID, border, RGB(0, 0, 0));
	HPEN hOldPen = SelectPen(hdc, hPen);
	HBRUSH hBrush = CreateSolidBrush(RGB(250, 250, 250));
	HBRUSH hOldBrush = SelectBrush(hdc, hBrush);
	Rectangle(hdc, rt.left, rt.top, rt.right, rt.bottom);
}
Ejemplo n.º 15
0
void TimelineDC::DrawSolidFlag(const std::wstring& tooltip, int x, int y, COLORREF border, COLORREF fill)
{
	CPen pen(CreatePen(PS_SOLID, 1, border));
	SelectPen(pen);
	CBrush b(CreateSolidBrush(fill));
	SelectBrush(b);
	DrawSolidFlag(tooltip, x, y);
}
Ejemplo n.º 16
0
void GUI::RefreshOtherPalettes(PaletteWindow* p)
{
	for(PaletteList::iterator piter = palettes.begin(); piter != palettes.end(); ++piter) {
		if(*piter != p)
			(*piter)->OnUpdate(IsEditorOpen()? &GetCurrentMap() : nullptr);
	}
	SelectBrush();
}
Ejemplo n.º 17
0
void CDrawContext::PolyFillOutlined( const POINT *pt, int nCount, COLORREF cr, COLORREF crOutline )
{
	ASSERT( nCount > 0 );
	ASSERT_VALID_READPTR( pt, sizeof( POINT) * nCount );

	SelectBrush( cr );
	SelectPen( crOutline );
	VAPI( ::Polygon( m_hdc, pt, nCount ) );

}
Ejemplo n.º 18
0
void CircuitSquare::Draw(HDC hdc, RECT rt){
	if (checkWin(rt) == 1) throw 0;
	if (checkSqr() == 1) throw 1;
	if (checkBord() == 1) throw 3;
	HPEN hPen = CreatePen(PS_SOLID, border, RGB(BorderColor.R, BorderColor.G, BorderColor.B));
	HPEN hOldPen = SelectPen(hdc, hPen);
	HBRUSH hBrush = CreateSolidBrush(RGB(255, 255, 255));
	HBRUSH hOldBrush = SelectBrush(hdc, hBrush);
	Rectangle(hdc, LeftTop.x, LeftTop.y, RightBottom.x, RightBottom.y);
}
Ejemplo n.º 19
0
void WINAPI
DrawColorButtonControl(LPDRAWITEMSTRUCT lpdis, HBRUSH hBrush)
{
	UINT	uState;

#ifdef _WIN32
	uState = DFCS_BUTTONPUSH | DFCS_ADJUSTRECT;

	if (lpdis->itemState & ODS_SELECTED)
		uState |= DFCS_PUSHED;
	DrawFrameControl(lpdis->hDC, &lpdis->rcItem, DFC_BUTTON, uState);
#else
	uState = DPBCS_ADJUSTRECT;
	
	if (lpdis->itemState & ODS_SELECTED)
		uState |= DPBCS_PUSHED;
	DrawPushButtonControl(lpdis->hDC, &lpdis->rcItem, uState);
#endif

	// If the button's selected, then shift everything down and over to the right
	if (lpdis->itemState & ODS_SELECTED)
		OffsetRect(&lpdis->rcItem, 1, 1);

	// The focus rect is inset one pixel on each edge
	//
	// Note: the reason we don't add one to the left and top is that DrawFrameControl()
	// always adjusts the rect by SM_CXEDGE/SM_CYEDGE on all sides even if it only draws
	// a one pixel on the left and top
	lpdis->rcItem.right--;
	lpdis->rcItem.bottom--;
	if ((lpdis->itemAction & ODA_FOCUS) || (lpdis->itemState & ODS_FOCUS))
		DrawFocusRect(lpdis->hDC, &lpdis->rcItem);

	// Draw the specified color framed with a black border just inside the focus rect
	if (!(lpdis->itemState & ODS_DISABLED)) {
		HBRUSH	hOldBrush = SelectBrush(lpdis->hDC, hBrush);
	
		InflateRect(&lpdis->rcItem, -1, -1);
		Rectangle(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top, lpdis->rcItem.right, lpdis->rcItem.bottom);
		SelectBrush(lpdis->hDC, hOldBrush);
	}
}
Ejemplo n.º 20
0
void CDC::Brush(int iObjectID)
{
	HBRUSH hOldBrush = SelectBrush(m_hDC, GetStockBrush(iObjectID));
	
	// Delete the old one?
	if (m_bDelOldBrush)
		DeleteBrush(hOldBrush);
		
	// This object doesn't need deleting.
	m_bDelOldBrush = FALSE;
}
Ejemplo n.º 21
0
/// Function name  : utilRestoreDeviceContext
// Description     : Reverts a DeviceContext to the state it was in when the object was created
// 
// DC_STATE*  pPrevState   : [in] DeviceContext state
// 
UtilityAPI 
VOID  utilRestoreDeviceContext(DC_STATE*  pPrevState)
{
   // [BACKGROUND MODE]
   if (pPrevState->eState INCLUDES DCC_BACKGROUND_MODE)
   {
      SetBkMode(pPrevState->hDC, pPrevState->iOldBackgroundMode);
      pPrevState->eState ^= DCC_BACKGROUND_MODE;
   }

   // [BACKGROUND COLOUR]
   if (pPrevState->eState INCLUDES DCC_BACKGROUND_COLOUR)
   {
      SetBkColor(pPrevState->hDC, pPrevState->clOldBackgroundColour);
      pPrevState->eState ^= DCC_BACKGROUND_COLOUR;
   }

   // [BITMAP]
   if (pPrevState->eState INCLUDES DCC_BITMAP)
   {
      SelectBitmap(pPrevState->hDC, pPrevState->hOldBitmap);
      pPrevState->eState ^= DCC_BITMAP;
   }

   // [BRUSH]
   if (pPrevState->eState INCLUDES DCC_BRUSH)
   {
      SelectBrush(pPrevState->hDC, pPrevState->hOldBrush);
      pPrevState->eState ^= DCC_BRUSH;
   }

   // [FONT]
   if (pPrevState->eState INCLUDES DCC_FONT)
   {
      SelectFont(pPrevState->hDC, pPrevState->hOldFont);
      pPrevState->eState ^= DCC_FONT;
   }

   // [PEN]
   if (pPrevState->eState INCLUDES DCC_PEN)
   {
      SelectPen(pPrevState->hDC, pPrevState->hOldPen);
      pPrevState->eState ^= DCC_PEN;
   }

   // [TEXT COLOUR]
   if (pPrevState->eState INCLUDES DCC_TEXT_COLOUR)
   {
      SetTextColor(pPrevState->hDC, pPrevState->clOldTextColour);
      pPrevState->eState ^= DCC_TEXT_COLOUR;
   }
}
Ejemplo n.º 22
0
	VOID ClearDrawDevice()
	{
		HBRUSH brush = GetStockBrush(NULL_BRUSH);
		SelectBrush(brush);
		m_switcher.push_back(CGDIHandleSwitcher
			(m_hDC,brush,TRUE,FALSE));

		HPEN pen = GetStockPen(NULL_PEN);
		SelectPen(pen);
		m_switcher.push_back(CGDIHandleSwitcher
			(m_hDC,pen,TRUE,FALSE));
		SetBkMode(TRANSPARENT);
	}
Ejemplo n.º 23
0
void CombinedSquare::Draw(HDC hdc, RECT rt){
	if (checkWin(rt) == 1) throw 0;
	if (checkSqr() == 1) throw 1;
	if (checkBord() == 1) throw 3;
//	if (checkIns(rt) == 1) throw 4;
	HPEN hPen = CreatePen(PS_SOLID, border, RGB(BorderColor.R, BorderColor.G, BorderColor.B));
	HPEN hOldPen = SelectPen(hdc, hPen);
	HBRUSH hBrush = CreateSolidBrush(RGB(MainColor.R, MainColor.G, MainColor.B));
	HBRUSH hOldBrush = SelectBrush(hdc, hBrush);
	Rectangle(hdc, LeftTop.x, LeftTop.y, RightBottom.x, RightBottom.y);
	fc.Load();
	fc.Draw(hdc, rt);

}
Ejemplo n.º 24
0
void CDC::Cleanup(void)
{
	// Currently selected pen needs deleting?
	if (m_bDelOldPen)
	{
		HPEN hOldPen = SelectPen(m_hDC, GetStockPen(BLACK_PEN));
		DeletePen(hOldPen);
	}
	
	// Currently selected brush needs deleting?
	if (m_bDelOldBrush)
	{
		HBRUSH hOldBrush = SelectBrush(m_hDC, GetStockBrush(WHITE_BRUSH));
		DeleteBrush(hOldBrush);
	}
}
Ejemplo n.º 25
0
void CDC::Brush(COLORREF crColour)
{
	// Create the new brush and select it
	HBRUSH hNewBrush = CreateSolidBrush(crColour);
	
	ASSERT(hNewBrush);
	
	HBRUSH hOldBrush = SelectBrush(m_hDC, hNewBrush);
	
	// Delete the old one?
	if (m_bDelOldBrush)
		DeleteBrush(hOldBrush);
		
	// The new one needs deleting.
	m_bDelOldBrush = TRUE;
}
Ejemplo n.º 26
0
BOOL CALLBACK FindBrushDlgProc (
    HWND hwndDlg,	// handle to dialog box
    UINT uMsg,	// message
    WPARAM wParam,	// first message parameter
    LPARAM lParam 	// second message parameter
   )
{
	char entstr[256];
	char brushstr[256];
	HWND	h;
	int		ent, brush;

	switch (uMsg)
    {
	case WM_INITDIALOG:
		// set entity and brush number
		GetSelectionIndex (&ent, &brush);
		sprintf (entstr, "%i", ent);
		sprintf (brushstr, "%i", brush);
		SetWindowText(GetDlgItem(hwndDlg, IDC_FIND_ENTITY), entstr);
		SetWindowText(GetDlgItem(hwndDlg, IDC_FIND_BRUSH), brushstr);

		h = GetDlgItem(hwndDlg, IDC_FIND_ENTITY);
		SetFocus (h);
		return FALSE;

	case WM_COMMAND: 
		switch (LOWORD(wParam)) 
		{ 
			case IDOK:
				GetWindowText(GetDlgItem(hwndDlg, IDC_FIND_ENTITY), entstr, 255);
				GetWindowText(GetDlgItem(hwndDlg, IDC_FIND_BRUSH), brushstr, 255);
				SelectBrush (atoi(entstr), atoi(brushstr));
				EndDialog(hwndDlg, 1);
				return TRUE;

			case IDCANCEL:
				EndDialog(hwndDlg, 0);
				return TRUE;
		}	
	}
	return FALSE;
}
Ejemplo n.º 27
0
//==============================================================================================
// FUNCTION: Copy Constructor.
// PURPOSE:  Object initialization.
//
CDisplaySurface::CDisplaySurface(const CDisplaySurface &C)
{
   MEMBERASSERT();
   m_pDibBits       = NULL;
   m_pBitmapInfo    = NULL;
   m_hdcWin         = C.GetWinDC();
   m_hdcBM          = CreateCompatibleDC( NULL );
   m_hBitmap        = NULL;
   m_hbmSave        = NULL;
   m_rgbBackground  = C.m_rgbBackground;
   m_nPaletteSize   = 0;
   m_nBitsPerPixel  = 0;
   m_nLockCount     = 0;

   SelectBrush(m_hdcBM, GetStockObject(HOLLOW_BRUSH));
   SetBkMode(m_hdcBM, TRANSPARENT);

   Resize(&C.m_rDisplay);
}
Ejemplo n.º 28
0
//Draws the cursor on the DC
void PrecisionCursor::drawCursor(RECT cursorRct, DWORD cursorShape, bool cross)
{
	//Save the DC state
	int DCState=SaveDC(m_wndDC);
	//Set the NOT ROP2
	SetROP2(m_wndDC,R2_NOT);
	//Remove any clipping region
	SelectClipRgn(m_wndDC,NULL);
	//Select a null brush
	SelectBrush(m_wndDC,GetStockBrush(NULL_BRUSH));
	//Draw the cursor
	switch(cursorShape)
	{
	case PS_ENDCAP_ROUND:
		Ellipse(m_wndDC,EXPANDRECT_C(cursorRct));
		break;
	case PS_ENDCAP_SQUARE:
		Rectangle(m_wndDC,EXPANDRECT_C(cursorRct));
		break;
	default:
		break;
	}
	//Eventually draw the cross
	if(cross)
	{
		//Find the medium point between the center and the pixel next to it
		POINT pos=m_position,pos2=m_position;
		pos2.x++;
		pos2.y++;
		DIB2IVWndPoint(&pos);
		DIB2IVWndPoint(&pos2);
		pos.x=(pos.x+pos2.x)/2;
		pos.y=(pos.y+pos2.y)/2;
		//Draw the cross
		MoveToEx(m_wndDC,pos.x-PREC_CURSOR_CROSS_SIZE,pos.y-PREC_CURSOR_CROSS_SIZE,NULL);
		LineTo(m_wndDC,pos.x+PREC_CURSOR_CROSS_SIZE,pos.y+PREC_CURSOR_CROSS_SIZE);
		MoveToEx(m_wndDC,pos.x+PREC_CURSOR_CROSS_SIZE,pos.y-PREC_CURSOR_CROSS_SIZE,NULL);
		LineTo(m_wndDC,pos.x-PREC_CURSOR_CROSS_SIZE,pos.y+PREC_CURSOR_CROSS_SIZE);
	}
	//Restore the DC state
	RestoreDC(m_wndDC,DCState);
}
Ejemplo n.º 29
0
void DoFind(const cmd::ArgumentList& args)
{
	ui::IDialogPtr dialog = GlobalDialogManager().createDialog(_("Find Brush"));

	ui::IDialog::Handle entityEntry = dialog->addEntryBox(_("Entity Number:"));
	ui::IDialog::Handle brushEntry = dialog->addEntryBox(_("Brush Number:"));

	std::size_t ent(0), br(0);
	GetSelectionIndex(ent, br);

	dialog->setElementValue(entityEntry, sizetToStr(ent));
	dialog->setElementValue(brushEntry, sizetToStr(br));
	
	if (dialog->run() == ui::IDialog::RESULT_OK)
	{
		std::string entityValue = dialog->getElementValue(entityEntry);
		std::string brushValue = dialog->getElementValue(brushEntry);
		
		SelectBrush(strToInt(entityValue), strToInt(brushValue));
	}
}
Ejemplo n.º 30
0
void PrintLegend (HDC hDC, PGRAPHSTRUCT pGraph, HWND hWndLegend,
                  RECT rectLegend)
   {
   PLEGEND        pLegend ;
   int            yItemHeight ;
   HFONT          hFontItems ;
   PLINE          pLine ;
   int            iIndex ;
   int            iIndexNum ;


   pLegend = LegendData (hWndLegend) ;

   yItemHeight = pLegend->yItemHeight ;
   hFontItems = pLegend->hFontItems ;

   pLegend->hFontItems = hFontPrinterScales ;
   SelectFont (hDC, pLegend->hFontItems) ;

   pLegend->yItemHeight = FontHeight (hDC, TRUE) ;

   iIndexNum = LBNumItems (pLegend->hWndItems) ;
   for (iIndex = 0 ;
        iIndex < iIndexNum ;
        iIndex++)
      {  // for
      pLine = (PLINE) LBData (pLegend->hWndItems, iIndex) ;
      DrawLegendItem (pLegend, pLine, iIndex * pLegend->yItemHeight, hDC) ;
      }  // for

   pLegend->hFontItems = hFontItems ;
   pLegend->yItemHeight = yItemHeight ;


   SelectBrush (hDC, GetStockObject (HOLLOW_BRUSH)) ;
   SelectPen (hDC, GetStockObject (BLACK_PEN)) ;
   Rectangle (hDC, 0, 0, 
              rectLegend.right - rectLegend.left,
              rectLegend.bottom - rectLegend.top) ;
   }