← Macintosh C Programming Primer, Volume II: Mastering the Toolbox Using THINK C

Macintosh C Programming Primer, Volume II: Mastering the Toolbox Using THINK C

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

Macintosh C Programming Primer

DAVE MARK Addison-Wesley Macintosh® C Programming Primer Volume II Mastering the Toolbox Using THINK C®

Book cover with a blue header band bearing the author name and publisher logo, large black serif title text, colorful cut-paper style letters spelling 'Primer' on pink, yellow, blue, purple, orange, and green squares, and a blue diagonal shape at the bottom left.

Reading notes: The word 'Primer' is set in colorful letter tiles; the letters P, r, i, M, e, R were read as one word and may be stylized.

Printed product names
Macintosh C Programming Primer · THINK C
Languages
English
PDF page 1

Macintosh C Programming Primer

Addison-Wesley DAVE MARK Macintosh® C Programming Primer Volume II Mastering the Toolbox Using THINK C®

Book cover with a blue header band holding the Addison-Wesley logo and author name, a large black serif title, colorful cut-paper letter blocks spelling 'Primer' in pink, yellow, blue, purple, orange, and green, and a blue diagonal shape at the bottom left behind the subtitle.

Reading notes: The subtitle words 'Mastering the Toolbox' overlap a blue diagonal shape, and 'THINK C' is partly obscured by it, so the exact rendering of 'THINK' is slightly uncertain. Volume number 'II' is read as Roman numeral II.

Printed product names
Macintosh C Programming Primer · THINK C
Languages
English
PDF page 2

Macintosh®C Programming Primer

Macintosh®C Programming Primer Volume II Mastering the Toolbox Using THINK C® Dave Mark • TT Addison-Wesley Publishing Company, Inc. Reading, Massachusetts Menlo Park, California New York Don Mills, Ontario Wokingham, England Amsterdam Bonn Sidney Singapore Tokyo Madrid San Juan Paris Seoul Milan Mexico City Taipei

Reading notes: The first title line reads 'Macintosh®C', which may be an extraction artifact, and the title is set against the 'Volume II' and 'Mastering the Toolbox' lines. A stray '• TT' appears above the publisher name and its meaning is uncertain. Transcript is intentionally empty because the exact extracted text is preserved separately; the other fields were filled from the supplied copy only. No advertised products, prices, or dates are present in the supplied copy; the only year-like content is absent, so printedDates is empty.

Languages
English
PDF page 3

Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and Addison-Wesley was aware of a trademark claim, the designations have been printed in initial capital letters or all capital letters. Under the copyright laws, this book may not be copied, photo- copied, reproduced, translated, modified, or reduced to any electronic medium or machine-readable form, in whole or in part, without the prior written consent of the publisher. Library of Congress Cataloging-in-Publication Data (Revised for vol. 2) Mark, Dave. Macintosh programming primer. Includes index. Bibliography: p. Vol. 2 has title: Macintosh C programming primer. Contents: [1] Inside the toolbox using THINK's Lightspeed C - v. 2. Mastering the toolbox using THINKC. 1. Macintosh (Computer) - Programming. 2. C (Computer program language). I. Reed, Cartwright. II. Title. III. Title: Macintosh C programming primer. QA76.8.M3M368 1989 005.265 88-34992 ISBN 0-201-15662-8 ISBN 0-201-57016-5 Copyright© 1990 by Dave Mark All rights reserved. Printed in the United States of America. Published simultaneously in Canada. ISBN 0-201-57016-5 5 6 7 8 9 10 - MW - 949392 Fifth printing, July 1992

Reading notes: Title spelling 'Macintosh C programming primer' vs 'Macintosh programming primer' differs across catalog entries 'THINKC' and 'THINK' may be the same product written differently

Printed product names
Lightspeed C · THINK · THINKC
Printed dates
1989 · 1990 · 1992 · 88-34992 · July 1992
Languages
English
PDF page 4

The image is an entirely blank white page with no visible artwork, layout, or markings.

Reading notes: No visible text found; the page appears blank.

PDF page 5

Contents Foreword by Scott Knaster ix Preface xi Acknowledgments xiii 1 Welcome Back 1 Volume I in Review 3 Volume II Topics 5 Chapter 2-Toolbox Techniques 5 Chapter 3-Code Resources 6 Chapter 4-Color QuickDraw 8 Chapter 5-TextEdit 11 Chapter 6-0bject Programming 12 Appendix A-Glossary of Terms 13 Appendix B-Source Code Listing 13 How to Use This Book 14 Ready, Set . . . 15 2 Toolbox Techniques 17 All About Pointers 19 Pointers Are Never Relocatable 22 The Macintosh Memory Layout 22 The System Space 23 The Application Space 23 v

