blob: e47c81a1301b91fa06721dc49d785a63d6400182 [file] [log] [blame]
Bram Moolenaar071d4272004-06-13 20:20:40 +00001// Commands.h : header file
2//
3
4#if !defined(AFX_COMMANDS_H__AC726717_2977_11D1_B2F3_006008040780__INCLUDED_)
5#define AFX_COMMANDS_H__AC726717_2977_11D1_B2F3_006008040780__INCLUDED_
6
7#include "vsvtypes.h"
8
9class CCommands :
10 public CComDualImpl < ICommands,
11 &IID_ICommands,
12 &LIBID_VisVim >,
13 public CComObjectRoot,
14 public CComCoClass < CCommands,
15 &CLSID_Commands >
16{
17 protected:
18 IApplication * m_pApplication;
19
20 public:
21 CCommands ();
22 ~CCommands ();
23 void SetApplicationObject (IApplication * m_pApplication);
24 IApplication *GetApplicationObject ()
25 {
26 return m_pApplication;
27 }
28 void UnadviseFromEvents ();
29
30 BEGIN_COM_MAP (CCommands)
31 COM_INTERFACE_ENTRY (IDispatch)
32 COM_INTERFACE_ENTRY (ICommands)
33 END_COM_MAP ()
34 DECLARE_NOT_AGGREGATABLE (CCommands)
35
36 protected:
37 // This class template is used as the base class for the Application
38 // event handler object and the Debugger event handler object,
39 // which are declared below.
40 template < class IEvents,
41 const IID * piidEvents,
42 const GUID * plibid,
43 class XEvents,
44 const CLSID * pClsidEvents >
45 class XEventHandler :
46 public CComDualImpl < IEvents,
47 piidEvents,
48 plibid >,
49 public CComObjectRoot,
50 public CComCoClass < XEvents,
51 pClsidEvents >
52 {
53 public:
54 BEGIN_COM_MAP (XEvents)
55 COM_INTERFACE_ENTRY (IDispatch)
56 COM_INTERFACE_ENTRY_IID (*piidEvents, IEvents)
57 END_COM_MAP ()
58 DECLARE_NOT_AGGREGATABLE (XEvents)
59 void Connect (IUnknown * pUnk)
60 {
61 VERIFY (SUCCEEDED (AtlAdvise (pUnk, this, *piidEvents,
62 &m_dwAdvise)));
63 }
64 void Disconnect (IUnknown * pUnk)
65 {
66 AtlUnadvise (pUnk, *piidEvents, m_dwAdvise);
67 }
68
69 CCommands *m_pCommands;
70
71 protected:
72 DWORD m_dwAdvise;
73 };
74
75 // This object handles events fired by the Application object
76 class XApplicationEvents : public XEventHandler < IApplicationEvents,
77 &IID_IApplicationEvents,
78 &LIBID_VisVim,
79 XApplicationEvents,
80 &CLSID_ApplicationEvents >
81 {
82 public:
83 // IApplicationEvents methods
84 STDMETHOD (BeforeBuildStart) (THIS);
85 STDMETHOD (BuildFinish) (THIS_ long nNumErrors, long nNumWarnings);
86 STDMETHOD (BeforeApplicationShutDown) (THIS);
87 STDMETHOD (DocumentOpen) (THIS_ IDispatch * theDocument);
88 STDMETHOD (BeforeDocumentClose) (THIS_ IDispatch * theDocument);
89 STDMETHOD (DocumentSave) (THIS_ IDispatch * theDocument);
90 STDMETHOD (NewDocument) (THIS_ IDispatch * theDocument);
91 STDMETHOD (WindowActivate) (THIS_ IDispatch * theWindow);
92 STDMETHOD (WindowDeactivate) (THIS_ IDispatch * theWindow);
93 STDMETHOD (WorkspaceOpen) (THIS);
94 STDMETHOD (WorkspaceClose) (THIS);
95 STDMETHOD (NewWorkspace) (THIS);
96 };
97 typedef CComObject < XApplicationEvents > XApplicationEventsObj;
98 XApplicationEventsObj *m_pApplicationEventsObj;
99
100 // This object handles events fired by the Application object
101 class XDebuggerEvents : public XEventHandler < IDebuggerEvents,
102 &IID_IDebuggerEvents,
103 &LIBID_VisVim,
104 XDebuggerEvents,
105 &CLSID_DebuggerEvents >
106 {
107 public:
108 // IDebuggerEvents method
109 STDMETHOD (BreakpointHit) (THIS_ IDispatch * pBreakpoint);
110 };
111 typedef CComObject < XDebuggerEvents > XDebuggerEventsObj;
112 XDebuggerEventsObj *m_pDebuggerEventsObj;
113
114 public:
115 // ICommands methods
116 STDMETHOD (VisVimDialog) (THIS);
117 STDMETHOD (VisVimEnable) (THIS);
118 STDMETHOD (VisVimDisable) (THIS);
119 STDMETHOD (VisVimToggle) (THIS);
120 STDMETHOD (VisVimLoad) (THIS);
121};
122
123typedef CComObject < CCommands > CCommandsObj;
124
125//{{AFX_INSERT_LOCATION}}
126
127#endif // !defined(AFX_COMMANDS_H__AC726717_2977_11D1_B2F3_006008040780__INCLUDED)