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;
      }
   }
}
LRESULT
FrameWindowSplitter::OnPaint()
{
	HDC			hdc;
	RECT		rect;
	PAINTSTRUCT ps;
    HPEN        hpen;

	// Begin Paint
	VERIFY(hdc = BeginPaint(m_hwnd, &ps));

	// Get the client rect of of the window.
	VERIFY(GetClientRect(m_hwnd, &rect));

    if(wyTheme::GetPen(PEN_VSPLITTER, &hpen))
    {
        hpen = SelectPen(hdc, hpen);
        MoveToEx(hdc, rect.right, rect.top, NULL);
        LineTo(hdc, rect.right, rect.bottom);
        hpen = SelectPen(hdc, hpen);
    }
    else
    {
	// now draw a beveled window depending upon whether it is horz splitter
	// or vertical splitter.
    DrawEdge(hdc, &rect, BDR_RAISEDOUTER | BDR_RAISEDOUTER, BF_RIGHT);
    }
		
	// End Painting
	EndPaint(m_hwnd, &ps);

	return 0;
}
Esempio n. 3
0
//обрабатывает нажатие левой клавиши мышки
void LineLButtonDown(HWND hwnd, int x, int y)
{
	Dat.ButtonDown = TRUE;
	Dat.Drawing = FALSE;
	
	anglOld.fi = angl.fi;
	anglOld.teta = angl.teta;
	corOld.x = x;
	corOld.y = y;
	
//при нажатии клавиши мыши выделяется куб синим цветом
	HDC PaintDC = GetDC(hwnd);
	HPEN hPen, hPenOld;
	hPen = CreatePen(PS_SOLID,1,RGB(0,0,255));
	hPenOld = SelectPen(PaintDC,hPen);   

	SetROP2(PaintDC, R2_NOTXORPEN);
		
	DrawBox(hwnd, PaintDC, anglOld);

	SelectPen(PaintDC,hPenOld);  
	DeletePen(hPen);           

	ReleaseDC(hwnd, PaintDC);
}
Esempio n. 4
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);
}
Esempio n. 5
0
//A local helper routine to draw bitmap button's frame,in normal state.
//It actually draws 2 white lines on button's left and top edges,then draws
//2 whites lines on button's right and bottom edges,to render the button
//looks like a 3D effect.
static VOID DrawButtonFrame(HANDLE hDC,__BITMAP_BUTTON* pButton)
{
	HANDLE hOldPen    = NULL;
	HANDLE hBlackPen  = NULL;
	HANDLE hWhitePen  = NULL;

	//Creat 2 pens,one is black and another is white.
	hBlackPen = CreatePen(0,1,RGB(0,0,0));
	if(NULL == hBlackPen)
	{
		goto __TERMINAL;
	}
	hWhitePen = CreatePen(0,1,RGB(255,255,255));
	if(NULL == hWhitePen)
	{
		goto __TERMINAL;
	}
	if(pButton->dwBmpBtnStatus == BUTTON_STATUS_NORMAL)
	{
		hOldPen = SelectPen(hDC,hWhitePen);
		//Draw button's top and left edge.
		DrawLine(hDC,0,0,pButton->cx,0);
		//DrawLine(hDC,0,1,pButton->cx,1);
		DrawLine(hDC,0,0,0,pButton->cy);
		//DrawLine(hDC,1,0,1,pButton->cy);
		//Draw button's bottom and right edit.
		SelectPen(hDC,hBlackPen);
		DrawLine(hDC,pButton->cx,0,pButton->cx,pButton->cy);
		//DrawLine(hDC,pButton->cx - 1,2,pButton->cx - 1,pButton->cy);
		DrawLine(hDC,0,pButton->cy,pButton->cx,pButton->cy);
		//DrawLine(hDC,2,pButton->cy,pButton->cx,pButton->cy);
	}
	else
	{
		hOldPen = SelectPen(hDC,hBlackPen);
		//Draw button's top and left edge.
		DrawLine(hDC,0,0,pButton->cx,0);
		//DrawLine(hDC,0,1,pButton->cx,1);
		DrawLine(hDC,0,0,0,pButton->cy);
		//DrawLine(hDC,1,0,1,pButton->cy);
		//Draw button's bottom and right edit.
		SelectPen(hDC,hWhitePen);
		DrawLine(hDC,pButton->cx,0,pButton->cx,pButton->cy);
		//DrawLine(hDC,pButton->cx - 1,2,pButton->cx - 1,pButton->cy);
		DrawLine(hDC,0,pButton->cy,pButton->cx,pButton->cy);
		//DrawLine(hDC,2,pButton->cy,pButton->cx,pButton->cy);
	}
	SelectPen(hDC,hOldPen);

__TERMINAL:
	if(NULL != hBlackPen)
	{
		DestroyPen(hBlackPen);
	}
	if(NULL != hWhitePen)
	{
		DestroyPen(hWhitePen);
	}
}
Esempio n. 6
0
/*
 * OnDrawItem() - WM_DRAWITEM handler to draw list box items.
 */
