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 / inc / ipages.h < prev    next >
Text File  |  1997-08-05  |  11KB  |  285 lines

  1. /*+==========================================================================
  2.   File:      IPAGES.H
  3.  
  4.   Summary:   This is the common include file for the persistent
  5.              page-related COM Interfaces. The Interface abstract base
  6.              classes are declared.
  7.  
  8.              This file is global to all the Tutorial Code Samples (kept in
  9.              the ..\INC directory).  It is a good practice to factor out
  10.              Interface and GUID specifications to reduce the possibility
  11.              of GUID or interface conflicts.
  12.  
  13.   Classes:   IPageList, IPageListSink, ITextPage, ITextPageSink,
  14.              IDrawPage, IDrawPageSink.
  15.  
  16.   Functions: .
  17.  
  18.   Origin:    5-26-97: atrent - Revised for the COM Tutorial Samples.
  19.  
  20. ----------------------------------------------------------------------------
  21.   This file is part of the Microsoft COM Tutorial Code Samples.
  22.  
  23.   Copyright (C) Microsoft Corporation, 1997.  All rights reserved.
  24.  
  25.   This source code is intended only as a supplement to Microsoft
  26.   Development Tools and/or on-line documentation.  See these other
  27.   materials for detailed information regarding Microsoft code samples.
  28.  
  29.   THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
  30.   KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  31.   IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  32.   PARTICULAR PURPOSE.
  33. ==========================================================================+*/
  34.  
  35. #if !defined(IPAGES_H)
  36. #define IPAGES_H
  37.  
  38. #if !defined(RC_INCLUDE)
  39.  
  40. // Here are the page types.
  41. #define PAGETYPE_NONE    0
  42. #define PAGETYPE_DELETED 1
  43. #define PAGETYPE_TEXT    2
  44. #define PAGETYPE_DRAWING 3
  45.  
  46. // Page Open Status.
  47. #define OPENSTATE_NONE   0
  48. #define OPENSTATE_YES    1
  49. #define OPENSTATE_NO     2
  50.  
  51. #define PAGE_TITLE_SIZE 64
  52. #define PAGE_NAME_SIZE 16
  53.  
  54. // Strings used for assembling IStorage/IStream names.
  55. #define PAGELIST_USTR L"PageList"
  56.  
  57. // Messages for posting events from page windows to main app window.
  58. #define WM_USER_PAGECHANGED WM_USER+400
  59. #define WM_USER_PAGECLOSED  WM_USER+401
  60.  
  61.  
  62. /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
  63.   Interface: IPageList
  64.  
  65.   Summary:   Interface for page list features to manipulate the
  66.              encapsulated page list.
  67.  
  68.   Methods:   Get(
  69.                  INT     iPage,
  70.                  BOOL*   pbOpened,
  71.                  SHORT*  pnType,
  72.                  WCHAR*  pwszTitle,
  73.                  WCHAR*  pwszDataName);
  74.                Get a Page List Item for a given page number. Get back
  75.                open status, page type, page title, and page data name.
  76.              Set(
  77.                  INT     iPage,
  78.                  SHORT   nOpenStatus,
  79.                  WCHAR*  pwszNewTitle);
  80.                Put a Page List Item of specified page number with new
  81.                page open status and page title.
  82.              Add(
  83.                  INT     iPage,
  84.                  SHORT   nType,
  85.                  WCHAR*  pwszTitle,
  86.                  INT*    piPage)
  87.                Add/insert a new Page List Item of specified type with
  88.                specified title.
  89.              Delete(INT  iPage);
  90.                Delete the Page List Item for the specified page number.
  91.              Clear(void);
  92.                Clear/Delete all Page List Items from the Page List.
  93. I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
  94. DECLARE_INTERFACE_(IPageList, IUnknown)
  95. {
  96.   // IUnknown methods.
  97.   STDMETHOD(QueryInterface) (THIS_ REFIID, PPVOID) PURE;
  98.   STDMETHOD_(ULONG,AddRef)  (THIS) PURE;
  99.   STDMETHOD_(ULONG,Release) (THIS) PURE;
  100.  
  101.   // IPageList methods.
  102.   STDMETHOD(Get)        (THIS_ INT, BOOL*, SHORT*, WCHAR*, WCHAR*) PURE;
  103.   STDMETHOD(Set)        (THIS_ INT, SHORT, WCHAR*) PURE;
  104.   STDMETHOD(Add)        (THIS_ INT, SHORT, WCHAR*, INT*) PURE;
  105.   STDMETHOD(Delete)     (THIS_ INT) PURE;
  106.   STDMETHOD(Clear)      (THIS) PURE;
  107. };
  108.  
  109.  
  110. /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
  111.   Interface: IPageListSink
  112.  
  113.   Summary:   Sink Connection Interface for PageList COM Objects
  114.              that communicate events back to the client.
  115.  
  116.   Methods:   Loaded
  117.                The PageList was loaded from persistent storage.
  118.              Saved
  119.                The PageList was saved to persistent storage.
  120.              Cleared
  121.                The entire PageList was cleared.
  122.              PageAdded(INT iPage);
  123.                A new PageItem was added to the PageList.
  124.              PageDeleted(INT iPage);
  125.                A PageItem was deleted from the PageList.
  126.              PageSet(INT iPage);
  127.                A PageItem entry was set with new data.
  128. I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
  129. DECLARE_INTERFACE_(IPageListSink, IUnknown)
  130. {
  131.   // IUnknown methods.
  132.   STDMETHOD(QueryInterface) (THIS_ REFIID, PPVOID) PURE;
  133.   STDMETHOD_(ULONG,AddRef)  (THIS) PURE;
  134.   STDMETHOD_(ULONG,Release) (THIS) PURE;
  135.  
  136.   // IPageListSink methods.
  137.   STDMETHOD(Loaded)      (THIS) PURE;
  138.   STDMETHOD(Saved)       (THIS) PURE;
  139.   STDMETHOD(Cleared)     (THIS) PURE;
  140.   STDMETHOD(PageAdded)   (THIS_ INT) PURE;
  141.   STDMETHOD(PageDeleted) (THIS_ INT) PURE;
  142.   STDMETHOD(PageSet)     (THIS_ INT) PURE;
  143. };
  144.  
  145.  
  146. /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
  147.   Interface: ITextPage
  148.  
  149.   Summary:   Interface for text page features to manipulate the text
  150.              in the encapsulated text page.
  151.  
  152.   Methods:   GetLength(INT*    piLength);
  153.                Get the current length (in WCHARs) of the text page.
  154.              GetText(WCHAR* pwszPageText);
  155.                Get the current page text held in this object.
  156.              PutText(WCHAR* pwszPageText, INT iLength);
  157.                Put specified wide character text of specified length
  158.                into this text page object. Does not save persistently.
  159.              Clear(BOOL bSaveNeeded);
  160.                Clears all text from the entire text page.
  161. I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
  162. DECLARE_INTERFACE_(ITextPage, IUnknown)
  163. {
  164.   // IUnknown methods.
  165.   STDMETHOD(QueryInterface) (THIS_ REFIID, PPVOID) PURE;
  166.   STDMETHOD_(ULONG,AddRef)  (THIS) PURE;
  167.   STDMETHOD_(ULONG,Release) (THIS) PURE;
  168.  
  169.   // ITextPage methods.
  170.   STDMETHOD(GetLength)  (THIS_ INT*) PURE;
  171.   STDMETHOD(GetText)    (THIS_ WCHAR*) PURE;
  172.   STDMETHOD(PutText)    (THIS_ WCHAR*, INT) PURE;
  173.   STDMETHOD(Clear)      (THIS_ BOOL) PURE;
  174. };
  175.  
  176.  
  177. /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
  178.   Interface: ITextPageSink
  179.  
  180.   Summary:   Sink Connection Interface for TextPage COM Objects
  181.              that communicate events back to the client.
  182.  
  183.   Methods:   Loaded
  184.                The TextPage was loaded from persistent stream.
  185.              Saved
  186.                The TextPage was saved to persistent stream.
  187.              Put
  188.                New text content was put into the TextPage object.
  189.              Cleared
  190.                The entire TextPage was cleared.
  191. I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
  192. DECLARE_INTERFACE_(ITextPageSink, IUnknown)
  193. {
  194.   // IUnknown methods.
  195.   STDMETHOD(QueryInterface) (THIS_ REFIID, PPVOID) PURE;
  196.   STDMETHOD_(ULONG,AddRef)  (THIS) PURE;
  197.   STDMETHOD_(ULONG,Release) (THIS) PURE;
  198.  
  199.   // ITextPageSink methods.
  200.   STDMETHOD(Loaded)      (THIS) PURE;
  201.   STDMETHOD(Saved)       (THIS) PURE;
  202.   STDMETHOD(Put)         (THIS) PURE;
  203.   STDMETHOD(Cleared)     (THIS) PURE;
  204. };
  205.  
  206.  
  207. /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
  208.   Interface: IDrawPage
  209.  
  210.   Summary:   Interface for free-form drawing on drawing page COM Objects.
  211.  
  212.   Methods:   InkStart(SHORT nX,SHORT nY,SHORT nInkWidth,COLORREF crInkColor);
  213.                Client starts color ink drawing to the drawing surface.
  214.              InkDraw(SHORT nX, SHORT nY);
  215.                Client puts ink data points on the drawing surface.
  216.              InkStop(SHORT nX, SHORT nY);
  217.                Client stops ink drawing to the drawing surface.
  218.              Clear(BOOL bSaveNeeded);
  219.                Clear the current drawing content. Notify Sinks.
  220.                Mark dirty flag if bSaveNeeded==TRUE.
  221.              Resize(SHORT nWidth, SHORT nHeight);
  222.                Resize the drawing rectangle size.
  223.              Redraw
  224.                Redraw content of drawing object via Sink notification.
  225. I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
  226. DECLARE_INTERFACE_(IDrawPage, IUnknown)
  227. {
  228.   // IUnknown methods.
  229.   STDMETHOD(QueryInterface) (THIS_ REFIID, PPVOID) PURE;
  230.   STDMETHOD_(ULONG,AddRef)  (THIS) PURE;
  231.   STDMETHOD_(ULONG,Release) (THIS) PURE;
  232.  
  233.   // IDrawPage methods.
  234.   STDMETHOD(InkStart)   (THIS_ SHORT, SHORT, SHORT, COLORREF) PURE;
  235.   STDMETHOD(InkDraw)    (THIS_ SHORT, SHORT) PURE;
  236.   STDMETHOD(InkStop)    (THIS_ SHORT, SHORT) PURE;
  237.   STDMETHOD(Clear)      (THIS_ BOOL) PURE;
  238.   STDMETHOD(Resize)     (THIS_ SHORT, SHORT) PURE;
  239.   STDMETHOD(Redraw)     (THIS) PURE;
  240. };
  241.  
  242.  
  243. /*I+I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I+++I
  244.   Interface: IDrawPageSink
  245.  
  246.   Summary:   Sink Connection Interface for use by DrawPage COM Objects
  247.              that communicate events back to the client.
  248.  
  249.   Methods:   Loaded
  250.                The DrawPage was loaded from persistent storage.
  251.              Saved
  252.                The DrawPage was saved to persistent storage.
  253.              InkStart(SHORT nX,SHORT nY,SHORT nInkWidth,COLORREF crInkColor);
  254.                A client started a color ink drawing sequence.
  255.              InkDraw(SHORT nX, SHORT nY);
  256.                A client is putting ink data points on the drawing surface.
  257.              InkStop(SHORT nX, SHORT nY);
  258.                A client stopped its ink drawing sequence.
  259.              Cleared
  260.                A client has erased/cleared the entire DrawPage.
  261.              Resized(SHORT nWidth, SHORT nHeight);
  262.                A client has resized the drawing window.
  263. I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I---I-I*/
  264. DECLARE_INTERFACE_(IDrawPageSink, IUnknown)
  265. {
  266.   // IUnknown methods.
  267.   STDMETHOD(QueryInterface) (THIS_ REFIID, PPVOID) PURE;
  268.   STDMETHOD_(ULONG,AddRef)  (THIS) PURE;
  269.   STDMETHOD_(ULONG,Release) (THIS) PURE;
  270.  
  271.   // IDrawPageSink methods.
  272.   STDMETHOD(Loaded)      (THIS) PURE;
  273.   STDMETHOD(Saved)       (THIS) PURE;
  274.   STDMETHOD(InkStart)    (THIS_ SHORT, SHORT, SHORT, COLORREF) PURE;
  275.   STDMETHOD(InkDraw)     (THIS_ SHORT, SHORT) PURE;
  276.   STDMETHOD(InkStop)     (THIS_ SHORT, SHORT) PURE;
  277.   STDMETHOD(Cleared)     (THIS) PURE;
  278.   STDMETHOD(Resized)     (THIS_ SHORT, SHORT) PURE;
  279. };
  280.  
  281.  
  282. #endif // RC_INCLUDE
  283.  
  284. #endif // IPAGES_H
  285.