Better sizing in wxDataViewSpinRenderer and wxDataViewChoiceRenderer.
Their GetSize() method used hardcoded size of (80,16). Instead, use GetTextExtent() to compute the size from content, as should be done. Add some extra room for editor control's extra parts. The space needed isn't computed exactly, as that would be quite convoluted (and in the end, most likely not 100% accurate even then), using a simple approximation instead. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@68242 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
7ecc7eb6be
commit
a1c9e7d143
@ -1456,7 +1456,15 @@ bool wxDataViewSpinRenderer::Render( wxRect rect, wxDC *dc, int state )
|
||||
|
||||
wxSize wxDataViewSpinRenderer::GetSize() const
|
||||
{
|
||||
return wxSize(80,16);
|
||||
wxSize sz = GetTextExtent(wxString::Format("%d", (int)m_data));
|
||||
|
||||
// Allow some space for the spin buttons, which is approximately the size
|
||||
// of a scrollbar (and getting pixel-exact value would be complicated).
|
||||
// Also add some whitespace between the text and the button:
|
||||
sz.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
|
||||
sz.x += GetTextExtent("M").x;
|
||||
|
||||
return sz;
|
||||
}
|
||||
|
||||
bool wxDataViewSpinRenderer::SetValue( const wxVariant &value )
|
||||
@ -1514,7 +1522,18 @@ bool wxDataViewChoiceRenderer::Render( wxRect rect, wxDC *dc, int state )
|
||||
|
||||
wxSize wxDataViewChoiceRenderer::GetSize() const
|
||||
{
|
||||
return wxSize(80,16);
|
||||
wxSize sz;
|
||||
|
||||
for ( wxArrayString::const_iterator i = m_choices.begin(); i != m_choices.end(); ++i )
|
||||
sz.IncTo(GetTextExtent(*i));
|
||||
|
||||
// Allow some space for the right-side button, which is approximately the
|
||||
// size of a scrollbar (and getting pixel-exact value would be complicated).
|
||||
// Also add some whitespace between the text and the button:
|
||||
sz.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
|
||||
sz.x += GetTextExtent("M").x;
|
||||
|
||||
return sz;
|
||||
}
|
||||
|
||||
bool wxDataViewChoiceRenderer::SetValue( const wxVariant &value )
|
||||
|
Loading…
Reference in New Issue
Block a user