- const wxSize sizeClient = GetClientSize();
-
- // we need to find the longest/tallest label
- wxCoord widthMax = 0,
- heightMax = 0;
- const int count = m_list->GetItemCount();
- if ( count )
- {
- for ( int i = 0; i < count; i++ )
- {
- wxRect r;
- m_list->GetItemRect(i, r);
-
- wxCoord w = r.x + r.width,
- h = r.y + r.height;
-
- if ( w > widthMax )
- widthMax = w;
- if ( h > heightMax )
- heightMax = h;
- }
- }
-
- wxSize size;
- if ( IsVertical() )
- {
- size.x = sizeClient.x;
- size.y = heightMax;
-
- if ( widthMax >= sizeClient.x )
- {
- // account for the scrollbar
- size.y += wxSystemSettings::GetMetric(wxSYS_HSCROLL_Y);
- }
- }
- else // left/right aligned
- {
- // +10 is due to an apparent bug in wxListCtrl::GetItemRect() but I
- // can't fix it there right now so just add a fudge here...
- size.x = widthMax + 10;
- size.y = sizeClient.y;
-
- if ( heightMax >= sizeClient.y )
- {
- // account for the scrollbar
- size.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
- }
- }
-
- return size;