TweetFollow Us on Twitter

MACINTOSH C CARBON
MACINTOSH C CARBON: A Hobbyist's Guide To Programming the Macintosh in C
Version 1.0
2001 K. J. Bricknell
Go to Contents Go to Program Listing

CHAPTER 26

MORE ON TEXT - MULTILINGUAL TEXT ENGINE

Introduction

The Multilingual Text Engine (MLTE), which was introduced with Mac OS 9.0 as an alternative for TextEdit, profoundly simplified the task of handling muliti-styled text and, at the same time, provided many new features not provided by TextEdit. The main additional features are as follows:

  • Documents can be larger than 32KB (the TextEdit limit).

  • Tabs.

  • Text justification.

  • Ability to embed movie, sound, and graphics objects in documents.

  • Built-in support for:

    • Scroll bar creation and handling, including live scrolling and proportional scroll boxes.

    • Undo/redo (32 levels).

    • Printing.

    • Drag and drop.

    • The public clipboard, specifically, copying and pasting:

      • Plain text.

      • Plain text with style resources.

      • Unicode text.

      • Flattened Unicode style information.

      • Movies, graphics, and sound.

  • In-line input.

MLTE uses Apple Type Services for Unicode Imaging (ATSUI) to measure and draw text. ATSUI, which was introduced with Mac OS 8.6, replaced QuickDraw and the Script Manager as the low-level means of imaging and measuring text.

MLTE renders text into a rectangular frame. Applications can specify that lines be arbitrarily wide or auto-wrapped.

Global Layout Settings

The following are the main settings applying to the whole document:

  • Justification, which can be default, left, right, centre, full, or forced full.

  • Tab values.

  • Margins.

  • Auto-indent on or off.

  • Text auto-wrap on or off.

  • Read-only status on or off.

  • Line direction.

Undoable and Re-doable Actions

The following actions are undoable and re-doable:

  • Typing.

  • Cut, paste. and clear.

  • Change font, and font size, style and colour.

  • Justification.

  • Drag and drop move and copy.

Selection Behaviour

Within an MLTE document, a single-click defines an insertion point. (Recall from Chapter 21 that an insertion point is, in effect, a selection containing zero characters.) A double-click selects a word, and a triple-click selects a line.

File Types

MLTE supports saving and opening files of the following types:

  • A new type introduced with MLTE called Textension ('txtn'). This should be the preferred type for media-rich documents that can contain movies, graphics, and sound.

  • Text ('TEXT'), with or without style information. Style information may be saved as either 'styl' resources or 'MPSR' resources. If 'styl' resources are used , documents can have text in an unlimited number of styles; however, tabs will not be saved. If 'MPSR' resources are used , only the first style in the document will be saved.

  • Plain Unicode text ('utxt').

  • Movie ('MooV'), sound ('sfil' and 'AIFF'), and picture ('PICT').

Working With MLTE

Initialising and Terminating MLTE

TXNInitTextension should be called at program start to initialise the Textension library:

OSStatus  TXNInitTextension(const TXNMacOSPreferredFontDescription iDefaultFonts[],
                            ItemCount iDefaultFonts,TXNInitOptions iUsageFlags);
                            
iDefaultFonts

NULL, or a table of entries for any encoding for which it is desired to designate a default font:

struct TXNMacOSPreferredFontDescription 
{
  UInt32       fontID;     // Can assign kTXNDefaultFontName
  Fixed        pointSize;  // Can assign kTXNDefaultFontSize
  TextEncoding encoding;
  Style        fontStyle;  // Can assign kTXNDefaultFontStyle
};

For the encoding field, relevant constants are:

kTXNSystemDefaultEncoding
kTXNMacOSEncoding
kTXNUnicodeEncoding

kTXNSystemDefaultEncoding is the encoding preferred by MLTE and the system. This is Unicode if ATSUI is present, as it will be on Mac OS 8.6 and later.)

iDefaultFonts

Number of default fonts designated.

iUsageFlags

Specifies whether movies, sound, and/or graphics should be supported. Relevant constants are:

kTXNWantMoviesMask
kTXNWantSoundMask
kTXNWantGraphicsMask

At program termination, you should call TXNTerminateTextension to close the Textension library and perform other clean-up actions.

Allocating and Deleting a TXNObject

Ordinarily, to create a new document, you create a new window and then pass a reference to that window in a call to TXNNewObject. TXNNewObject creates a new TXNObject, an object which contains private variables and functions required to handle text formatting:

OSStatus  TXNNewObject(const FSSpec *                iFileSpec,       // Can be NULL
                       WindowRef                     iWindow,
                       Rect *                        iFrame,          // Can be NULL
                       TXNFrameOptions               iFrameOptions,
                       TXNFrameType                  iFrameType,
                       TXNFileType                   iFileType,
                       TXNPermanentTextEncodingType  iPermanentEncoding,
                       TXNObject *                   oTXNObject,
                       TXNFrameID *                  oTXNFrameID,
                       TXNObjectRefcon               iRefCon);
                       
iFileSpec

Pointer to file system specification structure. The file is read in, and its contents displayed, after the TXNObject is allocated. If NULL is passed in this parameter, the document will be empty at start.

iWindow

Reference to the window to be attached to the TXNObject, and in which the document will be displayed.

iFrame

The area of the window in which the document's contents are to be displayed. Passing NULL in this parameter sets the frame to equate to the window's port rectangle.

iFrameOptions

The options supported by this frame. The principal relevant constants are:

kTXNShowWindowMask      Show window before TXNNewObject returns.
kTXNWantHScrollBarMask  Include horizontal scroll bar.
kTXNWantVScrollBarMask  Include vertical scroll bar.
kTXNNoSelectionMask     Do not display
insertion point.
iFrameType

The frame type. Relevant constants are:

kTXNTextEditStyleFrameType
kTXNPageFrameType
kTXNMultipleFrameType
iFileType

The primary file type. The principal relevant constants are:

kTXNTextensionFile
kTXNTextFile
kTXNUnicodeTextFile

If you specify kTXNTextFile, and want style information to be saved, you can specify whether that information should be saved in a 'styl' resource or an 'MPSR' resource when calling the function TXNSave (see below).

iPermanentEncoding

The encoding the application considers text to be in. Relevant constants are:

kTXNSystemDefaultEncoding  Encoding preferred by MLTE and the
                           system. (This is Unicode if ATSUI is 
                           present.)
KTXNMacOSEncoding          Incoming and outgoing text to be in 
                           traditional MacOS encoding.
kTXNUnicodeEncoding        Incoming and outgoing text to be in 
                           Unicode, even on systems that do not 
                           have ATSUI.
oTXNObject

On output, a pointer to a TXNObject.

oTXNFrameID

On output, a unique ID for the frame.

iRefCon

Reference constant for use by the application.

If TXNNewObject is called with NULL passed in the iWindow parameter, a window can later be attached to the TXNObject by a call to the function TXNAttachObjectToWindow.

A previously allocated TXNObject and its associated data structures may be deleted by a call to the function TXNDeleteObject.

Setting and Getting Global Layout Settings

As previously stated, certain layout settings (for example, justification, tabs, and margins) apply to the whole TXNObject, that is, the whole document. These layout settings are referred to as control information. You can set control information by calling TXNSetTXNObjectControls:

OSStatus  TXNSetTXNObjectControls(TXNObject iTXNObject,
                                  Boolean iClearAll,
                                  ItemCount iControlCount,
                                  TXNControlTag iControlTags[],
                                  TXNControlData iControlData[]);
                                  
iClearAll

Pass true to reset all controls to the default.

iControlCount

The number of elements in the iControlTags and iControlData arrays, that is, the number of settings being changed.

iControlTags

An array of type TXNControlTag containing control tags. The principal relevant tags are:

kTXNJustificationTag
kTXNTabSettingsTag
kTXNMarginsTag
kTXNWordWrapStateTag
iControlData

An array of TXNControlData structures containing the control information being set. The TXNControlData structure, and its associated structures, are as follows:

union TXNControlData
{
  UInt32       uValue;
  SInt32       sValue;
  TXNTab       tabValue;
  TXNMargins * marginsPtr;
};
typedef union TXNControlData;

struct TXNTab                      struct TXNMargins
{                                  {
  SInt16     value;                  SInt16 topMargin;
  TXNTabType tabType;                SInt16 leftMargin;
  UInt8      filler;                 SInt16 bottomMargin;
};                                   SInt16 rightMargin;
typedef struct TXNTab TXNTab;     };
                                  typedef struct TXNMargins TXNMargins;

Constants relevant to the uValue field when setting justification are:

kTXNFlushDefault
kTXNFlushLeft
kTXNFlushRight
kTXNCenter
kTXNFullJust
kTXNForceFullJust

Constants relevant to the tabType field when setting tabs are:

kTXNRightTab
kTXNLeftTab
kTXNCenterTab

Constants relevant to the uValue field when setting word wrapping are:

kTXNAutoWrap
kTXNNoAutoWrap

You can get control information by calling TXNGetTXNObjectControls:

OSStatus  TXNGetTXNObjectControls(TXNObject      iTXNObject,
                                  ItemCount      iControlCount,
                                  TXNControlTag  iControlTags[],
                                  TXNControlData oControlData[]);
                                  
iControlCount

The number of elements in the iControlTags and iControlData arrays.

iControlTags

An array of type TXNControlTag containing control tags.

oControlData

An array of TXNControlData structures containing, on output, the control information requested by the tags in the iControlTags array.

Setting the Background

You can set he background by calling TXNSetBackground:

OSStatus  TXNSetBackground(TXNObject iTXNObject,TXNBackground * iBackgroundInfo);
  
iBackgroundInfo

A pointer to a TXNBackground structure which describes the background. The TXNBackground structure and its associated union are as follows:

struct TXNBackground 
{
  TXNBackgroundType bgType;  // Assign kTXNBackgroundTypeRGB
  TXNBackgroundData bg;
};
typedef struct TXNBackground TXNBackground;

union TXNBackgroundData
{
  RGBColor color;
};
typedef union TXNBackgroundData TXNBackgroundData;

The only background type available with Version 1.1 of MLTE is a colour. TXNBackgroundData is a union so that it can be expanded in the future to support other background types, such as pictures.

Setting and Getting Type Attributes

You can set type attributes such as text size, style and colour by calling TXNSetTypeAttributes:

OSStatus  TXNSetTypeAttributes(TXNObject         iTXNObject,
                               ItemCount         iAttrCount,
                               TXNTypeAttributes iAttributes[],
                               TXNOffset         iStartOffset,
                               TXNOffset         iEndOffset);
                               
iAttrCount

The number of elements in the iAttributes array, that is, the number of attributes being set.

iAttributes

An array of TXNTypeAttributes structures specifying the attribute being set and the data, or pointer to the data, that will set the attribute. Values less than or equal to sizeof(UInt32) are passed by value. Values greater than sizeof(UInt32) are passed by pointer. The TXNTypeAttributes structure, and its main associated structure, are as follows:

