From b9993189cc61b29d68dfa255d4f23d58e16cadc2 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 12 Nov 2006 21:43:27 +0000 Subject: [PATCH] show all available information in the dialog (somewhat modified patch 1592306) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43372 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/aboutdlgg.h | 3 ++ src/generic/aboutdlgg.cpp | 51 ++++++++++++++++++++++++---------- 2 files changed, 39 insertions(+), 15 deletions(-) diff --git a/include/wx/generic/aboutdlgg.h b/include/wx/generic/aboutdlgg.h index 421fbe452b..9eaf9a4bfa 100644 --- a/include/wx/generic/aboutdlgg.h +++ b/include/wx/generic/aboutdlgg.h @@ -64,6 +64,9 @@ protected: // add the text, if it's not empty, to the text sizer contents void AddText(const wxString& text); + // add a wxCollapsiblePane containing the given text + void AddCollapsiblePane(const wxString& title, const wxString& text); + private: // common part of all ctors void Init() { m_sizerText = NULL; } diff --git a/src/generic/aboutdlgg.cpp b/src/generic/aboutdlgg.cpp index 542020e699..33cd027719 100644 --- a/src/generic/aboutdlgg.cpp +++ b/src/generic/aboutdlgg.cpp @@ -42,16 +42,13 @@ // implementation // ============================================================================ -// ---------------------------------------------------------------------------- -// wxAboutDialogInfo -// ---------------------------------------------------------------------------- - // helper function: returns all array elements in a single comma-separated and // newline-terminated string static wxString AllAsString(const wxArrayString& a) { wxString s; const size_t count = a.size(); + s.reserve(20*count); for ( size_t n = 0; n < count; n++ ) { s << a[n] << (n == count - 1 ? _T("\n") : _T(", ")); @@ -60,6 +57,10 @@ static wxString AllAsString(const wxArrayString& a) return s; } +// ---------------------------------------------------------------------------- +// wxAboutDialogInfo +// ---------------------------------------------------------------------------- + wxString wxAboutDialogInfo::GetDescriptionAndCredits() const { wxString s = GetDescription(); @@ -134,22 +135,26 @@ bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info) } #if wxUSE_COLLPANE - // add licence if ( info.HasLicence() ) - { - wxCollapsiblePane * - licensepnl = new wxCollapsiblePane(this, wxID_ANY, wxT("License")); + AddCollapsiblePane(wxT("License"), info.GetLicence()); - new wxStaticText(licensepnl->GetPane(), wxID_ANY, info.GetLicence(), - wxDefaultPosition, wxDefaultSize, - wxALIGN_CENTRE); + if ( info.HasDevelopers() ) + AddCollapsiblePane(wxT("Developers"), + AllAsString(info.GetDevelopers())); - m_sizerText->Add(licensepnl, wxSizerFlags(1).Expand().Border(wxBOTTOM)); - } + if ( info.HasDocWriters() ) + AddCollapsiblePane(wxT("Documentation writers"), + AllAsString(info.GetDocWriters())); + + if ( info.HasArtists() ) + AddCollapsiblePane(wxT("Artists"), + AllAsString(info.GetArtists())); + + if ( info.HasTranslators() ) + AddCollapsiblePane(wxT("Translators"), + AllAsString(info.GetTranslators())); #endif // wxUSE_COLLPANE - // TODO: add credits (developers, artists, doc writers, translators) - DoAddCustomControls(); @@ -199,6 +204,22 @@ void wxGenericAboutDialog::AddText(const wxString& text) AddControl(new wxStaticText(this, wxID_ANY, text)); } +void wxGenericAboutDialog::AddCollapsiblePane(const wxString& title, + const wxString& text) +{ + wxCollapsiblePane *pane = new wxCollapsiblePane(this, wxID_ANY, title); + wxStaticText *txt = new wxStaticText(pane->GetPane(), wxID_ANY, text, + wxDefaultPosition, wxDefaultSize, + wxALIGN_CENTRE); + + // don't make the text unreasonably wide + static const int maxWidth = wxGetDisplaySize().x/3; + txt->Wrap(maxWidth); + + // NB: all the wxCollapsiblePanes must be added with a null proportion value + m_sizerText->Add(pane, wxSizerFlags(0).Expand().Border(wxBOTTOM)); +} + // ---------------------------------------------------------------------------- // public functions // ----------------------------------------------------------------------------