X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cfa643708102b8f50f6251eea0623c57b2de86d3..fea909e19e86b8da2d54c530d3a89ee9456c3333:/src/generic/aboutdlgg.cpp?ds=inline diff --git a/src/generic/aboutdlgg.cpp b/src/generic/aboutdlgg.cpp index 2bd702fe67..21a6a05754 100644 --- a/src/generic/aboutdlgg.cpp +++ b/src/generic/aboutdlgg.cpp @@ -27,9 +27,9 @@ #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" @@ -38,10 +38,67 @@ #include "wx/hyperlink.h" // ============================================================================ -// wxAboutDialog implementation +// implementation // ============================================================================ -bool wxAboutDialog::Create(const wxAboutDialogInfo& info) +// ---------------------------------------------------------------------------- +// 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(); + for ( size_t n = 0; n < count; n++ ) + { + s << a[n] << (n == count - 1 ? _T("\n") : _T(", ")); + } + + return s; +} + +wxString wxAboutDialogInfo::GetDescriptionAndCredits() const +{ + wxString s = GetDescription(); + if ( !s.empty() ) + s << _T('\n'); + + if ( HasDevelopers() ) + s << _T('\n') << _("Developed by ") << AllAsString(GetDevelopers()); + + if ( HasDocWriters() ) + s << _T('\n') << _("Documentation by ") << AllAsString(GetDocWriters()); + + if ( HasArtists() ) + s << _T('\n') << _("Graphics art by ") << AllAsString(GetArtists()); + + if ( HasTranslators() ) + s << _T('\n') << _("Translations by ") << AllAsString(GetTranslators()); + + return s; +} + +wxIcon wxAboutDialogInfo::GetIcon() const +{ + wxIcon icon = m_icon; + if ( !icon.Ok() && wxTheApp ) + { + const wxTopLevelWindow * const + tlw = wxDynamicCast(wxTheApp->GetTopWindow(), wxTopLevelWindow); + if ( tlw ) + icon = tlw->GetIcon(); + } + + return icon; +} + +// ---------------------------------------------------------------------------- +// 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()) ) @@ -78,18 +135,12 @@ bool wxAboutDialog::Create(const wxAboutDialogInfo& info) // TODO: add credits (developers, artists, doc writers, translators) + DoAddCustomControls(); + wxSizer *sizerIconAndText = new wxBoxSizer(wxHORIZONTAL); #if wxUSE_STATBMP wxIcon icon = info.GetIcon(); - if ( !icon.Ok() && wxTheApp ) - { - const wxTopLevelWindow * const - tlw = wxDynamicCast(wxTheApp->GetTopWindow(), wxTopLevelWindow); - if ( tlw ) - icon = tlw->GetIcon(); - } - if ( icon.Ok() ) { sizerIconAndText->Add(new wxStaticBitmap(this, wxID_ANY, icon), @@ -100,22 +151,43 @@ bool wxAboutDialog::Create(const wxAboutDialogInfo& info) wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL); sizerTop->Add(sizerIconAndText, wxSizerFlags(1).Expand().Border()); - sizerTop->Add(new wxButton(this, wxID_OK), wxSizerFlags().Right().Border()); + + int defBorder = wxSizerFlags().Border().GetBorderInPixels(); + wxSizer *buttonSizer = CreateButtonSizer( wxOK , false, defBorder ); + if(buttonSizer->GetChildren().GetCount() > 0 ) + { + sizerTop->Add( buttonSizer, 0, wxEXPAND | wxALL, defBorder ); + } + else + { + sizerTop->AddSpacer( defBorder ); + delete buttonSizer; + } + SetSizerAndFit(sizerTop); CentreOnScreen(); + + wxWindow *ok = FindWindow(wxID_OK); + if (ok) ok->SetFocus(); + return true; } -void wxAboutDialog::AddControl(wxWindow *win) +void wxGenericAboutDialog::AddControl(wxWindow *win, const wxSizerFlags& flags) { wxCHECK_RET( m_sizerText, _T("can only be called after Create()") ); wxASSERT_MSG( win, _T("can't add NULL window to about dialog") ); - m_sizerText->Add(win, wxSizerFlags().Border(wxDOWN).Centre()); + m_sizerText->Add(win, flags); +} + +void wxGenericAboutDialog::AddControl(wxWindow *win) +{ + AddControl(win, wxSizerFlags().Border(wxDOWN).Centre()); } -void wxAboutDialog::AddText(const wxString& text) +void wxGenericAboutDialog::AddText(const wxString& text) { if ( !text.empty() ) AddControl(new wxStaticText(this, wxID_ANY, text)); @@ -127,14 +199,13 @@ void wxAboutDialog::AddText(const wxString& text) void wxGenericAboutBox(const wxAboutDialogInfo& info) { - wxAboutDialog dlg(info); + wxGenericAboutDialog dlg(info); dlg.ShowModal(); } -// currently wxAboutBox is implemented natively only under wxMSW, so we provide -// it here for the other platforms (this is going to change when GTK+ and Mac -// native versions are implemented) -#ifndef __WXMSW__ +// currently wxAboutBox is implemented natively only under these platforms, for +// the others we provide a generic fallback here +#if !defined(__WXMSW__) && !defined(__WXMAC__) && !defined(__WXGTK26__) void wxAboutBox(const wxAboutDialogInfo& info) {