struct TXNTypeAttributes 
{
  TXTNTag          tag;
  ByteCount        size;
  TXNAttributeData data;
};
typedef struct TXNTypeAttributes TXNTypeAttributes;

union TXNAttributeData 
{
  void *               dataPtr;
  UInt32               dataValue;
  TXNATSUIFeatures *   atsuFeatures;
  TXNATSUIVariations * atsuVariations;
};
typedef union TXNAttributeData TXNAttributeData;

The principal constants relevant to the tag field are:

kTXNQDFontSizeAttribute
kTXNQDFontStyleAttribute
kTXNQDFontColorAttribute

The associated constants relevant to the size field are:

kTXNFontSizeAttributeSize
kTXNQDFontStyleAttributeSize
kTXNQDFontColorAttributeSize
iStartOffset

The offset at which to begin setting the attributes. If the requirement is to apply the attributes to the current selection, pass kTXNUseCurrentSelection in this parameter.

iEndOffset

The offset at which to end setting the attributes. This parameter is ignored if kTXNUseCurrentSelection is passed in the iStartOffset parameter.

When your application detects a mouse-down in the menu bar or a Command-key combination, it typically adjusts its menus, enabling and disabling menu items as appropriate. If your application contains menus which allow the user to set type attributes, it must also prepare those menus for display by checkmarking and un-checkmarking items as appropriate.

Using a Size menu as an example, if the current selection (whether it be an empty or non-empty selection) contains text which is all of a single size, the menu item corresponding to that size, and only that menu item, should be checkmarked before the menu is displayed. However, if the selection contains text in two or more sizes, all menu items should be un-checkmarked. It is thus necessary to examine the selection to determine whether it contains a continuous size run or multiple sizes.

You can examine the current selection to determine whether font size, style, and colour are continuous by calling TXNGetContinuousTypeAttributes:

OSStatus  TXNGetContinuousTypeAttributes(TXNObject            iTxnObject,
                                         TXNContinuousFlags * oContinuousFlags,
                                         ItemCount            iCount,
                                         TXNTypeAttributes    ioTypeAttributes[]);
                                         
oContinuousFlags

On output, the relevant bit, or bits, of this parameter can be examined to determine whether the associated attribute, or attributes, is/are continuous. For example, if size is continuous, bit 1 will be set. The relevant constants are:

kTXNSizeContinuousMask
kTXNStyleContinuousMask
kTXNColorContinuousMask
iCount

Number of elements in the ioTypeAttributes array, that is, the number of attributes being examined.

ioTypeAttributes

An array of TXNTypeAttributes structures (see above). On input, the tag field in each structure specifies the attribute to be examined. On output, if the attribute is continuous, the dataValue or dataPtr field of the data field will contain a value, or a pointer to data, which can be used to determine which menu item should be checkmarked.

Functions Relevant to Events

The following functions are relevant to event handling:

Function

Description

TXNClick

Processes clicks in the content region, handling text selection, scrolling, drag and drop, and playing movies and sound.

TXNUpdate

Handles update events, redrawing the contents of the window. Calls BeginUpdate and EndUpdate.

TXNForceUpdate Forces an update event to be generated, thus forcing the contents of the window to be redrawn.

TXNDraw

Similar to TXNUpdate, except that BeginUpdate and EndUpdate are not called. Should be used, in lieu of TXNUpdate, for a window that contains multiple TXNObjects or some graphic element.

TXNActivate

In MLTE, activation is a two-step process. TXNActivate performs the first step, which has to do with activating or deactivating the scroll bars.

When true is passed in the TXNScrollBarState parameter, the scroll bars are activated, even when text input (selection and typing) has been defeated by TXNFocus (see below). When false is passed in the TXNScrollBarState parameter, the scroll bars are deactivated.

TXNFocus

The second step in the activation process has to do with activating text input (selection and typing).

When true is passed in the iBecomingFocused parameter, text input is activated. When false is passed in the iBecomingFocused parameter text input is deactivated.

TXNAdjustCursor

Handles cursor shape-changing. If the cursor is over a text area, it is set to the I-beam shape. If it is over a scrollbar, a movie, graphic, or a sound, or outside the frame, it is set to the arrow shape.

Not relevant in applications using the Carbon event model.

TXNZoomWindow

Handles mousedowns in the zoom box.

GrowWindow

Handles mouse-downs in the size box.

TXNGetSleepTicks

Gets the appropriate sleep time.

Note that, in Carbon applications, calling TXNKeyDown on receipt of key events is not necessary, since MLTE handles the event itself without any assistance on the part of your application. Note also that:

  • When the Classic event model is used, it is not possible to filter key events because the event is sent to MLTE before WaitNextEvent delivers it to your application.

  • When the Carbon event model is used, key events are sent through the Carbon event system before they are sent to MLTE. This means that you can filter key events by, for example, installing a handler for the kEventUnicodeForKeyEvent event kind (kEventClassTextInput event class).

Functions Relevant to the File Menu

The following functions are relevant to your application's File menu:

Function

Description

TXNSave

Saves the contents of a document to a file of a specified file type (for example, Textension, text, or Unicode text). The data fork of the file must be open and its file reference number passed in the iDataReference parameter.

For files of type text, if style information is also to be saved, the resource fork of the file must also be open and its file reference number passed in the iResourceReference parameter (The iResourceReference parameter is ignored when the Textension file type is specified.) kTXNMultipleStylesPerTextDocumentResType passed in the iResType parameter causes style information be saved to a 'style' resource. To specify that style information be saved to an 'MPSR' resource, pass kTXNSingleStylePerTextDocumentResType in the iResType parameter.

