]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/listbox.cpp
cleanup - more reformatting; fixed bug introduced in prior commit
[wxWidgets.git] / src / os2 / listbox.cpp
index 04dffe2b68b7098a2536f649adc17f01fefab98a..d5e6bc01faabc46c5965616ce55af30acfcbe02b 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:
@@ -21,7 +21,9 @@
 #include "wx/brush.h"
 #include "wx/font.h"
 #include "wx/dc.h"
 #include "wx/brush.h"
 #include "wx/font.h"
 #include "wx/dc.h"
+#include "wx/dcscreen.h"
 #include "wx/utils.h"
 #include "wx/utils.h"
+#include "wx/scrolwin.h"
 #endif
 
 #define INCL_M
 #endif
 
 #define INCL_M
 class wxListBoxItem : public wxOwnerDrawn
 {
 public:
 class wxListBoxItem : public wxOwnerDrawn
 {
 public:
-    wxListBoxItem(const wxString& rsStr = "");
+    wxListBoxItem(const wxString& rsStr = wxEmptyString);
 };
 
 wxListBoxItem::wxListBoxItem(
   const wxString& rsStr
 )
 : wxOwnerDrawn( rsStr
 };
 
 wxListBoxItem::wxListBoxItem(
   const wxString& rsStr
 )
 : wxOwnerDrawn( rsStr
-               ,FALSE
+               ,false
               )
 {
     //
               )
 {
     //
@@ -63,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
@@ -83,6 +83,23 @@ wxListBox::wxListBox()
     m_nSelected = 0;
 } // end of wxListBox::wxListBox
 
     m_nSelected = 0;
 } // end of wxListBox::wxListBox
 
+bool wxListBox::Create(
+  wxWindow*                         pParent
+, wxWindowID                        vId
+, const wxPoint&                    rPos
+, const wxSize&                     rSize
+, const wxArrayString&              asChoices
+, long                              lStyle
+, const wxValidator&                rValidator
+, const wxString&                   rsName
+)
+{
+    wxCArrayString chs(asChoices);
+
+    return Create(pParent, vId, rPos, rSize, chs.GetCount(), chs.GetStrings(),
+                  lStyle, rValidator, rsName);
+}
+
 bool wxListBox::Create(
   wxWindow*                         pParent
 , wxWindowID                        vId
 bool wxListBox::Create(
   wxWindow*                         pParent
 , wxWindowID                        vId
@@ -91,9 +108,7 @@ bool wxListBox::Create(
 , int                               n
 , const wxString                    asChoices[]
 , long                              lStyle
 , int                               n
 , const wxString                    asChoices[]
 , long                              lStyle
-#if wxUSE_VALIDATORS
 , const wxValidator&                rValidator
 , const wxValidator&                rValidator
-#endif
 , const wxString&                   rsName
 )
 {
 , const wxString&                   rsName
 )
 {
@@ -111,7 +126,7 @@ bool wxListBox::Create(
 
     wxSystemSettings                vSettings;
 
 
     wxSystemSettings                vSettings;
 
-    SetBackgroundColour(vSettings.GetSystemColour(wxSYS_COLOUR_WINDOW));
+    SetBackgroundColour(vSettings.GetColour(wxSYS_COLOUR_WINDOW));
     SetForegroundColour(pParent->GetForegroundColour());
 
     m_windowId = (vId == -1) ? (int)NewControlId() : vId;
     SetForegroundColour(pParent->GetForegroundColour());
 
     m_windowId = (vId == -1) ? (int)NewControlId() : vId;
@@ -155,7 +170,7 @@ bool wxListBox::Create(
                                       );
     if (m_hWnd == 0)
     {
                                       );
     if (m_hWnd == 0)
     {
-        return FALSE;
+        return false;
     }
 
     //
     }
 
     //
@@ -169,13 +184,44 @@ bool wxListBox::Create(
     {
         Append(asChoices[lUi]);
     }
     {
         Append(asChoices[lUi]);
     }
-    SetFont(pParent->GetFont());
+    wxFont*                          pTextFont = new wxFont( 10
+                                                            ,wxMODERN
+                                                            ,wxNORMAL
+                                                            ,wxNORMAL
+                                                           );
+    SetFont(*pTextFont);
+
+    //
+    // Set OS/2 system colours for Listbox items and highlighting
+    //
+    wxColour                        vColour;
+
+    vColour = wxSystemSettingsNative::GetColour(wxSYS_COLOUR_HIGHLIGHTTEXT);
+
+    LONG                            lColor = (LONG)vColour.GetPixel();
+
+    ::WinSetPresParam( m_hWnd
+                      ,PP_HILITEFOREGROUNDCOLOR
+                      ,sizeof(LONG)
+                      ,(PVOID)&lColor
+                     );
+    vColour = wxSystemSettingsNative::GetColour(wxSYS_COLOUR_HIGHLIGHT);
+    lColor = (LONG)vColour.GetPixel();
+    ::WinSetPresParam( m_hWnd
+                      ,PP_HILITEBACKGROUNDCOLOR
+                      ,sizeof(LONG)
+                      ,(PVOID)&lColor
+                     );
+
+    SetXComp(0);
+    SetYComp(0);
     SetSize( nX
             ,nY
             ,nWidth
             ,nHeight
            );
     SetSize( nX
             ,nY
             ,nWidth
             ,nHeight
            );
-    return TRUE;
+    delete pTextFont;
+    return true;
 } // end of wxListBox::Create
 
 wxListBox::~wxListBox()
 } // end of wxListBox::Create
 
 wxListBox::~wxListBox()
@@ -192,7 +238,7 @@ wxListBox::~wxListBox()
 
 void wxListBox::SetupColours()
 {
 
 void wxListBox::SetupColours()
 {
-    SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_WINDOW));
+    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW));
     SetForegroundColour(GetParent()->GetForegroundColour());
 } // end of wxListBox::SetupColours
 
     SetForegroundColour(GetParent()->GetForegroundColour());
 } // end of wxListBox::SetupColours
 
