コード例 #1
0
ファイル: wintabdraw.c プロジェクト: abyvaltsev/putty-nd3.x
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;
}
コード例 #2
0
ファイル: path.c プロジェクト: 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);
}
コード例 #3
0
static void dw_gt_closepath(vd_trace_interface *I)
{   get_window(); 
    if (host.tw == NULL) 
        return;
    LineTo(I->host->hdc, SX(I->host->bx), SY(I->host->by));
    CloseFigure(I->host->hdc);
}
コード例 #4
0
ファイル: cfde_path.cpp プロジェクト: gradescope/pdfium
void CFDE_Path::AddCurve(const CFX_PointsF& points,
                         FX_BOOL bClosed,
                         FX_FLOAT fTension) {
  int32_t iLast = points.GetUpperBound();
  if (iLast < 1)
    return;

  CFX_PointsF tangents;
  GetCurveTangents(points, tangents, bClosed, fTension);
  const CFX_PointF* pPoints = points.GetData();
  CFX_PointF* pTangents = tangents.GetData();
  MoveTo(pPoints[0]);
  for (int32_t i = 0; i < iLast; ++i) {
    BezierTo(CFX_PointF(pPoints[i].x + pTangents[i].x,
                        pPoints[i].y + pTangents[i].y),
             CFX_PointF(pPoints[i + 1].x - pTangents[i + 1].x,
                        pPoints[i + 1].y - pTangents[i + 1].y),
             CFX_PointF(pPoints[i + 1].x, pPoints[i + 1].y));
  }
  if (bClosed) {
    BezierTo(CFX_PointF(pPoints[iLast].x + pTangents[iLast].x,
                        pPoints[iLast].y + pTangents[iLast].y),
             CFX_PointF(pPoints[0].x - pTangents[0].x,
                        pPoints[0].y - pTangents[0].y),
             CFX_PointF(pPoints[0].x, pPoints[0].y));
    CloseFigure();
  }
}
コード例 #5
0
ファイル: cfde_path.cpp プロジェクト: gradescope/pdfium
void CFDE_Path::AddRectangle(const CFX_RectF& rect) {
  MoveTo(rect.TopLeft());
  LineTo(rect.TopRight());
  LineTo(rect.BottomRight());
  LineTo(rect.BottomLeft());
  CloseFigure();
}
コード例 #6
0
ファイル: Fosterer.cpp プロジェクト: b2kguga/CodesAndNotes
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);
}
コード例 #7
0
ファイル: cfde_path.cpp プロジェクト: gradescope/pdfium
void CFDE_Path::AddEllipse(const CFX_RectF& rect) {
  FX_FLOAT fStartAngle = 0;
  FX_FLOAT fEndAngle = FX_PI / 2;
  for (int32_t i = 0; i < 4; ++i) {
    ArcTo(i == 0, rect, fStartAngle, fEndAngle);
    fStartAngle += FX_PI / 2;
    fEndAngle += FX_PI / 2;
  }
  CloseFigure();
}
コード例 #8
0
ファイル: print.cpp プロジェクト: hzwjava/ORDER
int client_ClosePath(const int pdcID) {
    HDC pdc = printerDCs[pdcID];
    if (pdc != NULL) {
        if (CloseFigure(pdc)) {
            if (EndPath(pdc)) {
                return JNI_TRUE;
            }
        }
    }
    return JNI_FALSE;
}
コード例 #9
0
ファイル: cfde_path.cpp プロジェクト: gradescope/pdfium
void CFDE_Path::AddPolygon(const CFX_PointsF& points) {
  int32_t iCount = points.GetSize();
  if (iCount < 2)
    return;

  AddLines(points);
  const CFX_PointF* p = points.GetData();
  if (FXSYS_fabs(p[0].x - p[iCount - 1].x) < 0.01f ||
      FXSYS_fabs(p[0].y - p[iCount - 1].y) < 0.01f) {
    LineTo(p[0]);
  }
  CloseFigure();
}
コード例 #10
0
ファイル: path.c プロジェクト: winapiforphp/gdi
PHP_METHOD(WinGdiPath, closeFigure)
{
    wingdi_devicecontext_object *dc_obj;
    wingdi_path_object *path_obj;

    WINGDI_ERROR_HANDLING();
    if (zend_parse_parameters_none() == FAILURE)
        return;
    WINGDI_RESTORE_ERRORS();

    path_obj = zend_object_store_get_object(getThis() TSRMLS_CC);
    dc_obj = zend_object_store_get_object(path_obj->device_context TSRMLS_CC);
    RETURN_BOOL(CloseFigure(dc_obj->hdc));
}
コード例 #11
0
ファイル: path.c プロジェクト: 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);
}
コード例 #12
0
ファイル: path.c プロジェクト: 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);
}
コード例 #13
0
ファイル: Renderer.cpp プロジェクト: DieBagger/MediaPortal-1
	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;
	}
