Inside Macintosh: Overview
From the originals
13 scansMachine-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 Overview 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 a small black Apple logo at top, the spaced capital title INSIDE MACINTOSH, a horizontal rule with the word Overview beneath it, and a publisher's mark with city list at the bottom.
Reading notes: Headline is a section title 'Overview' rather than an advertisement headline; the spaced title INSIDE MACINTOSH is shown above it. Publisher logo at bottom is a small pixel-style mark with no readable text.
- 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 Overview
Reading notes: Fields were filled from locally extracted copy rather than the scan image, so layout and visual details are not verified. The headline is shown with the letter spacing exactly as supplied; it may be a styled title rather than a plain headline. Whether 'Overview' is a subtitle, section label, or part of the title block is uncertain from the supplied text alone. The publisher imprint city list is reproduced in a multi-line arrangement that may not match the original layout.
- Printed product names
- I N S I D E M A C I N T O S H
- 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, AppleLink, LaserWriter, MacApp, Macintosh, MPW, and MultiFinder are trademarks of Apple Computer, Inc., registered in the United States and other countries. Balloon Help, Finder, QuickDraw, QuickTime, ResEdit, and SourceBug 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 and Palatino 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-63247-0 1 2 3 4 5 6 7 8 9-MU-9695949392 First Printing, December 1992 The paper used in this book meets the EPA standards for recycled fiber.
Reading notes: Transcript is intentionally empty because the exact extracted text is preserved separately. No headline or advertised products or prices appear in the supplied copy; trademarked names are not treated as advertised products. Layout and reading order are inferred only from the supplied copy, not from the image itself.
- Printed dates
- © 1992 · December 1992
- Languages
- English
PDF page 3
iii Contents Figures, Tables, and Listings vii Preface About This Book xi About Inside Macintosh xii The New Inside Macintosh xiii Conventions Used in This Book xiii Special Fonts xiv Types of Notes xiv Development Environment xiv For More Information xv Chapter 1 Introduction 1 Getting Started 3 The Macintosh System Software 6 The Macintosh Toolbox 7 The Macintosh Operating System 11 Additional System Software Services 12 Text Handling 12 Interapplication Communication 14 QuickTime 17 Communications Toolbox 18 System Software Routines 19 The Sample Application 21 Conventions for Sample Code 24 Chapter 2 Memory 27 About Memory 29 The System Heap 31 The System Global Variables 31 Application Partitions 32 The Application Stack 33 The Application Heap 34 The Application Global Variables and A5 World 37 Memory Blocks 38 Nonrelocatable Blocks 39 Relocatable Blocks 40 Locking and Unlocking Relocatable Blocks 42
- Languages
- English
PDF page 4
iv Purging and Reallocating Relocatable Blocks 43 Data Types 44 Pointers and Handles 44 Strings 45 Procedure Pointers 46 Type Coercion 47 Chapter 3 Resources 49 About Resources 51 Resource Paths 52 Resource Types 55 Resource Structure 56 Using Standard Resources 59 Using Custom Resources 60 Chapter 4 Events 69 About Events 71 Initializing an Application 74 Receiving Events 75 Handling Events Outside the Main Event Loop 79 Chapter 5 Drawing 83 About QuickDraw 85 Points 86 Rectangles 87 Regions 89 Bit Images 91 Ports and Windows 92 Drawing Shapes 94 Drawing Bit Images 99 Drawing Text 101 Chapter 6 Windows 107 About Windows 109 Window Parts 110 Window Records 112 Window Types 113 Creating Windows 115
Reading notes: Source text is a table of contents fragment with page numbers rather than advertising copy No headline or advertised products, prices or dates are present
- Languages
- English
PDF page 5
v Handling Window Events 119 Mouse Events 119 Update Events 123 Activate Events 125 Closing Windows 128 Chapter 7 Dialog Boxes 131 About Dialog Boxes 133 Using Modeless Dialog Boxes 137 Creating a Modeless Dialog Box 137 Setting Up Application-Defined Items 139 Handling User Actions in a Modeless Dialog Box 141 Using Modal Dialog Boxes 144 Displaying a Modal Dialog Box 145 Defining a Modal Dialog Filter Function 146 Chapter 8 Menus 149 About Menus 151 Creating Menus 152 Creating a Menu Resource 152 Creating a Menu Bar Resource 154 Setting Up the Menu Bar and Menus 154 Handling Menu Choices 156 Handling Keyboard Equivalents 160 Adjusting Menus 161 Chapter 9 Processes 163 About Processes 165 Specifying Processing Options 168 Handling Suspend and Resume Events 170 Handling Null Events 173 Quitting an Application 175 Handling Errors 176 Checking the Operating Environment 178 Afterword Going Further 183 Implementing Further Features 183 Maintaining Compatibility 187 Making Your Application Localizable 188
- Languages
- English
PDF page 6
vi Using Developer Services 189 Technical Publications 189 Training 190 Technical Support 191 Appendix A Constants, Types, and Variables 195 Appendix B Utility Routines 199 Appendix C Dialog Code 205 Appendix D Resource Code 211 Appendix E User Interface Code 217 Glossary 233 Index 245
Reading notes: Source is a table of contents excerpt with no primary heading or advertised products.
- Languages
- English
PDF page 7
vii Figures, Tables, and Listings Chapter 1 Introduction 1 Figure 1-1 The window created by the simple application 4 Figure 1-2 Overview of the system software 7 Figure 1-3 Parts of the Macintosh Toolbox 8 Figure 1-4 A multiscript line of text drawn by QuickDraw 13 Figure 1-5 Input and conversion of Japanese text using the Text Services Manager 14 Figure 1-6 Sharing dynamic data with other applications 15 Figure 1-7 Sending and responding to Apple events 16 Figure 1-8 Playing a QuickTime movie 18 Figure 1-9 A typical Venn diagram window 22 Figure 1-10 The parts of a Venn diagram window 22 Figure 1-11 A correctly constructed Venn diagram 23 Figure 1-12 The Venn menu 24 Table 1-1 Parameters passed to NewWindow in Listing 1-1 4 Table 1-2 The Macintosh Toolbox 10 Table 1-3 The Macintosh Operating System 11 Listing 1-1 A simple Macintosh application 3 Chapter 2 Memory 27 Figure 2-1 Memory organization in the cooperative multitasking environment 30 Figure 2-2 Organization of an application partition 32 Figure 2-3 The application stack 34 Figure 2-4 A fragmented heap 35 Figure 2-5 A compacted heap 36 Figure 2-6 Organization of an application’s A5 world 37 Figure 2-7 A pointer to a nonrelocatable block 39 Figure 2-8 A handle to a relocatable block 41 Figure 2-9 Purging and reallocating a relocatable block 44 Chapter 3 Resources 49 Figure 3-1 Searching for a resource 54 Figure 3-2 The ResEdit version of the Preferences dialog box 58 Figure 3-3 A resource diagram 59 Figure 3-4 The Preferences dialog box 61 Table 3-1 Typical locations of resources 53 Table 3-2 Some standard resource types 55
Reading notes: Source is a table of contents listing figures, tables, and listings; no advertised products or prices present.
- Languages
- English
PDF page 8
viii Listing 3-1 Rez input for the Preferences dialog box 57 Listing 3-2 The structure of a resource containing Venn diagram preferences 61 Listing 3-3 Reading a user’s preferences 62 Listing 3-4 Creating a preferences file 64 Listing 3-5 Copying a resource from one resource file to another 65 Listing 3-6 Saving current preferences settings 66 Chapter 4 Events 69 Figure 4-1 Sources of events sent to your application 73 Listing 4-1 Initializing your application 74 Listing 4-2 Initializing the main Toolbox Managers 75 Listing 4-3 Handling disk-inserted events 77 Listing 4-4 An event loop 77 Listing 4-5 Tracking mouse events in the close box 79 Listing 4-6 Tracking the cursor in an arbitrary rectangle 80 Chapter 5 Drawing 83 Figure 5-1 Samples of QuickDraw’s abilities 85 Figure 5-2 The coordinate plane 86 Figure 5-3 A rectangle 87 Figure 5-4 Pixels and rectangles 88 Figure 5-5 Two regions 90 Figure 5-6 A bitmap 92 Figure 5-7 Calculating the overlap regions of a Venn diagram 98 Figure 5-8 Bit images in a document window 99 Listing 5-1 Saving and restoring the current graphics port 93 Listing 5-2 The structure of a record describing a document window’s geometry 94 Listing 5-3 Initializing the geometry record 95 Listing 5-4 Defining circular regions 96 Listing 5-5 Defining noncircular regions 96 Listing 5-6 Reading 'ICON' resources into memory 100 Listing 5-7 Drawing the tools area of a document window 100 Listing 5-8 Drawing a portion of an icon 101 Listing 5-9 Retrieving a status message from a resource 102 Listing 5-10 Informing the user of an argument’s validity or invalidity 103 Listing 5-11 Displaying a status message 103 Chapter 6 Windows 107 Figure 6-1 A Venn diagram window 111 Figure 6-2 An inactive window containing controls 127
Reading notes: Source is a table of contents listing, not advertising copy; no headline or product or price fields apply.
- Languages
- English
PDF page 9
ix Listing 6-1 The WindowRecord data structure 112 Listing 6-2 Determining if a window is a document window 114 Listing 6-3 Determining if a window is a dialog box 114 Listing 6-4 Determining if a window is a desk accessory window 115 Listing 6-5 The structure of a document record for the Venn Diagrammer application 115 Listing 6-6 Creating a new Venn diagram window 117 Listing 6-7 Handling mouse-down events 120 Listing 6-8 Dragging a window 121 Listing 6-9 Handling clicks in a window’s content region 121 Listing 6-10 Handling a click in a figure icon 123 Listing 6-11 Handling update events 124 Listing 6-12 Handling window activations and deactivations 126 Listing 6-13 Handling clicks in the close box 128 Listing 6-14 Closing a window 129 Listing 6-15 Closing a Venn diagram window 129 Chapter 7 Dialog Boxes 131 Figure 7-1 An About box 133 Figure 7-2 An alert box 134 Figure 7-3 A Preferences dialog box 134 Listing 7-1 Dialog item numbers 135 Listing 7-2 Creating a modeless dialog box 138 Listing 7-3 Setting up application-defined dialog items 139 Listing 7-4 Drawing application-defined dialog items 140 Listing 7-5 Handling events in a modeless dialog box 141 Listing 7-6 Setting the state of radio buttons and checkboxes 142 Listing 7-7 Displaying a modal dialog box 145 Listing 7-8 Outlining the default button of a modal dialog box 146 Listing 7-9 A modal dialog filter function 147 Chapter 8 Menus 149 Figure 8-1 A typical pull-down menu 151 Figure 8-2 Defining a 'MENU' resource 153 Figure 8-3 Editing a menu command 153 Figure 8-4 An 'MBAR' resource in ResEdit 154 Table 8-1 Reserved keyboard equivalents 161 Listing 8-1 Setting up the menu bar and menus 155 Listing 8-2 Defining menu numbers and menu item numbers 156 Listing 8-3 Handling menu selections 157 Listing 8-4 Handling Apple menu selections 159 Listing 8-5 Handling Command-key equivalents 160 Listing 8-6 Adjusting menus 161
Reading notes: Headline "ix" is a roman-numeral page marker rather than a conventional heading
- Languages
- English
PDF page 10
x Chapter 9 Processes 163 Figure 9-1 The desktop with several applications open 166 Figure 9-2 A Venn diagram before automatic adjusting 174 Figure 9-3 A Venn diagram after automatic adjusting 175 Table 9-1 The bits in the message field of an operating-system event record 172 Listing 9-1 The Rez input for a sample 'SIZE' resource 169 Listing 9-2 Handling operating-system events 171 Listing 9-3 Handling null events 173 Listing 9-4 Quitting your application 175 Listing 9-5 Handling serious errors 178 Listing 9-6 Checking that FindFolder is present 179 Listing 9-7 Determining whether a trap is available 180 Listing 9-8 Checking for the availability of the WaitNextEvent function 181
- Languages
- English
PDF page 11
xi P R E F A C E About This Book This book, Inside Macintosh: Overview, provides a general introduction to programming for Macintosh computers and to the Inside Macintosh library of reference books. Unless you are already an experienced developer of software for Macintosh computers, you should read this book for a general overview of the Macintosh system software and of the programming techniques that you should use when developing your application. This book is written for both professional developers and “hobbyists.” It assumes only that you understand fundamental programming concepts and that you have had experience using a high-level programming language such as Pascal or C. It is helpful, but not necessary, to have some experience programming for a graphic user interface (like the Macintosh desktop metaphor). At the very least, you should already have extensive experience using one or more applications on a Macintosh computer. Before you start programming, you need to understand what the basic elements of the Macintosh desktop metaphor are (windows, menus, scroll bars, and so forth) and how the user expects those elements to operate. This book leads by example. From the very first page, the fundamental programming techniques are illustrated by source code that you can compile into actual, working routines and applications. Gradually, you will learn how to implement the major features of a Macintosh application, including n responding to user actions and other events n creating and managing windows and dialog boxes n handling menu selections n storing application data in resources n managing your application’s memory efficiently n sharing processing time and available memory with other open applications n checking available system software features n handling errors or unexpected occurrences safely This book also provides guidelines on how to maximize your application’s compatibility with the entire family of Macintosh computers and minimize the amount of work required to localize your application (that is, to adapt it for use in other geographic locations). Compatibility and localizability are features that you should always plan in advance. In general, your best guide to writing software that follows these guidelines is to use the techniques illustrated throughout the Inside Macintosh series of books.
- Printed product names
- Inside Macintosh: Overview · Inside Macintosh
- Languages
- English