void TxLbx_OnDrawItem(HWND wnd, const DRAWITEMSTRUCT *drawItem)
{
    HDC dC = drawItem->hDC;
    RECT itemRect = drawItem->rcItem;
    HWND listBox = drawItem->hwndItem;
    TXLBX_PROPERTIES *txProps = (TXLBX_PROPERTIES *) GetWindowLong(listBox
            , GWL_USERDATA);
    int itemIndex = drawItem->itemID;
    COLORREF textColor;
    HBRUSH bgBrush;
    TXLBX_ATTR itemAttr = drawItem->itemData >> 24;
    int i;

    if (drawItem->itemAction == ODA_FOCUS) {
        /*
         * Draw focus rectangle.
         */
        DrawFocusRect(dC, &itemRect);
    } else {
        /*
         * Set up colors based on selection and copy state.
         */
        if (drawItem->itemState & ODS_SELECTED) {
            textColor = *TxLbx_colors[itemAttr & 0x0F];
            if (textColor == Prog_wndTextColor) {
                textColor = Prog_selTextColor;
            }
            bgBrush = Prog_selBrush;
        } else {
            textColor = *TxLbx_colors[itemAttr & 0x0F];
            bgBrush = *TxLbx_brushes[itemAttr >> 4];
        }
        /*
         * Draw the item's background.
         */
        FillRect(dC, &itemRect, bgBrush);
        if (itemIndex > -1) {
            _TUCHAR text[80];
            int textLen = ListBox_GetText(listBox, itemIndex, text);

            /*
             * Draw the string.
             */
            MiniFont_DrawString(dC, itemRect.left + 2, itemRect.top + 3, text
                    , textLen, textColor);
            /*
             * Draw column separators.
             */
            for (i = 0; i < txProps->divCnt; i++) {
                int x = txProps->divPos[i];
                HPEN oldPen = SelectPen(dC, Prog_wndTextPen);

                MoveToEx(dC, x, itemRect.top, NULL);
                LineTo(dC, x, itemRect.bottom);
                SelectPen(dC, oldPen);
            }
        }
    }
}
Esempio n. 7
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;
}
Esempio n. 8
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;
}
Esempio n. 9
0
/*
 * OnDrawItem()
 */
