]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/listbox.cpp
don't compare invalid iterators/node pointers
[wxWidgets.git] / src / os2 / listbox.cpp
index 8e785dc5d9632401b08a2b2a38e670148caa827d..4a057dea63afee9ad72f9085dcc9e98e296e54ac 100644 (file)
@@ -1,5 +1,5 @@
 ///////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////
-// Name:        listbox.cpp
+// Name:        src/os2/listbox.cpp
 // Purpose:     wxListBox
 // Author:      David Webster
 // Modified by:
 // Purpose:     wxListBox
 // Author:      David Webster
 // Modified by:
@@ -12,6 +12,8 @@
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
+#if wxUSE_LISTBOX
+
 #include "wx/window.h"
 #include "wx/os2/private.h"
 
 #include "wx/window.h"
 #include "wx/os2/private.h"
 
@@ -32,8 +34,6 @@
 #include "wx/dynarray.h"
 #include "wx/log.h"
 
 #include "wx/dynarray.h"
 #include "wx/log.h"
 
-#if wxUSE_LISTBOX
-
 #if wxUSE_OWNER_DRAWN
     #include  "wx/ownerdrw.h"
 #endif
 #if wxUSE_OWNER_DRAWN
     #include  "wx/ownerdrw.h"
 #endif
@@ -49,7 +49,7 @@
 class wxListBoxItem : public wxOwnerDrawn
 {
 public:
 class wxListBoxItem : public wxOwnerDrawn
 {
 public:
-    wxListBoxItem(const wxString& rsStr = "");
+    wxListBoxItem(const wxString& rsStr = wxEmptyString);
 };
 
 wxListBoxItem::wxListBoxItem(
 };
 
 wxListBoxItem::wxListBoxItem(
@@ -65,9 +65,7 @@ wxListBoxItem::wxListBoxItem(
     SetMarginWidth(0);
 } // end of 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
 {
     return new wxListBoxItem();
 } // end of wxListBox::CreateItem
@@ -102,17 +100,15 @@ bool wxListBox::Create(
                   lStyle, rValidator, rsName);
 }
 
                   lStyle, rValidator, rsName);
 }
 
