]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/listbox.cpp
nschars is never used for the wxEVT_CHAR case, so don't assign it a different value...
[wxWidgets.git] / src / os2 / listbox.cpp
index cd7946293414a799446b9112ad98aac928896692..ada1db3c6c1a77454077f898ce6bfc99d55db4b4 100644 (file)
 // For compilers that support precompilation, includes "wx.h".
 #include "wx/wxprec.h"
 
-#include "wx/window.h"
-#include "wx/os2/private.h"
+#if wxUSE_LISTBOX
 
-#ifndef WX_PRECOMP
 #include "wx/listbox.h"
-#include "wx/settings.h"
-#include "wx/brush.h"
-#include "wx/font.h"
-#include "wx/dc.h"
-#include "wx/dcscreen.h"
-#include "wx/utils.h"
-#include "wx/scrolwin.h"
+
+#ifndef WX_PRECOMP
+    #include "wx/dynarray.h"
+    #include "wx/settings.h"
+    #include "wx/brush.h"
+    #include "wx/font.h"
+    #include "wx/dc.h"
+    #include "wx/dcscreen.h"
+    #include "wx/utils.h"
+    #include "wx/scrolwin.h"
+    #include "wx/log.h"
+    #include "wx/window.h"
 #endif
 
+#include "wx/os2/dcclient.h"
+#include "wx/os2/private.h"
+
 #define INCL_M
 #include <os2.h>
 
-#include "wx/dynarray.h"
-#include "wx/log.h"
-
-#if wxUSE_LISTBOX
-
 #if wxUSE_OWNER_DRAWN
     #include  "wx/ownerdrw.h"
 #endif
 
-  IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControl)
+IMPLEMENT_DYNAMIC_CLASS(wxListBox, wxControlWithItems)
 
 // ============================================================================
 // list box item declaration and implementation
 class wxListBoxItem : public wxOwnerDrawn
 {
 public:
-    wxListBoxItem(const wxString& rsStr = wxEmptyString);
-};
+    wxListBoxItem(wxListBox *parent)
+        { m_parent = parent; }
 
-wxListBoxItem::wxListBoxItem(
-  const wxString& rsStr
-)
-: wxOwnerDrawn( rsStr
-               ,false
-              )
-{
-    //
-    // No bitmaps/checkmarks
-    //
-    SetMarginWidth(0);
-} // end of wxListBoxItem::wxListBoxItem
+    wxListBox *GetParent() const
+        { return m_parent; }
+
+    int GetIndex() const
+        { return m_parent->GetItemIndex(const_cast<wxListBoxItem*>(this)); }
+
+    wxString GetName() const
+        { return m_parent->GetString(GetIndex()); }
+
+private:
+    wxListBox *m_parent;
+};
 
 wxOwnerDrawn* wxListBox::CreateItem( size_t WXUNUSED(n) )
 {
-    return new wxListBoxItem();
+    return new wxListBoxItem(this);
 } // end of wxListBox::CreateItem
 
 #endif  //USE_OWNER_DRAWN
