]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/notebook.cpp
Document that wxDC::FloodFill() is not implemented under wxOSX.
[wxWidgets.git] / src / os2 / notebook.cpp
index f792c76a6057c50f1c2f0e5363bd2dd8f80e3aaa..de5fbf8e7ad510b2adfff4bab6d853e12d929057 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        notebook.cpp
+// Name:        src/os2/notebook.cpp
 // Purpose:     implementation of wxNotebook
 // Author:      David Webster
 // Modified by:
 // Purpose:     implementation of wxNotebook
 // Author:      David Webster
 // Modified by:
 
 #if wxUSE_NOTEBOOK
 
 
 #if wxUSE_NOTEBOOK
 
+#include  "wx/notebook.h"
+
 // wxWidgets
 #ifndef WX_PRECOMP
 // wxWidgets
 #ifndef WX_PRECOMP
-  #include "wx/app.h"
-  #include "wx/dcclient.h"
-  #include "wx/string.h"
-  #include "wx/settings.h"
+    #include "wx/app.h"
+    #include "wx/dcclient.h"
+    #include "wx/string.h"
+    #include "wx/settings.h"
+    #include "wx/log.h"
+    #include "wx/event.h"
+    #include  "wx/control.h"
 #endif  // WX_PRECOMP
 
 #endif  // WX_PRECOMP
 
-#include  "wx/log.h"
 #include  "wx/imaglist.h"
 #include  "wx/imaglist.h"
-#include  "wx/event.h"
-#include  "wx/control.h"
-#include  "wx/notebook.h"
 
 #include  "wx/os2/private.h"
 
 
 #include  "wx/os2/private.h"
 
 // ----------------------------------------------------------------------------
 
 // check that the page index is valid
 // ----------------------------------------------------------------------------
 
 // check that the page index is valid
-#define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((nPage) < GetPageCount()))
+#define IS_VALID_PAGE(nPage) (                                \
+                               /* size_t is _always_ >= 0 */  \
+                               /* ((nPage) >= 0) && */        \
+                               ((nPage) < GetPageCount())     \
+                             )
 
 // hide the ugly cast
 #define m_hWnd    (HWND)GetHWND()
 
 // hide the ugly cast
 #define m_hWnd    (HWND)GetHWND()
 // event table
 // ----------------------------------------------------------------------------
 
 // event table
 // ----------------------------------------------------------------------------
 
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)
-DEFINE_EVENT_TYPE(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING)
-
-BEGIN_EVENT_TABLE(wxNotebook, wxControl)
-    EVT_NOTEBOOK_PAGE_CHANGED(-1, wxNotebook::OnSelChange)
+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()
 
     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)
-
 // ============================================================================
 // implementation
 // ============================================================================
 // ============================================================================
 // implementation
 // ============================================================================
@@ -74,8 +73,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxNotebookEvent, wxNotifyEvent)
 //
 void wxNotebook::Init()
 {
 //
 void wxNotebook::Init()
 {
-    m_imageList  = NULL;
-    m_nSelection = -1;
     m_nTabSize   = 0;
 } // end of wxNotebook::Init
 
     m_nTabSize   = 0;
 } // end of wxNotebook::Init
 
@@ -112,15 +109,15 @@ wxNotebook::wxNotebook(
 //
 // Create() function
 //
 //
 // Create() function
 //
-bool wxNotebook::Create(
-  wxWindow*                         pParent
-, wxWindowID                        vId
-, const wxPoint&                    rPos
-, const wxSize&                     rSize
-, long                              lStyle
-, const wxString&                   rsName
-)
+bool wxNotebook::Create( wxWindow*       pParent,
+                         wxWindowID      vId,
+                         const wxPoint&  rPos,
+                         const wxSize&   rSize,
+                         long            lStyle,
+                         const wxString& rsName )
 {
 {
+    if ( (lStyle & wxBK_ALIGN_MASK) == wxBK_DEFAULT )
+        lStyle |= wxBK_TOP;
     //
     // Base init
     //
     //
     // Base init
     //
@@ -132,21 +129,21 @@ bool wxNotebook::Create(
                        ,wxDefaultValidator
                        ,rsName
                       ))
                        ,wxDefaultValidator
                        ,rsName
                       ))
