← Inside Macintosh: Macintosh Toolbox Essentials

Inside Macintosh: Macintosh Toolbox Essentials

From the originals

13 scans

Machine-transcribed text and image descriptions. Check the linked original for uncertain words or fine print.

These are transcribed pages from the documents, not the full publications. Open the original for the remaining pages.

Image 1

INSIDE MACINTOSH Macintosh Toolbox Essentials Addison-Wesley Publishing Company Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario Wokingham, England Amsterdam Bonn Sydney Singapore Tokyo Madrid San Juan Paris Seoul Milan Mexico City Taipei

A plain white title page with an Apple logo at top, the spaced capital title INSIDE MACINTOSH above a horizontal rule, a large subtitle Macintosh Toolbox Essentials, and a small publisher mark with city list at the bottom.

Reading notes: Page is a book title page rather than an advertisement; no products or prices are advertised. Publisher city list is set in small type and reading order is left-to-right by line.

Languages
English
PDF page 1

Addison-Wesley Publishing Company Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario Wokingham, England Amsterdam Bonn Sydney Singapore Tokyo Madrid San Juan Paris Seoul Milan Mexico City Taipei I N S I D E M A C I N T O S H Macintosh Toolbox Essentials

Reading notes: The supplied copy is a publisher's title page for a book, not an advertisement, so no advertised products or prices are present. Headline is taken from the spaced-out title line 'I N S I D E M A C I N T O S H'; the subtitle 'Macintosh Toolbox Essentials' is not treated as the headline. Layout and reading order of the publisher's city list cannot be confirmed from the text alone.

Languages
English
PDF page 2

Apple Computer, Inc. © 1992, Apple Computer, Inc. All rights reserved. No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by any means, mechanical, electronic, photocopying, recording, or otherwise, without prior written permission of Apple Computer, Inc. Printed in the United States of America. No licenses, express or implied, are granted with respect to any of the technology described in this book. Apple retains all intellectual property rights associated with the technology described in this book. This book is intended to assist application developers to develop applications only for Apple Macintosh computers. Apple Computer, Inc. 20525 Mariani Avenue Cupertino, CA 95014 408-996-1010 Apple, the Apple logo, APDA, AppleShare, AppleTalk, A/UX, EtherTalk, LaserWriter, Macintosh, MPW, and MultiFinder and are trademarks of Apple Computer, Inc., registered in the United States and other countries. Apple Desktop Bus, Balloon Help, BalloonWriter, Chicago, Finder, Geneva, KanjiTalk, Monaco, New York, QuickDraw, QuickTime, ResEdit, System 7, and TrueType are trademarks of Apple Computer, Inc. Adobe Illustrator and PostScript are trademarks of Adobe Systems Incorporated, which may be registered in certain jurisdictions. AGFA is a trademark of Agfa-Gevaert. FrameMaker is a registered trademark of Frame Technology Corporation. Helvetica, Palatino, andTimes are registered trademarks of Linotype Company. ITC Zapf Dingbats is a registered trademark of International Typeface Corporation. Simultaneously published in the United States and Canada. LIMITED WARRANTY ON MEDIA AND REPLACEMENT ALL IMPLIED WARRANTIES ON THIS MANUAL, INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE LIMITED IN DURATION TO NINETY (90) DAYS FROM THE DATE OF THE ORIGINAL RETAIL PURCHASE OF THIS PRODUCT. Even though Apple has reviewed this manual, APPLE MAKES NO WARRANTY OR REPRESENTATION, EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THIS MANUAL, ITS QUALITY, ACCURACY, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. AS A RESULT, THIS MANUAL IS SOLD “AS IS,” AND YOU, THE PURCHASER, ARE ASSUMING THE ENTIRE RISK AS TO ITS QUALITY AND ACCURACY. IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES RESULTING FROM ANY DEFECT OR INACCURACY IN THIS MANUAL, even if advised of the possibility of such damages. THE WARRANTY AND REMEDIES SET FORTH ABOVE ARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORAL OR WRITTEN, EXPRESS OR IMPLIED. No Apple dealer, agent, or employee is authorized to make any modification, extension, or addition to this warranty. Some states do not allow the exclusion or limitation of implied warranties or liability for incidental or consequential damages, so the above limitation or exclusion may not apply to you. This warranty gives you specific legal rights, and you may also have other rights which vary from state to state. ISBN 0-201-63243-8 1 2 3 4 5 6 7 8 9-MU-9695949392 First Printing, October 1992 The paper used in this book meets the EPA standards for recycled fiber.

