Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Imaging With QuickDraw /
Chapter 2 - Basic QuickDraw / Basic QuickDraw Reference
Routines / Managing Bitmaps, Port Rectangles, and Clipping Regions


To scroll the pixels of a specified portion of a basic graphics port's bitmap (or a color graphics port's pixel map), use the ScrollRect procedure.

PROCEDURE ScrollRect (r:\xDDRect; dh,dv: Integer; 
                      updateRgn: RgnHandle);
The rectangle defining the area to be scrolled.
The horizontal distance to be scrolled.
The vertical distance to be scrolled.
A handle to the region of the window that needs to be updated.
The ScrollRect procedure shifts pixels that are inside the specified rectangle of the current graphics port. No other pixels or the bits they represent are affected. The pixels are shifted a distance of dh horizontally and dv vertically. The positive directions are to the right and down. The pixels that are shifted out of the specified rectangle are not displayed, and the bits they represent are not saved. It is up to your application to save this data.

The empty area created by the scrolling is filled with the graphics port's background pattern, and the update region is changed to this filled area, as shown in Figure 2-8.

Figure 2-8 Scrolling the image in a rectangle by using the ScrollRect procedure

The ScrollRect procedure doesn't change the local coordinate system of the graphics port; it simply moves the rectangle specified in the r parameter to different coordinates. Notice that ScrollRect doesn't move the graphics pen or the clipping region. However, because the document has moved, they're in different positions relative to the document.

By creating an update region for the window, ScrollRect forces an update event. After using ScrollRect, your application should use its own window-updating code to draw into the update region of the window.

The ScrollRect procedure may move or purge memory blocks in the application heap. Your application should not call this procedure at interrupt time.

"Scrolling the Pixels in the Port Rectangle" beginning on page 2-18 provides a general discussion of the use of ScrollRect, and Listing 2-5 on page 2-19 illustrates how to use ScrollRect to scroll through a document in a window.

Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996