コード例 #1
1
ファイル: cpicture_121.c プロジェクト: Ericson2314/lighthouse
void WinInitPicture (int size, int mode,
					 int pr, int pg, int pb,
					 int br, int bg, int bb,
					 char *fname, int fstyle, int fsize,
					 HRGN clipRgn,
					 BOOL bDoubleBuffered,
					 OSPictContext context
				    )
{
	LOGBRUSH lb;
	LOGFONT lf;
	DWORD style;

	context->penSize = size;
	context->penPat = iBlackPattern;
	context->penMode = mode;
	context->penColor = RGB (pr, pg, pb);
	context->backColor = RGB (br, bg, bb);
	context->lastActivity = FILLING;

	if (bDoubleBuffered)
	{
		RECT clipRect;

		if (GetClipBox(context->hDC,&clipRect) == ERROR)
		{
			printf("osInitPicture -> GetClipBox failed\n");
			exit(1);
		}

		context->hBufferedDC = context->hDC;
		context->hDC = CreateCompatibleDC(context->hBufferedDC);
		context->hBufferBitmap = CreateCompatibleBitmap(context->hBufferedDC,clipRect.right-clipRect.left,clipRect.bottom-clipRect.top);
		SelectObject(context->hDC, context->hBufferBitmap);

		if (!BitBlt(context->hDC, 0, 0, clipRect.right-clipRect.left, clipRect.bottom-clipRect.top, context->hBufferedDC, clipRect.left, clipRect.top, SRCCOPY))
		{
			printf("osDonePicture -> BitBlt failed\n");
			exit(1);
		}

		SetViewportOrgEx(context->hDC,-clipRect.left,-clipRect.top,NULL);
	}


	thePolygon = NULL;
	SetPolyFillMode (context->hDC, WINDING);

	strcpy (context->curFont, fname);
	context->fontstyle = fstyle;
	context->fontsize = PointsToPix(context->hDC,fsize);
				// PointsToPix by MW

	SetLogFontData (&lf, context->curFont, context->fontstyle, context->fontsize);

	if (context->penSize == 1)
		style = PS_COSMETIC | PS_SOLID;
	else
		style = PS_GEOMETRIC | PS_INSIDEFRAME;

	lb.lbStyle = BS_SOLID;
	lb.lbColor = context->penColor;
	lb.lbHatch = 0;
	context->theNormalPen = ExtCreatePen (style, context->penSize, &lb, 0, NULL);

	lb.lbStyle = BS_SOLID;
	lb.lbColor = context->backColor;
	lb.lbHatch = 0;
	context->theBackPen = ExtCreatePen (style, context->penSize, &lb, 0, NULL);

	SetBrushOrgEx (context->hDC,0,0,NULL);
	context->theNormalBrush = CreateSolidBrush (context->penColor);
	context->theBackBrush = CreateSolidBrush (context->backColor);
	context->theFont = CreateFontIndirect (&lf);

	SaveDC (context->hDC);

	SetWindowOrgEx (context->hDC, 0,0, NULL);

	SelectObject (context->hDC, GetStockObject (NULL_PEN));
	SelectObject (context->hDC, context->theNormalBrush);
	SelectObject (context->hDC, context->theFont);

	SetBkMode (context->hDC, TRANSPARENT);
	SetBkColor (context->hDC, context->backColor);
	SetTextAlign (context->hDC, TA_LEFT | TA_BASELINE);
	WinSetMode (context->penMode, context);
	SetStretchBltMode (context->hDC,COLORONCOLOR);		/* PA: when stretching bitmaps, use COLORONCOLOR mode. */

	if (ghCaretWnd)
	{
		int mess, p1, p2, p3, p4, p5, p6;
		WinKickOsThread (CcRqHIDECARET, (int) ghCaretWnd, 0, 0, 0, 0, 0,
						 &mess, &p1, &p2, &p3, &p4, &p5, &p6);
	}

	if (clipRgn != NULL)
		SelectClipRgn (context->hDC, clipRgn);
}	/* WinInitPicture */
コード例 #2
0
ファイル: HGraf_WIN32.c プロジェクト: botonchou/AlgoFinal
/* EXPORT-> MakeXGraf: Create and open window, initialization */
void MakeXGraf(char *wname, int x, int y, int w, int h, int bw)
     /* WIN32: bw is ignored. */
{
   WNDCLASS WindowClass;
   char sbuf[256], *hgraf = "HGraf";
   HDC dc;
     
   if (winCreated)
      HError(6870, "MakeXGraf: Attempt to recreate the graphics window");
     
   WindowClass.hInstance = GetModuleHandle(NULL);
   WindowClass.lpszClassName = hgraf;
   WindowClass.lpfnWndProc = HGWinFunc;
   WindowClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
   WindowClass.hIcon = NULL;
   WindowClass.hCursor = LoadCursor(NULL,IDC_ARROW);
   WindowClass.lpszMenuName = NULL;
   WindowClass.cbClsExtra = 0;
   WindowClass.cbWndExtra = 0;
   WindowClass.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
     
   RegisterClass(&WindowClass);
     
   strcpy(sbuf, hgraf);  strcat(sbuf, ": ");  strcat(sbuf, wname);
     
   theWindow = 
      CreateWindow(hgraf, sbuf, WS_OVERLAPPEDWINDOW | WS_VISIBLE,
                   x,y, w,h, HWND_DESKTOP, NULL,
                   WindowClass.hInstance,       NULL);
     
   /* adjust window size so that the client rectangle is the size requested */
   /* by the caller of MakeXGraf() --- Win32 interprets w and h as the dimensions */
   /* of the overall window. */
   GetClientRect(theWindow,&ClientRect);
   MoveWindow(theWindow,x,y,w+w-ClientRect.right,h+h-ClientRect.bottom,TRUE); 
   GetClientRect(theWindow,&ClientRect);
     
   /* Obtain and initialize device contexts */
   dc = GetDC(theWindow);
   memDC = CreateCompatibleDC(dc);
   SetArcDirection(memDC,AD_COUNTERCLOCKWISE);
   SetArcDirection(dc,AD_COUNTERCLOCKWISE);
   SetPolyFillMode(memDC,WINDING);
   SetPolyFillMode(memDC,WINDING);
   SetTextAlign(memDC,TA_BASELINE | TA_LEFT);
   SetTextAlign(dc,TA_BASELINE | TA_LEFT);
   SetBkMode(memDC,TRANSPARENT);
   SetBkMode(dc,TRANSPARENT);
   theBitmap = CreateCompatibleBitmap(dc,w,h);
   SelectObject(memDC,theBitmap);
   ReleaseDC(theWindow,dc);
   CreateHeap(&btnHeap, "Button heap", MHEAP, sizeof(HButton), 1.0, 100, 100);
     
   InitGlobals();
   InstallColours();
     
   winCreated = TRUE;
   HSetColour(WHITE);
   HFillRectangle(0,0,ClientRect.right,ClientRect.bottom);
}
コード例 #3
0
void Ctl_DrawCheck (
HDC hDC,         // Handle to DC in which to draw bevel
COLOR rgbColor,     // Color of check
RECT rRect)         // Rectangle of outer bounds of the bevel
{
    POINT ptsCheck[7];
    HPEN hOldPen = (HPEN)SelectObject (hDC,GetStockObject (NULL_PEN));
    HBRUSH hOldBrush = (HBRUSH)SelectObject (hDC,CreateSolidBrush (rgbColor));
    int OldPolyMode = SetPolyFillMode (hDC,WINDING);
    int Width = (rRect.right - rRect.left);
    int Height = (rRect.bottom - rRect.top);

    ptsCheck[0].x = rRect.left;
    ptsCheck[0].y = rRect.top+Height;
    ptsCheck[1].x = rRect.left;
    ptsCheck[1].y = rRect.top+Height/2;
    ptsCheck[2].x = rRect.left+(2*Width+5)/10;
    ptsCheck[2].y = rRect.top+(3*Height+5)/10;
    ptsCheck[3].x = rRect.left+(2*Width+5)/10;
    ptsCheck[3].y = rRect.top+(8*Height+5)/10;
    ptsCheck[4].x = rRect.left+Width;
    ptsCheck[4].y = rRect.top;
    ptsCheck[5].x = rRect.left+Width;
    ptsCheck[5].y = rRect.top+Height/5;
    ptsCheck[6].x = rRect.left+Width/5;
    ptsCheck[6].y = rRect.top+Height;
    Polygon (hDC,ptsCheck,7);
    SelectObject (hDC,hOldPen);
    DeleteObject (SelectObject (hDC,hOldBrush));
    SetPolyFillMode (hDC,OldPolyMode);
}
コード例 #4
0
void Ctl_DrawDiamond (
HDC hDC,         // Handle to DC in which to draw diamond
COLOR rgbColor,     // Color of diamond
RECT rRect)         // Rectangle of outer bounds of the bevel
{
    POINT ptsDiamond[4];
    HPEN hOldPen, hPen;
    HBRUSH hOldBrush, hBrush;
    int OldPolyMode = SetPolyFillMode (hDC,WINDING);
    int hWidth = max ((rRect.right - rRect.left)/2,1);
    int hHeight = max ((rRect.bottom - rRect.top)/2,1);
    
    hPen = CreatePen (PS_SOLID,1,rgbColor);
    hOldPen = (HPEN)SelectObject (hDC,hPen);
    hBrush = CreateSolidBrush (rgbColor);
    hOldBrush = (HBRUSH)SelectObject (hDC,hBrush);
    ptsDiamond[0].x = rRect.left+hWidth;
    ptsDiamond[0].y = rRect.top;
    ptsDiamond[1].x = rRect.left+2*hWidth;
    ptsDiamond[1].y = rRect.top+hHeight;
    ptsDiamond[2].x = rRect.left+hWidth;
    ptsDiamond[2].y = rRect.top+2*hHeight;
    ptsDiamond[3].x = rRect.left;
    ptsDiamond[3].y = rRect.top+hHeight;
    Polygon (hDC,ptsDiamond,4);
    DeleteObject (SelectObject (hDC,hOldPen));
    DeleteObject (SelectObject (hDC,hOldBrush));
    SetPolyFillMode (hDC,OldPolyMode);
}
コード例 #5
0
/* ********************************************************************* */
int vecfill_()
{
  SetPolyFillMode(hdcWindow,WINDING);
  SetPolyFillMode(hdcMemory,WINDING);
  Polygon(hdcWindow,accis_path,accis_pathlen+1);
  Polygon(hdcMemory,accis_path,accis_pathlen+1);
  return 0;
}
コード例 #6
0
ファイル: Altwind.cpp プロジェクト: Magicmay/windowsProgram
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)//视窗讯息处理程式
{
	//CS_视窗类别样式
	//CW_建立视窗
	//DT_绘制文字
	//IDI_图示ID
	//IDC_游标ID
	//MB_讯息方块
	//SND_声音
	//WM_视窗讯息
	//WS_视窗样式
	//WHITE_BRUSH、LTGRAY_BRUSH、GRAY_BRUSH、DKGRAY_BRUSH、BLACK_BRUSH 和NULL_BRUSH
	HDC hdc;
	PAINTSTRUCT ps;
	//	RECT rect;
	static POINT aptFigure[10] = { 10, 70, 50,70, 50, 10, 90, 10, 90, 50, 30, 50, 30, 90, 70, 90, 70, 30,10, 30 };
	static int cxClient,cyClient;
	int i;
	POINT apt[10];
	switch (message)
	{
	case WM_SIZE:
		cxClient = LOWORD(lParam);
		cyClient = HIWORD(lParam);
		return 0;
	case WM_PAINT:
		hdc = BeginPaint(hwnd, &ps);
		SelectObject(hdc, GetStockObject(GRAY_BRUSH));
		for (i = 0; i < 10; ++i)
		{
			apt[i].x = cxClient*aptFigure[i].x / 200;
			apt[i].y = cyClient*aptFigure[i].y / 100;
		}
		SetPolyFillMode(hdc, ALTERNATE);
		Polygon(hdc, apt, 10);

		for (i = 0; i < 10;++i)
		{
			apt[i].x += cxClient / 2;
		}
		SetPolyFillMode(hdc, WINDING);
		Polygon(hdc, apt, 10);

		EndPaint(hwnd, &ps);
		return 0;
	case WM_DESTROY:
		PostQuitMessage(0);
		return 0;
	}
	//视窗讯息处理程式不予处理的所有讯息提供内定处理
	return DefWindowProc(hwnd, message, wParam, lParam);
}
コード例 #7
0
ファイル: AltWind.c プロジェクト: Jeanhwea/petzold-pw5e
LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
     static POINT aptFigure [10] = { 10,70, 50,70, 50,10, 90,10, 90,50,
                                     30,50, 30,90, 70,90, 70,30, 10,30 };
     static int   cxClient, cyClient ;
     HDC          hdc ;
     int          i ;
     PAINTSTRUCT  ps ;
     POINT        apt[10] ;
     
     switch (message)
     {
     case WM_SIZE:
          cxClient = LOWORD (lParam) ;
          cyClient = HIWORD (lParam) ;
          return 0 ;

     case WM_PAINT:
          hdc = BeginPaint (hwnd, &ps) ;

          SelectObject (hdc, GetStockObject (GRAY_BRUSH)) ;

          for (i = 0 ; i < 10 ; i++)
          {
               apt[i].x = cxClient * aptFigure[i].x / 200 ;
               apt[i].y = cyClient * aptFigure[i].y / 100 ;
          }

          SetPolyFillMode (hdc, ALTERNATE) ;
          Polygon (hdc, apt, 10) ;

          for (i = 0 ; i < 10 ; i++)
          {
               apt[i].x += cxClient / 2 ;
          }

          SetPolyFillMode (hdc, WINDING) ;
          Polygon (hdc, apt, 10) ;
          
          EndPaint (hwnd, &ps) ;
          return 0 ;
          
     case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
コード例 #8
0
ファイル: drawdialoggl.c プロジェクト: doolin/ntdda
static void 
addTriangle(HWND hDlg)
{

   if(nPoints < estNumPts) 
   {
      pp[nPoints].x = ptNew.x;
		    pp[nPoints].y = ptNew.y;
	     pp[nPoints].type = type;
		    nPoints++;
				  if(tool==3) 
         nlp++;
					 else 
         nfp++;
					 hCurrentBr = GetStockObject(WHITE_BRUSH);
					 if(tool==3) 
         hCurrentBr = GetStockObject(BLACK_BRUSH);
				  SelectObject(hdc, hCurrentBr);
		    tri[0].x = (int) (ptNew.x);
		    tri[0].y = (int) (ptNew.y + 1.2*radius);
		    tri[1].x = (int) (ptNew.x - 1.2*0.866*radius+.5);
		    tri[1].y = (int) (ptNew.y - 1.2*0.5*radius);
      tri[2].x = (int) (ptNew.x + 1.2*0.866*radius);
		    tri[2].y = (int) (ptNew.y - 1.2*0.5*radius);
				  SetPolyFillMode (hdc, WINDING) ;
			   Polygon(hdc, tri, 3);
			 } 
    else 
    {
			    MessageBox(hDlg, "Estimated # of Points Exceeded", "Too many points", MB_OK);
		 	}

}  /* close addTriangle() */
コード例 #9
0
ファイル: ColorButton.cpp プロジェクト: Deepfreeze32/taken
/*
================
ColorButton_DrawArrow

Draws the arrow on the color button
================
*/
static void ColorButton_DrawArrow ( HDC hDC, RECT* pRect, COLORREF color )
{
	POINT ptsArrow[3];

	ptsArrow[0].x = pRect->left;
	ptsArrow[0].y = pRect->top;
	ptsArrow[1].x = pRect->right;
	ptsArrow[1].y = pRect->top;
	ptsArrow[2].x = (pRect->left + pRect->right)/2;
	ptsArrow[2].y = pRect->bottom;
	
	HBRUSH arrowBrush = CreateSolidBrush ( color );
	HPEN   arrowPen   = CreatePen ( PS_SOLID, 1, color );
	
	HGDIOBJ oldBrush = SelectObject ( hDC, arrowBrush );
	HGDIOBJ oldPen   = SelectObject ( hDC, arrowPen );
	
	SetPolyFillMode(hDC, WINDING);
	Polygon(hDC, ptsArrow, 3);
	
	SelectObject ( hDC, oldBrush );
	SelectObject ( hDC, oldPen );
	
	DeleteObject ( arrowBrush );
	DeleteObject ( arrowPen );
}
コード例 #10
0
ファイル: region.c プロジェクト: baskanov/wine
static GpStatus get_path_hrgn(GpPath *path, GpGraphics *graphics, HRGN *hrgn)
{
    HDC new_hdc=NULL;
    GpGraphics *new_graphics=NULL;
    GpStatus stat;
    INT save_state;

    if (!path->pathdata.Count)  /* PathToRegion doesn't support empty paths */
    {
        *hrgn = CreateRectRgn( 0, 0, 0, 0 );
        return *hrgn ? Ok : OutOfMemory;
    }

    if (!graphics)
    {
        new_hdc = CreateCompatibleDC(0);
        if (!new_hdc)
            return OutOfMemory;

        stat = GdipCreateFromHDC(new_hdc, &new_graphics);
        graphics = new_graphics;
        if (stat != Ok)
        {
            DeleteDC(new_hdc);
            return stat;
        }
    }
    else if (!graphics->hdc)
    {
        graphics->hdc = new_hdc = CreateCompatibleDC(0);
        if (!new_hdc)
            return OutOfMemory;
    }

    save_state = SaveDC(graphics->hdc);
    EndPath(graphics->hdc);

    SetPolyFillMode(graphics->hdc, (path->fill == FillModeAlternate ? ALTERNATE
                                                                    : WINDING));

    stat = trace_path(graphics, path);
    if (stat == Ok)
    {
        *hrgn = PathToRegion(graphics->hdc);
        stat = *hrgn ? Ok : OutOfMemory;
    }

    RestoreDC(graphics->hdc, save_state);
    if (new_hdc)
    {
        DeleteDC(new_hdc);
        if (new_graphics)
            GdipDeleteGraphics(new_graphics);
        else
            graphics->hdc = NULL;
    }

    return stat;
}
コード例 #11
0
void LaserStatusDialog::DrawTemperaturePointer(POINT &StartLoc, HDC hdc)
{
	int PointerHeight=20;
	int PointerWidth=52;
	int PointerOffset=5;

	POINT ptArray[6];
	ptArray[0]=StartLoc;

	ptArray[1].x=StartLoc.x+PointerOffset;
	ptArray[1].y=StartLoc.y-PointerHeight/2;

	ptArray[2].x=ptArray[1].x+PointerWidth;
	ptArray[2].y=ptArray[1].y;

	ptArray[3].x=ptArray[2].x;
	ptArray[3].y=StartLoc.y+PointerHeight/2;

	ptArray[4].x=ptArray[1].x;
	ptArray[4].y=ptArray[3].y;


	ptArray[5]=StartLoc;

	RECT PolyTextZone;
	PolyTextZone.top=ptArray[1].y+2;
	PolyTextZone.left=ptArray[1].x;
	PolyTextZone.bottom=ptArray[3].y;
	PolyTextZone.right=ptArray[3].x;

	int OldPolyFillMode=SetPolyFillMode(hdc,WINDING);
	//Polyline (hdc, ptArray,6 );
	//PolyDraw(hdc,ptArray,PT_CLOSEFIGURE,6);
	Polygon(hdc,ptArray,6);
	
	SetPolyFillMode(hdc,OldPolyFillMode);

	char TempText[20];
	sprintf_s(TempText,"%.1f°C",m_dCurrentTempCelsius);

	

	DrawTempatureScaleText(hdc,PolyTextZone,TempText);


}
コード例 #12
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : rc - 
//			fillr - 
//			fillg - 
//			fillb - 
//-----------------------------------------------------------------------------
void CDrawHelper::DrawTriangleMarker( RECT& rc, COLORREF fill, bool inverted /*= false*/ )
{
	POINT region[3];
	int cPoints = 3;

	if ( !inverted )
	{
		region[ 0 ].x = rc.left - m_x;
		region[ 0 ].y = rc.top - m_y;

		region[ 1 ].x = rc.right - m_x;
		region[ 1 ].y = rc.top - m_y;

		region[ 2 ].x = ( ( rc.left + rc.right ) / 2 ) - m_x;
		region[ 2 ].y = rc.bottom - m_y;
	}
	else
	{
		region[ 0 ].x = rc.left - m_x;
		region[ 0 ].y = rc.bottom - m_y;

		region[ 1 ].x = rc.right - m_x;
		region[ 1 ].y = rc.bottom - m_y;

		region[ 2 ].x = ( ( rc.left + rc.right ) / 2 ) - m_x;
		region[ 2 ].y = rc.top - m_y;
	}

	HRGN rgn = CreatePolygonRgn( region, cPoints, ALTERNATE );

	int oldPF = SetPolyFillMode( m_dcMemory, ALTERNATE );
	
	HBRUSH brFace = CreateSolidBrush( fill );

	FillRgn( m_dcMemory, rgn, brFace );

	DeleteObject( brFace );
	
	SetPolyFillMode( m_dcMemory, oldPF );

	DeleteObject( rgn );
}
コード例 #13
0
ファイル: region.c プロジェクト: AmesianX/RosWine
static GpStatus get_path_hrgn(GpPath *path, GpGraphics *graphics, HRGN *hrgn)
{
    HDC new_hdc=NULL;
    GpGraphics *new_graphics=NULL;
    GpStatus stat;
    INT save_state;

    if (!graphics)
    {
        new_hdc = GetDC(0);
        if (!new_hdc)
            return OutOfMemory;

        stat = GdipCreateFromHDC(new_hdc, &new_graphics);
        graphics = new_graphics;
        if (stat != Ok)
        {
            ReleaseDC(0, new_hdc);
            return stat;
        }
    }
    else if (!graphics->hdc)
    {
        graphics->hdc = new_hdc = GetDC(0);
        if (!new_hdc)
            return OutOfMemory;
    }

    save_state = SaveDC(graphics->hdc);
    EndPath(graphics->hdc);

    SetPolyFillMode(graphics->hdc, (path->fill == FillModeAlternate ? ALTERNATE
                                                                    : WINDING));

    stat = trace_path(graphics, path);
    if (stat == Ok)
    {
        *hrgn = PathToRegion(graphics->hdc);
        stat = *hrgn ? Ok : OutOfMemory;
    }

    RestoreDC(graphics->hdc, save_state);
    if (new_hdc)
    {
        ReleaseDC(0, new_hdc);
        if (new_graphics)
            GdipDeleteGraphics(new_graphics);
        else
            graphics->hdc = NULL;
    }

    return stat;
}
コード例 #14
0
ファイル: gditest.c プロジェクト: jamjr/Helios-NG
static void calculate_polygon(void)
{
    WINT points, i;
    RECT rect;
    POINT p[9];
    HPEN hOldPen;
    HBRUSH hOldBrush;
    do {
        rect.left = 0x7fff;
        rect.top = 0x7fff;
        rect.right = 0;
        rect.bottom = 0;
        points = get_rand(2, 9);
        for (i=0; i<points; i++)
        {
            p[i].x = get_rand(0, xMax);
            p[i].y = get_rand(0, yMax);
            if (p[i].x < rect.left)
                rect.left = p[i].x;
            if (p[i].x > rect.right)
                rect.right = p[i].x;
            if (p[i].y < rect.top)
                rect.top = p[i].y;
            if (p[i].y > rect.bottom)
                rect.bottom = p[i].y;
        }
        hOldPen = SelectObject(hMemDC, create_pen());
        hOldBrush = SelectObject(hMemDC, create_brush());
        SetBkColor(hMemDC, colors[get_rand(0, num_colors)]);
        SetBkMode(hMemDC, get_rand(1,3));
        SetPolyFillMode(hMemDC, get_rand(1,3));
        SetROP2(hMemDC, get_rand(1,17));
        Polygon(hMemDC, &p[0], points);
        DeleteObject(SelectObject(hMemDC, hOldPen));
        DeleteObject(SelectObject(hMemDC, hOldBrush));
        if (TestSemaphore(&PainterRequired) < 0)
        {
            InvalidateRect(hWnd, &rect, FALSE);
            UpdateWindow(hWnd);
        }
    } while ((TestSemaphore(&DemoRun)) && (!TestSemaphore(&SingleRun)));
    
    if (!TestSemaphore(&SingleRun));
        Signal(&Done);
}
コード例 #15
0
void PaintPolygon(HWND hwnd,int iFillMode,POINT points[],int cxClient,int cyClient)
{
	PAINTSTRUCT ps;
	HDC hdc = BeginPaint (hwnd, &ps) ;
	int i;

	SelectObject (hdc, GetStockObject (GRAY_BRUSH)) ;

	for (i = 0 ; i < 10 ; i++)
	{
		points[i].x += cxClient / 2 ;
		points[i].y += cyClient / 4 ;
	}

	SetPolyFillMode (hdc, iFillMode) ;
	Polygon (hdc, points, 10) ;

	EndPaint (hwnd, &ps) ;
}
コード例 #16
0
ファイル: dcprev.cpp プロジェクト: rickerliang/OpenNT
void CPreviewDC::MirrorAttributes()
{
	ASSERT(m_hAttribDC != NULL);

	if (m_hDC != NULL)
	{
		// extract and re-set Pen and Brush
		HGDIOBJ hTemp = ::SelectObject(m_hAttribDC, ::GetStockObject(BLACK_PEN));
		::SelectObject(m_hAttribDC, hTemp);
		::SelectObject(m_hDC, hTemp);
		hTemp = ::SelectObject(m_hAttribDC, ::GetStockObject(BLACK_BRUSH));
		::SelectObject(m_hAttribDC, hTemp);
		::SelectObject(m_hDC, hTemp);

		SetROP2(GetROP2());
		SetBkMode(GetBkMode());
		SetTextAlign(GetTextAlign());
		SetPolyFillMode(GetPolyFillMode());
		SetStretchBltMode(GetStretchBltMode());
		SetTextColor(GetNearestColor(GetTextColor()));
		SetBkColor(GetNearestColor(GetBkColor()));
	}
}
コード例 #17
0
void mxExpressionSlider::DrawThumb( int barnum, HDC& dc )
{
	RECT rcThumb;

	GetThumbRect( barnum, rcThumb );

	// Draw it


	HPEN oldPen;

	HPEN shadow;
	HBRUSH face;
	HPEN hilight;

	shadow = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_3DDKSHADOW ) );
	hilight = CreatePen( PS_SOLID, 1, GetSysColor( COLOR_3DHIGHLIGHT ) );
	
	switch ( barnum )
	{
	default:
	case MAGNITUDE_BAR:

		if ( m_flCurrent[ barnum ] != m_flMin[ barnum ] )
		{
			// float frac = ( m_flCurrent[ barnum ] - m_flMin[ barnum ] ) / (  m_flMax[ barnum ] - m_flMin[ barnum ] );
			float frac;
			if (m_flCurrent[ barnum ] < 0)
			{
				frac = m_flCurrent[ barnum ] / m_flMin[ barnum ];
			}
			else
			{
				frac = m_flCurrent[ barnum ] / m_flMax[ barnum ];
			}
			frac = min( 1.0f, frac );
			frac = max( 0.0f, frac );

			COLORREF clr = GetSysColor( COLOR_3DFACE );
			int r, g, b;
			r = GetRValue( clr );
			g = GetRValue( clr );
			b = GetRValue( clr );

			// boost colors
			r = (int)( (1-frac) * b );
			b = min( 255, (int)(r + ( 255 - r ) * frac ) );
			g = (int)( (1-frac) * g );

			face = CreateSolidBrush( RGB( r, g, b ) );
		}
		else
		{
			face = CreateSolidBrush( GetSysColor( COLOR_3DFACE ) );
		}
		break;
	case BALANCE_BAR:
		{
			float frac = ( m_flCurrent[ barnum ] - m_flMin[ barnum ] ) / (  m_flMax[ barnum ] - m_flMin[ barnum ] );
			frac = min( 1.0f, frac );
			frac = max( 0.0f, frac );

			COLORREF clr = GetSysColor( COLOR_3DFACE );
			int r, g, b;
			r = GetRValue( clr );
			g = GetRValue( clr );
			b = GetRValue( clr );

			// boost colors toward red if we are not at 0.5
			float boost = 2.0 * ( fabs( frac - 0.5f ) );

			r = r + ( 255 - r ) * boost;
			g = ( 1 - boost ) * g;
			b = ( 1 - boost ) * b;

			face = CreateSolidBrush( RGB( r, g, b ) );
		}
		break;
	}

	//rcThumb.left += 1;
	//rcThumb.right -= 1;
	//rcThumb.top += 1;
	//rcThumb.bottom -= 1;

	//FillRect( dc, &rcThumb, face );
	POINT region[3];
	int cPoints = 3;

	InflateRect( &rcThumb, -2, 0 );