-bool wxListBox::Create(
-  wxWindow*                         pParent
-, wxWindowID                        vId
-, const wxPoint&                    rPos
-, const wxSize&                     rSize
-, int                               n
-, const wxString                    asChoices[]
-, long                              lStyle
-, const wxValidator&                rValidator
-, const wxString&                   rsName
-)
+bool wxListBox::Create( wxWindow* pParent,
+                        wxWindowID vId,
+                        const wxPoint& rPos,
+                        const wxSize& rSize,
+                        int n,
+                        const wxString asChoices[],
+                        long lStyle,
+                        const wxValidator& rValidator,
+                        const wxString& rsName )
 {
     m_nNumItems = 0;
     m_hWnd      = 0;
 {
     m_nNumItems = 0;
     m_hWnd      = 0;
@@ -194,11 +190,11 @@ bool wxListBox::Create(
     SetFont(*pTextFont);
 
     //
     SetFont(*pTextFont);
 
     //
-    // Set standard wxWidgets colors for Listbox items and highlighting
+    // Set OS/2 system colours for Listbox items and highlighting
     //
     wxColour                        vColour;
 
     //
     wxColour                        vColour;
 
-    vColour.Set(wxString("WHITE"));
+    vColour = wxSystemSettingsNative::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
 
     LONG                            lColor = (LONG)vColour.GetPixel();
 
 
     LONG                            lColor = (LONG)vColour.GetPixel();
 
@@ -207,7 +203,7 @@ bool wxListBox::Create(
                       ,sizeof(LONG)
                       ,(PVOID)&lColor
                      );
                       ,sizeof(LONG)
                       ,(PVOID)&lColor
                      );
-    vColour.Set(wxString("NAVY"));
+    vColour = wxSystemSettingsNative::GetColour(wxSYS_COLOUR_HIGHLIGHT);
     lColor = (LONG)vColour.GetPixel();
     ::WinSetPresParam( m_hWnd
                       ,PP_HILITEBACKGROUNDCOLOR
     lColor = (LONG)vColour.GetPixel();
     ::WinSetPresParam( m_hWnd
                       ,PP_HILITEBACKGROUNDCOLOR
@@ -215,6 +211,8 @@ bool wxListBox::Create(
                       ,(PVOID)&lColor
                      );
 
                       ,(PVOID)&lColor
                      );
 
+    SetXComp(0);
+    SetYComp(0);
     SetSize( nX
             ,nY
             ,nWidth
     SetSize( nX
             ,nY
             ,nWidth
@@ -227,7 +225,7 @@ bool wxListBox::Create(
 wxListBox::~wxListBox()
 {
 #if wxUSE_OWNER_DRAWN
 wxListBox::~wxListBox()
 {
 #if wxUSE_OWNER_DRAWN
-    size_t                          lUiCount = m_aItems.Count();
+    size_t lUiCount = m_aItems.Count();
 
     while (lUiCount-- != 0)
     {
 
     while (lUiCount-- != 0)
     {
@@ -246,21 +244,17 @@ void wxListBox::SetupColours()
 // implementation of wxListBoxBase methods
 // ----------------------------------------------------------------------------
 
 // implementation of wxListBoxBase methods
 // ----------------------------------------------------------------------------
 
-void wxListBox::DoSetFirstItem(
-  int                               N
-)
+void wxListBox::DoSetFirstItem(int N)
 {
 {
-    wxCHECK_RET( N >= 0 && N < m_nNumItems,
+    wxCHECK_RET( IsValid(N),
                  wxT("invalid index in wxListBox::SetFirstItem") );
 
     ::WinSendMsg(GetHwnd(), LM_SETTOPINDEX, MPFROMLONG(N), (MPARAM)0);
 } // end of wxListBox::DoSetFirstItem
 
                  wxT("invalid index in wxListBox::SetFirstItem") );
 
     ::WinSendMsg(GetHwnd(), LM_SETTOPINDEX, MPFROMLONG(N), (MPARAM)0);
 } // end of wxListBox::DoSetFirstItem
 
-void wxListBox::Delete(
-  int                               N
-)
+void wxListBox::Delete(int N)
 {
 {
-    wxCHECK_RET( N >= 0 && N < m_nNumItems,
+    wxCHECK_RET( IsValid(N),
                  wxT("invalid index in wxListBox::Delete") );
 
 #if wxUSE_OWNER_DRAWN
                  wxT("invalid index in wxListBox::Delete") );
 
 #if wxUSE_OWNER_DRAWN
@@ -277,17 +271,16 @@ void wxListBox::Delete(
     m_nNumItems--;
 } // end of wxListBox::DoSetFirstItem
 
     m_nNumItems--;
 } // end of wxListBox::DoSetFirstItem
 
-int wxListBox::DoAppend(
-  const wxString&                   rsItem
-)
+int wxListBox::DoAppend(const wxString& rsItem)
 {
 {
-    long                            lIndex = 0;
-    LONG                            lIndexType = 0;
+    long lIndex = 0;
+    LONG lIndexType = 0;
 
     if (m_windowStyle & wxLB_SORT)
         lIndexType = LIT_SORTASCENDING;
     else
         lIndexType = LIT_END;
 
     if (m_windowStyle & wxLB_SORT)
         lIndexType = LIT_SORTASCENDING;
     else
         lIndexType = LIT_END;
+
     lIndex = (long)::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)lIndexType, (MPARAM)rsItem.c_str());
     m_nNumItems++;
 
     lIndex = (long)::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)lIndexType, (MPARAM)rsItem.c_str());
     m_nNumItems++;
 
@@ -307,14 +300,11 @@ int wxListBox::DoAppend(
     return (int)lIndex;
 } // end of wxListBox::DoAppend
 
     return (int)lIndex;
 } // end of wxListBox::DoAppend
 
-void wxListBox::DoSetItems(
-  const wxArrayString&              raChoices
-, void**                            ppClientData
-)
+void wxListBox::DoSetItems( const wxArrayString& raChoices,
+                            void** ppClientData )
 {
 {
-    BOOL                            bHideAndShow = IsShown();
-    int                             i;
-    LONG                            lIndexType = 0;
+    BOOL bHideAndShow = IsShown();
+    LONG lIndexType = 0;
 
     if (bHideAndShow)
     {
 
     if (bHideAndShow)
     {
@@ -322,9 +312,8 @@ void wxListBox::DoSetItems(
     }
     ::WinSendMsg(GetHwnd(), LM_DELETEALL, (MPARAM)0, (MPARAM)0);
     m_nNumItems = raChoices.GetCount();
     }
     ::WinSendMsg(GetHwnd(), LM_DELETEALL, (MPARAM)0, (MPARAM)0);
     m_nNumItems = raChoices.GetCount();
-    for (i = 0; i < m_nNumItems; i++)
+    for (size_t i = 0; i < m_nNumItems; i++)
     {
     {
-
         if (m_windowStyle & wxLB_SORT)
             lIndexType = LIT_SORTASCENDING;
         else
         if (m_windowStyle & wxLB_SORT)
             lIndexType = LIT_SORTASCENDING;
         else
@@ -353,7 +342,7 @@ void wxListBox::DoSetItems(
         //
         // Then create new ones
         //
         //
         // Then create new ones
         //
-        for (size_t ui = 0; ui < (size_t)m_nNumItems; ui++)
+        for (size_t ui = 0; ui < m_nNumItems; ui++)
         {
             wxOwnerDrawn*           pNewItem = CreateItem(ui);
 
         {
             wxOwnerDrawn*           pNewItem = CreateItem(ui);
 
@@ -366,34 +355,10 @@ void wxListBox::DoSetItems(
     ::WinShowWindow(GetHwnd(), TRUE);
 } // end of 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
 void wxListBox::Clear()
 {
 #if wxUSE_OWNER_DRAWN
-    size_t                          lUiCount = m_aItems.Count();
+    size_t lUiCount = m_aItems.Count();
 
     while (lUiCount-- != 0)
     {
 
     while (lUiCount-- != 0)
     {
@@ -415,12 +380,9 @@ void wxListBox::Clear()
     m_nNumItems = 0;
 } // end of wxListBox::Clear
 
     m_nNumItems = 0;
 } // end of wxListBox::Clear
 
-void wxListBox::SetSelection(
-  int                               N
-, bool                              bSelect
-)
+void wxListBox::DoSetSelection( int N, bool bSelect)
 {
 {
-    wxCHECK_RET( N >= 0 && N < m_nNumItems,
+    wxCHECK_RET( IsValid(N),
                  wxT("invalid index in wxListBox::SetSelection") );
     ::WinSendMsg( GetHwnd()
                  ,LM_SELECTITEM
                  wxT("invalid index in wxListBox::SetSelection") );
     ::WinSendMsg( GetHwnd()
                  ,LM_SELECTITEM
@@ -431,11 +393,9 @@ void wxListBox::SetSelection(
         Refresh();
 } // end of wxListBox::SetSelection
 
         Refresh();
 } // end of wxListBox::SetSelection
 
-bool wxListBox::IsSelected(
-  int                               N
-) const
+bool wxListBox::IsSelected( int N ) const
 {
 {
-    wxCHECK_MSG( N >= 0 && N < m_nNumItems, false,
+    wxCHECK_MSG( IsValid(N), false,
                  wxT("invalid index in wxListBox::Selected") );
 
     LONG                            lItem;
                  wxT("invalid index in wxListBox::Selected") );
 
     LONG                            lItem;
@@ -454,39 +414,27 @@ bool wxListBox::IsSelected(
     return (lItem == (LONG)N && lItem != LIT_NONE);
 } // end of wxListBox::IsSelected
 
     return (lItem == (LONG)N && lItem != LIT_NONE);
 } // end of wxListBox::IsSelected
 
-wxClientData* wxListBox::DoGetItemClientObject(
-  int                               n
-) const
+wxClientData* wxListBox::DoGetItemClientObject(int n) const
 {
     return (wxClientData *)DoGetItemClientData(n);
 }
 
 {
     return (wxClientData *)DoGetItemClientData(n);
 }
 
-void* wxListBox::DoGetItemClientData(
-  int                               n
-) const
+void* wxListBox::DoGetItemClientData(int n) const
 {
 {
-    wxCHECK_MSG( n >= 0 && n < m_nNumItems, NULL,
+    wxCHECK_MSG( IsValid(n), NULL,
                  wxT("invalid index in wxListBox::GetClientData") );
 
     return((void *)::WinSendMsg(GetHwnd(), LM_QUERYITEMHANDLE, MPFROMLONG(n), (MPARAM)0));
 } // end of wxListBox::DoGetItemClientData
 
                  wxT("invalid index in wxListBox::GetClientData") );
 
     return((void *)::WinSendMsg(GetHwnd(), LM_QUERYITEMHANDLE, MPFROMLONG(n), (MPARAM)0));
 } // end of wxListBox::DoGetItemClientData
 
-void wxListBox::DoSetItemClientObject(
-  int                               n
-, wxClientData*                     pClientData
-)
+void wxListBox::DoSetItemClientObject(int n, wxClientData* pClientData)
 {
 {
-    DoSetItemClientData( n
-                        ,pClientData
-                       );
+    DoSetItemClientData(n, pClientData);
 } // end of wxListBox::DoSetItemClientObject
 
 } // end of wxListBox::DoSetItemClientObject
 
-void wxListBox::DoSetItemClientData(
-  int                               n
-, void*                             pClientData
-)
+void wxListBox::DoSetItemClientData(int n, void* pClientData)
 {
 {
-    wxCHECK_RET( n >= 0 && n < m_nNumItems,
+    wxCHECK_RET( IsValid(n),
                  wxT("invalid index in wxListBox::SetClientData") );
 
 #if wxUSE_OWNER_DRAWN
                  wxT("invalid index in wxListBox::SetClientData") );
 
 #if wxUSE_OWNER_DRAWN
@@ -508,12 +456,10 @@ bool wxListBox::HasMultipleSelection() const
     return (m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED);
 } // end of wxListBox::HasMultipleSelection
 
     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;
+    int  nCount = 0;
+    LONG lItem;
 
 
     raSelections.Empty();
 
 
     raSelections.Empty();
@@ -557,7 +503,6 @@ int wxListBox::GetSelections(
             }
             return nCount;
         }
             }
             return nCount;
         }
-        return 0;
     }
     else  // single-selection listbox
     {
     }
     else  // single-selection listbox
     {
@@ -588,19 +533,17 @@ int wxListBox::GetSelection() const
                      ));
 } // end of wxListBox::GetSelection
 
                      ));
 } // end of wxListBox::GetSelection
 
-wxString wxListBox::GetString(
-  int                               N
-) const
+wxString wxListBox::GetString( int N ) const
 {
 {
-    LONG                            lLen = 0;
-    char*                           zBuf;
-    wxString                        sResult;
+    LONG     lLen = 0;
+    wxChar*  zBuf;
+    wxString sResult;
 
 
-    wxCHECK_MSG( N >= 0 && N < m_nNumItems, "",
+    wxCHECK_MSG( IsValid(N), wxEmptyString,
                  wxT("invalid index in wxListBox::GetClientData") );
 
     lLen = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)N, (MPARAM)0));
                  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;
     ::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXT, MPFROM2SHORT((SHORT)N, (SHORT)lLen), (MPARAM)zBuf);
     zBuf[lLen] = '\0';
     sResult = zBuf;
@@ -608,25 +551,22 @@ wxString wxListBox::GetString(
     return sResult;
 } // end of wxListBox::GetString
 
     return sResult;
 } // end of wxListBox::GetString
 
-void wxListBox::DoInsertItems(
-  const wxArrayString&              asItems
-, int                               nPos
-)
+void wxListBox::DoInsertItems( const wxArrayString& asItems,
+                               int nPos )
 {
 {
-    wxCHECK_RET( nPos >= 0 && nPos <= m_nNumItems,
+    wxCHECK_RET( IsValidInsert(nPos),
                  wxT("invalid index in wxListBox::InsertItems") );
 
                  wxT("invalid index in wxListBox::InsertItems") );
 
-    int                             nItems = asItems.GetCount();
+    size_t nItems = asItems.GetCount();
 
 
-    for (int i = 0; i < nItems; i++)
+    for (size_t i = 0; i < nItems; i++)
     {
     {
-        int                         nIndex = (int)::WinSendMsg( GetHwnd()
-                                                               ,LM_INSERTITEM
-                                                               ,MPFROMLONG((LONG)(i + nPos))
-                                                               ,(MPARAM)asItems[i].c_str()
-                                                              );
+        int nIndex = (int)::WinSendMsg( GetHwnd(),
+                                        LM_INSERTITEM,
+                                        MPFROMLONG((LONG)(i + nPos)),
+                                        (MPARAM)asItems[i].c_str() );
 
 
-        wxOwnerDrawn*               pNewItem = CreateItem(nIndex);
+        wxOwnerDrawn* pNewItem = CreateItem(nIndex);
 
         pNewItem->SetName(asItems[i]);
         pNewItem->SetFont(GetFont());
 
         pNewItem->SetName(asItems[i]);
         pNewItem->SetFont(GetFont());
@@ -640,20 +580,17 @@ void wxListBox::DoInsertItems(
     }
 } // end of wxListBox::DoInsertItems
 
     }
 } // end of wxListBox::DoInsertItems
 
-void wxListBox::SetString(
-  int                               N
-, const wxString&                   rsString
-)
+void wxListBox::SetString(int N, const wxString& rsString)
 {
 {
-    wxCHECK_RET( N >= 0 && N < m_nNumItems,
+    wxCHECK_RET( IsValid(N),
                  wxT("invalid index in wxListBox::SetString") );
 
     //
     // Remember the state of the item
     //
                  wxT("invalid index in wxListBox::SetString") );
 
     //
     // Remember the state of the item
     //
-    bool                            bWasSelected = IsSelected(N);
-    void*                           pOldData = NULL;
-    wxClientData*                   pOldObjData = NULL;
+    bool           bWasSelected = IsSelected(N);
+    void*          pOldData = NULL;
+    wxClientData*  pOldObjData = NULL;
 
     if (m_clientDataItemsType == wxClientData_Void)
         pOldData = GetClientData(N);
 
     if (m_clientDataItemsType == wxClientData_Void)
         pOldData = GetClientData(N);
@@ -671,7 +608,7 @@ void wxListBox::SetString(
 
     int                             nNewN = N;
 
 
     int                             nNewN = N;
 
-    if (N == m_nNumItems - 1)
+    if (N == (int)(m_nNumItems - 1))
         nNewN = -1;
 
     ::WinSendMsg( GetHwnd()
         nNewN = -1;
 
     ::WinSendMsg( GetHwnd()
@@ -707,7 +644,7 @@ void wxListBox::SetString(
 #endif  //USE_OWNER_DRAWN
 } // end of wxListBox::SetString
 
 #endif  //USE_OWNER_DRAWN
 } // end of wxListBox::SetString
 
-int wxListBox::GetCount() const
+size_t wxListBox::GetCount() const
 {
     return m_nNumItems;
 }
 {
     return m_nNumItems;
 }
@@ -721,19 +658,17 @@ wxSize wxListBox::DoGetBestSize() const
     //
     // Find the widest string
     //
     //
     // Find the widest string
     //
-    int                             nLine;
-    int                             nListbox = 0;
-    int                             nCx;
-    int                             nCy;
+    int        nLine;
+    int        nListbox = 0;
+    int        nCx;
+    int        nCy;
+    wxFont     vFont = (wxFont)GetFont();
 
 
-    for (int i = 0; i < m_nNumItems; i++)
+    for (size_t i = 0; i < m_nNumItems; i++)
     {
     {
-        wxString                    vStr(GetString(i));
+        wxString vStr(GetString(i));
 
 
-        GetTextExtent( vStr
-                      ,&nLine
-                      ,NULL
-                     );
+        GetTextExtent( vStr, &nLine, NULL );
         if (nLine > nListbox)
             nListbox = nLine;
     }
         if (nLine > nListbox)
             nListbox = nLine;
     }
@@ -751,11 +686,11 @@ wxSize wxListBox::DoGetBestSize() const
     wxGetCharSize( GetHWND()
                   ,&nCx
                   ,&nCy
     wxGetCharSize( GetHWND()
                   ,&nCx
                   ,&nCy
-                  ,(wxFont*)&GetFont()
+                  ,&vFont
                  );
     nListbox += 3 * nCx;
 
                  );
     nListbox += 3 * nCx;
 
-    int                             hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy) * (wxMax(m_nNumItems, 7));
+    int hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(nCy) * (wxMax(m_nNumItems, 7));
 
     return wxSize( nListbox
                   ,hListbox
 
     return wxSize( nListbox
                   ,hListbox
@@ -776,7 +711,7 @@ bool wxListBox::OS2Command(
     {
         eEvtType = wxEVT_COMMAND_LISTBOX_SELECTED;
     }
     {
         eEvtType = wxEVT_COMMAND_LISTBOX_SELECTED;
     }
-    if (uParam == LN_ENTER)
+    else if (uParam == LN_ENTER)
     {
         eEvtType = wxEVT_COMMAND_LISTBOX_DOUBLECLICKED;
     }
     {
         eEvtType = wxEVT_COMMAND_LISTBOX_DOUBLECLICKED;
     }
@@ -793,9 +728,9 @@ bool wxListBox::OS2Command(
 
     vEvent.SetEventObject(this);
 
 
     vEvent.SetEventObject(this);
 
-    wxArrayInt                      aSelections;
-    int                             n;
-    int                             nCount = GetSelections(aSelections);
+    wxArrayInt aSelections;
+    int        n;
+    int        nCount = GetSelections(aSelections);
 
     if (nCount > 0)
     {
 
     if (nCount > 0)
     {
@@ -826,9 +761,7 @@ bool wxListBox::OS2Command(
 //
 #define OWNER_DRAWN_LISTBOX_EXTRA_SPACE    (1)
 
 //
 #define OWNER_DRAWN_LISTBOX_EXTRA_SPACE    (1)
 
-long wxListBox::OS2OnMeasure(
-  WXMEASUREITEMSTRUCT*              pItem
-)
+long wxListBox::OS2OnMeasure(WXMEASUREITEMSTRUCT* pItem)
 {
     if (!pItem)
         pItem = (WXMEASUREITEMSTRUCT*)new OWNERITEM;
 {
     if (!pItem)
         pItem = (WXMEASUREITEMSTRUCT*)new OWNERITEM;
@@ -891,14 +824,10 @@ 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);
 
 
     vDc.SetHPS(pDrawStruct->hps);
 
@@ -974,5 +903,4 @@ bool wxListBox::OS2OnDraw (
 
 #endif // ndef for wxUSE_OWNER_DRAWN
 
 
 #endif // ndef for wxUSE_OWNER_DRAWN
 
-#endif // ndef for wxUSE_LISTBOX
-
+#endif // wxUSE_LISTBOX