1552971 ] Add flag for wxODComboBox::OnDrawItem to indicate selection

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41305 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling 2006-09-19 17:16:50 +00:00
parent e42667e599
commit ce22ac4592
4 changed files with 33 additions and 17 deletions

View File

@ -44,7 +44,14 @@ enum
{
// when set, we are painting the selected item in control,
// not in the popup
wxODCB_PAINTING_CONTROL = 0x0001
wxODCB_PAINTING_CONTROL = 0x0001,
// when set, we are painting an item which should have
// focus rectangle painted in the background. Text colour
// and clipping region are then appropriately set in
// the default OnDrawBackground implementation.
wxODCB_PAINTING_SELECTED = 0x0002
};

View File

@ -230,8 +230,7 @@ public:
// If item is selected or even, or we are painting the
// combo control itself, use the default rendering.
if ( GetVListBoxComboPopup()->IsCurrent((size_t)item) ||
(flags & wxODCB_PAINTING_CONTROL) ||
if ( (flags & (wxODCB_PAINTING_CONTROL|wxODCB_PAINTING_SELECTED)) ||
(item & 1) == 0 )
{
wxOwnerDrawnComboBox::OnDrawBackground(dc,rect,item,flags);

View File

@ -264,8 +264,7 @@ public:
// If item is selected or even, or we are painting the
// combo control itself, use the default rendering.
if ( GetVListBoxComboPopup()->IsCurrent((size_t)item) ||
(flags & wxODCB_PAINTING_CONTROL) ||
if ( (flags & (wxODCB_PAINTING_CONTROL|wxODCB_PAINTING_SELECTED)) ||
(item & 1) == 0 )
{
wxOwnerDrawnComboBox::OnDrawBackground(dc,rect,item,flags);

View File

@ -107,7 +107,13 @@ void wxVListBoxComboPopup::PaintComboControl( wxDC& dc, const wxRect& rect )
{
if ( !(m_combo->GetWindowStyle() & wxODCB_STD_CONTROL_PAINT) )
{
OnDrawBg(dc,rect,m_value,wxODCB_PAINTING_CONTROL);
int flags = wxODCB_PAINTING_CONTROL;
if ( m_combo->ShouldDrawFocus() )
flags |= wxODCB_PAINTING_SELECTED;
OnDrawBg(dc, rect, m_value, flags);
if ( m_value >= 0 )
{
OnDrawItem(dc,rect,m_value,wxODCB_PAINTING_CONTROL);
@ -165,6 +171,9 @@ void wxVListBoxComboPopup::OnDrawBg( wxDC& dc,
wxASSERT_MSG( combo->IsKindOf(CLASSINFO(wxOwnerDrawnComboBox)),
wxT("you must subclass wxVListBoxComboPopup for drawing and measuring methods") );
if ( IsCurrent((size_t)item) && !(flags & wxODCB_PAINTING_CONTROL) )
flags |= wxODCB_PAINTING_SELECTED;
combo->OnDrawBackground(dc,rect,item,flags);
}
@ -1053,23 +1062,25 @@ wxCoord wxOwnerDrawnComboBox::OnMeasureItemWidth( size_t WXUNUSED(item) ) const
return -1;
}
void wxOwnerDrawnComboBox::OnDrawBackground(wxDC& dc, const wxRect& rect, int item, int flags) const
void wxOwnerDrawnComboBox::OnDrawBackground(wxDC& dc,
const wxRect& rect,
int WXUNUSED(item),
int flags) const
{
// we need to render selected and current items differently
if ( GetVListBoxComboPopup()->IsCurrent((size_t)item) ||
(flags & wxODCB_PAINTING_CONTROL) )
// 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)) )
{
int bgFlags = wxCONTROL_SELECTED;
if ( (flags & wxODCB_PAINTING_CONTROL) != wxODCB_PAINTING_CONTROL )
{
if ( !(flags & wxODCB_PAINTING_CONTROL) )
bgFlags |= wxCONTROL_ISSUBMENU;
PrepareBackground(dc, rect, bgFlags);
}
else if ( HasFlag(wxCB_READONLY) )
PrepareBackground(dc, rect, bgFlags);
PrepareBackground(dc, rect, bgFlags);
}
//else: do nothing for the normal items
}
#endif // wxUSE_ODCOMBOBOX