← Foundations of Mac Programming 1995

Foundations of Mac Programming 1995

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

FOUNDATIONS™ of Mac® PROGRAMMING NEW! Save Time with Reusable Code on CD — for Symantec C++ & Metrowerks Compilers All New! Learn Key Mac Programming Concepts and Put Them to Work in Your Programs Master Mac Memory and Resource Management for Efficient Programming Write Interactive Programs Capable of Playing QuickTime Movies Covers Symantec C++ 8.0 or Later & Metrowerks Code Warrior Compilers DAN PARKS SYDOW Foreword by Greg Galanos, President & CEO, Metrowerks, Inc. MAC® & POWER MAC™ PROGRAMMING IN C IDG BOOKS WORLDWIDE

A book cover with a stone column capital and shaft against a blue sky, binary digits running across the column, a purple panel with large white Mac lettering and yellow PROGRAMMING text, a CD graphic at top right, and a small inset photo of the same column.

Reading notes: Small CD sticker text and the IDG Books logo at bottom left are small and may have minor reading uncertainty. Reading order of the feature bullets on the right side is inferred from layout.

Printed product names
Mac · Symantec C++ · Metrowerks Compilers · Metrowerks Code Warrior Compilers
Languages
English
PDF page 1

FOUNDATIONS™ of Mac® PROGRAMMING NEW! Save Time with Reusable Code on CD — for Symantec C++ & Metrowerks Compilers All New! Learn Key Mac Programming Concepts and Put Them to Work in Your Programs Master Mac Memory and Resource Management for Efficient Programming Write Interactive Programs Capable of Playing QuickTime Movies Covers Symantec C++ 8.0 or Later & Metrowerks Code Warrior Compilers DAN PARKS SYDOW Foreword by Greg Galanos, President & CEO, Metrowerks, Inc. MAC® & POWER MAC™ PROGRAMMING IN C IDG BOOKS WORLDWIDE

A book cover with a classical fluted column capital and column photographed against a blue sky, overlaid with red and yellow binary digits, a purple title panel reading Mac in large white letters, a CD graphic in the upper right, and a small inset of the column image.

Reading notes: Sequence of the top-left title words is stylized; 'FOUNDATIONS' and 'of' are printed in differing typefaces and may read in a different order visually. '8.0' is a version number rather than a date, listed in printedDates only because it is the only numeric version string visible; may be reclassified. Small text in the bottom-left IDG logo area was read as 'IDG BOOKS WORLDWIDE' and may be partly obscured.

Printed product names
Symantec C++ · Metrowerks Compilers · Metrowerks Code Warrior Compilers
Printed dates
8.0
Languages
English
PDF page 2

Explore several advanced features of Macintosh programming. Expand your understanding of color, sound, and QuickTime movies. Master the development of multiple- document interface applications. By exploiting the programming features of graphical user interfaces, create advanced programming projects. programming language: program structure; QuickDraw, data files; input and output; and the events, properties, and methods of Mac controls. Examine - and revise! - the code of real-world applications. Master the steps of Macintosh application development. Learn to create useful and attractive windows and dialog boxes. Refine the program' s appearance and behavior by adding menus and text. programming environment and ~xplore its features through a series of hands-on example programs. L earn about resources and memory, and how to use the Toolbox to begin building an application. Run your first Mac program.

Reading notes: No headline is evident in the supplied copy, so headline is null. OCR-style irregularities in the supplied copy: '~xplore' (likely 'Explore'), 'L earn' (likely 'Learn'), and "program' s" (likely "program's"). Reading order of the four paragraphs is uncertain because the copy has irregular spacing and some paragraph breaks appear to be missing. Product names such as Macintosh, QuickTime, QuickDraw and Toolbox are topic terms in a course description, not clearly advertised products, so they may not belong in productNames.

Printed product names
Macintosh · QuickTime · QuickDraw · Toolbox · Mac
Languages
English
PDF page 3

FOUNDATIONS of Mac PROGRAMMING

FOUNDATIONS of Mac® PROGRAMMING

