home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / PowerPlant / 3D Additions 1.7 / 3D Additions / 3DDrawingUtils.h < prev    next >
Encoding:
Text File  |  1995-10-09  |  9.5 KB  |  238 lines  |  [TEXT/CWIE]

  1. // ===========================================================================
  2. // 3DDrawingUtils.h      ©1995 J. Rodden, DD/MF & Associates. All rights reserved
  3. // ===========================================================================
  4. // C++ wrapper class for 3D drawing utilities.
  5. // Dependent on PPlant UDrawingUtils
  6. //
  7. // This class acts solely as a wrapper class for the lower level, ANSI C,
  8. // routines in 3DUtilities. This class takes care of drawing to different 
  9. // bit depths.
  10. //
  11. // This source code is loosely based on and heavily inspired by source code
  12. // by James W. Osborne, copyright (c) 1993, Apple Computer.
  13. //
  14. // In designing the API for this utility class I came upon an interesting
  15. // design delima: should the arguments be pointers (call-by-value) in order
  16. // to mimic the underlying C API for which this is merely a wrapper class,
  17. // or should the arguments be C++ style references (call-by-reference) in
  18. // order to mimic the C++ pseudo-standard (used in PowerPlant)? Initially
  19. // I went with the former choice, but found it a bit awkward to use the
  20. // more C "style" of notation for mutatable arguments (when, in fact, they
  21. // weren't being mutated after all). I later found this approach inconsistent
  22. // with the C++ "style" of hiding such details and using const declarations
  23. // and strict type checking to help the programmer. I finally caved in and
  24. // duplicated the API using both styles so I wouldn't hurt anyone used to the
  25. // older style. They're all inlined routines anyway so performance and code
  26. // size shouldn't be affected, but it makes for an interesting philosophical
  27. // debate in API design (at least I think it does :).
  28.  
  29.  
  30. #pragma once
  31.  
  32. #include <3DUtilities.h>
  33. #include <UDrawingUtils.h>
  34.  
  35. class LWindow;
  36.  
  37. // ===========================================================================
  38.  
  39. typedef void (*RectArgProc)(const Rect* inRect);
  40. typedef void (*Rect2RGBColorArgProc)
  41.              (const Rect* inRect, const RGBColor* inColor1, const RGBColor* inColor2);
  42. typedef void (*Rect2RGBColorBooleanArgProc)
  43.              (const Rect* inRect, const RGBColor* inColor1, const RGBColor* inColor2,
  44.               const Boolean inBoolean);
  45. typedef void (*Rect3RGBColorBooleanArgProc)
  46.              (const Rect* inRect, const RGBColor* inColor1, const RGBColor* inColor2,
  47.               const RGBColor* inColor3, const Boolean inBoolean);
  48. typedef void (*LineArgProc)(const short arg1, const short arg2, const short arg3);
  49.  
  50. // ===========================================================================
  51.  
  52. class St3DDeviceLoop : public StDeviceLoop {
  53. public:
  54.     St3DDeviceLoop(const Rect &inLocalRect);
  55.     
  56.     Boolean    Next();
  57.     Boolean    CurrentDeviceIsGrayscale();
  58.     Boolean    CurrentDeviceIs3DCapable();
  59.     Boolean    CurrentDeviceIsGrayCapable();
  60. };
  61.  
  62.  
  63. // ===========================================================================
  64.  
  65. class St3DPenState {
  66. public:
  67.     St3DPenState();
  68.     ~St3DPenState();
  69.  
  70. private:
  71.     PenState mPenState;
  72. };
  73.  
  74.  
  75. // ===========================================================================
  76.  
  77. class    U3DDrawingUtils {
  78. public:
  79.     static void MakeWindow3D(LWindow* inWindow);
  80.     static void Paint3DBkgnd(const Rect* inRect);
  81.  
  82.     static void Get3DBackColor( RGBColor* outBkgndColor);
  83.     static void Get3DLightColor( RGBColor* outLightColor);
  84.     static void Get3DShadowColor( RGBColor* outShadowColor);
  85.     static void Get3DPenState( PenState* outPnState);
  86.  
  87.     static void Set3DBackColor(const RGBColor* inBkgndColor);
  88.     static void Set3DLightColor(const RGBColor* inLightColor);
  89.     static void Set3DShadowColor(const RGBColor* inShadowColor);
  90.     static void Set3DPenState(const PenState* inPnState);
  91.  
  92.     static void    Draw3DInsetOvalPanel(const Rect* inRect);
  93.     static void    Draw3DRaisedOvalPanel(const Rect* inRect);
  94.  
  95.     static void    Draw3DInsetOvalBorder(const Rect* inRect);
  96.     static void    Draw3DRaisedOvalBorder(const Rect* inRect);
  97.  
  98.     static void    Draw3DInsetOvalFrame(const Rect* inRect);
  99.     static void    Draw3DRaisedOvalFrame(const Rect* inRect);
  100.  
  101.     static void Draw3DInsetPanel(const Rect* inRect);
  102.     static void Draw3DRaisedPanel(const Rect* inRect);
  103.  
  104.     static void Draw3DInsetBorder(const Rect* inRect);
  105.     static void Draw3DRaisedBorder(const Rect* inRect);
  106.  
  107.     static void Draw3DInsetFrame(const Rect* inRect);
  108.     static void Draw3DRaisedFrame(const Rect* inRect);
  109.  
  110.     static void Draw3DInsetHLine(const short vpos, const short h1, const short h2);
  111.     static void Draw3DInsetVLine(const short hpos, const short v1, const short v2);
  112.  
  113.     static void Draw3DRaisedHLine(const short vpos, const short h1, const short h2);
  114.     static void Draw3DRaisedVLine(const short hpos, const short v1, const short v2);
  115.     
  116.     
  117.     static void    Draw3DOvalPanel(const Rect* inRect, const RGBColor* inBKColor,
  118.                                 const RGBColor* inULColor, const RGBColor* inLRColor,
  119.                                 const Boolean inFrameIt);
  120.  
  121.     static void    Draw3DOvalBorder(const Rect* inRect, const RGBColor* inULColor,
  122.                                  const RGBColor* inLRColor, const Boolean inFrameIt);
  123.  
  124.     static void    Draw3DOvalFrame(const Rect* inRect, const RGBColor* inULColor,
  125.                                 const RGBColor* inLRColor);
  126.  
  127.     static void    Draw3DPanel (const Rect* inRect, const RGBColor* inBKColor,
  128.                              const RGBColor* inULColor, const RGBColor* inLRColor,
  129.                              const Boolean inFrameIt);
  130.  
  131.     static void    Draw3DBorder(const Rect* inRect, const RGBColor* inULColor,
  132.                              const RGBColor* inLRColor, const Boolean inFrameIt);
  133.  
  134.     static void    Draw3DFrame (const Rect* inRect, const RGBColor* inULColor,
  135.                              const RGBColor* inLRColor);
  136.  
  137.     static void    Draw3DHLine (const short vpos, const short h1, const short h2,
  138.                              const RGBColor* inULColor, const RGBColor* inLRColor);
  139.                      
  140.     static void    Draw3DVLine    (const short hpos, const short v1, const short v2,
  141.                              const RGBColor* inULColor, const RGBColor* inLRColor);
  142.  
  143.     static void    DrawCLine    (const RGBColor* inColor, short h1, short v1, short h2, short v2);
  144.     static void    CLineTo        (const RGBColor* inColor, short h, short v);
  145.  
  146.     // -----------------------------------------------------
  147.     // Routines to make sure you don't have to worry about
  148.     // passing by value or by reference. To be more C++ish.
  149.     
  150.     static void Paint3DBkgnd(const Rect& inRect)    { Paint3DBkgnd(&inRect); }
  151.     static void MakeWindow3D(LWindow& inWindow)        { MakeWindow3D(&inWindow); }
  152.  
  153.     static void Get3DBackColor(RGBColor& outBkgndColor);
  154.     static void Get3DLightColor(RGBColor& outLightColor);
  155.     static void Get3DShadowColor(RGBColor& outShadowColor);
  156.     static void Get3DPenState(PenState& outPnState);
  157.  
  158.     static void Set3DBackColor(const RGBColor& inBkgndColor);
  159.     static void Set3DLightColor(const RGBColor& inLightColor);
  160.     static void Set3DShadowColor(const RGBColor& inShadowColor);
  161.     static void Set3DPenState(const PenState& inPnState);
  162.  
  163.     static void    Draw3DInsetOvalPanel(const Rect& inRect);
  164.     static void    Draw3DRaisedOvalPanel(const Rect& inRect);
  165.  
  166.     static void    Draw3DInsetOvalBorder(const Rect& inRect);
  167.     static void    Draw3DRaisedOvalBorder(const Rect& inRect);
  168.  
  169.     static void    Draw3DInsetOvalFrame(const Rect& inRect);
  170.     static void    Draw3DRaisedOvalFrame(const Rect& inRect);
  171.  
  172.     static void Draw3DInsetPanel(const Rect& inRect);
  173.     static void Draw3DRaisedPanel(const Rect& inRect);
  174.  
  175.     static void Draw3DInsetBorder(const Rect& inRect);
  176.     static void Draw3DRaisedBorder(const Rect& inRect);
  177.  
  178.     static void Draw3DInsetFrame(const Rect& inRect);
  179.     static void Draw3DRaisedFrame(const Rect& inRect);
  180.     
  181.     static void    Draw3DOvalPanel(const Rect& inRect, const RGBColor& inBKColor,
  182.                                 const RGBColor& inULColor, const RGBColor& inLRColor,
  183.                                 const Boolean inFrameIt);
  184.  
  185.     static void    Draw3DOvalBorder(const Rect& inRect, const RGBColor& inULColor,
  186.                                  const RGBColor& inLRColor, const Boolean inFrameIt);
  187.  
  188.     static void    Draw3DOvalFrame(const Rect& inRect, const RGBColor& inULColor,
  189.                                 const RGBColor& inLRColor);
  190.  
  191.     static void    Draw3DPanel (const Rect& inRect, const RGBColor& inBKColor,
  192.                              const RGBColor& inULColor, const RGBColor& inLRColor,
  193.                              const Boolean inFrameIt);
  194.  
  195.     static void    Draw3DBorder(const Rect& inRect, const RGBColor& inULColor,
  196.                              const RGBColor& inLRColor, const Boolean inFrameIt);
  197.  
  198.     static void    Draw3DFrame (const Rect& inRect, const RGBColor& inULColor,
  199.                              const RGBColor& inLRColor);
  200.  
  201.     static void    Draw3DHLine (const short vpos, const short h1, const short h2,
  202.                              const RGBColor& inULColor, const RGBColor& inLRColor);
  203.                      
  204.     static void    Draw3DVLine    (const short hpos, const short v1, const short v2,
  205.                              const RGBColor& inULColor, const RGBColor& inLRColor);
  206.  
  207.     static void    DrawCLine    (const RGBColor& inColor, short h1, short v1, short h2, short v2);
  208.     static void    CLineTo        (const RGBColor& inColor, short h, short v);
  209.  
  210.  
  211. private:
  212.     static void DoDeviceLoop( RectArgProc Draw3DEffect,
  213.                               RectArgProc DrawPlainEffect, const Rect* inRect);
  214.                               
  215.     static void DoDeviceLoop( Rect2RGBColorArgProc Draw3DEffect,
  216.                               RectArgProc DrawPlainEffect, const Rect* inRect,
  217.                               const RGBColor* inColor1, const RGBColor* inColor2);
  218.                               
  219.     static void DoDeviceLoop( Rect2RGBColorBooleanArgProc Draw3DEffect,
  220.                               RectArgProc DrawPlainEffect, const Rect* inRect,
  221.                               const RGBColor* inColor1, const RGBColor* inColor2,
  222.                               const Boolean inFrameIt);
  223.                               
  224.     static void DoDeviceLoop( Rect3RGBColorBooleanArgProc Draw3DEffect,
  225.                               RectArgProc DrawPlainEffect, const Rect* inRect,
  226.                               const RGBColor* inColor1, const RGBColor* inColor2,
  227.                               const RGBColor* inColor3, const Boolean inFrameIt);
  228.                               
  229.     static void DoDeviceLoopHLine( LineArgProc Draw3DEffect, const short vpos,
  230.                                     const short h1, const short h2);
  231.     static void DoDeviceLoopVLine( LineArgProc Draw3DEffect, const short hpos,
  232.                                     const short v1, const short v2);
  233.                               
  234.     static void DoFrameOval(const Rect* inRect);
  235.     static void DoFrameRect(const Rect* inRect);
  236. };
  237.  
  238. #include <3DDrawingUtils.inline.cp>