]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/notebook.cpp
fixed warnings about truncating 64 bit integers
[wxWidgets.git] / src / os2 / notebook.cpp
index d3620ccc4449e972bba9aee4951fd7bf539affc9..89f0f9d6fd3513bf532393a4ffbefc5b8db48587 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     10/12/99
 // RCS-ID:      $Id$
 // Copyright:   (c) David Webster
-// Licence:     wxWidgets licence
+// Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 
 // For compilers that support precompilation, includes "wx.h".
 // ----------------------------------------------------------------------------
 
 // 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()
@@ -112,14 +116,12 @@ wxNotebook::wxNotebook(
 //
 // 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 )
 {
     //
     // Base init
@@ -132,21 +134,21 @@ bool wxNotebook::Create(
                        ,wxDefaultValidator
                        ,rsName
                       ))
-        return FALSE;
+        return false;
 
     //
     // Notebook, so explicitly specify 0 as last parameter
     //
-    if (!OS2CreateControl( "NOTEBOOK"
-                          ,_T("")
+    if (!OS2CreateControl( wxT("NOTEBOOK")
+                          ,wxEmptyString
                           ,rPos
                           ,rSize
                           ,lStyle | wxTAB_TRAVERSAL
                          ))
-        return FALSE;
+        return false;
 
     SetBackgroundColour(wxColour(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)));
-    return TRUE;
+    return true;
 } // end of wxNotebook::Create
 
 WXDWORD wxNotebook::OS2GetStyle (
@@ -158,7 +160,7 @@ WXDWORD wxNotebook::OS2GetStyle (
                                                                         ,pdwExstyle
                                                                        );
 
-    dwTabStyle |= WS_TABSTOP | BKS_SOLIDBIND | BKS_ROUNDEDTABS | BKS_TABTEXTCENTER;
+    dwTabStyle |= WS_TABSTOP | BKS_SOLIDBIND | BKS_ROUNDEDTABS | BKS_TABTEXTCENTER | BKS_TABBEDDIALOG;
 
     if (lStyle & wxNB_BOTTOM)
         dwTabStyle |= BKS_MAJORTABBOTTOM | BKS_BACKPAGESBL;
@@ -205,9 +207,7 @@ int wxNotebook::GetRowCount() const
                             );
 } // 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") );
 
@@ -240,10 +240,8 @@ int wxNotebook::SetSelection(
     return nPage;
 } // end of wxNotebook::SetSelection
 
-bool wxNotebook::SetPageText(
-  size_t                            nPage
-, const wxString&                   rsStrText
-)
+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
@@ -253,9 +251,7 @@ bool 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];
@@ -280,7 +276,7 @@ wxString wxNotebook::GetPageText (
         return wxEmptyString;
     }
     vBookText.textLen = ulRc + 1; // To get the null terminator
-    vBookText.pString = zBuf;
+    vBookText.pString = (char*)zBuf;
 
     //
     // Now get the actual text
@@ -298,13 +294,11 @@ wxString wxNotebook::GetPageText (
         ulRc = 255L;
 
     vBookText.pString[ulRc] = '\0';
-    sStr = vBookText.pString;
+    sStr = (wxChar*)vBookText.pString;
     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") );
 
@@ -319,12 +313,12 @@ bool wxNotebook::SetPageImage (
 , int                               nImage
 )
 {
-    wxBitmap*                       pBitmap = (wxBitmap*)m_imageList->GetBitmap(nImage);
+    wxBitmap                        vBitmap = (wxBitmap)m_imageList->GetBitmap(nImage);
 
     return (bool)::WinSendMsg( GetHWND()
                               ,BKM_SETTABBITMAP
                               ,MPFROMLONG((ULONG)m_alPageId[nPage])
-                              ,(MPARAM)pBitmap->GetHBITMAP()
+                              ,(MPARAM)vBitmap.GetHBITMAP()
                              );
 } // end of wxNotebook::SetPageImage
 
@@ -332,10 +326,10 @@ void wxNotebook::SetImageList (
   wxImageList*                      pImageList
 )
 {
-    // 
+    //
     // Does not really do anything yet, but at least we need to
     // update the base class.
-    // 
+    //
     wxNotebookBase::SetImageList(pImageList);
 } // end of wxNotebook::SetImageList
 
@@ -346,22 +340,7 @@ void wxNotebook::SetPageSize (
   const wxSize&                     rSize
 )
 {
-    RECTL                           vRect;
-
-    //
-    // Transform the page size into the notebook size
-    //
-    vRect.xLeft   = vRect.yTop = 0;
-    vRect.xRight  = rSize.x;
-    vRect.yBottom = rSize.y;
-
-
-    //
-    // And now set it
-    //
-    SetSize( vRect.xRight - vRect.xLeft
-            ,vRect.yBottom - vRect.yTop
-           );
+    SetSize(rSize);
 } // end of wxNotebook::SetPageSize
 
 void wxNotebook::SetPadding (
@@ -393,11 +372,9 @@ void wxNotebook::SetTabSize (
 //
 // 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;
@@ -478,7 +455,8 @@ bool wxNotebook::DeleteAllPages()
                  ,(MPARAM)BKA_ALL
                 );
     m_nSelection = -1;
-    return TRUE;
+
+    return true;
 } // end of wxNotebook::DeleteAllPages
 
 //
@@ -502,13 +480,11 @@ bool wxNotebook::AddPage (
 //
 // 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;
 
@@ -600,9 +576,9 @@ bool wxNotebook::InsertPage (
     // 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;
@@ -619,7 +595,7 @@ bool wxNotebook::InsertPage (
     //
     // Now set any TAB text
     //
-    if (!rsStrText.IsEmpty())
+    if (!rsStrText.empty())
     {
         if (!SetPageText( nPage
                          ,rsStrText
@@ -671,6 +647,9 @@ bool wxNotebook::InsertPage (
 
     if (nSelNew != -1)
         SetSelection(nSelNew);
+
+    InvalidateBestSize();
+
     return TRUE;
 } // end of wxNotebook::InsertPage
 
@@ -681,20 +660,6 @@ void wxNotebook::OnSize(
   wxSizeEvent&                      rEvent
 )
 {
-    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
 
@@ -871,12 +836,10 @@ bool 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
@@ -892,4 +855,3 @@ bool wxNotebook::OS2OnScroll (
 } // end of wxNotebook::OS2OnScroll
 
 #endif // wxUSE_NOTEBOOK
-