-        return FALSE;
+        return false;
 
     //
     // Notebook, so explicitly specify 0 as last parameter
     //
 
     //
     // Notebook, so explicitly specify 0 as last parameter
     //
-    if (!OS2CreateControl( "NOTEBOOK"
-                          ,_T("")
+    if (!OS2CreateControl( wxT("NOTEBOOK")
+                          ,wxEmptyString
                           ,rPos
                           ,rSize
                           ,lStyle | wxTAB_TRAVERSAL
                          ))
                           ,rPos
                           ,rSize
                           ,lStyle | wxTAB_TRAVERSAL
                          ))
-        return FALSE;
+        return false;
 
     SetBackgroundColour(wxColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)));
 
     SetBackgroundColour(wxColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)));
-    return TRUE;
+    return true;
 } // end of wxNotebook::Create
 
 WXDWORD wxNotebook::OS2GetStyle (
 } // end of wxNotebook::Create
 
 WXDWORD wxNotebook::OS2GetStyle (
@@ -160,11 +157,11 @@ WXDWORD wxNotebook::OS2GetStyle (
 
     dwTabStyle |= WS_TABSTOP | BKS_SOLIDBIND | BKS_ROUNDEDTABS | BKS_TABTEXTCENTER | BKS_TABBEDDIALOG;
 
 
     dwTabStyle |= WS_TABSTOP | BKS_SOLIDBIND | BKS_ROUNDEDTABS | BKS_TABTEXTCENTER | BKS_TABBEDDIALOG;
 
-    if (lStyle & wxNB_BOTTOM)
+    if (lStyle & wxBK_BOTTOM)
         dwTabStyle |= BKS_MAJORTABBOTTOM | BKS_BACKPAGESBL;
         dwTabStyle |= BKS_MAJORTABBOTTOM | BKS_BACKPAGESBL;
-    else if (lStyle & wxNB_RIGHT)
+    else if (lStyle & wxBK_RIGHT)
         dwTabStyle |= BKS_MAJORTABRIGHT | BKS_BACKPAGESBR;
         dwTabStyle |= BKS_MAJORTABRIGHT | BKS_BACKPAGESBR;
-    else if (lStyle & wxNB_LEFT)
+    else if (lStyle & wxBK_LEFT)
         dwTabStyle |= BKS_MAJORTABLEFT | BKS_BACKPAGESTL;
     else // default to top
         dwTabStyle |= BKS_MAJORTABTOP | BKS_BACKPAGESTR;
         dwTabStyle |= BKS_MAJORTABLEFT | BKS_BACKPAGESTL;
     else // default to top
         dwTabStyle |= BKS_MAJORTABTOP | BKS_BACKPAGESTR;
@@ -205,29 +202,27 @@ int wxNotebook::GetRowCount() const
                             );
 } // end of wxNotebook::GetRowCount
 
                             );
 } // end of wxNotebook::GetRowCount
 
