int GUIAPI TabbedTextOutLen (HDC hdc, int x, int y, const char* spText, int len) { PCLIPRECT pClipRect; PDC pdc; SIZE size; RECT rcOutput; if (len == 0) return 0; if (len < 0) len = strlen (spText); pdc = dc_HDC2PDC(hdc); coor_LP2SP (pdc, &pdc->CurTextPos.x, &pdc->CurTextPos.y); gdi_get_TabbedTextOut_extent (pdc, pdc->pLogFont, pdc->tabstop, spText, len, &size, &pdc->CurTextPos); coor_SP2LP (pdc, &pdc->CurTextPos.x, &pdc->CurTextPos.y); if (dc_IsGeneralHDC(hdc)) { pthread_mutex_lock (&pdc->pGCRInfo->lock); if (!dc_GenerateECRgn (pdc, FALSE)) { pthread_mutex_unlock (&pdc->pGCRInfo->lock); return size.cx; } } // Transfer logical to device to screen here. coor_LP2SP(pdc, &x, &y); rcOutput.left = x; rcOutput.top = y; rcOutput.right = x + size.cx + 1; rcOutput.bottom = y + size.cy + 1; NormalizeRect(&rcOutput); pthread_mutex_lock (&__mg_gdilock); IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound); if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput); // set graphics context. GAL_SetGC(pdc->gc); pClipRect = pdc->ecrgn.head; while(pClipRect) { if (DoesIntersect (&rcOutput, &pClipRect->rc)) { GAL_SetClipping(pdc->gc, pClipRect->rc.left, pClipRect->rc.top, pClipRect->rc.right - 1, pClipRect->rc.bottom - 1); gdi_tabbedtextout (pdc, x, y, spText, len); } pClipRect = pClipRect->next; } if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(TRUE, &rcOutput); pthread_mutex_unlock(&__mg_gdilock); if (dc_IsGeneralHDC(hdc)) pthread_mutex_unlock (&pdc->pGCRInfo->lock); return size.cx; }
void GUIAPI BitBlt(HDC hsdc, int sx, int sy, int sw, int sh, HDC hddc, int dx, int dy, DWORD dwRop) { PCLIPRECT pClipRect; PDC psdc, pddc; RECT rcOutput; psdc = dc_HDC2PDC(hsdc); pddc = dc_HDC2PDC(hddc); if (dc_IsGeneralHDC(hddc)) { if (!dc_GenerateECRgn (pddc, FALSE)) { return; } } if (sw <= 0 || sh <= 0) { sw = RECTW (psdc->DevRC); sh = RECTH (psdc->DevRC); } // Transfer logical to device to screen here. sw += sx; sh += sy; coor_LP2SP(psdc, &sx, &sy); coor_LP2SP(psdc, &sw, &sh); (sw > sx) ? (sw -= sx) : (sw = sx - sw); (sh > sy) ? (sh -= sy) : (sh = sy - sh); coor_LP2SP(pddc, &dx, &dy); rcOutput.left = dx; rcOutput.top = dy; rcOutput.right = dx + sw; rcOutput.bottom = dy + sh; NormalizeRect(&rcOutput); ShowCursorForGDI(FALSE, &g_rcScr); // set graphics context. GAL_SetGC (pddc->gc); pClipRect = pddc->ecrgn.head; while(pClipRect) { if (DoesIntersect (&rcOutput, &pClipRect->rc)) { GAL_SetClipping(pddc->gc, pClipRect->rc.left, pClipRect->rc.top, pClipRect->rc.right - 1, pClipRect->rc.bottom - 1); GAL_CrossBlit (psdc->gc, sx, sy, sw, sh, pddc->gc, dx, dy); } pClipRect = pClipRect->next; } ShowCursorForGDI(TRUE, &g_rcScr); }
void GUIAPI Rectangle(HDC hdc, int x0, int y0, int x1, int y1) { PCLIPRECT pClipRect; PDC pdc; RECT rcOutput; pdc = dc_HDC2PDC(hdc); if (dc_IsGeneralHDC(hdc)) { pthread_mutex_lock (&pdc->pGCRInfo->lock); if (!dc_GenerateECRgn (pdc, FALSE)) { pthread_mutex_unlock (&pdc->pGCRInfo->lock); return; } } // Transfer logical to device to screen here. coor_LP2SP(pdc, &x0, &y0); coor_LP2SP(pdc, &x1, &y1); rcOutput.left = x0; rcOutput.top = y0; rcOutput.right = x1; rcOutput.bottom = y1; NormalizeRect (&rcOutput); rcOutput.right ++; rcOutput.bottom ++; pthread_mutex_lock (&__mg_gdilock); IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound); if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput); // set graphics context. GAL_SetGC (pdc->gc); GAL_SetFgColor (pdc->gc, pdc->pencolor); pClipRect = pdc->ecrgn.head; while(pClipRect) { if (DoesIntersect (&rcOutput, &pClipRect->rc)) { GAL_SetClipping (pdc->gc, pClipRect->rc.left, pClipRect->rc.top, pClipRect->rc.right - 1, pClipRect->rc.bottom - 1); GAL_Rectangle (pdc->gc, x0, y0, x1, y1, pdc->pencolor); } pClipRect = pClipRect->next; } if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(TRUE, &rcOutput); pthread_mutex_unlock(&__mg_gdilock); if (dc_IsGeneralHDC(hdc)) pthread_mutex_unlock (&pdc->pGCRInfo->lock); }
BOOL dc_GenerateECRgn(PDC pdc, BOOL fForce) { RECT rc, rcInter; PCLIPRECT pcr, pgcr; PCONTROL pCtrl; // is global clip region is empty? if ((!fForce) && (!dc_IsVisible (pdc))) return FALSE; // need regenerate? if (fForce || (pdc->oldage != pdc->pGCRInfo->age)) { EmptyClipRgn (&pdc->ecrgn); pcr = pdc->lcrgn.head; while (pcr) { rc = pcr->rc; coor_LP2SP (pdc, &rc.left, &rc.top); coor_LP2SP (pdc, &rc.right, &rc.bottom); pgcr = pdc->pGCRInfo->crgn.head; while (pgcr) { if (IntersectRect (&rcInter, &rc, &pgcr->rc)) AddClipRect (&pdc->ecrgn, &rcInter); pgcr = pgcr->next; } pcr = pcr->next; } if (pdc->lcrgn.head == NULL) ClipRgnCopy (&pdc->ecrgn, &pdc->pGCRInfo->crgn); // update the DevRC; if (pdc->bIsClient) WndClientRect (pdc->hwnd, &pdc->DevRC); else WndRect (pdc->hwnd, &pdc->DevRC); IntersectClipRect (&pdc->ecrgn, &pdc->DevRC); pCtrl = Control (pdc->hwnd); if (pCtrl && !(pCtrl->dwExStyle & WS_EX_CTRLASMAINWIN)) RestrictControlECRGN (&pdc->ecrgn, pCtrl); pdc->oldage = pdc->pGCRInfo->age; } return TRUE; }
/* FloodFill * Fills an enclosed area (starting at point x, y). */ BOOL GUIAPI FloodFill (HDC hdc, int x, int y) { PDC pdc; BOOL ret = TRUE; if (!(pdc = __mg_check_ecrgn (hdc))) return TRUE; /* hide cursor tempororily */ ShowCursor (FALSE); coor_LP2SP (pdc, &x, &y); pdc->cur_pixel = pdc->brushcolor; pdc->cur_ban = NULL; pdc->skip_pixel = _dc_get_pixel_cursor (pdc, x, y); /* does the start point have a equal value? */ if (pdc->skip_pixel == pdc->brushcolor) goto equal_pixel; ret = FloodFillGenerator (pdc, &pdc->DevRC, x, y, equal_pixel, _flood_fill_draw_hline); equal_pixel: UNLOCK_GCRINFO (pdc); /* Show cursor */ ShowCursor (TRUE); return ret; }
void GUIAPI CircleArc (HDC hdc, int sx, int sy, int r, int ang1, int ang2) { PDC pdc; if (!(pdc = __mg_check_ecrgn (hdc))) return; coor_LP2SP (pdc, &sx, &sy); pdc->cur_pixel = pdc->pencolor; pdc->cur_ban = NULL; if (r < 1) { _set_pixel_helper (pdc, sx, sy); goto ret; } pdc->rc_output.left = sx - r; pdc->rc_output.top = sy - r; pdc->rc_output.right = sx + r + 1; pdc->rc_output.bottom = sy + r + 1; ENTER_DRAWING (pdc); CircleArcGenerator (pdc, sx, sy, r, ang1, ang2, _dc_set_pixel_clip); LEAVE_DRAWING (pdc); ret: UNLOCK_GCRINFO (pdc); }
void GUIAPI Ellipse (HDC hdc, int sx, int sy, int rx, int ry) { PDC pdc; if (!(pdc = __mg_check_ecrgn (hdc))) return; coor_LP2SP (pdc, &sx, &sy); pdc->cur_pixel = pdc->pencolor; pdc->cur_ban = NULL; if (rx < 1 || ry < 1) { _set_pixel_helper (pdc, sx, sy); goto ret; } pdc->rc_output.left = sx - rx; pdc->rc_output.top = sy - ry; pdc->rc_output.right = sx + rx + 1; pdc->rc_output.bottom = sy + ry + 1; ENTER_DRAWING (pdc); EllipseGenerator (pdc, sx, sy, rx, ry, _dc_set_pixel_pair_clip); LEAVE_DRAWING (pdc); ret: UNLOCK_GCRINFO (pdc); }
/****************************** Bitmap Support *******************************/ void GUIAPI FillBox (HDC hdc, int x, int y, int w, int h) { PCLIPRECT pClipRect; PDC pdc; RECT rcOutput; pdc = dc_HDC2PDC(hdc); if (dc_IsGeneralHDC(hdc)) { if (!dc_GenerateECRgn (pdc, FALSE)) { return; } } // Transfer logical to device to screen here. w += x; h += y; coor_LP2SP(pdc, &x, &y); coor_LP2SP(pdc, &w, &h); rcOutput.left = x; rcOutput.top = y; rcOutput.right = w; rcOutput.bottom = h; NormalizeRect (&rcOutput); w = RECTW (rcOutput); h = RECTH (rcOutput); IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound); if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput); // set graphics context. GAL_SetGC (pdc->gc); GAL_SetFgColor (pdc->gc, pdc->brushcolor); pClipRect = pdc->ecrgn.head; while(pClipRect) { if (DoesIntersect (&rcOutput, &pClipRect->rc)) { GAL_SetClipping(pdc->gc, pClipRect->rc.left, pClipRect->rc.top, pClipRect->rc.right - 1, pClipRect->rc.bottom - 1); GAL_FillBox (pdc->gc, x, y, w, h, pdc->brushcolor); } pClipRect = pClipRect->next; } if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(TRUE, &rcOutput); }
void GUIAPI LPtoSP(HDC hdc, POINT* pPt) { /* DK[01/14/10]: Add condition to process case of hdc equal to * HDC_SCREEN_SYS for fix bug 4348. */ if (HDC_SCREEN == hdc || HDC_SCREEN_SYS == hdc) return; coor_LP2SP ((PDC)hdc, &pPt->x, &pPt->y); }
void GUIAPI GetPixelRGB(HDC hdc, int x, int y, int* r, int* g, int* b) { PDC pdc; PCLIPRECT pClipRect; gal_pixel pixel; GAL_Color color; RECT rcOutput; pdc = dc_HDC2PDC(hdc); if (dc_IsGeneralHDC(hdc)) { pthread_mutex_lock (&pdc->pGCRInfo->lock); if (!dc_GenerateECRgn (pdc, FALSE)) { pthread_mutex_unlock (&pdc->pGCRInfo->lock); return; } } coor_LP2SP(pdc, &x, &y); rcOutput.left = x - 1; rcOutput.top = y - 1; rcOutput.right = x + 1; rcOutput.bottom = y + 1; *r = 0; *g = 0; *b = 0; pthread_mutex_lock (&__mg_gdilock); IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound); if (!dc_IsMemHDC (hdc)) ShowCursorForGDI (FALSE, &rcOutput); // set graphics context. GAL_SetGC (pdc->gc); pClipRect = pdc->ecrgn.head; while(pClipRect) { if (PtInRect (&(pClipRect->rc), x, y) ) { GAL_GetPixel (pdc->gc, x, y, &pixel); GAL_UnmapPixel (pdc->gc, pixel, &color); *r = color.r; *g = color.g; *b = color.b; break; } pClipRect = pClipRect->next; } if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(TRUE, &rcOutput); pthread_mutex_unlock(&__mg_gdilock); if (dc_IsGeneralHDC(hdc)) pthread_mutex_unlock (&pdc->pGCRInfo->lock); }
gal_pixel GUIAPI GetPixel(HDC hdc, int x, int y) { PDC pdc; PCLIPRECT pClipRect; int color = 0; RECT rcOutput; pdc = dc_HDC2PDC(hdc); if (dc_IsGeneralHDC(hdc)) { pthread_mutex_lock (&pdc->pGCRInfo->lock); if (!dc_GenerateECRgn (pdc, FALSE)) { pthread_mutex_unlock (&pdc->pGCRInfo->lock); return PIXEL_invalid; } } coor_LP2SP (pdc, &x, &y); rcOutput.left = x - 1; rcOutput.top = y - 1; rcOutput.right = x + 1; rcOutput.bottom = y + 1; pthread_mutex_lock (&__mg_gdilock); IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound); if (!dc_IsMemHDC (hdc)) ShowCursorForGDI (FALSE, &rcOutput); // set graphics context. GAL_SetGC (pdc->gc); pClipRect = pdc->ecrgn.head; while(pClipRect) { if(PtInRect(&(pClipRect->rc), x, y)) { GAL_GetPixel (pdc->gc, x, y, &color); break; } pClipRect = pClipRect->next; } if (!dc_IsMemHDC (hdc)) ShowCursorForGDI (TRUE, &rcOutput); pthread_mutex_unlock(&__mg_gdilock); if (dc_IsGeneralHDC(hdc)) pthread_mutex_unlock (&pdc->pGCRInfo->lock); return color; }
void ScreenCopy (int sx, int sy, HDC hdc, int dx, int dy) { PCLIPRECT pClipRect; PDC pdc; int offx, offy; int boxLeft, boxTop, boxWidth, boxHeight; RECT* prc; pdc = dc_HDC2PDC(hdc); if (dc_IsGeneralHDC(hdc)) { if (!dc_GenerateECRgn (pdc, FALSE)) { return; } } else return; coor_LP2SP(pdc, &dx, &dy); offx = sx - dx; offy = sy - dy; ShowCursorForGDI(FALSE, &g_rcScr); GAL_SetGC (PHYSICALGC); GAL_DisableClipping (pdc->gc); pClipRect = pdc->ecrgn.head; while (pClipRect) { prc = &pClipRect->rc; boxLeft = prc->left + offx; boxTop = prc->top + offy; boxWidth = prc->right - prc->left; boxHeight = prc->bottom - prc->top; GAL_CopyBox (pdc->gc, boxLeft, boxTop, boxWidth, boxHeight, prc->left, prc->top); pClipRect = pClipRect->next; } ShowCursorForGDI(TRUE, &g_rcScr); }
void GUIAPI FillCircle (HDC hdc, int sx, int sy, int r) { PDC pdc; if (!(pdc = __mg_check_ecrgn (hdc))) return; coor_LP2SP (pdc, &sx, &sy); pdc->cur_pixel = pdc->brushcolor; pdc->cur_ban = NULL; if (r < 1) { _set_pixel_helper (pdc, sx, sy); goto ret; } pdc->rc_output.left = sx - r; pdc->rc_output.top = sy - r; pdc->rc_output.right = sx + r + 1; pdc->rc_output.bottom = sy + r + 1; ENTER_DRAWING (pdc); #ifdef _ADV_2DAPI if (pdc->brush_type == BT_SOLID) CircleGenerator (pdc, sx, sy, r, _dc_draw_hline_clip); else CircleGenerator (pdc, sx, sy, r, _dc_fill_hline_clip); #else CircleGenerator (pdc, sx, sy, r, _dc_draw_hline_clip); #endif LEAVE_DRAWING (pdc); ret: UNLOCK_GCRINFO (pdc); }
void GUIAPI LineTo (HDC hdc, int x, int y) { PCLIPRECT pClipRect; PDC pdc; RECT rcOutput; int startx, starty; pdc = dc_HDC2PDC(hdc); startx = pdc->CurPenPos.x; starty = pdc->CurPenPos.y; // Move the current pen pos. pdc->CurPenPos.x = x; pdc->CurPenPos.y = y; if (dc_IsGeneralHDC(hdc)) { pthread_mutex_lock (&pdc->pGCRInfo->lock); if (!dc_GenerateECRgn (pdc, FALSE)) { pthread_mutex_unlock (&pdc->pGCRInfo->lock); return; } } // Transfer logical to device to screen here. coor_LP2SP(pdc, &x, &y); coor_LP2SP(pdc, &startx, &starty); rcOutput.left = startx; rcOutput.top = starty; rcOutput.right = x; rcOutput.bottom = y; NormalizeRect (&rcOutput); InflateRect (&rcOutput, 1, 1); pthread_mutex_lock (&__mg_gdilock); IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound); if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput); // set graphics context. GAL_SetGC (pdc->gc); GAL_SetFgColor (pdc->gc, pdc->pencolor); pClipRect = pdc->ecrgn.head; while(pClipRect) { if (DoesIntersect (&rcOutput, &pClipRect->rc)) { GAL_SetClipping (pdc->gc, pClipRect->rc.left, pClipRect->rc.top, pClipRect->rc.right - 1, pClipRect->rc.bottom - 1); if(starty == y) { if (startx > x) GAL_DrawHLine (pdc->gc, x, y, startx - x, pdc->pencolor); else GAL_DrawHLine (pdc->gc, startx, y, x - startx, pdc->pencolor); } else GAL_Line (pdc->gc, startx, starty, x, y, pdc->pencolor); } pClipRect = pClipRect->next; } if (!dc_IsMemHDC (hdc)) ShowCursorForGDI (TRUE, &rcOutput); pthread_mutex_unlock (&__mg_gdilock); if (dc_IsGeneralHDC(hdc)) pthread_mutex_unlock (&pdc->pGCRInfo->lock); }
int DrawTextEx (HDC hdc, const char* pText, int nCount, RECT* pRect, int indent, UINT nFormat) { PDC pdc; int n, nLines = 0, width = 0; BOOL bOutput = TRUE; int x, y; RECT rcDraw, rcOutput; int nTabWidth, tabs; SIZE size; int line_height; pdc = dc_HDC2PDC(hdc); if (nCount == -1) nCount = strlen (pText); line_height = pdc->pLogFont->size + pdc->alExtra + pdc->blExtra; if (nFormat & DT_TABSTOP) nTabWidth = HIWORD (nFormat) * (*pdc->pLogFont->sbc_devfont->font_ops->get_ave_width) (pdc->pLogFont, pdc->pLogFont->sbc_devfont); else nTabWidth = pdc->tabstop * (*pdc->pLogFont->sbc_devfont->font_ops->get_ave_width) (pdc->pLogFont, pdc->pLogFont->sbc_devfont); // Transfer logical to device to screen here. rcDraw = *pRect; coor_LP2SP(pdc, &rcDraw.left, &rcDraw.top); coor_LP2SP(pdc, &rcDraw.right, &rcDraw.bottom); NormalizeRect (&rcDraw); if (dc_IsGeneralHDC(hdc)) { pthread_mutex_lock (&pdc->pGCRInfo->lock); if (!dc_GenerateECRgn (pdc, FALSE)) bOutput = FALSE; } pthread_mutex_lock (&__mg_gdilock); // set graphics context. GAL_SetGC (pdc->gc); // Draw text here. if (nFormat & DT_CALCRECT) bOutput = FALSE; y = rcDraw.top; if (nFormat & DT_SINGLELINE) { if (nFormat & DT_BOTTOM) y = rcDraw.bottom - pdc->pLogFont->size; else if (nFormat & DT_VCENTER) y = rcDraw.top + ((RECTH (rcDraw) - pdc->pLogFont->size) >> 1); } while (nCount != 0) { int nOutput; int maxwidth; if (nLines == 0) { maxwidth = rcDraw.right - rcDraw.left - indent; if (maxwidth <= 0) { // new line y += pdc->pLogFont->size; nLines ++; continue; } } else maxwidth = rcDraw.right - rcDraw.left; gdi_start_new_line (pdc->pLogFont); tabs = txtGetOneLine (pdc, pText, nCount, nTabWidth, maxwidth, nFormat, &n); gdi_get_TextOut_extent (pdc, pdc->pLogFont, pText, n, &size); width = size.cx + tabs * nTabWidth; n += tabs; if ( (pText[n-1] == '\n' || pText[n-1] == '\r') && !(nFormat & DT_SINGLELINE) ) { int tmpx = 0, tmpy = 0; nOutput = n - 1; width -= gdi_width_one_char (pdc->pLogFont, pdc->pLogFont->sbc_devfont, pText + n - 1, 1, &tmpx, &tmpy); } else nOutput = n; if (nFormat & DT_RIGHT) x = rcDraw.right - width; else if (nFormat & DT_CENTER) x = rcDraw.left + ((RECTW (rcDraw) - width) >> 1); else x = rcDraw.left; x += (nLines ? 0 : indent); rcOutput.left = x; rcOutput.top = y; rcOutput.right = rcOutput.left + width; rcOutput.bottom = rcOutput.top + line_height; NormalizeRect(&rcOutput); if (nFormat & DT_CALCRECT) { if (nLines == 0) *pRect = rcOutput; else GetBoundRect (pRect, pRect, &rcOutput); } // draw one line if (bOutput && width > 0) { if (!dc_IsMemHDC(hdc)) ShowCursorForGDI(FALSE, &rcOutput); if (nFormat & DT_NOCLIP) txtDrawOneLine (pdc, pText, nOutput, x, y, &rcOutput, nFormat, nTabWidth); else { RECT rcClip; IntersectRect (&rcClip, &rcOutput, &rcDraw); txtDrawOneLine (pdc, pText, nOutput, x, y, &rcClip, nFormat, nTabWidth); } if (!dc_IsMemHDC(hdc)) ShowCursorForGDI (TRUE, &rcOutput); } pText += n; // new line y += line_height; nLines ++; // left characters nCount = nCount - n; }
BOOL GUIAPI FillBoxWithBitmapPart (HDC hdc, int x, int y, int w, int h, int bw, int bh, const BITMAP* pBitmap, int xo, int yo) { PCLIPRECT pClipRect; PDC pdc; void* scaledBitmap = NULL; void* partBitmap = NULL; int sw = pBitmap->bmWidth, sh = pBitmap->bmHeight; RECT rcOutput; int bpp; if (pBitmap->bmWidth <= 0 || pBitmap->bmHeight <= 0 || pBitmap->bmBits == NULL) return FALSE; pdc = dc_HDC2PDC(hdc); bpp = GAL_BytesPerPixel (pdc->gc); if (dc_IsGeneralHDC(hdc)) { if (!dc_GenerateECRgn (pdc, FALSE)) { return TRUE; } } // Transfer logical to device to screen here. w += x; h += y; coor_LP2SP(pdc, &x, &y); coor_LP2SP(pdc, &w, &h); rcOutput.left = x; rcOutput.top = y; rcOutput.right = w; rcOutput.bottom = h; NormalizeRect (&rcOutput); w = RECTW (rcOutput); h = RECTH (rcOutput); IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound); if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput); // set graphics context. GAL_SetGC(pdc->gc); if (bw <= 0 || bh <= 0) { scaledBitmap = pBitmap->bmBits; bw = sw; bh = sh; } else if (bw == sw && bh == sh) scaledBitmap = pBitmap->bmBits; else { if ((scaledBitmap = malloc (GAL_BoxSize(pdc->gc, w, h))) == NULL) goto free_ret; GAL_ScaleBox (pdc->gc, sw, sh, pBitmap->bmBits, bw, bh, scaledBitmap); } // extract part box if ((partBitmap = malloc (GAL_BoxSize(pdc->gc, w, h))) == NULL) goto free_ret; bmpGetBoxPart (bpp, w, h, partBitmap, bw, bh, scaledBitmap, xo, yo); pClipRect = pdc->ecrgn.head; while(pClipRect) { if (DoesIntersect (&rcOutput, &pClipRect->rc)) { GAL_SetClipping(pdc->gc, pClipRect->rc.left, pClipRect->rc.top, pClipRect->rc.right - 1, pClipRect->rc.bottom - 1); if (pBitmap->bmType != BMP_TYPE_COLORKEY) GAL_PutBox (pdc->gc, x, y, w, h, partBitmap); else GAL_PutBoxMask (pdc->gc, x, y, w, h, partBitmap, pBitmap->bmColorKey); } pClipRect = pClipRect->next; } free_ret: if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(TRUE, &rcOutput); if (bw != sw || bh != sh) free (scaledBitmap); free (partBitmap); return TRUE; }
void GUIAPI FocusRect(HDC hdc, int x0, int y0, int x1, int y1) { PCLIPRECT pClipRect; PDC pdc; int l, t, r, b, w, h; RECT rcOutput; size_t sizeh, sizev; BYTE* vbuff = NULL; BYTE* hline1 = NULL, * hline2 = NULL; BYTE* vline1 = NULL, * vline2 = NULL; int bpp; BYTE xor_byte; pdc = dc_HDC2PDC(hdc); bpp = GAL_BytesPerPixel (pdc->gc); if (GAL_BitsPerPixel (pdc->gc) < 8) xor_byte = 0x0F; else xor_byte = 0xFF; if (dc_IsGeneralHDC(hdc)) { pthread_mutex_lock (&pdc->pGCRInfo->lock); if (!dc_GenerateECRgn (pdc, FALSE)) { pthread_mutex_unlock (&pdc->pGCRInfo->lock); return; } } // Transfer logical to device to screen here. coor_LP2SP(pdc, &x0, &y0); coor_LP2SP(pdc, &x1, &y1); l = MIN (x0, x1); t = MIN (y0, y1); r = MAX (x0, x1); b = MAX (y0, y1); rcOutput.left = l; rcOutput.top = t; rcOutput.right = r + 1; rcOutput.bottom = b + 1; pthread_mutex_lock (&__mg_gdilock); IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound); if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput); GAL_SetGC (pdc->gc); w = r - l + 1; h = b - t - 1; if (w == 0 || h == 0) goto my_exit; sizeh = w * bpp; sizev = h * bpp; #ifdef HAVE_ALLOCA if (!(vbuff = alloca ((sizeh << 1) + (sizev << 1)))) #else if (!(vbuff = malloc ((sizeh << 1) + (sizev << 1)))) #endif goto my_exit; if (w > 0) { int i, j; int offset; hline1 = vbuff; hline2 = vbuff + sizeh; GAL_GetBox (pdc->gc, l, t, w, 1, hline1); GAL_GetBox (pdc->gc, l, b, w, 1, hline2); offset = 0; for (i = 0; i < w; i += 2) { for (j = 0; j < bpp; j++) { hline1[offset + j] ^= xor_byte; hline2[offset + j] ^= xor_byte; } offset += bpp << 1; } } if (h > 0) { int i, j, offset; vline1 = vbuff + (sizeh << 1); vline2 = vbuff + (sizeh << 1) + sizev; GAL_GetBox (pdc->gc, l, t + 1, 1, h, vline1); GAL_GetBox (pdc->gc, r, t + 1, 1, h, vline2); offset = 0; for (i = 0; i < h; i += 2) { for (j = 0; j < bpp; j++) { vline1[offset + j] ^= xor_byte; vline2[offset + j] ^= xor_byte; } offset += bpp << 1; } } // set graphics context. GAL_SetGC (pdc->gc); pClipRect = pdc->ecrgn.head; while(pClipRect) { if (DoesIntersect (&rcOutput, &pClipRect->rc)) { GAL_SetClipping(pdc->gc, pClipRect->rc.left, pClipRect->rc.top, pClipRect->rc.right - 1, pClipRect->rc.bottom - 1); if (hline1) { GAL_PutBox (pdc->gc, l, t, w, 1, hline1); GAL_PutBox (pdc->gc, l, b, w, 1, hline2); } if (vline1) { GAL_PutBox (pdc->gc, l, t + 1, 1, h, vline1); GAL_PutBox (pdc->gc, r, t + 1, 1, h, vline2); } } pClipRect = pClipRect->next; } my_exit: if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(TRUE, &rcOutput); pthread_mutex_unlock (&__mg_gdilock); if (dc_IsGeneralHDC(hdc)) pthread_mutex_unlock (&pdc->pGCRInfo->lock); #ifndef HAVE_ALLOCA free (vbuff); #endif }
void GUIAPI DrawIcon(HDC hdc, int x, int y, int w, int h, HICON hicon) { PCLIPRECT pClipRect; PDC pdc; PICON picon = (PICON)hicon; int i; int imagesize; BYTE* iconimage; BYTE* andbits = NULL; BYTE* xorbits = NULL; RECT rcOutput; pdc = dc_HDC2PDC(hdc); if (dc_IsGeneralHDC(hdc)) { if (!dc_GenerateECRgn (pdc, FALSE)) { return; } } if(w <= 0) w = picon->width; if(h <= 0) h = picon->height; // Transfer logical to device to screen here. w += x; h += y; coor_LP2SP(pdc, &x, &y); coor_LP2SP(pdc, &w, &h); rcOutput.left = x; rcOutput.top = y; rcOutput.right = w; rcOutput.bottom = h; NormalizeRect (&rcOutput); w = RECTW (rcOutput); h = RECTH (rcOutput); IntersectRect (&rcOutput, &rcOutput, &pdc->ecrgn.rcBound); if( !dc_IsMemHDC(hdc) ) ShowCursorForGDI(FALSE, &rcOutput); GAL_SetGC (pdc->gc); imagesize = w * h * GAL_BytesPerPixel (pdc->gc); if ((iconimage = malloc (imagesize)) == NULL) goto free_ret; if (w != picon->width || h != picon->height) { andbits = malloc (imagesize); xorbits = malloc (imagesize); if (andbits == NULL || xorbits == NULL) goto free_ret; GAL_ScaleBox (pdc->gc, picon->width, picon->height, picon->AndBits, w, h, andbits); GAL_ScaleBox (pdc->gc, picon->width, picon->height, picon->XorBits, w, h, xorbits); } else { andbits = picon->AndBits; xorbits = picon->XorBits; } GAL_GetBox (pdc->gc, x, y, w, h, iconimage); for(i = 0; i < imagesize; i++) { iconimage[i] &= andbits [i]; iconimage[i] ^= xorbits [i]; } pClipRect = pdc->ecrgn.head; while (pClipRect) { if (DoesIntersect (&rcOutput, &pClipRect->rc)) { GAL_SetClipping(pdc->gc, pClipRect->rc.left, pClipRect->rc.top, pClipRect->rc.right - 1, pClipRect->rc.bottom - 1); GAL_PutBox(pdc->gc, x, y, w, h, iconimage); } pClipRect = pClipRect->next; } free_ret: if (!dc_IsMemHDC(hdc)) ShowCursorForGDI (TRUE, &rcOutput); free (iconimage); if (w != picon->width || h != picon->height) { free (andbits); free (xorbits); } }
void GUIAPI StretchBlt (HDC hsdc, int sx, int sy, int sw, int sh, HDC hddc, int dx, int dy, int dw, int dh, DWORD dwRop) { PCLIPRECT pClipRect; PDC psdc, pddc; void* srcBitmap = NULL; void* scaledBitmap = NULL; RECT rcOutput; psdc = dc_HDC2PDC(hsdc); pddc = dc_HDC2PDC(hddc); if (dc_IsGeneralHDC(hddc)) { if (!dc_GenerateECRgn (pddc, FALSE)) { return; } } // Transfer logical to device to screen here. sw += sx; sh += sy; coor_LP2SP(psdc, &sx, &sy); coor_LP2SP(psdc, &sw, &sh); (sw > sx) ? (sw -= sx) : (sw = sx - sw); (sh > sy) ? (sh -= sy) : (sh = sy - sh); dw += dx; dh += dy; coor_LP2SP(pddc, &dx, &dy); coor_LP2SP(pddc, &dw, &dh); rcOutput.left = dx; rcOutput.top = dy; rcOutput.right = dw; rcOutput.bottom = dh; NormalizeRect (&rcOutput); dw -= dx; dh -= dy; if (!dc_IsMemHDC(hddc)) ShowCursorForGDI(FALSE, &g_rcScr); GAL_SetGC (psdc->gc); if ((srcBitmap = malloc (GAL_BoxSize (psdc->gc, sw, sh))) == NULL || (scaledBitmap = malloc (GAL_BoxSize (pddc->gc, dw, dh))) == NULL) goto free_ret; GAL_GetBox (psdc->gc, sx, sy, sw, sh, srcBitmap); GAL_ScaleBox (psdc->gc, sw, sh, srcBitmap, dw, dh, scaledBitmap); GAL_SetGC (pddc->gc); pClipRect = pddc->ecrgn.head; while(pClipRect) { if (DoesIntersect (&rcOutput, &pClipRect->rc)) { GAL_SetClipping (pddc->gc, pClipRect->rc.left, pClipRect->rc.top, pClipRect->rc.right - 1, pClipRect->rc.bottom - 1); GAL_PutBox (pddc->gc, dx, dy, dw, dh, scaledBitmap); } pClipRect = pClipRect->next; } free_ret: if (!dc_IsMemHDC(hddc)) ShowCursorForGDI (TRUE, &g_rcScr); free (srcBitmap); free (scaledBitmap); }