]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/notebook.cpp
Prevent surplus calls of _size_allocate() if no change
[wxWidgets.git] / src / msw / notebook.cpp
index e58dcd3b425fa8489160a45692331ae2a2b6e10c..a4ee7df0d4a6863732b773e3706f64bc0f2b1efd 100644 (file)
@@ -120,9 +120,6 @@ static bool HasTroubleWithNonTopTabs()
 
 WX_DEFINE_LIST( wxNotebookPageInfoList )
 
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
-
 BEGIN_EVENT_TABLE(wxNotebook, wxBookCtrlBase)
     EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange)
     EVT_SIZE(wxNotebook::OnSize)
@@ -328,7 +325,7 @@ bool wxNotebook::Create(wxWindow *parent,
             if ( ::GetClassInfo(NULL, WC_TABCONTROL, &wc) )
             {
                 gs_wndprocNotebook =
-                    wx_reinterpret_cast(WXFARPROC, wc.lpfnWndProc);
+                    reinterpret_cast<WXFARPROC>(wc.lpfnWndProc);
                 wc.lpszClassName = wxT("_wx_SysTabCtl32");
                 wc.style &= ~(CS_HREDRAW | CS_VREDRAW);
                 wc.hInstance = wxGetInstance();
@@ -656,16 +653,18 @@ wxSize wxNotebook::CalcSizeFromPage(const wxSize& sizePage) const
         tabSize.y = rect.bottom - rect.top;
     }
 
+    const int rows = GetRowCount();
+
     // add an extra margin in both directions
     const int MARGIN = 8;
     if ( IsVertical() )
     {
         sizeTotal.x += MARGIN;
-        sizeTotal.y += tabSize.y + MARGIN;
+        sizeTotal.y += tabSize.y * rows + MARGIN;
     }
     else // horizontal layout
     {
-        sizeTotal.x += tabSize.x + MARGIN;
+        sizeTotal.x += tabSize.x * rows + MARGIN;
         sizeTotal.y += MARGIN;
     }
 
@@ -1029,6 +1028,10 @@ void wxNotebook::OnSize(wxSizeEvent& event)
                     MAKELPARAM(rc.right, rc.bottom));
             s_isInOnSize = false;
         }
+
+        // The best size depends on the number of rows of tabs, which can
+        // change when the notepad is resized.
+        InvalidateBestSize();
     }
 
 #if wxUSE_UXTHEME