"Fossies" - the Fresh Open Source Software Archive

Member "src/Main/GraphicUserInterface.h" (10 Oct 2018, 9017 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 "GraphicUserInterface.h" see the Fossies "Dox" file reference documentation and the last Fossies "Diffs" side-by-side code changes report: 1.22_Source_vs_1.23_Source.

    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 #ifndef TC_HEADER_Main_GraphicUserInterface
   14 #define TC_HEADER_Main_GraphicUserInterface
   15 
   16 #include "System.h"
   17 #include <utility>
   18 #include "Main.h"
   19 #include "UserInterface.h"
   20 #include "Forms/WaitDialog.h"
   21 
   22 namespace VeraCrypt
   23 {
   24     class GraphicUserInterface : public UserInterface
   25     {
   26     public:
   27         GraphicUserInterface ();
   28         virtual ~GraphicUserInterface ();
   29 
   30         virtual void AppendToListCtrl (wxListCtrl *listCtrl, const vector <wstring> &itemFields, int imageIndex = -1, void *itemDataPtr = nullptr) const;
   31         virtual wxMenuItem *AppendToMenu (wxMenu &menu, const wxString &label, wxEvtHandler *handler = nullptr, wxObjectEventFunction handlerFunction = nullptr, int itemId = wxID_ANY) const;
   32         virtual bool AskYesNo (const wxString &message, bool defaultYes = false, bool warning = false) const;
   33         virtual void AutoDismountVolumes (VolumeInfoList mountedVolumes, bool alwaysForce = true);
   34         virtual void BackupVolumeHeaders (shared_ptr <VolumePath> volumePath) const;
   35         virtual void BeginBusyState () const { wxBeginBusyCursor(); }
   36         virtual void BeginInteractiveBusyState (wxWindow *window);
   37         virtual void ChangePassword (shared_ptr <VolumePath> volumePath = shared_ptr <VolumePath>(), shared_ptr <VolumePassword> password = shared_ptr <VolumePassword>(), int pim = 0, shared_ptr <Hash> currentHash = shared_ptr <Hash>(), bool truecryptMode = false, shared_ptr <KeyfileList> keyfiles = shared_ptr <KeyfileList>(), shared_ptr <VolumePassword> newPassword = shared_ptr <VolumePassword>(), int newPim = 0, shared_ptr <KeyfileList> newKeyfiles = shared_ptr <KeyfileList>(), shared_ptr <Hash> newHash = shared_ptr <Hash>()) const { ThrowTextModeRequired(); }
   38         wxHyperlinkCtrl *CreateHyperlink (wxWindow *parent, const wxString &linkUrl, const wxString &linkText) const;
   39         virtual void CreateKeyfile (shared_ptr <FilePath> keyfilePath = shared_ptr <FilePath>()) const;
   40         virtual void CreateVolume (shared_ptr <VolumeCreationOptions> options) const { ThrowTextModeRequired(); }
   41         virtual void ClearListCtrlSelection (wxListCtrl *listCtrl) const;
   42         virtual void DeleteSecurityTokenKeyfiles () const { ThrowTextModeRequired(); }
   43         virtual void DoShowError (const wxString &message) const;
   44         virtual void DoShowInfo (const wxString &message) const;
   45         virtual void DoShowString (const wxString &str) const;
   46         virtual void DoShowWarning (const wxString &message) const;
   47         virtual void EndBusyState () const { wxEndBusyCursor(); }
   48         virtual void EndInteractiveBusyState (wxWindow *window) const;
   49         virtual void ExportSecurityTokenKeyfile () const { ThrowTextModeRequired(); }
   50         virtual wxTopLevelWindow *GetActiveWindow () const;
   51         virtual shared_ptr <GetStringFunctor> GetAdminPasswordRequestHandler ();
   52         virtual int GetCharHeight (wxWindow *window) const;
   53         virtual int GetCharWidth (wxWindow *window) const;
   54         virtual int GetDefaultBorderSize () const { return 5; }
   55         virtual wxFont GetDefaultBoldFont (wxWindow *window) const;
   56         virtual wxString GetHomepageLinkURL (const wxString &linkId, const wxString &extraVars = wxEmptyString) const;
   57         virtual wxFrame *GetMainFrame () const { return mMainFrame; }
   58         virtual int GetScrollbarWidth (wxWindow *window, bool noScrollBar = false) const;
   59         virtual list <long> GetListCtrlSelectedItems (wxListCtrl *listCtrl) const;
   60         virtual wxString GetListCtrlSubItemText (wxListCtrl *listCtrl, long itemIndex, int columnIndex) const;
   61         virtual void ImportSecurityTokenKeyfiles () const { ThrowTextModeRequired(); }
   62         virtual void InitSecurityTokenLibrary () const;
   63         virtual void InsertToListCtrl (wxListCtrl *listCtrl, long itemIndex, const vector <wstring> &itemFields, int imageIndex = -1, void *itemDataPtr = nullptr) const;
   64         virtual bool IsInBackgroundMode () const { return BackgroundMode; }
   65         virtual bool IsTheOnlyTopLevelWindow (const wxWindow *window) const;
   66         virtual void ListSecurityTokenKeyfiles () const;
   67         virtual VolumeInfoList MountAllDeviceHostedVolumes (MountOptions &options) const;
   68         virtual shared_ptr <VolumeInfo> MountVolume (MountOptions &options) const;
   69         virtual void MoveListCtrlItem (wxListCtrl *listCtrl, long itemIndex, long newItemIndex) const;
   70         virtual void OnAutoDismountAllEvent ();
   71         virtual bool OnInit ();
   72         virtual void OnLogOff ();
   73         virtual void OpenDocument (wxWindow *parent, const wxFileName &document);
   74         virtual void OpenHomepageLink (wxWindow *parent, const wxString &linkId, const wxString &extraVars = wxEmptyString);
   75         virtual void OpenOnlineHelp (wxWindow *parent);
   76         virtual void OpenUserGuide (wxWindow *parent);
   77         virtual void RestoreVolumeHeaders (shared_ptr <VolumePath> volumePath) const;
   78         virtual DevicePath SelectDevice (wxWindow *parent) const;
   79         virtual DirectoryPath SelectDirectory (wxWindow *parent, const wxString &message = wxEmptyString, bool existingOnly = true) const;
   80         virtual FilePathList SelectFiles (wxWindow *parent, const wxString &caption, bool saveMode = false, bool allowMultiple = false, const list < pair <wstring, wstring> > &fileExtensions = (list < pair <wstring, wstring> > ()), const DirectoryPath &directory = DirectoryPath()) const;
   81         virtual FilePath SelectVolumeFile (wxWindow *parent, bool saveMode = false, const DirectoryPath &directory = DirectoryPath()) const;
   82         virtual void SetActiveFrame (wxFrame *frame) { ActiveFrame = frame; }
   83         virtual void SetBackgroundMode (bool state);
   84         virtual void SetListCtrlColumnWidths (wxListCtrl *listCtrl, list <int> columnWidthPermilles, bool hasVerticalScrollbar = true) const;
   85         virtual void SetListCtrlHeight (wxListCtrl *listCtrl, size_t rowCount) const;
   86         virtual void SetListCtrlWidth (wxListCtrl *listCtrl, size_t charCount, bool hasVerticalScrollbar = true) const;
   87         virtual void ShowErrorTopMost (char *langStringId) const { ShowErrorTopMost (LangString[langStringId]); }
   88         virtual void ShowErrorTopMost (const wxString &message) const;
   89         virtual void ShowInfoTopMost (char *langStringId) const { ShowInfoTopMost (LangString[langStringId]); }
   90         virtual void ShowInfoTopMost (const wxString &message) const;
   91         virtual void ShowWarningTopMost (char *langStringId) const { ShowWarningTopMost (LangString[langStringId]); }
   92         virtual void ShowWarningTopMost (const wxString &message) const;
   93         virtual bool UpdateListCtrlItem (wxListCtrl *listCtrl, long itemIndex, const vector <wstring> &itemFields) const;
   94         virtual void UserEnrichRandomPool (wxWindow *parent, shared_ptr <Hash> hash = shared_ptr <Hash>()) const;
   95         virtual void Yield () const;
   96         virtual shared_ptr <VolumeInfo> MountVolumeThread (MountOptions &options) const;
   97         WaitDialog* GetWaitDialog () { return mWaitDialog; }
   98         void ExecuteWaitThreadRoutine (wxWindow *parent, WaitThreadRoutine *pRoutine) const;
   99 
  100 #ifdef TC_MACOSX
  101         virtual void MacOpenFiles (const wxArrayString &fileNames);
  102         virtual void MacReopenApp ();
  103         static bool HandlePasswordEntryCustomEvent (wxEvent& event);
  104         static void InstallPasswordEntryCustomKeyboardShortcuts (wxWindow* window);
  105 #endif
  106 
  107         template <class T>
  108         T *GetSelectedData (wxControlWithItems *control) const
  109         {
  110             int sel = control->GetSelection();
  111             if (sel == wxNOT_FOUND)
  112                 return nullptr;
  113 
  114             return reinterpret_cast <T *> (control->GetClientData (sel));
  115         }
  116 
  117         Event OpenVolumeSystemRequestEvent;
  118 
  119     protected:
  120         virtual void OnEndSession (wxCloseEvent& event) { OnLogOff(); }
  121 #ifdef wxHAS_POWER_EVENTS
  122         virtual void OnPowerSuspending (wxPowerEvent& event);
  123 #endif
  124         static void OnSignal (int signal);
  125         virtual void OnVolumesAutoDismounted ();
  126         virtual int ShowMessage (const wxString &message, long style, bool topMost = false) const;
  127         void ThrowTextModeRequired () const;
  128 
  129         wxFrame *ActiveFrame;
  130         bool BackgroundMode;
  131 #ifdef TC_WINDOWS
  132         auto_ptr <wxDDEServer> DDEServer;
  133 #endif
  134         wxFrame *mMainFrame;
  135         auto_ptr <wxSingleInstanceChecker> SingleInstanceChecker;
  136 
  137         mutable WaitDialog* mWaitDialog;
  138 public: 
  139 #ifdef TC_MACOSX
  140         static int g_customIdCmdV;
  141         static int g_customIdCmdA;
  142 #endif
  143 
  144     private:
  145         GraphicUserInterface (const GraphicUserInterface &);
  146         GraphicUserInterface &operator= (const GraphicUserInterface &);
  147     };
  148 
  149 
  150     struct OpenVolumeSystemRequestEventArgs : public EventArgs
  151     {
  152         OpenVolumeSystemRequestEventArgs (const wxString &volumePath) : mVolumePath (volumePath) { }
  153         wxString mVolumePath;
  154     };
  155 
  156 
  157     class FreezeScope
  158     {
  159     public:
  160         FreezeScope (wxWindow *window) : Window (window)
  161         {
  162             Window->Freeze();
  163         }
  164 
  165         ~FreezeScope ()
  166         {
  167             Window->Thaw();
  168         }
  169 
  170         wxWindow *Window;
  171     };
  172 
  173     DECLARE_EVENT_TYPE (TC_EVENT_THREAD_EXITING, -1);
  174 
  175     extern GraphicUserInterface *Gui;
  176 }
  177 
  178 #endif // TC_HEADER_Main_GraphicUserInterface