Reading notes: The source appears to be a table of contents rather than advertising copy, so no headline, products, prices or dates are identified.

Languages
English
PDF page 6

vi Macintosh Programming Primer The Stack 25 The Application Heap 27 Handles, At Last! 29 Careful With That Handle, Eugene! When To Use Handles 34 Miscellaneous Tips and Techniques 34 MoreMasters( ) and MoveHHI( ) 35 Purgeable Blocks 35 Keeping Your Applications 32-bit Clean Piggybacking Data on Your Windows Calling Them, So They Can Call You In Review 39 3 Code Resources 41 Specialized Code 43 The Common Thread 44 Chapter Programs 45 AFI, the Application Font INIT 46 AFI Resources 48 Creating the AFI Project 53 Walking Through the AFI Source Code The AFI cdev 60 AFI cdev Resources 61 The cdev Source Code 67 Checking Out the AFI edev 73 32 35 36 38 56 Walking Through the cdev Source Code 74 Writing Your Own MDEF 82 The MDEF Project and Source Code 83 Building Your MDEF 87 Building the MDEF Tester 88 Walking Through the PICT MDEF Source Code 100 Dialog Filter Procedures 106 Creating the DLOG Resources 107 Walking Through the DLOG Source Code 115 In Review 121 4 Color QuickDraw 123 The Evolution of QuickDraw 125 Color QuickDraw and Indexed Devices 126 The CGrafPort and the CWindowPtr 128 What Machine Is the Program Running On? 129 Keeping Track of Graphic Devices 131 The Pixel Image 132

Reading notes: Source text is a table of contents, so no advertised products, prices, or dates appear Page numbers and chapter titles run together in the extracted text

Languages
English
PDF page 7

Contents vii The First Program: Colorlnfo 133 Colorlnfo Resources 133 Setting Up the Project 135 Running Colorlnfo 140 Walking Through the Colorlnfo Source Code 141 The Palette Manager 149 Using the Palette Manager 150 Palette 152 Palette Resources 152 Setting Up the Project 152 Running Palette 159 Walking Through the Palette Source Code 159 Using the Arithmetic Color Modes 167 Color'futor: Hands-on Color 167 Color'futor Resources 169 Setting Up the Project 170 Running Color'futor 184 Walking Through the Color'futor Source Code 185 Working with Off-screen Drawing Environments 202 GWorld 203 GWorld Resources 203 Setting Up the Project 203 Running GWorld 208 Walking Through the GWorld Source Code 208 In Review 215 5 TextEdit 217 Exploring TextEdit 219 Using TextEdit 221 TextEdit Record 221 TextEdit Routines 224 Scrolling Text in TextEdit 227 Resizing the DestRect 228 TextEdit's Private Scrap 230 FormEdit 230 FormEdit Resources 232 The Code 242 Running FormEdit 270 Walking Through the FormEdit Source Code 271 In Review 311

Reading notes: Table-of-contents style text with OCR-like errors such as 'Colorlnfo' and 'Color'futor' where 'l' and 'Color'futor' may be misreadings. Reading order is uncertain for some lines with broken hyphenation or spacing, such as 'Color'futor: Hands-on Color'.

Languages
English
PDF page 8

viii Macintosh Programming Primer 6 Object Programming 313 About Object Programming 315 The Shaper Application 316 An Object View of Shaper 316 An Example 317 Instance Variables and Methods 318 Creating Some Shape Objects 319 Object References 320 Shape's Methods 322 Adding Subclasses to Shaper 323 CreateSquare ( ) versus CreateShape ( 324 A Second Shape Subclass 324 Object Classes Exist on Levels 326 More about Methods 327 The THINK Class Library 329 TCL Organization 330 The Visual Hierarchy 330 The Chain of Command 333 The Switchboard and the Bartender 335 Building an Application with the TCL 335 Art Class 336 TinyEdit 337 The Starter Application 338 MyStarter 340 Creating a Folder for MyStarter 341 Changing CStarterDoc.c 342 Replacing CStarterPane.c 344 Replacing CStarterPane.h 347 Creating CDragPane.c 347 Creating CDragPane.h 350 Creating CMouse.c 351 Creating CMouse.h 354 Checking Your Work 355 Walking Through the MyStarter Source Code 357 The CMouse Object Class 366 In Review 371 Appendix A Glossary 373 Appendix B Code Listing 395 Index 497

Reading notes: Source is a table of contents with page numbers; no headline or product copy is present Some entries have spacing irregularities in the extracted text, such as 'CreateShape (' with a missing closing parenthesis

