Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#12767 closed defect (fixed)

wxSpinCtrlDouble has different size than wxSpinCtrl in MSW

Reported by: LukasK Owned by:
Priority: normal Milestone:
Component: wxMSW Version: stable-latest
Keywords: Cc:
Blocked By: Blocking:
Patch: no

Description

The wxSpinCtrl and wxSpinCtrlDouble have different sizes and spacing in MSW, the wxSpinCtrlDouble appears not to honor the passed in constructor size exactly.

In XP with the classic theme i have seen this result in a clipped wxSpinCtrlDouble, and regardless of clipping it will look poor if a wxSpinCtrl and a wxSpinCtrlDouble are next to each other.

Attachments (2)

clipped_wxspinctrldouble.png download (2.1 KB) - added by LukasK 4 years ago.
A wxSpinCtrlDouble which has the wxSpinButton part clipped
control_diff.png download (2.8 KB) - added by LukasK 4 years ago.
The different size of a wxSpinCtrl and a wxSpinCtrlDouble in msw

Download all attachments as: .zip

Change History (6)

Changed 4 years ago by LukasK

A wxSpinCtrlDouble which has the wxSpinButton part clipped

Changed 4 years ago by LukasK

The different size of a wxSpinCtrl and a wxSpinCtrlDouble in msw

comment:1 Changed 4 years ago by LukasK

I've looked a bit in the wx source. In MSW the wxSpinCtrlDouble is the generic implementation which is a composite of a wxSpinButton and a wxTextCtrl. The regular wxSpinCtrl inherits from wxSpinButton, and uses the windows api up-down control buddy-messaging with a raw windows api edit field.

I don't know if the generic control can be adjusted and how that would affect other platforms (although, if the generic control is too large compared to size, this should probably be done anyway).

It also looks like it would be possible to create a wxSpinCtrlDouble implementation for msw which mimics the wxSpinControl, but using only the delta from the spin-button and counting with increment, digit precision etc. inside the wxSpinCtrlDouble.

comment:2 Changed 4 years ago by vadz

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

There are 2 things here:

  1. The code in wxSpinCtrlGenericBase::DoMoveWindow() was simply wrong as it forgot to account for the extra margin. This accounted for the truncation and I'll fix this.
  2. The margin is hard coded to be 2 while MSW uses 1 in the native control. This accounted for a different appearance from the native control and for now I'll just change the margin to 1 for the generic version, if something else is needed under the other platforms we can always add extra #ifdefs or what not.

As for implementing a native wxSpinCtrlDouble for MSW, this would be nice but unless somebody can contribute it I don't think it's going to happen soon.

comment:3 Changed 4 years ago by VZ

(In [66443]) Correct bug in the wxSpinCtrlGeneric sub-controls resizing.

The code in DoMoveWindow() didn't account for the margin and made the text
control part of the window too large resulting in the truncation of the spin
button.

Simply remember to take margin into account when computing the text width.

See #12767.

comment:4 Changed 4 years ago by VZ

(In [66444]) Make the margin between wxSpinCtrlGeneric sub-windows compatible with MSW.

Native MSW wxSpinCtrl uses a single pixel margin between the text part and the
spin button while the generic version used 2 pixels which resulted in a
slightly different appearance (see #12767).

Use the same margin as MSW now in the generic version too, it should be fine
for the other platforms as well and if it isn't we can always tweak them
later.

Note: See TracTickets for help on using tickets.