Hugintrunk  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AboutDialog.cpp
Go to the documentation of this file.
1 // -*- c-basic-offset: 4 -*-
2 
12 /* This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public
14  * License as published by the Free Software Foundation; either
15  * version 2 of the License, or (at your option) any later version.
16  *
17  * This software is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20  * General Public License for more details.
21  *
22  * You should have received a copy of the GNU General Public
23  * License along with this software. If not, see
24  * <http://www.gnu.org/licenses/>.
25  *
26  */
27 
28 #include "hugin/AboutDialog.h"
29 
30 #include "base_wx/wxPlatform.h"
31 #include "panoinc.h"
32 #include "hugin/huginApp.h"
33 #include <wx/utils.h>
34 extern "C"
35 {
36 #include "pano13/queryfeature.h"
37 }
38 #if !(defined HAVE_STD_FILESYSTEM)
39 #include "boost/version.hpp"
40 #endif
41 #ifdef _WIN32
42 // workaround for a conflict between exiv2 and wxWidgets/CMake built
43 #define HAVE_PID_T 1
44 #endif
45 #include <exiv2/exiv2.hpp>
46 #include "lensdb/LensDB.h"
47 #include "sqlite3.h"
48 #include <lcms2.h>
49 #include "vigra/config.hxx"
50 #include "hugin_config.h"
51 
52 BEGIN_EVENT_TABLE(AboutDialog, wxDialog)
53  EVT_NOTEBOOK_PAGE_CHANGED(XRCID("about_notebook"), AboutDialog::OnChangedTab)
55 
56 
57 AboutDialog::AboutDialog(wxWindow *parent)
58 {
59  wxString strFile;
60  wxString langCode;
61  wxTextCtrl *textCtrl;
62  m_logoImgCtrl=NULL;
63  m_mode=0;
64 
65  wxXmlResource::Get()->LoadDialog(this, parent, wxT("about_dlg"));
66 
67 #if 0
68 // currently authors and about text are not translated, so comment out
69 #if __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
70  //rely on the system's locale choice
71  strFile = MacGetPathToBundledResourceFile(CFSTR("about.htm"));
72  if(strFile!=wxT("")) XRCCTRL(*this,"about_html",wxHtmlWindow)->LoadPage(strFile);
73 #else
74  //if the language is not default, load custom About file (if exists)
75  langCode = huginApp::Get()->GetLocale().GetName().Left(2).Lower();
76  DEBUG_INFO("Lang Code: " << langCode.mb_str(wxConvLocal));
77  if(langCode != wxString(wxT("en")))
78  {
79  strFile = huginApp::Get()->GetXRCPath() + wxT("data/about_") + langCode + wxT(".htm");
80  if(wxFile::Exists(strFile))
81  {
82  DEBUG_TRACE("Using About: " << strFile.mb_str(wxConvLocal));
83  XRCCTRL(*this,"about_html",wxHtmlWindow)->LoadPage(strFile);
84  }
85  }
86 #endif
87 #endif
88 
89 
90  // Version
91  XRCCTRL(*this,"about_version", wxTextCtrl)->ChangeValue(wxString(hugin_utils::GetHuginVersion().c_str(), wxConvLocal));
92 
93  #ifdef __WXMAC__
94  wxFont font(10, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
95  #else
96  wxFont font(8, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
97  #endif
98 
99  // License
100  textCtrl = XRCCTRL(*this, "license_txt", wxTextCtrl);
101  strFile = huginApp::Get()->GetXRCPath() + wxT("data/COPYING.txt");
102 #ifndef _WIN32
103  textCtrl->SetFont(font);
104 #endif
105  textCtrl->LoadFile(strFile);
106 
107  // Upstream
108  textCtrl = XRCCTRL(*this, "upstream_txt", wxTextCtrl);
109  strFile = huginApp::Get()->GetXRCPath() + wxT("data/upstream.txt");
110 #ifndef _WIN32
111  textCtrl->SetFont(font);
112 #endif
113  textCtrl->LoadFile(strFile);
114  GetSystemInformation(&font);
115 
116  // the notebook
117  m_about_notebook = XRCCTRL(*this,"about_notebook", wxNotebook);
118  // the logo
119  m_logoImgCtrl = XRCCTRL(*this, "about_logo", wxStaticBitmap);
120 
121  // load the appropriate icon (.ico for Windows, .png for other systems)
122 #ifdef __WXMSW__
123  wxIconBundle myIcons(huginApp::Get()->GetXRCPath() + wxT("data/hugin.ico"),wxBITMAP_TYPE_ICO);
124  SetIcons(myIcons);
125 #else
126  wxIcon myIcon(huginApp::Get()->GetXRCPath() + wxT("data/hugin.png"),wxBITMAP_TYPE_PNG);
127  // set the icon in the title bar
128  SetIcon(myIcon);
129 #endif
130 
131  // set the position and the size (x,y,width,height). -1 = keep existing
132 #if wxCHECK_VERSION(3,1,0)
133  SetSize(this->FromDIP(wxSize(560, 560)));
134 #else
135  SetSize(1, 1, 560, 560);
136 #endif
137  CenterOnParent();
138 }
139 
141 {
142  wxTextCtrl* infoText=XRCCTRL(*this,"system_txt",wxTextCtrl);
143 #ifndef _WIN32
144  infoText->SetFont(*font);
145 #endif
146  wxString text;
147  text=wxString::Format(_("Operating System: %s"),wxGetOsDescription().c_str());
148  wxString is64;
149  if(wxIsPlatform64Bit())
150  is64=_("64 bit");
151  else
152  is64=_("32 bit");
153  text=text+wxT("\n")+wxString::Format(_("Architecture: %s"),is64.c_str());
154  // wxGetFreeMemory returns a wxMemorySize, which is undocumented.
155  // However, we know -1 is returned on failure, so it must be signed.
156  text=text+wxT("\n")+wxString::Format(_("Free memory: %lld kiB"), wxGetFreeMemory().GetValue()/1024ll);
157 #ifdef _WIN32
158  UINT cp=GetACP();
159  text=text+wxT("\n")+wxString::Format(_("Active Codepage: %u"),cp);
160  switch(cp)
161  {
162  case 1250:
163  text=text+wxT(" (Central European Windows)");
164  break;
165  case 1251:
166  text=text+wxT(" (Cyrillic Windows)");
167  break;
168  case 1252:
169  text=text+wxT(" (Western European Windows)");
170  break;
171  case 1253:
172  text=text+wxT(" (Greek Windows)");
173  break;
174  case 1254:
175  text=text+wxT(" (Turkish Windows)");
176  break;
177  case 1255:
178  text=text+wxT(" (Hebrew Windows)");
179  break;
180  case 1256:
181  text=text+wxT(" (Arabic Windows)");
182  break;
183  case 1257:
184  text=text+wxT(" (Baltic Windows)");
185  break;
186  case 1258:
187  text=text+wxT(" (Vietnamese Windows)");
188  break;
189  };
190 #endif
191  text = text + wxT("\n\nHugin\n") + wxString::Format(_("Version: %s"), wxString(hugin_utils::GetHuginVersion().c_str(), wxConvLocal).c_str());
192  text=text+wxT("\n")+wxString::Format(_("Path to resources: %s"),huginApp::Get()->GetXRCPath().c_str());
193  text=text+wxT("\n")+wxString::Format(_("Path to data: %s"),huginApp::Get()->GetDataPath().c_str());
195  text = text + wxT("\n") + wxString::Format(_("Hugins camera and lens database: %s"), wxString(lensDB.GetDBFilename().c_str(), wxConvLocal).c_str());
196  text = text + wxT("\n") + _("Multi-threading using C++11 std::thread and OpenMP");
197  if (huginApp::Get()->HasMonitorProfile())
198  {
199  text = text + wxT("\n") + wxString::Format(_("Monitor profile: %s"), huginApp::Get()->GetMonitorProfileName().c_str());
200  }
201  text=text+wxT("\n\n")+_("Libraries");
202  wxVersionInfo info = wxGetLibraryVersionInfo();
203  text = text + wxT("\nwxWidgets: ") + info.GetVersionString();
204  if(info.HasDescription())
205  {
206  text=text+wxT("\n")+info.GetDescription();
207  };
208  {
209  char panoVersion[255];
210  if (queryFeatureString(PTVERSION_NAME_FILEVERSION, panoVersion, sizeof(panoVersion) / sizeof(panoVersion[0])))
211  {
212  text = text + wxT("\nlibpano13: ") + wxString(panoVersion, wxConvLocal);
213  };
214  }
215 #if !(defined HAVE_STD_FILESYSTEM)
216  text=text+wxT("\n")+wxString::Format(wxT("Boost: %i.%i.%i"),BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
217 #endif
218  text = text + wxT("\n") + wxT("Exiv2: ") + wxString(Exiv2::versionString().c_str(), wxConvLocal);
219  text = text + wxT("\n") + wxT("SQLite3: ") + wxString(sqlite3_libversion(), wxConvLocal);
220  text = text + wxT("\n") + wxString::Format(wxT("Vigra: %s"), wxString(VIGRA_VERSION, wxConvLocal).c_str());
221  text = text + wxT("\n") + wxString::Format(wxT("LittleCMS2: %i.%i"), LCMS_VERSION / 1000, LCMS_VERSION / 10 % 100);
222  infoText->SetValue(text);
223 }
224 
225 void AboutDialog::OnChangedTab(wxNotebookEvent &e)
226 {
227  // determine which tab is currently visible
228  SetMode(e.GetSelection());
229 };
230 
231 void AboutDialog::SetMode(int newMode)
232 {
233  if(m_mode==newMode)
234  {
235  return;
236  }
237 
238  switch ( newMode )
239  {
240 
241  case 0 :
242  // about tab
243  SetLogo(wxT("splash.png"));
244  break;
245 
246 // dedication tab no longer in use
247 // case 6 :
248  // dedication tab
249 // SetLogo(wxT("dedication.png"));
250 // break;
251 
252  default :
253  // all other tabs
254  SetLogo(wxT("logo.png"));
255  }
256 
257  m_mode=newMode;
258  return;
259 };
260 
261 void AboutDialog::SetLogo(wxString newLogoFile)
262 {
263  if(m_logo_file!=newLogoFile)
264  {
265  if(m_logo.LoadFile(huginApp::Get()->GetXRCPath() +
266  wxT("data/") + newLogoFile,
267  wxBITMAP_TYPE_PNG))
268  {
269  if(m_logoImgCtrl)
270  {
271  m_logoImgCtrl->SetBitmap(m_logo);
272  m_logo_file=newLogoFile;
273  };
274  };
275  };
276 };
277 
#define DEBUG_INFO(msg)
Definition: utils.h:69
wxString GetDataPath()
return path to data directory, it depends on operating system
static LensDB & GetSingleton()
returns the static LensDB instance
Definition: LensDB.cpp:2001
#define DEBUG_TRACE(msg)
Definition: utils.h:67
void SetMode(int newMode)
function to switch the logo image based on selected tab
END_EVENT_TABLE()
include file for the hugin project
void OnChangedTab(wxNotebookEvent &e)
event handler for changing tab
std::string GetDBFilename() const
returns the filename of the lens database
Definition: LensDB.cpp:2019
static huginApp * Get()
hack.. kind of a pseudo singleton...
Definition: huginApp.cpp:649
main database class
Definition: LensDB.h:44
class to access Hugins camera and lens database
wxString m_logo_file
Definition: AboutDialog.h:49
Dialog for about window.
Definition: AboutDialog.h:40
Definition of dialog for numeric transforms.
wxBitmap m_logo
Definition: AboutDialog.h:52
std::string GetHuginVersion()
return a string with version numbers
Definition: utils.cpp:920
platform/compiler specific stuff.
static void info(const char *fmt,...)
Definition: svm.cpp:95
wxLocale & GetLocale()
return currently active locale
Definition: huginApp.h:123
void SetLogo(wxString newLogoFile)
function to set the log image
const wxString & GetXRCPath()
return the current xrc path
Definition: huginApp.h:134
void GetSystemInformation(wxFont *font)
retrieves the system information
wxStaticBitmap * m_logoImgCtrl
Definition: AboutDialog.h:51