← Macintosh Programming Primer: Inside the Toolbox Using THINK’s Lightspeed C

Macintosh Programming Primer: Inside the Toolbox Using THINK’s Lightspeed 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 Programming PRIMER

Addison-Wesley Publishing Company, Inc. DAVE MARK CARTWRIGHT REED SOFTWARE ETC 601-7045 ETC. PRICE $24.95 MACP ROGPRMR 143-9H 1503 0413 Macintosh® Programming PRIMER Inside the Toolbox Using THINK's LightspeedC™ Foreword by Stephen Chernicoff

A book cover with a blue top band holding publisher and author names, a tan background, and the large title 'Macintosh Programming PRIMER' where each letter of PRIMER sits on a different colored square, plus a Software Etc. price sticker in the upper right.

Reading notes: The price sticker text is faint and the price '$24.95' is partly obscured and uncertain; it may read '$24.95' or similar. Sticker codes '601-7045', 'MACP ROGPRMR', '143-9H', and '1503 0413' are hard to read and may be inaccurate. The ETC. PRICE line appears partly overwritten by a handwritten or stamped mark.

Printed product names
Macintosh Programming PRIMER
Printed prices
$24.95
Languages
English
PDF page 1

Macintosh Programming PRIMER

▲▼ Addison-Wesley Publishing Company, Inc. DAVE MARK CARTWRIGHT REED SOFTWARE ETC 601-7045 ETC. PRICE $24.95 MACPROGPRMR 143-9H 15030413 Macintosh® Programming PRIMER Inside the Toolbox Using THINK's LightspeedC™ Foreword by Stephen Chernicoff

A book cover with a blue top band holding the publisher logo and author names, a tan background, a large black title with each letter of PRIMER set on a different colored square, and a software store price sticker in the upper right.

Reading notes: The store sticker price reads as '$24.95' but the digits are partly obscured and blurred, so the amount is uncertain. The sticker code '15030413' and item codes '601-7045' and '143-9H' are small and partly faded; exact characters may be wrong. The sticker text 'MACPROGPRMR' is hard to read and may be misspelled. Reading order of the sticker fields is inferred from layout.

Printed product names
Macintosh Programming Primer
Printed prices
$24.95
Printed dates
15030413
Languages
English
PDF page 2

Macintosh® Programming Primer

Macintosh® Programming Primer Inside the Toolbox Using THINK's LightspeedC™ Dave Mark Cartwright Reed • •• Addison-Wesley Publishing Company, Inc. Reading, Massachussets Menlo Park, California New York Don Mills, Ontario Wokingham, England Amsterdam Bonn Sydney Singapore Tokyo Madrid San Juan

Reading notes: Transcript is set to empty because the exact extracted text is preserved separately. Supplied copy prints 'Massachussets', which is a misspelling of 'Massachusetts' as printed. Layout and reading order are inferred from the supplied line breaks, not confirmed from the image. No prices or dates appear in the supplied copy.

Printed product names
Macintosh® · THINK's LightspeedC™
Languages
English
PDF page 3

I To Kate and Deneen 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 caps or all caps-for example, Macintosh, THINK C. Library of Congress Cataloging-in-Publication Data Mark, Dave. Macintosh programming primer. Includes index. 1. Macintosh (Computer)--Programming. 2. C (Computer program language). I. Reed, Cartwright. II. Title. QA76.8.M3M368 1989 005.265 88-34992 ISBN 0-201-15662-8 Copyright © 1989 by Dave Mark and Cartwright Reed 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, electronic, mechanical, photocopying, recording, or otherwise, without the prior written permission of Addison-Wesley. Printed in the United States of America. ABCDEFGHIJ-AL-89 First Printing, April 1989

Reading notes: Source appears to be front matter of a book; no advertised products or prices present. Printed date 88-34992 is a Library of Congress control number rather than a publication date.

Printed product names
Macintosh · THINK C
Printed dates
1989 · April 1989 · 88-34992
Languages
English
PDF page 4

Contents Acknowledgments vii Foreword Stephen Chernicoff ix 1 Introduction 1 The Macintosh Vision 2 About the Book 6 How to Use This Book 19 What You Need to Get Started 20 Ready, Set... 21 2 SettingUp 23 Installing THINK C 24 Macintosh Programming Issues 26 The Hello, World Program 35 In Review 42 3 Drawing on the Macintosh 43 Introduction 44 Window Management 48 Drawing in Your Window: The QuickDraw Toolbox Routines 53 The QuickDraw Programs 60 Hello2 60 Walking through the Hello 2Code 66 Variants 69 Mondrian 73 iii

Printed product names
THINK C
Languages
English
PDF page 5