TXNSave does not move the file mark before writing to a file. This allows you to write private data first (if required), followed by the data written by TXNSave.

TXNRevert

Reverts to the last saved version of the document or, if the document has never been saved, reverts to an empty document.

TXNPageSetup

Displays the Page Setup dialog and reformats the text if settings are changed by the user.

TXNPrint

Displays the Print dialog and prints the document.

TXNGetChangeCount

Returns the number of times the document has been changed since the last save or, for new documents which have not yet been saved, since the document was created. Useful for determining whether the Save and Revert items should be enabled or disabled.

TXNDataSize

Returns the size in bytes of the characters in the document. Useful for determining if the Save As, Page Setup and Print items should be enabled or disabled.

Functions Relevant to the Edit Menu

The following functions are relevant to your application's Edit menu:

Function

Description

TXNCanUndo

Returns true if the last action is undoable, in which case the Undo item should be enabled.

TXNCanRedo

Returns true if the last action is re-doable, in which case the Redo item should be enabled.

TXNUndo

Undoes the last action.

TXNRedo

Re-does the last action.

TXNCut

Cuts the current selection to the MLTE private scrap.

TXNCopy

Copies the current selection to the MLTE private scrap.

TXNPaste

Pastes the MLTE private scrap to the document.

TXNClear

Clears the current selection.

TXNSelectAll

Selects everything in a frame.

TXNIsSelectionEmpty

Returns false if the current selection is not empty, in which case the Cut, Copy, and Clear items should be enabled.

TXNIsScrapPastable

Returns true if the current MLTE scrap is pastable, in which case the Paste item should be enabled.

TXNConvertToPublicScrap

Converts the MLTE private scrap to the public clipboard. Note that, in Carbon applications, this function should not be called on suspend events. Typically, it should be called immediately after TXNCut and TXNCopy.

TXNDataSize

Returns the size in bytes of the characters in the document. Useful for determining if the Select All item should be enabled or disabled.

Note that, in Carbon applications, there is no need to call TXNConvertFromPublicScrap to convert the public clipboard to the MLTE private scrap. In Carbon applications, MLTE automatically keeps the public scrap and private scrap synchronised.

More on TXNCanUndo and TXNCanRedo

When TXNCanUndo and TXNCanRedo return true, they also return in their oTXNActionKey parameters an action key which can be used by your application to load an indexed string describing the undoable or re-doable action. The Undo and Redo items should be set to this string using SetMenuItemText. The following are the main action key constants:

     kTXNTypingAction        kTXNChangeFontColorAction    kTXNAlignLeftAction 
     kTXNCutAction           kTXNChangeFontSizeAction     kTXNAlignRightAction
     kTXNPasteAction         kTXNChangeStyleAction        kTXNAlignCenterAction 
     kTXNClearAction         kTXNMoveAction               kTXNUndoLastAction
     kTXNChangeFontAction    kTXNDropAction

Creating, Preparing, and Handling the Font Menu

MLTE contains functions which greatly simplify the task of creating and managing the Font menu.

The TXNNewFontMenuObject function may be used to create a hierarchical Font menu. A reference to the (empty) Font menu, the menu ID, and the starting ID for the sub-menus are passed in the first three parameters, and a pointer to a TXNFontMenuObject is returned in the fourth parameter. The starting ID for the sub-menus must be 160 or higher.

To prepare the Font menu for display when the user clicks in the menu bar, you should simply call TXNPrepareFontMenu, which checkmarks and un-checkmarks items in the Font menu as appropriate.

A call to TXNDoFontMenuSelection, with the TXNFontMenuObject obtained by the call to TXNNewFontMenuObject passed in the second parameter and the menu ID and chosen menu item passed in the third and fourth parameters, sets the chosen font and changes the current selection to that font.

At program termination, you should call TXNDisposeFontMenuObject to dispose of the TXNFontMenuObject and its menu handle.

Setting Data

You can replace a specified range with data by calling TXNSetData:

OSStatus  TXNSetData(TXNObject iTXNObject,TXNDataType iDataType,void * iDataPtr,
                     ByteCount iDataSize,TXNOffset iStartOffset,TXNOffset iEndOffset);
                     
iDataType

The type of data. Relevant constants are:

kTXNTextData
kTXNPictureData
kTXNMovieData
kTXNSoundData
kTXNUnicodeTextData
iDataPtr

A pointer to the new data.

iDataSize

The size of new data.

iStartOffset

The offset to the beginning of the range to replace.

iEndOffset

The offset to the end of range to replace.

You can replace a specified range with the contents of a specified file by calling TXNSetDataFromFile:

OSStatus  TXNSetDataFromFile(TXNObject iTXNObject,SInt16 iFileRefNum,OSType iFileType,
                             ByteCount iFileLength,TXNOffset iStartOffset,
                             TXNOffset iEndOffset);
                             
iFileRefNum

The file reference number.

iFileType

The file type. For file types supported by MLTE, the relevant constants are:

kTXNTextensionFile
kTXNTextFile
kTXNPictureFile
kTXNMovieFile
kTXNSoundFile
kTXNAIFFFile
kTXNUnicodeTextFile
iFileLength

How much data should be read. Ignored if the file type is a file type that MLTE supports.

This parameter is useful when you want data that is embedded in the file. For the whole file, pass kTXNEndOffset in this parameter.

iStartOffset

The offset to the beginning of the range to replace.

iEndOffset

The offset to the end of range to replace.

The data fork of the file must be opened, and the file mark set, by the application. MLTE does not move the file's marker before reading the data.

