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