From fc17828ab2cb3dc5dd22d5634ce4f6764e1373fc Mon Sep 17 00:00:00 2001
From: Julian Smart <julian@anthemion.co.uk>
Date: Thu, 21 Jun 2007 15:07:51 +0000
Subject: [PATCH] Added font setting and ability to determine AUI notebook
 height for a given page height

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46583 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/auinotebook.tex | 43 ++++++++++++++++++++++++++++++
 include/wx/aui/auibook.h      | 18 +++++++++++++
 src/aui/auibook.cpp           | 50 +++++++++++++++++++++++++++++++++++
 3 files changed, 111 insertions(+)

diff --git a/docs/latex/wx/auinotebook.tex b/docs/latex/wx/auinotebook.tex
index b7d3ba5921..73a6be0624 100644
--- a/docs/latex/wx/auinotebook.tex
+++ b/docs/latex/wx/auinotebook.tex
@@ -81,6 +81,13 @@ Deletes a page at the given index.  Calling this method will generate a page cha
 
 Returns the associated art provider.
 
+\membersection{wxAuiNotebook::GetHeightForPageHeight}\label{wxauinotebookgetheightforpageheight}
+
+\func{int}{GetHeightForPageHeight}{\param{int }{pageHeight}}
+
+Returns the desired height of the notebook for the given page height. Use this to fit the notebook to
+a given page size.
+
 \membersection{wxAuiNotebook::GetPage}\label{wxauinotebookgetpage}
 
 \constfunc{wxWindow*}{GetPage}{\param{size\_t }{page\_idx}}
@@ -112,12 +119,24 @@ the notebook, wxNOT\_FOUND is returned.
 
 Returns the tab label for the page.
 
+\membersection{wxAuiNotebook::GetTabCtrlHeight}\label{wxauinotebookgettabctrlheight}
+
+\constfunc{int}{GetTabCtrlHeight}{\void}
+
+Returns the height of the tab control.
+
 \membersection{wxAuiNotebook::GetSelection}\label{wxauinotebookgetselection}
 
 \constfunc{int}{GetSelection}{\void}
 
 Returns the currently selected page.
 
+\membersection{wxAuiNotebook::GetTabCtrlHeight}\label{wxauinotebookgettabctrlheight}
+
+\constfunc{int}{GetTabCtrlHeight}{\void}
+
+Returns the height of the tab control.
+
 \membersection{wxAuiNotebook::InsertPage}\label{wxauinotebookinsertpage}
 
 \func{bool}{InsertPage}{\param{size\_t }{page\_idx}, \param{wxWindow* }{page}, \param{const wxString\& }{caption}, \param{bool }{select = false}, \param{const wxBitmap\& }{bitmap = wxNullBitmap}}
@@ -137,6 +156,30 @@ Removes a page, without deleting the window pointer.
 
 Sets the art provider to be used by the notebook.
 
+\membersection{wxAuiNotebook::SetFont}\label{wxauinotebooksetfont}
+
+\func{bool}{SetFont}{\param{const wxFont\& }{font}}
+
+Sets the font for drawing the tab labels, using a bold version of the font for selected tab labels.
+
+\membersection{wxAuiNotebook::SetNormalFont}\label{wxauinotebooksetnormalfont}
+
+\func{void}{SetNormalFont}{\param{const wxFont\& }{font}}
+
+Sets the font for drawing unselected tab labels.
+
+\membersection{wxAuiNotebook::SetSelectedFont}\label{wxauinotebooksetselectedfont}
+
+\func{void}{SetSelectedFont}{\param{const wxFont\& }{font}}
+
+Sets the font for drawing selected tab labels.
+
+\membersection{wxAuiNotebook::SetMeasuringFont}\label{wxauinotebooksetmeasuringfont}
+
+\func{void}{SetMeasuringFont}{\param{const wxFont\& }{font}}
+
+Sets the font for measuring tab labels.
+
 \membersection{wxAuiNotebook::SetPageBitmap}\label{wxauinotebooksetpagebitmap}
 
 \func{bool}{SetPageBitmap}{\param{size\_t }{page}, \param{const wxBitmap\& }{bitmap}}
diff --git a/include/wx/aui/auibook.h b/include/wx/aui/auibook.h
index 28358f7d0c..1dce07d902 100644
--- a/include/wx/aui/auibook.h
+++ b/include/wx/aui/auibook.h
@@ -533,6 +533,24 @@ public:
 
     const wxAuiManager& GetAuiManager() const { return m_mgr; }
 
+	// Sets the normal font
+	void SetNormalFont(const wxFont& font);
+
+	// Sets the selected tab font
+	void SetSelectedFont(const wxFont& font);
+
+	// Sets the measuring font
+	void SetMeasuringFont(const wxFont& font);
+
+	// Sets the tab font
+    virtual bool SetFont(const wxFont& font);
+
+	// Gets the tab control height
+    int GetTabCtrlHeight() const;
+
+    // Gets the height of the notebook for a given page height
+    int GetHeightForPageHeight(int pageHeight);
+
 protected:
 
     // these can be overridden
diff --git a/src/aui/auibook.cpp b/src/aui/auibook.cpp
index 64e0d728e5..66cbf8481b 100644
--- a/src/aui/auibook.cpp
+++ b/src/aui/auibook.cpp
@@ -3595,7 +3595,57 @@ void wxAuiNotebook::OnTabButton(wxCommandEvent& command_evt)
     }
 }
 
+// Sets the normal font
+void wxAuiNotebook::SetNormalFont(const wxFont& font)
+{
+    m_normal_font = font;
+    GetArtProvider()->SetNormalFont(font);
+}
+
+// Sets the selected tab font
+void wxAuiNotebook::SetSelectedFont(const wxFont& font)
+{
+    m_selected_font = font;
+    GetArtProvider()->SetSelectedFont(font);
+}
+
+// Sets the measuring font
+void wxAuiNotebook::SetMeasuringFont(const wxFont& font)
+{
+    GetArtProvider()->SetMeasuringFont(font);
+}
+
+// Sets the tab font
+bool wxAuiNotebook::SetFont(const wxFont& font)
+{
+    wxControl::SetFont(font);
 
+    wxFont normalFont(font);
+    wxFont selectedFont(normalFont);
+    selectedFont.SetWeight(wxBOLD);
+
+    SetNormalFont(normalFont);
+    SetSelectedFont(selectedFont);
+    SetMeasuringFont(selectedFont);
+
+    return true;
+}
+
+// Gets the tab control height
+int wxAuiNotebook::GetTabCtrlHeight() const
+{
+    return m_tab_ctrl_height;
+}
+
+// Gets the height of the notebook for a given page height
+int wxAuiNotebook::GetHeightForPageHeight(int pageHeight)
+{
+    UpdateTabCtrlHeight();
+
+    int tabCtrlHeight = GetTabCtrlHeight();
+    int decorHeight = 2;
+    return tabCtrlHeight + pageHeight + decorHeight;
+}
 
 
 #endif // wxUSE_AUI
-- 
2.50.0

