Re: Resend : Implements MIIM_BITMAP state in menus
Maxime Bellengé <maxime.bellenge(a)wanadoo.fr> writes:
+ * drawhbmbitmap : True to draw the hbmbitmap(MIIM_BITMAP)/False to draw the MF_BITMAP */ -static void MENU_DrawBitmapItem( HDC hdc, MENUITEM *lpitem, const RECT *rect, BOOL menuBar ) +static void MENU_DrawBitmapItem( HDC hdc, MENUITEM *lpitem, const RECT *rect, BOOL menuBar, BOOL drawhbmbitmap )
What's the point of passing the drawhbmbitmap flag since you always set it to TRUE?
@@ -762,14 +773,15 @@ int h = rect->bottom - rect->top; int bmp_xoffset = 0; int left, top; + HBITMAP swtch = (drawhbmbitmap)?lpitem->hbmpItem:(HBITMAP)lpitem->text;
That's a strange variable name for a bitmap...
+ /* New style MIIM_BITMAP */ + if (lpitem->hbmpItem) + { + if (lpitem->hbmpItem == HBMMENU_CALLBACK) + { + MEASUREITEMSTRUCT measItem; + measItem.CtlType = ODT_MENU; + measItem.CtlID = 0; + measItem.itemID = lpitem->wID; + measItem.itemWidth = lpitem->rect.right - lpitem->rect.left; + measItem.itemHeight = lpitem->rect.bottom - lpitem->rect.top; + measItem.itemData = lpitem->dwItemData; + + SendMessageW( hwndOwner, WM_MEASUREITEM, lpitem->wID, (LPARAM)&measItem); + + /* Keep the size of the bitmap in callback mode to be able to draw it correctly */ + lppop->bmpSize.cx = max(lppop->bmpSize.cx, measItem.itemWidth - (lpitem->rect.right - lpitem->rect.left)); + lppop->bmpSize.cy = max(lppop->bmpSize.cy, measItem.itemHeight - (lpitem->rect.bottom - lpitem->rect.top));
Why do you store the bitmap size in the parent popup? What if there are multiple items with bitmaps? -- Alexandre Julliard julliard(a)winehq.org
On Mon, 2005-03-07 at 19:52 +0100, Alexandre Julliard wrote:
Maxime Bellengé <maxime.bellenge(a)wanadoo.fr> writes:
+ * drawhbmbitmap : True to draw the hbmbitmap(MIIM_BITMAP)/False to draw the MF_BITMAP */ -static void MENU_DrawBitmapItem( HDC hdc, MENUITEM *lpitem, const RECT *rect, BOOL menuBar ) +static void MENU_DrawBitmapItem( HDC hdc, MENUITEM *lpitem, const RECT *rect, BOOL menuBar, BOOL drawhbmbitmap )
What's the point of passing the drawhbmbitmap flag since you always set it to TRUE?
You're right, it's a terrible typo
@@ -762,14 +773,15 @@ int h = rect->bottom - rect->top; int bmp_xoffset = 0; int left, top; + HBITMAP swtch = (drawhbmbitmap)?lpitem->hbmpItem:(HBITMAP)lpitem->text;
That's a strange variable name for a bitmap...
I agree, I should have chosen a better one.
+ /* New style MIIM_BITMAP */ + if (lpitem->hbmpItem) + { + if (lpitem->hbmpItem == HBMMENU_CALLBACK) + { + MEASUREITEMSTRUCT measItem; + measItem.CtlType = ODT_MENU; + measItem.CtlID = 0; + measItem.itemID = lpitem->wID; + measItem.itemWidth = lpitem->rect.right - lpitem->rect.left; + measItem.itemHeight = lpitem->rect.bottom - lpitem->rect.top; + measItem.itemData = lpitem->dwItemData; + + SendMessageW( hwndOwner, WM_MEASUREITEM, lpitem->wID, (LPARAM)&measItem); + + /* Keep the size of the bitmap in callback mode to be able to draw it correctly */ + lppop->bmpSize.cx = max(lppop->bmpSize.cx, measItem.itemWidth - (lpitem->rect.right - lpitem->rect.left)); + lppop->bmpSize.cy = max(lppop->bmpSize.cy, measItem.itemHeight - (lpitem->rect.bottom - lpitem->rect.top));
Why do you store the bitmap size in the parent popup? What if there are multiple items with bitmaps?
Because when drawing I want the maximum width among all the bitmaps of the items in order to align correctly the checkmarks and the text. It is the behavior I saw on two different apps. If you use different size bitmaps for each item, windows aligns the text and the checkmark. So I store it in the parent popup to be able to get it when drawing each item otherwise I wouldn't know how to align the checkmark and the text. Do you think it can be done more efficiently ? Maxime
Maxime Bellengé <maxime.bellenge(a)wanadoo.fr> writes:
Because when drawing I want the maximum width among all the bitmaps of the items in order to align correctly the checkmarks and the text. It is the behavior I saw on two different apps. If you use different size bitmaps for each item, windows aligns the text and the checkmark. So I store it in the parent popup to be able to get it when drawing each item otherwise I wouldn't know how to align the checkmark and the text.
Ah OK, I see now. Then you need to choose a better name than bmpSize to indicate that it's the maximum size, and you need to initialize it to zero before starting the loop. -- Alexandre Julliard julliard(a)winehq.org
participants (2)
-
Alexandre Julliard -
Maxime Bellengé