Welcome to mirror list, hosted at ThFree Co, Russian Federation.

ContextMenu.h « Explorer « UI « 7zip « CPP - github.com/kornelski/7z.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 285044e736ac94cb461e11079373302b60262389 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
// ContextMenu.h

#ifndef __CONTEXT_MENU_H
#define __CONTEXT_MENU_H

#include "../../../Common/MyWindows.h"

#include <ShlObj.h>

#include "MyExplorerCommand.h"

#include "../../../Common/MyString.h"

#include "../FileManager/MyCom2.h"

enum ECtxCommandType
{
  CtxCommandType_Normal,
  CtxCommandType_OpenRoot,
  CtxCommandType_OpenChild,
  CtxCommandType_CrcRoot,
  CtxCommandType_CrcChild,
};
   

class CZipContextMenu:
  public IContextMenu,
  public IShellExtInit,
  public IExplorerCommand,
  public IEnumExplorerCommand,
  public CMyUnknownImp
{
public:

  enum ECommandInternalID
  {
    kCommandNULL,
    kOpen,
    kExtract,
    kExtractHere,
    kExtractTo,
    kTest,
    kCompress,
    kCompressEmail,
    kCompressTo7z,
    kCompressTo7zEmail,
    kCompressToZip,
    kCompressToZipEmail,
    kHash_CRC32,
    kHash_CRC64,
    kHash_SHA1,
    kHash_SHA256,
    kHash_All,
    kHash_Generate_SHA256,
    kHash_TestArc
  };
  
  MY_UNKNOWN_IMP4_MT(
      IContextMenu,
      IShellExtInit,
      IExplorerCommand,
      IEnumExplorerCommand
      )

  // IShellExtInit
  STDMETHOD(Initialize)(LPCITEMIDLIST pidlFolder, LPDATAOBJECT dataObject, HKEY hkeyProgID);

  // IContextMenu
  STDMETHOD(QueryContextMenu)(HMENU hmenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);
  STDMETHOD(InvokeCommand)(LPCMINVOKECOMMANDINFO lpici);
  STDMETHOD(GetCommandString)(UINT_PTR idCmd, UINT uType, UINT *pwReserved, LPSTR pszName, UINT cchMax);

  HRESULT InitContextMenu(const wchar_t *folder, const wchar_t * const *names, unsigned numFiles);

  void LoadItems(IShellItemArray *psiItemArray);

  // IExplorerCommand
  STDMETHOD (GetTitle)   (IShellItemArray *psiItemArray, LPWSTR *ppszName);
  STDMETHOD (GetIcon)    (IShellItemArray *psiItemArray, LPWSTR *ppszIcon);
  STDMETHOD (GetToolTip) (IShellItemArray *psiItemArray, LPWSTR *ppszInfotip);
  STDMETHOD (GetCanonicalName) (GUID *pguidCommandName);
  STDMETHOD (GetState)   (IShellItemArray *psiItemArray, BOOL fOkToBeSlow, EXPCMDSTATE *pCmdState);
  STDMETHOD (Invoke)     (IShellItemArray *psiItemArray, IBindCtx *pbc);
  STDMETHOD (GetFlags)   (EXPCMDFLAGS *pFlags);
  STDMETHOD (EnumSubCommands) (IEnumExplorerCommand **ppEnum);

  // IEnumExplorerCommand
  STDMETHOD (Next) (ULONG celt, IExplorerCommand **pUICommand, ULONG *pceltFetched);
  STDMETHOD (Skip) (ULONG celt);
  STDMETHOD (Reset) (void);
  STDMETHOD (Clone) (IEnumExplorerCommand **ppenum);

  CZipContextMenu();
  ~CZipContextMenu();

  struct CCommandMapItem
  {
    ECommandInternalID CommandInternalID;
    UString Verb;
    UString UserString;
    // UString HelpString;
    UString Folder;
    UString ArcName;
    UString ArcType;
    bool IsPopup;
    ECtxCommandType CtxCommandType;

    CCommandMapItem():
        IsPopup(false),
        CtxCommandType(CtxCommandType_Normal)
        {}

    bool IsSubMenu() const
    {
      return
          CtxCommandType == CtxCommandType_CrcRoot ||
          CtxCommandType == CtxCommandType_OpenRoot;
    }
  };

private:

  bool _isMenuForFM;
  UStringVector _fileNames;
  bool _dropMode;
  UString _dropPath;
  CObjectVector<CCommandMapItem> _commandMap;
  CObjectVector<CCommandMapItem> _commandMap_Cur;

  HBITMAP _bitmap;
  CBoolPair _elimDup;

  bool IsSeparator;
  bool IsRoot;
  CObjectVector< CMyComPtr<IExplorerCommand> > SubCommands;
  ULONG CurrentSubCommand;

  void Set_UserString_in_LastCommand(const UString &s)
  {
    _commandMap.Back().UserString = s;
  }

  HRESULT GetFileNames(LPDATAOBJECT dataObject, UStringVector &fileNames);
  int FindVerb(const UString &verb);
  void FillCommand(ECommandInternalID id, UString &mainString, CCommandMapItem &cmi);
  void AddCommand(ECommandInternalID id, UString &mainString, CCommandMapItem &cmi);
  void AddMapItem_ForSubMenu(const char *ver);

  HRESULT InvokeCommandCommon(const CCommandMapItem &cmi);
};

#endif