]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listbkg.cpp
miscellaneous small enhancements
[wxWidgets.git] / src / generic / listbkg.cpp
index 82a1220c32673e2406dc5c9d57885dff1fb094ce..d7cf2df1db5cb156c1a8534b78b83d508013fbf5 100644 (file)
@@ -54,7 +54,6 @@
 // ----------------------------------------------------------------------------
 
 IMPLEMENT_DYNAMIC_CLASS(wxListbook, wxBookCtrlBase)
-IMPLEMENT_DYNAMIC_CLASS(wxListbookEvent, wxNotifyEvent)
 
 const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING = wxNewEventType();
 const wxEventType wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED = wxNewEventType();
@@ -185,9 +184,11 @@ void wxListbook::OnSize(wxSizeEvent& event)
     // under MSW, we'd finish with an ugly looking list control with both
     // vertical and horizontal scrollbar (with one of them being added because
     // the other one is not accounted for in client size computations)
-    wxListView *list = GetListView();
-    if (list) list->Arrange();
-    wxBookCtrlBase::OnSize(event);
+    wxListView * const list = GetListView();
+    if ( list )
+        list->Arrange();
+
+    event.Skip();
 }
 
 int wxListbook::HitTest(const wxPoint& pt, long *flags) const
@@ -247,6 +248,13 @@ wxSize wxListbook::CalcSizeFromPage(const wxSize& sizePage) const
     return size;
 }
 
+void wxListbook::UpdateSize()
+{
+    // we should find a more elegant way to force a layout than generating this
+    // dummy event
+    wxSizeEvent sz(GetSize(), GetId());
+    GetEventHandler()->ProcessEvent(sz);
+}
 
 // ----------------------------------------------------------------------------
 // accessing the pages
@@ -361,12 +369,12 @@ int wxListbook::GetSelection() const
     return m_selection;
 }
 
-wxBookCtrlBaseEvent* wxListbook::CreatePageChangingEvent() const
+wxBookCtrlEvent* wxListbook::CreatePageChangingEvent() const
 {
-    return new wxListbookEvent(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, m_windowId);
+    return new wxBookCtrlEvent(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGING, m_windowId);
 }
 
-void wxListbook::MakeChangedEvent(wxBookCtrlBaseEvent &event)
+void wxListbook::MakeChangedEvent(wxBookCtrlEvent &event)
 {
     event.SetEventType(wxEVT_COMMAND_LISTBOOK_PAGE_CHANGED);
 }
@@ -412,9 +420,8 @@ wxListbook::InsertPage(size_t n,
     if ( selNew != -1 )
         SetSelection(selNew);
 
-    wxSizeEvent sz(GetSize(), GetId());
-    GetEventHandler()->ProcessEvent(sz);
-    
+    UpdateSize();
+
     return true;
 }
 
@@ -444,11 +451,7 @@ wxWindow *wxListbook::DoRemovePage(size_t page)
         }
 
         GetListView()->Arrange();
-        if (GetPageCount() == 0)
-        {
-            wxSizeEvent sz(GetSize(), GetId());
-            GetEventHandler()->ProcessEvent(sz);
-        }
+        UpdateSize();
     }
 
     return win;
@@ -463,8 +466,7 @@ bool wxListbook::DeleteAllPages()
 
     m_selection = -1;
 
-    wxSizeEvent sz(GetSize(), GetId());
-    GetEventHandler()->ProcessEvent(sz);
+    UpdateSize();
 
     return true;
 }