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