Add support for wxBitmapBundle to wxAboutBox See #22192
| ... | ... | @@ -15,6 +15,7 @@ |
| 15 | 15 | #if wxUSE_ABOUTDLG
|
| 16 | 16 | |
| 17 | 17 | #include "wx/app.h"
|
| 18 | +#include "wx/bmpbndl.h"
|
|
| 18 | 19 | #include "wx/icon.h"
|
| 19 | 20 | |
| 20 | 21 | // ----------------------------------------------------------------------------
|
| ... | ... | @@ -67,9 +68,9 @@ public: |
| 67 | 68 | const wxString& GetLicence() const { return m_licence; }
|
| 68 | 69 | |
| 69 | 70 | // icon to be shown in the dialog, defaults to the main frame icon
|
| 70 | - void SetIcon(const wxIcon& icon) { m_icon = icon; }
|
|
| 71 | + void SetIcon(const wxBitmapBundle& icon) { m_icon = icon; }
|
|
| 71 | 72 | bool HasIcon() const { return m_icon.IsOk(); }
|
| 72 | - wxIcon GetIcon() const;
|
|
| 73 | + wxIcon GetIcon(wxWindow* window = nullptr) const;
|
|
| 73 | 74 | |
| 74 | 75 | // web site for the program and its description (defaults to URL itself if
|
| 75 | 76 | // empty)
|
| ... | ... | @@ -149,7 +150,7 @@ private: |
| 149 | 150 | m_copyright,
|
| 150 | 151 | m_licence;
|
| 151 | 152 | |
| 152 | - wxIcon m_icon;
|
|
| 153 | + wxBitmapBundle m_icon;
|
|
| 153 | 154 | |
| 154 | 155 | wxString m_url,
|
| 155 | 156 | m_urlDesc;
|
| ... | ... | @@ -179,8 +179,12 @@ public: |
| 179 | 179 | |
| 180 | 180 | /**
|
| 181 | 181 | Returns the icon set by SetIcon().
|
| 182 | + |
|
| 183 | + @param window
|
|
| 184 | + If non-null, this is used to help select an icon based on window DPI.
|
|
| 185 | + New since wxWidgets 3.3.3.
|
|
| 182 | 186 | */
|
| 183 | - wxIcon GetIcon() const;
|
|
| 187 | + wxIcon GetIcon(wxWindow* window = nullptr) const;
|
|
| 184 | 188 | |
| 185 | 189 | /**
|
| 186 | 190 | Set the icon to be shown in the dialog. By default the icon of the main frame
|
| ... | ... | @@ -189,7 +193,7 @@ public: |
| 189 | 193 | used instead so you should avoid calling this function for maximally native
|
| 190 | 194 | look and feel.
|
| 191 | 195 | */
|
| 192 | - void SetIcon(const wxIcon& icon);
|
|
| 196 | + void SetIcon(const wxBitmapBundle& icon);
|
|
| 193 | 197 | |
| 194 | 198 | /**
|
| 195 | 199 | Returns @true if the licence string has been set.
|
| ... | ... | @@ -80,15 +80,26 @@ wxString wxAboutDialogInfo::GetDescriptionAndCredits() const |
| 80 | 80 | return s;
|
| 81 | 81 | }
|
| 82 | 82 | |
| 83 | -wxIcon wxAboutDialogInfo::GetIcon() const
|
|
| 83 | +wxIcon wxAboutDialogInfo::GetIcon(wxWindow* window) const
|
|
| 84 | 84 | {
|
| 85 | - wxIcon icon = m_icon;
|
|
| 86 | - if ( !icon.IsOk() )
|
|
| 85 | + if (window == nullptr)
|
|
| 86 | + window = wxApp::GetMainTopWindow();
|
|
| 87 | + wxBitmapBundle bundle(m_icon);
|
|
| 88 | + if ( !bundle.IsOk() )
|
|
| 87 | 89 | {
|
| 88 | 90 | const wxTopLevelWindow * const
|
| 89 | - tlw = wxDynamicCast(wxApp::GetMainTopWindow(), wxTopLevelWindow);
|
|
| 91 | + tlw = wxDynamicCast(wxGetTopLevelParent(window), wxTopLevelWindow);
|
|
| 90 | 92 | if ( tlw )
|
| 91 | - icon = tlw->GetIcon();
|
|
| 93 | + bundle = wxBitmapBundle::FromIconBundle(tlw->GetIcons());
|
|
| 94 | + }
|
|
| 95 | + |
|
| 96 | + wxIcon icon;
|
|
| 97 | + if (bundle.IsOk())
|
|
| 98 | + {
|
|
| 99 | + if (window)
|
|
| 100 | + icon = bundle.GetIconFor(window);
|
|
| 101 | + else
|
|
| 102 | + icon = bundle.GetIcon(wxDefaultSize);
|
|
| 92 | 103 | }
|
| 93 | 104 | |
| 94 | 105 | return icon;
|
| ... | ... | @@ -172,7 +172,7 @@ void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* parent) |
| 172 | 172 | gtk_about_dialog_set_license(dlg, nullptr);
|
| 173 | 173 | |
| 174 | 174 | static wxIcon s_icon;
|
| 175 | - s_icon = info.GetIcon();
|
|
| 175 | + s_icon = info.GetIcon(parent);
|
|
| 176 | 176 | const wxIcon& icon = s_icon;
|
| 177 | 177 | if ( icon.IsOk() )
|
| 178 | 178 | {
|
—
View it on GitLab.
You're receiving this email because of your account on gitlab.com. Manage all notifications · Help