]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listbkg.cpp
Better temporary fix.
[wxWidgets.git] / src / generic / listbkg.cpp
index a0e5073a9c9ca20579014f21a5f372e24153db9b..67059a7197843378ab5854a0b3f3982008b1905c 100644 (file)
 
 #if wxUSE_LISTBOOK
 
+#include "wx/listbook.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/settings.h"
+#endif
+
 #include "wx/listctrl.h"
 #include "wx/statline.h"
-#include "wx/listbook.h"
 #include "wx/imaglist.h"
-#include "wx/settings.h"
 
 // ----------------------------------------------------------------------------
 // various wxWidgets macros
@@ -157,6 +161,45 @@ void wxListbook::OnSize(wxSizeEvent& event)
     wxBookCtrlBase::OnSize(event);
 }
 
+int wxListbook::HitTest(const wxPoint& pt, long *flags) const
+{
+    int pagePos = wxNOT_FOUND;
+
+    if ( flags )
+        *flags = wxBK_HITTEST_NOWHERE;
+
+    // convert from listbook control coordinates to list control coordinates
+    const wxListView * const list = GetListView();
+    const wxPoint listPt = list->ScreenToClient(ClientToScreen(pt));
+
+    // is the point inside list control?
+    if ( wxRect(list->GetSize()).Inside(listPt) )
+    {
+        int flagsList;
+        pagePos = list->HitTest(listPt, flagsList);
+
+        if ( flags )
+        {
+            if ( pagePos != wxNOT_FOUND )
+                *flags = 0;
+
+            if ( flagsList & (wxLIST_HITTEST_ONITEMICON |
+                              wxLIST_HITTEST_ONITEMSTATEICON ) )
+                *flags |= wxBK_HITTEST_ONICON;
+
+            if ( flagsList & wxLIST_HITTEST_ONITEMLABEL )
+                *flags |= wxBK_HITTEST_ONLABEL;
+        }
+    }
+    else // not over list control at all
+    {
+        if ( flags && GetPageRect().Inside(pt) )
+            *flags |= wxBK_HITTEST_ONPAGE;
+    }
+
+    return pagePos;
+}
+
 wxSize wxListbook::CalcSizeFromPage(const wxSize& sizePage) const
 {
     // we need to add the size of the list control and the border between
@@ -301,7 +344,14 @@ wxListbook::InsertPage(size_t n,
         SetSelection(selNew);
 
     InvalidateBestSize();
+    // GetListView()->InvalidateBestSize();
     GetListView()->Arrange();
+
+    if (GetPageCount() == 1)
+    {
+        wxSizeEvent sz(GetSize(), GetId());
+        ProcessEvent(sz);
+    }
     return true;
 }
 
@@ -331,6 +381,11 @@ wxWindow *wxListbook::DoRemovePage(size_t page)
         }
 
         GetListView()->Arrange();
+        if (GetPageCount() == 0)
+        {
+            wxSizeEvent sz(GetSize(), GetId());
+            ProcessEvent(sz);
+        }
     }
 
     return win;
@@ -340,7 +395,15 @@ wxWindow *wxListbook::DoRemovePage(size_t page)
 bool wxListbook::DeleteAllPages()
 {
     GetListView()->DeleteAllItems();
-    return wxBookCtrlBase::DeleteAllPages();
+    if (!wxBookCtrlBase::DeleteAllPages())
+        return false;
+
+    m_selection = -1;
+
+    wxSizeEvent sz(GetSize(), GetId());
+    ProcessEvent(sz);
+
+    return true;
 }
 
 // ----------------------------------------------------------------------------