AboutDialog.cpp

Go to the documentation of this file.
00001 // -*- c-basic-offset: 4 -*-
00002 
00012 /*  This program is free software; you can redistribute it and/or
00013  *  modify it under the terms of the GNU General Public
00014  *  License as published by the Free Software Foundation; either
00015  *  version 2 of the License, or (at your option) any later version.
00016  *
00017  *  This software is distributed in the hope that it will be useful,
00018  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00019  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00020  *  General Public License for more details.
00021  *
00022  *  You should have received a copy of the GNU General Public
00023  *  License along with this software. If not, see
00024  *  <http://www.gnu.org/licenses/>.
00025  *
00026  */
00027 
00028 #include "hugin/AboutDialog.h"
00029 
00030 #include "base_wx/wxPlatform.h"
00031 #include "panoinc.h"
00032 #include "hugin/huginApp.h"
00033 #include <wx/utils.h>
00034 extern "C"
00035 {
00036 #include "pano13/queryfeature.h"
00037 }
00038 #if !(defined HAVE_STD_FILESYSTEM)
00039 #include "boost/version.hpp"
00040 #endif
00041 #include "exiv2/exiv2.hpp"
00042 #include "lensdb/LensDB.h"
00043 #include "sqlite3.h"
00044 #include <lcms2.h>
00045 #include "vigra/config.hxx"
00046 #include "hugin_config.h"
00047 
00048 BEGIN_EVENT_TABLE(AboutDialog, wxDialog)
00049     EVT_NOTEBOOK_PAGE_CHANGED(XRCID("about_notebook"), AboutDialog::OnChangedTab)
00050 END_EVENT_TABLE()
00051 
00052 
00053 AboutDialog::AboutDialog(wxWindow *parent)
00054 {
00055         wxString strFile;
00056         wxString langCode;
00057         wxTextCtrl *textCtrl;
00058     m_logoImgCtrl=NULL;
00059     m_mode=0;
00060         
00061     wxXmlResource::Get()->LoadDialog(this, parent, wxT("about_dlg"));
00062 
00063 #if 0
00064 // currently authors and about text are not translated, so comment out
00065 #if __WXMAC__ && defined MAC_SELF_CONTAINED_BUNDLE
00066     //rely on the system's locale choice
00067     strFile = MacGetPathToBundledResourceFile(CFSTR("about.htm"));
00068     if(strFile!=wxT("")) XRCCTRL(*this,"about_html",wxHtmlWindow)->LoadPage(strFile);
00069 #else    
00070     //if the language is not default, load custom About file (if exists)
00071     langCode = huginApp::Get()->GetLocale().GetName().Left(2).Lower();
00072     DEBUG_INFO("Lang Code: " << langCode.mb_str(wxConvLocal));
00073     if(langCode != wxString(wxT("en")))
00074     {
00075         strFile = huginApp::Get()->GetXRCPath() + wxT("data/about_") + langCode + wxT(".htm");
00076         if(wxFile::Exists(strFile))
00077         {
00078             DEBUG_TRACE("Using About: " << strFile.mb_str(wxConvLocal));
00079             XRCCTRL(*this,"about_html",wxHtmlWindow)->LoadPage(strFile);
00080         }
00081     }
00082 #endif
00083 #endif
00084 
00085 
00086     // Version
00087     XRCCTRL(*this,"about_version", wxTextCtrl)->ChangeValue(wxString(hugin_utils::GetHuginVersion().c_str(), wxConvLocal));
00088 
00089         #ifdef __WXMAC__
00090                 wxFont font(10, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
00091         #else
00092                 wxFont font(8, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
00093         #endif
00094         
00095         // License
00096         textCtrl = XRCCTRL(*this, "license_txt", wxTextCtrl);
00097     strFile = huginApp::Get()->GetXRCPath() + wxT("data/COPYING.txt");
00098 #ifndef _WIN32
00099         textCtrl->SetFont(font);
00100 #endif
00101         textCtrl->LoadFile(strFile);
00102 
00103         // Upstream
00104         textCtrl = XRCCTRL(*this, "upstream_txt", wxTextCtrl);
00105     strFile = huginApp::Get()->GetXRCPath() + wxT("data/upstream.txt");
00106 #ifndef _WIN32
00107         textCtrl->SetFont(font);
00108 #endif
00109         textCtrl->LoadFile(strFile);
00110     GetSystemInformation(&font);
00111 
00112     // the notebook
00113     m_about_notebook = XRCCTRL(*this,"about_notebook", wxNotebook);
00114     // the logo
00115     m_logoImgCtrl = XRCCTRL(*this, "about_logo", wxStaticBitmap);
00116 
00117     // load the appropriate icon (.ico for Windows, .png for other systems)
00118 #ifdef __WXMSW__
00119     wxIcon myIcon(huginApp::Get()->GetXRCPath() + wxT("data/hugin.ico"),wxBITMAP_TYPE_ICO);
00120 #else
00121     wxIcon myIcon(huginApp::Get()->GetXRCPath() + wxT("data/hugin.png"),wxBITMAP_TYPE_PNG);
00122 #endif
00123     // set the icon in the title bar
00124     SetIcon(myIcon);
00125 
00126     // set the position and the size (x,y,width,height). -1 = keep existing
00127     SetSize(1,1,560,560);
00128     CenterOnParent();
00129 }
00130 
00131 void AboutDialog::GetSystemInformation(wxFont *font)
00132 {
00133     wxTextCtrl* infoText=XRCCTRL(*this,"system_txt",wxTextCtrl);
00134 #ifndef _WIN32
00135     infoText->SetFont(*font);
00136 #endif
00137     wxString text;
00138     text=wxString::Format(_("Operating System: %s"),wxGetOsDescription().c_str());
00139     wxString is64;
00140     if(wxIsPlatform64Bit())
00141         is64=_("64 bit");
00142     else
00143         is64=_("32 bit");
00144     text=text+wxT("\n")+wxString::Format(_("Architecture: %s"),is64.c_str());
00145     // wxGetFreeMemory returns a wxMemorySize, which is undocumented.
00146     // However, we know -1 is returned on failure, so it must be signed.
00147     text=text+wxT("\n")+wxString::Format(_("Free memory: %lld kiB"), wxGetFreeMemory().GetValue()/1024ll);
00148 #ifdef _WIN32
00149     UINT cp=GetACP();
00150     text=text+wxT("\n")+wxString::Format(_("Active Codepage: %u"),cp); 
00151     switch(cp)
00152     {
00153     case 1250:
00154         text=text+wxT(" (Central European Windows)");
00155         break;
00156     case 1251:
00157         text=text+wxT(" (Cyrillic Windows)");
00158         break;
00159     case 1252:
00160         text=text+wxT(" (Western European Windows)");
00161         break;
00162     case 1253:
00163         text=text+wxT(" (Greek Windows)");
00164         break;
00165     case 1254:
00166         text=text+wxT(" (Turkish Windows)");
00167         break;
00168     case 1255:
00169         text=text+wxT(" (Hebrew Windows)");
00170         break;
00171     case 1256:
00172         text=text+wxT(" (Arabic Windows)");
00173         break;
00174     case 1257:
00175         text=text+wxT(" (Baltic Windows)");
00176         break;
00177     case 1258:
00178         text=text+wxT(" (Vietnamese Windows)");
00179         break;
00180     };
00181 #endif
00182     text = text + wxT("\n\nHugin\n") + wxString::Format(_("Version: %s"), wxString(hugin_utils::GetHuginVersion().c_str(), wxConvLocal).c_str());
00183     text=text+wxT("\n")+wxString::Format(_("Path to resources: %s"),huginApp::Get()->GetXRCPath().c_str());
00184     text=text+wxT("\n")+wxString::Format(_("Path to data: %s"),huginApp::Get()->GetDataPath().c_str());
00185     HuginBase::LensDB::LensDB& lensDB=HuginBase::LensDB::LensDB::GetSingleton();
00186     text = text + wxT("\n") + wxString::Format(_("Hugins camera and lens database: %s"), wxString(lensDB.GetDBFilename().c_str(), wxConvLocal).c_str());
00187     text = text + wxT("\n") + _("Multi-threading using C++11 std::thread and OpenMP");
00188     if (huginApp::Get()->HasMonitorProfile())
00189     {
00190         text = text + wxT("\n") + wxString::Format(_("Monitor profile: %s"), huginApp::Get()->GetMonitorProfileName().c_str());
00191     }
00192     text=text+wxT("\n\n")+_("Libraries");
00193     wxVersionInfo info = wxGetLibraryVersionInfo();
00194     text = text + wxT("\nwxWidgets: ") + info.GetVersionString();
00195     if(info.HasDescription())
00196     {
00197         text=text+wxT("\n")+info.GetDescription();
00198     };
00199     {
00200         char panoVersion[255];
00201         if (queryFeatureString(PTVERSION_NAME_FILEVERSION, panoVersion, sizeof(panoVersion) / sizeof(panoVersion[0])))
00202         {
00203             text = text + wxT("\nlibpano13: ") + wxString(panoVersion, wxConvLocal);
00204         };
00205     }
00206 #if !(defined HAVE_STD_FILESYSTEM)
00207     text=text+wxT("\n")+wxString::Format(wxT("Boost: %i.%i.%i"),BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
00208 #endif
00209     text = text + wxT("\n") + wxT("Exiv2: ") + wxString(Exiv2::version(), wxConvLocal);
00210     text = text + wxT("\n") + wxT("SQLite3: ") + wxString(sqlite3_libversion(), wxConvLocal);
00211     text = text + wxT("\n") + wxString::Format(wxT("Vigra: %s"), wxString(VIGRA_VERSION, wxConvLocal).c_str());
00212     text = text + wxT("\n") + wxString::Format(wxT("LittleCMS2: %i.%i"), LCMS_VERSION / 1000, LCMS_VERSION / 10 % 100);
00213     infoText->SetValue(text);
00214 }
00215 
00216 void AboutDialog::OnChangedTab(wxNotebookEvent &e)
00217 {
00218     // determine which tab is currently visible
00219    SetMode(e.GetSelection());
00220 };
00221 
00222 void AboutDialog::SetMode(int newMode)
00223 {
00224     if(m_mode==newMode)
00225     {
00226         return;
00227     }
00228 
00229     switch ( newMode )
00230     {
00231 
00232         case 0 :
00233             // about tab
00234             SetLogo(wxT("splash.png"));
00235             break;
00236 
00237 // dedication tab no longer in use            
00238 //        case 6 :
00239             // dedication tab
00240 //            SetLogo(wxT("dedication.png"));
00241 //            break;
00242 
00243         default :
00244             // all other tabs
00245             SetLogo(wxT("logo.png"));
00246     }
00247 
00248     m_mode=newMode;
00249     return;
00250 };
00251 
00252 void AboutDialog::SetLogo(wxString newLogoFile)
00253 {
00254     if(m_logo_file!=newLogoFile)
00255     {
00256         if(m_logo.LoadFile(huginApp::Get()->GetXRCPath() +
00257                         wxT("data/") + newLogoFile,
00258                         wxBITMAP_TYPE_PNG))
00259         {
00260             if(m_logoImgCtrl)
00261             {
00262                 m_logoImgCtrl->SetBitmap(m_logo);
00263                 m_logo_file=newLogoFile;
00264             };
00265         };
00266     };
00267 };
00268 

Generated on 27 Jul 2016 for Hugintrunk by  doxygen 1.4.7