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
Super wx Problem Solver
Super wx Problem Solver
Posts: 299
Joined: Fri Oct 02, 2009 2:02 pm

SpinCtrl default width Windows/Mac/GTK2/GTK3

Post by rocrail »

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.
https://wiki.rocrail.net
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7481
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

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

Post by ONEEYEMAN »

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
Super wx Problem Solver
Super wx Problem Solver
Posts: 299
Joined: Fri Oct 02, 2009 2:02 pm

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

Post by rocrail »

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.
https://wiki.rocrail.net
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7481
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

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

Post by ONEEYEMAN »

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

Thank you.
User avatar
rocrail
Super wx Problem Solver
Super wx Problem Solver
Posts: 299
Joined: Fri Oct 02, 2009 2:02 pm

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

Post by rocrail »

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.
https://wiki.rocrail.net
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7481
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

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

Post by ONEEYEMAN »

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
Super wx Problem Solver
Super wx Problem Solver
Posts: 299
Joined: Fri Oct 02, 2009 2:02 pm

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

Post by rocrail »

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
ubuntu2004-widgets.png
You do not have the required permissions to view the files attached to this post.
Best regards,
Rob.
https://wiki.rocrail.net
User avatar
rocrail
Super wx Problem Solver
Super wx Problem Solver
Posts: 299
Joined: Fri Oct 02, 2009 2:02 pm

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

Post by rocrail »

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.
https://wiki.rocrail.net
User avatar
doublemax
Moderator
Moderator
Posts: 19163
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

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

Post by doublemax »

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
Super wx Problem Solver
Super wx Problem Solver
Posts: 299
Joined: Fri Oct 02, 2009 2:02 pm

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

Post by rocrail »

My initial issue still remains, because under Windows this is done automatically, and under GTK it must be set manually.
Best regards,
Rob.
https://wiki.rocrail.net
User avatar
rocrail
Super wx Problem Solver
Super wx Problem Solver
Posts: 299
Joined: Fri Oct 02, 2009 2:02 pm

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

Post by rocrail »

The calculation used in the widgets example is not OK:
macos-widgets-range.png
And some Linux distros come with wx3.0, so this method is not available.
You do not have the required permissions to view the files attached to this post.
Best regards,
Rob.
https://wiki.rocrail.net
User avatar
rocrail
Super wx Problem Solver
Super wx Problem Solver
Posts: 299
Joined: Fri Oct 02, 2009 2:02 pm

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

Post by rocrail »

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.
https://wiki.rocrail.net
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

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

Post by PB »

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
Super wx Problem Solver
Super wx Problem Solver
Posts: 299
Joined: Fri Oct 02, 2009 2:02 pm

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

Post by rocrail »

Sorry, but I'm not familiar with GTK.
Someone with some GTK knowledge should take a look at it.
Best regards,
Rob.
https://wiki.rocrail.net
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7481
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

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

Post by ONEEYEMAN »

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.