Main Constants, Data Types, and Functions

Constants

Initializing

kTXNWantMoviesMask           = 1L << kTXNWantMoviesBit
kTXNWantSoundMask            = 1L << kTXNWantSoundBit
kTXNWantGraphicsMask         = 1L << kTXNWantGraphicsBit

Text Encoding

kTXNSystemDefaultEncoding    = 0
kTXNMacOSEncoding            = 1
kTXNUnicodeEncoding          = 2

Frame Options

kTXNShowWindowMask           = 1L << kTXNShowWindowBit
kTXNWantHScrollBarMask       = 1L << kTXNWantHScrollBarBit
kTXNWantVScrollBarMask       = 1L << kTXNWantVScrollBarBit
kTXNNoSelectionMask          = 1L << kTXNNoSelectionBit

Frame Types

kTXNTextEditStyleFrameType   = 1
kTXNPageFrameType            = 2
kTXNMultipleFrameType        = 3
Global Layout
kTXNJustificationTag         = FOUR_CHAR_CODE('just')
kTXNTabSettingsTag           = FOUR_CHAR_CODE('tabs')
kTXNMarginsTag               = FOUR_CHAR_CODE('marg')
kTXNWordWrapStateTag         = FOUR_CHAR_CODE('wwrs')
kTXNFlushDefault             = 0
kTXNFlushLeft                = 1
kTXNFlushRight               = 2
kTXNCenter                   = 4
kTXNFullJust                 = 8
kTXNForceFullJust            = 16
kTXNAutoWrap                 = false
kTXNNoAutoWrap               = true
kTXNRightTab                 = -1
kTXNLeftTab                  = 0
kTXNCenterTab                = 1

Setting the Background

kTXNBackgroundTypeRGB        = 1

Type Attributes

kTXNSizeContinuousMask       = 1L << kTXNSizeContinuousBit
kTXNStyleContinuousMask      = 1L << kTXNStyleContinuousBit
kTXNColorContinuousMask      = 1L << kTXNColorContinuousBit
kTXNQDFontSizeAttribute      = FOUR_CHAR_CODE('size')
kTXNQDFontStyleAttribute     = FOUR_CHAR_CODE('face')
kTXNQDFontColorAttribute     = FOUR_CHAR_CODE('klor')
kTXNFontSizeAttributeSize    = sizeof(Fixed)
kTXNQDFontStyleAttributeSize = sizeof(Style)
kTXNQDFontColorAttributeSize = sizeof(RGBColor)

Data Types

kTXNTextData                 = FOUR_CHAR_CODE('TEXT')
kTXNPictureData              = FOUR_CHAR_CODE('PICT')
kTXNMovieData                = FOUR_CHAR_CODE('moov')
kTXNSoundData                = FOUR_CHAR_CODE('snd ')
kTXNUnicodeTextData          = FOUR_CHAR_CODE('utxt')

File Types

kTXNTextensionFile           = FOUR_CHAR_CODE('txtn')
kTXNTextFile                 = FOUR_CHAR_CODE('TEXT')
kTXNPictureFile              = FOUR_CHAR_CODE('PICT')
kTXNMovieFile                = FOUR_CHAR_CODE('MooV')
kTXNSoundFile                = FOUR_CHAR_CODE('sfil')
kTXNAIFFFile                 = FOUR_CHAR_CODE('AIFF')
kTXNUnicodeTextFile          = FOUR_CHAR_CODE('utxt')

Undo/Redo Action Keys

kTXNTypingAction             = 0
kTXNCutAction                = 1
kTXNPasteAction              = 2
kTXNClearAction              = 3
kTXNChangeFontAction         = 4
kTXNChangeFontColorAction    = 5
kTXNChangeFontSizeAction     = 6
kTXNChangeStyleAction        = 7
kTXNAlignLeftAction          = 8
kTXNAlignCenterAction        = 9
kTXNAlignRightAction         = 10
kTXNDropAction               = 11
kTXNMoveAction               = 12
kTXNUndoLastAction           = 1024

Saving Text Files Style Information

kTXNSingleStylePerTextDocumentResType    = FOUR_CHAR_CODE('MPSR')
kTXNMultipleStylesPerTextDocumentResType = FOUR_CHAR_CODE('styl')

Data Types

typedef struct OpaqueTXNObject*         TXNObject;
typedef struct OpaqueTXNFontMenuObject* TXNFontMenuObject;
typedef UInt32                          TXNFrameID;
typedef OptionBits                      TXNInitOptions;
typedef UInt32                          TXNPermanentTextEncodingType;
typedef OptionBits                      TXNFrameOptions;
typedef UInt32                          TXNFrameType;
typedef UInt32                          TXNBackgroundType;
typedef FourCharCode                    TXNControlTag;
typedef SInt8                           TXNTabType;
typedef OptionBits                      TXNContinuousFlags;
typedef ByteCount                       TXNTypeRunAttributeSizes;
typedef OSType                          TXNDataType;
typedef OSType                          TXNFileType;
typedef UInt32                          TXNActionKey;

Global Layout

union TXNControlData
{
  UInt32       uValue;
  SInt32       sValue;
  TXNTab       tabValue;
  TXNMargins * marginsPtr;
};
typedef union TXNControlData TXNControlData;

struct TXNTab
{
  SInt16     value;
  TXNTabType tabType;
  UInt8      filler;
};
typedef struct TXNTab TXNTab;

struct TXNMargins
{
  SInt16 topMargin;
  SInt16 leftMargin;
  SInt16 bottomMargin;
  SInt16 rightMargin;
};
typedef struct TXNMargins TXNMargins;

