Opened 13 months ago

Closed 12 months ago

Last modified 12 months ago

#18734 closed optimization (fixed)

The Default width of wxSpinCtrlDouble seems to be optimized

Reported by: happythings Owned by: Vadim Zeitlin <vadim@…>
Priority: normal Milestone:
Component: GUI-all Version: 3.1.3
Keywords: wxSpinCtrlDouble Cc: 445210566@…
Blocked By: Blocking:
Patch: yes

Description

I notice the default width of wxSpinCtrlDouble is incorrect when it's digits is set great than zero. On linux, the default width is calculated with the same way of wxSpinCtrl, it's too narrow. On Windows, I don't know how it's calculated, but it's too wide. I think it's should be optimized when next version of wsxWidgets released.

Attachments (1)

swSpinCtrlDouble.png download (12.5 KB) - added by happythings 13 months ago.
Demo of wxSpinCtrlDouble shows Too Narrow on Ubuntu and too Wide on Windows

Download all attachments as: .zip

Change History (6)

comment:1 Changed 13 months ago by vadz

  • Milestone 3.1.4 deleted
  • Status changed from new to infoneeded_new
  • Type changed from optimization to defect

Sorry, but it's really not clear what do you mean.

Please explain how to reproduce the problem in the widgets sample, which already has a wxSpinCtrlDouble in it. If necessary, please make a small patch to the sample to allow reproducing the problem.

comment:2 Changed 13 months ago by happythings

  • Cc 445210566@… added
  • Status changed from infoneeded_new to new
  • Type changed from defect to optimization

For Example:

m_SpinCtrlDoubleMax1With5Digits = new wxSpinCtrlDouble( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 1, 0.000000, 1e-05 );
m_SpinCtrlDoubleMax1With5Digits->SetDigits( 5 );
bSizer2->Add( m_SpinCtrlDoubleMax1With5Digits, 0, wxALL, 5 );

m_SpinCtrlMax1000 = new wxSpinCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxSP_ARROW_KEYS, 0, 1000, 0 );
bSizer2->Add( m_SpinCtrlMax1000, 0, wxALL, 5 );
mainSizer->Add( bSizer2, 0, wxEXPAND, 5 );

On Ubuntu 16.04LTS With GTK2,

m_SpinCtrlDoubleMax1000With5Digits is displayed very narrow , only 0. is visible, i think if its default size is correctly calculated, 0.00000 should be visible without m_SpinCtrlDoubleMax1000With5Digits->SetSize(100,-1) is called.

The m_SpinCtrlMax1000 is displayed with correct width, its width is wide enough to let 0~1000 visible.

But on Windows, m_SpinCtrlDoubleMax1000With5Digits is displayed very wide, too wide.

Sorry, I don't know how to paste a image here.

Changed 13 months ago by happythings

Demo of wxSpinCtrlDouble shows Too Narrow on Ubuntu and too Wide on Windows

comment:3 Changed 13 months ago by vadz

  • Patch set
  • Status changed from new to confirmed

OK, thanks, I see the problem -- and in wxGTK3 too.

I've created PR 1817 which should fix it under GTK. I didn't look at it under MSW yet.

comment:4 Changed 12 months ago by Vadim Zeitlin <vadim@…>

  • Owner set to Vadim Zeitlin <vadim@…>
  • Resolution set to fixed
  • Status changed from confirmed to closed

In d3b968609/git-wxWidgets:

Take number of digits into account in GTK wxSpinCtrlDouble

When determining the entry width in wxSpinCtrlDouble, we need to account
not only for the width of the integer part, but also for the number of
digits that determines the width of the fractional part.

Do it in the overridden version of (now virtual) GtkSetEntryWidth().

See https://github.com/wxWidgets/wxWidgets/pull/1817

Closes #18734.

comment:5 Changed 12 months ago by Artur Wieczorek <artwik@…>

In 6c64f4994/git-wxWidgets:

Fix calculation of the size of wxSpinCtrlDouble numeric box

Every time spin control precision, minimal or maximal value changes there
is necessary to adjust numeric box size to the new dimension of displayed
number.

See #18734.

Note: See TracTickets for help on using tickets.