]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/notebook.cpp
recognize schemes other than http and ftp in wxLaunchDefaultBrowser()
[wxWidgets.git] / src / os2 / notebook.cpp
index b0765dd8e85890aa6312e800de396f18d4f594bd..9f7df8f3f93986523a80e2bf0c696145b4717b0f 100644 (file)
     #include "wx/dcclient.h"
     #include "wx/string.h"
     #include "wx/settings.h"
-    #include  "wx/log.h"
+    #include "wx/log.h"
+    #include "wx/event.h"
+    #include  "wx/control.h"
 #endif  // WX_PRECOMP
 
 #include  "wx/imaglist.h"
-#include  "wx/event.h"
-#include  "wx/control.h"
 
 #include  "wx/os2/private.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_SET_FOCUS(wxNotebook::OnSetFocus)
     EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey)
 END_EVENT_TABLE()
 
-IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxControl)
-IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
+IMPLEMENT_DYNAMIC_CLASS(wxNotebook, wxBookCtrlBase)
 
 // ============================================================================
 // implementation
@@ -124,6 +120,8 @@ bool wxNotebook::Create( wxWindow*       pParent,
                          long            lStyle,
                          const wxString& rsName )
 {
+    if ( (lStyle & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
+        lStyle |= wxBK_TOP;
     //
     // Base init
     //
@@ -214,21 +212,21 @@ int wxNotebook::SetSelection( size_t nPage )
 
     if (nPage != (size_t)m_nSelection)
     {
-        wxNotebookEvent             vEvent( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
+        wxBookCtrlEvent             vEvent( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
                                            ,m_windowId
                                           );
 
         vEvent.SetSelection(nPage);
         vEvent.SetOldSelection(m_nSelection);
         vEvent.SetEventObject(this);
-        if (!GetEventHandler()->ProcessEvent(vEvent) || vEvent.IsAllowed())
+        if (!HandleWindowEvent(vEvent) || vEvent.IsAllowed())
         {
 
             //
             // Program allows the page change
             //
             vEvent.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
-            GetEventHandler()->ProcessEvent(vEvent);
+            HandleWindowEvent(vEvent);
 
             ::WinSendMsg( GetHWND()
                          ,BKM_TURNTOPAGE
@@ -241,6 +239,22 @@ int wxNotebook::SetSelection( size_t nPage )
     return nPage;
 } // end of wxNotebook::SetSelection
 
+int wxNotebook::ChangeSelection( size_t nPage )
+{
+    wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
+
+    if (nPage != (size_t)m_nSelection)
+    {
+        ::WinSendMsg( GetHWND()
+                ,BKM_TURNTOPAGE
+                ,MPFROMLONG((ULONG)m_alPageId[nPage])
+                        ,(MPARAM)0
+                    );
+    }
+    m_nSelection = nPage;
+    return nPage;
+}
+
 bool wxNotebook::SetPageText( size_t nPage,
                               const wxString& rsStrText )
 {
@@ -248,7 +262,7 @@ bool wxNotebook::SetPageText( size_t nPage,
     return (bool)::WinSendMsg( m_hWnd
                               ,BKM_SETTABTEXT
                               ,MPFROMLONG((ULONG)m_alPageId[nPage])
-                              ,MPFROMP((PSZ)rsStrText.c_str())
+                              ,MPFROMP((const char*)rsStrText.c_str())
                              );
 } // end of wxNotebook::SetPageText
 
@@ -319,7 +333,7 @@ bool wxNotebook::SetPageImage (
     return (bool)::WinSendMsg( GetHWND()
                               ,BKM_SETTABBITMAP
                               ,MPFROMLONG((ULONG)m_alPageId[nPage])
-                              ,(MPARAM)wxFlipBmp(vBitmap.GetHBITMAP())
+                              ,(MPARAM)wxCopyBmp(vBitmap.GetHBITMAP(), true)
                              );
 } // end of wxNotebook::SetPageImage
 
@@ -665,7 +679,7 @@ void wxNotebook::OnSize(
 } // end of wxNotebook::OnSize
 
 void wxNotebook::OnSelChange (
-  wxNotebookEvent&                  rEvent
+  wxBookCtrlEvent&                  rEvent
 )
 {
     //
@@ -782,7 +796,7 @@ void wxNotebook::OnNavigationKey (
 
                 wxWindow*           pPage = m_pages[m_nSelection];
 
-                if (!pPage->GetEventHandler()->ProcessEvent(rEvent))
+                if (!pPage->HandleWindowEvent(rEvent))
                 {
                     pPage->SetFocus();
                 }
@@ -804,7 +818,7 @@ void wxNotebook::OnNavigationKey (
             if (pParent)
             {
                 rEvent.SetCurrentFocus(this);
-                pParent->GetEventHandler()->ProcessEvent(rEvent);
+                pParent->HandleWindowEvent(rEvent);
             }
         }
     }