]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/listbox.cpp
renamed errcode to fix compilation with VC++ 8 (replaces patch 982303)
[wxWidgets.git] / src / os2 / listbox.cpp
index 9f9f1de5d28afada32461669d3806eed61b5c756..1d8fbd18d38ec6f578552a90539318026f1b62a7 100644 (file)
@@ -21,6 +21,7 @@
 #include "wx/brush.h"
 #include "wx/font.h"
 #include "wx/dc.h"
+#include "wx/dcscreen.h"
 #include "wx/utils.h"
 #include "wx/scrolwin.h"
 #endif
@@ -84,6 +85,23 @@ 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
@@ -92,9 +110,7 @@ bool wxListBox::Create(
 , int                               n
 , const wxString                    asChoices[]
 , long                              lStyle
-#if wxUSE_VALIDATORS
 , const wxValidator&                rValidator
-#endif
 , const wxString&                   rsName
 )
 {
@@ -178,7 +194,7 @@ 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;
 
@@ -265,31 +281,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(
@@ -298,9 +313,8 @@ void wxListBox::DoSetItems(
 )
 {
     BOOL                            bHideAndShow = IsShown();
-    int                             nCount = 0;
     int                             i;
-    SHORT                           nIndexType = 0;
+    LONG                            lIndexType = 0;
 
     if (bHideAndShow)
     {
@@ -312,10 +326,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)
         {
@@ -619,7 +633,7 @@ void wxListBox::DoInsertItems(
         m_aItems.Insert(pNewItem, nIndex);
         ::WinSendMsg( GetHwnd()
                      ,LM_SETITEMHANDLE
-                     ,(MPARAM)((SHORT)nIndex)
+                     ,(MPARAM)((LONG)nIndex)
                      ,MPFROMP(pNewItem)
                     );
         m_nNumItems += nItems;
@@ -841,7 +855,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));