Cocoa Drawing Guide

Total Page:16

File Type:pdf, Size:1020Kb

Cocoa Drawing Guide Cocoa Drawing Guide 2006-10-03 Adobe Systems Incorporated in the U.S. Apple Computer, Inc. and/or other countries. © 2005, 2006 Apple Computer, Inc. Helvetica is a registered trademark of All rights reserved. Heidelberger Druckmaschinen AG, available from Linotype Library GmbH. No part of this publication may be reproduced, stored in a retrieval system, or OpenGL is a registered trademark of Silicon transmitted, in any form or by any means, Graphics, Inc. mechanical, electronic, photocopying, Simultaneously published in the United recording, or otherwise, without prior States and Canada. written permission of Apple Computer, Inc., Even though Apple has reviewed this document, with the following exceptions: Any person APPLE MAKES NO WARRANTY OR is hereby authorized to store documentation REPRESENTATION, EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THIS on a single computer for personal use only DOCUMENT, ITS QUALITY, ACCURACY, and to print copies of documentation for MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. AS A RESULT, THIS personal use provided that the DOCUMENT IS PROVIDED “AS IS,” AND documentation contains Apple’s copyright YOU, THE READER, ARE ASSUMING THE ENTIRE RISK AS TO ITS QUALITY AND notice. ACCURACY. The Apple logo is a trademark of Apple IN NO EVENT WILL APPLE BE LIABLE FOR Computer, Inc. DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES Use of the “keyboard” Apple logo RESULTING FROM ANY DEFECT OR INACCURACY IN THIS DOCUMENT, even if (Option-Shift-K) for commercial purposes advised of the possibility of such damages. without the prior written consent of Apple THE WARRANTY AND REMEDIES SET may constitute trademark infringement and FORTH ABOVE ARE EXCLUSIVE AND IN LIEU OF ALL OTHERS, ORAL OR WRITTEN, unfair competition in violation of federal EXPRESS OR IMPLIED. No Apple dealer, agent, and state laws. or employee is authorized to make any modification, extension, or addition to this No licenses, express or implied, are granted warranty. with respect to any of the technology Some states do not allow the exclusion or described in this document. Apple retains limitation of implied warranties or liability for incidental or consequential damages, so the all intellectual property rights associated above limitation or exclusion may not apply to with the technology described in this you. This warranty gives you specific legal rights, and you may also have other rights which document. This document is intended to vary from state to state. assist application developers to develop applications only for Apple-labeled or Apple-licensed computers. Every effort has been made to ensure that the information in this document is accurate. Apple is not responsible for typographical errors. Apple Computer, Inc. 1 Infinite Loop Cupertino, CA 95014 408-996-1010 Apple, the Apple logo, Carbon, Cocoa, ColorSync, Mac, Mac OS, Macintosh, Quartz, QuickDraw, QuickTime, and Xcode are trademarks of Apple Computer, Inc., registered in the United States and other countries. Objective-C is a registered trademark of NeXT Software, Inc. Adobe, Acrobat, and PostScript are trademarks or registered trademarks of Contents Introduction Introduction to Cocoa Drawing Guide 13 Who Should Read This Document 13 Organization of This Document 13 See Also 14 Chapter 1 Overview of Cocoa Drawing 15 Cocoa Drawing Support 15 The Painter’s Model 16 The Drawing Environment 17 The Graphics Context 17 The Graphics State 17 The Coordinate System 18 Transforms 18 Color and Color Spaces 19 Basic Drawing Elements 19 Geometry Support 19 Shape Primitives 20 Images 21 Text 22 Views and Drawing 22 Common Drawing Tasks 23 Chapter 2 Graphics Contexts 25 Graphics Context Basics 25 The Current Context 26 Graphics State Information 27 Screen Canvases and Print Canvases 29 Graphics Contexts and Quartz 30 Modifying the Current Graphics State 30 Setting Colors and Patterns 31 Setting Path Attributes 31 Setting Text Attributes 31 Setting Compositing Options 32 Setting the Clipping Region 33 Setting the Anti-aliasing Options 35 3 2006-10-03 | © 2005, 2006 Apple Computer, Inc. All Rights Reserved. CONTENTS Creating Graphics Contexts 36 Creating a Screen-Based Context 37 Creating a PDF or PostScript Context 37 Threading and Graphics Contexts 38 Chapter 3 Coordinate Systems and Transforms 39 Coordinate Systems Basics 39 Local Coordinate Systems 39 Points and Pixels 40 Transform Basics 44 The Identity Transform 44 Transformation Operations 44 Transformation Ordering 47 Transform Mathematics 49 Using Transforms in Your Code 50 Creating and Applying a Transform 50 Undoing a Transformation 50 Transforming Coordinates 51 Converting from Window to View Coordinates 52 Flipped Coordinate Systems 52 Using Flipped Coordinates 53 Cocoa Use of Flipped Coordinates 54 Creating a Flip Transform 55 Flipping Images 55 Flipping Text 56 Chapter 4 Color and Transparency 57 About Color and Transparency 57 Color Models and Color Spaces 57 Color Objects 58 Color Component Values 58 Transparency 58 Pattern Colors 59 Color Lists 59 Color Matching 60 Creating Colors 60 Working with Colors 61 Applying Colors to Drawn Content 61 Applying Color to Text 61 Getting the Components of a Color 62 Choosing Colors 62 Working with Color Spaces 63 Converting Between Color Spaces 63 Mapping Physical Colors to a Color Space 63 4 2006-10-03 | © 2005, 2006 Apple Computer, Inc. All Rights Reserved. CONTENTS Chapter 5 Paths 65 Path Building Blocks 65 The NSBezierPath Class 66 Path Elements 66 Subpaths 67 Path Attributes 68 Winding Rules 73 Manipulating Geometric Types 75 Drawing Fundamental Shapes 76 Adding Points 76 Adding Lines and Polygons 77 Adding Rectangles 78 Adding Ovals and Circles 78 Adding Arcs 79 Adding Bezier Curves 81 Adding Text 81 Drawing the Shapes in a Path 82 Drawing Rectangles 83 Working with Paths 84 Building Paths 84 Improving Rendering Performance 84 Manipulating Individual Path Elements 86 Transforming a Path 87 Creating a CGPathRef From an NSBezierPath Object 87 Detecting Mouse Hits on a Path 88 Chapter 6 Images 91 Image Basics 91 Image Representations 92 Images and Caching 94 Image Size and Resolution 96 Images and Flipped Coordinates 97 Supported Image File Formats 98 Basic Formats 98 TIFF Compression 98 Support for Other File Formats 99 Guidelines for Using Images 100 Creating NSImage Objects 100 Loading an Existing Image 101 Loading a Named Image 101 Drawing to an Image 102 Creating a Bitmap 102 Creating a PDF or EPS Image Representation 105 Using a Quartz Image to Create an NSImage 106 5 2006-10-03 | © 2005, 2006 Apple Computer, Inc. All Rights Reserved. CONTENTS Working with Images 106 Drawing Images into a View 106 Creating an OpenGL Texture 107 Applying Core Image Filters 108 Converting a Bitmap to a Different Format 109 Associating a ColorSync Profile With an Image 109 Converting Between Color Spaces 110 Premultiplying Alpha Values for Bitmaps 114 Creating New Image Representation Classes 114 Chapter 7 Text 117 Text Attributes 117 Simple Text Drawing 117 Advanced Text Drawing 118 Chapter 8 Advanced Drawing Techniques 119 Adding Shadows to Drawn Paths 119 Creating Gradient Fills 120 Drawing to the Screen 121 Capturing the Screen 122 Full-Screen Drawing in OpenGL 122 Full-Screen Drawing in Cocoa 123 Disabling Screen Updates 125 Using NSTimer for Animated Content 125 Using Cocoa Animation Objects 125 Optimizing Your Drawing Code 126 Draw Minimally 126 Avoid Forcing Synchronous Updates 126 Reuse Your Objects 126 Minimize State Changes 127 Chapter 9 Incorporating Other Drawing Technologies 129 Using Quartz in Your Application 129 Using Quartz Features 129 Graphics Type Conversions 130 Getting a Quartz Graphics Context 131 Creating a Cocoa Graphics Context Using Quartz 131 131 Modifying the Graphics State 132 Using OpenGL in Your Application 132 Using NSOpenGLView 132 Creating an OpenGL Graphics Context 133 Using QuickTime in Your Application 134 6 2006-10-03 | © 2005, 2006 Apple Computer, Inc. All Rights Reserved. CONTENTS Using the QuickTime Kit 134 Using QuickTime C-Based Functions 134 Using Quartz Composer Compositions 135 Document Revision History 137 Index 139 7 2006-10-03 | © 2005, 2006 Apple Computer, Inc. All Rights Reserved. CONTENTS 8 2006-10-03 | © 2005, 2006 Apple Computer, Inc. All Rights Reserved. Figures, Tables, and Listings Chapter 1 Overview of Cocoa Drawing 15 Figure 1-1 The painter’s model 16 Figure 1-2 Examples of shape primitives 20 Figure 1-3 Examples of bitmap images 21 Figure 1-4 Examples of text 22 Table 1-1 Primitive data types 19 Table 1-2 Common tasks and solutions 24 Chapter 2 Graphics Contexts 25 Figure 2-1 Compositing operations in Cocoa 33 Figure 2-2 Clipping paths and winding rules 34 Figure 2-3 A comparison of aliased and anti-aliased content 36 Table 2-1 Graphics state information 27 Chapter 3 Coordinate Systems and Transforms 39 Figure 3-1 Coordinate systems on the screen 40 Figure 3-2 Translating content 45 Figure 3-3 Scaling content 46 Figure 3-4 Rotated content 46 Figure 3-5 Transform ordering 48 Figure 3-6 Basic transformation matrix 49 Figure 3-7 Mathematical conversion of coordinates 49 Figure 3-8 Normal and flipped coordinate axes 53 Listing 3-1 Adjusting coordinates for resolution independent interfaces 43 Listing 3-2 Flipping the coordinate system manually 55 Chapter 4 Color and Transparency 57 Figure 4-1 Drawing with a pattern 59 Table 4-1 Methods for changing color attributes 61 Table 4-2 Quartz rendering intents 63 Chapter 5 Paths 65 Figure 5-1 Path elements for a complex path 67 9 2006-10-03 | © 2005, 2006 Apple Computer, Inc. All Rights Reserved. FIGURES, TABLES, AND LISTINGS Figure 5-2 Line cap styles 69 Figure 5-3 Line join styles 70 Figure 5-4 Line dash patterns 71 Figure 5-5 Flatness effects on curves 72 Figure 5-6 Miter limit effects 73 Figure 5-7 Applying winding rules to a path 74 Figure 5-8 Creating arcs 80 Figure 5-9 Cubic Bezier curve 81 Figure 5-10 Stroking and filling a path.
Recommended publications
  • Apple Software Design Guidelines
    Apple Software Design Guidelines May 27, 2004 Java and all Java-based trademarks are Apple Computer, Inc. trademarks or registered trademarks of Sun © 2004 Apple Computer, Inc. Microsystems, Inc. in the U.S. and other All rights reserved. countries. OpenGL is a trademark of Silicon Graphics, No part of this publication may be Inc. reproduced, stored in a retrieval system, or transmitted, in any form or by any means, PowerPC and and the PowerPC logo are mechanical, electronic, photocopying, trademarks of International Business recording, or otherwise, without prior Machines Corporation, used under license written permission of Apple Computer, Inc., therefrom. with the following exceptions: Any person Simultaneously published in the United is hereby authorized to store documentation States and Canada. on a single computer for personal use only Even though Apple has reviewed this manual, and to print copies of documentation for APPLE MAKES NO WARRANTY OR personal use provided that the REPRESENTATION, EITHER EXPRESS OR IMPLIED, WITH RESPECT TO THIS MANUAL, documentation contains Apple's copyright ITS QUALITY, ACCURACY, notice. MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. AS A RESULT, THIS The Apple logo is a trademark of Apple MANUAL IS SOLD ªAS IS,º AND YOU, THE PURCHASER, ARE ASSUMING THE ENTIRE Computer, Inc. RISK AS TO ITS QUALITY AND ACCURACY. Use of the ªkeyboardº Apple logo IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, (Option-Shift-K) for commercial purposes OR CONSEQUENTIAL DAMAGES without the prior written consent of Apple RESULTING FROM ANY DEFECT OR may constitute trademark infringement and INACCURACY IN THIS MANUAL, even if advised of the possibility of such damages.
    [Show full text]
  • Mac OS X and PDF: the Real Story
    Mac OS X and PDF The Real Story Leonard Rosenthol Lazerware, Inc. Copyright©1999-2001, Lazerware, Inc. Overview •Mac OS X •PDF • Where’s the overlap? Copyright©1999-2001, Lazerware, Inc. You are here because… • You’re currently working with Mac OS and are interested in what Mac OS X brings to the table. • You’re curious about what Apple’s latest hype is all about. • You’re already awake and had to find something to kill time. • You’re a friend of mine and wanted to heckle Copyright©1999-2001, Lazerware, Inc. How I do things • You should all have copies of the presentation that you received when you walked in. • There is also an electronic copy of this presentation (PDF format, of course!) on my website at http://www.lazerware.com/ • I’ve left time at the end for Q&A, but please feel free to ask questions at any time! Copyright©1999-2001, Lazerware, Inc. Mac OS X Overview Copyright©1999-2001, Lazerware, Inc. Darwin • “Core OS” (Kernel) – Solid Unix foundation • FreeBSD 3.2 & Mach 3.0 • Memory protection, preemptive multitasking, etc. – High performance I/O • Firewire, USB, etc. • Open source Copyright©1999-2001, Lazerware, Inc. Graphics •Quartz – Adobe Imaging Model (PDF) • Includes full anti-aliasing and opacity/transparency • OpenGL – Industry standard 3D engine used by Quake & Maya • QuickTime Copyright©1999-2001, Lazerware, Inc. Graphics Demos - Quartz Copyright©1999-2001, Lazerware, Inc. Graphics Demos – OpenGL Copyright©1999-2001, Lazerware, Inc. Application Frameworks • Classic – Compatibility “box” for existing Mac OS applications. • Carbon – Modern versions of Mac OS applications prepared for Mac OS X.
    [Show full text]
  • Mac OS X for UNIX Users the Power of UNIX with the Simplicity of Macintosh
    Mac OS X for UNIX Users The power of UNIX with the simplicity of Macintosh. Features Mac OS X version 10.3 “Panther” combines a robust and open UNIX-based foundation with the richness and usability of the Macintosh interface, bringing UNIX technology Open source, standards-based UNIX to the mass market. Apple has made open source and standards a key part of its foundation strategy and delivers an operating system built on a powerful UNIX-based foundation •Based on FreeBSD 5 and Mach 3.0 • Support for POSIX, Linux, and System V APIs that is innovative and easy to use. • High-performance math libraries, including There are over 8.5 million Mac OS X users, including scientists, animators, developers, vector/DSP and PowerPC G5 support and system administrators, making Mac OS X the most widely used UNIX-based desktop • Optimized X11 window server for UNIX GUIs operating system. In addition, Mac OS X is the only UNIX-based environment that •Open source code available via the natively runs Microsoft Office, Adobe Photoshop, and thousands of other consumer Darwin project applications—all side by side with traditional command-line, X11, and Java applications. Standards-based networking For notebook computer users, Mac OS X delivers full power management and mobility •Open source TCP/IP-based networking support for Apple’s award-winning PowerBook G4. architecture, including IPv4, IPv6, and L2TP/IPSec •Interoperability with NFS, AFP, and Windows (SMB/CIFS) file servers •Powerful web server (Apache) •Open Directory 2, an LDAP-based directory services
    [Show full text]
  • Master Thesis
    Charles University in Prague Faculty of Mathematics and Physics MASTER THESIS Petr Koupý Graphics Stack for HelenOS Department of Distributed and Dependable Systems Supervisor of the master thesis: Mgr. Martin Děcký Study programme: Informatics Specialization: Software Systems Prague 2013 I would like to thank my supervisor, Martin Děcký, not only for giving me an idea on how to approach this thesis but also for his suggestions, numerous pieces of advice and significant help with code integration. Next, I would like to express my gratitude to all members of Hele- nOS developer community for their swift feedback and for making HelenOS such a good plat- form for works like this. Finally, I am very grateful to my parents and close family members for supporting me during my studies. I declare that I carried out this master thesis independently, and only with the cited sources, literature and other professional sources. I understand that my work relates to the rights and obligations under the Act No. 121/2000 Coll., the Copyright Act, as amended, in particular the fact that the Charles University in Pra- gue has the right to conclude a license agreement on the use of this work as a school work pursuant to Section 60 paragraph 1 of the Copyright Act. In Prague, March 27, 2013 Petr Koupý Název práce: Graphics Stack for HelenOS Autor: Petr Koupý Katedra / Ústav: Katedra distribuovaných a spolehlivých systémů Vedoucí diplomové práce: Mgr. Martin Děcký Abstrakt: HelenOS je experimentální operační systém založený na mikro-jádrové a multi- serverové architektuře. Před započetím této práce již HelenOS obsahoval početnou množinu moderně navržených subsystémů zajišťujících různé úkoly v rámci systému.
    [Show full text]
  • Quartz Programming Guide for Quickdraw Developers
    Quartz Programming Guide for QuickDraw Developers 2006-09-05 Even though Apple has reviewed this document, APPLE MAKES NO WARRANTY OR Apple Computer, Inc. REPRESENTATION, EITHER EXPRESS OR © 2004, 2006 Apple Computer, Inc. IMPLIED, WITH RESPECT TO THIS DOCUMENT, ITS QUALITY, ACCURACY, All rights reserved. MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. AS A RESULT, THIS DOCUMENT IS PROVIDED “AS IS,” AND No part of this publication may be YOU, THE READER, ARE ASSUMING THE reproduced, stored in a retrieval system, or ENTIRE RISK AS TO ITS QUALITY AND transmitted, in any form or by any means, ACCURACY. mechanical, electronic, photocopying, IN NO EVENT WILL APPLE BE LIABLE FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, recording, or otherwise, without prior OR CONSEQUENTIAL DAMAGES written permission of Apple Computer, Inc., RESULTING FROM ANY DEFECT OR INACCURACY IN THIS DOCUMENT, even if with the following exceptions: Any person advised of the possibility of such damages. is hereby authorized to store documentation THE WARRANTY AND REMEDIES SET on a single computer for personal use only FORTH ABOVE ARE EXCLUSIVE AND IN and to print copies of documentation for LIEU OF ALL OTHERS, ORAL OR WRITTEN, EXPRESS OR IMPLIED. No Apple dealer, agent, personal use provided that the or employee is authorized to make any documentation contains Apple’s copyright modification, extension, or addition to this notice. warranty. Some states do not allow the exclusion or The Apple logo is a trademark of Apple limitation of implied warranties or liability for Computer, Inc. incidental or consequential damages, so the above limitation or exclusion may not apply to Use of the “keyboard” Apple logo you.
    [Show full text]
  • Optimizing 2D Graphics and Animation Performance
    Optimizing 2D Graphics and Animation Performance Session 506 Tim Oriol Mike Funk These are confidential sessions—please refrain from streaming, blogging, or taking pictures Agenda Overview of topics for this session • Supporting Retina Display • Optimizing 2D graphics (Quartz 2D + Core Animation) • Identify and fix common Retina Display pitfalls • Using CGDisplayStream to get real-time display updates Prerequisites What you should know • Core Animation framework • Quartz 2D drawing techniques • Basic knowledge of UIView and NSView What Changes with Retina Displays? Retina Displays Today’s Retina Displays have 4x the pixels of previous displays Points Versus Pixels What’s the point • Points have nothing to do with typographer’s “points” • Points are logical coordinates • Pixels are actual device display coordinates • One point is not always equal to one pixel • The “scale factor” is the number of pixels per point • Use points with Quartz 2D, UIKit, AppKit, and Core Animation Retina Displays Set up your scale factor • Set the contentsScale property of layers that you would like to provide high-resolution content • Text, shapes, Quartz 2D drawing, and any layers that you have provided high-resolution images as content • UIKit/AppKit will set the appropriate contentsScale for layers they create layer.contentsScale = [UIScreen mainScreen].scale; Retina Displays Set up your scale factor • The CGContext provided to you via CALayer’s drawInContext will be set up correctly according to its contentsScale property • Any CGContextBitmap you create
    [Show full text]
  • Chapter 17 Performance and Debugging
    Chapter 17 Performance and Debugging The purpose of this chapter is to help you understand and address many of the issues that affect the graphics performance of your applications. It also provides tips on how to debug your drawing when things aren’t working as you expect. Performance is a dynamic topic. Many of the areas discussed in this chapter evolve and change with each major release of Mac OS X. To understand perfor- mance, simply reading this chapter isn’t enough. You need to keep up to date with information as it becomes available from Apple. The Apple Developer Con- nection website and the references at the end of this chapter will help you get the latest information about how to improve not only graphics performance but overall application performance as well. Optimizing Performance There are many aspects to achieving excellent performance with drawing code, some of which are related to the system and some of which are under your con- trol. The Quartz Compositor, Quartz object and memory management, and per- formance measurement are all key to understanding graphics performance. The Quartz Compositor (which is part of the Mac OS X windowing system) determines how drawing appears in windows on the display. As you’ve seen, cre- ating and managing Quartz objects is a key aspect of Quartz programming. By understanding the Quartz memory management and object model, you can ben- efit from any caching of those objects Quartz performs and avoid creating mem- ory leaks or other memory problems. Performance measurement helps you to 593 594 Chapter 17 Performance and Debugging better understand how your code works and to identify places where the code could be optimized.
    [Show full text]
  • Next Mac OS X Roots
    Mac OS X Roots: Mac OS X NeXT • 1985 Apple kicks out Jobs, who founds NeXT • 1988 NeXTSTEP 0.8: 68k, Mach kernel, 4.3BSD, Display PostScript, new Objective-C, platform for first web browser at CERN • 1990 NeXTSTEP 2.0: Interface Builder (OO) • 1993 Intel, SPARC, HP PA-RISC support (fat binaries), NeXT hardware dead • NeXT&Sun: OPENSTEP, used by SunOS, HP-UX, MacOS, also on Windows NT, GNUstep Jan Borchers 1 media computing group Jan Borchers 2 media computing group Mac OS X Roots: NeXT • 1996 Apple purchases NeXT, Jobs back at Apple, begins replacing Mac OS towards NeXTSTEP • 1999 Apple releases Mac OS X Preview • Mac OS X is directly derived from NeXTSTEP/ OPENSTEP (Mach/BSD, Objective-C, Cocoa, Interface Builder, NetInfo), and combines this with other Apple technologies (UI, Classic, Multimedia) Jan Borchers 3 media computing group Jan Borchers 4 media computing group It’s spelled “Ten” Mac OS X: Architecture Base Operating System Apps UITK Cocoa, Carbon, Java WM • Darwin (Open Source for PowerPC+Intel) WindowServer (user-level process) • Based on a Mach microkernel + BSD Unix BWS • Protected memory, preemptive multitasking GEL Quartz 2D / Core Graphics, IOKit • Single application cannot corrupt/freeze entire system HW 5 Jan Borchers media computing group Jan Borchers 6 media computing group Graphics and Event Library • Quartz 2D / Core Graphics, Display PDF • Roots: NeWS, NeXTSTEP (Display PostScript) • Vector-based, resolution-independent Demo: Quartz Extreme • Quartz Extreme: GPU-based compositing (pipe entire screen through OpenGL
    [Show full text]
  • Cocoa® Programming Developer's Handbook
    Cocoa® Programming Developer’s Handbook This page intentionally left blank Cocoa® Programming Developer’s Handbook David Chisnall Upper Saddle River, NJ • Boston • Indianapolis • San Francisco New York • Toronto • Montreal • London • Munich • Paris • Madrid Capetown • Sydney • Tokyo • Singapore • Mexico City Cocoa® Programming Developer’s Handbook Editor-in-Chief Copyright © 2010 Pearson Education, Inc. Mark L. Taub All rights reserved. No part of this book shall be reproduced, stored in a retrieval system, Managing Editor or transmitted by any means, electronic, mechanical, photocopying, recording, or otherwise, John Fuller without written permission from the publisher. No patent liability is assumed with respect to Full-Service the use of the information contained herein. Although every precaution has been taken in Production the preparation of this book, the publisher and author assume no responsibility for errors Manager or omissions. Nor is any liability assumed for damages resulting from the use of the Julie B. Nahil information contained herein. Technical Reviewer ISBN-13: 978-0-321-63963-9 Gregory ISBN-10: 0-321-63963-4 Casamento Book Designer Library of Congress Cataloging-in-Publication Data Gary Adair Chisnall, David. Composition Cocoa programming developer’s handbook / David Chisnall. David Chisnall p. cm. Includes index. ISBN 978-0-321-63963-9 (pbk. : alk. paper) 1. Cocoa (Application development environment) 2. Object-oriented programming (Computer science) 3. Application program interfaces (Computer software) 4. Mac OS. I. Title. QA76.64.C485 2010 005.26’8—dc22 2009042661 Printed in the United States on recycled paper at Edwards Brothers in Ann Arbor, Michigan. First Printing December 2009 Trademarks All terms mentioned in this book that are known to be trademarks or service marks have been appropriately capitalized.
    [Show full text]
  • Mac OS X and PDF: the Real Story
    Mac OS X and PDF The Real Story Leonard Rosenthol Director of Software Development Appligent, Inc. Copyright©1999-2001, Appligent, Inc. Overview •Mac OS X •PDF • Where’s the overlap? Copyright©1999-2001, Appligent, Inc. You are here because… • You’re currently working with Mac OS and are interested in what Mac OS X brings to the table. • You’re curious about what Apple’s latest hype is all about. • You’re already awake and had to find something to kill time. • You’re a friend of mine and wanted to heckle Copyright©1999-2001, Appligent, Inc. How I do things • There is a copy of this presentation on my website at http://www.appligent.com, so you shouldn’t need to take too many notes. • I’ve left time at the end for Q&A, but please feel free to ask questions at any time! Copyright©1999-2001, Appligent, Inc. Mac OS X Overview Copyright©1999-2001, Appligent, Inc. Darwin • “Core OS” (Kernel) – Solid Unix foundation • FreeBSD 3.2 & Mach 3.0 • Memory protection, preemptive multitasking, etc. – High performance I/O • Firewire, USB, etc. • Open source Copyright©1999-2001, Appligent, Inc. Graphics •Quartz – Adobe Imaging Model (PDF) • Includes full anti-aliasing and opacity/transparency • OpenGL – Industry standard 3D engine used by Quake & Maya • QuickTime Copyright©1999-2001, Appligent, Inc. Graphics Demos - Quartz Copyright©1999-2001, Appligent, Inc. Graphics Demos – OpenGL Copyright©1999-2001, Appligent, Inc. Application Frameworks • Classic – Compatibility “box” for existing Mac OS applications. • Carbon – Modern versions of Mac OS applications prepared for Mac OS X. • Cocoa – Completely new applications written using a modern object- oriented framework in either Objective-C or Java.
    [Show full text]
  • X Review Mac OS X Roots: Next
    X Review Application • Distributed window system Widget Set • Server is the user’s Terminal WM Xt Intrinsics • Client runs the application Xlib Xlib • Highly modular • (exchange WM, Widget Set) X Server BWS • Available for virtually every OS HW • Very successful in the UNIX world (with Motif) • Many Open Source implementations available • Xt intrinsics already allow OO GUI application programming Jan Borchers 1 media computing group Jan Borchers 2 media computing group Mac OS X Roots: NeXT • 1985 Apple kicks out Jobs, who founds NeXT • 1988 NeXTSTEP 0.8: 68k, Mach kernel, 4.3BSD, Display PostScript, new Objective-C, platform for first web browser at CERN • 1990 NeXTSTEP 2.0: Interface Builder (OO) • 1993 Intel, SPARC, HP PA-RISC support (fat binaries), NeXT hardware dead • NeXT&Sun: OPENSTEP, used by SunOS, HP-UX, MacOS, also on Windows NT, GNUstep Jan Borchers 3 media computing group Jan Borchers 4 media computing group Mac OS X Roots: It’s spelled “Ten” NeXT Mac OS X: Architecture Apps UITK Cocoa, Carbon, Java • 1996 Apple purchases NeXT, Jobs back at Apple, begins replacing Mac OS towards NeXTSTEP WM WindowServer (user-level process) • 1999 Apple releases Mac OS X Preview BWS ! Mac OS X is directly derived from NeXTSTEP/ OPENSTEP (Mach/BSD, Objective-C, Cocoa, Interface GEL Quartz 2D / Core Graphics, IOKit Builder, NetInfo), and combines this with other Apple HW technologies (UI, Multimedia) 6 Jan Borchers 5 media computing group Jan Borchers media computing group Base Operating System Graphics and Event Library • Quartz 2D / Core Graphics,
    [Show full text]
  • Mac OS X Developer Resources
    PART I Mac OS X Developer Resources CHAPTER 1: The Mac OS X Environment CHAPTER 2: Developer Tools CHAPTER 3: Xcode CHAPTER 4: Interface Builder COPYRIGHTED MATERIAL cc01.indd01.indd 1 112/12/092/12/09 11:01:15:01:15 PPMM cc01.indd01.indd 2 112/12/092/12/09 11:01:24:01:24 PPMM 1 The Mac OS X Environment WHAT YOU WILL LEARN IN THIS CHAPTER: ➤ How the Mac OS X operating system is structured, including what the major areas of the system are and how they work together ➤ How to use Mac OS X’ s command - line interface ➤ How applications take advantage of the operating system services on Mac OS X ➤ How Apple encourages a common look and feel for Mac OS X applications Welcome to the wonderful world of Mac OS X, the next - generation operating system from Apple Computer! The Mac OS X operating system powers modern Macintosh computers. After many long years and a few scrapped attempts to modernize the older Mac OS operating system, Apple released Mac OS X in April 2001. Since then, Apple has released a steady stream of upgrades and system updates. This book was written around Mac OS X v10.6 Snow Leopard, the latest version. To write software for Mac OS X, you need to know your way around the system. By now you may already be familiar with Mac OS X ’ s applications and user interface style. Those things all rest on top of a number of subsystems and services that make up the Mac OS X operating system.
    [Show full text]