]> git.saurik.com Git - wxWidgets.git/blobdiff - src/univ/notebook.cpp
use the window default colours, not hardcoded ones, in OnSysColourChanged()
[wxWidgets.git] / src / univ / notebook.cpp
index 84c4761c5ff5eba5fbb5cf7ba628cd83eaf08813..68e2ec2e236bd2c0eb04a289d276e27b0cf849e3 100644 (file)
 // headers
 // ----------------------------------------------------------------------------
 
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
     #pragma implementation "univnotebook.h"
 #endif
 
+#ifdef __VMS
+#pragma message disable unscomzer
+#endif
+
 #include "wx/wxprec.h"
 
 #ifdef __BORLANDC__
 // macros
 // ----------------------------------------------------------------------------
 
-#define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((nPage) < GetPageCount()))
+#if 0
+// due to unsigned type nPage is always >= 0
+#define IS_VALID_PAGE(nPage) (((nPage) >= 0) && ((size_t(nPage)) < GetPageCount()))
+#else
+#define IS_VALID_PAGE(nPage) ((size_t(nPage)) < GetPageCount())
+#endif
 
 // ----------------------------------------------------------------------------
 // constants
@@ -133,14 +142,14 @@ bool wxNotebook::Create(wxWindow *parent,
 // wxNotebook page titles and images
 // ----------------------------------------------------------------------------
 
-wxString wxNotebook::GetPageText(int nPage) const
+wxString wxNotebook::GetPageText(size_t nPage) const
 {
     wxCHECK_MSG( IS_VALID_PAGE(nPage), _T(""), _T("invalid notebook page") );
 
     return m_titles[nPage];
 }
 
-bool wxNotebook::SetPageText(int nPage, const wxString& strText)
+bool wxNotebook::SetPageText(size_t nPage, const wxString& strText)
 {
     wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("invalid notebook page") );
 
@@ -163,14 +172,14 @@ bool wxNotebook::SetPageText(int nPage, const wxString& strText)
     return TRUE;
 }
 
-int wxNotebook::GetPageImage(int nPage) const
+int wxNotebook::GetPageImage(size_t nPage) const
 {
     wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, _T("invalid notebook page") );
 
     return m_images[nPage];
 }
 
-bool wxNotebook::SetPageImage(int nPage, int nImage)
+bool wxNotebook::SetPageImage(size_t nPage, int nImage)
 {
     wxCHECK_MSG( IS_VALID_PAGE(nPage), FALSE, _T("invalid notebook page") );
 
@@ -202,7 +211,7 @@ wxNotebook::~wxNotebook()
 // wxNotebook page switching
 // ----------------------------------------------------------------------------
 
-int wxNotebook::SetSelection(int nPage)
+int wxNotebook::SetSelection(size_t nPage)
 {
     wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, _T("invalid notebook page") );
 
@@ -212,6 +221,17 @@ int wxNotebook::SetSelection(int 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() )
+    {
+        // program doesn't allow the page change
+        return m_sel;
+    }
+
     // we need to change m_sel first, before calling RefreshTab() below as
     // otherwise the previously selected tab wouldn't be redrawn properly under
     // wxGTK which calls Refresh() immediately and not during the next event
@@ -255,46 +275,24 @@ int wxNotebook::SetSelection(int nPage)
         m_pages[m_sel]->Show();
     }
 
-    return selOld;
-}
-
-void wxNotebook::ChangePage(int nPage)
-{
-    wxCHECK_RET( IS_VALID_PAGE(nPage), _T("invalid notebook page") );
-
-    if ( (size_t)nPage == m_sel )
-    {
-        // nothing to do
-        return;
-    }
-
-    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() )
-    {
-        // program doesn't allow the page change
-        return;
-    }
-
-    SetSelection(nPage);
-
+    // event handling
     event.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
     GetEventHandler()->ProcessEvent(event);
+
+    return selOld;
 }
 
 // ----------------------------------------------------------------------------
 // wxNotebook pages adding/deleting
 // ----------------------------------------------------------------------------
 
-bool wxNotebook::InsertPage(int nPage,
+bool wxNotebook::InsertPage(size_t nPage,
                             wxNotebookPage *pPage,
                             const wxString& strText,
                             bool bSelect,
                             int imageId)
 {
-    int nPages = GetPageCount();
+    size_t nPages = GetPageCount();
     wxCHECK_MSG( nPage == nPages || IS_VALID_PAGE(nPage), FALSE,
                  _T("invalid notebook page in InsertPage()") );
 
@@ -371,7 +369,7 @@ bool wxNotebook::DeleteAllPages()
     return TRUE;
 }
 
-wxNotebookPage *wxNotebook::DoRemovePage(int nPage)
+wxNotebookPage *wxNotebook::DoRemovePage(size_t nPage)
 {
     wxCHECK_MSG( IS_VALID_PAGE(nPage), NULL, _T("invalid notebook page") );
 
@@ -392,7 +390,7 @@ wxNotebookPage *wxNotebook::DoRemovePage(int nPage)
         UpdateSpinBtn();
     }
 
-    int count = GetPageCount();
+    size_t count = GetPageCount();
     if ( count )
     {
         if ( m_sel == (size_t)nPage )
@@ -1303,11 +1301,11 @@ bool wxNotebook::PerformAction(const wxControlAction& action,
                                const wxString& strArg)
 {
     if ( action == wxACTION_NOTEBOOK_NEXT )
-        ChangePage(GetNextPage(TRUE));
+        SetSelection(GetNextPage(TRUE));
     else if ( action == wxACTION_NOTEBOOK_PREV )
-        ChangePage(GetNextPage(FALSE));
+        SetSelection(GetNextPage(FALSE));
     else if ( action == wxACTION_NOTEBOOK_GOTO )
-        ChangePage((int)numArg);
+        SetSelection((int)numArg);
     else
         return wxControl::PerformAction(action, numArg, strArg);
 
@@ -1400,8 +1398,9 @@ bool wxStdNotebookInputHandler::HandleMouseMove(wxInputConsumer *consumer,
     return wxStdInputHandler::HandleMouseMove(consumer, event);
 }
 
-bool wxStdNotebookInputHandler::HandleFocus(wxInputConsumer *consumer,
-                                            const wxFocusEvent& event)
+bool
+wxStdNotebookInputHandler::HandleFocus(wxInputConsumer *consumer,
+                                       const wxFocusEvent& WXUNUSED(event))
 {
     HandleFocusChange(consumer);