//	int height = rcThumb.bottom - rcThumb.top;
//	int offset = height / 2 + 1;
	int offset = 2;

	switch ( barnum )
	{
	case MAGNITUDE_BAR:
	default:
		{
			region[ 0 ].x = rcThumb.left;
			region[ 0 ].y = rcThumb.top;
			
			region[ 1 ].x = rcThumb.right;
			region[ 1 ].y = rcThumb.top;
			
			region[ 2 ].x = ( rcThumb.left + rcThumb.right ) / 2;
			region[ 2 ].y = rcThumb.bottom - offset;
		}
		break;
	case BALANCE_BAR:
		{
			region[ 0 ].x = ( rcThumb.left + rcThumb.right ) / 2;
			region[ 0 ].y = rcThumb.top + offset;

			region[ 1 ].x = rcThumb.left;
			region[ 1 ].y = rcThumb.bottom;

			region[ 2 ].x = rcThumb.right;
			region[ 2 ].y = rcThumb.bottom;

		}
		break;
	}

	HRGN rgn = CreatePolygonRgn( region, cPoints, ALTERNATE );

	int oldPF = SetPolyFillMode( dc, ALTERNATE );
	FillRgn( dc, rgn, face );
	SetPolyFillMode( dc, oldPF );

	DeleteObject( rgn );

	oldPen = (HPEN)SelectObject( dc, hilight );

	MoveToEx( dc, region[0].x, region[0].y, NULL );
	LineTo( dc, region[1].x, region[1].y );
	SelectObject( dc, shadow );
	LineTo( dc, region[2].x, region[2].y );
	SelectObject( dc, hilight );
	LineTo( dc, region[0].x, region[0].y );

	SelectObject( dc, oldPen );

	DeleteObject( face );
	DeleteObject( shadow );
	DeleteObject( hilight );
}
コード例 #18
0
ファイル: advappdlg.c プロジェクト: HBelusca/NasuTek-Odyssey
/* Create the basic bitmaps for the color picker buttons */
static VOID
InitColorButtons(HWND hwndDlg, GLOBALS* g)
{
	INT i;
	HDC hdcColorButton, hdcCompat;
	RECT rect;
	HBRUSH hbrush;
	HPEN hPen;
	HWND hwndColorButton;
	HGDIOBJ hgdiTemp;
    THEME *theme = &g->ThemeAdv;

	const POINT Points[3] = {{29,6},{33,6},{31,8}};

	hwndColorButton = GetDlgItem(hwndDlg, IDC_ADVAPPEARANCE_COLOR1_B);
	hdcColorButton = GetDC(hwndColorButton);
	for (i = 0; i <= 2; i++)
	{
		/* Create a DC to draw on */
		hdcCompat = CreateCompatibleDC(hdcColorButton);

		/* Create the button image */
		g->hbmpColor[i] = CreateCompatibleBitmap(hdcColorButton, 36, 15);

		/* Select the button image to the DC */
		hgdiTemp = SelectObject(hdcCompat, g->hbmpColor[i]);

		/* Draw the buttons background color */
		rect.left = 0;
		rect.top = 0;
		rect.right = 36;
		rect.bottom = 15;
		hbrush = CreateSolidBrush(theme->crColor[COLOR_BTNFACE]);
		FillRect(hdcCompat, &rect, hbrush);
		DeleteObject(hbrush);

		/* Draw the rectangle */
		rect.left = 1;
		rect.top = 1;
		rect.right = 23;
		rect.bottom = 14;
		hbrush = CreateSolidBrush(theme->crColor[COLOR_BTNTEXT]);
		FillRect(hdcCompat, &rect, hbrush);
		DeleteObject(hbrush);

		/* Draw left side of line */
		hPen = CreatePen(PS_SOLID, 1, theme->crColor[COLOR_BTNSHADOW]);
		SelectObject(hdcCompat, hPen);
		MoveToEx(hdcCompat, 26, 1, NULL);
		LineTo(hdcCompat, 26, 14);
		SelectObject(hdcCompat, GetStockObject(BLACK_PEN));
		DeleteObject(hPen);

		/* Draw right side of line */
		hPen = CreatePen(PS_SOLID, 1, theme->crColor[COLOR_BTNHIGHLIGHT]);
		SelectObject(hdcCompat,hPen);
		MoveToEx(hdcCompat, 27, 1, NULL);
		LineTo(hdcCompat, 27, 14);
		SelectObject(hdcCompat, GetStockObject(BLACK_PEN));
		DeleteObject(hPen);

		/* Draw triangle */
		hPen = CreatePen(PS_SOLID, 1, theme->crColor[COLOR_BTNTEXT]);
		hbrush = CreateSolidBrush(theme->crColor[COLOR_BTNTEXT]);
		SelectObject(hdcCompat, hPen);
		SelectObject(hdcCompat, hbrush);
		SetPolyFillMode(hdcCompat, WINDING);

		/* FIXME: HACK, see Points definition */
		Polygon(hdcCompat, Points, 3);

		/* Cleanup */
		SelectObject(hdcCompat,hgdiTemp);
		DeleteDC(hdcCompat);
		DeleteObject(hPen);
		DeleteObject(hbrush);
	}

	ReleaseDC(hwndColorButton, hdcColorButton);

	/* Set the images of the buttons */
	SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_COLOR1_B, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)g->hbmpColor[0]);
	SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_COLOR2_B, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)g->hbmpColor[1]);
	SendDlgItemMessage(hwndDlg, IDC_ADVAPPEARANCE_FONTCOLOR_B, BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)g->hbmpColor[2]);
}
コード例 #19
0
ファイル: plot.c プロジェクト: MarkieMark/netsurf-git-svn
static bool polygon(const int *p, unsigned int n, const plot_style_t *style)
{
#if NSWS_PLOT_DEBUG
	LOG(("polygon %d points thumbnail %d", n, thumbnail));
#endif
	POINT points[n];
	unsigned int i;
	HDC hdc = doublebuffering ? bufferdc : GetDC(current_hwnd);
	if (hdc == NULL) {
		return false;
	}
	RECT *clipr = gui_window_clip_rect(current_gui);
	if (clipr == NULL)
		clipr = &localhistory_clip;
	HRGN clipregion = CreateRectRgnIndirect(clipr);
	if (clipregion == NULL) {
		if (!doublebuffering)
			ReleaseDC(current_hwnd, hdc);
		return false;
	}
	COLORREF pencol = (DWORD)(style->fill_colour & 0x00FFFFFF);
	COLORREF brushcol = (DWORD)(style->fill_colour & 0x00FFFFFF);
	HPEN pen = CreatePen(PS_GEOMETRIC | PS_NULL, 1, pencol);
	if (pen == NULL) {
		DeleteObject(clipregion);
		if (!doublebuffering)
			ReleaseDC(current_hwnd, hdc);
		return false;
	}
	HPEN penbak = SelectObject(hdc, pen);
	if (penbak == NULL) {
		DeleteObject(clipregion);
		DeleteObject(pen);
		if (!doublebuffering)
			ReleaseDC(current_hwnd, hdc);
		return false;
	}
	HBRUSH brush = CreateSolidBrush(brushcol);
	if (brush == NULL) {
		DeleteObject(clipregion);
		SelectObject(hdc, penbak);
		DeleteObject(pen);
		if (!doublebuffering)
			ReleaseDC(current_hwnd, hdc);
		return false;
	}
	HBRUSH brushbak = SelectObject(hdc, brush);
	if (brushbak == NULL) {
		DeleteObject(clipregion);
		SelectObject(hdc, penbak);
		DeleteObject(pen);
		DeleteObject(brush);
		if (!doublebuffering)
			ReleaseDC(current_hwnd, hdc);
		return false;
	}
	SetPolyFillMode(hdc, WINDING);
	for (i = 0; i < n; i++) {
		points[i].x = (long) p[2 * i];
		points[i].y = (long) p[2 * i + 1];

#if NSWS_PLOT_DEBUG
		printf ("%ld,%ld ", points[i].x, points[i].y);
#endif
	}
	
	SelectClipRgn(hdc, clipregion);
	
	if (n >= 2)
		Polygon(hdc, points, n);

	SelectClipRgn(hdc, NULL);

	pen = SelectObject(hdc, penbak);
	brush = SelectObject(hdc, brushbak);
	DeleteObject(clipregion);
	DeleteObject(pen);
	DeleteObject(brush);
	if (!doublebuffering)
		ReleaseDC(current_hwnd, hdc);
#if NSWS_PLOT_DEBUG
		printf("\n");
#endif
	return true;
}
コード例 #20
0
ファイル: plot.c プロジェクト: arczi84/NetSurf-68k
static bool polygon(const int *p, unsigned int n, const plot_style_t *style)
{
	PLOT_LOG("polygon %d points", n);

	/* ensure the plot HDC is set */
	if (plot_hdc == NULL) {
		LOG("HDC not set on call to plotters");
		return false;
	}

	POINT points[n];
	unsigned int i;
	HRGN clipregion = CreateRectRgnIndirect(&plot_clip);
	if (clipregion == NULL) {
		return false;
	}

	COLORREF pencol = (DWORD)(style->fill_colour & 0x00FFFFFF);
	COLORREF brushcol = (DWORD)(style->fill_colour & 0x00FFFFFF);
	HPEN pen = CreatePen(PS_GEOMETRIC | PS_NULL, 1, pencol);
	if (pen == NULL) {
		DeleteObject(clipregion);
		return false;
	}
	HPEN penbak = SelectObject(plot_hdc, pen);
	if (penbak == NULL) {
		DeleteObject(clipregion);
		DeleteObject(pen);
		return false;
	}
	HBRUSH brush = CreateSolidBrush(brushcol);
	if (brush == NULL) {
		DeleteObject(clipregion);
		SelectObject(plot_hdc, penbak);
		DeleteObject(pen);
		return false;
	}
	HBRUSH brushbak = SelectObject(plot_hdc, brush);
	if (brushbak == NULL) {
		DeleteObject(clipregion);
		SelectObject(plot_hdc, penbak);
		DeleteObject(pen);
		DeleteObject(brush);
		return false;
	}
	SetPolyFillMode(plot_hdc, WINDING);
	for (i = 0; i < n; i++) {
		points[i].x = (long) p[2 * i];
		points[i].y = (long) p[2 * i + 1];

		PLOT_LOG("%ld,%ld ", points[i].x, points[i].y);
	}

	SelectClipRgn(plot_hdc, clipregion);

	if (n >= 2)
		Polygon(plot_hdc, points, n);

	SelectClipRgn(plot_hdc, NULL);

	pen = SelectObject(plot_hdc, penbak);
	brush = SelectObject(plot_hdc, brushbak);
	DeleteObject(clipregion);
	DeleteObject(pen);
	DeleteObject(brush);

	return true;
}
コード例 #21
0
ファイル: win3.cpp プロジェクト: distanceModling/DAKOTA
void plD_init_win3(PLStream *pls)
{
	HWND      hwndMain;
	WNDCLASS  wndclass;
	HINSTANCE hInstance;
	WinDev    *dev;
	int       greyvalue;
	char      *ptitle;
	//long      backGroundColor;
	
	/* Initial window position */
	int xPos    = 100;
	int yPos    = 100;
	
	/* Initial window size */
	int nWidth  = 720;
	int nHeight = 540;
	
	int xmin = 0;
	int xmax = PIXELS_X-1;
	int ymin = 0;
	int ymax = PIXELS_Y-1;
	
	color = 1;
	hwnd = 0;
	pls->color = 1;		/* Is a color device */
	plParseDrvOpts(win3_options);
	if (!color) pls->color = 0; /* But user does not want color */
	
	/* Set up device parameters */
	pls->termin      = 1; /* is an interactive terminal */
	pls->icol0       = 1; /* current color */
	pls->width       = 1; /* current pen width */
	pls->bytecnt     = 0;
	pls->page        = 0;
	if (buffered)
		pls->plbuf_write = 1; /* buffer the output */
	else
		pls->plbuf_write = 0;
	pls->dev_flush   = 1; /* flush as we like */
	pls->dev_fill0   = 1;	
	pls->dev_fastimg = 1; /* is a fast image device */
	pls->dev_xor     = 1; /* device support xor mode */
	if (pls->dev != NULL) delete pls->dev;
	pls->dev = new WinDev;
	assert(pls->dev != NULL);
	
	dev = (WinDev *) pls->dev;
	dev->nextPlot = 0;
	dev->write_to_window = 1;
	dev->write_to_pixmap = 0;
	dev->PenColor=RGB(pls->cmap0[0].r,pls->cmap0[0].g,pls->cmap0[0].b);
	dev->PenWidth=0;
	
	dev->hPen     = CreatePen(PS_SOLID,dev->PenWidth,dev->PenColor);
	dev->hPenOld = (HPEN)SelectObject(dev->hdc,dev->hPen);
	dev->hbr      = CreateSolidBrush(RGB(pls->cmap0[0].r,pls->cmap0[0].g,pls->cmap0[0].b));
	dev->hbrOld   = (HBRUSH)SelectObject(dev->hdc,dev->hbr);
	dev->hMenu    = NULL;

        dev->isDead   = FALSE;
	
	if (pls->color) {
		dev->backGroundColor = RGB(pls->cmap0[0].r,pls->cmap0[0].g,pls->cmap0[0].b);
	} else {
		greyvalue = (pls->cmap0[0].r+pls->cmap0[0].g+pls->cmap0[0].b)/3;
		dev->backGroundColor = RGB(greyvalue,greyvalue,greyvalue);
	}

	if (!hwnd) {
		/* Window created by the driver */
		dev->externalWindow = 0;
		hInstance = GetModuleHandle(NULL);
		
		wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_SAVEBITS;
		wndclass.lpfnWndProc = ::PlPlotWndProc;
		wndclass.cbClsExtra = 0;
		wndclass.cbWndExtra = sizeof(pls);
		wndclass.hInstance = hInstance;
		wndclass.hIcon = LoadIcon(hInstance,"PLICON");
		wndclass.hCursor = LoadCursor(NULL,IDC_ARROW);
        wndclass.hbrBackground = (struct HBRUSH__ *)CreateSolidBrush(dev->backGroundColor);
		wndclass.lpszMenuName = NULL;
		wndclass.lpszClassName = szPlPlotClass;
		RegisterClass (&wndclass);
		ptitle = (char *) &szPlPlotWName[0] ;
		if ( pls->plwindow ) ptitle = pls->plwindow ;
		
		dev->hwnd = CreateWindow(szPlPlotClass,ptitle,
			WS_OVERLAPPEDWINDOW,
			xPos,yPos,nWidth,nHeight,
			NULL,dev->hMenu,
			hInstance,NULL);
		
		SetWindowLong(dev->hwnd,GWL_USERDATA,(long)pls);
		
		ShowWindow(dev->hwnd,SW_SHOWDEFAULT);
		
		SetForegroundWindow(dev->hwnd);
		
	} else {
		/* Window provided externally */		
		dev->hwnd = (HWND)hwnd;
		dev->externalWindow = 1;
	}


	dev->hdc = GetDC(dev->hwnd);

	SetPolyFillMode(dev->hdc,WINDING);
	
	plP_setpxl(xmax/150.0/nWidth*nHeight,ymax/150.0);
	plP_setphy(xmin,xmax,ymin,ymax);


	if (pls->db)
	{
     	// create a compatible device context
     	dev->db_hdc = CreateCompatibleDC(dev->hdc);
     	dev->db_bmp = CreateCompatibleBitmap(dev->hdc, nWidth,nHeight);
		SelectObject(dev->db_hdc, dev->db_bmp);
		dev->hdc=dev->db_hdc;
	}
}
コード例 #22
0
ファイル: tkWinDraw.c プロジェクト: Kiriwa/ns-allinone-2.35
static void
RenderObject(
    HDC dc,
    GC gc,
    XPoint *points,
    int npoints,
    int mode,
    HPEN pen,
    WinDrawFunc func)
{
    RECT rect;
    HPEN oldPen;
    HBRUSH oldBrush;
    POINT *winPoints = ConvertPoints(points, npoints, mode, &rect);

    if ((gc->fill_style == FillStippled
	    || gc->fill_style == FillOpaqueStippled)
	    && gc->stipple != None) {

	TkWinDrawable *twdPtr = (TkWinDrawable *)gc->stipple;
	HDC dcMem;
	LONG width, height;
	HBITMAP oldBitmap;
	int i;
	HBRUSH oldMemBrush;

	if (twdPtr->type != TWD_BITMAP) {
	    Tcl_Panic("unexpected drawable type in stipple");
	}

	/*
	 * Grow the bounding box enough to account for line width.
	 */

	rect.left -= gc->line_width;
	rect.top -= gc->line_width;
	rect.right += gc->line_width;
	rect.bottom += gc->line_width;

	width = rect.right - rect.left;
	height = rect.bottom - rect.top;

	/*
	 * Select stipple pattern into destination dc.
	 */

	SetBrushOrgEx(dc, gc->ts_x_origin, gc->ts_y_origin, NULL);
	oldBrush = SelectObject(dc, CreatePatternBrush(twdPtr->bitmap.handle));

	/*
	 * Create temporary drawing surface containing a copy of the
	 * destination equal in size to the bounding box of the object.
	 */

	dcMem = CreateCompatibleDC(dc);
	oldBitmap = SelectObject(dcMem, CreateCompatibleBitmap(dc, width,
		height));
	oldPen = SelectObject(dcMem, pen);
	BitBlt(dcMem, 0, 0, width, height, dc, rect.left, rect.top, SRCCOPY);

	/*
	 * Translate the object for rendering in the temporary drawing
	 * surface.
	 */

	for (i = 0; i < npoints; i++) {
	    winPoints[i].x -= rect.left;
	    winPoints[i].y -= rect.top;
	}

	/*
	 * Draw the object in the foreground color and copy it to the
	 * destination wherever the pattern is set.
	 */

	SetPolyFillMode(dcMem, (gc->fill_rule == EvenOddRule) ? ALTERNATE
		: WINDING);
	oldMemBrush = SelectObject(dcMem, CreateSolidBrush(gc->foreground));
	(*func)(dcMem, winPoints, npoints);
	BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0, COPYFG);

	/*
	 * If we are rendering an opaque stipple, then draw the polygon in the
	 * background color and copy it to the destination wherever the
	 * pattern is clear.
	 */

	if (gc->fill_style == FillOpaqueStippled) {
	    DeleteObject(SelectObject(dcMem,
		    CreateSolidBrush(gc->background)));
	    (*func)(dcMem, winPoints, npoints);
	    BitBlt(dc, rect.left, rect.top, width, height, dcMem, 0, 0,
		    COPYBG);
	}

	SelectObject(dcMem, oldPen);
	DeleteObject(SelectObject(dcMem, oldMemBrush));
	DeleteObject(SelectObject(dcMem, oldBitmap));
	DeleteDC(dcMem);
    } else {
	oldPen = SelectObject(dc, pen);
	oldBrush = SelectObject(dc, CreateSolidBrush(gc->foreground));
	SetROP2(dc, tkpWinRopModes[gc->function]);

	SetPolyFillMode(dc, (gc->fill_rule == EvenOddRule) ? ALTERNATE
		: WINDING);

	(*func)(dc, winPoints, npoints);

	SelectObject(dc, oldPen);
    }
    DeleteObject(SelectObject(dc, oldBrush));
}
コード例 #23
0
ファイル: VirtualLCD.cpp プロジェクト: BigEd/wp34s
void CVirtualLCD::UpdateScreenContent()
{
/*
#pragma warning(disable : 4996) 
  	  HANDLE h= CreateFile("c:\\polys", GENERIC_WRITE, 0, 0, CREATE_ALWAYS, 0, NULL);
	    for (int i=0; i<400; i++)
	    {
  	    char s[100000]= "";
	      sprintf(s, "POLY=%d,", i);
        for (int p=0; p<table[i].nbPoly; p++)
        {
          strcat(s, "{");
          for (int pt= 0; pt<table[i].poly[p].nbPoints; pt++)
            sprintf(s, "%s%d,%d,", s, table[i].poly[p].points[pt].x, table[i].poly[p].points[pt].y);
          s[strlen(s)-1]='}';
        }
	      sprintf(s, "%s\npoly=%d,", s, i);
        for (int p=0; p<table_LCD[i].nbPoly; p++)
        {
          strcat(s, "{");
          for (int pt= 0; pt<table_LCD[i].poly[p].nbPoints; pt++)
            sprintf(s, "%s%d,%d,", s, table_LCD[i].poly[p].points[pt].x, table_LCD[i].poly[p].points[pt].y);
          s[strlen(s)-1]='}';
        }
        strcat(s, "\n");
        DWORD wrote;
	      WriteFile(h, s, strlen(s), &wrote, NULL);
	    }
	    CloseHandle(h);
	*/
  u64 *e= (u64 *)AT91C_SLCDC_MEM;
  RECT re={0, 0, Skin.HighResScreen.x, Skin.HighResScreen.y};
  FillRect(m_hMemDC, &re, m_hBrushRepaint);

  re.right=Skin.screen.right; re.bottom=Skin.screen.bottom;
  FillRect(m_hMyDC, &re, m_hBrushRepaint);

  SelectObject(m_hMemDC, GetStockObject(DC_PEN));
  SetDCPenColor(m_hMemDC, Skin.screenfore);

  SelectObject(m_hMyDC, GetStockObject(DC_PEN));
  SetDCPenColor(m_hMyDC, Skin.screenfore);

  if (Skin.NbHighResPoly<400 || Skin.NbLowResPoly<400) return;
  SetPolyFillMode(m_hMyDC, WINDING);
  SetPolyFillMode(m_hMemDC, WINDING);
  for (int r=0; r<10; r++)
    for (int c=0; c<40; c++)
      if ((e[r]&((u64)1<<c))!=0)	
      {
        if (Skin.lowres[r*40+c].NbPoly==-1)
        {
          TSourceGraphic *sg= (TSourceGraphic*)&Skin.lowres[r*40+c];
          BitBlt(m_hMyDC, sg->p[0], sg->p[1], sg->p[2], sg->p[3], Skin.dc, sg->p[4], sg->p[5], SRCCOPY);
        } else
          for (int n=0; n<Skin.lowres[r*40+c].NbPoly; n++)
            Polygon(m_hMyDC, Skin.lowres[r*40+c].poly[n].points, Skin.lowres[r*40+c].poly[n].NbPoints);
        if (Skin.highres[r*40+c].NbPoly==-1)
        {
          TSourceGraphic *sg= (TSourceGraphic*)&Skin.highres[r*40+c];
          BitBlt(m_hMemDC, sg->p[0], sg->p[1], sg->p[2], sg->p[3], Skin.dc, sg->p[4], sg->p[5], SRCCOPY);
        } else
          for (int n=0; n<Skin.highres[r*40+c].NbPoly; n++)
            Polygon(m_hMemDC, Skin.highres[r*40+c].poly[n].points, Skin.highres[r*40+c].poly[n].NbPoints);
      }
  HDC hdc= ::GetDC(m_hWnd);
  BitBlt(hdc, 0,0, Skin.screen.right,Skin.screen.bottom, m_hMyDC, 0,0, SRCCOPY);
  ::ReleaseDC(m_hWnd, hdc);
}
コード例 #24
0
ファイル: shaptest.c プロジェクト: GYGit/reactos
void PolygonTest ( HDC hdc )
{
  HPEN Pen, OldPen;
  HBRUSH RedBrush, OldBrush;
  DWORD Mode;
  POINT PointsAlternate[] =
  {
    { 20, 80 },
    { 60, 20 },
    { 90, 80 },
    { 20, 40 },
    { 100, 40 }
  };
  POINT PointsWinding[] =
  {
    { 130, 80 },
    { 170, 20 },
    { 200, 80 },
    { 130, 40 },
    { 210, 40 }
  };
  POINT Tri1[] =
  {
    { 3, 3 },
    { 5, 3 },
    { 3, 5 }
  };
  POINT Tri2[] =
  {
    { 7, 3 },
    { 7, 7 },
    { 3, 7 },
  };
  POINT Square1[] =
  {
    { 1, 15 },
    { 3, 15 },
    { 3, 17 },
    { 1, 17 }
  };
  POINT Square2[] =
  {
    { 5, 15 },
    { 7, 15 },
    { 7, 17 },
    { 5, 17 }
  };
  POINT Square3[] =
  {
    { 1, 23 },
    { 3, 23 },
    { 3, 25 },
    { 1, 25 }
  };
  POINT Square4[] =
  {
    { 5, 23 },
    { 7, 23 },
    { 7, 25 },
    { 5, 25 }
  };
  POINT Square5[] =
  {
    { 1, 31 },
    { 3, 31 },
    { 3, 33 },
    { 1, 33 }
  };
  POINT Square6[] =
  {
    { 5, 31 },
    { 7, 31 },
    { 7, 33 },
    { 5, 33 }
  };

  //create a pen to draw the shape
  Pen = CreatePen(PS_SOLID, 1, RGB(0, 0, 0xff));
  ASSERT(Pen);
  RedBrush = CreateSolidBrush(RGB(0xff, 0, 0));
  ASSERT(RedBrush);

  OldPen = (HPEN)SelectObject(hdc, Pen);
  OldBrush = (HBRUSH)SelectObject(hdc, RedBrush);

  Mode = GetPolyFillMode(hdc);

  RoundRect ( hdc, 32, 8, 48, 24, 8, 8 );

  SetPolyFillMode(hdc, ALTERNATE);
  Polygon(hdc,PointsAlternate,nelem(PointsAlternate));

  SetPolyFillMode(hdc, WINDING);
  Polygon(hdc,PointsWinding,nelem(PointsWinding));

  Rectangle ( hdc, 1, 1, 10, 10 );
  Polygon(hdc,Tri1,nelem(Tri1));
  Polygon(hdc,Tri2,nelem(Tri2));

  Rectangle ( hdc,  1, 11,  4, 14 );
  Rectangle ( hdc,  5, 11,  8, 14 );
  Rectangle ( hdc,  9, 11, 12, 14 );
  Rectangle ( hdc, 13, 11, 16, 14 );
  Polygon(hdc,Square1,nelem(Square1));
  Polygon(hdc,Square2,nelem(Square2));
  Rectangle ( hdc,  1, 19,  4, 22 );
  Rectangle ( hdc,  5, 19,  8, 22 );
  Rectangle ( hdc,  9, 19, 12, 22 );
  Rectangle ( hdc, 13, 19, 16, 22 );
  Polygon(hdc,Square3,nelem(Square3));
  Polygon(hdc,Square4,nelem(Square4));
  Rectangle ( hdc,  1, 27,  4, 30 );
  Rectangle ( hdc,  5, 27,  8, 30 );
  Rectangle ( hdc,  9, 27, 12, 30 );
  Rectangle ( hdc, 13, 27, 16, 30 );

  // switch to null pen to make surey they display correctly
  DeleteObject ( SelectObject(hdc, OldPen) );
  Pen = CreatePen ( PS_NULL, 0, 0 );
  ASSERT(Pen);
  OldPen = (HPEN)SelectObject(hdc, Pen);

  Polygon(hdc,Square5,nelem(Square5));
  Polygon(hdc,Square6,nelem(Square6));
  Rectangle ( hdc,  1, 35,  4, 38 );
  Rectangle ( hdc,  5, 35,  8, 38 );
  Rectangle ( hdc,  9, 35, 12, 38 );
  Rectangle ( hdc, 13, 35, 16, 38 );

  //cleanup
  SetPolyFillMode(hdc, Mode);
  DeleteObject ( SelectObject(hdc, OldPen) );
  DeleteObject ( SelectObject(hdc, OldBrush) );
}