Merge branch 'msw-about'
Improve "About" dialog appearance under MSW. See #23294.
This commit is contained in:
commit
1a314b4e10
5 changed files with 51 additions and 23 deletions
Binary file not shown.
|
Before Width: | Height: | Size: 18 KiB After Width: | Height: | Size: 20 KiB |
|
|
@ -42,13 +42,11 @@ public:
|
|||
// --------------------------------
|
||||
|
||||
// default ctor, you must use Create() to really initialize the dialog
|
||||
wxGenericAboutDialog() { Init(); }
|
||||
wxGenericAboutDialog() = default;
|
||||
|
||||
// ctor which fully initializes the object
|
||||
wxGenericAboutDialog(const wxAboutDialogInfo& info, wxWindow* parent = nullptr)
|
||||
{
|
||||
Init();
|
||||
|
||||
(void)Create(info, parent);
|
||||
}
|
||||
|
||||
|
|
@ -80,9 +78,6 @@ protected:
|
|||
#endif // wxUSE_COLLPANE
|
||||
|
||||
private:
|
||||
// common part of all ctors
|
||||
void Init() { m_sizerText = nullptr; }
|
||||
|
||||
#if !wxUSE_MODAL_ABOUT_DIALOG
|
||||
// An explicit handler for deleting the dialog when it's closed is needed
|
||||
// when we show it non-modally.
|
||||
|
|
@ -90,7 +85,10 @@ private:
|
|||
void OnOK(wxCommandEvent& event);
|
||||
#endif // !wxUSE_MODAL_ABOUT_DIALOG
|
||||
|
||||
wxSizer *m_sizerText;
|
||||
// The panel containing the dialog contents.
|
||||
wxPanel *m_contents = nullptr;
|
||||
|
||||
wxSizer *m_sizerText = nullptr;
|
||||
};
|
||||
|
||||
// unlike wxAboutBox which can show either the native or generic about dialog,
|
||||
|
|
|
|||
|
|
@ -146,6 +146,10 @@ public:
|
|||
any occurrences of @c "(C)" in @a copyright will be replaced by the
|
||||
copyright symbol (circled C) automatically, which means that you can avoid
|
||||
using this symbol in the program source code which can be problematic,
|
||||
|
||||
Also note that under MSW platform the word "Copyright" itself will be
|
||||
removed from the string if it is followed by the copyright symbol, to
|
||||
follow the platform convention.
|
||||
*/
|
||||
void SetCopyright(const wxString& copyright);
|
||||
|
||||
|
|
|
|||
|
|
@ -3407,7 +3407,7 @@ static void InitAboutInfoMinimal(wxAboutDialogInfo& info)
|
|||
wxVERSION_NUM_DOT_STRING
|
||||
));
|
||||
info.SetDescription("This sample shows different wxWidgets dialogs.");
|
||||
info.SetCopyright("(C) 1998-2023 wxWidgets dev team.");
|
||||
info.SetCopyright("Copyright (C) 1998-2023 wxWidgets dev team.");
|
||||
}
|
||||
|
||||
static void InitAboutInfoWebsite(wxAboutDialogInfo& info)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,8 @@
|
|||
#if wxUSE_ABOUTDLG
|
||||
|
||||
#ifndef WX_PRECOMP
|
||||
#include "wx/panel.h"
|
||||
#include "wx/settings.h"
|
||||
#include "wx/sizer.h"
|
||||
#include "wx/statbmp.h"
|
||||
#include "wx/stattext.h"
|
||||
|
|
@ -100,6 +102,14 @@ wxString wxAboutDialogInfo::GetCopyrightToDisplay() const
|
|||
ret.Replace("(c)", copyrightSign);
|
||||
ret.Replace("(C)", copyrightSign);
|
||||
|
||||
#ifdef __WXMSW__
|
||||
// Under MSW the dialogs typically show only "(C)" and "Copyright (C)", but
|
||||
// under other platforms dialogs do use the word "Copyright" too, so to
|
||||
// make it simpler to do the right thing under all platforms, remove the
|
||||
// extra word here.
|
||||
ret.Replace("Copyright " + copyrightSign, copyrightSign);
|
||||
#endif // __WXMSW__
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -136,17 +146,20 @@ bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info, wxWindow* paren
|
|||
wxDefaultPosition, wxDefaultSize, wxRESIZE_BORDER|wxDEFAULT_DIALOG_STYLE) )
|
||||
return false;
|
||||
|
||||
m_contents = new wxPanel(this);
|
||||
m_contents->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX));
|
||||
|
||||
m_sizerText = new wxBoxSizer(wxVERTICAL);
|
||||
wxString nameAndVersion = info.GetName();
|
||||
if ( info.HasVersion() )
|
||||
nameAndVersion << wxT(' ') << info.GetVersion();
|
||||
wxStaticText *label = new wxStaticText(this, wxID_ANY, nameAndVersion);
|
||||
wxStaticText *label = new wxStaticText(m_contents, wxID_ANY, nameAndVersion);
|
||||
wxFont fontBig(*wxNORMAL_FONT);
|
||||
fontBig.SetFractionalPointSize(fontBig.GetFractionalPointSize() + 2.0);
|
||||
fontBig.SetWeight(wxFONTWEIGHT_BOLD);
|
||||
label->SetFont(fontBig);
|
||||
|
||||
m_sizerText->Add(label, wxSizerFlags().Centre().Border());
|
||||
m_sizerText->Add(label, wxSizerFlags().Border(wxTOP|wxDOWN));
|
||||
m_sizerText->AddSpacer(wxSizerFlags::GetDefaultBorder());
|
||||
|
||||
AddText(info.GetDescription());
|
||||
|
|
@ -154,7 +167,7 @@ bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info, wxWindow* paren
|
|||
if ( info.HasWebSite() )
|
||||
{
|
||||
#if wxUSE_HYPERLINKCTRL
|
||||
AddControl(new wxHyperlinkCtrl(this, wxID_ANY,
|
||||
AddControl(new wxHyperlinkCtrl(m_contents, wxID_ANY,
|
||||
info.GetWebSiteDescription(),
|
||||
info.GetWebSiteURL()));
|
||||
#else
|
||||
|
|
@ -200,30 +213,45 @@ bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info, wxWindow* paren
|
|||
|
||||
wxSizer *sizerIconAndText = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
wxSizerFlags flagsText = wxSizerFlags(1).Expand();
|
||||
int horzBorder = 2*wxSizerFlags::GetDefaultBorder();
|
||||
sizerIconAndText->AddSpacer(horzBorder);
|
||||
|
||||
#if wxUSE_STATBMP
|
||||
wxIcon icon = info.GetIcon();
|
||||
if ( icon.IsOk() )
|
||||
{
|
||||
sizerIconAndText->Add(new wxStaticBitmap(this, wxID_ANY, icon),
|
||||
wxSizerFlags().Border(wxRIGHT));
|
||||
sizerIconAndText->Add(new wxStaticBitmap(m_contents, wxID_ANY, icon),
|
||||
wxSizerFlags().DoubleBorder(wxTOP));
|
||||
|
||||
sizerIconAndText->AddSpacer(horzBorder);
|
||||
|
||||
// Add a border to the right of the text to make the layout slightly
|
||||
// more symmetrical.
|
||||
flagsText.DoubleBorder(wxRIGHT);
|
||||
horzBorder *= 2;
|
||||
}
|
||||
#endif // wxUSE_STATBMP
|
||||
sizerIconAndText->Add(m_sizerText, flagsText);
|
||||
sizerIconAndText->Add(m_sizerText, wxSizerFlags(1).Expand().DoubleBorder(wxTOP));
|
||||
sizerIconAndText->AddSpacer(horzBorder);
|
||||
|
||||
m_contents->SetSizer(sizerIconAndText);
|
||||
|
||||
wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
|
||||
sizerTop->Add(sizerIconAndText, wxSizerFlags(1).Expand().DoubleBorder());
|
||||
sizerTop->Add(m_contents, wxSizerFlags(1).Expand());
|
||||
|
||||
// Mac typically doesn't use OK buttons just for dismissing dialogs.
|
||||
#if !defined(__WXMAC__)
|
||||
wxSizer *sizerBtns = CreateButtonSizer(wxOK);
|
||||
if ( sizerBtns )
|
||||
{
|
||||
sizerTop->Add(sizerBtns, wxSizerFlags().Expand().Border());
|
||||
// A wxStaticLine would be too heavy here, but a single line of
|
||||
// slightly different colour separates the contents from the buttons
|
||||
// better and is similar to how the native MSW message box looks.
|
||||
wxWindow* const separator = new wxWindow(this, wxID_ANY);
|
||||
separator->SetInitialSize(wxSize(1, 1));
|
||||
separator->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DLIGHT));
|
||||
sizerTop->Add(separator, wxSizerFlags().Expand());
|
||||
|
||||
sizerTop->Add(sizerBtns, wxSizerFlags().Expand().DoubleBorder());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -249,7 +277,7 @@ void wxGenericAboutDialog::AddControl(wxWindow *win, const wxSizerFlags& flags)
|
|||
|
||||
void wxGenericAboutDialog::AddControl(wxWindow *win)
|
||||
{
|
||||
AddControl(win, wxSizerFlags().Border(wxDOWN).Centre());
|
||||
AddControl(win, wxSizerFlags().Border(wxDOWN));
|
||||
}
|
||||
|
||||
wxStaticText* wxGenericAboutDialog::AddText(const wxString& text)
|
||||
|
|
@ -257,9 +285,7 @@ wxStaticText* wxGenericAboutDialog::AddText(const wxString& text)
|
|||
if ( text.empty() )
|
||||
return nullptr;
|
||||
|
||||
auto *win = new wxStaticText(this, wxID_ANY, text,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
wxALIGN_CENTRE);
|
||||
auto *win = new wxStaticText(m_contents, wxID_ANY, text);
|
||||
AddControl(win);
|
||||
|
||||
return win;
|
||||
|
|
@ -269,7 +295,7 @@ wxStaticText* wxGenericAboutDialog::AddText(const wxString& text)
|
|||
void wxGenericAboutDialog::AddCollapsiblePane(const wxString& title,
|
||||
const wxString& text)
|
||||
{
|
||||
wxCollapsiblePane *pane = new wxCollapsiblePane(this, wxID_ANY, title);
|
||||
wxCollapsiblePane *pane = new wxCollapsiblePane(m_contents, wxID_ANY, title);
|
||||
wxWindow * const paneContents = pane->GetPane();
|
||||
wxStaticText *txt = new wxStaticText(paneContents, wxID_ANY, text,
|
||||
wxDefaultPosition, wxDefaultSize,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue