home *** CD-ROM | disk | FTP | other *** search
- #ifndef __CTickerControl_h__
- #define __CTickerControl_h__
-
- #include <QuickDraw.h>
- #include <QDOffscreen.h>
- #include <deque.h>
-
- #include "CBaseBindStatusCallback.h"
-
- class CTick;
- class CTickerError;
-
- ///////////////////////////////////////////////////////////////////////////////
- //
- // Things to make Intrinsic Control ported souRce compile
- //
- #define T2OLE(x) (x) // T2OLE not needed on Mac, which doesn't use Unicode
- #define LPTSTR char*
- #define TCHAR char
- #define _T(x) (x)
-
- ///////////////////////////////////////////////////////////////////////////////
- //
- // convenience items
- //
- #define streq(x,y) (!strcmp((x),(y)))
- #define NO_XRT_SUPPORT "WOSA/XRT\tDATA\nFORMAT\tNOT\nYET\tSUPPORTED...\n" // default
-
- /////////////////////////////////////////////////////////////////////////////
- //
- // Numeric constants
- //
-
- // Set user-definable defaults
- const short TICK_WIDTH = 1;
- const long SCROLL_INTERVAL = 1; // 60 ticks == 1 second
- const long RELOAD_INTERVAL = 3600; // 60 ticks == 1 second
-
- // other constants
-
- // the max que size is set large because we've optimized the CTick objects and
- // the usage thereof in CTickControl to require minimum memory. We don't keep
- // old renderings around in any offscreen bitmaps.
- const unsigned long QUEUE_SIZE = 0x7FFFFFFF; // not max because we still detect overflow
-
- // token used in parsing ticks. Logic depends on TICKTOKENS being a
- // concatenation of CRCHAR AND LFCHAR. Saw no need for anything more elegant.
- const char NAMEVALUETOKENS[] = "\t";
- const char TICKTOKENS[] = "\r\n"; // must be concatenation of CRCHAR and LFCHAR
- const char CRCHAR = '\r'; // <-- tied to TICKTOKENS
- const char LFCHAR = '\n'; // <-- tied to TICKTOKENS
-
- // Somewhat arbitrary
- const int MAX_URL_STRING_LENGTH = 1024;
-
- // data validation
- typedef enum tagDataValidation
- {
- dataUnconfirmed = 0,
- dataValid = 1,
- dataInvalid = 2
- } DataValidation;
-
- /////////////////////////////////////////////////////////////////////////////
- //
- // Dumb Structs
- //
-
- typedef struct
- {
- DateTimeRec time;
- unsigned long ticks;
- unsigned long idleValue;
- unsigned long idleAccumulator;
- Boolean changed;
- }
- Timer;
-
- typedef struct
- {
- Style textFace;
- short textFont;
- short textSize;
- short textMode;
- }
- FontParams;
-
- /////////////////////////////////////////////////////////////////////////////
- //
- // CTickerControl class definition
- //
-
- class CTickerControl :
- public CBaseControl,
- public CBaseBindStatusCallback,
- public CErrorControl
- {
- public:
-
- // *** CPictControl methods ***
- CTickerControl();
- ~CTickerControl();
-
- // *** IIUnknown methods ***
- STDMETHOD (QueryInterface)(REFIID inRefID, void** outObj);
-
- // *** IControl methods ***
- STDMETHOD (Draw) (THIS_ DrawContext* inContext);
- STDMETHOD (DoMouse)(THIS_ MouseEventType inMouseET, PlatformEvent* inEvent);
- STDMETHOD (DoIdle)(THIS_ Uint32 idleRefCon) ;
-
- // *** IPersistPropertyBag methods ***
- STDMETHOD(Load)(IPropertyBag* propertyBag, IErrorLog* errorLog);
- STDMETHOD(LoadTextState)(IPropertyBag * propertyBag, IErrorLog * errorLog);
-
- // *** IBindStatusCallback methods ***
- STDMETHOD(OnStopBinding)(HRESULT result, const char* error);
- STDMETHOD(OnDataAvailable)(DWORD BSCF, DWORD size, FORMATETC* formatEtc, STGMEDIUM* stgMedium);
-
- public: // accessors for CTick
- Boolean GetUserOffsetValues(void) { return mUserOffsetValues; }
- short GetOffsetValues(void) { return mOffsetValues; }
- void GetForeColor(RGBColor * theColor) { *theColor = mForeColor; }
- void GetBackColor(RGBColor * theColor) { *theColor = mBackColor; }
-
- friend CTickerError;
-
- protected:
- void OnNewTextData(void);
- void PrepareOffscreenWorld(void);
- void MoveTicker(short nMove);
- CTick * GetNextTick(void);
- void ClearDisplay(void);
- void MoveOnScreen(DrawContext* Context = NULL);
- Boolean LoadColor(RGBColor * theColor, char * colorString);
- Boolean IsXRT(FORMATETC* FormatEtc);
- Boolean SaveLeftOvers(char * theData);
- BitMap * GetOffscreenBitMap(void);
- void ReleaseOffscreenBitMap(BitMap * offscreenBitMap);
- void ReloadTicker(void);
- void BindToData(void);
- void ClearQueues(void);
- Boolean ContinueRead(void);
-
- protected: // user-adjustable parameters
- char mDataURL[MAX_URL_STRING_LENGTH]; // location of the data
- Boolean mDataActive; // use data? (do nothing otherwise)
- short mScrollWidth; // how big a chunk we scroll at a time
- long mScrollInterval; // the time between scrolling jumps (ticks)
- long mReloadInterval; // how long between data fetches (in ticks)
- RGBColor mForeColor; // foreground color specifier
- RGBColor mBackColor; // background color specifier
- short mOffsetValues; // how much (in pixels) we offset the value from the name.
- Boolean mUserOffsetValues; // did the user specify an offset value?
-
- protected: // internal variables
- long mBirthTime; // the time at which the control is born
- long mNextScrollTime; // the next point at which we scroll
- long mNextReloadTime; // the next point at which we reload data
- char * mData; // the textual data being displayed
- char * mDataTemp; // used for mData reallocation
- Boolean mBound; // bind status
- LPBINDHOST mBindSite; // site we bind to (duh)
- Boolean mFeedDown; // is the data feed down?
- GWorldPtr mOffscreenGWorld; // where all the drawing gets done
- short mGWorldPixelDepth; // how deep is the offscreen GWorld
- Rect mRectOffscreenBounds; // bounds of offscreen world
- CTabHandle mGWorldCTable; // color table for the offscreen GWorld
- GDHandle mGWorldAGDevice; // graphics device for the offscreen GWorld
- GWorldFlags mGWorldFlags; // flags for offscreen GWorld
- PixMapHandle mPixOffscreenPixMap; // pixmap of offscreen world
- deque<CTick*> mQNew; // CTick objects that have yet to be drawn
- deque<CTick*> mQCache; // CTick objects that have already been drawn once
- CTick* mOnstage; // Currently being drawn
- long mMaxCacheSize; // limit on number of ticks
- char * mCurrentLeftOvers; // any incomplete tick data from the last new data
- unsigned long mReadTillNow; // how much data we've actuall pulled from the stream
- Boolean mOffscreenWorldReady; // tells us when the offscreen gworld is set up
- Boolean mOffscreenImageReady; // tells us when we've got an offscreen image to move on screen
- Boolean mPurgeOnstage; // trash the current onstage tick when we load the next one
- DataValidation mDataValidation; // used to confirm valid data
- Boolean mIsIdling; // TRUE if we are idling
- };
-
- #endif // __CTickerControl_h__
-