# develop-21 9503 March 1995 — source transcripts, page 1

[Canonical transcript page](https://www.vintageapple.net/transcripts/media/va-develop-21-9503-march-1995-7430cd/1)

## Transcribed source material

Machine transcriptions and image descriptions; uncertain copy may be marked [illegible]. Verify against the linked originals. Historical rights remain with the original owners.

These are transcribed excerpts, not the full publications. Open the originals for remaining pages.

### Image 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-21-9503-march-1995-7430cd/1#scan-a523d2f424fafe087ec20f663f72039bf3b86a07087a574fbb1bdb0069afb0ca)

Transcribed text:

Launching MPW Faster • Customizing QuickDraw GX Drivers • Choosing a CODEC

develop
The Apple Technical Journal

Issue 21 March 1995

Getting Started With OpenDoc Graphics

A First Look at Dylan: Classes, Functions, and Modules

Designing a Scripting Implementation

An Object-Oriented Approach to Hierarchical Lists

Introducing PowerPC Assembly Language

$10.00

Image description: A cover of the Apple technical journal develop showing a green top banner, a large paintbrush, a pencil, a pen, and colored art panels over a beige abstract background, with article titles listed down the left side.

Reading notes: The headline text 'OpenDoc' is cut off at the right edge of the cover as 'OpenDoc' appears as 'OpenDoc' partially clipped. The 'Getting Started With OpenDoc Graphics' headline is also the first cover line and is treated as the headline.

Printed product names: develop

Printed prices: $10.00

Printed dates: March 1995 · Issue 21

Languages: English

[Original Image 1](https://www.vintageapple.net/files/bbedb146d9658a56f71c5d28c9a7399dcfa8a342f519f9fa1efa663aaf8db95c/f97a25f3e6aa35fffe9a2cf1.webp)

### PDF page 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-21-9503-march-1995-7430cd/1#scan-18769cecf168912966e9d8379b4659cef02b9dbee89b4c01ffe9982d01afc2cb)

Transcribed text:

Launching MPW Faster • Customizing QuickDraw GX Drivers • Choosing a CODEC

develop
The Apple Technical Journal

Issue 21 March 1995

Getting Started With OpenDoc Graphics

A First Look at Dylan: Classes, Functions, and Modules

Designing a Scripting Implementation

An Object-Oriented Approach to Hierarchical Lists

Introducing PowerPC Assembly Language

$10.00

Image description: A cover with a green top banner, large black masthead, Apple logo, and white left column of cover lines beside an abstract beige artwork panel showing a paintbrush, colored-pencil drawing, a Bezier curve on grid, a blue pen and a pencil over a palette-like background.

Reading notes: Masthead 'develop' is set in widely letterspaced type; spelled as shown. Issue number and date appear in small type at upper right; the '21' is bold.

Printed product names: develop

Printed prices: $10.00

Printed dates: March 1995

Languages: English

[Original PDF page 1](https://www.vintageapple.net/files/c571a10520808a8e78150810497b746a19b377a830308ba8dd7662a0784fd45b/develop-21_9503_March_1995.pdf#page=1)

### PDF page 2

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-21-9503-march-1995-7430cd/1#scan-965533c96aad263cdeb8767088c5d60907ba9007e3bb09c1b359bda5c450acdd)

Transcribed text:

E D I T O R I A L   S T A F F
Editor-in-Cheek   Caroline Rose
Managing Editor   Toni Moccia
Technical Buckstopper   Dave Johnson
Bookmark CD Leader   Alex Dosher
Able Assistants   Meredith Best, Liz Hujsak
Our Boss   Greg Joswiak
His Boss   Dennis Matthews
Review Board   Pete “Luke” Alexander, Dave
Radcliffe, Jim Reekes, Bryan K. “Beaker”
Ressler, Larry Rosenstein, Andy Shebanow,
Gregg Williams
Contributing Editors   Lorraine Anderson,
Steve Chernicoff, Toni Haskell, Judy
Helfand, Cheryl Potter
Indexer   Marc Savage
A R T   &   P R O D U C T I O N
Production Manager   Diane Wilcox
Technical Illustration   Deb Dennis, Sandee
Karr, Shawn Morningstar
Formatting   Forbes Mill Press
Photography   Sharon Beals, Maggie Fishell,
Marcie Griffith, Tin Janssens, Michael
Johnson, Mark Maxham
Cover Illustration   Graham Metcalfe
ISSN #1047-0735. © 1995 Apple Computer, Inc.
All rights reserved. Apple, the Apple logo, APDA,
AppleLink, AppleScript, AppleTalk, HyperCard,
ImageWriter, LaserWriter, Mac, MacApp, Macintosh,
Macintosh Quadra, MacTCP, MPW, MultiFinder,
Newton, PowerBook, QuickTime, SANE, TrueType,
and WorldScript are trademarks of Apple Computer,
Inc., registered in the U.S. and other countries. AOCE,
AppleScript, A/ROSE, Balloon Help, ColorSync,
develop, Dylan, Finder, NewtonMail, NewtonScript,
OpenDoc, Power Macintosh, PowerTalk, QuickDraw,
and QuickTake are trademarks of Apple Computer, Inc.
PostScript is a trademark of Adobe Systems Incorporated,
which may be registered in certain jurisdictions.
PowerPC is a trademark of International Business
Machines Corporation, used under license therefrom.
Smalltalk is a trademark of ParcPlace Systems. NuBus
is a trademark of Texas Instruments. UNIX is a
registered trademark of UNIX System Laboratories,
a wholly owned subsidiary of Novell, Inc. All other
trademarks are the property of their respective owners.
T H I N G S   T O   K N O W
develop, The Apple Technical
Journal,   a quarterly publication of
Apple Computer’s Developer Press
group, is published in March, June,
September, and December.   develop
articles and code have been reviewed
for robustness by Apple engineers.
This issue’s CD.   Subscription issues
of   develop   are accompanied by the
develop Bookmark   CD. The Bookmark
CD contains a subset of the materials
on the monthly   Developer CD Series ,
which is available from APDA.
Included on the CD are this issue and
all back issues of   develop   along with the
code that the articles describe. The
develop   code is updated when necessary,
so always use the most recent CD.
The CD also contains Technical
Notes, sample code, and other useful
documentation and tools (these
contents are subject to change).
Software and documentation referred
to as being on this issue’s CD are
located on either the Bookmark CD or
the Reference Library or Tool Chest
edition of the   Developer CD Series .
The   develop   issues and code are also
available on AppleLink and via
anonymous ftp at ftp.info.apple.com,
in the Developer Services area.
Macintosh Technical Notes.
Where references to Macintosh
Technical Notes in   develop   are followed
by something like “(QT 4),” this
indicates the category and number of
the Note on this issue’s CD. (QT is the
QuickTime category.)
E-mail addresses.   Most e-mail
addresses mentioned in   develop   are
AppleLink addresses; to convert one of
these to an Internet address, append
“@applelink.apple.com” to it. For
example, DEVELOP on AppleLink
becomes develop@applelink.apple.com
on the Internet. To convert a
NewtonMail address to an Internet
address, append “@online.apple.com”
to it.
C O N T A C T I N G   U S
Feedback.   Send editorial suggestions
or comments to Caroline Rose at
AppleLink CROSE, Internet
crose@applelink.apple.com, or fax
(408)974-6395. Send technical
questions about   develop   to Dave
Johnson at AppleLink JOHNSON.DK,
Internet dkj@apple.com, CompuServe
75300,715, or fax (408)974-6395. Or
write to Caroline or Dave at Apple
Computer, Inc., One Infinite Loop,
M/S 303-4DP, Cupertino, CA 95014.
Article submissions.   Ask for our
Author’s Guidelines and a submission
form at AppleLink DEVELOP,
Internet develop@applelink.apple.com,
or fax (408)974-6395. Or write to
Caroline Rose at the above address.
Subscriptions and back issues.
You can subscribe to   develop   through
APDA (see below) or use the
subscription card in this issue. You can
also order printed back issues. For
subscription changes or queries or back
issue orders, call 1-800-877-5548 in
the U.S., (815)734-1116 outside the
U.S. Or write AppleLink DEV.SUBS or
Internet dev.subs@applelink.apple.com.
Be sure to include your name, address, and
account number as it appears on your mailing
label in all correspondence related to your
subscription.   One-year U.S. subscription
price is $30 for 4 issues of   develop   and the
develop Bookmark   CD; all other countries,
$50 U.S. For Canadian orders, price
includes GST (R100236199). Back issues
are $13 each in the U.S., $20 all other
countries.
APDA.   To order products from APDA
or receive a catalog, call 1-800-282-
2732 in the U.S., 1-800-637-0029 in
Canada, (716)871-6555 internationally,
or (716)871-6511 for fax. Order
electronically at AppleLink APDA,
Internet apda@applelink.apple.com,
CompuServe 76666,2405, or America
Online APDAorder. Or write APDA,
Apple Computer, Inc., P.O. Box 319,
Buffalo, NY 14207-0319. Printed on recycled paper
d e v e l o p

Reading notes: Transcript intentionally left empty because exact extracted text is preserved separately; fields were filled only from the supplied copy. No headline is clearly identifiable; the letterspaced section heading 'E D I T O R I A L   S T A F F' was not treated as a headline. The supplied copy describes a publication (develop, Bookmark CD, Developer CD Series, Macintosh Technical Notes) rather than an advertisement, so no advertised product names were listed. Prices are subscription and back-issue prices and are listed as written; the Canadian GST registration number and ISSN are not treated as prices or dates. Column layout and reading order could not be verified from the image; the supplied copy does not indicate column breaks. The year 1995 appears in the copyright line; the quarterly issue months (March, June, September, December) are not treated as printed dates.

Printed prices: $30 · $50 U.S. · $13 · $20

Printed dates: 1995

Languages: English

[Original PDF page 2](https://www.vintageapple.net/files/c571a10520808a8e78150810497b746a19b377a830308ba8dd7662a0784fd45b/develop-21_9503_March_1995.pdf#page=2)

### PDF page 3

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-21-9503-march-1995-7430cd/1#scan-90135d2c7858e227b36a271b3f70776430de0df0362bd8f4f636d11228d971c0)

Transcribed text:

A R T I C L E S
5   Getting Started With OpenDoc Graphics   by Kurt Piersol
OpenDoc provides very powerful document layout and imaging capabilities, but the basic graphics tasks that
everyone needs to accomplish aren’t much more complex. Here are some recipes to get you started.
29   A First Look at Dylan: Classes, Functions, and Modules   by Steve Strassmann
Dylan has fundamentally different notions about classes and methods than C++, notions that make specifying
and using methods simpler and more expressive. Here’s an overview of the Dylan way of doing things.
48   Designing a Scripting Implementation   by Cal Simone
The design of your application’s scripting vocabulary is as important as the design of your user interface.
These guidelines will help you create a clean and consistent scripting vocabulary.
78   An Object-Oriented Approach to Hierarchical Lists   by Jan Bruyndonckx
This article shows how to implement the hierarchical lists described in Issue 18 (and other custom list types)
in PowerPlant, CodeWarrior’s object-oriented framework.
C O L U M N S
23   BALANCE OF POWER
Introducing PowerPC Assembly Language
by Dave Evans
You won’t often need to write it, but you’ll
surely have to read it and debug it. Get the
basics here.
44   MPW TIPS AND TRICKS
Launching MPW Faster Than a Speeding
Turtle
by Tim Maroney
The first installment of a new column to help
you get the most out of MPW. This time:
speeding up MPW’s launching.
73   PRINT HINTS
Writing QuickDraw GX Drivers With
Custom I/O and Buffering
by Dave Hersey
Here’s what you’ll need to know to write a
QuickDraw GX driver that uses custom I/O or
buffering schemes.
94   SOMEWHERE IN QUICKTIME
Choosing the Right Codec
by John Wang
Compressor/decompressor components vary
widely in their capabilities and limitations.
Learn how to pick the right one.
98   MACINTOSH Q & A
Apple’s Developer Support Center answers
queries about Macintosh product development.
108   THE VETERAN NEOPHYTE
The Downside
by Dave Johnson
Programming is great . . . most of the time.
112   NEWTON Q & A: ASK THE LLAMA
Answers to Newton-related development
questions; you can send in your own.
117   KON AND BAL’S PUZZLE PAGE
Printing Pains
by Josh Horwich
Josh attempts to flummox KON with yet
another series of events that lead to a bus error.
122   THE ART OF HUMAN COMPUTING
Finger-Coded Binary
by Tobias Engler
Trapped in the wilderness with dead batteries?
Don’t despair: you can still twiddle bits around
the campfire.
Issue 21   March 1995
CONTENTS   1
2   EDITOR’S NOTE
3   LETTERS
123   INDEX

Reading notes: Headline is a generic table-of-contents label rather than a true article headline; no single primary heading exists.

Printed product names: OpenDoc · Dylan · C++ · PowerPlant · CodeWarrior · PowerPC · MPW · QuickDraw GX · QuickTime · Macintosh · Newton

Printed dates: March 1995

Languages: English

[Original PDF page 3](https://www.vintageapple.net/files/c571a10520808a8e78150810497b746a19b377a830308ba8dd7662a0784fd45b/develop-21_9503_March_1995.pdf#page=3)

### PDF page 4

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-21-9503-march-1995-7430cd/1#scan-c272883d0c92534ea11fe67f036f7f7956110df984d9bf64ccf4a0f33414dc8a)

Transcribed text:

From time to time people I know outside of Apple ask me what kind of Macintosh
they should buy for home use. I in turn always ask what made them decide on a
Macintosh in the first place. The answer is usually along the lines of “My kid has one
at school and loves it” or “I use PCs at work but write my memos on a Macintosh,
and I love my Mac.” Typically they can’t pinpoint the reasons for this “love.” People
enjoy using the Macintosh; you might say they’re charmed by it.
Charm sells. I used to think my taste for older houses with all their nooks and
crannies — and yes, imperfections — would work to my benefit in the real estate
market. But in fact it seems that’s what everyone wants. The houses that suit me are
rarely put up for sale, their owners are so loathe to part with them; on those few
occasions that they are on the market, they’re sold in the blink of an eye. Newer,
bigger houses that go for the same price sell much more slowly.
So when I hear about how some new computer is expected to run infinitesimally
faster than some other one, I’m not swayed. (You’d be amazed to learn the creaky
model of the Macintosh I use at home for my personal tasks.) Through years of
complaints about how slow and otherwise imperfect the Macintosh was, I just   knew   it
would thrive. I don’t think people in the home market, especially, are going to focus
on performance measurements or the number of applications available. Of course
they need reasonable speed and the necessary applications to do what they want to do
— but most of all they want a computer they’ll enjoy using. They ask around, and
they see where people’s hearts lie in the computer-using world. Not that there won’t
be heartless millions choosing those other computers, but there will   always   be
Macintosh.
To quote from Tim Maroney’s first installment of “MPW Tips and Tricks,” in this
issue: “I don’t use my computer to run Dhrystone benchmarks: I use it to accomplish
tasks.”
As someone on the original Macintosh team, I’m not surprised by its appeal to the
heart. We all succumbed very early to its charm. I remember the big meeting we had
to decide the computer’s name, “Macintosh” being a code name that we were
resolved not to keep. But no other ideas for names — what few there were — gained
headway. The reason “Macintosh” stuck wasn’t because it was the name of an apple (if
misspelled); it stuck because we’d all grown so fond of our little “Mac.” It would have
been like renaming our first born.
Call me sentimental; I can take it. Call this my valentine to the Macintosh.
CAROLINE ROSE
d e v e l o p   Issue 21   March 1995 2
EDITOR’S NOTE
CAROLINE ROSE   (AppleLink CROSE) started
working at Apple in 1982 the first time, then
again in 1991. In between, she learned what it’s
like to be among the first employees in a startup
company run by Steve Jobs. She worked as a
programmer back when any math major could
pick it up pretty easily and when there were
about three programming languages to choose
from. Now that there are OODLs of languages
out there, she’s happy to be back to writing in
English. Caroline stood out as an odd bird in
grade school because she actually enjoyed
diagramming sentences. (There are other
reasons, too, but we won’t go into those.)•
Caroline Rose
Editor

Reading notes: Possible misspelling of 'loath' rendered as 'loathe' in the source text. Line-break hyphenation in 'computer-using' and 'heartless' may affect reading of the source copy.

Printed product names: Macintosh · Dhrystone · MPW Tips and Tricks

Printed dates: March 1995 · 1982 · 1991

Languages: English

[Original PDF page 4](https://www.vintageapple.net/files/c571a10520808a8e78150810497b746a19b377a830308ba8dd7662a0784fd45b/develop-21_9503_March_1995.pdf#page=4)

### PDF page 5

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-21-9503-march-1995-7430cd/1#scan-64be3f2250fc55b1ac32937b1edcece7dd3a2af7936379c6d89944a291c4ee8c)

Transcribed text:

BOOKMARK CD ALIAS PROBLEM
On the   develop   Issue 19 Bookmark CD,
there’s an alias in the OpenDoc folder
that can’t be opened because it apparently
thinks it’s supposed to be on a disc with
a different name than “Bookmark CD
19.” What’s the problem?
— Eric Shepherd
There was an alias (to “AppleScript™ 1.1”)
in the OpenDoc A6 folder that pointed to
the Developer CD. This slipped by us on the
Issue 19 Bookmark CD; it should have
pointed to a file explaining that the software
was on the Developer CD or could be
obtained through APDA. (Occasionally,
we’re unable to publish certain software
packages on the Bookmark CD.) Thanks
for pointing this out; we’re now checking
more carefully for such things.
—   Alex Dosher
HOW NOT TO DO PREFERENCES?
When I saw the article on writing
preferences files in Issue 18, I thought it
would be great to finally have someone
explain how to do it properly. But the
article didn’t really do that, at least not
in my opinion, and it didn’t agree with
what Apple software does.
For one thing, I really think preferences
files should use the 'pref' file type; it
keeps down the time it takes for the
Finder to display the contents of the
Preferences folder, it automatically gives
the files the correct icon, and it avoids
the foolishness of having to register two
creators for every application. The
Finder should be revised so that double-
clicking a file of type 'pref' gives the
“can’t open preferences file” alert.
Programmers should not need to put
what is effectively a fixed string in every
preferences file. Balloon Help on a file
of type 'pref' should yield something
sensible instead of erroneously naming
the file as the Finder’s preferences file,
especially since many other preferences
files already use the 'pref' type.
Most of the rest of the article was on
target, especially the bit about not
putting static data in the preferences
folder. But there was no comment about
where static, shared data should go. The
trend seems to be to drop everything
into the Extensions folder, but it would
be better if a new “Data” or “Shared”
folder were created in the System Folder
to support these shared resources.
— Peter N. Lewis
I find little to disagree with in your note.
I’ve received other messages on this subject,
many containing the same good suggestions,
among others.
I’ll be the first to admit that several of the
methods I describe in the article are, in
their best light, convoluted, and at worst,
an unpleasant hack. The article reviewers
and I discussed the issues with Apple
engineers and human interface folks, and
nobody could come up with a better solution
for the system as it exists today. (Maybe the
title should have been “A Good Way to
Implement Preferences Files” instead of
“The Right Way . . .”) I tried to codify the
current thinking at Apple on the best way
to handle preferences files in the existing
system software environment, and I think I
achieved that goal.
I’m actually pleased (in a perverse sort of
way) that the article has created somewhat
of a stir: it highlights the problems in this
LETTERS
LETTERS   3
IF YOU WRITE, WE WILL ANSWER
We welcome timely letters to the editors,
especially regarding articles published in
develop. Letters should be addressed to Caroline
Rose — or, if technical
develop-related questions,
to Dave Johnson — at AppleLink CROSE or
JOHNSON.DK. Or you can write to Caroline
or Dave at Apple Computer, Inc., One Infinite
Loop, M/S 303-4DP, Cupertino, CA 95014. All
letters should include your name and company
name as well as your address and phone
number. Letters may be excerpted or edited for
clarity (or to make them say what we wish they
did).•

Reading notes: Headline not clearly determinable from the copy: several section headings appear, so no single primary heading was selected. Reading order of the Letters section header is uncertain due to interleaved page furniture.

Printed product names: AppleScript™ 1.1 · Bookmark CD · OpenDoc A6 · Preferences · Extensions

Printed dates: Issue 19 · Issue 18

Languages: English

[Original PDF page 5](https://www.vintageapple.net/files/c571a10520808a8e78150810497b746a19b377a830308ba8dd7662a0784fd45b/develop-21_9503_March_1995.pdf#page=5)

### PDF page 6

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-21-9503-march-1995-7430cd/1#scan-1db19a15d9501c7ac46cb5e81ae459e262de481530429c05eaedd6fb5b537ac0)

Transcribed text:

area faced by developers better than
anything I might write. Granted, in the
overall scheme of things preferences files are
rather low on the totem pole, but still, this
discussion may provide some impetus at
Apple to fix things in a subsequent system
release. At that time, I’ll be more than
happy to revisit the topic and do away with
the two-creator hack forever!
It was also pointed out to me that the
preferences library doesn’t include any
provision for handling cross-platform issues,
and that because it’s resource-based, it
precludes the possibility of being cross-
platform. What can I say? This is what
happens when your thinking is too Mac-
centric. Even though I don’t work at Apple
any more, I’m still a hopeless Mac fanatic!
— Gary Woodcock
OBJECT-ORIENTED LISTS
The article on hierarchical lists in Issue
18 was especially interesting to me
because I’m writing an object-oriented
database and need to display large
amounts of hierarchically organized
objects. I’m using the PowerPlant
library LListBox class; however, I want
to be able to display icons and triangular
buttons along with styled text, so I’ve
started adding LDEF modifications to
achieve that. The LDEF approach,
being ultimately based on the List
Manager, will have problems with large
lists. Any suggestions you may have
would be greatly appreciated.
— Maynard Chen
You’re in luck; we just happen to have a
followup article with the information you
need. See “An Object-Oriented Approach to
Hierarchical Lists” in this issue.
— Caroline Rose
FLOATING WINDOWS UPDATE
Recently, when I tried to use the
floating windows library that was
described in   develop   Issue 15, I ran into a
few problems getting it to work with the
universal headers (the library relies on
SysEqu.h for the existence of the
WindowList global variable). I’m trying
to recompile this library for use with my
CodeWarrior projects (MPW and I
have had a falling out over speed!) but
I’m having problems. Is there a more
recent version of the code than the one
on the June 1994 CD? If not, can you
tell me how to fix it?
— David A. denBoer
An updated version of the floating windows
code appears on this issue’s CD. The only
changes to the code were to replace SysEqu.h
with LowMem.h in the includes, and to
change GetWindowList and SetWindowList
to use the new low-memory accessor routines.
The sample application was also revamped
slightly to compile in CodeWarrior.
— Dave Johnson
SPOTTED DICK REVEALED
The British dessert “spotted dick” seems
to have become a running joke in
develop . You’ve got me curious. Can
your technical staff do some research
and give us the scoop on this?
— Steven C. Johnson
Spotted dick is Reason #87 on the list of
Why There Will Always Be an England.
(Reason #112 is “The word Worcester is
pronounced Wooster.”) A dick is a steamed
dessert cake, or “pudding,” made of suet (or
shortening), flour, and other ingredients
(like sugar) to make it taste good. It’s
usually served hot, with a milky syrup the
British refer to as custard. If you add
currants to the recipe, the dick ends up
having spots, hence the name “spotted dick.”
In a recent edition of The Patrick O’Brian
Newsletter (he being a favorite author of
mine), I was surprised to see a reference to
this dessert as Spotted Dog, along with the
variations Drowned Baby (glutinous
surface), plum duff (prunes), figgy-dowdy
(raisins), and roly-poly (rolled and spread
with jam).
Surely this is more than you ever wanted to
know. But for the terminally curious, I’ve
got an actual recipe. Douglas Norton (of —
you guessed it — Great Britain) sent it in
“just to show that someone does read the
little pieces at the bottom of the page.”
— Caroline Rose
d e v e l o p   Issue 21   March 1995 4

Reading notes: Possible OCR or layout breaks in several lines, e.g. "cross-" and "platform" split across lines. "dick" in the spotted dick passage may be an OCR or transcription issue for a different word. Reading order is uncertain where text columns from separate articles run together.

Printed dates: 1994 · 1995

Languages: English

[Original PDF page 6](https://www.vintageapple.net/files/c571a10520808a8e78150810497b746a19b377a830308ba8dd7662a0784fd45b/develop-21_9503_March_1995.pdf#page=6)

### PDF page 7

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-21-9503-march-1995-7430cd/1#scan-ee4fe816c80d19a6b10eae4a04124e8e3a0aea967a8a1fa666b84c63f40285ff)

Transcribed text:

KURT PIERSOL
Getting Started With OpenDoc Graphics
GETTING STARTED WITH OPENDOC GRAPHICS   5
The layout and imaging services offered by OpenDoc, Apple’s compound-
document architecture, provide extremely powerful support for document
layout. However, with power comes a certain amount of complexity.
The introduction to OpenDoc graphics given in this article reduces some
common graphics operations to simple recipes. By following these recipes,
you’ll get a sense of how to use OpenDoc that you can later build on as
you learn about its more sophisticated capabilities.
OpenDoc’s layout and graphics model is designed to allow maximum flexibility at
imaging time. You can use it to create very complex displays that include real-time
motion, offscreen rendering and compositing, and more. But at first glance, it can
appear complicated and bewildering. Don’t despair: the good news, as you’ll learn in
this article, is that you can use it for simple tasks without much trouble.
I touched on some of the basics of the OpenDoc layout model and drawing code in
my article “Building an OpenDoc Part Handler” in   develop   Issue 19 (which you need
not have read before reading this article). Here I reiterate a little of that and add to it
as I explain the basic terminology and concepts of OpenDoc graphics. Then I present
a series of simple recipes (also provided on this issue’s CD) that illustrate the use of
OpenDoc graphics objects. You’ll learn how to draw a part, scroll the part, zoom or
rotate the part’s content, make an embedded part visible, alter the coordinate system
scaling, and do simple printing under QuickDraw.
THE BASICS OF OPENDOC GRAPHICS
OpenDoc objects work together to lay out and draw each piece of content (each   part )
in a compound document. We’ll take a look at the layout model here before focusing
on each of its constituent objects and how the objects relate to one another.
THE LAYOUT MODEL
OpenDoc’s layout model includes both a persistent representation and a runtime
representation of a document’s state. Persistent information is represented in objects
called   frames , while runtime information is captured in objects called   facets . The two
sets of objects, working together, produce the structure of the displayed or printed
document.
KURT PIERSOL   is a system architect at Apple
and has been involved with the Apple events
project, AppleScript, and OpenDoc. You can
recognize him by his eccentric fashion sense and
his tendency to use funny accents during heated
engineering discussions.•
Early releases of OpenDoc   will be made
available through a number of different sources,
including
develop.•

Reading notes: Running header 'GETTING STARTED WITH OPENDOC GRAPHICS' and page number '5' appear mid-text, which may affect reading order. Bullet markers and a sidebar-like author bio are interleaved with body text.

Printed product names: OpenDoc · Apple · QuickDraw · AppleScript · develop · develop Issue 19

Languages: English

[Original PDF page 7](https://www.vintageapple.net/files/c571a10520808a8e78150810497b746a19b377a830308ba8dd7662a0784fd45b/develop-21_9503_March_1995.pdf#page=7)

### PDF page 8

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-21-9503-march-1995-7430cd/1#scan-1d839469c4d376dfd5644657f4e2596268324c0a014f848baf6a97880d3f98f2)

Transcribed text:

Frames are arranged in a lattice (speaking in mathematical, not geometric, terms).
Any frame can contain any other, but in practice they almost always fall into a strict
hierarchy, with each frame contained in only one other frame. Frames always contain
a pointer to their containing frame but not directly to their embedded frames. Some
applications — like Personal Information Managers, which handle lots of unstructured
information — have more sophisticated data models, however, so OpenDoc is built to
accommodate these applications.
Facets are   always   arranged in a strict hierarchy, and every facet has pointers to every
contained facet as well as to the containing facet. OpenDoc walks this structure at run
time to perform drawing as well as to handle geometric events such as mouse clicks.
The runtime representation is hooked into the window system by means of a window
object. This window object simply points to the topmost facet in that window’s facet
hierarchy.
To understand these objects in greater detail, you need to be familiar with three basic
ideas that form the foundation of OpenDoc’s layout and imaging capabilities: canvas,
shape, and transform.
•   A   canvas   is simply a drawing context. Different platforms have
different ideas of what a canvas might be, based on the particular
graphics toolbox they provide. On the Macintosh, a canvas can be
either a QuickDraw graphics port or a QuickDraw GX view port.
•   A   shape   is a way to describe an area of a canvas. OpenDoc provides
a platform-independent shape definition based on polygons. In
addition, for speed, QuickDraw regions and rectangles and
QuickDraw GX shapes can serve as shape objects in OpenDoc.
•   A   transform   is a way of altering the coordinate system that applies
to a particular canvas. You’re familiar with the concept of
transforms if you provide scrolling in your applications. When a
window is scrolled, a new origin is set in the graphics port before
drawing calls are performed. This offset is an example of a
transform. In QuickDraw, the only transforms with built-in
support are offsets and (partly) scaling, both of which require a
certain amount of work on the programmer’s part; QuickDraw GX
offers offsets and scaling as well as more interesting transforms
such as rotating and skewing. OpenDoc supports full two-
dimensional transformations and provides hooks to supply your
own transform types.
With these definitions in mind, let’s take a closer look at frames, facets, and windows.
FRAMES
A containing part and its embedded part share a single frame object, which they use
to communicate persistent layout information. Much of this information is
communicated in the form of shapes, which are ways to describe a geometric area.
Specifically, layout information is communicated by way of the frame shape, the used
shape, and the internal transform associated with a frame.
The   frame shape   is how the container tells the embedded part how much area it has in
which to lay itself out. The container “owns” this shape, meaning that it’s allowed to
set the value. If the embedded part wants a different frame shape, it must ask the
container to change it, and the container might refuse.
d e v e l o p   Issue 21   March 1995 6

Reading notes: Possible running header or footer text 'd e v e l o p Issue 21 March 1995 6' appears at the end of the copy and may not be body text.

Printed product names: OpenDoc · QuickDraw · QuickDraw GX · Personal Information Managers

Printed dates: March 1995 · Issue 21

Languages: English

[Original PDF page 8](https://www.vintageapple.net/files/c571a10520808a8e78150810497b746a19b377a830308ba8dd7662a0784fd45b/develop-21_9503_March_1995.pdf#page=8)

### PDF page 9

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-21-9503-march-1995-7430cd/1#scan-07bfb1d6ab4de0fea89246dc683934f94833d322c73b11ad445518575a3c0d44)

Transcribed text:

The rule in this sort of negotiation is “Don’t ask twice!” This means that if an
embedded part asks for a new frame shape and is denied, it shouldn’t ask again. It
might want to request a different shape later, but it should never again request exactly
the same shape. The reason, as you might imagine, is to avoid infinite loops in
negotiation. Very long, dull, and useless negotiations between parts may well result if
the “Don’t ask twice!” rule isn’t followed.
The   used shape   serves to inform the container exactly what part of the frame shape the
embedded part decided to use, and is “owned” by the embedded part. For example,
imagine that a word processing container passes a rectangular area as the frame
shape, but an embedded pie chart uses only a circular area within the frame shape.
The pie chart can inform the word processor of this by setting the used shape of the
frame to the circular area actually used. It’s then the responsibility of the container to
fill in any unused areas of the frame with an appropriate background or drawing. This
is what makes part transparency work.
The   internal transform , also “owned” by an embedded part, captures information
about how the embedded part wishes to transform its content when it’s displayed. If,
for example, the pie chart of the previous example were too big to fit in the allotted
space in the word processor and wanted to scroll itself to a particular location, it
could do so by setting the internal transform of the frame. We’ll look at some
examples in the recipes section to come.
FACETS
A facet is similar to a QuickDraw GX view port, or to a QuickDraw graphics port on
steroids; it’s a description of the place where a particular frame of a part becomes
visible. Typically passed in to your part handler by an object at drawing time, a facet
has information about where the part should be drawing the content of the frame
right now. It specifies the canvas where all drawing calls should be made and also
includes clipping and transformation information.
The clipping information appears in the form of the   clip shape . This shape specifies
exactly where on a canvas a part handler can draw. It’s equivalent to the content
region of a window in a traditional Macintosh application. Actually, there are two
versions of this shape that you can retrieve: the aggregate clip shape, which is the
clipping information relative to your drawing canvas, and the clip shape, which is
relative to the coordinate system of your container. Your container owns the clip
shape and sets it in its own coordinate system. You should always clip any drawing
calls you make to the aggregate clip shape of the facet you’re drawing into.
The transformation information comes in the form of a set of transform objects that
are available from the facet, each one specifying a particular coordinate system related
to the frame being displayed. The   external transform   of a facet specifies where the
facet sits in relation to its container. For example, as illustrated in Figure 1, if the
embedded facet should be offset by (100,100) from the origin of its container, the
external transform would specify an offset of (100,100). Note that in this figure, only
a portion of the content is being displayed in the embedded facet, and the coordinates
(0,0) refer to the content and indicate that the content’s upper left corner presently
coincides with the upper left corner of the facet.
The internal transform of a frame is composed with the external transform of its facet
plus all the transforms above it in the facet hierarchy to give the complete
transformation used to draw into the facet, called the   content transform.   In Figure 2,
which illustrates this process of composition, both transforms are simply offsets. The
external transform specifies an offset of (100,100), so the embedded facet is offset by
(100,100) from the origin of its container, the same as in Figure 1. The internal
GETTING STARTED WITH OPENDOC GRAPHICS   7

Reading notes: Source text is cut off mid-sentence at the end of the internal transform example in the FACETS section.

Languages: English

[Original PDF page 9](https://www.vintageapple.net/files/c571a10520808a8e78150810497b746a19b377a830308ba8dd7662a0784fd45b/develop-21_9503_March_1995.pdf#page=9)

### PDF page 10

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-21-9503-march-1995-7430cd/1#scan-24e750e160016f82aa7f6f1efa15ca850954b7198a58166a3c3e5a5a9719ee80)

Transcribed text:

transform specifies an offset of (0,-75), so the content is scrolled upward from its
position in Figure 1. A different portion of it now shows in the embedded facet,
which remains the same size as before.
This composition is recursive, so every level of embedding adds a new external and
internal transform to the final transformation. All of the transforms must be
composed together to produce a correct graphical result. When drawing occurs, the
content transform should be applied to any drawing commands. The only exception
to this rule is if you’re drawing content that shouldn’t scroll as well as content that
should. In this case, use the content transform for scrolling content and use a
different transform, called the   frame transform , to draw the rest. The frame transform
is exactly the same as the content transform except that it doesn’t include the internal
transform of the innermost frame.
d e v e l o p   Issue 21   March 1995 8
Containing facet
(0,0) (100,100)
(0,0)
External transform
Embedded facet
Containing facet
(100,100)
(0,0)
(100,25)
(0,75)
Embedded facet
(0,0)
Internal transform
External transform
Content transform
Figure 2.   Composing internal and external transforms to obtain a content transform
Figure 1.   An embedded facet with an external transform of (100,100)

Printed dates: 1995 · Issue 21

Languages: English

[Original PDF page 10](https://www.vintageapple.net/files/c571a10520808a8e78150810497b746a19b377a830308ba8dd7662a0784fd45b/develop-21_9503_March_1995.pdf#page=10)

### PDF page 11

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-21-9503-march-1995-7430cd/1#scan-7d705000b628babfc44e2697f48c8fdae1f874800f699e0137fd967a098c39d6)

Transcribed text:

WINDOWS
Windows are the objects that hook OpenDoc facets and frames into the Macintosh
window structure. A window object holds a Macintosh window structure, as well as a
pointer to the topmost facet visible in the window. We call this facet the   root facet
because it’s the root of the facet hierarchy in that window. The frame being displayed
through that facet is called the   root frame , and the part being displayed in the root
frame is called the   root part .
HOW THESE OBJECTS RELATE TO ONE ANOTHER
When a window is visible, it points to a facet at the root of the window. The graphics
port, or root QuickDraw GX view port, of that window is used as the canvas on
which that facet appears.
Every facet displays a particular frame, but a frame can be visible in more than one
facet at the same time. Every frame displays a particular part, but a part can be
displayed in more than one frame, as shown in Figure 3. Here we see a window
displaying two parts: a drawing container that has chosen to split itself into two
independently scrollable sections, and an embedded charting part. To split itself, the
container has set up two facets on the same frame of its embedded charting part, as
indicated in the schematic to the right of the window (in which the arrows represent
pointers). This automatically causes the embedded charting part to display
synchronized views of itself in the two scrollable sections. This is the model that
people who already do splitting in their code are most likely to implement, although
there are more elegant models included in the standard recipes that are part of the
OpenDoc Software Development Kit.
When the information in a part changes, the part needs to update every frame in
which it’s displayed. When a part updates the information in a frame, it should
redraw into every facet of the frame. Let’s assume, for example, that we have a
charting part that can display a bar chart. When someone changes a data value, the
part should make sure that every frame is redrawn. Since every frame may have
multiple facets, the part handler should iterate through every display frame, iterate
through each frame’s visible facets, and draw the content into each. To accomplish
this, you can decide to invalidate all of the affected frames and let OpenDoc make
sure everything is redrawn correctly. However, if performance or timing constraints
make this impractical, or if flicker is an issue, your part handler can draw directly into
each facet or each affected frame, using a doubly nested loop.
GETTING STARTED WITH OPENDOC GRAPHICS   9
Facet
Facet
Facet
Frame   Containing
part
Embedded
part
Frame
Drawing container
Embedded
charting part
Embedded
charting part
Figure 3.   A split window using multiple facets of the same frame

Reading notes: Figure 3 caption and schematic labels are fragmentary in the source copy and reading order may be uncertain.

Languages: English

[Original PDF page 11](https://www.vintageapple.net/files/c571a10520808a8e78150810497b746a19b377a830308ba8dd7662a0784fd45b/develop-21_9503_March_1995.pdf#page=11)

[Next transcribed scans](https://www.vintageapple.net/transcripts/media/va-develop-21-9503-march-1995-7430cd/2.md)
