]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/listbox.cpp
compilation fixes
[wxWidgets.git] / src / msw / listbox.cpp
index 19a8753d283e53984466ac50c0ca5fea0dbddb12..e466ae97eed8e4c10f2194a932eecdce66c1b5d1 100644 (file)
@@ -100,7 +100,7 @@ wxListBoxItem::wxListBoxItem(const wxString& str) : wxOwnerDrawn(str, FALSE)
     SetMarginWidth(0);
 }
 
-wxOwnerDrawn *wxListBox::CreateItem(size_t n)
+wxOwnerDrawn *wxListBox::CreateItem(size_t WXUNUSED(n))
 {
     return new wxListBoxItem();
 }
@@ -157,6 +157,12 @@ bool wxListBox::Create(wxWindow *parent,
 
     DWORD wstyle = WS_VISIBLE | WS_VSCROLL | WS_TABSTOP |
                    LBS_NOTIFY | LBS_HASSTRINGS /* | WS_CLIPSIBLINGS */;
+
+    wxASSERT_MSG( !(style & wxLB_MULTIPLE) || !(style & wxLB_EXTENDED),
+                  _T("only one of listbox selection modes can be specified") );
+    if ( m_windowStyle & wxCLIP_SIBLINGS )
+        wstyle |= WS_CLIPSIBLINGS;
+
     if (m_windowStyle & wxLB_MULTIPLE)
         wstyle |= LBS_MULTIPLESEL;
     else if (m_windowStyle & wxLB_EXTENDED)
@@ -657,7 +663,10 @@ wxSize wxListBox::DoGetBestSize() const
 
     wListbox += 3*cx;
 
-    int hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*(wxMax(m_noItems, 7));
+    // don't make the listbox too tall (limit height to 10 items) but don't
+    // make it too small neither
+    int hListbox = EDIT_HEIGHT_FROM_CHAR_HEIGHT(cy)*
+                    wxMin(wxMax(m_noItems, 3), 10);
 
     return wxSize(wListbox, hListbox);
 }
@@ -767,14 +776,13 @@ bool wxListBox::MSWOnDraw(WXDRAWITEMSTRUCT *item)
 
     wxListBoxItem *pItem = (wxListBoxItem *)data;
 
-    wxDC dc;
-    dc.SetHDC((WXHDC)pStruct->hDC, FALSE);
+    wxDCTemp dc((WXHDC)pStruct->hDC);
     wxRect rect(wxPoint(pStruct->rcItem.left, pStruct->rcItem.top),
                 wxPoint(pStruct->rcItem.right, pStruct->rcItem.bottom));
 
     return pItem->OnDrawItem(dc, rect,
-            (wxOwnerDrawn::wxODAction)pStruct->itemAction,
-            (wxOwnerDrawn::wxODStatus)pStruct->itemState);
+                             (wxOwnerDrawn::wxODAction)pStruct->itemAction,
+                             (wxOwnerDrawn::wxODStatus)pStruct->itemState);
 }
 
 #endif