diff --git a/docs/changes.txt b/docs/changes.txt index a1b8c69426..c8bc869e05 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -143,6 +143,9 @@ Changes in behaviour not resulting in compilation errors Changes in behaviour which may result in build errors ----------------------------------------------------- +- wxBitmapComboBoxBase::SetItemBitmap() changed argument's type from wxBitmap + to wxBitmapBundle. + - "webview" library is not included in `wx-config --libs` output any more, you need to request it explicitly, e.g. `wx-config --libs std,webview`. diff --git a/include/wx/bmpcbox.h b/include/wx/bmpcbox.h index cfa3b1ce91..25cc727e26 100644 --- a/include/wx/bmpcbox.h +++ b/include/wx/bmpcbox.h @@ -16,7 +16,7 @@ #if wxUSE_BITMAPCOMBOBOX -#include "wx/bitmap.h" +#include "wx/bmpbndl.h" #include "wx/dynarray.h" class WXDLLIMPEXP_FWD_CORE wxWindow; @@ -43,7 +43,7 @@ public: virtual ~wxBitmapComboBoxBase() { } // Sets the image for the given item. - virtual void SetItemBitmap(unsigned int n, const wxBitmap& bitmap) = 0; + virtual void SetItemBitmap(unsigned int n, const wxBitmapBundle& bitmap) = 0; #if !defined(wxBITMAPCOMBOBOX_OWNERDRAWN_BASED) @@ -79,7 +79,7 @@ protected: void BCBDoClear(); void BCBDoDeleteOneItem(unsigned int n); - void DoSetItemBitmap(unsigned int n, const wxBitmap& bitmap); + void DoSetItemBitmap(unsigned int n, const wxBitmapBundle& bitmap); void DrawBackground(wxDC& dc, const wxRect& rect, int item, int flags) const; void DrawItem(wxDC& dc, const wxRect& rect, int item, const wxString& text, @@ -87,7 +87,7 @@ protected: wxCoord MeasureItem(size_t item) const; // Returns true if image size was affected - virtual bool OnAddBitmap(const wxBitmap& bitmap); + virtual bool OnAddBitmap(const wxBitmapBundle& bitmap); // Recalculates amount of empty space needed in front of text // in control itself. Returns number that can be passed to @@ -97,7 +97,7 @@ protected: void UpdateInternals(); - wxArrayPtrVoid m_bitmaps; // Images associated with items + wxArrayPtrVoid m_bitmapbundles;// Images associated with items wxSize m_usedImgSize; // Size of bitmaps int m_imgAreaWidth; // Width and height of area next to text field diff --git a/include/wx/msw/bmpcbox.h b/include/wx/msw/bmpcbox.h index ef7d462b4d..2a62858e6a 100644 --- a/include/wx/msw/bmpcbox.h +++ b/include/wx/msw/bmpcbox.h @@ -82,21 +82,21 @@ public: virtual ~wxBitmapComboBox(); // Sets the image for the given item. - virtual void SetItemBitmap(unsigned int n, const wxBitmap& bitmap) wxOVERRIDE; + virtual void SetItemBitmap(unsigned int n, const wxBitmapBundle& bitmap) wxOVERRIDE; virtual bool SetFont(const wxFont& font) wxOVERRIDE; // Adds item with image to the end of the combo box. - int Append(const wxString& item, const wxBitmap& bitmap = wxNullBitmap); - int Append(const wxString& item, const wxBitmap& bitmap, void *clientData); - int Append(const wxString& item, const wxBitmap& bitmap, wxClientData *clientData); + int Append(const wxString& item, const wxBitmapBundle& bitmap = wxBitmapBundle()); + int Append(const wxString& item, const wxBitmapBundle& bitmap, void *clientData); + int Append(const wxString& item, const wxBitmapBundle& bitmap, wxClientData *clientData); // Inserts item with image into the list before pos. Not valid for wxCB_SORT // styles, use Append instead. - int Insert(const wxString& item, const wxBitmap& bitmap, unsigned int pos); - int Insert(const wxString& item, const wxBitmap& bitmap, + int Insert(const wxString& item, const wxBitmapBundle& bitmap, unsigned int pos); + int Insert(const wxString& item, const wxBitmapBundle& bitmap, unsigned int pos, void *clientData); - int Insert(const wxString& item, const wxBitmap& bitmap, + int Insert(const wxString& item, const wxBitmapBundle& bitmap, unsigned int pos, wxClientData *clientData); protected: @@ -119,7 +119,7 @@ protected: virtual void DoClear() wxOVERRIDE; virtual void DoDeleteOneItem(unsigned int n) wxOVERRIDE; - virtual bool OnAddBitmap(const wxBitmap& bitmap) wxOVERRIDE; + virtual bool OnAddBitmap(const wxBitmapBundle& bitmap) wxOVERRIDE; virtual wxSize DoGetBestSize() const wxOVERRIDE; void RecreateControl(); diff --git a/src/common/bmpcboxcmn.cpp b/src/common/bmpcboxcmn.cpp index 1ea298eff0..fd983f6434 100644 --- a/src/common/bmpcboxcmn.cpp +++ b/src/common/bmpcboxcmn.cpp @@ -48,7 +48,7 @@ const char wxBitmapComboBoxNameStr[] = "bitmapComboBox"; // This macros allows wxArrayPtrVoid to be used in more convenient manner -#define GetBitmapPtr(n) ((wxBitmap*)m_bitmaps[n]) +#define GetBitmapBundlePtr(n) ((wxBitmapBundle*)m_bitmapbundles[n]) // ---------------------------------------------------------------------------- @@ -68,24 +68,26 @@ void wxBitmapComboBoxBase::UpdateInternals() m_fontHeight = GetControl()->GetCharHeight() + GetControl()->FromDIP(EXTRA_FONT_HEIGHT); - while ( m_bitmaps.GetCount() < GetItemContainer()->GetCount() ) - m_bitmaps.Add( new wxBitmap() ); + while ( m_bitmapbundles.GetCount() < GetItemContainer()->GetCount() ) + m_bitmapbundles.Add( new wxBitmapBundle() ); } // ---------------------------------------------------------------------------- // Item manipulation // ---------------------------------------------------------------------------- -void wxBitmapComboBoxBase::DoSetItemBitmap(unsigned int n, const wxBitmap& bitmap) +void wxBitmapComboBoxBase::DoSetItemBitmap(unsigned int n, const wxBitmapBundle& bitmap) { - wxCHECK_RET( n < m_bitmaps.size(), "invalid item index" ); - *GetBitmapPtr(n) = bitmap; + wxCHECK_RET( n < m_bitmapbundles.size(), "invalid item index" ); + *GetBitmapBundlePtr(n) = bitmap; } wxBitmap wxBitmapComboBoxBase::GetItemBitmap(unsigned int n) const { - wxCHECK_MSG( n < m_bitmaps.size(), wxNullBitmap, "invalid item index" ); - return *GetBitmapPtr(n); + wxCHECK_MSG( n < m_bitmapbundles.size(), wxNullBitmap, "invalid item index" ); + return (*GetBitmapBundlePtr(n)).GetBitmapFor( + const_cast(this)->GetControl() + ); } // ---------------------------------------------------------------------------- @@ -94,10 +96,10 @@ wxBitmap wxBitmapComboBoxBase::GetItemBitmap(unsigned int n) const void wxBitmapComboBoxBase::BCBDoClear() { - for ( unsigned i = 0; i < m_bitmaps.size(); i++ ) - delete GetBitmapPtr(i); + for ( unsigned i = 0; i < m_bitmapbundles.size(); i++ ) + delete GetBitmapBundlePtr(i); - m_bitmaps.Empty(); + m_bitmapbundles.Empty(); m_usedImgSize.x = -1; m_usedImgSize.y = -1; @@ -107,20 +109,21 @@ void wxBitmapComboBoxBase::BCBDoClear() void wxBitmapComboBoxBase::BCBDoDeleteOneItem(unsigned int n) { - delete GetBitmapPtr(n); - m_bitmaps.RemoveAt(n); + delete GetBitmapBundlePtr(n); + m_bitmapbundles.RemoveAt(n); } // ---------------------------------------------------------------------------- // Preparation and Calculations // ---------------------------------------------------------------------------- -bool wxBitmapComboBoxBase::OnAddBitmap(const wxBitmap& bitmap) +bool wxBitmapComboBoxBase::OnAddBitmap(const wxBitmapBundle& bitmap) { if ( bitmap.IsOk() ) { - int width = bitmap.GetWidth(); - int height = bitmap.GetHeight(); + wxSize bmpDefaultSize = bitmap.GetPreferredLogicalSizeFor(GetControl()); + int width = bmpDefaultSize.GetWidth(); + int height = bmpDefaultSize.GetHeight(); if ( m_usedImgSize.x < 0 ) { @@ -157,7 +160,7 @@ int wxBitmapComboBoxBase::DetermineIndent() if ( m_usedImgSize.x > 0 ) { - indent = m_usedImgSize.x + indent = GetControl()->FromDIP(m_usedImgSize.x) + GetControl()->FromDIP(IMAGE_SPACING_LEFT) + GetControl()->FromDIP(IMAGE_SPACING_RIGHT); m_imgAreaWidth = indent; @@ -208,13 +211,15 @@ void wxBitmapComboBoxBase::DrawItem(wxDC& dc, const wxString& text, int WXUNUSED(flags)) const { - const wxBitmap& bmp = *GetBitmapPtr(item); - if ( bmp.IsOk() ) + const wxBitmapBundle& bb = *GetBitmapBundlePtr(item); + if ( bb.IsOk() ) { - wxCoord w = bmp.GetWidth(); - wxCoord h = bmp.GetHeight(); - const wxWindow* win = const_cast(this)->GetControl(); + wxBitmap bmp = bb.GetBitmapFor(win); + + wxCoord w = bmp.GetLogicalWidth(); + wxCoord h = bmp.GetLogicalHeight(); + const int imgSpacingLeft = win->FromDIP(IMAGE_SPACING_LEFT); // Draw the image centered diff --git a/src/msw/bmpcbox.cpp b/src/msw/bmpcbox.cpp index 0a2d167ad7..bfec96c274 100644 --- a/src/msw/bmpcbox.cpp +++ b/src/msw/bmpcbox.cpp @@ -236,7 +236,7 @@ wxSize wxBitmapComboBox::DoGetBestSize() const // Item manipulation // ---------------------------------------------------------------------------- -void wxBitmapComboBox::SetItemBitmap(unsigned int n, const wxBitmap& bitmap) +void wxBitmapComboBox::SetItemBitmap(unsigned int n, const wxBitmapBundle& bitmap) { OnAddBitmap(bitmap); DoSetItemBitmap(n, bitmap); @@ -245,7 +245,7 @@ void wxBitmapComboBox::SetItemBitmap(unsigned int n, const wxBitmap& bitmap) Refresh(); } -int wxBitmapComboBox::Append(const wxString& item, const wxBitmap& bitmap) +int wxBitmapComboBox::Append(const wxString& item, const wxBitmapBundle& bitmap) { OnAddBitmap(bitmap); const int n = wxComboBox::Append(item); @@ -254,7 +254,7 @@ int wxBitmapComboBox::Append(const wxString& item, const wxBitmap& bitmap) return n; } -int wxBitmapComboBox::Append(const wxString& item, const wxBitmap& bitmap, +int wxBitmapComboBox::Append(const wxString& item, const wxBitmapBundle& bitmap, void *clientData) { OnAddBitmap(bitmap); @@ -264,7 +264,7 @@ int wxBitmapComboBox::Append(const wxString& item, const wxBitmap& bitmap, return n; } -int wxBitmapComboBox::Append(const wxString& item, const wxBitmap& bitmap, +int wxBitmapComboBox::Append(const wxString& item, const wxBitmapBundle& bitmap, wxClientData *clientData) { OnAddBitmap(bitmap); @@ -275,7 +275,7 @@ int wxBitmapComboBox::Append(const wxString& item, const wxBitmap& bitmap, } int wxBitmapComboBox::Insert(const wxString& item, - const wxBitmap& bitmap, + const wxBitmapBundle& bitmap, unsigned int pos) { OnAddBitmap(bitmap); @@ -285,7 +285,7 @@ int wxBitmapComboBox::Insert(const wxString& item, return n; } -int wxBitmapComboBox::Insert(const wxString& item, const wxBitmap& bitmap, +int wxBitmapComboBox::Insert(const wxString& item, const wxBitmapBundle& bitmap, unsigned int pos, void *clientData) { OnAddBitmap(bitmap); @@ -295,7 +295,7 @@ int wxBitmapComboBox::Insert(const wxString& item, const wxBitmap& bitmap, return n; } -int wxBitmapComboBox::Insert(const wxString& item, const wxBitmap& bitmap, +int wxBitmapComboBox::Insert(const wxString& item, const wxBitmapBundle& bitmap, unsigned int pos, wxClientData *clientData) { OnAddBitmap(bitmap); @@ -332,16 +332,16 @@ int wxBitmapComboBox::DoInsertItems(const wxArrayStringsAdapter & items, } // Update the bitmap array. - if ( GetCount() > m_bitmaps.Count() ) + if ( GetCount() > m_bitmapbundles.Count() ) { - wxASSERT_MSG( GetCount() == m_bitmaps.Count() + 1, + wxASSERT_MSG( GetCount() == m_bitmapbundles.Count() + 1, wxS("Invalid wxBitmapComboBox state") ); // Control is in the normal state. // New item has been just added. // Insert bitmap at the given index into the array. - wxASSERT_MSG( (size_t)index <= m_bitmaps.Count(), + wxASSERT_MSG( (size_t)index <= m_bitmapbundles.Count(), wxS("wxBitmapComboBox item index out of bound") ); - m_bitmaps.Insert(new wxBitmap(wxNullBitmap), index); + m_bitmapbundles.Insert(new wxBitmapBundle(wxNullBitmap), index); } else { @@ -350,7 +350,7 @@ int wxBitmapComboBox::DoInsertItems(const wxArrayStringsAdapter & items, // In this case existing bitmaps are reused. // Required and actual indices should be the same to assure // consistency between list of items and bitmap array. - wxASSERT_MSG( (size_t)index < m_bitmaps.Count(), + wxASSERT_MSG( (size_t)index < m_bitmapbundles.Count(), wxS("wxBitmapComboBox item index out of bound") ); wxASSERT_MSG( (unsigned int)index == pos+i, wxS("Invalid index for wxBitmapComboBox item") ); @@ -359,28 +359,28 @@ int wxBitmapComboBox::DoInsertItems(const wxArrayStringsAdapter & items, } else { - if ( GetCount() == m_bitmaps.Count() ) + if ( GetCount() == m_bitmapbundles.Count() ) { // Control is in the normal state. // Just insert new bitmaps into the array. const unsigned int countNew = GetCount() + numItems; - m_bitmaps.Alloc(countNew); + m_bitmapbundles.Alloc(countNew); for ( unsigned int i = 0; i < numItems; i++ ) { - m_bitmaps.Insert(new wxBitmap(wxNullBitmap), pos + i); + m_bitmapbundles.Insert(new wxBitmapBundle(wxNullBitmap), pos + i); } } else { - wxASSERT_MSG( GetCount() < m_bitmaps.Count(), + wxASSERT_MSG( GetCount() < m_bitmapbundles.Count(), wxS("Invalid wxBitmapComboBox state") ); // There are less items then bitmaps. // (This can happen if control is e.g. recreated with RecreateControl). // In this case existing bitmaps are reused. // The whole block of inserted items should be within the range // of indices of the existing bitmap array. - wxASSERT_MSG( pos + numItems <= m_bitmaps.Count(), + wxASSERT_MSG( pos + numItems <= m_bitmapbundles.Count(), wxS("wxBitmapComboBox item index out of bound") ); } @@ -405,7 +405,7 @@ int wxBitmapComboBox::DoInsertItems(const wxArrayStringsAdapter & items, return index; } -bool wxBitmapComboBox::OnAddBitmap(const wxBitmap& bitmap) +bool wxBitmapComboBox::OnAddBitmap(const wxBitmapBundle& bitmap) { if ( wxBitmapComboBoxBase::OnAddBitmap(bitmap) || !GetCount() ) {