Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Macintosh Toolbox Essentials /


Chapter 5 - Control Manager

This chapter describes how your application can use the Control Manager to create
and manage controls. Controls are onscreen objects that the user can manipulate with the mouse. By manipulating controls, the user can take an immediate action or change settings to modify a future action. For example, a scroll bar control allows a user to immediately change the portion of the document that your application displays, whereas a pop-up menu control for baud rate might allow the user to change the rate by which your application handles subsequent data transmissions.

Read this chapter to learn how and when to implement controls. Virtually all applications need to implement controls, at least in the form of scroll bars for document
windows. You use Control Manager routines, resources, and data structures to implement scroll bars in your application's document windows.

The other standard Macintosh controls are buttons, checkboxes, radio buttons, and pop-up menus. You can use the Control Manager to create and manage these controls, too. Alternatively, you can use the Dialog Manager to implement these controls in alert boxes and dialog boxes more easily. (You typically use an alert box to warn a user of
an unusual situation, and you typically use a dialog box to ask the user for information necessary to carry out a command.) The chapter "Dialog Manager" in this book describes in detail how to implement controls in alert and dialog boxes. However, in certain situations--for instance, when you need to implement highly complex dialog boxes--you may want to use Control Manager routines to manage these types of controls directly; read this chapter for information on how to do so.

For scrolling lists of graphic or textual information (similar to the list of files that system software presents after the user chooses the Open command from the File menu), your application can use the List Manager to implement the scroll bars. See the chapter "List Manager" in Inside Macintosh: More Macintosh Toolbox for more information.

The Control Manager offers routines for automatically handling user-generated
mouse events in controls and redrawing controls in response to update events. For further information about events and event handling, see the chapter "Event Manager" in this book.

You typically use a control resource--a resource of type 'CNTL'--to specify the type, size, location, and other attributes of a control. See the chapter "Introduction to the Macintosh Toolbox" in this book for general information about resources; detailed information about the Resource Manager and its routines is provided in the chapter "Resource Manager" in Inside Macintosh: More Macintosh Toolbox.

Every control you create must be associated with a particular window. All of the controls for a window are stored in a control list referenced by the window's window record. See the chapter "Window Manager" in this book for general information about windows. (When you use the Dialog Manager to implement a control, the Dialog Manager associates it with its respective dialog box or alert box, as described in the chapter "Dialog Manager.")

This chapter provides an introduction to the use of controls, and then discusses how
you can


Chapter Contents
Introduction to Controls
Buttons
Checkboxes
Radio Buttons
Pop-Up Menus
Scroll Bars
Other Controls
Active and Inactive Controls
The Control Definition Function
About the Control Manager
Using the Control Manager
Creating and Displaying a Control
Creating a Button, Checkbox, or Radio Button
Creating Scroll Bars
Creating a Pop-Up Menu
Updating a Control
Responding to Mouse Events in a Control
Determining a Mouse-Down Event in a Control
Tracking the Cursor in a Control
Determining and Changing Control Settings
Scrolling Through a Document
Scrolling in Response to Events in the Scroll Box
Scrolling in Response to Events in Scroll Arrows and Gray Areas
Drawing a Scrolled Document Inside a Window
Moving and Resizing Scroll Bars
Defining Your Own Control Definition Function
Control Manager Reference
Data Structures
The Control Record
The Auxiliary Control Record
The Pop-Up Menu Private Data Record
The Control Color Table Record
Control Manager Routines
Creating Controls
Drawing Controls
Handling Mouse Events in Controls
Changing Control Settings and Display
Determining Control Values
Removing Controls
Application-Defined Routines
Defining Your Own Control Definition Function
Defining Your Own Action Procedures
Resources
The Control Resource
The Control Color Table Resource
The Control Definition Function
Summary of the Control Manager
Pascal Summary
Constants
Data Types
Control Manager Routines
Application-Defined Routines
C Summary
Constants
Data Types
Control Manager Routines
Application-Defined Routines
Assembly-Language Summary
Data Structures
Global Variables

Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996