]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/notebook.cpp
Finally corrected drawing of wxListCtrl selection rect for GTK+
[wxWidgets.git] / src / generic / notebook.cpp
index c3e7cb4821d0364773a3b878550abfa111146167..29b5a4137d7638c669aa72a3591475f0f1909528 100644 (file)
@@ -35,7 +35,7 @@
     #include  "wx/settings.h"
 #endif
 
-#include  "wx/generic/imaglist.h"
+#include  "wx/imaglist.h"
 #include  "wx/generic/tabg.h"
 
 // ----------------------------------------------------------------------------
 // event table
 // ----------------------------------------------------------------------------
 
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
-
-BEGIN_EVENT_TABLE(wxNotebook, wxControl)
+BEGIN_EVENT_TABLE(wxNotebook, wxBookCtrlBase)
     EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange)
     EVT_SIZE(wxNotebook::OnSize)
     EVT_PAINT(wxNotebook::OnPaint)
@@ -61,8 +58,7 @@ BEGIN_EVENT_TABLE(wxNotebook, wxControl)
     EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
 END_EVENT_TABLE()
 
-IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
-IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxBookCtrlBase)
 
 // ============================================================================
 // implementation
@@ -84,7 +80,7 @@ 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);
+    virtual ~wxNotebookTabView(void);
 
     // Called when a tab is activated
     virtual void OnTabActivate(int activateId, int deactivateId);
@@ -106,7 +102,7 @@ private:
 
 static int GetPageId(wxTabView *tabview, wxNotebookPage *page)
 {
-    return wx_static_cast(wxNotebookTabView*, tabview)->GetId(page);
+    return static_cast<wxNotebookTabView*>(tabview)->GetId(page);
 }
 
 // ----------------------------------------------------------------------------
@@ -116,7 +112,7 @@ static int GetPageId(wxTabView *tabview, wxNotebookPage *page)
 // common part of all ctors
 void wxNotebook::Init()
 {
-    m_tabView = (wxNotebookTabView*) NULL;
+    m_tabView = NULL;
     m_nSelection = -1;
 }
 
@@ -150,13 +146,14 @@ bool wxNotebook::Create(wxWindow *parent,
     // base init
     SetName(name);
 
+    if ( (style & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
+        style |= wxBK_TOP;
+
     m_windowId = id == wxID_ANY ? NewControlId() : id;
 
     if (!wxControl::Create(parent, id, pos, size, style|wxNO_BORDER, wxDefaultValidator, name))
         return false;
 
-    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
-
     SetTabView(new wxNotebookTabView(this));
 
     return true;
@@ -189,6 +186,12 @@ int wxNotebook::SetSelection(size_t nPage)
     return 0;
 }
 
+int wxNotebook::ChangeSelection(size_t nPage)
+{
+    // FIXME: currently it does generate events too
+    return SetSelection(nPage);
+}
+
 #if 0
 void wxNotebook::AdvanceSelection(bool bForward)
 {
@@ -538,7 +541,7 @@ bool wxNotebook::RefreshLayout(bool force)
     return true;
 }
 
-void wxNotebook::OnSelChange(wxNotebookEvent& event)
+void wxNotebook::OnSelChange(wxBookCtrlEvent& event)
 {
     // is it our tab control?
     if ( event.GetEventObject() == this )
@@ -706,7 +709,7 @@ void wxNotebookTabView::OnTabActivate(int activateId, int deactivateId)
   if (!m_notebook)
     return;
 
-  wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_notebook->GetId());
+  wxBookCtrlEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, m_notebook->GetId());
 
   // Translate from wxTabView's ids (which aren't position-dependent)
   // to wxNotebook's (which are).
@@ -729,7 +732,7 @@ bool wxNotebookTabView::OnTabPreActivate(int activateId, int deactivateId)
 
   if (m_notebook)
   {
-    wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_notebook->GetId());
+    wxBookCtrlEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_notebook->GetId());
 
     // Translate from wxTabView's ids (which aren't position-dependent)
     // to wxNotebook's (which are).