home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / com / inole2 / chap01 / cosmo / cosmo.h < prev    next >
C/C++ Source or Header  |  1995-05-03  |  4KB  |  155 lines

  1. /*
  2.  * COSMO.H
  3.  * Cosmo Chapter 1
  4.  *
  5.  * Single include file that pulls in everything needed for other
  6.  * source files in the Cosmo application.
  7.  *
  8.  * Copyright (c)1993-1995 Microsoft Corporation, All Rights Reserved
  9.  *
  10.  * Kraig Brockschmidt, Microsoft
  11.  * Internet  :  kraigb@microsoft.com
  12.  * Compuserve:  >INTERNET:kraigb@microsoft.com
  13.  */
  14.  
  15.  
  16. #ifndef _COSMO_H_
  17. #define _COSMO_H_
  18.  
  19. #define INC_CLASSLIB
  20. #define CHAPTER1
  21. #include <inole.h>
  22. #include "resource.h"
  23.  
  24.  
  25. //Get the editor window information.
  26. #include "polyline.h"
  27.  
  28.  
  29.  
  30. //COSMO.CPP:  Frame object that creates a main window
  31.  
  32. class CCosmoFrame : public CFrame
  33.     {
  34.     private:
  35.         HBITMAP         m_hBmpLines[5];     //Menu item bitmaps
  36.         UINT            m_uIDCurLine;       //Current line selection
  37.  
  38.     protected:
  39.         //Overridable for creating a CClient for this frame
  40.         virtual PCClient  CreateCClient(void);
  41.  
  42.         virtual BOOL      RegisterAllClasses(void);
  43.         virtual BOOL      PreShowInit(void);
  44.         virtual UINT      CreateToolbar(void);
  45.  
  46.         virtual LRESULT   OnCommand(HWND, WPARAM, LPARAM);
  47.         virtual void      OnDocumentDataChange(PCDocument);
  48.         virtual void      OnDocumentActivate(PCDocument);
  49.  
  50.         //New for this class
  51.         virtual void      CreateLineMenu(void);
  52.  
  53.     public:
  54.         CCosmoFrame(HINSTANCE, HINSTANCE, LPSTR, int);
  55.         virtual ~CCosmoFrame(void);
  56.  
  57.         //Overrides
  58.         virtual void      UpdateMenus(HMENU, UINT);
  59.         virtual void      UpdateToolbar(void);
  60.  
  61.         //New for this class
  62.         virtual void      CheckLineSelection(UINT);
  63.     };
  64.  
  65.  
  66. typedef CCosmoFrame *PCCosmoFrame;
  67.  
  68.  
  69.  
  70.  
  71.  
  72. //CLIENT.CPP
  73.  
  74. /*
  75.  * The only reason we have a derived class here is to override
  76.  * CreateCDocument so we can create our own type as well as
  77.  * overriding NewDocument to perform one other piece of work once
  78.  * the document's been created.
  79.  */
  80.  
  81. class CCosmoClient : public CClient
  82.     {
  83.     protected:
  84.         //Overridable for creating a new CDocument
  85.         virtual PCDocument CreateCDocument(void);
  86.  
  87.     public:
  88.         CCosmoClient(HINSTANCE, PCFrame);
  89.         virtual ~CCosmoClient(void);
  90.  
  91.         virtual PCDocument NewDocument(BOOL);
  92.     };
  93.  
  94.  
  95. typedef CCosmoClient *PCCosmoClient;
  96.  
  97.  
  98.  
  99.  
  100. //DOCUMENT.CPP
  101.  
  102. //Constant ID for the window polyline that lives in a document
  103. #define ID_POLYLINE         10
  104.  
  105.  
  106. class CCosmoDoc : public CDocument
  107.     {
  108.     friend class CPolylineAdviseSink;
  109.  
  110.     protected:
  111.         UINT                    m_uPrevSize;    //Last WM_SIZE wParam
  112.         LONG                    m_lVer;         //Loaded Polyline ver
  113.  
  114.         PCPolyline              m_pPL;          //Polyline window here
  115.         PCPolylineAdviseSink    m_pPLAdv;       //Advises from Polyline
  116.  
  117.     protected:
  118.         virtual BOOL     FMessageHook(HWND, UINT, WPARAM, LPARAM
  119.             , LRESULT *);
  120.  
  121.     public:
  122.         CCosmoDoc(HINSTANCE, PCFrame, PCDocumentAdviseSink);
  123.         virtual ~CCosmoDoc(void);
  124.  
  125.         virtual BOOL     Init(PDOCUMENTINIT);
  126.  
  127.         virtual void     Clear(void);
  128.  
  129.         virtual UINT     Load(BOOL, LPTSTR);
  130.         virtual UINT     Save(UINT, LPTSTR);
  131.  
  132.         virtual void     Undo(void);
  133.         virtual BOOL     Clip(HWND, BOOL);
  134.         virtual HGLOBAL  RenderFormat(UINT);
  135.         virtual BOOL     FQueryPaste(void);
  136.         virtual BOOL     Paste(HWND);
  137.  
  138.         virtual COLORREF ColorSet(UINT, COLORREF);
  139.         virtual COLORREF ColorGet(UINT);
  140.  
  141.         virtual UINT     LineStyleSet(UINT);
  142.         virtual UINT     LineStyleGet(void);
  143.     };
  144.  
  145. typedef CCosmoDoc *PCCosmoDoc;
  146.  
  147.  
  148. //These color indices wrap the polyline definitions
  149. #define DOCCOLOR_BACKGROUND             POLYLINECOLOR_BACKGROUND
  150. #define DOCCOLOR_LINE                   POLYLINECOLOR_LINE
  151.  
  152.  
  153.  
  154. #endif //_COSMO_H_
  155.