#ifndef WX_PRECOMP
#include "wx/sizer.h"
-
#include "wx/statbmp.h"
#include "wx/stattext.h"
+ #include "wx/button.h"
#endif //WX_PRECOMP
#include "wx/aboutdlg.h"
#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(", "));
return s;
}
+// ----------------------------------------------------------------------------
+// wxAboutDialogInfo
+// ----------------------------------------------------------------------------
+
wxString wxAboutDialogInfo::GetDescriptionAndCredits() const
{
wxString s = GetDescription();
s << _T('\n') << _("Developed by ") << AllAsString(GetDevelopers());
if ( HasDocWriters() )
- s << _T('\n') << ("Documentation by ") << AllAsString(GetDocWriters());
+ s << _T('\n') << _("Documentation by ") << AllAsString(GetDocWriters());
if ( HasArtists() )
- s << _T('\n') << ("Graphics art by ") << AllAsString(GetArtists());
+ s << _T('\n') << _("Graphics art by ") << AllAsString(GetArtists());
if ( HasTranslators() )
- s << _T('\n') << ("Translations by ") << AllAsString(GetTranslators());
+ s << _T('\n') << _("Translations by ") << AllAsString(GetTranslators());
return s;
}
return icon;
}
+wxString wxAboutDialogInfo::GetCopyrightToDisplay() const
+{
+ wxString ret = m_copyright;
+
+ const wxString copyrightSign = wxString::FromUTF8("\xc2\xa9");
+ ret.Replace("(c)", copyrightSign);
+ ret.Replace("(C)", copyrightSign);
+
+ return ret;
+}
+
// ----------------------------------------------------------------------------
// wxGenericAboutDialog
// ----------------------------------------------------------------------------
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);
m_sizerText->Add(label, wxSizerFlags().Centre().Border());
m_sizerText->AddSpacer(5);
- AddText(info.GetCopyright());
+ AddText(info.GetCopyrightToDisplay());
AddText(info.GetDescription());
if ( info.HasWebSite() )
#endif // wxUSE_HYPERLINKCTRL/!wxUSE_HYPERLINKCTRL
}
- // TODO: add licence
+#if wxUSE_COLLPANE
+ if ( info.HasLicence() )
+ AddCollapsiblePane(_("License"), info.GetLicence());
- // TODO: add credits (developers, artists, doc writers, translators)
+ if ( info.HasDevelopers() )
+ AddCollapsiblePane(_("Developers"),
+ AllAsString(info.GetDevelopers()));
+
+ if ( info.HasDocWriters() )
+ AddCollapsiblePane(_("Documentation writers"),
+ AllAsString(info.GetDocWriters()));
+
+ if ( info.HasArtists() )
+ AddCollapsiblePane(_("Artists"),
+ AllAsString(info.GetArtists()));
+
+ if ( info.HasTranslators() )
+ AddCollapsiblePane(_("Translators"),
+ AllAsString(info.GetTranslators()));
+#endif // wxUSE_COLLPANE
DoAddCustomControls();
wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
sizerTop->Add(sizerIconAndText, wxSizerFlags(1).Expand().Border());
- sizerTop->Add(new wxButton(this, wxID_OK), wxSizerFlags().Right().Border());
+
+ wxSizer *sizerBtns = CreateButtonSizer(wxOK);
+ if ( sizerBtns )
+ {
+ sizerTop->Add(sizerBtns, wxSizerFlags().Expand().Border());
+ }
+
SetSizerAndFit(sizerTop);
CentreOnScreen();
+
return true;
}
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
// ----------------------------------------------------------------------------