Author Topic: Menu Icons are gone  (Read 44174 times)

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Menu Icons are gone
« Reply #45 on: January 03, 2006, 04:24:19 pm »
@tiwag: try this but keep a copy of the devel/ dir first. If this fixes it for you too, compare the new devel/ with the copy you kept. We might pinpoint the reason then...

although i thought i would have done something equivalent with completely rebuilding,
i followed your advice and --  YOU ARE RIGHT !!!
with a newly generated devel directory the icons are back again !

now i'll study the differences...
some ideas where to look first ?

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Menu Icons are gone
« Reply #46 on: January 03, 2006, 04:24:36 pm »
@thomas - can you please post your mingw10.dll here
Hmm... don't believe that can be a reason, but ok.

I assume I don't have to post the source to comply with the GPL, too... ;)

[attachment deleted by admin]
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Menu Icons are gone
« Reply #47 on: January 03, 2006, 04:27:47 pm »
@thomas - can you please post your mingw10.dll here
Hmm... don't believe that can be a reason, but ok.

thomas the nonbeliever is right - my mingwm10.dll is exactly the same as yours ;-)

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Re: Menu Icons are gone
« Reply #48 on: January 03, 2006, 04:37:43 pm »
Ok folks,

This looks like a keybinder problem. Keybinder replaces
the menuitem name and label even if it doesnt have a
darn binding for the thing.

Any suggestions as to how I should preserve the icon??

thanks
pecan

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Menu Icons are gone
« Reply #49 on: January 03, 2006, 04:38:41 pm »
Now that explains a lot... I have the keybinder plugin disabled... :lol:
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Menu Icons are gone
« Reply #50 on: January 03, 2006, 04:39:32 pm »
and on linux, I did not build the contribs ..

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5491
Re: Menu Icons are gone
« Reply #51 on: January 03, 2006, 04:40:53 pm »
turned keybinder off and --> icons back .  yesssssssssssssssss

Offline tiwag

  • Developer
  • Lives here!
  • *****
  • Posts: 1196
  • sailing away ...
    • tiwag.cb
Re: Menu Icons are gone
« Reply #52 on: January 03, 2006, 04:42:48 pm »
just now found independently out that cbKeybinder is guilty - ok - bug is pinpointed !
thx @all !

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Re: Menu Icons are gone
« Reply #53 on: January 03, 2006, 04:45:39 pm »
I could get busy and look it up, but.....

How is that icon attached to the menuitem label?
Could someone point my nose in an "info" direction?

thanks
pecan

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Menu Icons are gone
« Reply #54 on: January 03, 2006, 04:52:58 pm »
Umm... XRC...  if you want a reference to the bitmap, you will have to call wxMenuItem::GetBitmap, no other way.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Re: Menu Icons are gone
« Reply #55 on: January 03, 2006, 05:00:58 pm »
Thanks thomas

That give me a direction in which to start.

thanks
pecan

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Re: Menu Icons are gone
« Reply #56 on: January 08, 2006, 05:05:23 am »
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!!!

Code
	// 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

Offline Der Meister

  • Regular
  • ***
  • Posts: 307
Re: Menu Icons are gone
« Reply #57 on: January 08, 2006, 11:39:32 am »
Well, there is a little problem with the modification you showed here:
wxMenuItem::SetOwnerDrawn() does not exist - at least not in wxGTK 2.6.1 and not in the official documentation of wxWidgets 2.6.2. Maybe it is a wxMSW-specific function (although I could not find something like this in the documentation) but then it should be wrapped with preprocessor macros to be only included on windows. Therefore it should be changed like this:
Code
$ svn diff src/plugins/contrib/keybinder/menuutils.cpp 
Index: src/plugins/contrib/keybinder/menuutils.cpp
===================================================================
--- src/plugins/contrib/keybinder/menuutils.cpp (revision 1676)
+++ src/plugins/contrib/keybinder/menuutils.cpp (working copy)
@@ -109,7 +109,10 @@
         m_pItem->SetText(newtext);
         //now redraw the menuitem if bitmapped
                if (m_pItem->GetBitmap().GetWidth())
-        {   m_pItem->SetOwnerDrawn();
+        {
+#if defined( __WXMSW__ )
+               m_pItem->SetOwnerDrawn();
+#endif
             m_pItem->SetText(newtext);
         }
         //-m_pItem->GetMenu()->UpdateAccel(m_pItem); //<--does nothing previous SetTExt() didnt
I don't know if this still workes - but at least it can be compiled again.
Real Programmers don't comment their code. If it was hard to write, it should be hard to understand.
Real Programmers don't write in BASIC. Actually, no programmers write in BASIC, after the age of 12.

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Re: Menu Icons are gone
« Reply #58 on: January 08, 2006, 03:06:16 pm »
Is there anyone out there that could test the
Der Meister fix and tell me yea or ney on this.

I dont have a GTK system.

thanks
pecan

Edit:
Looking at the DerMeister fix again....
That looks good, if GTK was working Ok before,
it should work fine with the DerMeister fix.

I'll change it and re-commit

Thanks
pecan
« Last Edit: January 08, 2006, 03:19:20 pm by Pecan »

Offline Pecan

  • Plugin developer
  • Lives here!
  • ****
  • Posts: 2778
Re: Menu Icons are gone
« Reply #59 on: January 08, 2006, 04:25:44 pm »
I've commited keybinder (svn1682) with hopefully
the original GTK menuitem update code.

If someone with GTK would test this and report back,
I'd really appreciate it.

thanks
pecan