// 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(", "));
return s;
}
+// ----------------------------------------------------------------------------
+// wxAboutDialogInfo
+// ----------------------------------------------------------------------------
+
wxString wxAboutDialogInfo::GetDescriptionAndCredits() const
{
wxString s = GetDescription();
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;
}
#if wxUSE_COLLPANE
- // add licence
if ( info.HasLicence() )
- {
- wxCollapsiblePane *
- licensepnl = new wxCollapsiblePane(this, wxID_ANY, wxT("License"));
+ AddCollapsiblePane(_("License"), info.GetLicence());
- new wxStaticText(licensepnl->GetPane(), wxID_ANY, info.GetLicence(),
- wxDefaultPosition, wxDefaultSize,
- wxALIGN_CENTRE);
+ if ( info.HasDevelopers() )
+ AddCollapsiblePane(_("Developers"),
+ AllAsString(info.GetDevelopers()));
- m_sizerText->Add(licensepnl, wxSizerFlags(1).Expand().Border(wxBOTTOM));
- }
-#endif // wxUSE_COLLPANE
+ 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();
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
// ----------------------------------------------------------------------------