A plain white page with a bold black title logo reading FOUNDATIONS in heavy sans-serif capitals at upper left, an italic lowercase 'of' beneath it, and a large rounded 'Mac' with a registered trademark symbol above the spaced capitals PROGRAMMING, with a yellowish stain at the upper right edge.

Reading notes: The word 'of' is in italic script and is set slightly lower than FOUNDATIONS; reading order is treated as FOUNDATIONS, of, Mac, PROGRAMMING. The ® symbol after Mac is small and is included as shown.

Printed product names
Mac
Languages
English
PDF page 4

A completely blank white page with no visible artwork, layout, or printed content.

Reading notes: The image appears entirely blank white with no visible text, so no transcription was possible.

PDF page 5

Foundations of Mac® Programming

Foundations of Mac® Programming Published by IDG Books Worldwide, Inc. An International Data Group Company 919 E. Hillsdale Blvd. Foster City, CA 94404 Text, art, and software compilations copyright© 1995 by IDG Books Worldwide, Inc. All rights reserved. No part of this book, including interior design, cover design, and icons, may be reproduced or transmitted in any form, by any means (electronic, photocopying, recording, or otherwise) without the prior written permission of the publisher. Library of Congress Catalog Card No.: 95-81091 ISBN: 1-56884-349-6 Printed in the United States of America 10987654321 lNSZ/RR/ZV Distributed in the United States by IDG Books Worldwide, Inc. Distributed by Macmillan Canada for Canada; by Computer and Technical Books for the Caribbean Basin; by Contemporanea de Ediciones for Venezuela; by Distribuidora Cuspide for Argentina; by CITEC for Brazil; by Ediciones ZETA S.C.R. Leda. for Peru; by Editorial Limusa SA for Mexico; by Transworld Publishers Limited in the United Kingdom and Europe; by Al-Maiman Publishers & Distributors for Saudi Arabia; by Simron Pty. Ltd. for South Africa; by IDG Communications (HK) Ltd. for Hong Kong; by Toppan Company Ltd. for Japan; by Addison Wesley Publishing Company for Korea; by Longman Singapore Publishers Ltd. for Singapore, Malaysia, Thailand, and Indonesia; by Unalis Corporation for Taiwan; by WS Computer Publishing Company, Inc. for the Philippines; by WoodsLane Pty. Ltd. for Australia; by WoodsLane Enterprises Ltd. for New Zealand. For general information on IDG Books Worldwide's books in the U.S., please call our Consumer Customer Service department at 800-762-2974. For reseller information, including discounts and premium sales, please call our Reseller Customer Service department at 800-434-3422. For information on where to purchase IDG Books Worldwide's books outside the U.S., contact IDG Books Worldwide at 415-655-3021 or fax 415-655-3295. For information on translations, contact Marc Jeffrey Mikulich, Director, Foreign & Subsidiary Rights, at IDG Books Worldwide, 415-655-3018 or fax 415-655-3295. For sales inquiries and special prices for bulk quantities, write to the address above or call IDG Books Worldwide at 415-655-3200. For information on using IDG Books Worldwide's books in the classroom, or ordering examination copies, contact Jim Kelly at 800-434-2086. For authorization to photocopy items for corporate, personal, or educational use, please contact Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, or fax 508-750-4470. limit of liability/Disclaimer of Warranty: The author and publisher have used their best efforts in preparing this book. IDG Books Worldwide, Inc., and the author make no representation or warranties with respect to the accuracy or completeness of the contents of this book and specifically disclaim any implied warranties of merchantability or fitness for any particular purpose and shall in no event be liable for any loss of profit or any other commercial damage, including but not limited to special, incidental, consequential, or other damages. Trademarks: Mac and Macintosh are registered trademarks of Apple Computer, Inc. All brand names and product names used in this book are trademarks, registered trademarks, or trade names of their respective holders. IDG Books Worldwide is not associated with any product or vendor mentioned in this book. _,,, ::::;;;;;; is a trademark under exclusive IDG license to IDG Books Worldwide, Inc., BOOKS from International Data Group, Inc. WOlllDWIDE

Reading notes: Some OCR spacing irregularities in distributor list (e.g., 'Ediciones ZETA S.C.R. Leda.') Logo text at bottom ('WOlllDWIDE', '::::;;;;;;') is partially garbled

