]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/choice.cpp
moved DLL import/export declarations from wx/defs.h to (new) wx/dlimpexp.h for GSocke...
[wxWidgets.git] / src / os2 / choice.cpp
index 0393f574e0d24b417f3bb335628ecb285dad6621..6098b3afa471faf797745c9081ea096616bdc5b6 100644 (file)
@@ -31,24 +31,20 @@ bool wxChoice::Create(
 , int                               n
 , const wxString                    asChoices[]
 , long                              lStyle
-#if wxUSE_VALIDATORS
 , const wxValidator&                rValidator
-#endif
 , const wxString&                   rsName
 )
 {
     long                            lSstyle;
 
-    if (!OS2CreateControl( pParent
-                          ,vId
-                          ,rPos
-                          ,rSize
-                          ,lStyle
-#if wxUSE_VALIDATORS
-                          ,rValidator
-#endif
-                          ,rsName
-                         ))
+    if (!CreateControl( pParent
+                       ,vId
+                       ,rPos
+                       ,rSize
+                       ,lStyle
+                       ,rValidator
+                       ,rsName
+                      ))
         return FALSE;
     lSstyle = CBS_DROPDOWNLIST |
               WS_TABSTOP       |
@@ -115,6 +111,32 @@ int wxChoice::DoAppend(
     return nIndex;
 } // end of wxChoice::DoAppend
 
+int wxChoice::DoInsert(
+  const wxString&                   rsItem,
+  int                               pos
+)
+{
+    wxCHECK_MSG(!(GetWindowStyle() & wxCB_SORT), -1, wxT("can't insert into sorted list"));
+    wxCHECK_MSG((pos>=0) && (pos<=GetCount()), -1, wxT("invalid index"));
+
+    if (pos == GetCount())
+        return DoAppend(rsItem);
+
+    int                             nIndex;
+    SHORT                           nIndexType = 0;
+
+    if (m_windowStyle & wxLB_SORT)
+        nIndexType = LIT_SORTASCENDING;
+    else
+        nIndexType = pos;
+    nIndex = (int)::WinSendMsg( GetHwnd()
+                               ,LM_INSERTITEM
+                               ,(MPARAM)nIndexType
+                               ,(MPARAM)rsItem.c_str()
+                              );
+    return nIndex;
+} // end of wxChoice::DoInsert
+
 void wxChoice::Delete(
   int                               n
 )
@@ -189,19 +211,35 @@ void wxChoice::SetString(
 )
 {
     SHORT                           nIndexType = 0;
+    void*                           pData;
 
-    ::WinSendMsg(WinUtil_GetHwnd(), LM_DELETEITEM, (MPARAM)n, 0);
+    if ( m_clientDataItemsType != wxClientData_None )
+    {
+        pData = DoGetItemClientData(n);
+    }
+    else // no client data
+    {
+        pData = NULL;
+    }
 
+    ::WinSendMsg(GetHwnd(), LM_DELETEITEM, (MPARAM)n, 0);
 
-    if (m_lWindowStyle & winLB_SORT)
+    if (m_windowStyle & wxLB_SORT)
         nIndexType = LIT_SORTASCENDING;
     else
         nIndexType = LIT_END;
-    lIndex = (YInt32)::WinSendMsg( WinUtil_GetHwnd()
-                                  ,LM_INSERTITEM
-                                  ,(MPARAM)nIndexType
-                                  ,(MPARAM)rsStr.Data()
-                                 );
+    ::WinSendMsg( GetHwnd()
+                 ,LM_INSERTITEM
+                 ,(MPARAM)nIndexType
+                 ,(MPARAM)rsStr.c_str()
+                );
+
+    if (pData)
+    {
+        DoSetItemClientData( n
+                            ,pData
+                           );
+    }
 } // end of wxChoice::SetString
 
 wxString wxChoice::GetString(
@@ -213,7 +251,7 @@ wxString wxChoice::GetString(
     char*                           zBuf;
 
     nLen = (size_t)LONGFROMMR(::WinSendMsg(GetHwnd(), LM_QUERYITEMTEXTLENGTH, (MPARAM)n, (MPARAM)0));
-    if (nLen)
+    if (nLen != LIT_ERROR && nLen > 0)
     {
         zBuf = new char[nLen + 1];
         ::WinSendMsg( GetHwnd()