DIALOG ITEM INTERFACE DEFINITION OBJECT

Abstract: An object-oriented item is used to define the behavior of an item in a dialog box in a windows environment. A class hierarchical library is established with a base class setting up initial definitions of instance variables and methods used to define the behavior of a customized item. An applications developer can create customized items for a dialog box by creating subclasses. The subclasses will inherit portions of the superclasses, and the developer will customize the item by overriding certain methods. The object, an instance of the class, is referenced by a resource associated with an application.

Description: DIALOG ITEM INTERFACE DEFINITION OBJECT LIMITED COPYRIGHT WAIVER A portion of the disclosure of this patent document contains material which is subject to copyright protection. The copyright owner has no objection to the facsimile reproduction by anyone of the patent document or d e patent disclosure as it appears in the U.S. Patent and Trademark Office patent file or records, but otherwise reserves all copyright rights whatsoever. BACKGROUND OF THE INVENTION Field of the Invention The present invention is directed to a system for defining, using and customizing items in a dialog box. Description of the Related Art Many computers utilize a windows environment. A window is a user interface element that delimits an area on the screen in which a user can enter and view information. Software applications that have a user interface, can use windows to communicate with the user. A software application (or simply "application") is computer software that performs a particular task. Any piece of information that an application needs to present to a user can be displayed in a window. Similarly, any piece of information that an application needs to solicit from a user can be obtained by requesting the user to perform appropriate actions in a window. Appropriate actions means that the user types in information, edits information, checks a box or uses a mouse to click on a button or icon. There can be at least two general kinds of windows: document windows and dialog boxes. Document windows are used primarily to allow the user to enter and manipulate information, such as text, graphics or other data. Often, but not always, the information in a document window can be stored in a file, from which the user can later retrieve the information. The dialog box is a window that is used for some special, limited purpose. In the simplest case, a dialog box can be used to display information to the user. The information might be a report of an error, a greeting, or a progress bar showing what percentage of some operation has been completed. A dialog box is usually a pop-out window that an application uses to display or prompt for information. In some cases, the information is needed to complete a command. Dialog boxes can display information to the user, allow the user to change information and allow the user to enter additional information. A dialog box can contain one or more items, with which the user can type text, choose options, or direct the action of a particular command. The items include, but are not limited to, a button, a check box, editable text, a help item, icon, a picture, radio button, and static text. The above listed items are predefined items. An applications developer also can create user-defined or customized items. Figure 1 shows dialog box 10, which may be used as part of an application to draw Venn Diagrams. Dialog box 10 includes various items. For example, dialog box 10 includes a button 12 ("Save current preferences"). If the user clicks on button 12, the application will save all the selections the user made in the dialog box. The term "click" is defined to include the act of the user, using a mouse, placing the cursor over the button and depressing a button on the mouse. The mouse can be replaced by another apparatus for positioning the cursor. Dialog box 10 also includes four check boxes 14, 16, 18, 20, all of which have associated static text. For example, check box 14 has static text "Give existential import to subjects." In an alternative embodiment, each of the static text can be thought of as separate items. While the dialog box is active on a screen, the user can click on the check box. Clicking on the associated check box (14, 16, 18 and 20), toggles the check box between chosen and unchosen states. When the user clicks on button 12, the features that are chosen from check boxes 14, 16, 18 and 20 are stored and used by the application in producing the Venn Diagram. Dialog box 10 also includes eight radio buttons 30, 32, 34, 36, 38, 40, 42 and 44. Each radio button has an associated picture 46, 48, 50, 52, 54, 56, 58, and 60, respectively. Each of these pictures shows an available feature; for example, picture 46, 48, 50 and 52, show the existence of symbols, and pictures 54, 56, 58 and 60 show emptiness patterns that can be used in the Venn Diagram. The user can click on various radio buttons to select or deselect any of the symbols or emptiness patterns. When the user clicks Save Button 12, the selected patterns and symbols are stored. Alternatively, pictures 46, 48, 50, 52, 54, 56, 58 and 60 can be separate icons. Dialog boxes tend to be easier to create and manage as compared to document windows. Many computers will have a Dialog Manager that manages or oversees the use of dialog boxes. The Dialog Manager reads a description of the dialog box and the items inside the dialog box. The Dialog Manager then draws the dialog box and process (or manage the response to) user actions that effect the dialog box. The Dialog Manager's duties include manipulating items in a dialog box, including but not limited to, drawing an item, erasing an item, changing the appearance of an item and overseeing the handling of any event which effects the item. Currently, the behavior of a dialog box and its items are defined in the Dialog Manager, the windows system, or in an application. The phrase "defining behavior" includes, but is not limited to, defining how and where to draw dialog boxes and dialog items, various attributes of the items (e.g. font, point size, color, test, etc.) and what actions need to be performed when an event occurs (for example when a user clicks on an item, enters text in an item, edits text in an item or performs any other action involving an item or dialog box). When designing a Dialog Manager and accompanying software, the Dialog Manager includes predefined items for an applications programmer to use in dialog boxes. Thus, a windows environment may come with a library of predefined items. The current use and structure of dialog boxes and dialog items has given rise to some hardship in regard to software development. A first hardship occurs when the provider of the Dialog Manager or windows system, and perhaps the operating system, desires to make changes to the library of predefined items. Changes to the library include adding more items or changing the definition of preexisting items. Making changes to the library usually requires making changes to the Dialog Manager, and possibly the windows system or the operating system (the Dialog Manager may or may not be part of the operating system). Additionally, after completing the changes to the library, the operating system and the Dialog Manager may need to be recompiled in order to take advantage of new features. In most cases, if the operating system, window system or Dialog Manager are recompiled, applications that run on the operating system or windows system must be recompiled in order to take advantage of the new features. Thus, as the provider of a window system or Dialog Manager adds new items or changes items in the library, every application running on the system may need to be recompiled. This is burdensome on the users and applications developers. Furthermore, changes in the library may make other library items or software applications obsolete. Specifically, if the definition of an item is changed other items which incorporate that item or applications which incorporate that item will no longer function properly and may need to be edited. A third hardship arises when an application developer (developer) needs to use an item that does not appear in the predefined item library. Thus, the applications programmer creates a new, customized item. Currently, creating a customized item requires a lot of effort. The applications programmer must understand how the Dialog Manager works and how to override various features of the Dialog Manager to deal with a new type of item. Also contributing to the hardship is the possibility that the applications developer does not have the ability to easily incorporate all the prior definitions and code used to define me original library. Another problem is that each item's behavioral definition may include instructions for behaving in various situations. When the Dialog Manager accesses an item's behavioral definition, there is only one point of entry for the Dialog Manager. Currently, behavioral definitions are typically defined by a list of instructions. When the Dialog Manager accesses the item, the Dialog Manager reads the first instruction on the list of instructions followed by reading the second instruction and so on, until die Dialog Manager completes all the necessary steps as defined in me list of instructions. However, the Dialog Manager may only need to execute a small subset of instructions to carry out the desired task. Thus, it is a waste of processing time for the Dialog Manager to execute instructions not pertinent to the desired task. Additionally, having only one entry point requires a developer to create code to handle die flow of control from that one entry point to all sets of behavioral definitions. Thus, the developer may be required to create a large amount of code for simple customizations. When an applications developer creates a customized item, me module defining me new item can be a separate file from or part of the application program. The application may need to be compiled every time the definition of the item is altered. Additionally, when die applications developer is creating a second application, d e item defined in me first application would not necessarily be able to be referenced by, for example, a pointer in the second application because part of d e code used to create die new dialog item is in die first application. Finally, because the applications developer is overriding various segments of code in die Dialog Manager, a change in the Dialog Manager could render an application (widi a custom or user-defined item) obsolete. SUMMARY OF THE INVENTION The present invention is directed to overcome d e disadvantages of d e prior art. Thus, the present invention is directed to a dialog item interface definition object which allows for the creation of customized dialog items in a simple and more powerful manner. The advantages of die dialog item interface definition object (hereinafter referred to as a "IDO") includes the property of longevity. That is, a change in the dialog item library generally does not render an IDO obsolete. Furthermore, an IDO is independent. That is, an IDO is not part of the operating system, the windows system, Dialog Manager or the application. Thus, the IDO can be edited widiout necessarily having to recompile the application, windows system, Dialog Manager or operating system. Similarly, a change in the item library, or Dialog Manager or application or windows system, would not necessarily require recompiling the IDO. Creation of a custom item using an IDO requires significantly less code to be written and less understanding of die Dialog Manager. An item designed with an IDO can include multiple entry points; therefore, reducing die time wasted executing commands tiiat are not pertinent to die behavior sought to be implemented. Additionally, because diere are multiple entry points, a developer creating an IDO need only create code for the entry points that are being customized. Finally, dialog items created using an IDO can be edited widiout affecting other software and can include a system for self editing. Most editing tools are packaged wid a window system or are sold as an off the shelf item. These tools would not necessarily know how to edit a custom dialog item. The self editing capability of an IDO allows for the editing of a custom dialog item. An IDO is implemented using an object oriented class library (or class structure or class hierarchy). Each class can define die behaviors and attributes used in a particular item. A class library can be created separately from die operating system, windows system, Dialog Manager and application. The applications developer adds to the class library to customize a dialog item. When an application is written, the application need only include a reference to a dialog window. A resource is then created which defines die dialog window. This resource has references to the various items needed in the window. The references could indicate a class in die class library. Because the object oriented class library is used, defining or customizing a new item allows for inheriting all the features of a superclass and overriding only die pertinent features needed for customizing. Accordingly, one aspect of the present invention includes a class structure including a base class and a subclass. The base class has a method adapted to be inherited by the subclass. The method is capable of defining a behavior of an item. A resource, associated widi die application, is included which is adapted to store a reference to a particular subclass. The system includes a manager. The manager is adapted to be in communication with the resource, such that the manager can find die referenced subclass. The manager is adapted to manipulate an item in a dialog box according to die behavior defined in die referenced subclass (or class). The base class can have a plurality of methods. There can be more than one subclass and each subclass can inherit all or some of die mediods defined in die base class. Each subclass can have its own subclass which can inherit methods. A subclass can be compiled widiout compiling die base class (and vice versa). Additionally, a subclass can be compiled widiout compiling die application, or the windows system, die manager or the operating system (and vice versa). Anodier aspect of die present invention includes a dialog interface definition object for defining an item in a dialog box. The dialog box is used as part of an application. The application includes a resource adapted to store and reference information relative to the dialog box. The information is used by a manager to manipulate the dialog box and die dialog items. An object is an instance of a class in a class library. The class includes attributes, inherited mediods capable of defining a first behavior of die item, and new mediods which override a mediods defined in a superclass and are capable of defining a second behavior of die item. The new methods are capable of being inherited by subclasses. Another aspect of the invention includes a mediod for creating an item in a dialog box. The mediod includes the steps of executing an instruction calling for the dialog box and reading a resource associated with the dialog box. The step of reading a resource includes die steps of reading a list of items to be presented in the dialog box and following a reference, in the list of items, which references an object. The method further includes waiting for a first event and executing a first mediod associated widi die first event, widiout executing odier mediods in response to die first event. The event can be a draw event, and thus a draw mediod is executed. A further aspect of the present invention includes a mediod for defining die behavior of a new item to be used in die dialog. The method includes die steps of defining attributes and inheriting a first mediod from a superclass. The first method defines die first task to be performed in response to a first event. A second mediod is overridden from die superclass, including die steps of defining a second task to be performed at a second event. An application is created which includes a dialog box. The application includes a reference path to the first and second mediods. The first method and die second mediod can be compiled widiout coupling me application. These and odier objects and advantages of die invention will appear more clearly from die following description in which d e preferred embodiments of die invention have been set forth in detail in conjunction widi die drawings. BRIEF DESCRIPTION OF THE DRAWINGS Figure 1 shows a dialog box. Figure 2 is a block diagram of a computer system which can be used to implement die features of the present invention. Figure 3 shows an overview of the systems software. Figure 4 is a symbolic representation of the structure of a file. Figure 5 is a symbolic representation of a resource. Figure 6 is a symbolic representation of the structure of a dialog resource. Figure 7 is a symbolic representation of the structure of a dialog item list resource. Figure 8 is a symbolic representation of the structure of an IDO item in the dialog item list resource. Figure 9 is a symbolic representation of a class library. Figure 10 shows the flow chart describing the mediod of creating a new item in a dialog box. Figure 11 shows a dialog box wid an item defined by an IDO. Figure 12 is a flow chart explaining how the Dialog Manager manipulates an IDO. Figure 13 is a symbolic representation of how an application, an IDO and die Dialog Manger interact. Figure 14 is a symbolic representation of how the Dialog Manger process events pertaining to an IDO. Figure 15 is a block diagram showing die various routines carried out by die Dialog Manager. Figure 16 shows die DLOG Resource Editor. Figure 17 shows the DLOG Menu. Figure 18 shows a window for setting the DLOG characteristics. Figure 19 shows the DITL Editor. Figure 20 shows the DITL Item Editor. Figure 21 shows the DITL menu. Figure 22 is a flow chart of the method for editing an IDO. DESCRIPTION OF THE PREFERRED EMBODIMENTS I. Hardware Overview Fig. 1 illustrates a computer system which can be used to implement die features of the present invention. The computer system includes a host CPU 110 coupled to a system bus 111. The system includes a keyboard 112, a mouse 113 including a mouse button, or other pointing device, and a non-volatile memory 114, such as a hard disk, floppy disk, non-volatile integrated circuit memory system, or e like. Similarly, instruction memory 115 and working memory 116 are coupled to die bus 111. The instruction memory 115 stores window management software, among other software needed for operation of the system. The working memory 116 is used to maintain various tables needed by die software in die instruction memory 115 in order to maintain the display. The system also includes a display controller 117 which includes video memory. The display controller 117 drives a display 118 such as a CRT video monitor, LCD flat panel display, or die like. The display system 118 has a screen, generally 119. On screen 119, a workspace 120 is displayed. Workspace 120 is implemented widi a desktop metaphor in the Macintosh type systems with a menu bar region 107 for pull-down menus, and a window region 108 for displaying windows and icons. Within the window region 108 of the desktop 120, a plurality of identifiers may be displayed, such as die identifier 121 representing a hard disk drive, me identifier 122 representing a floppy disk, and odier identifiers not shown which represent files, applications, control panels, or enclosures which enclose other objects. Also in the window region of die desktop 120, a plurality of windows, such as windows 143, 144, and 145 may be opened. The windows 143, 144, and 145 enclose identifiers, such as identifiers 146 and 147 in window 143, identifier 148 in window 144, and identifier 149 in window 145. Windows may overlap odier windows, so identifiers in one window can become obscured by anodier window. But die entire surface of the identifier is "hot" during a drag, so the user only needs leave one pixel showing an identifier for the entire identifier to be accessible. In die figure, die identifiers are shown as graphical elements, or icons. Alternative identifiers may be textual elements, such as the name of the corresponding object. The behaviors described herein may be applied to bodi textual and graphical elements, as may occur in windows opened in a view by name mode or a view by icon mode in Macintosh computers. Displayed widiin die desktop 120 is die cursor 105. In order to identify a particular desired icon, die user moves d e cursor on die display by moving die mouse 113 in a corresponding motion. When die cursor is positioned over one of die icons, die icon automatically changes to reverse video. The user can click on that icon using the mouse button, and can drag it to anodier icon, eidier in the same window or in a different window, and tiien release the mouse button to indicate selection of objects corresponding to bod die first and second icons. II. Software Overview System software is used to implement die various functions of the computer and to provide routines available for application developers to call or include in an application. Systems software routines can be logically divided into functional groups, usually known as managers, that handle specific tasks or user interface elements. For example, the Window Manager allows an application to create, move, hide, resize and odierwise manipulate windows. Similarly, die parts of the system software that allow a developer to create and manipulate menus belongs to die Menu Manager. An application can call system software routines to create standard user interface elements and to coordinate its actions with other open applications. Fig. 3, which depicts an overview of the systems software, shows a user 140 engaging the mouse 113 and keyboard 112. Via a user interface 142, die user 140 interacts with application 146. User interface 142 typically includes a display system; for example, as described in Fig. 2. The application interacts with toolbox 148, operating system 150 and additional system software 152. Toolbox 148 is used to implement die user interface, resource management, sound input and output, text and graphics. The toolbox offers a common set of routines that applications can call to implement various functions. The toolbox ensures familiarity and consistency for the user and helps reduce an application's code size and development time. The toolbox is logically divided into functional groups, usually known as managers, that handle specific tasks for user interface elements. Following, is a description of some of die various managers a given toolbox can have. A more detailed description of die toolbox and system software can be found in "Inside Macintosh, Overview," Apple Computer, Inc., 1992, Addison-Wesley Publishing Company, incorporated herein by reference; and "Inside Macintosh, Macintosh Toolbox Essentials," Apple Computer, Inc., 1992, Addison-Wesley Publishing Company, incorporated herein by reference. The Window Manager allows a developer to create and manage windows of various types. The Dialog Manager allows a developer to create and manage dialog boxes. The Control Manager allows the developer to create and manage controls such as buttons, radio buttons, check boxes, pop up menus, scroll bars, and application-defined controls. The Menu Manager allows the developer to create and manage an application's menu bars and die menus it contains. The Menu Manager also handles die drawing of menus and user actions within a menu. The TextEdit Manager provides simple text-formatting and text-editing capabilities, such as text input, selection, cutting and pasting. Applications that are not primarily concerned widi text processing can use the TextEdit Manager to handle most text manipulation. The Resource Manager allows an application to read and write resources. The Finder Interface Manager allows an application to interact widi die finder, die application diat helps keep track of files and manages die users desktop display. The Scrap Manager allows an application to support cutting and pasting of information among applications. The Help Manager allows an application to provide balloon help on-line assistance. The List Manager allows an application to create a visual list of items. The Sound Manager provides sound output capabilities. The Sound Input Manager provides sound input capabilities for computers equipped widi a sound input device such as a microphone. Each of die various managers can call odier managers to perform tasks. For example, the Dialog Manager can call the Window Manager to set up a window for a dialog box. The operating system provides routines diat allow for performance of basic low level tasks such as file input and output, memory management, and process control. Toolbox 148 can call operating system 150 to perform low level operations. An application may also be able to call operating system 150 directly. The toolbox allows for the creation and management of parts of an application's user interface, and in some sense mediates between the application and the user. By contrast, the operating system essentially mediates between the application and d e hardware. For example, an application does not read and write files by reading data directly from die medium from which diey are stored. Radier, die application calls appropriate File Manager routines. The File Manager locates the desired data widiin the logical hierarchal structure of files and directories diat it manages: Then, die File Manager calls the Device Manager to rewrite the data on die actual physical device. The File Manager and the Device Manager d ereby insulate an application from the low level details of interacting widi the available data storage hardware. Thus, toolbox 148 can be diought of as a level above operating system 150. An alternative embodiment may have die toolbox at die same level. Below is a description for the various main components of a preferred operating system. The Process Manager handles die launching, scheduling and termination of applications. It also provides information about open processes. The Memory Manager manages the dynamic allocation and releasing of memory in an applications memory partition. The Virtual Memory Manager provides virtual memory services. That is, the ability to have a logical address space diat is larger dian die total amount of available RAM. The File Manager provides access to die file system; allows applications to create, open, read, write, and close files. The Alias Manager helps locate specified files, directories, or volumes. The Disk Initialization Manager manages the process of initializing disks. The Device Manager provides input from and output to hardware devices attached to die computer. The SCSI Manager controls the exchange of information from the computer and a peripheral device attached to a Small Computer Standard Interface (SCSI). The Time Manager allows for die execution of a routine periodically or after a specified time delay. The Vertical Retrace Manager allows the synchronization of the execution of a routine with die redrawing of die screen. The Shutdown Manager allows for the execution of a routine while the computer is shutting down or restarting. The system software includes a number of other parts, collectively called additional system software 152, diat do not historically belong to either die toolbox 148 or die operating system 150. Additional system software 152 provides an extremely powerful set of services that can be used to handle text and to support die varying text handling requirements of different languages and writing systems. The additional system software 152 also includes an Inter- Application Communications Architecture (IAC) and a communications toolbox. The IAC provides a standard and extensible mechanism for communication among applications. The IAC architecture includes die following main parts. The Edit Manager allows applications to automate, copy and paste operations between applications, so diat data can be shared dynamically. The Event Manager allows applications to send and respond to events. The Program to Program Communications Toolbox (PPC) allows applications to exchange blocks of data widi each odier by reading and writing low-level message blocks. It also provides a standard user interface diat allows a user working in one application to select anodier application widi which to exchange data. The system software routines can be stored in a library and linked to an application. In the preferred embodiment, diese routines reside in a read only memory (ROM), provided by special chips in die computer. When an application calls a routine, the operating system intercepts the call and executes die appropriate code contained in die ROM. This mechanism provides a way for die operating system 150 to substitute the code diat is executed in response to a particular system software routine. Instead of executing die ROM based code for some routine, the operating system may choose, at die instruction of the application developer, to load some substitute code in die computer's RAM. Then when the application calls the routine in question, the operating system intercepts the call and executes the RAM based code. RAM based code diat substitutes for ROM based code is called a patch. Patches are usually stored in die system file, located in die system folder. The system file also contains collections of data, known as resources, that applications can use to help present the standard user interface. Anodier mediod for adding capabilities to die system software is to include executable code of new routines as a system extension. Extensions are stored in a special location, die Extension Folder in die System Folder, and are loaded into memory at system startup time. When an application calls a system software routine, it generally does not matter whetiier die code diat is executed resides in ROM, is a patch in RAM loaded from the system file, or is part of a RAM-based extension. It is, however, important that appropriate code exists in at least one of these locations, because the application will crash if an attempt to call a routine that is not defined anywhere. The system software breaks up the users actions into component events, which are passed one by one to an application for handling. For example, when a user 140 passes a key on die keyboard 112, the system sends die application information about at event. Alternatively, an event could be die user 140 clicking on die mouse 113 or placing a disk 160 in a disk drive 162. The event information passed to the application includes which key was pressed, when die key was pressed and were diere any modifier keys (for instance, the Command key) were being held down at a time for the key press and so forth. Applications respond to die event by performing whatever actions are appropriate. Applications may receive many types of events. Events are usually divided into diree categories: low-level events, operating system events and high-level events. The Event Manager returns low-level events to an application for occurrences such as the user pressing die mouse button, releasing the mouse button, pressing a key on the keyboard or inserting a disk. The Event Manager also returns low-level events to an application if the application needs to activate a window (diat is, make changes to a window based on whedier it is in front or behind anodier window) or update a window (diat is, redraw die windows contents). When die application requests an event and diere are no other events to report, the Event Manager returns a null event. The Event Manager returns operating-system events to an application when the processing status of the application is about to change or has changed. For example, if a user brings an application to die foreground, die Process Manager sends an event dirough the Event Manager to an application. Some of the work of reactivating an application is done automatically, bodi by die Process Manager and by die Window Manager. Applications must take care of any further processing needs as a result of an application being reactivated. The Event Manager returns high-level events to an application as a result of communication directed to die application from another application or process. Figure 4 is a symbolic representation of the structure of a file in the preferred embodiment. File 160 has a data fork 162 and a resource fork 164. File 160 is treated as a named, ordered sequence of bytes stored on a volume and divided into two forks. The data fork 162 contains data diat usually corresponds to data created by die users. The application creating the file can store and interpret the data in die data fork in whatever manner is appropriate. Resource fork 164 consists of a resource map and die resources themselves. A resource is any data stored according to a defined structure. The data in die resource is interpreted according to die resource type. Resources can be created by compiling code, using a resource compiler, or using a resource editor. When data is written to a file, it is either written to the file's resource fork or the file's data fork. Data is typically read from die data fork using the File Manager routines, and read from and written to a resource fork using the Resource Manager. Resources typically store resources data diat has a defined structure, such as icons, sounds, and descriptions of menus, controls, dialog boxes and windows. When a resource is created it is assigned a resource type and resource ID. A resource type is a sequence of characters that uniquely identifies a specific type of resource, and a resource ID identifies by number a specific resource. Examples of resource types include CODE, DLOG, DITL, and ICON. An ICON resource type is used to define an icon. A WIND resource is used to define a window. A DLOG resource is used to define a dialog box. A DITL resource is used to define a dialog item list (which is a lot of items in a given dialog box). Resources specific to a given application, such as descriptions of windows, menus, controls and dialog boxes, are stored in die resource fork of the given application. A resource fork has a resource map which contains entries that provide die location of each resource in die resource fork. When the Resource Manager opens the resource fork of a file, it reads die resource map into memory. As die Resource Manager reads resources into memory, it replaces their entities in die resource map widi handles to die data in memory. When a user opens an application, the system software opens the application's resource fork. When die application opens a file, die application typically opens both die files data fork and die files resource fork. When die application requests a resource from the Resource Manager, the Resource Manager files a specific search order. The Resource Manager normally looks first for the resource in die resource fork of the last file that the application opened. If die Resource Manager does not find die resource diere, it continues to search each resource fork open to the application in reverse order diat die files were opened. After looking in the resource forks of files the application has opened, die Resource Manager searches the application's resource fork. If it is not found, die Resource Manager searches the resource fork of the system file. III. Dialog Boxes A dialog box was previously described in die background of die invention. This section provides further details of die preferred embodiment dialog box. When creating a dialog box, die application developer needs to define a dialog resource (DLOG) and a dialog item list resource (DITL). The Dialog Manager gets most of the descriptive information about dialog boxes from diese resources. Fig. 5 shows the resources for an application that contains dialog boxes. Resource fork 164 includes a first resource for storing code 182. The application calls for two dialog boxes; therefore, resource 164 includes two dialog resources: DLOG, 184 and DLOG 2 186. For each dialog resource there is a corresponding dialog item list. Thus, DLOG ! 184 corresponds to DITL, 188, and DLOG 2 186 corresponds to DITI^ 190. Fig. 6 shows a structure of a DLOG resource 200. Rectangle field 202 determines die dialog box's dimensions. Window definition ID 204 (Procld) is used to determine what type of dialog box is being defined. For example, types of dialog boxes can include dialog boxes diat can be moved across die screen (i.e. dragged widi a mouse), dialog boxes which must be dismissed by a user action before any other actions can take place (modal dialog box), and dialog boxes which can be used now or put in die background and used later. If the visibility field 206 is set to a value of 1, the Dialog Manager displays diis dialog box as soon as die dialog box is called in die application. Alternatively, d e dialog box can be defined and set up in memory when called, and would require a draw dialog box command to be displayed. Close box specification 208 specifies whether to draw a close box. A close box is a box drawn in die dialog box diat, when clicked on, causes die dialog box to be closed. Field 212 is reference constant (refCon), which contains any data diat an application stores here. For example, an application can store a number diat represents an item of data, or a pointer to data. Item list ID 216 is the identification of the item list resource (DITL) that specifies the items in the dialog box. Window title 218 is a Pascal string displayed in die dialog boxes title bar. Alignment by 220 is an extra byte added if necessary to make die previous Pascal string end on a word boundary. Dialog box position 222 specifies die position of die dialog box on die screen. A dialog item list (DITL) resource is used to specify what items are being included in die dialog box. The format and structure of a DITL 230 is shown in Fig. 7. Field 232 (item count minus 1) stores the value of one less dian die total number of items defined in this resource. Below that count is a variable number of items (234 . . . 236 . . .). Figure 8 shows the format of an individual IDO item in a DITL. Display Rectangle 242 is used to define die size and location of die item in die dialog box. The display rectangle is specified in corners local to the dialog box; these corners specify the upper left and lower right hand corners of die item. Item Type 244 contains a value which indicates die type of item being defined. For example, mis field may be loaded widi a first constant if the item type is a button, a second constant if the item type is a check box, a third constant if the item type is an IDO, etc. Handle 246 is a pointer which references a class (classes are discussed below). IDO Name stores die name of die class (referencing die class) which defines die IDO. IV. Object Oriented Programming The IDO of the present invention is a product of object oriented programming. In object-oriented programming, action and data are closely coupled. That is, when a programmer defines data, action can also be defined. Instead of a set of routines diat do somediing to data, diere is a set of objects interacting with each odier. An object is an entity that contains some data and an associated set of actions diat operate on die data. To make an object perform one of the actions, the object is sent a message. For example, one might create an object mat represents a rectangle. Its data contains the locations of the rectangles four corner points and its actions might include drawing, erasing and moving. To draw a rectangle, one sends a draw message to the rectangle. Every object belongs to a class, which defines die implementation of a particular kind of object. A class describes die object's data and how die object responds to a message. An object is called an instance of a class. Classes are very much like record declarations. A programmer defines die private data for the class similar to the fields of a record. In classes, die fields are called instance variables (or attributes). Each instance of a class has its own instance variables just as each variable of a record type has the same fields. When a message is sent to an object, a software routine implements that message. This routine is called a method. Thus, a class definition includes instance variables and methods. One important thing to keep in mind is that message and method are not the same. A message is what is sent to an object. How an object responds to a message is the mediod. Thus, a given class will have a class name, instance variables, messages that it can be sent, and mediods it will carry out when received a particular message. A class can be defined in terms of an existing class. The new class is called die subclass and die existing class is called the superclass. A class without a superclass is said to be a root class. A subclass inherits all the instance variables and mediods of its superclass. Inheriting means that a variable or mediod existing in a given class will automatically exist in die subclass. Subclasses can define additional instance variables and methods. Subclasses can also override mediods defined by die superclass. Overriding a mediod means creating a new set of instructions such diat die subclass responds to die same message as a superclass but uses its own method (new mediod) to respond to die message. If a mediod is not overridden, die subclass responds to die mediod in die same manner as the superclass. Fig. 9 shows a hierarchical class library (or class structure or class hierarchy). Class 300 represents the root class. Class 302 is a subclass of the root class. Class 304 is also a subclass of the root class 300. Class 304 also has subclasses 306 and 308. Therefore, class 304 is a superclass of 306 and 308, but a subclass of class 300. Thus, any method defined in class 300 can be inherited in classes 304, 306 and 308. If class 304 overrides a method in class 300, class 306 and class 308 inherit die new mediod. For example, class 300 defines how to draw a circle (see box 301), and has two instance variables, Center and Radius. Class 300 also has two mediods: DrawCircle and EraseCircle. The DrawCircle method draws a circle when class 300 received die message "DrawCircle. " When class 300 receives the message "EraseCircle," die mediod EraseCircle erases the circle that was drawn. Subclass 302 contains one additional instance variable: Color. That means that class 302 also inherits Center and Radius from class 300. Furthermore, class 302 inherits DrawCircle from class 300. Class 302 however, overrides die EraseCircle, so that when a message "EraseCircle" is sent to an object of class 302 a new EraseCircle method is performed. Class 302 also includes anodier mediod, FilllnCircle, mat fills in a previously drawn circle to make it solid. The ink used to fill in die circle is designated by die variable Color. Thus, a routine trying to draw a circle diat is solid sends a message first indicating die value of Color, next send a message of Radius, next send a message of Center, next send a message indicating to DrawCircle and dien send a message indicating to FilllnCircle. When die application is done a message is sent to EraseCircle. Box 310 represents an object, which is an instance of class 302. Object 310 is created in an application. Witiiin the application, messages can be sent to object 310. V. System Object Model IBM's System Object Model (SOM) which is known in the art, is a technology for packaging object-oriented class libraries. SOM allows objects in classes to be shared and imported across languages, and it does not compete widi such languages as SmallTalk, C- + or any other programming language. Instead, SOM compliments languages because SOM is not so much a language technology as it is a packaging technology for binary code. This feature lets vendors ship properly compiled object libraries without source code. SOM allows the creation of language independent objects. This means that class libraries built with SOM in one language can be used and extended by client programs written in another language. SOM allows a developer, because of its breakdown of die language barrier, to more easily change the implementation details of a SOM class - such as adding new methods, editing or deleting variables, inserting new parent class in die inheritance hierarchy, removing methods outwards in die hierarchy - widiout requiring client programs to be recompiled. This enhances the ability to distribute truly upward compatible class libraries. Aldiough SOM is used in die preferred embodiment, SOM can be replaced by anodier model, or by an environment where language compatibility is not a problem. More information about SOM can be found in "OS/2 2.1 Application Programmer's Guide," by Jody Kelly, Craig Swearingen, Dawn Bezviner and Theodore Shrader, 1994, Van Nostrand Reinhold, incorporated herein by reference. VI. Interface Definition Objects An IDO is an object used to define an item in a dialog box. An IDO is an instance of a class. The class library (or class hierarchy or class structure) is set up using SOM. Each class will define a different type of item. For example, a button can be defined widi one class, an icon can be defined widi a second class, a box can be defined widi a diird class, etc. An IDO is an object (or instance) of one of these classes. Since an IDO is an instance of a class, the class inherits all the methods and instance variables of the superclass. The class hierarchy used has a base class. The base class is a relative root class. A base class can be the same as a root class or, a base class can be a subclass of a root class. The base class is the effective or relative root class for a species of objects. Thus, for purposes of dialog boxes one particular class in a perhaps giant system class hierarchy will serve as the base class. In effect, this may not be me root class for the entire class hierarchy. However, for purposes of dialog boxes it will appear to be the root class. Alternatively, there may be a separate class hierarchy for dialog boxes; tiierefore, the base class would also be d e root class. Below is an example of one type (the preferred embodiment) of a base class for an IDO. BASE CLASS Copyright Apple Computer, Inc. 1994 #include <somobj.idl> #include <somcls.idl> #include < types. IDO > interface DialogltemDefinitionObject : SOMObject { /* following are the methods */ /* initialization and disposal */ void Initialize 0; void Dispose 0; /* editing item data - for resource editors */ void EditStaticData 0; /* handle specific events */ void DoDraw 0; void Doldle 0; void DoActivate (in boolean isActive); void CursorEnteredRect 0; void SimulateClick 0; void SetKeyboardFocus (in boolean isFocus); boolean DoMouseDown (in EventRecord *dιeEvent); boolean DoKeyDown (in EventRecord *theEvent); /* drag manager routines */ boolean DragEnteredltem (in DragReference theDrag); void Draglnltem (in DragReference theDrag); void DragLeftltem (in DragReference theDrag); OSErr Droplnltem (in DragReference theDrag); /* utility routines - these should never be overridden, * and are intended to be callable only by subclasses */ OSErr GetProperty (in OSType propertyType, in void *propertyData, in unsigned long propertySize, out unsigned long actualPropertySize); OSErr SetProperty (in OSType propertyType, in void *propertyData, in unsigned long propertySize); Handle GetResourceFromMyChain (in OSType resType, in short resID); implementation { passthru C_h = "#include <Dialogs.h> "; /* Release Orer. Note, only append to die end of this * list, so that die base class is forward compatible. */ releaseorder: fDialog, flndex, fRect, fldleTimeWaitPeriod, Initialize, Dispose, GetData, EditStaticData, DoDraw, EraseBackground, Doldle, DoActivate, CursorEnteredRect, SimulateClick, SetKeyboardFocus, DoMouseDown, DoKeyDown, _get_fDialog, _set_fDialog, _get_flndex, _set_flndex, _get_fRect, _set_fRect, _get_fIdleTimeWaitPeriod , _set_fldleTimeWaitPeriod, DragEnteredltem, Draglnltem, DragLeftltem, Droplnltem, GetProperty, SetProperty, GetResourceFromMyChain; }; }; The following is a description of die fields of die base class. "DialogRef fDialog" indicates die dialog box diat owns this item. "Dialogltemlndexl findex" indicates die term of diat item widiin the dialog box. Thus by using fDialog and findex, die IDO can access and set any generic information for itself by using GetDialogltem and GetDialogltemProperty, etc. "Rect fRect" indicates die item's bounding rectangle (in coordinates local to die dialog in which it resides). "Short fldleTimeWaitPeriod" specifies how long (in 1/60 of a second) die Dialog Manager should wait in between calls to this item's idle procedure. Thus, any item can receive idle time. If die item does not need idle time, it should set this field to kDoesNotNeedldleTime (-1). By default, items will not get idle time. The following text describes die mediods of die base class. Note that if a class only performs standard behavior, for a given mediod, dien die class does not have to override die method of die superclass. The Dialog Manager will call through to die item's inherited method if no mediod is implemented by die class. Usually, the behavior defined in die base class will involve doing very little or doing nodiing. "Initialize (void)" is called when an instance of the IDO is created (at dialog box creation time) to allow the IDO to set its fields appropriately. The IDO calls the inherited SetData before doing any of its own work, to do die default initialization tasks. This includes setting die appropriate value for fldleTimeWaitPeriod. (By default diis is set to -1. If a dialog item needs idle time, it should set fNeedsIdleTime to the number of ticks desired between calls to the Doldle mediod.) Before this mediod is invoked, die Dialog Manager will have set all of the IDO item's properties that define its static startup data. (For example, a text displaying IDO has a property of type "TEXT" that specifies its initial text.) The IDO can access any of these properties by a GetProperty utility method. "Dispose (void)" is called at disposal time for die item (usually when its dialog is disposed) so diat it can be free any dynamically allocated data. "GetStaticData (void)" is called when die Dialog Manager needs an encapsulated form of the item's data (diat it can read in widi die SetData method). "EditStaticData (void)" is called to allow an item to be edited. It is similar to what happens when somebody double clicks on a dialog item in ResEdit: a dialog box is displayed on die screen allowing the user to specify specific fields for the item. "DoActivate (Boolean is Active)" is called when die item's dialog receives an activate event. IsActive is true when die item should be activated, and false when it should be deactivated. "DoDraw (void)" is called when an item redraws itself. The IDO can assume that its port (its dialog) has been set, and diat its state (including die port's pen style, text info, etc.) will be preserved, regardless of what die IDO does when it draws itself. The IDO can also assume that die EraseBackground mediod has been called already. "CursorEnteredRect (void)" is called when the cursor has entered die item's rect. If e IDO wants to change the cursor at this time, it implements this method; odierwise, it does not have to. "DoMouseDown (EventRecord *dιeEvent)" is called when die user has clicked inside die item's rect. The method returns true if it has been selected by die user, indicating diat die Dialog Manager sends die item's index back to die application tiirough DialogSelect or ModalDialog (in die parameter itemHit). "DoKeyDown (EventRecord *dιeEvent)" is called to react to a DoKeyDown event (depressing a key on die keyboard). The return value is similar to the return value of DoMouseDown. "SetKeyboardFocus (Boolean isFocussed)" is called when die user has tabbed or clicked into (or out of, depending on die value of isFocussed) die item's area and it now has keyboard focus, and dius, should draw itself differently. "DragEnteredltem (DragReference dieDrag)" is called when a Drag Manager drag has entered die IDO item's bounding rect. If this item can accept this drag, it should call ShowDragHilite, and return true. Otherwise, it should return false. "Draglnltem (DragReference theDrag)" is called when a drag continues over die given IDO item. It is only called if this item returned true in the DragEnteredltem routine. This method draws an insertion point or do any item- specific drag feedback as appropriate. "DragLeftltem (DragReference theDrag)" is called if a drag is leaving this item's bounding rectangle. The Dialog Manager will call HideDragHilite before calling this mediod, but any other drag-tracking cleanup duties should be performed here. "Droplnltem (DragReference theDrag)" is called when the dialog receives a drag in this item's bounding rectangle. It is the item's duty to take the data in die drag and update its own data accordingly. The method returns any OSErr that is valid for a DragReceiverHandler (see die Drag Manager documentation for details.) The following utility methods are implemented in die base class for an IDO, intended as utility routines for use by any subclassed IDO item. These methods should not be overridden. "SetProperty (OSType propertyType, void* propertyData, unsigned long propertySize)" allows an item to assign data of any type and size to itself, such that it is (a) accessible by the item, application or die Dialog Manager, and (b) arbitrarily storable in a "flat" manner, so diat any item can arbitrarily store its static data in a consistent manner. This routine calls through to SetDialogltemProperty to accomplish this. "GetProperty (OSType propertyType, void* propertyData, unsigned long propertySize, unsigned long* actualPropertySize)" is the complement to the GetProperty method, allowing the item to access any arbitrary property. "Handle GetResourceFromMyChain (OSType resType, short resID) sets up the resource chain such mat the IDO's resource fork is included. This allows IDO's resource to be bundled widi associated resources. As described above, each class can have many methods. When a message is sent to a object by the Dialog Manager, only one method need be invoked. Thus, the Dialog Manager enters the object at the particular method. That is, each method can be looked at as an entry point. If only one method needs to be executed, mere is no reason for the computer to read or execute odier lines of code diat are not pertinent to diat one method. Thus, it is said diat each object has multiple points of entry. Each point of entry being at a method. In Appendix A is a more detailed code listing for each method in die base class. Most of die methods in the base class set up definitions for development in subclasses. The next step is to set up subclasses. Since each subclass is part of the class hierarchy, the subclasses may inherit all the instance variables, or attributes, and die methods from the base class. The developer overrides die methods in die base class as necessary in order to perform the behavior of the desired item. Overriding a method includes adding instructions (source code) to define a list of steps to be taken when a message is received invoking diat mediod. For example, one subclass might define how to draw a rectangle as a box. Then, if an application developer needed a rectangle as an item in a dialog, the developer sets up an object referencing that particular subclass. If an application developer needed a box which had text inside, die developer creates a new subclass from the box subclass. The new subclass, let's call it GroupingRect, will then inherit all the mediods from the box subclass. Furthermore, the new subclass may modify some of die mediods from the box subclass to add text. Using IDOs, it is fairly simple to create a new item. A developer looks for die class closest in form to the new item. Once that class is located, die developer merely sets up a new subclass, inheriting all the methods and instance variables. The developer does not need to know all die details of die inherited methods. The developer does not need to know the flow of control of die Dialog Manager. The developer merely needs to override whatever methods are necessary to implement the customization of the new item. Figure 10 shows the mediod of creating a new type of dialog item. The first step (350), is to set up a new subclass. Setting up a new subclass requires a linking or interfacing with die class hierarchy. The developer must decide what existing class in die class hierarchy should be die immediate superclass to the new subclass. For example, in the GroupingRect example described below, die immediate superclass is the base class. The developer needs to decide what variables or mediods to override and what new methods or variables to add. The developer dien (step 352) defines any new instance variables. It is possible that die developer may not need to define any new variables. The developer will dien (step 354) override any methods necessary to customize the new item. It is possible that no methods may need to be overridden. The developer may also append to die subclass (step 356). Appending to die subclass includes adding new instance variables and adding new methods. At diat point, die developer compiles the subclass (step 358). If die rest of die class hierarchy is already compiled, diere is no need to recompile die class hierarchy after compiling a new subclass because the new subclass should be binary compatible with die class hierarchy. Furthermore, if die application program is already compiled, diere is no need to compile the application program after compiling the subclass. Development of the item can end at step 358 or it can continue. For example, after using the item or testing the item, the developer may decide diat die IDO needs to be edited (step 360). The IDO can be edited by editing text or by using resource editor (see discussion below). After editing is complete, the subclass will need to be compiled again (step 362). When die subclass is recompiled (step 362), there may be no need to recompile the rest of die class hierarchy, die application or die Dialog Manager code. In order to better understand an IDO, die following example is presented. Figure 11 shows a dialog window 320. Dialog window 320 has four items: button 322, StaticText 324, StaticText 326 and GroupingRect 328. GroupingRect 328 is an IDO. GroupingRect is a rectangle. Let's start with the scenario that a developer is creating an application and decides diat a GroupingRect is needed. The GroupingRect is a customized IDO since it does not exist. First, die developer creates a new subclass, a GroupingRect subclass. GroupingRect is a subclass of the base class. Therefore, the GroupingRect inherits the methods and instance variables of die base class. Further, GroupingRect overrides any mediods necessary to draw die rectangle. For this example, GroupingRect overrides die function DoDraw. The new DoDraw includes instructions to draw a rectangle. Furthermore, GroupingRect may override die method EditStaticData. Below is code for the GroupingRect class. This code is written in IDL, the native language of SOM. GROUPING RECT Copyright Apple Computer, Inc. 1994 #include "DialogltemDefinitionObject.idl" interface GroupingRect : DialogltemDefinitionObject { implementation { // method overrides DoDraw: override; EditStaticData: override; }; }; The instructions for the new methods can be written in C: #defιne GroupingRect_Class_Source #include <Drag.h > #include < GroupingRect. ih > /* m mmm m mmmmm mm mm mmm m mmm mm mum DoDraw FUNCTION: Draw the grouping rectangle INPUTS: none OUTPUTS: none RETURNS: void */ SOM_Scope void SOMLINK DoDraw(GroupingRect *somSelf, Environment *ev) { Rect theRect; Str255 theTitle; OSErr theError; /* get the title - it's stored in a property */ theError = _GetProperty (somSelf, ev, kTextDialogltemProperty, (void *) &theTitle[0], sizeof (theTitle), NULL); /* if no title is available, die title defaults to "" */ if (dieError ! = noErr) theTitle[0] = '\0'; theRect = __get_fRect (somSelf, ev); PenNormal 0; FrameRect (&theRect); } /* mmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmmm mm mmtf EditStaticData FUNCTION: Edit the grouping rectangle's static data. Callable by ResEdit and odier similar resource editing programs. INPUTS: none OUTPUTS: none RETURNS: void */ SOM_Scope void SOMLINK EditStaticData(GroupingRect *somSelf, Environment *ev) { /* * this is pseudo-code: create a dialog to find out what die title should be; wait until die user is done widi die dialog; if die user selected "ok" { get the title diat the user entered; set my title property to be that title } odierwise, the user selected cancel. Don't bother changing the title. */ } Now that a class is set up, the applications developer can create an application diat calls a dialog box. The following source code (written in c) shows an application program that calls a dialog box. Aldiough a dialog box was called, diere was no mention to what items are in the dialog box. That information is loaded into a resource. APPLICATION Copyright Apple Computer, Inc. 1994 #include < Dialogs. h> #include <Quickdraw.h> #include <TextEdit.h> #include < Events. h> include <TextEdit.h> #include < Menus. h> #include < Windows .h> #include < Fonts .h> #include < Resources. h> #if powerc QDGlobals qd; #endif void main (void) { DialogPtr theDialog; short itemHit; EventRecord dieEvent; short i; InitGraf (&qd.thePort); InitFonts 0; InitWindows 0; InitMenus 0; TEInit 0; InitDialogs (NULL); for (i = 1; i < 10; i-f - ) WaitNextEvent (-1, &theEvent, 0, NULL); theDialog = GetNewDialog (128, NULL, (WindowPtr) -1); while (itemHit ! = 4) ModalDialog (NULL, &itemHit); DisposeDialog (theDialog); After creating the application program, the applications developer dien must set up a resource. The developer sets up a dialog resource (DLOG) and a dialog items resource (DITL) as described above. The DLOG source code is shown below: DLOG Copyright Apple Computer, Inc. 1994 #include "Types. r" /* This is the dialog displayed by IDOTest */ resource 'DLOG' (128) { {100, 100, 210, 360}, dBoxProc, visible, noGoAway, 0, 128, //indicates we our items are in DITL 128 }; The above resource shows that die dialog box's dimensions are given by d e following four values (100, 100, 210, 360). Window definition ID is dBoxProc which means that this is a modal dialog box. The dialog box is visible and no close box will be drawn. The item list ID points to DITL 128. Below is the source code representation of DITL 128. DITL Copyright Apple Computer, Inc. 1994 /* This is a list of the items in the dialog */ resource 'DITL' (128) { { {10, 100, 25, 155 }, StaticText { enabled, "IDO Test" }, {30, 30, 45, 130}, StaticText { enabled, "GroupingRect" }, /* Here's die new IDO dialog item. * note that we only have to specify * the name of the IDO - in this * case we have a Grouping Rectangle. */ {30, 140, 45, 250}, IDOItem { enabled, "GroupingRect" }, {75, 105, 95, 155}, Button { enabled, "Quit" } }; In the DITL there are four items listed. The first item is StaticText at the size and location indicated by die four values (10, 100, 25, 155). The StaticText is to be put into die dialog is "IDO Test". The second item is also StaticText at the size and location defined by the four values (30, 30, 45, 130). The text to be displayed is "GroupingRect". The third item is an IDO dialog item. The size and location are defined by the four values (30, 140, 45, 250). The item type is specified to be an IDO item and die name of the IDO class is GroupingRect. The fourth item is a button. It's location and size are defined by die values (75, 105, 95, 155). Included widi die button is the text "Quit". The Dialog Manager uses the name of the IDO class to find die IDO class. After locating die IDO class, die Dialog Manager stores a pointer to die IDO class in die handle field (see Fig. 8, reference # 246). Additionally, note how die format of an IDO in a DITL is slightly different dian the format for a predefined item. Each predefined item has its own format known by the Dialog Manager. It is contemplated diat in one embodiment all predefined items are eliminated and only IDO's exist. In die preferred embodiment, predefined items are not eliminated in order to be compatible with existing software. Note diat all die customization is done in the class definition. The resource has a pointer to the class. The application source code does not include any reference to die class. The application source code merely instructs that a dialog box is to be used. The resource only knows that a dialog box is to be set up widi an IDO named GroupingRect. GroupingRect can be changed any time without requiring compiling of the application source code or resource or any of its subclasses. Thus, the class which is the definition of die item is set up separately from the application. Editing and compiling the class will not require a revision of die application, operating system or Dialog Manager. The developer setting up die GroupingRect does not need to know anything about die application. Furthermore, die developer of GroupingRect does not need to know very much about the Dialog Manager or even die details of die implementation of all the methods in die superclasses. VII. Operation of Dialog Manager Figure 12 shows a flow chart of how the Dialog Manager works with an IDO. First, the given application will have an instruction to set up a dialog. Thus, in step 400 the Dialog Manager will begin setting up the new dialog. The first step is to read die resource of die application (402). When reading die resource, die Dialog Manager will first read die DLOG resource which will point to a DITL resource. Reading die DITL, die Dialog Manager will see all die different items. The Dialog Manager then creates die dialog box (404). If there is an IDO item in die DITL, the IDO item will include a reference to a class. The Dialog Manager will read the appropriate class and store the handle in the DITL (406). After reading all die appropriate classes, die dialog is displayed (410). Alternatively, die Dialog Manager may wait to create the dialog box until after die class is read. After displaying die dialog box, die Dialog Manager gives control back to the application (410). When an event occurs that is relevant to the Dialog Manager, control is passed to die Dialog Manager for overseeing die processing of die event (412). In anodier embodiment, the Dialog Manager may receive the event itself, or may receive the event from the Event Manager or other Managers in the toolbox. Once receiving the event, the Dialog Manager or the other tool that sends die event must figure out what type of event it is and where die event occurred. Figuring out where the event occurred means figuring out what item did die event effect. If the event occurred to a dialog item that was created by an IDO, die Dialog Manager figures out which is die effected IDO. In step 414, die Dialog Manager causes the execution of the appropriate method. Note diat die only method executed is die one that die Dialog Manager messages. Figure 13 shows a symbolic representation which can aid in die explanation of the flow chart of Figure 12. Figure 13 shows an application 420 with die data fork 422 and a resource 424. Resource 424 includes a DLOG 426 widi a handle 428 pointing to a DITL 430. DITL 430 includes an item that is an IDO and, tiius, diere is a handle 434 pointing to the GroupingRect class 436. GroupingRect class 436 is part of a class hierarchy 437, which includes a base class 438. Base class 438 has two subclasses, GroupingRect 436 and Circle 440. Circle 440 has two subclasses, Solidcircle 442 and Brokencircle 444. When setting up a resource, Dialog Manager 446 reads DLOG 426 which points the Dialog Manager to DITL 430. Since DITL 430 includes an item which is defined by an IDO, Dialog Manager 446 sets up handle 434 to reference the GroupingRect class 436. Dialog Manager 446 then creates an IDO 448. IDO 448 is shown in broken lines because it represents an instance of GroupingRect class 446. Dialog Manager 446 uses the behavior defined in IDO 448 to manipulate the item. Manipulating an item, in the preferred embodiment, may include sending messages that call for the performance of any of the methods of die IDO. Figure 14 shows a symbolic representation of how the Dialog Manager 446 deals widi events. For illustration purposes, the event diat occurs in this drawing is die user pressing one of die keys on die keyboard 112. Bidirectional arrow 449 indicates diat die Dialog Manager processes events with die help of odier tools in die toolbox. At one point, Dialog Manager 446 is idle (waiting for an event); for example, the application has control. The user presses the key on die keyboard 112 and triggers a KeyDown event. Control is passed to die Dialog Manager which figures out what item the KeyDown pertains to. In this particular dialog (fictitious dialog) diere were diree items defined by IDOs. The first item 450 includes instance variables 456, a DoDraw method 452, a DoKeyDown method 456 and odier methods 458. Dialog item 460 includes instance variables 462, DoDraw method 464, DoKeyDown method 466 and odier mediods 468. Dialog item 470 includes instance variables 472, DoDraw method 474, DoKeyDown mediod 476 and odier methods 478. As illustrated, each of die diree items (450, 460, 470) each have a DoKeyDown method. Any or all of die diree items (IDOs) could have inherited die DoKeyDown mediod from the superclass or could have overridden die DoKeyDown method from the superclass. Once the Dialog Manager figures out that it is a DoKeyDown event and which item die event happened to, die Dialog Manager goes to die appropriate object and looks for die DoKeyDown method. That is, a message is sent to the object indicating die DoKeyDown mediod. In this instance if the key was depressed by die user while on top of die item defined by IDO 460, the Dialog Manager will message DoKeyDown method 466. The Dialog Manager performs all the tasks described widi respect to Figs. 11- 13 while utilizing various routines. Fig. 15 shows the Dialog Manager and a symbolic representation of the routines that are pertinent to dialog items. CountDITL 502 determines the number of items in a dialog item list. GetDialogltem 504 returns all pertinent information regarding an item. SetDialogltem 506 sets the given specifications for the dialog item at the given index in die item list. SetDialogDefaultltem 508 indicates which item in the give dialog box is die default choice. SetDialogCancelltem 510 indicates which item in the dialog box is a cancel button. For example, a dialog box may ask the user whether user wants all changes to be saved in a file and die choices may be "yes" or "cancel. " HideDialogltem 512 hides a given dialog item in die given dialog. ShowDialogltem 514 shows the given dialog item in die given dialog. DrawDialog 516 draws each item in the dialog. UpdateDialog 518 draws each item in die dialog diat lies widiin the given update region. The update region is die area on die screen where visual elements must be redrawn. FindDialogltem 520 returns the first dialog item whose rect encloses die given point. GetDialogltemCommon 522 is common code for getting a dialog item. This is called to get an individual DITL item. GetCompleteltemRect 524 returns the rect of the entire drawing area given a particular item. NextDialogltem 526 skips to the next dialog item ahead of die one passed to Dialog Manager. This function assumes that d e Dialog Manager was passed a valid DITL item. FirstDialogltem 528 determines the first item in the dialog's item list. InitDialogltem 530 initializes the given dialog item as appropriate. DisposeDialogltem 532 disposes of die given dialog item. InitControlItem 534 initializes the given control dialog item. GetltemListCopy 536 gets a copy of the item list for the given DITL. SetupItemList 538 reloads die DITL resource if it was purged and locks it (cannot move around in memory). DoneWidiltemList 540 is called when the Dialog Manager is done working widi the DITL. The DITL is unlocked. FrameDialogltem 542 places a framed round rectangle around die dialog item. DoForEachltem 544 cycles through die item list (DITL) and applies die given function to each item. DrawDialogltem 546 draws a given dialog item in die given dialog. UpdateDialogltem 548 redraws a given dialog item if it is in the given update region. SetDialogltemKeyboardFocus 550 sets the keyboard focus on die given dialog item. UnsetDialogltemKeyboardFocus 552 unsets the keyboard focus on die given dialog item. GetDialogKeyboardFocusItem 554 returns the current keyboard focus item in the dialog. If none is focussed, search for the first item in the DITL that can take a keyboard focus. Below is pseudo-code for the routine DrawDialogltem: DRAW DIALOG ITEM DrawDialogltem (Dialogltem theltem, Dialog theDialog) { if (IsControlItem (theltem)) call control manager routines draw die item's control else if (IsTextltem (theltem)) call text routines to draw die item's text else if (IsPictureltem (theltem)) call QuickDraw to draw die item's picture else if (Islconltem (the Item)) call Icon Utilities to draw the item's icon else if (IsIDOItem (theltem)) dispatch to diat item's DoDraw mediod VIII. Editing A Dialoe Item Editing a dialog item is defined as changing die data diat defines die item's state; for example, change static text, position coordinates, fonts, colors, etc. Dialog items can be edited in at least two different ways. First, create a resource using source code as shown in die code representing die resource for the GroupingRect shown above. The dialog box can be edited by using die Text Editor to edit die source code and dien recompiling die source code. The source code for the dialog item and all odier resources is independent from die source code for the application. A second method for editing dialogs includes creating and editing resources widi an interactive graphics-oriented resource editor; for example, ResEdit™ by Apple Computer. A more detailed description of ResEdit™ can be found in "ResEdit™ Reference For ResEdit version 2.1," 1991, Addison-Wesley Publishing Company, incorporated herein by reference. ResEdit™ is an application that can read a resource, and then provide die user widi a dialog window presenting die data inside die resource. Using die dialog window, die user can edit die data in die resource. When editing a DLOG resource, ResEdit™ will display a window or dialog box 600 shown in Fig. 16. At die top of window 600 is a pictorial list 602 of die selectable window styles for the dialog box. Below diat is a miniscreen 604 diat shows a small picture 606 of the dialog box. Coordinates top 608, left 610, bottom 612, right 614 correspond to rectangle 202 in the dialog resource shown in Fig. 6. DITL ID 616 corresponds to item list ID 216 in dialog resource 200 of Fig. 6. Visible 618 corresponds to visibility 206 in dialog resource 200 of Fig. 6. Close box 620 corresponds to close box 210 in dialog resource 200 of Fig. 6. When a DLOG resource is displayed in ResEdit™ a corresponding menu appears. This menu 630 is shown in Fig. 16. "Set 'DLOG' characteristics" brings up a dialog box 640 shown in Fig. 18, which allows the user to title the window and set its refCon and procID. If the procID is not associated widi any of the pictures at the top of die main window, none of tiiose pictures are selected. "Preview at Full Size" displays die resource size as its normal display. "Autoposition" allows the system to position a window automatically when it is drawn. "Never Use Custom 'WDEF' for Drawing" when true (default) causes the resource to be drawn widi the standard 'WDEF' resource from e system file regardless of die value assigned to die procID. "Show Height & With" changes the editable fields (top, bottom, left, right) at die bottom of the window to show relative size position information. "Show Bottom & Right" changes the editable fields (left, right) at the bottom of the window to show absolute size/position information. "Use Color Picker" lets the user use an automatic color picker to set the colors of die various parts of the resource. The color picker is optional and is not necessary. When a user is interacting with window 600, shown in Fig. 16, the user can open up the DITL resource editor by double clicking on die picture 652 of the dialog box in die DLOG resource editor. Alternatively, die DITL resource editor can be invoked directly. When die DITL resource editor 654 (Fig. 19) is invoked, it displays an image of d e items from the list just as they are displayed in a dialog box. When an item is selected a dotted rectangle is drawn around it. The rectangle has a size box in its lower right corner so you can change the size of the rectangle. The DITL editor uses die Dialog Manager to display the DITL resources. This ensures that d e items look the same when the application displays diem as they do in ResEdit™. To create a new item, the user drags die type that the user wants from the item palate 656. To edit an existing item, the user double clicks on the item or select the item and press the return key. When an item is selected, ResEdit™ sets up the item editor shown as 660 in Fig. 20. In the case of the item editor 660, the user double clicked on item 9 shown in die DITL resource editor as reference 655 and shown in die DLOG picture as reference 658. Item 9 is StaticText. When the user double clicks on any of the items, an item editor is set up for that item. Each type of item has its own item editor. That is, there is a button item editor, a check box item editor, a radio button editor, etc. This is so because button, check box and radio button are predefined items and ResEdit™ can be programmed to edit those items. However, if die item is an IDO, ResEdit™ will not know the structure, behavior or definition of the IDO. Therefore, ResEdit™ will not have item editor for an IDO. Thus, each IDO must have its own editor embedded inside the IDO. This will be discussed below. Looking at Fig. 20, die user can edit the rectangle values by manipulating the numbers in boxes 662. Additionally, die text can be edited by moving the cursor into box 664, and widi die keyboard, typing new text. When using the DITL resource editor 654 of Fig. 19, the user has a DITL menu, shown in Fig. 21. The DITL menu 670, contains the following commands: "Renumber Items" allows a user to reorder items in the 'DITL' resource. "Set Item Number . . ." allows a user to specify a new number for a selected item. Some of e items may need to be renumbered. "Select Item Number . . ." allows a user to select an item by specifying its number. This is useful for items that are obscured by odier items or are outside die window. Once an item is selected, it can be opened by pressing die Return key. "Show Item Numbers" sets the display to show die number of each item in die 'DITL' resource. "Align To Grid" aligns the items on an invisible grid, die size of which defaults to 10 by 10 pixels. If die location of die item is changed while Align To Grid is on, die location is adjusted such diat the upper-left corner lies on die grid point nearest to die location given. If an item's size is changed, it is constrained to be a multiple of die current grid setting in each dimension. "Grid Settings . . ." allows for die setting of die horizontal and vertical grid sizes. These both default to 10 pixels. "Show All Items" adjusts die window size so that all items in the item list are visible in the window (or makes the window as large as the current screen size allows, if the screen is smaller). This command is present solely for convenience when editing die dialog items. "View As . . ." brings up a dialog box, diat allows die setting of die typeface and size in which Edit Text and Static Text items are displayed in die editor. This command does not actually change the resource itself. It is useful if a user is designing a dialog box diat is to be displayed using a different font from the default font of die editor, which is 12-point Chicago. "Balloon Help . . ." brings up a dialog box widi items that relate to Balloon Help in die system software. In regard to editing an IDO, die problem is that ResEdit™ will not know the structure of an IDO. Thus, the ResEdit™ will not know how to edit an IDO. The solution is that die IDOs must include methods diat tell ResEdit™ how to edit die IDO. For example, one of those methods is EditStaticData. Below is a pseudocode for the method EditStaticData. EDIT STATIC DATA void GroupingRect: : EditStaticData (void) { create a dialog to find out what the title should be (702) wait until die user is done widi die dialog (704) if the user selected "ok" { (706) get die title diat die user entered set my title property to be that title (708) } odierwise, the user selected cancel. Don't bother changing die title. (710) } After the various lines of pseudocode, diere is a number included in parendiesis. This number corresponds to the step in the flow chart of Fig. 22. The first step of the method is to create a dialog to get die Static Data from the user (700). The method dien creates (702) a dialog box 702a, which shows a rectangle 702b and has a predefined text string 702e in die rectangle 702b. At that point, the user can erase text 702e and type in new text. When the user is done entering information, die user can choose one of two buttons: OK button 702c or die cancel button 702d. By pushing eidier of die two buttons, die user is dismissing (704) die dialog box. If die user pressed cancel (710), die edits by die user will not be saved. If die user pressed OK (706), die user's inputs are stored (708). The next time the item is called, die text inputted by the user will show up in die dialog box. Finally the mediod is finished (712). All the instructions for doing diese edits will be found in die EditStaticData method. If ResEdit™ attempts to edit an IDO, ResEdit™ will see d at it is an IDO and pass control to die proper method. Other methods would be used to edit other aspects of various items. One skilled in die art will be able to use die description above to create odier types of edit mediods. The foregoing description of a preferred embodiment of die invention has been presented for purposes of illustration and description. It is not intended to be exhaustive or to limit the invention to die precise form disclosed, and obviously many modifications and variations are possible in light of die above teaching. The preferred embodiment was chosen and described in order to best explain die principles of die invention and its practical application to thereby enable odiers skilled in die art to best utilize the invention in various embodiments and widi various modifications as are suited to particular use contemplated. It is intended diat die scope of die invention be defined by die claims appended hereto. APPENDIX A Copyright Apple Computer, Inc. 1994 #define DialogI temDefini tionObj ect Class Source ^include <Drag.h> #include < Errors. h> #include < Resources. h> #include < Dialogs. h> #include "DialogltemDefinitionObject.ih" /* Initialize FUNCTION: Sets the IDO's data handle and its other fields at initialization time. INPUTS: itsDialog: the IDO's owning dialog itslndex: the IDO's index in its dialog's item list itsRect: the IDO's bounding rect theData: the IDO's data (to be defined by subclasses.) OUTPUTS: none RETURNS: void */ SOM_Scope void SOMLINK Initiali__e(DialogItemDefinitionObject *somSelf, Environment *ev) { DialogI temDefini tionObjectData *somThis = DialogI temDefinitionObjectGetData(somSelf); /* assume that we don't want idle time. It's the subclass's responsibility * to reset _fldleTimeWaitPeriod if it wants idle time. */ fldleTimeWaitPeriod = -1; } /* EditStaticData FUNCTION: Method called to allow easier manipulation of an IDO at creation time, so IDO editors (like future versions of ResEdit) can edit any IDO without knowing its characteristics. Any static data for an IDO item should be stored in properties (using the SetProperty utility routine) This method is never called by the dialog manager itself. INPUTS: none OUTPUTS: none RETURNS: void */ SOM Scope void SOMLINK EditStaticData(DialogItemDefinitionObject *somSelf, Environment *ev) { DialogltemDefinitionObjectData *somThis = DialogI ten_-DefinitionObjectGetData(somSelf); } /* Dispose FUNCTION: Dispose the IDO's dynamically allocated data INPUTS: none OUTPUTS: none RETURNS: void */ SOM Scope void SOMLINK Dispose(DialogItemDefinitionObject *somSelf, Environment *ev) { DialogltemDefinitionObjectData *somThis = DialogI temDefinitionObjectGetData(somSelf); } /* DoDraw FUNCTION: Draw the IDO. Assumes that the port has been set to the IDO's dialog, and that the port's state is being preserved. INPUTS: none OUTPUTS: none RETURNS: void */ SOM Scope void SOMLINK DoDraw(DialogItemDef_nitionObject *somSelf, Environment *ev) { DialogltemDefinitionObjectData *somThis = DialogItemDefinitionObjectGetData(somSel ; } /* Doldle FUNCTION: Do whatever is necessary at idle time. This is only called if the fNeedsIdleTime field was set when SetData was called. INPUTS: none OUTPUTS: none RETURNS: void */ SOM Scope void SOMLINK DoIdle(DialogItemDefιnitionObject *somSelf, Environment *ev) { DialogltemDefinitionObjectData *somThis = DialogltemDefinitionObjectGetData(somSelf); } /* DoActivate FUNCTION: Activate or DeActivate the IDO. INPUTS: isActive: true if we are activating, false if we are deactivating OUTPUTS: none RETURNS: void */ SOM Scope void SOMLINK DoActivate(DialogItemDefinitionObject *somSelf, Environment *ev, boolean isActive) { DialogltemDefinitionObjectData *somThis = DialogI .emDefinitionObjec-GetData(somSelf); } /+ CursorEnteredRect FUNCTION: adjust the cursor as it has just entered this item's bounds rect. INPUTS: none OUTPUTS: none RETURNS: void */ SOM_Scope void SOMLINK CursorEnteredRect(DialogItemDef_nitionObject *somSelf, Environment *ev) { DialogltemDefinitionObjectData *somThis = DialogltemDefinitionObjectGetData(somSelf); /* by default, IDO's have the arrow cursor */ InitCursor 0; /* mmm mmm m mmm«mitmmm#Mmmmmmmmm## m»m» SetKeyboardFocus FUNCTION: when the user has tabbed into or clicked into a new item, this method is called to allow the item to visually show its keyboard focus. INPUTS: isFocus: if true, then we are setting keyboard focus to this item; otherwise, focus is being removed from this item and it should be redrawn normally. OUTPUTS: RETURNS: */ SOM_Scope void SOMLINK SetKeybo__rdFocus(DialogItemDefinitionObject *somSelf, Environment *ev, boolean isFocus) { DialogltemDefinitionObjectData *somThis = DialogI temDefinitionObjectGetData(somSelf); } /* DoMouseDown FUNCΗON: the user has just clicked inside this IDO. react to the MouseDown event as necessary. INPUTS: theEvent: the MouseDown event that indicates the click in this IDO OUTPUTS: none RETURNS: true if we want to return this item's index to the app (through dialog select or ModalDialog) *./ SOM Scope boolean SOMLINK DoMouseDown(DialogItemDefinitionObject *somSelf, Environment *ev, EventRecord* theEvent) { DialogltemDefinitionObjectData *somThis = DialogΙtemDefιnitionObjectGetData(somSelf); /* Return statement to be customized: */ return; } /* ##########rø^^^ DoKeyDown FUNCΗON: The user has just pressed a key and this is the dialog's keyboard focus item, react to the keystroke as necessary. INPUTS: theEvent: the KeyDown event that indicates the keystroke in this IDO OUTPUTS: none RETURNS: true if we want to return this item's index to the app (through dialog select or ModalDialog) */ SOM_Scope boolean SOMLINK DoKeyDown(DialogItemDefinitionObject *somSelf, Environment *ev, EventRecord* theEvent) { DialogHemDefinitionObjectData *somThis = DialogI temDefinitionObjectGetData(somSelf); /* Return statement to be customized: */ return; } /* SimulateClick FUNCΗON: simulate the selection of this item (eg, when the equivalent shortcut key is pressed) INPUTS: none OUTPUTS: none RETURNS: void */ SOM Scope void SOMLINK SimulateClick(DialogItemDefinitionObject *somSelf, Environment *ev) { DialogltemDefinitionObjectData *somThis = DialogΙtemDefinitionObjectGetData(somSelf); } /* DragEnteredltem FUNCΗON: React to a drag entering this item's rect INPUTS: theDrag: the drag that has entered this item OUTPUTS: none RETURNS: true if this item can accept the given drag. */ SOM Scope boolean SOMLINK DragEnteredItem(DialogItemDefιnitionObject *somSelf, Environment *ev, DragReference theDrag) { DialogltemDefinitionObjectData *somThis = DialogI temDefinitionObjectGetData(somSelf); return false; } /* Draglnltem FUNCTION: continue to track drag in this item's rect INPUTS: theDrag: the drag that has entered this item OUTPUTS: none RETURNS: void */ SOM Scope void SOMLINK DragInItem(DialogItemDef_nitionObject *somSelf, Environment *ev, DragReference theDrag) { DialogltemDefinitionObjectData *somThis = DialogI temDefinitionObjectGetData(somSelf); } /* DragLeftltem FUNCTION: React to a drag leaving this item's rect INPUTS: theDrag: the drag that has entered this item OUTPUTS: none RETURNS: void */ SOM Scope void SOMLINK DragLeftItem(DialogItemDef_nitionObject *somSelf, Environment *ev, DragReference theDrag) { DialogltemDefinitionObjectData *somThis = DialogI temDefini tionObj ectGetData(somSelf) ; } /* Droplnltem FUNCTION: React to a drag manager reception in this item's rect INPUTS: theDrag: the drag that has entered this item OUTPUTS: none RETURNS: OSErr as appropriate. */ SOM Scope OSErr SOMLINK DropInItem(DialogItemDefinitionObject *somSelf, Environment *ev, DragReference theDrag) { DialogltemDefinitionObjectData *somThis = DialogltemDefinitionObjectGetData(somSelf); return dragNotAcceptedErr; } /* mm ummmmum m m u mmMMmm mm mm mm GetProperty FUNCTION: Get a property associated with this item INPUTS: propertyType: the type of property we're looking for propertySize: expected size of the property's data OUTPUTS: propertyData: the property's data actualPropertySize: the actual size of the property's data RETURNS: OSErr as appropriate. */ SOM Scope OSErr SOMLINK GetProperty (DialogI temDefimtionObject *somSelf, Environment *ev, OSType propertyType, void* propertyData, unsigned long propertySize, unsigned long* actualPropertySize) { DialogltemDefinitionObjectData *somThis = DialogI temDefinitionObjectGetData(somSelf); /* simply call through to the dialog manager's property managerment routines */ return GetDialogltemProperty (_fDialog, findex, propertyType, propertyData, propertySize, actualPropertySize); } /* SetProperty FUNCΗON: Set a property associated with this item INPUTS: propertyType: the type of property we're looking for propertySize: size of the property's data propertyData: the property's data OUTPUTS: none. RETURNS: OSErr as appropriate. */ SOM Scope OSErr SOMUNK SetProperty(DialogItemDefinitionObject *somSelf, Environment *ev, OSType propertyType, void* propertyData, unsigned long propertySize) { DialogltemDefinitionObjectData *somThis = DialogI temDefinitionObjectGetData(somSelf); /* simply call through to the dialog manager's property managerment routines */ return SetDialogltemProperty (_fDialog, findex, propertyType, propertyData, propertySize); } /* mm mm Mmm Mmmm mm mmMmM ititM GetResourceFromMyChain FUNCΗON: Just like toolbox GetResource, but sets up the resource chain such that this IDO can have its own associated resources. INPUTS: resType: type of the desired resource resID: ID of the desired resource OUTPUTS: none RETURNS: The resource or NULL if we had an error. (Check ResErrorO for details) */ SOM Scope Handle SOMUNK GetResourceFromMyChain(DialogItemDefinitionObject *somSelf, Environment *ev, OSType resType, short resID) { DialogltemDefinitionObjectData *somThis = DialogI temDefinitionObjectGetData(somSelf); Handle theResource; /* Set up the resource chain such that the ido's file is in it */ /* now, get the resource */ theResource = GetResource (resType, resID); /* restore the resource chain */ return theResource; APPENDIX B Copyright Apple Computer, Inc. 1994 #include <LowMemPriv.h> ^include <DialogsPriv.h> #include < MixedModePriv.h > /* CountDITL FUNCΗON: detrermines the number of items in the dialog item list INPUTS: theDialog: the dialog we're working with OUTPUTS: none RETURNS: number of items in the item list */ pascal DialogI temlndexl CountDITL (DialogRef theDialog) { DITLHeaderPtr theDITL; Handle itemUst; DialogPeek realDialog = (DialogPeek) theDialog; require (realDialog ! = NULL, NULLDialog); require (realDialog- > items ! = NULL, NULUtemlist); /* get the item list handle. If it has been purged, recover it */ itemList = realDialog- > items; if (*itemUst = = NULL) { LoadResource (itemList); require (ResErrorO = = noErr, ResourceError); } /* get the DITL to count the number of items, and return that number * (converted to 1 -based) */ theDITL = (DITLHeaderPtr) *itemUst; return theDITL- >numltems + 1; /* we get here if a problem was encountered trying to count the items. * return 0 as an error value */ ResourceError: NULUtemUst: NULLDialog: return 0; } /* GetDialogltem FUNCTION: given a dialog and an item index, return al pertinent information regarding the item at that index INPUTS: theDialog: the dialog we're working with itemNum: index of the item we want to find (1 -based) OUTPUTS: itemType: the item's type itemData: a handle to the item's data (NULL if we can't find an item at the given index) itemRect: the item's bounding rectangle RETURNS: void. *l pascal void GetDialogltem (DialogRef theDialog, DialogI temlndexl itemNum, DialogltemType *itemType, Handle *itemData, Rect *itemRect) { DITUtemPtr theltem; /* make sure our DITL list is loaded and locked */ SetupItemList ((DialogPeek) theDialog); /* get the item from our item list. If it exists (ie, if * itemNum is a valid index) then set our output * variables accordingly */ if (GetDialogltemCommon ((DialogPeek) theDialog, itemNum, &theltem)) { /* jam the appropriate values into our outputs */ *itemType = theltem- > itemType & OxFF; // low byte only *itemData = theltem- > itemHandle; *itemRect = theltem- > itemRect; /* if an invalid index, set itemData to NULL, indicating the * item doesn't exist */ else ♦ itemData = NULL; /* unlock the DITL list again */ DoneWithltemList ((DialogPeek) theDialog); /* SetDialogltem FUNCΗON: set the given specifications for the dialog item at the given index in its item list. INPUTS: theDialog: the dialog we're working with itemNum: index of the item we want to find (1 -based) itemType: the item's type itemData: a handle to the item's data itemRect: the item's bounding rectangle OUTPUTS: none. RETURNS: void. */ pascal void SetDialogltem (DialogRef theDialog, DialogI temlndexl itemNum, DialogltemType itemType, Handle itemData, const Rect *itemRect) { DITUtemPtr theltem; /* make sure our DITL list is loaded and locked */ SetupItemUst ((DialogPeek) theDialog); /* get the item from our item list. If it exists (ie, if * itemNum is a valid index) then set the item's attributes * accordingly */ if (GetDialogltemCommon ((DialogPeek) theDialog, itemNum, &theltem)) { /* jam the appropriate values into our outputs */ theltem- > itemType = (SignedByte) (itemType & OxFF); // low byte only theltem- > itemHandle — itemData; theltem- > itemRect = *itemRect; /* unlock the DITL list again */ DoneWithltemList ((DialogPeek) theDialog); /* SetDialogDefaultltem FUNCTION: Indicate which item in the given dialog box is the default. INPUTS: theDialog: the dialog that owns this item itemNum: index of the default item (1 -based) OUTPUTS: none RETURNS: noErr */ pascal OSErr SetDialogDefaultltem (DialogRef theDialog, Dialogltemlndexl itemlndex) { DialogPeek realDialog = (DialogPeek) theDialog; AuxDialogHandle auxDialog = GetAuxDialog (realDialog); DITUtemPtr defaultltem; OSErr theError; /* set the current default item */ realDialog- > dlgDefaultButtonltem = itemlndex; /* get the default item and set its control attribute accordingly */ if (GetDialogltemCommon (realDialog, itemlndex, &defaultltem) = = false) return -1; /* we should always have an auxDialog rec */ check (auxDialog != NULL); /* if this is a control and the control can draw itself in * "Default" mode, tell the control that it is default */ if (IsControlItem (defaultltem)) { ControlRef theControl; theControl = (ControlRef) defaultltem- > itemHandle; if (GetControlProperty (theControl, kSupportsDrawingCallsControlProperty, NULL, 0, NULL) = = noErr) { Boolean isDefault = true; theError = SetControlProperty (theControl, klsKeyboardFocusControlProperty, (void *) &isDefault, sizeof (isDefault)); require (theError ! = noErr, CouldNotSetProperty); (**auxDialog).drawDefaultButton = true; } else (**auxDialog).drawDefaultButton = false; } else (**auxDialog).drawDefaultButton = false; if (defaultltem = = 0) (**auxDialog).handleDefaultButton = false; else (**auxDialog).handleDefaultButton = true; return noErr; CouldNotSetProperty: return theError; } /* SetDialogCancelltem FUNCΗON: Indicate which item in the given dialog box is the cancel button. INPUTS: theDialog: the dialog that owns this item itemNum: index of the default item (1 -based) OUTPUTS: none RETURNS: noErr */ pascal OSErr SetDialogCancelltem (DialogRef theDialog, DialogI temlndexl cancelltem) { DialogPeek realDialog = (DialogPeek) theDialog; AuxDialogHandle auxDialog = GetAuxDialog (realDialog); /* set the current cancel item */ realDialog- > dlgCancelButtonl tem = cancelltem; /* we should always have an auxDialog rec */ check (auxDialog ! = NULL); /* remember whether or not we handle the default button */ if (cancelltem = = 0) (**auxDialog).handleCancelButton = false; else (**auxDialog).handleCancelButton = true; return noErr; I* Mmm mmmmmMmmmmmmmmMMmmMMMmmmm HideDialogltem FUNCΗON: Hide the given dialog item in the given dialog INPUTS: theDialog: the dialog we're working with itemNum: index of the item we want to hide OUTPUTS: none RETURNS: void */ pascal void HideDialogltem (DialogRef theDialog, Dialogltemlndexl itemNum) { GrafPtr oldPort; DialogPeek realDialog = (DialogPeek) theDialog; DITUtemPtr theltem; DialogltemlndexO newEditField; /* set the port and set up our item list */ BeginlnWind (realDialog, &oldPort); (void) GetDialogltemCommon (realDialog, itemNum, &theltem); require (theltem ! = NULL, CouldNotFindltem); itemNum--; /* if the item isn't already hidden, hide it */ if (IsVisibleltem (realDialog, itemNum)) { Rect oldRect; AuxDialogltemPtr auxltem; /* get the item's aux record =p it holds the visible attribute =p and * set the attribute to false */ auxltem = GetAuxDialogltem (realDialog, itemNum); auxltem- > isVisible = false; /* if the item is the active edit text field, deactivate * it before we move its rect */ if (realDialog- > editField = = itemNum) DeactivateEditField (realDialog); /* save the old item's rect and erase that area */ GetCompleteltemRect (theltem, &oldRect); EraseRect (&oldRect); // NNN does this have to change for MASH? /* if we just hid the active edit text item, find a new * one and activate it */ if (realDialog- > editField = = kNoEditField) { newEditField = GetDialogKeyboardFocusItem (realDialog, NULL); if (newEditField ! = kNoEditField) { DITUtemPtr newTextltem; (void) GetDialogltemCommon (realDialog, newEditField + 1, &newTextItem) ; SetDialogltemKeyboardFocus (realDialog, newEditField, newTextltem, 0, 0); } } /* if this item is a control, hide it */ if (IsControlItem (theltem)) HideControl ((ControlRef) theltem- >itemHandle); } CouldNotFindltem: EndTnWind (realDialog, oldPort); } /* ShowDialogltem FUNCΗON: Show the given dialog item in the given dialog INPUTS: theDialog: the dialog we're working with itemNum: index of the item we want to show (0-based) OUTPUTS: none RETURNS: void *./ pascal void ShowDialogltem (DialogRef theDialog, Dialogltemlndexl itemNum) { DialogPeek realDialog = (DialogPeek) theDialog; GrafPtr savedPort; DITUtemPtr theltem; /* save our port */ BeginlnWind (realDialog, &savedPort); /* get the item we're going to show, bail if twe can't find it */ (void) GetDialogltemCommon (realDialog, itemNum, &theltem); require (theltem ! = NULL, CouldNotFindltem); /* use a 0-based item offset */ itemNum--; /* if the item is invisible, show it */ if (! IsVisibleltem (realDialog, itemNum)) { Rect redrawRect; AuxDialogltemPtr auxltem; auxltem = GetAuxDialogltem (realDialog, itemNum); auxltem- > isVisible = true; /* if the dialog does not have a keyboard-focused item, and this * item can take keyboard focus, set focus onto this item */ if ((realDialog- >editField = = kNoEditField) &&. (IsKeyboardSelectableltem (realDialog, itemNum, theltem))) SetDialogltemKeyboardFocus (realDialog, itemNum, theltem, 0, 0); /* if this is a control, show it */ if (IsControlItem (theltem)) ShowControl ((ControlRef) theltem- > itemHandle); /* invalidate the item's rect so it will be redrawn */ GetCompleteltemRect (theltem, &redrawRect); InvalRect (&redrawRect); } CouldNotFindltem: EndlnWind (realDialog, savedPort); } /* DrawDialog FUNCΗON: Draws each item in the dialog INPUTS: theDialog: the dialog we want to draw OUTPUTS: none RETURNS: void */ pascal void DrawDialog (DialogRef theDialog) DialogPeek realDialog = (DialogPeek) theDialog; GrafPtr savedPort; // set the port BeginlnWind (realDialog, &savedPort); // draw all controls DrawControls (theDialog); // draw all the items DoForEachltem (realDialog, kDraw, NULL); // restore port EndlnWind (realDialog, savedPort); } /* M mm mmmm#um m #mm #m#MMMm mMM UpdateDialog FUNCΗON: Draws each item in the dialog that lies within the given update region INPUTS: theDialog: the dialog we want to draw updateRegion: the region in which items should be redrawn OUTPUTS: none RETURNS: void */ pascal void UpdateDialog (DialogRef theDialog, RgnHandle updateRegion) { WindowRef dialog Window = GetDialog Window (theDialog); DialogPeek realDialog = (DialogPeek) theDialog; GrafPtr savedPort; // set the port BeginlnWind (realDialog, &savedPort); // draw all controls DrawControls (dialog Window); // draw all the items DoForEachltem (realDialog, kUpdate, updateRegion); // restore port EndlnWind (realDialog, savedPort); } /* m mmm mmm mmmmm umm mmm nmm m mm um FindDialogltem FUNCΗON: returns the first dialog item whose rect encloses the given point INPUTS: theDialog: the dialog in which we are searching thePoint: the point that is enclosed by the item we return (nice english!) OUTPUTS: none RETURNS: index of the first item whose rect encloses the given point (0-based), or kNoItemHit (-1) if no item surrounds this point */ pascal DialogltemlndexO FindDialogltem (DialogRef theDialog, Point thePoint) { DITUtemPtr currentltem; DialogPeek realDialog = (DialogPeek) theDialog; Dialogltemlndexl numl terns = CountDITL (theDialog); DialogltemlndexO itemlndex; SetupItemUst (realDialog); currentltem = FirstDialogltem (realDialog); for (itemlndex = 0; itemlndex < numl terns; itemlndex + +) { if ((PtlnRect (thePoint, &currentltem- > itemRect)) && (TsVisibleltem (realDialog, itemlndex))) { DoneWithltemList (realDialog); return itemlndex; } currentltem = NextDialogltem (currentltem); } DoneWithltemList (realDialog); return kNoItemHit; } /* GetDialogltemCommon FUNCTION: Common code for getting a dialog item. Call this from inside the dialog manager to get an individula DITL item. INPUTS: theDialog: the dialog we're working with itemlndex: the index of the item we want (1-based) OUTPUTS: theltem: the item we want (or NULL if no such item exists) RETURNS: true if the index points to a real item */ Boolean GetDialogltemCommon (DialogPeek theDialog, Dialogltemlndexl itemlndex, DITUtemPtr *theltem) Dialogl temlndexl i; DITUtemPtr currentltem; require (itemlndex < = CountDITL ((DialogRef) theDialog), Badlndex); /* get the first item */ currentltem = FirstDialogltem (theDialog); /* skip ahead to each item in the DITL */ for (i = 1; i < itemlndex; i+ +) currentltem = NextDialogltem (currentltem); /* all done - set the index appropriately and return true, indicating success */ *theltem = currentltem; return true; Badlndex: *theltem = NULL; return false; } /* m m# mmmn mmmm mmmm #mmmm mm m m#tmι m GetCompleteltemRect FUNCΗON: Given an item, return the rect of its entire drawing area. (for edit text and default buttons, this area is outside the bounds of its rect) INPUTS: theltem: the item whose rect we want OUTPUTS: theRect: the entire drawing area rect for this item RETURNS: void -./ void GetCompleteltemRect (DITUtemPtr theltem, Rect *theRect) { SIntlό inset; if (IsEditTextltem (theltem)) inset = -3; else if (IsButtonControlItem (theltem)) inset = -kDefaultltemSlop; else inset = 0; /* get the item's rect and inset it */ *theRect = theltem- > itemRect; InsetRect (theRect, inset, inset); /* NextDialogltem FUNCΗON: skips to the next dialog item ahead of the one passed to us. Assumes we are passed a valid DITL item. INPUTS: currentltem: the current item in a DITL list OUTPUTS: none RETURNS: next item after currentltem in the DITL NOTE: will not check to see if we have gone beyond the end of the DITL! */ DITUtemPtr NextDialogltem (DITUtemPtr currentltem) { Ulntlό offset; /* calculate the offset from currentltem - take the base size and add the * length of the string at the end */ offset = DITUtemSizeWithNoData + StrLength (currentltem- > itemData); /* make the offset even */ if ((offset & 1) ! = 0) offset+ + ; return (DITUtemPtr) BYTE OFFSET (currentltem, offset); /* FirstDialogltem FUNCΗON: determines the first item in the dialog's item list. INPUTS: theDialog: the dialog we're working with OUTPUTS: none RETURNS: first item of the DITL of this dialog */ DITUtemPtr FirstDialogltem (DialogPeek theDialog) { DTTLHeader *.heDITL; /* get the dialog's items */ theDITL = (DTTLHeader *) *theDialog- > items; check (theDITL ! = NULL); /* return the first member of the item list */ return theDITL- > items; ^ m M M mM mn mm mmmm m mM mmmm mm n InitDialogltem FUNCΗON: Initializes the given dialog item as appropriate. INPUTS: theDialog: the dialog we're working with theltem: the DITL item within theDialog itemlndex: 0-based index of that item. OUTPUTS: none RETURNS: void */ void InitDialogltem (DialogPeek theDialog, DITUtemPtr theltem, DialogltemlndexO itemlndex) { require (theltem- > itemHandle = = NULL, DoNotlnitialize); if (IsControlItem (theltem)) InitControlItem (theDialog, theltem, itemlndex); /* text item - just create a handle to the text for the item from * its data and place it into the item's data handle */ else if ((IsStaticTextltem (theltem)) j | (IsEditTextltem (theltem))) { Handle textHandle; Ptr textPtr; SInt32 handleLength; OSErr theError; textPtr = (Ptr) &(theItem-> itemData[l]); handleLength = StrLength (theltem- > itemData); theError = PtrToHand (textPtr, &textHandle, handleLength); /* check for memory error */ check (theError = = noErr); theltem- > itemHandle = textHandle; } /* icon item - tiy for a color icon first, then a b/w one. Place * the icon into the item's handle */ else if (Islconltem (theltem)) { Handle iconHandle; IconDITUtemPtr iconDIT Item; /* this is a fixed-length item with the resource id * at the last word. */ iconDITUtem = (IconDITUtemPtr) theltem; iconHandle = (Handle) GetCIcon (iconDITUtem- >resourceID); /* no color icon? try for a black and white one */ if (iconHandle = = NULL) iconHandle = Getlcon (iconDITUtem- > resourcelD); iconDITUtem- > itemHandle = iconHandle; } /* picture item - try to get the corresponding picture * resource, and put it into the item's handle */ else if (IsPictureltem (theltem)) { PicHandle pictureHandle; PictureDITUteinPtr pictureDITUtem; /* this is a fixed-length item with the resource id * at the last word. */ pictureDITUtem = (PictureDITUtemPtr) theltem; pictureHandle = GetPicture (pictureDITUtem- > resourcelD); pictureDITUtem- > itemHandle = (Handle) pictureHandle; } /* new IDO item - Get the IDO and initialize it */ else if (IsIDOItem (theltem)) { OSErr theError; theError = InitlDOItem (theDialog, theltem, itemlndex); if (theError = = noErr) AddToIdleTimeltemList (theDialog, itemlndex); } /* otherwise, the item is a user field and doesn't need a special * initialization */ DoNotlnitialize: return; } /* ########rø######rø^^ DisposeDialogltem FUNCΗON: Disposes the given dialog item INPUTS: theltem: the item we're disposing OUTPUTS: none RETURNS: void */ static void DisposeDialogltem (DialogPeek theDialog, DITUtemPtr theltem, DialogltemlndexO itemlndex) { /* special case for controls. The window manager may have * disposed this already (in the case of a Dispose Window, * wherein it disposes all controls in its list. If this * is the case, then the window's controlUst will * be null, and don't bother doubly disposing the control */ if (IsControlItem (theltem)) { WindowRef dialogWindow; dialogWindow = GetDialogWindow ((DialogRef) theDialog); if (GetWindowControlList (dialogWindow) ! = NULL) DisposeControl ((ControlRef) theltem- > itemHandle); } else if (IsSUticTextltem (theltem) | | IsEditTextltem (theltem)) DisposeHandle (theltem- > itemHandle); else if (Islconltem (theltem)) { Size iconSize; iconSize = GetHandleSize (theltem- > itemHandle); if (iconSize > kBWIconSize) DisposeCIcon ((CIconHandle) theltem- > itemHandle); } else if (IsIDOItem (theltem)) { DisposelDOItem (theltem); RemoveFromldleTimeltem st (theDialog, itemlndex); } /* regardless, NULL out the item's handle */ theltem- > itemHandle = NULL; /* InitControUtem FUNCΗON: Initializes the given control item INPUTS: theDialog: the dialog we're working with theltem: the DITL item within theDialog itemlndex: 0-based index of that item. OUTPUTS: none RETURNS: void */ void InitControUtem (DialogPeek theDialog, DITUtemPtr theltem, DialogltemlndexO itemlndex) { ControlRef theControl; ControlDITUtemPtr controlDITUtem; CCTabHandle controlColorTable; WindowRef dialogWindow; dialogWindow = GetDialogWindow ((DialogRef) theDialog); /* if this is a resources based control, get the control * resource */ if (IsResourceControlItem (theltem)) { /* this DITL item is fixed length with the resource id * at the end. */ controlDITUtem = (ControlDITUtemPtr) theltem; /* get the new control and position it */ theControl = GetNewControl (controlDITUtem- > resourcelD, dialogWindow); MoveControl (theControl, theltem- > itemRect. left, theltem- > itemRect. top) ; } /* otherwise, create a new control. The CDEF's index is indicated in * the lower 2 bits of the type field */ else { SIntlό itemControlType; itemControlType = GetltemType (theltem) & 3; theControl = NewControl (dialogWindow, &(theItem-> itemRect), (ConstStr255Param) theltem- > itemData, true, 0, 0, 1, itemControlType, 0); } /* if this is a color control, set its accordingly */ controlColorTable = (CCTabHandle) NewHandle (0); if (MemError 0 • = noErr) { if (GetControlItemColorTable (theDialog, itemlndex, &controlColorTable)) SetControl Color (theControl, controlColorTable); DisposeHandle ((Handle) controlColorTable); } /* all done coloring. Validate the control's rectangle to avoid redraw, * and place it into the item's handle for future use. */ ValidRect (<S_(theItem- > itemRect)); theltem- > itemHandle = (Handle) theControl; } /* um u mmmmmuMM mmmmmmmmmmmm m mm#m#m # GetltemListCopy FUNCTION: Gets a copy of the item list for the given 'DITL' INPUTS: resourcelD: resource ID for the dialog's 'DITL'. OUTPUTS: theDITL: copy of the DITL resource. RETURNS: the appropriate error value (MemError or ResError) if we don't succeed; noErr if everything is cool. */ OSErr GetltemUstCopy (ResourcelD resourcelD, Handle *theDITL, ICTBHeaderHandle *theICTB) { OSErr theError; Handle ditlResource; Handle ictbResource; #if HandlesICTBs /* * get the ictb and copy it */ MyTempInsertROMMap (true); ictbResource = GetResource ('ictb', resourcelD); if (ictbResource ! = NULL) { theError = HandToHand (...ictbResource); if (theError ! = noErr) return theError; } /* fill in our copied ictb */ if (thelCTB ! = NULL) *theICTB = (ICTBHeaderHandle) ictbResource; #else *theICTB = NULL; #endif /* * get the DITL and copy it */ MyTempInsertROMMap (true); ditlResource = GetResource ('DITL', resourcelD); if (ditlResource ! = NULL) { theError = HandToHand (&ditlResource); if (theError ! = noErr) return theError; /* fill in our copied DITL */ if (theDITL ! = NULL) *theDITL = ditlResource; /* if we had a resource error, indicate this in the return value */ return ResError Q; /* SetupItemUst FUNCΗON: reloads the DITL resource if it was purged, locks it. also locks the AuxDialog handle. INPUTS: theDialog: the dialog we're working with OUTPUTS: none RETURNS: void */ void SetupItemList (DialogPeek theDialog) { Handle items; AuxDialogHandle auxDialog; items = theDialog- > items; /* sanity check */ check (items ! = NULL); /* purged? get it again. */ if (*items = = NULL) { LoadResource (items); /* we should check for ResError, check (ResErrorQ = = noErr); /* lock this down */ HLock (items); /* get and lock the dialog's Auxl terns */ auxDialog = GetAuxDialog (theDialog); if (auxDialog ! = NULL) HLock ((**auxDialog).auxItems); } /* DoneWithltemUst FUNCΗON: Call this when done working with the DITL; it unlocks the DITL handle and the aux dialog item handle INPUTS: theDialog: the dialog we're working with OUTPUTS: none RETURNS: void */ void DoneWithltemList (DialogPeek theDialog) { AuxDialogHandle auxDialog; HUnlock ((Handle) theDialog- > items); auxDialog = GetAuxDialog (theDialog); if (auxDialog ! = NULL) HUnlock ((**auxDialog).auxItems); } /* FrameDialogltem FUNCTION: Place a framed round rectangle around the given dialog item rect INPUTS: theRect: the rectangle around which we set the frame frameThickness: thickness of the frame in pixels frameCorner: oval width and height for the RoundRect frameOutset: outset from theRect that we set the frame for. OUTPUTS: none RETURNS: void */ void FrameDialogltem (Rect *theRect, SIntlό frameThickness, SIntlό frameCorner, SIntlό frameOutset) { /* frame the given rect at the given outset, thickness and corner */ PenSize (frameThickness, frameThickness); InsetRect (theRect, -frameOutset, -frameOutset); FrameRoundRect (theRect, frameCorner, frameCorner); /* restore theRect */ InsetRect (theRect, frameOutset, frameOutset); /* DoForEachltem FUNCΗON: cycle through each item in the list and apply the given function to each item. INPUTS: theDialog: the dialog we are working with function: indicates what to do with each item updateRegion: if NULL, apply to all items. If not null, apply only to items in this region. OUTPUTS: none RETURNS: void */ void DoForEachltem (DialogPeek theDialog, ScanDialogFunction function, RgnHandle updateRegion) { DITUtemPtr currentltem; Dialogltemlndexl itemlndex, numltems; /* get the number of items in the ditl */ numltems = CountDITL ((DialogRef) theDialog); /* loop through all the items in the list */ currentltem = FirstDialogltem (theDialog); for (itemlndex = 0; itemlndex < numltems; itemlndex+ +) { /* apply the given function to the current item */ switch (function) { case klnitialize: InitDialogltem (theDialog, currentltem, itemlndex); break; case kDraw: DrawDialogltem (theDialog, currentltem, itemlndex); break; case kDispose: DisposeDialogltem (theDialog, currentltem, itemlndex); break; case kUpdate: UpdateDialogltem (theDialog, currentltem, itemlndex, updateRegion); break; default: /* should never get here */ check (true); } /* move on to the next item in the list */ currentltem = NextDialogltem (currentltem); } } /* DrawDialogltem FUNCπON: draw the given dialog item in the given dialog INPUTS: theDialog: the dialog we are working with theltem: the item to be drawn itemlndex: the index of the item in the dialog's DITL (0-based) OUTPUTS: none RETURNS: void */ void DrawDialogltem (DialogPeek theDialog, DITUtemPtr theltem, DialogltemlndexO itemlndex) { UserltemUPP userltemProc; DialogSaveState saveState; Boolean doSaveAndRestore; /* if the item is invisible, don't draw anything */ if (! IsVisibleltem (theDialog, itemlndex)) return; /* if this item is a user field, draw it */ if (IsUserltem (theltem)) { /* get the user item's drawing proc - it's in its itemHandle */ userltemProc = (UserltemUPP) (theltem- > itemHandle); /* is there one? If so, save our state and call the proc to * draw it */ if (userltemProc ! = NULL) { /* if we're a color dialog, we have to save and restore * the dialog's state */ doSaveAndRestore = DialogHasColorltems (theDialog); if (doSaveAndRestore) { /* set our port, since the item will be drawn in the dialog */ SetPort ((GrafPtr) theDialog); /* preserve our dialog state - anything could happen */ SaveDialogState (theDialog, kDontRestoreTextEditlnfo, &saveState); SetEmulatorRegister (kRegisterDl, 1); /* call through to the user item procedure */ (void) CallUserltemProc (userltemProc, (DialogRef) theDialog, itemlndex + i); /* if we're a color dialog, restore the state */ if (doSaveAndRestore) { /* just in case the user item did something nasty... */ SetPort ((GrafPtr) theDialog); /* restore everything */ RestoreDialogState (theDialog, kDontRestoreTextEditlnfo, &saveState); } } } /* control item? only draw a hilight around it if it's * the keyboard foucs item */ else if (IsControlItem (theltem)) { #if ControlItemsAreKeyboardSelectable if (itemlndex = = theDialog- > editField) FrameDialogltem (&theltem- > itemRect, 1, 1, 1); #endif } /* text item? call through to DrawTextDialogltem */ else if (IsStaticTextltem (theltem)) DrawTextDialogltem (theDialog, theltem, itemlndex, true); else if (IsEditTextltem (theltem)) DrawTextDialogltem (theDialog, theltem, itemlndex, false); /* picture item? draw it */ else if (IsPictureltem (theltem)) { PicHandle thePicture; thePicture = (PicHandle) theltem- > itemHandle; if (*thePicture = = NULL) LoadResource ((Handle) thePicture); DrawPicture (thePicture, &theItem-> itemRect); else if (Islconltem (theltem)) { Size iconSize; iconSize = GetHandleSize (theltem- > itemHandle); if (iconSize < = 0) /* assume we have a b/w icon if the icon's size is * the standard b/w icon size. Otherwise, draw a * color icon. */ else if (iconSize = = kBWIconSize) Plotlcon (&theltem- > itemRect, theltem- > itemHandle); else PlotCIcon (<S_theItem-> itemRect, (CIconHandle) theltem- > itemHandle); } /* IDO - send it a draw message */ else if (IsIDOItem (theltem)) DrawIDOItem (theDialog, theltem); /* UpdateDialogltem FUNCΗON: if the given dialog item is inside the given region, draw it INPUTS: theDialog: the dialog we are working with theltem: the item to be drawn itemlndex: the index of the item in the dialog's DITL (0-based) updateRegion: the region in which items should be redrawn OUTPUTS: none RETURNS: void */ static void UpdateDialogltem (DialogPeek theDialog, DITUtemPtr theltem, DialogltemlndexO itemlndex, RgnHandle updateRegion) { Rect itemRect; /* get the item's rect, but give it a 4 pixel buffer (for the frame * around the default button) */ itemRect = theltem- > itemRect; InsetRect (&iteπ_Rect, -kDefaultBorderOutset, -kDefaultBorderOutset); /* if this rect lies within the update region, draw this item */ if (RectlnRgn (<S_itemRect, updateRegion)) DrawDialogltem (theDialog, theltem, itemlndex); } /* SetDialogltemKeyboardFocus FUNCΗON: Sets keyboard focus on the given dialog item INPUTS: theDialog: the dialog we're working with itemlndex: index of item we're setting focus on theltem: the item we're focusing on selStart, selEnd: if we are setting focus on an edit text item, the selection range for that item OUTPUTS: none RETURNS: void */ void SetDialogltemKeyboardFocus (DialogPeek theDialog, DialogltemlndexO itemlndex, DITUtemPtr theltem, TextSelectionPoint selStart, TextSelectionPoint selEnd) { check (IsKeyboardSelectableltem (theDialog, itemlndex, theltem)); if (IsEditTextltem (theltem)) ActivateNewEditField (theDialog, itemlndex, selStart, selEnd); else if (IsIDOItem (theltem)) SetlDOItemKeyboardFocus (theltem, true); #if ControlItemsAreKeyboardSelectable else if (IsControlItem (theltem)) { // tell the control it has focus } #endif else check (true); // we don't know how to select other items } /* UnsetDialogltemKeyboardFocus FUNCΗON: Unsets keyboard focus on the given dialog item INPUTS: theDialog: the dialog we're working with OUTPUTS: none RETURNS: void */ void UnsetDialogltemKeyboardFocus (DialogPeek theDialog) { DialogltemlndexO itemlndex; DITUtemPtr theltem; itemlndex = theDialog- > editField; /* tiy to get the item that has keyboard focus. If there * is an item, unset the focus */ if (GetDialogltemCommon (theDialog, itemlndex + 1 , &theltem)) { if (IsEditTextltem (theltem)) DeactivateEdi .Field (theDialog); else if (IsIDOItem (theltem)) SetlDOItemKeyboardFocus (theltem, false); #if ControlItemsAreKeyboardSelectable else if (IsControlItem (theltem)) { // tell the control it lost its focus } #endif } /* GetDialogKeyboardFocusItem FUNCTION: return the current keyboard focus item in the dialog. If none is focused, search for the first item in the DITL that can take keyboard focus INPUTS: theDialog: the dialog we are working with OUTPUTS: editltem: the edit field's DITL item (NULL if none found) If passed in as NULL, don't fill it in RETURNS: the index of the item in the list (kNoEditField if none found) - 0 based */ DialogltemlndexO GetDialogKeyboardFocusItem (DialogPeek theDialog, DITUtemPtr *editltem) { /* if we already have an focused item, return that item */ if (theDialog- >editField ! = kNoEditField) { DITUtemPtr dummyltem; /* if there is an item that corresponds to editField's * index, return that item and its index */ if (GetDialogltemCommon (theDialog, theDialog- > editField + 1, &dummyltem)) { if (editltem ! = NULL) *editltem = dummyltem; return theDialog- > editField; } } /* otherwise, scan the list of items, and return the first * visible keyboard focus item we find */ else { DITUtemPtr currentltem; DialogltemlndexO itemlndex, numltems; /* get the number of items in the ditl */ numltems = CountDITL ((DialogRef) theDialog); /* loop through all of the items in this dialog */ currentltem = FirstDialogltem (theDialog); for (itemlndex = 0; itemlndex < numltems; itemlndex + +) { /* if the current item's type is edit text and it's visible, we're * done - return this item */ if ((IsKeyboardSelectableltem (theDialog, itemlndex, currentltem)) && (IsVisibleltem (theDialog, itemlndex))) { if (editltem ! = NULL) *editltem = currentltem; return itemlndex; } /* move on to the next item */ currentltem = NextDialogltem (currentltem); } /* we get here if we didn't find an edit field. Indicate thus in the return value */ if (editltem ! = NULL) *editltem = NULL; return kNoEditField; }

