[comp.sys.apple] Files, Windows, & Orca/Pascal

DWAYNE@VAXB.ACS.UNT.EDU (02/08/89)

I am in the middle of delving into the mysteries of the IIgs toolbox and more
exactly windows and their controls.  I read a file into a linked list so that
it is available in memory.  Then in the window content update procedure I dump
the file into the window a line at a time using QDII's DrawText call.  THe
problem is that the whole file gets redrawn whenever the window controls are
accessed or the window is resized.  For large files this can be a pain.  Does
anyone out there know of somw cute algorithm to redraw only that part of the
file that will be displayed?  It would certainly speed things up.  I'm writing
this in Orca/Pascal, but if you have any code at all (TML Basic, TML Pascal, or
Assembley Language) I'd like to take a look at it.  I know that there has to be
a better way.

thanks,
dwayne
-----------
BitNet : dwayne@untvaxa
ALPE : Dwayne Spr

keith@Apple.COM (Keith Rollin) (02/11/89)

In article <8902080513.aa00573@SMOKE.BRL.MIL> DWAYNE@VAXB.ACS.UNT.EDU writes:
>I am in the middle of delving into the mysteries of the IIgs toolbox and more
>exactly windows and their controls.  I read a file into a linked list so that
>it is available in memory.  Then in the window content update procedure I dump
>the file into the window a line at a time using QDII's DrawText call.  THe
>problem is that the whole file gets redrawn whenever the window controls are
>accessed or the window is resized.  For large files this can be a pain.  Does
>anyone out there know of somw cute algorithm to redraw only that part of the
>file that will be displayed?  It would certainly speed things up.  I'm writing
>this in Orca/Pascal, but if you have any code at all (TML Basic, TML Pascal, or
>Assembley Language) I'd like to take a look at it.  I know that there has to be
>a better way.
>
There is no "cute algorithm" - just good hard work.

When updating a window, you can look at the update region to see just what
parts need tobe redrawn. The beginning part of a region is defined as:

	region = RECORD
		rgnSize: WORD;
		rgnBBox: RECT;
		rgnData: {undocumented}
	END;

By looking at the rgnBBox - the smallest Rect that surrounds the region - you
can determine the extent of the parts of the window that need to be updated.
Based on this, you can examine your data and determine which parts fall 
within this rectangle. Using this method give significant speed improvements
over the "draw everything and let QuickDraw clip it for you" method.



------------------------------------------------------------------------------

Keith Rollin  ---  Apple Computer, Inc.  ---  Developer Technical Support
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your limitations, and sure enough...they're yours" -Bach, Illusions