mirror of
https://github.com/wxWidgets/wxWidgets.git
synced 2026-08-17 08:53:06 +08:00
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:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user