From 0f5c2851f40facef6fe8e7f603df2cc6a90250a1 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 16 Oct 2021 20:01:28 +0200 Subject: [PATCH] Add wxToolBarTool::Get{Normal,Disabled}BitmapBundle() accessors The existing variants returning wxBitmap are insufficient for non-MSW ports where the toolbar bitmap size is unavailable otherwise, as GetToolBitmapSize() value doesn't really correspond to it (which is a problem on its own, but there is not much that can be done about it by now). Having these functions allows to retrieve the actually used bitmap size by using wxBitmapBundle::GetDefaultSize(). --- include/wx/tbarbase.h | 3 +++ interface/wx/toolbar.h | 20 ++++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/wx/tbarbase.h b/include/wx/tbarbase.h index c489d4c068..b6addcc4cf 100644 --- a/include/wx/tbarbase.h +++ b/include/wx/tbarbase.h @@ -146,6 +146,9 @@ public: { return m_kind == wxITEM_CHECK || m_kind == wxITEM_RADIO; } // attributes + wxBitmapBundle GetNormalBitmapBundle() const { return m_bmpNormal; } + wxBitmapBundle GetDisabledBitmapBundle() const { return m_bmpDisabled; } + wxBitmap GetNormalBitmap(const wxSize& size = wxDefaultSize) const { return m_bmpNormal.GetBitmap(size); } wxBitmap GetDisabledBitmap(const wxSize& size = wxDefaultSize) const diff --git a/interface/wx/toolbar.h b/interface/wx/toolbar.h index 35474cf509..19cf6a4506 100644 --- a/interface/wx/toolbar.h +++ b/interface/wx/toolbar.h @@ -112,6 +112,26 @@ public: bool IsToggled() const; bool CanBeToggled() const; + /** + Return the bundle containing normal tool bitmaps. + + This bundle may be invalid if the tool doesn't show a bitmap. + + @since 3.1.6 + */ + wxBitmapBundle GetNormalBitmapBundle() const; + + /** + Return the bundle containing disabled tool bitmaps. + + This bundle may be invalid if the tool doesn't show a bitmap or doesn't + have a specific disabled bitmap creates one automatically from the + normal bitmap. + + @since 3.1.6 + */ + wxBitmapBundle GetDisabledBitmapBundle() const; + wxBitmap GetNormalBitmap() const; wxBitmap GetDisabledBitmap() const;