home *** CD-ROM | disk | FTP | other *** search
- #ifndef __CLabelControl_h__
- #define __CLabelControl_h__
-
- #include <QuickDraw.h>
- #include <QDOffscreen.h>
- #include <fp.h>
- #include "CBaseBindStatusCallback.h"
-
- class CLabelError;
- class CBaseControl;
-
-
- ///////////////////////////////////////////////////////////////////////////////
- //
- // convenience items
- //
- #define streq(x,y) (!strcmp((x),(y)))
-
- /////////////////////////////////////////////////////////////////////////////
- //
- // Constants
- //
-
- // Somewhat arbitrary
- const int MAX_PROPERTY_STRING_LENGTH = 1023;
- const int MAX_CAPTION_STRING_LENGTH = 255;
- const int MAX_FONTNAME_LENGTH = 127;
- const short NUM_CONNECTIONS = 1; // This control only has one connection point
- const short twoHundredFiftySixColorsDepth = 8;
- const short fullRevolution = 360; // full revolution
- const short quarterRevolution = 90; // quarter revolution
-
- /////////////////////////////////////////////////////////////////////////////
- //
- // Structs
- //
-
- typedef struct
- {
- Style textFace;
- short textFont;
- short textSize;
- short textMode;
- }
- FontParams;
-
- /////////////////////////////////////////////////////////////////////////////
- //
- // CLabelControl class definition
- //
-
- class CLabelControl :
- public CBaseControl,
- public CBaseBindStatusCallback,
- public CErrorControl
- {
-
- public:
- // *** construct/destruct methods ***
- CLabelControl();
- ~CLabelControl();
-
- // *** IIUnknown methods ***
- STDMETHOD(QueryInterface)(REFIID inRefID, void** outObj);
- STDMETHOD_(ULONG,AddRef)(THIS) {return CBaseControl::AddRef();}
- STDMETHOD_(ULONG,Release)(THIS) {return CBaseControl::Release();}
-
- // *** IControl methods ***
- STDMETHOD(Draw) (THIS_ DrawContext* Context);
- STDMETHOD(DoMouse)(THIS_ MouseEventType inMouseET, PlatformEvent* inEvent);
-
- // *** IPersistPropertyBag methods ***
- STDMETHOD(Load)(IPropertyBag* PropBag, IErrorLog* ErrorLog);
- STDMETHOD(LoadTextState)(IPropertyBag *PropertyBag, IErrorLog *ErrorLog);
-
- // *** Event sending ***
- STDMETHOD(FireEvent)(REFIID RefID, long EventID, PlatformEvent* Event);
- STDMETHOD(FireOneEvent)(REFIID /*RefID*/, long EventID, IUnknown* EventTarget, EventRecord* Event);
-
- friend CLabelError;
-
- protected:
- void PrepareOffscreenWorld(const DrawContext* Context = nil);
- void MoveOnScreen(const BitMap* offscreenBitMap, const DrawContext* Context = nil);
- void ClearDisplay(void);
- Boolean LoadColor(RGBColor* theColor, char* colorString);
- BitMap* GetOffscreenBitMap(void);
- void ReleaseOffscreenBitMap(BitMap* offscreenBitMap);
-
- private:
- void SetFontParams(GWorldPtr theGWorld);
- void GetTextSize(const StringPtr aString, Point* textSize);
- void RenderLabelControl(void);
- double DegressToRadians(double angDegrees) { return (angDegrees / 180.0) * pi;}
- Point RotatedSize(const double angDegrees, const Point origSize);
- QDErr CreateContent(Point* textSize, GWorldPtr &contentGWorld);
- void ComputeAlignmentRect(Rect &theContentRect, const Rect theLabelRect);
- QDErr Rotate90( const GWorldPtr inputGWorld, GWorldPtr &rotate90GWorld );
-
- protected: // user-defineable parameters
- short mAngle; // caption rotation angle (CCW 0 >= angle >= 360)
- short mAlignment; // 0..8 how to align text in control - see property desc
- short mBackStyle; // 0..1 background property trans/opaque - see property desc
- RGBColor mBackColor; // background color specifier
- char mCaption[MAX_CAPTION_STRING_LENGTH];// the text in the button
- char mFontName[MAX_FONTNAME_LENGTH]; // the font name to use for drawing
- Boolean mFontBold; // flag for bold
- Boolean mFontItalic; // flag for italic
- Boolean mFontUnderline; // flag for underline
- Boolean mFontStrikeout; // flag for strikeout
- short mFontSize; // size of the font in pixels
- RGBColor mForeColor; // foreground color specifier
- short mMode; // 0..3 mode text will be rendered in - see property desc
- short mRotateBy; // angle to rotate by when clicked
-
- private: // for our use internally:
- FontInfo mFontInfo; // fontinfo for the current font
- GWorldPtr mMainOffscreenGWorld; // where all the drawing gets done
- PixMapHandle mPixOffscreenPixMap; // pixmap of offscreen world
- Rect mRectOffscreenBounds; // bounds of offscreen world
- };
-
- #endif // __CLabelControl_h__
-
- // end-of-file
-
-