Some small fixes for wxAboutBox HiDPI support

Always use the wxApp top window for default icon bundle, it's possible the
provided window is not the main one. Pass window argument to GetIcon() in
generic implementation. Make GetIcon() window parameter pointer-to-const.
This commit is contained in:
Paul Cornett
2026-05-21 15:17:38 -07:00
parent ee4fbdfb88
commit 47c35e67f5
3 changed files with 11 additions and 7 deletions
+1 -1
View File
@@ -70,7 +70,7 @@ public:
// icon to be shown in the dialog, defaults to the main frame icon
void SetIcon(const wxBitmapBundle& icon) { m_icon = icon; }
bool HasIcon() const { return m_icon.IsOk(); }
wxIcon GetIcon(wxWindow* window = nullptr) const;
wxIcon GetIcon(const wxWindow* window = nullptr) const;
// web site for the program and its description (defaults to URL itself if
// empty)
+1 -1
View File
@@ -184,7 +184,7 @@ public:
If non-null, this is used to help select an icon based on window DPI.
New since wxWidgets 3.3.3.
*/
wxIcon GetIcon(wxWindow* window = nullptr) const;
wxIcon GetIcon(const wxWindow* window = nullptr) const;
/**
Set the icon to be shown in the dialog. By default the icon of the main frame
+9 -5
View File
@@ -80,18 +80,22 @@ wxString wxAboutDialogInfo::GetDescriptionAndCredits() const
return s;
}
wxIcon wxAboutDialogInfo::GetIcon(wxWindow* window) const
wxIcon wxAboutDialogInfo::GetIcon(const wxWindow* window) const
{
if (window == nullptr)
window = wxApp::GetMainTopWindow();
wxBitmapBundle bundle(m_icon);
if ( !bundle.IsOk() )
{
const wxTopLevelWindow * const
tlw = wxDynamicCast(wxGetTopLevelParent(window), wxTopLevelWindow);
tlw = wxDynamicCast(wxApp::GetMainTopWindow(), wxTopLevelWindow);
if ( tlw )
{
bundle = wxBitmapBundle::FromIconBundle(tlw->GetIcons());
if (window == nullptr)
window = tlw;
}
}
else if (window == nullptr)
window = wxApp::GetMainTopWindow();
wxIcon icon;
if (bundle.IsOk())
@@ -229,7 +233,7 @@ bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info, wxWindow* paren
sizerIconAndText->AddSpacer(horzBorder);
#if wxUSE_STATBMP
wxIcon icon = info.GetIcon();
wxIcon icon = info.GetIcon(parent);
if ( icon.IsOk() )
{
sizerIconAndText->Add(new wxStaticBitmap(m_contents, wxID_ANY, icon),