#include "wx/generic/imaglist.h"
#include "wx/notebook.h"
#include "wx/dcclient.h"
+#include "wx/generic/tabg.h"
// ----------------------------------------------------------------------------
// macros
EVT_MOUSE_EVENTS(wxNotebook::OnMouseEvent)
EVT_SET_FOCUS(wxNotebook::OnSetFocus)
EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
-// EVT_IDLE(wxNotebook::OnIdle)
END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
// implementation
// ============================================================================
+// ============================================================================
+// Private class
+// ============================================================================
+
+// This reuses wxTabView to draw the tabs.
+class WXDLLEXPORT wxNotebookTabView: public wxTabView
+{
+DECLARE_DYNAMIC_CLASS(wxNotebookTabView)
+public:
+ wxNotebookTabView(wxNotebook* notebook, long style = wxTAB_STYLE_DRAW_BOX | wxTAB_STYLE_COLOUR_INTERIOR);
+ ~wxNotebookTabView(void);
+
+ // Called when a tab is activated
+ virtual void OnTabActivate(int activateId, int deactivateId);
+ // Allows vetoing
+ virtual bool OnTabPreActivate(int activateId, int deactivateId);
+
+protected:
+ wxNotebook* m_notebook;
+};
+
// ----------------------------------------------------------------------------
// wxNotebook construction
// ----------------------------------------------------------------------------
// This was supposed to cure the non-display of the notebook
// until the user resizes the window.
// What's going on?
-void wxNotebook::OnIdle(wxIdleEvent& event)
+void wxNotebook::OnInternalIdle()
{
+ wxWindow::OnInternalIdle();
+
+#if 0
static bool s_bFirstTime = TRUE;
if ( s_bFirstTime ) {
/*
*/
s_bFirstTime = FALSE;
}
- event.Skip();
+#endif
}
// Implementation: calculate the layout of the view rect
unsigned int nCount = m_pages.Count();
for ( unsigned int nPage = 0; nPage < nCount; nPage++ ) {
wxNotebookPage *pPage = m_pages[nPage];
+ wxRect clientRect = GetAvailableClientSize();
if (pPage->IsShown())
{
- wxRect clientRect = GetAvailableClientSize();
pPage->SetSize(clientRect.x, clientRect.y, clientRect.width, clientRect.height);
if ( pPage->GetAutoLayout() )
pPage->Layout();
m_notebook->GetEventHandler()->ProcessEvent(event);
}
+// Allows Vetoing
+bool wxNotebookTabView::OnTabPreActivate(int activateId, int deactivateId)
+{
+ bool retval = TRUE;
+
+ if (m_notebook)
+ {
+ wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_notebook->GetId());
+
+#if defined (__WIN16__)
+ int activatePos = activateId;
+ int deactivatePos = deactivateId;
+#else
+ // Translate from wxTabView's ids (which aren't position-dependent)
+ // to wxNotebook's (which are).
+ wxNotebookPage* pActive = (wxNotebookPage*) activateId;
+ wxNotebookPage* pDeactive = (wxNotebookPage*) deactivateId;
+
+ int activatePos = m_notebook->FindPagePosition(pActive);
+ int deactivatePos = m_notebook->FindPagePosition(pDeactive);
+
+#endif
+ event.SetEventObject(m_notebook);
+ event.SetSelection(activatePos);
+ event.SetOldSelection(deactivatePos);
+ if (m_notebook->GetEventHandler()->ProcessEvent(event))
+ {
+ retval = event.IsAllowed();
+ }
+ }
+ return retval;
+}