• Aucun résultat trouvé

Toolbox and Operating System Routines

Dans le document TURBO THE (Page 73-76)

To make the Mac user interface standard in most applications, Apple designed it to be easy to follow and difficult to deviate from. This was particularly true of the original Mac, which had 128K of RAM (much of which was consumed by the video display and the operating system) and 64K of ROM (the Toolbox). Since graphic applications tend to be memory intensive (that is, they need lots of RAM), most developers on the Mac just didn't have the extra memory to do things their way. So they were forced to use the extensive libraries of procedures and functions found in the Toolbox ROM and in the operating system itself

The resulting uniformity in Mac software allows most Mac owners to use a brand-new software package with little or no reference to the manual.

The Toolbox and operating system (OS) routines are organized into related groups, often labeled managers or packages (not unlike units, which you'll learn about in Chapter 7). A hst follows with the routine name and a brief description

52 Turbo Pascal for the Macintosh

of what the routines and data types within each allow you to handle. The list is arranged more or less in order of what you need to learn before moving on to the next item, although some concepts are best understood as a group.

Resource Manager: Files can contain resources, such as definitions of menus, windows, icons, and text strings, as well as chunks of code. These routines let you access, identify, and manipulate resources within a given file.

QuickDraw: The heart of the Macintosh, this package contains the basic graphics routines used by the other managers and packages.

Font Manager: You can display text on the Mac in different fonts, that is, with differently designed character sets. This package helps you (and QuickDraw) load or unload specific fonts from the disk for text display.

Toolbox Event Manager: These routines form the foundation for event-driven programming. Besides GetNextEvent, this package also allows for direct polling of the mouse, the keyboard, and the system clock.

Window Manager: The Mac allows you to set up multiple windows, each acting like its own screen. This package helps you create, move, modify, update, and delete windows.

Control Manager: Mac software often uses graphic controls - buttons, dials, scroll bars, switches, and check boxes - for selection and display. These rou-tines allow you to select and use predefined controls and to design your own.

Menu Manager: A menu bar across the top of the screen shows you the pull-down menu options; selecting a particular menu allows you to examine com-mands and pick a specific one. This package lets you create, manipulate, and interrogate your menus (that is, go into the menu commands and find out how they were set up).

TextEdit: TextEdit helps you edit text by providing routines to insert, delete, select, and scroll text within a window, and to transfer text from one location (or window) to another.

Dialog Manager: When a Mac application wants to bring something to the user's attention, it usually does so via a dialog box. This is a window with some informa-tion (graphics and/or text) in it and with one or more ways to enter a command (buttons, switches, text or numeric entry, and so on). 1bis package helps you de-sign and present dialog boxes, and to correctly interpret a user's response to it.

Desk Manager: Most applications maintain the Apple menu option (the one on the far left with the Apple logo instead of a name), which contains special pro-grams known as desk accessories (covered in Chapter 8). Desk accessories can be open and running even while your program is running, so you need to be able to accept and receive their messages. Desk Manager routines allow you to detect and handle actions required by the desk accessory.

Scrap Manager: This package helps you transfer data (such as text) between applications or between locations in .a given application.

Toolbox Utilities: This is a collection of miscellaneous routines, including (but not limited to) fixed-point math; string, byte, and bit, including logical operations on long integers; and miscellaneous graphics-oriented routines.

Package Manager: A package is a set of routines and data structures stored on disk (as resources in the SYSTEM file) and loaded into RAM as needed. Six different packages are available through the Package Manager:

• the Binary-Decimal Conversion Package (conversions between decimal strings and internal binary representations);

• the International Utilities Package (different languages' character sets);

• the Standard File Package (selecting files for I/O);

• the Disk Initialization Package (formatting blank disks);

• the Floating-Point Arithmetic Package (for IEEE-standard floating-point math);

• the Transcendental Functions Package (for floating-point routines, such as trig-onometric functions, logs, and financial functions).

Memory Manager: The Mac has a complex way to allocate relocatable blocks of memory so that dynamic garbage collection can occur without disturbing any program currently executing. When used properly, these routines ensure that memory is correctly allocated or recovered.

Segment Loader: Programs that are unwieldy because of size can be divided up into .segments; each segment can be up to 32K in size. The Segment· Loader governs the execution, segment loading, and termination of an application.

Operating System Event Manager: The Toolbox Event Manager allows you to query the operating system for events; the routines in this manager allow you to work directly with the event queue that the operating system maintains.

File Manager: This. manager handles just about everything having to do with files, from high-level volume management to low-level file I/O.

Printing Manager: The Macintosh presents some special challenges in capturing what's on the screen or in a text file out to a printer. In conjunction with the printer drivers found on your system disk, these routines allow you to print the graphic images created by Mac software.

Device Manager: This package is a general version of the File and Printing Managers. It lets you work with custom device drivers and perform I/O with those devices.

54 Turbo Pascal for the Macintosh

Disk Driver, Sound Driver, Serial Drivers: These routines give your software control 6f the corresponding hardware items (Hoppy drives, DAC, RS422 ports) on the Mac.

AppleTaik Manager: Apple has defined a simple local-area network (LAN) for Apple products known as AppleTalk. This collection of data structures and rou-tines allows you to communicate over that network.

Vertical Retrace Manager: This allows you to create interrupt-driven tasks that are called every so many ticks, where a tick is one-sixtieth of a second and corre-sponds to how often a vertical retrace interrupt occurs. A vertical retrace is one cycle of redrawing the screen, and you can use the cycle as a timer to trigger a routine.

System Error Handler: The one routine in this package, SysError, brings up the system error dialog box (with the bomb in it). Not for casual use.

Operating System Utilities: Another collection of assorted handy routines, including procedures and functions for pointer and handle manipulation, string comparison, date and time operations, parameter RAM operations, and other utilities.

With the proper use of these routines, your application will fit into the stan-dard Macintosh mold. A regular Mac user will then be able to easily start it up and use it.

Dans le document TURBO THE (Page 73-76)