Opened 11 years ago

Last modified 3 years ago

#11645 confirmed defect

Owner-drawn menu item height inconsistent with the normal items

Reported by: BuschnicK Owned by:
Priority: low Milestone:
Component: wxMSW Version: dev-latest
Keywords: menu, ownerdrawn Cc:
Blocked By: Blocking:
Patch: no

Description

On WindowsXP the menu item line heights and item alignments are inconsistent between different types of items (ownerdrawn, checkitem, normal item). Line heights vary considerably and horizontal alignments jump in and out based on item type.

Note that this used to be even worse in 2.8.10 where item alignments depended on a static variable in wx which remembered the deepest indentation encountered so far. This meant that your indentation depended on the order in which menus were first opened.

The current state produces ugly and fidgety looking menus.

Attachments (2)

Menu1.png download (5.1 KB) - added by BuschnicK 11 years ago.
screenshot showing indentation
Menu2.png download (15.6 KB) - added by BuschnicK 11 years ago.
screenshot showing line heights

Download all attachments as: .zip

Change History (7)

Changed 11 years ago by BuschnicK

screenshot showing indentation

Changed 11 years ago by BuschnicK

screenshot showing line heights

comment:1 follow-up: Changed 11 years ago by vadz

  • Priority changed from high to normal
  • Status changed from new to infoneeded_new

Could you please retest with the latest svn (r63230)? I've merged the ownerdrawn branch, which fixed several menu-related issues (#10635, #11244, #11268, #11420, #11479, #11480) so this could have taken care of this problem as well. If you still see it, please provide a way to reproduce it. TIA!

comment:2 in reply to: ↑ 1 Changed 11 years ago by BuschnicK

  • Status changed from infoneeded_new to new

Replying to vadz:

Could you please retest with the latest svn (r63230)? I've merged the ownerdrawn branch, which fixed several menu-related issues (#10635, #11244, #11268, #11420, #11479, #11480) so this could have taken care of this problem as well. If you still see it, please provide a way to reproduce it. TIA!

I'd like to but that is a little more involved. My application is huge and a wx upgrade not easily done. Also, for some reason I cannot seem to be able to access the SVN repository from the office, only from home. Apparently our company firewall is preventing access. I will test with trunk eventually, but it may take some time yet.

comment:3 follow-up: Changed 3 years ago by vadz

  • Keywords ownerdrawn added; item alignment removed
  • Status changed from new to confirmed
  • Summary changed from inconsistent menu item alignment and line height to Owner-drawn menu item height inconsistent with the normal items
  • Version changed from 2.9.0 to dev-latest

The problem with line height can still be seen under Win7 and 10 (see the one but last comment of #11657) in the menu sample, in the "Test" menu with 3.1.1.

We probably just need to measure the owner-drawn items better.

comment:4 in reply to: ↑ 3 Changed 3 years ago by catalin

Replying to vadz:

The problem with line height can still be seen under Win7 and 10

Looking a bit into this shows that right now the line height problem is with non-ownerdrawn items. According to wxMenuItem::MSWMustUseOwnerDrawn(), the item will be ownerdrawn if it has custom colours or font, which is not the case in menu sample.
When setting background colour for any of the check menu items and making it ownerdrawn everything looks fine, for all of them.

The problem there however is the size of the check image in the sample, which is 8. Increasing that size makes the entry react accordingly by increasing its height. But Creating Custom Check Mark Bitmaps sais "A custom check-mark bitmap must be the same size as the default check-mark bitmap".
In that case there could be a few options:
1) Assert when the bitmap size is too small (|big?), but then the programmer would still have to put some magic numbers there.
2) Rebuild the bitmap when the provided one is too small (|big?), but that could be too error prone.
3) Allow the user to retrieve the default check-mark size, using something like GetSystemMetrics() with SM_CXMENUCHECK and SM_CYMENUCHECK.
4) Always make the menu item height at least GetSystemMetrics(SM_CYMENUCHECK) (on Win10 it is 15).

comment:5 Changed 3 years ago by vadz

  • Priority changed from normal to low

We actually already kind of implement (3) with wxRenderer::GetCheckBoxSize() so there is a relatively simple workaround and I'm lowering the priority because of this, but I think it'd be still nice to also do (4), perhaps by doing (2) and centring the user-provided bitmap in the bitmap of the right size with transparent pixels.

Note: See TracTickets for help on using tickets.