@@ -100,17 +101,15 @@ bool wxListBox::Create(
                   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;
@@ -192,11 +191,11 @@ bool wxListBox::Create(
     SetFont(*pTextFont);
 
     //
-    // Set standard wxWidgets colors for Listbox items and highlighting
+    // Set OS/2 system colours for Listbox items and highlighting
     //
     wxColour                        vColour;
 
-    vColour.Set(wxString(wxT("WHITE")));
+    vColour = wxSystemSettingsNative::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
 
     LONG                            lColor = (LONG)vColour.GetPixel();
 
@@ -205,7 +204,7 @@ bool wxListBox::Create(
                       ,sizeof(LONG)
                       ,(PVOID)&lColor
                      );
-    vColour.Set(wxString(wxT("NAVY")));
+    vColour = wxSystemSettingsNative::GetColour(wxSYS_COLOUR_HIGHLIGHT);
     lColor = (LONG)vColour.GetPixel();
     ::WinSetPresParam( m_hWnd
                       ,PP_HILITEBACKGROUNDCOLOR
@@ -213,6 +212,8 @@ bool wxListBox::Create(
                       ,(PVOID)&lColor
                      );
 
+    SetXComp(0);
+    SetYComp(0);
     SetSize( nX
             ,nY
             ,nWidth
@@ -224,14 +225,7 @@ bool wxListBox::Create(
 
 wxListBox::~wxListBox()
 {
-#if wxUSE_OWNER_DRAWN
-    size_t                          lUiCount = m_aItems.Count();
-
-    while (lUiCount-- != 0)
-    {
-        delete m_aItems[lUiCount];
-    }
-#endif // wxUSE_OWNER_DRAWN
+    Clear();
 } // end of wxListBox::~wxListBox
 
 void wxListBox::SetupColours()
@@ -244,157 +238,94 @@ void wxListBox::SetupColours()
 // 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
 
-void wxListBox::Delete(
-  int                               N
-)
+void wxListBox::DoDeleteOneItem(unsigned int n)
 {
-    wxCHECK_RET( N >= 0 && N < m_nNumItems,
+    wxCHECK_RET( IsValid(n),
                  wxT("invalid index in wxListBox::Delete") );
 
 #if wxUSE_OWNER_DRAWN
-    delete m_aItems[N];
-    m_aItems.RemoveAt(N);
-#else // !wxUSE_OWNER_DRAWN
-    if (HasClientObjectData())
-    {
-        delete GetClientObject(N);
-    }
-#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
+    delete m_aItems[n];
+    m_aItems.RemoveAt(n);
+#endif // wxUSE_OWNER_DRAWN
 
-    ::WinSendMsg(GetHwnd(), LM_DELETEITEM, (MPARAM)N, (MPARAM)0);
+    ::WinSendMsg(GetHwnd(), LM_DELETEITEM, (MPARAM)n, (MPARAM)0);
     m_nNumItems--;
 } // end of wxListBox::DoSetFirstItem
 
-int wxListBox::DoAppend(
-  const wxString&                   rsItem
-)
+int wxListBox::DoInsertItems(const wxArrayStringsAdapter & items,
+                             unsigned int pos,
+                             void **clientData,
+                             wxClientDataType type)
 {
-    long                            lIndex = 0;
-    LONG                            lIndexType = 0;
+    long lIndex = 0;
+    LONG lIndexType = 0;
+    bool incrementPos = false;
 
-    if (m_windowStyle & wxLB_SORT)
+    if (IsSorted())
         lIndexType = LIT_SORTASCENDING;
-    else
+    else if (pos == GetCount())
         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)
+    else
     {
-        wxOwnerDrawn*               pNewItem = CreateItem(lIndex); // dummy argument
-        wxScreenDC                  vDc;
-
-
-        pNewItem->SetName(rsItem);
-        m_aItems.Insert(pNewItem, lIndex);
-        ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, (MPARAM)lIndex, MPFROMP(pNewItem));
-        pNewItem->SetFont(GetFont());
+        lIndexType = (LONG)pos;
+        incrementPos = true;
     }
-#endif
-    return (int)lIndex;
-} // end of wxListBox::DoAppend
 
-void wxListBox::DoSetItems(
-  const wxArrayString&              raChoices
-, void**                            ppClientData
-)
-{
-    BOOL                            bHideAndShow = IsShown();
-    int                             i;
-    LONG                            lIndexType = 0;
+    int n = wxNOT_FOUND;
 
-    if (bHideAndShow)
-    {
-        ::WinShowWindow(GetHwnd(), FALSE);
-    }
-    ::WinSendMsg(GetHwnd(), LM_DELETEALL, (MPARAM)0, (MPARAM)0);
-    m_nNumItems = raChoices.GetCount();
-    for (i = 0; i < m_nNumItems; i++)
+    unsigned int count = items.GetCount();
+    for (unsigned int i = 0; i < count; i++)
     {
-
-        if (m_windowStyle & wxLB_SORT)
-            lIndexType = LIT_SORTASCENDING;
-        else
-            lIndexType = LIT_END;
-        ::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)lIndexType, (MPARAM)raChoices[i].c_str());
-
-        if (ppClientData)
+        n = (int)::WinSendMsg(GetHwnd(), LM_INSERTITEM, (MPARAM)lIndexType, (MPARAM)items[i].wx_str());
+        if (n < 0)
         {
-#if wxUSE_OWNER_DRAWN
-            wxASSERT_MSG(ppClientData[i] == NULL,
-                         wxT("Can't use client data with owner-drawn listboxes"));
-#else // !wxUSE_OWNER_DRAWN
-            ::WinSendMsg(WinUtil_GetHwnd(), LM_SETITEMHANDLE, MPFROMLONG(lCount), MPFROMP(ppClientData[i]));
-#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
+            wxLogLastError(wxT("WinSendMsg(LM_INSERTITEM)"));
+            n = wxNOT_FOUND;
+            break;
         }
-    }
+        ++m_nNumItems;
 
 #if wxUSE_OWNER_DRAWN
-    if ( m_windowStyle & wxLB_OWNERDRAW )
-    {
-        //
-        // First delete old items
-        //
-        WX_CLEAR_ARRAY(m_aItems);
-
-        //
-        // Then create new ones
-        //
-        for (size_t ui = 0; ui < (size_t)m_nNumItems; ui++)
+        if (HasFlag(wxLB_OWNERDRAW))
         {
-            wxOwnerDrawn*           pNewItem = CreateItem(ui);
-
-            pNewItem->SetName(raChoices[ui]);
-            m_aItems.Add(pNewItem);
-            ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, MPFROMLONG(ui), MPFROMP(pNewItem));
+            wxOwnerDrawn* pNewItem = CreateItem(n); // dummy argument
+            pNewItem->SetFont(GetFont());
+            m_aItems.Insert(pNewItem, n);
         }
+#endif
+        AssignNewItemClientData(n, clientData, i, type);
+
+        if (incrementPos)
+            ++lIndexType;
     }
-#endif // wxUSE_OWNER_DRAWN
-    ::WinShowWindow(GetHwnd(), TRUE);
-} // end of wxListBox::DoSetItems
 
-void wxListBox::Clear()
+    return n;
+} // end of wxListBox::DoInsertAppendItemsWithData
+
+void wxListBox::DoClear()
 {
 #if wxUSE_OWNER_DRAWN
-    size_t                          lUiCount = m_aItems.Count();
-
-    while (lUiCount-- != 0)
-    {
-        delete m_aItems[lUiCount];
-    }
-
-    m_aItems.Clear();
-#else // !wxUSE_OWNER_DRAWN
-    if (HasClientObjectData())
+    if ( m_windowStyle & wxLB_OWNERDRAW )
     {
-        for (size_t n = 0; n < (size_t)m_lNumItems; n++)
-        {
-            delete GetClientObject(n);
-        }
+        WX_CLEAR_ARRAY(m_aItems);
     }
-#endif // wxUSE_OWNER_DRAWN/!wxUSE_OWNER_DRAWN
+#endif // wxUSE_OWNER_DRAWN
     ::WinSendMsg(GetHwnd(), LM_DELETEALL, (MPARAM)0, (MPARAM)0);
 
     m_nNumItems = 0;
 } // end of wxListBox::Clear
 
