initial implementation of wxAboutBox()
[wxWidgets.git] / src / msw / aboutdlg.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/msw/aboutdlg.cpp
3 // Purpose: implementation of wxAboutBox() for wxMSW
4 // Author: Vadim Zeitlin
5 // Created: 2006-10-07
6 // RCS-ID: $Id$
7 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 // ============================================================================
12 // declarations
13 // ============================================================================
14
15 // ----------------------------------------------------------------------------
16 // headers
17 // ----------------------------------------------------------------------------
18
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
21
22 #ifdef __BORLANDC__
23 #pragma hdrstop
24 #endif
25
26 #if wxUSE_ABOUTDLG
27
28 #ifndef WX_PRECOMP
29 #endif //WX_PRECOMP
30
31 #include "wx/aboutdlg.h"
32 #include "wx/generic/aboutdlgg.h"
33
34 // ============================================================================
35 // implementation
36 // ============================================================================
37
38 // helper function: returns all array elements in a single comma-separated and
39 // newline-terminated string
40 static wxString AllAsString(const wxArrayString& a)
41 {
42 wxString s;
43 const size_t count = a.size();
44 for ( size_t n = 0; n < count; n++ )
45 {
46 s << a[n] << (n == count - 1 ? _T("\n") : _T(", "));
47 }
48
49 return s;
50 }
51
52 // our public entry point
53 void wxAboutBox(const wxAboutDialogInfo& info)
54 {
55 // we prefer to show a simple message box if we don't have any fields which
56 // can't be shown in it because as much as there is a standard about box
57 // under MSW at all, this is it
58 if ( info.HasWebSite() || info.HasIcon() || info.HasLicence() )
59 {
60 // we need to use the full-blown generic version
61 wxGenericAboutBox(info);
62 }
63 else // simple "native" version should do
64 {
65 // build the text to show in the box
66 const wxString name = info.GetName();
67 wxString msg;
68 msg << name;
69 if ( info.HasVersion() )
70 msg << _(" Version ") << info.GetVersion();
71 msg << _T('\n');
72
73 if ( info.HasCopyright() )
74 msg << info.GetCopyright() << _T('\n');
75
76 msg << info.GetDescription() << _T('\n');
77
78 if ( info.HasDevelopers() )
79 msg << _("Developed by ") << AllAsString(info.GetDevelopers());
80
81 if ( info.HasDocWriters() )
82 msg << _("Documentation by ") << AllAsString(info.GetDocWriters());
83
84 if ( info.HasArtists() )
85 msg << _("Graphics art by ") << AllAsString(info.GetArtists());
86
87 if ( info.HasTranslators() )
88 msg << _("Translations by ") << AllAsString(info.GetTranslators());
89
90 wxMessageBox(msg, _T("About ") + name);
91 }
92 }
93
94 #endif // wxUSE_ABOUTDLG