creating the sea. er with • :- LScar . . . sets tile scan poslt1oo to a point ).1st before the first element In the Hst. If you Wf:Ilt to set al lnlta1 position 8'ld
SCII1J1I8ctlcn
use
themetlWJd
~.at=nm
tocreate
thesca.... eactl
execution Of the \rtt-LE loop
• AdvanceS value of LscaI.4JOSlUm by 1.
• sets
menDtr to the next. merJt)er of tile co1Jectkn When the coUecUmIs
a llst, IT'B11b8r Is al Object-reference. When theconecum
Is astrIrld
ora
ftJe, met ilber Is a CharaCter.
When thecollectkrl Is
ill may,men Iller Is
8 pointer to a recont
• RUlS the code In the \\MLE loop.
WIlen the scan position reactes a point )at after the last element In tne list
• s.scan
returns FPLSE.• mJ Is set
to ~for
Usts ,tn:Sarrays, or
~for stdr9
tn:S tiles.• The . . . er trees Itself.
LIsa Toolkit Referetr:e MI!n.JaJ U2Jject When tre JXJIPOSe of tne Itq) Is to
searcn
fOr a certain element, call s.Dnt When tne element being searched for Is fcx.n1 Tnen• The next s.Sca'l returns FALSE.
• me
object variable retains Its asSI{Jled value.• me sea ••
frees Itself.The following excrT1lle Illustrates the use of 8~"llStSca'n!r to peel
every
ba'la'laIn a tum Of t8lanas cnl reroove the rotten
ones.
If CIl tl'Grrtpe bancnllseroot.rlteretL ro more DCnrlaS are peeled
PROCE:l..RE 01eckBcnnIs (b.nn lUst ~ BilIJI$
VM
s:
TUstscaYm';b: TBalIJ lit BEGIN
s :-
tud\.Scamer; peatea sea. er
to SOCI'ltud\I
WHl..E s.sca(b) 00
for
~ b in tum dO:) BEGIN. b.Peel; ~1l b to P8elltself.) If b.l.merrIpe It£N b If It is tl'Grrtpe}
s.DoI'8 f so, force tne scan to terminate.) B..SE F b.mtten It£N ~ b If it is rotten.1
ENJ;
ENJ;
2JLl FUe8CaI. ers
s.Delete (1RLE); {If so, tell s to delete b from bl.nCh cnj free it.1
flle oojects, lIlllke oUler collectbl objects, C8'l only be ~
UlfOUC1\
scalers.
oroe
the flle8CaIl m Is created, fUrther refereooes to the file Object ~t as Ifthe contents of the fUe
were
a string stored CIl the heap. The CCIltents of thediSk file are rot moved to the
neap,
rowever (trey are pagedUlfOUC1\
bUffers In the OS), so file qlerat1<JlS can take l~r than string operations. If ro diskfile wltn the given rane exiSts, the file Is created When tne f1leScaner Is
created, CI'ld the tile Object acts like a'l8l'f1)ty
strq.
~ that the ToolKit does not explicitly tell yclJ Whether or rot the rue existed before you createdthe ft1eSaa I .,1.
LIsa ToolKIt RefeJa?ce MInJs/
~ YaJ-la:)les. t::ls:lara::llrll...D'W •••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 3--4.
3.6.1
Arittr1'letic CI1CJ LJtlllty
ClIJeratiCllS ••••••.•••••••••••••••••••••••••••••••••••••••••••••
3-6~ F~()I'lS. ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 3-7 3.7.2.1
MU1TlE!tic
(J"l Points ••••••••••••••••••••••••••••••••••••••••••••••••••••••••••• 3-7 3.7.2.2. Aritt1Tletlc 00 Recta'lgles •••••••••••••••••••••••••••••••••••••••••••••••••••• 3-9 3.7.2.3ClIJeratiCllS
CJI'l Recta'lgles •••••••••••••••••••••••••••••••••••••••••••••••••• 3-10 calculations with Recta'lgles a'ld Points - View COOrdinates ••••••••••••••• 3-11Draw1~
ClIJeratlO1S for
'Ilew CCJc)rtIlrlates •••••••••••••••••••••••••••••••••••••••• 3-12 3.7.4..1 L1rle--Orawlrlg Rootlrles •••••••••••••••••••••••• : ••••••••••••••••••••••••.••• 3-12 3.7.4.2 ~cClIJeratlO1S
CJrl Rec:ta'lgles •••••••••••••••••••••••••••••••••••••• 3-13 3.7 .4..3 ~cClIJeratlO1S
00ovals •••••••••••••••••••••••••••••••••••••••••••••.
3-133.7.4.4
GraJtllc OperatiCllS
CJrl ROU"Oed-Comer Recta'lgles •••••••••••••• 3-14 3.7 .4..5 ~cClIJerations on
Arcs a'ld wedges ... 3-15Liss ToolKIt RefenJnce !4InIaJ
3.1 Jnt.mcl£t.lm
LDraw provideS ~CS routines for draw~ In ToolKit prognms. It I1IJSt
be used wltn all ToolKlt appllcaUons. The fU1cUons l.Dr8W provideS 1nclll1e ,most Of the flroUCIlS provided by QulCkOraW,~.except trial l.Dr8W uses 32-blt
long integer (L~ coordinates instead of 16-blt Integer (INTEGER) ooordlnates. l.DraW also provideS a feW' extra ftmUms.
USing long integer coordlnates provideS coordlnates that cal IlVlge from -2147483648 (-231) to 2147483647 (~1-1~
However, no single
object calhaVe a size greater Ulan 215 In either dimenslcn
Thls Chapter assunes that you are fam11iar with the QuiCkOraW doclmentatlm, WhIch Is contained In the Pascal marual.
LDraw defines TAmIl,
w.t ...a
~TArea lrT1>lements methods for all parts of an ~UcaUm that draW til the
screen, including bOrdered
areas, sucn as
windowsaoo JBlBls.
w.t
wtllch Is a S\bClass of TArea, lrT1>lements methods that take InfOrmation arawn In al appllcatltll's view, alO alsplay It on tne screen.TBIaD\Area, WhICh Is also a SlbJlass of TArea, Is used Internally to maintain spl1ttaDle panels. Tnere Is a reference Sheet follBra1chAraa'1n Part II Of this mcn.aal. 'Because you dO not deal direcuy with tills class, It Is not discussed fUrther In tnls Chapter.
3.2 The PUlposes
or
lDnIWLDraw exists, for two maln p.Irposes. Flnt, it d8f1nes the baSic grapI'llcal structures that ~ter1Ze ToolKtt ClAlllcatlms:
ooraerea em
\I'C)Oraereascreen areas. S8cot'l(t l.Dr8W t.ra1s1ates graphics from ToolKit fonnats to fOrms tnat ccrt De
usea
by QUlCkOraW. QUlCkOraWmas
all on screenaraw1rYJ on
the Lisa.QuiCkDrS'fl al'N8YS draws In
a
grsfPort. A grafPOrtIs a
SOftware-defined port that cornects ya.ar appllcatltll'S ~ raJtlnes to the screen. When'you WEWlt to draW, you fDcUs the grafPorton some
part Of thescreen.
You rormally Ck) rot
neea
toworry
abOUtfOCUS1rYJ
In ToolKItprograns.
YWdraW in ywr view, using tile view ooordinate ~ rout1nes lrT1>1emented in LDraw nJ
aescrtDea
In tnts cnapt.er.sane
Of ywr-~lIcat1on's meVDlS are callao wltn thegratPort alrealy focused CIld ready to draW ina
pEnor m a
page. Otter metl'02S are callea fOr a Wfl)le pEnl, n:J ITUSt call t.ne metnod
~, 'Nhlctl fOcUses