~tanj-tanj/tortoisebzr/trunk

« back to all changes in this revision

Viewing changes to shellext/cpp/tbzrshellext/IconOverlay.h

  • Committer: John teBokkel
  • Date: 2009-05-30 00:57:57 UTC
  • Revision ID: john@powercoreeng.com-20090530005757-10syngt5k64cyliu
changed the line endings back to DOS

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// IconOverlay.h : Declaration of the CIconOverlay
2
 
 
3
 
#pragma once
4
 
#include "resource.h"       // main symbols
5
 
 
6
 
// CIconOverlay
7
 
 
8
 
class ATL_NO_VTABLE CIconOverlayBase :
9
 
        public CComObjectRootEx<CComMultiThreadModel>,
10
 
        public IShellIconOverlayIdentifier
11
 
{
12
 
protected:
13
 
        // From app.py:
14
 
        static const DWORD STATE_NOTHING = 0;
15
 
        static const DWORD STATE_UNVERSIONED = 1;
16
 
        static const DWORD STATE_IGNORED = 2;
17
 
        static const DWORD STATE_UNCHANGED = 3;
18
 
        static const DWORD STATE_MODIFIED = 4;
19
 
        static const DWORD STATE_ADDED = 5;
20
 
        static const DWORD STATE_DELETED = 6;
21
 
        static const DWORD STATE_MISSING = 7;
22
 
        static const DWORD STATE_CONFLICT = 8;
23
 
 
24
 
        virtual DWORD GetMyState() = 0;
25
 
        virtual const TCHAR *GetMyStateName() = 0;
26
 
 
27
 
public:
28
 
        CIconOverlayBase()
29
 
        {
30
 
        }
31
 
 
32
 
BEGIN_COM_MAP(CIconOverlayBase)
33
 
        COM_INTERFACE_ENTRY(IShellIconOverlayIdentifier)
34
 
END_COM_MAP()
35
 
 
36
 
 
37
 
 
38
 
        DECLARE_PROTECT_FINAL_CONSTRUCT()
39
 
 
40
 
        HRESULT FinalConstruct()
41
 
        {
42
 
                return S_OK;
43
 
        }
44
 
 
45
 
        void FinalRelease()
46
 
        {
47
 
        }
48
 
 
49
 
        // IIconOverlay implementation
50
 
        STDMETHOD(IsMemberOf)(LPCWSTR pwszPath, DWORD dwAttrib);
51
 
        STDMETHOD(GetOverlayInfo)(LPWSTR pwszIconFile, int cchMax, int * pIndex, DWORD * pdwFlags);
52
 
        STDMETHOD(GetPriority)(int * pIPriority);
53
 
protected:
54
 
        DWORD CIconOverlayBase::GetFileStatus(LPCWSTR pwszPath);
55
 
 
56
 
        // As each of the overlay classes will generally be called one after
57
 
        // another for the same filename, we keep a quick cache of the last 
58
 
        // thing we were asked for.
59
 
        static CCriticalSection m_last_request_lock;
60
 
        static DWORD m_last_request_tick;
61
 
        static std::wstring m_last_request_path;
62
 
        static DWORD m_last_request_value;
63
 
 
64
 
public:
65
 
 
66
 
};
67
 
 
68
 
 
69
 
#define MAKE_OVERLAY_CLASS(TYPE, STATE) \
70
 
class ATL_NO_VTABLE CIconOverlay##TYPE : \
71
 
        public CIconOverlayBase, \
72
 
        public CComCoClass<CIconOverlay##TYPE, &CLSID_IconOverlay##TYPE> \
73
 
