diff options
Diffstat (limited to 'CPP/7zip/UI/FileManager/SplitDialog.cpp')
-rw-r--r-- | CPP/7zip/UI/FileManager/SplitDialog.cpp | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/CPP/7zip/UI/FileManager/SplitDialog.cpp b/CPP/7zip/UI/FileManager/SplitDialog.cpp new file mode 100644 index 0000000..0c9fdd1 --- /dev/null +++ b/CPP/7zip/UI/FileManager/SplitDialog.cpp | |||
@@ -0,0 +1,116 @@ | |||
1 | // SplitDialog.cpp | ||
2 | |||
3 | #include "StdAfx.h" | ||
4 | |||
5 | #include "../../../Windows/FileName.h" | ||
6 | |||
7 | #ifdef LANG | ||
8 | #include "LangUtils.h" | ||
9 | #endif | ||
10 | |||
11 | #include "BrowseDialog.h" | ||
12 | #include "CopyDialogRes.h" | ||
13 | #include "SplitDialog.h" | ||
14 | #include "SplitUtils.h" | ||
15 | #include "resourceGui.h" | ||
16 | |||
17 | using namespace NWindows; | ||
18 | |||
19 | #ifdef LANG | ||
20 | static const UInt32 kLangIDs[] = | ||
21 | { | ||
22 | IDT_SPLIT_PATH, | ||
23 | IDT_SPLIT_VOLUME | ||
24 | }; | ||
25 | #endif | ||
26 | |||
27 | |||
28 | bool CSplitDialog::OnInit() | ||
29 | { | ||
30 | #ifdef LANG | ||
31 | LangSetWindowText(*this, IDD_SPLIT); | ||
32 | LangSetDlgItems(*this, kLangIDs, ARRAY_SIZE(kLangIDs)); | ||
33 | #endif | ||
34 | _pathCombo.Attach(GetItem(IDC_SPLIT_PATH)); | ||
35 | _volumeCombo.Attach(GetItem(IDC_SPLIT_VOLUME)); | ||
36 | |||
37 | if (!FilePath.IsEmpty()) | ||
38 | { | ||
39 | UString title; | ||
40 | GetText(title); | ||
41 | title.Add_Space(); | ||
42 | title += FilePath; | ||
43 | SetText(title); | ||
44 | } | ||
45 | _pathCombo.SetText(Path); | ||
46 | AddVolumeItems(_volumeCombo); | ||
47 | _volumeCombo.SetCurSel(0); | ||
48 | NormalizeSize(); | ||
49 | return CModalDialog::OnInit(); | ||
50 | } | ||
51 | |||
52 | bool CSplitDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize) | ||
53 | { | ||
54 | int mx, my; | ||
55 | GetMargins(8, mx, my); | ||
56 | int bx1, bx2, by; | ||
57 | GetItemSizes(IDCANCEL, bx1, by); | ||
58 | GetItemSizes(IDOK, bx2, by); | ||
59 | int yPos = ySize - my - by; | ||
60 | int xPos = xSize - mx - bx1; | ||
61 | |||
62 | InvalidateRect(NULL); | ||
63 | |||
64 | { | ||
65 | RECT r; | ||
66 | GetClientRectOfItem(IDB_SPLIT_PATH, r); | ||
67 | int bx = RECT_SIZE_X(r); | ||
68 | MoveItem(IDB_SPLIT_PATH, xSize - mx - bx, r.top, bx, RECT_SIZE_Y(r)); | ||
69 | ChangeSubWindowSizeX(_pathCombo, xSize - mx - mx - bx - mx); | ||
70 | } | ||
71 | |||
72 | MoveItem(IDCANCEL, xPos, yPos, bx1, by); | ||
73 | MoveItem(IDOK, xPos - mx - bx2, yPos, bx2, by); | ||
74 | |||
75 | return false; | ||
76 | } | ||
77 | |||
78 | bool CSplitDialog::OnButtonClicked(int buttonID, HWND buttonHWND) | ||
79 | { | ||
80 | switch (buttonID) | ||
81 | { | ||
82 | case IDB_SPLIT_PATH: | ||
83 | OnButtonSetPath(); | ||
84 | return true; | ||
85 | } | ||
86 | return CModalDialog::OnButtonClicked(buttonID, buttonHWND); | ||
87 | } | ||
88 | |||
89 | void CSplitDialog::OnButtonSetPath() | ||
90 | { | ||
91 | UString currentPath; | ||
92 | _pathCombo.GetText(currentPath); | ||
93 | // UString title = "Specify a location for output folder"; | ||
94 | UString title = LangString(IDS_SET_FOLDER); | ||
95 | |||
96 | UString resultPath; | ||
97 | if (!MyBrowseForFolder(*this, title, currentPath, resultPath)) | ||
98 | return; | ||
99 | NFile::NName::NormalizeDirPathPrefix(resultPath); | ||
100 | _pathCombo.SetCurSel(-1); | ||
101 | _pathCombo.SetText(resultPath); | ||
102 | } | ||
103 | |||
104 | void CSplitDialog::OnOK() | ||
105 | { | ||
106 | _pathCombo.GetText(Path); | ||
107 | UString volumeString; | ||
108 | _volumeCombo.GetText(volumeString); | ||
109 | volumeString.Trim(); | ||
110 | if (!ParseVolumeSizes(volumeString, VolumeSizes) || VolumeSizes.Size() == 0) | ||
111 | { | ||
112 | ::MessageBoxW(*this, LangString(IDS_INCORRECT_VOLUME_SIZE), L"7-Zip", MB_ICONERROR); | ||
113 | return; | ||
114 | } | ||
115 | CModalDialog::OnOK(); | ||
116 | } | ||