Annotation of truecrypt/main/resources.cpp, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.