Macintosh Programming Techniques 1994
From the originals
12 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
New Technology Building Blocks DISK INCLUDED Macintosh Programming Techniques A Foundation for All Macintosh Programmers • Learn essential techniques for expert Macintosh programming • Understand terms and concepts unique to Macintosh programming • Gain hands-on experience with interactive software tutorial Dan Parks Sydow M&T BOOKS Series Editor: Anthony Meadow Bear River Associates
A book cover with a green and red layout showing a yellow Macintosh-style computer monitor, keyboard, mouse and tower, with a sparkling burst on the screen and a small green cartoon figure on a floppy disk emitting a glowing trail.
Reading notes: Small text in the top-right disk badge and M&T logo may be approximate. Series title line and author line are on separate visual levels; reading order follows layout.
- Printed product names
- Macintosh Programming Techniques
- Languages
- English
PDF page 1
Macintosh Programming Techniques
Macintosh Programming Techniques A Foundation for All Macintosh Programmers ~ • Learn essential techniques for expert Macintosh programming • Understand terms and concepts unique to Macintosh programming • Gain hands-on experience with interactive software tutorial Dan Parks Sydow
Reading notes: Transcript is intentionally empty because the exact extracted text is preserved separately; other fields were filled from the supplied copy only. Layout, reading order, and visual artwork were not confirmed against the image and are inferred from the supplied text. The supplied text ends with 'Dan Parks Sydow' with no separator, so the line break and whether it is one name or several (e.g., 'Dan Parks' and 'Sydow') is uncertain. The tilde (~) between the subtitle and the bullet list may be a decorative mark rather than text. No prices or dates appear in the supplied copy, so none were listed.
- Printed product names
- Macintosh Programming Techniques
- Languages
- English
PDF page 2
The image is a plain, entirely blank white portrait page with no visible artwork, layout, or markings.
Reading notes: No visible text found in the image; transcript and printed fields left empty.
PDF page 3
PDF page 4 · PDF page 6
The image is an entirely blank white portrait-format page with no visible artwork, layout elements, or text.
Reading notes: No visible text found in the image; transcript and printed fields left empty per instructions.
PDF page 5
M&T Books A Division of MIS:Press, Inc. A Subsidiary of Henry Holt and Company, Inc. 115 West 18th Street New York, New York 10011 © 1994 by M&T Books Printed in the United States of America All rights reserved. No part of this book may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any information storage and retrieval system, without prior written permission from the Publisher. Contact the Publisher for information on foreign rights. Limits of Liability and Disclaimer of Warranty The Author and Publisher of this book have used their best efforts in preparing the book and the pro- grams contained in it. These efforts include the development, research, and testing of the theories and programs to determine their effectiveness. The Author and Publisher make no warranty of any kind, expressed or implied, with regard to these programs or the documentation contained in this book. The Author and Publisher shall not be liable in any event for incidental or consequential damages in connection with, or arising out of, the fur- nishing, performance, or use of these programs. All products, names and services are trademarks or registered trademarks of their respective companies. Library of Congress Cataloging-in-Publication Data Sydow, Dan P. Macintosh programming techniques: a foundation for all Macintosh programmers I DanP. Sydow p. cm. Includes index. ISBN l-55828-326-9 : $34.95 1. Macintosh (Computer)--Programming. I. Title. QA76.8.M3S96 1993 005 .265--dc20 96 95 94 4 3 2 Publisher: Steve Berkowitz Associate Publisher: Brenda McLaughlin Project Editor: Margot Owens Pagan Development Editor: Mike Miley Copy Editor: Judy Whittle Technical Editor: Ray Valdes Production Editor: Eileen Mullin Associate Production Editors: Maya Riddick, Joseph McPartland Cover Design: JPD Communications 93-46619 CIP
Reading notes: Library of Congress catalog data contains OCR spacing and character irregularities such as 'DanP.' and 'l-55828-326-9' Cataloging line 'QA76.8.M3S96 1993' and printer digits '96 95 94 4 3 2' have uncertain reading order
- Printed product names
- Macintosh (Computer)
- Printed prices
- $34.95
- Printed dates
- 1994 · 1993 · 96 · 95 · 94
- Languages
- English
PDF page 7
.,,. '~··~ / Table of Contents Fe>re"VVe>rc:I •••••••••••••••••••••••••••••••••••••••••••••••••••• lClCi Why This Be>e>k is fe>r Ye>u •••••••••••••••••••••••••••••••• 1 l11tre>c:lllctie>11 •••••••••••••••••••••••••••••••••••••••••••••••••••• 3 What's on the Disk ......................................................................................... 4 What You Need ...............................................................................................5 Extracting the Contents of the Disk .............................................................5 Using the In Action! Program ........................................................................ 9 Running the program ............................................................................... 9 The program windows ............................................................................. 9 Moving about in the program ................................................................ 10 Chapter 1: l11tre>c:luctio11 te> Maci11te>sh Pre>grammi11g •••••••••••••••••••••••••••••••••••••••••••••••• 13 Development Systems ................................................................................. 13 Information environments ....................................................................14 Application frameworks ........................................................................ 14 Programming languages .........................................................................14 vii
Reading notes: Headline not clearly identifiable; source appears to be a table of contents with no primary heading Possible OCR artifacts in characters such as 'lClCi' and 'Be>e>k' in the table of contents
- Printed product names
- In Action!
- Languages
- English
PDF page 8
••• VIII Macintosh Programming Techniques About Macintosh Programming .................................................................. 15 Bit-mapped Graphics .................................................................................... 16 Event-driven Programming .......................................................................... 17 Resources ....................................................................................................... 22 The Toolbox .................................................................................................. 26 The Operating System .................................................................................. 31 System Software ...........................................................................................32 The System File and Finder ......................................................................... 33 The System file ....................................................................................... 33 The Finder ...............................................................................................34 Chapter Program: Intro to Mac Programming ...........................................35 Program project: VeryBasics.n ...............................................................36 Program resources: VeryBasics. n.rsrc ................................................... 3 7 Program listing: VeryBasics.c ................................................................38 Stepping through the code ..................................................................... 40 Where are the #includes? ................................................................ 40 Function prototypes ......................................................................... 41 The #define directives ..................................................................... 41 Global variables ............................................................................... 42 The main() function ........................................................................ 42 Toolbox initialization ...................................................................... 42 Loading a window ............................................................................ 43 Drawing to a window ...................................................................... 44 The main event loop ........................................................................ 45 A Macintosh function ..................................................................... 46 Chapter Summary ........................................................................................ 47 Chapter 1 Lessons on Disk 0. Lesson 1-1: Events ................................................................................. 22 p Lesson 1-2. Resources ............................................................................ 26 Lesson 1--3: The Toolbox ....................................................................... 30 Chapter 2: Macintosh Memory •••••••••••••••••••••• 49 Memory Organization .................................................................................. 49 System partition organization ............................................................... 50 System global variables ................................................................... 51 System heap ..................................................................................... 51 Application partition organization ....................................................... 52 AS World ........................................................................................... 52 Application stack ............................................................................. 52
Reading notes: Table of contents with dot leaders and page numbers; some OCR fragments such as 'p Lesson 1-2' and 'AS World' are uncertain. Heading 'Chapter 1 Lessons on Disk' appears out of sequence with the surrounding contents, so reading order is uncertain.
- Languages
- English
PDF page 9
• Table of Contents IX Application heap .............................................................................. 54 Summary of memory organization ....................................................... 56 The Application Heap .................................................................................. 57 Heap fragmentation ............................................................................... 58 Heap compaction ................................................................................... 60 Nonrelocatable and relocatable blocks ................................................. 61 Chapter Program: Memory Partitions ........................................................ 65 Program resources: MemoryFiller.1t.rsrc ...............................................68 Program listing: MemoryFiJler.c ........................................................... 69 Stepping through the code ..................................................................... 70 Chapter Summary ........................................................................................ 71 Disk Files Lesson 2-1: Memory organization ........................................................ 57 Lesson 2-2: Heap fragmentation ........................................................... 58 Lesson 2-3: Heap compaction ............................................................... 60 Lesson 2-4: Master Pointers and Handles ............................................ 64 Chapter 2 Lessons on Disk b. Lesson 2-1: Memory organization ........................................................ 57 b Lesson 2-2: Heap fragmentation ........................................................... 58 Lesson 2-3: Heap compaction ............................................................... 60 Lesson 2-4: Master pointers and handles ............................................. 64 Chapter 3: Resources •••••••••••••••••••••••••••••••••••• 73 About Resources ........................................................................................... 74 The importance of resources ................................................................. 74 Resource types ........................................................................................ 75 Checking for errors ................................................................................ 75 Working With Strings ................................................................................... 77 The 'STR#' resource ............................................................................... 77 Using a string in a program ................................................................... 78 Pictures and Animation ............................................................................... 81 The 'PICT' resource ............................................................................... 81 Displaying a 'PICT' in a program .......................................................... 83 Using 'PICT's to create animation ........................................................ 86 Creating a series of 'PICT's ............................................................. 86 Animation source code ................................................................... 88 Sounding Off ................................................................................................. 91 The 'snd' file .......................................................................................... 91 The 'snd' resource ................................................................................. 92
Reading notes: Table of contents entries show inconsistent OCR spacing and punctuation in several lines, e.g. 'MemoryFiJler.c' and 'Lesson 2-1' repeated with varied bullet characters.
- Languages
- English
PDF page 10
X Macintosh Programming Techniques Playing a 'snd' in a program ................................................................. 94 Giving a Program an Icon ............................................................................ 95 Th.e Finder and icons .............................................................................. 96 Creating the 'BNDL' resource ............................................................... 97 Setting the Creator in the compiler .................................................... 102 Making the Finder aware of a new icon ............................................. 102 Chapter Program: Using Resources ........................................................... 103 Program resources: ResourceUser:rc.rsrc ............................................ 104 Program listing: ResourceUser.c ......................................................... 106 Stepping through the code ................................................................... 110 The #include directives ................................................................. 110 The #define directives ................................................................... 110 The main() Function ..................................................................... 111 Using strings .................................................................................. 112 Using pictures for animation ........................................................ 113 Playing sounds ............................................................................... 113 Chapter Summary ...................................................................................... 113 Chapter 3 Lessons on Disk tu Lesson 3-1: The 'STR#' resource .......................................................... 80 ~ Lesson 3-2: Th~ 'PIC?T' resource ........................................................... 86 Lesson 3-3: Animation .......................................................................... 90 Chapter 4: QuickDraw Graphics ••••••••••••••••• 115 About QuickDraw ...................................................................................... 115 Initializing QuickDraw ....................................................................... 116 Pixels and the coordinate system ....................................................... 117 Graphics Ports ............................................................................................. 118 The Graf Port and GrafPtr .................................................................... 118 The graphics pen .................................................................................. 119 Defensive Drawing ..................................................................................... 121 Changing ports ..................................................................................... 121 Changing characteristics of a port ...................................................... 123 Drawing Shapes .......................................................................................... 125 Working with rectangles ...................................................................... 126 Working with ovals .............................................................................. 128 Working with round rectangles ........................................................... 129 Patterns ....................................................................................................... 131 The 'PAT ' resource .............................................................................. 131 The pattern source code ...................................................................... 133
Reading notes: Several table-of-contents entries contain OCR-damaged characters (e.g., 'Th.e', 'tu', '~', 'PIC?T', 'Graf Port') Reading order of mixed table-of-contents sections is uncertain
- Languages
- English
PDF page 11
• Table of Contents XI Color QuickDraw ....................................................................................... 134 Checking for color ................................................................................ 134 Color windows ..................................................................................... 136 Color pattems ....................................................................................... 137 The 'ppat' resource ........................................................................ 138 The color pattern source code ...................................................... 138 Color drawing ....................................................................................... 140 The 'wctb' resource .............................................................................. 141 The Cursor .................................................................................................. 143 Chapter Program: Drawing on the Mac .................................................... 146 Program resources: QuickDrawing.1t.rsrc .......................................... 146 Program listing: ResourceUser.c ......................................................... 147 Stepping through the code ................................................................... 152 The #include directives ................................................................. 152 The #define directives ................................................................... 152 The main() function ...................................................................... 153 lnitialization ................................................................................... 153 Checking for color ......................................................................... 154 Preserving the environment ......................................................... 154 Lines and shape painting ............................................................... 155 Shape filling .................................................................................... 156 Chapter Summary ...................................................................................... 15 7 Chapter 4 Lessons on Disk tu Lesson 4-1: Moving the pen ................................................................ 121 μ Lesson 4-2: Sw~tching ports ................................................................ 123 Lesson 4-3: Using patterns .................................................................. 134 Chapter 5: Working With Windows •••••••••••• 159 Windows Primer ......................................................................................... 160 The WIND resource ............................................................................. 160 Loading a 'WIND' ................................................................................. 160 The WindowRecord, WindowPtr, and WindowPeek......................... 161 Event Handling ........................................................................................... 163 Windows and Events .................................................................................. 170 Mouse down events ............................................................................. 171 Handling a mouse click in a drag bar ........................................... 171 Handling a mouse click in a close box ......................................... 173 Handling a mouse click in a content region ................................ 174 Handling a mouse click in other areas ......................................... 175
Reading notes: Table of contents page numbers and some characters are garbled (e.g., 'pems', 'tu', 'μ', 'Sw~tching').
- Languages
- English
PDF page 12
•• XI I Macintosh Programming Techniques Single Window Techniques ....................................................................... 176 Activate events ..................................................................................... 177 Updating a window .............................................................................. 177 Simple window techniques ................................................................. 182 Moving a window .......................................................................... 183 Showing and hiding a window ...................................................... 184 Changing a window's title ............................................................ 184 Multiple Window Techniques ................................................................... 184 Expanding the WindowRecord ............................................................ 185 Activates and multiple windows ........................................................ 190 Updates and multiple windows .......................................................... 192 Chapter Program: Working With Multiple Windows .............................. 193 Program resources: MultiWindows.1t.rsrc .......................................... 194 Program listing: MultiWindows.c ....................................................... 195 Stepping through the code ................................................................... 205 . The #include directives ................................................................. 205 The #define directives ................................................................... 205 Global types ................................................................................... 206 Global variables ............................................................................. 206 The main() function ...................................................................... 207 Initialization ................................................................................... 208 Marking and examining a window ............................................... 209 Opening a window ......................................................................... 211 Event handling ............................................................................... 213 Chapter Summary ...................................................................................... 220 Chapter 5 Lessons on Disk tu Lesson 5-1: Handling events ............................................................... 169 D Lesson 5-2: Window updating ............................................................ 182 Lesson 5-3: MyWindPeek .................................................................... 185 Lesson 5-4: Using MyWindPeek ......................................................... 185 Chapter 6: Dealing With Dialogs ••••••••••••••••• 223 Alerts ........................................................................................................... 224 Alert resources: 'ALRT' and 'DITL' .................................................... 224 Alert source code .................................................................................. 227 Dialogs ......................................................................................................... 228 Dialog Resources ........................................................................................ 229 Dialog item types ................................................................................. 229 The 'DLOG' and 'DITL' Resources ..................................................... 230
Reading notes: Table of contents page; some entries contain stray bullet and page-number characters that may affect reading order.
- Languages
- English