xref: /aosp_15_r20/external/lzma/CPP/7zip/UI/FileManager/SystemPage.h (revision f6dc9357d832569d4d1f5d24eacdb3935a1ae8e6)
1 // SystemPage.h
2 
3 #ifndef ZIP7_INC_SYSTEM_PAGE_H
4 #define ZIP7_INC_SYSTEM_PAGE_H
5 
6 #include "../../../Windows/Control/ImageList.h"
7 #include "../../../Windows/Control/ListView.h"
8 #include "../../../Windows/Control/PropertyPage.h"
9 
10 #include "FilePlugins.h"
11 #include "RegistryAssociations.h"
12 
13 enum EExtState
14 {
15   kExtState_Clear = 0,
16   kExtState_Other,
17   kExtState_7Zip
18 };
19 
20 struct CModifiedExtInfo: public NRegistryAssoc::CShellExtInfo
21 {
22   int OldState;
23   int State;
24   int ImageIndex;
25   bool Other;
26   bool Other7Zip;
27 
CModifiedExtInfoCModifiedExtInfo28   CModifiedExtInfo(): ImageIndex(-1) {}
29 
30   CSysString GetString() const;
31 
SetStateCModifiedExtInfo32   void SetState(const UString &iconPath)
33   {
34     State = kExtState_Clear;
35     Other = false;
36     Other7Zip = false;
37     if (!ProgramKey.IsEmpty())
38     {
39       State = kExtState_Other;
40       Other = true;
41       if (IsIt7Zip())
42       {
43         Other7Zip = !iconPath.IsEqualTo_NoCase(IconPath);
44         if (!Other7Zip)
45         {
46           State = kExtState_7Zip;
47           Other = false;
48         }
49       }
50     }
51     OldState = State;
52   }
53 };
54 
55 struct CAssoc
56 {
57   CModifiedExtInfo Pair[2];
58   int SevenZipImageIndex;
59 
GetIconIndexCAssoc60   int GetIconIndex() const
61   {
62     for (unsigned i = 0; i < 2; i++)
63     {
64       const CModifiedExtInfo &pair = Pair[i];
65       if (pair.State == kExtState_Clear)
66         continue;
67       if (pair.State == kExtState_7Zip)
68         return SevenZipImageIndex;
69       if (pair.ImageIndex != -1)
70         return pair.ImageIndex;
71     }
72     return -1;
73   }
74 };
75 
76 #ifdef UNDER_CE
77   #define NUM_EXT_GROUPS 1
78 #else
79   #define NUM_EXT_GROUPS 2
80 #endif
81 
82 class CSystemPage: public NWindows::NControl::CPropertyPage
83 {
84   CExtDatabase _extDB;
85   CObjectVector<CAssoc> _items;
86 
87   unsigned _numIcons;
88   NWindows::NControl::CImageList _imageList;
89   NWindows::NControl::CListView _listView;
90 
91   bool _needSave;
92 
GetHKey(unsigned group)93   HKEY GetHKey(unsigned
94       #if NUM_EXT_GROUPS != 1
95         group
96       #endif
97       ) const
98   {
99     #if NUM_EXT_GROUPS == 1
100       return HKEY_CLASSES_ROOT;
101     #else
102       return group == 0 ? HKEY_CURRENT_USER : HKEY_LOCAL_MACHINE;
103     #endif
104   }
105 
106   int AddIcon(const UString &path, int iconIndex);
GetRealIndex(unsigned listIndex)107   unsigned GetRealIndex(unsigned listIndex) const { return listIndex; }
108   void RefreshListItem(unsigned group, unsigned listIndex);
109   void ChangeState(unsigned group, const CUIntVector &indices);
110   void ChangeState(unsigned group);
111 
112   bool OnListKeyDown(LPNMLVKEYDOWN keyDownInfo);
113 
114 public:
115   bool WasChanged;
116 
CSystemPage()117   CSystemPage(): WasChanged(false) {}
118 
119   virtual bool OnInit() Z7_override;
120   virtual void OnNotifyHelp() Z7_override;
121   virtual bool OnNotify(UINT controlID, LPNMHDR lParam) Z7_override;
122   virtual LONG OnApply() Z7_override;
123   virtual bool OnButtonClicked(unsigned buttonID, HWND buttonHWND) Z7_override;
124 };
125 
126 #endif
127