home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / ODFDev / ODF / OS / FWGraphx / Include / FWGC.h < prev    next >
Encoding:
Text File  |  1995-11-08  |  5.9 KB  |  204 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWGC.h
  4. //    Release Version:    $ 1.0d11 $
  5. //
  6. //    Copyright:    © 1993, 1995 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #ifndef FWGC_H
  11. #define FWGC_H
  12.  
  13. #ifndef FWGRDEF_H
  14. #include "FWGrDef.h"
  15. #endif
  16.  
  17. #ifndef FWPOINT_H
  18. #include "FWPoint.h"
  19. #endif
  20.  
  21. #ifndef FWRECT_H
  22. #include "FWRect.h"
  23. #endif
  24.  
  25. #ifndef FWMAPING_H
  26. #include "FWMaping.h"
  27. #endif
  28.  
  29. // ----- Foundation Includes -----
  30.  
  31. #ifndef FWAUTODE_H
  32. #include "FWAutoDe.h"
  33. #endif
  34.  
  35. // ----- Platform Includes -----
  36.  
  37. #if defined(FW_BUILD_WIN) && !defined(_INC_WINDOWS)
  38. #include <windows.h>
  39. #endif
  40.  
  41. #if FW_LIB_EXPORT_PRAGMAS
  42. #pragma lib_export on
  43. #endif
  44.  
  45. //========================================================================================
  46. //    Forward Declarations
  47. //========================================================================================
  48.  
  49. class FW_CLASS_ATTR ODShape;
  50. class FW_CLASS_ATTR ODCanvas;
  51. class FW_CLASS_ATTR ODTransform;
  52. class FW_CLASS_ATTR FW_CRasterizer;
  53. class FW_CLASS_ATTR FW_CGraphicDevice;
  54.  
  55. struct FW_CLASS_ATTR FW_SRasterizerState;
  56. struct FW_CLASS_ATTR FW_SSuspendResumeState;
  57. struct FW_CLASS_ATTR FW_SDeviceState;
  58.  
  59. //========================================================================================
  60. //    class FW_CGraphicContext
  61. //========================================================================================
  62.  
  63. class FW_CLASS_ATTR FW_CGraphicContext FW_AUTO_DESTRUCT_OBJECT
  64. {
  65. //----------------------------------------------------------------------------------------
  66. //    Constructors/Destructors
  67. //
  68. public:
  69.     virtual ~FW_CGraphicContext();
  70.  
  71. protected:
  72.     FW_CGraphicContext(Environment* ev);
  73.     
  74.     // ----- Init Graphic Context with a transform
  75.     void    InitGraphicContext(FW_CGraphicDevice* graphicDevice,
  76.                                ODTransform* transform,
  77.                                ODShape* clipShape);
  78.                                 
  79.     // ----- Terminate the Graphic Context
  80.     void    TerminateGraphicContext();
  81.  
  82. //----------------------------------------------------------------------------------------
  83. //    New API
  84. //
  85. public:
  86.     // ----- Conversion -----
  87.     FW_SPlatformPoint        LogicalToDevice(FW_CFixed xSize, FW_CFixed ySize) const;
  88.     FW_SPlatformPoint        LogicalToDevice(const FW_CPoint& point) const;
  89.     FW_SPlatformRect        LogicalToDevice(const FW_CRect& rect) const;
  90.     ODShape*                LogicalToDevice(ODShape* shape) const;
  91.                                 
  92.     FW_CPoint                DeviceToLogical(short xSize, short ySize) const;
  93.     FW_CPoint                DeviceToLogical(const FW_SPlatformPoint& point) const;
  94.     FW_CRect                DeviceToLogical(const FW_SPlatformRect& rect) const;
  95.     ODShape*                DeviceToLogical(ODShape* region) const;
  96.  
  97.     // ----- Clipping -----
  98.     ODShape*                GetClip() const;                        // the resulting shape belongs to the caller
  99.     void                    SetClip(ODShape* odShape);                // a copy of odShape is used
  100.     
  101.     void                    GetClipRect(FW_CRect& clipRect) const;
  102.     void                    SetClipRect(const FW_CRect& clipRect);
  103.     
  104.     // ----- Mapping -----
  105.     void                    SetMapping(const FW_CMapping& newMapping);
  106.     void                    GetMapping(FW_CMapping& mapping) const;
  107.  
  108. //----------------------------------------------------------------------------------------
  109. //    Internal use only
  110. //
  111. public:
  112.     // ----- Rasterizer -----
  113.     FW_CRasterizer*            GetRasterizer() const;
  114.     void                    SetRasterizer(FW_CRasterizer *rasterizer);
  115.     
  116.     // ----- Transform info -----
  117.     FW_SPlatformPoint        GetOriginOffset() const;
  118.     
  119.     // ----- GraphicDevice -----
  120.     FW_CGraphicDevice*        GetGraphicDevice() const;
  121.     
  122.     // ----- Getters -----
  123.     ODPlatformCanvas        GetPlatformCanvas() const;
  124.     
  125.     // ----- Suspend/Resume -----
  126.     void                    PrivSuspend();
  127.     void                    PrivResume();
  128.     
  129.     Environment*            GetEnvironment() const;
  130.     
  131. private:
  132.     FW_CGraphicContext(const FW_CGraphicContext& other);
  133.     FW_CGraphicContext& operator=(const FW_CGraphicContext& other);
  134.         // Copy constructor and assignment operator not valid for this class.    
  135.     
  136. //----------------------------------------------------------------------------------------
  137. //    Data Members
  138. //
  139. private:
  140.     FW_Boolean                fInitialized;
  141.  
  142.     Environment*            fEnvironment;
  143.     
  144.     FW_CGraphicContext        *fPreviousGraphicContext;
  145.     
  146.     FW_CMapping                fMapping;
  147.     
  148.     FW_CRasterizer*            fRasterizer;
  149.     FW_CGraphicDevice*        fGraphicDevice;
  150.     ODTransform*            fTransform;
  151.     
  152.     FW_SDeviceState*        fDevicePreviousState;
  153.     FW_SSuspendResumeState*    fDeviceSuspendState;
  154. };
  155.  
  156. //========================================================================================
  157. //    class FW_CSaveRestoreContext
  158. //========================================================================================
  159.  
  160. class FW_CLASS_ATTR FW_CSaveRestoreContext FW_AUTO_DESTRUCT_OBJECT
  161. {
  162. public:
  163.     FW_CSaveRestoreContext(FW_CGraphicContext& gc);
  164.     virtual ~ FW_CSaveRestoreContext();
  165.  
  166. private:
  167.     FW_CGraphicContext&        fGC;
  168.     FW_SSuspendResumeState*    fSuspendResume;
  169. };
  170.  
  171. //========================================================================================
  172. //    Inlines
  173. //========================================================================================
  174.  
  175. //----------------------------------------------------------------------------------------
  176. //    FW_CGraphicContext::GetRasterizer
  177. //----------------------------------------------------------------------------------------
  178. inline FW_CRasterizer* FW_CGraphicContext::GetRasterizer() const
  179. {
  180.     return fRasterizer;
  181. }
  182.  
  183. //----------------------------------------------------------------------------------------
  184. //    FW_CGraphicContext::GetGraphicDevice
  185. //----------------------------------------------------------------------------------------
  186. inline FW_CGraphicDevice* FW_CGraphicContext::GetGraphicDevice() const
  187. {
  188.     return fGraphicDevice;
  189. }
  190.  
  191. //----------------------------------------------------------------------------------------
  192. //    FW_CGraphicContext::GetEnvironment
  193. //----------------------------------------------------------------------------------------
  194. inline Environment* FW_CGraphicContext::GetEnvironment() const
  195. {
  196.     return fEnvironment;
  197. }
  198.  
  199. #if FW_LIB_EXPORT_PRAGMAS
  200. #pragma lib_export off
  201. #endif
  202.  
  203. #endif
  204.