Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Text /
Chapter 3 - QuickDraw Text


Summary of QuickDraw Text

Pascal Summary

Constants

CONST
   {CharToPixel directions}
   leftCaret   =  0;    {Place caret for left block}
   rightCaret  =  -1;   {Place caret for right block}
   hilite      =  1;    {Direction is SysDirection}

   {constants for styleRunPosition parameter in PortionLine, DrawJustified, }
   { MeasureJustified, CharToPixel, and PixelToChar} 
   onlyStyleRun   =  0;    {This is the only style run on the line.}
   leftStyleRun   =  1;    {This is the leftmost of multiple style runs on }
                           { the line.}
   rightStyleRun  =  2;    {This is the rightmost of multiple style runs } 
                           {  on the line.}
   middleStyleRun =  3;    {There are multiple style runs on the line }
                           {  and this one is interior; neither }
                           {  leftmost nor rightmost.}

Data Types

TYPE
   {Type declaration for GetFontInfo info VAR parameter}
   FontInfo =  RECORD
      ascent:  Integer;
      descent: Integer;
      widMax:  Integer;
      leading: Integer;
      END;
   {GetFormatOrder ordering array}
   FormatOrder = ARRAY  [0..0] OF Integer;
   FormatOrderPtr =  ^FormatOrder;
   FormatStatus   =  Integer;

   {Type declaration for TextFace face parameter} 
   StyleItem   =  (bold,italic,underline,outline,shadow,condense,extend);
   Style       =  SET OF StyleItem;

Routines

Setting Text Characteristics

PROCEDURE TextFont          (font: Integer);
PROCEDURE TextFace          (face: Style);
PROCEDURE TextMode          (mode: Integer);
PROCEDURE TextSize          (size: Integer);
PROCEDURE SpaceExtra        (extra: Fixed);
PROCEDURE CharExtra         (extra: Fixed);
PROCEDURE GetFontInfo       (VAR info: FontInfo);

Drawing Text

PROCEDURE DrawChar          (ch: CHAR);
PROCEDURE DrawString        (s: Str255);
PROCEDURE DrawText          (textBuf: Ptr; firstByte, byteCount: Integer);
PROCEDURE DrawJustified     (textPtr: Ptr; textLength: LongInt;slop: Fixed; 
                             styleRunPosition: JustStyleCode; 
                             numer: Point; denom: Point);

Measuring Text

FUNCTION CharWidth          (ch:\xDDCHAR): Integer;
FUNCTION StringWidth        (s: Str255) : Integer;
FUNCTION TextWidth          (textBuf: Ptr;
                             firstByte, byteCount: Integer): Integer;
PROCEDURE MeasureText       (count: Integer; textAddr, charLocs: Ptr);
PROCEDURE MeasureJustified  (textPtr: Ptr; textLength: LongInt; 
                             slop: Fixed; charLocs: Ptr; 
                             styleRunPosition: JustStyleCode;
                             numer: Point; denom: Point);

Laying Out a Line of Text

PROCEDURE GetFormatOrder    (ordering: FormatOrderPtr; firstFormat: Integer; 
                             lastFormat: Integer; lineRight: Boolean; 
                             rlDirProc: Ptr;dirParam: Ptr);
FUNCTION VisibleLength      (textPtr: Ptr; textLength: LongInt): LongInt;
FUNCTION PortionLine        (textPtr: Ptr; textLen: LongInt; 
                             styleRunPosition: JustStyleCode; 
                             numer: Point; denom: Point): Fixed;

Determining the Caret Position, and Selecting and Highlighting Text

FUNCTION PixelToChar        (textBuf: Ptr; textLen: LongInt;
                             slop: Fixed; pixelWidth: Fixed;
                             VAR leadingEdge: Boolean;
                             VAR widthRemaining: Fixed;
                             styleRunPosition: JustStyleCode;
                             numer, denom: Point): Integer;
FUNCTION CharToPixel        (textBuf: Ptr; textLen: LongInt; 
                             slop: Fixed; offset: LongInt;
                             direction: Integer; 
                             styleRunPosition: JustStyleCode;
                             numer: Point; denom: Point): Integer;
PROCEDURE HiliteText        (textPtr: Ptr;textLength, firstOffset,
                             secondOffset: Integer;
                             VAR offsets: OffsetTable);

Low-Level QuickDraw Text Routines

PROCEDURE StdText           (count: Integer; textAddr: Ptr;
                             numer, denom: Point);
FUNCTION StdTxMeas          (byteCount: Integer; textAddr: Ptr;
                             VAR numer, denom: Point;
                             VAR info: FontInfo): Integer;

Application-Supplied Routine

FUNCTION MyRlDirProc(theFormat: Integer; dirParam: Ptr) Boolean;

C Summary

Constants

enum{
   /*CharToPixel directions*/
   leftCaret   =  0,    /*Place caret for left block*/
   rightCaret  =  -1,   /*Place caret for right block*/
   hilite      =  1,    /*Direction is SysDirection*/