Setting the Background

struct TXNBackground 
{
  TXNBackgroundType bgType;
  TXNBackgroundData bg;
};
typedef struct TXNBackground TXNBackground;

union TXNBackgroundData
{
  RGBColor color;
};
typedef union TXNBackgroundData TXNBackgroundData;

Type Attributes

struct TXNTypeAttributes 
{
    TXTNTag          tag;
    ByteCount        size;
    TXNAttributeData data;
};
typedef struct TXNTypeAttributes TXNTypeAttributes;

union TXNAttributeData
{
  void *               dataPtr;
  UInt32               dataValue;
  TXNATSUIFeatures *   atsuFeatures;
  TXNATSUIVariations * atsuVariations;
};
typedef union TXNAttributeData TXNAttributeData;

Font Description

struct TXNMacOSPreferredFontDescription
{
  UInt32       fontID;
  Fixed        pointSize;
  TextEncoding encoding;
  Style        fontStyle;
};
typedef struct TXNMacOSPreferredFontDescription TXNMacOSPreferredFontDescription;

Functions

Initialising and Terminating

void      TXNTerminateTextension(void);
OSStatus  TXNInitTextension(const TXNMacOSPreferredFontDescription iDefaultFonts[],
          ItemCount iCountDefaultFonts,TXNInitOptions iUsageFlags);

Allocating and Deleting TXNObject

OSStatus  TXNNewObject(const FSSpec *iFileSpec,WindowRef iWindow,Rect *iFrame,
          TXNFrameOptions iFrameOptions,TXNFrameType iFrameType, TXNFileType iFileType,
          TXNPermanentTextEncodingType iPermanentEncoding,TXNObject *oTXNObject,
          TXNFrameID *oTXNFrameID,TXNObjectRefcon iRefCon);
void      TXNDeleteObject(TXNObject iTXNObject);

Attaching an Object to a Window

OSStatus  TXNAttachObjectToWindow(TXNObject iTXNObject,GWorldPtr iWindow,
          Boolean iIsActualWindow);
Boolean   TXNIsObjectAttachedToWindow(TXNObject iTXNObject);

Resizing the Frame

void      TXNResizeFrame(TXNObject iTXNObject,UInt32 iWidth,UInt32 iHeight,
          TXNFrameID iTXNFrameID);

Setting and Getting Global Layout Settings

OSStatus  TXNSetTXNObjectControls(TXNObject iTXNObject,Boolean iClearAll,
          ItemCount iControlCount,TXNControlTag iControlTags[],TXNControlData iControlData[]);
OSStatus  TXNGetTXNObjectControls(TXNObject iTXNObject,ItemCount iControlCount,
          TXNControlTag iControlTags[],TXNControlData oControlData[]);

Setting the Background

OSStatus  TXNSetBackground(TXNObject iTXNObject,TXNBackground *iBackgroundInfo);
Setting and Getting Type Attributes
OSStatus  TXNSetTypeAttributes(TXNObject iTXNObject,ItemCount iAttrCount,
          TXNTypeAttributes iAttributes[],TXNOffset iStartOffset,TXNOffset iEndOffset);
OSStatus  TXNGetContinuousTypeAttributes(TXNObject iTxnObject,
          TXNContinuousFlags *oContinuousFlags,ItemCount iCount,
          TXNTypeAttributes  ioTypeAttributes[]);

Event Handling

void      TXNClick(TXNObject iTXNObject,const EventRecord *iEvent);
void      TXNUpdate(TXNObject iTXNObject);
void      TXNForceUpdate(TXNObject iTXNObject);
void      TXNDraw(TXNObject iTXNObject,GWorldPtr iDrawPort);
OSStatus  TXNActivate(TXNObject iTXNObject,TXNFrameID iTXNFrameID,
          TXNScrollBarState iActiveState);
void      TXNFocus(TXNObject iTXNObject,Boolean iBecomingFocused);
void      TXNAdjustCursor(TXNObject iTXNObject,RgnHandle ioCursorRgn);
void      TXNZoomWindow(TXNObject iTXNObject,short iPart);
void      TXNGrowWindow(TXNObject iTXNObject,const EventRecord *iEvent);
UInt32    TXNGetSleepTicks(TXNObject iTXNObject);

Functions Relevant to the File Menu

OSStatus  TXNSave(TXNObject iTXNObject,TXNFileType iType,OSType iResType,
          TXNPermanentTextEncodingType iPermanentEncoding,FSSpec *iFileSpecification,
          SInt16 iDataReference,SInt16 iResourceReference);
OSStatus  TXNRevert(TXNObject iTXNObject);
OSStatus  TXNPageSetup(TXNObject iTXNObject);
OSStatus  TXNPrint(TXNObject iTXNObject);

Functions Relevant to the Edit Menu

Boolean   TXNCanUndo(TXNObject iTXNObject,TXNActionKey *oTXNActionKey);
Boolean   TXNCanRedo(TXNObject iTXNObject,TXNActionKey *oTXNActionKey);
void      TXNUndo(TXNObject iTXNObject);
void      TXNRedo(TXNObject iTXNObject);
OSStatus  TXNCut(TXNObject iTXNObject);
OSStatus  TXNCopy(TXNObject iTXNObject);
OSStatus  TXNPaste(TXNObject iTXNObject);
OSStatus  TXNClear(TXNObject iTXNObject);
void      TXNSelectAll(TXNObject iTXNObject);

Creating, Preparing, Handling, and Disposing of the Font Menu

