ImageList: {x,y}Bitmap, misc

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



ChangeLog:
  -- implement support for xBitmap and yBitmap in ImageList_DrawIndirect
  -- small code, docs, and messages cleanups

Index: dlls/comctl32/imagelist.c
===================================================================
RCS file: /var/cvs/wine/dlls/comctl32/imagelist.c,v
retrieving revision 1.56
diff -u -r1.56 imagelist.c
--- dlls/comctl32/imagelist.c	16 Aug 2002 01:35:43 -0000	1.56
+++ dlls/comctl32/imagelist.c	2 Sep 2002 06:30:21 -0000
@@ -21,7 +21,7 @@
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  *
  *  TODO:
- *    - Fix ImageList_DrawIndirect (xBitmap, yBitmap, rgbFg, rgbBk, dwRop).
+ *    - Fix ImageList_DrawIndirect (rgbFg, rgbBk, dwRop).
  *    - Fix ImageList_GetIcon.
  *    - Fix ImageList_SetFilter (undocumented).
  *      BTW does anybody know anything about this function???
@@ -156,7 +156,7 @@
  * PARAMS
  *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
  *     cx            [I] the width of the image to display
- *     cy............[I] the height of the image to display
+ *     cy            [I] the height of the image to display
  *
  * RETURNS
  *     nothing
@@ -178,7 +178,7 @@
     BitBlt(pimldp->hdcDst,
         pimldp->x, pimldp->y, cx, cy,
         hImageDC,
-        pimldp->himl->cx * pimldp->i, 0,
+        pimldp->himl->cx * pimldp->i + pimldp->xBitmap, pimldp->yBitmap,
         SRCCOPY);
 
     SelectObject(hImageDC, hOldBitmap);
@@ -194,7 +194,7 @@
  * PARAMS
  *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
  *     cx            [I] the width of the image to display
- *     cy............[I] the height of the image to display
+ *     cy            [I] the height of the image to display
  *
  * RETURNS
  *     nothing
@@ -208,42 +208,27 @@
 static VOID
 IMAGELIST_InternalDrawMask(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
 {
-    BOOL bUseCustomBackground, bBlendFlag;
-    HBRUSH hBrush, hOldBrush;
-    HDC     hMaskDC, hImageDC;
     HBITMAP hOldBitmapImage, hOldBitmapMask;
     HIMAGELIST himlLocal = pimldp->himl;
-    COLORREF oldBkColor, oldFgColor;
     UINT fStyle = pimldp->fStyle & (~ILD_OVERLAYMASK);
 
     /*
      * We need a dc and bitmap to draw on that is
      * not on the screen.
      */
-    HDC hOffScreenDC = 0;
-    HBITMAP hOffScreenBmp = 0;
+    HDC hOffScreenDC = CreateCompatibleDC( pimldp->hdcDst );
+    HBITMAP hOffScreenBmp = CreateCompatibleBitmap( pimldp->hdcDst, cx, cy );
 
-    bUseCustomBackground = (himlLocal->clrBk != CLR_NONE);
-    bBlendFlag = (fStyle & ILD_BLEND50 ) || (fStyle & ILD_BLEND25);
+    BOOL bUseCustomBackground = (himlLocal->clrBk != CLR_NONE);
+    BOOL bBlendFlag = (fStyle & ILD_BLEND50 ) || (fStyle & ILD_BLEND25);
 
-    hImageDC = CreateCompatibleDC(0);
-    hMaskDC = CreateCompatibleDC(0);
+    HDC hImageDC = CreateCompatibleDC(0);
+    HDC hMaskDC = CreateCompatibleDC(0);
 
     /* Create a compatible DC. */
-    hOffScreenDC = CreateCompatibleDC( pimldp->hdcDst );
-
-    if ( hOffScreenDC )
-    {
-        hOffScreenBmp = CreateCompatibleBitmap( pimldp->hdcDst, cx, cy );
-
-        if ( hOffScreenBmp )
-            SelectObject( hOffScreenDC, hOffScreenBmp  );
-        else
-            goto cleanup;
-    }
-    else
-        goto cleanup;
-
+    if (!hOffScreenDC || !hOffScreenBmp || !hImageDC || !hMaskDC) goto cleanup;
+    SelectObject( hOffScreenDC, hOffScreenBmp  );
+    
     hOldBitmapImage = SelectObject(hImageDC, himlLocal->hbmImage);
     hOldBitmapMask = SelectObject(hMaskDC, himlLocal->hbmMask);
 
@@ -263,8 +248,8 @@
          || bBlendFlag) )
     {
 
-        hBrush = CreateSolidBrush (himlLocal->clrBk);
-        hOldBrush = SelectObject (pimldp->hdcDst, hBrush);
+        HBRUSH hBrush = CreateSolidBrush (himlLocal->clrBk);
+        HBRUSH hOldBrush = SelectObject (pimldp->hdcDst, hBrush);
 
         PatBlt( hOffScreenDC, pimldp->x, pimldp->y, cx, cy, PATCOPY );
 
@@ -282,15 +267,19 @@
          * monochrome mask.
          */
 
-        oldBkColor = SetBkColor( hOffScreenDC, RGB( 0xff, 0xff, 0xff ) );
-        oldFgColor = SetTextColor( hOffScreenDC, RGB( 0, 0, 0 ) );
+        COLORREF oldBk = SetBkColor( hOffScreenDC, RGB( 0xff, 0xff, 0xff ) );
+        COLORREF oldFg = SetTextColor( hOffScreenDC, RGB( 0, 0, 0 ) );
 
-        BitBlt( hOffScreenDC, 0, 0, cx, cy,hMaskDC, himlLocal->cx * pimldp->i,
-                0, SRCAND );
+        BitBlt( hOffScreenDC, 0, 0, cx, cy, hMaskDC, 
+		himlLocal->cx * pimldp->i + pimldp->xBitmap, pimldp->yBitmap, 
+		SRCAND );
 
-        BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC,himlLocal->cx * pimldp->i,
-                0, SRCPAINT );
+        BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC,
+		himlLocal->cx * pimldp->i + pimldp->xBitmap, pimldp->yBitmap, 
+                SRCPAINT );
 