Printed product names
Mac · Macintosh
Printed dates
1995 · 95-81091
Languages
English
PDF page 6

About the Author Since graduating from the Milwaukee School of Engineering, Dan Parks Sydow has worked on software in areas as diverse as the control of nuclear reactors for defense purposes and the display of heart images for medical purposes. He is currently a consultant and free-lance writer. Dan is the author of several books on programming the Macintosh, including Program- ming the PowerPC and the IDG title Mac Programming For Dummies. You can contact Dan at danparks@aol .com

Reading notes: Line-break hyphenation in 'Program-ming' may affect reading of the book title

Printed product names
Mac Programming For Dummies
Languages
English
PDF page 7

Welcome to the world of IDG Books Worldwide. IDG Books Worldwide, Inc., is a subsidiary of International Data Group, the world's largest publisher of computer-related information and the leading global provider of information services on information technology. !DG was founded more than 25 years ago and now employs more than 7,700 people worldwide. IDG publishes more than 250 computer publications in 67 countries (see listing below). More than 70 million people read one or more IDG publications each month. Launched in 1990, IDG Books Worldwide is today the #l publisher of best-selling computer books in the United States. We are proud to have received 8 awards from the Computer Press Association in recognition of editorial excellence and three from Computer Currents' First Annual Readers' Choice Awards, and our best-selling ... For Dummies® series has more than 19 million copies in print with translations in 28 languages. IDG Books Worldwide, through a joint venture with IDG's Hi-Tech Beijing, became the first U.S. publisher to publish a computer book in the People's Republic of China. In record time, IDG Books Worldwide has become the first choice for millions of readers around the world who want to learn how to better manage their businesses. Our mission is simple: Every one of our books is designed to bring extra value and skill-building instructions to the reader. Our books are written by experts who understand and care about our readers. The knowledge base of our editorial staff comes from years of experience in publishing, education , and journalism - experience which we use to produce books for the '90s. In short, we care about books, so we attract the best people. We devote special attention to details such as audience, interior design, use of icons, and illustrations. And because we use an efficient process of authoring, editing, and desktop publishing our books electronically, we can spend more time ensuring superior content and spend less time on the technicalities of making books. You can count on our commitment to deliver high-quality books at competitive prices on topics you want to read about. At IDG Books Worldwide, we continue in the IDG tradition of delivering quality for more than 25 years. You'll find no better book on a subject than one from IDG Books Worldwide. john Kilcullen President and CEO !DG Books Worldwide, Inc. IDG Books Worldwide, Inc., is .a subsidiary of lnicrnatlonal Oaca Group, 1 hc world's largest publisher of computer-related lnfo1ma1 ion and Lhc leading global provider of lnforma1ion services on information technology. l111crna1 ional Data Group publishes over 250 compu1cr publica1ions in 67 countries. Seventy million }>'Opie rtad one or mart lmcrna1ional Data Group publications cO'lch month. International Data Group's public.-i!lons include: ARGENTINA: Computerworld A rgentina. GamcPro. lnfoworld , PC World Argentina: AUSTRALIA: AUStf;llian Macworld. Clienv'Server Journ.11. Computer Living. Compu tcrn-orld, Digi 1al News. NC!work World. PC \\brld. Publishing Ess<ntials. R csellcr: AUSTRIA: Computerwelr. PC TEST; BELARUS: PC World Bc:larus; BELGIUM: Dala News: BRAZIL: Annuii no de lnforml1tica, Computerworld Brazil, Connccllons, Supu Game Power. MaC\\·orld , PC World Brazil, Publish Brazil, SUPERGAME: BULGARIA; Cornputtrworld Bulgaria, Networkworld/Bulgaria. PC&. MacW orld Bulgaria; CANADA: CIO U.nada, Computer\Vorld Canada. lnfoCanada. Network World Canada, Rtscller World. CHILE: Compmerworld Chile, GamePro. PC World Chile; COLUMBIA: Computerworld Colombia, GamePro. PC \Vorl<l Colombia: COSTA RI CA: PC W orld Co.ta Rica/Nic::iragua; THE CZECH AND SLOVAK REPUBLICS: Computcrworld ucchoslovakia. Elcktronika ucchoslo•~kta. PC W orld Cuch<><lo\'akta; DENMARK: Communiauons V.\lrld. Cornputerworld Darunark. M acworld l>.mmark. PC \\brld Danmark. PC \\\Jrld Danm:irk Supple.mcntS. TECH World; DOM INICAN REPUBLIC: PC World R<:pubha Dommlcana; ECUADOR: PC World Ecuador. GamePro; EGYPT: Computcrworld Middle East. PC \\\lrld Middle East; EL SA L VADOR: PC World C<ntro Amenca: FINI.AND: MikroPC. Tu:tovcrkko. Ticto•11kko: FRANCE: Distributique, Golden. Info PC. le Gulde du t.fonde lnformatique. le Monde lnfomut1que, Rescaux 6r Telecoms; GERMANY: Computer Business. Computerwoche. Computerv.-oche Extra, Compu1erwoc.he Focus, Electronic En1cn ainmcn1. G.am cPro. VM lnformauon Management , M:icwch, PC Weh: GREECE: GamcPro, Macv.·orld l:;J. Publish: GUATEMALA: PC World C<ntro America; HONDURAS: PC World C<ntro America; HONG KONG: Comput<rworld Hong Kong. PC\\\lrld Hong Kong. Publish m Asia: HU NGARY : ABCD CD-ROM. Computerworld S.tamnasiechm\u, PC & Mac 'A'orld Hun~f)'. PC·X Magazine; INDIA: Ccmputerv.·orld India, PC World India, Publish m Asia: INDONESlA: ln£oKomputcr PC World, Komputek Computerworld, Puhhsh ln Asu:i: IRELAND: ComputerScopc. PC Uvc!: ISRAEL: PC W orld 32 BIT, Peo~le & ~m tu 1 crs; ITALY: Computerv.·orld Italia, Computerworld Italia Special Ednions, Lotus ltJlia, Macworld halia, Ne1working Italia, PC ~Pfr~ 1!.;nr g,~~~~~r 1 ~~!sr KO~~~~i~c~i~~fl ~~ro~C:r!:;~:~~:1&. 3 ~;~ ~~~d i :~~."~ ~~;,~u~~r~~: 5 ~~~~ ~6N~~~ ~!~~rld~1~~~~~i~~~~~~~s~~~ Compumworld Malaysia, PC World Malaysia, Publish In Asia; MEXICO: Compmerworld ~icxi c.o. GamcPro, Macworld , PC World Mexico; MYANMAR: PC W orld Myanmar; NETHERLANDS: Compu<ablc. Compu1crl T otaal. lAN Magl'lzinc, Macworld, Net Magazine: NEW ZEAL.AND: Cc mputer Bu}·er. Computtrworld New Zealand, MTB, Network World, PC World New Zealand: NICARAGUA: PC World Costa Ric<V'Nicar3gu:i; NIGERIA: PC World Afric3: NORWAY: Computerwod d Norge. Computerv.·orld Privat. CW Rapport Khent/Tjc:ner, CW Rappon Neu verk &. Tela:om, CW R.1ppon Offcntlig Scktor. IDG's KURSGUIDE, Macworld Norge. f..tultimedia World, PC World Eksprcss. PC World Nettverk, PC World Norge, PC World's Produktguide, Wmdows Spcs1al; PAKISTAN: Computcrn-orld Palasun. PC V.\lrld Pakistan; PANAMA: G:imcPro. PC World Panam:i: PARAGUAY: PC World P:uaguay; P.R. OF CHINA: Otina Comput<rworld. China lnfowor1d, Computer&. Commumcanon, Electronic Product \Vorld, Electronics Toda}'. Game Camp. PC W orld China, Popular Computer Wtek Soft ware World. Telecom Product World: PE RU: Computerv.• orld Peru. GamePro. PC World Profosional Peru, PC World Pnu; POLAND: Compu1crworld Poland , Compu1erworld Special Report, M acworld, Nctworld, PC World KomP'Jter, PIULI PPlNES: Computerworld Ph1hppines. PC Digest Publish in Asia: PORTUGAL: C.CrcbrolPC World, Comio lnfonnJ.tiro'Compurerworld, Mac •ln/PC•ln Ponugal; PUERTO RICO: PC World Pucno Rlco: ROMANIA: Computtrv.'Orld Romanta, PC World Romania, Telecom Romania; RUSSIA: Computerv.·orld RoSSl}":l. Network World Russi.a, PC World Russia. SINGAPORE: Cornputcrworld Singapo re , PC V.\lrld Sm~port. Publish in Asia: SLOVENIA: MONITOR. SOUTII AFRICA: Computing S.A., Network World SA .• Software \\brld: SPAIN: Com&::tcrworld ~~r~~~~:;~~ 1 ~~~o~~~~~~~r&~~ 1 !~M:n~~~~n~~~kt~\~ ~o~~~~~~~~~~1d~~~~fLA~~r~~~;~ ~ ~ r 'fd~~,~eiz, ~~~~~~ Sc:hwciz, PCtip; TAIWAN: Computerv.·orld Taiwan, Macworld T :1iw:1n, PC World Taiwan. Publish T ;.1iwan, Windows World: THAILAND: Thai Compmerworld, Publish in Asia: TURKE\': Compmerv.·orld Monitor, MAC\\'ORW Turki)'C, PC WORLD Turkt)'e: UKRAI NE: Computerworld Kiev, Computers & Software Magazine. PC World Ukraine; UN ITED KJNG DOM: Acom User, Amiga Ac<ion, Amiga Computing, Amiga, Appleulk, CD Powerplay, CD-ROM Now. Compu1\ng, Connexion. GamePro, Lotus Magru:ine. Macaction, M;1cworld, Open Computing, Parents and Computers. PC Home. PC Works, The WEB: UNITED STATES: Cable in the Clw room, CD Re\ficw, CIO Mag.tzlne. Computcrworld , Computerworld Client/Server Journal. Digital Video Magazine. DOS World, Elec1ronic, lnfoWorld, 1-Way, Mncworld, Maximize, MULTIMEDIA WORLD, Network \Vorld , PC W orld. PUBLISH, SWATPro M3gazine, Video Event, Wcbtviastcr. URUGUAY: PC World Uruguay; VENEZUEL\: Compulerworld V enezuelt1. GamePro, PC World Venezuela: and VIETNAM: PC World Viemarn l0/17/95