@@ -235,28 +281,30 @@ int wxListBox::DoAppend(
   const wxString&                   rsItem
 )
 {
   const wxString&                   rsItem
 )
 {
-    int                             nIndex = 0;
-    SHORT                           nIndexType = 0;
+    long                            lIndex = 0;
+    LONG                            lIndexType = 0;
 
     if (m_windowStyle & wxLB_SORT)
 
     if (m_windowStyle & wxLB_SORT)
-        nIndexType = LIT_SORTASCENDING;
+        lIndexType = LIT_SORTASCENDING;
     else
     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)
     {
     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;
+
 
         pNewItem->SetName(rsItem);
 
         pNewItem->SetName(rsItem);
-        m_aItems.Add(pNewItem);
-        ::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
         pNewItem->SetFont(GetFont());
     }
 #endif
-    return nIndex;
+    return (int)lIndex;
 } // end of wxListBox::DoAppend
 
 void wxListBox::DoSetItems(
 } // end of wxListBox::DoAppend
 
 void wxListBox::DoSetItems(
@@ -265,9 +313,8 @@ void wxListBox::DoSetItems(
 )
 {
     BOOL                            bHideAndShow = IsShown();
 )
 {
     BOOL                            bHideAndShow = IsShown();
-    int                             nCount = 0;
     int                             i;
     int                             i;
-    SHORT                           nIndexType = 0;
+    LONG                            lIndexType = 0;
 
     if (bHideAndShow)
     {
 
     if (bHideAndShow)
     {
@@ -279,10 +326,10 @@ void wxListBox::DoSetItems(
     {
 
         if (m_windowStyle & wxLB_SORT)
     {
 
         if (m_windowStyle & wxLB_SORT)
-            nIndexType = LIT_SORTASCENDING;
+            lIndexType = LIT_SORTASCENDING;
         else
         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)
         {
 
         if (ppClientData)
         {
@@ -301,54 +348,24 @@ void wxListBox::DoSetItems(
         //
         // First delete old items
         //
         //
         // First delete old items
         //
-        size_t                      lUi = m_aItems.Count();
-
-        while (lUi-- != 0)
-        {
-            delete m_aItems[lUi];
-        }
-        m_aItems.Empty();
+        WX_CLEAR_ARRAY(m_aItems);
 
         //
         // Then create new ones
         //
 
         //
         // Then create new ones
         //
-        for (lUi = 0; lUi < (size_t)m_nNumItems; lUi++)
+        for (size_t ui = 0; ui < (size_t)m_nNumItems; ui++)
         {
         {
-            wxOwnerDrawn*           pNewItem = CreateItem(lUi);
+            wxOwnerDrawn*           pNewItem = CreateItem(ui);
 
 
-            pNewItem->SetName(raChoices[lUi]);
+            pNewItem->SetName(raChoices[ui]);
             m_aItems.Add(pNewItem);
             m_aItems.Add(pNewItem);
-            ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, MPFROMLONG(lUi), MPFROMP(pNewItem));
+            ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, MPFROMLONG(ui), MPFROMP(pNewItem));
         }
     }
 #endif // wxUSE_OWNER_DRAWN
     ::WinShowWindow(GetHwnd(), TRUE);
 } // end of wxListBox::DoSetItems
 
         }
     }
 #endif // wxUSE_OWNER_DRAWN
     ::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
@@ -374,7 +391,7 @@ void wxListBox::Clear()
     m_nNumItems = 0;
 } // end of wxListBox::Clear
 
     m_nNumItems = 0;
 } // end of wxListBox::Clear
 
-void wxListBox::SetSelection(
+void wxListBox::DoSetSelection(
   int                               N
 , bool                              bSelect
 )
   int                               N
 , bool                              bSelect
 )
@@ -386,19 +403,31 @@ void wxListBox::SetSelection(
                  ,MPFROMLONG(N)
                  ,(MPARAM)bSelect
                 );
                  ,MPFROMLONG(N)
                  ,(MPARAM)bSelect
                 );
+    if(m_windowStyle & wxLB_OWNERDRAW)
+        Refresh();
 } // end of wxListBox::SetSelection
 
 bool wxListBox::IsSelected(
   int                               N
 ) const
 {
 } // end of wxListBox::SetSelection
 
 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;
 
                  wxT("invalid index in wxListBox::Selected") );
 
     LONG                            lItem;
 
