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

Generated on 7 Feb 2016 for Hugintrunk by  doxygen 1.4.7