Chapter 8 - Control Panels
This chapter describes how to develop a control panel to control the settings of systemwide features and how to create an extension for the standard Monitors control panel.Create a control panel if you want to provide users with the ability to set preferences for global values or systemwide features. Some of the standard control panels allow users to change the speaker volume, set the date and time, and select a different desktop pattern. Although you must not develop control panels to replace the standard ones, you can create additional control panels for any features that meet the stipulations for control panels. If the feature that you want to implement as a control panel is complex or if its interface requires menu items and multiple, layered dialog boxes, you should create a small application instead of a control panel.
If you are a manufacturer of a video device, you can extend the standard Monitors control panel to include items that give users a simple way to control the features of your device. To do this, read the sections in this chapter that describe how to create an extension to the Monitors control panel. The standard Monitors control panel lets the user define the monitor's display of colors and, if more than one monitor is connected to the system, the relative position of each monitor. The Monitors control panel manages any extensions to it that you create.
To use this chapter, you should be familiar with how to create
'BNDL'
,'ICN#'
,'FREF'
, signature, and'DITL'
resources as described in the chapters "Finder Interface" and "Dialog Manager" of Inside Macintosh: Macintosh Toolbox Essentials. You should also understand how to handle events and change settings of controls, as explained in the chapters "Event Manager" and "Control Manager" of Inside Macintosh: Macintosh Toolbox Essentials.The Finder, which performs a number of services for your control panel, uses the Dialog Manager to display your control panel's dialog box. In turn, the Dialog Manager uses the Control Manager to create and display buttons, radio buttons, checkboxes, and pop-up menus. Your control panel needs to make these controls active and inactive in response to messages from the Finder. If you include editable text items in your control panel, the Dialog Manager uses TextEdit to handle associated editing tasks. (For general information on TextEdit, see the chapter "TextEdit" in Inside Macintosh: Text.)
This chapter provides a general introduction to control panels and introduces the Monitors control panel. It then describes how to
- define the user interface for a control panel
- create the resources for a control panel, including the rectangle and item list resources
- specify the font for your control panel's text
- write a control panel function
- write an extension for the Monitors control panel
Chapter Contents
- About Control Panels
- Control Panels
- A Control Panel's Resources
- The Finder's Interaction With Control Panels
- Control Panels and System Extensions
- About User Documentation for Control Panels
- The Monitors Control Panel and Extensions to It
- Creating Control Panel Files
- Defining the User Interface for a Control Panel
- Creating a Control Panel's Resources
- Resource IDs for Control Panels
- Defining the Control Panel Rectangles
- Creating the Item List Resource
- Defining the Icon for a Control Panel
- Specifying the Machine Resource
- Creating the File Reference, Bundle, and Signature Resources
- Providing Additional Resources for a Control Panel
- Specifying the Font of Text in a Control Panel
- Creating a Font Information Resource
- Defining Text in a Control Panel as User Items
- Writing a Control Panel Function
- Determining If a Control Panel Can Run on the Current System
- Initializing the Control Panel Items and Allocating Storage
- Responding to Activate Events
- Responding to Keyboard Events
- Responding to Mouse Events
- Responding to Update Events
- Handling Text Defined as User Items
- Responding to Null Events
- Responding to the User Closing the Control Panel
- Handling Edit Menu Commands
- Handling Errors
- Creating an Extension for the Monitors Control Panel
- Designing the User Interface for a Monitors Extension
- Creating the Required Resources for a Monitors Extension
- Creating a Card Resource for a Monitors Extension
- Defining a Rectangle for a Monitors Extension
- Creating an Item List Resource for a Monitors Extension
- Creating the Monitor Code Resource
- Supplying Optional Resources for a Monitors Extension
- Specifying an Icon for the Options Dialog Box
- Specifying Version Information
- Providing an Alternative Name for a Video Card
- Supplying Gamma Table Resources
- Creating File Reference, Bundle, and Signature Resources
- Including a System Extension Resource
- Writing a Monitors Extension Function
- Handling the Startup Message
- Performing Initialization
- Responding to a Click in the OK Button
- Responding to a Cancel Request
- Handling Mouse Events for a Monitors Extension
- Handling Keyboard Events
- Including Another Control Panel Definition in a Monitors Extension File
- Control Panels Reference
- Application-Defined Routines
- Control Device Functions
- Monitors Extension Functions
- Resources
- The Machine Resource
- The Rectangle Positions Resource
- The Font Information Resource
- The Control Device Function Code Resource
- The Card Resource
- The Monitor Code Resource
- The Rectangle Resource
- Summary of Control Panels
- Pascal Summary
- Constants
- Application-Defined Routines
- Control Device Functions
- Monitors Extension Functions
- C Summary
- Constants
- Application-Defined Routines
- Control Device Functions
- Monitors Extension Functions