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

unix.superglobalmegacorp.com

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