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)
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.txt");
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"), wxGetFreeMemory().GetValue()/1024ll);
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     text = text + wxT("\n") + _("Multi-threading using C++11 std::thread and OpenMP");
00192     if (huginApp::Get()->HasMonitorProfile())
00193     {
00194         text = text + wxT("\n") + wxString::Format(_("Monitor profile: %s"), huginApp::Get()->GetMonitorProfileName().c_str());
00195     }
00196     text=text+wxT("\n\n")+_("Libraries");
00197 #if wxCHECK_VERSION(3,0,0)
00198     wxVersionInfo info = wxGetLibraryVersionInfo();
00199     text = text + wxT("\nwxWidgets: ") + info.GetVersionString();
00200     if(info.HasDescription())
00201     {
00202         text=text+wxT("\n")+info.GetDescription();
00203     };
00204 #else
00205     text=text+wxT("\n")+wxString::Format(wxT("wxWidgets: %i.%i.%i.%i"),
00206                                             wxMAJOR_VERSION,
00207                                             wxMINOR_VERSION,
00208                                             wxRELEASE_NUMBER,
00209                                             wxSUBRELEASE_NUMBER
00210                                             );
00211 #endif
00212     {
00213         char panoVersion[255];
00214         if (queryFeatureString(PTVERSION_NAME_FILEVERSION, panoVersion, sizeof(panoVersion) / sizeof(panoVersion[0])))
00215         {
00216             text = text + wxT("\nlibpano13: ") + wxString(panoVersion, wxConvLocal);
00217         };
00218     }
00219 #if !(defined HAVE_STD_FILESYSTEM)
00220     text=text+wxT("\n")+wxString::Format(wxT("Boost: %i.%i.%i"),BOOST_VERSION / 100000, BOOST_VERSION / 100 % 1000, BOOST_VERSION % 100);
00221 #endif
00222     text = text + wxT("\n") + wxT("Exiv2: ") + wxString(Exiv2::version(), wxConvLocal);
00223     text = text + wxT("\n") + wxT("SQLite3: ") + wxString(sqlite3_libversion(), wxConvLocal);
00224     text = text + wxT("\n") + wxString::Format(wxT("Vigra: %s"), wxString(VIGRA_VERSION, wxConvLocal).c_str());
00225     text = text + wxT("\n") + wxString::Format(wxT("LittleCMS2: %i.%i"), LCMS_VERSION / 1000, LCMS_VERSION / 10 % 100);
00226     infoText->SetValue(text);
00227 }
00228 
00229 void AboutDialog::OnChangedTab(wxNotebookEvent &e)
00230 {
00231     // determine which tab is currently visible
00232    SetMode(e.GetSelection());
00233 };
00234 
00235 void AboutDialog::SetMode(int newMode)
00236 {
00237     if(m_mode==newMode)
00238     {
00239         return;
00240     }
00241 
00242     switch ( newMode )
00243     {
00244 
00245         case 0 :
00246             // about tab
00247             SetLogo(wxT("splash.png"));
00248             break;
00249 
00250 // dedication tab no longer in use            
00251 //        case 6 :
00252             // dedication tab
00253 //            SetLogo(wxT("dedication.png"));
00254 //            break;
00255 
00256         default :
00257             // all other tabs
00258             SetLogo(wxT("logo.png"));
00259     }
00260 
00261     m_mode=newMode;
00262     return;
00263 };
00264 
00265 void AboutDialog::SetLogo(wxString newLogoFile)
00266 {
00267     if(m_logo_file!=newLogoFile)
00268     {
00269         if(m_logo.LoadFile(huginApp::Get()->GetXRCPath() +
00270                         wxT("data/") + newLogoFile,
00271                         wxBITMAP_TYPE_PNG))
00272         {
00273             if(m_logoImgCtrl)
00274             {
00275                 m_logoImgCtrl->SetBitmap(m_logo);
00276                 m_logo_file=newLogoFile;
00277             };
00278         };
00279     };
00280 };
00281 

Generated on 26 May 2016 for Hugintrunk by  doxygen 1.4.7