QUAD.H
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:4k
源码类别:

Windows编程

开发平台:

Visual C++

  1. //+---------------------------------------------------------------------------
  2. //
  3. //  Microsoft Windows
  4. //  Copyright 1992 - 1997 Microsoft Corporation.
  5. //
  6. //  File:       quad.h
  7. //
  8. //  Contents:   class definitions for the Quadrant Engine
  9. //
  10. //  Classes:    CQuadrantEngineCF
  11. //              CQuadrantEngine
  12. //
  13. //  Functions:
  14. //
  15. //  History:    4-14-94   stevebl   Created
  16. //
  17. //----------------------------------------------------------------------------
  18. #ifndef __QUAD_H__
  19. #define __QUAD_H__
  20. #ifdef __cplusplus
  21. #include <frcngn.h>
  22. #include <frhost.h>
  23. #include <qudcln.h>
  24. #include <qudngn.h>
  25. //+---------------------------------------------------------------------------
  26. //
  27. //  Class:      CQuadrantEngineCF
  28. //
  29. //  Purpose:    the class factory for the Quadrant Engine
  30. //
  31. //  Interface:  CQuadrantEngineCF  -- constructor
  32. //              ~CQuadrantEngineCF -- destructor
  33. //              QueryInterface     -- retrieves an interface on the cf
  34. //              AddRef             -- incrementes referencec count
  35. //              Release            -- decrements reference count
  36. //              CreateInstance     -- creates a Quadrant Engine object
  37. //              LockServer         -- keeps cf from being deleted on release
  38. //
  39. //  History:    4-14-94   stevebl   Created
  40. //
  41. //----------------------------------------------------------------------------
  42. class CQuadrantEngineCF : public IClassFactory
  43. {
  44. public:
  45.     CQuadrantEngineCF();
  46.     ~CQuadrantEngineCF();
  47.     HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, LPVOID *);
  48.     ULONG STDMETHODCALLTYPE AddRef(void);
  49.     ULONG STDMETHODCALLTYPE Release(void);
  50.     HRESULT STDMETHODCALLTYPE CreateInstance(LPUNKNOWN, REFIID, LPVOID*);
  51.     HRESULT STDMETHODCALLTYPE LockServer(BOOL);
  52. protected:
  53.     ULONG _cRef;
  54. };
  55. //+---------------------------------------------------------------------------
  56. //
  57. //  Class:      CQuadrantEngine
  58. //
  59. //  Purpose:    implementation for the quadrant engine object
  60. //
  61. //  Interface:  QueryInterface     -- retrieves an interface from the engine
  62. //              AddRef             -- increments refcount
  63. //              Release            -- decrements refcount
  64. //              Init               -- initializes quadrant engine
  65. //              UseBoundingBoxes   -- tells engine to use bounding boxes
  66. //              SetGraphSize       -- tells engine the size of its graph
  67. //              Start              -- starts engine
  68. //              Stop               -- stops engine
  69. //              Reset              -- resets engine
  70. //              GraphicsThread     -- entry point for the graphics thread
  71. //              PlotAreaSlowly     -- plots a rectangle
  72. //              Subdivide          -- recursively plots a quadrant
  73. //              Initialize         -- private method to initialize c++ object
  74. //              CQuadrantEngine    -- constructor
  75. //              ~CQuadrantEngine   -- destructor
  76. //
  77. //  History:    4-14-94   stevebl   Created
  78. //
  79. //----------------------------------------------------------------------------
  80. class CQuadrantEngine : public IQuadrantEngine
  81. {
  82. public:
  83.     // IUnknown methods
  84.     HRESULT STDMETHODCALLTYPE QueryInterface(REFIID, LPVOID *);
  85.     ULONG STDMETHODCALLTYPE AddRef(void);
  86.     ULONG STDMETHODCALLTYPE Release(void);
  87.     // IQuadrantEngine methods
  88.     HRESULT STDMETHODCALLTYPE Init(
  89.         IQuadrantClient *pqc,
  90.         IFractalHost *pfh);
  91.     HRESULT STDMETHODCALLTYPE UseBoundingBoxes(BOOL fFlag);
  92.     HRESULT STDMETHODCALLTYPE SetGraphSize(
  93.         unsigned int uWidth,
  94.         unsigned int uHeight);
  95.     HRESULT STDMETHODCALLTYPE Start(void);
  96.     HRESULT STDMETHODCALLTYPE Stop(void);
  97.     HRESULT STDMETHODCALLTYPE Reset(void);
  98.     // Methods that aren't part of any interface
  99.     DWORD GraphicsThread(void);
  100.     void PlotAreaSlowly(
  101.         int iXLow,
  102.         int iYLow,
  103.         int iXHigh,
  104.         int iYHigh);
  105.     void Subdivide(
  106.         int iXLow,
  107.         int iYLow,
  108.         int iXHigh,
  109.         int iYHigh);
  110.     BOOL Initialize(void);
  111.     CQuadrantEngine();
  112.     ~CQuadrantEngine();
  113. private:
  114.     BOOL _fUseBoundingBoxes;
  115.     ULONG _cRef;
  116.     unsigned _uWidth, _uHeight;
  117.     HANDLE _hRestart, _hRunning;
  118.     HANDLE _hEngine;
  119.     DWORD _dwThreadId;
  120.     IFractalHost * _pfh;
  121.     IQuadrantClient * _pqc;
  122. };
  123. extern HINSTANCE ghinst;
  124. extern ULONG gcRef, gcLock;
  125. #endif //__cplusplus
  126. #endif //__QUAD_H__