summaryrefslogtreecommitdiff
path: root/src/VisVim/Commands.h
blob: e47c81a1301b91fa06721dc49d785a63d6400182 (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
// Commands.h : header file
//

#if !defined(AFX_COMMANDS_H__AC726717_2977_11D1_B2F3_006008040780__INCLUDED_)
#define AFX_COMMANDS_H__AC726717_2977_11D1_B2F3_006008040780__INCLUDED_

#include "vsvtypes.h"

class CCommands :
	public   CComDualImpl < ICommands,
				 &IID_ICommands,
				 &LIBID_VisVim >,
	public   CComObjectRoot,
	public   CComCoClass < CCommands,
				 &CLSID_Commands >
{
    protected:
	IApplication * m_pApplication;

    public:
	CCommands ();
	~CCommands ();
	void SetApplicationObject (IApplication * m_pApplication);
	IApplication *GetApplicationObject ()
	{
		return m_pApplication;
	}
	void UnadviseFromEvents ();

	BEGIN_COM_MAP (CCommands)
	COM_INTERFACE_ENTRY (IDispatch)
	COM_INTERFACE_ENTRY (ICommands)
	END_COM_MAP ()
	DECLARE_NOT_AGGREGATABLE (CCommands)

    protected:
	// This class template is used as the base class for the Application
	// event handler object and the Debugger event handler object,
	// which are declared below.
	template < class IEvents,
		const IID * piidEvents,
		const GUID * plibid,
		class XEvents,
		const CLSID * pClsidEvents >
		class XEventHandler :
		public	      CComDualImpl < IEvents,
			      piidEvents,
			      plibid >,
		public	      CComObjectRoot,
		public	      CComCoClass < XEvents,
			      pClsidEvents >
	{
	    public:
		BEGIN_COM_MAP (XEvents)
		COM_INTERFACE_ENTRY (IDispatch)
		COM_INTERFACE_ENTRY_IID (*piidEvents, IEvents)
		END_COM_MAP ()
		DECLARE_NOT_AGGREGATABLE (XEvents)
		void Connect (IUnknown * pUnk)
		{
			VERIFY (SUCCEEDED (AtlAdvise (pUnk, this, *piidEvents,
						      &m_dwAdvise)));
		}
		void Disconnect (IUnknown * pUnk)
		{
			AtlUnadvise (pUnk, *piidEvents, m_dwAdvise);
		}

		CCommands *m_pCommands;

	    protected:
		DWORD m_dwAdvise;
	};

	// This object handles events fired by the Application object
	class XApplicationEvents : public XEventHandler < IApplicationEvents,
			&IID_IApplicationEvents,
			&LIBID_VisVim,
			XApplicationEvents,
			&CLSID_ApplicationEvents >
	{
	    public:
		// IApplicationEvents methods
		STDMETHOD (BeforeBuildStart) (THIS);
		STDMETHOD (BuildFinish) (THIS_ long nNumErrors, long nNumWarnings);
		STDMETHOD (BeforeApplicationShutDown) (THIS);
		STDMETHOD (DocumentOpen) (THIS_ IDispatch * theDocument);
		STDMETHOD (BeforeDocumentClose) (THIS_ IDispatch * theDocument);
		STDMETHOD (DocumentSave) (THIS_ IDispatch * theDocument);
		STDMETHOD (NewDocument) (THIS_ IDispatch * theDocument);
		STDMETHOD (WindowActivate) (THIS_ IDispatch * theWindow);
		STDMETHOD (WindowDeactivate) (THIS_ IDispatch * theWindow);
		STDMETHOD (WorkspaceOpen) (THIS);
		STDMETHOD (WorkspaceClose) (THIS);
		STDMETHOD (NewWorkspace) (THIS);
	};
	typedef CComObject < XApplicationEvents > XApplicationEventsObj;
	XApplicationEventsObj *m_pApplicationEventsObj;

	// This object handles events fired by the Application object
	class XDebuggerEvents : public XEventHandler < IDebuggerEvents,
			&IID_IDebuggerEvents,
			&LIBID_VisVim,
			XDebuggerEvents,
			&CLSID_DebuggerEvents >
	{
	    public:
		// IDebuggerEvents method
		STDMETHOD (BreakpointHit) (THIS_ IDispatch * pBreakpoint);
	};
	typedef CComObject < XDebuggerEvents > XDebuggerEventsObj;
	XDebuggerEventsObj *m_pDebuggerEventsObj;

    public:
	// ICommands methods
	STDMETHOD (VisVimDialog) (THIS);
	STDMETHOD (VisVimEnable) (THIS);
	STDMETHOD (VisVimDisable) (THIS);
	STDMETHOD (VisVimToggle) (THIS);
	STDMETHOD (VisVimLoad) (THIS);
};

typedef CComObject < CCommands > CCommandsObj;

//{{AFX_INSERT_LOCATION}}

#endif // !defined(AFX_COMMANDS_H__AC726717_2977_11D1_B2F3_006008040780__INCLUDED)