Carbon Programming is a comprehensive guide that is logically
organized, compatible with the current system software, and includes
ready-to-run demonstration programs within each chapter. The book covers Mac
programming using the Carbon API. Topics include:
- Event Manager;
- Appearance Manager;
This book is for Mac programmers who are familiar with the C language but who
are new to the Carbon API. Professionals coming to the Macintosh and computer
science students will benefit from the book as a learning tool relating
specifically to the Macintosh computer and the Carbon API.
Table of Contents
1. System Software, PowerPC Run-Time Environment,
Managing Memory, and Resources.
System Software. PowerPC Run-Time Environment.
Managing Memory—Mac OS 8/9. Managing Memory—Mac OS X Considerations. Resources.
Main Memory Manager Data Types and Functions. Main Resource Manager Constants,
Data Types, and Functions. Demonstration Program SysMemRes Listing.
Demonstration Program SysMemRes Comments.
2. The Classic Event Manager—Low-Level and Operating System Events.
The Two Event Managers. Overview of the Classic
Event Model. Obtaining Information About Events. Flushing the Operating System
Event Queue. Handling Events. Handling Events in Alerts and Dialogs. The 'SIZE'
Resource. Main Event Manager Constants, Data Types and Functions. Demonstration
Program LowEvents Listing. Demonstration Program LowEvents Comments.
Introduction—Types of Menus. Pull-Down Menus.
Hierarchical Menus. Pop-Up Menus. Menu Objects, Menu IDs and Item Numbers,
Command IDs, and Menu Lists. Creating Your Application's Menus. Providing Help
Balloons (Mac OS 8/9). Changing Menu Item Appearance. Adding Items to a Menu.
Associating Data With Menu Items. Handling Menu Choices. Hiding and Showing the
Menu Bar. Accessing Menus From Alerts and Dialogs. Main Menu Manager Constants,
Data Types, and Functions. Demonstration Program Menus1 Listing. Demonstration
Program Menus1 Comments. Demonstration Program Menus2 Listing. Demonstration
Program Menus2 Comments.
4. Introduction to Windows.
Scope of This Chapter. Window Basics. Types of
Windows. Window Regions. Controls and Control Lists. The Window List. The
Graphics Port and the Window Object. Events in Windows. Creating Your
Application's Windows. Managing Multiple Windows and Associated Data. Handling
Events. Manipulating Windows. Providing Help Balloons (Mac OS 8/9). Main Window
Manager Constants, Data Types, and Functions. Demonstration Program Windows1
Listing. Demonstration Program Windows1 Comments.
5. Carbon and Universal Procedure Pointers.
Introduction. The 68LC040 Emulator and the Mixed
Mode Manager. Universal Procedure Pointers and Carbon. Creation/Disposal
Functions Relevant to Demonstration Programs.
6. The Appearance Manager.
History. The Appearance Manager. Main Constants,
Data Types, and Functions. Demonstration Program Appearance Listing.
Demonstration Program Appearance Comments.
7. Introduction to Controls.
Introduction. Standard Controls. The Control
Definition Function. The Basic Controls, Primary Group Boxes (Text Title
Variant), and User Panes. Activating, Deactivating, Hiding, Showing, Enabling,
and Disabling Controls. Visual Feedback from the Basic Controls. Embedding
Controls. Getting and Setting Control Data. The Control Object. Creating
Controls. Updating, Moving, and Removing Controls. Handling Mouse Events in
Controls. Determining and Changing Control Settings, and Getting a Control's
Kind. Moving and Resizing Scroll Bars. Scrolling Operations With Scroll Bars.
Small Versions of Controls. Main Control Manager Constants, Data Types and
Functions Relevant to the Basic Controls, Primary Group Box and User Panes.
Demonstration Program Controls1 Listing. Demonstration Program Controls1
Comments. Demonstration Program Controls2 Listing. Demonstration Program
8. Dialogs and Alerts.
Introduction. Alert Types, Modalities, and
Levels. Dialog Types and Modalities. Window Types for Alerts and Dialogs.
Content of Alerts and Dialogs. Removing Dialogs. Creating and Removing Alerts.
Creating Dialogs. Items in Dialogs. Displaying Alerts and Dialogs. Handling
Events in Alerts and Dialogs. Closing and Disposing of Dialogs. Creating
Displaying and Handling Window-Modal (Sheet) Alerts and Dialogs. Balloon Help
for Dialogs—Mac OS 8/9. Help Tags for Dialogs—Mac OS X. Main Dialog Manager
Constants, Data Types and Functions. Relevant Window Manager Functions (Mac OS X
Only). Demonstration Program DialogAndAlerts Listing. Demonstration Program
9. The Finder and the Application.
Introduction. An Application's Required
Resources. Application Signature, File Creator, and File Types. Icons for the
Finder. File Reference ('FREF') Resources. The Bundle ('BNDL') Resource. The
Version ('vers') Resource. Finder Icon Help ('hfdr') Resource—Mac OS 8/9.
Missing Application and Application-Missing Resources— Mac OS 8/9. The 'plst'
Resource and Information Property Lists. Application Launching by the Finder.
The Finder and the Catalog File. Preferences, Temporary Items, and Trash
Folders— Using FindFolder. Stationery Pads. Using Aliases. Mac OS 9 Packages and
Mac OS X Bundles. Relevant Constants, Data Types, and Functions. Demonstration
10. Apple Events.
Introduction. Apple Event Attributes and
Parameters. Data Structures Within Apple Events. Handling Apple Events. Required
Apple Events—Contents and Required Action. Main Apple Event Manager and
Appearance Manager Constants, Data Types, and Functions Relevant to Required
Apple Events and Appearance Manager Apple Events. Demonstration Program
AppleEvents. Demonstration Program AppleEvents Comments.
11. QuickDraw Preliminaries.
QuickDraw and Imaging. RGB Colors and Pixels.
Color and the Video Device. Graphics Port. Translation of RGB Colors to Pixel
Values. Graphics Devices and GDevice Structures. Other Graphics Managers. Coping
with Multiple Monitors. Relevant QuickDraw Constants, Data Types, and Functions.
Demonstration Program PreQuickDraw Listing. Demonstration Program PreQuickDraw
12. Drawing with QuickDraw.
Introduction. The Coordinate Plane, Points,
Rectangles, and Regions. The Graphics Pen, Foreground and Background Colors,
Pixel Patterns and Bit Patterns, and Transfer Modes. Drawing Lines and Framed
Shapes. Drawing Painted and Filled Shapes. Erasing and Inverting Shapes. Drawing
Pictures. Drawing Text. Copying Pixel Images Between Graphics Ports. Scrolling
Pixels in the Port Rectangle. Manipulating Rectangles and Regions. Highlighting.
Drawing Other Graphics Entities. Saving and Restoring the Graphics Port Drawing
State. Main QuickDraw Constants, Data Types and Functions. Relevant Appearance
Manager Data Types and Functions. Demonstration Program QuickDraw Listing.
Demonstration Program QuickDraw Comments.
13. Offscreen Graphics Worlds, Pictures, Cursors, and Icons.
Offscreen Graphics Worlds. Pictures. Cursors.
Icons. Main Constants, Data Types and Functions—Offscreen Graphics Worlds. Main
Constants, Data Types and Functions—Pictures. Main Constants, Data Types and
Functions—Cursors. Appearance Manager Constants, Data Types and
Functions—Cursors. Main Constants, Data Types and Functions—Icons. Demonstration
Program GworldPicCursIcn Listing. Demonstration Program GWorldPicCursIcn
14. More on Controls.
Introduction. Control Descriptions. Small
Versions of Controls. Idle Processing. Defining Your Own Key Filter Function.
Defining Your Own Edit Text Validation Function. Defining Your Own User Pane
Functions. Main Constants, Data Types and Functions. Demonstration Program
Controls3 Listing. Demonstration Program Controls3 Comments.
15. Carbon Printing.
The Carbon Printing Manager. Printer Drivers.
Page and Paper Rectangles. Page Setup Dialogs and Print Dialogs. Printing
Sessions—The PMPrintSession Object. The PMPageFormat and PMPrintSettings
Objects. Printing a Document. Text on the Screen and the Printed Page.
Customizing the Page Setup and Print Dialogs. Displaying Page Setup and Print
Dialogs As Window-Modal (Sheet) Dialogs. Saving and Retrieving a Page Format
Object. Printing from the Finder—Mac OS 8/9. Main Carbon Printing Manager
Constants, Data Types and Functions. Demonstration Program CarbonPrinting
Listing. Demonstration Program CarbonPrinting Comments.
16. More on Windows.
Introduction. Floating Windows. Utility and
Toolbar Windows. Window Proxy Icons. Window Path Pop-Up Menus. Transitional
Window Animation and Sounds. Creating and Storing Windows. Accessing Window
Information. Moving and Positioning Windows. Associating Data with Windows.
Adding To and Removing From the Update Region. Setting Content Region Color and
Pattern. Window Scrolling. The Window Menu. Live Window Resizing. Main
Constants, Data Types, and Functions. Demonstration Program Windows2 Listing.
Demonstration Program Windows2 Comments.
17. The Carbon Event Manager.
Overview. Event Reference, Class, and Type.
Standard Event Handlers. The Application's Event Handlers. Sending and
Explicitly Propagating Events. Event Timers. Getting Event Time. Other Aspects
of the Carbon Event Model. Main Constants, Data Types, and Functions. Relevant
Window Manager Constants and Functions. Demonstration Program CarbonEvents1
Listing. Demonstration Program CarbonEvents1 Comments. Demonstration Program
CarbonEvents2 Listing. Demonstration Program CarbonEvents2 Comments.
18. Files and Navigation Services.
Introduction. Files. Navigation Services. Main
File Manager Constants, Data Types and Functions. Relevant Resource Manager
Functions. Relevant Finder Interface Functions. Main Navigation Services
Constants, Data Types, and Functions. Demonstration Program Files Listing.
Demonstration Program Files Comments.
19. More on Resources and Core Foundation Preferences.
Introduction. Search Path for Resources.
Releasing and Detaching Resources. Creating, Opening, and Closing Resource
Forks. Reading and Manipulating Resources. Writing Resources. Partial Resources.
Application Preferences. Main Resource Manager Constants, Data Types and
Functions. Main Core Foundation Preferences Services Functions. Demonstration
Program MoreResources Listing. Demonstration Program MoreResources Comments.
20. Carbon Scrap.
The Carbon Scrap Manager and the Scrap. Private
Scrap. TextEdit, Dialogs, and Scrap. Main Carbon Scrap Manager Constants, Data
Types, and Functions. Demonstration Program CarbonScrap Listing. Demonstration
Program CarbonScrap Comments.
21. Text, Textedit, Dates, Times, and Numbers.
Introduction. More on Text. Introduction to
TextEdit. Monostyled TextEdit. Multistyled TextEdit. Formatting and Displaying
Dates, Times, and Numbers. Main TextEdit Constants, Data Types and Functions.
Main Constants, Data Types and Functions Relating to Dates, Times and Numbers.
Demonstration Program MonoTextEdit Listing. Demonstration Program MonoTextEdit
Comments. Demonstration Program DateTimeNumbers Listing. Demonstration Program
22. Lists and Custom List Definition Functions.
Introduction to Lists. Appearance and Features
of Lists. Selection of Cells Using the Mouse. Selection of Cells Using the
Keyboard. Creating, Disposing of, and Managing Lists. The List Box Control.
Custom List Definition Functions. Main List Manager Constants, Data Types, and
Functions. Relevant Text Utilities Data Type and Functions. Demonstration
Program Lists Listing. Demonstration Program Lists Comments.
23. Drag and Drop.
Overview. Drag Items, Drag Item Flavors, and
Handlers. The Drag Region and The Drag Image. Drag Functions—Overriding Drag
Manager Default Behavior. Main Drag Manager Constants, Data Types, and
Functions. Relevant TextEdit Function. Demonstration Program Drag Listing.
Demonstration Program Drag Comments.
24. Basic Sound and Speech.
Introduction to Sound. Sound Production. Sound
Recording—Mac OS 8/9. Speech. Relevant Constants, Data Types, and Functions. The
AsynchSoundLib Library. Demonstration Program SoundAndSpeech Listing.
Demonstration Program SoundAndSpeech Comments.
Notification From Applications in the
Background. Progress Bars Command-Period Key-Down Events, and Mouse-Down Events.
The Color Picker. Coping with Multiple Monitors. Help Tags. Ensuring
Compatibility with the Operating Environment. Carbon and Available APIs. Main
Notification Manager Data Types and Functions. Relevant Process Manager Data
Types and Functions. Relevant Event Manager Function. Relevant Color Picker
Utilities Function. Relevant QuickDraw Function. Relevant Window Manager
Function. Main Help Package Constants, Data Types, and Functions. Relevant
Gestalt Manager Function. Demonstration Program Miscellany Listing.
Demonstration Program Miscellany Comments.
26. More on Text—Multilingual Text Engine.
Introduction. Working with MLTE. Main Constants,
Data Types, and Functions. Demonstration Program MLTETextEditor Listing.
Demonstration Program MLTETextEditor Comments.