]> git.saurik.com Git - wxWidgets.git/blobdiff - src/univ/notebook.cpp
Don't use result for both NS and wx button ID values.
[wxWidgets.git] / src / univ / notebook.cpp
index 4fe59855e84baf2c955379e05b470ad49bff901d..d219fa2162d231ce63196cd647dd84ba931c95da 100644 (file)
 
 #include "wx/univ/renderer.h"
 
+// ----------------------------------------------------------------------------
+// wxStdNotebookInputHandler: translates SPACE and ENTER keys and the left mouse
+// click into button press/release actions
+// ----------------------------------------------------------------------------
+
+class WXDLLEXPORT wxStdNotebookInputHandler : public wxStdInputHandler
+{
+public:
+    wxStdNotebookInputHandler(wxInputHandler *inphand);
+
+    virtual bool HandleKey(wxInputConsumer *consumer,
+                           const wxKeyEvent& event,
+                           bool pressed);
+    virtual bool HandleMouse(wxInputConsumer *consumer,
+                             const wxMouseEvent& event);
+    virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event);
+    virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
+    virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
+
+protected:
+    void HandleFocusChange(wxInputConsumer *consumer);
+};
+
 // ----------------------------------------------------------------------------
 // macros
 // ----------------------------------------------------------------------------
@@ -53,9 +76,6 @@
 
 static const size_t INVALID_PAGE = (size_t)-1;
 
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
-
 // ----------------------------------------------------------------------------
 // private classes
 // ----------------------------------------------------------------------------
@@ -91,8 +111,7 @@ END_EVENT_TABLE()
 // implementation
 // ============================================================================
 
-IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
-IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxCommandEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxBookCtrlBase)
 
 // ----------------------------------------------------------------------------
 // wxNotebook creation
@@ -130,7 +149,7 @@ bool wxNotebook::Create(wxWindow *parent,
 
     m_sizePad = GetRenderer()->GetTabPadding();
 
-    SetBestSize(size);
+    SetInitialSize(size);
 
     CreateInputHandler(wxINP_HANDLER_NOTEBOOK);
 
@@ -210,7 +229,7 @@ wxNotebook::~wxNotebook()
 // wxNotebook page switching
 // ----------------------------------------------------------------------------
 
-int wxNotebook::SetSelection(size_t nPage)
+int wxNotebook::DoSetSelection(size_t nPage, int flags)
 {
     wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, _T("invalid notebook page") );
 
@@ -220,15 +239,13 @@ int wxNotebook::SetSelection(size_t nPage)
         return m_sel;
     }
 
-    // event handling
-    wxNotebookEvent event(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING, m_windowId);
-    event.SetSelection(nPage);
-    event.SetOldSelection(m_sel);
-    event.SetEventObject(this);
-    if ( GetEventHandler()->ProcessEvent(event) && !event.IsAllowed() )
+    if ( flags & SetSelection_SendEvent )
     {
-        // program doesn't allow the page change
-        return m_sel;
+        if ( !SendPageChangingEvent(nPage) )
+        {
+            // program doesn't allow the page change
+            return m_sel;
+        }
     }
 
     // we need to change m_sel first, before calling RefreshTab() below as
@@ -274,9 +291,11 @@ int wxNotebook::SetSelection(size_t nPage)
         m_pages[m_sel]->Show();
     }
 
-    // event handling
-    event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
-    GetEventHandler()->ProcessEvent(event);
+    if ( flags & SetSelection_SendEvent )
+    {
+        // event handling
+        SendPageChangedEvent(selOld);
+    }
 
     return selOld;
 }
@@ -588,7 +607,7 @@ int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
         *flags = wxBK_HITTEST_NOWHERE;
 
     // first check that it is in this window at all
-    if ( !GetClientRect().Inside(pt) )
+    if ( !GetClientRect().Contains(pt) )
     {
         return -1;
     }
@@ -626,7 +645,7 @@ int wxNotebook::HitTest(const wxPoint& pt, long *flags) const
     {
         GetTabSize(n, &rectTabs.width, &rectTabs.height);
 
-        if ( rectTabs.Inside(pt) )
+        if ( rectTabs.Contains(pt) )
         {
             if ( flags )
             {
@@ -1319,6 +1338,14 @@ bool wxNotebook::PerformAction(const wxControlAction& action,
     return true;
 }
 
+/* static */
+wxInputHandler *wxNotebook::GetStdInputHandler(wxInputHandler *handlerDef)
+{
+    static wxStdNotebookInputHandler s_handler(handlerDef);
+
+    return &s_handler;
+}
+
 // ----------------------------------------------------------------------------
 // wxStdNotebookInputHandler
 // ----------------------------------------------------------------------------