Пример #1
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;
}
Пример #2
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;
}
Пример #3
0
int client_Arc(const int pdcID, int x, int y, int r, float alpha, float beta) {
    HDC pdc = printerDCs[pdcID];
    if (pdc != NULL) {
        if (AngleArc(pdc, x, y, r, alpha, beta) > 0) {
            return JNI_TRUE;
        }
    }
    return JNI_FALSE;
}
Пример #4
0
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);
}
	void WinGDISimpleRenderObjectUtility::DrawCircle(f32 x, f32 y, f32 radius, D_Color clr, f32 lineWidth)
	{
		HDC hdc = m_poRenderer->GetOffscreenDC();  
		HPEN hpen = (HPEN)SelectObject(hdc, CreatePen(PS_SOLID, lineWidth, WinGDIMapping::MappingColor(clr))) ;

		MoveToEx(hdc, x + radius, y, NULL);
		AngleArc(hdc, x, y, radius, 0.f, 360.0f);

		DeleteObject(SelectObject(hdc, hpen));
	}
Пример #6
0
PHP_METHOD(WinGdiPath, angleArc)
{
    wingdi_devicecontext_object *dc_obj;
    wingdi_path_object *path_obj;
    DWORD radius;
    FLOAT start, sweep; 
    int x, y;

    WINGDI_ERROR_HANDLING();
    if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llldd", &x, &y, &radius, &start, &sweep) == 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(AngleArc(dc_obj->hdc, x, y, radius, start, sweep));
}
Пример #7
0
/**
 * @brief GetPoints return list of points needed for drawing arc.
 * @return list of points
 */
QVector<QPointF> VArc::GetPoints() const
{
    QVector<QPointF> points;
    qreal i = 0;
    qreal angle = AngleArc();
    qint32 k = static_cast<qint32>(angle);
    qreal s = angle/(k/4);
    do
    {
        QLineF line(d->center.toQPointF(), GetP1());
        line.setAngle(line.angle()+i);
        points.append(line.p2());
        i = i + s;
        if (i > angle)
        {
            QLineF line(d->center.toQPointF(), GetP1());
            line.setAngle(line.angle()+angle);
            points.append(line.p2());
        }
    } while (i <= angle);
    return points;
}
Пример #8
0
void  ErrorCodeTest(HDC hdcScreen)
{
    char * psz = "This is ExtTextOut error code test";
    DWORD  err;
    RECT   rc;

    rc.left = 0;     // arbitrary values
    rc.right = 100;
    rc.top   = 0;
    rc.bottom = 200;

// verify that retrieving error codes works properly:

   // SetBatchLimit(1);

    ExtTextOut (
                hdcScreen,
                10,20,
                ETO_CLIPPED,    // illegal to have null rect and nonzero flags
                (LPRECT)NULL,
                psz, strlen(psz),
                (LPINT)NULL);
    GdiFlush();
    err = GetLastError();
    DbgPrint ("ExtTextOut 1, Last error  = 0x%lx = %ld\n", err, err);


    ExtTextOut (
                hdcScreen,
                10,20,
                5,                        // invalid flag
                &rc,
                psz, strlen(psz),
                (LPINT)NULL);
    GdiFlush();
    err = GetLastError();
    DbgPrint ("ExtTextOut 2,  Last error  = 0x%lx = %ld\n", err, err);


    ExtTextOut (
                0X33344455,               // INVALID HANDLE
                10,20,
                0,
                (LPRECT)NULL,
                psz, strlen(psz),
                (LPINT)NULL);
    GdiFlush();
    err = GetLastError();
    DbgPrint ("ExtTextOut 3, Last error = 0x%lx = %ld\n", err, err);


    SetTextAlign (hdcScreen,0x77777777);
    GdiFlush();
    err = GetLastError();
    DbgPrint ("SetTextAlign, Last error  = 0x%lx = %ld\n", err, err);



    AngleArc(hdcScreen,
             100,          // x
             200,          // y
             0XFFFFFFFF,   // overflows when converted to long        // radius
             (FLOAT)0,
             (FLOAT)30
             );
    GdiFlush();
    err = GetLastError();
    DbgPrint ("AngleArc, Last error = 0x%lx = %ld\n", err, err);

    vDoPause(0);
}
Пример #9
0
/***************************************************************************
 *  AngleArc  - Win32 to Win16 Metafile Converter Entry Point
 **************************************************************************/
