[go: up one dir, main page]

Menu

[r15]: / LTAbout.cpp  Maximize  Restore  History

Download this file

127 lines (109 with data), 4.7 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/* 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);
}
}
}