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 7 - Translation Manager / Using the Translation Manager

Declaring the File Types Your Application Can Open

In system software versions 7.0 and later, the Finder determines which types of files your application can open by inspecting the resources of type 'FREF' whose resource IDs are listed in your application's bundle (that is, your application's resource of type 'BNDL'). The Finder uses this information to determine which file types can be drop-launched on your application. All file types in the 'FREF' resources listed in your application's bundle, regardless of whether they have associated icons, are considered droppable on your application.

See the chapter "Finder Interface" in Inside Macintosh: Macintosh Toolbox Essentials for a complete description of resources of types 'FREF' and 'BNDL'.
In some cases, however, your application might include 'FREF' resources for file types that you don't want the user to open. For example, your application might use non-document files such as dictionaries and help files. Even though these files should have icons and hence deserve 'FREF' resources, their contents should not be displayed to the user. Similarly, your application might read data from preferences files; this data is intended to be used internally by the application, not opened by the user as a document.

Because the list of file types your application can open may be different from the list of types that have icons, the Translation Manager defines a new resource of type 'open'. The open resource declares which file types your application can open as documents (and hence can be dropped onto your application). Listing 7-2 shows a sample resource of type 'open', in Rez input format.

Listing 7-2 A sample resource of type 'open'

/*open resource for TeachText*/
resource 'open' (128)
   'ttxt', { 'ttro', 'PICT', 'TEXT' }
An open resource consists of an application signature followed by a list of file types. It indicates that the specified application can open files whose types occur in the list. For example, TeachText can open documents created in its own private format, 'ttro', as well as documents of file type 'PICT' and 'TEXT'. If Macintosh Easy Open is available, the Finder allows the user to drop documents of those types onto the application. In addition, if any translation extensions are installed, all documents that can be translated to one of the specified types can also be dropped on the application. So, if a translation extension exists that can translate documents from type 'SURF' to type 'ttro', the user can drop SurfWriter documents onto TeachText.

You should list file types in your open resource in order of decreasing preference. If the Translation Manager has to choose between multiple file types as the destination file type for a translation, it chooses the file type that occurs earliest in the list.

The open resource is also used by the routine StandardOpenDialog to determine which documents should be listed in the file-opening dialog box. See "Using File-Opening Dialog Boxes" on page 7-15 for details on StandardOpenDialog.

If you use the StandardOpenDialog function, the open resource in your application should have resource ID 128.
Your application might need to determine dynamically which types of files it can open (perhaps by inspecting which filters are available in a certain folder). If so, you cannot list those file types statically in an open resource. Instead, you can write a simple translation extension to generate a list of openable file types at runtime. See "Writing Application Translation Extensions" beginning on page 7-35 for details.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
6 JUL 1996