Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pavlov <ipavlov@users.sourceforge.net>2007-01-20 03:00:00 +0300
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:15:49 +0300
commitd9666cf046a8453b33b3e2fbf4d82295a9f87df3 (patch)
treec722ed19b844b53042aec0c1d7d2f8381140a5ed /CPP/7zip/UI/Far/ProgressBox.cpp
parent804edc5756fede54dbb1aefda6d39d306111938d (diff)
4.44 beta
Diffstat (limited to 'CPP/7zip/UI/Far/ProgressBox.cpp')
-rwxr-xr-xCPP/7zip/UI/Far/ProgressBox.cpp103
1 files changed, 103 insertions, 0 deletions
diff --git a/CPP/7zip/UI/Far/ProgressBox.cpp b/CPP/7zip/UI/Far/ProgressBox.cpp
new file mode 100755
index 00000000..64e0e09d
--- /dev/null
+++ b/CPP/7zip/UI/Far/ProgressBox.cpp
@@ -0,0 +1,103 @@
+// ProgressBox.cpp
+
+#include "StdAfx.h"
+
+#include <stdio.h>
+
+#include "ProgressBox.h"
+
+#include "FarUtils.h"
+
+using namespace NFar;
+
+static void CopySpaces(char *destString, int numSpaces)
+{
+ for(int i = 0; i < numSpaces; i++)
+ destString[i] = ' ';
+ destString[i] = '\0';
+}
+
+/////////////////////////////////
+// CMessageBox
+
+const int kNumStringsMax = 10;
+
+void CMessageBox::Init(const CSysString &title, const CSysString &message,
+ int numStrings, int width)
+{
+ if (numStrings > kNumStringsMax)
+ throw 120620;
+ m_NumStrings = numStrings;
+ m_Width = width;
+
+ m_Title = title;
+ m_Message = message;
+}
+
+const int kNumStaticStrings = 2;
+
+void CMessageBox::ShowProcessMessages(const char *messages[])
+{
+ const char *msgItems[kNumStaticStrings + kNumStringsMax];
+ msgItems[0] = m_Title;
+ msgItems[1] = m_Message;
+
+ char formattedMessages[kNumStringsMax][256];
+
+ for (int i = 0; i < m_NumStrings; i++)
+ {
+ char *formattedMessage = formattedMessages[i];
+ int len = strlen(messages[i]);
+ int size = MyMax(m_Width, len);
+ int startPos = (size - len) / 2;
+ CopySpaces(formattedMessage, startPos);
+ strcpy(formattedMessage + startPos, messages[i]);
+ CopySpaces(formattedMessage + startPos + len, size - startPos - len);
+ msgItems[kNumStaticStrings + i] = formattedMessage;
+ }
+
+ g_StartupInfo.ShowMessage(0, NULL, msgItems, kNumStaticStrings + m_NumStrings, 0);
+}
+
+/////////////////////////////////
+// CProgressBox
+
+void CProgressBox::Init(const CSysString &title, const CSysString &message,
+ UInt64 step)
+{
+ CMessageBox::Init(title, message, 1, 22);
+ m_Step = step;
+ m_CompletedPrev = 0;
+ m_Total = 0;
+}
+
+
+void CProgressBox::ShowProcessMessage(const char *message)
+{
+ CMessageBox::ShowProcessMessages(&message);
+}
+
+void CProgressBox::PrintPercent(UInt64 percent)
+{
+ char valueBuffer[32];
+ sprintf(valueBuffer, "%I64u%%", percent);
+ ShowProcessMessage(valueBuffer);
+}
+
+void CProgressBox::SetTotal(UInt64 total)
+{
+ m_Total = total;
+}
+
+void CProgressBox::PrintCompeteValue(UInt64 completed)
+{
+ if (completed >= m_CompletedPrev + m_Step || completed < m_CompletedPrev ||
+ completed == 0)
+ {
+ if (m_Total == 0)
+ PrintPercent(0);
+ else
+ PrintPercent(completed * 100 / m_Total);
+ m_CompletedPrev = completed;
+ }
+}