Reading notes: Second block of OCR text is heavily garbled, with many character substitutions and broken words, so the publication list cannot be reliably transcribed. Headline cannot be determined from the supplied copy, as the opening line is body text rather than a labeled primary heading.

Printed product names
For Dummies
Printed dates
1990 · 25 years ago · '90s
Languages
English
PDF page 8

Acknowledgments Most importantly, I'd like to thank Nadine and Taylor for their patience and support. Without knowing it, you've helped write this book! Thanks to Ken Brown, Developmental Editor, IDG Books, for keeping things running smoothly, and to Felicity O'Meara, who brought her keen copy editor's eyes to the manuscript. As always, Peter Ferrante, Apple Computer, gains my appreciation for another helpful technical edit. Thanks also to Carole McClendon, Waterside Productions, for making this book happen. Many thanks to the software authors who granted permission to allow their programs and utilities to appear on this book's CD. A special thanks to Ambrosia Software - their handy, easy to use shareware products helped with this book's figures. The ColorSwitch color-setting control panel made it easy to quickly change monitor color levels, and the Snapz screen-capture control panel allowed screen dumps to be made while menus were dropped. Contact Ambrosia Software at AmbrosiaSW@aol.com. (The Publisher would like to give special thanks to Patrick J. McGovern, without whom this book would not have been possible.) - ...

