X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0d598bae33dff0e48eebd569aa3d75e95e8d6947..f081c944e891b0cc76ba648982175279bdbce904:/src/os2/notebook.cpp diff --git a/src/os2/notebook.cpp b/src/os2/notebook.cpp index f792c76a60..ee9b6810eb 100644 --- a/src/os2/notebook.cpp +++ b/src/os2/notebook.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: notebook.cpp +// Name: src/os2/notebook.cpp // Purpose: implementation of wxNotebook // Author: David Webster // Modified by: @@ -35,7 +35,11 @@ // ---------------------------------------------------------------------------- // 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() @@ -52,7 +56,7 @@ 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) + EVT_NOTEBOOK_PAGE_CHANGED(wxID_ANY, wxNotebook::OnSelChange) EVT_SIZE(wxNotebook::OnSize) EVT_SET_FOCUS(wxNotebook::OnSetFocus) EVT_NAVIGATION_KEY(wxNotebook::OnNavigationKey) @@ -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 ( @@ -160,11 +162,11 @@ WXDWORD wxNotebook::OS2GetStyle ( dwTabStyle |= WS_TABSTOP | BKS_SOLIDBIND | BKS_ROUNDEDTABS | BKS_TABTEXTCENTER | BKS_TABBEDDIALOG; - if (lStyle & wxNB_BOTTOM) + if (lStyle & wxBK_BOTTOM) dwTabStyle |= BKS_MAJORTABBOTTOM | BKS_BACKPAGESBL; - else if (lStyle & wxNB_RIGHT) + else if (lStyle & wxBK_RIGHT) 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; @@ -205,11 +207,9 @@ 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") ); + wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") ); if (nPage != (size_t)m_nSelection) { @@ -240,12 +240,10 @@ 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") ); + 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]) @@ -253,16 +251,14 @@ 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]; 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 @@ -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,15 +294,13 @@ 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") ); + wxCHECK_MSG( IS_VALID_PAGE(nPage), wxNOT_FOUND, wxT("notebook page out of range") ); // // For OS/2 just return the page @@ -324,7 +318,7 @@ bool wxNotebook::SetPageImage ( return (bool)::WinSendMsg( GetHWND() ,BKM_SETTABBITMAP ,MPFROMLONG((ULONG)m_alPageId[nPage]) - ,(MPARAM)vBitmap.GetHBITMAP() + ,(MPARAM)wxFlipBmp(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 @@ -378,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; @@ -463,7 +455,8 @@ bool wxNotebook::DeleteAllPages() ,(MPARAM)BKA_ALL ); m_nSelection = -1; - return TRUE; + + return true; } // end of wxNotebook::DeleteAllPages // @@ -487,18 +480,16 @@ 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; 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 @@ -524,7 +515,7 @@ bool wxNotebook::InsertPage ( vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); - return FALSE; + return false; } m_alPageId.Insert((long)ulApiPage, nPage); } @@ -542,7 +533,7 @@ bool wxNotebook::InsertPage ( vError = ::WinGetLastError(vHabmain); sError = wxPMErrorToStr(vError); - return FALSE; + return false; } m_alPageId.Insert((long)ulApiPage, nPage); } @@ -557,7 +548,7 @@ bool wxNotebook::InsertPage ( ,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 @@ -585,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; @@ -604,12 +595,12 @@ bool wxNotebook::InsertPage ( // // Now set any TAB text // - if (!rsStrText.IsEmpty()) + if (!rsStrText.empty()) { if (!SetPageText( nPage ,rsStrText )) - return FALSE; + return false; } // @@ -620,7 +611,7 @@ bool wxNotebook::InsertPage ( if (!SetPageImage( nPage ,nImageId )) - return FALSE; + return false; } if (pPage) @@ -628,7 +619,7 @@ bool wxNotebook::InsertPage ( // // 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 @@ -640,14 +631,14 @@ bool wxNotebook::InsertPage ( // // 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; + int nSelNew = -1; if (bSelect) nSelNew = nPage; @@ -659,7 +650,7 @@ bool wxNotebook::InsertPage ( InvalidateBestSize(); - return TRUE; + return true; } // end of wxNotebook::InsertPage // ---------------------------------------------------------------------------- @@ -681,16 +672,16 @@ void wxNotebook::OnSelChange ( // 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]) { - bFound = TRUE; + bFound = true; break; } } @@ -698,17 +689,17 @@ void wxNotebook::OnSelChange ( if (!bFound) return; - m_pages[nSel]->Show(FALSE); + m_pages[nSel]->Show(false); ulOS2Sel = (ULONG)rEvent.GetSelection(); - bFound = FALSE; + bFound = false; for (nSel = 0; nSel < nPageCount; nSel++) { if (ulOS2Sel == (ULONG)m_alPageId[nSel]) { - bFound = TRUE; + bFound = true; break; } } @@ -718,7 +709,7 @@ void wxNotebook::OnSelChange ( wxNotebookPage* pPage = m_pages[nSel]; - pPage->Show(TRUE); + pPage->Show(true); m_nSelection = nSel; } @@ -825,39 +816,33 @@ void wxNotebook::OnNavigationKey ( // // 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 // - wxControl::SetConstraintSizes(FALSE); + wxControl::SetConstraintSizes(false); } // 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 // ---------------------------------------------------------------------------- -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) - return FALSE; + return false; return wxNotebookBase::OS2OnScroll( nOrientation ,wSBCode ,wPos @@ -866,4 +851,3 @@ bool wxNotebook::OS2OnScroll ( } // end of wxNotebook::OS2OnScroll #endif // wxUSE_NOTEBOOK -