X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c6179a847d8899cceb8880abc2ab2fe9d0244c90..7d09b97f5321d0accd758eb420c008853ad9ec26:/src/os2/listbox.cpp diff --git a/src/os2/listbox.cpp b/src/os2/listbox.cpp index 350cea8f68..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,7 +49,7 @@ class wxListBoxItem : public wxOwnerDrawn { public: - wxListBoxItem(const wxString& rsStr = ""); + wxListBoxItem(const wxString& rsStr = wxEmptyString); }; wxListBoxItem::wxListBoxItem( @@ -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 @@ -198,7 +196,7 @@ bool wxListBox::Create( // 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 @@ -366,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 @@ -508,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; @@ -557,7 +529,6 @@ int wxListBox::GetSelections( } return nCount; } - return 0; } else // single-selection listbox { @@ -593,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; @@ -725,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++) { @@ -751,7 +723,7 @@ wxSize wxListBox::DoGetBestSize() const wxGetCharSize( GetHWND() ,&nCx ,&nCy - ,(wxFont*)&GetFont() + ,&vFont ); nListbox += 3 * nCx; @@ -776,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; } @@ -891,14 +863,10 @@ bool wxListBox::OS2OnDraw ( 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); @@ -975,4 +943,3 @@ bool wxListBox::OS2OnDraw ( #endif // ndef for wxUSE_OWNER_DRAWN #endif // ndef for wxUSE_LISTBOX -