home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-09 | 9.5 KB | 238 lines | [TEXT/CWIE] |
- // ===========================================================================
- // 3DDrawingUtils.h ©1995 J. Rodden, DD/MF & Associates. All rights reserved
- // ===========================================================================
- // C++ wrapper class for 3D drawing utilities.
- // Dependent on PPlant UDrawingUtils
- //
- // This class acts solely as a wrapper class for the lower level, ANSI C,
- // routines in 3DUtilities. This class takes care of drawing to different
- // bit depths.
- //
- // This source code is loosely based on and heavily inspired by source code
- // by James W. Osborne, copyright (c) 1993, Apple Computer.
- //
- // In designing the API for this utility class I came upon an interesting
- // design delima: should the arguments be pointers (call-by-value) in order
- // to mimic the underlying C API for which this is merely a wrapper class,
- // or should the arguments be C++ style references (call-by-reference) in
- // order to mimic the C++ pseudo-standard (used in PowerPlant)? Initially
- // I went with the former choice, but found it a bit awkward to use the
- // more C "style" of notation for mutatable arguments (when, in fact, they
- // weren't being mutated after all). I later found this approach inconsistent
- // with the C++ "style" of hiding such details and using const declarations
- // and strict type checking to help the programmer. I finally caved in and
- // duplicated the API using both styles so I wouldn't hurt anyone used to the
- // older style. They're all inlined routines anyway so performance and code
- // size shouldn't be affected, but it makes for an interesting philosophical
- // debate in API design (at least I think it does :).
-
-
- #pragma once
-
- #include <3DUtilities.h>
- #include <UDrawingUtils.h>
-
- class LWindow;
-
- // ===========================================================================
-
- typedef void (*RectArgProc)(const Rect* inRect);
- typedef void (*Rect2RGBColorArgProc)
- (const Rect* inRect, const RGBColor* inColor1, const RGBColor* inColor2);
- typedef void (*Rect2RGBColorBooleanArgProc)
- (const Rect* inRect, const RGBColor* inColor1, const RGBColor* inColor2,
- const Boolean inBoolean);
- typedef void (*Rect3RGBColorBooleanArgProc)
- (const Rect* inRect, const RGBColor* inColor1, const RGBColor* inColor2,
- const RGBColor* inColor3, const Boolean inBoolean);
- typedef void (*LineArgProc)(const short arg1, const short arg2, const short arg3);
-
- // ===========================================================================
-
- class St3DDeviceLoop : public StDeviceLoop {
- public:
- St3DDeviceLoop(const Rect &inLocalRect);
-
- Boolean Next();
- Boolean CurrentDeviceIsGrayscale();
- Boolean CurrentDeviceIs3DCapable();
- Boolean CurrentDeviceIsGrayCapable();
- };
-
-
- // ===========================================================================
-
- class St3DPenState {
- public:
- St3DPenState();
- ~St3DPenState();
-
- private:
- PenState mPenState;
- };
-
-
- // ===========================================================================
-
- class U3DDrawingUtils {
- public:
- static void MakeWindow3D(LWindow* inWindow);
- static void Paint3DBkgnd(const Rect* inRect);
-
- static void Get3DBackColor( RGBColor* outBkgndColor);
- static void Get3DLightColor( RGBColor* outLightColor);
- static void Get3DShadowColor( RGBColor* outShadowColor);
- static void Get3DPenState( PenState* outPnState);
-
- static void Set3DBackColor(const RGBColor* inBkgndColor);
- static void Set3DLightColor(const RGBColor* inLightColor);
- static void Set3DShadowColor(const RGBColor* inShadowColor);
- static void Set3DPenState(const PenState* inPnState);
-
- static void Draw3DInsetOvalPanel(const Rect* inRect);
- static void Draw3DRaisedOvalPanel(const Rect* inRect);
-
- static void Draw3DInsetOvalBorder(const Rect* inRect);
- static void Draw3DRaisedOvalBorder(const Rect* inRect);
-
- static void Draw3DInsetOvalFrame(const Rect* inRect);
- static void Draw3DRaisedOvalFrame(const Rect* inRect);
-
- static void Draw3DInsetPanel(const Rect* inRect);
- static void Draw3DRaisedPanel(const Rect* inRect);
-
- static void Draw3DInsetBorder(const Rect* inRect);
- static void Draw3DRaisedBorder(const Rect* inRect);
-
- static void Draw3DInsetFrame(const Rect* inRect);
- static void Draw3DRaisedFrame(const Rect* inRect);
-
- static void Draw3DInsetHLine(const short vpos, const short h1, const short h2);
- static void Draw3DInsetVLine(const short hpos, const short v1, const short v2);
-
- static void Draw3DRaisedHLine(const short vpos, const short h1, const short h2);
- static void Draw3DRaisedVLine(const short hpos, const short v1, const short v2);
-
-
- static void Draw3DOvalPanel(const Rect* inRect, const RGBColor* inBKColor,
- const RGBColor* inULColor, const RGBColor* inLRColor,
- const Boolean inFrameIt);
-
- static void Draw3DOvalBorder(const Rect* inRect, const RGBColor* inULColor,
- const RGBColor* inLRColor, const Boolean inFrameIt);
-
- static void Draw3DOvalFrame(const Rect* inRect, const RGBColor* inULColor,
- const RGBColor* inLRColor);
-
- static void Draw3DPanel (const Rect* inRect, const RGBColor* inBKColor,
- const RGBColor* inULColor, const RGBColor* inLRColor,
- const Boolean inFrameIt);
-
- static void Draw3DBorder(const Rect* inRect, const RGBColor* inULColor,
- const RGBColor* inLRColor, const Boolean inFrameIt);
-
- static void Draw3DFrame (const Rect* inRect, const RGBColor* inULColor,
- const RGBColor* inLRColor);
-
- static void Draw3DHLine (const short vpos, const short h1, const short h2,
- const RGBColor* inULColor, const RGBColor* inLRColor);
-
- static void Draw3DVLine (const short hpos, const short v1, const short v2,
- const RGBColor* inULColor, const RGBColor* inLRColor);
-
- static void DrawCLine (const RGBColor* inColor, short h1, short v1, short h2, short v2);
- static void CLineTo (const RGBColor* inColor, short h, short v);
-
- // -----------------------------------------------------
- // Routines to make sure you don't have to worry about
- // passing by value or by reference. To be more C++ish.
-
- static void Paint3DBkgnd(const Rect& inRect) { Paint3DBkgnd(&inRect); }
- static void MakeWindow3D(LWindow& inWindow) { MakeWindow3D(&inWindow); }
-
- static void Get3DBackColor(RGBColor& outBkgndColor);
- static void Get3DLightColor(RGBColor& outLightColor);
- static void Get3DShadowColor(RGBColor& outShadowColor);
- static void Get3DPenState(PenState& outPnState);
-
- static void Set3DBackColor(const RGBColor& inBkgndColor);
- static void Set3DLightColor(const RGBColor& inLightColor);
- static void Set3DShadowColor(const RGBColor& inShadowColor);
- static void Set3DPenState(const PenState& inPnState);
-
- static void Draw3DInsetOvalPanel(const Rect& inRect);
- static void Draw3DRaisedOvalPanel(const Rect& inRect);
-
- static void Draw3DInsetOvalBorder(const Rect& inRect);
- static void Draw3DRaisedOvalBorder(const Rect& inRect);
-
- static void Draw3DInsetOvalFrame(const Rect& inRect);
- static void Draw3DRaisedOvalFrame(const Rect& inRect);
-
- static void Draw3DInsetPanel(const Rect& inRect);
- static void Draw3DRaisedPanel(const Rect& inRect);
-
- static void Draw3DInsetBorder(const Rect& inRect);
- static void Draw3DRaisedBorder(const Rect& inRect);
-
- static void Draw3DInsetFrame(const Rect& inRect);
- static void Draw3DRaisedFrame(const Rect& inRect);
-
- static void Draw3DOvalPanel(const Rect& inRect, const RGBColor& inBKColor,
- const RGBColor& inULColor, const RGBColor& inLRColor,
- const Boolean inFrameIt);
-
- static void Draw3DOvalBorder(const Rect& inRect, const RGBColor& inULColor,
- const RGBColor& inLRColor, const Boolean inFrameIt);
-
- static void Draw3DOvalFrame(const Rect& inRect, const RGBColor& inULColor,
- const RGBColor& inLRColor);
-
- static void Draw3DPanel (const Rect& inRect, const RGBColor& inBKColor,
- const RGBColor& inULColor, const RGBColor& inLRColor,
- const Boolean inFrameIt);
-
- static void Draw3DBorder(const Rect& inRect, const RGBColor& inULColor,
- const RGBColor& inLRColor, const Boolean inFrameIt);
-
- static void Draw3DFrame (const Rect& inRect, const RGBColor& inULColor,
- const RGBColor& inLRColor);
-
- static void Draw3DHLine (const short vpos, const short h1, const short h2,
- const RGBColor& inULColor, const RGBColor& inLRColor);
-
- static void Draw3DVLine (const short hpos, const short v1, const short v2,
- const RGBColor& inULColor, const RGBColor& inLRColor);
-
- static void DrawCLine (const RGBColor& inColor, short h1, short v1, short h2, short v2);
- static void CLineTo (const RGBColor& inColor, short h, short v);
-
-
- private:
- static void DoDeviceLoop( RectArgProc Draw3DEffect,
- RectArgProc DrawPlainEffect, const Rect* inRect);
-
- static void DoDeviceLoop( Rect2RGBColorArgProc Draw3DEffect,
- RectArgProc DrawPlainEffect, const Rect* inRect,
- const RGBColor* inColor1, const RGBColor* inColor2);
-
- static void DoDeviceLoop( Rect2RGBColorBooleanArgProc Draw3DEffect,
- RectArgProc DrawPlainEffect, const Rect* inRect,
- const RGBColor* inColor1, const RGBColor* inColor2,
- const Boolean inFrameIt);
-
- static void DoDeviceLoop( Rect3RGBColorBooleanArgProc Draw3DEffect,
- RectArgProc DrawPlainEffect, const Rect* inRect,
- const RGBColor* inColor1, const RGBColor* inColor2,
- const RGBColor* inColor3, const Boolean inFrameIt);
-
- static void DoDeviceLoopHLine( LineArgProc Draw3DEffect, const short vpos,
- const short h1, const short h2);
- static void DoDeviceLoopVLine( LineArgProc Draw3DEffect, const short hpos,
- const short v1, const short v2);
-
- static void DoFrameOval(const Rect* inRect);
- static void DoFrameRect(const Rect* inRect);
- };
-
- #include <3DDrawingUtils.inline.cp>