BOOL WINAPI DoAngleArc
(
PLOCALDC pLocalDC,
int     x,
int     y,
DWORD   ulRadius,
FLOAT   eStartAngle,
FLOAT   eSweepAngle
)
{
BOOL    b ;
POINTL  aptl[4] ;
FLOAT   eEndAngle;
INT     iArcDirection;

// If we're recording the drawing orders for a path
// then just pass the drawing order to the helper DC.
// Do not emit any Win16 drawing orders.

        if (pLocalDC->flags & RECORDING_PATH)
        {
	    b = AngleArc(pLocalDC->hdcHelper, x, y, ulRadius, eStartAngle, eSweepAngle) ;
            ASSERTGDI(b, "MF3216: DoAngleArc, in path render failed\n") ;
            return(b) ;
        }

// Do the transformations.
// And emit the Win16 drawing orders.

	if (pLocalDC->flags & STRANGE_XFORM
	 || eSweepAngle >  360.0f	// more than one revolution
	 || eSweepAngle < -360.0f
	   )
        {
            b = bRenderCurveWithPath(pLocalDC, (LPPOINT) NULL, (PBYTE) NULL, 0,
		    x, y, 0, 0, 0, 0, 0, 0,
		    ulRadius, eStartAngle, eSweepAngle, EMR_ANGLEARC);

	    return(b);
	}

// Calculate the ARC bounding box.

        aptl[0].x = x - ulRadius ;
        aptl[0].y = y - ulRadius ;
        aptl[1].x = x + ulRadius ;
        aptl[1].y = y + ulRadius ;

// Calculate the begin and end points for ARC from the
// eStartAngle and eSweepAngle.

        aptl[2].x = x + (LONG) ((double) (ulRadius) * cos(eStartAngle * eRadsPerDegree) + 0.5f) ;
        aptl[2].y = y - (LONG) ((double) (ulRadius) * sin(eStartAngle * eRadsPerDegree) + 0.5f) ;

        eEndAngle = eStartAngle + eSweepAngle ;

        aptl[3].x = x + (LONG) ((double) (ulRadius) * cos(eEndAngle * eRadsPerDegree) + 0.5f) ;
        aptl[3].y = y - (LONG) ((double) (ulRadius) * sin(eEndAngle * eRadsPerDegree) + 0.5f) ;

// If the endpoints are identical, we cannot represent the AngleArc as
// an ArcTo.  Use path to render it instead.

	if (aptl[2].x == aptl[3].x && aptl[2].y == aptl[3].y)
        {
            b = bRenderCurveWithPath(pLocalDC, (LPPOINT) NULL, (PBYTE) NULL, 0,
		    x, y, 0, 0, 0, 0, 0, 0,
		    ulRadius, eStartAngle, eSweepAngle, EMR_ANGLEARC);

	    return(b);
	}

// At this point we have the same parameters that would apply to
// a standard ArcTo.  However, we still need to determine the arc
// direction to apply.  If the sweep angle is positive, it is counter-
// clockwise.  If the sweep angle is negative, it is clockwise.

// Save the current arc direction.

        iArcDirection = pLocalDC->iArcDirection;

// Prepare the arc direction for the ArcTo.

        (void) DoSetArcDirection
	    (pLocalDC, eSweepAngle < 0.0f ? AD_CLOCKWISE : AD_COUNTERCLOCKWISE);

// Do the ArcTo.

        b = DoArcTo(pLocalDC, aptl[0].x, aptl[0].y, aptl[1].x, aptl[1].y,
                              aptl[2].x, aptl[2].y, aptl[3].x, aptl[3].y) ;

// Restore the current arc direction.

        (void) DoSetArcDirection(pLocalDC, iArcDirection);

        return (b) ;
}
Пример #10
0
/**
 * @brief GetLength return arc length.
 * @return length.
 */
qreal VArc::GetLength() const
{
    return (M_PI * d->radius)/180 * AngleArc();
}