+	SetBkColor( hOffScreenDC, oldBk);
+	SetBkColor( hOffScreenDC, oldFg);
     }
 
     /*
@@ -299,15 +288,17 @@
     else if((fStyle & ILD_IMAGE) && !bUseCustomBackground)
     {
         BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC,
-                himlLocal->cx * pimldp->i, 0, SRCCOPY);
+                himlLocal->cx * pimldp->i + pimldp->xBitmap, pimldp->yBitmap, 
+		SRCCOPY);
     }
     /*
      * Draw the mask with or without a background
      */
     else if(fStyle & ILD_MASK)
     {
-        BitBlt( hOffScreenDC, 0, 0, cx, cy, hMaskDC, himlLocal->cx * pimldp->i,
-                0, bUseCustomBackground ? SRCCOPY : SRCAND);
+        BitBlt( hOffScreenDC, 0, 0, cx, cy, hMaskDC,
+                himlLocal->cx * pimldp->i + pimldp->xBitmap, pimldp->yBitmap, 
+                bUseCustomBackground ? SRCCOPY : SRCAND);
     }
 
     /*
@@ -339,7 +330,7 @@
  * PARAMS
  *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
  *     cx            [I] the width of the image to display
- *     cy............[I] the height of the image to display
+ *     cy            [I] the height of the image to display
  *
  * RETURNS
  *     nothing
@@ -353,10 +344,10 @@
 IMAGELIST_InternalDrawBlend(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
 {
 
-    HDC         hBlendMaskDC,hMaskDC;
+    HDC         hBlendMaskDC;
     HBRUSH      hBlendColorBrush, hBlendBrush, hOldBrush;
     HBITMAP     hBlendMaskBitmap, hOldBitmap;
-    COLORREF    clrBlend, OldTextColor, OldBkColor;
+    COLORREF    clrBlend, oldFgColor, oldBkColor;
     HIMAGELIST  himlLocal = pimldp->himl;
 
     clrBlend = GetSysColor (COLOR_HIGHLIGHT);
@@ -382,20 +373,16 @@
     if(pimldp->himl->hbmMask != 0)
     {
         HBITMAP hOldMaskBitmap;
-        hMaskDC = CreateCompatibleDC(0);
+        HDC hMaskDC = CreateCompatibleDC(0);
         hOldMaskBitmap = (HBITMAP) SelectObject(hMaskDC, himlLocal->hbmMask);
 
-        BitBlt(hBlendMaskDC,
-            0,0, cx, cy,
-            hMaskDC,
-            himlLocal->cx * pimldp->i,0,
-            0x220326); /* NOTSRCAND */
-
-        BitBlt(hBlendMaskDC,
-            0,0, cx, cy,
-            hBlendMaskDC,
-            0,0,
-            NOTSRCCOPY);
+        BitBlt(hBlendMaskDC, 0, 0, cx, cy, hMaskDC,
+               himlLocal->cx * pimldp->i + pimldp->xBitmap, pimldp->yBitmap,
+               0x220326); /* NOTSRCAND */
+
+        BitBlt(hBlendMaskDC, 0, 0, cx, cy, hBlendMaskDC,
+               0, 0,
+               NOTSRCCOPY);
 
         SelectObject(hMaskDC, hOldMaskBitmap);
         DeleteDC(hMaskDC);
@@ -403,8 +390,8 @@
     }
     /* Apply blend to the current image given the BlendMask
     */
-    OldTextColor = SetTextColor(pimldp->hdcDst, 0);
-    OldBkColor = SetBkColor(pimldp->hdcDst, RGB(255,255,255));
+    oldFgColor = SetTextColor(pimldp->hdcDst, RGB(0, 0, 0));
+    oldBkColor = SetBkColor(pimldp->hdcDst, RGB(255,255,255));
     hBlendColorBrush = CreateSolidBrush(clrBlend);
     hOldBrush = (HBRUSH) SelectObject (pimldp->hdcDst, hBlendColorBrush);
 
@@ -415,8 +402,8 @@
         0xB8074A); /* PSDPxax */
 
     SelectObject(pimldp->hdcDst, hOldBrush);