Reading notes: No primary headline is evident; 'LIMITED WARRANTY ON MEDIA AND REPLACEMENT' is a section heading in the warranty text, not an advertising headline, so headline is null. Trademarked product names such as AppleShare, LaserWriter, and Macintosh appear in the trademark notice but are not advertised products, so productNames is empty. The source text reads 'Helvetica, Palatino, andTimes' with a missing space, which is reproduced only in the supplied copy and not verified against any image. Layout and reading order cannot be verified because no visual page was provided.

Printed dates
1992 · October 1992
Languages
English
PDF page 3

iii Contents Figures, Tables, and Listings xv Preface About This Book xxv Format of a Typical Chapter xxvi Conventions Used in This Book xxvi Special Fonts xxvii Types of Notes xxvii Empty Strings xxvii Assembly-Language Information xxvii The Development Environment xxviii Chapter 1 Introduction to the Macintosh Toolbox 1-1 Overview of the Macintosh Toolbox 1-4 Events 1-5 Menus 1-6 Windows 1-6 Controls 1-7 Alert Boxes and Dialog Boxes 1-8 Icons and Other Interactions With the Finder 1-10 Resources 1-11 Help Balloons 1-14 Copy and Paste 1-14 Related System Software Features 1-14 Drawing on the Screen 1-14 Handling Text 1-14 Managing Files 1-15 Allocating Memory and Launching Processes 1-15 Creating Publishers and Subscribers 1-15 Communicating With Other Applications 1-16 Designing Your Application 1-16 Chapter 2 Event Manager 2-1 Introduction to Events 2-4 Low-Level Events 2-8 Operating-System Events 2-10 High-Level Events 2-13 Priority of Events 2-15

Reading notes: Source appears to be a book table of contents rather than an advertisement, so product, price and date fields are empty.

Languages
English
PDF page 4

iv Switching Contexts 2-15 About the Event Manager 2-16 Using the Event Manager 2-17 Obtaining Information About Events 2-18 Processing Events 2-21 Using the WaitNextEvent Function 2-22 Writing an Event Loop 2-24 Setting the Event Mask 2-26 Handling Events in a Dialog Box 2-29 Creating a Size Resource 2-30 Handling Low-Level Events 2-32 Responding to Mouse Events 2-33 Responding to Keyboard Events 2-38 Scanning for a Cancel Event 2-46 Responding to Update Events 2-47 Responding to Activate Events 2-50 Responding to Disk-Inserted Events 2-55 Responding to Null Events 2-57 Handling Operating-System Events 2-58 Responding to Suspend and Resume Events 2-60 Responding to Mouse-Moved Events 2-62 Handling High-Level Events 2-67 Responding to Events From Other Applications 2-69 Searching for a Specific High-Level Event 2-71 Determining the Sender of a High-Level Event 2-72 Sending High-Level Events 2-73 Requesting Return Receipts 2-77 Handling Apple Events 2-78 Event Manager Reference 2-78 Data Structures 2-79 The Event Record 2-79 The Target ID Record 2-81 The High-Level Event Message Record 2-82 The Event Queue 2-83 Event Manager Routines 2-84 Receiving Events 2-84 Sending Events 2-100 Converting Process Serial Numbers and Port Names 2-105 Reading the Mouse 2-108 Reading the Keyboard 2-110 Getting Timing Information 2-112 Application-Defined Routine 2-114 Filter Function for Searching the High-Level Event Queue 2-114 Resource 2-115 The Size Resource 2-115 Summary of the Event Manager 2-120 Pascal Summary 2-120

Languages
English
PDF page 5

