]> git.saurik.com Git - wxWidgets.git/blobdiff - src/os2/listbox.cpp
fix for bug reported by Robert and Julian, probably causes other problems
[wxWidgets.git] / src / os2 / listbox.cpp
index 04dffe2b68b7098a2536f649adc17f01fefab98a..d23bedc5125dbf0d97312db157f0250457a86cc6 100644 (file)
@@ -22,6 +22,7 @@
 #include "wx/font.h"
 #include "wx/dc.h"
 #include "wx/utils.h"
 #include "wx/font.h"
 #include "wx/dc.h"
 #include "wx/utils.h"
+#include "wx/scrolwin.h"
 #endif
 
 #define INCL_M
 #endif
 
 #define INCL_M
@@ -169,12 +170,41 @@ bool wxListBox::Create(
     {
         Append(asChoices[lUi]);
     }
     {
         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
+    //
+    wxColour                        vColour;
+
+    vColour.Set(wxString("WHITE"));
+
+    LONG                            lColor = (LONG)vColour.GetPixel();
+
+    ::WinSetPresParam( m_hWnd
+                      ,PP_HILITEFOREGROUNDCOLOR
+                      ,sizeof(LONG)
+                      ,(PVOID)&lColor
+                     );
+    vColour.Set(wxString("NAVY"));
+    lColor = (LONG)vColour.GetPixel();
+    ::WinSetPresParam( m_hWnd
+                      ,PP_HILITEBACKGROUNDCOLOR
+                      ,sizeof(LONG)
+                      ,(PVOID)&lColor
+                     );
+
     SetSize( nX
             ,nY
             ,nWidth
             ,nHeight
            );
     SetSize( nX
             ,nY
             ,nWidth
             ,nHeight
            );
+    delete pTextFont;
     return TRUE;
 } // end of wxListBox::Create
 
     return TRUE;
 } // end of wxListBox::Create
 
@@ -192,7 +222,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
 
@@ -251,7 +281,7 @@ int wxListBox::DoAppend(
         wxOwnerDrawn*               pNewItem = CreateItem(nIndex); // dummy argument
 
         pNewItem->SetName(rsItem);
         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());
     }
         ::WinSendMsg(GetHwnd(), LM_SETITEMHANDLE, (MPARAM)((SHORT)nIndex), MPFROMP(pNewItem));
         pNewItem->SetFont(GetFont());
     }
@@ -301,24 +331,18 @@ 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
         }
     }
 #endif // wxUSE_OWNER_DRAWN
@@ -566,8 +590,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)((SHORT)nIndex)
+                     ,MPFROMP(pNewItem)
+                    );
+        m_nNumItems += nItems;
+    }
 } // end of wxListBox::DoInsertItems
 
 void wxListBox::SetString(
 } // end of wxListBox::DoInsertItems
 
 void wxListBox::SetString(