Exemplo n.º 1
5
void portal::SeekEndRoom( entityid p_room )
{
    BeginPath();
    while( IsValidPath() )
    {
        // exit out when you find a match
        if( CurrentEnd() == p_room )
            return;
        NextPath();
    }
}
Exemplo n.º 2
0
Arquivo: path.c Projeto: mikekap/wine
static void test_closefigure(void) {
    int nSize, nSizeWitness;
    HDC hdc = GetDC(0);

    BeginPath(hdc);
    MoveToEx(hdc, 95, 95, NULL);
    LineTo(hdc, 95,  0);
    LineTo(hdc,  0, 95);

    CloseFigure(hdc);
    EndPath(hdc);
    nSize = GetPath(hdc, NULL, NULL, 0);

    AbortPath(hdc);

    BeginPath(hdc);
    MoveToEx(hdc, 95, 95, NULL);
    LineTo(hdc, 95,  0);
    LineTo(hdc,  0, 95);

    EndPath(hdc);
    nSizeWitness = GetPath(hdc, NULL, NULL, 0);

    /* This test shows CloseFigure does not have to add a point at the end of the path */
    ok(nSize == nSizeWitness, "Wrong number of points, no point should be added by CloseFigure\n");

    ReleaseDC(0, hdc);
}
Exemplo n.º 3
0
int DrawSysButtonFrame(HDC hdc, RECT *pRect, COLORREF clrBorder, COLORREF clrBack, HRGN* hRgns)
{
    HBRUSH hBackBrush;
    HBRUSH hBorderBrush;
    HRGN hRgn;
    int width = pRect->right - pRect->left;
    POINT prt[2][4] = {
{{pRect->left, pRect->top},    {pRect->left + width*0.31, pRect->top},    {pRect->left + width*0.62, pRect->top},    {pRect->right, pRect->top}},
{{pRect->left, pRect->bottom}, {pRect->left + width*0.31, pRect->bottom}, {pRect->left + width*0.62, pRect->bottom}, {pRect->right, pRect->bottom}}
        };
    int radius = 3;

    hBorderBrush = CreateSolidBrush(clrBorder);
    //hBorderBrush = GetSysColorBrush(COLOR_3DSHADOW);
    hBackBrush = CreateSolidBrush (clrBack);

    MoveToEx(hdc, prt[0][0].x, prt[0][0].y, NULL);
    BeginPath(hdc);
    LineTo(hdc, prt[1][0].x, prt[1][0].y - radius);
    AngleArc(hdc, prt[1][0].x + radius, prt[1][0].y - radius,
            radius,180, 90);
    LineTo(hdc, prt[1][1].x, prt[1][1].y);
    LineTo(hdc, prt[0][1].x, prt[0][1].y);
    CloseFigure(hdc);
    EndPath(hdc);
    hRgn = PathToRegion(hdc);
    FillRgn(hdc, hRgn, hBackBrush);
    FrameRgn(hdc, hRgn, hBorderBrush, 1, 1);
    hRgns[0] = hRgn;

    MoveToEx(hdc, prt[0][1].x, prt[0][1].y, NULL);
    BeginPath(hdc);
    LineTo(hdc, prt[1][1].x, prt[1][1].y);
    LineTo(hdc, prt[1][2].x, prt[1][2].y);
    LineTo(hdc, prt[0][2].x, prt[0][2].y);
    CloseFigure(hdc);
    EndPath(hdc);
    hRgn = PathToRegion(hdc);
    FillRgn(hdc, hRgn, hBackBrush);
    FrameRgn(hdc, hRgn, hBorderBrush, 1, 1);
    hRgns[1] = hRgn;

    MoveToEx(hdc, prt[0][2].x, prt[0][2].y, NULL);
    BeginPath(hdc);
    LineTo(hdc, prt[1][2].x, prt[1][2].y);
    LineTo(hdc, prt[1][3].x - radius, prt[1][3].y);
    AngleArc(hdc, prt[1][3].x - radius, prt[1][3].y - radius,
            radius,270, 90);
    LineTo(hdc, prt[0][3].x, prt[0][3].y);
    CloseFigure(hdc);
    EndPath(hdc);
    hRgn = PathToRegion(hdc);
    FillRgn(hdc, hRgn, hBackBrush);
    FrameRgn(hdc, hRgn, hBorderBrush, 1, 1);
    hRgns[2] = hRgn;
    
    //DeleteObject(hBorderBrush);    
    DeleteObject(hBackBrush);
    return 0;
}
Exemplo n.º 4
0
void iupDrawArc(IdrawCanvas* dc, int x1, int y1, int x2, int y2, double a1, double a2, unsigned char r, unsigned char g, unsigned char b, int style)
{
  int XStartArc = winDrawCalcArc(x1, x2, a1, 1);
  int XEndArc = winDrawCalcArc(x1, x2, a2, 0);
  int YStartArc = winDrawCalcArc(y1, y2, a1, 1);
  int YEndArc = winDrawCalcArc(y1, y2, a2, 0);

  if (style==IUP_DRAW_FILL)
  {
    HBRUSH hBrush = CreateSolidBrush(RGB(r,g,b));
    HPEN hBrushOld = SelectObject(dc->hBitmapDC, hBrush); 
    BeginPath(dc->hBitmapDC); 
    Pie(dc->hBitmapDC, x1, y1, x2+1, y2+1, XStartArc, YStartArc, XEndArc, YEndArc);
    EndPath(dc->hBitmapDC);
    FillPath(dc->hBitmapDC);
    SelectObject(dc->hBitmapDC, hBrushOld);
    DeleteObject(hBrush);
  }
  else
  {
    HPEN hPen = CreatePen(style==IUP_DRAW_STROKE_DASH? PS_DASH: PS_SOLID, 1, RGB(r, g, b));
    HPEN hPenOld = SelectObject(dc->hBitmapDC, hPen);
    Arc(dc->hBitmapDC, x1, y1, x2+1, y2+1, XStartArc, YStartArc, XEndArc, YEndArc);
    SelectObject(dc->hBitmapDC, hPenOld);
    DeleteObject(hPen);
  }
}
Exemplo n.º 5
0
HRGN DrawCloseButton(HDC hdc, const int x, const int y, 
    COLORREF clrBorder, COLORREF clrBack )
{
    HGDIOBJ hPen = NULL;
    HGDIOBJ hOldPen; 
    HBRUSH hBrush = NULL;
    HBRUSH hOldBrush;

    hPen = CreatePen(PS_SOLID, 2, clrBorder);
    hOldPen = SelectObject(hdc, hPen); 

    hBrush = CreateSolidBrush (clrBack);
    hOldBrush = (HBRUSH__*)SelectObject(hdc, hBrush);

    BeginPath(hdc);
    AngleArc(hdc, x , y, 6, 0, 360);
    EndPath(hdc);
    HRGN hRgn = PathToRegion(hdc);
    FillRgn(hdc, hRgn, hBrush);
    
    DrawLine(hdc, x - 4, y - 4, 
                  x + 4, y + 4);
    DrawLine(hdc, x - 4, y + 4,
                  x + 4, y - 4);
    
    SelectObject(hdc, hOldPen);
    DeleteObject(hPen);
    DeleteObject(hBrush);
    return hRgn;
}
Exemplo n.º 6
0
void TJerFile::GetRelativePath(const char *BeginDir,const char *Path,char **TheRelativePath)
{
	BPath BeginPath(BeginDir);
	BPath PathPath(Path);
	string Begin(BeginPath.Path());
	string Chemin(PathPath.Path());
	string RelativePathBuffer("");
	string RelativePath("");
	int indSav;
	for (uint32 ind=Begin.length();ind<Chemin.length();ind++)
	{
		RelativePathBuffer = RelativePathBuffer + Chemin[ind];
	}
	for (int ind=RelativePathBuffer.length()-1;ind>=0;ind--)
	{
		if (RelativePathBuffer[ind]=='/')
		{
			indSav = ind;
			break;
		}
	}
	for (int ind=0;ind<indSav;ind++)
	{
		RelativePath = RelativePath + RelativePathBuffer[ind];
	}
	*TheRelativePath = (char *)malloc(sizeof(char)*(RelativePath.length()+1));
	strcpy(*TheRelativePath,RelativePath.c_str());
}
Exemplo n.º 7
0
void __fastcall TExtPolyline::CreatePath(void *dc)
{
BeginPath(dc);
void *oldpen=SelectObject(dc,GetStockObject(BLACK_PEN));
int i=0;
if (Count>2)
    {
    if (Codes[0].Connection()==2)
        i=2;
    else if (Codes[Count-1].Connection()==2)
        i=1;
    int p1=(i+Count-1)%Count;
    MoveToEx(dc,Points[p1].x,Points[p1].y,NULL);
    for (;i<Count;i++)
        {
        int n1=(i+1)%Count;
        if (Codes[i].Connection()==1)
            DrawArcSeg(dc,i);
        else if (Codes[n1].Connection()==2)
            {
            DrawBezierSeg(dc,n1);
            i+=2;
            }
        else
            LineTo(dc,Points[i].x,Points[i].y);
        }
    }
else
    {
    Polyline(dc,Points,Count);
    }
EndPath(dc);
SelectObject(dc,oldpen);
}
Exemplo n.º 8
0
void PaintRoutine (HWND hwnd, HDC hdc, int cxArea, int cyArea)
{
     static TCHAR szString [] = TEXT ("Filling") ;
     HFONT        hFont ;
     SIZE         size ;

     hFont = EzCreateFont (hdc, TEXT ("Times New Roman"), 1440, 0, 0, TRUE) ;

     SelectObject (hdc, hFont) ;
     SetBkMode (hdc, TRANSPARENT) ;

     GetTextExtentPoint32 (hdc, szString, lstrlen (szString), &size) ;

     BeginPath (hdc) ;
     TextOut (hdc, (cxArea - size.cx) / 2, (cyArea - size.cy) / 2,
                    szString, lstrlen (szString)) ;
     EndPath (hdc) ;

     SelectObject (hdc, CreateHatchBrush (HS_DIAGCROSS, RGB (255, 0, 0))) ;
     SetBkColor (hdc, RGB (0, 0, 255)) ;
     SetBkMode (hdc, OPAQUE) ;

     StrokeAndFillPath (hdc) ;

     DeleteObject (SelectObject (hdc, GetStockObject (WHITE_BRUSH))) ;
     SelectObject (hdc, GetStockObject (SYSTEM_FONT)) ;
     DeleteObject (hFont) ;
}
Exemplo n.º 9
0
void elli (COORDS figure, HDC hdc) {
	BeginPath (hdc);
	Ellipse (
		hdc,
		int (figure.xStart), int (figure.yStart),
		int (figure.xFinal), int (figure.yFinal));
	EndPath (hdc);
}
Exemplo n.º 10
0
void GDITest(void)
{
	ENUMLOGFONTEXW enumlog;
	EXTLOGFONTW extlog;
	
	memset(& enumlog, 0, sizeof(enumlog));
	memset(& extlog, 0, sizeof(extlog));

	int j = sizeof(enumlog);
	int k = sizeof(extlog);
	
	for (int i=0; i<sizeof(FIXARRAY)/sizeof(long); i++)
	{
		char t[20];

		long v = FIXARRAY[i];

		if ( v >= 0)
			t[0] = '+';
		else
		{
			t[0] = '-';
			v = - v;
		}

		sprintf(t+1, "%d + %d/16\n", v/16, v%16);
		OutputDebugString(t);
	}

	HDC hDC = GetDC(NULL);
	
	HBITMAP bmp1 = CreateBitmap(100, 100, 1, 1, NULL);
	HBITMAP bmp2 = CreateBitmap(100, 100, 1, 4, NULL);
	HBITMAP bmp3 = CreateBitmap(100, 100, 1, 8, NULL);
	HBITMAP bmp4 = CreateBitmap(100, 100, 3, 8, NULL);
	HBITMAP bmp5 = CreateBitmap(100, 100, 1, 24, NULL);

	void * dibbits;

	HBITMAP bmp6 = CreateDIBSection(hDC, (BITMAPINFO *) & dib, 
					    DIB_RGB_COLORS, & dibbits, NULL, 0);

	BeginPath(hDC);
	MoveToEx(hDC, 100, 100, NULL);
	LineTo(hDC, 150, 150);
	PolyBezierTo(hDC, & Points[0], 3);
	CloseFigure(hDC);
	Ellipse(hDC, -100, -100, 100, 100);
	EndPath(hDC);
	POINT points[20];
	BYTE  types[20];

	int n = GetPath(hDC, NULL, NULL, 0);
	n = GetPath(hDC, points, types, min(n, 20));

	SetBitmapDimensionEx(bmp1, 10000, 10000, NULL);
}
Exemplo n.º 11
0
int client_BeginPath(const int pdcID) {
    HDC pdc = printerDCs[pdcID];
    if (pdc != NULL) {
        if (BeginPath(pdc)) {
            return JNI_TRUE;
        }
    }
    return JNI_FALSE;
}
Exemplo n.º 12
0
void roundRect (COORDS figure, HDC hdc) {
	BeginPath (hdc);
	RoundRect (
		hdc,
		int (figure.xStart), int (figure.yStart),
		int (figure.xFinal), int (figure.yFinal),
		figure.wRound, figure.hRound);
	EndPath (hdc);
}
Exemplo n.º 13
0
void circ (COORDS figure, HDC hdc) {
	BeginPath (hdc);
	Arc (
		hdc,
		int (figure.xAxis - figure.radius), int (figure.yAxis - figure.radius),
		int (figure.xAxis + figure.radius), int (figure.yAxis + figure.radius),
		int (figure.xAxis - figure.radius), int (figure.yAxis - figure.radius),
		int (figure.xAxis - figure.radius), int (figure.yAxis - figure.radius));
	EndPath (hdc);
}
Exemplo n.º 14
0
void rect (COORDS figure, HDC hdc) {
	BeginPath (hdc);
	MoveToEx (hdc, int (figure.xStart), int (figure.yStart), NULL);

	LineTo (hdc, int (figure.xStart), int (figure.yFinal));
	LineTo (hdc, int (figure.xFinal), int (figure.yFinal));
	LineTo (hdc, int (figure.xFinal), int (figure.yStart));
	LineTo (hdc, int (figure.xStart), int (figure.yStart));

	EndPath (hdc);
}
Exemplo n.º 15
0
void TJerFile::GetRelativePathAndName(const char *BeginDir,const char *Path,char **TheRelativePathAndName)
{
	BPath BeginPath(BeginDir);
	BPath PathPath(Path);
	string Begin(BeginPath.Path());
	string Chemin(PathPath.Path());
	string RelativePathBuffer("");
	string RelativePath("");
	for (uint32 ind=Begin.length();ind<Chemin.length();ind++)
	{
		RelativePathBuffer = RelativePathBuffer + Chemin[ind];
	}
	*TheRelativePathAndName = (char *)malloc(sizeof(char)*(RelativePathBuffer.length()+1));
	strcpy(*TheRelativePathAndName,RelativePathBuffer.c_str());
}
Exemplo n.º 16
0
Arquivo: path.c Projeto: mikekap/wine
static void test_polydraw(void)
{
    BOOL retb;
    HDC hdc = GetDC(0);
    BeginPath(hdc);

    /* closefigure with no previous moveto */
    if (!(retb = PolyDraw(hdc, polydraw_pts, polydraw_tps, 2)) &&
        GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
    {
        /* PolyDraw is only available on Win2k and later */
        win_skip("PolyDraw is not available\n");
        goto done;
    }
    expect(TRUE, retb);

    MoveToEx(hdc, 100, 100, NULL);
    LineTo(hdc, 95, 95);
    /* closefigure with previous moveto */
    retb = PolyDraw(hdc, polydraw_pts, polydraw_tps, 2);
    expect(TRUE, retb);
    /* bad bezier points */
    retb = PolyDraw(hdc, &(polydraw_pts[2]), &(polydraw_tps[2]), 4);
    expect(FALSE, retb);
    retb = PolyDraw(hdc, &(polydraw_pts[6]), &(polydraw_tps[6]), 4);
    expect(FALSE, retb);
    /* good bezier points */
    retb = PolyDraw(hdc, &(polydraw_pts[8]), &(polydraw_tps[8]), 4);
    expect(TRUE, retb);
    /* does lineto or bezierto take precedence? */
    retb = PolyDraw(hdc, &(polydraw_pts[12]), &(polydraw_tps[12]), 4);
    expect(FALSE, retb);
    /* bad point type, has already moved cursor position */
    retb = PolyDraw(hdc, &(polydraw_pts[15]), &(polydraw_tps[15]), 4);
    expect(FALSE, retb);
    /* bad point type, cursor position is moved, but back to its original spot */
    retb = PolyDraw(hdc, &(polydraw_pts[17]), &(polydraw_tps[17]), 4);
    expect(FALSE, retb);
    /* does lineto or moveto take precedence? */
    retb = PolyDraw(hdc, &(polydraw_pts[20]), &(polydraw_tps[20]), 3);
    expect(TRUE, retb);

    EndPath(hdc);
    ok_path(hdc, "polydraw_path", polydraw_path, sizeof(polydraw_path)/sizeof(path_test_t), 0);
done:
    ReleaseDC(0, hdc);
}
Exemplo n.º 17
0
void CHTMLContainerDlg::SetWindowEllispeFrame(int nWidthEllipse, int nHeightEllipse)
{
	HDC hdc = ::GetDC(m_hWnd);
	HDC hdcMem = CreateCompatibleDC(hdc);
	::ReleaseDC(m_hWnd, hdc);

	RECT rect;
	GetWindowRect(&rect);

	// 画一个圆角矩形。
	BeginPath(hdcMem);
	RoundRect(hdcMem, 0, 0, rect.right - rect.left, rect.bottom - rect.top, nWidthEllipse, nHeightEllipse); 
	EndPath(hdcMem);

	HRGN hRgn = PathToRegion(hdcMem); // 最后把路径转换为区域。

	SetWindowRgn(hRgn, TRUE);
}
Exemplo n.º 18
0
Arquivo: path.c Projeto: mikekap/wine
static void test_anglearc(void)
{
    HDC hdc = GetDC(0);
    BeginPath(hdc);
    if (!AngleArc(hdc, 300, 300, 100, 45.0, 135.0) &&
        GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
    {
        /* AngleArc is only available on Win2k and later */
        win_skip("AngleArc is not available\n");
        goto done;
    }
    AngleArc(hdc, 300, 300, 80, 150.0, -180.0);
    CloseFigure(hdc);
    EndPath(hdc);

    ok_path(hdc, "anglearc_path", anglearc_path, sizeof(anglearc_path)/sizeof(path_test_t), 0);
done:
    ReleaseDC(0, hdc);
}
Exemplo n.º 19
0
static PetscErrorCode PetscDrawTriangle_Win32(PetscDraw draw,PetscReal x1,PetscReal yone,PetscReal x2,PetscReal y2,
			      PetscReal x3,PetscReal y3,int c1,int c2,int c3)
{       
  PetscDraw_Win32 *windraw = (PetscDraw_Win32*)draw->data;
  HBRUSH          hbrush;
  HPEN            hpen;
  int             p1x,p1y,p2x,p2y,p3x,p3y;
  HDC             bit;
  
  PetscFunctionBegin;
  AverageColorTriangle_Win32(draw,c1,c2,c3); 
  hbrush = CreateSolidBrush(windraw->currentcolor);
  hpen   = CreatePen(PS_SOLID,0,windraw->currentcolor);
  p1x = XTRANS(draw,windraw,x1);
  p2x = XTRANS(draw,windraw,x2);
  p3x = XTRANS(draw,windraw,x3);
  p1y = YTRANS(draw,windraw,yone);
  p2y = YTRANS(draw,windraw,y2);
  p3y = YTRANS(draw,windraw,y3);
  
  if(windraw->node->DoubleBuffered) {
    bit = windraw->node->DoubleBuffer;
  } else {
    bit = windraw->node->Buffer;
  }
  BeginPath(bit);
  MoveToEx(bit,p1x,p1y,NULL);
  LineTo(bit,p2x,p2y);
  LineTo(bit,p3x,p3y);
  LineTo(bit,p1x,p1y);
  EndPath(bit);
  SelectPen(bit,hpen);
  SelectBrush(bit,hbrush);
  StrokeAndFillPath(bit);
  /* Forces a WM_PAINT message and erases background */
  InvalidateRect(windraw->hWnd,NULL,TRUE);
  UpdateWindow(windraw->hWnd);
  PetscFunctionReturn(0);
}
Exemplo n.º 20
0
Arquivo: path.c Projeto: mikekap/wine
static void test_arcto(void)
{
    HDC hdc = GetDC(0);

    BeginPath(hdc);
    SetArcDirection(hdc, AD_CLOCKWISE);
    if (!ArcTo(hdc, 200, 200, 400, 300, 200, 200, 400, 300) &&
        GetLastError() == ERROR_CALL_NOT_IMPLEMENTED)
    {
        /* ArcTo is only available on Win2k and later */
        win_skip("ArcTo is not available\n");
        goto done;
    }
    SetArcDirection(hdc, AD_COUNTERCLOCKWISE);
    ArcTo(hdc, 210, 210, 390, 290, 390, 290, 210, 210);
    CloseFigure(hdc);
    EndPath(hdc);

    ok_path(hdc, "arcto_path", arcto_path, sizeof(arcto_path)/sizeof(path_test_t), 0);
done:
    ReleaseDC(0, hdc);
}
Exemplo n.º 21
0
void iupDrawPolygon(IdrawCanvas* dc, int* points, int count, unsigned char r, unsigned char g, unsigned char b, int style)
{
  if (style==IUP_DRAW_FILL)
  {
    HBRUSH hBrush = CreateSolidBrush(RGB(r,g,b));
    HPEN hBrushOld = SelectObject(dc->hBitmapDC, hBrush); 
    BeginPath(dc->hBitmapDC); 
    Polygon(dc->hBitmapDC, (POINT*)points, count);
    EndPath(dc->hBitmapDC);
    FillPath(dc->hBitmapDC);
    SelectObject(dc->hBitmapDC, hBrushOld);
    DeleteObject(hBrush);
  }
  else
  {
    HPEN hPen = CreatePen(style==IUP_DRAW_STROKE_DASH? PS_DASH: PS_SOLID, 1, RGB(r, g, b));
    HPEN hPenOld = SelectObject(dc->hBitmapDC, hPen);
    Polyline(dc->hBitmapDC, (POINT*)points, count);
    SelectObject(dc->hBitmapDC, hPenOld);
    DeleteObject(hPen);
  }
}
Exemplo n.º 22
0
void PaintRoutine (HWND hwnd, HDC hdc, int cxArea, int cyArea)
{
     static TCHAR szString [] = TEXT ("Outline") ;
     HFONT        hFont ;
     SIZE         size ;

     hFont = EzCreateFont (hdc, TEXT ("Times New Roman"), 1440, 0, 0, TRUE) ;

     SelectObject (hdc, hFont) ;

     GetTextExtentPoint32 (hdc, szString, lstrlen (szString), &size) ;

     BeginPath (hdc) ;
     TextOut (hdc, (cxArea - size.cx) / 2, (cyArea - size.cy) / 2,
                    szString, lstrlen (szString)) ;
     EndPath (hdc) ;

     StrokePath (hdc) ;

     SelectObject (hdc, GetStockObject (SYSTEM_FONT)) ;
     DeleteObject (hFont) ;
}
Exemplo n.º 23
0
	GlyphPath* GlyphPathCache::Create(HDC hDC, const FontWrapper* f, WCHAR c)
	{
		CStringW key = CStringW((LPCWSTR)*f) + c;

		GlyphPath* path = NULL;

		if(m_key2obj.Lookup(key, path)) {
			return path;
		}

		BeginPath(hDC);
		TextOutW(hDC, 0, 0, &c, 1);
		CloseFigure(hDC);
		if(!EndPath(hDC)) {
			AbortPath(hDC);
			ASSERT(0);
			return NULL;
		}

		path = DNew GlyphPath();

		int count = GetPath(hDC, NULL, NULL, 0);

		if(count > 0) {
			path->points.SetCount(count);
			path->types.SetCount(count);

			if(count != GetPath(hDC, path->points.GetData(), path->types.GetData(), count)) {
				ASSERT(0);
				delete path;
				return NULL;
			}
		}

		Add(key, path);

		return path;
	}
Exemplo n.º 24
0
PHP_METHOD(WinGdiPath, __construct)
{
    wingdi_path_object *path_obj = zend_object_store_get_object(getThis() TSRMLS_CC);
    wingdi_devicecontext_object *dc_obj;
    zval *dc_zval;
    BOOL result;

    WINGDI_ERROR_HANDLING();
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &dc_zval) == FAILURE)
        return;
    WINGDI_RESTORE_ERRORS();

    dc_obj = zend_object_store_get_object(dc_zval TSRMLS_CC);
    result = BeginPath(dc_obj->hdc);
    // Is this the correct way to handle this error?
    if (result == 0)
        zend_throw_exception(ce_wingdi_exception, "error creating path", 0 TSRMLS_CC);

    path_obj->device_context = dc_zval;
    path_obj->constructed    = 1;

    Z_ADDREF_P(dc_zval);
}
Exemplo n.º 25
0
HRGN DrawChromeFrame(HDC hdc, RECT *pRect, COLORREF clrBorder, COLORREF clrBack)
{
    HBRUSH hBackBrush = NULL;
    HBRUSH hBorderBrush;
    HRGN hRgn;

    hBorderBrush = CreateSolidBrush(clrBorder);
    hBackBrush = CreateSolidBrush (clrBack);

    POINT lpts[4], rpts[4];
    int spread, eigth, sixth, quarter;
    int width = pRect->right - pRect->left;
    int height = pRect->bottom - pRect->top;

    if (1){//bottom
        spread = ((float)height) * 2/3;
        eigth = ((float)height) * 1/8;
        sixth = ((float)height) * 1/6;
        quarter = ((float)height) * 1/4;    
    }else{
        spread = ((float)width) * 2/3;
        eigth = ((float)width) * 1/8;
        sixth = ((float)width) * 1/6;
        quarter = ((float)width) * 1/4;
    }
    
    pRect->right += spread;
    
    lpts[3].x = pRect->left;                     lpts[3].y = pRect->bottom;
	lpts[2].x = pRect->left + sixth;             lpts[2].y = pRect->bottom - eigth;
	lpts[1].x = pRect->left + spread - quarter;  lpts[1].y = pRect->top + eigth;
	lpts[0].x = pRect->left + spread;            lpts[0].y = pRect->top;

    rpts[3].x = pRect->right - spread;           rpts[3].y = pRect->top;
	rpts[2].x = pRect->right - spread + quarter; rpts[2].y = pRect->top + eigth;
	rpts[1].x = pRect->right - sixth;            rpts[1].y = pRect->bottom - eigth;
	rpts[0].x = pRect->right;                    rpts[0].y = pRect->bottom;
    MoveToEx(hdc, lpts[3].x, lpts[3].y, NULL);
    BeginPath(hdc);
    
    PolyBezier(hdc, lpts, sizeof(lpts)/sizeof(POINT));
    
    //MoveToEx(hdc, lpts[0].x, lpts[0].y, NULL);
	LineTo(hdc, rpts[3].x, rpts[3].y);
    
    PolyBezier(hdc, rpts, sizeof(rpts)/sizeof(POINT));
    
    //MoveToEx(hdc, rpts[0].x, rpts[0].y, NULL);
    LineTo(hdc, lpts[3].x, lpts[3].y);

    CloseFigure(hdc);
    EndPath(hdc);
    //StrokePath (hdc);
    FlattenPath(hdc);
    hRgn = PathToRegion(hdc);
    FillRgn(hdc, hRgn, hBackBrush);
    FrameRgn(hdc, hRgn, hBorderBrush, 1, 1);

    DeleteObject(hBorderBrush);    
    DeleteObject(hBackBrush);

    HGDIOBJ hPen = NULL;
    HGDIOBJ hOldPen; 

    hPen = CreatePen(PS_SOLID, 2, clrBack);
    hOldPen = SelectObject(hdc, hPen);

    DrawLine(hdc, rpts[0].x, rpts[0].y, 
                  lpts[3].x, lpts[3].y);

    SelectObject(hdc, hOldPen);
    DeleteObject(hPen);

    pRect->left += spread;
    pRect->right -= spread;
    return hRgn;
}
Exemplo n.º 26
0
//
// InitWindowRegion
//
// We display the video in a window that has a region selected into it that
// matches the word we are passed in. By doing this we let Windows manage
// all the clipping and mouse technology. The trick is in creating a region
// that matches the word, which is done by using paths. We create a path for
// a temporary HDC, draw the word and then end the path. After that, we can then
// ask Windows for a region that describes that path. That gives us a region
// for the outside of the word, so we bitwise "not" it to get the word region.
//
HRESULT CVideoText::InitWindowRegion(TCHAR *pStringName)
{
    ASSERT(pStringName);

    OSVERSIONINFO VersionInfo;
    VersionInfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
    EXECUTE_ASSERT(GetVersionEx(&VersionInfo));

    // Set a window region according to the OS capabilities

    if ((VersionInfo.dwPlatformId & VER_PLATFORM_WIN32_NT) == 0) 
    {
        m_Size.cx = 320;
        m_Size.cy = 240;
        return NOERROR;
    }

    // Get the text extents the word passed in will require based on the
    // font and bitmap selected in the current device context. For it to
    // be displayed in a different font it must be selected into the HDC

    HDC hdc = CreateCompatibleDC(m_hdc);
    HFONT hFont = CreateVideoFont();
    SelectObject(hdc,hFont);

    GetTextExtentPoint32((HDC) hdc,             // The output device context
                         pStringName,           // The string we'll be using
                         lstrlen(pStringName),  // Number of characters in it
                         (LPSIZE) &m_Size);     // Filled in with the extents

    // Create a bitmap that matches the current format

    HBITMAP hMaskBitmap = CreateCompatibleBitmap(hdc,m_Size.cx,m_Size.cy);
    if (hMaskBitmap == NULL) {
        ASSERT(hMaskBitmap);
        return E_UNEXPECTED;
    }

    // Select the monochrome bitmap into the device context

    HBITMAP hBitmap = (HBITMAP) SelectObject(hdc,hMaskBitmap);
    EXECUTE_ASSERT(BeginPath(hdc));

    // Draw the string into the monochrome bitmap

    ExtTextOut((HDC) hdc,               // Target device context
               (int) 0,                 // x coordinate reference
               (int) 0,                 // Likewise y coordinate
               (DWORD) 0,               // No special flags to set
               NULL,                    // No clipping rectangle
               pStringName,             // Pointer to text words
               lstrlen(pStringName),    // Number of characters
               NULL);                   // Intercharacter spacing

    EXECUTE_ASSERT(EndPath(hdc));

    HRGN hOutside = PathToRegion(hdc);
    HRGN hFullWindow = CreateRectRgn(0,0,m_Size.cx,m_Size.cy);
    HRGN hWordRegion = CreateRectRgn(0,0,1,1);
    CombineRgn(hWordRegion,hFullWindow,hOutside,RGN_DIFF);
    SetWindowRgn(m_hwnd,hWordRegion,TRUE);

    // Clear up the regions we created

    DeleteObject(hWordRegion);
    DeleteObject(hOutside);
    DeleteObject(hFullWindow);

    // Delete the HDC and text bitmap

    SelectObject(hdc,hBitmap);
    HFONT hDefault = (HFONT) GetStockObject(SYSTEM_FONT);
    SelectObject(hdc,hDefault);

    DeleteObject(hFont);
    DeleteObject(hMaskBitmap);
    DeleteDC(hdc);

    return NOERROR;

} // InitWindowRegion
Exemplo n.º 27
0
 void GdiContext2D::beginPath()
 {
     Check();
     BeginPath(m_hDC);
 }
