Changeset 2820 for trunk/src/comctl32/imagelist.c
- Timestamp:
- Feb 18, 2000, 6:13:39 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/comctl32/imagelist.c
r2635 r2820 1 /* $Id: imagelist.c,v 1.1 1 2000-02-04 17:02:07 cbratschi Exp $ */1 /* $Id: imagelist.c,v 1.12 2000-02-18 17:13:37 cbratschi Exp $ */ 2 2 /* 3 3 * ImageList implementation … … 458 458 HBITMAP hOldBitmapImage, hOldBitmap; 459 459 460 dprintf(("COMCTL32: ImageList_Add")); 461 460 462 if (!himl || !hbmImage) 461 463 return -1; … … 539 541 ImageList_AddIcon (HIMAGELIST himl, HICON hIcon) 540 542 { 543 dprintf(("COMCTL32: ImageList_AddIcon")); 544 541 545 return ImageList_ReplaceIcon (himl, -1, hIcon); 542 546 } … … 568 572 HBITMAP hMaskBitmap=0; 569 573 COLORREF bkColor; 574 575 dprintf(("COMCTL32: ImageList_AddMasked")); 570 576 571 577 if (himl == NULL) … … 680 686 HDC hdcSrc, hdcDst; 681 687 682 // FIXME(imagelist, "partially implemented!\n");688 dprintf(("COMCTL32: ImageList_BeginDrag - partial implemented")); 683 689 684 690 if (himlTrack == NULL) … … 752 758 HDC hdcSrc, hdcDst; 753 759 754 // TRACE(imagelist, "iDst=%d iSrc=%d\n", iDst, iSrc);760 dprintf(("COMCTL32: ImageList_Copy")); 755 761 756 762 if ((himlSrc == NULL) || (himlDst == NULL)) … … 880 886 {0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA}; 881 887 882 // TRACE (imagelist, "(%d %d 0x%x %d %d)\n", cx, cy, flags, cInitial, cGrow);888 dprintf(("COMCTL32: ImageList_Create")); 883 889 884 890 himl = (HIMAGELIST)COMCTL32_Alloc (sizeof(struct _IMAGELIST)); … … 960 966 ImageList_Destroy (HIMAGELIST himl) 961 967 { 968 dprintf(("COMCTL32: ImageList_Destroy")); 969 962 970 if (!himl) 963 971 return FALSE; … … 1003 1011 ImageList_DragEnter (HWND hwndLock, INT x, INT y) 1004 1012 { 1013 dprintf(("COMCTL32: ImageList_DragEnter")); 1014 1005 1015 if (himlInternalDrag == NULL) 1006 1016 return FALSE; … … 1040 1050 ImageList_DragLeave (HWND hwndLock) 1041 1051 { 1052 dprintf(("COMCTL32: ImageList_DragLeave")); 1053 1042 1054 if (hwndLock) 1043 1055 hwndInternalDrag = hwndLock; … … 1075 1087 ImageList_DragMove (INT x, INT y) 1076 1088 { 1089 dprintf(("COMCTL32: ImageList_DragMove")); 1090 1077 1091 ImageList_DragShowNolock (FALSE); 1078 1092 … … 1107 1121 HDC hdcDrag; 1108 1122 1109 // FIXME (imagelist, "semi-stub!\n"); 1110 // TRACE (imagelist, "bShow=0x%X!\n", bShow); 1123 dprintf(("COMCTL32: ImageList_DragShowNolock - semi-stub!")); 1111 1124 1112 1125 hdcDrag = GetDCEx (hwndInternalDrag, 0, … … 1161 1174 { 1162 1175 IMAGELISTDRAWPARAMS imldp; 1176 1177 dprintf(("COMCTL32: ImageList_Draw")); 1163 1178 1164 1179 imldp.cbSize = sizeof(IMAGELISTDRAWPARAMS); … … 1216 1231 IMAGELISTDRAWPARAMS imldp; 1217 1232 1233 dprintf(("COMCTL32: ImageList_DrawEx")); 1234 1218 1235 imldp.cbSize = sizeof(IMAGELISTDRAWPARAMS); 1219 1236 imldp.himl = himl; … … 1252 1269 { 1253 1270 INT cx, cy; 1271 1272 dprintf(("COMCTL32: ImageList_DrawIndirect")); 1273 1254 1274 /* 1255 1275 Do some Error Checking … … 1316 1336 HDC hdcSrc, hdcDst; 1317 1337 1338 dprintf(("COMCTL32: ImageList_Duplicate")); 1339 1318 1340 if (himlSrc == NULL) { 1319 1341 // ERR (imagelist, "Invalid image list handle!\n"); … … 1344 1366 DeleteDC (hdcSrc); 1345 1367 1346 1347 1368 himlDst->cCurImage = himlSrc->cCurImage; 1369 himlDst->cMaxImage = himlSrc->cMaxImage; 1348 1370 } 1349 1371 … … 1371 1393 ImageList_EndDrag (VOID) 1372 1394 { 1373 // FIXME (imagelist, "semi-stub!\n");1395 dprintf(("COMCTL32: ImageList_EndDrag - semi-stub")); 1374 1396 1375 1397 if (himlInternalDrag) … … 1404 1426 ImageList_GetBkColor (HIMAGELIST himl) 1405 1427 { 1428 dprintf(("COMCTL32: ImageList_GetBkColor")); 1429 1406 1430 if (himl == NULL) 1407 1431 return CLR_NONE; … … 1431 1455 ImageList_GetDragImage (POINT *ppt, POINT *pptHotspot) 1432 1456 { 1433 // FIXME (imagelist, "semi-stub!\n");1457 dprintf(("COMCTL32: ImageList_GetDragImage - semi-stub!")); 1434 1458 1435 1459 if (himlInternalDrag) … … 1462 1486 HBITMAP hOldSrcBitmap,hOldDstBitmap; 1463 1487 HDC hdcSrc, hdcDst; 1488 1489 dprintf(("COMCTL32: ImageList_GetIcon")); 1464 1490 1465 1491 if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage)) … … 1528 1554 ImageList_GetIconSize (HIMAGELIST himl, INT *cx, INT *cy) 1529 1555 { 1556 dprintf(("COMCTL32: ImageList_GetIconSize")); 1557 1530 1558 if (himl == NULL) 1531 1559 return FALSE; … … 1558 1586 ImageList_GetImageCount (HIMAGELIST himl) 1559 1587 { 1588 dprintf(("COMCTL32: ImageList_GetImageCount")); 1589 1560 1590 if (himl == NULL) 1561 1591 return 0; … … 1583 1613 ImageList_GetImageInfo (HIMAGELIST himl, INT i, IMAGEINFO *pImageInfo) 1584 1614 { 1615 dprintf(("COMCTL32: ImageList_GetImageInfo")); 1616 1585 1617 if ((himl == NULL) || (pImageInfo == NULL)) 1586 1618 return FALSE; … … 1621 1653 ImageList_GetImageRect (HIMAGELIST himl, INT i, LPRECT lpRect) 1622 1654 { 1655 dprintf(("COMCTL32: ImageList_GetImageRect")); 1656 1623 1657 if ((himl == NULL) || (lpRect == NULL)) 1624 1658 return FALSE; … … 1664 1698 HANDLE handle; 1665 1699 INT nImageCount; 1700 1701 dprintf(("COMCTL32: ImageList_LoadImageA")); 1666 1702 1667 1703 handle = LoadImageA (hi, lpbmp, uType, 0, 0, uFlags); … … 1742 1778 INT nImageCount; 1743 1779 1780 dprintf(("COMCTL32: ImageList_LoadImageW")); 1781 1744 1782 handle = LoadImageW (hi, lpbmp, uType, 0, 0, uFlags); 1745 1783 if (!handle) { … … 1805 1843 INT nX1, nX2; 1806 1844 1845 dprintf(("COMCTL32: ImageList_Merge")); 1846 1807 1847 if ((himl1 == NULL) || (himl2 == NULL)) 1808 1848 return NULL; … … 1899 1939 int bitspixel = GetDeviceCaps(hdc,BITSPIXEL)*GetDeviceCaps(hdc,PLANES); 1900 1940 if (bitspixel>8) 1901 1941 return TRUE; 1902 1942 if (bitspixel<=4) 1903 1943 return FALSE; 1904 1944 return GetDeviceCaps(hdc,94) & 0x10; 1905 1945 } … … 1907 1947 /* helper for ImageList_Read, see comments below */ 1908 1948 static HBITMAP _read_bitmap(LPSTREAM pstm,int ilcFlag,int cx,int cy) { 1909 HDC 1910 BITMAPFILEHEADER 1911 BITMAPINFOHEADER 1912 int 1913 LPBITMAPINFOHEADER 1914 int 1915 HBITMAP 1916 LPBYTE 1917 int 1918 1919 if (!SUCCEEDED(IStream_Read ( pstm, &bmfh, sizeof(bmfh), NULL)) 1920 (bmfh.bfType != (('M'<<8)|'B'))||1921 !SUCCEEDED(IStream_Read ( pstm, &bmih, sizeof(bmih), NULL))||1922 1949 HDC xdc = 0; 1950 BITMAPFILEHEADER bmfh; 1951 BITMAPINFOHEADER bmih; 1952 int bitsperpixel,palspace,longsperline,width,height; 1953 LPBITMAPINFOHEADER bmihc = NULL; 1954 int result = 0; 1955 HBITMAP hbitmap = 0; 1956 LPBYTE bits = NULL,nbits = NULL; 1957 int nbytesperline,bytesperline; 1958 1959 if (!SUCCEEDED(IStream_Read ( pstm, &bmfh, sizeof(bmfh), NULL)) || 1960 (bmfh.bfType != (('M'<<8)|'B')) || 1961 !SUCCEEDED(IStream_Read ( pstm, &bmih, sizeof(bmih), NULL)) || 1962 (bmih.biSize != sizeof(bmih)) 1923 1963 ) 1924 1964 return 0; 1925 1965 1926 1966 bitsperpixel = bmih.biPlanes * bmih.biBitCount; 1927 1967 if (bitsperpixel<=8) 1928 1968 palspace = (1<<bitsperpixel)*sizeof(RGBQUAD); 1929 1969 else 1930 1970 palspace = 0; 1931 1971 width = bmih.biWidth; 1932 1972 height = bmih.biHeight; 1933 1973 bmihc = (LPBITMAPINFOHEADER)LocalAlloc(LMEM_ZEROINIT,sizeof(bmih)+palspace); 1934 1974 memcpy(bmihc,&bmih,sizeof(bmih)); 1935 longsperline 1936 bmihc->biSizeImage 1975 longsperline = ((width*bitsperpixel+31)&~0x1f)>>5; 1976 bmihc->biSizeImage = (longsperline*height)<<2; 1937 1977 1938 1978 /* read the palette right after the end of the bitmapinfoheader */ 1939 1979 if (palspace) 1940 1941 1980 if (!SUCCEEDED(IStream_Read ( pstm, bmihc+1, palspace, NULL))) 1981 goto ret1; 1942 1982 1943 1983 xdc = GetDC(0); 1944 1984 #if 0 /* Magic for NxM -> 1x(N*M) not implemented for DIB Sections */ 1945 1985 if ((bitsperpixel>1) && 1946 1986 ((ilcFlag!=ILC_COLORDDB) && (!ilcFlag || may_use_dibsection(xdc))) 1947 1987 ) { 1948 1949 1950 1951 1952 1953 1988 hbitmap = CreateDIBSection(xdc,(BITMAPINFO*)bmihc,0,(LPVOID*)&bits,0,0); 1989 if (!hbitmap) 1990 goto ret1; 1991 if (!SUCCEEDED(IStream_Read( pstm, bits, bmihc->biSizeImage, NULL))) 1992 goto ret1; 1993 result = 1; 1954 1994 } else 1955 1995 #endif 1956 1996 { 1957 1958 1959 nwidth= width*(height/cy);1960 nheight= cy;1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 bytesperline= longsperline*4;1976 nbytesperline= (height/cy)*bytesperline;1977 1978 1979 1980 1981 1982 1983 1984 bmihc->biWidth= nwidth;1985 bmihc->biHeight= nheight;1986 1987 1988 1989 1990 1997 int i,nwidth,nheight; 1998 1999 nwidth = width*(height/cy); 2000 nheight = cy; 2001 2002 if (bitsperpixel==1) 2003 hbitmap = CreateBitmap(nwidth,nheight,1,1,NULL); 2004 else 2005 hbitmap = CreateCompatibleBitmap(xdc,nwidth,nheight); 2006 2007 /* Might be a bit excessive memory use here */ 2008 bits = (LPBYTE)LocalAlloc(LMEM_ZEROINIT,bmihc->biSizeImage); 2009 nbits = (LPBYTE)LocalAlloc(LMEM_ZEROINIT,bmihc->biSizeImage); 2010 if (!SUCCEEDED(IStream_Read ( pstm, bits, bmihc->biSizeImage, NULL))) 2011 goto ret1; 2012 2013 /* Copy the NxM bitmap into a 1x(N*M) bitmap we need, linewise */ 2014 /* Do not forget that windows bitmaps are bottom->top */ 2015 bytesperline = longsperline*4; 2016 nbytesperline = (height/cy)*bytesperline; 2017 for (i=0;i<height;i++) { 2018 memcpy( 2019 nbits+((height-i)%cy)*nbytesperline+(i/cy)*bytesperline, 2020 bits+bytesperline*(height-i), 2021 bytesperline 2022 ); 2023 } 2024 bmihc->biWidth = nwidth; 2025 bmihc->biHeight = nheight; 2026 if (!SetDIBits(xdc,hbitmap,0,nheight,nbits,(BITMAPINFO*)bmihc,0)) 2027 goto ret1; 2028 LocalFree((HLOCAL)nbits); 2029 LocalFree((HLOCAL)bits); 2030 result = 1; 1991 2031 } 1992 2032 ret1: 1993 if (xdc) 1994 if (bmihc) 2033 if (xdc) ReleaseDC(0,xdc); 2034 if (bmihc) LocalFree((HLOCAL)bmihc); 1995 2035 if (!result) { 1996 1997 1998 1999 2036 if (hbitmap) { 2037 DeleteObject(hbitmap); 2038 hbitmap = 0; 2039 } 2000 2040 } 2001 2041 return hbitmap; … … 2015 2055 * 2016 2056 * The format is like this: 2017 * ILHEADilheadstruct;2057 * ILHEAD ilheadstruct; 2018 2058 * 2019 2059 * for the color image part: 2020 * BITMAPFILEHEADERbmfh;2021 * BITMAPINFOHEADERbmih;2060 * BITMAPFILEHEADER bmfh; 2061 * BITMAPINFOHEADER bmih; 2022 2062 * only if it has a palette: 2023 * RGBQUADrgbs[nr_of_paletted_colors];2024 * 2025 * BYTEcolorbits[imagesize];2063 * RGBQUAD rgbs[nr_of_paletted_colors]; 2064 * 2065 * BYTE colorbits[imagesize]; 2026 2066 * 2027 2067 * the following only if the ILC_MASK bit is set in ILHEAD.ilFlags: 2028 * BITMAPFILEHEADERbmfh_mask;2029 * BITMAPINFOHEADERbmih_mask;2068 * BITMAPFILEHEADER bmfh_mask; 2069 * BITMAPINFOHEADER bmih_mask; 2030 2070 * only if it has a palette (it usually does not): 2031 * RGBQUADrgbs[nr_of_paletted_colors];2032 * 2033 * BYTEmaskbits[imagesize];2071 * RGBQUAD rgbs[nr_of_paletted_colors]; 2072 * 2073 * BYTE maskbits[imagesize]; 2034 2074 * 2035 2075 * CAVEAT: Those images are within a NxM bitmap, not the 1xN we expect. … … 2038 2078 HIMAGELIST WINAPI ImageList_Read (LPSTREAM pstm) 2039 2079 { 2040 ILHEAD ilHead; 2041 HIMAGELIST himl; 2042 HBITMAP hbmColor=0,hbmMask=0; 2043 int i; 2080 ILHEAD ilHead; 2081 HIMAGELIST himl; 2082 HBITMAP hbmColor=0,hbmMask=0; 2083 int i; 2084 2085 dprintf(("COMCTL32: ImageList_Read")); 2044 2086 2045 2087 if (!SUCCEEDED(IStream_Read (pstm, &ilHead, sizeof(ILHEAD), NULL))) 2046 2088 return NULL; 2047 2089 if (ilHead.usMagic != (('L' << 8) | 'I')) 2048 2090 return NULL; 2049 2091 if (ilHead.usVersion != 0x101) /* probably version? */ 2050 2092 return NULL; 2051 2093 2052 2094 #if 0 2053 FIXME(" 2054 FIXME(" 2055 FIXME(" 2056 FIXME(" 2057 FIXME(" 2058 FIXME(" 2059 FIXME(" 2060 FIXME(" 2061 FIXME(" 2062 FIXME(" 2095 FIXME(" ilHead.cCurImage = %d\n",ilHead.cCurImage); 2096 FIXME(" ilHead.cMaxImage = %d\n",ilHead.cMaxImage); 2097 FIXME(" ilHead.cGrow = %d\n",ilHead.cGrow); 2098 FIXME(" ilHead.cx = %d\n",ilHead.cx); 2099 FIXME(" ilHead.cy = %d\n",ilHead.cy); 2100 FIXME(" ilHead.flags = %x\n",ilHead.flags); 2101 FIXME(" ilHead.ovls[0] = %d\n",ilHead.ovls[0]); 2102 FIXME(" ilHead.ovls[1] = %d\n",ilHead.ovls[1]); 2103 FIXME(" ilHead.ovls[2] = %d\n",ilHead.ovls[2]); 2104 FIXME(" ilHead.ovls[3] = %d\n",ilHead.ovls[3]); 2063 2105 #endif 2064 2106 2065 2107 hbmColor = _read_bitmap(pstm,ilHead.flags & ~ILC_MASK,ilHead.cx,ilHead.cy); 2066 2108 if (!hbmColor) 2067 2109 return NULL; 2068 2110 if (ilHead.flags & ILC_MASK) { 2069 2070 2071 2072 2073 2111 hbmMask = _read_bitmap(pstm,0,ilHead.cx,ilHead.cy); 2112 if (!hbmMask) { 2113 DeleteObject(hbmColor); 2114 return NULL; 2115 } 2074 2116 } 2075 2117 2076 2118 himl = ImageList_Create ( 2077 2078 2079 2080 1,/* initial */2081 2119 ilHead.cx, 2120 ilHead.cy, 2121 ilHead.flags, 2122 1, /* initial */ 2123 ilHead.cGrow 2082 2124 ); 2083 2125 if (!himl) { 2084 2085 2086 2126 DeleteObject(hbmColor); 2127 DeleteObject(hbmMask); 2128 return NULL; 2087 2129 } 2088 2130 himl->hbmImage = hbmColor; … … 2093 2135 ImageList_SetBkColor(himl,ilHead.bkcolor); 2094 2136 for (i=0;i<4;i++) 2095 2137 ImageList_SetOverlayImage(himl,ilHead.ovls[i],i+1); 2096 2138 return himl; 2097 2139 } … … 2116 2158 HDC hdcSrc, hdcDst; 2117 2159 INT cxNew, nCount; 2160 2161 dprintf(("COMCTL32: ImageList_Remove")); 2118 2162 2119 2163 if ((i < -1) || (i >= himl->cCurImage)) { … … 2247 2291 BITMAP bmp; 2248 2292 2293 dprintf(("COMCTL32: ImageList_Replace")); 2294 2249 2295 if (himl == NULL) { 2250 2296 // ERR (imagelist, "Invalid image list handle!\n"); … … 2310 2356 BITMAP bmp; 2311 2357 2312 // TRACE (imagelist, "(0x%lx 0x%x 0x%x)\n", (DWORD)himl, i, hIcon);2358 dprintf(("COMCTL32: ImageList_ReplaceIcon")); 2313 2359 2314 2360 if (himl == NULL) … … 2400 2446 COLORREF clrOldBk; 2401 2447 2448 dprintf(("COMCTL32: ImageList_SetBkColor")); 2449 2402 2450 if (himl == NULL) 2403 2451 return CLR_NONE; … … 2434 2482 HIMAGELIST himlTemp; 2435 2483 2436 // FIXME (imagelist, "semi-stub!\n");2484 dprintf(("COMCTL32: ImageList_SetDragCursorImage - semi-stub")); 2437 2485 2438 2486 if (himlInternalDrag == NULL) … … 2477 2525 ImageList_SetFilter (HIMAGELIST himl, INT i, DWORD dwFilter) 2478 2526 { 2479 // FIXME (imagelist, "(%p 0x%x 0x%lx):empty stub!\n", 2480 // himl, i, dwFilter); 2527 dprintf(("COMCTL32: ImageList_SetFilter - empty stub!")); 2481 2528 2482 2529 return FALSE; … … 2503 2550 { 2504 2551 INT nCount; 2552 2553 dprintf(("COMCTL32: ImageList_SetIconSize")); 2505 2554 2506 2555 if (!himl) … … 2553 2602 HBITMAP hbmNewBitmap; 2554 2603 INT nNewCount, nCopyCount; 2604 2605 dprintf(("COMCTL32: ImageList_SetImageCount")); 2555 2606 2556 2607 if (!himl) … … 2646 2697 ImageList_SetOverlayImage (HIMAGELIST himl, INT iImage, INT iOverlay) 2647 2698 { 2699 dprintf(("COMCTL32: ImageList_SetOverlayImage")); 2700 2648 2701 if (!himl) 2649 2702 return FALSE; … … 2682 2735 ImageList_Write (HIMAGELIST himl, PVOID pstm) 2683 2736 { 2737 dprintf(("COMCTL32: ImageList_Write - empty stub!")); 2738 2684 2739 if (!himl) 2685 2740 return FALSE; 2686 2741 2687 dprintf(("ImageList_Write empty stub!\n"));2688 2689 2690 2742 return FALSE; 2691 2743 }
Note:
See TracChangeset
for help on using the changeset viewer.