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 / Line.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-21  |  3.9 KB  |  174 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        Line.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.  
  18. #ifndef _Line_
  19. #define _Line_
  20.  
  21. #ifndef _ToolBoxDump_
  22. #include "ToolBoxDump.h"
  23. #endif
  24.  
  25. #ifndef _TextensionCommon_
  26. #include "TextensionCommon.h"
  27. #endif
  28.  
  29. #ifndef _Array_
  30. #include "Array.h"
  31. #endif
  32.  
  33. #ifndef _StyledText_
  34. #include "StyledText.h"
  35. #endif
  36.  
  37. #ifdef txtnRulers
  38. #ifndef _RulersRanges_
  39. #include "RulersRanges.h"
  40. #endif
  41.  
  42. #ifndef _RulerObject_
  43. #include "RulerObject.h"
  44. #endif
  45. #endif
  46.  
  47. //***************************************************************************************************
  48.  
  49.  
  50. struct TCharLocs {
  51.     Fixed leftEdge;
  52.     Fixed pixWidth;
  53. };
  54. const short kMaxLineCharsLocs = 3;  // 3 is the max nbr of discontinued char ranges
  55.  
  56.  
  57. //***************************************************************************************************
  58.  
  59. class CLine    :    public HandleObject {
  60.     
  61. public:
  62.     static void Start();
  63.     static void Terminate();
  64.     
  65.     CLine();
  66.     
  67.     #ifdef txtnRulers
  68.     void ILine(CStyledText* lineText, char direction, CRulersRanges* rulersRanges, TSize sizeInfo = kLargeSize);
  69.     #else
  70.     void ILine(CStyledText* lineText, char direction, TSize sizeInfo = kLargeSize);
  71.     #endif
  72.     
  73.     void Free();
  74.  
  75.     void SetLineInfo(long lineStart, short lineLen, short maxLineWidth);
  76.  
  77.     void Draw(const Rect* lineRect, short lineAscent);
  78.                                             
  79.     inline void    Invalid() {fStart = -1;}
  80.  
  81. #ifdef txtnScal        
  82.     void SetScale(Point numer, Point denom);
  83. #endif
  84.  
  85.     void SetDirection(char newDirection);
  86.  
  87.     short RunCharsLocs(short startOff, short endOff, short runVisIndex
  88.                                             , Fixed* startPix, Fixed* pixWidth, Fixed* runLeft, Boolean lineBounds);
  89.  
  90.     
  91.     void LineCharsLocs(TOffsetRange charRange, TCharLocs* charLocsArr, Boolean lineBounds, char caretDir = kRunDir);
  92.     
  93.     CRunObject* Pixel2Character(Fixed hPixel, TOffsetRange* charRange);
  94.     
  95.     short Character2Pixel(TOffset charOffset, char caretDir = kRunDir);
  96.     
  97.     Boolean Visible2BackOrder(TOffset* charOffset, char runDir);
  98.     
  99.     short GetRunDirection(const TLineRun* runInfo); //public since called from "RunDirProc" which can't be a method
  100.  
  101. private:
  102.     CStyledText*    fStyledText;
  103.     CRunsRanges* fRunsRanges;
  104.     
  105.     #ifdef txtnRulers
  106.     CRulersRanges* fRulersRanges;
  107.     CRulerObject* fLineRuler;
  108.     #endif
  109.     
  110.     long         fStart;
  111.     short        fVisLen;
  112.     Boolean fNoDraw;
  113.     char        fDirection;
  114.  
  115.     #ifdef txtnScal        
  116.     Point        fNumer;
  117.     Point        fDenom;
  118.     #endif
  119.  
  120.  
  121.     CArray*    fOrderedRuns; // array of TLineRun contains the runs in their visible order
  122.  
  123.     short    fLastRun;
  124.  
  125.     Fixed    fLeftEdge;
  126.     Fixed fMaxWidth;
  127.     
  128.     
  129.     #ifdef txtnNever
  130.     JustStyleCode RunPosition(short runVisOrder);
  131.     #endif
  132.  
  133.     void DoPixel2Char(TLineRun* runInfo, Fixed pixelWidth, short runVisOrder, TOffsetRange* charRange);
  134.     Fixed DoChar2Pixel(TLineRun* runInfo, short offset, short runVisOrder);
  135.     void DoDrawJust(TLineRun* runInfo, const Rect* lineRect, short lineAscent, Fixed runLeftEdge
  136.                                     , short runVisOrder);
  137.     
  138.     #ifdef txtnRulers
  139.     Fixed DoFullJustifPortion(TLineRun* runInfo, short runVisOrder);
  140.     #endif
  141.     
  142.     Fixed DoMeasure(TLineRun* runInfo);
  143.  
  144.  
  145.     void InsertRun(long runStart, short runLen, CRunObject* runObj, CArray* unorderedRuns);
  146.  
  147.     #ifdef txtnAdvRulers
  148.     Fixed CalcAlignTabWidth(TPendingTab* pendingTab, Fixed tabTrailWidth, const TLineRunPtr runAfter);
  149.     #endif
  150.     
  151.     void     DefineRuns(long lineStart, short lineLen, CArray* unorderedRuns);
  152.     
  153.     short CalcVisibleLength(CArray* theRuns, short lineLen, short* blankRuns);
  154.     
  155.     void     OrderRuns(CArray* unorderedRuns);
  156.  
  157.     Fixed DefineRunWidths(CArray* unorderedRuns, Fixed maxWidth);
  158.  
  159.     #ifdef txtnRulers
  160.     Fixed GetPortionRuns(Fixed* portionRunArr, short* cFullJustifRuns);
  161.     
  162.     void     DefineExtraRunWidths(Fixed theSlope);
  163.     #endif
  164.     
  165.     short Char2Run(TOffset charOffset, Fixed* runLeftEdge= nil);
  166.  
  167.     short Pixel2Run(Fixed* hPix);
  168. };
  169.  
  170. //**************************************************************************************************
  171.  
  172. #endif
  173.  
  174.