-void wxListBox::DoSetSelection(
-  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
@@ -405,11 +336,9 @@ void wxListBox::DoSetSelection(
         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;
@@ -428,52 +357,19 @@ bool wxListBox::IsSelected(
     return (lItem == (LONG)N && lItem != LIT_NONE);
 } // end of wxListBox::IsSelected
 
-wxClientData* wxListBox::DoGetItemClientObject(
-  int                               n
-) const
+void* wxListBox::DoGetItemClientData(unsigned int n) const
 {
-    return (wxClientData *)DoGetItemClientData(n);
-}
-
-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
 
-void wxListBox::DoSetItemClientObject(
-  int                               n
-, wxClientData*                     pClientData
-)
-{
-    DoSetItemClientData( n
-                        ,pClientData
-                       );
-} // end of wxListBox::DoSetItemClientObject
-
-void wxListBox::DoSetItemClientData(
-  int                               n
-, void*                             pClientData
-)
+void wxListBox::DoSetItemClientData(unsigned 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
-    if ( m_windowStyle & wxLB_OWNERDRAW )
-    {
-        //
-        // Client data must be pointer to wxOwnerDrawn, otherwise we would crash
-        // in OnMeasure/OnDraw.
-        //
-        wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
-    }
-#endif // wxUSE_OWNER_DRAWN
-
     ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, MPFROMLONG(n), MPFROMP(pClientData));
 } // end of wxListBox::DoSetItemClientData
 
@@ -484,8 +380,8 @@ bool wxListBox::HasMultipleSelection() const
 
 int wxListBox::GetSelections( wxArrayInt& raSelections ) const
 {
-    int                             nCount = 0;
-    LONG                            lItem;
+    int  nCount = 0;
+    LONG lItem;
 
 
     raSelections.Empty();
@@ -559,126 +455,77 @@ int wxListBox::GetSelection() const
                      ));
 } // end of wxListBox::GetSelection
 