v Constants 2-120 Data Types 2-122 Event Manager Routines 2-123 Application-Defined Routine 2-124 C Summary 2-125 Constants 2-125 Data Types 2-127 Event Manager Routines 2-128 Application-Defined Routine 2-129 Assembly-Language Summary 2-130 Data Structures 2-130 Trap Macros 2-130 Global Variables 2-131 Result Codes 2-132 Chapter 3 Menu Manager 3-1 Introduction to Menus 3-5 Menu and Menu Bar Definition Routines 3-9 The Menu Bar 3-9 Menus 3-11 Menu Items 3-12 Groups of Menu Items 3-14 Keyboard Equivalents for Menu Commands 3-16 Menus Added Automatically by the Menu Manager 3-19 The Apple Menu 3-20 The File Menu 3-22 The Edit Menu 3-24 The Font Menu 3-26 The Size Menu 3-27 The Help Menu 3-29 The Keyboard Menu 3-32 The Application Menu 3-33 Pop-Up Menus 3-33 Hierarchical Menus 3-38 About the Menu Manager 3-39 How the Menu Manager Maintains Information About Menus 3-40 How the Menu Manager Maintains Information About an Application’s Menu Bar 3-40 Using the Menu Manager 3-41 Creating a Menu 3-42 Creating a Menu Resource 3-43 Creating a Menu Bar Resource 3-49 Setting Up Your Application’s Menu Bar 3-50 Creating a Hierarchical Menu 3-53 Creating a Pop-Up Menu 3-56

Reading notes: Source is a table of contents with page numbers; no advertised products, prices, or dates are present.

Languages
English
PDF page 6

vi Changing the Appearance of Items in a Menu 3-57 Enabling and Disabling Menu Items 3-58 Changing the Text of an Item 3-59 Changing the Font Style of Menu Items 3-60 Changing the Mark of Menu Items 3-61 Changing the Icon or Script Code of Menu Items 3-62 Adding Items to a Menu 3-64 Adding Items to the Help Menu 3-67 Adding Items to the Apple Menu 3-68 Adding Fonts to a Menu 3-69 Handling User Choice of a Menu Command 3-70 Handling Mouse-Down Events in the Menu Bar 3-72 Adjusting the Menus of an Application 3-73 Determining if the User Chose a Keyboard Equivalent 3-77 Responding When the User Chooses a Menu Item 3-78 Handling the Apple Menu 3-80 Handling the Help Menu 3-81 Handling a Size Menu 3-82 Accessing Menus From a Dialog Box 3-84 Writing Your Own Menu Definition Procedure 3-87 Calculating the Dimensions of a Menu 3-89 Drawing Menu Items in a Menu 3-90 Determining Whether the Cursor Is in an Enabled Menu Item 3-92 Menu Manager Reference 3-95 Data Structures 3-95 The Menu Record 3-95 The Menu List 3-97 The Menu Color Information Table Record 3-98 Menu Manager Routines 3-102 Initializing the Menu Manager 3-103 Creating Menus 3-105 Adding Menus to and Removing Menus From the Current Menu List 3-108 Getting a Menu Bar Description From an 'MBAR' Resource 3-110 Getting and Setting the Menu Bar 3-112 Drawing the Menu Bar 3-113 Responding to the User’s Choice of a Menu Command 3-114 Getting a Handle to a Menu Record 3-122 Adding and Deleting Menu Items 3-124 Getting and Setting the Appearance of Menu Items 3-130 Disposing of Menus 3-140 Counting the Items in a Menu 3-140 Highlighting the Menu Bar 3-141 Recalculating Menu Dimensions 3-142 Managing Entries in the Menu Color Information Table 3-143 Application-Defined Routine 3-148 The Menu Definition Procedure 3-148

Reading notes: Source is a table of contents with page numbers, not advertising copy; no headline or product or price data present.

Languages
English
PDF page 7

