]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listbkg.cpp
Oops, forgot to cleanup some commented-out code before last commit.
[wxWidgets.git] / src / generic / listbkg.cpp
index 676b202c93662e19cc6c0b1ebe397b3effda71ca..b82b9dde2f1d7827d9568465ec47533ef236a5d2 100644 (file)
@@ -57,7 +57,6 @@ const int wxID_LISTBOOKLISTVIEW = wxNewId();
 
 BEGIN_EVENT_TABLE(wxListbook, wxBookCtrl)
     EVT_SIZE(wxListbook::OnSize)
 
 BEGIN_EVENT_TABLE(wxListbook, wxBookCtrl)
     EVT_SIZE(wxListbook::OnSize)
-
     EVT_LIST_ITEM_SELECTED(wxID_LISTBOOKLISTVIEW, wxListbook::OnListSelected)
 END_EVENT_TABLE()
 
     EVT_LIST_ITEM_SELECTED(wxID_LISTBOOKLISTVIEW, wxListbook::OnListSelected)
 END_EVENT_TABLE()
 
@@ -125,6 +124,16 @@ wxListbook::Create(wxWindow *parent,
                  );
 #endif // wxUSE_LINE_IN_LISTBOOK
 
                  );
 #endif // wxUSE_LINE_IN_LISTBOOK
 
+#ifdef __WXMSW__
+    // On XP with themes enabled the GetViewRect used in GetListSize to
+    // determine the space needed for the list view will incorrectly return
+    // (0,0,0,0) the first time.  So send a pending event so OnSize wiull be
+    // called again after the window is ready to go.  Technically we don't
+    // need to do this on non-XP windows, but if things are already sized
+    // correctly then nothing changes and so there is no harm.
+    wxSizeEvent evt;
+    GetEventHandler()->AddPendingEvent(evt);
+#endif
     return true;
 }
 
     return true;
 }
 
@@ -348,10 +357,12 @@ int wxListbook::SetSelection(size_t n)
 
     if ( (int)n != m_selection )
     {
 
     if ( (int)n != m_selection )
     {
-        m_selection = n;
+        m_list->Select(n);
+        m_list->Focus(n);
 
 
-        m_list->Select(m_selection);
-        m_list->Focus(m_selection);
+        // change m_selection only now, otherwise OnListSelected() would ignore
+        // the selection change event
+        m_selection = n;
     }
 
     return selOld;
     }
 
     return selOld;