コード例 #14
0
ファイル: wintabdraw.c プロジェクト: abyvaltsev/putty-nd3.x
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;
}
コード例 #15
0
ファイル: pathproc.cpp プロジェクト: Amadiro/xara-cairo
INT32 ProcessPathDistance::Process(const ProcessFlags& PFlags, INT32 AlreadyProcessed)
{

	// The idea here is that we create a quantised path. This means we
	// scan through the path descretizing curves and lines dependent
	// on the flatness value given.

    DocCoord* ICoords = ProcSource->GetCoordArray();
	PathVerb* IVerbs = ProcSource->GetVerbArray();

	UINT32*     IPressure = NULL;
	if (ProcSource->HasWidth())
		IPressure = ProcSource->GetWidthArray();
	
	//if (IPressure == NULL)
	//	ERROR3("No pressure array");

	INT32 numinsource = ProcSource->GetNumCoords();

    INT32 i=AlreadyProcessed;
    BOOL ok = TRUE;
	if ( i > 0)
	{
		ProcFirstPoint = FALSE;
	}
	
	// scan through the input verbs
    while ((i < numinsource) && (ok) && (!Found))
    {
	//	if (IPressure != NULL)
	//		TRACEUSER( "Diccon", _T("PathProc Pressure =  %d\n"), IPressure[i]);
		switch (IVerbs[i] & ~PT_CLOSEFIGURE)
		{
			case PT_MOVETO:
				OpenElement(PT_MOVETO, i);
				if (IPressure != NULL)
					ok = NewPointA(PT_MOVETO, &ICoords[i], &IPressure[i]);
				else
					ok = NewPoint(PT_MOVETO, &ICoords[i]);

				if (CloseElement(ok, PT_MOVETO, i))
					i=(numinsource-1);
				break;

			case PT_LINETO:
				{
					BOOL IsCloseFigure = ((IVerbs[i] & PT_CLOSEFIGURE) != 0);	// Remember if this is the closing element

					OpenElement(PT_LINETO, i);
					if (!PFlags.QuantiseAll)
					{
						if (!PFlags.QuantiseLines)
							if (IPressure != NULL)
								ok = NewPointA(PT_LINETO, &ICoords[i], &IPressure[i]);
							else
								ok = NewPoint(PT_LINETO, &ICoords[i]);
						else
						{
							DocCoord End = ICoords[i];
							for (double mu = 0.2; (mu<1.2) && ok; mu+=0.2 )
							{
								DocCoord dest;
								dest.x = (INT32)((1-mu)*ProcPreviousEl.x + mu*End.x);
								dest.y = (INT32)((1-mu)*ProcPreviousEl.y + mu*End.y);
								ok = NewPoint(PT_LINETO, &dest);
							}
						}
					}
					else
					{
						ok = InsertQuantisedLineTo(&ICoords[i], &ProcPreviousEl);
					}
					if (CloseElement(ok, PT_LINETO, i))
						i=(numinsource-1);
					else if (IsCloseFigure)		// If continuing, and this is the end of a closed figure
						CloseFigure();			// then close it off
				}
				break;

			case PT_BEZIERTO:
				{
					BOOL IsCloseFigure = ((IVerbs[i+2] & PT_CLOSEFIGURE) != 0);	// Remember if this is the closing element

					OpenElement(PT_BEZIERTO, i);
					if (!PFlags.FlattenCurves)
						ok = NewPoint(PT_BEZIERTO, &ICoords[i]);
					else
					{
						ok = FlattenCurve(ProcPreviousEl.x, ProcPreviousEl.y,
										  ICoords[i].x, ICoords[i].y,
										  ICoords[i+1].x, ICoords[i+1].y,
										  ICoords[i+2].x, ICoords[i+2].y, (PFlags.QuantiseAll) );
					}
					if (CloseElement(ok, PT_BEZIERTO, i))
						i=(numinsource-1);
					else
					{
						if (IsCloseFigure)		// If continuing, and this is the end of a closed figure
							CloseFigure();		// then close it off

                		i+=2;
					}
				}
				break;

			default: ERROR3("ProcessPath::Process() - unknown path verb!");

    	}
		ICoords = ProcSource->GetCoordArray();
		IVerbs = ProcSource->GetVerbArray();
		i++;
		ProcFirstPoint = FALSE;
		ProcPreviousEl = ICoords[i-1];
    }

	// we are recording the point previous to the one we just found. 
	// i represents the next point, i-1 is the point we just found, so 
	// the one before that is i-2
	if (Found)
		m_LastFoundIndex = i -2;

	INT32 ReturnValue;
	// we have processed i-1 points
	if (ok)
		ReturnValue = i-1; 
	else
		ReturnValue = -1;

	return ok;
}
コード例 #16
0
ファイル: pathproc.cpp プロジェクト: Amadiro/xara-cairo
BOOL ProcessPath::Process(const ProcessFlags& PFlags)
{

	// The idea here is that we create a quantised path. This means we
	// scan through the path descretizing curves and lines dependent
	// on the flatness value given.

    DocCoord* ICoords = ProcSource->GetCoordArray();
	PathVerb* IVerbs = ProcSource->GetVerbArray();

	INT32 numinsource = ProcSource->GetNumCoords();

    INT32 i=0;
    BOOL ok = TRUE;

	// scan through the input verbs
    while ((i<numinsource) && (ok))
    {
		switch (IVerbs[i] & ~PT_CLOSEFIGURE)
		{
			case PT_MOVETO:
				OpenElement(PT_MOVETO, i);
				ok = NewPoint(PT_MOVETO, &ICoords[i]);
				if (CloseElement(ok, PT_MOVETO, i))
					i=(numinsource-1);
				break;

			case PT_LINETO:
				{
					BOOL IsCloseFigure = ((IVerbs[i] & PT_CLOSEFIGURE) != 0);	// Remember if this is the closing element

					OpenElement(PT_LINETO, i);
					if (!PFlags.QuantiseAll)
					{
						if (!PFlags.QuantiseLines)
							ok = NewPoint(PT_LINETO, &ICoords[i]);
						else
						{
							DocCoord End = ICoords[i];
							for (double mu = 0.2; (mu<1.2) && ok; mu+=0.2 )
							{
								DocCoord dest;
								dest.x = (INT32)((1-mu)*ProcPreviousEl.x + mu*End.x);
								dest.y = (INT32)((1-mu)*ProcPreviousEl.y + mu*End.y);
								ok = NewPoint(PT_LINETO, &dest);
							}
						}
					}
					else
					{
						ok = InsertQuantisedLineTo(&ICoords[i], &ProcPreviousEl);
					}
					if (CloseElement(ok, PT_LINETO, i))
						i=(numinsource-1);
					else if (IsCloseFigure)		// If continuing, and this is the end of a closed figure
						CloseFigure();			// then close it off
				}
				break;

			case PT_BEZIERTO:
				{
					BOOL IsCloseFigure = ((IVerbs[i+2] & PT_CLOSEFIGURE) != 0);	// Remember if this is the closing element

					OpenElement(PT_BEZIERTO, i);
					if (!PFlags.FlattenCurves)
						ok = NewPoint(PT_BEZIERTO, &ICoords[i]);
					else
					{
						ok = FlattenCurve(ProcPreviousEl.x, ProcPreviousEl.y,
										  ICoords[i].x, ICoords[i].y,
										  ICoords[i+1].x, ICoords[i+1].y,
										  ICoords[i+2].x, ICoords[i+2].y, (PFlags.QuantiseAll) );
					}
					if (CloseElement(ok, PT_BEZIERTO, i))
						i=(numinsource-1);
					else
					{
						if (IsCloseFigure)		// If continuing, and this is the end of a closed figure
							CloseFigure();		// then close it off

                		i+=2;
					}
				}
				break;

			default: ERROR3("ProcessPath::Process() - unknown path verb!");

    	}
		ICoords = ProcSource->GetCoordArray();
		IVerbs = ProcSource->GetVerbArray();
		i++;
		ProcFirstPoint = FALSE;
		ProcPreviousEl = ICoords[i-1];
    }
	return ok;
}
コード例 #17
0
ファイル: cfde_path.cpp プロジェクト: gradescope/pdfium
FX_BOOL CFDE_Path::StartFigure() {
  return CloseFigure();
}
コード例 #18
0
 void GdiContext2D::closePath()
 {
     Check();
     CloseFigure(m_hDC);
     EndPath(m_hDC);
 }