   /*constants for styleRunPosition parameter in PortionLine,*/
   /*DrawJustified, MeasureJustified, CharToPixel, and PixelToChar*/ 
   onlyStyleRun   =  0,    /*This is the only style run on the line.*/
   leftStyleRun   =  1,    /*This is the leftmost of multiple style */
                           /*runs on the line.*/
   rightStyleRun  =  2,    /*This is the rightmost of multiple style runs */ 
                           /* on the line.*/
   middleStyleRun =  3,    /*There are multiple style runs on the line */
                           /* and this one is interior: neither */
                           /* leftmost nor rightmost.*/

Types

TYPE
   /*Type declaration for GetFontInfo info VAR parameter*/
   struct FontInfo {
      short ascent;
      short descent;
      short widMax;
      short leading;
   };
   typedef struct FontInfo FontInfo;

   /*GetFormatOrder ordering array*/
   typedef short FormatOrder[1];
   typedef FormatOrder *FormatOrderPtr;
   typedef short FormatStatus;

   /*Type declaration for TextFace face parameter*/
   ??StyleItem =  (bold,italic,underline,outline,shadow,condense,extend);
   Style       =  SET OF StyleItem;??

Routines

Setting Text Characteristics

pascal void TextFont          (short font);
pascal void TextFace          (short face);
pascal void TextMode          (short mode);
pascal void TextSize          (short size);
pascal void SpaceExtra        (extra: Fixed);
pascal void CharExtra         (Fixed extra);
pascal void GetFontInfo       (FontInfo *info); 

Drawing Text

pascal void DrawChar          (short ch);
pascal void DrawString        (ConstStr255Param s);
pascal void DrawText          (const void *textBuf, short firstByte,
                               short byteCount);
pascal void DrawJustified     (Ptr textPtr, long textLength, Fixed slop, 
                               JustStyleCode styleRunPosition, 
                               Point numer, Point denom);

Measuring Text

pascal short CharWidth        (short ch);
pascal short StringWidth      (ConstStr255Param s);
pascal short TextWidth        (const void *textBuf, short firstByte, 
                               short byteCount);
pascal void MeasureText       (short count, const void *textAddr, 
                               void *charLocs);
pascal void MeasureJustified
                              (Ptr textPtr, long textLength, Fixed slop, 
                               Ptr charLocs, JustStyleCode styleRunPosition, Point numer, Point denom);

Laying Out a Line of Text

pascal void GetFormatOrder    (FormatOrderPtr ordering, 
                               short firstFormat, short lastFormat, 
                               Boolean lineRight, 
                               Ptr rlDirProc, Ptr dirParam);
pascal long VisibleLength     (Ptr textPtr,long textLen);
pascal Fixed PortionLine      (Ptr textPtr, long textLen, JustStyleCode 
                               styleRunPosition, Point numer, Point denom);

Determining the Caret Position, and Selecting and Highlighting Text

pascal short PixelToChar      (Ptr textBuf, long textLen, Fixed slop,
                               Fixed pixelWidth, Boolean *leadingEdge,
                               Fixed *widthRemaining, JustStyleCode 
                               styleRunPosition, Point numer, Point denom);
pascal short CharToPixel      (Ptr textBuf, long textLen, Fixed slop,
                               long offset, short direction, JustStyleCode
                               styleRunPosition, Point numer, Point denom);
pascal void HiliteText        (Ptr textPtr, short textLength,
                               short firstOffset, short secondOffset, 
                               OffsetTable offsets);

Low-Level QuickDraw Text Routines

pascal void StdText           (short count, const void *textAddr,
                               Point numer, Point denom);
pascal short StdTxMeas        (short byteCount, const void *textAddr,
                               Point *numer, Point *denom, FontInfo *info);

Application-Supplied Routine

pascal Boolean MyRlDirProc    (short theFormat,Ptr dirParam);

Assembly-Language Summary

Trap Macros

Pascal nameTrap macro name
DrawJustified_DrawJustified
MeasureJustified_MeasureJustified
GetFormatOrder_GetFormatOrder
VisibleLength_VisibleLength
PortionLine_PortionLine
CharToPixel_CharToPixel
PixelToChar_PixelToChar
HiliteText_HiliteText
Trap Macro Names

Trap Macros With Trap Words
Trap macro nameTrap word
_MeasureText$A837
_StdText $A882
_DrawChar $A883
_DrawString$A884
_DrawText $A885
_TextWidth$A886
_TextFont $A887
_TextFace $A888
_TextMode $A889
_TextSize $A88A
_GetFontInfo$A88B
_StringWidth$A88C
_CharWidth$A88D
_SpaceExtra$A88E
_StdTxMeas$A8ED
_CharExtra$AA23

Global Variables
HiliteModeFlag used for color highlighting
SysDirectionSystem direction; the primary line direction and alignment for text
thePortThe currently active graphics port


Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996