From 21db32c1294eff5c1b6b087d260d2accc17abb53 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Fri, 19 Nov 2004 18:57:53 +0000
Subject: [PATCH] added GetCurrentPage()

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@30633 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 docs/latex/wx/notebook.tex | 32 ++++++++++++++++++++++++++++++++
 include/wx/bookctrl.h      |  8 ++++++++
 2 files changed, 40 insertions(+)

diff --git a/docs/latex/wx/notebook.tex b/docs/latex/wx/notebook.tex
index 1e07b54517..556e3ffe20 100644
--- a/docs/latex/wx/notebook.tex
+++ b/docs/latex/wx/notebook.tex
@@ -43,6 +43,7 @@ See also \helpref{window styles overview}{windowstyles}.
 
 \latexignore{\rtfignore{\wxheading{Members}}}
 
+
 \membersection{wxNotebook::wxNotebook}\label{wxnotebookctor}
 
 \func{}{wxNotebook}{\void}
@@ -70,12 +71,14 @@ Note that sometimes you can reduce flicker by passing the wxCLIP\_CHILDREN windo
 
 \docparam{name}{The name of the control (used only under Motif).}
 
+
 \membersection{wxNotebook::\destruct{wxNotebook}}\label{wxnotebookdtor}
 
 \func{}{\destruct{wxNotebook}}{\void}
 
 Destroys the wxNotebook object.
 
