]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/notebook.cpp
compositing and transtion changes
[wxWidgets.git] / src / os2 / notebook.cpp
index 7cfd92ab124e2a409467f826e0a85a58047d7777..59818d3529fea37391b2dbe2164a5166be1f8c55 100644 (file)
 
 // wxWindows
 #ifndef WX_PRECOMP
-  #include  "wx/string.h"
+  #include "wx/app.h"
+  #include "wx/dcclient.h"
+  #include "wx/string.h"
+  #include "wx/settings.h"
 #endif  // WX_PRECOMP
 
 #include  "wx/log.h"
@@ -184,7 +187,7 @@ WXDWORD wxNotebook::OS2GetStyle (
 // wxNotebook accessors
 // ----------------------------------------------------------------------------
 
-int wxNotebook::GetPageCount() const
+size_t wxNotebook::GetPageCount() const
 {
     int                             nPageInternal = m_pages.Count();
     int                             nPageAPI = (int)::WinSendMsg(GetHWND(), BKM_QUERYPAGECOUNT, (MPARAM)0, (MPARAM)BKA_END);
@@ -206,29 +209,44 @@ int wxNotebook::GetRowCount() const
 } // end of wxNotebook::GetRowCount
 
 int wxNotebook::SetSelection(
-  int                               nPage
+  size_t                            nPage
 )
 {
     wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
-    int                             nOldPage = GetSelection();
 
-    ChangePage( m_nSelection
-               ,nPage
-              );
+    if (nPage != m_nSelection)
+    {
+        wxNotebookEvent             vEvent( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
+                                           ,m_windowId
+                                          );
 
-    ULONG                           ulPageId = (ULONG)m_alPageId[nPage];
+        vEvent.SetSelection(nPage);
+        vEvent.SetOldSelection(m_nSelection);
+        vEvent.SetEventObject(this);
+        if (!GetEventHandler()->ProcessEvent(vEvent) || vEvent.IsAllowed())
+        {
 
-    ::WinSendMsg( GetHWND()
-                 ,BKM_TURNTOPAGE
-                 ,MPFROMLONG((ULONG)m_alPageId[nPage])
-                 ,(MPARAM)0
-                );
+            //
+            // Program allows the page change
+            //
+            vEvent.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
+            GetEventHandler()->ProcessEvent(vEvent);
+
+            ULONG                   ulPageId = (ULONG)m_alPageId[nPage];
+
+            ::WinSendMsg( GetHWND()
+                         ,BKM_TURNTOPAGE
+                         ,MPFROMLONG((ULONG)m_alPageId[nPage])
+                         ,(MPARAM)0
+                        );
+        }
+    }
     m_nSelection = nPage;
     return nPage;
 } // end of wxNotebook::SetSelection
 
 bool wxNotebook::SetPageText(
-  int                               nPage
+  size_t                            nPage
 , const wxString&                   rsStrText
 )
 {
@@ -245,7 +263,7 @@ bool wxNotebook::SetPageText(
 } // end of wxNotebook::SetPageText
 
 wxString wxNotebook::GetPageText (
-  int                               nPage
+  size_t                            nPage
 ) const
 {
     BOOKTEXT                        vBookText;
@@ -297,7 +315,7 @@ wxString wxNotebook::GetPageText (
 } // end of wxNotebook::GetPageText
 
 int wxNotebook::GetPageImage (
-  int                               nPage
+  size_t                            nPage
 ) const
 {
     wxCHECK_MSG( IS_VALID_PAGE(nPage), -1, wxT("notebook page out of range") );
@@ -309,7 +327,7 @@ int wxNotebook::GetPageImage (
 } // end of wxNotebook::GetPageImage
 
 bool wxNotebook::SetPageImage (
-  int                               nPage
+  size_t                            nPage
 , int                               nImage
 )
 {
@@ -389,7 +407,7 @@ void wxNotebook::SetTabSize (
 // Remove one page from the notebook, without deleting
 //
 wxNotebookPage* wxNotebook::DoRemovePage (
-  int                               nPage
+  size_t                            nPage
 )
 {
     wxNotebookPage*                 pPageRemoved = wxNotebookBase::DoRemovePage(nPage);
@@ -501,7 +519,7 @@ bool wxNotebook::AddPage (
 // Same as AddPage() but does it at given position
 //
 bool wxNotebook::InsertPage (
-  int                               nPage
+  size_t                            nPage
 , wxNotebookPage*                   pPage
 , const wxString&                   rsStrText
 , bool                              bSelect
@@ -679,8 +697,20 @@ void wxNotebook::OnSize(
   wxSizeEvent&                      rEvent
 )
 {
-    if (m_nSelection < m_pages.Count() && m_nSelection >= 0)
-        m_pages[m_nSelection]->Refresh();
+    int                             nPage;
+    int                             nCount = (int)m_pages.Count();
+
+    for (nPage = 0; nPage < nCount; nPage++)
+    {
+        if (m_nSelection == nPage)
+            m_pages[nPage]->Refresh();
+        else
+            ::WinSetWindowPos(m_pages[nPage]->GetHWND()
+                              ,NULLHANDLE
+                              ,0,0,0,0
+                              ,SWP_HIDE
+                             );
+    }
     rEvent.Skip();
 } // end of wxNotebook::OnSize
 
@@ -693,22 +723,44 @@ void wxNotebook::OnSelChange (
     //
     if (rEvent.GetEventObject() == this)
     {
-        int                         nSel = rEvent.GetOldSelection();
+        int                         nPageCount = GetPageCount();
+        int                         nSel;
+        ULONG                       ulOS2Sel = (ULONG)rEvent.GetOldSelection();
+        bool                        bFound = FALSE;
 
-        if (nSel != -1)
+        for (nSel = 0; nSel < nPageCount; nSel++)
         {
-            m_pages[nSel]->Show(FALSE);
-            m_pages[nSel]->SetActivePage(FALSE);
+            if (ulOS2Sel == m_alPageId[nSel])
+            {
+                bFound = TRUE;
+                break;
+            }
         }
-        nSel = rEvent.GetSelection();
-        if (nSel != -1)
-        {
-            wxNotebookPage*         pPage = m_pages[nSel];
 
-            pPage->Show(TRUE);
-            pPage->SetFocus();
-            m_pages[nSel]->SetActivePage(TRUE);
+        if (!bFound)
+            return;
+
+        m_pages[nSel]->Show(FALSE);
+
+        ulOS2Sel = (ULONG)rEvent.GetSelection();
+
+        bFound = FALSE;
+
+        for (nSel = 0; nSel < nPageCount; nSel++)
+        {
+            if (ulOS2Sel == m_alPageId[nSel])
+            {
+                bFound = TRUE;
+                break;
+            }
         }
+
+        if (!bFound)
+            return;
+
+        wxNotebookPage*         pPage = m_pages[nSel];
+
+        pPage->Show(TRUE);
         m_nSelection = nSel;
     }
 
@@ -855,56 +907,5 @@ bool wxNotebook::OS2OnScroll (
                                       );
 } // end of wxNotebook::OS2OnScroll
 
-// ----------------------------------------------------------------------------
-// wxNotebook helper functions
-// ----------------------------------------------------------------------------
-
-//
-// Generate the page changing and changed events, hide the currently active
-// panel and show the new one
-//
-void wxNotebook::ChangePage (
-  int                               nOldSel
-, int                               nSel
-)
-{
-    static bool                     sbInsideChangePage = FALSE;
-
-    //
-    // When we call ProcessEvent(), our own OnSelChange() is called which calls
-    // this function - break the infinite loop
-    //
-    if (sbInsideChangePage)
-        return;
-
-    //
-    // It's not an error (the message may be generated by the tab control itself)
-    // and it may happen - just do nothing
-    //
-    if (nSel == nOldSel)
-        return;
-
-    sbInsideChangePage = TRUE;
-
-    wxNotebookEvent                 rEvent( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGING
-                                           ,m_windowId
-                                          );
-
-    rEvent.SetSelection(nSel);
-    rEvent.SetOldSelection(nOldSel);
-    rEvent.SetEventObject(this);
-    if (GetEventHandler()->ProcessEvent(rEvent) && !rEvent.IsAllowed())
-    {
-        //
-        // Program doesn't allow the page change
-        //
-        sbInsideChangePage = FALSE;
-        return;
-    }
-    rEvent.SetEventType(wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED);
-    GetEventHandler()->ProcessEvent(rEvent);
-    sbInsideChangePage = FALSE;
-} // end of wxNotebook::ChangePage
-
 #endif // wxUSE_NOTEBOOK