Imported Upstream version 9.20
[platform/upstream/7zip.git] / CPP / 7zip / UI / FileManager / ComboDialog.cpp
1 // ComboDialog.cpp\r
2 \r
3 #include "StdAfx.h"\r
4 #include "ComboDialog.h"\r
5 \r
6 #include "Windows/Control/Static.h"\r
7 \r
8 #ifdef LANG\r
9 #include "LangUtils.h"\r
10 #endif\r
11 \r
12 using namespace NWindows;\r
13 \r
14 #ifdef LANG\r
15 static CIDLangPair kIDLangPairs[] =\r
16 {\r
17   { IDOK, 0x02000702 },\r
18   { IDCANCEL, 0x02000710 }\r
19 };\r
20 #endif\r
21 \r
22 bool CComboDialog::OnInit()\r
23 {\r
24   #ifdef LANG\r
25   LangSetDlgItemsText(HWND(*this), kIDLangPairs, sizeof(kIDLangPairs) / sizeof(kIDLangPairs[0]));\r
26   #endif\r
27   _comboBox.Attach(GetItem(IDC_COMBO_COMBO));\r
28 \r
29   /*\r
30   // why it doesn't work ?\r
31   DWORD style = _comboBox.GetStyle();\r
32   if (Sorted)\r
33     style |= CBS_SORT;\r
34   else\r
35     style &= ~CBS_SORT;\r
36   _comboBox.SetStyle(style);\r
37   */\r
38   SetText(Title);\r
39   \r
40   NControl::CStatic staticContol;\r
41   staticContol.Attach(GetItem(IDC_COMBO_STATIC));\r
42   staticContol.SetText(Static);\r
43   _comboBox.SetText(Value);\r
44   for(int i = 0; i < Strings.Size(); i++)\r
45     _comboBox.AddString(Strings[i]);\r
46   NormalizeSize();\r
47   return CModalDialog::OnInit();\r
48 }\r
49 \r
50 bool CComboDialog::OnSize(WPARAM /* wParam */, int xSize, int ySize)\r
51 {\r
52   int mx, my;\r
53   GetMargins(8, mx, my);\r
54   int bx1, bx2, by;\r
55   GetItemSizes(IDCANCEL, bx1, by);\r
56   GetItemSizes(IDOK, bx2, by);\r
57   int y = ySize - my - by;\r
58   int x = xSize - mx - bx1;\r
59 \r
60   InvalidateRect(NULL);\r
61 \r
62   MoveItem(IDCANCEL, x, y, bx1, by);\r
63   MoveItem(IDOK, x - mx - bx2, y, bx2, by);\r
64   ChangeSubWindowSizeX(_comboBox, xSize - mx * 2);\r
65   return false;\r
66 }\r
67 \r
68 void CComboDialog::OnOK()\r
69 {\r
70   _comboBox.GetText(Value);\r
71   CModalDialog::OnOK();\r
72 }\r