home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vile-src.zip / vile-8.1 / visvile / commands.h < prev    next >
C/C++ Source or Header  |  1998-08-25  |  3KB  |  107 lines

  1. // Commands.h : header file
  2. //
  3.  
  4. #if !defined(AFX_COMMANDS_H__E4C5E2F8_36FF_11D2_B8E4_0020AF0F4354__INCLUDED_)
  5. #define AFX_COMMANDS_H__E4C5E2F8_36FF_11D2_B8E4_0020AF0F4354__INCLUDED_
  6.  
  7. #include "VisVileTypes.h"
  8.  
  9. class CCommands : 
  10.     public CComDualImpl<ICommands, &IID_ICommands, &LIBID_VisVile>, 
  11.     public CComObjectRoot,
  12.     public CComCoClass<CCommands, &CLSID_Commands>
  13. {
  14. protected:
  15.     IApplication* m_pApplication;
  16.  
  17. public:
  18.     CCommands();
  19.     ~CCommands();
  20.     BOOL SetApplicationObject(IApplication* m_pApplication);
  21.     IApplication* GetApplicationObject() { return m_pApplication; }
  22.     void UnadviseFromEvents();
  23.  
  24.     BEGIN_COM_MAP(CCommands)
  25.         COM_INTERFACE_ENTRY(IDispatch)
  26.         COM_INTERFACE_ENTRY(ICommands)
  27.     END_COM_MAP()
  28.     DECLARE_NOT_AGGREGATABLE(CCommands)
  29.  
  30. protected:
  31.     // This class template is used as the base class for the Application
  32.     //  event handler object and the Debugger event handler object,
  33.     //  which are declared below.
  34.     template <class IEvents, const IID* piidEvents, const GUID* plibid,
  35.         class XEvents, const CLSID* pClsidEvents>
  36.     class XEventHandler :
  37.         public CComDualImpl<IEvents, piidEvents, plibid>,
  38.         public CComObjectRoot,
  39.         public CComCoClass<XEvents, pClsidEvents>
  40.     {
  41.     public:
  42.         BEGIN_COM_MAP(XEvents)
  43.             COM_INTERFACE_ENTRY(IDispatch)
  44.             COM_INTERFACE_ENTRY_IID(*piidEvents, IEvents)
  45.         END_COM_MAP()
  46.         DECLARE_NOT_AGGREGATABLE(XEvents)
  47.         void Connect(IUnknown* pUnk)
  48.         { VERIFY(SUCCEEDED(AtlAdvise(pUnk, this, *piidEvents, &m_dwAdvise))); }
  49.         void Disconnect(IUnknown* pUnk)
  50.         { AtlUnadvise(pUnk, *piidEvents, m_dwAdvise); }
  51.  
  52.         CCommands* m_pCommands;
  53.  
  54.     protected:
  55.         DWORD m_dwAdvise;
  56.     };
  57.  
  58.     // This object handles events fired by the Application object
  59.     class XApplicationEvents : public XEventHandler<IApplicationEvents, 
  60.         &IID_IApplicationEvents, &LIBID_VisVile, 
  61.         XApplicationEvents, &CLSID_ApplicationEvents>
  62.     {
  63.     public:
  64.         // IApplicationEvents methods
  65.         STDMETHOD(BeforeBuildStart)(THIS);
  66.         STDMETHOD(BuildFinish)(THIS_ long nNumErrors, long nNumWarnings);
  67.         STDMETHOD(BeforeApplicationShutDown)(THIS);
  68.         STDMETHOD(DocumentOpen)(THIS_ IDispatch * theDocument);
  69.         STDMETHOD(BeforeDocumentClose)(THIS_ IDispatch * theDocument);
  70.         STDMETHOD(DocumentSave)(THIS_ IDispatch * theDocument);
  71.         STDMETHOD(NewDocument)(THIS_ IDispatch * theDocument);
  72.         STDMETHOD(WindowActivate)(THIS_ IDispatch * theWindow);
  73.         STDMETHOD(WindowDeactivate)(THIS_ IDispatch * theWindow);
  74.         STDMETHOD(WorkspaceOpen)(THIS);
  75.         STDMETHOD(WorkspaceClose)(THIS);
  76.         STDMETHOD(NewWorkspace)(THIS);
  77.     };
  78.     typedef CComObject<XApplicationEvents> XApplicationEventsObj;
  79.     XApplicationEventsObj* m_pApplicationEventsObj;
  80.  
  81.     // This object handles events fired by the Application object
  82.     class XDebuggerEvents : public XEventHandler<IDebuggerEvents, 
  83.         &IID_IDebuggerEvents, &LIBID_VisVile, 
  84.         XDebuggerEvents, &CLSID_DebuggerEvents>
  85.     {
  86.     public:
  87.         // IDebuggerEvents method
  88.         STDMETHOD(BreakpointHit)(THIS_ IDispatch * pBreakpoint);
  89.     };
  90.     typedef CComObject<XDebuggerEvents> XDebuggerEventsObj;
  91.     XDebuggerEventsObj* m_pDebuggerEventsObj;
  92.  
  93. public:
  94. // ICommands methods
  95.     STDMETHOD(VisVileConfig)(THIS);
  96.     STDMETHOD(VisVileEnable)(THIS);
  97.     STDMETHOD(VisVileDisable)(THIS);
  98.     STDMETHOD(VisVileOpenDoc)(THIS);
  99. };
  100.  
  101. typedef CComObject<CCommands> CCommandsObj;
  102.  
  103. //{{AFX_INSERT_LOCATION}}
  104. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  105.  
  106. #endif // !defined(AFX_COMMANDS_H__E4C5E2F8_36FF_11D2_B8E4_0020AF0F4354__INCLUDED)
  107.