\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}}}
+
+Returns the index of the tab at the specified position or {\tt wxNOT\_FOUND}
+if none. If {\it flags} parameter is non {\tt NULL}, the position of the point
+inside the tab is returned as well.
+
+{\bf NB: } This method is currently only implemented under wxMSW and wxUniv.
+
+\wxheading{Parameters}
+
+\docparam{pt}{Specifies the point for the hit test.}
+
+\docparam{flags}{Return value for detailed information. One of the following values:
+\twocolwidtha{7cm}
+\begin{twocollist}\itemsep=0pt
+\twocolitem{{\bf wxNB\_HITTEST\_NOWHERE}}{There was no tab under this point.}
+\twocolitem{{\bf wxNB\_HITTEST\_ONICON}}{The point was over an icon (currently wxMSW only).}
+\twocolitem{{\bf wxNB\_HITTEST\_ONLABEL}}{The point was over a label (currently wxMSW only).}
+\twocolitem{{\bf wxNB\_HITTEST\_ONITEM}}{The point was over an item, but not on the label or icon.}
+\end{twocollist}
+}
+
+\wxheading{Return value}
+
+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{int}{ index}, \param{wxNotebookPage*}{ page},
// wxNotebook
// ----------------------------------------------------------------------------
-/*
- * Flags returned by HitTest
- */
-
-#define wxNB_HITTEST_NOWHERE 1
-#define wxNB_HITTEST_ONICON 2
-#define wxNB_HITTEST_ONLABEL 4
-#define wxNB_HITTEST_ONITEM 6
-
class WXDLLEXPORT wxNotebook : public wxNotebookBase
{
public:
// ----------
// remove all pages
bool DeleteAllPages();
+
// inserts a new page to the notebook (it will be deleted ny the notebook,
// don't delete it yourself). If bSelect, this page becomes active.
bool InsertPage(int nPage,
// Windows only: attempts to apply the UX theme page background to this page
void ApplyThemeBackground(wxWindow* window, const wxColour& colour);
- // Hit test
- int HitTest(const wxPoint& pt, long& flags);
- // calculate the size of the notebook from the size of its page
+ // hit test
+ virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
+
+ // calculate the size of the notebook from the size of its page
virtual wxSize CalcSizeFromPage(const wxSize& sizePage) const;
// callbacks
#include "wx/dynarray.h"
#include "wx/imaglist.h"
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+// wxNotebook hit results
+enum
+{
+ wxNB_HITTEST_NOWHERE = 1, // not on tab
+ wxNB_HITTEST_ONICON = 2, // on icon
+ wxNB_HITTEST_ONLABEL = 4, // on label
+ wxNB_HITTEST_ONITEM = wxNB_HITTEST_ONICON | wxNB_HITTEST_ONLABEL
+};
+
// ----------------------------------------------------------------------------
// types
// ----------------------------------------------------------------------------
// NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
virtual int SetSelection(int nPage) = 0;
+ // hit test, returns which tab is hit and, optionally, where (icon, label)
+ // (not implemented on all platforms)
+ virtual int HitTest(const wxPoint& pt, long *flags = NULL) const
+ {
+ return wxNOT_FOUND;
+ }
+
// cycle thru the tabs
void AdvanceSelection(bool forward = TRUE)
{
// hit testing
// -----------
- // return the tab at this position or -1 if none
- int HitTest(const wxPoint& pt) const;
+ virtual int HitTest(const wxPoint& pt, long *flags = NULL) const;
// input handling
// --------------
return TRUE;
}
-// Hit test
-int wxNotebook::HitTest(const wxPoint& pt, long& flags)
+int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
{
TC_HITTESTINFO hitTestInfo;
hitTestInfo.pt.x = pt.x;
hitTestInfo.pt.y = pt.y;
- int item = TabCtrl_HitTest( (HWND) GetHWND(), & hitTestInfo ) ;
- flags = 0;
+ int item = TabCtrl_HitTest(GetHwnd(), &hitTestInfo);
- if ((hitTestInfo.flags & TCHT_NOWHERE) == TCHT_NOWHERE)
- flags |= wxNB_HITTEST_NOWHERE;
- if ((hitTestInfo.flags & TCHT_ONITEMICON) == TCHT_ONITEMICON)
- flags |= wxNB_HITTEST_ONICON;
- if ((hitTestInfo.flags & TCHT_ONITEMLABEL) == TCHT_ONITEMLABEL)
- flags |= wxNB_HITTEST_ONLABEL;
+ if ( flags )
+ {
+ *flags = 0;
+
+ if ((hitTestInfo.flags & TCHT_NOWHERE) == TCHT_NOWHERE)
+ *flags |= wxNB_HITTEST_NOWHERE;
+ if ((hitTestInfo.flags & TCHT_ONITEM) == TCHT_ONITEM)
+ *flags |= wxNB_HITTEST_ONITEM;
+ if ((hitTestInfo.flags & TCHT_ONITEMICON) == TCHT_ONITEMICON)
+ *flags |= wxNB_HITTEST_ONICON;
+ if ((hitTestInfo.flags & TCHT_ONITEMLABEL) == TCHT_ONITEMLABEL)
+ *flags |= wxNB_HITTEST_ONLABEL;
+ }
return item;
}
+
// ----------------------------------------------------------------------------
// wxNotebook callbacks
// ----------------------------------------------------------------------------
// wxNotebook geometry
// ----------------------------------------------------------------------------
-int wxNotebook::HitTest(const wxPoint& pt) const
+int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
{
+ if ( flags )
+ *flags = wxNB_HITTEST_NOWHERE;
+
// first check that it is in this window at all
if ( !GetClientRect().Inside(pt) )
{
GetTabSize(n, &rectTabs.width, &rectTabs.height);
if ( rectTabs.Inside(pt) )
+ {
+ if ( flags )
+ {
+ // TODO: be more precise
+ *flags = wxNB_HITTEST_ONITEM;
+ }
+
return n;
+ }
// move the rectTabs to the next tab
if ( IsVertical() )