-wxString wxListBox::GetString(
-  int                               N
-) const
+wxString wxListBox::GetString(unsigned int n) const
 {
-    LONG                            lLen = 0;
-    wxChar*                         zBuf;
-    wxString                        sResult;
+    LONG     lLen = 0;
+    wxChar*  zBuf;
+    wxString sResult;
 
-    wxCHECK_MSG( N >= 0 && N < m_nNumItems, wxEmptyString,
+    wxCHECK_MSG( IsValid(n), wxEmptyString,
                  wxT("invalid index in wxListBox::GetClientData") );
 
-    lLen = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)N, (MPARAM)0));
+    lLen = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)n, (MPARAM)0));
     zBuf = new wxChar[lLen + 1];
-    ::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXT, MPFROM2SHORT((SHORT)N, (SHORT)lLen), (MPARAM)zBuf);
+    ::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXT, MPFROM2SHORT((SHORT)n, (SHORT)lLen), (MPARAM)zBuf);
     zBuf[lLen] = '\0';
     sResult = zBuf;
     delete [] zBuf;
     return sResult;
 } // end of wxListBox::GetString
 
-void wxListBox::DoInsertItems(
-  const wxArrayString&              asItems
-, int                               nPos
-)
-{
-    wxCHECK_RET( nPos >= 0 && nPos <= m_nNumItems,
-                 wxT("invalid index in wxListBox::InsertItems") );
-
-    int                             nItems = asItems.GetCount();
-
-    for (int i = 0; i < nItems; i++)
-    {
-        int                         nIndex = (int)::WinSendMsg( GetHwnd()
-                                                               ,LM_INSERTITEM
-                                                               ,MPFROMLONG((LONG)(i + nPos))
-                                                               ,(MPARAM)asItems[i].c_str()
-                                                              );
-
-        wxOwnerDrawn*               pNewItem = CreateItem(nIndex);
-
-        pNewItem->SetName(asItems[i]);
-        pNewItem->SetFont(GetFont());
-        m_aItems.Insert(pNewItem, nIndex);
-        ::WinSendMsg( GetHwnd()
-                     ,LM_SETITEMHANDLE
-                     ,(MPARAM)((LONG)nIndex)
-                     ,MPFROMP(pNewItem)
-                    );
-        m_nNumItems += nItems;
-    }
-} // end of wxListBox::DoInsertItems
-
-void wxListBox::SetString(
-  int                               N
-, const wxString&                   rsString
-)
+void wxListBox::SetString(unsigned 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
     //
-    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);
-    else if (m_clientDataItemsType == wxClientData_Object)
-        pOldObjData = GetClientObject(N);
+    if ( HasClientUntypedData() )
+        pOldData = GetClientData(n);
+    else if ( HasClientObjectData() )
+        pOldObjData = GetClientObject(n);
 
     //
     // Delete and recreate it
     //
     ::WinSendMsg( GetHwnd()
                  ,LM_DELETEITEM
-                 ,(MPARAM)N
+                 ,(MPARAM)n
                  ,(MPARAM)0
                 );
 
-    int                             nNewN = N;
+    int nNewN = n;
 
-    if (N == m_nNumItems - 1)
+    if (n == (m_nNumItems - 1))
         nNewN = -1;
 
     ::WinSendMsg( GetHwnd()
                  ,LM_INSERTITEM
                  ,(MPARAM)nNewN
-                 ,(MPARAM)rsString.c_str()
+                 ,(MPARAM)rsString.wx_str()
                 );
 
     //
     // Restore the client data
     //
     if (pOldData)
-        SetClientData( N
-                      ,pOldData
-                     );
+        SetClientData(n, pOldData);
     else if (pOldObjData)
-        SetClientObject( N
-                        ,pOldObjData
-                       );
+        SetClientObject(n, pOldObjData);
 
     //
     // We may have lost the selection
     //
     if (bWasSelected)
-        Select(N);
-
-#if wxUSE_OWNER_DRAWN
-    if (m_windowStyle & wxLB_OWNERDRAW)
-        //
-        // Update item's text
-        //
-        m_aItems[N]->SetName(rsString);
-#endif  //USE_OWNER_DRAWN
+        Select(n);
 } // end of wxListBox::SetString
 
-int wxListBox::GetCount() const
+unsigned int wxListBox::GetCount() const
 {
     return m_nNumItems;
 }
@@ -692,20 +539,17 @@ wxSize wxListBox::DoGetBestSize() const
     //
     // Find the widest string
     //
