Opened 10 years ago

Closed 5 years ago

#4608 closed defect (fixed)

Incorrect icons' alignment in menus

Reported by: hzd_byte Owned by:
Priority: normal Milestone:
Component: wxMSW Version:
Keywords: menu ownerdrawn regression Cc: hzd_byte
Blocked By: Blocking:
Patch: no


There is incorrect icons' alignment in menus..
In wxWidgets 2.8.0 there was no bug.

Look at attached image.

Attachments (2)

menu_icons_bug.JPG download (10.4 KB) - added by hzd_byte 10 years ago.
Icons' alignment bug
wx_2.8.0_menu_icons.JPG download (10.4 KB) - added by hzd_byte 10 years ago.

Download all attachments as: .zip

Change History (11)

Changed 10 years ago by hzd_byte

Icons' alignment bug

comment:1 Changed 10 years ago by vadz

The icons seem to be aligned just fine to me, but they seem to be cut off on the left, is this what you mean?

As usual, having a patch showing the problem in the menu or ownerdrawm sample would be very helpful.

Changed 10 years ago by hzd_byte


comment:2 Changed 10 years ago by hzd_byte

Look at these menu's icons in wxWidgets 2.8.0 (attached image)
File Added: wx_2.8.0_menu_icons.JPG

comment:3 Changed 10 years ago by vadz

Yes, something changed... Can you see the same effect in the ownerdrw sample or not?

comment:4 Changed 10 years ago by hzd_byte

There is all ok in the ownerdrw sample.. Icons correctly drawn.

comment:5 Changed 10 years ago by vadz

And could you please try to reproduce the bug in ownerdrw sample? I.e. try to provide minimal modification to it showing the problem?

It's going to be rather difficult for us to fix the bug without being able to see it I'm afraid.


comment:6 Changed 10 years ago by hzd_byte

In the "menu" sample I changed line



item->SetBitmap(wxBitmap(_T("sound.gif"), wxBITMAP_TYPE_ANY));

"sound.gif" is an 34x31 pixels image.

comment:7 Changed 10 years ago by vadz

  • Cc vadz removed
  • Keywords menu ownerdrawn regression added
  • Status changed from new to confirmed

I can indeed see that the bitmap is cut off on the left side with the following patch (even with the latest trunk):

Index: samples/menu/menu.cpp
--- samples/menu/menu.cpp       (revision 54766)
+++ samples/menu/menu.cpp       (working copy)
@@ -59,6 +59,8 @@
 #include "copy.xpm"

+#include "wx/dcmemory.h"
 // ----------------------------------------------------------------------------
 // classes
 // ----------------------------------------------------------------------------
@@ -442,7 +444,14 @@
     wxMenuItem *item = new wxMenuItem(fileMenu, Menu_File_ClearLog,
                                       _T("Clear &log\tCtrl-L"));
 #if wxUSE_OWNER_DRAWN || defined(__WXGTK__)
-    item->SetBitmap(copy_xpm);
+    wxBitmap bmp(34, 31);
+    wxMemoryDC dc(bmp);
+    dc.SetBrush(*wxBLACK_BRUSH);
+    dc.Clear();
+    dc.SetPen(*wxRED_PEN);
+    dc.DrawLine(0, 0, 34, 31);
+    dc.DrawLine(0, 31, 34, 0);
+    item->SetBitmap(bmp);

comment:8 Changed 5 years ago by catalin

This no longer happens in 2.9-svn. The bitmap is correctly aligned, tested with the test code in comment:7

comment:9 Changed 5 years ago by vadz

  • Resolution set to fixed
  • Status changed from confirmed to closed

Hmm, I wonder what has actually fixed this as I thought we still had some problems in the owner draw menu code. But if it works now, all the better, thanks for testing!

Note: See TracTickets for help on using tickets.