⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 udsimnt.c

📁 zinc60t22.tar.gz:zinc在tornado2.2.x下的补丁
💻 C
📖 第 1 页 / 共 5 页
字号:
            UGL_RECT clipRect;            const UGL_RECT * pRegionRect = UGL_NULL;            /* build windows clip region from UGL clip list */            if (uglClipListGet (gc, &clipRect, &pRegionRect) == UGL_STATUS_OK)                {                hClipRegion = win_CreateRectRgn (clipRect.left, clipRect.top,                                              clipRect.right + 1,                                              clipRect.bottom + 1);                while (uglClipListGet (gc, &clipRect, &pRegionRect) ==                        UGL_STATUS_OK)                    {                    WIN_HRGN hAddRegion;                    hAddRegion = win_CreateRectRgn (clipRect.left,                                                     clipRect.top,                                                     clipRect.right + 1,                                                     clipRect.bottom + 1);                    win_CombineRgn (hClipRegion, hClipRegion, hAddRegion, 		    		    WIN_RGN_OR);                    win_DeleteObject (hAddRegion);                    }                }            else                 {                /* clip list is empty */                hClipRegion = win_CreateRectRgn (0, 0, 0, 0);                }            }        else            {            /* no clip region, only clip rect is used */            hClipRegion = win_CreateRectRgn (gc->viewPort.left + gc->clipRect.left,                                             gc->viewPort.top + gc->clipRect.top,                                             gc->viewPort.left + gc->clipRect.right + 1,                                             gc->viewPort.top + gc->clipRect.bottom + 1);            }        /* replace old clip region */        win_DeleteObject (pDriver->hClipRegion);        pDriver->hClipRegion = hClipRegion;        /* set clip region into device contexts */        win_SelectClipRgn (pDriver->hDrawDc, pDriver->hClipRegion);        win_SelectClipRgn (pDriver->hScreenDc, pDriver->hClipRegion);        intUnlock (key);        }    /* set the Windows pen and text color */    if (gc->changed & (UGL_GC_FOREGROUND_COLOR_CHANGED |                        UGL_GC_LINE_WIDTH_CHANGED))        {        WIN_HPEN hOldPen;        /* update driver settings */        hOldPen = pDriver->hPen;        if (gc->foregroundColor == UGL_COLOR_TRANSPARENT)            {            key = intLock ();            pDriver->hPen = win_CreatePen (WIN_PS_NULL, 0, 0);            intUnlock (key);            }        else            {            UGL_ARGB argbColor;            WIN_COLORREF colorRef;            /* convert UGL color to Windows color */            if (gc->foregroundColor == 0x00FFFFFF)                {                /* special color case for XOR operations */                argbColor = 0x00FFFFFF;                }            else                (pUgiDriver->colorConvert) (pUgiDriver,                                             &gc->foregroundColor,                                            UGL_DEVICE_COLOR_32, &argbColor,                                             UGL_ARGB8888, 1);            colorRef = WIN_RGB (UGL_RGB_RED (argbColor), 	    			UGL_RGB_GREEN (argbColor),                                UGL_RGB_BLUE (argbColor));            /* create windows pen */            key = intLock ();            pDriver->hPen = win_CreatePen (WIN_PS_SOLID, gc->lineWidth, 	    				   colorRef);            /* 1 bits in Windows mono bitmaps represent background color */            win_SetBkColor (pDriver->hDrawDc, colorRef);            win_SetBkColor (pDriver->hScreenDc, colorRef);            win_SetBkColor (pDriver->hBltDc, colorRef);            intUnlock (key);            }        /* select new pen into device contexts */        key = intLock ();        win_SelectObject (pDriver->hDrawDc, pDriver->hPen);        win_SelectObject (pDriver->hScreenDc, pDriver->hPen);        /* delete old pen */        win_DeleteObject (hOldPen);        intUnlock (key);        }    /* set the Windows brush and background color */    if (gc->changed & UGL_GC_BACKGROUND_COLOR_CHANGED)        {        WIN_HBRUSH hOldBrush;        hOldBrush = pDriver->hBrush;            /* convert UGL color to Windows color */        if (gc->backgroundColor == UGL_COLOR_TRANSPARENT)            {            key = intLock ();            pDriver->hBrush = win_GetStockObject (WIN_NULL_BRUSH);            intUnlock (key);            }        else            {            UGL_ARGB argbColor;            WIN_COLORREF colorRef;            if (gc->backgroundColor == 0x00FFFFFF)                {                /* special color case for XOR operations */                argbColor = gc->backgroundColor;                }            else                (pUgiDriver->colorConvert) (pUgiDriver,                                             &gc->backgroundColor,                                            UGL_DEVICE_COLOR_32, &argbColor,                                             UGL_ARGB8888, 1);            colorRef = WIN_RGB (UGL_RGB_RED (argbColor),                                 UGL_RGB_GREEN (argbColor),                                UGL_RGB_BLUE (argbColor));            /* create windows brush */            key = intLock ();            pDriver->hBrush = win_CreateSolidBrush(colorRef);            /* 0 bits in Windows mono bitmaps represent text color */            win_SetTextColor (pDriver->hDrawDc, colorRef);            win_SetTextColor (pDriver->hScreenDc, colorRef);            win_SetTextColor (pDriver->hBltDc, colorRef);            intUnlock (key);            }        /* select new brush into device contexts */        key = intLock ();        win_SelectObject (pDriver->hDrawDc, pDriver->hBrush);        win_SelectObject (pDriver->hScreenDc, pDriver->hBrush);        /* delete old brush */        win_DeleteObject (hOldBrush);        intUnlock (key);        }    /* set default beitmap */    if (gc->changed & UGL_GC_DEFAULT_BITMAP_CHANGED)        {        if (gc->pDefaultBitmap == UGL_DISPLAY_ID)            pDriver->pDrawDdb = (UGL_SIMNT_DDB *)                                pDriver->generic.pDrawPage->pDdb;        else            pDriver->pDrawDdb = (UGL_SIMNT_DDB *)gc->pDefaultBitmap;        key = intLock ();        win_SelectObject (pDriver->hDrawDc, pDriver->pDrawDdb->hBitmap);        intUnlock (key);        }    if (gc->changed & UGL_GC_RASTER_OP_CHANGED)        {        /* set new raster op into device contexts */        int rop;        if (gc->rasterOp == UGL_RASTER_OP_XOR)            rop = WIN_R2_XORPEN;        else if (gc->rasterOp == UGL_RASTER_OP_AND)            rop = WIN_R2_MASKPEN;        else if (gc->rasterOp == UGL_RASTER_OP_OR)            rop = WIN_R2_MERGEPEN;        else            rop = WIN_R2_COPYPEN;        key = intLock ();        win_SetROP2 (pDriver->hDrawDc, rop);        win_SetROP2 (pDriver->hScreenDc, rop);        intUnlock (key);        }    /* Update the GC */    pDriver->generic.gc = gc;    return (UGL_STATUS_OK);    }/***************************************************************************** uglSimPcLine - draw a line**/UGL_STATUS uglSimPcLine     (    UGL_UGI_DRIVER * pUgiDriver,    UGL_POINT * pPoint1,    UGL_POINT * pPoint2    )    {    UGL_SIMNT_DRIVER * pDriver = (UGL_SIMNT_DRIVER *)pUgiDriver;    UGL_GC * gc = pDriver->generic.gc;    UGL_POINT p1;    UGL_POINT p2;    int signX;    int signY;    int numPoints;    UGL_LINE_STYLE lineStyle = gc->lineStyle;          /* Validate that we have a line that is visible */    if ((gc->lineWidth <= 0) || (gc->foregroundColor == UGL_COLOR_TRANSPARENT) ||         (lineStyle == 0))        return (UGL_STATUS_OK);    /* adjust for view port */    UGL_POINT_MOVE (*pPoint1, gc->viewPort.left, gc->viewPort.top);    UGL_POINT_MOVE (*pPoint2, gc->viewPort.left, gc->viewPort.top);    /*     * Calculate a new end point that is one pixel beyond the specified     * endpoint because the Window's LineTo() API does not include the     * end point when it draws.     */    signX = (pPoint2->x - pPoint1->x >= 0) ? 1 : -1;    signY = (pPoint2->y - pPoint1->y >= 0) ? 1 : -1;    numPoints = max ((pPoint2->x - pPoint1->x) * signX,                      (pPoint2->y - pPoint1->y) * signY);    p1 = *pPoint1;    uglSimPcLinePointGet (pPoint1, pPoint2, numPoints + 1, &p2);    if (lineStyle == UGL_LINE_STYLE_SOLID)        {        /* draw a line on the draw page */        key = intLock ();        win_MoveToEx (pDriver->hDrawDc, p1.x, p1.y, NULL);        win_LineTo (pDriver->hDrawDc, p2.x, p2.y);        /* update the display */        if (gc->pDefaultBitmap == UGL_DISPLAY_ID &&            pDriver->generic.pDrawPage == pDriver->generic.pVisiblePage)            {            win_MoveToEx (pDriver->hScreenDc, p1.x, p1.y, NULL);            win_LineTo (pDriver->hScreenDc, p2.x, p2.y);            }        intUnlock (key);        }    else        {        /* draw a patterned line by recusivively drawing each segment */        int startPointNum = 0;        UGL_UINT32 lineStyleMask = 0x80000000;        /* set style to solid for drawing segments */        gc->lineStyle = UGL_LINE_STYLE_SOLID;        while (numPoints > 0)            {            UGL_BOOL draw = ((lineStyle & lineStyleMask) != 0);            int length = 0;            int endPointNum;            /* count points in next sement */            while(((lineStyle & lineStyleMask) != 0) == draw)                {                length++;                if(lineStyleMask == 0x00000001)                    lineStyleMask = 0x80000000;                else                    lineStyleMask >>= 1;                }            if (draw == UGL_FALSE)                length++;            length *= gc->lineWidth;            if (length > numPoints)                length = numPoints;            endPointNum = startPointNum + length;            if (draw)                {                UGL_POINT segP1;                 UGL_POINT segP2;                /* get segement endpoints */                uglSimPcLinePointGet (&p1, &p2, startPointNum, &segP1);                uglSimPcLinePointGet (&p1, &p2, endPointNum, &segP2);                /* draw segment */                uglSimPcLine(pUgiDriver, &segP1, &segP2);                }            numPoints -= length;            startPointNum = endPointNum;            }        /* restory line style */        gc->lineStyle = lineStyle;        }    return (UGL_STATUS_OK);    }/***************************************************************************** uglSimPcHLine - draw a horizontal line**/UGL_STATUS uglSimPcHLine    (    UGL_GENERIC_DRIVER  * pGenDriver, /* graphics device driver */    int y,                            /* Y coordinate of line */    int x1,                           /* X coordinate of line start */    int x2,                           /* X coordiante of line end */    UGL_COLOR color                   /* color of line */    )    {    UGL_POINT point1 = {x1, y};    UGL_POINT point2 = {x2, y};    UGL_SIMNT_DRIVER * pDriver = (UGL_SIMNT_DRIVER *)pGenDriver;    UGL_GC * gc = pDriver->generic.gc;        UGL_POINT * pPoint1 = &point1;    UGL_POINT * pPoint2 = &point2;    UGL_POINT p1;    UGL_POINT p2;    int signX;    int signY;    int numPoints;    UGL_LINE_STYLE lineStyle = gc->lineStyle;     /* Validate that we have a line that is visible */    if ((gc->lineWidth <= 0) || (gc->foregroundColor == UGL_COLOR_TRANSPARENT) ||         (lineStyle == 0))        return (UGL_STATUS_OK);    /* adjust for view port */    UGL_POINT_MOVE (*pPoint1, gc->viewPort.left, gc->viewPort.top);    UGL_POINT_MOVE (*pPoint2, gc->viewPort.left, gc->viewPort.top);    /*     * Calculate a new end point that is one pixel beyond the specified     * endpoint because the Window's LineTo() API does not include the     * end point when it draws.     */    signX = (pPoint2->x - pPoint1->x >= 0) ? 1 : -1;    signY = (pPoint2->y - pPoint1->y >= 0) ? 1 : -1;    numPoints = max ((pPoint2->x - pPoint1->x) * signX,                      (pPoint2->y - pPoint1->y) * signY);    p1 = *pPoint1;    uglSimPcLinePointGet (pPoint1, pPoint2, numPoints + 1, &p2);    if (lineStyle == UGL_LINE_STYLE_SOLID)        {        /* draw a line on the draw page */        key = intLock ();        win_MoveToEx (pDriver->hDrawDc, p1.x, p1.y, NULL);        win_LineTo (pDriver->hDrawDc, p2.x, p2.y);        /* update the display */        if (gc->pDefaultBitmap == UGL_DISPLAY_ID &&            pDriver->generic.pDrawPage == pDriver->generic.pVisiblePage)            {            win_MoveToEx (pDriver->hScreenDc, p1.x, p1.y, NULL);            win_LineTo (pDriver->hScreenDc, p2.x, p2.y);            }        intUnlock (key);        }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -