Fix drawing bitmap in the selection field of wxBitmapComboBox
When drop-down list is open for wxBitmapComboBox with wxCB_READONLY style and keyboard is used to select the item on the list then the contents of the selection field should remain unchanged. (Especially, the bitmap bitmap drawn in the selection field should be the bitmap associated with text value displayed in this field.) Closes #17299.
This commit is contained in:
committed by
Vadim Zeitlin
parent
50435ef678
commit
358e42a829
@@ -481,22 +481,30 @@ bool wxBitmapComboBox::MSWOnDraw(WXDRAWITEMSTRUCT *item)
|
|||||||
if ( lpDrawItem->itemState & ODS_SELECTED )
|
if ( lpDrawItem->itemState & ODS_SELECTED )
|
||||||
flags |= wxODCB_PAINTING_SELECTED;
|
flags |= wxODCB_PAINTING_SELECTED;
|
||||||
|
|
||||||
|
wxPaintDCEx dc(this, lpDrawItem->hDC);
|
||||||
|
wxRect rect = wxRectFromRECT(lpDrawItem->rcItem);
|
||||||
|
wxBitmapComboBoxBase::DrawBackground(dc, rect, pos, flags);
|
||||||
|
|
||||||
wxString text;
|
wxString text;
|
||||||
|
|
||||||
if ( flags & wxODCB_PAINTING_CONTROL )
|
if ( flags & wxODCB_PAINTING_CONTROL )
|
||||||
{
|
{
|
||||||
text = GetValue();
|
// Don't draw anything in the editable selection field.
|
||||||
if ( !HasFlag(wxCB_READONLY) )
|
if ( !HasFlag(wxCB_READONLY) )
|
||||||
text.clear();
|
return true;
|
||||||
|
|
||||||
|
pos = GetSelection();
|
||||||
|
// Skip drawing if there is nothing selected.
|
||||||
|
if ( pos < 0 )
|
||||||
|
return true;
|
||||||
|
|
||||||
|
text = GetValue();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
text = GetString(pos);
|
text = GetString(pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPaintDCEx dc(this, lpDrawItem->hDC);
|
|
||||||
wxRect rect = wxRectFromRECT(lpDrawItem->rcItem);
|
|
||||||
wxBitmapComboBoxBase::DrawBackground(dc, rect, pos, flags);
|
|
||||||
wxBitmapComboBoxBase::DrawItem(dc, rect, pos, text, flags);
|
wxBitmapComboBoxBase::DrawItem(dc, rect, pos, text, flags);
|
||||||
|
|
||||||
// If the item has the focus, draw focus rectangle.
|
// If the item has the focus, draw focus rectangle.
|
||||||
|
Reference in New Issue
Block a user