]>
git.saurik.com Git - wxWidgets.git/blob - src/generic/aboutdlgg.cpp
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/aboutdlgg.cpp
3 // Purpose: implements wxGenericAboutBox() function
4 // Author: Vadim Zeitlin
7 // Copyright: (c) 2006 Vadim Zeitlin <vadim@wxwindows.org>
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
11 // ============================================================================
13 // ============================================================================
15 // ----------------------------------------------------------------------------
17 // ----------------------------------------------------------------------------
19 // for compilers that support precompilation, includes "wx.h".
20 #include "wx/wxprec.h"
31 #include "wx/statbmp.h"
32 #include "wx/stattext.h"
35 #include "wx/aboutdlg.h"
36 #include "wx/generic/aboutdlgg.h"
38 #include "wx/hyperlink.h"
40 // ============================================================================
41 // wxAboutDialog implementation
42 // ============================================================================
44 bool wxAboutDialog::Create(const wxAboutDialogInfo
& info
)
46 // TODO: should we use main frame as parent by default here?
47 if ( !wxDialog::Create(NULL
, wxID_ANY
, _("About ") + info
.GetName()) )
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
);
60 m_sizerText
->Add(label
, wxSizerFlags().Centre().Border());
61 m_sizerText
->AddSpacer(5);
63 AddText(info
.GetCopyright());
64 AddText(info
.GetDescription());
66 if ( info
.HasWebSite() )
68 #if wxUSE_HYPERLINKCTRL
69 AddControl(new wxHyperlinkCtrl(this, wxID_ANY
,
70 info
.GetWebSiteDescription(),
71 info
.GetWebSiteURL()));
73 AddText(info
.GetWebSiteURL());
74 #endif // wxUSE_HYPERLINKCTRL/!wxUSE_HYPERLINKCTRL
79 // TODO: add credits (developers, artists, doc writers, translators)
82 wxSizer
*sizerIconAndText
= new wxBoxSizer(wxHORIZONTAL
);
84 wxIcon icon
= info
.GetIcon();
85 if ( !icon
.Ok() && wxTheApp
)
87 const wxTopLevelWindow
* const
88 tlw
= wxDynamicCast(wxTheApp
->GetTopWindow(), wxTopLevelWindow
);
90 icon
= tlw
->GetIcon();
95 sizerIconAndText
->Add(new wxStaticBitmap(this, wxID_ANY
, icon
),
96 wxSizerFlags().Border(wxRIGHT
));
98 #endif // wxUSE_STATBMP
99 sizerIconAndText
->Add(m_sizerText
, wxSizerFlags(1).Expand());
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
);
110 void wxAboutDialog::AddControl(wxWindow
*win
)
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") );
115 m_sizerText
->Add(win
, wxSizerFlags().Border(wxDOWN
).Centre());
118 void wxAboutDialog::AddText(const wxString
& text
)
121 AddControl(new wxStaticText(this, wxID_ANY
, text
));
124 // ----------------------------------------------------------------------------
126 // ----------------------------------------------------------------------------
128 void wxGenericAboutBox(const wxAboutDialogInfo
& info
)
130 wxAboutDialog
dlg(info
);
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)
139 void wxAboutBox(const wxAboutDialogInfo
& info
)
141 wxGenericAboutBox(info
);
144 #endif // platforms without native about dialog
147 #endif // wxUSE_ABOUTDLG