ebook img

Learning Carbon PDF

363 Pages·2001·4.981 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Learning Carbon

Learning Carbon By Apple Computer, Inc. Publisher: O'Reilly Pub Date: May 2001 ISBN: 0-596-00161-4 Pages: 358 • Reviews • Examples Reader • Reviews • Errata Copyright Preface Why Carbon? Who Might Find This Book Helpful What You Need What's Up Ahead Side Trips and Terms Code The Environment Could Change How to Contact Us Chapter 1. Introduction to Carbon Section 1.1. Carbon and Mac OS X Section 1.2. What's in Carbon? Section 1.3. Building Carbon Applications Section 1.4. The Carbon Factory Tour Section 1.5. Recap Chapter 2. Specifying a Carbon Application: Moon Travel Planner Section 2.1. The Moon Travel Planner Window Section 2.2. The Menu Bar Section 2.3. The About Window Section 2.4. The Facts for the Traveler Window Section 2.5. The Itinerary Window Section 2.6. Recap Chapter 3. Project Builder Projects Section 3.1. A Carbon Application Project Section 3.2. Moon Travel Planner: Creating a Project Section 3.3. Recap Chapter 4. Interface Builder: Nibs and Windows Section 4.1. A Carbon Nib File Section 4.2. Moon Travel Planner: Modifying the Default Window Chapter 5. Interface Builder: Tools and Controls Section 5.1. Palettes and Layout Tools Section 5.2. Moon Travel Planner: Adding Objects to the Main Window Chapter 6. Carbon Events Section 6.1. Carbon Event Handling Section 6.2. MoonTravel Planner: Writing an Event Handler Chapter 7. Interface Builder: Menus Section 7.1. The Menu Bar Section 7.2. Moon Travel Planner: Modifying the Menu Bar Chapter 8. Text and Localization Section 8.1. Language-Specific Folders Section 8.2. Moon Travel Planner: Displaying Localized Text Chapter 9. Printing Section 9.1. The Carbon Printing Manager Section 9.2. Moon Travel Planner: Adding Printing to the Moon Facts Window Chapter 10. Property Lists Section 10.1. The Information Property List: Info.plist Section 10.2. Moon Travel Planner: Modifying and Using Properties Chapter 11. Files Section 11.1. Managing Files on the Mac Section 11.2. Moon Travel Planner: Handling Files Section 11.3. Recap Chapter 12. Providing Help Section 12.1. Help on Mac OS X Section 12.2. Moon Travel Planner: Adding Help Section 12.3. Recap Chapter 13. Desktop Icons Section 13.1. Icon Basics Section 13.2. Moon Travel Planner: Adding Icons Section 13.3. Recap Chapter 14. Beyond Moon Travel: Advanced Topics Section 14.1. Scriptable Applications Section 14.2. Threads and Multiprocessing Section 14.3. Tab Controls Section 14.4. Epilogue Appendix A. Additional Resources Section A.1. Building Your Mac OS X Library Section A.2. Tapping the Carbon Developer Community Section A.3. Keeping Current Section A.4. Getting Sample Code Section A.5. Registering Creator Codes Section A.6. Partnering with Apple Appendix B. Carbon Event Classes and Kinds Appendix C. Parameter Names and Types for Common Event Kinds Section C.1. Apple Events Section C.2. Control Events Section C.3. Command Events Section C.4. Menu Events Section C.5. Mouse Events Section C.6. Text Input Events Section C.7. Window Events Colophon Index Book: Learning Carbon Copyright © 2001 O'Reilly & Associates, Inc. All rights reserved. Printed in the United States of America. Published by O'Reilly & Associates, Inc., 101 Morris Street, Sebastopol, CA 95472. The O'Reilly logo is a registered trademark of O'Reilly & Associates, Inc. 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 O'Reilly & Associates, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. The association between the image of bloodhounds and Carbon is a trademark of O'Reilly & Associates, Inc. Apple Computer, Inc. boldly combined open source technologies with its own progamming efforts to create Mac OS X, one of the most versatile and stable operating systems now available. In the same spirit, Apple has joined forces with O'Reilly & Associates to bring you an indispensable collection of technical publications. The ADC logo indicates that the book has been technically reviewed by Apple engineers and is recommended by the Apple Developer Connection. Apple, the Apple logo, AppleScript, AppleTalk, AppleWorks, Cocoa, Finder, Mac, Macintosh, MPW, QuickDraw, QuickTime, and Sherlock are trademarks of Apple Computer, Inc., registered in the United States and other countries. Aqua, Carbon, and Quartz are trademarks of Apple Computer, Inc. While every precaution has been taken in the preparation of this book, the publisher assumes no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. Book: Learning Carbon Preface If you want to get up to speed quickly on using Carbon to create Mac OS X applications, this is the book for you. It shows how to put together a Carbon application that does all the things commonly found in an application, such as handling windows, responding to menu commands and controls in the interface, printing documents, and opening and saving files. The application you'll create in this book isn't one of those boring computational programs that figure prime numbers or compute factorials. Instead, you'll put together something that could be of practical value as we enter the third millennium-a moon travel planner. This book is not an exhaustive guide to writing Carbon applications. We've limited the topics and scope of coverage to those we think are most important for programmers new to Carbon. We've provided a road map to all the Carbon managers and services (Chapter 1) and an introduction to a few advanced topics-scripting, tab controls, threads, and multiprocessing (Chapter 14). So once you are finished with this book, you'll be prepared to write a Carbon application on your own. cat:31ms (xsl)109ms (ent)0ms (buf)0ms (tot)2344ms --> BSeocotkio: nLe: aPrrneifnagc eCarbon Why Carbon? If you're writing an application that will run exclusively on Mac OS X, there are several ways you can do it. You can use Cocoa, Carbon, or Java. So why use Carbon? If you know a procedural language, such as C, you'll feel right at home with Carbon. You'll be able to draw upon your knowledge and experience of procedural programming languages. You might even find that in new applications you create with Carbon, you can reuse code you've already written. Although the Carbon programming interface uses the C language, you can write Carbon applications in many different languages, including object oriented languages such as C++. Apple provides both C and C++ compilers for use with Carbon, and third-party tools are available for writing Carbon applications in Pascal, BASIC, Fortran, and other languages. If you are more familiar with object-oriented programming, you should take a look at Learning Cocoa (O'Reilly & Associates). Java programmers may want to read Inside Mac OS X: Java Development for Mac OS X, available from Apple's Java Developer Documentation web site: http://developer.apple.com/techpubs/java/ BSeocotkio: nLe: aPrrneifnagc eCarbon Who Might Find This Book Helpful Anyone who has some experience programming with the C language (extensive programming experience is not required) and a rudimentary understanding of computer science concepts should find the book helpful and fun. This book is a good starting point for students, individual programmers, small developers, and anyone who has an interest in, or curiosity about, Mac OS X. You don't need to be familiar with the Mac OS, or any platform for that matter. As long as you've knocked out a few small programs using C, you should do just fine with Carbon. BSeocotkio: nLe: aPrrneifnagc eCarbon What You Need This book takes a hands-on approach. To get the most out of it, you need to use this book along with Apple's development tools-Project Builder and Interface Builder. You'll need the following to complete this tutorial: A computer that's running Mac OS X. l Project Builder and Interface Builder, available on the Mac OS X Developer CD, l which is included with every copy of Mac OS X. Files and images to complete the Moon Travel Planner application you'll build in l this book. You can find information on how to download these materials by going to this O'Reilly web site (where you'll also find all of the numbered code examples from this book): http://www.oreilly.com/catalog/learncarbon/. BSeocotkio: nLe: aPrrneifnagc eCarbon What's Up Ahead This book is designed as a tutorial. Each chapter builds upon the previous one. You should start at the beginning and proceed sequentially. Chapters are designed so you can stop at the end of each one, then pick up with the next at a later time. This book will take you, step by step, through the design and building of a simple Carbon application (Moon Travel Planner). After finishing this book, you should be comfortable enough with basic Carbon concepts and the workings of Project Builder and Interface Builder to start writing your own Carbon applications. The topics in upcoming chapters are as follows: Chapter 1 provides an overview of Carbon, Mac OS X, and the Carbon l programming interfaces and tells what's involved in building a Carbon application. Chapter 2 discusses the process of specifying a simple application, Moon Travel l Planner, and its user interface. Chapter 3 introduces Project Builder and describes how to build a minimalist l application (essentially the prototypical "Hello World" application without the "Hello World" part). It also introduces the concept of bundles and application packaging. Chapter 4 introduces Interface Builder and shows how to use it to create a simple l window. Chapter 5 expands on Chapter 4, letting you add buttons and other controls to the l simple window. Chapter 6 introduces the Carbon event-handling model and shows you how to l create a basic event handler. Chapter 7 shows you how to use Interface Builder to create menus for your l application. Chapter 8 shows you how to organize a project to support localization and how to l handle text that is displayed in a window. Chapter 9 introduces the basics of printing in Carbon and shows you how to print a l window containing text. Chapter 10 introduces property lists, which are a generic way to store information l needed by your application. It also describes how to design and implement an About window so that it displays information from a property list. Chapter 11 shows you how to store and retrieve data in a file. l Chapter 12 describes help facilities, namely help books and help tags, available to l your application and shows how to implement them. Chapter 13 shows how to create an icon for your application and how to identify l your application (and any files it creates) to the Finder application. Chapter 14 describes some additional features that may be useful for your l applications. Appendix A provides information on Carbon-related resources and where to find l them. If a book or document is mentioned in a chapter, you'll find out how to get it here. Appendix B describes the event constants you'll need when you create an l application that uses the Carbon Event Manager. Appendix C provides a detailed set of tables that list constants you'll need to l retrieve parameter values associated with Carbon events.

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.