SpinCtrl default width Windows/Mac/GTK2/GTK3 Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
User avatar
rocrail
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Fri Oct 02, 2009 2:02 pm
Contact:

SpinCtrl default width Windows/Mac/GTK2/GTK3

Post by rocrail » Fri May 15, 2020 1:41 pm

Hi,

if using SpinCtrl default width, -1, it sizes different under all supported Operating Systems:

- Windows resize it as needed for its range. =D>
- Mac shows an acceptable default width. :|
- Ubuntu 20.04, GTK3, resize it so to make it possible to changed values on a touch device with your feet. :shock:

Is this a wxWidgets feature, or OS dependent?
Best regards,
Rob.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4361
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: SpinCtrl default width Windows/Mac/GTK2/GTK3

Post by ONEEYEMAN » Fri May 15, 2020 3:23 pm

Hi,
Which wx version?
What version of Windows - 10 or lower?
What is exact GTK+ version?
How did you configure OSX build?
Can you reproduce it in the widgets sample?

Thank you.

User avatar
rocrail
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Fri Oct 02, 2009 2:02 pm
Contact:

Re: SpinCtrl default width Windows/Mac/GTK2/GTK3

Post by rocrail » Fri May 15, 2020 3:35 pm

wxWidgets version: 3.1.4
Windows 10 -> Locoal wxWidgets library compiled with latest git, statically linked.
macOS Catalina -> Locoal wxWidgets library compiled with latest git
Ubuntu 20.04 GTK3 -> Distribution wxWidgets library
Best regards,
Rob.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4361
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: SpinCtrl default width Windows/Mac/GTK2/GTK3

Post by ONEEYEMAN » Fri May 15, 2020 4:02 pm

Hi,
Can you reproduce it in the {widgets} sample?

Thank you.

User avatar
rocrail
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Fri Oct 02, 2009 2:02 pm
Contact:

Re: SpinCtrl default width Windows/Mac/GTK2/GTK3

Post by rocrail » Fri May 15, 2020 4:11 pm

Hi ONEEYEMAN,

why should I?
Its not a defect, but a rendering issue, which I cannot, and do not want to, control by the wxWidgets API.

This thread is only meant to show diffs for the SpinCtrl on all Platforms.
As I already wrote before: The GTK3 implementation is not OK.

I will not add a simple wx example to show this.
Best regards,
Rob.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4361
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: SpinCtrl default width Windows/Mac/GTK2/GTK3

Post by ONEEYEMAN » Fri May 15, 2020 4:49 pm

Hi,
I understand.
But it means that there is an inconsistency in behavior between platforms which could be possibly fixed by core wx devs.

There are multiple instances of such inconsistencies that was fixed over the years.

So could you please confirm that the same behavior is observed in the widgets sample?

Thank you.

User avatar
rocrail
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Fri Oct 02, 2009 2:02 pm
Contact:

Re: SpinCtrl default width Windows/Mac/GTK2/GTK3

Post by rocrail » Sat May 16, 2020 6:54 am

OK,

using the wxWidgets sample widgets unchanged.
Attached are macOS Catalina, Windows 10-64, Ubuntu 20.04.

The wxWidgets I build from source, and the sample looks good...
I must investigate this.
macos-widgets.png
win10-widgets.png
win10-widgets.png (51.24 KiB) Viewed 656 times
ubuntu2004-widgets.png
ubuntu2004-widgets.png (69.23 KiB) Viewed 656 times
Best regards,
Rob.

User avatar
rocrail
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Fri Oct 02, 2009 2:02 pm
Contact:

Re: SpinCtrl default width Windows/Mac/GTK2/GTK3

Post by rocrail » Sat May 16, 2020 7:02 am

Just saw that in the widgets sample the resizing is calculated and set programmatically:

