- // we need to render selected and current items differently
- if ( GetVListBoxComboPopup()->IsCurrent((size_t)item) ||
- (flags & wxODCB_PAINTING_CONTROL) )
+ wxSize best( wxComboCtrlBase::DoGetBestSize() );
+
+ if ( GetCount() > 0 )
+ {
+ wxOwnerDrawnComboBox* odc = const_cast<wxOwnerDrawnComboBox*>(this);
+ best.x = odc->GetWidestItemWidth();
+ // TODO: this class may also have GetHightestItemHeight() and
+ // GetHightestItem() methods, and so set the whole (edit part + arrow)
+ // control's height according with this max height, not only max width.
+ }
+
+ return GetSizeFromTextSize(best.x);
+}
+
+void wxOwnerDrawnComboBox::OnDrawBackground(wxDC& dc,
+ const wxRect& rect,
+ int WXUNUSED(item),
+ int flags) const
+{
+ // We need only to explicitly draw background for items
+ // that should have selected background. Also, call PrepareBackground
+ // always when painting the control so that clipping is done properly.
+
+ if ( (flags & wxODCB_PAINTING_SELECTED) ||
+ ((flags & wxODCB_PAINTING_CONTROL) && HasFlag(wxCB_READONLY)) )