"Fossies" - the Fresh Open Source Software Archive

Member "src/Main/Resources.cpp" (10 Oct 2018, 4537 Bytes) of package /windows/misc/VeraCrypt_1.23-Hotfix-2_Source.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "Resources.cpp" see the Fossies "Dox" file reference documentation.

    1 /*
    2  Derived from source code of TrueCrypt 7.1a, which is
    3  Copyright (c) 2008-2012 TrueCrypt Developers Association and which is governed
    4  by the TrueCrypt License 3.0.
    5 
    6  Modifications and additions to the original source code (contained in this file)
    7  and all other portions of this file are Copyright (c) 2013-2017 IDRIX
    8  and are governed by the Apache License 2.0 the full text of which is
    9  contained in the file License.txt included in VeraCrypt binary and source
   10  code distribution packages.
   11 */
   12 
   13 #include "System.h"
   14 #include "Platform/Platform.h"
   15 #include "Resources.h"
   16 
   17 #ifdef TC_WINDOWS
   18 #include "Main/resource.h"
   19 #endif
   20 
   21 namespace VeraCrypt
   22 {
   23 
   24 #ifdef TC_WINDOWS
   25     static ConstBufferPtr GetWindowsResource (const wchar_t *resourceType, const wchar_t *resourceName)
   26     {
   27         HGLOBAL hResL;
   28         HRSRC hRes;
   29 
   30         hRes = FindResource (NULL, resourceName, resourceType);
   31         throw_sys_if (!hRes);
   32         hResL = LoadResource (NULL, hRes);
   33         throw_sys_if (!hResL);
   34 
   35         const byte *resPtr = (const byte *) LockResource (hResL);
   36         throw_sys_if (!resPtr);
   37 
   38         return ConstBufferPtr (resPtr, SizeofResource (NULL, hRes));
   39     }
   40 #endif // TC_WINDOWS
   41 
   42 
   43     string Resources::GetLanguageXml ()
   44     {
   45 #ifdef TC_WINDOWS
   46         ConstBufferPtr res = GetWindowsResource (L"XML", L"IDR_LANGUAGE");
   47         Buffer strBuf (res.Size() + 1);
   48         strBuf.Zero();
   49         strBuf.CopyFrom (res);
   50         return string (reinterpret_cast <char *> (strBuf.Ptr()));
   51 #else
   52         static byte LanguageXml[] =
   53         {
   54 #           include "Common/Language.xml.h"
   55             , 0
   56         };
   57 
   58         return string ((const char*) LanguageXml);
   59 #endif
   60     }
   61 
   62     string Resources::GetLegalNotices ()
   63     {
   64 #ifdef TC_WINDOWS
   65         ConstBufferPtr res = GetWindowsResource (L"TEXT", L"IDR_LICENSE");
   66         Buffer strBuf (res.Size() + 1);
   67         strBuf.Zero();
   68         strBuf.CopyFrom (res);
   69         return string (reinterpret_cast <char *> (strBuf.Ptr()));
   70 #else
   71         static byte License[] =
   72         {
   73 #           include "License.txt.h"
   74             , 0
   75         };
   76 
   77         return string ((const char*) License);
   78 #endif
   79     }
   80 
   81 
   82 #ifndef TC_NO_GUI
   83 
   84     wxBitmap Resources::GetDriveIconBitmap ()
   85     {
   86 #ifdef TC_WINDOWS
   87         return wxBitmap (L"IDB_DRIVE_ICON", wxBITMAP_TYPE_BMP_RESOURCE).ConvertToImage().Resize (wxSize (16, 12), wxPoint (0, 0));
   88 #else
   89         static const byte DriveIcon[] =
   90         {
   91 #           include "Mount/Drive_icon_96dpi.bmp.h"
   92         };
   93 
   94         wxMemoryInputStream stream (DriveIcon, sizeof (DriveIcon));
   95         return wxBitmap (wxImage (stream).Resize (wxSize (16, 12), wxPoint (0, 0)));
   96 #endif
   97     }
   98 
   99     wxBitmap Resources::GetDriveIconMaskBitmap ()
  100     {
  101 #ifdef TC_WINDOWS
  102         wxImage image = wxBitmap (L"IDB_DRIVE_ICON_MASK", wxBITMAP_TYPE_BMP_RESOURCE).ConvertToImage().Resize (wxSize (16, 12), wxPoint (0, 0));
  103         return wxBitmap (image.ConvertToMono (0, 0, 0), 1);
  104 #else
  105         static const byte DriveIconMask[] =
  106         {
  107 #           include "Mount/Drive_icon_mask_96dpi.bmp.h"
  108         };
  109 
  110         wxMemoryInputStream stream (DriveIconMask, sizeof (DriveIconMask));
  111         wxImage image (stream);
  112         image.Resize (wxSize (16, 12), wxPoint (0, 0));
  113 
  114 #   ifdef __WXGTK__
  115         return wxBitmap (image.ConvertToMono (0, 0, 0), 1);
  116 #   else
  117         return wxBitmap (image);
  118 #   endif
  119 #endif
  120     }
  121 
  122 
  123     wxBitmap Resources::GetLogoBitmap ()
  124     {
  125 #ifdef TC_WINDOWS
  126         return wxBitmap (L"IDB_LOGO", wxBITMAP_TYPE_BMP_RESOURCE);
  127 #else
  128         static const byte Logo[] =
  129         {
  130 #           include "Mount/Logo_96dpi.bmp.h"
  131         };
  132 
  133         wxMemoryInputStream stream (Logo, sizeof (Logo));
  134         return wxBitmap (wxImage (stream));
  135 #endif
  136     }
  137 
  138     wxBitmap Resources::GetTextualLogoBitmap ()
  139     {
  140 #ifdef TC_WINDOWS
  141         return wxBitmap (L"IDB_TEXTUAL_LOGO", wxBITMAP_TYPE_BMP_RESOURCE);
  142 #else
  143         static const byte Logo[] =
  144         {
  145 #           include "Common/Textual_logo_96dpi.bmp.h"
  146         };
  147 
  148         wxMemoryInputStream stream (Logo, sizeof (Logo));
  149         return wxBitmap (wxImage (stream));
  150 #endif
  151     }
  152 
  153     wxIcon Resources::GetVeraCryptIcon ()
  154     {
  155 #ifdef TC_WINDOWS
  156         return wxIcon (L"IDI_TRUECRYPT_ICON", wxBITMAP_TYPE_ICO_RESOURCE, 16, 16);
  157 #else
  158 #       include "Resources/Icons/VeraCrypt-256x256.xpm"
  159         return wxIcon (VeraCryptIcon256x256);
  160 #endif
  161     }
  162 
  163     wxBitmap Resources::GetVolumeCreationWizardBitmap (int height)
  164     {
  165 #ifdef TC_WINDOWS
  166         return wxBitmap (L"IDB_VOLUME_WIZARD_BITMAP", wxBITMAP_TYPE_BMP_RESOURCE);
  167 #else
  168         static const byte VolumeWizardIcon[] =
  169         {
  170 #           include "Format/VeraCrypt_Wizard.bmp.h"
  171         };
  172 
  173         wxMemoryInputStream stream (VolumeWizardIcon, sizeof (VolumeWizardIcon));
  174 
  175         wxImage image (stream);
  176         if (height != -1)
  177         {
  178             double scaleFactor = double (height) / double (image.GetHeight());
  179             image.Rescale (int (image.GetWidth() * scaleFactor), int (image.GetHeight() * scaleFactor), wxIMAGE_QUALITY_HIGH);
  180         }
  181 
  182         return wxBitmap (image);
  183 #endif
  184     }
  185 
  186 #endif // !TC_NO_GUI
  187 
  188 }