home *** CD-ROM | disk | FTP | other *** search
/ ...taking it to the Macs! / ...taking it to the Macs!.iso / Extras / ActiveX Mac SDK / ActiveX SDK / Sample Controls / Gradient / CGradientControl.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-12-20  |  3.2 KB  |  120 lines  |  [TEXT/CWIE]

  1. #ifndef __CGradientControl_h__
  2. #define __CGradientControl_h__
  3.  
  4. #include <QuickDraw.h>
  5. #include <QDOffscreen.h>
  6. #include <fp.h>
  7. #include "CBaseBindStatusCallback.h"
  8.  
  9. //class CTick;
  10. class CGradientError;
  11. class CBaseControl;
  12.  
  13. ///////////////////////////////////////////////////////////////////////////////
  14. //
  15. //    convenience items
  16. //
  17.  
  18. #define streq(x,y) (!strcmp((x),(y)))
  19.  
  20. /////////////////////////////////////////////////////////////////////////////
  21. //
  22. // Constants
  23. //
  24.  
  25. const Rect gZeroRect                        = { 0, 0, 0, 0 };    // a nil rect
  26. const Point gZeroPoint                         = { 0, 0 };            // a nil point
  27. const unsigned short maxRGBComponentValue     = 65535;            // the max value that an RGB component can hold
  28. const short    thousandsOfColorsDepth             = 16;
  29. const short    millionsOfColorsDepth             = 32;
  30. const int    maxPropertyStringLength         = 1023;                // Somewhat arbitrary
  31.  
  32. // an enumerated type to define the property - direction of the gradient
  33. typedef enum
  34. {
  35.     Horizontal = 0,
  36.     Vertical = 1,
  37.     BothHV = 2,
  38.     Corner = 3,
  39.     DiagDn = 4,
  40.     DiagUp = 5,
  41.     PointBased = 6,
  42.     LineBased = 7
  43. } enumDirection;
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. //
  47. // Structs
  48. //
  49.  
  50. typedef struct
  51. {
  52.     Style    textFace;
  53.     short    textFont;
  54.     short    textSize;
  55.     short    textMode;
  56. }
  57. FontParams;
  58.  
  59. /////////////////////////////////////////////////////////////////////////////
  60. //
  61. // CGradientControl class definition
  62. //
  63.  
  64. class CGradientControl : 
  65.     public CBaseControl, 
  66.     public CBaseBindStatusCallback, 
  67.     public CErrorControl
  68. {
  69.  
  70. public:
  71.     // *** construct/destruct methods ***
  72.     CGradientControl();
  73.     ~CGradientControl();
  74.  
  75.     // *** IIUnknown methods ***
  76.     STDMETHOD (QueryInterface)(REFIID inRefID, void** outObj);
  77.  
  78.     // *** IControl methods ***
  79.     STDMETHOD(Draw) (THIS_ DrawContext* Context);
  80.  
  81.     //  *** IPersistPropertyBag methods ***
  82.     STDMETHOD(Load)(IPropertyBag* PropBag, IErrorLog* ErrorLog);
  83.     STDMETHOD(LoadTextState)(IPropertyBag *PropertyBag, IErrorLog *ErrorLog);
  84.     
  85. friend CGradientError;
  86.     
  87. protected:
  88.     void PrepareOffscreenWorld(const DrawContext* Context = nil);
  89.     void MoveOnScreen(const BitMap* offscreenBitMap, const DrawContext* Context = nil);
  90.     void ClearDisplay(void);
  91.     Boolean LoadColor(RGBColor* theColor, char* colorString);
  92.     BitMap* GetOffscreenBitMap(void);
  93.     void ReleaseOffscreenBitMap(BitMap* offscreenBitMap);
  94.  
  95. private:    
  96.     void RenderGradientControl(const Rect contentRect);
  97.     double DegressToRadians(double angDegrees) { return (angDegrees / 180.0) * pi;}
  98.     Point RotatedSize(const double angDegrees, const Point origSize);
  99.     QDErr CreateContent(const Rect contentRect, GWorldPtr &contentGWorld);
  100.     
  101. protected: // user-defineable parameters
  102.     short            mAngle;                    //%BD+jdo should this be a float or fixed???
  103.     RGBColor        mEndColor;                // end of gradient color specifier
  104.     enumDirection    mDirection;                // 0..7 direction of gradient in control - see property desc
  105.     RGBColor        mStartColor;            // start of gradient color specifier
  106. #if defined (start_end_point)
  107.     Point            mStartPoint;
  108.     Point            mEndPoint;
  109. #endif
  110.  
  111. private:    // for our use internally:
  112.     GWorldPtr        mMainOffscreenGWorld;    // where all the drawing gets done
  113.     PixMapHandle    mPixOffscreenPixMap;    // pixmap of offscreen world
  114.     Rect            mRectOffscreenBounds;    // bounds of offscreen world
  115. };
  116.  
  117. #endif // __CGradientControl_h__
  118.  
  119. // end-of-file
  120.