Exemplo n.º 28
0
LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam,
   LPARAM lParam)
{
   switch (msg)
   {
      case WM_CREATE:
      {
         INITCOMMONCONTROLSEX icx;
         icx.dwSize = sizeof(INITCOMMONCONTROLSEX);
         icx.dwICC = ICC_BAR_CLASSES;

         InitCommonControlsEx(&icx);

         hTrackBar =
            CreateWindow(
               TRACKBAR_CLASS, "",
               TBS_HORZ | TBS_BOTH | TBS_AUTOTICKS |
               TBS_FIXEDLENGTH | TBS_ENABLESELRANGE |
               WS_CHILD | WS_VISIBLE,
               10, 260, 375, 40,
               hWnd, NULL, hInst, NULL
               );

         assert(hTrackBar != NULL);
         SNDMSG(hTrackBar, TBM_SETTHUMBLENGTH, 20, 0);
         SNDMSG(hTrackBar, TBM_SETRANGEMAX, TRUE, 100);

         // create the TrueType (scalable) font
         HDC hDC = GetDC(hWnd);
         try
         {
            // see Chapter 4 for the definition of MakeFont
            hTTFont = font::MakeFont(hDC, "Impact", 72);
            if (!hTTFont) throw;
         }
         catch (...)
         {
            ReleaseDC(hWnd, hDC);
         }
         ReleaseDC(hWnd, hDC);
         break;
      }
      case WM_HSCROLL:
      {
         if (reinterpret_cast<HWND>(lParam) == hTrackBar)
         {
            //
            // adjust the scaling factor according to
            // the position of the trackbar's slider
            //
            scale = static_cast<double>(
               (SNDMSG(hTrackBar, TBM_GETPOS, 0, 0) + 1) / 50.0
               );
            InvalidateRect(hWnd, NULL, true);
         }
         break;
      }
      case WM_ERASEBKGND:
      {
         LRESULT res = DefWindowProc(hWnd, msg, wParam, lParam);

         HDC hDC = reinterpret_cast<HDC>(wParam);
         HFONT hOldFont = static_cast<HFONT>(
            SelectObject(hDC, hTTFont)
            );
         try
         {
            SetBkMode(hDC, TRANSPARENT);

            // open a path bracket
            if (!BeginPath(hDC)) throw;

            // record the text to the path
            TextOut(hDC, 10, 10, pText, lstrlen(pText));

            // close the path bracket and
            // select the path into hDC
            EndPath(hDC);

            // determine the number of endpoints in the path
            const int num_points = GetPath(hDC, NULL, NULL, 0);
            if (num_points > 0)
            {
               // make room for the POINTs and vertex types
               POINT* pPEnds = new POINT[num_points];
               unsigned char* pTypes = new unsigned char[num_points];
               try
               {
                  // get the path's description
                  int num_got = GetPath(hDC, pPEnds, pTypes, num_points);
                  if (num_got > 0)
                  {
                     // start a new path bracket
                     if (!BeginPath(hDC)) throw;

                     // scale each point in the description
                     int iPoint;
                     for (iPoint = 0; iPoint < num_got; ++iPoint)
                     {
                        pPEnds[iPoint].x = static_cast<LONG>(
                           scale * pPEnds[iPoint].x + 0.5
                           );
                        pPEnds[iPoint].y = static_cast<LONG>(
                           scale * pPEnds[iPoint].y + 0.5
                           );
                     }

                     for (iPoint = 0; iPoint < num_points; ++iPoint)
                     {
                        // handle the MoveToEx case
                        if (pTypes[iPoint] == PT_MOVETO)
                        {
                           MoveToEx(
                             hDC, pPEnds[iPoint].x, pPEnds[iPoint].y, NULL
                             );
                        }
                        // handle the LineTo case
                        else if (
                           pTypes[iPoint] == PT_LINETO ||
                           pTypes[iPoint] == (PT_LINETO | PT_CLOSEFIGURE)
                           )
                        {
                           LineTo(hDC, pPEnds[iPoint].x, pPEnds[iPoint].y);
                        }
                        // handle the PolyBezierTo case
                        else if (
                           pTypes[iPoint] == PT_BEZIERTO ||
                           pTypes[iPoint] == (PT_BEZIERTO | PT_CLOSEFIGURE)
                           )
                        {
                           PolyBezierTo(hDC, pPEnds + iPoint, 3);
                           iPoint += 2;
                        }
                     }

                     // close the new path bracket
                     EndPath(hDC);

                     // stroke and fill the new path
                     StrokeAndFillPath(hDC);
                  }
               }
               catch (...)
               {
                  // clean up
                  delete [] pTypes;
                  delete [] pPEnds;
                  throw;
               }
               // clean up
               delete [] pTypes;
               delete [] pPEnds;
            }
            // ...
         }
         catch (...)
         {
            SelectObject(hDC, hOldFont);
         }
         SelectObject(hDC, hOldFont);
         return res;
      }
      case WM_SIZE:
      {
         MoveWindow(
            hTrackBar,
            0, HIWORD(lParam) - 40, LOWORD(lParam), 40,
            false
            );
         break;
      }
      case WM_DESTROY:
      {
         // clean up
         DeleteObject(hTTFont);
         PostQuitMessage(0);
         break;
      }
   }
   return DefWindowProc(hWnd, msg, wParam, lParam);
}
// 窗口消息处理函数
LRESULT APIENTRY MainWndProc(
							 HWND hwnd,
							 UINT message,
							 WPARAM wParam,
							 LPARAM lParam)

