From c09615b8ed48b6203e7c239fd74d1799e34cfe79 Mon Sep 17 00:00:00 2001
From: Julian Smart <julian@anthemion.co.uk>
Date: Thu, 15 May 2003 22:15:25 +0000
Subject: [PATCH] An attempt to make the notebook sizer report its size
 correctly under Windows, otherwise you get a huge gap at the bottom if
 fitting to the content of the page.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20631 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 src/common/nbkbase.cpp | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/common/nbkbase.cpp b/src/common/nbkbase.cpp
index 527fcc27db..e29c2dbdaf 100644
--- a/src/common/nbkbase.cpp
+++ b/src/common/nbkbase.cpp
@@ -36,6 +36,12 @@
 #include "wx/imaglist.h"
 #include "wx/notebook.h"
 
+#if defined(__WXMSW__) && !((defined(__GNUWIN32_OLD__) || defined(__TWIN32__)) && !defined(__CYGWIN10__))
+#include "wx/msw/private.h"
+#include <commctrl.h>
+#include "wx/msw/winundef.h"
+#endif
+
 // ============================================================================
 // implementation
 // ============================================================================
@@ -92,6 +98,28 @@ wxSize wxNotebookBase::CalcSizeFromPage(const wxSize& sizePage)
     // course, totally bogus - just like the original code was
     wxSize sizeTotal = sizePage;
     
+    // Slightly less bogus, at least under Windows.
+    // We need to make getting tab size part of the wxWindows API.
+#ifdef __WXMSW__
+    wxSize tabSize(0, 0);
+    if (GetPageCount() > 0)
+    {
+        RECT rect;
+        TabCtrl_GetItemRect((HWND) GetHWND(), 0, & rect);
+        tabSize.x = rect.right - rect.left;
+        tabSize.y = rect.bottom - rect.top;
+    }
+    if ( HasFlag(wxNB_LEFT) || HasFlag(wxNB_RIGHT) )
+    {
+        sizeTotal.x += tabSize.x + 7;
+        sizeTotal.y += 7;
+    }
+    else
+    {
+        sizeTotal.x += 7;
+        sizeTotal.y += tabSize.y + 7;
+    }
+#else
     if ( HasFlag(wxNB_LEFT) || HasFlag(wxNB_RIGHT) )
     {
         sizeTotal.x += 90;
@@ -102,6 +130,7 @@ wxSize wxNotebookBase::CalcSizeFromPage(const wxSize& sizePage)
         sizeTotal.x += 10;
         sizeTotal.y += 40;
     }
+#endif
 
     return sizeTotal;
 }
-- 
2.47.2