iv Contents Walking through the Mondrian Code 76 Variants 79 ShowPICT 84 Walking through the ShowPICT code 88 Variants 92 Screen Saver: The Flying Line Program 92 Walking through the Flying Line Code 96 In Review 102 4 The Event Mechanism 103 Event Types 105 The Structure of a Mac Program: New and Improved 107 Retrieving Events from the Event Queue 109 Handling Events 112 EventTutor: The Return of Show PICT 113 Walking through the EventTutor Code 125 In Review 142 5 Menu Management 143 Menu Components 144 The Pull Down Menu 146 The Hierarchical Menu 146 The Pop-Up Menu 147 Other Kinds of Menus 147 Putting Menus into Your Programs 148 Timer 149 Setting Up the Project 150 Timer Code 163 Walking through the Timer Code 172 Zinger 182 Walking through Zinger 190 In Review 196 6 Working with Dialogs 197 How Dialogs Work 199 Dialog Items: Controls 201 Other Dialog Items 204 Working with Alerts 206 Adding Dialogs to Your Programs 207 The Notification Manager 212 Reminder 215 Walking through the Reminder Code 244 In Review 261 7 Toolbox Potpourri 263 Keeping Track of Windows: WindowMaker 264 The Scrap Manager 295 ShowClip 297

Languages
English
PDF page 6

Contents v Inside the Printing and File Managers 307 Using the Printing Manager 312 PrintPICT 312 Scroll Bars! We're Gonna Do Scroll Bars! 327 Pager 329 The Sound Manager 347 Sounder 347 Walking through the Sounder Code 352 In Review 354 8 Using ResEdit 355 The Finder Resources 357 Completing a Standalone Application: Hello2 Revisited 358 Notes on Using ResEdit 360 The ResEdit Tutorial: Installing the Finder Resources 366 Rebuilding the Desktop 384 Minimalist, the ResEdit Program 391 In Review 395 9 The Final Chapter 397 Macintosh Periodicals 398 The Essential Inside Macintosh 398 Apple Technical References 400 Apple's Developer Programs 402 Macintosh Developer Technical Support and AppleLink 402 Software Development Tools 403 To Boldly Go 404 Appendix A Glossary 405 Appendix B Code Listings 419 Chapter 2, Hello.c 420 Chapter 3, Hello2.c 420 Chapter 3, Mondrian.c 421 Chapter 3, ShowPict.c 423 Chapter 3, Flying Line.c 425 Chapter 4, EventTutor.c 428 Chapter 5, Timer.c 436 Chapter 5, Popup.c 444 Chapter 6, Reminder.c 448 Chapter 7, WindowMaker.c 460 Chapter 7, ShowClip.c 466 Chapter 7, PrintPICT.c 469 Chapter 7, Pager.c 472 Chapter 7, Sounder.c 478 Appendix C THINK C Command Summary 481 The Project Menu 482 The File Menu 485

Reading notes: Primary heading not clearly identifiable from the supplied copy; headline set to null.

Printed product names
THINK C · ResEdit · Inside Macintosh · Hello2 · PrintPICT · Sounder · Minimalist · AppleLink · Mondrian
Languages
English
PDF page 7

vi The Edit Menu 486 The Search Menu The Source Menu The Windows Menu 489 491 492 Appendix D The Debugger Command Summary The Source Window of the Debugger 494 The Data Window of the Debugger 495 Appendix E Debugging Techniques Compilation Errors 500 Improving Your Debugging Technique 502 Recommended Reading 503 Appendix F Building HyperCard XCMDs The XChooser XCMD 506 Building the XCMD 507 Copying the XCMD into a Stack 508 Appendix G Bibliography Index 523 Contents 493 499 505 521

Languages
English
PDF page 8

Acknowledgments WE'D LIKE To thank some of the people who made this book possible: Deneen Melander and Kate Joyce, who waited patiently for us to return; Fred Cole: Without his support and guidance, this book would not have been written; Dr. Oleh Tretiak, director of Drexel University's Image Processing Center, who gave us the time to do a better job; Steve Baker, Bill Wagoner, and Dave Frazier, who covered for us; Julie Stillman, Debbie Cook, Perry Mcintosh, Judy Ashkenaz, and David Ershun, who kept this book on track to the end; Jim Friedlander, our technical referee, who managed to squeeze a move to Paris in between chapters; Steve Chernicoff, who was there at the beginning; Stu Mark, who was like a brother to us! Jacob Joseph Taber. This was why I missed your first birthday party. Hi, Lori. Hi, Ralph. Hayward, Mary, Brian, Erik, and Chris, and Amy: the best kind of kin; Karen Elizabeth Ann Swartz: the newest member of DATOM Enterprises; the great DD: Ross and Chris Bartell, Mike Poreda, Jeff Sesler, Denis Roark, and Steve and Linda Schnetzler; Erik and Deb Hardy, Missy Kane, and Allen Lang, the folks at NASA HQ, and the entire gang in LA-thanks, guys! and finally, our parents, Murray and Trudy Mark, and Ogden and Nancy Reed, who gave us years and years. vii