-    lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)N, (MPARAM)0));
-    return (lItem != LIT_NONE);
+    if (GetWindowStyleFlag() & wxLB_EXTENDED)
+    {
+        if (N == 0)
+            lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)LIT_FIRST, (MPARAM)0));
+        else
+            lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)(N - 1), (MPARAM)0));
+    }
+    else
+    {
+        lItem = LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYSELECTION, (MPARAM)LIT_FIRST, (MPARAM)0));
+    }
+    return (lItem == (LONG)N && lItem != LIT_NONE);
 } // end of wxListBox::IsSelected
 
 wxClientData* wxListBox::DoGetItemClientObject(
 } // end of wxListBox::IsSelected
 
 wxClientData* wxListBox::DoGetItemClientObject(
@@ -455,9 +484,7 @@ 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;
@@ -504,7 +531,6 @@ int wxListBox::GetSelections(
             }
             return nCount;
         }
             }
             return nCount;
         }
-        return 0;
     }
     else  // single-selection listbox
     {
     }
     else  // single-selection listbox
     {
@@ -540,14 +566,14 @@ wxString wxListBox::GetString(
 ) const
 {
     LONG                            lLen = 0;
 ) const
 {
     LONG                            lLen = 0;
-    char*                           zBuf;
+    wxChar*                         zBuf;
     wxString                        sResult;
 
     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));
                  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;
