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: More Macintosh Toolbox /
Chapter 8 - Control Panels / Creating Control Panel Files

Specifying the Font of Text in a Control Panel

A control panel typically contains uneditable text that is part of a control item or defined as static text. See Listing 8-7 on page 8-24 for examples.

The Finder uses the default application font to draw control panel items that you define as static text. However, you can specify that a different font be used for this purpose. There are two ways to do so. The easiest way is to define a font information ('finf') resource. This is the method you should use if you intend your control panel to run in System 7 only.

If you want your control panel to be compatible with the Control Panel desk accessory, you cannot use this method because the Control Panel desk accessory does not recognize font information resources. In this case, you can use an alternative method, which entails defining your control panel's static text as user items, setting the font, and drawing the text. This section explains both methods.

You can also specify the font to be used for each item by creating an item color table ('ictb') resource whose entries correspond to the items in your item list. However, you cannot use this method in System 6, because the Control Panel desk accessory appends your control panel's item list to its own. For more information about the item color table ('ictb') resource, see the chapter "Dialog Manager" in Inside Macintosh: Macintosh Toolbox Essentials.

Creating a Font Information Resource

You create a font information ('finf') resource to specify the font in which the Finder displays your control panel's static text. You include the font information resource in your control panel file, and the Finder reads this resource when it opens your file. You must use the resource ID -4049 for a font information resource.

In the font information resource, you specify the font ID number, the font style, and its size. The Finder sets the graphics port's txFont, txFace, and txSize fields to the values you specify, and QuickDraw draws the text using these values.

Defining Text in a Control Panel as User Items

If you want to specify the font for your control panel's text and also want your control panel to run in both System 6 and System 7, you can define your control panel's text as disabled user items rather than as disabled static text items. Your control device function must call QuickDraw to set the graphics port fields for the font and its characteristics, and then draw the text at initialization and in response to update events. See "Handling Text Defined as User Items" on page 8-43 for more information.

For these user items, you can define a string list ('STR#') resource to store the text strings that make up your text. Your control device function can read the text from
the string list resource and store the text in a data structure in your control device function's private storage. If you do this, then your control device function can read the values from its private storage whenever it needs to update user items.

Listing 8-7 shows a part of the River control panel's item list with the control panel's text defined as user items. Because the user does not need to read the product title and copyright regularly to interact with the control panel, the control panel defines this string as a static text item; the Finder draws this text string only in 9-point Geneva. The control panel defines all other text strings as user items, and the control device function sets the font and draws those user items containing text.

Listing 8-7 A control panel's static text defined as user items

resource 'DITL' (rControlPanelDialog, purgeable) {
   { /* array DITLarray: 18 elements */ } 
   /* . . . */
   /* [2] */
   StaticText {   disabled,      "River Change Systems\n© 1993" },
   /* . . . */
   /* [5] */
   {51, 95, 70, 196},
   UserItem {     disabled,      /*Flow Direction:*/                                         }, 
   /* . . . */
   /* [9] */
   {157, 95, 178, 156},
   UserItem {     disabled,      /*Velocity:*/                    },
   /* . . . */
   /* [14] */
   {157, 202, 176, 242},
   UserItem {     disabled,      /*mph*/                          },
   /* . . . */

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996