-    int                             nLine;
-    int                             nListbox = 0;
-    int                             nCx;
-    int                             nCy;
-    wxFont                          vFont = (wxFont)GetFont();
+    int        nLine;
+    int        nListbox = 0;
+    int        nCx;
+    int        nCy;
+    wxFont     vFont = (wxFont)GetFont();
 
-    for (int i = 0; i < m_nNumItems; i++)
+    for (unsigned int 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;
     }
@@ -727,7 +571,7 @@ wxSize wxListBox::DoGetBestSize() const
                  );
     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
@@ -748,7 +592,7 @@ bool wxListBox::OS2Command(
     {
         eEvtType = wxEVT_COMMAND_LISTBOX_SELECTED;
     }
-    if (uParam == LN_ENTER)
+    else if (uParam == LN_ENTER)
     {
         eEvtType = wxEVT_COMMAND_LISTBOX_DOUBLECLICKED;
     }
@@ -765,9 +609,9 @@ bool wxListBox::OS2Command(
 
     vEvent.SetEventObject(this);
 
-    wxArrayInt                      aSelections;
-    int                             n;
-    int                             nCount = GetSelections(aSelections);
+    wxArrayInt aSelections;
+    int        n;
+    int        nCount = GetSelections(aSelections);
 
     if (nCount > 0)
     {
@@ -783,7 +627,7 @@ bool wxListBox::OS2Command(
         n = -1;
     }
     vEvent.SetInt(n);
-    return GetEventHandler()->ProcessEvent(vEvent);
+    return HandleWindowEvent(vEvent);
 } // end of wxListBox::OS2Command
 
 // ----------------------------------------------------------------------------
@@ -798,9 +642,7 @@ bool wxListBox::OS2Command(
 //
 #define OWNER_DRAWN_LISTBOX_EXTRA_SPACE    (1)
 
-long wxListBox::OS2OnMeasure(
-  WXMEASUREITEMSTRUCT*              pItem
-)
+long wxListBox::OS2OnMeasure(WXMEASUREITEMSTRUCT* pItem)
 {
     if (!pItem)
         pItem = (WXMEASUREITEMSTRUCT*)new OWNERITEM;
@@ -838,7 +680,6 @@ bool wxListBox::OS2OnDraw (
 )
 {
     POWNERITEM                      pDrawStruct = (POWNERITEM)pItem;
-    LONG                            lItemID = pDrawStruct->idItem;
     int                             eAction = 0;
     int                             eStatus = 0;
 
@@ -851,24 +692,18 @@ bool wxListBox::OS2OnDraw (
     //
     // The item may be -1 for an empty listbox
     //
-    if (lItemID == -1L)
+    if (pDrawStruct->idItem == -1L)
         return false;
 
-    wxListBoxItem*                   pData = (wxListBoxItem*)PVOIDFROMMR( ::WinSendMsg( GetHwnd()
-                                                                                       ,LM_QUERYITEMHANDLE
-                                                                                       ,MPFROMLONG(pDrawStruct->idItem)
-                                                                                       ,(MPARAM)0
-                                                                                      )
-                                                                        );
-
-    wxCHECK(pData, false );
+    wxListBoxItem* pData = (wxListBoxItem*)m_aItems[pDrawStruct->idItem];
 
-    wxDC    vDc;
+    wxClientDC    vDc(this);
+    wxPMDCImpl *impl = (wxPMDCImpl*) vDc.GetImpl();
     wxPoint pt1( pDrawStruct->rclItem.xLeft, pDrawStruct->rclItem.yTop );
     wxPoint pt2( pDrawStruct->rclItem.xRight, pDrawStruct->rclItem.yBottom );
     wxRect  vRect( pt1, pt2 );
 
-    vDc.SetHPS(pDrawStruct->hps);
+    impl->SetHPS(pDrawStruct->hps);
 
     if (pDrawStruct->fsAttribute == pDrawStruct->fsAttributeOld)
     {
@@ -936,10 +771,10 @@ bool wxListBox::OS2OnDraw (
     return pData->OnDrawItem( vDc
                              ,vRect
                              ,(wxOwnerDrawn::wxODAction)eAction
-                             ,(wxOwnerDrawn::wxODStatus)eStatus
+                             ,(wxOwnerDrawn::wxODStatus)(eStatus | wxOwnerDrawn::wxODHidePrefix)
                             );
 } // end of wxListBox::OS2OnDraw
 
 #endif // ndef for wxUSE_OWNER_DRAWN
 
-#endif // ndef for wxUSE_LISTBOX
+#endif // wxUSE_LISTBOX