{

	PAINTSTRUCT ps;

	switch (message)
	{
	case WM_PAINT:
		hdc = BeginPaint(hwnd, &ps);
		EndPaint(hwnd, &ps);
		break;

	case WM_COMMAND: // 菜单命令
		switch (wParam)
		{
		case IDM_VANISH: // 消除客户区(在设置了修剪全其输出范围也会被限制)
			hdc = GetDC(hwnd);
			GetClientRect(hwnd, &rc);
			FillRect(hdc, &rc, (HBRUSH)GetStockObject(WHITE_BRUSH));
			DeleteDC( hdc);
			break;
			// 根据用户的菜单输入,设置修剪路径的组合模式
		case IDM_AND:
			iMode = RGN_AND;
			break;
		case IDM_COPY:
			iMode = RGN_COPY;
			break;
		case IDM_DIFF:
			iMode = RGN_DIFF;
			break;
		case IDM_OR:
			iMode = RGN_OR;
			break;
		case IDM_XOR:
			iMode = RGN_XOR;
			break;

		case IDM_CLIP:
			{
				// 获取窗口客户区的DC
				hdc = GetDC(hwnd);
				// 创建并为DC选择字体
				// 消息在菜单中点击此项前需先选择字体
				hfont = CreateFontIndirect(cf.lpLogFont);
				hfontOld = (HFONT)SelectObject(hdc, hfont);

				// 五个点,用于创建五角星区域
				POINT point[5]= {{0,200},{600,200},{100,600},{300,0},{500,600}};
				// 创建多边形区域,五角星
				hrgn = CreatePolygonRgn(point, 5, WINDING);
				// 将区域选择为修剪区域
				SelectClipRgn(hdc, hrgn);
				// 输出的文字
				LPSTR szOut = "Lorem ipsum dolor sit amet, consectetur \n"
					"adipisicing elit, sed do eiusmod tempor \n"
					"incididunt ut labore et dolore magna \n"
					"aliqua. Ut enim ad minim veniam, quis \n"
					"nostrud exercitation ullamco laboris nisi \n"
					"ut aliquip ex ea commodo consequat. Duis \n"
					"aute irure dolor in reprehenderit in \n"
					"voluptate velit esse cillum dolore eu \n"
					"fugiat nulla pariatur. Excepteur sint \n"
					"occaecat cupidatat non proident, sunt \n"
					"in culpa qui officia deserunt mollit \n"
					"anim id est laborum.\n";
				// 窗口客户区,用于输出文字
				RECT rect;
				GetClientRect(hwnd,&rect);
				// 设置文字背景为透明
				SetBkMode(hdc, TRANSPARENT);
				// 开始创建路径
				BeginPath(hdc);
				// 路径的形状为输出的文字
				DrawText(hdc, szOut, lstrlen(szOut),&rect , DT_CENTER);
				EndPath(hdc);// 路径已经为DC的当前路径
				// 为DC选择修剪路径,使用用户通过菜单输入的模式
				// 注意在进行此操作前需通过菜单选择组合模式
				SelectClipPath(hdc, iMode);

				// 输出放射状直线,以左上角为原点
				// 计算线的终点
				for (i = 0; i < 90; i++)
				{
					aflSin[i] = sin( (((double)i) / 180.0)
						* 3.14159);
				}
				for (i = 0; i < 90; i++)
				{
					aflCos[i] = cos( (((double)i) / 180.0)
						* 3.14159);
				}
				flRadius = 1000;// 线的长度(窗口大小为600*650)
				// 画线,第一度画一条线
				for (i = 0; i < 90; i++)
				{
					MoveToEx(hdc, nXStart, nYStart,
						(LPPOINT) NULL);
					LineTo(hdc, nXStart + ((int) (flRadius
						* aflCos[i])),
						nYStart + ((int) (flRadius
						* aflSin[i])));
				}
				// 选择回字体,释放
				SelectObject(hdc, hfontOld);
				DeleteObject(hfont);
				DeleteDC( hdc);
				// 刷新窗口
				UpdateWindow(hwnd);

				break;
			}

		case IDM_FONT:
			// 用户选择字体
			cf.lStructSize = sizeof (CHOOSEFONT);
			cf.hwndOwner = hwnd;
			cf.lpLogFont = &lf;
			cf.Flags = CF_SCREENFONTS | CF_EFFECTS;
			cf.rgbColors = RGB(0, 255, 255);
			cf.nFontType = SCREEN_FONTTYPE;

			ChooseFont(&cf);
			break;

		default:
			return DefWindowProc(hwnd, message, wParam,
				lParam);
		}
		break;

	case WM_DESTROY:
		PostQuitMessage(0);
		break;

	default:
		return DefWindowProc(hwnd, message, wParam, lParam);
	}
	return 0;
}
Exemplo n.º 30
0
void LAYER::BeginPath( int32_t x, int32_t y )
{
   BeginPath( x, y, NOWHERE );
}