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>2009-08-17 04:00:00 +0400
committerKornel LesiƄski <kornel@geekhood.net>2016-05-28 02:16:00 +0300
commitc99f3ebdd639c2adb03d8b44001b10af18516504 (patch)
tree92aaf34e5edbd7287c3f55037190da75ab0a8000 /CPP/7zip/UI/GUI/CompressDialog.cpp
parent829409452d85cd6dd9dfc9151f109d6e13a2bb1c (diff)
9.06 beta
Diffstat (limited to 'CPP/7zip/UI/GUI/CompressDialog.cpp')
-rwxr-xr-xCPP/7zip/UI/GUI/CompressDialog.cpp114
1 files changed, 58 insertions, 56 deletions
diff --git a/CPP/7zip/UI/GUI/CompressDialog.cpp b/CPP/7zip/UI/GUI/CompressDialog.cpp
index 04a40a43..bafaf371 100755
--- a/CPP/7zip/UI/GUI/CompressDialog.cpp
+++ b/CPP/7zip/UI/GUI/CompressDialog.cpp
@@ -2,16 +2,14 @@
#include "StdAfx.h"
-#include "Common/Defs.h"
#include "Common/IntToString.h"
#include "Common/StringConvert.h"
-#include "Windows/CommonDialog.h"
#include "Windows/FileDir.h"
#include "Windows/FileName.h"
-#include "Windows/ResourceString.h"
#include "Windows/System.h"
+#include "../FileManager/BrowseDialog.h"
#include "../FileManager/FormatUtils.h"
#include "../FileManager/HelpUtils.h"
#include "../FileManager/SplitUtils.h"
@@ -22,8 +20,6 @@
#include "CompressDialog.h"
-#include "resource.h"
-
#ifndef _UNICODE
extern bool g_IsNT;
#endif
@@ -249,7 +245,7 @@ static UInt64 GetMaxRamSizeForProgram()
physSize = 0;
else
physSize -= kMinSysSize;
- const UInt64 kMinUseSize = (1 << 25);
+ const UInt64 kMinUseSize = (1 << 24);
if (physSize < kMinUseSize)
physSize = kMinUseSize;
return physSize;
@@ -282,23 +278,24 @@ bool CCompressDialog::OnInit()
AddVolumeItems(m_Volume);
- ReadCompressionInfo(m_RegistryInfo);
+ m_RegistryInfo.Load();
CheckButton(IDC_COMPRESS_CHECK_SHOW_PASSWORD, m_RegistryInfo.ShowPassword);
CheckButton(IDC_COMPRESS_CHECK_ENCRYPT_FILE_NAMES, m_RegistryInfo.EncryptHeaders);
UpdatePasswordControl();
- Info.ArchiverInfoIndex = 0;
+ Info.FormatIndex = -1;
int i;
- for (i = 0; i < m_ArchiverInfoList.Size(); i++)
+ for (i = 0; i < ArcIndices.Size(); i++)
{
- const CArcInfoEx &ai = m_ArchiverInfoList[i];
+ int arcIndex = ArcIndices[i];
+ const CArcInfoEx &ai = (*ArcFormats)[arcIndex];
int index = (int)m_Format.AddString(ai.Name);
- m_Format.SetItemData(index, i);
- if (ai.Name.CompareNoCase(m_RegistryInfo.ArchiveType) == 0 || i == 0)
+ m_Format.SetItemData(index, arcIndex);
+ if (ai.Name.CompareNoCase(m_RegistryInfo.ArcType) == 0 || i == 0)
{
m_Format.SetCurSel(index);
- Info.ArchiverInfoIndex = i;
+ Info.FormatIndex = arcIndex;
}
}
@@ -306,8 +303,8 @@ bool CCompressDialog::OnInit()
SetLevel();
SetParams();
- for (i = 0; i < m_RegistryInfo.HistoryArchives.Size() && i < kHistorySize; i++)
- m_ArchivePath.AddString(m_RegistryInfo.HistoryArchives[i]);
+ for (i = 0; i < m_RegistryInfo.ArcPaths.Size() && i < kHistorySize; i++)
+ m_ArchivePath.AddString(m_RegistryInfo.ArcPaths[i]);
m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_ADD, 0x02000DA1));
m_UpdateMode.AddString(LangString(IDS_COMPRESS_UPDATE_MODE_UPDATE, 0x02000DA2));
@@ -332,6 +329,9 @@ bool CCompressDialog::OnInit()
SetEncryptionMethod();
SetMemoryUsage();
+
+ NormalizePosition();
+
return CModalDialog::OnInit();
}
@@ -339,7 +339,9 @@ namespace NCompressDialog
{
bool CInfo::GetFullPathName(UString &result) const
{
+ #ifndef UNDER_CE
NDirectory::MySetCurrentDirectory(CurrentDirPrefix);
+ #endif
return MyGetFullPathName(ArchiveName, result);
}
}
@@ -491,7 +493,7 @@ void CCompressDialog::OnButtonSetArchive()
UString s = LangString(IDS_OPEN_TYPE_ALL_FILES, 0x02000DB1);
s += L" (*.*)";
UString resPath;
- if (!MyGetOpenFileName(HWND(*this), title, fullFileName, s, resPath))
+ if (!MyBrowseForFile(HWND(*this), title, fullFileName, s, resPath))
return;
m_ArchivePath.SetText(resPath);
}
@@ -546,8 +548,8 @@ void CCompressDialog::OnOK()
UString s;
m_ArchivePath.GetText(s);
s.Trim();
- m_RegistryInfo.HistoryArchives.Clear();
- AddUniqueString(m_RegistryInfo.HistoryArchives, s);
+ m_RegistryInfo.ArcPaths.Clear();
+ AddUniqueString(m_RegistryInfo.ArcPaths, s);
Info.ArchiveName = s;
Info.UpdateMode = NCompressDialog::NUpdateMode::EEnum(m_UpdateMode.GetCurSel());
@@ -564,7 +566,7 @@ void CCompressDialog::OnOK()
Info.Method = GetMethodSpec();
Info.EncryptionMethod = GetEncryptionMethodSpec();
- Info.ArchiverInfoIndex = GetFormatIndex();
+ Info.FormatIndex = GetFormatIndex();
Info.SFXMode = IsSFX();
Info.OpenShareForWrite = IsButtonCheckedBool(IDC_COMPRESS_SHARED);
@@ -590,7 +592,7 @@ void CCompressDialog::OnOK()
wchar_t s[32];
ConvertUInt64ToString(volumeSize, s);
if (::MessageBoxW(*this, MyFormatNew(IDS_COMPRESS_SPLIT_CONFIRM_MESSAGE, 0x02000D42, s),
- L"7-Zip", MB_YESNOCANCEL | MB_ICONQUESTION | MB_TASKMODAL) != IDYES)
+ L"7-Zip", MB_YESNOCANCEL | MB_ICONQUESTION) != IDYES)
return;
}
}
@@ -601,15 +603,15 @@ void CCompressDialog::OnOK()
UString sTemp;
m_ArchivePath.GetLBText(i, sTemp);
sTemp.Trim();
- AddUniqueString(m_RegistryInfo.HistoryArchives, sTemp);
+ AddUniqueString(m_RegistryInfo.ArcPaths, sTemp);
}
- if (m_RegistryInfo.HistoryArchives.Size() > kHistorySize)
- m_RegistryInfo.HistoryArchives.DeleteBack();
+ if (m_RegistryInfo.ArcPaths.Size() > kHistorySize)
+ m_RegistryInfo.ArcPaths.DeleteBack();
- m_RegistryInfo.ArchiveType = m_ArchiverInfoList[Info.ArchiverInfoIndex].Name;
+ m_RegistryInfo.ArcType = (*ArcFormats)[Info.FormatIndex].Name;
m_RegistryInfo.ShowPassword = IsShowPasswordChecked();
- SaveCompressionInfo(m_RegistryInfo);
+ m_RegistryInfo.Save();
CModalDialog::OnOK();
}
@@ -643,9 +645,9 @@ bool CCompressDialog::OnCommand(int code, int itemID, LPARAM lParam)
}
case IDC_COMPRESS_COMBO_LEVEL:
{
- const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
int index = FindRegistryFormatAlways(ai.Name);
- NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
fo.ResetForLevelChange();
SetMethod();
SetSolidBlockSize();
@@ -693,7 +695,7 @@ void CCompressDialog::SetArchiveName2(bool prevWasSFX)
{
UString fileName;
m_ArchivePath.GetText(fileName);
- const CArcInfoEx &prevArchiverInfo = m_ArchiverInfoList[m_PrevFormat];
+ const CArcInfoEx &prevArchiverInfo = (*ArcFormats)[m_PrevFormat];
if (prevArchiverInfo.KeepName || Info.KeepName)
{
UString prevExtension = prevArchiverInfo.GetMainExt();
@@ -716,9 +718,9 @@ void CCompressDialog::SetArchiveName2(bool prevWasSFX)
void CCompressDialog::SetArchiveName(const UString &name)
{
UString fileName = name;
- Info.ArchiverInfoIndex = GetFormatIndex();
- const CArcInfoEx &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
- m_PrevFormat = Info.ArchiverInfoIndex;
+ Info.FormatIndex = GetFormatIndex();
+ const CArcInfoEx &ai = (*ArcFormats)[Info.FormatIndex];
+ m_PrevFormat = Info.FormatIndex;
if (ai.KeepName)
{
fileName = OriginalFileName;
@@ -746,10 +748,10 @@ void CCompressDialog::SetArchiveName(const UString &name)
int CCompressDialog::FindRegistryFormat(const UString &name)
{
- for (int i = 0; i < m_RegistryInfo.FormatOptionsVector.Size(); i++)
+ for (int i = 0; i < m_RegistryInfo.Formats.Size(); i++)
{
- const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[i];
- if (GetUnicodeString(fo.FormatID) == name)
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[i];
+ if (name.CompareNoCase(GetUnicodeString(fo.FormatID)) == 0)
return i;
}
return -1;
@@ -762,7 +764,7 @@ int CCompressDialog::FindRegistryFormatAlways(const UString &name)
{
NCompression::CFormatOptions fo;
fo.FormatID = GetSystemString(name);
- index = m_RegistryInfo.FormatOptionsVector.Add(fo);
+ index = m_RegistryInfo.Formats.Add(fo);
}
return index;
}
@@ -770,7 +772,7 @@ int CCompressDialog::FindRegistryFormatAlways(const UString &name)
int CCompressDialog::GetStaticFormatIndex()
{
int formatIndex = GetFormatIndex();
- const CArcInfoEx &ai = m_ArchiverInfoList[formatIndex];
+ const CArcInfoEx &ai = (*ArcFormats)[formatIndex];
for (int i = 0; i < MY_SIZE_OF_ARRAY(g_Formats); i++)
if (ai.Name.CompareNoCase(g_Formats[i].Name) == 0)
return i;
@@ -793,12 +795,12 @@ void CCompressDialog::SetLevel()
{
m_Level.ResetContent();
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
- const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
int index = FindRegistryFormat(ai.Name);
UInt32 level = kNormal;
if (index >= 0)
{
- const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
if (fo.Level <= kUltra)
level = fo.Level;
else
@@ -829,12 +831,12 @@ void CCompressDialog::SetMethod(int keepMethodId)
return;
}
const CFormatInfo &fi = g_Formats[GetStaticFormatIndex()];
- const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
int index = FindRegistryFormat(ai.Name);
UString defaultMethod;
if (index >= 0)
{
- const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
defaultMethod = fo.Method;
}
bool isSfx = IsSFX();
@@ -865,14 +867,14 @@ void CCompressDialog::SetMethod(int keepMethodId)
bool CCompressDialog::IsZipFormat()
{
- const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
return (ai.Name.CompareNoCase(L"zip") == 0);
}
void CCompressDialog::SetEncryptionMethod()
{
_encryptionMethod.ResetContent();
- const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
if (ai.Name.CompareNoCase(L"7z") == 0)
{
_encryptionMethod.AddString(TEXT("AES-256"));
@@ -884,7 +886,7 @@ void CCompressDialog::SetEncryptionMethod()
UString encryptionMethod;
if (index >= 0)
{
- const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
encryptionMethod = fo.EncryptionMethod;
}
_encryptionMethod.AddString(TEXT("ZipCrypto"));
@@ -960,12 +962,12 @@ int CCompressDialog::AddDictionarySize(UInt32 size)
void CCompressDialog::SetDictionary()
{
m_Dictionary.ResetContent();
- const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
int index = FindRegistryFormat(ai.Name);
UInt32 defaultDictionary = UInt32(-1);
if (index >= 0)
{
- const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
if (fo.Method.CompareNoCase(GetMethodSpec()) == 0)
defaultDictionary = fo.Dictionary;
}
@@ -1105,12 +1107,12 @@ int CCompressDialog::AddOrder(UInt32 size)
void CCompressDialog::SetOrder()
{
m_Order.ResetContent();
- const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
int index = FindRegistryFormat(ai.Name);
UInt32 defaultOrder = UInt32(-1);
if (index >= 0)
{
- const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
if (fo.Method.CompareNoCase(GetMethodSpec()) == 0)
defaultOrder = fo.Order;
}
@@ -1224,11 +1226,11 @@ void CCompressDialog::SetSolidBlockSize()
UInt32 defaultBlockSize = (UInt32)-1;
- const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
int index = FindRegistryFormat(ai.Name);
if (index >= 0)
{
- const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
if (fo.Method.CompareNoCase(GetMethodSpec()) == 0)
defaultBlockSize = fo.BlockLogSize;
}
@@ -1268,12 +1270,12 @@ void CCompressDialog::SetNumThreads()
UInt32 numHardwareThreads = NSystem::GetNumberOfProcessors();
UInt32 defaultValue = numHardwareThreads;
- const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
int index = FindRegistryFormat(ai.Name);
if (index >= 0)
{
- const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
- if (fo.Method.CompareNoCase(GetMethodSpec()) == 0)
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
+ if (fo.Method.CompareNoCase(GetMethodSpec()) == 0 && fo.NumThreads != (UInt32)-1)
defaultValue = fo.NumThreads;
}
@@ -1422,23 +1424,23 @@ void CCompressDialog::SetMemoryUsage()
void CCompressDialog::SetParams()
{
- const CArcInfoEx &ai = m_ArchiverInfoList[GetFormatIndex()];
+ const CArcInfoEx &ai = (*ArcFormats)[GetFormatIndex()];
m_Params.SetText(TEXT(""));
int index = FindRegistryFormat(ai.Name);
if (index >= 0)
{
- const NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ const NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
m_Params.SetText(fo.Options);
}
}
void CCompressDialog::SaveOptionsInMem()
{
- const CArcInfoEx &ai = m_ArchiverInfoList[Info.ArchiverInfoIndex];
+ const CArcInfoEx &ai = (*ArcFormats)[Info.FormatIndex];
int index = FindRegistryFormatAlways(ai.Name);
m_Params.GetText(Info.Options);
Info.Options.Trim();
- NCompression::CFormatOptions &fo = m_RegistryInfo.FormatOptionsVector[index];
+ NCompression::CFormatOptions &fo = m_RegistryInfo.Formats[index];
fo.Options = Info.Options;
fo.Level = GetLevelSpec();
fo.Dictionary = GetDictionarySpec();