Code: Select all

    wxString smax('9', m_textMax->GetValue().length());
    wxSize  size = m_spinctrl->GetSizeFromTextSize(m_spinctrl->GetTextExtent(smax));

    m_spinctrl->SetMinSize(size);
    m_spinctrl->SetSize(size);
In case of my Project, Rocrail, there are hundreds of SpinCtrl used, so this is no option...
Best regards,
Rob.

User avatar
doublemax
Moderator
Moderator
Posts: 15068
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: SpinCtrl default width Windows/Mac/GTK2/GTK3

Post by doublemax » Sat May 16, 2020 7:35 am

In case of my Project, Rocrail, there are hundreds of SpinCtrl used, so this is no option...
If worst comes to worst, you can subclass it and replace all occurrences with a custom version that does this in its constructor.
Use the source, Luke!

User avatar
rocrail
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Fri Oct 02, 2009 2:02 pm
Contact:

Re: SpinCtrl default width Windows/Mac/GTK2/GTK3

Post by rocrail » Sat May 16, 2020 7:48 am

My initial issue still remains, because under Windows this is done automatically, and under GTK it must be set manually.
Best regards,
Rob.

User avatar
rocrail
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Fri Oct 02, 2009 2:02 pm
Contact:

Re: SpinCtrl default width Windows/Mac/GTK2/GTK3

Post by rocrail » Sat May 16, 2020 8:07 am

The calculation used in the widgets example is not OK:
macos-widgets-range.png
macos-widgets-range.png (23.83 KiB) Viewed 645 times
And some Linux distros come with wx3.0, so this method is not available.
Best regards,
Rob.

User avatar
rocrail
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Fri Oct 02, 2009 2:02 pm
Contact:

Re: SpinCtrl default width Windows/Mac/GTK2/GTK3

Post by rocrail » Sat May 16, 2020 8:53 am

In file "common/spinctrlcmn.cpp" the function GetBestSize already calculate this automatically:

Code: Select all

int wxSpinCtrlImpl::GetMaxValueLength(int minVal, int maxVal, int base)
{
    const int lenMin = (base == 16 ?
                       FormatAsHex(minVal, maxVal) :
                       wxString::Format("%d", minVal)).length();
    const int lenMax = (base == 16 ?
                       FormatAsHex(maxVal, maxVal) :
                       wxString::Format("%d", maxVal)).length();
    return wxMax(lenMin, lenMax);
}

wxSize wxSpinCtrlImpl::GetBestSize(const wxControl* spin,
                                   int minVal, int maxVal, int base)
{
    const wxString largestString('8', GetMaxValueLength(minVal, maxVal, base));
    return spin->GetSizeFromText(largestString);
}
Which works under Windows10, but is ignored under GTK.
Best regards,
Rob.

PB
Part Of The Furniture
Part Of The Furniture
Posts: 2512
Joined: Sun Jan 03, 2010 5:45 pm

Re: SpinCtrl default width Windows/Mac/GTK2/GTK3

Post by PB » Sat May 16, 2020 9:14 am

I do not use Linux so I have not idea why it does not work, but the code doing that is supposedly there, see e.g. GtkSetEntryWidth() in this recent commit
https://github.com/wxWidgets/wxWidgets/ ... 96abb9deac

Perhaps you could step into the code and see why it does not work as expected (the best size is invalidated when the spin params change)?

User avatar
rocrail
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 207
Joined: Fri Oct 02, 2009 2:02 pm
Contact:

Re: SpinCtrl default width Windows/Mac/GTK2/GTK3

Post by rocrail » Sat May 16, 2020 12:29 pm

Sorry, but I'm not familiar with GTK.
Someone with some GTK knowledge should take a look at it.
Best regards,
Rob.

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 4361
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: SpinCtrl default width Windows/Mac/GTK2/GTK3

Post by ONEEYEMAN » Sat May 16, 2020 2:03 pm

Hi,
So you are saying that even in the unmodified sample this is not ok?

Then you should file a bug on trac...

Thank you.

Post Reply