Changeset 9370 for trunk/src/comctl32/imagelist.c
- Timestamp:
- Oct 29, 2002, 1:19:36 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/imagelist.c
r8520 r9370 3 3 * 4 4 * Copyright 1998 Eric Kohl 5 * 2000 Jason Mawdsley. 6 * 2001 Michael Stefaniuc 7 * 2001 Charles Loep for CodeWeavers 5 * Copyright 2000 Jason Mawdsley 6 * Copyright 2001 Michael Stefaniuc 7 * Copyright 2001 Charles Loep for CodeWeavers 8 * Copyright 2002 Dimitrie O. Paun 8 9 * 9 10 * This library is free software; you can redistribute it and/or … … 21 22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 22 23 * 24 * NOTE 25 * 26 * This code was audited for completeness against the documented features 27 * of Comctl32.dll version 6.0 on Sep. 12, 2002, by Dimitrie O. Paun. 28 * 29 * Unless otherwise noted, we belive this code to be complete, as per 30 * the specification mentioned above. 31 * If you discover missing features, or bugs, please note them below. 32 * 23 33 * TODO: 24 * - Fix ImageList_DrawIndirect (xBitmap, yBitmap, rgbFg, rgbBk, dwRop). 25 * - Fix ImageList_GetIcon. 26 * - Fix ImageList_SetFilter (undocumented). 27 * BTW does anybody know anything about this function??? 28 * - It removes 12 Bytes from the stack (3 Parameters). 29 * - First parameter SHOULD be a HIMAGELIST. 30 * - Second parameter COULD be an index????? 31 * - Third parameter.... ????????????????????? 32 * 33 * Comments: 34 * - ImageList_Draw, ImageList_DrawEx and ImageList_GetIcon use 35 * ImageList_DrawIndirect. Since ImageList_DrawIndirect is still 36 * partially implemented, the functions mentioned above will be 37 * limited in functionality too. 38 * 34 * - Add support for ILD_PRESERVEALPHA, ILD_SCALE, ILD_DPISCALE 35 * - Add support for ILS_GLOW, ILS_SHADOW, ILS_SATURATE, ILS_ALPHA 36 * 37 * FIXME: 39 38 * - Hotspot handling still not correct. The Hotspot passed to BeginDrag 40 39 * is the offset of the image position relative to the actual mouse pointer … … 81 80 82 81 /************************************************************************* 83 * IMAGELIST_InternalExpandBitmaps [Internal] 82 * IMAGELIST_InternalExpandBitmaps [Internal] 84 83 * 85 84 * Expands the bitmaps of an image list by the given number of images. … … 95 94 * This function can NOT be used to reduce the number of images. 96 95 */ 97 static VOID96 static void 98 97 IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount, INT cx, INT cy) 99 98 { … … 128 127 129 128 if (himl->hbmMask) { 130 hbmNewBitmap = 129 hbmNewBitmap = 131 130 CreateBitmap (nNewWidth, cy, 1, 1, NULL); 132 131 … … 150 149 151 150 /************************************************************************* 152 * IMAGELIST_InternalDraw [Internal] 153 * 154 * Draws the image in the ImageList (without the mask) 155 * 156 * PARAMS 157 * pimldp [I] pointer to IMAGELISTDRAWPARAMS structure. 158 * cx [I] the width of the image to display 159 * cy............[I] the height of the image to display 160 * 161 * RETURNS 162 * nothing 163 * 164 * NOTES 165 * This function is used by ImageList_DrawIndirect, when it is 166 * required to draw only the Image (without the mask) to the screen. 167 * 168 * Blending and Overlays styles are accomplished by another function 169 */ 170 static VOID 171 IMAGELIST_InternalDraw(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy) 172 { 173 HDC hImageDC; 174 HBITMAP hOldBitmap; 175 176 hImageDC = CreateCompatibleDC(0); 177 hOldBitmap = SelectObject(hImageDC, pimldp->himl->hbmImage); 178 BitBlt(pimldp->hdcDst, 179 pimldp->x, pimldp->y, cx, cy, 180 hImageDC, 181 pimldp->himl->cx * pimldp->i, 0, 182 SRCCOPY); 183 184 SelectObject(hImageDC, hOldBitmap); 185 DeleteDC(hImageDC); 186 } 187 188 189 /************************************************************************* 190 * IMAGELIST_InternalDrawMask [Internal] 191 * 192 * Draws the image in the ImageList with the mask 193 * 194 * PARAMS 195 * pimldp [I] pointer to IMAGELISTDRAWPARAMS structure. 196 * cx [I] the width of the image to display 197 * cy............[I] the height of the image to display 198 * 199 * RETURNS 200 * nothing 201 * 202 * NOTES 203 * This function is used by ImageList_DrawIndirect, when it is 204 * required to draw the Image with the mask to the screen. 205 * 206 * Blending and Overlays styles are accomplished by another function. 207 */ 208 static VOID 209 IMAGELIST_InternalDrawMask(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy) 210 { 211 BOOL bUseCustomBackground, bBlendFlag; 212 HBRUSH hBrush, hOldBrush; 213 HDC hMaskDC, hImageDC; 214 HBITMAP hOldBitmapImage, hOldBitmapMask; 215 HIMAGELIST himlLocal = pimldp->himl; 216 COLORREF oldBkColor, oldFgColor; 217 UINT fStyle = pimldp->fStyle & (~ILD_OVERLAYMASK); 218 219 /* 220 * We need a dc and bitmap to draw on that is 221 * not on the screen. 222 */ 223 HDC hOffScreenDC = 0; 224 HBITMAP hOffScreenBmp = 0; 225 226 bUseCustomBackground = (himlLocal->clrBk != CLR_NONE); 227 bBlendFlag = (fStyle & ILD_BLEND50 ) || (fStyle & ILD_BLEND25); 228 229 hImageDC = CreateCompatibleDC(0); 230 hMaskDC = CreateCompatibleDC(0); 231 232 /* Create a compatible DC. */ 233 hOffScreenDC = CreateCompatibleDC( pimldp->hdcDst ); 234 235 if ( hOffScreenDC ) 236 { 237 hOffScreenBmp = CreateCompatibleBitmap( pimldp->hdcDst, cx, cy ); 238 239 if ( hOffScreenBmp ) 240 SelectObject( hOffScreenDC, hOffScreenBmp ); 241 else 242 goto cleanup; 243 } 244 else 245 goto cleanup; 246 247 hOldBitmapImage = SelectObject(hImageDC, himlLocal->hbmImage); 248 hOldBitmapMask = SelectObject(hMaskDC, himlLocal->hbmMask); 249 250 /* 251 * Get a copy of the image for the masking operations. 252 * We will use the copy, and this dc for all the various 253 * blitting, and then do one final blit to the screen dc. 254 * This should clean up most of the flickering. 255 */ 256 BitBlt( hOffScreenDC, 0, 0, cx, cy, pimldp->hdcDst, pimldp->x, 257 pimldp->y, SRCCOPY); 258 259 /* 260 * Draw the Background for the appropriate Styles 261 */ 262 if( bUseCustomBackground && (fStyle == ILD_NORMAL || fStyle & ILD_IMAGE 263 || bBlendFlag) ) 264 { 265 266 hBrush = CreateSolidBrush (himlLocal->clrBk); 267 hOldBrush = SelectObject (pimldp->hdcDst, hBrush); 268 269 PatBlt( hOffScreenDC, pimldp->x, pimldp->y, cx, cy, PATCOPY ); 270 271 DeleteObject (SelectObject (pimldp->hdcDst, hOldBrush)); 272 } 273 274 /* 275 * Draw Image Transparently over the current background 276 */ 277 if(fStyle == ILD_NORMAL || (fStyle & ILD_TRANSPARENT) || 278 ((fStyle & ILD_IMAGE) && bUseCustomBackground) || bBlendFlag) 279 { /* 280 * To obtain a transparent look, background color should be set 281 * to white and foreground color to black when blting the 282 * monochrome mask. 283 */ 284 285 oldBkColor = SetBkColor( hOffScreenDC, RGB( 0xff, 0xff, 0xff ) ); 286 oldFgColor = SetTextColor( hOffScreenDC, RGB( 0, 0, 0 ) ); 287 288 BitBlt( hOffScreenDC, 0, 0, cx, cy,hMaskDC, himlLocal->cx * pimldp->i, 289 0, SRCAND ); 290 291 BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC,himlLocal->cx * pimldp->i, 292 0, SRCPAINT ); 293 294 } 295 296 /* 297 * Draw the image when no Background is specified 298 */ 299 else if((fStyle & ILD_IMAGE) && !bUseCustomBackground) 300 { 301 BitBlt( hOffScreenDC, 0, 0, cx, cy, hImageDC, 302 himlLocal->cx * pimldp->i, 0, SRCCOPY); 303 } 304 /* 305 * Draw the mask with or without a background 306 */ 307 else if(fStyle & ILD_MASK) 308 { 309 BitBlt( hOffScreenDC, 0, 0, cx, cy, hMaskDC, himlLocal->cx * pimldp->i, 310 0, bUseCustomBackground ? SRCCOPY : SRCAND); 311 } 312 313 /* 314 * Blit the bitmap to the screen now. 315 */ 316 BitBlt( pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, 317 hOffScreenDC, 0, 0, SRCCOPY); 318 319 320 SelectObject(hImageDC, hOldBitmapImage); 321 SelectObject(hMaskDC, hOldBitmapMask); 322 323 cleanup: 324 325 DeleteDC(hImageDC); 326 DeleteDC(hMaskDC); 327 328 DeleteDC( hOffScreenDC ); 329 DeleteObject( hOffScreenBmp ); 330 331 return; 332 } 333 334 /************************************************************************* 335 * IMAGELIST_InternalDrawBlend [Internal] 336 * 337 * Draws the Blend over the current image 338 * 339 * PARAMS 340 * pimldp [I] pointer to IMAGELISTDRAWPARAMS structure. 341 * cx [I] the width of the image to display 342 * cy............[I] the height of the image to display 343 * 344 * RETURNS 345 * nothing 346 * 347 * NOTES 348 * This functions is used by ImageList_DrawIndirect, when it is 349 * required to add the blend to the current image. 350 * 351 */ 352 static VOID 353 IMAGELIST_InternalDrawBlend(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy) 354 { 355 356 HDC hBlendMaskDC,hMaskDC; 357 HBRUSH hBlendColorBrush, hBlendBrush, hOldBrush; 358 HBITMAP hBlendMaskBitmap, hOldBitmap; 359 COLORREF clrBlend, OldTextColor, OldBkColor; 360 HIMAGELIST himlLocal = pimldp->himl; 361 362 clrBlend = GetSysColor (COLOR_HIGHLIGHT); 363 if (!(pimldp->rgbFg == CLR_DEFAULT)) 364 { 365 clrBlend = pimldp->rgbFg; 366 } 367 /* Create the blend Mask 368 */ 369 hBlendMaskDC = CreateCompatibleDC(0); 370 hBlendBrush = pimldp->fStyle & ILD_BLEND50 ? 371 himlLocal->hbrBlend50 : himlLocal->hbrBlend25; 372 373 hBlendMaskBitmap = CreateBitmap(cx, cy, 1, 1, NULL); 374 hOldBitmap = SelectObject(hBlendMaskDC, hBlendMaskBitmap); 375 376 hOldBrush = (HBRUSH) SelectObject(hBlendMaskDC, hBlendBrush); 377 PatBlt(hBlendMaskDC, 0, 0, cx, cy, PATCOPY); 378 SelectObject(hBlendMaskDC, hOldBrush); 379 380 /* Modify the blend mask if an Image Mask exist 381 */ 382 if(pimldp->himl->hbmMask != 0) 383 { 384 HBITMAP hOldMaskBitmap; 385 hMaskDC = CreateCompatibleDC(0); 386 hOldMaskBitmap = (HBITMAP) SelectObject(hMaskDC, himlLocal->hbmMask); 387 388 BitBlt(hBlendMaskDC, 389 0,0, cx, cy, 390 hMaskDC, 391 himlLocal->cx * pimldp->i,0, 392 0x220326); /* NOTSRCAND */ 393 394 BitBlt(hBlendMaskDC, 395 0,0, cx, cy, 396 hBlendMaskDC, 397 0,0, 398 NOTSRCCOPY); 399 400 SelectObject(hMaskDC, hOldMaskBitmap); 401 DeleteDC(hMaskDC); 402 403 } 404 /* Apply blend to the current image given the BlendMask 405 */ 406 OldTextColor = SetTextColor(pimldp->hdcDst, 0); 407 OldBkColor = SetBkColor(pimldp->hdcDst, RGB(255,255,255)); 408 hBlendColorBrush = CreateSolidBrush(clrBlend); 409 hOldBrush = (HBRUSH) SelectObject (pimldp->hdcDst, hBlendColorBrush); 410 411 BitBlt (pimldp->hdcDst, 412 pimldp->x, pimldp->y, cx, cy, 413 hBlendMaskDC, 414 0, 0, 415 0xB8074A); /* PSDPxax */ 416 417 SelectObject(pimldp->hdcDst, hOldBrush); 418 SetTextColor(pimldp->hdcDst, OldTextColor); 419 SetBkColor(pimldp->hdcDst, OldBkColor); 420 SelectObject(hBlendMaskDC, hOldBitmap); 421 DeleteDC(hBlendMaskDC); 422 DeleteObject(hBlendMaskBitmap); 423 DeleteObject(hBlendColorBrush); 424 } 425 426 /************************************************************************* 427 * IMAGELIST_InternalDrawOverlay [Internal] 428 * 429 * Draws the overlay image 430 * 431 * PARAMS 432 * pimldp [I] pointer to IMAGELISTDRAWPARAMS structure. 433 * cx [I] the width of the image to display 434 * cy............[I] the height of the image to display 435 * 436 * RETURNS 437 * nothing 438 * 439 * NOTES 440 * This functions is used by ImageList_DrawIndirect, when it is 441 * required to draw the overlay 442 * 443 * 444 */ 445 static VOID 446 IMAGELIST_InternalDrawOverlay(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy) 447 { 448 INT nOvlIdx; 449 HDC hImageDC; 450 HBITMAP hOldBitmap; 451 452 nOvlIdx = (pimldp->fStyle & ILD_OVERLAYMASK) >> 8; 453 if ((nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE)) 454 { 455 nOvlIdx = pimldp->himl->nOvlIdx[nOvlIdx - 1]; 456 if ((nOvlIdx >= 0) && (nOvlIdx <= pimldp->himl->cCurImage)) 457 { 458 hImageDC = CreateCompatibleDC(0); 459 if (pimldp->himl->hbmMask) 460 { 461 hOldBitmap = (HBITMAP) SelectObject (hImageDC, 462 pimldp->himl->hbmMask); 463 464 BitBlt (pimldp->hdcDst, 465 pimldp->x, pimldp->y, cx, cy, 466 hImageDC, pimldp->himl->cx * nOvlIdx, 0, 467 SRCAND); 468 469 SelectObject(hImageDC, hOldBitmap); 470 } 471 hOldBitmap = (HBITMAP) SelectObject (hImageDC, 472 pimldp->himl->hbmImage); 473 474 BitBlt (pimldp->hdcDst, 475 pimldp->x, pimldp->y, cx, cy, 476 hImageDC, 477 pimldp->himl->cx * nOvlIdx, 0, 478 SRCPAINT); 479 480 SelectObject(hImageDC, hOldBitmap); 481 DeleteDC(hImageDC); 482 } 483 } 484 } 485 486 487 /************************************************************************* 488 * ImageList_Add [COMCTL32.40] 151 * ImageList_Add [COMCTL32.@] 489 152 * 490 153 * Add an image or images to an image list. … … 509 172 HBITMAP hOldBitmapImage, hOldBitmap; 510 173 511 TRACE("himl=%p hbmimage=% x hbmmask=%x\n", himl, hbmImage, hbmMask);174 TRACE("himl=%p hbmimage=%p hbmmask=%p\n", himl, hbmImage, hbmMask); 512 175 if (!himl || !hbmImage) 513 176 return -1; … … 533 196 if(himl->hbmMask) 534 197 { 535 HDC hdcMask, hdcTemp, hOldBitmapMask, hOldBitmapTemp; 198 HDC hdcMask, hdcTemp; 199 HBITMAP hOldBitmapMask, hOldBitmapTemp; 536 200 537 201 hdcMask = CreateCompatibleDC (0); 538 202 hdcTemp = CreateCompatibleDC(0); 539 hOldBitmapMask = (HBITMAP)SelectObject(hdcMask, himl->hbmMask);540 hOldBitmapTemp = (HBITMAP)SelectObject(hdcTemp, hbmMask);541 542 BitBlt (hdcMask, 203 hOldBitmapMask = SelectObject(hdcMask, himl->hbmMask); 204 hOldBitmapTemp = SelectObject(hdcTemp, hbmMask); 205 206 BitBlt (hdcMask, 543 207 nStartX, 0, bmp.bmWidth, bmp.bmHeight, 544 hdcTemp, 545 0, 0, 208 hdcTemp, 209 0, 0, 546 210 SRCCOPY); 547 211 … … 551 215 /* Remove the background from the image 552 216 */ 553 BitBlt (hdcImage, 217 BitBlt (hdcImage, 554 218 nStartX, 0, bmp.bmWidth, bmp.bmHeight, 555 hdcMask, 556 nStartX, 0, 219 hdcMask, 220 nStartX, 0, 557 221 0x220326); /* NOTSRCAND */ 558 222 … … 574 238 575 239 /************************************************************************* 576 * ImageList_AddIcon [COMCTL32. 41]240 * ImageList_AddIcon [COMCTL32.@] 577 241 * 578 242 * Adds an icon to an image list. … … 595 259 596 260 /************************************************************************* 597 * ImageList_AddMasked [COMCTL32. 42]261 * ImageList_AddMasked [COMCTL32.@] 598 262 * 599 263 * Adds an image or images to an image list and creates a mask from the … … 620 284 COLORREF bkColor; 621 285 622 TRACE("himl=%p hbitmap=% xclrmask=%lx\n", himl, hBitmap, clrMask);286 TRACE("himl=%p hbitmap=%p clrmask=%lx\n", himl, hBitmap, clrMask); 623 287 if (himl == NULL) 624 288 return -1; … … 660 324 GetPixel (hdcBitmap, 0, 0); 661 325 SetBkColor (hdcBitmap, bkColor); 662 BitBlt (hdcMask, 326 BitBlt (hdcMask, 663 327 nMaskXOffset, 0, bmp.bmWidth, bmp.bmHeight, 664 hdcBitmap, 0, 0, 328 hdcBitmap, 0, 0, 665 329 SRCCOPY); 666 330 … … 677 341 This is here in case some apps rely on this bug 678 342 */ 679 BitBlt(hdcBitmap, 343 BitBlt(hdcBitmap, 680 344 0, 0, bmp.bmWidth, bmp.bmHeight, 681 hdcMask, 682 nMaskXOffset, 0, 345 hdcMask, 346 nMaskXOffset, 0, 683 347 0x220326); /* NOTSRCAND */ 684 348 /* Copy result to the imagelist 685 349 */ 686 BitBlt (hdcImage, 350 BitBlt (hdcImage, 687 351 nIndex * himl->cx, 0, bmp.bmWidth, bmp.bmHeight, 688 hdcBitmap, 689 0, 0, 352 hdcBitmap, 353 0, 0, 690 354 SRCCOPY); 691 355 /* Clean up … … 707 371 708 372 /************************************************************************* 709 * ImageList_BeginDrag [COMCTL32. 43]373 * ImageList_BeginDrag [COMCTL32.@] 710 374 * 711 375 * Creates a temporary image list that contains one image. It will be used … … 744 408 InternalDrag.himl = ImageList_Create (cx, cy, himlTrack->flags, 1, 1); 745 409 if (InternalDrag.himl == NULL) { 746 ERR("Error creating drag image list!\n");410 WARN("Error creating drag image list!\n"); 747 411 return FALSE; 748 412 } … … 775 439 776 440 /************************************************************************* 777 * ImageList_Copy [COMCTL32. 44]778 * 779 * Copies an image of the source image list to an image of the 441 * ImageList_Copy [COMCTL32.@] 442 * 443 * Copies an image of the source image list to an image of the 780 444 * destination image list. Images can be copied or swapped. 781 445 * … … 801 465 INT iSrc, INT uFlags) 802 466 { 803 HDC hdcSrc, hdcDst; 467 HDC hdcSrc, hdcDst; 804 468 805 469 TRACE("iDst=%d iSrc=%d\n", iDst, iSrc); … … 903 567 904 568 /************************************************************************* 905 * ImageList_Create [COMCTL32. 45] Creates a new image list.569 * ImageList_Create [COMCTL32.@] Creates a new image list. 906 570 * 907 571 * PARAMS … … 925 589 INT nCount; 926 590 HBITMAP hbmTemp; 927 static WORD aBitBlend25[] = 591 static WORD aBitBlend25[] = 928 592 {0xAA, 0x00, 0x55, 0x00, 0xAA, 0x00, 0x55, 0x00}; 929 593 … … 968 632 else 969 633 himl->hbmImage = 0; 970 971 if ( (himl->cMaxImage > 0) && (himl->flags & ILC_MASK)) { 972 himl->hbmMask = CreateBitmap (himl->cx * himl->cMaxImage, himl->cy, 634 635 if ( (himl->flags & ILC_MASK)) { 636 int images = himl->cMaxImage; 637 if (images <= 0) 638 images = 1; 639 640 himl->hbmMask = CreateBitmap (himl->cx * images, himl->cy, 973 641 1, 1, NULL); 974 642 if (himl->hbmMask == 0) { … … 997 665 998 666 /************************************************************************* 999 * ImageList_Destroy [COMCTL32. 46]667 * ImageList_Destroy [COMCTL32.@] 1000 668 * 1001 669 * Destroys an image list. … … 1011 679 BOOL WINAPI 1012 680 ImageList_Destroy (HIMAGELIST himl) 1013 { 681 { 1014 682 if (!himl) 1015 683 return FALSE; … … 1026 694 if (himl->hbrBlend50) 1027 695 DeleteObject (himl->hbrBlend50); 1028 696 1029 697 COMCTL32_Free (himl); 1030 698 … … 1034 702 1035 703 /************************************************************************* 1036 * ImageList_DragEnter [COMCTL32. 47]704 * ImageList_DragEnter [COMCTL32.@] 1037 705 * 1038 706 * Locks window update and displays the drag image at the given position. … … 1055 723 ImageList_DragEnter (HWND hwndLock, INT x, INT y) 1056 724 { 1057 TRACE("(hwnd=% #xx=%d y=%d)\n", hwndLock, x, y);725 TRACE("(hwnd=%p x=%d y=%d)\n", hwndLock, x, y); 1058 726 1059 727 if (InternalDrag.himl == NULL) … … 1078 746 1079 747 /************************************************************************* 1080 * ImageList_DragLeave [COMCTL32. 48]748 * ImageList_DragLeave [COMCTL32.@] 1081 749 * 1082 750 * Unlocks window update and hides the drag image. … … 1111 779 1112 780 /************************************************************************* 1113 * ImageList_DragMove [COMCTL32.49] 781 * ImageList_InternalDragDraw [Internal] 782 * 783 * Draws the drag image. 784 * 785 * PARAMS 786 * hdc [I] device context to draw into. 787 * x [I] X position of the drag image. 788 * y [I] Y position of the drag image. 789 * 790 * RETURNS 791 * Success: TRUE 792 * Failure: FALSE 793 * 794 * NOTES 795 * The position of the drag image is relative to the window, not 796 * the client area. 797 * 798 */ 799 800 static inline void 801 ImageList_InternalDragDraw (HDC hdc, INT x, INT y) 802 { 803 IMAGELISTDRAWPARAMS imldp; 804 805 ZeroMemory (&imldp, sizeof(imldp)); 806 imldp.cbSize = sizeof(imldp); 807 imldp.himl = InternalDrag.himl; 808 imldp.i = 0; 809 imldp.hdcDst = hdc, 810 imldp.x = x; 811 imldp.y = y; 812 imldp.rgbBk = CLR_DEFAULT; 813 imldp.rgbFg = CLR_DEFAULT; 814 imldp.fStyle = ILD_NORMAL; 815 imldp.fState = ILS_ALPHA; 816 imldp.Frame = 128; 817 818 /* FIXME: instead of using the alpha blending, we should 819 * create a 50% mask, and draw it semitransparantly that way */ 820 ImageList_DrawIndirect (&imldp); 821 } 822 823 /************************************************************************* 824 * ImageList_DragMove [COMCTL32.@] 1114 825 * 1115 826 * Moves the drag image. … … 1150 861 INT origRegX, origRegY; 1151 862 INT sizeRegX, sizeRegY; 1152 863 1153 864 1154 865 /* calculate the update region */ … … 1182 893 hdcOffScreen, origNewX - origRegX, origNewY - origRegY, SRCCOPY); 1183 894 /* draw the image */ 1184 /* FIXME: image should be drawn semitransparent */ 1185 ImageList_Draw(InternalDrag.himl, 0, hdcOffScreen, origNewX - origRegX, 1186 origNewY - origRegY, ILD_NORMAL); 895 ImageList_InternalDragDraw(hdcOffScreen, origNewX - origRegX, 896 origNewY - origRegY); 1187 897 /* draw the update region to the screen */ 1188 898 BitBlt(hdcDrag, origRegX, origRegY, sizeRegX, sizeRegY, … … 1204 914 1205 915 /************************************************************************* 1206 * ImageList_DragShowNolock [COMCTL32. 50]916 * ImageList_DragShowNolock [COMCTL32.@] 1207 917 * 1208 918 * Shows or hides the drag image. … … 1249 959 } 1250 960 SelectObject(hdcBg, InternalDrag.hbmBg); 1251 961 1252 962 if (bShow) { 1253 963 /* save the background */ … … 1255 965 hdcDrag, x, y, SRCCOPY); 1256 966 /* show the image */ 1257 /* FIXME: this should be drawn semitransparent */ 1258 ImageList_Draw(InternalDrag.himl, 0, hdcDrag, x, y, ILD_NORMAL); 1259 } else { 967 ImageList_InternalDragDraw(hdcDrag, x, y); 968 } else { 1260 969 /* hide the image */ 1261 970 BitBlt(hdcDrag, x, y, InternalDrag.himl->cx, InternalDrag.himl->cy, … … 1272 981 1273 982 /************************************************************************* 1274 * ImageList_Draw [COMCTL32. 51] Draws an image.983 * ImageList_Draw [COMCTL32.@] Draws an image. 1275 984 * 1276 985 * PARAMS … … 1286 995 * Failure: FALSE 1287 996 * 1288 * NOTES1289 * Calls ImageList_DrawIndirect.1290 *1291 997 * SEE 1292 * ImageList_Draw Indirect.998 * ImageList_DrawEx. 1293 999 */ 1294 1000 1295 1001 BOOL WINAPI 1296 ImageList_Draw (HIMAGELIST himl, INT i, HDC hdc, 1297 INT x, INT y, UINT fStyle) 1298 { 1299 IMAGELISTDRAWPARAMS imldp; 1300 1301 imldp.cbSize = sizeof(IMAGELISTDRAWPARAMS); 1302 imldp.himl = himl; 1303 imldp.i = i; 1304 imldp.hdcDst = hdc, 1305 imldp.x = x; 1306 imldp.y = y; 1307 imldp.cx = 0; 1308 imldp.cy = 0; 1309 imldp.xBitmap = 0; 1310 imldp.yBitmap = 0; 1311 imldp.rgbBk = CLR_DEFAULT; 1312 imldp.rgbFg = CLR_DEFAULT; 1313 imldp.fStyle = fStyle; 1314 imldp.dwRop = 0; 1315 1316 return ImageList_DrawIndirect (&imldp); 1317 } 1318 1319 1320 /************************************************************************* 1321 * ImageList_DrawEx [COMCTL32.52] 1002 ImageList_Draw (HIMAGELIST himl, INT i, HDC hdc, INT x, INT y, UINT fStyle) 1003 { 1004 return ImageList_DrawEx (himl, i, hdc, x, y, 0, 0, 1005 CLR_DEFAULT, CLR_DEFAULT, fStyle); 1006 } 1007 1008 1009 /************************************************************************* 1010 * ImageList_DrawEx [COMCTL32.@] 1322 1011 * 1323 1012 * Draws an image and allows to use extended drawing features. … … 1329 1018 * x [I] X position 1330 1019 * y [I] Y position 1331 * xOffs[I] X offset1332 * yOffs[I] Y offset1020 * dx [I] X offset 1021 * dy [I] Y offset 1333 1022 * rgbBk [I] background color 1334 1023 * rgbFg [I] foreground color … … 1353 1042 IMAGELISTDRAWPARAMS imldp; 1354 1043 1355 imldp.cbSize = sizeof(IMAGELISTDRAWPARAMS); 1044 ZeroMemory (&imldp, sizeof(imldp)); 1045 imldp.cbSize = sizeof(imldp); 1356 1046 imldp.himl = himl; 1357 1047 imldp.i = i; … … 1361 1051 imldp.cx = dx; 1362 1052 imldp.cy = dy; 1363 imldp.xBitmap = 0;1364 imldp.yBitmap = 0;1365 1053 imldp.rgbBk = rgbBk; 1366 1054 imldp.rgbFg = rgbFg; 1367 1055 imldp.fStyle = fStyle; 1368 imldp.dwRop = 0;1369 1056 1370 1057 return ImageList_DrawIndirect (&imldp); … … 1373 1060 1374 1061 /************************************************************************* 1375 * ImageList_DrawIndirect [COMCTL32. 53]1062 * ImageList_DrawIndirect [COMCTL32.@] 1376 1063 * 1377 1064 * Draws an image using ... … … 1388 1075 ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp) 1389 1076 { 1390 INT cx, cy; 1391 /* 1392 Do some Error Checking 1393 */ 1394 if (pimldp == NULL) 1395 return FALSE; 1396 if (pimldp->cbSize < sizeof(IMAGELISTDRAWPARAMS)) 1397 return FALSE; 1398 if (pimldp->himl == NULL) 1399 return FALSE; 1400 if ((pimldp->i < 0) || (pimldp->i >= pimldp->himl->cCurImage)) { 1401 ERR("%d not within range (max %d)\n",pimldp->i,pimldp->himl->cCurImage-1); 1402 return FALSE; 1403 } 1077 INT cx, cy, nOvlIdx; 1078 DWORD fState, dwRop; 1079 UINT fStyle; 1080 COLORREF clrBk, oldImageBk, oldImageFg; 1081 HDC hImageDC, hImageListDC, hMaskListDC; 1082 HBITMAP hImageBmp, hOldImageBmp, hOldImageListBmp, hOldMaskListBmp, hBlendMaskBmp; 1083 BOOL bIsTransparent, bBlend, bResult = FALSE; 1084 const HIMAGELIST himl = pimldp->himl; 1085 const INT lx = himl->cx * pimldp->i + pimldp->xBitmap; 1086 const INT ly = pimldp->yBitmap; 1087 1088 if (!pimldp || !himl) return FALSE; 1089 if ((pimldp->i < 0) || (pimldp->i >= himl->cCurImage)) return FALSE; 1090 1091 fState = pimldp->cbSize < sizeof(IMAGELISTDRAWPARAMS) ? ILS_NORMAL : pimldp->fState; 1092 fStyle = pimldp->fStyle & ~ILD_OVERLAYMASK; 1093 cx = (pimldp->cx == 0) ? himl->cx : pimldp->cx; 1094 cy = (pimldp->cy == 0) ? himl->cy : pimldp->cy; 1095 clrBk = (pimldp->rgbBk == CLR_DEFAULT) ? himl->clrBk : pimldp->rgbBk; 1096 bIsTransparent = (fStyle & ILD_TRANSPARENT) || clrBk == CLR_NONE; 1097 bBlend = fStyle & (ILD_BLEND25 | ILD_BLEND50); 1098 1099 TRACE("hbmMask(%p) iImage(%d) x(%d) y(%d) cx(%d) cy(%d)\n", 1100 himl->hbmMask, pimldp->i, pimldp->x, pimldp->y, cx, cy); 1101 1102 /* we will use these DCs to access the images and masks in the ImageList */ 1103 hImageListDC = CreateCompatibleDC(0); 1104 hMaskListDC = himl->hbmMask ? CreateCompatibleDC(0) : 0; 1105 1106 /* these will accumulate the image and mask for the image we're drawing */ 1107 hImageDC = CreateCompatibleDC( pimldp->hdcDst ); 1108 hImageBmp = CreateCompatibleBitmap( pimldp->hdcDst, cx, cy ); 1109 hBlendMaskBmp = bBlend ? CreateBitmap(cx, cy, 1, 1, NULL) : 0; 1110 1111 /* Create a compatible DC. */ 1112 if (!hImageListDC || !hImageDC || !hImageBmp || 1113 (bBlend && !hBlendMaskBmp) || (himl->hbmMask && !hMaskListDC)) 1114 goto cleanup; 1115 1116 hOldImageListBmp = SelectObject(hImageListDC, himl->hbmImage); 1117 hOldImageBmp = SelectObject(hImageDC, hImageBmp); 1118 hOldMaskListBmp = hMaskListDC ? SelectObject(hMaskListDC, himl->hbmMask) : 0; 1119 1404 1120 /* 1405 Get the Height and Width to display 1406 */ 1407 cx = (pimldp->cx == 0) ? pimldp->himl->cx : pimldp->cx; 1408 cy = (pimldp->cy == 0) ? pimldp->himl->cy : pimldp->cy; 1121 * To obtain a transparent look, background color should be set 1122 * to white and foreground color to black when blting the 1123 * monochrome mask. 1124 */ 1125 oldImageFg = SetTextColor( hImageDC, RGB( 0, 0, 0 ) ); 1126 oldImageBk = SetBkColor( hImageDC, RGB( 0xff, 0xff, 0xff ) ); 1127 1409 1128 /* 1410 Draw the image 1411 */ 1412 if(pimldp->himl->hbmMask != 0) 1413 { 1414 IMAGELIST_InternalDrawMask(pimldp, cx, cy); 1415 } 1416 else 1417 { 1418 IMAGELIST_InternalDraw(pimldp, cx, cy); 1419 } 1420 /* 1421 Apply the blend if needed to the Image 1422 */ 1423 if((pimldp->fStyle & ILD_BLEND50) 1424 || (pimldp->fStyle & ILD_BLEND25)) 1425 { 1426 IMAGELIST_InternalDrawBlend(pimldp, cx, cy); 1427 } 1428 /* 1429 Apply the Overlay if needed 1430 */ 1431 if (pimldp->fStyle & ILD_OVERLAYMASK) 1432 { 1433 IMAGELIST_InternalDrawOverlay(pimldp, cx, cy); 1434 } 1435 1436 return TRUE; 1437 } 1438 1439 1440 /************************************************************************* 1441 * ImageList_Duplicate [COMCTL32.54] Duplicates an image list. 1129 * Draw the initial image 1130 */ 1131 if(fStyle & ILD_MASK) { 1132 if (himl->hbmMask) { 1133 BitBlt(hImageDC, 0, 0, cx, cy, hMaskListDC, lx, ly, SRCCOPY); 1134 } else { 1135 HBRUSH hOldBrush = SelectObject (hImageDC, GetStockObject(BLACK_BRUSH)); 1136 PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY); 1137 SelectObject(hImageDC, hOldBrush); 1138 } 1139 } else if (himl->hbmMask && !bIsTransparent) { 1140 /* blend the image with the needed solid background */ 1141 HBRUSH hOldBrush = SelectObject (hImageDC, CreateSolidBrush (clrBk)); 1142 PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY ); 1143 BitBlt( hImageDC, 0, 0, cx, cy, hMaskListDC, lx, ly, SRCAND ); 1144 BitBlt( hImageDC, 0, 0, cx, cy, hImageListDC, lx, ly, SRCPAINT ); 1145 DeleteObject (SelectObject (hImageDC, hOldBrush)); 1146 } else { 1147 /* start off with the image, if we have a mask, we'll use it later */ 1148 BitBlt( hImageDC, 0, 0, cx, cy, hImageListDC, lx, ly, SRCCOPY); 1149 } 1150 1151 /* Time for blending, if required */ 1152 if (bBlend) { 1153 HBRUSH hBlendBrush, hOldBrush; 1154 COLORREF clrBlend = pimldp->rgbFg; 1155 HDC hBlendMaskDC = hImageListDC; 1156 HBITMAP hOldBitmap; 1157 1158 /* Create the blend Mask */ 1159 hOldBitmap = SelectObject(hBlendMaskDC, hBlendMaskBmp); 1160 hBlendBrush = fStyle & ILD_BLEND50 ? himl->hbrBlend50 : himl->hbrBlend25; 1161 hOldBrush = (HBRUSH) SelectObject(hBlendMaskDC, hBlendBrush); 1162 PatBlt(hBlendMaskDC, 0, 0, cx, cy, PATCOPY); 1163 SelectObject(hBlendMaskDC, hOldBrush); 1164 1165 /* Modify the blend mask if an Image Mask exist */ 1166 if(himl->hbmMask) { 1167 BitBlt(hBlendMaskDC, 0, 0, cx, cy, hMaskListDC, lx, ly, 0x220326); /* NOTSRCAND */ 1168 BitBlt(hBlendMaskDC, 0, 0, cx, cy, hBlendMaskDC, 0, 0, NOTSRCCOPY); 1169 } 1170 1171 /* now apply blend to the current image given the BlendMask */ 1172 if (clrBlend == CLR_DEFAULT) clrBlend = GetSysColor (COLOR_HIGHLIGHT); 1173 else if (clrBlend == CLR_NONE) clrBlend = GetTextColor (pimldp->hdcDst); 1174 hOldBrush = (HBRUSH) SelectObject (hImageDC, CreateSolidBrush(clrBlend)); 1175 BitBlt (hImageDC, 0, 0, cx, cy, hBlendMaskDC, 0, 0, 0xB8074A); /* PSDPxax */ 1176 DeleteObject(SelectObject(hImageDC, hOldBrush)); 1177 SelectObject(hBlendMaskDC, hOldBitmap); 1178 } 1179 1180 /* Now do the overlay image, if any */ 1181 nOvlIdx = (pimldp->fStyle & ILD_OVERLAYMASK) >> 8; 1182 if ( (nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE)) { 1183 nOvlIdx = himl->nOvlIdx[nOvlIdx - 1]; 1184 if ((nOvlIdx >= 0) && (nOvlIdx < himl->cCurImage)) { 1185 const INT ox = himl->cx * nOvlIdx + pimldp->xBitmap; 1186 if (himl->hbmMask && !(fStyle & ILD_IMAGE)) 1187 BitBlt (hImageDC, 0, 0, cx, cy, hMaskListDC, ox, ly, SRCAND); 1188 BitBlt (hImageDC, 0, 0, cx, cy, hImageListDC, ox, ly, SRCPAINT); 1189 } 1190 } 1191 1192 if (fState & ILS_SATURATE) FIXME("ILS_SATURATE: unimplemented!\n"); 1193 if (fState & ILS_GLOW) FIXME("ILS_GLOW: unimplemented!\n"); 1194 if (fState & ILS_SHADOW) FIXME("ILS_SHADOW: unimplemented!\n"); 1195 if (fState & ILS_ALPHA) FIXME("ILS_SHADOW: unimplemented!\n"); 1196 1197 if (fStyle & ILD_PRESERVEALPHA) FIXME("ILD_PRESERVEALPHA: unimplemented!\n"); 1198 if (fStyle & ILD_SCALE) FIXME("ILD_SCALE: unimplemented!\n"); 1199 if (fStyle & ILD_DPISCALE) FIXME("ILD_DPISCALE: unimplemented!\n"); 1200 1201 /* now copy the image to the screen */ 1202 dwRop = SRCCOPY; 1203 if (himl->hbmMask && bIsTransparent && !(fStyle & ILD_MASK)) { 1204 COLORREF oldDstFg = SetTextColor(pimldp->hdcDst, RGB( 0, 0, 0 ) ); 1205 COLORREF oldDstBk = SetBkColor(pimldp->hdcDst, RGB( 0xff, 0xff, 0xff )); 1206 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, hMaskListDC, lx, ly, SRCAND); 1207 SetBkColor(pimldp->hdcDst, oldDstBk); 1208 SetTextColor(pimldp->hdcDst, oldDstFg); 1209 dwRop = SRCPAINT; 1210 } 1211 if (fStyle & ILD_ROP) dwRop = pimldp->dwRop; 1212 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, hImageDC, 0, 0, dwRop); 1213 1214 bResult = TRUE; 1215 1216 /* cleanup the mess */ 1217 SetBkColor(hImageDC, oldImageBk); 1218 SetTextColor(hImageDC, oldImageFg); 1219 SelectObject(hImageDC, hOldImageBmp); 1220 SelectObject(hImageListDC, hOldImageListBmp); 1221 if (hMaskListDC) SelectObject(hMaskListDC, hOldMaskListBmp); 1222 cleanup: 1223 DeleteObject(hBlendMaskBmp); 1224 DeleteObject(hImageBmp); 1225 DeleteObject(hImageDC); 1226 DeleteObject(hImageListDC); 1227 DeleteObject(hMaskListDC); 1228 1229 return bResult; 1230 } 1231 1232 1233 /************************************************************************* 1234 * ImageList_Duplicate [COMCTL32.@] Duplicates an image list. 1442 1235 * 1443 1236 * PARAMS … … 1491 1284 1492 1285 /************************************************************************* 1493 * ImageList_EndDrag [COMCTL32. 55] Finishes a drag operation.1286 * ImageList_EndDrag [COMCTL32.@] Finishes a drag operation. 1494 1287 * 1495 1288 * Finishes a drag operation. … … 1524 1317 1525 1318 /************************************************************************* 1526 * ImageList_GetBkColor [COMCTL32. 56]1319 * ImageList_GetBkColor [COMCTL32.@] 1527 1320 * 1528 1321 * Returns the background color of an image list. … … 1539 1332 ImageList_GetBkColor (HIMAGELIST himl) 1540 1333 { 1541 if (himl == NULL) 1542 return CLR_NONE; 1543 1544 return himl->clrBk; 1545 } 1546 1547 1548 /************************************************************************* 1549 * ImageList_GetDragImage [COMCTL32.57] 1334 return himl ? himl->clrBk : CLR_NONE; 1335 } 1336 1337 1338 /************************************************************************* 1339 * ImageList_GetDragImage [COMCTL32.@] 1550 1340 * 1551 1341 * Returns the handle to the internal drag image list. … … 1580 1370 1581 1371 /************************************************************************* 1582 * ImageList_GetFlags [COMCTL32. 58]1372 * ImageList_GetFlags [COMCTL32.@] 1583 1373 * 1584 1374 * BUGS … … 1595 1385 1596 1386 /************************************************************************* 1597 * ImageList_GetIcon [COMCTL32. 59]1387 * ImageList_GetIcon [COMCTL32.@] 1598 1388 * 1599 1389 * Creates an icon from a masked image of an image list. … … 1613 1403 { 1614 1404 ICONINFO ii; 1615 HICON hIcon; 1616 HBITMAP hOldSrcBitmap,hOldDstBitmap; 1617 HDC hdcSrc, hdcDst; 1618 1619 if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) { 1620 FIXME("(%p,%d,%x), params out of range!\n",himl,i,fStyle); 1621 return 0; 1622 } 1623 1624 hdcSrc = CreateCompatibleDC(0); 1405 HICON hIcon; 1406 HBITMAP hOldDstBitmap; 1407 HDC hdcDst; 1408 1409 if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) return 0; 1410 1625 1411 hdcDst = CreateCompatibleDC(0); 1626 1412 1627 1413 ii.fIcon = TRUE; 1414 1415 /* draw mask*/ 1628 1416 ii.hbmMask = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy); 1629 1630 /* draw mask*/1631 1417 hOldDstBitmap = (HBITMAP)SelectObject (hdcDst, ii.hbmMask); 1632 if (himl->hbmMask) { 1633 SelectObject (hdcSrc, himl->hbmMask); 1634 BitBlt (hdcDst, 0, 0, himl->cx, himl->cy, 1635 hdcSrc, i * himl->cx, 0, SRCCOPY); 1636 } 1637 else 1638 PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS); 1418 ImageList_Draw(himl, i, hdcDst, 0, 0, ILD_MASK); 1639 1419 1640 1420 /* draw image*/ 1641 hOldSrcBitmap = (HBITMAP)SelectObject (hdcSrc, himl->hbmImage);1642 ii.hbmColor = CreateCompatibleBitmap (hdc Src, himl->cx, himl->cy);1421 SelectObject (hdcDst, himl->hbmImage); 1422 ii.hbmColor = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy); 1643 1423 SelectObject (hdcDst, ii.hbmColor); 1644 BitBlt (hdcDst, 0, 0, himl->cx, himl->cy, 1645 hdcSrc, i * himl->cx, 0, SRCCOPY); 1424 ImageList_Draw(himl, i, hdcDst, 0, 0, fStyle); 1646 1425 1647 1426 /* 1648 1427 * CreateIconIndirect requires us to deselect the bitmaps from 1649 * the DCs before calling 1428 * the DCs before calling 1650 1429 */ 1651 SelectObject(hdcSrc, hOldSrcBitmap);1652 1430 SelectObject(hdcDst, hOldDstBitmap); 1653 1431 1654 hIcon = CreateIconIndirect (&ii); 1655 1656 DeleteDC (hdcSrc); 1657 DeleteDC (hdcDst); 1432 hIcon = CreateIconIndirect (&ii); 1433 1658 1434 DeleteObject (ii.hbmMask); 1659 1435 DeleteObject (ii.hbmColor); 1436 DeleteDC (hdcDst); 1660 1437 1661 1438 return hIcon; … … 1664 1441 1665 1442 /************************************************************************* 1666 * ImageList_GetIconSize [COMCTL32. 60]1443 * ImageList_GetIconSize [COMCTL32.@] 1667 1444 * 1668 1445 * Retrieves the size of an image in an image list. … … 1699 1476 1700 1477 /************************************************************************* 1701 * ImageList_GetImageCount [COMCTL32. 61]1478 * ImageList_GetImageCount [COMCTL32.@] 1702 1479 * 1703 1480 * Returns the number of images in an image list. … … 1722 1499 1723 1500 /************************************************************************* 1724 * ImageList_GetImageInfo [COMCTL32. 62]1501 * ImageList_GetImageInfo [COMCTL32.@] 1725 1502 * 1726 1503 * Returns information about an image in an image list. … … 1746 1523 pImageInfo->hbmImage = himl->hbmImage; 1747 1524 pImageInfo->hbmMask = himl->hbmMask; 1748 1525 1749 1526 pImageInfo->rcImage.top = 0; 1750 1527 pImageInfo->rcImage.bottom = himl->cy; 1751 1528 pImageInfo->rcImage.left = i * himl->cx; 1752 1529 pImageInfo->rcImage.right = (i+1) * himl->cx; 1753 1530 1754 1531 return TRUE; 1755 1532 } … … 1757 1534 1758 1535 /************************************************************************* 1759 * ImageList_GetImageRect [COMCTL32. 63]1536 * ImageList_GetImageRect [COMCTL32.@] 1760 1537 * 1761 1538 * Retrieves the rectangle of the specified image in an image list. … … 1792 1569 1793 1570 /************************************************************************* 1794 * ImageList_LoadImage [COMCTL32. 64]1795 * ImageList_LoadImageA [COMCTL32. 65]1571 * ImageList_LoadImage [COMCTL32.@] 1572 * ImageList_LoadImageA [COMCTL32.@] 1796 1573 * 1797 1574 * Creates an image list from a bitmap, icon or cursor. … … 1856 1633 GetIconInfo (handle, &ii); 1857 1634 GetObjectA (ii.hbmColor, sizeof(BITMAP), (LPVOID)&bmp); 1858 himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 1635 himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 1859 1636 ILC_MASK | ILC_COLOR, 1, cGrow); 1860 1637 ImageList_Add (himl, ii.hbmColor, ii.hbmMask); … … 1864 1641 1865 1642 DeleteObject (handle); 1866 1643 1867 1644 return himl; 1868 1645 } … … 1870 1647 1871 1648 /************************************************************************* 1872 * ImageList_LoadImageW [COMCTL32. 66]1649 * ImageList_LoadImageW [COMCTL32.@] 1873 1650 * 1874 1651 * Creates an image list from a bitmap, icon or cursor. … … 1933 1710 GetIconInfo (handle, &ii); 1934 1711 GetObjectA (ii.hbmMask, sizeof(BITMAP), (LPVOID)&bmp); 1935 himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 1712 himl = ImageList_Create (bmp.bmWidth, bmp.bmHeight, 1936 1713 ILC_MASK | ILC_COLOR, 1, cGrow); 1937 1714 ImageList_Add (himl, ii.hbmColor, ii.hbmMask); … … 1941 1718 1942 1719 DeleteObject (handle); 1943 1720 1944 1721 return himl; 1945 1722 } … … 1947 1724 1948 1725 /************************************************************************* 1949 * ImageList_Merge [COMCTL32. 67]1726 * ImageList_Merge [COMCTL32.@] 1950 1727 * 1951 1728 * Creates a new image list that contains a merged image from the specified … … 2031 1808 nX1 = i1 * himl1->cx; 2032 1809 nX2 = i2 * himl2->cx; 2033 1810 2034 1811 /* copy image */ 2035 1812 SelectObject (hdcSrcImage, himl1->hbmImage); 2036 1813 SelectObject (hdcDstImage, himlDst->hbmImage); 2037 BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 1814 BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 2038 1815 hdcSrcImage, 0, 0, BLACKNESS); 2039 BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 1816 BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 2040 1817 hdcSrcImage, nX1, 0, SRCCOPY); 2041 1818 2042 1819 SelectObject (hdcSrcImage, himl2->hbmMask); 2043 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1820 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 2044 1821 hdcSrcImage, nX2, 0, SRCAND); 2045 1822 2046 1823 SelectObject (hdcSrcImage, himl2->hbmImage); 2047 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1824 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 2048 1825 hdcSrcImage, nX2, 0, SRCPAINT); 2049 1826 … … 2051 1828 SelectObject (hdcSrcImage, himl1->hbmMask); 2052 1829 SelectObject (hdcDstImage, himlDst->hbmMask); 2053 BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 1830 BitBlt (hdcDstImage, 0, 0, cxDst, cyDst, 2054 1831 hdcSrcImage, 0, 0, WHITENESS); 2055 BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 1832 BitBlt (hdcDstImage, xOff1, yOff1, himl1->cx, himl1->cy, 2056 1833 hdcSrcImage, nX1, 0, SRCCOPY); 2057 1834 2058 1835 SelectObject (hdcSrcImage, himl2->hbmMask); 2059 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 1836 BitBlt (hdcDstImage, xOff2, yOff2, himl2->cx, himl2->cy, 2060 1837 hdcSrcImage, nX2, 0, SRCAND); 2061 1838 … … 2064 1841 himlDst->cCurImage = 1; 2065 1842 } 2066 1843 2067 1844 return himlDst; 2068 1845 } … … 2179 1956 2180 1957 /************************************************************************* 2181 * ImageList_Read [COMCTL32. 68]1958 * ImageList_Read [COMCTL32.@] 2182 1959 * 2183 1960 * Reads an image list from a stream. … … 2194 1971 * 2195 1972 * for the color image part: 2196 * BITMAPFILEHEADER bmfh; 1973 * BITMAPFILEHEADER bmfh; 2197 1974 * BITMAPINFOHEADER bmih; 2198 1975 * only if it has a palette: 2199 * RGBQUAD rgbs[nr_of_paletted_colors]; 1976 * RGBQUAD rgbs[nr_of_paletted_colors]; 2200 1977 * 2201 1978 * BYTE colorbits[imagesize]; … … 2205 1982 * BITMAPINFOHEADER bmih_mask; 2206 1983 * only if it has a palette (it usually does not): 2207 * RGBQUAD rgbs[nr_of_paletted_colors]; 1984 * RGBQUAD rgbs[nr_of_paletted_colors]; 2208 1985 * 2209 1986 * BYTE maskbits[imagesize]; … … 2275 2052 2276 2053 /************************************************************************* 2277 * ImageList_Remove [COMCTL32. 69] Removes an image from an image list2054 * ImageList_Remove [COMCTL32.@] Removes an image from an image list 2278 2055 * 2279 2056 * PARAMS … … 2293 2070 INT cxNew, nCount; 2294 2071 2072 TRACE("(himl=%p i=%d)\n", himl, i); 2073 2295 2074 if (himl == NULL) { 2296 2075 ERR("Invalid image list handle!\n"); 2297 2076 return FALSE; 2298 2077 } 2299 2078 2300 2079 if ((i < -1) || (i >= himl->cCurImage)) { 2301 2080 ERR("index out of range! %d\n", i); … … 2303 2082 } 2304 2083 2305 if (himl->cCurImage == 0) {2306 ERR("image list is already empty!\n");2307 return FALSE;2308 }2309 2310 2084 if (i == -1) { 2311 2085 /* remove all */ 2312 TRACE("remove all!\n"); 2086 if (himl->cCurImage == 0) { 2087 /* remove all on empty ImageList is allowed */ 2088 TRACE("remove all on empty ImageList!\n"); 2089 return TRUE; 2090 } 2313 2091 2314 2092 himl->cMaxImage = himl->cInitial + himl->cGrow; … … 2340 2118 TRACE(" - Max. number of images: %d / %d (Old/New)\n", 2341 2119 himl->cMaxImage, himl->cCurImage + himl->cGrow - 1); 2342 2120 2343 2121 hbmNewImage = 2344 2122 CreateBitmap (cxNew, himl->cy, 1, himl->uBitsPixel, NULL); … … 2355 2133 if (i > 0) { 2356 2134 TRACE("Pre image copy: Copy %d images\n", i); 2357 2135 2358 2136 SelectObject (hdcSrc, himl->hbmImage); 2359 2137 SelectObject (hdcDst, hbmNewImage); … … 2406 2184 2407 2185 /************************************************************************* 2408 * ImageList_Replace [COMCTL32. 70]2186 * ImageList_Replace [COMCTL32.@] 2409 2187 * 2410 2188 * Replaces an image in an image list with a new image. … … 2428 2206 BITMAP bmp; 2429 2207 2208 TRACE("%p %d %p %p\n", himl, i, hbmImage, hbmMask); 2209 2430 2210 if (himl == NULL) { 2431 2211 ERR("Invalid image list handle!\n"); 2432 2212 return FALSE; 2433 2213 } 2434 2214 2435 2215 if ((i >= himl->cMaxImage) || (i < 0)) { 2436 2216 ERR("Invalid image index!\n"); … … 2462 2242 */ 2463 2243 SelectObject (hdcImageList, himl->hbmImage); 2464 StretchBlt (hdcImageList, 2244 StretchBlt (hdcImageList, 2465 2245 i*himl->cx, 0, himl->cx, himl->cy, 2466 hdcImage, 2467 0, 0, bmp.bmWidth, bmp.bmHeight, 2246 hdcImage, 2247 0, 0, bmp.bmWidth, bmp.bmHeight, 2468 2248 0x220326); /* NOTSRCAND */ 2469 2249 } … … 2477 2257 2478 2258 /************************************************************************* 2479 * ImageList_ReplaceIcon [COMCTL32. 75]2259 * ImageList_ReplaceIcon [COMCTL32.@] 2480 2260 * 2481 2261 * Replaces an image in an image list using an icon. … … 2501 2281 BITMAP bmp; 2502 2282 2503 TRACE("(0x%lx 0x%x 0x%x)\n", (DWORD)himl, i, hIcon);2283 TRACE("(0x%lx 0x%x %p)\n", (DWORD)himl, i, hIcon); 2504 2284 2505 2285 if (himl == NULL) … … 2509 2289 2510 2290 hBestFitIcon = CopyImage( 2511 hIcon, IMAGE_ICON, 2512 himl->cx, himl->cy, 2291 hIcon, IMAGE_ICON, 2292 himl->cx, himl->cy, 2513 2293 LR_COPYFROMRESOURCE); 2514 2294 … … 2531 2311 2532 2312 hdcImageList = CreateCompatibleDC (0); 2533 TRACE("hdcImageList= 0x%x!\n", hdcImageList);2313 TRACE("hdcImageList=%p!\n", hdcImageList); 2534 2314 if (hdcImageList == 0) 2535 2315 ERR("invalid hdcImageList!\n"); 2536 2316 2537 2317 hdcImage = CreateCompatibleDC (0); 2538 TRACE("hdcImage= 0x%x!\n", hdcImage);2318 TRACE("hdcImage=%p!\n", hdcImage); 2539 2319 if (hdcImage == 0) 2540 2320 ERR("invalid hdcImage!\n"); … … 2573 2353 2574 2354 /************************************************************************* 2575 * ImageList_SetBkColor [COMCTL32. 76]2355 * ImageList_SetBkColor [COMCTL32.@] 2576 2356 * 2577 2357 * Sets the background color of an image list. … … 2601 2381 2602 2382 /************************************************************************* 2603 * ImageList_SetDragCursorImage [COMCTL32. 77]2383 * ImageList_SetDragCursorImage [COMCTL32.@] 2604 2384 * 2605 2385 * Combines the specified image with the current drag image … … 2683 2463 2684 2464 /************************************************************************* 2685 * ImageList_SetFilter [COMCTL32. 78]2465 * ImageList_SetFilter [COMCTL32.@] 2686 2466 * 2687 2467 * Sets a filter (or does something completely different)!!??? 2688 * 2689 * PARAMS 2690 * himl [I] handle to image list 2691 * i [I] ??? 2468 * It removes 12 Bytes from the stack (3 Parameters). 2469 * 2470 * PARAMS 2471 * himl [I] SHOULD be a handle to image list 2472 * i [I] COULD be an index? 2692 2473 * dwFilter [I] ??? 2693 2474 * … … 2704 2485 ImageList_SetFilter (HIMAGELIST himl, INT i, DWORD dwFilter) 2705 2486 { 2706 FIXME("(%p 0x%x 0x%lx):empty stub!\n", 2707 himl, i, dwFilter); 2487 FIXME("(%p 0x%x 0x%lx):empty stub!\n", himl, i, dwFilter); 2708 2488 2709 2489 return FALSE; … … 2712 2492 2713 2493 /************************************************************************* 2714 * ImageList_SetFlags [COMCTL32. 79]2494 * ImageList_SetFlags [COMCTL32.@] 2715 2495 * 2716 2496 * BUGS … … 2727 2507 2728 2508 /************************************************************************* 2729 * ImageList_SetIconSize [COMCTL32. 80]2509 * ImageList_SetIconSize [COMCTL32.@] 2730 2510 * 2731 2511 * Sets the image size of the bitmap and deletes all images. … … 2776 2556 2777 2557 /************************************************************************* 2778 * ImageList_SetImageCount [COMCTL32. 81]2558 * ImageList_SetImageCount [COMCTL32.@] 2779 2559 * 2780 2560 * Resizes an image list to the specified number of images. … … 2795 2575 HBITMAP hbmNewBitmap; 2796 2576 INT nNewCount, nCopyCount; 2577 2578 TRACE("%p %d\n",himl,iImageCount); 2797 2579 2798 2580 if (!himl) … … 2801 2583 return FALSE; 2802 2584 if (himl->cMaxImage > iImageCount) 2585 { 2586 himl->cCurImage = iImageCount; 2803 2587 return TRUE; 2588 } 2804 2589 2805 2590 nNewCount = iImageCount + himl->cGrow; … … 2823 2608 SetBkColor (hdcBitmap, RGB(255, 255, 255)); 2824 2609 SetTextColor (hdcBitmap, RGB(0, 0, 0)); 2825 PatBlt (hdcBitmap, nCopyCount * himl->cx, 0, 2610 PatBlt (hdcBitmap, nCopyCount * himl->cx, 0, 2826 2611 (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS); 2827 2612 #endif … … 2848 2633 SetBkColor (hdcBitmap, RGB(255, 255, 255)); 2849 2634 SetTextColor (hdcBitmap, RGB(0, 0, 0)); 2850 PatBlt (hdcBitmap, nCopyCount * himl->cx, 0, 2635 PatBlt (hdcBitmap, nCopyCount * himl->cx, 0, 2851 2636 (nNewCount - nCopyCount) * himl->cx, himl->cy, BLACKNESS); 2852 2637 #endif … … 2863 2648 /* Update max image count and current image count */ 2864 2649 himl->cMaxImage = nNewCount; 2865 if (himl->cCurImage > nCopyCount) 2866 himl->cCurImage = nCopyCount; 2650 himl->cCurImage = iImageCount; 2867 2651 2868 2652 return TRUE; … … 2871 2655 2872 2656 /************************************************************************* 2873 * ImageList_SetOverlayImage [COMCTL32. 82]2657 * ImageList_SetOverlayImage [COMCTL32.@] 2874 2658 * 2875 2659 * Assigns an overlay mask index to an existing image in an image list. … … 2900 2684 2901 2685 2902 /* helper for ImageList_Write - write bitmap to pstm 2686 /* helper for ImageList_Write - write bitmap to pstm 2903 2687 * currently everything is written as 24 bit RGB, except masks 2904 2688 */ 2905 static BOOL 2689 static BOOL 2906 2690 _write_bitmap(HBITMAP hBitmap, LPSTREAM pstm, int cx, int cy) 2907 2691 { … … 2918 2702 xdc = GetDC(0); 2919 2703 GetObjectA(hBitmap, sizeof(BITMAP), (LPVOID)&bm); 2920 2704 2921 2705 /* XXX is this always correct? */ 2922 2706 icount = bm.bmWidth / cx; … … 2960 2744 2961 2745 lpBitsOrg = (LPBYTE)LocalAlloc(LMEM_ZEROINIT, nsizeImage); 2962 if(!GetDIBits(xdc, hBitmap, 0, bm.bmHeight, lpBitsOrg, 2746 if(!GetDIBits(xdc, hBitmap, 0, bm.bmHeight, lpBitsOrg, 2963 2747 (BITMAPINFO *)bmih, DIB_RGB_COLORS)) 2964 2748 goto failed; … … 2967 2751 int obpl = (((bm.bmWidth*bitCount+31) & ~31)>>3); 2968 2752 int nbpl = (((nwidth*bitCount+31) & ~31)>>3); 2969 2753 2970 2754 for(i = 0; i < nheight; i++) { 2971 2755 int ooff = ((nheight-1-i)%cy) * obpl + ((i/cy) * nbpl); … … 2974 2758 } 2975 2759 } 2976 2760 2977 2761 bmih->biWidth = nwidth; 2978 2762 bmih->biHeight = nheight; … … 2999 2783 3000 2784 /************************************************************************* 3001 * ImageList_Write [COMCTL32. 83]2785 * ImageList_Write [COMCTL32.@] 3002 2786 * 3003 2787 * Writes an image list to a stream. … … 3052 2836 return TRUE; 3053 2837 } 3054
Note:
See TracChangeset
for help on using the changeset viewer.