-int wxNotebook::SetSelection(
-  size_t                            nPage
-)
+int wxNotebook::SetSelection( size_t nPage )
 {
 {
-    wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
+    wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
 
 
-    if (nPage != (size_t)m_nSelection)
+    if (nPage != (size_t)m_selection)
     {
     {
-        wxNotebookEvent             vEvent( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
+        wxBookCtrlEvent             vEvent( wxEVT_NOTEBOOK_PAGE_CHANGING
                                            ,m_windowId
                                           );
 
         vEvent.SetSelection(nPage);
                                            ,m_windowId
                                           );
 
         vEvent.SetSelection(nPage);
-        vEvent.SetOldSelection(m_nSelection);
+        vEvent.SetOldSelection(m_selection);
         vEvent.SetEventObject(this);
         vEvent.SetEventObject(this);
-        if (!GetEventHandler()->ProcessEvent(vEvent) || vEvent.IsAllowed())
+        if (!HandleWindowEvent(vEvent) || vEvent.IsAllowed())
         {
 
             //
             // Program allows the page change
             //
         {
 
             //
             // Program allows the page change
             //
-            vEvent.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
-            GetEventHandler()->ProcessEvent(vEvent);
+            vEvent.SetEventType(wxEVT_NOTEBOOK_PAGE_CHANGED);
+            HandleWindowEvent(vEvent);
 
             ::WinSendMsg( GetHWND()
                          ,BKM_TURNTOPAGE
 
             ::WinSendMsg( GetHWND()
                          ,BKM_TURNTOPAGE
@@ -236,33 +231,45 @@ int wxNotebook::SetSelection(
                         );
         }
     }
                         );
         }
     }
-    m_nSelection = nPage;
+    m_selection = nPage;
     return nPage;
 } // end of wxNotebook::SetSelection
 
     return nPage;
 } // end of wxNotebook::SetSelection
 
-bool wxNotebook::SetPageText(
-  size_t                            nPage
-, const wxString&                   rsStrText
-)
+int wxNotebook::ChangeSelection( size_t nPage )
 {
 {
-    wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, wxT("notebook page out of range") );
+    wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
+
+    if (nPage != (size_t)m_selection)
+    {
+        ::WinSendMsg( GetHWND()
+                ,BKM_TURNTOPAGE
+                ,MPFROMLONG((ULONG)m_alPageId[nPage])
+                        ,(MPARAM)0
+                    );
+    }
+    m_selection = nPage;
+    return nPage;
+}
+
+bool wxNotebook::SetPageText( size_t nPage,
+                              const wxString& rsStrText )
+{
+    wxCHECK_MSG( IS_VALID_PAGE(nPage), false, wxT("notebook page out of range") );
     return (bool)::WinSendMsg( m_hWnd
                               ,BKM_SETTABTEXT
                               ,MPFROMLONG((ULONG)m_alPageId[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
 
                              );
 } // end of wxNotebook::SetPageText
 
-wxString wxNotebook::GetPageText (
-  size_t                            nPage
-) const
+wxString wxNotebook::GetPageText ( size_t nPage ) const
 {
     BOOKTEXT                        vBookText;
     wxChar                          zBuf[256];
     wxString                        sStr;
     ULONG                           ulRc;
 
 {
     BOOKTEXT                        vBookText;
     wxChar                          zBuf[256];
     wxString                        sStr;
     ULONG                           ulRc;
 
-    wxCHECK_MSG( IS_VALID_PAGE(nPage), wxT(""), wxT("notebook page out of range") );
+    wxCHECK_MSG( IS_VALID_PAGE(nPage), wxEmptyString, wxT("notebook page out of range") );
 
     memset(&vBookText, '\0', sizeof(BOOKTEXT));
     vBookText.textLen = 0; // This will get the length
 
     memset(&vBookText, '\0', sizeof(BOOKTEXT));
     vBookText.textLen = 0; // This will get the length
@@ -280,7 +287,7 @@ wxString wxNotebook::GetPageText (
         return wxEmptyString;
     }
     vBookText.textLen = ulRc + 1; // To get the null terminator
         return wxEmptyString;
     }
     vBookText.textLen = ulRc + 1; // To get the null terminator
-    vBookText.pString = zBuf;
+    vBookText.pString = (char*)zBuf;
 
     //
     // Now get the actual text
 
     //
     // Now get the actual text
@@ -298,15 +305,13 @@ wxString wxNotebook::GetPageText (
         ulRc = 255L;
 
     vBookText.pString[ulRc] = '\0';
         ulRc = 255L;
 
     vBookText.pString[ulRc] = '\0';
-    sStr = vBookText.pString;
+    sStr = (wxChar*)vBookText.pString;
     return sStr;
 } // end of wxNotebook::GetPageText
 
     return sStr;
 } // end of wxNotebook::GetPageText
 
-int wxNotebook::GetPageImage (
-  size_t                            nPage
-) const
+int wxNotebook::GetPageImage ( size_t nPage ) const
 {
 {
-    wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
+    wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") );
 
     //
     // For OS/2 just return the page
 
     //
     // For OS/2 just return the page
@@ -319,12 +324,12 @@ bool wxNotebook::SetPageImage (
 , int                               nImage
 )
 {
 , int                               nImage
 )
 {
-    wxBitmap                        vBitmap = (wxBitmap)m_imageList->GetBitmap(nImage);
+    wxBitmap                        vBitmap = (wxBitmap)GetImageList()->GetBitmap(nImage);
 
     return (bool)::WinSendMsg( GetHWND()
                               ,BKM_SETTABBITMAP
                               ,MPFROMLONG((ULONG)m_alPageId[nPage])
 
     return (bool)::WinSendMsg( GetHWND()
                               ,BKM_SETTABBITMAP
                               ,MPFROMLONG((ULONG)m_alPageId[nPage])
-                              ,(MPARAM)vBitmap.GetHBITMAP()
+                              ,(MPARAM)wxCopyBmp(vBitmap.GetHBITMAP(), true)
                              );
 } // end of wxNotebook::SetPageImage
 
                              );
 } // end of wxNotebook::SetPageImage
 
@@ -332,10 +337,10 @@ void wxNotebook::SetImageList (
   wxImageList*                      pImageList
 )
 {
   wxImageList*                      pImageList
 )
 {
-    // 
+    //
     // Does not really do anything yet, but at least we need to
     // update the base class.
     // Does not really do anything yet, but at least we need to
     // update the base class.
-    // 
+    //
     wxNotebookBase::SetImageList(pImageList);
 } // end of wxNotebook::SetImageList
 
     wxNotebookBase::SetImageList(pImageList);
 } // end of wxNotebook::SetImageList
 
@@ -378,11 +383,9 @@ void wxNotebook::SetTabSize (
 //
 // Remove one page from the notebook, without deleting
 //
 //
 // Remove one page from the notebook, without deleting
 //
-wxNotebookPage* wxNotebook::DoRemovePage (
-  size_t                            nPage
-)
+wxNotebookPage* wxNotebook::DoRemovePage ( size_t nPage )
 {
 {
-    wxNotebookPage*                 pPageRemoved = wxNotebookBase::DoRemovePage(nPage);
+    wxNotebookPage* pPageRemoved = wxNotebookBase::DoRemovePage(nPage);
 
     if (!pPageRemoved)
         return NULL;
 
     if (!pPageRemoved)
         return NULL;
@@ -397,7 +400,7 @@ wxNotebookPage* wxNotebook::DoRemovePage (
         //
         // No selection any more, the notebook becamse empty
         //
         //
         // No selection any more, the notebook becamse empty
         //
-        m_nSelection = -1;
+        m_selection = wxNOT_FOUND;
     }
     else // notebook still not empty
     {
     }
     else // notebook still not empty
     {
@@ -406,23 +409,23 @@ wxNotebookPage* wxNotebook::DoRemovePage (
         //
         int                         nSelNew;
 
         //
         int                         nSelNew;
 
-        if (m_nSelection == (int)GetPageCount())
+        if (m_selection == (int)GetPageCount())
         {
             //
             // Last page deleted, make the new last page the new selection
             //
         {
             //
             // Last page deleted, make the new last page the new selection
             //
-            nSelNew = m_nSelection - 1;
+            nSelNew = m_selection - 1;
         }
         }
-        else if (nPage <= (size_t)m_nSelection)
+        else if (nPage <= (size_t)m_selection)
         {
             //
             // We must show another page, even if it has the same index
             //
         {
             //
             // We must show another page, even if it has the same index
             //
-            nSelNew = m_nSelection;
+            nSelNew = m_selection;
         }
         else // nothing changes for the currently selected page
         {
         }
         else // nothing changes for the currently selected page
         {
-            nSelNew = -1;
+            nSelNew = wxNOT_FOUND;
 
             //
             // We still must refresh the current page: this needs to be done
 
             //
             // We still must refresh the current page: this needs to be done
@@ -430,16 +433,16 @@ wxNotebookPage* wxNotebook::DoRemovePage (
             // control (i.e. when there are too many pages) -- otherwise after
             // deleting a page nothing at all is shown
             //
             // control (i.e. when there are too many pages) -- otherwise after
             // deleting a page nothing at all is shown
             //
-            m_pages[m_nSelection]->Refresh();
+            m_pages[m_selection]->Refresh();
         }
 
         }
 
-        if (nSelNew != -1)
+        if (nSelNew != wxNOT_FOUND)
         {
             //
         {
             //
-            // m_nSelection must be always valid so reset it before calling
+            // m_selection must be always valid so reset it before calling
             // SetSelection()
             //
             // SetSelection()
             //
-            m_nSelection = -1;
+            m_selection = wxNOT_FOUND;
             SetSelection(nSelNew);
         }
     }
             SetSelection(nSelNew);
         }
     }
@@ -462,8 +465,9 @@ bool wxNotebook::DeleteAllPages()
                  ,(MPARAM)0
                  ,(MPARAM)BKA_ALL
                 );
                  ,(MPARAM)0
                  ,(MPARAM)BKA_ALL
                 );
-    m_nSelection = -1;
-    return TRUE;
+    m_selection = wxNOT_FOUND;
+
+    return true;
 } // end of wxNotebook::DeleteAllPages
 
 //
 } // end of wxNotebook::DeleteAllPages
 
 //
@@ -487,18 +491,16 @@ bool wxNotebook::AddPage (
 //
 // Same as AddPage() but does it at given position
 //
 //
 // Same as AddPage() but does it at given position
 //
-bool wxNotebook::InsertPage (
-  size_t                            nPage
-, wxNotebookPage*                   pPage
-, const wxString&                   rsStrText
-, bool                              bSelect
-, int                               nImageId
-)
+bool wxNotebook::InsertPage ( size_t          nPage,
+                              wxNotebookPage* pPage,
+                              const wxString& rsStrText,
+                              bool            bSelect,
+                              int             nImageId )
 {
     ULONG                           ulApiPage;
 
     wxASSERT( pPage != NULL );
 {
     ULONG                           ulApiPage;
 
     wxASSERT( pPage != NULL );
-    wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), FALSE );
+    wxCHECK( IS_VALID_PAGE(nPage) || nPage == GetPageCount(), false );
 
     //
     // Under OS/2 we can only insert FIRST, LAST, NEXT or PREV.  Requires
 
     //
     // Under OS/2 we can only insert FIRST, LAST, NEXT or PREV.  Requires
@@ -524,7 +526,7 @@ bool wxNotebook::InsertPage (
 
             vError = ::WinGetLastError(vHabmain);
             sError = wxPMErrorToStr(vError);
 
             vError = ::WinGetLastError(vHabmain);
             sError = wxPMErrorToStr(vError);
-            return FALSE;
+            return false;
         }
         m_alPageId.Insert((long)ulApiPage, nPage);
     }
         }
         m_alPageId.Insert((long)ulApiPage, nPage);
     }
@@ -542,7 +544,7 @@ bool wxNotebook::InsertPage (
 
             vError = ::WinGetLastError(vHabmain);
             sError = wxPMErrorToStr(vError);
 
             vError = ::WinGetLastError(vHabmain);
             sError = wxPMErrorToStr(vError);
-            return FALSE;
+            return false;
         }
         m_alPageId.Insert((long)ulApiPage, nPage);
     }
         }
         m_alPageId.Insert((long)ulApiPage, nPage);
     }