Printed product names
ColorSwitch · Snapz
Languages
English
PDF page 9

Credits Senior Vice President and Group Publisher Brenda Mclaughlin Acquisitions Editor Nancy E. Dunn Brand Manager Pradeepa Siva Developmental Editor Kenyon Brown Editorial Assistant Suki Gear Production Director Beth Jenkins Production Assistant Jacalyn L. Pennywell Supervisor of Project Coordination Cindy L. Phipps Supervisor of Page Layout Kathie S. Schnorr Production Systems Specialist Steve Peake Pre-Press Coordination Tony Augsburger Patricia R. Reynolds Theresa Sanchez-Baker Media/Archive Coordination Leslie Popplewell Kerri Cornell Michael Wilkey Copy Editor Felicity O'Meara Technical Reviewer Peter Ferrante Project Coordinator Valery Bourke Graphics Coordination Shelley Lea Gina Scott Carla Radzikinas Production Page Layout Dominique Defelice Angela Hunckler Drew R. Moore Proofreaders Sandra Profant Gwenette Gaddis Dwight Ramsey Carl Saff Robert Springer Indexer Richard T. Evans Cover Design Draper and Liew Cover Image Draper and Liew

Reading notes: Source appears to be a publication credits page; no advertised products, prices, or headline are present.

