]> git.saurik.com Git - wxWidgets.git/commitdiff
use newly added GetViewRect() instead of trying to guess the list ctrl size ourselves
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 14 Sep 2003 16:00:29 +0000 (16:00 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 14 Sep 2003 16:00:29 +0000 (16:00 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23575 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/generic/listbkg.cpp

index c4c83d0b9157463c49986f413feefae8d5f1429c..6b5f08b442433d3cefe55a755e91332df48eac1b 100644 (file)
@@ -103,7 +103,8 @@ wxListbook::Create(wxWindow *parent,
                     wxID_LISTBOOKLISTVIEW,
                     wxDefaultPosition,
                     wxDefaultSize,
                     wxID_LISTBOOKLISTVIEW,
                     wxDefaultPosition,
                     wxDefaultSize,
-                    wxLC_ICON | wxLC_SINGLE_SEL
+                    wxBORDER_NONE | wxLC_ICON | wxLC_SINGLE_SEL |
+                        (IsVertical() ? wxLC_ALIGN_LEFT : wxLC_ALIGN_TOP)
                  );
 
     m_line = new wxStaticLine
                  );
 
     m_line = new wxStaticLine
@@ -124,53 +125,19 @@ wxListbook::Create(wxWindow *parent,
 
 wxSize wxListbook::GetListSize() const
 {
 
 wxSize wxListbook::GetListSize() const
 {
-    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.width,
-                    h = r.height;
-
-            if ( w > widthMax )
-                widthMax = w;
-            if ( h > heightMax )
-                heightMax = h;
-        }
-    }
+    const wxSize sizeClient = GetClientSize(),
+                 sizeList = m_list->GetViewRect().GetSize();
 
     wxSize size;
     if ( IsVertical() )
     {
         size.x = sizeClient.x;
 
     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);
-        }
+        size.y = sizeList.y;
     }
     else // left/right aligned
     {
     }
     else // left/right aligned
     {
-        // +20 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 + 20;
+        size.x = sizeList.x;
         size.y = sizeClient.y;
         size.y = sizeClient.y;
-
-        if ( heightMax >= sizeClient.y )
-        {
-            // account for the scrollbar
-            size.x += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
-        }
     }
 
     return size;
     }
 
     return size;