@@ -557,18 +559,18 @@ bool wxNotebook::InsertPage (
                           ,MPFROMLONG((ULONG)m_alPageId[nPage])
                           ,MPFROMHWND(pPage->GetHWND())
                          ))
                           ,MPFROMLONG((ULONG)m_alPageId[nPage])
                           ,MPFROMHWND(pPage->GetHWND())
                          ))
-            return FALSE;
+            return false;
     }
     //
     // If the inserted page is before the selected one, we must update the
     // index of the selected page
     //
     }
     //
     // If the inserted page is before the selected one, we must update the
     // index of the selected page
     //
-    if (nPage <= (size_t)m_nSelection)
+    if (nPage <= (size_t)m_selection)
     {
         //
         // One extra page added
         //
     {
         //
         // One extra page added
         //
-        m_nSelection++;
+        m_selection++;
     }
 
     if (pPage)
     }
 
     if (pPage)
@@ -585,9 +587,9 @@ bool wxNotebook::InsertPage (
     // Now set TAB dimenstions
     //
 
     // Now set TAB dimenstions
     //
 
-    wxWindowDC                      vDC(this);
-    wxCoord                         nTextX;
-    wxCoord                         nTextY;
+    wxWindowDC vDC(this);
+    wxCoord    nTextX;
+    wxCoord    nTextY;
 
     vDC.GetTextExtent(rsStrText, &nTextX, &nTextY);
     nTextY *= 2;
 
     vDC.GetTextExtent(rsStrText, &nTextX, &nTextY);
     nTextY *= 2;
@@ -604,12 +606,12 @@ bool wxNotebook::InsertPage (
     //
     // Now set any TAB text
     //
     //
     // Now set any TAB text
     //
-    if (!rsStrText.IsEmpty())
+    if (!rsStrText.empty())
     {
         if (!SetPageText( nPage
                          ,rsStrText
                         ))
     {
         if (!SetPageText( nPage
                          ,rsStrText
                         ))
-            return FALSE;
+            return false;
     }
 
     //
     }
 
     //
@@ -620,7 +622,7 @@ bool wxNotebook::InsertPage (
         if (!SetPageImage( nPage
                           ,nImageId
                          ))
         if (!SetPageImage( nPage
                           ,nImageId
                          ))
-            return FALSE;
+            return false;
     }
 
     if (pPage)
     }
 
     if (pPage)
@@ -628,7 +630,7 @@ bool wxNotebook::InsertPage (
         //
         // Don't show pages by default (we'll need to adjust their size first)
         //
         //
         // Don't show pages by default (we'll need to adjust their size first)
         //
-        HWND                        hWnd = GetWinHwnd(pPage);
+        HWND hWnd = GetWinHwnd(pPage);
 
         WinSetWindowULong( hWnd
                           ,QWL_STYLE
 
         WinSetWindowULong( hWnd
                           ,QWL_STYLE
@@ -640,26 +642,14 @@ bool wxNotebook::InsertPage (
         //
         // This updates internal flag too - otherwise it will get out of sync
         //
         //
         // This updates internal flag too - otherwise it will get out of sync
         //
-        pPage->Show(FALSE);
+        pPage->Show(false);
     }
 
     }
 
-    //
-    // Some page should be selected: either this one or the first one if there is
-    // still no selection
-    //
-    int                             nSelNew = -1;
-
-    if (bSelect)
-        nSelNew = nPage;
-    else if ( m_nSelection == -1 )
-        nSelNew = 0;
-
-    if (nSelNew != -1)
-        SetSelection(nSelNew);
+    DoSetSelectionAfterInsertion(nPage, bSelect);
 
     InvalidateBestSize();
 
 
     InvalidateBestSize();
 
-    return TRUE;
+    return true;
 } // end of wxNotebook::InsertPage
 
 // ----------------------------------------------------------------------------
 } // end of wxNotebook::InsertPage
 
 // ----------------------------------------------------------------------------
@@ -673,7 +663,7 @@ void wxNotebook::OnSize(
 } // end of wxNotebook::OnSize
 
 void wxNotebook::OnSelChange (
 } // end of wxNotebook::OnSize
 
 void wxNotebook::OnSelChange (
-  wxNotebookEvent&                  rEvent
+  wxBookCtrlEvent&                  rEvent
 )
 {
     //
 )
 {
     //
@@ -681,16 +671,16 @@ void wxNotebook::OnSelChange (
     //
     if (rEvent.GetEventObject() == this)
     {
     //
     if (rEvent.GetEventObject() == this)
     {
-        int                         nPageCount = GetPageCount();
-        int                         nSel;
-        ULONG                       ulOS2Sel = (ULONG)rEvent.GetOldSelection();
-        bool                        bFound = FALSE;
+        int   nPageCount = GetPageCount();
+        int   nSel;
+        ULONG ulOS2Sel = (ULONG)rEvent.GetOldSelection();
+        bool  bFound = false;
 
         for (nSel = 0; nSel < nPageCount; nSel++)
         {
             if (ulOS2Sel == (ULONG)m_alPageId[nSel])
             {
 
         for (nSel = 0; nSel < nPageCount; nSel++)
         {
             if (ulOS2Sel == (ULONG)m_alPageId[nSel])
             {
-                bFound = TRUE;
+                bFound = true;
                 break;
             }
         }
                 break;
             }
         }
@@ -698,17 +688,17 @@ void wxNotebook::OnSelChange (
         if (!bFound)
             return;
 
         if (!bFound)
             return;
 
-        m_pages[nSel]->Show(FALSE);
+        m_pages[nSel]->Show(false);
 
         ulOS2Sel = (ULONG)rEvent.GetSelection();
 
 
         ulOS2Sel = (ULONG)rEvent.GetSelection();
 
-        bFound = FALSE;
+        bFound = false;
 
         for (nSel = 0; nSel < nPageCount; nSel++)
         {
             if (ulOS2Sel == (ULONG)m_alPageId[nSel])
             {
 
         for (nSel = 0; nSel < nPageCount; nSel++)
         {
             if (ulOS2Sel == (ULONG)m_alPageId[nSel])
             {
-                bFound = TRUE;
+                bFound = true;
                 break;
             }
         }
                 break;
             }
         }
@@ -718,8 +708,8 @@ void wxNotebook::OnSelChange (
 
         wxNotebookPage*         pPage = m_pages[nSel];
 
 
         wxNotebookPage*         pPage = m_pages[nSel];
 
-        pPage->Show(TRUE);
-        m_nSelection = nSel;
+        pPage->Show(true);
+        m_selection = nSel;
     }
 
     //
     }
 
     //
@@ -740,8 +730,8 @@ void wxNotebook::OnSetFocus (
     //
     // set focus to the currently selected page if any
     //
     //
     // set focus to the currently selected page if any
     //
-    if (m_nSelection != -1)
-        m_pages[m_nSelection]->SetFocus();
+    if (m_selection != wxNOT_FOUND)
+        m_pages[m_selection]->SetFocus();
     rEvent.Skip();
 } // end of wxNotebook::OnSetFocus
 
     rEvent.Skip();
 } // end of wxNotebook::OnSetFocus
 
@@ -780,7 +770,7 @@ void wxNotebook::OnNavigationKey (
             //
             // No, it doesn't come from child, case (b): forward to a page
             //
             //
             // No, it doesn't come from child, case (b): forward to a page
             //
-            if (m_nSelection != -1)
+            if (m_selection != wxNOT_FOUND)
             {
                 //
                 // So that the page knows that the event comes from it's parent
             {
                 //
                 // So that the page knows that the event comes from it's parent
@@ -788,9 +778,9 @@ void wxNotebook::OnNavigationKey (
                 //
                 rEvent.SetEventObject(this);
 
                 //
                 rEvent.SetEventObject(this);
 
-                wxWindow*           pPage = m_pages[m_nSelection];
+                wxWindow*           pPage = m_pages[m_selection];
 
 
-                if (!pPage->GetEventHandler()->ProcessEvent(rEvent))
+                if (!pPage->HandleWindowEvent(rEvent))
                 {
                     pPage->SetFocus();
                 }
                 {
                     pPage->SetFocus();
                 }
@@ -812,7 +802,7 @@ void wxNotebook::OnNavigationKey (
             if (pParent)
             {
                 rEvent.SetCurrentFocus(this);
             if (pParent)
             {
                 rEvent.SetCurrentFocus(this);
-                pParent->GetEventHandler()->ProcessEvent(rEvent);
+                pParent->HandleWindowEvent(rEvent);
             }
         }
     }
             }
         }
     }
@@ -825,39 +815,33 @@ void wxNotebook::OnNavigationKey (
 //
 // Override these 2 functions to do nothing: everything is done in OnSize
 //
 //
 // Override these 2 functions to do nothing: everything is done in OnSize
 //
-void wxNotebook::SetConstraintSizes(
-  bool                              WXUNUSED(bRecurse)
-)
+void wxNotebook::SetConstraintSizes( bool WXUNUSED(bRecurse) )
 {
     //
     // Don't set the sizes of the pages - their correct size is not yet known
     //
 {
     //
     // Don't set the sizes of the pages - their correct size is not yet known
     //
-    wxControl::SetConstraintSizes(FALSE);
+    wxControl::SetConstraintSizes(false);
 } // end of wxNotebook::SetConstraintSizes
 
 } // end of wxNotebook::SetConstraintSizes
 
-bool wxNotebook::DoPhase (
-  int                               WXUNUSED(nPhase)
-)
+bool wxNotebook::DoPhase ( int WXUNUSED(nPhase) )
 {
 {
-    return TRUE;
+    return true;
 } // end of wxNotebook::DoPhase
 
 // ----------------------------------------------------------------------------
 // wxNotebook Windows message handlers
 // ----------------------------------------------------------------------------
 } // end of wxNotebook::DoPhase
 
 // ----------------------------------------------------------------------------
 // wxNotebook Windows message handlers
 // ----------------------------------------------------------------------------
-bool wxNotebook::OS2OnScroll (
-  int                               nOrientation
-, WXWORD                            wSBCode
-, WXWORD                            wPos
-, WXHWND                            wControl
-)
+bool wxNotebook::OS2OnScroll ( int    nOrientation,
+                               WXWORD wSBCode,
+                               WXWORD wPos,
+                               WXHWND wControl )
 {
     //
     // Don't generate EVT_SCROLLWIN events for the WM_SCROLLs coming from the
     // up-down control
     //
     if (wControl)
 {
     //
     // Don't generate EVT_SCROLLWIN events for the WM_SCROLLs coming from the
     // up-down control
     //
     if (wControl)
-        return FALSE;
+        return false;
     return wxNotebookBase::OS2OnScroll( nOrientation
                                        ,wSBCode
                                        ,wPos
     return wxNotebookBase::OS2OnScroll( nOrientation
                                        ,wSBCode
                                        ,wPos
@@ -866,4 +850,3 @@ bool wxNotebook::OS2OnScroll (
 } // end of wxNotebook::OS2OnScroll
 
 #endif // wxUSE_NOTEBOOK
 } // end of wxNotebook::OS2OnScroll
 
 #endif // wxUSE_NOTEBOOK
-