X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2be7beda2d186af20ce9f0cd2bc28352d890db77..8239070ba965672ed531d04f2109e4e4e1f3fbec:/src/generic/aboutdlgg.cpp diff --git a/src/generic/aboutdlgg.cpp b/src/generic/aboutdlgg.cpp index 11a545c816..09122a1c16 100644 --- a/src/generic/aboutdlgg.cpp +++ b/src/generic/aboutdlgg.cpp @@ -36,21 +36,19 @@ #include "wx/generic/aboutdlgg.h" #include "wx/hyperlink.h" +#include "wx/collpane.h" // ============================================================================ // 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(", ")); @@ -59,6 +57,10 @@ static wxString AllAsString(const wxArrayString& a) return s; } +// ---------------------------------------------------------------------------- +// wxAboutDialogInfo +// ---------------------------------------------------------------------------- + wxString wxAboutDialogInfo::GetDescriptionAndCredits() const { wxString s = GetDescription(); @@ -100,8 +102,9 @@ wxIcon wxAboutDialogInfo::GetIcon() const bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info) { - // TODO: should we use main frame as parent by default here? - if ( !wxDialog::Create(NULL, wxID_ANY, _("About ") + info.GetName()) ) + // this is a modal dialog thus we'll use GetParentForModalDialog: + if ( !wxDialog::Create(GetParentForModalDialog(), wxID_ANY, _("About ") + info.GetName(), + wxDefaultPosition, wxDefaultSize, wxRESIZE_BORDER|wxDEFAULT_DIALOG_STYLE) ) return false; m_sizerText = new wxBoxSizer(wxVERTICAL); @@ -131,9 +134,26 @@ bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info) #endif // wxUSE_HYPERLINKCTRL/!wxUSE_HYPERLINKCTRL } - // TODO: add licence +#if wxUSE_COLLPANE + if ( info.HasLicence() ) + AddCollapsiblePane(_("License"), info.GetLicence()); + + if ( info.HasDevelopers() ) + AddCollapsiblePane(_("Developers"), + AllAsString(info.GetDevelopers())); + + if ( info.HasDocWriters() ) + AddCollapsiblePane(_("Documentation writers"), + AllAsString(info.GetDocWriters())); - // TODO: add credits (developers, artists, doc writers, translators) + if ( info.HasArtists() ) + AddCollapsiblePane(_("Artists"), + AllAsString(info.GetArtists())); + + if ( info.HasTranslators() ) + AddCollapsiblePane(_("Translators"), + AllAsString(info.GetTranslators())); +#endif // wxUSE_COLLPANE DoAddCustomControls(); @@ -152,25 +172,16 @@ bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info) wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); sizerTop->Add(sizerIconAndText, wxSizerFlags(1).Expand().Border()); - const int defBorder = wxSizerFlags::GetDefaultBorder(); - wxSizer *buttonSizer = CreateButtonSizer( wxOK , false, defBorder ); - if(buttonSizer->GetChildren().GetCount() > 0 ) - { - sizerTop->Add( buttonSizer, 0, wxEXPAND | wxALL, defBorder ); - } - else + wxSizer *sizerBtns = CreateButtonSizer(wxOK); + if ( sizerBtns ) { - sizerTop->AddSpacer( defBorder ); - delete buttonSizer; + sizerTop->Add(sizerBtns, wxSizerFlags().Expand().Border()); } SetSizerAndFit(sizerTop); CentreOnScreen(); - wxWindow *ok = FindWindow(wxID_OK); - if (ok) ok->SetFocus(); - return true; } @@ -193,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 // ----------------------------------------------------------------------------