home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1994 November: Tool Chest / Dev.CD Nov 94.toast / New System Software Extensions / OpenDoc A6 / OpenDoc Parts Framework / OPF / Examples / Text / Textension / Include / QDTextRun.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-21  |  4.5 KB  |  156 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        QDTextRun.h
  3.  
  4.     Contains:    xxx put contents here xxx
  5.  
  6.     Written by:    Essam Zaky
  7.  
  8.     Copyright:    © 1994 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <2>      1/4/94    EZ        clean up
  13.          <1>      1/4/94    EZ        first checked in
  14.  
  15. */
  16.  
  17. #ifndef _QDTextRun_
  18. #define _QDTextRun_
  19.  
  20. #ifndef _ToolBoxDump_
  21. #include "ToolBoxDump.h"
  22. #endif
  23.  
  24. #ifndef _RunObject_
  25. #include "RunObject.h"
  26. #endif
  27.  
  28. #ifndef _Array_
  29. #include "Array.h"
  30. #endif
  31.  
  32. #ifndef _Streams_
  33. #include "Streams.h"
  34. #endif
  35.  
  36. //***************************************************************************************************
  37.  
  38. #ifdef txtnScal
  39. const ClassId kQDTextRunClassId = 'QDT+'; //scal factor are written to stream
  40. #else
  41. const ClassId kQDTextRunClassId = 'QDTx';
  42. #endif
  43.  
  44. const AttrId kFontAttr = 'font';
  45. const AttrId kSizeAttr = 'size';
  46. const AttrId kFaceAttr = 'face';
  47. const AttrId kForeColorAttr = 'klor';
  48.  
  49. //constants for message to UpdateAttribute
  50. const long kForceScriptModif = 1; //for font
  51. const long kAddSize = 2;
  52.  
  53. const long kToggleFace = 4;
  54. const long kAddFace = 8;
  55. const long kRemoveFace = 16;
  56. /*a face can be added and another removed if updateMessage has both kAddFace and kRemoveFace set.
  57. This is only possible if CAttrObj::Update is called by attr and not by obj, since in this caller can a ptr
  58. to the following type:
  59. */
  60. struct TAdd_RemoveFaces {
  61.     long face2Add;
  62.     long face2Remove;
  63. };
  64. typedef TAdd_RemoveFaces* TAdd_RemoveFacesPtr;
  65. //***************************************************************************************************
  66.  
  67. Fixed StdTxFixedMeas(short byteCount,const void *textAddr, Point numer, Point denom);
  68.  
  69. //***************************************************************************************************
  70.  
  71. class    CQDTextRun    :    public CRunObject {
  72.     public:
  73.         CQDTextRun();
  74.         
  75.         void    IQDTextRun();
  76.         virtual CAttrObject* CreateNew() const;
  77.         
  78.         virtual ClassId GetClassId() const;
  79.         
  80.         Boolean IsTextRun() const;
  81.         
  82.         virtual void GetAttrIDs(short* countAttr, AttrId* attrArray) const;
  83.         
  84.         virtual char GetRunDir() const;
  85.         virtual Boolean Is2Bytes() const;
  86.         virtual char GetRunScript() const;
  87.         virtual void SetKeyScript() const;
  88.         
  89.         virtual void SaveRunEnv();
  90.         #ifdef txtnScal
  91.         virtual void SetRunEnv(SetRunEnvPb* paramPb) const;
  92.         #else
  93.         virtual void SetRunEnv() const;
  94.         #endif
  95.         
  96.         virtual void SetDefaults(long message = 0);
  97.     
  98.         virtual Boolean FilterControlChar(uchar theKey) const;
  99.  
  100.         virtual void DoPixel2Char(Pixel2CharPb* paramPb);
  101.         virtual short DoChar2Pixel(Char2PixelPb* paramPb);
  102.         virtual void DoDrawJust(DrawJustPb* paramPb);
  103.         
  104.         #ifdef txtnRulers
  105.         virtual Fixed DoFullJustifPortion(FullJustPortionPb* paramPb);
  106.         #endif
  107.         
  108.         virtual Fixed DoMeasure(MeasurePb* paramPb);
  109.         virtual StyledLineBreakCode DoBreak(LineBreakPb* paramPb);
  110.  
  111.         virtual void SetCursor(Point, const RunPositionPB*) const; //set it to ibeam
  112.         
  113.         virtual OSErr WriteToStream(CStream* outputStream);
  114.         virtual OSErr ReadFromStream(CStream* inputStream);
  115.         
  116.     protected:
  117.         char            fScript;
  118.         short            fFont;
  119.         long            fFace;
  120.         RGBColor    fForeColor;    
  121.         
  122.         /*the lowest byte is reserved for the QD Style (bold, italic, ...), descendents can add more faces*/
  123.         char fDirection;
  124.         Boolean f2Bytes;
  125.         short            fSize;
  126.  
  127.         virtual long GetFaceAttrFlags(long theFace) const;
  128.         
  129.         virtual long GetAttrFlags(AttrId theAttr, const void* attrBuffer, long updateMessage =0) const;
  130.         /*•note that attrBuffer may be nil, in this case descendents should return a value based only
  131.         on the AttrId.
  132.         */
  133.  
  134.         virtual void CalcHiteInfo(short* ascent, short* descent, short* leading); //override
  135.         
  136.         virtual Boolean EqualAttribute(AttrId theAttr, const void* valToCheck) const;
  137.         //override, •any descendent should override, otherwise the result is always false
  138.         
  139.         virtual Boolean SetCommonAttribute(AttrId theAttr, const void* val2Check); //override
  140.         virtual void AttributeToBuffer(AttrId theAttr, void* attrBuffer) const; //override
  141.         virtual void BufferToAttribute(AttrId theAttr, const void* attrBuffer); //override
  142.         virtual void UpdateAttribute(AttrId theAttr, const void* srcAttr, long updateMessage
  143.                                                                 , const void* continuousAttr = nil); //override
  144.         //continuousAttr is used only if fFlags has the kToggleFace set
  145.  
  146.         virtual void AddFace(long face2Add, long* destFace);
  147.         /*normally the result is (face2Add | destFace), but this methode is the place to check for exclusif faces
  148.         (eg superScript-subScript, condensed-extended)
  149.         */
  150.         
  151.         void RemoveFace(long face2Remove, long *destFace) const;
  152. };
  153. //***************************************************************************************************
  154.  
  155. #endif
  156.