From 7e837615b95205297821dc0b85791ad9e0055df6 Mon Sep 17 00:00:00 2001
From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Wed, 27 Oct 2010 16:54:24 +0000
Subject: [PATCH] No real changes, just replace -1 with wxNOT_FOUND in
 wxBookCtrl code.

Make the code consistently use wxNOT_FOUND instead of -1 everywhere.

See #12622.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@65930 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---
 include/wx/bookctrl.h         | 10 +++++-----
 include/wx/cocoa/notebook.h   |  2 +-
 include/wx/generic/notebook.h |  4 ++--
 include/wx/gtk/notebook.h     |  2 +-
 include/wx/gtk1/notebook.h    |  2 +-
 include/wx/msw/notebook.h     |  2 +-
 include/wx/notebook.h         |  4 ++--
 include/wx/os2/notebook.h     |  2 +-
 include/wx/osx/notebook.h     |  2 +-
 src/cocoa/notebook.mm         |  2 +-
 src/generic/listbkg.cpp       |  8 ++++----
 src/generic/toolbkg.cpp       |  6 +++---
 src/gtk/notebook.cpp          |  6 +++---
 src/gtk1/notebook.cpp         | 12 ++++++------
 src/os2/notebook.cpp          |  8 ++++----
 src/osx/notebook_osx.cpp      |  8 ++++----
 16 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/include/wx/bookctrl.h b/include/wx/bookctrl.h
index 66704cb9a1..228d34f3c2 100644
--- a/include/wx/bookctrl.h
+++ b/include/wx/bookctrl.h
@@ -204,7 +204,7 @@ public:
                             int imageId = -1) = 0;
 
     // set the currently selected page, return the index of the previously
-    // selected one (or -1 on error)
+    // selected one (or wxNOT_FOUND on error)
     //
     // NB: this function will generate PAGE_CHANGING/ED events
     virtual int SetSelection(size_t n) = 0;