void rw_OnDrawItem(HWND remoteWnd, const DRAWITEMSTRUCT *drawItem)
{
    HDC dC = drawItem->hDC;
    RECT rect = drawItem->rcItem;
    HDC memDC = CreateCompatibleDC(dC);
    UINT ctrlID = drawItem->CtlID;
    HWND wnd = drawItem->hwndItem;
    UINT state = drawItem->itemState;
    int leftOffset = 3;
    int topOffset = 2;
    int i;

    rect.right--;
    rect.bottom--;
    FillRect(dC, &rect, Prog_wndTextBrush);
    if (ctrlID == IDC_REMOTE_STORE_BTN) {
        if (GetWindowLong(wnd, GWL_USERDATA) == BST_CHECKED) {
            state |= ODS_SELECTED;
        }
    }
    if (state & ODS_SELECTED) {
        SelectPen(dC, Prog_3dLightPen);
        MoveToEx(dC, rect.right, rect.top, NULL);
        LineTo(dC, rect.right, rect.bottom);
        LineTo(dC, rect.left, rect.bottom);
        SelectPen(dC, Prog_3dShadowPen);
        LineTo(dC, rect.left, rect.top);
        LineTo(dC, rect.right, rect.top);
        leftOffset++;
        topOffset++;
    } else {
        SelectPen(dC, Prog_3dShadowPen);
        MoveToEx(dC, rect.right, rect.top, NULL);
        LineTo(dC, rect.right, rect.bottom);
        LineTo(dC, rect.left, rect.bottom);
        SelectPen(dC, Prog_3dLightPen);
        LineTo(dC, rect.left, rect.top);
        LineTo(dC, rect.right, rect.top);
    }
    for (i = 0; i < btnInitCnt; i++) {
        if (ctrlID == btnInits[i].btnID) {
            SelectBitmap(memDC, *btnInits[i].bmp);
            break;
        }
    }
    BitBlt(dC, rect.left + leftOffset, rect.top + topOffset, 40, 40
            , memDC, 0, 0, SRCCOPY);
    DeleteDC(memDC);
}
Esempio n. 10
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);
}
Esempio n. 11
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);
	}
}
Esempio n. 12
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;
}
Esempio n. 13
0
static void winPrepareLine (GraphicsScreen me) {
    HPEN newPen;
    int lineWidth_pixels = LINE_WIDTH_IN_PIXELS (me) + 0.5;
    if (! lineWidth_pixels) lineWidth_pixels = 1;
    my d_fatNonSolid = my lineType != Graphics_DRAWN && my lineWidth > 1;
    if (Melder_debug == 10) {
        LOGBRUSH brush;
        brush. lbStyle = BS_SOLID;
        brush. lbColor = my d_winForegroundColour;
        brush. lbHatch = my lineType == Graphics_DRAWN ? 0 : my lineType == Graphics_DOTTED ? PS_DOT : my lineType == Graphics_DASHED ? PS_DASH : PS_DASHDOT;
        newPen = ExtCreatePen (PS_GEOMETRIC, lineWidth_pixels, & brush, 0, NULL);
    } else {
        /*newPen = CreatePen (my lineType == Graphics_DRAWN ? PS_SOLID :
        	my lineType == Graphics_DOTTED ? PS_DOT : my lineType == Graphics_DASHED ? PS_DASH : PS_DASHDOT,
        	my fatNonSolid ? 1 : lineWidth_pixels, my foregroundColour);*/
        LOGPEN pen;
        pen. lopnStyle = my lineType == Graphics_DRAWN ? PS_SOLID : my lineType == Graphics_DOTTED ? PS_DOT : my lineType == Graphics_DASHED ? PS_DASH : PS_DASHDOT;
        pen. lopnWidth. x = my d_fatNonSolid ? 1 : lineWidth_pixels;
        pen. lopnWidth. y = 0;
        pen. lopnColor = my d_winForegroundColour | 0x02000000;
        newPen = CreatePenIndirect (& pen);
    }
    SelectPen (my d_gdiGraphicsContext, newPen);
    DeletePen (my d_winPen);
    my d_winPen = newPen;
}
Esempio n. 14
0
/// Function name  : utilSetDeviceContextPen
// Description     : Selects a pen into a device context
// 
// DC_STATE*  pPrevState : [in] DeviceContextState
// HPEN       hPen       : [in] New pen to apply
//
UtilityAPI 
VOID  utilSetDeviceContextPen(DC_STATE*  pPrevState, HPEN  hPen)
{
   /// [PEN] Change mode and update state
   pPrevState->hOldPen  = SelectPen(pPrevState->hDC, hPen);
   pPrevState->eState  |= DCC_PEN;
}
Esempio n. 15
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);
}
Esempio n. 16
0
//A helper routine to erase clock's pointers.
static void EraseClockPointer(HANDLE hDC,int cx,int cy,int r,int hour,int minute,int second)
{
	HANDLE hOldPen  = NULL;
	HANDLE hNewPen  = NULL;

	hNewPen = CreatePen(0,1,CLK_FACE_COLOR);
	if(NULL == hNewPen)
	{
		return;
	}
	hOldPen = SelectPen(hDC,hNewPen);
	_DrawClockPointer(hDC,cx,cy,r,hour,minute,second);
	//Restore the old pen.
	SelectPen(hDC,hOldPen);
	DestroyPen(hNewPen);
}
Esempio n. 17
0
static PetscErrorCode PetscDrawLine_Win32(PetscDraw draw,PetscReal xl,PetscReal yl,PetscReal xr,PetscReal yr,int color)
{
  PetscDraw_Win32 *windraw = (PetscDraw_Win32*)draw->data;
  HPEN            hpen;
  int             x1,yone,x2,y2;
  HDC             hdc;
  
  PetscFunctionBegin;
  TranslateColor_Win32(draw,color);
  x1   = XTRANS(draw,windraw,xl);x2  = XTRANS(draw,windraw,xr); 
  yone   = YTRANS(draw,windraw,yl);y2  = YTRANS(draw,windraw,yr); 
  hpen = CreatePen (PS_SOLID, windraw->linewidth, windraw->currentcolor);
  if(windraw->node->DoubleBuffered) {
    hdc = windraw->node->DoubleBuffer;
  } else {
    hdc = windraw->node->Buffer;
  }
  SelectPen(hdc,hpen);
  MoveToEx(hdc,x1,yone,NULL);
  LineTo(hdc,x2,y2);
  /* Forces a WM_PAINT message and erases background */
  InvalidateRect(windraw->hWnd,NULL,TRUE);
  UpdateWindow(windraw->hWnd);
  PetscFunctionReturn(0);
}
Esempio n. 18
0
void TimelineDC::DrawTimeline(const std::wstring& name, Pixel x, Pixel y, int width, COLORREF color)
{
	CPen pen(CreatePen(PS_SOLID, 1, color));
	SelectPen(pen);
	DrawTextOut(name, x + 15, y -15);
	Rectangle(x + s_leftTextAreaBorder, y, x + s_leftTextAreaBorder + width, y + 2);
}
Esempio n. 19
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);
}
Esempio n. 20
0
/*
 * LbxProc() - List box window procedure.  Draws the dividers on empty slots,
 *             makes sure the mouse cursor is an arrow, and sets focus to the
 *             list box when the user clicks on the scrollbar.
 */
