diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-03-29 16:04:01 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2019-03-29 16:04:01 +0100 |
commit | 88083f8c683c18f4de68a20c863a82a9da65db8f (patch) | |
tree | 926656892d9d80260da02ea8ea71031b140c51df /other-licenses/7zstub/src/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp | |
parent | f999f544aad04069b03704d994a99352263f600b (diff) | |
parent | 843e4ceffd6ce21a6e6db37419335eafdc543e18 (diff) | |
download | UXP-88083f8c683c18f4de68a20c863a82a9da65db8f.tar UXP-88083f8c683c18f4de68a20c863a82a9da65db8f.tar.gz UXP-88083f8c683c18f4de68a20c863a82a9da65db8f.tar.lz UXP-88083f8c683c18f4de68a20c863a82a9da65db8f.tar.xz UXP-88083f8c683c18f4de68a20c863a82a9da65db8f.zip |
Merge branch 'master' into Sync-weave
Diffstat (limited to 'other-licenses/7zstub/src/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp')
-rw-r--r-- | other-licenses/7zstub/src/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp | 175 |
1 files changed, 0 insertions, 175 deletions
diff --git a/other-licenses/7zstub/src/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp b/other-licenses/7zstub/src/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp deleted file mode 100644 index b421e8cce..000000000 --- a/other-licenses/7zstub/src/7zip/FileManager/Resource/ProgressDialog/ProgressDialog.cpp +++ /dev/null @@ -1,175 +0,0 @@ -// ProgressDialog.cpp
-
-#include "StdAfx.h"
-#include "resource.h"
-#include "ProgressDialog.h"
-#include "Common/IntToString.h"
-#include "Common/IntToString.h"
-
-using namespace NWindows;
-
-static const UINT_PTR kTimerID = 3;
-static const UINT kTimerElapse = 50;
-
-#ifdef LANG
-#include "../../LangUtils.h"
-#endif
-
-#ifdef LANG
-static CIDLangPair kIDLangPairs[] =
-{
- { IDCANCEL, 0x02000711 }
-};
-#endif
-
-#ifndef _SFX
-CProgressDialog::~CProgressDialog()
-{
- AddToTitle(TEXT(""));
-}
-void CProgressDialog::AddToTitle(LPCWSTR s)
-{
- if (MainWindow != 0)
- ::MySetWindowText(MainWindow, UString(s) + MainTitle);
-}
-#endif
-
-
-
-bool CProgressDialog::OnInit()
-{
- _range = UINT64(-1);
- _prevPercentValue = -1;
-
- #ifdef LANG
- // LangSetWindowText(HWND(*this), 0x02000C00);
- LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));
- #endif
-
- m_ProgressBar.Attach(GetItem(IDC_PROGRESS1));
- _timer = SetTimer(kTimerID, kTimerElapse);
- _dialogCreatedEvent.Set();
- SetText(_title);
- return CModalDialog::OnInit();
-}
-
-void CProgressDialog::OnCancel()
-{
- ProgressSynch.SetStopped(true);
-}
-
-void CProgressDialog::SetRange(UINT64 range)
-{
- _range = range;
- _peviousPos = (UInt64)(Int64)-1;
- _converter.Init(range);
- m_ProgressBar.SetRange32(0 , _converter.Count(range)); // Test it for 100%
-}
-
-void CProgressDialog::SetPos(UINT64 pos)
-{
- bool redraw = true;
- if (pos < _range && pos > _peviousPos)
- {
- UINT64 posDelta = pos - _peviousPos;
- if (posDelta < (_range >> 10))
- redraw = false;
- }
- if(redraw)
- {
- m_ProgressBar.SetPos(_converter.Count(pos)); // Test it for 100%
- _peviousPos = pos;
- }
-}
-
-bool CProgressDialog::OnTimer(WPARAM timerID, LPARAM callback)
-{
- if (ProgressSynch.GetPaused())
- return true;
- UINT64 total, completed;
- ProgressSynch.GetProgress(total, completed);
- if (total != _range)
- SetRange(total);
- SetPos(completed);
-
- if (total == 0)
- total = 1;
-
- int percentValue = (int)(completed * 100 / total);
- if (percentValue != _prevPercentValue)
- {
- wchar_t s[64];
- ConvertUInt64ToString(percentValue, s);
- UString title = s;
- title += L"% ";
- SetText(title + _title);
- #ifndef _SFX
- AddToTitle(title + MainAddTitle);
- #endif
- _prevPercentValue = percentValue;
- }
- return true;
-}
-
-
-////////////////////
-// CU64ToI32Converter
-
-static const UINT64 kMaxIntValue = 0x7FFFFFFF;
-
-void CU64ToI32Converter::Init(UINT64 range)
-{
- _numShiftBits = 0;
- while(range > kMaxIntValue)
- {
- range >>= 1;
- _numShiftBits++;
- }
-}
-
-int CU64ToI32Converter::Count(UINT64 aValue)
-{
- return int(aValue >> _numShiftBits);
-}
-
-const UINT CProgressDialog::kCloseMessage = WM_USER + 1;
-
-bool CProgressDialog::OnMessage(UINT message, WPARAM wParam, LPARAM lParam)
-{
- switch(message)
- {
- case kCloseMessage:
- {
- KillTimer(_timer);
- _timer = 0;
- End(0);
- return true;
- }
- case WM_SETTEXT:
- {
- if (_timer == 0)
- return true;
- }
- }
- return CModalDialog::OnMessage(message, wParam, lParam);
-}
-
-bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
-{
- switch(buttonID)
- {
- case IDCANCEL:
- {
- bool paused = ProgressSynch.GetPaused();;
- ProgressSynch.SetPaused(true);
- int res = ::MessageBoxW(HWND(*this),
- L"Are you sure you want to cancel?",
- _title, MB_YESNO);
- ProgressSynch.SetPaused(paused);
- if (res == IDNO)
- return true;
- break;
- }
- }
- return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
-}
|