#ifndef _c_Custom_TE_Drawing_h #define _c_Custom_TE_Drawing_h #include // =========================================================================== // cCustomTEDrawing.cpp Version 1.0 ©1998 Joakim Braun All rights reserved. // =========================================================================== // // CONTENTS: A base class for providing TextEdit custom drawing behavior. // Mainly handles installing and removing of draw hooks. // Subclass to provide actual drawing behavior. // HOW TO USE: Derive a class from cCustomTEDrawing. Override DrawProc() to provide // custom text drawing behavior. Attach the drawing object to a // multistyled TEHandle: // new cCustomTEDrawingDerivedClass(myTEHandle); // TextEdit will cause DrawProc() to be called whenever text needs to be drawn. // When deallocating the TEHandle, don't forget to deallocate your "drawing object", // a pointer to which is stored in the teRefCon field of the style handle: // TEStyleHandle styleH = ::TEGetStyleHandle(myTEHandle); // if(styleH){ // cCustomTEDrawingDerivedClass* theDrawer = (cCustomTEDrawingDerivedClass*)(*styleH)->teRefCon; // if(theDrawer) // delete theDrawer; // } // cCustomTEDrawing is free for any and all use. // Do not distribute modified source code under my name. // No support promised, no liability accepted. Provided "as is". // That said, I can be reached at braun@swipnet.se. // Latest version at http://home4.swipnet.se/~w-41308/ // Change history: // 1.0 September 10, 1998 First release class cCustomTEDrawing{ public: cCustomTEDrawing( void); cCustomTEDrawing( TEHandle theTEH); ~cCustomTEDrawing( void ); static void InstallHook(TEHandle theTEH, cCustomTEDrawing* theDrawer); static pascal void StaticTEDrawProc(void); static asm pascal void PrepareDrawProc(void); static asm pascal void CleanupDrawProc(void); static Uint16 CalcLineFromOffset(TEHandle theTEH, Uint16 offset); static Uint16 GetRealOffset(TEHandle theTEH, Uint16 fakeOffset); protected: TEHandle mTEH; DrawHookUPP mOldDrawHook, mNewDrawHook; virtual void DrawProc(void); virtual void CallDefaultDrawProc(void); static unsigned short sTextOffset, sDrawLen; static void* sTextBufferPtr; static TEPtr sPTE; static TEHandle sHTE; }; #endif