Merge branch 'msw-about'

Improve generic and MSW "About" dialog appearance.

See #23196.
This commit is contained in:
Vadim Zeitlin 2023-02-03 15:11:48 +01:00
commit 0a1b0fbe01
11 changed files with 42 additions and 18 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 190 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View file

@ -19,6 +19,7 @@
class WXDLLIMPEXP_FWD_CORE wxAboutDialogInfo;
class WXDLLIMPEXP_FWD_CORE wxSizer;
class WXDLLIMPEXP_FWD_CORE wxSizerFlags;
class WXDLLIMPEXP_FWD_CORE wxStaticText;
// Under GTK and OS X "About" dialogs are not supposed to be modal, unlike MSW
// and, presumably, all the other platforms.
@ -71,7 +72,7 @@ protected:
void AddControl(wxWindow *win);
// add the text, if it's not empty, to the text sizer contents
void AddText(const wxString& text);
wxStaticText* AddText(const wxString& text);
#if wxUSE_COLLPANE
// add a wxCollapsiblePane containing the given text

View file

@ -45,6 +45,13 @@
}
@endcode
Example of appearance of a simple about dialog:
@appearance{about-simple}
And that of a dialog using a web site link, which results in using the
generic version under MSW and Mac:
@appearance{about-with-url}
@library{wxcore}
@category{cmndlg,data}

View file

@ -3406,9 +3406,8 @@ static void InitAboutInfoMinimal(wxAboutDialogInfo& info)
wxMINOR_VERSION % 2 ? "Development" : "Stable",
wxVERSION_NUM_DOT_STRING
));
info.SetDescription("This sample shows different wxWidgets dialogs");
info.SetCopyright("(C) 1998-2006 wxWidgets dev team");
info.AddDeveloper("Vadim Zeitlin");
info.SetDescription("This sample shows different wxWidgets dialogs.");
info.SetCopyright("(C) 1998-2023 wxWidgets dev team.");
}
static void InitAboutInfoWebsite(wxAboutDialogInfo& info)
@ -3422,7 +3421,8 @@ static void InitAboutInfoAll(wxAboutDialogInfo& info)
{
InitAboutInfoWebsite(info);
// we can add a second developer
// we can add several developers one by one
info.AddDeveloper("Vadim Zeitlin");
info.AddDeveloper("A.N. Other");
// or we can add several persons at once like this
@ -3431,6 +3431,7 @@ static void InitAboutInfoAll(wxAboutDialogInfo& info)
docwriters.Add("Second One");
info.SetDocWriters(docwriters);
info.SetLicence(wxString::FromAscii(
" wxWindows Library Licence, Version 3.1\n"
" ======================================\n"

View file

@ -147,9 +147,8 @@ bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info, wxWindow* paren
label->SetFont(fontBig);
m_sizerText->Add(label, wxSizerFlags().Centre().Border());
m_sizerText->AddSpacer(5);
m_sizerText->AddSpacer(wxSizerFlags::GetDefaultBorder());
AddText(info.GetCopyrightToDisplay());
AddText(info.GetDescription());
if ( info.HasWebSite() )
@ -186,6 +185,18 @@ bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info, wxWindow* paren
DoAddCustomControls();
// Separate the copyright from all the rest and use smaller font for it as
// is custom.
const wxString& copyrightText = info.GetCopyrightToDisplay();
if ( !copyrightText.empty() )
{
m_sizerText->AddSpacer(wxSizerFlags::GetDefaultBorder());
wxFont fontSmall(*wxNORMAL_FONT);
fontSmall.SetFractionalPointSize(fontSmall.GetFractionalPointSize() - 1.0);
AddText(copyrightText)->SetFont(fontSmall);
}
wxSizer *sizerIconAndText = new wxBoxSizer(wxHORIZONTAL);
#if wxUSE_STATBMP
@ -235,10 +246,17 @@ void wxGenericAboutDialog::AddControl(wxWindow *win)
AddControl(win, wxSizerFlags().Border(wxDOWN).Centre());
}
void wxGenericAboutDialog::AddText(const wxString& text)
wxStaticText* wxGenericAboutDialog::AddText(const wxString& text)
{
if ( !text.empty() )
AddControl(new wxStaticText(this, wxID_ANY, text));
if ( text.empty() )
return nullptr;
auto *win = new wxStaticText(this, wxID_ANY, text,
wxDefaultPosition, wxDefaultSize,
wxALIGN_CENTRE);
AddControl(win);
return win;
}
#if wxUSE_COLLPANE

View file

@ -45,19 +45,16 @@ void wxAboutBox(const wxAboutDialogInfo& info, wxWindow* parent)
wxString msg;
msg << name;
if ( info.HasVersion() )
{
msg << wxT('\n');
msg << info.GetLongVersion();
}
msg << wxT(' ') << info.GetVersion();
// Separate the title from the rest with an extra blank line.
msg << wxT("\n\n");
if ( info.HasCopyright() )
msg << info.GetCopyrightToDisplay() << wxT('\n');
// add everything remaining
msg << info.GetDescriptionAndCredits();
if ( info.HasCopyright() )
msg << wxT('\n') << info.GetCopyrightToDisplay();
wxMessageBox(msg, wxString::Format(_("About %s"), name), wxOK | wxCENTRE, parent);
}
else // simple "native" version is not enough