home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / tutsamp / perclien / drawsink.h < prev    next >
C/C++ Source or Header  |  1997-08-05  |  5KB  |  141 lines

  1. /*+==========================================================================
  2.   File:      DRAWSINK.H
  3.  
  4.   Summary:   Include file for the CODrawPageSink COM object class.
  5.  
  6.              CODrawPageSink offers a main IUnknown interface and the
  7.              custom IDrawPageSink interface (outgoing connection events
  8.              from CODrawPage DrawPage objects). This multiple interface
  9.              COM Object Class is achieved via the technique of nested
  10.              classes.  The implementation of the IDrawPageSink interface
  11.              is nested inside of the CODrawPageSink Class.
  12.  
  13.              For a comprehensive tutorial code tour of this module's
  14.              contents and offerings see the tutorial PERCLIEN.HTM
  15.              file. For more specific technical details on the internal
  16.              workings see the comments dispersed throughout the module's
  17.              source code.
  18.  
  19.   Functions: .
  20.  
  21.   Classes:   CODrawPageSink.
  22.  
  23.   Origin:    5-24-97: atrent - Editor-inheritance from TEXTSINK.H in the
  24.              PERCLIEN Tutorial Code Sample.
  25.  
  26. ----------------------------------------------------------------------------
  27.   This file is part of the Microsoft COM Tutorial Code Samples.
  28.  
  29.   Copyright (C) Microsoft Corporation, 1997.  All rights reserved.
  30.  
  31.   This source code is intended only as a supplement to Microsoft
  32.   Development Tools and/or on-line documentation.  See these other
  33.   materials for detailed information regarding Microsoft code samples.
  34.  
  35.   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  36.   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  37.   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  38.   PARTICULAR PURPOSE.
  39. ==========================================================================+*/
  40.  
  41. #if !defined(DRAWSINK_H)
  42. #define DRAWSINK_H
  43.  
  44. #ifdef __cplusplus
  45.  
  46.  
  47. /*O+O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O+++O
  48.   ObjectClass: CODrawPageSink
  49.  
  50.   Summary:     The main Sink COM object class for CODrawPageSink COM
  51.                objects. COM objects of this class offer the IDrawPageSink
  52.                sink interface supporting various DrawPage events. The
  53.                mulitple interfaces on this COM object are constructed via
  54.                the nested interface classes technique.
  55.  
  56.   Interfaces:  IUnknown
  57.                  Standard interface providing COM object features.
  58.                IDrawPageSink
  59.                  Sink interface for DrawPage events.
  60.  
  61.   Aggregation: Yes, CODrawPageSink COM Objects are aggregatable by passing
  62.                a non-NULL pUnkOuter IUnknown pointer into the constructor.
  63. O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O---O-O*/
  64. class CODrawPageSink : public IUnknown
  65. {
  66.   public:
  67.     // Main Object Constructor & Destructor.
  68.     CODrawPageSink(IUnknown* pUnkOuter, CGuiDraw* pGuiDraw);
  69.     ~CODrawPageSink(void);
  70.  
  71.     // IUnknown methods. Main object, non-delegating.
  72.     STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  73.     STDMETHODIMP_(ULONG) AddRef(void);
  74.     STDMETHODIMP_(ULONG) Release(void);
  75.  
  76.   private:
  77.     // We declare nested class interface implementations here.
  78.  
  79.     class CImpIDrawPageSink : public IDrawPageSink
  80.     {
  81.       public:
  82.         // Interface Implementation Constructor & Destructor.
  83.         CImpIDrawPageSink(CODrawPageSink* pCO, IUnknown* pUnkOuter);
  84.         ~CImpIDrawPageSink(void);
  85.  
  86.         // IUnknown methods.
  87.         STDMETHODIMP         QueryInterface(REFIID, PPVOID);
  88.         STDMETHODIMP_(ULONG) AddRef(void);
  89.         STDMETHODIMP_(ULONG) Release(void);
  90.  
  91.         // IDrawPageSink methods.
  92.         STDMETHODIMP         Loaded(void);
  93.         STDMETHODIMP         Saved(void);
  94.         STDMETHODIMP         Cleared(void);
  95.         STDMETHODIMP         Resized(SHORT nWidth, SHORT nHeight);
  96.         STDMETHODIMP         InkStart(
  97.                                SHORT nX,
  98.                                SHORT nY,
  99.                                SHORT nWidth,
  100.                                COLORREF crInkColor);
  101.         STDMETHODIMP         InkDraw(
  102.                                SHORT nX,
  103.                                SHORT nY);
  104.         STDMETHODIMP         InkStop(
  105.                                SHORT nX,
  106.                                SHORT nY);
  107.  
  108.       private:
  109.         // Data private to this interface implementation of IDrawPage.
  110.         CODrawPageSink*  m_pCO;          // Parent Object back pointer.
  111.         IUnknown*        m_pUnkOuter;    // Outer unknown for Delegation.
  112.     };
  113.  
  114.     // Make the otherwise private and nested IDrawPageSink interface
  115.     // implementation a friend to COM object instantiations of this
  116.     // CODrawPageSink COM object class.
  117.     friend CImpIDrawPageSink;
  118.  
  119.     // Private data of CODrawPageSink COM objects.
  120.  
  121.     // Nested IDrawPageSink implementation instantiation.  This
  122.     // IDrawPageSink interface is instantiated inside this CODrawPageSink
  123.     // object as a native interface.
  124.     CImpIDrawPageSink    m_ImpIDrawPageSink;
  125.  
  126.     // Main Object reference count.
  127.     ULONG                m_cRefs;
  128.  
  129.     // Outer unknown (aggregation delegation). Used when this COM object
  130.     // is being aggregated.
  131.     IUnknown*            m_pUnkOuter;
  132.  
  133.     // Pointer to the main object that can service the Sink events.
  134.     CGuiDraw*            m_pGuiDraw;
  135. };
  136.  
  137. #endif // __cplusplus
  138.  
  139.  
  140. #endif // DRAWSINK_H
  141.