Reading notes: Possible OCR spacing artifacts in some lines, such as 'Mcintosh' and 'Chernicoff' Page marker 'vii' at end of text is ambiguous in reading order

Languages
English
PDF page 9

Source Code Disk for the Primer

viii Source Code Disk for the Primer IF You WoULD like the source code presented in the Macintosh Programming Primer on disk, please send in the coupon on the last page. In addition to the source code presented in the book, we also include the HyperCard XCMD source code and libraries. These were made available to us by Symantec, the publishers of THINK C. We hope you like the Macintosh Programming Primer. If you have any comments or suggestions regarding future editions, you can reach us at this address: The Mac Primer-Comments 2534 North Jefferson Street Arlington, VA 22207

Reading notes: Possible letter-spacing artifacts in 'Macintosh Programming Primer' and 'THINK C' from extraction

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

Foreword Stephen Chernicoff EVERYBODY REMEMBERS How revolutionary Apple's Macintosh computer was when it first appeared in January 1984. One look was enough to tell you that this was something new. The bright, lively screen, the high-resolution graphics, the multiple fonts and type styles-not to mention that funny little gadget with the button on top and the roller ball on the bottom-all served notice that this was not just another boring old computer. Here at last was a machine that met you on your terms instead of its own. Gone were the days of enigmatic prompt characters, cryptic command sequences, and incomprehensible error messages. In their place was a new vocabulary of concepts, novel and yet reassuringly natural and intuitive: windows and scroll bars, pull-down menus and dialog boxes, check boxes and radio buttons, icons and desk accessories. Using a computer was suddenly easy, comfortable, and above all fun. For most of us, it was love at first sight. But as great a boon as the Macintosh was to ordinary users, it held an unprecedented gift for programmers as well. An integral part of the system was the User Interface Toolbox, a body of tightly engineered, lovingly handcrafted machine-language code built into every Macintosh in read- only memory (ROM). By implementing the features of the standard user interface, the Toolbox gave programmers all the support they needed to produce finished-quality software with the distinctive Macintosh "look and feel." Unfortunately, even with this considerable helping hand from Apple, learning to program the Macintosh remained a formidable undertaking. All ix

Reading notes: Headline not identifiable: the text is a foreword with no distinct primary heading. Source is a foreword excerpt, so the product list is limited to names explicitly mentioned in the copy.

Printed product names
Macintosh · User Interface Toolbox
Printed dates
January 1984
Languages
English
PDF page 11

x Foreword that increased freedom and convenience for the user imposed a heavier burden of discipline on the programmer, who had to master a new and perhaps unfamiliar "event-driven" style of programming. The original Toolbox included more than 400 different routines, and the latest models add even more. Apple's own epic reference work on the Toolbox, Inside Macintosh, was a prodigious brainful for any programmer to digest. It was to help readers come to terms with this mass of material that I wrote my Macintosh Revealed series of books back in 1984. My aim was to present the fundamental ideas underlying the Toolbox in a more readable, accessible way, along with an extensive, fully developed example program showing how to put those ideas to practical use. I hoped to give my readers a compass with which to chart their own course through the labyrinth of Inside Macintosh. Still, the sheer scope of the subject remained daunting. What was clearly needed was a good introductory book that could serve as a stepping-stone to the level of Mac Revealed andlnside Mac. Now, Dave Mark and Cartwright Reed have filled that need with their Macintosh Programming Primer. Starting from the most basic concepts, they take you by the hand and lead you step by step into the brave new world of the Toolbox and event-driven programming. Instead of a single, all- embracing programming example, Dave and Cart have taken a more gradual approach. A series of smaller, more manageable programs focus on specific aspects of the Toolbox: drawing simple text and graphics, displaying and maintaining windows on the screen, defining menu commands, managing scroll bars and dialog boxes. By the time you've worked through all the examples, you'll be ready to combine the concepts to build full-scale application programs of your own. One of the great strengths of this book is its emphasis on the use of resources as a way of structuring Macintosh programs. The Macintosh Resource Manager is perhaps its boldest and most innovative contribution to the state ofthe programming art, an idea whose versatility and power are only beginning to be fully realized. Right from the start, Dave and Cart show you how to use resources as a central organizing principle to make your programming easier, cleaner, and more modular. Their chapter on Apple's on-screen resource editor, ResEdit, is the best discussion I've seen on this important program development tool. If you're interested in learning to program the Macintosh, there isn't a better place to start than with the book you're holding in your hands right now. Stephen Chernicoff Berkeley, California December 15, 1988

Reading notes: Possible OCR spacing artifacts in titles such as 'andlnside Mac' and 'Inside Macintosh' Heading unclear: no explicit primary heading appears in the supplied copy

Printed product names
Macintosh Revealed · Inside Macintosh · Macintosh Programming Primer · ResEdit · Macintosh Resource Manager
Printed dates
1984 · December 15, 1988
Languages
English