X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/584ad2a32fec156c6049145d7ece9a33213aea28..a8cb1a4947bbbf5e18ce52448f4c3bb4cff4daee:/src/os2/listbox.cpp diff --git a/src/os2/listbox.cpp b/src/os2/listbox.cpp index 6d56ce1890..475e9f8143 100644 --- a/src/os2/listbox.cpp +++ b/src/os2/listbox.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////////// -// Name: listbox.cpp +// Name: src/os2/listbox.cpp // Purpose: wxListBox // Author: David Webster // Modified by: @@ -49,14 +49,14 @@ class wxListBoxItem : public wxOwnerDrawn { public: - wxListBoxItem(const wxString& rsStr = ""); + wxListBoxItem(const wxString& rsStr = wxEmptyString); }; wxListBoxItem::wxListBoxItem( const wxString& rsStr ) : wxOwnerDrawn( rsStr - ,FALSE + ,false ) { // @@ -65,9 +65,7 @@ wxListBoxItem::wxListBoxItem( SetMarginWidth(0); } // end of wxListBoxItem::wxListBoxItem -wxOwnerDrawn* wxListBox::CreateItem( - size_t n -) +wxOwnerDrawn* wxListBox::CreateItem( size_t WXUNUSED(n) ) { return new wxListBoxItem(); } // end of wxListBox::CreateItem @@ -128,7 +126,7 @@ bool wxListBox::Create( wxSystemSettings vSettings; - SetBackgroundColour(vSettings.GetSystemColour(wxSYS_COLOUR_WINDOW)); + SetBackgroundColour(vSettings.GetColour(wxSYS_COLOUR_WINDOW)); SetForegroundColour(pParent->GetForegroundColour()); m_windowId = (vId == -1) ? (int)NewControlId() : vId; @@ -172,7 +170,7 @@ bool wxListBox::Create( ); if (m_hWnd == 0) { - return FALSE; + return false; } // @@ -194,11 +192,11 @@ bool wxListBox::Create( SetFont(*pTextFont); // - // Set standard wxWindows colors for Listbox items and highlighting + // Set standard wxWidgets colors for Listbox items and highlighting // wxColour vColour; - vColour.Set(wxString("WHITE")); + vColour.Set(wxString(wxT("WHITE"))); LONG lColor = (LONG)vColour.GetPixel(); @@ -207,7 +205,7 @@ bool wxListBox::Create( ,sizeof(LONG) ,(PVOID)&lColor ); - vColour.Set(wxString("NAVY")); + vColour.Set(wxString(wxT("NAVY"))); lColor = (LONG)vColour.GetPixel(); ::WinSetPresParam( m_hWnd ,PP_HILITEBACKGROUNDCOLOR @@ -221,7 +219,7 @@ bool wxListBox::Create( ,nHeight ); delete pTextFont; - return TRUE; + return true; } // end of wxListBox::Create wxListBox::~wxListBox() @@ -281,31 +279,30 @@ int wxListBox::DoAppend( const wxString& rsItem ) { - int nIndex = 0; - SHORT nIndexType = 0; + long lIndex = 0; + LONG lIndexType = 0; if (m_windowStyle & wxLB_SORT) - nIndexType = LIT_SORTASCENDING; + lIndexType = LIT_SORTASCENDING; else - nIndexType = LIT_END; - nIndex = (int)::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)nIndexType, (MPARAM)rsItem.c_str()); + lIndexType = LIT_END; + lIndex = (long)::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)lIndexType, (MPARAM)rsItem.c_str()); m_nNumItems++; #if wxUSE_OWNER_DRAWN if (m_windowStyle & wxLB_OWNERDRAW) { - wxOwnerDrawn* pNewItem = CreateItem(nIndex); // dummy argument + wxOwnerDrawn* pNewItem = CreateItem(lIndex); // dummy argument wxScreenDC vDc; - wxCoord vHeight; pNewItem->SetName(rsItem); - m_aItems.Insert(pNewItem, nIndex); - ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, (MPARAM)((SHORT)nIndex), MPFROMP(pNewItem)); + m_aItems.Insert(pNewItem, lIndex); + ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, (MPARAM)lIndex, MPFROMP(pNewItem)); pNewItem->SetFont(GetFont()); } #endif - return nIndex; + return (int)lIndex; } // end of wxListBox::DoAppend void wxListBox::DoSetItems( @@ -314,9 +311,8 @@ void wxListBox::DoSetItems( ) { BOOL bHideAndShow = IsShown(); - int nCount = 0; int i; - SHORT nIndexType = 0; + LONG lIndexType = 0; if (bHideAndShow) { @@ -328,10 +324,10 @@ void wxListBox::DoSetItems( { if (m_windowStyle & wxLB_SORT) - nIndexType = LIT_SORTASCENDING; + lIndexType = LIT_SORTASCENDING; else - nIndexType = LIT_END; - ::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)nIndexType, (MPARAM)raChoices[i].c_str()); + lIndexType = LIT_END; + ::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)lIndexType, (MPARAM)raChoices[i].c_str()); if (ppClientData) { @@ -368,30 +364,6 @@ void wxListBox::DoSetItems( ::WinShowWindow(GetHwnd(), TRUE); } // end of wxListBox::DoSetItems -int wxListBox::FindString( - const wxString& rsString -) const -{ - int nPos; - LONG lTextLength; - PSZ zStr; - - - for (nPos = 0; nPos < m_nNumItems; nPos++) - { - lTextLength = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)nPos, (MPARAM)0)); - zStr = new char[lTextLength + 1]; - ::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXT, MPFROM2SHORT(nPos, (SHORT)lTextLength), (MPARAM)zStr); - if (rsString == (char*)zStr) - { - delete [] zStr; - break; - } - delete [] zStr; - } - return nPos; -} // end of wxListBox::FindString - void wxListBox::Clear() { #if wxUSE_OWNER_DRAWN @@ -417,7 +389,7 @@ void wxListBox::Clear() m_nNumItems = 0; } // end of wxListBox::Clear -void wxListBox::SetSelection( +void wxListBox::DoSetSelection( int N , bool bSelect ) @@ -437,7 +409,7 @@ bool wxListBox::IsSelected( int N ) const { - wxCHECK_MSG( N >= 0 && N < m_nNumItems, FALSE, + wxCHECK_MSG( N >= 0 && N < m_nNumItems, false, wxT("invalid index in wxListBox::Selected") ); LONG lItem; @@ -510,9 +482,7 @@ bool wxListBox::HasMultipleSelection() const return (m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED); } // end of wxListBox::HasMultipleSelection -int wxListBox::GetSelections( - wxArrayInt& raSelections -) const +int wxListBox::GetSelections( wxArrayInt& raSelections ) const { int nCount = 0; LONG lItem; @@ -559,7 +529,6 @@ int wxListBox::GetSelections( } return nCount; } - return 0; } else // single-selection listbox { @@ -595,14 +564,14 @@ wxString wxListBox::GetString( ) const { LONG lLen = 0; - char* zBuf; + wxChar* zBuf; wxString sResult; - wxCHECK_MSG( N >= 0 && N < m_nNumItems, "", + wxCHECK_MSG( N >= 0 && N < m_nNumItems, wxEmptyString, wxT("invalid index in wxListBox::GetClientData") ); lLen = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)N, (MPARAM)0)); - zBuf = new char[lLen + 1]; + zBuf = new wxChar[lLen + 1]; ::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXT, MPFROM2SHORT((SHORT)N, (SHORT)lLen), (MPARAM)zBuf); zBuf[lLen] = '\0'; sResult = zBuf; @@ -635,7 +604,7 @@ void wxListBox::DoInsertItems( m_aItems.Insert(pNewItem, nIndex); ::WinSendMsg( GetHwnd() ,LM_SETITEMHANDLE - ,(MPARAM)((SHORT)nIndex) + ,(MPARAM)((LONG)nIndex) ,MPFROMP(pNewItem) ); m_nNumItems += nItems; @@ -727,6 +696,7 @@ wxSize wxListBox::DoGetBestSize() const int nListbox = 0; int nCx; int nCy; + wxFont vFont = (wxFont)GetFont(); for (int i = 0; i < m_nNumItems; i++) { @@ -753,7 +723,7 @@ wxSize wxListBox::DoGetBestSize() const wxGetCharSize( GetHWND() ,&nCx ,&nCy - ,(wxFont*)&GetFont() + ,&vFont ); nListbox += 3 * nCx; @@ -778,7 +748,7 @@ bool wxListBox::OS2Command( { eEvtType = wxEVT_COMMAND_LISTBOX_SELECTED; } - if (uParam == LN_ENTER) + else if (uParam == LN_ENTER) { eEvtType = wxEVT_COMMAND_LISTBOX_DOUBLECLICKED; } @@ -787,7 +757,7 @@ bool wxListBox::OS2Command( // // Some event we're not interested in // - return FALSE; + return false; } wxCommandEvent vEvent( eEvtType ,m_windowId @@ -812,7 +782,7 @@ bool wxListBox::OS2Command( { n = -1; } - vEvent.m_commandInt = n; + vEvent.SetInt(n); return GetEventHandler()->ProcessEvent(vEvent); } // end of wxListBox::OS2Command @@ -857,7 +827,7 @@ long wxListBox::OS2OnMeasure( pMeasureStruct->rclItem.yTop = 0; pMeasureStruct->rclItem.yBottom = 0; - vHeight = vDc.GetCharHeight() * 2.5; + vHeight = (wxCoord)(vDc.GetCharHeight() * 2.5); pMeasureStruct->rclItem.yTop = (USHORT)vHeight; return long(MRFROM2SHORT((USHORT)vHeight, (USHORT)vWidth)); @@ -875,14 +845,14 @@ bool wxListBox::OS2OnDraw ( // // Only owner-drawn control should receive this message // - wxCHECK(((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), FALSE); + wxCHECK(((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), false); // // The item may be -1 for an empty listbox // if (lItemID == -1L) - return FALSE; + return false; wxListBoxItem* pData = (wxListBoxItem*)PVOIDFROMMR( ::WinSendMsg( GetHwnd() ,LM_QUERYITEMHANDLE @@ -891,16 +861,12 @@ bool wxListBox::OS2OnDraw ( ) ); - wxCHECK(pData, FALSE ); + wxCHECK(pData, false ); - wxDC vDc; - wxRect vRect( wxPoint( pDrawStruct->rclItem.xLeft - ,pDrawStruct->rclItem.yTop - ) - ,wxPoint( pDrawStruct->rclItem.xRight - ,pDrawStruct->rclItem.yBottom - ) - ); + wxDC vDc; + wxPoint pt1( pDrawStruct->rclItem.xLeft, pDrawStruct->rclItem.yTop ); + wxPoint pt2( pDrawStruct->rclItem.xRight, pDrawStruct->rclItem.yBottom ); + wxRect vRect( pt1, pt2 ); vDc.SetHPS(pDrawStruct->hps); @@ -964,7 +930,7 @@ bool wxListBox::OS2OnDraw ( // For now we don't care about anything else // just ignore the entire message! // - return TRUE; + return true; } } return pData->OnDrawItem( vDc @@ -977,4 +943,3 @@ bool wxListBox::OS2OnDraw ( #endif // ndef for wxUSE_OWNER_DRAWN #endif // ndef for wxUSE_LISTBOX -