Imported Upstream version 9.20
[platform/upstream/7zip.git] / CPP / 7zip / UI / GUI / CompressDialog.h
1 // CompressDialog.h\r
2 \r
3 #ifndef __COMPRESS_DIALOG_H\r
4 #define __COMPRESS_DIALOG_H\r
5 \r
6 #include "Windows/Control/ComboBox.h"\r
7 #include "Windows/Control/Edit.h"\r
8 \r
9 #include "../Common/LoadCodecs.h"\r
10 #include "../Common/ZipRegistry.h"\r
11 \r
12 #include "../FileManager/DialogSize.h"\r
13 \r
14 #include "CompressDialogRes.h"\r
15 \r
16 namespace NCompressDialog\r
17 {\r
18   namespace NUpdateMode\r
19   {\r
20     enum EEnum\r
21     {\r
22       kAdd,\r
23       kUpdate,\r
24       kFresh,\r
25       kSynchronize\r
26     };\r
27   }\r
28   struct CInfo\r
29   {\r
30     NUpdateMode::EEnum UpdateMode;\r
31     bool SolidIsSpecified;\r
32     bool MultiThreadIsAllowed;\r
33     UInt64 SolidBlockSize;\r
34     UInt32 NumThreads;\r
35 \r
36     CRecordVector<UInt64> VolumeSizes;\r
37 \r
38     UInt32 Level;\r
39     UString Method;\r
40     UInt32 Dictionary;\r
41     bool OrderMode;\r
42     UInt32 Order;\r
43     UString Options;\r
44 \r
45     UString EncryptionMethod;\r
46 \r
47     bool SFXMode;\r
48     bool OpenShareForWrite;\r
49 \r
50     \r
51     UString ArchiveName; // in: Relative for ; out: abs\r
52     UString CurrentDirPrefix;\r
53     bool KeepName;\r
54 \r
55     bool GetFullPathName(UString &result) const;\r
56 \r
57     int FormatIndex;\r
58 \r
59     UString Password;\r
60     bool EncryptHeadersIsAllowed;\r
61     bool EncryptHeaders;\r
62 \r
63     void Init()\r
64     {\r
65       Level = Dictionary = Order = UInt32(-1);\r
66       OrderMode = false;\r
67       Method.Empty();\r
68       Options.Empty();\r
69       EncryptionMethod.Empty();\r
70     }\r
71     CInfo()\r
72     {\r
73       Init();\r
74     }\r
75   };\r
76 }\r
77 \r
78 class CCompressDialog: public NWindows::NControl::CModalDialog\r
79 {\r
80   NWindows::NControl::CComboBox m_ArchivePath;\r
81   NWindows::NControl::CComboBox m_Format;\r
82   NWindows::NControl::CComboBox m_Level;\r
83   NWindows::NControl::CComboBox m_Method;\r
84   NWindows::NControl::CComboBox m_Dictionary;\r
85   NWindows::NControl::CComboBox m_Order;\r
86   NWindows::NControl::CComboBox m_Solid;\r
87   NWindows::NControl::CComboBox m_NumThreads;\r
88   NWindows::NControl::CComboBox m_UpdateMode;\r
89   NWindows::NControl::CComboBox m_Volume;\r
90   NWindows::NControl::CDialogChildControl m_Params;\r
91 \r
92   NWindows::NControl::CEdit _password1Control;\r
93   NWindows::NControl::CEdit _password2Control;\r
94   NWindows::NControl::CComboBox _encryptionMethod;\r
95 \r
96   NCompression::CInfo m_RegistryInfo;\r
97 \r
98   int m_PrevFormat;\r
99   void SetArchiveName(const UString &name);\r
100   int FindRegistryFormat(const UString &name);\r
101   int FindRegistryFormatAlways(const UString &name);\r
102   \r
103   void CheckSFXNameChange();\r
104   void SetArchiveName2(bool prevWasSFX);\r
105   \r
106   int GetStaticFormatIndex();\r
107 \r
108   void SetNearestSelectComboBox(NWindows::NControl::CComboBox &comboBox, UInt32 value);\r
109 \r
110   void SetLevel();\r
111   \r
112   void SetMethod(int keepMethodId = -1);\r
113   int GetMethodID();\r
114   UString GetMethodSpec();\r
115   UString GetEncryptionMethodSpec();\r
116 \r
117   bool IsZipFormat();\r
118 \r
119   void SetEncryptionMethod();\r
120 \r
121   int AddDictionarySize(UInt32 size, bool kilo, bool maga);\r
122   int AddDictionarySize(UInt32 size);\r
123   \r
124   void SetDictionary();\r
125 \r
126   UInt32 GetComboValue(NWindows::NControl::CComboBox &c, int defMax = 0);\r
127 \r
128   UInt32 GetLevel()  { return GetComboValue(m_Level); }\r
129   UInt32 GetLevelSpec()  { return GetComboValue(m_Level, 1); }\r
130   UInt32 GetLevel2();\r
131   UInt32 GetDictionary() { return GetComboValue(m_Dictionary); }\r
132   UInt32 GetDictionarySpec() { return GetComboValue(m_Dictionary, 1); }\r
133   UInt32 GetOrder() { return GetComboValue(m_Order); }\r
134   UInt32 GetOrderSpec() { return GetComboValue(m_Order, 1); }\r
135   UInt32 GetNumThreadsSpec() { return GetComboValue(m_NumThreads, 1); }\r
136   UInt32 GetNumThreads2() { UInt32 num = GetNumThreadsSpec(); if (num == UInt32(-1)) num = 1; return num; }\r
137   UInt32 GetBlockSizeSpec() { return GetComboValue(m_Solid, 1); }\r
138 \r
139   int AddOrder(UInt32 size);\r
140   void SetOrder();\r
141   bool GetOrderMode();\r
142 \r
143   void SetSolidBlockSize();\r
144   void SetNumThreads();\r
145 \r
146   UInt64 GetMemoryUsage(UInt32 dictionary, UInt64 &decompressMemory);\r
147   UInt64 GetMemoryUsage(UInt64 &decompressMemory);\r
148   void PrintMemUsage(UINT res, UInt64 value);\r
149   void SetMemoryUsage();\r
150   void SetParams();\r
151   void SaveOptionsInMem();\r
152 \r
153   void UpdatePasswordControl();\r
154   bool IsShowPasswordChecked() const\r
155     { return IsButtonChecked(IDC_COMPRESS_CHECK_SHOW_PASSWORD) == BST_CHECKED; }\r
156 \r
157   int GetFormatIndex();\r
158 public:\r
159   CObjectVector<CArcInfoEx> *ArcFormats;\r
160   CRecordVector<int> ArcIndices;\r
161 \r
162   NCompressDialog::CInfo Info;\r
163   UString OriginalFileName; // for bzip2, gzip2\r
164 \r
165   INT_PTR Create(HWND wndParent = 0)\r
166   {\r
167     BIG_DIALOG_SIZE(400, 304);\r
168     return CModalDialog::Create(SIZED_DIALOG(IDD_DIALOG_COMPRESS), wndParent);\r
169   }\r
170 \r
171 protected:\r
172 \r
173   void CheckSFXControlsEnable();\r
174   void CheckVolumeEnable();\r
175   void CheckControlsEnable();\r
176 \r
177   void OnButtonSetArchive();\r
178   bool IsSFX();\r
179   void OnButtonSFX();\r
180 \r
181   virtual bool OnInit();\r
182   virtual bool OnCommand(int code, int itemID, LPARAM lParam);\r
183   virtual bool OnButtonClicked(int buttonID, HWND buttonHWND);\r
184   virtual void OnOK();\r
185   virtual void OnHelp();\r
186 \r
187 };\r
188 \r
189 #endif\r