Add wxMSW-specific wxBitmapBundle accessors to wxMenuItem

Provide GetBitmapBundle(bool checked) and GetDisabledBitmapBundle() too
in wxMSW, for consistency with the existing MSW-only member functions
returning bitmaps.

See #25705.

Closes #25685.
This commit is contained in:
Vadim Zeitlin
2025-08-22 00:43:19 +02:00
parent 0aefcd7e9b
commit 0dfe37a643
3 changed files with 32 additions and 1 deletions
+7
View File
@@ -83,6 +83,11 @@ public:
DoSetBitmap(bmp, bChecked);
}
wxBitmapBundle GetBitmapBundle(bool bChecked) const
{
return bChecked ? m_bitmap : m_bmpUnchecked;
}
wxBitmap GetBitmap(bool bChecked) const;
#if wxUSE_OWNER_DRAWN
@@ -92,6 +97,8 @@ public:
SetOwnerDrawn(true);
}
wxBitmapBundle GetDisabledBitmapBundle() const { return m_bmpDisabled; }
wxBitmap GetDisabledBitmap() const;
int MeasureAccelWidth() const;
+24
View File
@@ -179,6 +179,9 @@ public:
/**
Returns the checked or unchecked bitmap.
Prefer using GetBitmapBundle() overload taking @a checked parameter in
the new code.
This overload only exists in wxMSW, avoid using it in portable code.
*/
wxBitmap GetBitmap(bool checked) const;
@@ -195,13 +198,34 @@ public:
*/
wxBitmapBundle GetBitmapBundle() const;
/**
Returns the bitmap bundle containing the checked or unchecked bitmap
for this item.
@onlyfor{wxmsw}
@since 3.3.2
*/
wxBitmapBundle GetBitmapBundle(bool checked) const;
/**
Returns the bitmap used for disabled items.
@see GetDisabledBitmapBundle()
@onlyfor{wxmsw}
*/
virtual wxBitmap GetDisabledBitmap() const;
/**
Returns the bitmap bundle used for disabled items.
@onlyfor{wxmsw}
@since 3.3.2
*/
wxBitmap GetDisabledBitmapBundle() const;
/**
Returns the font associated with the menu item.
+1 -1
View File
@@ -663,7 +663,7 @@ void wxMenuItem::SetItemLabel(const wxString& txt)
wxBitmap wxMenuItem::GetBitmap(bool bChecked) const
{
wxBitmap bmp = GetBitmapFromBundle(bChecked ? m_bitmap : m_bmpUnchecked);
wxBitmap bmp = GetBitmapFromBundle(GetBitmapBundle(bChecked));
#if wxUSE_IMAGE
if ( bmp.IsOk() )
{