"Fossies" - the Fresh Open Source Software Archive

Member "src/Main/Forms/ProgressWizardPage.cpp" (10 Oct 2018, 2208 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 "ProgressWizardPage.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 "Main/GraphicUserInterface.h"
   15 #include "ProgressWizardPage.h"
   16 
   17 namespace VeraCrypt
   18 {
   19     ProgressWizardPage::ProgressWizardPage (wxPanel* parent, bool enableAbort)
   20         : ProgressWizardPageBase (parent),
   21         PreviousGaugeValue (0),
   22         ProgressBarRange (1),
   23         RealProgressBarRange (1)
   24     {
   25 #ifdef TC_MACOSX
   26         ProgressGauge->SetMinSize (wxSize (-1, 12)); // OS X apparently supports only up to 12px thick progress bars
   27 #else
   28         ProgressGauge->SetMinSize (wxSize (-1, Gui->GetCharHeight (this) * 2));
   29 #endif
   30 
   31         ProgressValue.Set (0);
   32         ProgressGauge->SetValue (0);
   33 
   34         AbortButton->Show (enableAbort);
   35 
   36         class Timer : public wxTimer
   37         {
   38         public:
   39             Timer (ProgressWizardPage *page) : Page (page) { }
   40 
   41             void Notify()
   42             {
   43                 Page->OnTimer();
   44             }
   45 
   46             ProgressWizardPage *Page;
   47         };
   48 
   49         mTimer.reset (dynamic_cast <wxTimer *> (new Timer (this)));
   50         mTimer->Start (30);
   51     }
   52 
   53     void ProgressWizardPage::OnAbortButtonClick (wxCommandEvent& event)
   54     {
   55         AbortEvent.Raise();
   56     }
   57 
   58     void ProgressWizardPage::OnTimer ()
   59     {
   60         uint64 value = ProgressValue.Get();
   61         int gaugeValue = static_cast <int> (value * RealProgressBarRange / ProgressBarRange);
   62 
   63         if (value == ProgressBarRange)
   64             gaugeValue = RealProgressBarRange; // Prevent round-off error
   65 
   66         if (gaugeValue != PreviousGaugeValue)
   67         {
   68             ProgressGauge->SetValue (gaugeValue);
   69             PreviousGaugeValue = gaugeValue;
   70         }
   71     }
   72 
   73     void ProgressWizardPage::SetMaxStaticTextWidth (int width)
   74     {
   75         InfoStaticText->Wrap (width);
   76     }
   77 
   78     void ProgressWizardPage::SetProgressRange (uint64 progressBarRange)
   79     {
   80         ProgressBarRange = progressBarRange;
   81         RealProgressBarRange = ProgressGauge->GetSize().GetWidth();
   82         ProgressGauge->SetRange (RealProgressBarRange);
   83     }
   84 }