X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/95a4630380511f5e747b1465bf4834e5fac3d515..9154a136d5e1d79a4be2cf012e4a815fdc6df3ff:/src/generic/bmpcboxg.cpp diff --git a/src/generic/bmpcboxg.cpp b/src/generic/bmpcboxg.cpp index 88d9cd7218..6aec2b629e 100644 --- a/src/generic/bmpcboxg.cpp +++ b/src/generic/bmpcboxg.cpp @@ -4,7 +4,7 @@ // Author: Jaakko Salli // Modified by: // Created: Aug-31-2006 -// RCS-ID: $Id: +// RCS-ID: $Id$ // Copyright: (c) 2005 Jaakko Salli // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// @@ -35,6 +35,7 @@ #include "wx/odcombo.h" #include "wx/settings.h" +#include "wx/dc.h" #if wxUSE_IMAGE #include "wx/image.h" @@ -65,7 +66,7 @@ const wxChar wxBitmapComboBoxNameStr[] = wxT("bitmapComboBox"); BEGIN_EVENT_TABLE(wxBitmapComboBox, wxOwnerDrawnComboBox) - EVT_SIZE(wxBitmapComboBox::OnResize) + EVT_SIZE(wxBitmapComboBox::OnSize) END_EVENT_TABLE() @@ -145,6 +146,9 @@ bool wxBitmapComboBox::Create(wxWindow *parent, void wxBitmapComboBox::PostCreate() { m_fontHeight = GetCharHeight() + EXTRA_FONT_HEIGHT; + + while ( m_bitmaps.GetCount() < GetCount() ) + m_bitmaps.Add( new wxBitmap() ); } wxBitmapComboBox::~wxBitmapComboBox() @@ -158,7 +162,7 @@ wxBitmapComboBox::~wxBitmapComboBox() void wxBitmapComboBox::SetItemBitmap(unsigned int n, const wxBitmap& bitmap) { - wxCHECK_RET( n < m_bitmaps.size(), wxT("invalid item index") ); + wxCHECK_RET( n < GetCount(), wxT("invalid item index") ); OnAddBitmap(bitmap); *GetBitmapPtr(n) = bitmap; @@ -168,7 +172,7 @@ void wxBitmapComboBox::SetItemBitmap(unsigned int n, const wxBitmap& bitmap) wxBitmap wxBitmapComboBox::GetItemBitmap(unsigned int n) const { - wxCHECK_MSG( n < m_bitmaps.size(), wxNullBitmap, wxT("invalid item index") ); + wxCHECK_MSG( n < GetCount(), wxNullBitmap, wxT("invalid item index") ); return *GetBitmapPtr(n); } @@ -263,6 +267,8 @@ int wxBitmapComboBox::DoInsertWithImage(const wxString& item, const wxBitmap& image, unsigned int pos) { + wxCHECK_MSG( IsValidInsert(pos), wxNOT_FOUND, wxT("invalid item index") ); + if ( !DoInsertBitmap(image, pos) ) return wxNOT_FOUND; @@ -316,7 +322,7 @@ void wxBitmapComboBox::DetermineIndent() if ( m_usedImgSize.x > 0 ) { - indent = m_usedImgSize.y + IMAGE_SPACING_LEFT + IMAGE_SPACING_RIGHT; + indent = m_usedImgSize.x + IMAGE_SPACING_LEFT + IMAGE_SPACING_RIGHT; m_imgAreaWidth = indent; indent -= 3; @@ -325,7 +331,7 @@ void wxBitmapComboBox::DetermineIndent() SetCustomPaintWidth(indent); } -void wxBitmapComboBox::OnResize(wxSizeEvent& event) +void wxBitmapComboBox::OnSize(wxSizeEvent& event) { // Prevent infinite looping if ( !m_inResize ) @@ -374,7 +380,8 @@ void wxBitmapComboBox::OnDrawBackground(wxDC& dc, { if ( GetCustomPaintWidth() == 0 || !(flags & wxODCB_PAINTING_SELECTED) || - item < 0 ) + item < 0 || + ( (flags & wxODCB_PAINTING_CONTROL) && (GetInternalFlags() & wxCC_FULL_BUTTON)) ) { wxOwnerDrawnComboBox::OnDrawBackground(dc, rect, item, flags); return;