diff options
author | Igor Pavlov <ipavlov@users.sourceforge.net> | 2007-08-27 04:00:00 +0400 |
---|---|---|
committer | Kornel LesiĆski <kornel@geekhood.net> | 2016-05-28 02:15:54 +0300 |
commit | 051769bbc577aeede90558b6ab5c9be187940ca0 (patch) | |
tree | e6330cb80f2d4a526d8aa27812528e053b0cda90 /CPP/7zip/UI/FileManager/OverwriteDialog.cpp | |
parent | 33ccab7e728a996800e166d849fe1e92a17e1afe (diff) |
4.53 beta
Diffstat (limited to 'CPP/7zip/UI/FileManager/OverwriteDialog.cpp')
-rwxr-xr-x | CPP/7zip/UI/FileManager/OverwriteDialog.cpp | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/CPP/7zip/UI/FileManager/OverwriteDialog.cpp b/CPP/7zip/UI/FileManager/OverwriteDialog.cpp new file mode 100755 index 00000000..442df929 --- /dev/null +++ b/CPP/7zip/UI/FileManager/OverwriteDialog.cpp @@ -0,0 +1,124 @@ +// OverwriteDialog.cpp + +#include "StdAfx.h" + +#include "OverwriteDialog.h" + +#include "Common/StringConvert.h" +#include "Windows/FileName.h" +#include "Windows/Defs.h" +#include "Windows/ResourceString.h" +#include "Windows/Control/Static.h" +#include "Windows/PropVariantConversions.h" + +#include "FormatUtils.h" + +// #include "../resource.h" + +#ifdef LANG +#include "LangUtils.h" +#endif + +using namespace NWindows; + +#ifdef LANG +static CIDLangPair kIDLangPairs[] = +{ + { IDC_STATIC_OVERWRITE_HEADER, 0x02000901}, + { IDC_STATIC_OVERWRITE_QUESTION_BEGIN, 0x02000902 }, + { IDC_STATIC_OVERWRITE_QUESTION_END, 0x02000903 }, + { IDYES, 0x02000705 }, + { IDC_BUTTON_OVERWRITE_YES_TO_ALL, 0x02000707 }, + { IDNO, 0x02000709 }, + { IDC_BUTTON_OVERWRITE_NO_TO_ALL,0x0200070B }, + { IDC_BUTTON_OVERWRITE_AUTO_RENAME, 0x02000911 }, + { IDCANCEL, 0x02000711 } +}; +#endif + +void COverwriteDialog::SetFileInfoControl(int textID, int iconID, + const NOverwriteDialog::CFileInfo &fileInfo) +{ + UString sizeString; + if (fileInfo.SizeIsDefined) + sizeString = MyFormatNew(IDS_FILE_SIZE, + #ifdef LANG + 0x02000982, + #endif + NumberToString(fileInfo.Size)); + + UString reducedName; + const int kLineSize = 88; + for (int i = 0; i < fileInfo.Name.Length();) + { + reducedName += fileInfo.Name.Mid(i, kLineSize); + reducedName += L" "; + i += kLineSize; + } + + UString fullString = reducedName; + fullString += L"\n"; + fullString += sizeString; + fullString += L"\n"; + + if (fileInfo.TimeIsDefined) + { + UString timeString; + FILETIME localFileTime; + if (!FileTimeToLocalFileTime(&fileInfo.Time, &localFileTime)) + throw 4190402; + timeString = ConvertFileTimeToString(localFileTime); + + fullString += + #ifdef LANG + LangString(IDS_FILE_MODIFIED, 0x02000983); + #else + MyLoadStringW(IDS_FILE_MODIFIED); + #endif + + fullString += L" "; + fullString += timeString; + } + + NWindows::NControl::CDialogChildControl control; + control.Init(*this, textID); + control.SetText(fullString); + + SHFILEINFO shellFileInfo; + if (::SHGetFileInfo( + GetSystemString(fileInfo.Name), FILE_ATTRIBUTE_NORMAL, &shellFileInfo, + sizeof(shellFileInfo), SHGFI_ICON | SHGFI_USEFILEATTRIBUTES | SHGFI_LARGEICON)) + { + NControl::CStatic staticContol; + staticContol.Attach(GetItem(iconID)); + staticContol.SetIcon(shellFileInfo.hIcon); + } +} + +bool COverwriteDialog::OnInit() +{ + #ifdef LANG + LangSetWindowText(HWND(*this), 0x02000900); + LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0])); + #endif + SetFileInfoControl(IDC_STATIC_OVERWRITE_OLD_FILE_SIZE_TIME, + IDC_STATIC_OVERWRITE_OLD_FILE_ICON, OldFileInfo); + SetFileInfoControl(IDC_STATIC_OVERWRITE_NEW_FILE_SIZE_TIME, + IDC_STATIC_OVERWRITE_NEW_FILE_ICON, NewFileInfo); + return CModalDialog::OnInit(); +} + +bool COverwriteDialog::OnButtonClicked(int buttonID, HWND buttonHWND) +{ + switch(buttonID) + { + case IDYES: + case IDC_BUTTON_OVERWRITE_YES_TO_ALL: + case IDNO: + case IDC_BUTTON_OVERWRITE_NO_TO_ALL: + case IDC_BUTTON_OVERWRITE_AUTO_RENAME: + End(buttonID); + return true; + } + return CModalDialog::OnButtonClicked(buttonID, buttonHWND); +} |