OSStatus  TXNNewFontMenuObject(MenuRef iFontMenuHandle,SInt16 iMenuID,
          SInt16 iStartHierMenuID,TXNFontMenuObject *oTXNFontMenuObject);
OSStatus  TXNPrepareFontMenu(TXNObject iTXNObject,TXNFontMenuObject iTXNFontMenuObject);
OSStatus  TXNDoFontMenuSelection(TXNObject iTXNObject,TXNFontMenuObject iTXNFontMenuObject,
          SInt16 iMenuID,SInt16 iMenuItem);
OSStatus  TXNGetFontMenuRef(TXNFontMenuObject iTXNFontMenuObject,MenuRef *oFontMenuHandle);
OSStatus  TXNDisposeFontMenuObject(TXNFontMenuObject iTXNFontMenuObject);

Selections

Boolean   TXNIsSelectionEmpty(TXNObject iTXNObject);
void      TXNGetSelection(TXNObject iTXNObject,TXNOffset *oStartOffset,TXNOffset *oEndOffset);
void      TXNShowSelection(TXNObject iTXNObject,Boolean iShowEnd);
OSStatus  TXNSetSelection(TXNObject iTXNObject,TXNOffset iStartOffset,TXNOffset iEndOffset);

Setting Data

ByteCount TXNDataSize(TXNObject iTXNObject);
OSStatus  TXNGetData(TXNObject iTXNObject,TXNOffset iStartOffset,TXNOffset iEndOffset,
          Handle *oDataHandle);
OSStatus  TXNSetDataFromFile(TXNObject iTXNObject,SInt16 iFileRefNum,OSType iFileType,
          ByteCount iFileLength,TXNOffset iStartOffset,TXNOffset iEndOffset);

Getting the Change Count

ItemCount TXNGetChangeCount(TXNObject iTXNObject);

Scrap

Boolean   TXNIsScrapPastable(void);
OSStatus  TXNConvertToPublicScrap(void);

Font Defaults

OSStatus  TXNSetFontDefaults(TXNObject iTXNObject,ItemCount iCount,
          TXNMacOSPreferredFontDescription iFontDefaults[]);
OSStatus  TXNGetFontDefaults(TXNObject iTXNObject,ItemCount *ioCount,
          TXNMacOSPreferredFontDescription iFontDefaults[]);

 
AAPL
$116.31
Apple Inc.
+1.64
MSFT
$48.70
Microsoft Corpora
+0.48
GOOG
$534.83
Google Inc.
-2.16

MacTech Search:
Community Search:

Software Updates via MacUpdate

Herald 5.0.1 - Notification plugin for M...
Note: Versions 2.1.3 (for OS X 10.7), 3.0.6 (for OS X 10.8), and 4.0.8 (for OS X 10.9) are no longer supported by the developer. Herald is a notification plugin for Mail.app, Apple's Mac OS X email... Read more
Firetask 3.7 - Innovative task managemen...
Firetask uniquely combines the advantages of classical priority-and-due-date-based task management with GTD. Stay focused and on top of your commitments - Firetask's "Today" view shows all relevant... Read more
TechTool Pro 7.0.6 - Hard drive and syst...
TechTool Pro is now 7, and this is the most advanced version of the acclaimed Macintosh troubleshooting utility created in its 20-year history. Micromat has redeveloped TechTool Pro 7 to be fully 64... Read more
PhotoDesk 3.0.1 - Instagram client for p...
PhotoDesk lets you view, like, comment, and download Instagram pictures/videos! (NO Uploads! / Image Posting! Instagram forbids that! AND you *need* an *existing* Instagram account). But you can do... Read more
SuperDuper! 2.7.3 - Advanced disk clonin...
SuperDuper! is an advanced, yet easy to use disk copying program. It can, of course, make a straight copy, or "clone" -- useful when you want to move all your data from one machine to another, or do... Read more
MacJournal 6.1.5 - Create, maintain, and...
MacJournal is the world's most popular journaling software for the Mac. MacJournal 6 adds a calendar mode that show entries from any journal, geolocation, word count, and progress tracking, as well... Read more
Skim 1.4.10 - PDF Reader and note-taker...
Skim is a PDF reader and note-taker for OS X. It is designed to help you read and annotate scientific papers in PDF, but is also great for viewing any PDF file. Skim includes many features and has a... Read more
FontExplorer X Pro 4.2.2 - Font manageme...
FontExplorer X Pro is optimized for professional use; it's the solution that gives you the power you need to manage all your fonts. Now you can more easily manage, activate and organize your... Read more
SoftRAID 5.0.5 - High-quality RAID manag...
SoftRAID allows you to create and manage disk arrays to increase performance and reliability. SoftRAID's intuitive interface and powerful feature set makes this utility a must have for any Mac OS X... Read more
DEVONthink Pro 2.8.2 - Knowledge base, i...
Save 10% with our exclusive coupon code: MACUPDATE10 DEVONthink Pro is your essential assistant for today's world, where almost everything is digital. From shopping receipts to important research... Read more

Latest Forum Discussions

See All

