OSDN Git Service

7ef39e8d21003177b1a5ccc06c50632372cf0bf0
[tortoisegit/TortoiseGitJp.git] / src / TortoiseShell / ShellExt.h
1 // TortoiseSVN - a Windows shell extension for easy version control\r
2 \r
3 // Copyright (C) 2003-2008 - TortoiseSVN\r
4 \r
5 // This program is free software; you can redistribute it and/or\r
6 // modify it under the terms of the GNU General Public License\r
7 // as published by the Free Software Foundation; either version 2\r
8 // of the License, or (at your option) any later version.\r
9 \r
10 // This program is distributed in the hope that it will be useful,\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
13 // GNU General Public License for more details.\r
14 \r
15 // You should have received a copy of the GNU General Public License\r
16 // along with this program; if not, write to the Free Software Foundation,\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\r
18 //\r
19 #pragma once\r
20 \r
21 #include "Globals.h"\r
22 #include "registry.h"\r
23 #include "resource.h"\r
24 #include "ShellCache.h"\r
25 #include "RemoteCacheLink.h"\r
26 #include "GitStatus.h"\r
27 #include "GitFolderStatus.h"\r
28 #include "uxtheme.h"\r
29 #include "MenuInfo.h"\r
30 \r
31 extern  UINT                            g_cRefThisDll;                  // Reference count of this DLL.\r
32 extern  HINSTANCE                       g_hmodThisDll;                  // Instance handle for this DLL\r
33 extern  ShellCache                      g_ShellCache;                   // caching of registry entries, ...\r
34 extern  DWORD                           g_langid;\r
35 extern  DWORD                           g_langTimeout;\r
36 extern  HINSTANCE                       g_hResInst;\r
37 extern  stdstring                       g_filepath;\r
38 extern  git_wc_status_kind      g_filestatus;                   ///< holds the corresponding status to the file/dir above\r
39 extern  bool                            g_readonlyoverlay;              ///< whether to show the read only overlay or not\r
40 extern  bool                            g_lockedoverlay;                ///< whether to show the locked overlay or not\r
41 \r
42 extern bool                                     g_normalovlloaded;\r
43 extern bool                                     g_modifiedovlloaded;\r
44 extern bool                                     g_conflictedovlloaded;\r
45 extern bool                                     g_readonlyovlloaded;\r
46 extern bool                                     g_deletedovlloaded;\r
47 extern bool                                     g_lockedovlloaded;\r
48 extern bool                                     g_addedovlloaded;\r
49 extern bool                                     g_ignoredovlloaded;\r
50 extern bool                                     g_unversionedovlloaded;\r
51 extern LPCTSTR                          g_MenuIDString;\r
52 \r
53 extern  void                            LoadLangDll();\r
54 extern  CComCriticalSection     g_csGlobalCOMGuard;\r
55 typedef CComCritSecLock<CComCriticalSection> AutoLocker;\r
56 \r
57 typedef DWORD ARGB;\r
58 \r
59 typedef HRESULT (WINAPI *FN_GetBufferedPaintBits) (HPAINTBUFFER hBufferedPaint, RGBQUAD **ppbBuffer, int *pcxRow);\r
60 typedef HPAINTBUFFER (WINAPI *FN_BeginBufferedPaint) (HDC hdcTarget, const RECT *prcTarget, BP_BUFFERFORMAT dwFormat, BP_PAINTPARAMS *pPaintParams, HDC *phdc);\r
61 typedef HRESULT (WINAPI *FN_EndBufferedPaint) (HPAINTBUFFER hBufferedPaint, BOOL fUpdateTarget);\r
62 \r
63 \r
64 // The actual OLE Shell context menu handler\r
65 /**\r
66  * \ingroup TortoiseShell\r
67  * The main class of our COM object / Shell Extension.\r
68  * It contains all Interfaces we implement for the shell to use.\r
69  * \remark The implementations of the different interfaces are\r
70  * split into several *.cpp files to keep them in a reasonable size.\r
71  */\r
72 class CShellExt : public IContextMenu3,\r
73                                                         IPersistFile,\r
74                                                         IColumnProvider,\r
75                                                         IShellExtInit,\r
76                                                         IShellIconOverlayIdentifier,\r
77                                                         IShellPropSheetExt,\r
78                                                         ICopyHookW\r
79 \r
80 // COMPILER ERROR? You need the latest version of the\r
81 // platform SDK which has references to IColumnProvider \r
82 // in the header files.  Download it here:\r
83 // http://www.microsoft.com/msdownload/platformsdk/sdkupdate/\r
84 {\r
85 protected:\r
86 \r
87         WORD fullver;\r
88         FileState m_State;\r
89         ULONG   m_cRef;\r
90         //std::map<int,std::string> verbMap;\r
91         std::map<UINT_PTR, UINT_PTR>    myIDMap;\r
92         std::map<UINT_PTR, UINT_PTR>    mySubMenuMap;\r
93         std::map<stdstring, UINT_PTR> myVerbsMap;\r
94         std::map<UINT_PTR, stdstring> myVerbsIDMap;\r
95         stdstring       folder_;\r
96         std::vector<stdstring> files_;\r
97         DWORD itemStates;                               ///< see the globals.h file for the ITEMIS_* defines\r
98         DWORD itemStatesFolder;                 ///< used for states of the folder_ (folder background and/or drop target folder)\r
99         stdstring uuidSource;\r
100         stdstring uuidTarget;\r
101         int space;\r
102         TCHAR stringtablebuffer[255];\r
103         stdstring columnfilepath;               ///< holds the last file/dir path for the column provider\r
104         stdstring columnauthor;                 ///< holds the corresponding author of the file/dir above\r
105         stdstring itemurl;\r
106         stdstring itemshorturl;\r
107         stdstring ignoredprops;\r
108         stdstring owner;\r
109         git_revnum_t columnrev;                 ///< holds the corresponding revision to the file/dir above\r
110         git_wc_status_kind      filestatus;\r
111         std::map<UINT, HBITMAP> bitmaps;\r
112 \r
113         GitFolderStatus         m_CachedStatus;         // status cache\r
114         CRemoteCacheLink        m_remoteCacheLink;\r
115 \r
116         FN_GetBufferedPaintBits pfnGetBufferedPaintBits;\r
117         FN_BeginBufferedPaint pfnBeginBufferedPaint;\r
118         FN_EndBufferedPaint pfnEndBufferedPaint;\r
119 \r
120 #define MAKESTRING(ID) LoadStringEx(g_hResInst, ID, stringtablebuffer, sizeof(stringtablebuffer)/sizeof(TCHAR), (WORD)CRegStdWORD(_T("Software\\TortoiseGit\\LanguageID"), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT)))\r
121 private:\r
122         void                    InsertGitMenu(BOOL istop, HMENU menu, UINT pos, UINT_PTR id, UINT stringid, UINT icon, UINT idCmdFirst, GitCommands com, UINT uFlags);\r
123         void                    InsertIgnoreSubmenus(UINT &idCmd, UINT idCmdFirst, HMENU hMenu, HMENU subMenu, UINT &indexMenu, int &indexSubMenu, unsigned __int64 topmenu, bool bShowIcons, UINT uFlags);\r
124         stdstring               WriteFileListToTempFile();\r
125         bool                    WriteClipboardPathsToTempFile(stdstring& tempfile);\r
126         LPCTSTR                 GetMenuTextFromResource(int id);\r
127         void                    GetColumnStatus(const TCHAR * path, BOOL bIsDir);\r
128         HBITMAP                 IconToBitmap(UINT uIcon);\r
129         STDMETHODIMP    QueryDropContext(UINT uFlags, UINT idCmdFirst, HMENU hMenu, UINT &indexMenu);\r
130         bool                    IsIllegalFolder(std::wstring folder, int * cslidarray);\r
131         HBITMAP                 IconToBitmapPARGB32(UINT uIcon);\r
132         HRESULT                 Create32BitHBITMAP(HDC hdc, const SIZE *psize, __deref_opt_out void **ppvBits, __out HBITMAP* phBmp);\r
133         HRESULT                 ConvertBufferToPARGB32(HPAINTBUFFER hPaintBuffer, HDC hdc, HICON hicon, SIZE& sizIcon);\r
134         bool                    HasAlpha(__in ARGB *pargb, SIZE& sizImage, int cxRow);\r
135         HRESULT                 ConvertToPARGB32(HDC hdc, __inout ARGB *pargb, HBITMAP hbmp, SIZE& sizImage, int cxRow);\r
136 \r
137 \r
138 public:\r
139         CShellExt(FileState state);\r
140         virtual ~CShellExt();\r
141 \r
142         /** \name IUnknown \r
143          * IUnknown members\r
144          */\r
145         //@{\r
146         STDMETHODIMP         QueryInterface(REFIID, LPVOID FAR *);\r
147         STDMETHODIMP_(ULONG) AddRef();\r
148         STDMETHODIMP_(ULONG) Release();\r
149         //@}\r
150 \r
151         /** \name IContextMenu2 \r
152          * IContextMenu2 members\r
153          */\r
154         //@{\r
155         STDMETHODIMP    QueryContextMenu(HMENU hMenu, UINT indexMenu, UINT idCmdFirst, UINT idCmdLast, UINT uFlags);\r
156         STDMETHODIMP    InvokeCommand(LPCMINVOKECOMMANDINFO lpcmi);\r
157         STDMETHODIMP    GetCommandString(UINT_PTR idCmd, UINT uFlags, UINT FAR *reserved, LPSTR pszName, UINT cchMax);\r
158         STDMETHODIMP    HandleMenuMsg(UINT uMsg, WPARAM wParam, LPARAM lParam);\r
159         //@}\r
160 \r
161     /** \name IContextMenu3 \r
162          * IContextMenu3 members\r
163          */\r
164         //@{\r
165         STDMETHODIMP    HandleMenuMsg2(UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *pResult);\r
166         //@}\r
167 \r
168         /** \name IColumnProvider\r
169          * IColumnProvider members\r
170          */\r
171         //@{\r
172         STDMETHODIMP    GetColumnInfo(DWORD dwIndex, SHCOLUMNINFO *psci);\r
173         STDMETHODIMP    GetItemData(LPCSHCOLUMNID pscid, LPCSHCOLUMNDATA pscd, VARIANT *pvarData);\r
174         STDMETHODIMP    Initialize(LPCSHCOLUMNINIT psci);\r
175         //@}\r
176 \r
177         /** \name IShellExtInit\r
178          * IShellExtInit methods\r
179          */\r
180         //@{\r
181         STDMETHODIMP    Initialize(LPCITEMIDLIST pIDFolder, LPDATAOBJECT pDataObj, HKEY hKeyID);\r
182         //@}\r
183 \r
184     /** \name IPersistFile\r
185          * IPersistFile methods\r
186          */\r
187         //@{\r
188     STDMETHODIMP        GetClassID(CLSID *pclsid);\r
189     STDMETHODIMP        Load(LPCOLESTR pszFileName, DWORD dwMode);\r
190     STDMETHODIMP        IsDirty(void) { return S_OK; };\r
191     STDMETHODIMP        Save(LPCOLESTR /*pszFileName*/, BOOL /*fRemember*/) { return S_OK; };\r
192     STDMETHODIMP        SaveCompleted(LPCOLESTR /*pszFileName*/) { return S_OK; };\r
193     STDMETHODIMP        GetCurFile(LPOLESTR * /*ppszFileName*/) { return S_OK; };\r
194         //@}\r
195 \r
196         /** \name IShellIconOverlayIdentifier \r
197          * IShellIconOverlayIdentifier methods\r
198          */\r
199         //@{\r
200         STDMETHODIMP    GetOverlayInfo(LPWSTR pwszIconFile, int cchMax, int *pIndex, DWORD *pdwFlags);\r
201         STDMETHODIMP    GetPriority(int *pPriority); \r
202         STDMETHODIMP    IsMemberOf(LPCWSTR pwszPath, DWORD dwAttrib);\r
203         //@}\r
204 \r
205         /** \name IShellPropSheetExt \r
206          * IShellPropSheetExt methods\r
207          */\r
208         //@{\r
209         STDMETHODIMP    AddPages(LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam);\r
210         STDMETHODIMP    ReplacePage (UINT, LPFNADDPROPSHEETPAGE, LPARAM);\r
211         //@}\r
212 \r
213         /** \name ICopyHook \r
214          * ICopyHook members\r
215          */\r
216         //@{\r
217         STDMETHODIMP_(UINT) CopyCallback(HWND hWnd, UINT wFunc, UINT wFlags, LPCTSTR pszSrcFile, DWORD dwSrcAttribs, LPCTSTR pszDestFile, DWORD dwDestAttribs);\r
218         //@}\r
219 \r
220 };\r