Allow the size of bitmaps to be changed after toolbar buttons have
been added.
This commit is contained in:
parent
5b0ace1c24
commit
19cef6ca10
@ -76,28 +76,32 @@ static HBITMAP hbmBackBuffer = 0;
|
|||||||
* This function can NOT be used to reduce the number of images.
|
* This function can NOT be used to reduce the number of images.
|
||||||
*/
|
*/
|
||||||
static VOID
|
static VOID
|
||||||
IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount)
|
IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount, INT cx, INT cy)
|
||||||
{
|
{
|
||||||
HDC hdcImageList, hdcBitmap;
|
HDC hdcImageList, hdcBitmap;
|
||||||
HBITMAP hbmNewBitmap;
|
HBITMAP hbmNewBitmap;
|
||||||
INT nNewWidth, nNewCount;
|
INT nNewWidth, nNewCount;
|
||||||
|
|
||||||
TRACE("Create expanded bitmaps!\n");
|
if ((himl->cCurImage + nImageCount < himl->cMaxImage)
|
||||||
|
&& (himl->cy >= cy))
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (cy == 0) cy = himl->cy;
|
||||||
nNewCount = himl->cCurImage + nImageCount + himl->cGrow;
|
nNewCount = himl->cCurImage + nImageCount + himl->cGrow;
|
||||||
nNewWidth = nNewCount * himl->cx;
|
nNewWidth = nNewCount * himl->cx;
|
||||||
|
|
||||||
|
TRACE("Create expanded bitmaps : himl=%p x=%d y=%d count=%d\n", himl, nNewWidth, cy, nNewCount);
|
||||||
hdcImageList = CreateCompatibleDC (0);
|
hdcImageList = CreateCompatibleDC (0);
|
||||||
hdcBitmap = CreateCompatibleDC (0);
|
hdcBitmap = CreateCompatibleDC (0);
|
||||||
|
|
||||||
hbmNewBitmap =
|
hbmNewBitmap =
|
||||||
CreateBitmap (nNewWidth, himl->cy, 1, himl->uBitsPixel, NULL);
|
CreateBitmap (nNewWidth, cy, 1, himl->uBitsPixel, NULL);
|
||||||
if (hbmNewBitmap == 0)
|
if (hbmNewBitmap == 0)
|
||||||
ERR("creating new image bitmap!\n");
|
ERR("creating new image bitmap (x=%d y=%d)!\n", nNewWidth, cy);
|
||||||
|
|
||||||
SelectObject (hdcImageList, himl->hbmImage);
|
SelectObject (hdcImageList, himl->hbmImage);
|
||||||
SelectObject (hdcBitmap, hbmNewBitmap);
|
SelectObject (hdcBitmap, hbmNewBitmap);
|
||||||
BitBlt (hdcBitmap, 0, 0, himl->cCurImage * himl->cx, himl->cy,
|
BitBlt (hdcBitmap, 0, 0, himl->cCurImage * himl->cx, cy,
|
||||||
hdcImageList, 0, 0, SRCCOPY);
|
hdcImageList, 0, 0, SRCCOPY);
|
||||||
|
|
||||||
DeleteObject (himl->hbmImage);
|
DeleteObject (himl->hbmImage);
|
||||||
@ -105,14 +109,14 @@ IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount)
|
|||||||
|
|
||||||
if (himl->hbmMask) {
|
if (himl->hbmMask) {
|
||||||
hbmNewBitmap =
|
hbmNewBitmap =
|
||||||
CreateBitmap (nNewWidth, himl->cy, 1, 1, NULL);
|
CreateBitmap (nNewWidth, cy, 1, 1, NULL);
|
||||||
|
|
||||||
if (hbmNewBitmap == 0)
|
if (hbmNewBitmap == 0)
|
||||||
ERR("creating new mask bitmap!");
|
ERR("creating new mask bitmap!\n");
|
||||||
|
|
||||||
SelectObject (hdcImageList, himl->hbmMask);
|
SelectObject (hdcImageList, himl->hbmMask);
|
||||||
SelectObject (hdcBitmap, hbmNewBitmap);
|
SelectObject (hdcBitmap, hbmNewBitmap);
|
||||||
BitBlt (hdcBitmap, 0, 0, himl->cCurImage * himl->cx, himl->cy,
|
BitBlt (hdcBitmap, 0, 0, himl->cCurImage * himl->cx, cy,
|
||||||
hdcImageList, 0, 0, SRCCOPY);
|
hdcImageList, 0, 0, SRCCOPY);
|
||||||
DeleteObject (himl->hbmMask);
|
DeleteObject (himl->hbmMask);
|
||||||
himl->hbmMask = hbmNewBitmap;
|
himl->hbmMask = hbmNewBitmap;
|
||||||
@ -449,14 +453,14 @@ ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask)
|
|||||||
BITMAP bmp;
|
BITMAP bmp;
|
||||||
HBITMAP hOldBitmapImage, hOldBitmap;
|
HBITMAP hOldBitmapImage, hOldBitmap;
|
||||||
|
|
||||||
|
TRACE("himl=%p hbmimage=%x hbmmask=%x\n", himl, hbmImage, hbmMask);
|
||||||
if (!himl || !hbmImage)
|
if (!himl || !hbmImage)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
GetObjectA (hbmImage, sizeof(BITMAP), (LPVOID)&bmp);
|
GetObjectA (hbmImage, sizeof(BITMAP), (LPVOID)&bmp);
|
||||||
nImageCount = bmp.bmWidth / himl->cx;
|
nImageCount = bmp.bmWidth / himl->cx;
|
||||||
|
|
||||||
if (himl->cCurImage + nImageCount >= himl->cMaxImage)
|
IMAGELIST_InternalExpandBitmaps (himl, nImageCount, bmp.bmWidth, bmp.bmHeight);
|
||||||
IMAGELIST_InternalExpandBitmaps (himl, nImageCount);
|
|
||||||
|
|
||||||
nStartX = himl->cCurImage * himl->cx;
|
nStartX = himl->cCurImage * himl->cx;
|
||||||
|
|
||||||
@ -468,7 +472,7 @@ ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask)
|
|||||||
|
|
||||||
/* Copy result to the imagelist
|
/* Copy result to the imagelist
|
||||||
*/
|
*/
|
||||||
BitBlt (hdcImage, nStartX, 0, bmp.bmWidth, himl->cy,
|
BitBlt (hdcImage, nStartX, 0, bmp.bmWidth, bmp.bmHeight,
|
||||||
hdcBitmap, 0, 0, SRCCOPY);
|
hdcBitmap, 0, 0, SRCCOPY);
|
||||||
|
|
||||||
if(himl->hbmMask)
|
if(himl->hbmMask)
|
||||||
@ -481,7 +485,7 @@ ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask)
|
|||||||
hOldBitmapTemp = (HBITMAP) SelectObject(hdcTemp, hbmMask);
|
hOldBitmapTemp = (HBITMAP) SelectObject(hdcTemp, hbmMask);
|
||||||
|
|
||||||
BitBlt (hdcMask,
|
BitBlt (hdcMask,
|
||||||
nStartX, 0, bmp.bmWidth, himl->cy,
|
nStartX, 0, bmp.bmWidth, bmp.bmHeight,
|
||||||
hdcTemp,
|
hdcTemp,
|
||||||
0, 0,
|
0, 0,
|
||||||
SRCCOPY);
|
SRCCOPY);
|
||||||
@ -492,7 +496,7 @@ ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask)
|
|||||||
/* Remove the background from the image
|
/* Remove the background from the image
|
||||||
*/
|
*/
|
||||||
BitBlt (hdcImage,
|
BitBlt (hdcImage,
|
||||||
nStartX, 0, bmp.bmWidth, himl->cy,
|
nStartX, 0, bmp.bmWidth, bmp.bmHeight,
|
||||||
hdcMask,
|
hdcMask,
|
||||||
nStartX, 0,
|
nStartX, 0,
|
||||||
0x220326); /* NOTSRCAND */
|
0x220326); /* NOTSRCAND */
|
||||||
@ -560,6 +564,7 @@ ImageList_AddMasked (HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
|
|||||||
HBITMAP hMaskBitmap=0;
|
HBITMAP hMaskBitmap=0;
|
||||||
COLORREF bkColor;
|
COLORREF bkColor;
|
||||||
|
|
||||||
|
TRACE("himl=%p hbitmap=%x clrmask=%lx\n", himl, hBitmap, clrMask);
|
||||||
if (himl == NULL)
|
if (himl == NULL)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -568,10 +573,7 @@ ImageList_AddMasked (HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
|
|||||||
|
|
||||||
nImageCount = bmp.bmWidth / himl->cx;
|
nImageCount = bmp.bmWidth / himl->cx;
|
||||||
|
|
||||||
if (himl->cCurImage + nImageCount >= himl->cMaxImage)
|
IMAGELIST_InternalExpandBitmaps (himl, nImageCount, bmp.bmWidth, bmp.bmHeight);
|
||||||
{
|
|
||||||
IMAGELIST_InternalExpandBitmaps (himl, nImageCount);
|
|
||||||
}
|
|
||||||
|
|
||||||
nIndex = himl->cCurImage;
|
nIndex = himl->cCurImage;
|
||||||
himl->cCurImage += nImageCount;
|
himl->cCurImage += nImageCount;
|
||||||
@ -594,7 +596,7 @@ ImageList_AddMasked (HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
|
|||||||
Create a temp Mask so we can remove the background of
|
Create a temp Mask so we can remove the background of
|
||||||
the Image (Windows does this even if there is no mask)
|
the Image (Windows does this even if there is no mask)
|
||||||
*/
|
*/
|
||||||
hMaskBitmap = CreateBitmap(bmp.bmWidth, himl->cy, 1, 1, NULL);
|
hMaskBitmap = CreateBitmap(bmp.bmWidth, bmp.bmHeight, 1, 1, NULL);
|
||||||
hOldBitmapMask = SelectObject(hdcMask, hMaskBitmap);
|
hOldBitmapMask = SelectObject(hdcMask, hMaskBitmap);
|
||||||
nMaskXOffset = 0;
|
nMaskXOffset = 0;
|
||||||
}
|
}
|
||||||
@ -603,7 +605,7 @@ ImageList_AddMasked (HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
|
|||||||
GetPixel (hdcBitmap, 0, 0);
|
GetPixel (hdcBitmap, 0, 0);
|
||||||
SetBkColor (hdcBitmap, bkColor);
|
SetBkColor (hdcBitmap, bkColor);
|
||||||
BitBlt (hdcMask,
|
BitBlt (hdcMask,
|
||||||
nMaskXOffset, 0, bmp.bmWidth, himl->cy,
|
nMaskXOffset, 0, bmp.bmWidth, bmp.bmHeight,
|
||||||
hdcBitmap, 0, 0,
|
hdcBitmap, 0, 0,
|
||||||
SRCCOPY);
|
SRCCOPY);
|
||||||
|
|
||||||
@ -620,14 +622,14 @@ ImageList_AddMasked (HIMAGELIST himl, HBITMAP hBitmap, COLORREF clrMask)
|
|||||||
This is here in case some apps really on this bug
|
This is here in case some apps really on this bug
|
||||||
*/
|
*/
|
||||||
BitBlt(hdcBitmap,
|
BitBlt(hdcBitmap,
|
||||||
0, 0, bmp.bmWidth, himl->cy,
|
0, 0, bmp.bmWidth, bmp.bmHeight,
|
||||||
hdcMask,
|
hdcMask,
|
||||||
nMaskXOffset, 0,
|
nMaskXOffset, 0,
|
||||||
0x220326); /* NOTSRCAND */
|
0x220326); /* NOTSRCAND */
|
||||||
/* Copy result to the imagelist
|
/* Copy result to the imagelist
|
||||||
*/
|
*/
|
||||||
BitBlt (hdcImage,
|
BitBlt (hdcImage,
|
||||||
nIndex * himl->cx, 0, bmp.bmWidth, himl->cy,
|
nIndex * himl->cx, 0, bmp.bmWidth, bmp.bmHeight,
|
||||||
hdcBitmap,
|
hdcBitmap,
|
||||||
0, 0,
|
0, 0,
|
||||||
SRCCOPY);
|
SRCCOPY);
|
||||||
@ -931,6 +933,7 @@ ImageList_Create (INT cx, INT cy, UINT flags,
|
|||||||
himl->hbrBlend50 = CreatePatternBrush (hbmTemp);
|
himl->hbrBlend50 = CreatePatternBrush (hbmTemp);
|
||||||
DeleteObject (hbmTemp);
|
DeleteObject (hbmTemp);
|
||||||
|
|
||||||
|
TRACE("created imagelist %p\n", himl);
|
||||||
return himl;
|
return himl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2337,7 +2340,7 @@ ImageList_ReplaceIcon (HIMAGELIST himl, INT i, HICON hIcon)
|
|||||||
|
|
||||||
if (i == -1) {
|
if (i == -1) {
|
||||||
if (himl->cCurImage + 1 >= himl->cMaxImage)
|
if (himl->cCurImage + 1 >= himl->cMaxImage)
|
||||||
IMAGELIST_InternalExpandBitmaps (himl, 1);
|
IMAGELIST_InternalExpandBitmaps (himl, 1, 0, 0);
|
||||||
|
|
||||||
nIndex = himl->cCurImage;
|
nIndex = himl->cCurImage;
|
||||||
himl->cCurImage++;
|
himl->cCurImage++;
|
||||||
|
@ -1017,6 +1017,7 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||||||
INT nIndex = 0, nButtons, nCount;
|
INT nIndex = 0, nButtons, nCount;
|
||||||
HBITMAP hbmLoad;
|
HBITMAP hbmLoad;
|
||||||
|
|
||||||
|
TRACE("hwnd=%x wParam=%x lParam=%lx\n", hwnd, wParam, lParam);
|
||||||
if (!lpAddBmp)
|
if (!lpAddBmp)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
@ -1482,7 +1483,7 @@ TOOLBAR_AutoSize (HWND hwnd)
|
|||||||
INT cx, cy;
|
INT cx, cy;
|
||||||
UINT uPosFlags = SWP_NOZORDER;
|
UINT uPosFlags = SWP_NOZORDER;
|
||||||
|
|
||||||
TRACE("resize forced!\n");
|
TRACE("resize forced, style=%lx!\n", dwStyle);
|
||||||
|
|
||||||
parent = GetParent (hwnd);
|
parent = GetParent (hwnd);
|
||||||
GetClientRect(parent, &parent_rect);
|
GetClientRect(parent, &parent_rect);
|
||||||
@ -2612,14 +2613,21 @@ TOOLBAR_SetBitmapSize (HWND hwnd, WPARAM wParam, LPARAM lParam)
|
|||||||
if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
|
if ((LOWORD(lParam) <= 0) || (HIWORD(lParam)<=0))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Bitmap size can only be set before adding any button to the toolbar
|
if (infoPtr->nNumButtons > 0)
|
||||||
according to the documentation. */
|
WARN("%d buttons, undoc increase to bitmap size : %d-%d -> %d-%d\n",
|
||||||
if( infoPtr->nNumButtons != 0 )
|
infoPtr->nNumButtons,
|
||||||
return FALSE;
|
infoPtr->nBitmapWidth, infoPtr->nBitmapHeight,
|
||||||
|
LOWORD(lParam), HIWORD(lParam));
|
||||||
|
|
||||||
infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
|
infoPtr->nBitmapWidth = (INT)LOWORD(lParam);
|
||||||
infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
|
infoPtr->nBitmapHeight = (INT)HIWORD(lParam);
|
||||||
|
|
||||||
|
/* uses image list internals directly */
|
||||||
|
if (infoPtr->himlDef) {
|
||||||
|
infoPtr->himlDef->cx = infoPtr->nBitmapWidth;
|
||||||
|
infoPtr->himlDef->cy = infoPtr->nBitmapHeight;
|
||||||
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user