Improve wxSpinCtrl best size computation in wxGTK
Don't hardcode completely arbitrary width of 95px for the text part, but compute it from the values this control is actually used for.
This commit is contained in:
parent
25c9b032a8
commit
7465237353
2 changed files with 11 additions and 1 deletions
|
|
@ -76,6 +76,7 @@ wxGTK:
|
|||
|
||||
- Implement setting link colours in wxHyperlinkCtrl for GTK+3 (Hanmac).
|
||||
- Support background colour in wxDataViewCtrl attributes.
|
||||
- Improve wxSpinCtrl best size calculation.
|
||||
|
||||
wxMSW:
|
||||
|
||||
|
|
|
|||
|
|
@ -355,7 +355,16 @@ GdkWindow *wxSpinCtrlGTKBase::GTKGetWindow(wxArrayGdkWindows& windows) const
|
|||
|
||||
wxSize wxSpinCtrlGTKBase::DoGetBestSize() const
|
||||
{
|
||||
return DoGetSizeFromTextSize(95); // TODO: 95 is completely arbitrary
|
||||
const int minVal = static_cast<int>(DoGetMin());
|
||||
const int lenMin = wxString::Format("%d", minVal).length();
|
||||
|
||||
const int maxVal = static_cast<int>(DoGetMax());
|
||||
const int lenMax = wxString::Format("%d", maxVal).length();
|
||||
|
||||
wxString longestText(wxMax(lenMin, lenMax), '9');
|
||||
if ( minVal < 0 )
|
||||
longestText.insert(0, "-");
|
||||
return DoGetSizeFromTextSize(GetTextExtent(longestText).x, -1);
|
||||
}
|
||||
|
||||
wxSize wxSpinCtrlGTKBase::DoGetSizeFromTextSize(int xlen, int ylen) const
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue