Opened 5 years ago

Closed 5 years ago

#15499 closed defect (fixed)

wxFlagProperty; issue with combined flags

Reported by: jens Owned by:
Priority: normal Milestone: 3.0.0
Component: wxPropertyGrid Version: stable-latest
Keywords: wxFlagProperty Cc:
Blocked By: Blocking:
Patch: yes


I found a somewhat irritating behaviour with wxFlagProperty.

Sometimes flags get combined with a bitwise or to a flag with another name for convenience:
e.g. three of the possible SetSze-flags in defs.h

/*  Use internally-calculated width if -1 */
#define wxSIZE_AUTO_WIDTH       0x0001
/*  Use internally-calculated height if -1 */
#define wxSIZE_AUTO_HEIGHT      0x0002
/*  Use internally-calculated width and height if each is -1 */
#define wxSIZE_AUTO             (wxSIZE_AUTO_WIDTH|wxSIZE_AUTO_HEIGHT)

Expected behaviour (if they are used in wxFlagProperty) is that if wxSIZE_AUTO is set, both other flags get set automatically, or if wxSIZE_AUTO_WIDTH and wxSIZE_AUTO_HEIGHT are both set, wxSIZE_AUTO is set automatically.

In current implementatio wxSIZE_AUTO gets set, if any of the other two is set.

I attach a patch to the propgrid-sample that shows this behaviour.
I added the three flags to the end of the "Window Styles" property.

I also attach a patch that makes wxFlagProperty work as I expect it.

Attachments (2)

propgrid_sample.patch download (707 bytes) - added by jens 5 years ago.
patch to show issue in propgrid sample
propgrid.patch download (659 bytes) - added by jens 5 years ago.
patch that can fix the issue

Download all attachments as: .zip

Change History (3)

Changed 5 years ago by jens

patch to show issue in propgrid sample

Changed 5 years ago by jens

patch that can fix the issue

comment:1 Changed 5 years ago by VZ

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

(In [74808]) Improve composite flags handling in the property grid wxFlagsProperty.

Don't consider that a flag is on just because one of its bits is enabled in
the current flags, for the composite flags (e.g. something like "BOTH = ONE |
TWO") all the bits composing the flag must be on for it to be enabled.

Closes #15499.

Note: See TracTickets for help on using tickets.