summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/lzma/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2023-12-06 07:58:49 +1100
committer Vas Crabb <vas@vastheman.com>2023-12-06 07:58:49 +1100
commit79bef1e23049fdac25f1fefd132e0b6c7d2cc3a1 (patch)
tree643e9313fe86f583c4022c338677cbc12b761df7 /3rdparty/lzma/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
parent512ccf0c7c9b4f08e41038b2ed2de220e140385b (diff)
3rdparty/lzma: Updated to version 23.01.
Diffstat (limited to '3rdparty/lzma/CPP/7zip/UI/FileManager/ProgressDialog2.cpp')
-rw-r--r--3rdparty/lzma/CPP/7zip/UI/FileManager/ProgressDialog2.cpp127
1 files changed, 67 insertions, 60 deletions
diff --git a/3rdparty/lzma/CPP/7zip/UI/FileManager/ProgressDialog2.cpp b/3rdparty/lzma/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
index 54273d0ce12..1521d83ceca 100644
--- a/3rdparty/lzma/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
+++ b/3rdparty/lzma/CPP/7zip/UI/FileManager/ProgressDialog2.cpp
@@ -2,6 +2,10 @@
#include "StdAfx.h"
+#ifdef Z7_OLD_WIN_SDK
+#include <ShlGuid.h>
+#endif
+
#include "../../../Common/IntToString.h"
#include "../../../Common/StringConvert.h"
@@ -43,7 +47,7 @@ static const UINT kCreateDelay =
static const DWORD kPauseSleepTime = 100;
-#ifdef LANG
+#ifdef Z7_LANG
static const UInt32 kLangIDs[] =
{
@@ -67,19 +71,19 @@ static const UInt32 kLangIDs_Colon[] =
#endif
-#define UNDEFINED_VAL ((UInt64)(Int64)-1)
-#define INIT_AS_UNDEFINED(v) v = UNDEFINED_VAL;
-#define IS_UNDEFINED_VAL(v) ((v) == UNDEFINED_VAL)
-#define IS_DEFINED_VAL(v) ((v) != UNDEFINED_VAL)
+#define UNDEFINED_VAL ((UInt64)(Int64)-1)
+#define INIT_AS_UNDEFINED(v) v = UNDEFINED_VAL;
+#define IS_UNDEFINED_VAL(v) ((v) == UNDEFINED_VAL)
+#define IS_DEFINED_VAL(v) ((v) != UNDEFINED_VAL)
CProgressSync::CProgressSync():
_stopped(false), _paused(false),
_bytesProgressMode(true),
+ _isDir(false),
_totalBytes(UNDEFINED_VAL), _completedBytes(0),
_totalFiles(UNDEFINED_VAL), _curFiles(0),
_inSize(UNDEFINED_VAL),
- _outSize(UNDEFINED_VAL),
- _isDir(false)
+ _outSize(UNDEFINED_VAL)
{}
#define CHECK_STOP if (_stopped) return E_ABORT; if (!_paused) return S_OK;
@@ -228,7 +232,7 @@ void CProgressSync::AddError_Message_Name(const wchar_t *message, const wchar_t
AddError_Message(s);
}
-void CProgressSync::AddError_Code_Name(DWORD systemError, const wchar_t *name)
+void CProgressSync::AddError_Code_Name(HRESULT systemError, const wchar_t *name)
{
UString s = NError::MyFormatMessage(systemError);
if (systemError == 0)
@@ -262,20 +266,20 @@ CProgressDialog::CProgressDialog():
throw 1334987;
if (_createDialogEvent.Create() != S_OK)
throw 1334987;
- #ifdef __ITaskbarList3_INTERFACE_DEFINED__
+ // #ifdef __ITaskbarList3_INTERFACE_DEFINED__
CoCreateInstance(CLSID_TaskbarList, NULL, CLSCTX_INPROC_SERVER, IID_ITaskbarList3, (void**)&_taskbarList);
if (_taskbarList)
_taskbarList->HrInit();
- #endif
+ // #endif
}
-#ifndef _SFX
+#ifndef Z7_SFX
CProgressDialog::~CProgressDialog()
{
- #ifdef __ITaskbarList3_INTERFACE_DEFINED__
+ // #ifdef __ITaskbarList3_INTERFACE_DEFINED__
SetTaskbarProgressState(TBPF_NOPROGRESS);
- #endif
+ // #endif
AddToTitle(L"");
}
void CProgressDialog::AddToTitle(LPCWSTR s)
@@ -292,7 +296,7 @@ void CProgressDialog::AddToTitle(LPCWSTR s)
void CProgressDialog::SetTaskbarProgressState()
{
- #ifdef __ITaskbarList3_INTERFACE_DEFINED__
+ // #ifdef __ITaskbarList3_INTERFACE_DEFINED__
if (_taskbarList && _hwndForTaskbar)
{
TBPFLAG tbpFlags;
@@ -302,7 +306,7 @@ void CProgressDialog::SetTaskbarProgressState()
tbpFlags = _errorsWereDisplayed ? TBPF_ERROR: TBPF_NORMAL;
SetTaskbarProgressState(tbpFlags);
}
- #endif
+ // #endif
}
static const unsigned kTitleFileNameSizeLimit = 36;
@@ -331,23 +335,23 @@ bool CProgressDialog::OnInit()
if (!_hwndForTaskbar)
_hwndForTaskbar = *this;
- INIT_AS_UNDEFINED(_progressBar_Range);
- INIT_AS_UNDEFINED(_progressBar_Pos);
+ INIT_AS_UNDEFINED(_progressBar_Range)
+ INIT_AS_UNDEFINED(_progressBar_Pos)
- INIT_AS_UNDEFINED(_prevPercentValue);
- INIT_AS_UNDEFINED(_prevElapsedSec);
- INIT_AS_UNDEFINED(_prevRemainingSec);
+ INIT_AS_UNDEFINED(_prevPercentValue)
+ INIT_AS_UNDEFINED(_prevElapsedSec)
+ INIT_AS_UNDEFINED(_prevRemainingSec)
- INIT_AS_UNDEFINED(_prevSpeed);
+ INIT_AS_UNDEFINED(_prevSpeed)
_prevSpeed_MoveBits = 0;
_prevTime = ::GetTickCount();
_elapsedTime = 0;
- INIT_AS_UNDEFINED(_totalBytes_Prev);
- INIT_AS_UNDEFINED(_processed_Prev);
- INIT_AS_UNDEFINED(_packed_Prev);
- INIT_AS_UNDEFINED(_ratio_Prev);
+ INIT_AS_UNDEFINED(_totalBytes_Prev)
+ INIT_AS_UNDEFINED(_processed_Prev)
+ INIT_AS_UNDEFINED(_packed_Prev)
+ INIT_AS_UNDEFINED(_ratio_Prev)
_filesStr_Prev.Empty();
_filesTotStr_Prev.Empty();
@@ -362,9 +366,9 @@ bool CProgressDialog::OnInit()
_wasCreated = true;
_dialogCreatedEvent.Set();
- #ifdef LANG
- LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs));
- LangSetDlgItems_Colon(*this, kLangIDs_Colon, ARRAY_SIZE(kLangIDs_Colon));
+ #ifdef Z7_LANG
+ LangSetDlgItems(*this, kLangIDs, Z7_ARRAY_SIZE(kLangIDs));
+ LangSetDlgItems_Colon(*this, kLangIDs_Colon, Z7_ARRAY_SIZE(kLangIDs_Colon));
#endif
CWindow window(GetItem(IDB_PROGRESS_BACKGROUND));
@@ -453,12 +457,12 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
InvalidateRect(NULL);
- int xSizeClient = xSize - mx * 2;
+ const int xSizeClient = xSize - mx * 2;
{
- int i;
+ unsigned i;
for (i = 800; i > 40; i = i * 9 / 10)
- if (Units_To_Pixels_X(i) <= xSizeClient)
+ if (Units_To_Pixels_X((int)i) <= xSizeClient)
break;
_numReduceSymbols = i / 4;
}
@@ -473,7 +477,7 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
int mx2 = mx;
for (;; mx2--)
{
- int bSize2 = bSizeX * 3 + mx2 * 2;
+ const int bSize2 = bSizeX * 3 + mx2 * 2;
if (bSize2 <= xSizeClient)
break;
if (mx2 < 5)
@@ -488,7 +492,7 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
{
RECT r;
GetClientRectOfItem(IDL_PROGRESS_MESSAGES, r);
- int y = r.top;
+ const int y = r.top;
int ySize2 = yPos - my - y;
const int kMinYSize = _buttonSizeY + _buttonSizeY * 3 / 4;
int xx = xSize - mx * 2;
@@ -519,13 +523,13 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
labelSize = Units_To_Pixels_X(MY_PROGRESS_LABEL_UNITS_MIN);
valueSize = Units_To_Pixels_X(MY_PROGRESS_VAL_UNITS);
padSize = Units_To_Pixels_X(MY_PROGRESS_PAD_UNITS);
- int requiredSize = (labelSize + valueSize) * 2 + padSize;
+ const int requiredSize = (labelSize + valueSize) * 2 + padSize;
int gSize;
{
if (requiredSize < xSizeClient)
{
- int incr = (xSizeClient - requiredSize) / 3;
+ const int incr = (xSizeClient - requiredSize) / 3;
labelSize += incr;
}
else
@@ -540,7 +544,7 @@ bool CProgressDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
labelSize = gSize - valueSize;
yPos = my;
- for (unsigned i = 0; i < ARRAY_SIZE(kIDs); i += 2)
+ for (unsigned i = 0; i < Z7_ARRAY_SIZE(kIDs); i += 2)
{
int x = mx;
const unsigned kNumColumn1Items = 5 * 2;
@@ -566,7 +570,7 @@ void CProgressDialog::SetProgressRange(UInt64 range)
if (range == _progressBar_Range)
return;
_progressBar_Range = range;
- INIT_AS_UNDEFINED(_progressBar_Pos);
+ INIT_AS_UNDEFINED(_progressBar_Pos)
_progressConv.Init(range);
m_ProgressBar.SetRange32(0, _progressConv.Count(range));
}
@@ -578,10 +582,10 @@ void CProgressDialog::SetProgressPos(UInt64 pos)
pos - _progressBar_Pos >= (_progressBar_Range >> 10))
{
m_ProgressBar.SetPos(_progressConv.Count(pos));
- #ifdef __ITaskbarList3_INTERFACE_DEFINED__
+ // #ifdef __ITaskbarList3_INTERFACE_DEFINED__
if (_taskbarList && _hwndForTaskbar)
_taskbarList->SetProgressValue(_hwndForTaskbar, pos, _progressBar_Range);
- #endif
+ // #endif
_progressBar_Pos = pos;
}
}
@@ -603,10 +607,10 @@ void GetTimeString(UInt64 timeValue, wchar_t *s)
else
{
UInt32 hours32 = (UInt32)hours;
- UINT_TO_STR_2(hours32);
+ UINT_TO_STR_2(hours32)
}
- *s++ = ':'; UINT_TO_STR_2(minutes);
- *s++ = ':'; UINT_TO_STR_2(seconds);
+ *s++ = ':'; UINT_TO_STR_2(minutes)
+ *s++ = ':'; UINT_TO_STR_2(seconds)
*s = 0;
}
@@ -627,7 +631,7 @@ static void ConvertSizeToString(UInt64 v, wchar_t *s)
}
}
-void CProgressDialog::ShowSize(int id, UInt64 val, UInt64 &prev)
+void CProgressDialog::ShowSize(unsigned id, UInt64 val, UInt64 &prev)
{
if (val == prev)
return;
@@ -771,7 +775,7 @@ void CProgressDialog::UpdateStatInfo(bool showAll)
{
if (IS_DEFINED_VAL(_prevRemainingSec))
{
- INIT_AS_UNDEFINED(_prevRemainingSec);
+ INIT_AS_UNDEFINED(_prevRemainingSec)
SetItemText(IDT_PROGRESS_REMAINING_VAL, L"");
}
}
@@ -790,8 +794,9 @@ void CProgressDialog::UpdateStatInfo(bool showAll)
}
}
{
- UInt64 elapsedTime = (_elapsedTime == 0) ? 1 : _elapsedTime;
- UInt64 v = (progressCompleted * 1000) / elapsedTime;
+ const UInt64 elapsedTime = (_elapsedTime == 0) ? 1 : _elapsedTime;
+ // 22.02: progressCompleted can be for number of files
+ UInt64 v = (completed * 1000) / elapsedTime;
Byte c = 0;
unsigned moveBits = 0;
if (v >= ((UInt64)10000 << 10)) { moveBits = 20; c = 'M'; }
@@ -957,7 +962,7 @@ INT_PTR CProgressDialog::Create(const UString &title, NWindows::CThread &thread,
CWaitCursor waitCursor;
HANDLE h[] = { thread, _createDialogEvent };
- DWORD res2 = WaitForMultipleObjects(ARRAY_SIZE(h), h, FALSE, kCreateDelay);
+ const DWORD res2 = WaitForMultipleObjects(Z7_ARRAY_SIZE(h), h, FALSE, kCreateDelay);
if (res2 == WAIT_OBJECT_0 && !Sync.ThereIsMessage())
return 0;
}
@@ -979,9 +984,9 @@ INT_PTR CProgressDialog::Create(const UString &title, NWindows::CThread &thread,
bool CProgressDialog::OnExternalCloseMessage()
{
// it doesn't work if there is MessageBox.
- #ifdef __ITaskbarList3_INTERFACE_DEFINED__
+ // #ifdef __ITaskbarList3_INTERFACE_DEFINED__
SetTaskbarProgressState(TBPF_NOPROGRESS);
- #endif
+ // #endif
// AddToTitle(L"Finished ");
// SetText(L"Finished2 ");
@@ -1088,7 +1093,7 @@ void CProgressDialog::SetTitleText()
}
s.Add_Space();
- #ifndef _SFX
+ #ifndef Z7_SFX
{
unsigned len = s.Len();
s += MainAddTitle;
@@ -1150,9 +1155,9 @@ void CProgressDialog::AddMessageDirect(LPCWSTR message, bool needNumber)
if (needNumber)
ConvertUInt32ToString(_numMessages + 1, sz);
const unsigned itemIndex = _messageStrings.Size(); // _messageList.GetItemCount();
- if (_messageList.InsertItem((int)itemIndex, sz) == (int)itemIndex)
+ if (_messageList.InsertItem(itemIndex, sz) == (int)itemIndex)
{
- _messageList.SetSubItem((int)itemIndex, 1, message);
+ _messageList.SetSubItem(itemIndex, 1, message);
_messageStrings.Add(message);
}
}
@@ -1163,12 +1168,12 @@ void CProgressDialog::AddMessage(LPCWSTR message)
bool needNumber = true;
while (!s.IsEmpty())
{
- int pos = s.Find(L'\n');
+ const int pos = s.Find(L'\n');
if (pos < 0)
break;
- AddMessageDirect(s.Left(pos), needNumber);
+ AddMessageDirect(s.Left((unsigned)pos), needNumber);
needNumber = false;
- s.DeleteFrontal(pos + 1);
+ s.DeleteFrontal((unsigned)pos + 1);
}
AddMessageDirect(s, needNumber);
_numMessages++;
@@ -1210,7 +1215,7 @@ void CProgressDialog::UpdateMessagesDialog()
}
-bool CProgressDialog::OnButtonClicked(int buttonID, HWND buttonHWND)
+bool CProgressDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
{
switch (buttonID)
{
@@ -1340,7 +1345,7 @@ static void ListView_GetSelected(NControl::CListView &listView, CUIntVector &vec
index = listView.GetNextSelectedItem(index);
if (index < 0)
break;
- vector.Add(index);
+ vector.Add((unsigned)index);
}
}
@@ -1352,7 +1357,7 @@ void CProgressDialog::CopyToClipboard()
UString s;
unsigned numIndexes = indexes.Size();
if (numIndexes == 0)
- numIndexes = _messageList.GetItemCount();
+ numIndexes = (unsigned)_messageList.GetItemCount();
for (unsigned i = 0; i < numIndexes; i++)
{
@@ -1391,7 +1396,9 @@ static THREAD_FUNC_DECL MyThreadFunction(void *param)
HRESULT CProgressThreadVirt::Create(const UString &title, HWND parentWindow)
{
NWindows::CThread thread;
- RINOK(thread.Create(MyThreadFunction, this));
+ const WRes wres = thread.Create(MyThreadFunction, this);
+ if (wres != 0)
+ return HRESULT_FROM_WIN32(wres);
CProgressDialog::Create(title, thread, parentWindow);
return S_OK;
}
@@ -1417,7 +1424,7 @@ void CProgressThreadVirt::Process()
catch(int v)
{
m = "Error #";
- m.Add_UInt32(v);
+ m.Add_UInt32((unsigned)v);
}
catch(...) { m = "Error"; }
if (Result != E_ABORT)