///////////////////////////////////////////////////////////////////////////////
// Name: wx/generic/aboutdlgg.h
-// Purpose: generic wxAboutDialog implementation
+// Purpose: generic wxAboutBox() implementation
// Author: Vadim Zeitlin
// Created: 2006-10-07
// RCS-ID: $Id$
class WXDLLIMPEXP_CORE wxAboutDialogInfo;
class WXDLLIMPEXP_CORE wxSizer;
+class WXDLLIMPEXP_CORE wxSizerFlags;
// ----------------------------------------------------------------------------
-// wxAboutDialog: generic "About" dialog implementation
+// wxGenericAboutDialog: generic "About" dialog implementation
// ----------------------------------------------------------------------------
-class WXDLLIMPEXP_CORE wxAboutDialog : public wxDialog
+class WXDLLIMPEXP_CORE wxGenericAboutDialog : public wxDialog
{
public:
// constructors and Create() method
// --------------------------------
// default ctor, you must use Create() to really initialize the dialog
- wxAboutDialog() { Init(); }
+ wxGenericAboutDialog() { Init(); }
// ctor which fully initializes the object
- wxAboutDialog(const wxAboutDialogInfo& info)
+ wxGenericAboutDialog(const wxAboutDialogInfo& info)
{
Init();
bool Create(const wxAboutDialogInfo& info);
protected:
- // common part of all ctors
- void Init() { m_sizerText = NULL; }
-
- // add arbitrary control to the text sizer contents
+ // this virtual method may be overridden to add some more controls to the
+ // dialog
+ //
+ // notice that for this to work you must call Create() from the derived
+ // class ctor and not use the base class ctor directly as otherwise the
+ // virtual function of the derived class wouldn't be called
+ virtual void DoAddCustomControls() { }
+
+ // add arbitrary control to the text sizer contents with the specified
+ // flags
+ void AddControl(wxWindow *win, const wxSizerFlags& flags);
+
+ // add arbitrary control to the text sizer contents and center it
void AddControl(wxWindow *win);
// add the text, if it's not empty, to the text sizer contents
void AddText(const wxString& text);
+private:
+ // common part of all ctors
+ void Init() { m_sizerText = NULL; }
+
wxSizer *m_sizerText;
};
#if wxUSE_ABOUTDLG
#include "wx/aboutdlg.h"
+
+ // these headers are only needed for custom about dialog
+ #include "wx/statline.h"
+ #include "wx/generic/aboutdlgg.h"
#endif // wxUSE_ABOUTDLG
#if wxUSE_BUSYINFO
#if wxUSE_ABOUTDLG
EVT_MENU(DIALOGS_ABOUTDLG_SIMPLE, MyFrame::ShowSimpleAboutDialog)
EVT_MENU(DIALOGS_ABOUTDLG_FANCY, MyFrame::ShowFancyAboutDialog)
+ EVT_MENU(DIALOGS_ABOUTDLG_FULL, MyFrame::ShowFullAboutDialog)
+ EVT_MENU(DIALOGS_ABOUTDLG_CUSTOM, MyFrame::ShowCustomAboutDialog)
#endif // wxUSE_ABOUTDLG
#if wxUSE_BUSYINFO
#if wxUSE_ABOUTDLG
wxMenu *menuHelp = new wxMenu;
- menuHelp->Append(DIALOGS_ABOUTDLG_SIMPLE, _T("&About (simple)..."));
- menuHelp->Append(DIALOGS_ABOUTDLG_FANCY, _T("About (&fancy)..."));
+ menuHelp->Append(DIALOGS_ABOUTDLG_SIMPLE, _T("&About (simple)...\tF1"));
+ menuHelp->Append(DIALOGS_ABOUTDLG_FANCY, _T("About (&fancy)...\tShift-F1"));
+ menuHelp->Append(DIALOGS_ABOUTDLG_FULL, _T("About (f&ull)...\tCtrl-F1"));
+ menuHelp->Append(DIALOGS_ABOUTDLG_CUSTOM, _T("About (&custom)...\tCtrl-Shift-F1"));
#endif // wxUSE_ABOUTDLG
wxMenuBar *menubar = new wxMenuBar;
#if wxUSE_ABOUTDLG
-static void CommonAboutInfoInit(wxAboutDialogInfo& info)
+static void InitAboutInfoMinimal(wxAboutDialogInfo& info)
{
info.SetName(_T("Dialogs Sample"));
info.SetVersion(wxVERSION_NUM_DOT_STRING_T);
info.AddDeveloper(_T("Vadim Zeitlin"));
}
+static void InitAboutInfoWebsite(wxAboutDialogInfo& info)
+{
+ InitAboutInfoMinimal(info);
+
+ info.SetWebSite(_T("http://www.wxwidgets.org/"), _T("wxWidgets web site"));
+}
+
+static void InitAboutInfoAll(wxAboutDialogInfo& info)
+{
+ InitAboutInfoMinimal(info);
+
+ // we can add a second developer
+ info.AddDeveloper(_T("A.N. Other"));
+
+ // or we can add several persons at once like this
+ static const wxChar *docwriters[] =
+ {
+ _T("First D. Writer"),
+ _T("Second One"),
+ };
+
+ info.SetDocWriters(wxArrayString(WXSIZEOF(docwriters), docwriters));
+ info.SetLicence(wxString::FromAscii(
+" wxWindows Library Licence, Version 3.1\n"
+" ======================================\n"
+"\n"
+" Copyright (c) 1998-2005 Julian Smart, Robert Roebling et al\n"
+"\n"
+" Everyone is permitted to copy and distribute verbatim copies\n"
+" of this licence document, but changing it is not allowed.\n"
+"\n"
+" WXWINDOWS LIBRARY LICENCE\n"
+" TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n"
+"\n"
+" ...and so on and so forth...\n"
+ ));
+}
+
void MyFrame::ShowSimpleAboutDialog(wxCommandEvent& WXUNUSED(event))
{
wxAboutDialogInfo info;
- CommonAboutInfoInit(info);
+ InitAboutInfoMinimal(info);
wxAboutBox(info);
}
void MyFrame::ShowFancyAboutDialog(wxCommandEvent& WXUNUSED(event))
{
wxAboutDialogInfo info;
- CommonAboutInfoInit(info);
- info.SetWebSite(_T("http://www.wxwidgets.org/"), _T("wxWidgets web site"));
+ InitAboutInfoWebsite(info);
wxAboutBox(info);
}
+void MyFrame::ShowFullAboutDialog(wxCommandEvent& WXUNUSED(event))
+{
+ wxAboutDialogInfo info;
+ InitAboutInfoAll(info);
+
+ wxAboutBox(info);
+}
+
+void MyFrame::ShowCustomAboutDialog(wxCommandEvent& WXUNUSED(event))
+{
+ class MyAboutDialog : public wxGenericAboutDialog
+ {
+ public:
+ MyAboutDialog(const wxAboutDialogInfo& info)
+ {
+ Create(info);
+ }
+
+ // add some custom controls
+ virtual void DoAddCustomControls()
+ {
+ AddControl(new wxStaticLine(this), wxSizerFlags().Expand());
+ AddText(_T("Some custom text"));
+ AddControl(new wxStaticLine(this), wxSizerFlags().Expand());
+ }
+ };
+
+ wxAboutDialogInfo info;
+ InitAboutInfoAll(info);
+
+ MyAboutDialog dlg(info);
+ dlg.ShowModal();
+}
+
#endif // wxUSE_ABOUTDLG
#if wxUSE_BUSYINFO
#if wxUSE_ABOUTDLG
void ShowSimpleAboutDialog(wxCommandEvent& event);
void ShowFancyAboutDialog(wxCommandEvent& event);
+ void ShowFullAboutDialog(wxCommandEvent& event);
+ void ShowCustomAboutDialog(wxCommandEvent& event);
#endif // wxUSE_ABOUTDLG
#if wxUSE_BUSYINFO
DIALOGS_PROGRESS,
DIALOGS_ABOUTDLG_SIMPLE,
DIALOGS_ABOUTDLG_FANCY,
+ DIALOGS_ABOUTDLG_FULL,
+ DIALOGS_ABOUTDLG_CUSTOM,
DIALOGS_BUSYINFO,
DIALOGS_FIND,
DIALOGS_REPLACE,
}
// ----------------------------------------------------------------------------
-// wxAboutDialog
+// wxGenericAboutDialog
// ----------------------------------------------------------------------------
-bool wxAboutDialog::Create(const wxAboutDialogInfo& info)
+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()) )
// TODO: add credits (developers, artists, doc writers, translators)
+ DoAddCustomControls();
+
wxSizer *sizerIconAndText = new wxBoxSizer(wxHORIZONTAL);
#if wxUSE_STATBMP
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));
void wxGenericAboutBox(const wxAboutDialogInfo& info)
{
- wxAboutDialog dlg(info);
+ wxGenericAboutDialog dlg(info);
dlg.ShowModal();
}