Languages
English
PDF page 9

Foreword Scott Knaster Back in 1984, just after the end of the Pleistocene Era, it was actually possible for one person to know just about everything there was to know technically about a Macintosh. There was, after all, just one model, the venerable but not venerated Macintosh 128K. In fact, calling the Macintosh 128K the first member of a product line was pretty much wishful thinking; after all, they didn't say ''World War I" until the sequel came out. But I digress (or just think of it as hypertext). For all its 64K of ROM, several hundred routines, and many storage options (you could connect an external at inch disk drive, or not), the Macintosh programmer's world was well-defined, and by today's standards, it was graspable-you could get your head around it, as they used to say here in California. Things around here are a little bit different now, of course. Chances are your Macintosh knows how to talk to one or two across the room, and if you're really cool, probably a few hundred more located somewhere between here and Indonesia. There are now well over a thousand routines defined in the many versions of the ROMs that Apple's genius engineers have cranked out over the past few years in between cans of Jolt cola and occasional minutes of sleep. It's a rich and complex world for programmers of all stripes, both pro- fessional and hobby varieties. ix

Reading notes: Heading 'Foreword' and author line 'Scott Knaster' appear as document front matter, not a primary headline. Possible inline hyphenation and line-break artifacts in the body text, e.g. 'at inch disk' and 'ROMs' spacing.

Printed product names
Macintosh 128K · Macintosh
Printed dates
1984 · World War I
Languages
English
PDF page 10

Macintosh Programming Primer

x Macintosh Programming Primer And that, at last, is where this book comes in. Not too long ago, I was wondering (electronically) aloud why no one had written a practical, up-to-date book about programming the Macintosh in C, currently the most popular language among Macintosh programming gurus. The answer, of course, was that there was a book like that. Hiding behind the innocent guise of a primer was just such a volume, with friendly presentation, thoroughness, and fun. That was Volume I of the Macintosh Programming Primer, predecessor of this book. (Digression again: as you probably know, the folks who invented the Macintosh planned on programmers using Pascal or assembly language. At that time, C was for UNIX hackers and employees of huge telephone companies. Pretty soon, though, the clamor for C started, and the rest is history. If you have practical reasons for avoiding C, such as the need for features available in another language, you probably have no reason to switch. To those of you who resist C for religious reasons, I'll point out that Pascal and C really aren't so different. It's a little like those two guys with black and white faces on Star Trek; they hated each other, but nobody else could tell them apart. Language religion wars don't really help anyone, but writing great software does.) Anyway, Dave Mark sees all the neat new stuff in the Macintosh world as his playground, and he invites us to play, too. In this wonderful volume, we get to go exploring with Dave as he takes us on a tour of many of the things that our new and improved Macintoshes can do. Some of my favorite discussions include the ones about cdevs, object programming, and the world of living color with Color QuickDraw, but they're all entertaining. By choosing THINK C as the learning tool, we can all easily sing along with Dave as we go. This book is full of fun and good learning. With the vast landscape of Macintosh programming as your goal and Dave Mark as your friend, you'll soon feel the awe and mystery of commanding your Macintosh to do great things. Scott Knaster

Reading notes: Running header 'Macintosh Programming Primer' may not be the primary heading of the page

Printed product names
Macintosh Programming Primer · THINK C · Color QuickDraw · Star Trek
Languages
English
PDF page 11

Preface From the sounds of it, Macintosh C Programming Primer, Volume I was well received. Cartwright Reed and I got lots of letters, phone calls, and AppleLinks, and all were much appreciated. People also sent us personal letters relating their own programming experiences. We even got Christmas cards! We also received a bunch of letters from people with suggestions for Volume II of the Primer. These letters were the primary factor in determining the table of contents for this book. Color QuickDraw, Object Programming, and TextEdit all made the cut-you asked for it, you got it! I am very interested in hearing from you. Though you can write to me in care of Addison-Wesley, the best way to get in touch with me is via CompuServe's Learn Programming forum. Log in to CompuServe, type: GOMACDEV then check out Section 11. Whether you have questions or comments about the Primer or just want to say hello, the Learn Programming forum is the place to be. One more thing. Please join me and millions of others in the cam- paign to save our planet's natural resources. Recycling, conservation of water and gasoline, and reduced consumption of non-biodegradable products are vital to that goal. I believe that together we can make a difference. D.M. Arlington, VA xi

Reading notes: Preface text contains irregular spacing around some words, possibly from extraction.

Printed product names
Macintosh C Programming Primer, Volume I · Color QuickDraw · TextEdit
Languages
English