other-licenses/7zstub/src/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/other-licenses/7zstub/src/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,129 @@
     1.4 +// ProgressDialog.h
     1.5 +
     1.6 +#ifndef __PROGRESSDIALOG_H
     1.7 +#define __PROGRESSDIALOG_H
     1.8 +
     1.9 +#include "resource.h"
    1.10 +
    1.11 +#include "Windows/Control/Dialog.h"
    1.12 +#include "Windows/Control/ProgressBar.h"
    1.13 +#include "Windows/Synchronization.h"
    1.14 +
    1.15 +class CProgressSynch
    1.16 +{
    1.17 +  NWindows::NSynchronization::CCriticalSection _criticalSection;
    1.18 +  bool _stopped;
    1.19 +  bool _paused;
    1.20 +  UINT64 _total;
    1.21 +  UINT64 _completed;
    1.22 +public:
    1.23 +  CProgressSynch(): _stopped(false), _paused(false), _total(1), _completed(0) {}
    1.24 +
    1.25 +  bool GetStopped()
    1.26 +  {
    1.27 +    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
    1.28 +    return _stopped;
    1.29 +  }
    1.30 +  void SetStopped(bool value)
    1.31 +  {
    1.32 +    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
    1.33 +    _stopped = value;
    1.34 +  }
    1.35 +  bool GetPaused()
    1.36 +  {
    1.37 +    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
    1.38 +    return _paused;
    1.39 +  }
    1.40 +  void SetPaused(bool value)
    1.41 +  {
    1.42 +    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
    1.43 +    _paused = value;
    1.44 +  }
    1.45 +  void SetProgress(UINT64 total, UINT64 completed)
    1.46 +  {
    1.47 +    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
    1.48 +    _total = total;
    1.49 +    _completed = completed;
    1.50 +  }
    1.51 +  void SetPos(UINT64 completed)
    1.52 +  {
    1.53 +    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
    1.54 +    _completed = completed;
    1.55 +  }
    1.56 +  void GetProgress(UINT64 &total, UINT64 &completed)
    1.57 +  {
    1.58 +    NWindows::NSynchronization::CCriticalSectionLock lock(_criticalSection);
    1.59 +    total = _total;
    1.60 +    completed = _completed;
    1.61 +  }
    1.62 +};
    1.63 +
    1.64 +class CU64ToI32Converter
    1.65 +{
    1.66 +  UINT64 _numShiftBits;
    1.67 +public:
    1.68 +  void Init(UINT64 _range);
    1.69 +  int Count(UINT64 aValue);
    1.70 +};
    1.71 +
    1.72 +// class CProgressDialog: public NWindows::NControl::CModelessDialog
    1.73 +
    1.74 +class CProgressDialog: public NWindows::NControl::CModalDialog
    1.75 +{
    1.76 +private:
    1.77 +  UINT_PTR _timer;
    1.78 +
    1.79 +  UString _title;
    1.80 +  CU64ToI32Converter _converter;
    1.81 +  UINT64 _peviousPos;
    1.82 +  UINT64 _range;
    1.83 +	NWindows::NControl::CProgressBar m_ProgressBar;
    1.84 +
    1.85 +  int _prevPercentValue;
    1.86 +
    1.87 +  bool OnTimer(WPARAM timerID, LPARAM callback);
    1.88 +  void SetRange(UINT64 range);
    1.89 +  void SetPos(UINT64 pos);
    1.90 +	virtual bool OnInit();
    1.91 +	virtual void OnCancel();
    1.92 +  NWindows::NSynchronization::CManualResetEvent _dialogCreatedEvent;
    1.93 +  #ifndef _SFX
    1.94 +  void AddToTitle(LPCWSTR string);
    1.95 +  #endif
    1.96 +  bool OnButtonClicked(int buttonID, HWND buttonHWND);
    1.97 +public:
    1.98 +  CProgressSynch ProgressSynch;
    1.99 +
   1.100 +  #ifndef _SFX
   1.101 +  HWND MainWindow;
   1.102 +  UString MainTitle;
   1.103 +  UString MainAddTitle;
   1.104 +  ~CProgressDialog();
   1.105 +  #endif
   1.106 +
   1.107 +  CProgressDialog(): _timer(0)
   1.108 +    #ifndef _SFX
   1.109 +    ,MainWindow(0) 
   1.110 +    #endif
   1.111 +  {}
   1.112 +
   1.113 +  void WaitCreating() { _dialogCreatedEvent.Lock(); }
   1.114 +
   1.115 +
   1.116 +  INT_PTR Create(const UString &title, HWND wndParent = 0)
   1.117 +  { 
   1.118 +    _title = title;
   1.119 +    return CModalDialog::Create(IDD_DIALOG_PROGRESS, wndParent); 
   1.120 +  }
   1.121 +
   1.122 +  static const UINT kCloseMessage;
   1.123 +
   1.124 +  virtual bool OnMessage(UINT message, WPARAM wParam, LPARAM lParam);
   1.125 +
   1.126 +  void MyClose()
   1.127 +  {
   1.128 +    PostMessage(kCloseMessage);
   1.129 +  };
   1.130 +};
   1.131 +
   1.132 +#endif

mercurial