Languages
English
PDF page 10

ontents Overview ·~·························································· 1 DUCTION TO MAC PROGRAMMING CONCEPTS .......... 7 m ,ou•re new to Macintosh programming, or have only compiled a few trivJil example programs, you'll want to read the chapters in Prut I to get an overview of what Mac code looks like, how it works, and how it inter- -atts With resomces and me ory. Chapter 1 Overview f Mac Programming ............................................. 9 This chapter covers th to pics, techniques, and terminology that are of importance to all Mac rogrammers, and introduces you to the p ur- pose of resources and he Macintosh Toolbox. Here you'll find a very short, well-documente first look at a Macintosh source code listing for a program that plays a QuickTime movie . Chapter 2 Resources • ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••.••••••••••• 51 This chapter takes a l ok at how a programmer uses resources to easily define the elem nts of the Mac's graphical user interface - ele- ments such as menus, windows, dialog boxes. The chapter describes how a Mac program loads resource data into memory for use by your program's code. Chapter 3 Memory ............................................................................ 99 Each program that runs on a Macintosh is given its own p rivate area of RAM. This chapter shows how your program will make use of this memory.

Reading notes: Several words are broken by OCR artifacts (e.g., 'ontents', 'DUCTION', 'ount', 'tr', 'ith', 'resomces'), making some text uncertain. Chapter 1 description and some other passages have dropped characters that make reading uncertain.

Languages
English
PDF page 11

PART II PROGRAMMING FUNDAMENTALS

PART II PROGRAMMING FUNDAMENTALS ••••••••••••••••••••••••••• 133 The topics covered in Part II are the true fundamentals of Macintosh pro- gramming. All but the most trivial Mac applications make use of the topics covered here. Chapter 4 . Drawing .......................................................................... 135 Much of the work of drawing graphics to a window is taken care of for you by QuickDraw. QuickDraw is the name for the hundreds of built-in drawing routines that are a subset of the thousands of Toolbox routines. This chapter shows how simple shapes such as rectangles and ovals can be drawn with just a function call or two. Chapter 5 Events •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 167 Macintosh programs respond to actions, or events, initiated by the user. A click of the mouse button or a press of a key on the keyboard are each considered an event. This chapter shows how to write an event-driven program - an application that handles such events. Chapter 6 Menus ............................................................................ 189 Users of a Macintosh program make their wishes known to a program through menu selections. All but the simplest of example programs display a menu bar and menus, and respond to user's selection from these menus. This chapter describes how menus are added to a program, and how that pro- gram takes the correct action in response to a user's menu choice. Chapter 7 Windows ••••••••••••••••••••.••••••••••••••••••••••••••••••••••••••••••••••••••• 229 Everything that is displayed by a Mac program is done so in a window. Whether it's graphics, text, or a movie, a programmer needs to first display a window to be used as the drawing board. This chapter shows how to not only open windows, but to allow the user to drag, grow, zoom, and close them as well. Chapter 8 Dialogs ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 269 A dialog box is a window with a few "extras" thrown in. These extras, called dialog items, consist of buttons, check boxes, radio buttons, text items, and more. This chapter demonstrates how a dialog box is displayed and how your program properly handles user mouse button clicks on any of the dialog box items. Both stationary and movable dialog boxes are covered in detail.

Printed product names
QuickDraw
Languages
English