SpinCtrl default width Windows/Mac/GTK2/GTK3 Topic is solved
-
- Super wx Problem Solver
- Posts: 299
- Joined: Fri Oct 02, 2009 2:02 pm
SpinCtrl default width Windows/Mac/GTK2/GTK3
Hi,
if using SpinCtrl default width, -1, it sizes different under all supported Operating Systems:
- Windows resize it as needed for its range.
- 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.
Is this a wxWidgets feature, or OS dependent?
if using SpinCtrl default width, -1, it sizes different under all supported Operating Systems:
- Windows resize it as needed for its range.
- 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.
Is this a wxWidgets feature, or OS dependent?
-
- 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
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.
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.
-
- Super wx Problem Solver
- Posts: 299
- Joined: Fri Oct 02, 2009 2:02 pm
Re: SpinCtrl default width Windows/Mac/GTK2/GTK3
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
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
-
- 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
Hi,
Can you reproduce it in the {widgets} sample?
Thank you.
Can you reproduce it in the {widgets} sample?
Thank you.
-
- Super wx Problem Solver
- Posts: 299
- Joined: Fri Oct 02, 2009 2:02 pm
Re: SpinCtrl default width Windows/Mac/GTK2/GTK3
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.
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.
-
- 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
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.
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.
-
- Super wx Problem Solver
- Posts: 299
- Joined: Fri Oct 02, 2009 2:02 pm
Re: SpinCtrl default width Windows/Mac/GTK2/GTK3
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.
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.
You do not have the required permissions to view the files attached to this post.
-
- Super wx Problem Solver
- Posts: 299
- Joined: Fri Oct 02, 2009 2:02 pm
Re: SpinCtrl default width Windows/Mac/GTK2/GTK3
Just saw that in the widgets sample the resizing is calculated and set programmatically:
In case of my Project, Rocrail, there are hundreds of SpinCtrl used, so this is no option...
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);
-
- Moderator
- Posts: 19163
- Joined: Fri Apr 21, 2006 8:03 pm
- Location: $FCE2
Re: SpinCtrl default width Windows/Mac/GTK2/GTK3
If worst comes to worst, you can subclass it and replace all occurrences with a custom version that does this in its constructor.In case of my Project, Rocrail, there are hundreds of SpinCtrl used, so this is no option...
Use the source, Luke!
-
- Super wx Problem Solver
- Posts: 299
- Joined: Fri Oct 02, 2009 2:02 pm
Re: SpinCtrl default width Windows/Mac/GTK2/GTK3
My initial issue still remains, because under Windows this is done automatically, and under GTK it must be set manually.
-
- Super wx Problem Solver
- Posts: 299
- Joined: Fri Oct 02, 2009 2:02 pm
Re: SpinCtrl default width Windows/Mac/GTK2/GTK3
The calculation used in the widgets example is not OK:
And some Linux distros come with wx3.0, so this method is not available.
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.
-
- Super wx Problem Solver
- Posts: 299
- Joined: Fri Oct 02, 2009 2:02 pm
Re: SpinCtrl default width Windows/Mac/GTK2/GTK3
In file "common/spinctrlcmn.cpp" the function GetBestSize already calculate this automatically:
Which works under Windows10, but is ignored under GTK.
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);
}
-
- Part Of The Furniture
- Posts: 4204
- Joined: Sun Jan 03, 2010 5:45 pm
Re: SpinCtrl default width Windows/Mac/GTK2/GTK3
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)?
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)?
-
- Super wx Problem Solver
- Posts: 299
- Joined: Fri Oct 02, 2009 2:02 pm
Re: SpinCtrl default width Windows/Mac/GTK2/GTK3
Sorry, but I'm not familiar with GTK.
Someone with some GTK knowledge should take a look at it.
Someone with some GTK knowledge should take a look at it.
-
- 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
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.
So you are saying that even in the unmodified sample this is not ok?
Then you should file a bug on trac...
Thank you.