Specifications

Apple II Technical Notes
2 of 4 #74: Top Ten List Manager Things
Eight—Custom listDraw Routines and the Clip Region
The custom listDraw routine below speeds up your list when running System Software earlier than
6.0. The System 6.0 List Manager already calls your listDraw routine only for members that
will not be completely clipped (but this is still a good starting point if you’re writing a custom
listDraw routine for some other reason).
To scroll text, the List Manager calls ScrollRect to scroll the list—then 6.0 redraws the newly-
exposed members, and older versions redraw all the visible members. On small lists this is fine, but
on larger lists it can cause the redrawing of much data that is already on the screen, which can take
time. If your application does not require 6.0, you may want to use a custom listDraw routine
like this one.
First, we check the current clipRgn (which the List Manager was kind enough to shrink down to
include only the portion of the list that needs redrawing) against the passed item rectangle. If the
rectangle is in any way enclosed in the clipRgn, then the member is redrawn; otherwise the
routine simply returns to the List Manager without drawing. This sample routine is designed to
work only with Pascal-style strings, but it can be easily modified to use any other type of string you
choose.
MyListDraw Start
;
; This routine draws a list member if any part of the member's
; rectangle is inside the current clipRgn.
;
; Note that the Data Bank register is not defined on entry
; to this routine. If you use any absolute addressing, you
; must set B yourself and restore its value before exiting.
;
top equ 0
left equ top+2
bottom equ left+2
right equ bottom+2
rgnBounds equ 2
;
oldDPage equ 1
theRTL equ oldDPage+2
listHand equ theRTL+3
memPtr equ listHand+4
theRect equ memPtr+4
using globals
phd
tsc
tcd
pha
pha
_GetClipHandle
PullLong listHand
ldy #2
lda [listhand],y
tax
lda [listhand]
sta listhand
stx listhand+2
lda [therect] ; now test the top
dec a ; adjust and give a little slack
ldy #rgnbounds+bottom
cmp [listhand],y ; rgnRectBottom>=top?