]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/listbox.cpp
force making stats
[wxWidgets.git] / src / os2 / listbox.cpp
index df1b7cc473d7e48f451c348e78e0413a439c3810..968cd9a851b95f46d1e77b2775c8611b602df2a8 100644 (file)
@@ -22,6 +22,7 @@
 #include "wx/font.h"
 #include "wx/dc.h"
 #include "wx/utils.h"
+#include "wx/scrolwin.h"
 #endif
 
 #define INCL_M
@@ -142,15 +143,6 @@ bool wxListBox::Create(
     //
     lStyle |= LS_NOADJUSTPOS;
 
-    //
-    // If the parent is a scrolled window the controls must
-    // have this style or they will overlap the scrollbars
-    //
-    if (pParent)
-        if (pParent->IsKindOf(CLASSINFO(wxScrolledWindow)) ||
-            pParent->IsKindOf(CLASSINFO(wxGenericScrolledWindow)))
-            lStyle |= WS_CLIPSIBLINGS;
-
     m_hWnd = (WXHWND)::WinCreateWindow( GetWinHwnd(pParent) // Parent
                                        ,WC_LISTBOX          // Default Listbox class
                                        ,"LISTBOX"           // Control's name
@@ -178,8 +170,13 @@ bool wxListBox::Create(
     {
         Append(asChoices[lUi]);
     }
-    SetFont(pParent->GetFont());
-    
+    wxFont*                          pTextFont = new wxFont( 10
+                                                            ,wxMODERN
+                                                            ,wxNORMAL
+                                                            ,wxNORMAL
+                                                           );
+    SetFont(*pTextFont);
+
     //
     // Set standard wxWindows colors for Listbox items and highlighting
     //
@@ -207,6 +204,7 @@ bool wxListBox::Create(
             ,nWidth
             ,nHeight
            );
+    delete pTextFont;
     return TRUE;
 } // end of wxListBox::Create
 
@@ -283,7 +281,7 @@ int wxListBox::DoAppend(
         wxOwnerDrawn*               pNewItem = CreateItem(nIndex); // dummy argument
 
         pNewItem->SetName(rsItem);
-        m_aItems.Add(pNewItem);
+        m_aItems.Insert(pNewItem, nIndex);
         ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, (MPARAM)((SHORT)nIndex), MPFROMP(pNewItem));
         pNewItem->SetFont(GetFont());
     }
@@ -333,24 +331,18 @@ void wxListBox::DoSetItems(
         //
         // 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
         //
-        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);
-            ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, MPFROMLONG(lUi), MPFROMP(pNewItem));
+            ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, MPFROMLONG(ui), MPFROMP(pNewItem));
         }
     }
 #endif // wxUSE_OWNER_DRAWN
@@ -429,8 +421,18 @@ bool wxListBox::IsSelected(
 
     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(
@@ -598,8 +600,25 @@ void wxListBox::DoInsertItems(
     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)((SHORT)nIndex)
+                     ,MPFROMP(pNewItem)
+                    );
+        m_nNumItems += nItems;
+    }
 } // end of wxListBox::DoInsertItems
 
 void wxListBox::SetString(