# develop-19 9408 September 1994 — source transcripts, page 1

[Canonical transcript page](https://www.vintageapple.net/transcripts/media/va-develop-19-9408-september-1994-3d466f/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-19-9408-september-1994-3d466f/1#scan-2ff5b5701a587c1f03e976a03dc222b28a190118c35a2bf4f04ad7d14ff11159)

Transcribed text:

Pick Your Picker With Color Picker 2.0 • Media Capture Using the Sequence Grabber

develop

The Apple Technical Journal

Issue 19 September 1994

Building an OpenDoc Part Handler

Tuning PowerPC Memory Usage

Designing for the Power Macintosh

Adding QuickDraw GX Printing to QuickDraw Applications

Making the Most of QuickDraw GX Bitmaps

Implementing Inheritance in Scripts

$10.00

Image description: A magazine cover with a green masthead band, the word develop in large black type, and a collage of framed photos showing an abacus, a Holiday II movie camera, a typewriter, an artist's palette with brushes, and small photos over body text columns on a beige background.

Reading notes: Body text in the collage pages (small columns near the center and right) is too small and blurred to transcribe reliably and is omitted. The small text on the camera body reads Holiday II, which is treated as a printed product name on the photographed object rather than an advertised product. Reading order of the cover lines is inferred from top-to-bottom layout.

Printed prices: $10.00

Printed dates: September 1994 · Issue 19

Languages: English

[Original Image 1](https://www.vintageapple.net/files/9ec107f6a06aa1c45d5fad69725d1db3334c963b0cc1866c8d179b2f4e010dbb/00f2defc4c22a986efde71f6.webp)

### PDF page 1

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-19-9408-september-1994-3d466f/1#scan-d914388074f905f262c735a262a02925fbbe8abbf06973f6ecf905f397a46a44)

Transcribed text:

Pick Your Picker With Color Picker 2.0 • Media Capture Using the Sequence Grabber

develop
The Apple Technical Journal

Issue 19 September 1994

Building an OpenDoc Part Handler

Tuning PowerPC Memory Usage

Designing for the Power Macintosh

Adding QuickDraw GX Printing to QuickDraw Applications

Making the Most of QuickDraw GX Bitmaps

Implementing Inheritance in Scripts

$10.00

Image description: A magazine cover with a green banner at top, the large 'develop' masthead with an Apple logo, and a left column of red and black cover-line headlines beside a collage of framed vintage objects (an abacus, a Holiday II movie camera, a typewriter, and an artist's palette) over a magazine article page with a bar chart and photos.

Reading notes: Body text on the collage pages is too small and blurred to transcribe reliably and is omitted. Small text on the camera label and typewriter plate is not reliably legible. Reading order of the cover lines is top to bottom in the left column.

Printed product names: develop

Printed prices: $10.00

Printed dates: Issue 19 September 1994 · 1994

Languages: English

[Original PDF page 1](https://www.vintageapple.net/files/e792d564edc03d6a467b81df4be8743ea95e472730151a5fdf48cea136f54b55/develop-19_9408_September_1994.pdf#page=1)

### PDF page 2

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-19-9408-september-1994-3d466f/1#scan-6753f5b3eef243e1396cd87afce3ea86f9506d5011c6c7c9130f2adab22b18a3)

Transcribed text:

E D I T O R I A L   S T A F F
Editor-in-Cheek   Caroline Rose
Managing Editor   Cynthia Jasper
Technical Buckstopper   Dave Johnson
Bookmark CD Leader   Alex Dosher
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, Jody Larson, Joe Williams
Indexer   Marc Savage
A R T   &   P R O D U C T I O N
Production/Art Director   Diane Wilcox
Technical Illustration   Ruth Anderson,
Sandee Karr
Formatting   Forbes Mill Press
Film Services   Aptos Post, Inc.
Prepress Production   PrePress Assembly
Printing   Wolfer Printing Company, Inc.
Photography   Sharon Beals, Cynthia Jasper,
Mark Maxham, John Wang, Diane Wilcox
Cover Illustration   Hal Rucker and Peter
Andrea of Rucker Huggins Design
ISSN #1047-0735. © 1994 Apple Computer,
Inc. All rights reserved. Apple, the Apple logo,
APDA, AppleLink, AppleTalk, HyperCard,
ImageWriter, LaserWriter, Mac, MacApp,
Macintosh, MacTCP, MPW, Newton,
QuickTime, and TrueType are trademarks of
Apple Computer, Inc., registered in the U.S. and
other countries. AOCE, AppleScript, A/ROSE,
Balloon Help, ColorSync, develop, DocViewer,
Finder, MessagePad, NewtonMail, NewtonScript,
OpenDoc, Power Macintosh, PowerShare,
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. FaceSpan is a trademark of Software
Designs Unlimited, 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.apple.com.
Macintosh Technical Notes.
Where references to Macintosh
Technical Notes in   develop   are followed
by something in parentheses like
“(Memory 13),” this indicates the
category and number of the Note on
this issue’s CD.
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.   Subscribe to   develop
through APDA (see below) or use the
subscription card in this issue. For
subscription changes or queries, call
1-800-877-5548 in the U.S. or
(815)734-1116 outside the U.S., or
write to AppleLink DEV.SUBS,
Internet dev.subs@applelink.apple.com,
or   develop , P.O. Box 531, Mount Morris,
IL 61054-7858.
Back issues.   Printed back issues are
available for $13 each in the U.S. or
$20 outside the U.S. To order, call
1-800-877-5548 in the U.S. or
(815)734-1116 outside the U.S., or
write to AppleLink DEV.SUBS,
Internet dev.subs@applelink.apple.com,
or   develop , P.O. Box 531, Mount Morris,
IL 61054-7858.
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 is set to empty because the exact text is preserved separately; the other fields were filled only from the supplied copy and were not checked against a visible image. No readable headline is printed as a distinct display heading; the section labels such as E D I T O R I A L STAFF are spaced-out letters and were not treated as a headline. Multi-column layout and reading order could not be confirmed from the supplied text alone. Printed dates are limited to the copyright year 1994; the months March, June, September, and December refer to publication frequency and were not listed as dates. The ISSN and phone and fax numbers were not treated as dates or prices.

Printed product names: develop · Bookmark CD · Developer CD Series

Printed prices: $13 · $20

Printed dates: 1994

Languages: English

[Original PDF page 2](https://www.vintageapple.net/files/e792d564edc03d6a467b81df4be8743ea95e472730151a5fdf48cea136f54b55/develop-19_9408_September_1994.pdf#page=2)

### PDF page 3

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-19-9408-september-1994-3d466f/1#scan-3d7ff755cf88d1bf1ea522948c106440ab0e40dfb355a1dd5f8f1229b0479639)

Transcribed text:

A R T I C L E S
6   Building an OpenDoc Part Handler   by Kurt Piersol
Writing code to support Apple’s new compound-document architecture is a lot like writing any Macintosh
application. Here’s an overview of what you’ll need to know.
24   Adding QuickDraw GX Printing to QuickDraw Applications   by Dave Hersey
Even if your application doesn’t need the advanced graphics capabilities of QuickDraw GX, your users will
love the new printing architecture, and you can support it with a minimum of effort.
48   Making the Most of QuickDraw GX Bitmaps   by David Surovell
A primer on handling bitmapped graphics in QuickDraw GX: tips, tricks, and whizzy effects.
68   Pick Your Picker With Color Picker 2.0   by Shannon Holland
The new Color Picker Manager is flexible and customizable, allowing much tighter integration of color
pickers with your application.
89   Implementing Inheritance in Scripts   by Paul G. Smith
Supporting inheritance in your application’s scripts so that they can share handlers and global variables isn’t
as difficult as you might think.
C O L U M N S
17   BALANCE OF POWER
Tuning PowerPC Memory Usage
by Dave Evans
Avoiding inadvertent cache thrashing is
important for maximum performance.
20   Designing Applications for the Power
Macintosh
by Greg Robbins and Ron Avitzur
The power of the Power Macintosh means
more than just faster spreadsheets.
65   GRAPHICAL TRUFFLES
A Cool QuickDraw GX Clipping Effect
by Pete (“Luke”) Alexander
A stroll through a snippet of code that
demonstrates some fancy clipping.
85   SOMEWHERE IN QUICKTIME
Media Capture Using the Sequence
Grabber
by John Wang and Fernando Urbina
The sequence grabber component supports
capture of any media type. Here’s how to use it.
100   Macintosh Q & A
Apple’s Developer Support Center answers
questions about Macintosh product
development.
110   THE VETERAN NEOPHYTE
Rubber Meets Road
by Dave Johnson
Edges make the world go ’round.
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
Heaps of Fun
by Konstantin Othmer, Bruce Leak, and Steve
Newman
Our heroes take on a guest puzzler.
2   EDITOR’S NOTE
3   LETTERS
124   INDEX
Issue 19   September 1994
CONTENTS   1

Printed product names: Apple · Macintosh · QuickDraw GX · Color Picker 2.0 · Power Macintosh · QuickTime · Newton · OpenDoc

Printed dates: September 1994

Languages: English

[Original PDF page 3](https://www.vintageapple.net/files/e792d564edc03d6a467b81df4be8743ea95e472730151a5fdf48cea136f54b55/develop-19_9408_September_1994.pdf#page=3)

### PDF page 4

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-19-9408-september-1994-3d466f/1#scan-cae188e532d0ce55bb551ccb345a6244baffe37d919d0b580fa1f9bc74ab8a64)

EDITOR'S NOTE

Transcribed text:

Around the time I was faced with writing this editorial, I had just attended the
celebration of my friend Mrs. Robertson’s 100th birthday, and my 85-year-old father
had flown over from Florida to celebrate it with us. With the subject of longevity on
my mind, I got to thinking about how it relates to   develop .
develop ’s goal is to provide you with articles and code that will have a long life — that
can live in your applications happily and compatibly even as new Macintosh systems
are introduced. We do all we can to ensure this (at the risk of incurring the wrath of
our authors, who may wonder why it takes so long to see something in print after
it’s submitted to   develop ). We’d rather an article “have legs” than be published
prematurely and get you into trouble further down the line. We do our best to test
the code and get our technical reviewers’ opinions on whether a particular method is
safe. This should be a primary concern of all developers, especially now in light of
the whole new world of Power Macintosh systems.
Evidence that we’re succeeding is that we still get requests to reprint articles as far
back as Issue 2, and we often hear from readers who save every issue because they
retain their usefulness. (Remember that, the next time you’re thinning out your
bookshelves!)
Our being an Apple publication gives us the distinct advantage of being able to have
a thorough code review with future systems in mind, but at the same time it puts us
in a unique position to have early articles on new Apple technology. So we also try to
give you articles as soon as possible after the API for a new technology has frozen.
And if we can, we give you a prerelease version of the new software along with the
code on our CD. These articles may have somewhat shorter legs, but the bulk of the
information should remain accurate for a very long time.
In the past we’ve given you early QuickDraw GX versions and articles; now that
QuickDraw GX has shipped, the two articles on that subject in this issue are only the
most recent in a long line. Also in this issue we’re pleased to bring you our first
article on OpenDoc, Apple’s new cross-platform compound-document architecture,
even though the final version of OpenDoc will not have shipped by the time you
read this.
Further evidence that we’re succeeding is that we’ve again won in the International
Technical Publications Competition of the Society for Technical Communication,
this time the highest award in our category. But nothing would please us more than
to hear from you, the most important judges of all, on what we can do to make
develop   an even better publication; please let us know at AppleLink DEVELOP.
CAROLINE ROSE
d e v e l o p   Issue 19   September 1994 2
EDITOR’S NOTE
CAROLINE ROSE   (AppleLink CROSE)   As a
child, Caroline wrote a one-page newsletter
about the goings-on in her neighborhood; it
included news items, a gossip column, and a
comic strip. Her readership was small, and the
operation folded after one issue. She’s happy that
develop has lasted longer than that, because
after various jobs at Tymshare, NeXT, and Apple
as a programmer, writer, editor, and manager,
she feels she’s found her niche here. These days
when Caroline’s not at work she’s likely to be
sailing, swimming, jogging, dancing, gardening,
or otherwise not being sedentary. She hopes to
live 100 very active years.•
Caroline Rose
Editor

Reading notes: Headline 'EDITOR'S NOTE' appears beside a separate editorial heading; primary heading may be ambiguous Running header line 'develop Issue 19 September 1994 2' is interleaved within the body text, so reading order around it is uncertain

Printed product names: develop · QuickDraw GX · OpenDoc · Power Macintosh · CD

Printed dates: September 1994 · Issue 19 · Issue 2

Languages: English

[Original PDF page 4](https://www.vintageapple.net/files/e792d564edc03d6a467b81df4be8743ea95e472730151a5fdf48cea136f54b55/develop-19_9408_September_1994.pdf#page=4)

### PDF page 5

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-19-9408-september-1994-3d466f/1#scan-c885b18f53a757e759e28fdf1e6310e2eb7d6188656994c997f88dd949b0389d)

Transcribed text:

MISSING GAME FOLDER
The column by Brigham Stevens on
game development in   develop   Issue 17
refers to a Game Development folder
on the Bookmark 17 CD. I was unable
to locate the folder. Is it me, or was
there a production glitch?
Also, is the folder the same one that was
on the February Developer CD?
— Bob Boonstra
There was a production glitch. The folder
was on Issue 16’s Bookmark CD but was
inadvertently removed from Issue 17’s CD.
We have since restored it (it’s in the Tools &
Applications folder). We also got the name
wrong: it’s Games, not Game Development.
And yes, it’s the same folder as the one on
the Developer CD. The Bookmark CD
always contains a subset of the Developer
CD Series.
Happy gaming!
— Dave Johnson
DEVELOP ON THE SMALL SCREEN
In Issue 17 you ask why so many
applications lack common sense, and
then you go on to list a number of
annoyances caused by bad designs. I
agree that the items mentioned could
be better handled, but I have a similar
complaint with   develop !
develop , shipped on CD-ROM with
Apple DocViewer, is a software product
that’s produced like a printed document.
Things like double-columned pages are
extremely difficult to read on a standard
Macintosh 13-inch monitor — you have
to scroll down the entire page as you
read a single column and then scroll
back up and repeat the process. While
this orientation makes sense on a
printed page, it really bites on my 13-
inch monitor. Also,   develop   is nearly
unreadable with its serif typefaces,
italics, etc.
Right now you’re probably shaking your
head and saying that you don’t have the
money to produce two versions of
develop   — one for print and one for CD.
If so, then you also know why so many
applications lack common sense!
— Brooks Bell
Certainly time and money do enter into
design decisions, even at Apple. But there
are still a lot of cases where common sense
could be followed without a big hit to the
schedule or pocketbook.
Regarding your problem with viewing the
CD version of   develop   on a 13-inch screen,
you might try DocViewer’s “text” view (the
icon in the tool bar that looks like a sheet of
paper with writing, just to the left of the
scaling pop-up menu). This view gets rid
of all special formatting such as double
columns. You can still look at illustrations,
by clicking the Open button next to the
figure caption.
In text view you can change the font size
and type of any structural part of the
document, using the Format command in
the Edit menu. For example, you can choose
Body in the Format dialog and change the
font of all the body text. (In the normal
view, the scaling pop-up menu can be used
to magnify everything.)
Thanks for writing and giving us the
opportunity to provide these tips. We
welcome all gripes!
— Caroline Rose
LETTERS
LETTERS   3
WE’RE DYING TO HEAR FROM YOU
We welcome timely letters to the editors,
especially from readers reacting to articles that
we publish in
develop. Letters should be
addressed to Caroline Rose (or, if technical
develop-related questions, to Dave Johnson) at
Apple Computer, Inc., One Infinite Loop, M/S
303-4DP, Cupertino, CA 95014 (AppleLink
CROSE or JOHNSON.DK). 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: Letter headers and bylines are merged in extraction order; reading order of the 'Missing Game Folder' and 'Develop on the Small Screen' sections may be uncertain.

Printed product names: develop · DocViewer · Apple DocViewer · Macintosh

Printed dates: Issue 17 · Issue 16 · February

Languages: English

[Original PDF page 5](https://www.vintageapple.net/files/e792d564edc03d6a467b81df4be8743ea95e472730151a5fdf48cea136f54b55/develop-19_9408_September_1994.pdf#page=5)

### PDF page 6

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-19-9408-september-1994-3d466f/1#scan-d87b09293c96a43563cb2de6cc27ebd4863c9a0b9b66ce9e73380b0807b7d4f8)

Transcribed text:

QUICKDRAW GX MORPH TABLES
The Macintosh Q&A section of   develop
Issue 16 stated that there’s no way to
do an automatic checksum digit
insertion using QuickDraw GX’s glyph
metamorphosis tables. I haven’t read
much about QuickDraw GX’s 'mort'
tables, but I do know finite state tables.
It’s quite feasible to build a 12-state
table that will generate a checksum digit
for a digit-string of any length. The key
is to make the checksum be calculated
dynamically instead of at the end. This
reduces the required number of states to
ten, plus beginning and end, which is
well within the limits of QuickDraw GX.
— Mark Cogan
Developer Wannabe
You’re quite right; you can indeed use
morph tables to generate checksums. Other
cyclic kinds of calculations are also possible;
for example, a morph table could be set up
to do pseudo-random selection of letterforms
from a font that was designed with five
variant forms of A-Z and a-z. When a
letter is encountered, it would be replaced
with its version from one of the sets. But
regardless of the specific glyph, each time a
glyph is processed the state advances and
eventually loops back to the starting state.
This is in general the template for how
cyclic effects can be implemented with the
QuickDraw GX morph tables.
— Dave Opstad
GX Line Layout Weenie
WATCH-CURSOR PUSH-UPS
AND BEYOND
Regarding Dave Johnson’s bio in Issue
16: He’s not the only one who plays with
the cursor while waiting for the Mac.
Here are some other silly things to do:
• Try to fit the watch inside an empty
horizontal scroll bar. It always overlaps
one of the lines, either the top or
bottom one, so if you move that single
pixel that alternates between them, the
watch seems to be slipping on its wrist
belt.
• While installing the system, position
the counting hand so that it’s just
touching a horizontal line. Don’t
overlap the line, and the hand will seem
to be cut from its owner, instead of
being a ghost unterminated hand.
— Javier Guerra G.
Dave is not alone in doing watch-cursor
push-ups and pull-ups. My personal
favorite activity here is trying to find a
place where I can do both at once. I
remember that the old Font/DA Mover
has a spot between two buttons where
you can do that nicely.
— Maarten Hazewinkel
Hot Dawg! I knew there were others out
there doing the watch cursor thing. I’ve
heard from a half dozen or so; it’s a lot more
common than I thought.
I remember doing that with the old
Font/DA Mover, too. The progress bar
during long Finder operations also worked
well. (Nowadays we have movable modal
progress windows, so the watch cursor is
gone — the price of progress.)
Thanks for letting me know I’m not alone!
— Dave Johnson
UNABASHED PRAISE
develop   is an inspiring magazine. The
layout is clean yet warm and inviting.
The articles are relevant and the authors
are knowlegeable.
The on-line issues of   develop   are
invaluable. This is the best on-line
documentation I have seen, period. The
articles look great — just like the
magazine. And searching and setting
filters is fast. Microsoft’s CD comes
with a lot of files, but most of it is old,
irrelevant, and ugly to read.
I sure appreciate your effort.
— Brent Foust
We can’t thank you enough for taking the
time to write. Letters like this keep us
going, in more ways than one. We hope
you’re as happy with the recent changes to
our layout; please let us know if not.
— Caroline Rose
d e v e l o p   Issue 19   September 1994 4

Reading notes: Source contains a blank gap where the magazine name was lost in extraction Heading 'WATCH-CURSOR PUSH-UPS AND BEYOND' and later sections are not explicitly separated in reading order

Printed product names: QuickDraw GX · Macintosh · Microsoft's CD · Font/DA Mover

Printed dates: September 1994 · Issue 16 · Issue 19

Languages: English

[Original PDF page 6](https://www.vintageapple.net/files/e792d564edc03d6a467b81df4be8743ea95e472730151a5fdf48cea136f54b55/develop-19_9408_September_1994.pdf#page=6)

### PDF page 7

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-19-9408-september-1994-3d466f/1#scan-6d69fba9eb83ab4cb7fe795028d811d65eaf9c784f8521740ca805860fe46230)

Transcribed text:

OpenDoc, Apple’s compound-document architecture, brings users a new,
more powerful metaphor for working with documents. Writing code to
support OpenDoc is a lot like writing a normal application. This article
gives an overview of what’s involved in writing OpenDoc code and
presents a simple working example.
OpenDoc provides a new way to write application code for the Macintosh and a
number of other desktop platforms. By following the OpenDoc guidelines, you can
produce applications that share files, windows, and interface elements seamlessly. The
process of writing an OpenDoc application, which we call a   part handler , is much like
writing any Macintosh application. There are differences as well, of course, and this
article will help you understand them.
OpenDoc applications are designed to allow code from several sources to cooperate
in producing   compound documents , documents that can embed almost any kind of
content inside them. Each piece of content in the document (each   part ) includes its
own part handler, the code that’s used to edit and view it. To achieve this, OpenDoc
part handlers must cooperate in a number of ways. They must sort out how events
are passed, where data is stored on the disk, and where drawing is allowed to occur on
windows or printed pages.
This article starts with a brief overview of OpenDoc and then talks about
implementing a simple part handler. It will show you the absolute basics, much as
TESample does for TextEdit in the Macintosh Toolbox. You’ll learn about a simple
example of building a part handler, included on this issue’s CD: a clock that can
handle two different display modes, digital and analog. The clock updates itself every
second and allows the user to select the display mode from a menu.
A quick caveat: The sample code provided on the CD is from the alpha version of
OpenDoc, but by the time you read this, a beta version should be available. When
you begin implementing your own part handler, you may find that some details of the
API have changed; however, the overall structure will be the same. The sample clock,
for instance, is specific to C++ and the alpha version of OpenDoc. The final version
of OpenDoc will be based on IBM’s System Object Model (SOM), which will allow
part handlers to be written in a variety of languages, both object-oriented and
procedural. Similarly, the   XMP   prefix on OpenDoc class names (you’ll see a lot of
them in this article) will be changed to   OD   beginning with the beta release.
KURT PIERSOL
Building an OpenDoc Part Handler
d e v e l o p   Issue 19   September 1994 6
KURT PIERSOL , the chief architect of OpenDoc,
previously led the Apple Event project and was
an early technical lead for AppleScript. He’s
responsible for making technologies fit together at
Apple. Kurt also likes to wear suspenders, though
that has very little to do with his software
architectural responsibilities.•

Reading notes: Author byline and running header may be interleaved with body text in the extracted source Trailing bullet character after author bio is of uncertain meaning

Printed product names: OpenDoc · TESample · TextEdit · AppleScript · IBM's System Object Model (SOM)

Printed dates: September 1994 · Issue 19

Languages: English

[Original PDF page 7](https://www.vintageapple.net/files/e792d564edc03d6a467b81df4be8743ea95e472730151a5fdf48cea136f54b55/develop-19_9408_September_1994.pdf#page=7)

### PDF page 8

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-19-9408-september-1994-3d466f/1#scan-f934e14f0aaeee4492910f10b900f7d60b81779de6b703cf6b54919803e62a46)

Transcribed text:

This is perhaps a good time to mention a bit more about SOM. This technology is
the basic mechanism that OpenDoc part handlers use to communicate with one
another. SOM solves many hard problems associated with using object-oriented
languages, including those of subclassing across language boundaries, altering base
classes under dynamic linking, and long-term maintenance of object-oriented APIs.
OVERVIEW OF OPENDOC
Before getting into the specifics of OpenDoc and how to write part handlers, we’ll
talk about some of the basic services you’ll see in OpenDoc and where your own code
fits into the OpenDoc architecture.
PART HANDLERS
Part handlers are what provide OpenDoc with its ability to handle different kinds of
content in a single document. You, the developer community, will write the various
part handlers that plug into OpenDoc.
Part handlers are a lot like existing applications. They handle events, draw and print,
and read and store data onto disk. Every part handler provides a series of entry points
that allow OpenDoc to request any of these actions from the part handler. In
addition, the API has a number of “bookkeeping calls,” which allow OpenDoc to
provide undo services and notify part handlers when their environment has changed.
Overall, there are about 50 calls in the OpenDoc part API that a part needs to
implement. This is a lot, but it actually maps fairly closely with the number of things
you’d have to do to write any Macintosh application. In addition, you can ignore
many of these calls in many cases. For instance, if you don’t allow embedding of other
parts within your part, there are about ten calls that you can safely ignore. If you
don’t update your display asynchronously, but simply wait for update calls, there are
additional calls that you can ignore. In many typical cases, this means that you can
build a part handler very quickly from existing code.
Part handlers are packaged as shared libraries in the Macintosh version of OpenDoc.
This won’t always be the case on other OpenDoc platforms, but you can count on the
API being the same on all platforms. The alpha version of OpenDoc uses the Apple
Shared Library Manager to dynamically link your part handler into OpenDoc, while
the beta version will use SOM. These versions will have different linker behavior but
will essentially require the same basic packaging of your code: a shared library.
In either case, you’ll find that OpenDoc is an object-oriented API. That means
you’ll be talking to OpenDoc objects, and your part handler will itself be an
OpenDoc object (or set of objects). This doesn’t mean that your code has to be built
from the ground up in C++, though. SOM will provide interfaces to many languages,
including C.
Because part handlers are themselves objects, we often refer to them as “part objects”
or “parts” in conversation. In fact, what the user would call a “part” in a document is
really the combination of some persistent data stored in the document file and a set of
objects that OpenDoc uses to display and manipulate the stored data. OpenDoc
chooses appropriate part handlers based on the type of data stored in the document.
RUNTIME OBJECTS
As we describe how to write a part handler, we’ll mention some runtime objects that
interact with your code. In OpenDoc, these objects can be located at run time using
the session object (XMPSession), to which your part object will be given a pointer
BUILDING AN OPENDOC PART HANDLER   7

Reading notes: Page header and page number at end of excerpt may be fragmentary; no primary heading is printed in the supplied copy.

Printed product names: OpenDoc · SOM · Apple Shared Library Manager · XMPSession

Languages: English

[Original PDF page 8](https://www.vintageapple.net/files/e792d564edc03d6a467b81df4be8743ea95e472730151a5fdf48cea136f54b55/develop-19_9408_September_1994.pdf#page=8)

### PDF page 9

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-19-9408-september-1994-3d466f/1#scan-4ca5c75cf6e9de99e2a802439c4c957f215a1e0024b41943f630a67e04fead9f)

Transcribed text:

when it’s initialized. The session object is very important because it’s your link to the
rest of the OpenDoc objects that are running in the document.
There’s a whole list of objects that the session object makes available. Of these, only
three will be important for the purposes of this article: the arbitrator, the dispatcher,
and the undo stack.
•   The   arbitrator   is an object of class XMPArbitrator. The arbitrator
for a session is the place where part handlers register their
ownership of certain resources. The menu bar, the keystroke
stream, and the current selection are all examples of resources that
the arbitrator tracks.
•   The   dispatcher   is the object that dispatches events to the various
part handlers. It’s an object of class XMPDispatcher. It’s used in
our example as a way to register for background time.
•   The   undo stack   is an object of class XMPUndo that allows
OpenDoc to support multilevel undo across part handler
boundaries.
Each of these objects will be discussed as it’s encountered.
A RUNNING START
To give you a running start, we’ve built a small object-oriented framework for parts
that implements the direct interface to OpenDoc. This framework is a precursor to
the new part handler framework that Apple is building, and is included here simply as
sample code. Our sample clock uses this framework. The good thing about the
framework is that it clearly separates the work that any part handler must do to be
OpenDoc compliant from the specific work performed in putting up a clock.
The framework divides the work of a part into three objects: a frame object, a facet
object, and a part object. OpenDoc itself doesn’t require that you create anything but
a part object, but for the sake of clarity the framework divides the labor among
several smaller objects. For easy reference, here’s a list of the classes we’ll be
discussing throughout the article and their corresponding source files, included on
the CD:
CPart   FWPart.h, FWPart.cpp
CFrame   FWFrame.h, FWFrame.cpp
CFacet   FWFacet.h, FWFacet.cpp
CClockPart   ClockPar.h, ClockPar.cpp
CClockFrame   ClockFra.h, ClockFra.cpp
CClockFacet   ClockFac.h, ClockFac.cpp
The classes defined by the framework generally start with the letter   C , hence the
classes CPart, CFrame, and CFacet. These three parts are helper objects for three
OpenDoc classes, XMPPart, XMPFrame, and XMPFacet. XMPPart objects are
OpenDoc part handlers: you’ll subclass XMPPart when writing your own. OpenDoc
uses the frame and facet objects to help part handlers lay themselves out in a window.
How these classes work together is probably the single most complex thing to
understand in OpenDoc.
XMPPart, the class from which part handlers are derived, is simply the base class of
every OpenDoc part handler. It’s the class that actually handles the drawing, editing,
and storage. Every part handler is an implementation of some subclass of XMPPart.
d e v e l o p   Issue 19   September 1994 8

Printed dates: 1994

Languages: English

[Original PDF page 9](https://www.vintageapple.net/files/e792d564edc03d6a467b81df4be8743ea95e472730151a5fdf48cea136f54b55/develop-19_9408_September_1994.pdf#page=9)

### PDF page 10

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-19-9408-september-1994-3d466f/1#scan-bfc9c7a930fb42e6f6156169a55be40207f6b757f21f4769d03bc407824410ae)

Transcribed text:

CPart, in the framework, is a class derived from XMPPart. It’s just a default
implementation of the basic XMPPart behavior. As such, CPart is a treasure trove of
information about the correct way to “ignore” calls that aren’t interesting because
your part handler doesn’t support embedding, update asynchronously, or use
offscreen bitmaps.
Every part is embedded in another part, with the exception of the   root part,   the top-
level part in each compound document. When a part is embedded in another part,
there’s an object that’s used to store information about the shape of the embedded
part. This boundary between a container and an embedded part is a   frame   — an
instance of the class XMPFrame. Every frame has a single part displayed inside it.
The container actually embeds the frame; it knows nothing about the part inside.
Any part can be displayed in several frames at the same time. This makes it easy for a
part to be visible in several windows or to have several different presentations. For
example, a charting part might want to have one frame displaying the chart and
another allowing the data to be edited in a table.
A   facet   (an instance of an XMPFacet object) is a visible part of a frame. There can be
many facets displaying within any given frame. This is a useful property, for instance,
when a container wants to “split” windows.
Both XMPFrames and XMPFacets have a field, partInfo, for storing information
specific to the part being displayed. This is rather like a window refCon, a handy
place to store information independent of the object itself. The CFrame and CFacet
objects are designed to be plugged into the partInfo fields of their XMPFrame and
XMPFacet counterparts. The containing part creates the XMPFrame and XMPFacet
objects and then allows your part handler to initialize their partInfo fields. In the
framework, the actual work of drawing the part on the screen is done in the CFacet
object. The work of deciding what shape the embedded part will take is done in the
CFrame object. As we describe the specific operations, we’ll point out the class in
which the code resides.
INITIALIZATION CODE
The first bit of code we’ll consider is the initialization code for each part object. Each
distinct part in a document gets an instance of the part object, so if there are seven
little clocks running in different windows (or the same window, for that matter) there
are seven instances of the clock part object. This means that you probably want to
come up with a scheme to share any global data so that you aren’t wasting space with
many copies of it. Both the Apple Shared Library Manager and SOM support
systemwide global storage, so this should be straightforward.
Resources are a special case. You’ll want to be very polite about not permanently
fiddling with the resource chain or making assumptions about where your resource
file is in the chain. We suggest saving the previous head of the resource chain, setting
your file to be the end of the chain, and using the single-level resource calls (such as
Get1IndResource) to find the resources you’re after. Since you’ll probably want to
share the resources among separate instances of your part object, it may be better to
detach the resources you get and manage them yourself instead of counting on any
particular application heap to have the correct resource map.
THE CONSTRUCTOR
The first step in initialization is the   constructor . You should never do anything that
could possibly fail in a constructor. This pretty much limits you to operations like
BUILDING AN OPENDOC PART HANDLER   9

Languages: English

[Original PDF page 10](https://www.vintageapple.net/files/e792d564edc03d6a467b81df4be8743ea95e472730151a5fdf48cea136f54b55/develop-19_9408_September_1994.pdf#page=10)

### PDF page 11

[Cite this scan](https://www.vintageapple.net/transcripts/media/va-develop-19-9408-september-1994-3d466f/1#scan-8c25984caeb47a739374a8c304f5c1638ccc09b7ffaa2a970208e6b33479dfa4)

Transcribed text:

setting pointer variables to NULL, setting numeric variables to appropriate values,
and making similar assignments from constants.
You can see a good example in ClockPar.cpp. The clock part simply sets up its fields
with appropriate constant values.
XMPPART::INITPART
The next phase of initialization takes place in the InitPart method that every part
object implements. The InitPart method is called by OpenDoc after the part object
has been created, and here you   can   attempt things that can fail. This is where you
should attempt to allocate any extra memory you need for your part instance, get
resources if you need them, and set up your persistent storage.
Let’s examine how OpenDoc’s storage system looks to a part handler. When your
part object is created, the InitPart method is passed a   storage unit   object in which you
can persistently store information. A storage unit is really just a list of named
properties , each of which has one or more   values . Each value is an entire stream, like an
existing Macintosh file. You can do read, write, seek, insert, and delete operations on
individual values.
Each value has a type, much like the type code associated with a Macintosh file. Every
property in a storage unit can have one or more values, each with their own type
code. Thus, you can store multiple representations of any property. You can make up
any property names you like. One special property name, kXMPPropContents, is
used by OpenDoc to determine which handler goes with which part at run time.
Every part object should have a property named kXMPPropContents so that OpenDoc
can determine what part handler to run.
In our sample, CClockPart has an Initialize method, which is called by CPart::InitPart.
It sets up the menu bar for the clock and sets up a focus set for obtaining system
resources from the arbitrator (more about this later). A good example of code to set
up persistent storage can be found in the implementation of CPart. The framework
calls its own method, called CheckAndAddProperties, to make sure that the storage
unit is set up correctly.
DRAWING CODE
Now that your initialization code is in place, you’ll want to make sure you can get
your part to draw onscreen. OpenDoc will call your part with the Draw method and
tell you which facet should be drawn.
Our sample, CClockPart, inherits some code from CPart that asks the CFacet object
to do the drawing. Notice, though, that before it does this, CPart::Draw sets up the
graphics port for drawing using the clipping information from the facet. This is very
similar to the basic drawing model for the Macintosh, where you draw using the
appropriate graphics port and clipping region. You can find the rest of the drawing
code in CClockFacet::Draw. This code consists of just the straightforward QuickDraw
calls and attendant calculations needed to display either the digital or the analog clock
face.
We use a utility class called CDrawInitiator to set up the drawing environment
reliably. The constructor of this class does all the work of setting the graphics port’s
clipping region and origin. Later, the destructor restores the port to its previous state.
This is a tricky bit of C++ coding that takes advantage of the object allocation
behavior of stack-based objects in C++.
d e v e l o p   Issue 19   September 1994 10

Reading notes: Source appears to be a technical article excerpt with no advertised products or prices; header/footer year '1994' is the only printed date.

Printed dates: 1994

Languages: English

[Original PDF page 11](https://www.vintageapple.net/files/e792d564edc03d6a467b81df4be8743ea95e472730151a5fdf48cea136f54b55/develop-19_9408_September_1994.pdf#page=11)

[Next transcribed scans](https://www.vintageapple.net/transcripts/media/va-develop-19-9408-september-1994-3d466f/2.md)