Claims: CLAIMS What is claimed is: 1. A system for providing an item in a dialog box, comprising: a class structure including a base class and a subclass, said base class having a first method adapted to be inherited by said subclass, said method being capable of defining a behavior of die item; a resource adapted to store a reference to said subclass; and a manager, adapted to be in communication with said resource such that said manager can use said reference to find said referenced subclass, said manager adapted to manipulate said item according to die behavior defined in said referenced subclass. 2. A system according to claim 1, wherein: said first method is adapted to define a first behavior; said base class further including a second method adapted to define a second behavior; and said first subclass inherits said first method and overrides said second mediod. 3. A system according to claim 2, 7, wherein said class structure further includes a second subclass, said second subclass inherits said second mediod and overrides said first method. 4. A system according to claim 1, wherein said first subclass includes a second mediod adapted to define how die item can be drawn. 5. A system according to claim 1, wherein said first subclass includes a second method adapted to define how die item reacts to a given event. 6. A system according to claim 1, wherein said first subclass includes a method adapted to define how die item can be edited. 7. A system according to claim 1 , wherein said class structure is hierarchical. 8. A system according to claim 1, wherein: said first subclass includes at least two mediods; and said manager can enter said first subclass at either of said two mediods. 9. A system according to claim 1, wherein: said first subclass includes at least diree mediods; and said manager can enter said first subclass at any of said diree methods. 10. A system according to claim 1, wherein said first subclass can be recompiled while remaining binary compatible with said base class. 11. A system according to claim 1, wherein said first subclass is adapted to be compiled without compiling said resource. 12. A system according to claim 1, wherein said first subclass is adapted to be compiled widiout compiling said manager. 13. A system according to claim 1, wherein: said resource includes an item list; said item list includes a first entry; and said first entry having an item type, an attribute and said reference. 14. A system for providing an item in a dialog box, comprising: a class library including a first class, said first class including a first mediod adapted to be inherited by a second class, said second class being capable of defining a behavior of the item; a resource adapted to reference said second class; and a manager, adapted to be in communication with said resource such diat said manager can use said reference to set up an object of said second class, said manager adapted to manipulate said item according to die behavior defined in said second class. 15. A system according to claim 14, wherein: said first class includes a second mediod; and said second class overrides said second mediod, creating a new method. 16. A system according to claim 15, wherein said manager manipulates said item according to instructions in said new method. 17. A system according to claim 15, wherein: said manager enters said object at said first method in response to a first event; and said manager enters said new mediod in response to a second event. 18. A system according to claim 14, wherein any class in said class library can be compiled widiout compiling said manager. 19. A system for providing an item in a dialog box, comprising: class means for storing classes in an object oriented fashion, at least two classes capable of defining a behavior of die item; an application, said application including a resource means for referencing one of said classes, said referenced class defining a behavior of die item; and dialog means for managing the dialog, said dialog means including means of reacting to events, as defined by die referenced class. 20. A system according to claim 19, wherein the class means can be edited and compiled widiout compiling the dialog means or the application. 21. A system according to claim 19, wherein die referenced class includes a plurality of methods, each mediod defining a behavior of die item. 22. A system according to claim 21, wherein the dialog means reacts to events by executing the behavior defined in an appropriate method. 23. A structure for defining items in a dialog box, said dialog box being used as part of an application, said application including a resource adapted to store and reference information relevant to said dialog box, said information used by a manager to manipulate the dialog, said structure comprising: a base class, said base class including a plurality of methods, said methods adapted to define item behavior; and a first subclass capable of inheriting a first subset of said plurality of methods and capable of overriding a second subset of said plurality of methods thereby creating a third set of mediods; an object, being an instance of said first subclass, said object capable of being referenced by said resource, said object capable of receiving messages invoking one mediod of said first subset, and die manager can enter the object at any method in said first subset and said diird set. 24. A structure according to claim 23, wherein one of said third set of methods defines how said object can be edited. 25. A structure according to claim 23, wherein one of said diird set of mediods defines how to draw a particular item. 26. A dialog interface definition object for defining an item in a dialog box, said dialog box being used as part of an application, said application including a resource adapted to store and reference information relevant to said dialog box including information relevant to said object, said object being an instance of a class in a class library, said information used by a manager to manipulate the dialog, said object comprising: an inherited method capable of defining a first behavior of the item; and an overriding mediod capable of defining a second behavior of die item, said overriding mediod capable of being inherited by a subclass object. 27. An object according to claim 26, wherein said one of said diird set of methods defines how said object can be edited. 28. An object according to claim 26, further including attributes. 29. A method for using an item in a dialog box, comprising the steps of: (a) executing an instruction calling for the dialog box; (b) reading a resource associated with the dialog box, including the steps of: reading a list of items to be presented in the dialog; following a reference, in the list of items, which references an object; (c) waiting for a first event; and (d) after step (c), executing a first method in die object, widiout executing odier mediods, said first method being associated widi said first event. 30. A method according to claim 29, further including die step of: (e) waiting for a draw event; and (f) after step (e), executing a draw mediod, widiout executing odier methods. 31. A method according to claim 29, further including die step of: (g) waiting for an edit event; and (h) after step (g), executing an edit mediod, widiout executing odier methods. 32. A mediod for defining die behavior of a new item to be used in a dialog box, die mediod comprising die steps of: inheriting a first method from a higher class, said first method defining a first task to be performed at a first event; overriding a second mediod from a super class including die step of defining a second task to be performed at a second event; and creating an application, said application including a reference patii to said first and second methods. 33. A mediod according to claim 32, further including die step of defining attributes. 34. A method according to claim 32, further including die steps of: (a) compiling die application, widiout compiling die second method; and (b) after step a, compiling the second method, widiout compiling the application. 35. A method according to claim 32, further including die steps of: (a) compiling the application; and (b) after step a, editing die second mediod, widiout compiling the application. 36. A method according to claim 32, wherein said first mediod is independent of said application. 37. A method according to claim 32, further including the step of overriding a diird method from a superclass, including die step of providing instructions for editing die new item. 38. A method according to claim 32, further including die step of providing die ability to enter the behavioral definition at die first method and at die second mediod.

Inventors: CIRNE LEWIS K, CIRNE, LEWIS, K.
Applicants: APPLE COMPUTER, APPLE COMPUTER, INC.
Application year: 1995
Main classification: G06F9
IPC codes: G06F9