xref: /aosp_15_r20/external/lzma/CPP/7zip/UI/Far/ProgressBox.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // ProgressBox.h
2 
3 #ifndef ZIP7_INC_PROGRESS_BOX_H
4 #define ZIP7_INC_PROGRESS_BOX_H
5 
6 #include "../../../Common/MyString.h"
7 #include "../../../Common/MyTypes.h"
8 
9 struct CPercentPrinterState
10 {
11   UInt64 Completed;
12   UInt64 Total;
13 
14   UInt64 Files;
15   UInt64 FilesTotal;
16 
17   AString Command;
18   UString FileName;
19 
20   void ClearCurState();
21 
IsEqualToCPercentPrinterState22   bool IsEqualTo(const CPercentPrinterState &s) const
23   {
24     return
25            Completed == s.Completed
26         && Total == s.Total
27         && Files == s.Files
28         && FilesTotal == s.FilesTotal
29         && Command == s.Command
30         && FileName == s.FileName;
31   }
32 
CPercentPrinterStateCPercentPrinterState33   CPercentPrinterState():
34       Completed(0),
35       Total((UInt64)(Int64)-1),
36       Files(0),
37       FilesTotal(0)
38     {}
39 };
40 
41 class CProgressBox: public CPercentPrinterState
42 {
43   UInt32 _tickStep;
44   DWORD _prevTick;
45   DWORD _prevElapsedSec;
46 
47   bool _wasPrinted;
48 public:
49   bool UseBytesForPercents;
50   DWORD StartTick;
51   unsigned MaxLen;
52 
53 private:
54   UString _tempU;
55   UString _name1U;
56   UString _name2U;
57 
58   CPercentPrinterState _printedState;
59 
60   AString _title;
61 
62   AString _timeStr;
63   AString _files;
64   AString _sizesStr;
65   AString _name1;
66   AString _name2;
67   AString _perc;
68 
69   void ReduceString(const UString &src, AString &dest);
70 
71 public:
72 
73   CProgressBox(UInt32 tickStep = 200):
_tickStep(tickStep)74       _tickStep(tickStep),
75       _prevTick(0),
76       UseBytesForPercents(true),
77       StartTick(0),
78       MaxLen(60)
79     {}
80 
81   void Init(const char *title);
82   void Print();
83 };
84 
85 #endif
86