-    SetTextColor(pimldp->hdcDst, OldTextColor);
-    SetBkColor(pimldp->hdcDst, OldBkColor);
+    SetTextColor(pimldp->hdcDst, oldFgColor);
+    SetBkColor(pimldp->hdcDst, oldBkColor);
     SelectObject(hBlendMaskDC, hOldBitmap);
     DeleteDC(hBlendMaskDC);
     DeleteObject(hBlendMaskBitmap);
@@ -431,7 +418,7 @@
  * PARAMS
  *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
  *     cx            [I] the width of the image to display
- *     cy............[I] the height of the image to display
+ *     cy            [I] the height of the image to display
  *
  * RETURNS
  *     nothing
@@ -445,42 +432,36 @@
 static VOID
 IMAGELIST_InternalDrawOverlay(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
 {
-    INT     nOvlIdx;
-    HDC     hImageDC;
+    INT nOvlIdx;
+    HDC hImageDC;
     HBITMAP hOldBitmap;
-
+    
     nOvlIdx = (pimldp->fStyle & ILD_OVERLAYMASK) >> 8;
-    if ((nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE))
-    {
-        nOvlIdx = pimldp->himl->nOvlIdx[nOvlIdx - 1];
-        if ((nOvlIdx >= 0) && (nOvlIdx <= pimldp->himl->cCurImage))
-        {
-            hImageDC = CreateCompatibleDC(0);
-            if (pimldp->himl->hbmMask)
-            {
-                hOldBitmap = (HBITMAP) SelectObject (hImageDC,
-                    pimldp->himl->hbmMask);
-
-                BitBlt (pimldp->hdcDst,
-                    pimldp->x, pimldp->y, cx, cy,
-                    hImageDC, pimldp->himl->cx * nOvlIdx, 0,
-                    SRCAND);
-
-                SelectObject(hImageDC, hOldBitmap);
-            }
-            hOldBitmap = (HBITMAP) SelectObject (hImageDC,
-                pimldp->himl->hbmImage);
-
-            BitBlt (pimldp->hdcDst,
-                pimldp->x, pimldp->y, cx, cy,
-                hImageDC,
-                pimldp->himl->cx * nOvlIdx, 0,
-                SRCPAINT);
+    if ( (nOvlIdx < 1) || (nOvlIdx > MAX_OVERLAYIMAGE)) return;
+    
+    nOvlIdx = pimldp->himl->nOvlIdx[nOvlIdx - 1];
+    if ((nOvlIdx < 0) || (nOvlIdx > pimldp->himl->cCurImage)) return;
+
+    if (!(hImageDC = CreateCompatibleDC(0))) return;
+    
+    if (pimldp->himl->hbmMask) {
+        hOldBitmap = (HBITMAP) SelectObject (hImageDC, pimldp->himl->hbmMask);
+
+        BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, hImageDC,
+		pimldp->himl->cx * nOvlIdx + pimldp->xBitmap, pimldp->yBitmap,
+	       	SRCAND);
+
+        SelectObject(hImageDC, hOldBitmap);
+    }
+    
+    hOldBitmap = (HBITMAP) SelectObject (hImageDC, pimldp->himl->hbmImage);
+
+    BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, hImageDC,
+	    pimldp->himl->cx * nOvlIdx + pimldp->xBitmap, pimldp->yBitmap,
+	    SRCPAINT);
 
-            SelectObject(hImageDC, hOldBitmap);
-            DeleteDC(hImageDC);
-        }
-    }
+    SelectObject(hImageDC, hOldBitmap);
+    DeleteDC(hImageDC);
 }
 
 
@@ -743,7 +724,7 @@
 
     InternalDrag.himl = ImageList_Create (cx, cy, himlTrack->flags, 1, 1);
     if (InternalDrag.himl == NULL) {
-        ERR("Error creating drag image list!\n");
+        WARN("Error creating drag image list!\n");
         return FALSE;
     }
 
@@ -1332,8 +1313,8 @@
  *     hdc    [I] handle to device context
  *     x      [I] X position
  *     y      [I] Y position
- *     xOffs  [I] X offset
- *     yOffs  [I] Y offset
+ *     dx     [I] X offset
+ *     dy     [I] Y offset
  *     rgbBk  [I] background color
  *     rgbFg  [I] foreground color
  *     fStyle [I] drawing flags
@@ -1402,7 +1383,6 @@
     if (pimldp->himl == NULL)
         return FALSE;
     if ((pimldp->i < 0) || (pimldp->i >= pimldp->himl->cCurImage)) {
-	ERR("%d not within range (max %d)\n",pimldp->i,pimldp->himl->cCurImage-1);
         return FALSE;
     }
     /*
@@ -1625,7 +1605,6 @@
     HDC    hdcSrc, hdcDst;
 
     if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) {
-	FIXME("(%p,%d,%x), params out of range!\n",himl,i,fStyle);
 	return 0;
    }
 



[Index of Archives]     [Gimp for Windows]     [Red Hat]     [Samba]     [Yosemite Camping]     [Graphics Cards]     [Wine Home]

  Powered by Linux