/* LTAbout.cpp
**
** This file is part of wxLaserTank.
**
** Copyright © 2002, 2009 Gary Harris
**
** Based on LaserTank ver 4.1.2 by Jim Kindley.
**
** wxLaserTank is free software; you can redistribute it and/or
** modify it under the terms of the GNU General Public License as
** published by the Free Software Foundation; either version 2 of
** the License, or (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; see the file docs\gpl.txt.
** If not, write to the Free Software Foundation, Inc.,
** 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
**
** Gary Harris
** garyjharris@sourceforge.net
*/
// For compilers that support pre-compilation, includes "wx.h".
#include <wx/wxprec.h>
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
// Include your minimal set of headers here, or wx.h
#include <wx/wx.h>
#endif
#include <wx/xrc/xmlres.h>
#include "LTAbout.h"
#include "LTGlobal.h"
#include "LT32l_us.h"
#include "version.h"
// the application icon
#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
#include "LaserTank.xpm"
#include "JEK.xpm"
#endif
// About dialogue.
BEGIN_EVENT_TABLE(AboutDialog, wxDialog)
EVT_BUTTON(XRCID("wxID_OK"), AboutDialog::OnAboutOK)
EVT_TEXT_URL(XRCID("txtMessage"), AboutDialog::OnTextUrl)
END_EVENT_TABLE()
AboutDialog::AboutDialog(wxWindow *parent)
// Don't call the base class here because we'll be loading from the XRC.
{
wxXmlResource::Get()->LoadDialog(this, parent, wxT("About"));
CentreOnParent(); // Centre the dialogue.
wxIcon LTicon(wxICON(LaserTank)); // Paint icons.
wxIcon JEKicon(wxICON(JEK));
if(LTicon.IsOk()){
(void)new wxStaticBitmap(this, wxID_ANY, LTicon, wxPoint(17, 15));
}
if(JEKicon.IsOk()){
(void)new wxStaticBitmap(this, wxID_ANY, JEKicon, wxPoint(17, 52));
}
// Set version text.
wxString nl = wxT("\n");
wxString wxLTver = wxString::Format(wxT("%d.%d.%dr%d"), AutoVersion::MAJOR, AutoVersion::MINOR, AutoVersion::BUILD, AutoVersion::REVISION);
wxString wxVer = wxString::Format(wxT("%d.%d.%d"), wxMAJOR_VERSION, wxMINOR_VERSION, wxRELEASE_NUMBER);
wxTextCtrl* txtVersion = (wxTextCtrl*)FindWindow(XRCID("ID_TEXTCTRL_VERSION"));
txtVersion->AppendText(wxT("Laser Tank\n"));
txtVersion->AppendText(_("Version ") + LTGlobal::Inst()->App_Version() + nl);
txtVersion->AppendText(_("By"));
txtVersion->AppendText(wxT(" Jim Kindley") + nl);
txtVersion->AppendText(wxT("\xa9")); // Copyright symbol (ergh).
txtVersion->AppendText(wxT("2002, JEK Software.\n\n"));
txtVersion->AppendText(wxT("wxLaserTank") + nl);
txtVersion->AppendText(_("Version ") + wxLTver + nl);
txtVersion->AppendText(_("By"));
txtVersion->AppendText(wxT(" Gary Harris") + nl);
txtVersion->AppendText(wxT("Copyright \xa9 2002, 2009.\n\n"));
txtVersion->AppendText(_("This version of"));
txtVersion->AppendText(wxT(" wxLaserTank "));
txtVersion->AppendText(_("is using wxWidgets ") + wxVer + wxT("."));
txtVersion->ShowPosition(0);
FindWindow(XRCID("wxID_OK"))->SetFocus(); // Focus the OK button.
((wxTextCtrl*)FindWindow(XRCID("txtMessage")))->WriteText(LTG->txtAbout()); // Write text box message.
}
void AboutDialog::OnAboutOK(wxCommandEvent& WXUNUSED(event))
{
EndModal(0);
}
void AboutDialog::OnTextUrl(wxTextUrlEvent& event)
{
const wxMouseEvent& ev = event.GetMouseEvent();
// filter out mouse moves, too many of them
if(ev.Moving()){
return;
}
long start = event.GetURLStart();
long end = event.GetURLEnd();
wxTextCtrl* txtVersion = (wxTextCtrl*)FindWindow(XRCID("txtMessage"));
if(ev.LeftDown()){
// Mouse was left-clicked.
wxString url(txtVersion->GetValue().Mid(start, end - start));
if(!wxLaunchDefaultBrowser(url)){
wxString s(_("Unable to launch the default browser."));
wxMessageDialog msgdlgError(this, s, LTG->txt007(), wxOK|wxICON_ERROR|wxCENTRE);
}
}
}