Weather or Not - Reports and Forecasts...
Weather or Not - Reports and Forecasts for your Calendar 1.0.0 Device: iOS iPhone Category: Weather Price: $2.99, Version: 1.0.0 (iTunes) Description: Weather or Not is a beautiful and intuitive way to check the weather and... | Read more »
Sago Mini Road Trip (Education)
Sago Mini Road Trip 1.0 Device: iOS Universal Category: Education Price: $2.99, Version: 1.0 (iTunes) Description: Go for a fun-filled drive with Jinja the cat. Pick a destination, select a vehicle and hit the road. What will Jinja... | Read more »
New Tower Defense Game, Kingdom Rush: Or...
New Tower Defense Game, Kingdom Rush: Origins, is Available Today Posted by Jessica Fisher on November 20th, 2014 [ permalink ] iPad Only App - Designed for the iPad | Read more »
Sunburn! (Games)
Sunburn! 1.0.0 Device: iOS Universal Category: Games Price: $2.99, Version: 1.0.0 (iTunes) Description: Your ship is gone. Your crew is scattered. One option remains. Gather your crew... and jump into the sun. Reunite your... | Read more »
Tapventures Review
Tapventures Review By Jennifer Allen on November 20th, 2014 Our Rating: :: ODDLY COMPELLINGUniversal App - Designed for iPhone and iPad Tapventures is an increasingly hands-off one-tap RPG, but expect it to hook you despite your... | Read more »
Who Wore it Best? The Hunger Games: Girl...
With The Hunger Games: Mockingjay Part 1 out this weekend, Who Wore it Best? pits two Hunger Games tie-ins, Girl on Fire and Panem Run, against each other in a brutal and pointless fight to the death. I wonder where we got that idea from? | Read more »
Ironkill Review
Ironkill Review By Jennifer Allen on November 20th, 2014 Our Rating: :: LACKLUSTER PUNCHINGUniversal App - Designed for iPhone and iPad Ironkill is a freemium focused fighting game that doesn’t offer particularly thrilling fights... | Read more »
Real-Time Multiplayer Match-3 RPG Crusad...
Real-Time Multiplayer Match-3 RPG Crusaders Quest Set to Launch Next Month Posted by Ellis Spice on November 20th, 2014 [ permalink ] | Read more »
Checkpoint Champion Review
Checkpoint Champion Review By Jennifer Allen on November 20th, 2014 Our Rating: :: SPEEDY DRIFTINGUniversal App - Designed for iPhone and iPad Checkpoint Champion is a drift-focused racing game that’s ideal for short but fun gaming... | Read more »
MediaFire iOS 8 Native Update Brings New...
MediaFire iOS 8 Native Update Brings New “Power Upload” Feature to iPad and iPhone Posted by Jessica Fisher on November 20th, 2014 [ | Read more »

Price Scanner via MacPrices.net

64GB iPod touch on sale for $249, save $50
Best Buy has the 64GB iPod touch on sale for $249 on their online store for a limited time. Their price is $50 off MSRP. Choose free shipping or free local store pickup (if available). Sale price for... Read more
15″ 2.2GHz Retina MacBook Pro on sale for $17...
 B&H Photo has the 2014 15″ 2.2GHz Retina MacBook Pro on sale for $1799.99 for a limited time. Shipping is free, and B&H charges NY sales tax only. B&H will also include free copies of... Read more
New Logitech AnyAngle Case/Stand Brings Flexi...
Logitec has announced the newest addition to its suite of tablet products — the Logitech AnyAngle. A protective case with an any-angle stand for iPad Air 2 and all iPad mini models, AnyAngle is the... Read more
2013 15-inch 2.0GHz Retina MacBook Pro availa...
B&H Photo has leftover previous-generation 15″ 2.0GHz Retina MacBook Pros available for $1499 including free shipping plus NY sales tax only. Their price is $500 off original MSRP. B&H will... Read more
16GB Retina iPad mini on sale today for $199,...
 Staples has 2nd generation 16GB Retina iPad minis on sale for $199 on their online store for a limited time. Their price is $100 off MSRP. Choose free shipping or free local store pickup (if... Read more
Developers Start Designing Apps for Apple Wat...
Apple has announced the availability of WatchKit, software that gives developers a set of tools to easily create experiences designed specifically for Apple Watch. Apple’s developer community can now... Read more
C Spire Launches iPad Air 2 and iPad Mini 3 o...
C Spire has announced that iPad Air 2 with Wi-Fi + Cellular and iPad mini 3 with Wi-Fi + Cellular are now available on its 4G LTE network. C Spire offers both new iPads with a range of data plans... Read more
Are You On Your Last PC? – The ‘Book Mystique
Will your current PC be your last? Quite possibly so if you define “personal computer” as a traditional desktop or laptop form factor machine according to some commentators. So then, the upshot that... Read more
Save up to $180 on MacBook Airs with Apple re...
The Apple Store has Apple Certified Refurbished 2014 MacBook Airs available for up to $180 off the cost of new models. An Apple one-year warranty is included with each MacBook, and shipping is free.... Read more
16GB iPad mini available for $219, save $30
Walmart has 16GB iPad minis (1st generation) available for $219 on their online store. Their price is $30 off MSRP. Choose free shipping or free store pickup (if available). Price for online orders... Read more

Jobs Board

*Apple* Solutions Consultant (ASC)- Retail S...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
Project Manager, *Apple* Financial Services...
**Job Summary** Apple Financial Services (AFS) offers consumers, businesses and educational institutions ways to finance Apple purchases. We work with national and Read more
*Apple* Store Leader Program - College Gradu...
Job Description: Job Summary As an Apple Store Leader Program agent, you can continue your education as you major in the art of leadership at the Apple Store. You'll Read more
*Apple* Retail - Multiple Positions (US) - A...
Sales Specialist - Retail Customer Service and Sales Transform Apple Store visitors into loyal Apple customers. When customers enter the store, you're also the Read more
Senior Event Manager, *Apple* Retail Market...
…This senior level position is responsible for leading and imagining the Apple Retail Team's global event strategy. Delivering an overarching brand story; in-store, Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.