vii Resources 3-151 The Menu Resource 3-151 The Menu Bar Resource 3-155 The Menu Color Information Table Resource 3-155 The Menu Definition Procedure Resource 3-157 Summary of the Menu Manager 3-158 Pascal Summary 3-158 Constants 3-158 Data Types 3-158 Menu Manager Routines 3-159 Application-Defined Routine 3-162 C Summary 3-162 Constants 3-162 Data Types 3-163 Menu Manager Routines 3-164 Application-Defined Routine 3-166 Assembly-Language Summary 3-167 Data Structures 3-167 Global Variables 3-167 Result Codes 3-167 Chapter 4 Window Manager 4-1 Introduction to Windows 4-4 Active and Inactive Windows 4-6 Types of Windows 4-8 Window Regions 4-12 Dialog Boxes and Alert Boxes 4-13 Controls 4-14 Windows on the Desktop 4-15 About the Window Manager 4-16 Graphics Ports 4-17 Window Records 4-19 Color Windows 4-20 Events in Windows 4-21 Using the Window Manager 4-22 Managing Multiple Windows 4-23 Creating a Window 4-25 Defining a Window Resource 4-25 Creating a Window From a Resource 4-27 Positioning a Document Window on the Desktop 4-30 Drawing the Window Contents 4-39 Updating the Content Region 4-40 Maintaining the Update Region 4-41 Handling Events in Windows 4-41 Handling Mouse Events in Windows 4-42

Reading notes: Source is a table of contents with page numbers rather than advertising copy; no advertised products, prices, or headline are present.

Languages
English
PDF page 8

viii Handling Keyboard Events in Windows 4-47 Handling Update Events 4-48 Handling Activate Events 4-50 Moving a Window 4-53 Zooming a Window 4-53 Resizing a Window 4-57 Closing a Window 4-60 Hiding and Showing a Window 4-62 Window Manager Reference 4-64 Data Structures 4-65 The Color Window Record 4-65 The Window Record 4-69 The Window State Data Record 4-70 The Window Color Table Record 4-71 The Auxiliary Window Record 4-73 The Window List 4-74 Window Manager Routines 4-74 Initializing the Window Manager 4-74 Creating Windows 4-75 Naming Windows 4-85 Displaying Windows 4-86 Retrieving Window Information 4-91 Moving Windows 4-94 Resizing Windows 4-99 Zooming Windows 4-101 Closing and Deallocating Windows 4-103 Maintaining the Update Region 4-106 Setting and Retrieving Other Window Characteristics 4-109 Manipulating the Desktop 4-112 Manipulating Window Color Information 4-114 Low-Level Routines 4-116 Application-Defined Routine 4-120 The Window Definition Function 4-120 Resources 4-124 The Window Resource 4-124 The Window Definition Function Resource 4-127 The Window Color Table Resource 4-127 Summary of the Window Manager 4-130 Pascal Summary 4-130 Constants 4-130 Data Types 4-132 Window Manager Routines 4-134 Application-Defined Routine 4-136 C Summary 4-137 Constants 4-137 Data Types 4-139

Languages
English
PDF page 9

ix Window Manager Routines 4-140 Application-Defined Routine 4-143 Assembly-Language Summary 4-144 Data Types 4-144 Global Variables 4-145 Chapter 5 Control Manager 5-1 Introduction to Controls 5-4 Buttons 5-5 Checkboxes 5-5 Radio Buttons 5-6 Pop-Up Menus 5-6 Scroll Bars 5-7 Other Controls 5-11 Active and Inactive Controls 5-11 The Control Definition Function 5-14 About the Control Manager 5-14 Using the Control Manager 5-15 Creating and Displaying a Control 5-15 Creating a Button, Checkbox, or Radio Button 5-17 Creating Scroll Bars 5-21 Creating a Pop-Up Menu 5-25 Updating a Control 5-29 Responding to Mouse Events in a Control 5-30 Determining a Mouse-Down Event in a Control 5-31 Tracking the Cursor in a Control 5-35 Determining and Changing Control Settings 5-37 Scrolling Through a Document 5-43 Scrolling in Response to Events in the Scroll Box 5-53 Scrolling in Response to Events in Scroll Arrows and Gray Areas 5-57 Drawing a Scrolled Document Inside a Window 5-62 Moving and Resizing Scroll Bars 5-65 Defining Your Own Control Definition Function 5-71 Control Manager Reference 5-72 Data Structures 5-72 The Control Record 5-73 The Auxiliary Control Record 5-76 The Pop-Up Menu Private Data Record 5-77 The Control Color Table Record 5-77 Control Manager Routines 5-80 Creating Controls 5-81 Drawing Controls 5-85 Handling Mouse Events in Controls 5-88 Changing Control Settings and Display 5-93 Determining Control Values 5-102 Removing Controls 5-108

