Commited Keybinder ver 0.4.4 1/7/2006 10:56 PM
Re: keybinder clobbers menuitems with bitmaps.
It's been a real education tracing through WX262 menu
code this past week. It appears to me that the menu bitmap code
is a paste and forget job. Very disappointing.
The XRC code "owner draws" the bitmap onto the menu, then
the menu code willy nilly turns off the "m_bOwnerDrawn" flag.
Bitmapped menuitems are not supported in WX menu code, only OwnerDrawn.
Reason: Looks like a Win98 thingie. But...
The next time the menuitem is updated, ownerdrawn attributes, bitmaps
etc are clobbered because, of course, the owner drawn code is never called.
If the modifying coder turns owner drawn back on, the width of the
menuitem is ignored, the accelerator is drawn "right aligned", thus
clobbering (drawing over) the menuitem text. Ugly!
Hack:
SetText without OwnerDrawn to guarantee the menuitem width,
then do it again with OwnerDrawn=true to redraw/reinstate the bitmap. Jeeezzh!!!
// set "un-ownerdrawn" text to preserve menu width
m_pItem->SetText(newtext);
//now redraw the menuitem if bitmapped
if (m_pItem->GetBitmap().GetWidth())
{ m_pItem->SetOwnerDrawn();
m_pItem->SetText(newtext);
}
//-m_pItem->GetMenu()->UpdateAccel(m_pItem); //<--does nothing previous SetTExt() didnt
The results are not pretty. The margin between the bitmap and the text is changed,
and the accelerator is vertically misaligned with its siblings because it's
drawn "right aligned" into the menuitem. Yuk!
So: I'm commiting the "fixed" keybinder, and will now find a way to draw
it as pretty as XRC does it. I think this is important, because we're all
gonna have to mangle a menu someday.
thanks
pecan