Take wxBitmapBundle in wxMenuItem::SetBitmap() in all ports

Update the remaining ports to take wxBitmapBundle rather than wxBitmap
as well to make their API consistent with the tier 1 ports -- even if
there is no actual support for choosing the resolution-appropriate
bitmap in them yet.
This commit is contained in:
Vadim Zeitlin
2022-02-20 17:54:52 +01:00
parent dec0c1b5b6
commit 5fcea04d71
5 changed files with 22 additions and 24 deletions

View File

@@ -39,8 +39,8 @@ public:
// I'm not sure if this works but it silences the linker in the // I'm not sure if this works but it silences the linker in the
// menu sample. // menu sample.
// JJ // JJ
virtual void SetBitmap(const wxBitmap& bitmap) { m_bitmap = bitmap; } virtual void SetBitmap(const wxBitmapBundle& bitmap) { m_bitmap = bitmap; }
virtual const wxBitmap& GetBitmap() const { return m_bitmap; } virtual wxBitmap GetBitmap() const { return GetBitmapFromBundle(m_bitmap); }
// implementation from now on // implementation from now on
void CreateItem (WXWidget menu, wxMenuBar * menuBar, wxMenu * topMenu, void CreateItem (WXWidget menu, wxMenuBar * menuBar, wxMenu * topMenu,
@@ -59,7 +59,7 @@ private:
WXWidget m_buttonWidget; WXWidget m_buttonWidget;
wxMenuBar* m_menuBar; wxMenuBar* m_menuBar;
wxMenu* m_topMenu; // Top-level menu e.g. popup-menu wxMenu* m_topMenu; // Top-level menu e.g. popup-menu
wxBitmap m_bitmap; // Bitmap for menuitem, if any wxBitmapBundle m_bitmap; // Bitmap for menuitem, if any
wxDECLARE_DYNAMIC_CLASS(wxMenuItem); wxDECLARE_DYNAMIC_CLASS(wxMenuItem);
}; };

View File

@@ -35,8 +35,8 @@ public:
virtual void Check(bool check = true) wxOVERRIDE; virtual void Check(bool check = true) wxOVERRIDE;
virtual bool IsChecked() const wxOVERRIDE; virtual bool IsChecked() const wxOVERRIDE;
virtual void SetBitmap(const wxBitmap& bitmap); virtual void SetBitmap(const wxBitmapBundle& bitmap);
virtual const wxBitmap& GetBitmap() const { return m_bitmap; } virtual wxBitmap GetBitmap() const { return GetBitmapFromBundle(m_bitmap); }
virtual QAction *GetHandle() const; virtual QAction *GetHandle() const;
@@ -44,7 +44,7 @@ public:
private: private:
// Qt is using an action instead of a menu item. // Qt is using an action instead of a menu item.
wxQtAction *m_qtAction; wxQtAction *m_qtAction;
wxBitmap m_bitmap; wxBitmapBundle m_bitmap;
wxDECLARE_DYNAMIC_CLASS( wxMenuItem ); wxDECLARE_DYNAMIC_CLASS( wxMenuItem );
}; };

View File

@@ -37,16 +37,16 @@ public:
// we add some extra functions which are also available under MSW from // we add some extra functions which are also available under MSW from
// wxOwnerDrawn class - they will be moved to wxMenuItemBase later // wxOwnerDrawn class - they will be moved to wxMenuItemBase later
// hopefully // hopefully
void SetBitmaps(const wxBitmap& bmpChecked, void SetBitmaps(const wxBitmapBundle& bmpChecked,
const wxBitmap& bmpUnchecked = wxNullBitmap); const wxBitmapBundle& bmpUnchecked = wxBitmapBundle());
void SetBitmap(const wxBitmap& bmp) { SetBitmaps(bmp); } void SetBitmap(const wxBitmapBundle& bmp) { SetBitmaps(bmp); }
const wxBitmap& GetBitmap(bool checked = true) const wxBitmap GetBitmap(bool checked = true) const
{ return checked ? m_bmpChecked : m_bmpUnchecked; } { return GetBitmapFromBundle(checked ? m_bmpChecked : m_bmpUnchecked); }
void SetDisabledBitmap( const wxBitmap& bmpDisabled ) void SetDisabledBitmap( const wxBitmapBundle& bmpDisabled )
{ m_bmpDisabled = bmpDisabled; } { m_bmpDisabled = bmpDisabled; }
const wxBitmap& GetDisabledBitmap() const wxBitmap GetDisabledBitmap() const
{ return m_bmpDisabled; } { return GetBitmapFromBundle(m_bmpDisabled); }
// mark item as belonging to the given radio group // mark item as belonging to the given radio group
void SetAsRadioGroupStart(); void SetAsRadioGroupStart();
@@ -93,7 +93,7 @@ protected:
void UpdateAccelInfo(); void UpdateAccelInfo();
// the bitmaps (may be invalid, then they're not used) // the bitmaps (may be invalid, then they're not used)
wxBitmap m_bmpChecked, wxBitmapBundle m_bmpChecked,
m_bmpUnchecked, m_bmpUnchecked,
m_bmpDisabled; m_bmpDisabled;

View File

@@ -112,14 +112,14 @@ bool wxMenuItem::IsChecked() const
} }
void wxMenuItem::SetBitmap(const wxBitmap& bitmap) void wxMenuItem::SetBitmap(const wxBitmapBundle& bitmap)
{ {
if ( m_kind == wxITEM_NORMAL ) if ( m_kind == wxITEM_NORMAL )
{ {
m_bitmap = bitmap; m_bitmap = bitmap;
if ( !m_bitmap.IsNull() ) if ( m_bitmap.IsOk() )
{ {
m_qtAction->setIcon( QIcon(*m_bitmap.GetHandle()) ); m_qtAction->setIcon( QIcon(*GetBitmapFromBundle(m_bitmap).GetHandle()) );
} }
} }
else else

View File

@@ -1550,8 +1550,6 @@ wxMenuItem::wxMenuItem(wxMenu *parentMenu,
m_radioGroup.start = -1; m_radioGroup.start = -1;
m_isRadioGroupStart = false; m_isRadioGroupStart = false;
m_bmpDisabled = wxNullBitmap;
UpdateAccelInfo(); UpdateAccelInfo();
} }
@@ -1615,8 +1613,8 @@ void wxMenuItem::SetCheckable(bool checkable)
} }
} }
void wxMenuItem::SetBitmaps(const wxBitmap& bmpChecked, void wxMenuItem::SetBitmaps(const wxBitmapBundle& bmpChecked,
const wxBitmap& bmpUnchecked) const wxBitmapBundle& bmpUnchecked)
{ {
m_bmpChecked = bmpChecked; m_bmpChecked = bmpChecked;
m_bmpUnchecked = bmpUnchecked; m_bmpUnchecked = bmpUnchecked;