📄 udsimnt.c
字号:
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 ((UGL_UGI_DRIVER *)pGenDriver, &segP1, &segP2); } numPoints -= length; startPointNum = endPointNum; } /* restory line style */ gc->lineStyle = lineStyle; } return (UGL_STATUS_OK); }/***************************************************************************** uglSimPcRectangle - draw a rectangle**/UGL_STATUS uglSimPcRectangle ( UGL_UGI_DRIVER * pUgiDriver, UGL_RECT * rect ) { UGL_SIMNT_DRIVER * pDriver = (UGL_SIMNT_DRIVER *)pUgiDriver; UGL_GC * gc = pDriver->generic.gc; if (gc->pPatternBitmap != UGL_NULL) return (uglGenericRectangle (pUgiDriver, rect)); /* adjust for view port */ UGL_RECT_MOVE (*rect, gc->viewPort.left, gc->viewPort.top); key = intLock (); if (gc->foregroundColor == UGL_COLOR_TRANSPARENT || gc->lineWidth == 0) { /* fill rectangle with no outline */ WIN_RECT winRect; winRect.left = rect->left; winRect.top = rect->top; winRect.right = rect->right + 1; winRect.bottom = rect->bottom + 1; /* fill rect on draw page */ win_FillRect (pDriver->hDrawDc, &winRect, pDriver->hBrush); /* update display */ if (gc->pDefaultBitmap == UGL_DISPLAY_ID && pDriver->generic.pDrawPage == pDriver->generic.pVisiblePage) { win_FillRect (pDriver->hScreenDc, &winRect, pDriver->hBrush); } } else { /* draw rect on draw page */ win_Rectangle (pDriver->hDrawDc, rect->left, rect->top, rect->right + 1, rect->bottom + 1); /* update display */ if (gc->pDefaultBitmap == UGL_DISPLAY_ID && pDriver->generic.pDrawPage == pDriver->generic.pVisiblePage) { win_Rectangle (pDriver->hScreenDc, rect->left, rect->top, rect->right + 1, rect->bottom + 1); } } intUnlock (key); return (UGL_STATUS_OK); }/***************************************************************************** uglSimPcPolygon - draw a polygon**/UGL_STATUS uglSimPcPolygon ( UGL_UGI_DRIVER * pUgiDriver, const UGL_POINT * pointArray, UGL_ORD numPoints ) { UGL_SIMNT_DRIVER * pDriver = (UGL_SIMNT_DRIVER *)pUgiDriver; UGL_GC_ID gc = pDriver->generic.gc; WIN_POINT * winPointArray; int i; if (gc->pPatternBitmap != UGL_NULL) return (uglGenericPolygon (pUgiDriver, pointArray, numPoints)); winPointArray = (WIN_POINT *)uglScratchBufferAlloc (pUgiDriver, numPoints * sizeof (WIN_POINT)); /* Adjust for view port */ for (i = 0; i < numPoints; i++) { winPointArray[i] = ((WIN_POINT *)pointArray)[i]; UGL_POINT_MOVE (((UGL_POINT *)winPointArray)[i], gc->viewPort.left, gc->viewPort.top); } /* draw polygon on draw page */ if (gc->backgroundColor != UGL_COLOR_TRANSPARENT) { key = intLock (); win_Polygon (pDriver->hDrawDc, winPointArray, numPoints); /* update display */ if (gc->pDefaultBitmap == UGL_DISPLAY_ID && pDriver->generic.pDrawPage == pDriver->generic.pVisiblePage) { win_Polygon (pDriver->hScreenDc, winPointArray, numPoints); } intUnlock (key); } uglScratchBufferFree (pUgiDriver, winPointArray); /* Draw outline over the top of the border */ if ((gc->foregroundColor != UGL_COLOR_TRANSPARENT) && (gc->backgroundColor == UGL_COLOR_TRANSPARENT)) for (i = 0; i < (numPoints - 1); i++) { uglSimPcLine (pUgiDriver, (UGL_POINT *)&pointArray[i], (UGL_POINT *)&pointArray[i+1]); } return (UGL_STATUS_OK); }/***************************************************************************** uglSimPcEllipse - draw ellipse, arc, or pie slice**/UGL_STATUS uglSimPcEllipse ( UGL_UGI_DRIVER * pUgiDriver, UGL_RECT * pBoundRect, UGL_POINT * pStartArc, UGL_POINT * pEndArc ) { UGL_SIMNT_DRIVER * pDriver = (UGL_SIMNT_DRIVER *)pUgiDriver; UGL_GC_ID gc = pDriver->generic.gc; if (gc->pPatternBitmap != UGL_NULL) return (uglGenericEllipse (pUgiDriver, pBoundRect, pStartArc, pEndArc)); /* adjust for view port */ UGL_RECT_MOVE (*pBoundRect, gc->viewPort.left, gc->viewPort.top); UGL_POINT_MOVE (*pStartArc, gc->viewPort.left, gc->viewPort.top); UGL_POINT_MOVE (*pEndArc, gc->viewPort.left, gc->viewPort.top); key = intLock (); if (pStartArc->x == pEndArc->x && pStartArc->y == pEndArc->y) { /* draw ellipse on draw page */ win_Ellipse (pDriver->hDrawDc, pBoundRect->left, pBoundRect->top, pBoundRect->right + 1, pBoundRect->bottom + 1); /* update display */ if (gc->pDefaultBitmap == UGL_DISPLAY_ID && pDriver->generic.pDrawPage == pDriver->generic.pVisiblePage) { win_Ellipse (pDriver->hScreenDc, pBoundRect->left, pBoundRect->top, pBoundRect->right + 1, pBoundRect->bottom + 1); } } else if (((UGL_GENERIC_DRIVER *)pDriver)->gc->backgroundColor == UGL_COLOR_TRANSPARENT) { /* draw arc on draw page */ win_Arc (pDriver->hDrawDc, pBoundRect->left, pBoundRect->top, pBoundRect->right + 1, pBoundRect->bottom + 1, pStartArc->x, pStartArc->y, pEndArc->x, pEndArc->y); /* update display */ if (gc->pDefaultBitmap == UGL_DISPLAY_ID && pDriver->generic.pDrawPage == pDriver->generic.pVisiblePage) { win_Arc (pDriver->hScreenDc, pBoundRect->left, pBoundRect->top, pBoundRect->right + 1, pBoundRect->bottom + 1, pStartArc->x, pStartArc->y, pEndArc->x, pEndArc->y); } } else { /* draw pie slice on draw page */ win_Pie (pDriver->hDrawDc, pBoundRect->left, pBoundRect->top, pBoundRect->right + 1, pBoundRect->bottom + 1, pStartArc->x, pStartArc->y, pEndArc->x, pEndArc->y); /* update display */ if (gc->pDefaultBitmap == UGL_DISPLAY_ID && pDriver->generic.pDrawPage == pDriver->generic.pVisiblePage) { win_Pie (pDriver->hScreenDc, pBoundRect->left, pBoundRect->top, pBoundRect->right + 1, pBoundRect->bottom + 1, pStartArc->x, pStartArc->y, pEndArc->x, pEndArc->y); } } intUnlock (key); return (UGL_STATUS_OK); }/***************************************************************************** uglSimPcBitmapCreate - create a bitmap**/UGL_DDB_ID uglSimPcBitmapCreate ( UGL_UGI_DRIVER * pUgiDriver, UGL_DIB * pDib, UGL_DIB_CREATE_MODE createMode, UGL_COLOR initColor, UGL_MEM_POOL_ID poolId ) { UGL_SIMNT_DRIVER * pDriver = (UGL_SIMNT_DRIVER *)pUgiDriver; UGL_SIMNT_DDB * pDdb; /* * Explicit video mem allocation not supported. Must not fail, however, * if creating a page. If size is same as screen, page creation is * assumed. */ if (poolId == UGL_VIDEO_MEM_POOL_ID && (pDib->width != pUgiDriver->pMode->width || pDib->height != pUgiDriver->pMode->height || createMode != UGL_DIB_INIT_VALUE || initColor != 0)) return (UGL_NULL); /* allocate DDB (device dependant bitmap) structure */ pDdb = (UGL_SIMNT_DDB *)UGL_MALLOC (sizeof (UGL_SIMNT_DDB)); if (pDdb == UGL_NULL) return (UGL_NULL); /* create bitmap and initialize header */ pDdb->header.type = UGL_DDB_TYPE; pDdb->header.width = pDib->width; pDdb->header.height = pDib->height; key = intLock (); pDdb->hBitmap = win_CreateCompatibleBitmap (pDriver->hScreenDc, pDdb->header.width, pDdb->header.height); intUnlock (key); /* initialize the bitmap */ if (createMode == UGL_DIB_INIT_DATA) { UGL_RECT sourceRect; UGL_POINT destPoint; /* initialize from DIB (device independant bitmap) */ sourceRect.left = sourceRect.top = destPoint.x = destPoint.y = 0; sourceRect.right = pDib->width - 1; sourceRect.bottom = pDib->height - 1; (*pUgiDriver->bitmapWrite) (pUgiDriver, pDib, &sourceRect, (UGL_DDB *)pDdb, &destPoint); } else if (createMode == UGL_DIB_INIT_VALUE) { WIN_HBRUSH hFillBrush; WIN_RECT fillRect; WIN_HBITMAP hOldBitmap; WIN_HBRUSH hOldBrush; /* initialize bitmap to a solid color */ fillRect.left = fillRect.top = 0; fillRect.right = pDib->width - 1; fillRect.bottom = pDib->height - 1; key = intLock (); hFillBrush = win_CreateSolidBrush (WIN_RGB (UGL_RGB_RED (initColor), UGL_RGB_GREEN (initColor), UGL_RGB_BLUE (initColor))); hOldBitmap = win_SelectObject (pDriver->hExtraDc, pDdb->hBitmap); hOldBrush = win_SelectObject (pDriver->hExtraDc, hFillBrush); win_FillRect (pDriver->hExtraDc, &fillRect, hFillBrush); win_SelectObject (pDriver->hExtraDc, hOldBitmap); win_SelectObject (pDriver->hExtraDc, hOldBrush); win_DeleteObject (hFillBrush); intUnlock (key); } return ((UGL_DDB *)pDdb); }/***************************************************************************** uglSimPcBitmapDestroy - destroy a bitmap**/UGL_STATUS uglSimPcBitmapDestroy ( UGL_UGI_DRIVER * pDriver, UGL_DDB * pDdb ) { if (pDriver == UGL_NULL) return (UGL_STATUS_ERROR); /* delete the windows bitmap */ key = intLock (); win_DeleteObject (((UGL_SIMNT_DDB *)pDdb)->hBitmap); intUnlock (key); /* free the DDB structure */ UGL_FREE (pDdb); return (UGL_STATUS_OK); }/***************************************************************************** uglSimPcBitmapWrite - write image information to a bitmap**/UGL_STATUS uglSimPcBitmapWrite ( UGL_UGI_DRIVER * pUgiDriver, UGL_DIB * pDib, UGL_RECT * pSrcRect, UGL_DDB * pUgiDdb, UGL_POINT * pDstPoint ) { UGL_SIMNT_DRIVER *pDriver = (UGL_SIMNT_DRIVER *)pUgiDriver; UGL_SIMNT_DDB *pDdb = (UGL_SIMNT_DDB *)pUgiDdb; UGL_GC_ID gc = pDriver->generic.gc; int clutSize = 0; WIN_HDC hDstDc; WIN_HDC hTempDc;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -