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

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

## 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.

### PDF page 12

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

Transcribed text:

SOME OPENDOC GRAPHICS RECIPES
Now let’s look at a series of examples of how to use these objects to perform basic
graphics operations. Each of the following recipes is, by nature, just a skeleton. Every
part handler has different drawing code, so we’ll concentrate on outlining general
recipes and wave our hands over the specific drawing commands.
The examples are all based on Color QuickDraw, on the assumption that more
readers will be familiar with these calls than with the QuickDraw GX equivalents. I’m
counting on you QuickDraw GX aficionados to perform the necessary mapping
between QuickDraw and QuickDraw GX as you read. The QuickDraw GX
equivalent calls will work equally well to clip, set up drawing contexts, and perform
geometric operations. Of course, you’ll find QuickDraw GX helps tremendously in
implementing scaling, rotation, and other transformations. Even though these
examples are in Color QuickDraw, I urge you to use QuickDraw GX as your basic
imaging model if you can.
The example code you’ll see here is a simplified version of code written by Steve
Smith and Eric House. The good ideas are theirs; the mistakes are probably mine.
This is not intended to be working code, since error handling and some other pieces
have been left out for the sake of simplicity.
DRAWING A PART
Our first recipe tells how to draw a part. There are only a few simple steps here, for
the most basic case. Take a look at Listing 1 as we discuss the recipe. To keep things
as simple as possible, we’ll ignore scrolling and printing for the moment. The basic
steps are as follows:
1. Get the canvas of the facet you’re drawing into and set the
graphics port to that.
2. Get the content transform out of the facet and use it to set offset
information.
3. Get the aggregate clip shape out of the facet and use it to set the
clipping region.
4. Draw your content.
5. Clean up.
As you may have noticed, this is only slightly more complex than using the existing
window system. Luckily, all of the added complexity comes only in the setup code,
not in the actual drawing calls. Once the drawing environment has been set up,
you’re free to make the same drawing calls you always have.
Incidentally, there’s an easy way to get all of the correct setup code done for you: a
public utility called FocusLib, available as part of the OpenDoc Software
Development Kit, reduces the setup code you see in this and the following examples
to a single call. I didn’t use it here because I wanted you to see exactly what needs to
be done, just in case FocusLib doesn’t meet your precise requirements and you must
do it yourself. For instance, FocusLib is in C++, so not everyone can use it.
SCROLLING THE PART
Creating a scrolling part is only a bit more complex than making one that doesn’t
scroll. The best way to scroll in OpenDoc is to modify the internal transform of your
part’s display frame. This has the effect of automatically scrolling any embedded parts
that are visible right now, without any extra work on your part. Check out Listing 2,
d e v e l o p   Issue 21   March 1995 10

Printed dates: 1995

Languages: English

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

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