]> git.saurik.com Git - wxWidgets.git/blame - src/generic/aboutdlgg.cpp
use wxSTRINGIZE instead of redefining a special STRINGIZE in this file
[wxWidgets.git] / src / generic / aboutdlgg.cpp
CommitLineData
ca7adbf8
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: src/generic/aboutdlgg.cpp
3// Purpose: implements wxGenericAboutBox() function
4// Author: Vadim Zeitlin
5// Created: 2006-10-08
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 #include "wx/sizer.h"
30
31 #include "wx/statbmp.h"
32 #include "wx/stattext.h"
33#endif //WX_PRECOMP
34
35#include "wx/aboutdlg.h"
36#include "wx/generic/aboutdlgg.h"
37
38#include "wx/hyperlink.h"
39
40// ============================================================================
41// wxAboutDialog implementation
42// ============================================================================
43
44bool wxAboutDialog::Create(const wxAboutDialogInfo& info)
45{
46 // TODO: should we use main frame as parent by default here?
47 if ( !wxDialog::Create(NULL, wxID_ANY, _("About ") + info.GetName()) )
48 return false;
49
50 m_sizerText = new wxBoxSizer(wxVERTICAL);
51 wxString nameAndVersion = info.GetName();
52 if ( info.HasVersion() )
53 nameAndVersion << _T(' ') << info.GetVersion();
54 wxStaticText *label = new wxStaticText(this, wxID_ANY, nameAndVersion);
55 wxFont fontBig(*wxNORMAL_FONT);
56 fontBig.SetPointSize(fontBig.GetPointSize() + 2);
57 fontBig.SetWeight(wxFONTWEIGHT_BOLD);
58 label->SetFont(fontBig);
59
60 m_sizerText->Add(label, wxSizerFlags().Centre().Border());
61 m_sizerText->AddSpacer(5);
62
63 AddText(info.GetCopyright());
64 AddText(info.GetDescription());
65
66 if ( info.HasWebSite() )
67 {
68#if wxUSE_HYPERLINKCTRL
69 AddControl(new wxHyperlinkCtrl(this, wxID_ANY,
70 info.GetWebSiteDescription(),
71 info.GetWebSiteURL()));
72#else
73 AddText(info.GetWebSiteURL());
74#endif // wxUSE_HYPERLINKCTRL/!wxUSE_HYPERLINKCTRL
75 }
76
77 // TODO: add licence
78
79 // TODO: add credits (developers, artists, doc writers, translators)
80
81
82 wxSizer *sizerIconAndText = new wxBoxSizer(wxHORIZONTAL);
83#if wxUSE_STATBMP
cfa64370
VZ
84 wxIcon icon = info.GetIcon();
85 if ( !icon.Ok() && wxTheApp )
86 {
87 const wxTopLevelWindow * const
88 tlw = wxDynamicCast(wxTheApp->GetTopWindow(), wxTopLevelWindow);
89 if ( tlw )
90 icon = tlw->GetIcon();
91 }
92
93 if ( icon.Ok() )
94 {
95 sizerIconAndText->Add(new wxStaticBitmap(this, wxID_ANY, icon),
96 wxSizerFlags().Border(wxRIGHT));
97 }
ca7adbf8
VZ
98#endif // wxUSE_STATBMP
99 sizerIconAndText->Add(m_sizerText, wxSizerFlags(1).Expand());
100
101 wxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
102 sizerTop->Add(sizerIconAndText, wxSizerFlags(1).Expand().Border());
103 sizerTop->Add(new wxButton(this, wxID_OK), wxSizerFlags().Right().Border());
104 SetSizerAndFit(sizerTop);
105
106 CentreOnScreen();
107 return true;
108}
109
110void wxAboutDialog::AddControl(wxWindow *win)
111{
112 wxCHECK_RET( m_sizerText, _T("can only be called after Create()") );
113 wxASSERT_MSG( win, _T("can't add NULL window to about dialog") );
114
115 m_sizerText->Add(win, wxSizerFlags().Border(wxDOWN).Centre());
116}
117
118void wxAboutDialog::AddText(const wxString& text)
119{
120 if ( !text.empty() )
121 AddControl(new wxStaticText(this, wxID_ANY, text));
122}
123
124// ----------------------------------------------------------------------------
125// public functions
126// ----------------------------------------------------------------------------
127
128void wxGenericAboutBox(const wxAboutDialogInfo& info)
129{
130 wxAboutDialog dlg(info);
131 dlg.ShowModal();
132}
133
134// currently wxAboutBox is implemented natively only under wxMSW, so we provide
135// it here for the other platforms (this is going to change when GTK+ and Mac
136// native versions are implemented)
137#ifndef __WXMSW__
138
139void wxAboutBox(const wxAboutDialogInfo& info)
140{
141 wxGenericAboutBox(info);
142}
143
144#endif // platforms without native about dialog
145
146
147#endif // wxUSE_ABOUTDLG