]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/aboutdlgg.cpp
Return optimal label width from DrawHeaderButton
[wxWidgets.git] / src / generic / aboutdlgg.cpp
index 61f0db4470fe6e2a8943bb1ebca3931e3fa8d5ce..33cd027719517c027d47860398bc70e120e0440d 100644 (file)
 // 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();
@@ -133,16 +134,26 @@ bool wxGenericAboutDialog::Create(const wxAboutDialogInfo& info)
 #endif // wxUSE_HYPERLINKCTRL/!wxUSE_HYPERLINKCTRL
     }
 
-    // add licence
-    wxCollapsiblePane *licensepnl = new wxCollapsiblePane(this, wxID_ANY, wxT("License"));
+#if wxUSE_COLLPANE
+    if ( info.HasLicence() )
+        AddCollapsiblePane(wxT("License"), info.GetLicence());
+
+    if ( info.HasDevelopers() )
+        AddCollapsiblePane(wxT("Developers"),
+                           AllAsString(info.GetDevelopers()));
 
-    new wxStaticText(licensepnl->GetPane(), wxID_ANY, info.GetLicence(),
-                     wxDefaultPosition, wxDefaultSize,
-                     wxALIGN_CENTRE);
+    if ( info.HasDocWriters() )
+        AddCollapsiblePane(wxT("Documentation writers"),
+                           AllAsString(info.GetDocWriters()));
 
-    m_sizerText->Add(licensepnl, wxSizerFlags(1).Expand().Border(wxBOTTOM));
+    if ( info.HasArtists() )
+        AddCollapsiblePane(wxT("Artists"),
+                           AllAsString(info.GetArtists()));
 
-    // TODO: add credits (developers, artists, doc writers, translators)
+    if ( info.HasTranslators() )
+        AddCollapsiblePane(wxT("Translators"),
+                           AllAsString(info.GetTranslators()));
+#endif // wxUSE_COLLPANE
 
     DoAddCustomControls();
 
@@ -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
 // ----------------------------------------------------------------------------