Reading notes: Source appears to be a table of contents fragment with no advertised products, prices, or dates. Headline not identifiable; primary heading absent from supplied copy.

Languages
English
PDF page 10

x Application-Defined Routines 5-109 Defining Your Own Control Definition Function 5-109 Defining Your Own Action Procedures 5-115 Resources 5-117 The Control Resource 5-118 The Control Color Table Resource 5-121 The Control Definition Function 5-123 Summary of the Control Manager 5-124 Pascal Summary 5-124 Constants 5-124 Data Types 5-126 Control Manager Routines 5-127 Application-Defined Routines 5-129 C Summary 5-129 Constants 5-129 Data Types 5-131 Control Manager Routines 5-132 Application-Defined Routines 5-134 Assembly-Language Summary 5-134 Data Structures 5-134 Global Variables 5-135 Chapter 6 Dialog Manager 6-1 Introduction to Alerts and Dialog Boxes 6-6 Types of Alerts 6-8 Types of Dialog Boxes 6-9 Modal Dialog Boxes 6-10 Movable Modal Dialog Boxes 6-11 Modeless Dialog Boxes 6-12 Items in Alert and Dialog Boxes 6-13 Events in Alert and Dialog Boxes 6-14 Alert Boxes, Dialog Boxes, and the Window Manager 6-15 About the Dialog Manager 6-16 Using the Dialog Manager 6-17 Creating Alert Sounds and Alert Boxes 6-18 Creating Dialog Boxes 6-23 Providing Items for Alert and Dialog Boxes 6-26 Item Types 6-30 Display Rectangles 6-32 Enabled and Disabled Items 6-36 Resource IDs for Items 6-36 Titles for Buttons, Checkboxes, and Radio Buttons 6-37 Text Strings for Static Text and Editable Text Items 6-40 Pop-Up Menus as Items 6-42 Keyboard Navigation Among Items 6-44

Languages
English
PDF page 11

xi Manipulating Items 6-44 Changing Static Text 6-46 Getting Text From Editable Text Items 6-48 Adding Items to an Existing Dialog Box 6-51 Using an Application-Defined Item to Draw the Bold Outline for a Default Button 6-56 Displaying Alert and Dialog Boxes 6-61 Positioning Alert and Dialog Boxes 6-62 Deactivating Windows Behind Alert and Modal Dialog Boxes 6-64 Displaying Modeless Dialog Boxes 6-66 Adjusting Menus for Modal Dialog Boxes 6-68 Adjusting Menus for Movable Modal and Modeless Dialog Boxes 6-73 Displaying Multiple Alert and Dialog Boxes 6-74 Displaying Alert and Dialog Boxes From the Background 6-74 Including Color in Your Alert and Dialog Boxes 6-75 Handling Events in Alert and Dialog Boxes 6-77 Responding to Events in Controls 6-78 Responding to Events in Editable Text Items 6-79 Responding to Events in Alert Boxes 6-81 Responding to Events in Modal Dialog Boxes 6-82 Writing an Event Filter Function for Alert and Modal Dialog Boxes 6-86 Responding to Mouse Events in Modeless and Movable Modal Dialog Boxes 6-89 Responding to Keyboard Events in Modeless and Movable Modal Dialog Boxes 6-94 Responding to Activate and Update Events in Modeless and Movable Modal Dialog Boxes 6-97 Closing Dialog Boxes 6-100 Dialog Manager Reference 6-101 Data Structure 6-101 The Dialog Record 6-101 Dialog Manager Routines 6-102 Initializing the Dialog Manager 6-103 Creating Alerts 6-105 Creating and Disposing of Dialog Boxes 6-113 Manipulating Items in Alert and Dialog Boxes 6-120 Handling Text in Alert and Dialog Boxes 6-129 Handling Events in Dialog Boxes 6-135 Application-Defined Routines 6-143 Resources 6-147 The Dialog Resource 6-148 The Alert Resource 6-150 The Item List Resource 6-151 The Dialog Color Table Resource 6-156 The Alert Color Table Resource 6-157 The Item Color Table Resource 6-158

Languages
English