@@ -566,8 +592,25 @@ void wxListBox::DoInsertItems(
     int                             nItems = asItems.GetCount();
 
     for (int i = 0; i < nItems; i++)
     int                             nItems = asItems.GetCount();
 
     for (int i = 0; i < nItems; i++)
-        ::WinSendMsg(GetHwnd(), LM_INSERTITEM, MPFROMLONG((LONG)(i + nPos)), (MPARAM)asItems[i].c_str());
-    m_nNumItems += nItems;
+    {
+        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(
 } // end of wxListBox::DoInsertItems
 
 void wxListBox::SetString(
@@ -655,6 +698,7 @@ wxSize wxListBox::DoGetBestSize() const
     int                             nListbox = 0;
     int                             nCx;
     int                             nCy;
     int                             nListbox = 0;
     int                             nCx;
     int                             nCy;
+    wxFont                          vFont = (wxFont)GetFont();
 
     for (int i = 0; i < m_nNumItems; i++)
     {
 
     for (int i = 0; i < m_nNumItems; i++)
     {
@@ -681,7 +725,7 @@ wxSize wxListBox::DoGetBestSize() const
     wxGetCharSize( GetHWND()
                   ,&nCx
                   ,&nCy
     wxGetCharSize( GetHWND()
                   ,&nCx
                   ,&nCy
-                  ,(wxFont*)&GetFont()
+                  ,&vFont
                  );
     nListbox += 3 * nCx;
 
                  );
     nListbox += 3 * nCx;
 
@@ -706,7 +750,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;
     }
@@ -715,7 +759,7 @@ bool wxListBox::OS2Command(
         //
         // Some event we're not interested in
         //
         //
         // Some event we're not interested in
         //
-        return FALSE;
+        return false;
     }
     wxCommandEvent                  vEvent( eEvtType
                                            ,m_windowId
     }
     wxCommandEvent                  vEvent( eEvtType
                                            ,m_windowId
@@ -740,7 +784,7 @@ bool wxListBox::OS2Command(
     {
         n = -1;
     }
     {
         n = -1;
     }
-    vEvent.m_commandInt = n;
+    vEvent.SetInt(n);
     return GetEventHandler()->ProcessEvent(vEvent);
 } // end of wxListBox::OS2Command
 
     return GetEventHandler()->ProcessEvent(vEvent);
 } // end of wxListBox::OS2Command
 
@@ -756,22 +800,148 @@ bool wxListBox::OS2Command(
 //
 #define OWNER_DRAWN_LISTBOX_EXTRA_SPACE    (1)
 
 //
 #define OWNER_DRAWN_LISTBOX_EXTRA_SPACE    (1)
 
-bool wxListBox::OS2OnMeasure(WXMEASUREITEMSTRUCT *item)
+long wxListBox::OS2OnMeasure(
+  WXMEASUREITEMSTRUCT*              pItem
+)
 {
 {
+    if (!pItem)
+        pItem = (WXMEASUREITEMSTRUCT*)new OWNERITEM;
+
+    POWNERITEM                      pMeasureStruct = (POWNERITEM)pItem;
+    wxScreenDC                      vDc;
+
     //
     //
-    // TODO: Get to this eventually
+    // Only owner-drawn control should receive this message
     //
     //
-    return TRUE;
-}
+    wxCHECK( ((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), FALSE );
+
+    vDc.SetFont(GetFont());
+
+    wxCoord                         vHeight;
+    wxCoord                         vWidth;
 
 
-bool wxListBox::OS2OnDraw(WXDRAWITEMSTRUCT *item)
+    GetSize( &vWidth
+            ,NULL
+           );
+
+    pMeasureStruct->rclItem.xRight = (USHORT)vWidth;
+    pMeasureStruct->rclItem.xLeft  = 0;
+    pMeasureStruct->rclItem.yTop   = 0;
+    pMeasureStruct->rclItem.yBottom = 0;
+
+    vHeight = (wxCoord)(vDc.GetCharHeight() * 2.5);
+    pMeasureStruct->rclItem.yTop  = (USHORT)vHeight;
+
+    return long(MRFROM2SHORT((USHORT)vHeight, (USHORT)vWidth));
+} // end of wxListBox::OS2OnMeasure
+
+bool wxListBox::OS2OnDraw (
+  WXDRAWITEMSTRUCT*                 pItem
+)
 {
 {
+    POWNERITEM                      pDrawStruct = (POWNERITEM)pItem;
+    LONG                            lItemID = pDrawStruct->idItem;
+    int                             eAction = 0;
+    int                             eStatus = 0;
+
     //
     //
-    // TODO: Get to this eventually
+    // Only owner-drawn control should receive this message
     //
     //
-    return FALSE;
-}
+    wxCHECK(((m_windowStyle & wxLB_OWNERDRAW) == wxLB_OWNERDRAW), false);
+
+
+    //
+    // The item may be -1 for an empty listbox
+    //
+    if (lItemID == -1L)
+        return false;
+
+    wxListBoxItem*                   pData = (wxListBoxItem*)PVOIDFROMMR( ::WinSendMsg( GetHwnd()
+                                                                                       ,LM_QUERYITEMHANDLE
+                                                                                       ,MPFROMLONG(pDrawStruct->idItem)
+                                                                                       ,(MPARAM)0
+                                                                                      )
+                                                                        );
+
+    wxCHECK(pData, false );
+
+    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);
+
+    if (pDrawStruct->fsAttribute == pDrawStruct->fsAttributeOld)
+    {
+        //
+        // Entire Item needs to be redrawn (either it has reappeared from
+        // behind another window or is being displayed for the first time
+        //
+        eAction = wxOwnerDrawn::wxODDrawAll;
+
+        if (pDrawStruct->fsAttribute & MIA_HILITED)
+        {
+            //
+            // If it is currently selected we let the system handle it
+            //
+            eStatus |= wxOwnerDrawn::wxODSelected;
+        }
+        if (pDrawStruct->fsAttribute & MIA_CHECKED)
+        {
+            //
+            // If it is currently checked we draw our own
+            //
+            eStatus |= wxOwnerDrawn::wxODChecked;
+            pDrawStruct->fsAttributeOld = pDrawStruct->fsAttribute &= ~MIA_CHECKED;
+        }
+        if (pDrawStruct->fsAttribute & MIA_DISABLED)
+        {
+            //
+            // If it is currently disabled we let the system handle it
+            //
+            eStatus |= wxOwnerDrawn::wxODDisabled;
+        }
+        //
+        // Don't really care about framed (indicationg focus) or NoDismiss
+        //
+    }
+    else
+    {
+        if (pDrawStruct->fsAttribute & MIA_HILITED)
+        {
+            eAction = wxOwnerDrawn::wxODDrawAll;
+            eStatus |= wxOwnerDrawn::wxODSelected;
+            //
+            // Keep the system from trying to highlight with its bogus colors
+            //
+            pDrawStruct->fsAttributeOld = pDrawStruct->fsAttribute &= ~MIA_HILITED;
+        }
+        else if (!(pDrawStruct->fsAttribute & MIA_HILITED))
+        {
+            eAction = wxOwnerDrawn::wxODDrawAll;
+            eStatus = 0;
+            //
+            // Keep the system from trying to highlight with its bogus colors
+            //
+            pDrawStruct->fsAttribute = pDrawStruct->fsAttributeOld &= ~MIA_HILITED;
+        }
+        else
+        {
+            //
+            // For now we don't care about anything else
+            // just ignore the entire message!
+            //
+            return true;
+        }
+    }
+    return pData->OnDrawItem( vDc
+                             ,vRect
+                             ,(wxOwnerDrawn::wxODAction)eAction
+                             ,(wxOwnerDrawn::wxODStatus)eStatus
+                            );
+} // end of wxListBox::OS2OnDraw
+
 #endif // ndef for wxUSE_OWNER_DRAWN
 
 #endif // ndef for wxUSE_LISTBOX
 #endif // ndef for wxUSE_OWNER_DRAWN
 
 #endif // ndef for wxUSE_LISTBOX
-