xref: /aosp_15_r20/external/lzma/CPP/7zip/UI/FileManager/CopyDialog.cpp (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // CopyDialog.cpp
2 
3 #include "StdAfx.h"
4 
5 #include "../../../Windows/FileName.h"
6 
7 #include "../../../Windows/Control/Static.h"
8 
9 #include "BrowseDialog.h"
10 #include "CopyDialog.h"
11 #include "LangUtils.h"
12 
13 using namespace NWindows;
14 
OnInit()15 bool CCopyDialog::OnInit()
16 {
17   #ifdef Z7_LANG
18   LangSetDlgItems(*this, NULL, 0);
19   #endif
20   _path.Attach(GetItem(IDC_COPY));
21   SetText(Title);
22 
23   NControl::CStatic staticContol;
24   staticContol.Attach(GetItem(IDT_COPY));
25   staticContol.SetText(Static);
26   #ifdef UNDER_CE
27   // we do it, since WinCE selects Value\something instead of Value !!!!
28   _path.AddString(Value);
29   #endif
30   FOR_VECTOR (i, Strings)
31     _path.AddString(Strings[i]);
32   _path.SetText(Value);
33   SetItemText(IDT_COPY_INFO, Info);
34   NormalizeSize(true);
35   return CModalDialog::OnInit();
36 }
37 
OnSize(WPARAM,int xSize,int ySize)38 bool CCopyDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)
39 {
40   int mx, my;
41   GetMargins(8, mx, my);
42   int bx1, bx2, by;
43   GetItemSizes(IDCANCEL, bx1, by);
44   GetItemSizes(IDOK, bx2, by);
45   const int y = ySize - my - by;
46   const int x = xSize - mx - bx1;
47 
48   InvalidateRect(NULL);
49 
50   {
51     RECT r;
52     GetClientRectOfItem(IDB_COPY_SET_PATH, r);
53     const int bx = RECT_SIZE_X(r);
54     MoveItem(IDB_COPY_SET_PATH, xSize - mx - bx, r.top, bx, RECT_SIZE_Y(r));
55     ChangeSubWindowSizeX(_path, xSize - mx - mx - bx - mx);
56   }
57 
58   {
59     RECT r;
60     GetClientRectOfItem(IDT_COPY_INFO, r);
61     NControl::CStatic staticContol;
62     staticContol.Attach(GetItem(IDT_COPY_INFO));
63     const int yPos = r.top;
64     staticContol.Move(mx, yPos, xSize - mx * 2, y - 2 - yPos);
65   }
66 
67   MoveItem(IDCANCEL, x, y, bx1, by);
68   MoveItem(IDOK, x - mx - bx2, y, bx2, by);
69 
70   return false;
71 }
72 
OnButtonClicked(unsigned buttonID,HWND buttonHWND)73 bool CCopyDialog::OnButtonClicked(unsigned buttonID, HWND buttonHWND)
74 {
75   switch (buttonID)
76   {
77     case IDB_COPY_SET_PATH:
78       OnButtonSetPath();
79       return true;
80   }
81   return CModalDialog::OnButtonClicked(buttonID, buttonHWND);
82 }
83 
OnButtonSetPath()84 void CCopyDialog::OnButtonSetPath()
85 {
86   UString currentPath;
87   _path.GetText(currentPath);
88 
89   const UString title = LangString(IDS_SET_FOLDER);
90 
91   UString resultPath;
92   if (!MyBrowseForFolder(*this, title, currentPath, resultPath))
93     return;
94   NFile::NName::NormalizeDirPathPrefix(resultPath);
95   _path.SetCurSel(-1);
96   _path.SetText(resultPath);
97 }
98 
OnOK()99 void CCopyDialog::OnOK()
100 {
101   _path.GetText(Value);
102   CModalDialog::OnOK();
103 }
104