{ \
74
 
public: \
75
 
        DECLARE_NOT_AGGREGATABLE(CIconOverlay##TYPE) \
76
 
        static HRESULT WINAPI UpdateRegistry(BOOL bRegister) \
77
 
        { \
78
 
          return TortoiseUpdateRegistryFromResource(IDR_ICONOVERLAY, \
79
 
                                                                                                bRegister, \
80
 
                                                                                                _T(#TYPE), \
81
 
                                                                                                &GetObjectCLSID()); \
82
 
        } \
83
 
        virtual DWORD GetMyState() { return STATE; } \
84
 
        virtual const TCHAR *GetMyStateName() { return _T(#TYPE); } \
85
 
}; \
86
 
        OBJECT_ENTRY_AUTO(CLSID_IconOverlay##TYPE, CIconOverlay##TYPE)
87
 
 
88
 
MAKE_OVERLAY_CLASS(Added, STATE_ADDED);
89
 
MAKE_OVERLAY_CLASS(Normal, STATE_UNCHANGED);
90
 
MAKE_OVERLAY_CLASS(Modified, STATE_MODIFIED);
91
 
MAKE_OVERLAY_CLASS(Conflict, STATE_CONFLICT);
92
 
//MAKE_OVERLAY_CLASS(Locked, STATE_LOCKED);
93
 
//MAKE_OVERLAY_CLASS(ReadOnly, STATE_READONLY);
94
 
MAKE_OVERLAY_CLASS(Deleted, STATE_DELETED);
95
 
MAKE_OVERLAY_CLASS(Ignored, STATE_IGNORED);
96
 
// MAKE_OVERLAY_CLASS(Invalid);
97
 
MAKE_OVERLAY_CLASS(Unversioned, STATE_UNVERSIONED);
 
1
// IconOverlay.h : Declaration of the CIconOverlay
 
2
 
 
3
#pragma once
 
4
#include "resource.h"       // main symbols
 
5
 
 
6
// CIconOverlay
 
7
 
 
8
class ATL_NO_VTABLE CIconOverlayBase :
 
9
        public CComObjectRootEx<CComMultiThreadModel>,
 
10
        public IShellIconOverlayIdentifier
 
11
{
 
12
protected:
 
13
        // From app.py:
 
14
        static const DWORD STATE_NOTHING = 0;
 
15
        static const DWORD STATE_UNVERSIONED = 1;
 
16
        static const DWORD STATE_IGNORED = 2;
 
17
        static const DWORD STATE_UNCHANGED = 3;
 
18
        static const DWORD STATE_MODIFIED = 4;
 
19
        static const DWORD STATE_ADDED = 5;
 
20
        static const DWORD STATE_DELETED = 6;
 
21
        static const DWORD STATE_MISSING = 7;
 
22
        static const DWORD STATE_CONFLICT = 8;
 
23
 
 
24
        virtual DWORD GetMyState() = 0;
 
25
        virtual const TCHAR *GetMyStateName() = 0;
 
26
 
 
27
public:
 
28
        CIconOverlayBase()
 
29
        {
 
30
        }
 
31
 
 
32
BEGIN_COM_MAP(CIconOverlayBase)
 
33
        COM_INTERFACE_ENTRY(IShellIconOverlayIdentifier)
 
34
END_COM_MAP()
 
35
 
 
36
 
 
37
 
 
38
        DECLARE_PROTECT_FINAL_CONSTRUCT()
 
39
 
 
40
        HRESULT FinalConstruct()
 
41
        {
 
42
                return S_OK;
 
43
        }
 
44
 
 
45
        void FinalRelease()
 
46
        {
 
47
        }
 
48
 
 
49
        // IIconOverlay implementation
 
50
        STDMETHOD(IsMemberOf)(LPCWSTR pwszPath, DWORD dwAttrib);
 
51
        STDMETHOD(GetOverlayInfo)(LPWSTR pwszIconFile, int cchMax, int * pIndex, DWORD * pdwFlags);
 
52
        STDMETHOD(GetPriority)(int * pIPriority);
 
53
protected:
 
54
        DWORD CIconOverlayBase::GetFileStatus(LPCWSTR pwszPath);
 
55
 
 
56
        // As each of the overlay classes will generally be called one after
 
57
        // another for the same filename, we keep a quick cache of the last 
 
58
        // thing we were asked for.
 
59
        static CCriticalSection m_last_request_lock;
 
60
        static DWORD m_last_request_tick;
 
61
        static std::wstring m_last_request_path;
 
62
        static DWORD m_last_request_value;
 
63
 
 
64
public:
 
65
 
 
66
};
 
67
 
 
68
 
 
69
#define MAKE_OVERLAY_CLASS(TYPE, STATE) \
 
70
class ATL_NO_VTABLE CIconOverlay##TYPE : \
 
71
        public CIconOverlayBase, \
 
72
        public CComCoClass<CIconOverlay##TYPE, &CLSID_IconOverlay##TYPE> \
 
73
{ \
 
74
public: \
 
75
        DECLARE_NOT_AGGREGATABLE(CIconOverlay##TYPE) \
 
76
        static HRESULT WINAPI UpdateRegistry(BOOL bRegister) \
 
77
        { \
 
78
          return TortoiseUpdateRegistryFromResource(IDR_ICONOVERLAY, \
 
79
                                                                                                bRegister, \
 
80
                                                                                                _T(#TYPE), \
 
81
                                                                                                &GetObjectCLSID()); \
 
82
        } \
 
83
        virtual DWORD GetMyState() { return STATE; } \
 
84
        virtual const TCHAR *GetMyStateName() { return _T(#TYPE); } \
 
85
}; \
 
86
        OBJECT_ENTRY_AUTO(CLSID_IconOverlay##TYPE, CIconOverlay##TYPE)
 
87
 
 
88
MAKE_OVERLAY_CLASS(Added, STATE_ADDED);
 
89
MAKE_OVERLAY_CLASS(Normal, STATE_UNCHANGED);
 
90
MAKE_OVERLAY_CLASS(Modified, STATE_MODIFIED);
 
91
MAKE_OVERLAY_CLASS(Conflict, STATE_CONFLICT);
 
92
//MAKE_OVERLAY_CLASS(Locked, STATE_LOCKED);
 
93
//MAKE_OVERLAY_CLASS(ReadOnly, STATE_READONLY);
 
94
MAKE_OVERLAY_CLASS(Deleted, STATE_DELETED);
 
95
MAKE_OVERLAY_CLASS(Ignored, STATE_IGNORED);
 
96
// MAKE_OVERLAY_CLASS(Invalid);
 
97
MAKE_OVERLAY_CLASS(Unversioned, STATE_UNVERSIONED);