LRESULT CALLBACK tl_LbxProc(HWND listBox, UINT message, WPARAM wParam
        , LPARAM lParam)
{
    switch (message) {
        case WM_PAINT:
        {
            TXLBX_PROPERTIES *txProps
                = (TXLBX_PROPERTIES *) GetWindowLong(listBox, GWL_USERDATA);
            HDC dC;
            RECT clientRect;
            int i;

            /*
             * Draw items.
             */
            CallWindowProc(tl_origLbxProc, listBox, message, wParam
                    , lParam);

            /*
             * Draw column separators.
             */
            dC = GetDC(listBox);
            GetClientRect(listBox, &clientRect);
            for (i = 0; i < txProps->divCnt; i++) {
                int x = txProps->divPos[i];
                HPEN oldPen = SelectPen(dC, Prog_wndTextPen);

                MoveToEx(dC, x, 0, NULL);
                LineTo(dC, x, clientRect.bottom);
                SelectPen(dC, oldPen);
            }
            ReleaseDC(listBox, dC);
            return 0;
        }
        case WM_MOUSEMOVE:
            SetCursor(Prog_arrowCursor);
            break;
        case WM_NCLBUTTONDOWN:
            if (GetFocus() != listBox) {
                SetFocus(listBox);
            }
            break;
    }
    return CallWindowProc(tl_origLbxProc, listBox, message, wParam
            , lParam);
}
Esempio n. 21
0
void DrawHilite(HDC hdc, Rect& rect, Shader* pShader )
{
int w,h,npts,xcen,ybot,ytop,ylast,i,iy;

   HPEN linePen = (HPEN)GetStockObject(WHITE_PEN);
   HPEN fgPen = CreatePen(PS_SOLID,0,GetCustSysColor(COLOR_BTNFACE));
   HPEN bgPen = CreatePen(PS_SOLID,0,GetCustSysColor(COLOR_BTNSHADOW));

   w = rect.w();
   h = rect.h()-3;
   npts = (w-2)/2;
   xcen = rect.left+npts;
   ybot = rect.top+h;
   ytop = rect.top+2;
   ylast = -1;
   for (i=0; i<npts; i++) {
      float v = pShader->EvalHiliteCurve( (float)i/((float)npts*2.0f) );
      if (v>2.0f) v = 2.0f; // keep iy from wrapping
      iy = ybot-(int)(v*((float)h-2.0f));

      if (iy<ytop) iy = ytop;

      SelectPen(hdc, fgPen);
      VertLine(hdc,xcen+i,ybot,iy);
      VertLine(hdc,xcen-i,ybot,iy);

      if (iy-1>ytop) {
         // Fill in above curve
         SelectPen(hdc,bgPen);
         VertLine(hdc,xcen+i, ytop, iy-1);
         VertLine(hdc,xcen-i, ytop, iy-1);
         }
      if (ylast>=0) {
         SelectPen(hdc,linePen);
         VertLine(hdc,xcen+i-1,iy-1,ylast);
         VertLine(hdc,xcen-i+1,iy-1,ylast);
         }

      ylast = iy;
   }

   SelectObject( hdc, linePen );
   DeleteObject(fgPen);
   DeleteObject(bgPen);
   WhiteRect3D(hdc, rect, 1);
}
Esempio n. 22
0
//обрабатывает движение мыши при нажатой левой клавиши
void LineMouseMove(HWND hwnd,int x, int y)
{

	if(Dat.ButtonDown)
	{
		Dat.Drawing = TRUE;

		HDC PaintDC = GetDC(hwnd);
		
		//перерисовывает куб в новом положении в режиме NOTXOR
		HPEN hPen, hPenOld;
		hPen = CreatePen(PS_SOLID,1,RGB(0,0,255));
		hPenOld = SelectPen(PaintDC,hPen);  

		SetROP2(PaintDC, R2_NOTXORPEN);
		
		DrawBox(hwnd, PaintDC, anglOld);

		angl.fi += corOld.x-x;
		angl.teta += corOld.y-y;
		
		corOld.x = x; corOld.y = y;

		anglOld.fi   = angl.fi;
		anglOld.teta   = angl.teta;

		DrawBox(hwnd, PaintDC, anglOld);

		SelectPen(PaintDC,hPenOld);   
		DeletePen(hPen);           


		//информация об углах поворота куба
		TCHAR ss[20];
		SetBkColor(PaintDC,RGB(0xC0,0xC0,0xC0));
		SetTextColor(PaintDC,RGB(0,0,0x80));
		swprintf_s(ss,20,L"fi = %4.0lf",angl.fi);
		TextOut(PaintDC,(ne1+ne2)/2-80,me2-25,ss,9);
		swprintf_s(ss,20,L"teta = %4.0lf",angl.teta);
		TextOut(PaintDC,(ne1+ne2)/2+20,me2-25,ss,11);

		ReleaseDC(hwnd, PaintDC);
	}

}
Esempio n. 23
0
void TimelineDC::DrawFlag(const std::wstring& tooltip, int x, int y, COLORREF color, bool solid)
{
	CPen pen(CreatePen(PS_SOLID, 1, color));
	SelectPen(pen);
	if (solid)
		DrawSolidFlag(tooltip, x, y);
	else
		DrawFlag(tooltip, x, y);
}
Esempio n. 24
0
void CDrawContext::Rectangle( const CRect &rc, COLORREF cr )
{
	SelectPen( cr );
	//	Save and restore the brush because otherwise the caching system (GetBrush) still thinks
	//	a coloured brush is selected!
	HGDIOBJ hOld = ::SelectObject( m_hdc, GetStockObject( HOLLOW_BRUSH ) );
	VAPI( ::Rectangle( m_hdc, rc.left, rc.top, rc.right, rc.bottom ) );
	::SelectObject( m_hdc, hOld );
}
Esempio n. 25
0
/* make sure that the xvalues and yvalues contain enough values to go tracers deep */
void drawTracerGraph(HWND hwnd, long *xvalues, long *yvalues, int maxval, int tracers) {
//void drawTracerGraph(HWND hwnd, float nx, float ny) {
	HDC hdc;
	RECT rect;
	HPEN pen;
	int x,y;
	int w,h,fw,fh;
	int c;

	if (hdcTracer == NULL) initTracer(hwnd);

	/* get attributes */
	GetClientRect(hwnd, &rect);
	hdc = GetDC(hwnd);
	fw = rect.right - rect.left;
	fh = rect.bottom - rect.top;
	w = rect.right - rect.left - (XHAIR_HALF*2|1);
	h = rect.bottom - rect.top - (XHAIR_HALF*2|1);

	/* copy over the trace graph */
	BitBlt(hdc, 0, 0, fw, fh, hdcTracer, 0, 0, SRCCOPY);

	/* draw the xhair */
	for (c=tracers; c>0; c--) {
		pen = CreatePen(PS_SOLID, 1, RGB(255-(128/tracers*c),255-(255/tracers*c),0));
		SelectPen(hdc, pen);
		x = (int) (w*((float)xvalues[c] / maxval + 1)/2.0f) + XHAIR_HALF;
		y = (int) (h*((float)yvalues[c] / maxval + 1)/2.0f) + XHAIR_HALF;
		centerLine(hdc, x, y, (XHAIR_HALF|1)-2, LINE_XAXIS);
		centerLine(hdc, x, y, (XHAIR_HALF|1)-2, LINE_YAXIS);
		DeletePen(pen);
	}
	//special case of very first xhair
	pen = CreatePen(PS_SOLID, 1, RGB(255,0,0));
	SelectPen(hdc, pen);
	x = (int) (w*((float)xvalues[c] / maxval + 1)/2.0f) + XHAIR_HALF;
	y = (int) (h*((float)yvalues[c] / maxval + 1)/2.0f) + XHAIR_HALF;
	centerLine(hdc, x, y, XHAIR_HALF*2|1, LINE_XAXIS);
	centerLine(hdc, x, y, XHAIR_HALF*2|1, LINE_YAXIS);
	DeletePen(pen);
	GdiFlush();

	ReleaseDC(hwnd, hdc); 
}
Esempio n. 26
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);
}
Esempio n. 27
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 ) );

}
Esempio n. 28
0
void CDC::Pen(int iObjectID)
{
	HPEN hOldPen = SelectPen(m_hDC, GetStockPen(iObjectID));
	
	// Delete the old one?
	if (m_bDelOldPen)
		DeletePen(hOldPen);
		
	// This object doesn't need deleting.
	m_bDelOldPen = FALSE;
}
Esempio n. 29
0
// --------------------------------------------------------------
void GDeviceWin32::initialize(VGSystem* sys)
{
	SelectPen( VGColor(0,0,0,ALPHA_OPAQUE), 1);		//opaque black
	SelectFillColor( VGColor(0,0,0,ALPHA_OPAQUE) );	//opaque black
	SetFontColor( VGColor(0,0,0) );					//opaque black
	SetFontBackgroundColor( VGColor(255,255,255,ALPHA_TRANSPARENT) );	//transp. white
	SetFontAlign( kAlignLeft | kAlignBase );

	// guido hack - must be removed asap
	mSys = sys;
}
Esempio n. 30
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;
   }
}