@@ -217,7 +217,7 @@ public:
     void AdvanceSelection(bool forward = true)
     {
         int nPage = GetNextPage(forward);
-        if ( nPage != -1 )
+        if ( nPage != wxNOT_FOUND )
         {
             // cast is safe because of the check above
             SetSelection((size_t)nPage);
@@ -353,7 +353,7 @@ class WXDLLIMPEXP_CORE wxBookCtrlEvent : public wxNotifyEvent
 {
 public:
     wxBookCtrlEvent(wxEventType commandType = wxEVT_NULL, int winid = 0,
-                        int nSel = -1, int nOldSel = -1)
+                        int nSel = wxNOT_FOUND, int nOldSel = wxNOT_FOUND)
         : wxNotifyEvent(commandType, winid)
     {
         m_nSel = nSel;
@@ -370,10 +370,10 @@ public:
     virtual wxEvent *Clone() const { return new wxBookCtrlEvent(*this); }
 
     // accessors
-        // the currently selected page (-1 if none)
+        // the currently selected page (wxNOT_FOUND if none)
     int GetSelection() const { return m_nSel; }
     void SetSelection(int nSel) { m_nSel = nSel; }
-        // the page that was selected before the change (-1 if none)
+        // the page that was selected before the change (wxNOT_FOUND if none)
     int GetOldSelection() const { return m_nOldSel; }
     void SetOldSelection(int nOldSel) { m_nOldSel = nOldSel; }
 
diff --git a/include/wx/cocoa/notebook.h b/include/wx/cocoa/notebook.h
index 21e6ad3271..6cc8161ff0 100644
--- a/include/wx/cocoa/notebook.h
+++ b/include/wx/cocoa/notebook.h
@@ -56,7 +56,7 @@ protected:
 // ------------------------------------------------------------------------
 public:
     // set the currently selected page, return the index of the previously
-    // selected one (or -1 on error)
+    // selected one (or wxNOT_FOUND on error)
     int SetSelection(size_t nPage);
     // get the currently selected page
     int GetSelection() const;
diff --git a/include/wx/generic/notebook.h b/include/wx/generic/notebook.h
index 1007d42240..6784c1914b 100644
--- a/include/wx/generic/notebook.h
+++ b/include/wx/generic/notebook.h
@@ -56,11 +56,11 @@ public:
 
   // accessors
   // ---------
-  // Find the position of the wxNotebookPage, -1 if not found.
+  // Find the position of the wxNotebookPage, wxNOT_FOUND if not found.
   int FindPagePosition(wxNotebookPage* page) const;
 
     // set the currently selected page, return the index of the previously
-    // selected one (or -1 on error)
+    // selected one (or wxNOT_FOUND on error)
     // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
   int SetSelection(size_t nPage);
     // cycle thru the tabs
diff --git a/include/wx/gtk/notebook.h b/include/wx/gtk/notebook.h
index 45cb903ea5..67c655b679 100644
--- a/include/wx/gtk/notebook.h
+++ b/include/wx/gtk/notebook.h
@@ -50,7 +50,7 @@ public:
   // ---------
 
     // set the currently selected page, return the index of the previously
-    // selected one (or -1 on error)
+    // selected one (or wxNOT_FOUND on error)
     // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
     int SetSelection(size_t nPage) { return DoSetSelection(nPage, SetSelection_SendEvent); }
     // get the currently selected page
diff --git a/include/wx/gtk1/notebook.h b/include/wx/gtk1/notebook.h
index 112171e148..f5ec7e3a7a 100644
--- a/include/wx/gtk1/notebook.h
+++ b/include/wx/gtk1/notebook.h
@@ -50,7 +50,7 @@ public:
   // ---------
 
     // set the currently selected page, return the index of the previously
-    // selected one (or -1 on error)
+    // selected one (or wxNOT_FOUND on error)
     // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
     int SetSelection(size_t nPage) { return DoSetSelection(nPage, SetSelection_SendEvent); }
     // get the currently selected page
diff --git a/include/wx/msw/notebook.h b/include/wx/msw/notebook.h
index 30fe5c6780..582b613e94 100644
--- a/include/wx/msw/notebook.h
+++ b/include/wx/msw/notebook.h
@@ -86,7 +86,7 @@ public:
   virtual size_t GetPageCount() const;
 
     // set the currently selected page, return the index of the previously
-    // selected one (or -1 on error)
+    // selected one (or wxNOT_FOUND on error)
     // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
   int SetSelection(size_t nPage);
     // get the currently selected page
diff --git a/include/wx/notebook.h b/include/wx/notebook.h
index 96278d07d3..7810274385 100644
--- a/include/wx/notebook.h
+++ b/include/wx/notebook.h
@@ -96,8 +96,8 @@ public:
     bool SendPageChangingEvent(int nPage);
 
     // sends the event about page change from old to new (or GetSelection() if
-    // new is -1)
-    void SendPageChangedEvent(int nPageOld, int nPageNew = -1);
+    // new is wxNOT_FOUND)
+    void SendPageChangedEvent(int nPageOld, int nPageNew = wxNOT_FOUND);
 
     // wxBookCtrlBase overrides this method to return false but we do need
     // focus because we have tabs
diff --git a/include/wx/os2/notebook.h b/include/wx/os2/notebook.h
index 83b964c0bf..0758d59d28 100644
--- a/include/wx/os2/notebook.h
+++ b/include/wx/os2/notebook.h
@@ -61,7 +61,7 @@ public:
 
     //
     // Set the currently selected page, return the index of the previously
-    // selected one (or -1 on error)
+    // selected one (or wxNOT_FOUND on error)
     // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
     //
     int      SetSelection(size_t nPage);
diff --git a/include/wx/osx/notebook.h b/include/wx/osx/notebook.h
index 3be36587ad..04adb74a1a 100644
--- a/include/wx/osx/notebook.h
+++ b/include/wx/osx/notebook.h
@@ -55,7 +55,7 @@ public:
   // accessors
   // ---------
     // set the currently selected page, return the index of the previously
-    // selected one (or -1 on error)
+    // selected one (or wxNOT_FOUND on error)
     // NB: this function will _not_ generate wxEVT_NOTEBOOK_PAGE_xxx events
   int SetSelection(size_t nPage) { return DoSetSelection(nPage, SetSelection_SendEvent); }
     // get the currently selected page
diff --git a/src/cocoa/notebook.mm b/src/cocoa/notebook.mm
index 8291868fab..1b1fd296fd 100644
--- a/src/cocoa/notebook.mm
+++ b/src/cocoa/notebook.mm
@@ -301,7 +301,7 @@ int wxNotebook::GetSelection() const
 {
     NSTabViewItem *selectedItem = [GetNSTabView() selectedTabViewItem];
     if(!selectedItem)
-        return -1;
+        return wxNOT_FOUND;
     return [GetNSTabView() indexOfTabViewItem:selectedItem];
 }
 
diff --git a/src/generic/listbkg.cpp b/src/generic/listbkg.cpp
index bd48126901..d297ff31f3 100644
--- a/src/generic/listbkg.cpp
+++ b/src/generic/listbkg.cpp
@@ -355,16 +355,16 @@ wxListbook::InsertPage(size_t n,
 
     // some page should be selected: either this one or the first one if there
     // is still no selection
-    int selNew = -1;
+    int selNew = wxNOT_FOUND;
     if ( bSelect )
         selNew = n;
-    else if ( m_selection == -1 )
+    else if ( m_selection == wxNOT_FOUND )
         selNew = 0;
 
     if ( selNew != m_selection )
         page->Hide();
 
-    if ( selNew != -1 )
+    if ( selNew != wxNOT_FOUND )
         SetSelection(selNew);
 
     UpdateSize();
@@ -387,7 +387,7 @@ wxWindow *wxListbook::DoRemovePage(size_t page)
             int sel = m_selection - 1;
             if (page_count == 1)
                 sel = wxNOT_FOUND;
-            else if ((page_count == 2) || (sel == -1))
+            else if ((page_count == 2) || (sel == wxNOT_FOUND))
                 sel = 0;
 
             // force sel invalid if deleting current page - don't try to hide it
diff --git a/src/generic/toolbkg.cpp b/src/generic/toolbkg.cpp
index b88e45b9cd..d92bde82bc 100644
--- a/src/generic/toolbkg.cpp
+++ b/src/generic/toolbkg.cpp
@@ -235,13 +235,13 @@ void wxToolbook::Realize()
         GetToolBar()->Realize();
     }
 
-    if (m_selection == -1)
+    if (m_selection == wxNOT_FOUND)
         m_selection = 0;
 
     if (GetPageCount() > 0)
     {
         int sel = m_selection;
-        m_selection = -1;
+        m_selection = wxNOT_FOUND;
         SetSelection(sel);
     }
 
@@ -352,7 +352,7 @@ wxWindow *wxToolbook::DoRemovePage(size_t page)
             int sel = m_selection - 1;
             if (page_count == 1)
                 sel = wxNOT_FOUND;
-            else if ((page_count == 2) || (sel == -1))
+            else if ((page_count == 2) || (sel == wxNOT_FOUND))
                 sel = 0;
 
             // force sel invalid if deleting current page - don't try to hide it
diff --git a/src/gtk/notebook.cpp b/src/gtk/notebook.cpp
index 4802f31fcd..c169d019c2 100644
--- a/src/gtk/notebook.cpp
+++ b/src/gtk/notebook.cpp
@@ -202,7 +202,7 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
 
 int wxNotebook::GetSelection() const
 {
-    wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") );
+    wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid notebook") );
 
     return gtk_notebook_get_current_page( GTK_NOTEBOOK(m_widget) );
 }
@@ -217,7 +217,7 @@ wxString wxNotebook::GetPageText( size_t page ) const
 
 int wxNotebook::GetPageImage( size_t page ) const
 {
-    wxCHECK_MSG(page < GetPageCount(), -1, "invalid notebook index");
+    wxCHECK_MSG(page < GetPageCount(), wxNOT_FOUND, "invalid notebook index");
 
     return GetNotebookPage(page)->m_imageIndex;
 }
@@ -229,7 +229,7 @@ wxGtkNotebookPage* wxNotebook::GetNotebookPage( int page ) const
 
 int wxNotebook::DoSetSelection( size_t page, int flags )
 {
-    wxCHECK_MSG(page < GetPageCount(), -1, "invalid notebook index");
+    wxCHECK_MSG(page < GetPageCount(), wxNOT_FOUND, "invalid notebook index");
 
     int selOld = GetSelection();
 
diff --git a/src/gtk1/notebook.cpp b/src/gtk1/notebook.cpp
index 1b821aad1e..5b2099a4e6 100644
--- a/src/gtk1/notebook.cpp
+++ b/src/gtk1/notebook.cpp
@@ -227,7 +227,7 @@ static gint gtk_notebook_key_press_callback( GtkWidget *widget, GdkEventKey *gdk
     if ((gdk_event->keyval == GDK_Tab) || (gdk_event->keyval == GDK_ISO_Left_Tab))
     {
         int sel = notebook->GetSelection();
-        if (sel == -1)
+        if (sel == wxNOT_FOUND)
             return TRUE;
         wxGtkNotebookPage *nb_page = notebook->GetNotebookPage(sel);
         wxCHECK_MSG( nb_page, FALSE, wxT("invalid selection in wxNotebook") );
@@ -362,9 +362,9 @@ bool wxNotebook::Create(wxWindow *parent, wxWindowID id,
 
 int wxNotebook::GetSelection() const
 {
-    wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") );
+    wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid notebook") );
 
-    if ( m_selection == -1 )
+    if ( m_selection == wxNOT_FOUND )
     {
         GList *nb_pages = GTK_NOTEBOOK(m_widget)->children;
 
@@ -417,7 +417,7 @@ wxGtkNotebookPage* wxNotebook::GetNotebookPage( int page ) const
 
 int wxNotebook::DoSetSelection( size_t page, int flags )
 {
-    wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid notebook") );
+    wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid notebook") );
 
     wxCHECK_MSG( page < m_pagesData.GetCount(), -1, wxT("invalid notebook index") );
 
@@ -597,10 +597,10 @@ bool wxNotebook::DeleteAllPages()
 
 wxNotebookPage *wxNotebook::DoRemovePage( size_t page )
 {
-    if ( m_selection != -1 && (size_t)m_selection >= page )
+    if ( m_selection != wxNOT_FOUND && (size_t)m_selection >= page )
     {
         // the index will become invalid after the page is deleted
-        m_selection = -1;
+        m_selection = wxNOT_FOUND;
     }
 
     wxNotebookPage *client = wxNotebookBase::DoRemovePage(page);
diff --git a/src/os2/notebook.cpp b/src/os2/notebook.cpp
index 9f7df8f3f9..5876c5b5a7 100644
--- a/src/os2/notebook.cpp
+++ b/src/os2/notebook.cpp
@@ -429,7 +429,7 @@ wxNotebookPage* wxNotebook::DoRemovePage ( size_t nPage )
         }
         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
@@ -440,7 +440,7 @@ wxNotebookPage* wxNotebook::DoRemovePage ( size_t nPage )
             m_pages[m_nSelection]->Refresh();
         }
 
-        if (nSelNew != -1)
+        if (nSelNew != wxNOT_FOUND)
         {
             //
             // m_nSelection must be always valid so reset it before calling
@@ -653,14 +653,14 @@ bool wxNotebook::InsertPage ( size_t          nPage,
     // Some page should be selected: either this one or the first one if there is
     // still no selection
     //
-    int nSelNew = -1;
+    int nSelNew = wxNOT_FOUND;
 
     if (bSelect)
         nSelNew = nPage;
     else if ( m_nSelection == -1 )
         nSelNew = 0;
 
-    if (nSelNew != -1)
+    if (nSelNew != wxNOT_FOUND)
         SetSelection(nSelNew);
 
     InvalidateBestSize();
diff --git a/src/osx/notebook_osx.cpp b/src/osx/notebook_osx.cpp
index d78e3b4040..5f8d022044 100644
--- a/src/osx/notebook_osx.cpp
+++ b/src/osx/notebook_osx.cpp
@@ -268,13 +268,13 @@ bool wxNotebook::InsertPage(size_t nPage,
 
     // some page should be selected: either this one or the first one if there
     // is still no selection
-    int selNew = -1;
+    int selNew = wxNOT_FOUND;
     if ( bSelect )
         selNew = nPage;
     else if ( m_nSelection == -1 )
         selNew = 0;
 
-    if ( selNew != -1 )
+    if ( selNew != wxNOT_FOUND )
         SetSelection( selNew );
 
     InvalidateBestSize();
@@ -508,10 +508,10 @@ void wxNotebook::ChangePage(int nOldSel, int nSel)
     if (nOldSel == nSel)
         return;
 
-    if ( nOldSel != -1 )
+    if ( nOldSel != wxNOT_FOUND )
         m_pages[nOldSel]->Show( false );
 
-    if ( nSel != -1 )
+    if ( nSel != wxNOT_FOUND )
     {
         wxNotebookPage *pPage = m_pages[nSel];
         if ( IsShownOnScreen() )
-- 
2.45.2