+
 \membersection{wxNotebook::AddPage}\label{wxnotebookaddpage}
 
 \func{bool}{AddPage}{\param{wxNotebookPage*}{ page},
@@ -109,6 +112,7 @@ Do not delete the page, it will be deleted by the notebook.
 
 \helpref{wxNotebook::InsertPage}{wxnotebookinsertpage}
 
+
 \membersection{wxNotebook::AdvanceSelection}\label{wxnotebookadvanceselection}
 
 \func{void}{AdvanceSelection}{\param{bool}{ forward = true}}
@@ -117,6 +121,7 @@ Cycles through the tabs.
 
 The call to this function generates the page changing events.
 
+
 \membersection{wxNotebook::AssignImageList}\label{wxnotebookassignimagelist}
 
 \func{void}{AssignImageList}{\param{wxImageList*}{ imageList}}
@@ -129,6 +134,7 @@ the list.
 \helpref{wxImageList}{wximagelist},
 \helpref{SetImageList}{wxnotebooksetimagelist}
 
+
 \membersection{wxNotebook::Create}\label{wxnotebookcreate}
 
 \func{bool}{Create}{\param{wxWindow*}{ parent}, \param{wxWindowID }{id}, \param{const wxPoint\&}{ pos = wxDefaultPosition},
@@ -137,12 +143,14 @@ the list.
 Creates a notebook control. See \helpref{wxNotebook::wxNotebook}{wxnotebookctor} for a description
 of the parameters.
 
+
 \membersection{wxNotebook::DeleteAllPages}\label{wxnotebookdeleteallpages}
 
 \func{bool}{DeleteAllPages}{\void}
 
 Deletes all pages.
 
+
 \membersection{wxNotebook::DeletePage}\label{wxnotebookdeletepage}
 
 \func{bool}{DeletePage}{\param{size\_t}{ page}}
@@ -151,6 +159,14 @@ Deletes the specified page, and the associated window.
 
 The call to this function generates the page changing events.
 
+
+\membersection{wxNotebook::GetCurrentPage}\label{wxnotebookgetcurrentpage}
+
+\constfunc{wxWindow *}{GetCurrentPage}{\void}
+
+Returns the currently selected notebook age or \texttt{NULL}.
+
+
 \membersection{wxNotebook::GetImageList}\label{wxnotebookgetimagelist}
 
 \constfunc{wxImageList*}{GetImageList}{\void}
@@ -161,36 +177,42 @@ Returns the associated image list.
 
 \helpref{wxImageList}{wximagelist}, \helpref{wxNotebook::SetImageList}{wxnotebooksetimagelist}
 
+
 \membersection{wxNotebook::GetPage}\label{wxnotebookgetpage}
 
 \func{wxNotebookPage*}{GetPage}{\param{size\_t}{ page}}
 
 Returns the window at the given page position.
 
+
 \membersection{wxNotebook::GetPageCount}\label{wxnotebookgetpagecount}
 
 \constfunc{size\_t}{GetPageCount}{\void}
 
 Returns the number of pages in the notebook control.
 
+
 \membersection{wxNotebook::GetPageImage}\label{wxnotebookgetpageimage}
 
 \constfunc{int}{GetPageImage}{\param{size\_t }{nPage}}
 
 Returns the image index for the given page.
 
+
 \membersection{wxNotebook::GetPageText}\label{wxnotebookgetpagetext}
 
 \constfunc{wxString}{GetPageText}{\param{size\_t }{nPage}}
 
 Returns the string for the given page.
 
+
 \membersection{wxNotebook::GetRowCount}\label{wxnotebookgetrowcount}
 
 \constfunc{int}{GetRowCount}{\void}
 
 Returns the number of rows in the notebook control.
 
+
 \membersection{wxNotebook::GetSelection}\label{wxnotebookgetselection}
 
 \constfunc{int}{GetSelection}{\void}
@@ -203,6 +225,7 @@ the platform and so\rtfsp
 \helpref{wxNotebookEvent::GetSelection}{wxnotebookeventgetselection} should be
 used instead in this case.
 
+
 \membersection{wxNotebook::HitTest}\label{wxnotebookhittest}
 
 \func{int}{HitTest}{\param{const wxPoint\&}{ pt}, \param{long}{ *flags = {\tt NULL}}}
@@ -233,6 +256,7 @@ Returns the zero-based tab index or {\tt wxNOT\_FOUND} if there is no tab is at
 the specified position.
 
 
+
 \membersection{wxNotebook::InsertPage}\label{wxnotebookinsertpage}
 
 \func{bool}{InsertPage}{\param{size\_t}{ index}, \param{wxNotebookPage*}{ page},
@@ -266,6 +290,7 @@ Do not delete the page, it will be deleted by the notebook.
 
 \helpref{wxNotebook::AddPage}{wxnotebookaddpage}
 
+
 \membersection{wxNotebook::OnSelChange}\label{wxnotebookonselchange}
 
 \func{void}{OnSelChange}{\param{wxNotebookEvent\&}{ event}}
@@ -276,12 +301,14 @@ An event handler function, called when the page selection is changed.
 
 \helpref{wxNotebookEvent}{wxnotebookevent}
 
+
 \membersection{wxNotebook::RemovePage}\label{wxnotebookremovepage}
 
 \func{bool}{RemovePage}{\param{size\_t}{ page}}
 
 Deletes the specified page, without deleting the associated window.
 
+
 \membersection{wxNotebook::SetImageList}\label{wxnotebooksetimagelist}
 
 \func{void}{SetImageList}{\param{wxImageList*}{ imageList}}
@@ -294,6 +321,7 @@ ownership of the image list, you must delete it yourself.
 \helpref{wxImageList}{wximagelist},
 \helpref{AssignImageList}{wxnotebookassignimagelist}
 
+
 \membersection{wxNotebook::SetPadding}\label{wxnotebooksetpadding}
 
 \func{void}{SetPadding}{\param{const wxSize\&}{ padding}}
@@ -302,6 +330,7 @@ Sets the amount of space around each page's icon and label, in pixels.
 
 {\bf NB:} The vertical padding cannot be changed in wxGTK.
 
+
 \membersection{wxNotebook::SetPageSize}\label{wxnotebooksetpagesize}
 
 \func{void}{SetPageSize}{\param{const wxSize\&}{ size}}
@@ -310,6 +339,7 @@ Sets the width and height of the pages.
 
 {\bf NB:} This method is currently not implemented for wxGTK.
 
+
 \membersection{wxNotebook::SetPageImage}\label{wxnotebooksetpageimage}
 
 \func{bool}{SetPageImage}{\param{size\_t}{ page}, \param{int }{image}}
@@ -317,12 +347,14 @@ Sets the width and height of the pages.
 Sets the image index for the given page. {\it image} is an index into
 the image list which was set with \helpref{wxNotebook::SetImageList}{wxnotebooksetimagelist}.
 
+
 \membersection{wxNotebook::SetPageText}\label{wxnotebooksetpagetext}
 
 \func{bool}{SetPageText}{\param{size\_t}{ page}, \param{const wxString\& }{text}}
 
 Sets the text for the given page.
 
+
 \membersection{wxNotebook::SetSelection}\label{wxnotebooksetselection}
 
 \func{int}{SetSelection}{\param{size\_t}{ page}}
diff --git a/include/wx/bookctrl.h b/include/wx/bookctrl.h
index d404021123..49952ecb2c 100644
--- a/include/wx/bookctrl.h
+++ b/include/wx/bookctrl.h
@@ -79,6 +79,14 @@ public:
     // get the panel which represents the given page
     virtual wxWindow *GetPage(size_t n) { return m_pages[n]; }
 
+    // get the current page or NULL if none
+    wxWindow *GetCurrentPage() const
+    {
+        int n = GetSelection();
+        return n == wxNOT_FOUND ? NULL
+                                : wx_const_cast(wxBookCtrl *, this)->GetPage(n);
+    }
+
     // get the currently selected page or wxNOT_FOUND if none
     virtual int GetSelection() const = 0;
 
-- 
2.50.0

