You are on page 1of 1012

Apple Lisa Computer Technical Information

Apple Lisa ToolKit 3.0


Source Code Listing

This is a listing of all the Lisa ToolKit 3.0 source code files. These files are for the most part written in Lisa Clascal, an
object-oriented Pascal that Apple Computer created from its Lisa Pascal compiler. Other source code languages exist
here too which includes the Lisa Workshop EXEC language (the BUILD files are in this) and various 68000 assembly
language sources such as LIBPL/CLASLIB.TEXT.
For detailed information about the Lisa ToolKit see Apple's extensive ToolKit documentation which includes the Lisa
ToolKit Reference Manual, a Clascal primer, and a ToolKit tutorial.Tmagazine's 1984 article "Software Frameworks"
which describes the ToolKit architecture and its various core classes.
Apple Lisa ToolKit 3.0 Source Code Listing -- 1 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: " ToolKit 3.0 Source Catalog"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043
000044

APPLE LISA TOOLKIT 3.0 SOURCE CODE DISK CATALOG LISTINGS


========================================================
This document contains catalog listings of the 4 disks which held all the
source code files for the Lisa ToolKit 3.0 object library.
Document prepared by David T. Craig -- March 1993
+---------------------------------------------------------------------------| TOOLKIT SOURCE DISK # 1
+---------------------------------------------------------------------------Filename
-------libpl/CLASLIB.TEXT
libpl/UCLASCAL.TEXT
libtk/UABC.TEXT
libtk/UABC2.TEXT
libtk/UABC3.TEXT
LIBTK/UABC4.TEXT

Size Psize
---- ----12288
24
45056
88
69632
136
93184
182
66560
130
61440
120

Last-Mod-Date
------------02/06/84-11:01
08/29/84-14:49
08/29/84-15:08
08/17/84-11:25
08/17/84-11:27
08/17/84-11:29

Creation-Date
------------02/06/84-11:01
04/02/84-16:44
04/26/84-12:02
05/18/84-19:28
05/07/84-17:57
05/07/84-18:04

Attr
---C
C

680 total blocks for files listed


28 blocks of OS overhead for volume and files listed
76 blocks free out of 772
+---------------------------------------------------------------------------| TOOLKIT SOURCE DISK # 2
+---------------------------------------------------------------------------Filename
-------LIBTK/UABC5.TEXT
libtk/UDIALOG.TEXT
libtk/UDIALOG2.TEXT
libtk/UDIALOG3.TEXT
libtk/UDIALOG4.TEXT
libtk/UDRAW.TEXT

Size Psize
---- ----95232
186
44032
86
78848
154
61440
120
37888
74
22528
44

Last-Mod-Date
------------08/17/84-11:32
08/17/84-15:20
08/17/84-15:29
08/17/84-15:23
04/25/84-18:58
08/29/84-15:06

Creation-Date
------------05/07/84-18:03
04/26/84-13:23
04/25/84-16:28
04/25/84-18:01
04/25/84-18:58
05/01/84-15:07

Attr
----

664 total blocks for files listed


28 blocks of OS overhead for volume and files listed
92 blocks free out of 772
+----------------------------------------------------------------------------

Apple Lisa ToolKit 3.0 Source Code Listing -- 2 of 1012

Apple Lisa Computer Technical Information


000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091
000092

| TOOLKIT SOURCE DISK # 3


+---------------------------------------------------------------------------Filename
-------libtk/Udraw2.TEXT
LIBTK/UOBJECT.TEXT
libtk/UOBJECT2.TEXT
libtk/UOBJECT3.TEXT
libtk/UOBJECT4.TEXT
libtk/utext.text

Size Psize
---- ----54272
106
43008
84
55296
108
70656
138
76800
150
33792
66

Last-Mod-Date
------------08/16/84-19:13
08/29/84-14:57
08/17/84-14:01
08/17/84-14:03
08/17/84-14:07
08/17/84-15:53

Creation-Date
------------05/07/84-18:02
05/16/84-08:57
05/01/84-15:50
04/30/84-13:17
04/30/84-14:26
04/26/84-13:03

Attr
---C
C
C

652 total blocks for files listed


28 blocks of OS overhead for volume and files listed
104 blocks free out of 772
+---------------------------------------------------------------------------| TOOLKIT SOURCE DISK # 4
+---------------------------------------------------------------------------Filename
-------BUILD/ASSEMB.TEXT
BUILD/COMP.TEXT
BUILD/INSTALL.TEXT
BUILD/MAKE/ATKLIB.TEXT
build/make/Ctk2lib.text
BUILD/MAKE/CTKLIB.TEXT
build/make/Ltk2lib.text
BUILD/MAKE/LTKLIB.TEXT
BUILD/MAKE/TKLIB.TEXT
INTERFACE/PASLIBC...TEXT
INTERFACE/PASSWD.TEXT
INTERFACE/PPASLIBC.TEXT
LIBPL/PASLIBCALL.OBJ
LIBPL/PPASLIBC.OBJ
libtk/passwd.OBJ
libtk/UTEXT2.TEXT
libtk/UTEXT3.TEXT
LIBTK/UTEXT4.TEXT
LIBTK/UUNIVTEXT.TEXT
libtk/XFER.TEXT
LIBUT/UUNIVTEXT2.TEXT
UFIXUTEXT.TEXT

Size Psize
---- ----2048
4
2048
4
2048
4
2048
4
2048
4
2048
4
2048
4
2048
4
2048
4
3072
6
2048
4
3072
6
2560
5
2560
5
1536
3
58368
114
63488
124
102400
200
13312
26
10240
20
71680
140
12288
24

Last-Mod-Date
------------12/12/83-18:55
08/16/84-13:20
08/16/84-13:20
02/02/84-15:47
02/24/84-15:50
08/16/84-13:20
08/16/84-13:21
08/16/84-13:21
08/27/84-11:06
11/13/85-13:56
11/13/85-13:17
11/13/85-13:59
04/04/84-14:07
04/04/84-14:08
08/16/84-13:47
08/17/84-15:55
08/17/84-15:56
08/17/84-15:58
08/29/84-17:12
04/25/84-20:36
05/23/84-09:49
08/15/84-13:10

Creation-Date
------------12/12/83-18:55
09/21/83-14:49
05/15/84-14:58
02/02/84-15:47
02/24/84-15:50
02/24/84-15:50
04/26/84-11:31
05/01/84-15:23
02/24/84-15:51
11/13/85-13:18
11/13/85-13:17
11/13/85-13:18
04/04/84-14:07
04/04/84-14:08
08/16/84-13:47
04/25/84-17:01
05/21/84-09:25
05/21/84-09:30
05/18/84-15:29
04/25/84-20:36
05/18/84-17:44
08/14/84-17:23

Attr
----

713 total blocks for files listed


44 blocks of OS overhead for volume and files listed
27 blocks free out of 772

Apple Lisa ToolKit 3.0 Source Code Listing -- 3 of 1012

Apple Lisa Computer Technical Information


000093
000094
000095

THAT'S ALL, FOLKS !

End of File -- Lines: 95 Characters: 4680

Apple Lisa ToolKit 3.0 Source Code Listing -- 4 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "BUILD/ASSEMB.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029

$EXEC
{Assemble a module }
{filename build/assemb.text}
$
${ %0 -- pathname of the module to assemble}
${ %1 -- (optional) pathname of the resulting object file. Default name is %0}
${ %2 -- (optional) segment name for the resulting object file. Default is 'blank' segment}
$
$IF %0='' THEN
$WRITE 'File To Assemble? '
$READLN %0
$IF %1='' THEN
$WRITE "Name For Object File [<cr> For %0]? "
$READLN %1
$IF %2='' THEN
$WRITE 'Segment Name [<cr> For Blank Segment]? '
$READLN %2
$ENDIF
$ENDIF
$ENDIF
$DEFAULT %1 to %0
A{ssemble}%0
{source file}
{no listing file}
%1
{object file}
$IF %2<>'' THEN
R{un}changeseg
{re-assign segmentation (optional)}
%1
y%2
$ENDIF
$ENDEXEC

End of File -- Lines: 29 Characters: 744

Apple Lisa ToolKit 3.0 Source Code Listing -- 5 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "BUILD/COMP.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028

$EXEC
{Compile and Code Generate a Pascal Unit}
{filename build/comp.text}
$
${ %0 -- pathname of the unit to compile}
${ %1 -- (optional) pathname of the resulting object file. Defaults to %0}
${
Destroys file 'temp/c.i'}
${ %2 -- (optional) pathname of intrinsic.lib. Defaults to -#boot-intrinsic.lib}
$
$IF %0='' THEN
$WRITE 'File To Compile? '
$READLN %0
$IF %1='' THEN
$WRITE "Name For Object File [<cr> For %0]? "
$READLN %1
$IF %2='' THEN
$WRITE 'Name Of Intrinsic.lib [<cr> For -#boot-intrinsic.lib]? '
$READLN %2
$ENDIF
$ENDIF
$ENDIF
$DEFAULT %1 TO %0
$DEFAULT %2 TO '-#boot-intrinsic.lib'
P{ascal Compile}?{option flag}
%2
{intrinsic.lib}
%0
{source file}
{no listing file}
%1
{object file}
$ENDEXEC

End of File -- Lines: 28 Characters: 818

Apple Lisa ToolKit 3.0 Source Code Listing -- 6 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "BUILD/INSTALL.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032

$EXEC
{Install a Library in Intrinsic.lib}
{filename build/install.text}
$
${ %0 -- number of the library to install}
${ %1 -- (optional)pathname for input intrinsic.lib. Defaults to }
${
-#boot-intrinsic.lib}
${ %2 -- (optional) pathname for output intrinsic.lib. Defaults to %1}
$
$IF %0='' THEN
$WRITE 'Number Of The Library To Install? '
$READLN %0
$IF %1='' THEN
$WRITE 'Pathname For Input Intrinsic.lib [<cr> For -#boot-intrinsic.lib]? '
$READLN %1
$IF %2='' THEN
$WRITE 'Pathname For Output Intrinsic.lib [<cr> For -#boot-intrinsic.lib]? '
$READLN %2
$ENDIF
$ENDIF
$ENDIF
$DEFAULT %1 TO '-#boot-intrinsic.lib'
$DEFAULT %2 TO %1
R{un}IUmanager
%1
%2
I{nstall}%0
QY
$
F{ile-MGR}B{ackup}%2,$
Q{uit}
$ENDEXEC

End of File -- Lines: 32 Characters: 744

Apple Lisa ToolKit 3.0 Source Code Listing -- 7 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "BUILD/MAKE/ATKLIB.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006

$EXEC {BUILD/MAKE/ATKLIB -- Assemble modules needed by the Toolkit}


F{ile-Mgr}D{elete}LIBTK/XFER.OBJ
Y{es}Q{uit}
$SUBMIT BUILD/ASSEMB(LIBTK/XFER)
$ENDEXEC

End of File -- Lines: 6 Characters: 150

Apple Lisa ToolKit 3.0 Source Code Listing -- 8 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "BUILD/MAKE/CTK2LIB.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014

$EXEC {BUILD/MAKE/CTKLIB -- Compile units needed by the Toolkit}


F{ile-Mgr}
D{elete}LIBTK/UUNIVTEXT.OBJ
Y{es}
D{elete}LIBTK/UTEXT.OBJ
Y{es}
D{elete}LIBTK/UDIALOG.OBJ
Y{es}
Q{uit}
$SUBMIT BUILD/COMP(LIBTK/UUNIVTEXT)
$SUBMIT BUILD/COMP(LIBTK/UTEXT)
$SUBMIT BUILD/COMP(LIBTK/UDIALOG)
$ENDEXEC

End of File -- Lines: 14 Characters: 277

Apple Lisa ToolKit 3.0 Source Code Listing -- 9 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "BUILD/MAKE/CTKLIB.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013

$EXEC {BUILD/MAKE/CTKLIB -- Compile units needed by the Toolkit}


F{ile-Mgr}D{elete}LIBTK/UOBJECT.OBJ
Y{es}
D{elete}LIBTK/UDRAW.OBJ
Y{es}
D{elete}LIBTK/UABC.OBJ
Y{es}
Q{uit}
$SUBMIT BUILD/COMP(LIBTK/UOBJECT)
$SUBMIT BUILD/COMP(LIBTK/UDRAW)
$SUBMIT BUILD/COMP(LIBTK/UABC)
$ENDEXEC

End of File -- Lines: 13 Characters: 267

Apple Lisa ToolKit 3.0 Source Code Listing -- 10 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "BUILD/MAKE/LTK2LIB.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035

$EXEC {BUILD/MAKE/LTKLIB -- Link the Toolkit}


F{ile-Mgr}D{elete}-#boot-TK2LIB.OBJ
Y{es}Q{uit}
L{ink}?
+i
+m TKUTInit SgTxtIni
+m DlgInit SgTxtIni
+m DlgAlloc SgTxtIni
+m SgTxtHot SgTxtRes
+m TK2Start SgParRes
+m SgTxtWrm SgParRes
+m DlgText SgTxtRes
+m SgTxtCld SgTxtTwo
+m DlgDbg SgDIAdbg
+m DlgHot SgDialog
+m DlgRes SgDialog
+m DlgCold SgDialog
+m DlgWarm SgDialog
+m HdgMarg SgDialog
+m DlgLayou SgLayout
+m TKUTWrit TKUT
+m TKUTMain TKUT
LIBTK/UUNIVTEXT
LIBTK/UTEXT
LIBTK/UDIALOG
-#boot-TKLIB
-#boot-IOSPASLIB
-#boot-SYS1LIB
{no more input files}
{no listing file}
-#boot-TK2LIB
$SUBMIT BUILD/INSTALL(11)
$ENDEXEC

End of File -- Lines: 35 Characters: 586

Apple Lisa ToolKit 3.0 Source Code Listing -- 11 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "BUILD/MAKE/LTKLIB.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

$EXEC {BUILD/MAKE/LTKLIB -- Link the Toolkit}


F{ile-Mgr}D{elete}-#boot-TKLIB.OBJ
Y{es}Q{uit}
L{ink}?
+i
+M SgCLAres SgABCdat
+M SgCLAcld SgABCdat
+M sABCdat SgABCdat {remove}
+M sSplit SgABCdat
+M sRes SgDRWres
+M sClick SgDRWres {SgABCdat}
+M sFilter SgDRWres {SgABCdat}
+M SgXFER SgABCres
+M sHotUtil SgABCres {?}
+M sStartup SgABCres
+M sResDat SgABCres
+M sCommand SgDRWres {SgABCdat}
+M sCmd2 SgABCres
+M sScroll SgABCres
+M sLOX SgCLAini
+M sError SgABCdbg
+M Override SgCLAini
+M sCldInit SgCLAdbg
+M sInit1 SgABCini
+M sAlert SgABCcld
+M sUtil SgCLAdbg
+M sCut SgABCdat
+M sPaste SgABCdat
LIBTK/UOBJECT
LIBTK/UDRAW
LIBTK/UABC
LIBTK/XFER
-#BOOT-IOSPASLIB
-#BOOT-IOSFPLIB
-#BOOT-SYS1LIB
-#BOOT-PRLIB
{no more input files}
{no listing file}
-#BOOT-TKLIB
$SUBMIT BUILD/INSTALL(10)
$ENDEXEC

Apple Lisa ToolKit 3.0 Source Code Listing -- 12 of 1012

Apple Lisa Computer Technical Information


End of File -- Lines: 43 Characters: 753

Apple Lisa ToolKit 3.0 Source Code Listing -- 13 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "BUILD/MAKE/TKLIB.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009

$EXEC {BUILD/MAKE/TKLIB -- build the Toolkit}


$SUBMIT BUILD/ASSEMB(LIBPL/CLASLIB)
$SUBMIT BUILD/COMP(LIBPL/UCLASCAL)
$SUBMIT BUILD/MAKE/ATKLIB
$SUBMIT BUILD/MAKE/CTKLIB
$SUBMIT BUILD/MAKE/LTKLIB
$SUBMIT BUILD/MAKE/CTK2LIB
$SUBMIT BUILD/MAKE/LTK2LIB
$ENDEXEC

End of File -- Lines: 9 Characters: 249

Apple Lisa ToolKit 3.0 Source Code Listing -- 14 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "INTERFACE/PASLIBCALL.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{ libpl/paslibcall interface }
intrinsic;
interface
USES
{$U libos/syscall.obj }

syscall;

{ -----------------------------------------------------------------------------------}
CONST
CclearScreen
CclearEScreen
CclearELine
CgoHome
CleftArrow
CrightArrow
CupArrow
CdownArrow

= 1;
= 2;
= 3;

{clear the whole screen}


{clear to the end of the screen}
{clear to end of line}

=
=
=
=
=

{move
{move
{move
{move
{move

11;
12;
13;
14;
15;

cursor
cursor
cursor
cursor
cursor

to home position}
left one character position}
right one character position}
up one line position}
down one line position}

{ -----------------------------------------------------------------------------------}
function PAbortFlag : boolean;

{Apple-period entered or not}

PROCEDURE GetGPrefix (Var prefix : pathname); {get global working directory}


procedure ScreenCtr (contrfun : integer); {standard screen control functions}
procedure GetPrDevice (var PrDevice : e_name);
function PaslibVersion : integer;

{return PASLIB version}

PROCEDURE PTranLisaChar (toTranslate : boolean);

{to translate Lisa char when print}

{ Optional Call To Initialize the Heap }


procedure PLINITHEAP(var ernum,refnum: integer; size,delta: longint;
ldsn: integer; swapable: boolean);
implementation
{ FINIS }

Apple Lisa ToolKit 3.0 Source Code Listing -- 15 of 1012

Apple Lisa Computer Technical Information


000044
End of File -- Lines: 44 Characters: 1480

Apple Lisa ToolKit 3.0 Source Code Listing -- 16 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "INTERFACE/PASSWD.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{ libtk/passwd interface }
INTRINSIC;
{Provides calls for Password Protection in the Lisa Toolkit}
{ Copyright 1983, 1984, Apple Computer Inc. }
INTERFACE
USES {$U -#BOOT-SYSCALL} syscall;
procedure MAKE_SECURE ( var ecode : integer;
var path
: pathname;
var passwd : e_name );
procedure KILL_SECURE ( var ecode : integer;
var path
: pathname;
var passwd : e_name );
procedure OPEN_SECURE ( var ecode
var path
var refnum
manip
var passwd
procedure RENAME_SECURE ( var
var
var
var

:
:
:
:
:

integer;
pathname;
integer;
mset;
e_name );

ecode
path
newName
passwd

:
:
:
:

integer;
pathname;
e_name;
e_name );

procedure VERIFY_PASSWORD ( var ecode : integer;


var path
: pathname;
var passwd : e_name );
procedure CHANGE_PASSWORD ( var
var
var
var

ecode
path
oldPasswd
newPasswd

:
:
:
:

integer;
pathname;
e_name;
e_name );

IMPLEMENTATION

Apple Lisa ToolKit 3.0 Source Code Listing -- 17 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046

{ FINIS }

End of File -- Lines: 46 Characters: 1416

Apple Lisa ToolKit 3.0 Source Code Listing -- 18 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "INTERFACE/PPASLIBC.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{ libpl/ppaslibc interface }
intrinsic; interface
USES {$U libos/syscall.obj } syscall;
type
consoledest = (alscreen, mainscreen, xsorocA, xsorocB, folder, spare1, spare2, spare3); { max 8 }
dsProcCode = (dsResProg, dsSoftPwbtn, dsPrintDev, dsSetGPrefix, dsEnbDisk, dsGetDiskEnbF);
dsProcParam = record
case ProcCode : dsProcCode of
dsResProg
: (RProcessId : longint); {must be called before
the process starts running.}
dsSoftPwbtn : (SPButton : boolean);
{result}
dsPrintDev
: (PrDevice : e_name);
dsSetGPrefix : (errnum : INTEGER; prefix : pathname); {result}
dsEnbDisk
: (toEnbDisk : boolean);
dsGetDiskEnbF : (diskEnbF : boolean);
{result}
end;
{ ------ Procedures called by Shell only, some by WorkShop Shell only ---------------- }
PROCEDURE BlockIOInit;

{entire blockio unit init, once per system}

procedure BlockIOdisinit;

{blockio unit clean up, called by shell only}

procedure lockPaslib (var errnum : integer); {lock PASLIB1 for Filer}


procedure lockPasiolib (var errnum : integer); {lock PASIOLIB for Filer }
procedure moveconsole (var errnum : integer; applconsole : consoledest);
PROCEDURE ExecReset (VAR errnum : INTEGER; VAR execfile : pathname;
stopexec : BOOLEAN);
{open/stop exec file}
FUNCTION ExecFlag : BOOLEAN;

{return TRUE if EXEC file is active}

PROCEDURE OutputRedirect (VAR errnum : INTEGER; VAR outfile : pathname;


stopoutput : BOOLEAN); {open/stop output file}
FUNCTION OutputRFlag : BOOLEAN;

{return true if output is redirected}

procedure DSPaslibCall (VAR ProcParam : dsProcParam); {by Workshop Shell only}

Apple Lisa ToolKit 3.0 Source Code Listing -- 19 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047

implementation
{ FINIS }

End of File -- Lines: 47 Characters: 2018

Apple Lisa ToolKit 3.0 Source Code Listing -- 20 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBPL/CLASLIB.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

; UNIT CLASLIB; {Copyright 1984, Apple Computer, Inc.}


;
;
;
;
;
;
;
;

{changed
{changed
{changed
{changed

02/06/84
01/20/84
01/18/84
01/09/84

1530
1530
0732
2105

%_Method must swap in caller}


IUJSR decoded corrected}
Fixed BEQ bug in %_CallMethod & renamed it %_MethodCall}
Separated from XFER so we can include it in PASLIB
SgPASres: %_CallMethod, %_Super, %GoLisaBug;
SgPASini: %_JmpTo, %_ExitCaller, %_ExitPoppingTo, %_GetA5,
%_NextMethod; %_InsStack
Added an argument to %_ExitPoppingTo}

;=============================================================================================
DEBUGF .EQU 1
; 1 to include $D+ info, 0 to exclude it
;=============================================================================================
.MACRO HEAD
.IF DEBUGF
LINK
A6,#0
MOVE.L (SP)+,A6
.ENDC
.ENDM

; These two instructions form a slow no-op

.MACRO TAIL
.IF DEBUGF
UNLK
A6
RTS
.ASCII %1
.ENDC
.ENDM
;=============================================================================================
.SEG
'SgPASres'
;=============================================================================================
.PROC
HEAD

%_GoLisabug

; PROCEDURE %_GoLisabug;
TRAP
RTS

#0

Apple Lisa ToolKit 3.0 Source Code Listing -- 21 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

TAIL

'%_GOLISA'

;=============================================================================================
.FUNC
HEAD

%_GetA5

;
; FUNCTION %_GetA5: LONGINT;
;
; USES A0
;
MOVE.L (SP)+,A0
MOVE.L A5,(SP)
JMP
(A0)
TAIL

{ returns register A5 }

; GET RETURN ADDRESS


; STORE A5 INTO RETURN SLOT
; EASY, HUH?

'%_GETA5 '

;=============================================================================================
.PROC %_MethodCall
HEAD
;
;

PROCEDURE %_MethodCall;

; 157 cycles or about 32 microseconds for a regular call

uses A0,A1,D0,D1,D2
MOVE.L
TST.B

(SP)+,A1
(A1)

;08
;08

A1 := Return Address
Swap in caller

MOVE
MOVE.B
LSL.W

#0,D0;
(A1)+,D0
#2,D0

;04
;08
;10

D0 := Level Number (0-origin)

MOVE
MOVE.B
LSL.W

#0,D1;
(A1)+,D1
#2,D1

;04
;08
;10

D1 := Method Number (1-origin)

MOVE.L

A1,-(SP)

;13

Return Address := A1 (which has been incremented by 2)

MOVE.L

4(SP),A0

;16

A0 := SELF

.IF DEBUGF
MOVE.L
BEQ
.ENDC

A0,D2
SELFNIL

;04
;08

MOVEA didn't set condition codes


Error if NIL (next line fails anyway, but we could give a better msg}

MOVE.L

(A0),A0

;12

A0 := master pointer of SELF

Change to a byte offset

Change to a byte offset

Apple Lisa ToolKit 3.0 Source Code Listing -- 22 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

MOVE.L

(A0),A0

MOVE.L
MOVE.L

$00(A0,D0.W),A0 ;18
-4(A0,D1.W),A0 ;18

A0 := method table pointer for the desired level


A0 := method address

JMP

(A0)

;08

Jump to method

#0,D0

**Temporary** Error report

SELFNIL DIVS
TAIL

;12

A0 := slice table pointer of SELF's class

'%_METHOD'

;=============================================================================================
.PROC %_SUPER
HEAD
;
;

PROCEDURE %_Super;

; 199 cycles or about 44 microseconds for SUPERSELF (chain dist = 1)

uses A0,A1,D0,D1,D2
MOVE.L

(SP)+,A1

;08

A1 := Return Address

MOVE
MOVE.B
LSL.W

#0,D1
1(SP),D1
#2,D1

;04
;12
;10

D1 := Method Number (1-origin)

MOVE
MOVE.B
LSL.W

#0,D0
(SP)+,D0
#2,D0

;04
;08
;10

D0 := Level Number (0-origin)


Increments SP by 2!!
Change to a byte offset

MOVE.W
MOVE.L

(SP)+,D2
(SP)+,A0

;08
;12

Chain distance
Slice table pointer of this class

MOVE.L

A1,-(SP)

;13

Return Address := A1 (which has not been modified)

JMP

ENDSUPL

;10

SUPLOOP MOVE.L -4(A0),A0


ENDSUPL DBEQ
D2,SUPLOOP

;16
;10-14

Change to a byte offset

A0 := superclass slice table pointer


Loop until chain distance has been traversed (or end of chain)

MOVE.L
MOVE.L

$00(A0,D0.W),A0 ;18
-4(A0,D1.W),A0 ;18

A0 := method table pointer for the desired level


A0 := method address

JMP

(A0)

;08

Jump to method

**Temporary** Error report

SELFNIL DIVS #0,D0


TAIL

'%_SUPER '

Apple Lisa ToolKit 3.0 Source Code Listing -- 23 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

;=============================================================================================
.SEG
'SgPASini'
;=============================================================================================
.PROC %_JMPTO
HEAD
;
;

PROCEDURE %_JmpTo(pc: LONGINT);


uses A0
MOVE.L (SP)+,A0
MOVE.L (SP)+,A0
JMP (A0)
TAIL

; Pop Return address and ignore it


; Pop pc argument
; Jump there

'%_JMPTO '

;=============================================================================================
.PROC %_EXITCA
HEAD
;
;

PROCEDURE %_ExitCaller;

that is, exit the caller of my caller, undoing two LINKs

modifies A6,SP
UNLK
UNLK
RTS

A6
A6

.IF DEBUGF
.ASCII '%_EXITCA'
.ENDC
;=============================================================================================
.PROC %_EXITPO
HEAD
;
;
;

PROCEDURE %_ExitPoppingTo(newSP: LONGINT);


exit my caller, and cut back the stack of the next frame to newSP
uses A0,A1 and modifies A6,SP
MOVE.L

4(A6),A0

; A0 := caller's return address

Apple Lisa ToolKit 3.0 Source Code Listing -- 24 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

MOVE.L
UNLK
MOVE.L
JMP

4(SP),A1
A6
A1,SP
(A0)

; A1 := newSP
; pop my caller's stack frame
; SP := newSP

.IF DEBUGF
.ASCII '%_EXITPO'
.ENDC
;=============================================================================================
.FUNC %_NextMethod
HEAD
;
;
;

FUNCTION

%_NextMethod(VAR pc@12: LONGINT;


VAR impLevelNumber@8, impMethNumber@4: INTEGER
)@16: ProcPtr;

uses A0,A1,D0
MOVE.L
MOVE.L
TST.B

12(SP),A0
(A0),A1
(A1)

; @PC
; PC throughout this routine
; swap in the code to test

INTRPLP CMP.W
BEQ
CMP.W
BEQ
CMP.B
BEQ
CMP.W
BEQ
DIVS

#$4EBA,(A1)
JSR_PC
#$4EAD,(A1)
JSR_A5
#$A0,(A1)
INTJSR
#$3F3C,(A1)
PSHCON
#0,D0

; test for JSR PC+d

PSHCON

MOVE.W
MOVE.B
MOVE.L
MOVE.W

#0,D0
2(A1),D0
8(SP),A0
D0,(A0)

;
;
;
;

Clear
D0 :=
A0 :=
store

MOVE.W
MOVE.B
SUB.W
MOVE.L
MOVE.W

#0,D0
3(A1),D0
#1,D0
4(SP),A0
D0,(A0)

;
;
;
;
;

Clear D0 before loading a byte into it


D0 := the "Lo" of JSR PC+HiLo, i.e., methodNumber
decrement methodNumber (will be re-incremented by FINJSR)
A0 := @methodNumber
store methodNumber-1 from D0

ADD.L
JMP

#4,A1
INTRPLP

; increment PC past MOVE

; test for JSR d(A5)


; test for IUJSR
; test for MOVE.W #nn,-(SP)
; supposedly impossible
D0 before loading a byte into it
the "Hi" of JSR PC+HiLo, i.e., levelNumber
@levelNumber
levelNumber from D0

Apple Lisa ToolKit 3.0 Source Code Listing -- 25 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

INTJSR

MOVE.L
AND.L
MOVE.L

(A1),D1
#$FFFFFF,D1
D1,A0

; D1 := IUJSR xxx
; D1 := targetLocation
; A0 := targetLocation

FINJSR

MOVE.L

A0,16(SP)

; function result := targetLocation

ADD.L
MOVE.L
MOVE.L

#4,A1
12(SP),A0
A1,(A0)

; increment PC past JSR


; @PC
; store back incremented PC

MOVE.L
ADD.W

4(SP),A0
#1,(A0)

; A0 := @methodNumber
; increment methodNumber

MOVE.L
ADD.L
JMP

(SP)+,A0
#12,SP
(A0)

; pop and save return address


; pop and discard arguments
; return

JSR_PC

MOVE.W
LEA
JMP

2(A1),D0
2(A1,D0.W),A0
FINJSR

; D0 := the "d" of JSR PC+d


; A0 := targetLocation

JSR_A5

MOVE.W
LEA
JMP

2(A1),D0
0(A5,D0.W),A0
FINJSR

; D0 := the "d" of JSR d(A5)


; A0 := targetLocation

TAIL

'%_NEXTME'

;=============================================================================================
.FUNC %_InsStack
HEAD
;
;
;
;
;
;

PROCEDURE %_InsStack(addrToInsertAt, bytesToInsert: LONGINT);

uses A0,A1,D0,D1,D2; modifies A6,A7 and static chain

This routine must be used with extreme care. It inserts space in the middle of the stack.
It adjusts A6, A7, and the static chain, but it can not adjust other pointers that may
exist into the moved area; that is the responsibility of the caller.
This assumes that at least one static link needs adjustment

MOVE.L
MOVE.L
MOVE.L

(SP)+,D2
(SP)+,D1
(SP)+,D0

; D2 := Return address
; D1 := bytesToInsert: must be even and at least 4
; D0 := addrToInsertAt: must be even

SUB.L
SUB.W
LSR.W

SP,D0
#2,D0
#2,D0

; D0 := how many bytes need to move


; D0.W := how many longs
;
... need to move

Apple Lisa ToolKit 3.0 Source Code Listing -- 26 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311

INSLP

ADJLP

MOVE.L
SUB.L
MOVE.L

SP,A0
D1,SP
SP,A1

; A0 := Old SP
; SP := ultimate SP
; A1 := ultimate SP

TST.W

-1024(SP)

; Make the OS expand the stack if necessary

MOVE.L
DBF

(A0)+,(A1)+
D0,INSLP

; Move the data

SUB.L
MOVE.L

D1,A6
A6,A1

; A6 := ultimate A6
; A1 := addr of first static link

SUB.L
MOVE.L
MOVE.L
CMP.L
BLT

D1,(A1)
(A1),A1
(A1),D0
A0,D0
ADJLP

;
;
;
;
;

MOVE.L
JMP

D2,A1
(A1)

; A1 := Return address
; Return and Pray

TAIL

'%_INSSTA'

adjust this static link


A1 := addr of next static link
D0 := value of that static link
If (value of that static link - first unmoved addr)
< 0 then that static link needs adjusting, too

;=============================================================================================
.END

End of File -- Lines: 311 Characters: 10279

Apple Lisa ToolKit 3.0 Source Code Listing -- 27 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBPL/UCLASCAL.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{UClascal -- In Spring '84 Release, part of PASLIB: only special units like UOBJECT will ever USE it}
{Copyright 1984, Apple Computer, Inc.}
{changed 04/02/84 1330
{changed
{changed
{changed
{changed
{changed
{changed

02/23/84
02/22/84
02/19/84
01/18/84
01/18/84
01/15/84

1200
1715
1908
2348
0737
1725

{changed 01/12/84 1952


{changed 01/12/84 1525
{changed
{changed
{changed
{changed
{

01/11/84
01/11/84
01/10/84
01/05/84

1714
1312
2117
2141

Before exiting %_PGM2, see if the compiler saved A7 away, and if so


change the value to account for the method tables on the stack.}
%_InObCp/Cn: Make them work before classesInitialized, too}
CiToCn: Make it work before classesInitialized, too}
SizeOfCp & CiOfCp: Make them work before classesInitialized, too}
LookupInHashArray returns -index instead of -1 for failure, 0 for full table}
Renamed %_CallMethod to %_MethodCall so LisaBug traces mean more to people}
ObjectSize is always positive now, so QClassSize has been eliminated;
TOctet & TPOctets to INTERFACE}
Added TOctets and used it to get around signed byte bugs}
Added fTrcClascal to turn off extra writeLns when not debugging this unit;
%_InObCp/Cn mask off high byte of object's stp before testing quality}
Fixed a bunch of bugs}
Added DumpArrays}
More moved to UObject so apps don't have to USE this unit}
Began Construction}

RESPONSIBILITIES...
The first class-init block is responsible for calling our procedure:
InitClascal(PROCEDURE Finished(error: INTEGER));
If no other class has already called it, then pleaseInitClascal will be TRUE, in case interested.
If an error occurs during initialization and InitClascal has been called, we'll call:
Finished(error);
The error code is an OS error code, except 3333 (need a new number!!!!) is our own error;
If an error occurs during initialization and InitClascal has not been called, we
do a Trap 0, which should get into LisaBug if present, else cause Technical Difficulties.
Just before returning from %_Pgm2, if FinishedProc is installed, we'll call:
Finished(0);
which may want to copy tables from pClasses, pSTables, pAuthors, pAliases (interface globals)
Typecast errors will also call Finished(3333) (need a new number!!!!)

}
{$SETC ForOS := TRUE }

Apple Lisa ToolKit 3.0 Source Code Listing -- 28 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

UNIT UClascal;
{$SETC IsIntrinsic := TRUE }
{$IFC IsIntrinsic}
INTRINSIC;
{$ENDC}
INTERFACE
USES
{$U -#BOOT-SysCall
{$SETC fTrcClascal
{$SETC fSymClascal
{$SETC fDbgClascal

} SysCall;

:= FALSE}
:= TRUE}{FALSE}
:= TRUE}{FALSE}

{$%+}
CONST
maxClasses
maxUnits

= 800;
= 100;

{Hash table sizes}

maxAuthors
maxAliases

= 127;
= 127;

{Because their indices are encoded in one byte in TClassInfo}

TYPE
TByte = -128..127; {The T-names are so programs can USE UObject, NOT USE UClascal, and use "Byte"}
TOctet = 0..255;
TOctets = PACKED ARRAY [0..32700] OF TOctet;
TPOctets = ^TOctets;
TS8 = STRING[8];
TS32 = STRING[32];
TA8 = PACKED ARRAY [1..8] OF CHAR;
TA32 = PACKED ARRAY [1..32] OF CHAR;
THashCompare = (cHole, cMatch, cMismatch);
TMethodArray = ARRAY [1..256] OF LONGINT;

Apple Lisa ToolKit 3.0 Source Code Listing -- 29 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

TPMethodArray = ^TMethodArray;
TSliceTable = ARRAY [0..255] OF TPMethodArray;
TPSliceTable = ^TSliceTable;
TClassInfo = RECORD
classAlpha:
superIndex:
objectSize:
classAlias:
companyAndAuthor:
version:
oldestReadableVersion:
END;

{16 bytes
TA8;
INTEGER;
INTEGER;
TByte;
TByte;
TByte;
TByte;

per class}
{Class name in this program: Exactly 8 upper-case characters}
{Index of my superclass in ARRAY [1..xx] OF TClassInfo}
{SIZEOF(an object of this class) as declared}
{For ToolKit: Array index, or 0 if same as classAlpha}
{For ToolKit: Array index, or 0 if unspecified}
{For ToolKit: Version number of the object format (default=1)}
{For ToolKit: Oldest version number it is capable of updating}

{Each of the following types has only one member at run-time, and only during initialization}
{These arrays start out small, but can grow. Each has a single pointer that is updated automatically}
TClassArray
TPClassArray

= ARRAY [1..maxClasses] OF TClassInfo;


= ^TClassArray;

TSTableArray
TPSTableArray

= ARRAY [1..maxClasses] OF TPSliceTable;


= ^TSTableArray;

TAuthorArray
TPAuthorArray

= ARRAY [1..maxAuthors] OF TA32;


= ^TAuthorArray;

TAliasArray
TPAliasArray

= ARRAY [1..maxAliases] OF TA8;


= ^TAliasArray;

VAR
pleaseInitClascal: BOOLEAN;
classesInitialized: BOOLEAN;

{does InitClascal need to be called by some SUBCLASS OF NIL?}


{has %_Pgm2 completed?}

pClasses:
pSTables:
pAuthors:
pAliases:
pMethods:

TPClassArray;
TPSTableArray;
TPAuthorArray;
TPAliasArray;
TPMethodArray;

{pointer to array of
{.................of
{.................of
{.................of
{.................of

limClasses:
limAuthors:
limAliases:
limMethods:

INTEGER;
INTEGER;
INTEGER;
INTEGER;

{space allocated in
{................in
{................in
{................in

numClasses:

INTEGER;

{number of elements in pClasses^ & pSTables^}

TClassInfo,
TPSliceTable,
TA32,
TA8,
ProcPtr,

or NIL after %_Pgm2}


..........}
..........}
..........}
..........}

pClasses^ & pSTables^}


pAuthors^}
pAliases^}
pMethods^}

Apple Lisa ToolKit 3.0 Source Code Listing -- 30 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

numAuthors:
numAliases:
numMethods:

INTEGER;
INTEGER;
INTEGER;

{...................in pAuthors^}
{...................in pAliases^}
{...................in pMethods^

... now or last time they existed}

{Called from class-initialization blocks}


PROCEDURE InitClascal(PROCEDURE FinishedProc(error: INTEGER));

{required from first class-init}

PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

{required once per unit with ToolKit}


{optional}
{optional}
{optional}

QUnitAuthor(VAR companyAndAuthor: TA32);


QClassAuthor(VAR companyAndAuthor: TA32);
QClassAlias(VAR classAlias: TA8);
QClassVersion(itsVersion, oldestItCanRead: TByte);

{Called from version-conversion, allocation, and debugging code}


PROCEDURE CiToCn(index: INTEGER; VAR className: TS8);
PROCEDURE CpToCn(stp: TPSliceTable; VAR className: TS8);

{convert class index to class title S8}


{convert stp to class title S8}

FUNCTION
FUNCTION

CiOfCp(stp: TPSliceTable): INTEGER;


SizeOfCp(stp: TPSliceTable): INTEGER;

{convert stp to class index}


{convert stp to object size}

FUNCTION

LookupInHashArray(tblSize: INTEGER; hashKey: LONGINT; toInsert: BOOLEAN;


FUNCTION Compare(index: INTEGER): THashCompare): INTEGER;
CallPC: LONGINT;

FUNCTION

{Called by code generated by the compiler}


PROCEDURE %_Pgm1;
{Called before the first unit is initialized}
PROCEDURE %_Unit;
{Called at the beginning of each unit-initialization block}
PROCEDURE %_Class(itsClassName, itsSuperName: TS8; itsSTP: TPSliceTable; itsEvenMethods, itsOddMethods,
itsObjSize: INTEGER); {Called at the beginning of each class-initialization block}
PROCEDURE %_Pgm2;
{Called after the last unit is initialized}
{These both return their first argument if it is NIL or passes a class-membership check; else Finished(3333) }
FUNCTION %_CkObCP(ordObject, ordSTP: LONGINT): LONGINT;
{TFoo(obj),
TFoo in same unit }
FUNCTION %_CkObCN(ordObject: LONGINT; VAR className: TS8): LONGINT; {TFoo(obj),
TFoo in other unit}
{These both return TRUE if their first arg is NON-NIL and if it passes a class-membership check}
FUNCTION %_InObCP(ordObject, ordSTP: LONGINT): BOOLEAN;
{InClass(obj, TFoo), TFoo in same unit }
FUNCTION %_InObCN(ordObject: LONGINT; VAR className: TS8): BOOLEAN; {InClass(obj, TFoo), TFoo in other unit}
IMPLEMENTATION

Apple Lisa ToolKit 3.0 Source Code Listing -- 31 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

{Segments: SgPASini(tialize and Terminate), SgPASres(ident)}


{$R-}
{$IFC fSymClascal}
{$D+}
{$ELSEC}
{$D-}
{$ENDC}
CONST
minClasses
minAuthors
minAliases
minMethods

=
=
=
=

1;
1;
1;
1;

{Initial array sizes}

growClasses
growAuthors
growAliases
growMethods

=
=
=
=

100;
8;
32;
2000;

{Array growth increments (tunable)}

TYPE
TS255 = STRING[255];
TPA8 = ^TA8;
TPA32 = ^TA32;
TBytes = ARRAY [0..32700] OF TByte;
TPBytes = ^TBytes;
TWords = ARRAY [0..16350] OF INTEGER;
TPWords = ^TWords;
TPOctet = ^TOctet;
TPByte = ^TByte;
TPInt = ^INTEGER;
TPLint = ^LONGINT;
Handle = ^TPLint;
ProcPtr = ^LONGINT;
TIdxArray = ARRAY [0..maxClasses] OF INTEGER;
TPIdxArray = ^TIdxArray;

{Element 0 is length; holes contain 0}

Apple Lisa ToolKit 3.0 Source Code Listing -- 32 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

TUnitArray = ARRAY [0..maxUnits] OF LONGINT;


TPUnitArray = ^TUnitArray;

{Element 0 is length; holes contain 0}

VAR
biggestAbstractClass:
mAllocAddr:
currCallCallPC:

INTEGER;
LONGINT;
LONGINT;

{max number of methods among all entirely abstract slices, or 1}


{last allocated location in the method table}
{the callPC of the unit whose classes are being initted}

pHashName:
pHashUnit:

TPIdxArray;
TPUnitArray;

{index of a class in pClasses & pSTables, or 0 for a hole}


{pc of %_Unit caller, or 0 if a hole}

p%_Class:
pJmp%_Class:

ProcPtr;
ProcPtr;

{@ %_Class -- a pointer to the first instruction}


{...same, but a pointer to the jump table entry}

pFinishedProc:
authorOfUnit:
oldNumClasses:

ProcPtr;
TByte;
INTEGER;

{@ FinishedProc passed in to InitClascal or @ DefaultFinishedProc}


{Set by UnitAuthor and cleared by EndPreviousUnit}
{numClasses at the beginning of this unit's initialization}

firstPackedName:
dictBase:

INTEGER;
LONGINT;

{Set in %_Pgm2; see FindCn for explanation}


{Ditto}

{The following are assembler routines in CLASLIB.TEXT}


FUNCTION %_GetA5: LONGINT; EXTERNAL;
FUNCTION %_NextMethod(VAR pc: LONGINT;
VAR impLevelNumber, impMethNumber: INTEGER
): ProcPtr; EXTERNAL;
PROCEDURE %_JmpTo(pc: LONGINT); EXTERNAL;
PROCEDURE %_ExitCaller(argBytes: INTEGER); EXTERNAL;
PROCEDURE %_ExitPoppingTo(newSP: LONGINT); EXTERNAL;
PROCEDURE %_MethodCall; EXTERNAL;
PROCEDURE %_GoLisaBug; EXTERNAL;
PROCEDURE %_InsStack(addrToInsertAt, bytesToInsert: LONGINT); EXTERNAL;

{input and inc'd by 4 or 8}


{input and output both}

{$S SgPASres}
FUNCTION FindCn(index: INTEGER; VAR charsApart: BOOLEAN): LONGINT;
{The class names starting with index=firstPackedName are stored packed below the method table,
so the 8-character names start 8 bytes apart.
The class names before index=firstSpreadName are stored in the unused high-order
bytes of the method table, one every fourth byte, so the 8-character names start
32 bytes apart. This kludge saves 1-2K of resident storage in a ToolKit application.
The name of the first class ends just before dictBase, the second class precedes it, etc.}
VAR firstCharOffset: LONGINT;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 33 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

charsApart := index < firstPackedName;


IF charsApart THEN
firstCharOffset := index * 32
ELSE
firstCharOffset := (numMethods * 4) + ((index + 1 - firstPackedName) * 8);
FindCn := dictBase - firstCharOffset;
END;
FUNCTION CiOfCp(stp: TPSliceTable): INTEGER;
VAR index: INTEGER;
{After init, the class index is recorded in the slice table, bytes 0 and 4 (high and low order bytes)}
BEGIN
CiOfCp := 0;
IF classesInitialized THEN
CiOfCp := 256 * TPOctets(stp)^[0] + TPOctets(stp)^[4]
ELSE
FOR index := 1 TO numClasses DO
IF pSTables^[index] = stp THEN
CiOfCp := index;
END;
FUNCTION SizeOfCp(stp: TPSliceTable): INTEGER;
{After init, the size is recorded in the slice table, bytes 8 and 12, unless there are only 2 slices,}
{..in which case the long before the slice table has a -1 in the even word and the object size
in the odd word, instead of a superlink}
BEGIN
IF NOT classesInitialized THEN
SizeOfCp := pClasses^[CiOfCp(stp)].objectSize
ELSE
IF TPWords(stp)^[-2] <= 0 THEN
SizeOfCp := TPWords(stp)^[-1]
ELSE
SizeOfCp := 256 * TPOctets(stp)^[8] + TPOctets(stp)^[12];
END;
PROCEDURE CiToCn(index: INTEGER; VAR className: TS8);
VAR charsApart: BOOLEAN;
deltaAddr: INTEGER;
dictAddr:
LONGINT;
i:
INTEGER;
classAlpha: TA8;
BEGIN
className[0] := CHAR(8);
IF NOT classesInitialized THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 34 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

classAlpha := pClasses^[index].classAlpha;
FOR i := 1 TO 8 DO
className[i] := classAlpha[i];
END
ELSE
BEGIN
dictAddr := FindCn(index, charsApart);
deltaAddr := 3*ORD(charsApart) + 1;
FOR i := 1 TO 8 DO
BEGIN
className[i] := CHAR(TPByte(dictAddr)^);
dictAddr := dictAddr + deltaAddr;
END;
END;
END;
PROCEDURE CpToCn(stp: TPSliceTable; VAR className: TS8);
BEGIN
CiToCn(CiOfCp(stp), className);
END;
PROCEDURE DefaultFinishedProc(error: INTEGER);
BEGIN
%_GoLisabug;
END;
PROCEDURE CallFinishedProc(PROCEDURE ModelFinishedProc(error: INTEGER); error: INTEGER);
VAR pModelFinishedProc: TPLint;
BEGIN
pModelFinishedProc := TPLint(ORD(@pModelFinishedProc) + 18);
pModelFinishedProc^ := ORD(pFinishedProc);
ModelFinishedProc(error);
END;
PROCEDURE CLAFail(error: INTEGER);
BEGIN
IF error = 0 THEN
error := 3333;
CallFinishedProc(DefaultFinishedProc, error);
END;
{$IFC fDbgClascal}
PROCEDURE CLABreak(s: TS255; n: LONGINT);

{Called when fDbgClascal is FALSE}


{GET A NUMBER ASSIGNED}

{Called when fDbgClascal is TRUE}

Apple Lisa ToolKit 3.0 Source Code Listing -- 35 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

BEGIN
WriteLn('CLABreak: ', s, ' = ', n);
ClaFail(0);
END;
{$ENDC}
{Each expression "InClass(obj, TFoo)" generates:
%_InObCp(val, classPtr) or %_InObCn(val, 'TFOO
')
The former ("In Object Class Pointer") is generated when TFoo is defined in the same unit.
The latter ("In Object Class Name") is generated when TFoo is defined in another unit.
Both are defined below}
FUNCTION %_InObCp(ordObject, ordSTP: LONGINT): BOOLEAN;
TYPE
PST = ^TST;
TST = ARRAY[0..0] OF PST;
PPST = ^PST;
PPPST = ^PPST;
VAR trialSTP:
PST;
pSTP:
PPST;
BEGIN
%_InObCp := FALSE;
IF ordObject <> 0 THEN
BEGIN
trialSTP := PPPST(ordObject)^^;
pSTP := @trialSTP;
TPByte(pSTP)^ := 0;
WHILE trialSTP <> PST(ordSTP) DO
BEGIN
IF classesInitialized THEN
trialSTP := trialSTP^[-1]
ELSE
trialSTP := PST (TPMethodArray(pSTables^[pClasses^[CiOfCp(TPSliceTable(trialSTP))].superIndex]));
IF ORD(trialSTP) <= 0 THEN
EXIT(%_InObCp);
END;
%_InObCp := TRUE;
END;
END;
FUNCTION %_InObCn(ordObject: LONGINT; VAR className: TS8): BOOLEAN;
TYPE
PST = ^TST;
TST = ARRAY[0..0] OF PST;
PPST = ^PST;
PPPST = ^PPST;
VAR trialSTP:
PST;
tryClassName:
TS8;

Apple Lisa ToolKit 3.0 Source Code Listing -- 36 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

pSTP:
PPST;
BEGIN
%_InObCn := FALSE;
IF ordObject <> 0 THEN
BEGIN
trialSTP := PPPST(ordObject)^^;
pSTP := @trialSTP;
TPByte(pSTP)^ := 0;
REPEAT
CpToCn(TPSliceTable(trialSTP), tryClassName);
IF tryClassName = className THEN
BEGIN
%_InObCn := TRUE;
EXIT(%_InObCn);
END;
IF classesInitialized THEN
trialSTP := trialSTP^[-1]
ELSE
trialSTP := PST(TPMethodArray(pSTables^[pClasses^[CiOfCp(TPSliceTable(trialSTP))].superIndex]));
UNTIL ORD(trialSTP) <= 0;
END;
END;
{Each typecast expression TFoo(val) with range checking on generates:
%_CkObCp(val, classPtr) or %_CkObCn(val, 'TFOO
')
The former ("Check Object Class Pointer") is generated when TFoo is defined in the same unit.
The latter ("Check Object Class Name") is generated when TFoo is defined in another unit.
Both are defined below}
FUNCTION %_CkObCp(ordObject, ordSTP: LONGINT): LONGINT;
VAR objClassName:
TS8;
desClassName:
TS8;
BEGIN
%_CkObCp := ordObject;
IF ordObject <> 0 THEN
IF NOT %_InObCp(ordObject, ordSTP) THEN
BEGIN
CpToCn(TPSliceTable(Handle(ordObject)^^), objClassName);
CpToCn(TPSliceTable(ordSTP), desClassName);
{$IFC fDbgClascal}
CLABreak(CONCAT('Attempt to coerce an object of class ',
CONCAT(objClassName,
CONCAT(' to a value of type ',
desClassName))),
0);
{$ELSEC}
CLAFail(0);

Apple Lisa ToolKit 3.0 Source Code Listing -- 37 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

END;

{$ENDC}
EXIT(%_CkObCp);
END;

FUNCTION %_CkObCn(ordObject: LONGINT; VAR className: TS8): LONGINT;


VAR objClassName:
TS8;
BEGIN
%_CkObCn := ordObject;
IF ordObject <> 0 THEN
IF NOT %_InObCn(ordObject, className) THEN
BEGIN
CpToCn(TPSliceTable(Handle(ordObject)^^), objClassName);
{$IFC fDbgClascal}
CLABreak(CONCAT('Attempt to coerce an object of class ',
CONCAT(objClassName,
CONCAT(' to a value of type ',
className))),
0);
{$ELSEC}
CLAFail(0);
{$ENDC}
EXIT(%_CkObCn);
END;
END;
{MUST BE IN A DIFFERENT SEGMENT FROM %_Class, i.e., NOT IN SgPASini}
FUNCTION GetPJmp%_Class: ProcPtr;
BEGIN
GetPJmp%_Class := @%_Class;
END;
{$S SgPASini}
PROCEDURE InitClascal(PROCEDURE FinishedProc(error: INTEGER));
BEGIN
pFinishedProc
:= @FinishedProc;
pleaseInitClascal := FALSE;
END;
PROCEDURE StoreCn(index: INTEGER; VAR classAlpha: TA8);
VAR charsApart: BOOLEAN;
dictAddr:
LONGINT;

Apple Lisa ToolKit 3.0 Source Code Listing -- 38 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

i:
INTEGER;
BEGIN
dictAddr := FindCn(index, charsApart);
IF charsApart THEN
FOR i := 1 TO 8 DO
BEGIN
TPByte(dictAddr)^ := TByte(classAlpha[i]);
dictAddr := dictAddr + 4;
END
ELSE
TPA8(dictAddr)^ := classAlpha;
END;
PROCEDURE _Abstract;
BEGIN
{$IFC fDbgClascal}
CLABreak('An ABSTRACT method has been called: you can''t continue', 0);
{$ELSEC}
CLAFail(0);
{$ENDC}
END;
PROCEDURE InsStack(addrOfGrownArray, afterByte, bytesToInsert: LONGINT);
PROCEDURE AdjustPArray(VAR addrOfOtherArray: LONGINT; which: TS32);
BEGIN
{$IFC fTrcClascal}
Write('... ', which, ' moved from ', addrOfOtherArray:12, ' to ');
{$ENDC}
IF (addrOfGrownArray + afterByte) >= addrOfOtherArray THEN
addrOfOtherArray := addrOfOtherArray - bytesToInsert;
{$IFC fTrcClascal}
WriteLn(addrOfOtherArray:12);
{$ENDC}
END;
BEGIN
{$IFC fTrcClascal}
WriteLn('$$$ About to insert ', bytesToInsert:4, ' bytes after byte ', afterByte:3,
' of ', addrOfGrownArray:5, '$$$');
{$ENDC}
%_InsStack(addrOfGrownArray + afterByte, bytesToInsert); {bytesToInsert must be even and at least 4}
AdjustPArray(LONGINT(pAuthors), 'pAuthors');
AdjustPArray(LONGINT(pAliases), 'pAliases');
AdjustPArray(LONGINT(pClasses), 'pClasses');
AdjustPArray(LONGINT(pSTables), 'pSTables');

Apple Lisa ToolKit 3.0 Source Code Listing -- 39 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

AdjustPArray(LONGINT(pMethods), 'pMethods');
AdjustPArray(LONGINT(pHashName),'pHashName');
AdjustPArray(LONGINT(pHashUnit),'pHashUnit');
END;
FUNCTION MAllocate(numNeeded, numToGrowBy: INTEGER): LONGINT;
{** NO VAR PARAMETERS ALLOWED THAT ARE REFERENCED AFTER CALLING InsStack **}
VAR numBytes:
LONGINT;
bytesToInsert: LONGINT;
BEGIN
numBytes := 4 * numNeeded;
mAllocAddr := mAllocAddr - numBytes;
MAllocate := mAllocAddr;
bytesToInsert := ORD(pMethods) - mAllocAddr;
IF bytesToInsert > 0 THEN
BEGIN
IF bytesToInsert < (4 * numToGrowBy) THEN
bytesToInsert := 4 * numToGrowBy;
InsStack(ORD(pMethods), 0, bytesToInsert);
END;
{$IFC fTrcClascal}
WriteLn('******* Allocated ', numNeeded:3, ' method entries at ', mAllocAddr:5, '********');
{$ENDC}
END;
FUNCTION RAllocate(bytesPerRec, numNow, numToGrowBy, numRoomFor, maxNumAllowed: INTEGER;
whutzits: TS8; ordPArray: LONGINT): INTEGER;
{** NO VAR PARAMETERS ALLOWED THAT ARE REFERENCED AFTER CALLING InsStack **}
{bytesPerRec must be even; this function returns the new numRoomFor value}
VAR bytesToInsert: INTEGER;
BEGIN
IF (numRoomFor + numToGrowBy) > maxNumAllowed THEN
numToGrowBy := maxNumAllowed - numRoomFor;
IF numToGrowBy <= 0 THEN
{$IFC fDbgClascal}
CLABreak(CONCAT('Too many ', whutzits), maxNumAllowed);
{$ELSEC}
CLAFail(0);
{$ENDC}
bytesToInsert := bytesPerRec * numToGrowBy;
InsStack(ordPArray, bytesPerRec * numNow, bytesToInsert);
RAllocate := numRoomFor + numToGrowBy;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 40 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

FUNCTION LookupAuthor(VAR classAuthor: TA32): INTEGER;


{There should be room for two Authors (a ClassAuthor & a UnitAuthor) because %_Class checked}
VAR addr:
LONGINT;
i:
INTEGER;
BEGIN
addr := ORD(pAuthors);
FOR i := 1 TO numAuthors DO
BEGIN
IF TPA32(addr)^ = classAuthor THEN
BEGIN
LookupAuthor := i;
EXIT(LookupAuthor);
END;
addr := addr + 32;
END;
IF numAuthors >= limAuthors THEN
CLAFail(0)
ELSE
BEGIN
numAuthors := numAuthors + 1;
TPA32(addr)^ := classAuthor;
LookupAuthor := numAuthors;
END;
END;
{** I tried merging the routines above and below, but I don't think it is worth it **}
FUNCTION LookupAlias(VAR classAlias: TA8): INTEGER;
{There should be room for one alias because %_Class checked}
VAR addr:
LONGINT;
i:
INTEGER;
BEGIN
addr := ORD(pAliases);
FOR i := 1 TO numAliases DO
BEGIN
IF TPA8(addr)^ = classAlias THEN
BEGIN
LookupAlias := i;
EXIT(LookupAlias);
END;
addr := addr + 8;
END;
IF numAliases >= limAliases THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 41 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

CLAFail(0)
ELSE
BEGIN
numAliases := numAliases + 1;
TPA8(addr)^ := classAlias;
LookupAlias := numAliases;
END;
END;
PROCEDURE QUnitAuthor(VAR companyAndAuthor: TA32);
BEGIN
IF classesInitialized THEN
CLAFail(0);
authorOfUnit := LookupAuthor(companyAndAuthor);
END;
PROCEDURE QClassAuthor(VAR companyAndAuthor: TA32);
BEGIN
{Must call procedures before the WITH because Lookups might move pClasses^}
IF classesInitialized THEN
CLAFail(0);
pClasses^[numClasses].companyAndAuthor := LookupAuthor(companyAndAuthor);
END;
PROCEDURE QClassAlias(VAR classAlias: TA8);
BEGIN
{Must call procedures before the WITH because Lookups might move pClasses^}
IF classesInitialized THEN
CLAFail(0);
pClasses^[numClasses].classAlias := LookupAlias(classAlias);
END;
PROCEDURE QClassVersion(itsVersion, oldestItCanRead: TByte);
BEGIN
IF classesInitialized THEN
CLAFail(0);
WITH pClasses^[numClasses] DO
BEGIN
version := itsVersion;
oldestReadableVersion := oldestItCanRead;
END;
END;
FUNCTION NumSlices(classIndex: INTEGER): INTEGER;
VAR n: INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 42 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

BEGIN
n := 0;
WHILE classIndex > 0 DO
BEGIN
classIndex := pClasses^[classIndex].superIndex;
n := n + 2;
END;
NumSlices := n;
END;
FUNCTION CallCallPC: LONGINT;
VAR dummy:
INTEGER;
{ must be first local and two bytes long }
BEGIN
CallCallPC := TPLint(TPLint(TPLint(ORD(@dummy) + 2)^)^ + 4)^;
{caller's caller's return address}
END;
FUNCTION CallPC: LONGINT;
VAR dummy:
INTEGER;
{ must be first local and two bytes long }
BEGIN
CallPC := TPLint(TPLint(ORD(@dummy) + 2)^ + 4)^;
{caller's return address}
END;
PROCEDURE SetCallPC(pc: LONGINT);
VAR dummy:
INTEGER;
{ must be first local and two bytes long }
addrOfPC:
LONGINT;
BEGIN
addrOfPC := TPLint(ORD(@dummy) + 2)^ + 4;
TPLint(addrOfPC)^ := pc;
{caller's return address}
END;
FUNCTION LookupInHashArray(tblSize: INTEGER; hashKey: LONGINT; toInsert: BOOLEAN;
FUNCTION Compare(index: INTEGER): THashCompare): INTEGER;
{toInsert, return: -index if entry already there, index (>0) if a hole found}
{not toInsert, return: index (> 0) if entry found, -index if not there}
{return 0 if table is full}
VAR probe:
INTEGER;
origProbe:
INTEGER;
hashCompare:
THashCompare;
BEGIN
{This could be made faster -- and probably should be}
LookupInHashArray := 0;
probe := hashKey;
probe := (ABS(probe) MOD tblSize) + 1;
origProbe := probe;
REPEAT

Apple Lisa ToolKit 3.0 Source Code Listing -- 43 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

END;

hashCompare := Compare(probe);
IF hashCompare <> cMismatch THEN
BEGIN
IF toInsert = (hashCompare = cHole) THEN
LookupInHashArray := probe
ELSE
LookupInHashArray := - probe;
EXIT(LookupInHashArray);
END;
probe := probe + 1;
IF probe > tblSize THEN
probe := 1;
UNTIL probe = origProbe;

{$IFC fTrcClascal}
PROCEDURE DumpArrays;
VAR index:
INTEGER;
itsSTP:
TPSliceTable;
slices:
INTEGER;
s:
TS8;
j:
INTEGER;
i:
INTEGER;
level:
INTEGER;
methArrPtr:
TPMethodArray;
numAtThatLevel: INTEGER;
BEGIN
WriteLn;
WriteLn(' *************** ARRAYS *************** ');
WriteLn;
FOR index := 1 TO numClasses DO
BEGIN
Write('Class Index = ', index:3);
itsSTP := pSTables^[index];
Write(' Class Pointer = ', ORD(itsSTP):10);
slices := NumSlices(index);
Write(' Number of slices = ', slices:3);
s[0] := CHAR(8);
FOR j := 1 TO 8 DO
s[j] := pClasses^[index].classAlpha[j];
WriteLn(' Name = ', s);
i := index;
FOR level := slices - 1 DOWNTO 0 DO
BEGIN
Write('
Level ', level:1);
Write('
Index ', i:2);

Apple Lisa ToolKit 3.0 Source Code Listing -- 44 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

methArrPtr := itsSTP^[level];
Write(' Method array ptr = ', ORD(methArrPtr):10);
numAtThatLevel := TPWords(pSTables^[i])^[ORD(ODD(level))-2];
Write(' numAtThatLevel ', numAtThatLevel:2);
IF methArrPtr = NIL THEN
WriteLn(', ... all Abstract')
ELSE
BEGIN
WriteLn;
FOR j := 1 TO numAtThatLevel DO
WriteLn(j:10, ORD(methArrPtr^[j]):10);
END;

END;
{$ENDC}

IF NOT ODD(level) THEN


i := pClasses^[i].superIndex;
WriteLn;
END;
WriteLn;
END;

{The main program starts with:


JSR %_Pgm1
; Defined below
JSR unit#m
; for every unit USEd by the main program within $CLASSES+ (in order USEd)...
...
JSR unit#n
JSR %_Pgm2
; Defined below}
PROCEDURE %_Pgm1;
VAR methads:
aliases:
authors:
sTables:
classes:
{The arrays above
excepName:
error:
addr:
i:
hashUnit:
hashName:

ARRAY [1..minMethods] OF ProcPtr;


{!!! MUST MUST MUST be the first VAR !!!}
ARRAY [1..minAliases] OF TA8;
{!!! Should be in this group of VARs !!!}
ARRAY [1..minAuthors] OF TA32;
{!!! Should be in this group of VARs !!!}
ARRAY [1..minClasses] OF TPSliceTable;{!!! Should be in this group of VARs !!!}
ARRAY [1..minClasses] OF TClassInfo; {!!! Should be in this group of VARs !!!}
can grow; only one ptr to each is maintained in a global variable, e.g., pMethods}
T_Ex_Name;
{These all stay allocated until the end of %_Pgm2}
INTEGER;
LONGINT;
INTEGER;
TUnitArray;
TIdxArray;

BEGIN
{Install Default Finished procedure}

Apple Lisa ToolKit 3.0 Source Code Listing -- 45 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

pFinishedProc := @DefaultFinished;
{Initialize global interface variables}
pleaseInitClascal := TRUE;
classesInitialized := FALSE;

{A global set to FALSE in InitClascal}


{A global set TRUE in %_Pgm2}

pClasses := @classes;
pSTables := @sTables;
pAuthors := @authors;
pAliases := @aliases;
pMethods := @methads;
{methads spelled funny because METHODS is a reserved word}
{NOTE: pMethods^[] is never written; the "ARRAY" can be > 32K bytes if necessary}
limClasses
limAuthors
limAliases
limMethods

:=
:=
:=
:=

minClasses;
minAuthors;
minAliases;
minMethods;

numClasses
numAuthors
numAliases
numMethods

:=
:=
:=
:=

0;
0;
0;
0;

{incremented by
{never modified
{never modified
{incremented by

%_Class}
in this unit; UOBJECT manages them}
in this unit; UOBJECT manages them}
FillArraysFrom, called by %_Class}

{Set the scheduling mode}


Sched_Class(error, TRUE);
IF error > 0 THEN
CLAFail(error);
{Set six bytes at 0(A5) to JMP %_MethodCall in XFER}
addr := %_GetA5;
TPInt(addr)^ := $4EF9; {JMP fullAddr}
addr := addr + 2;
TPLint(addr)^ := ORD(@%_MethodCall);
{Clear hash tables}
FOR i := 1 TO maxUnits DO
hashUnit[i] := 0;
FOR i := 1 TO maxClasses DO
hashName[i] := 0;
{Initialize global implementation variables}
pHashName
pHashUnit

:= @hashName;
:= @hashUnit;

authorOfUnit := 0;
mAllocAddr := ORD(pMethods) + limMethods * 4;

Apple Lisa ToolKit 3.0 Source Code Listing -- 46 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

biggestAbstractClass := 1;
currCallCallPC := 0;

{Could be 0, but this produces a more comprehensible memory dump}

p%_Class
:= @%_Class;
pJmp%_Class := GetPJmp%_Class;

{The %_NextMethod loop in %_Class stops at a JSR %_Class}


{A function in another segment must get the jump table address for me}

{We can never return because we need our locals around during the unit initializations and need
the method tables around forever}
%_JmpTo(CallPC);
END;
PROCEDURE EndPreviousUnit; {We don't require companyAndAuthor--but client could do so at the end of %_Pgm2}
VAR i: INTEGER;
BEGIN
IF authorOfUnit <> 0 THEN
FOR i := oldNumClasses + 1 TO numClasses DO
WITH pClasses^[i] DO
IF companyAndAuthor = 0 THEN
companyAndAuthor := authorOfUnit;
authorOfUnit := 0;
oldNumClasses := numClasses;
END;
PROCEDURE %_Pgm2;
{** NO VAR PARAMETERS ALLOWED THAT ARE REFERENCED AFTER CALLING MAllocate **}
VAR dummy:
LONGINT; {MUST BE FIRST VAR AND 4 BYTES LONG!!!}
pAbstracts:
TPMethodArray;
index:
INTEGER;
extraLongs:
LONGINT;
itsSTP:
TPSliceTable;
slices:
INTEGER;
level:
INTEGER;
objSize:
INTEGER;
pInt:
TPInt;
pLint:
TPLint;
BEGIN
EndPreviousUnit;
{For any slice that was fully abstract, we will make it point at a special block of @_Abstract}
pAbstracts := TPMethodArray(MAllocate(biggestAbstractClass, 16));
numMethods := numMethods + biggestAbstractClass;
FOR index := 1 TO biggestAbstractClass DO
pAbstracts^[index] := ORD(@ _Abstract);
{Assure sufficient room for names}
dictBase := mAllocAddr + (numMethods * 4);

Apple Lisa ToolKit 3.0 Source Code Listing -- 47 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

firstPackedName := (numMethods DIV 8) + 1;


extraLongs := 2 * (numClasses - firstPackedName + 1);
IF extraLongs > 0 THEN
dummy := MAllocate(extraLongs, 0);
{$IFC fTrcClascal}
WriteLn('biggestAbstractClass
WriteLn('numMethods allocated
WriteLn('firstPackedName
WriteLn('extraLongs
WriteLn('mAllocAddr
WriteLn('dictBase
WriteLn('pClasses
WriteLn('pSTables
{$ENDC}

=
=
=
=
=
=
=
=

',
',
',
',
',
',
',
',

biggestAbstractClass:6);
numMethods:6);
firstPackedName:6);
extraLongs:6);
mAllocAddr:6);
dictBase:6);
ORD(pClasses):6);
ORD(pSTables):6);

{Search back from call to %_PGM2 for a MOVE.L A7, xxxx(A5) (opcode $2B4F); if found, calculate the
address that contains the saved A7 and stuff in mAllocAddr instead. Stop searching if we
find a LINK A5, xxxx instruction.}
pLint := Pointer(Ord(@dummy) + 8); {pLint^ should be our return address}
pInt := Pointer(pLint^);
WHILE (pInt^ <> $2B4F {MOVE.L A7, xxxx(A5)}) AND (pInt^ <> $4E55 {LINK A5, xxxx}) DO
pInt := Pointer(Ord(pInt) - 2);
IF pInt^ = $2B4F THEN
BEGIN
pInt := Pointer(Ord(pInt) + 2);
pLint := Pointer(pInt^ + %_GetA5);
pLint^ := mAllocAddr;
END;
{Final initialization of each class in turn}
FOR index := 1 TO numClasses DO
BEGIN
{Fill in missing slices}
itsSTP := pSTables^[index];
slices := NumSlices(index);
FOR level := 0 TO slices - 1 DO
IF itsSTP^[level] = NIL THEN
itsSTP^[level] := pAbstracts;
{Copy the name to the method table area}
StoreCn(index, pClasses^[index].classAlpha);
{The class index is recorded in the slice table, bytes 0 and 4 (high and low order bytes)}
{The object size is recorded in the slice table, bytes 8 and 12, unless there are only two slices,}
{..in which case the long before the slice table has a -1 in the even word and the object size
in the odd word, instead of a superlink}

Apple Lisa ToolKit 3.0 Source Code Listing -- 48 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

objSize := pClasses^[index].objectSize;
IF slices > 2 THEN
BEGIN
TPOctets(itsSTP)^[8] := TPOctets(@objSize)^[0];
TPOctets(itsSTP)^[12] := TPOctets(@objSize)^[1];
itsSTP^[-1] := TPMethodArray(pSTables^[pClasses^[index].superIndex]);
END
ELSE
BEGIN
TPWords(itsSTP)^[-2] := -1;
TPWords(itsSTP)^[-1] := objSize;
END;
TPOctets(itsSTP)^[0] := TPOctets(@index)^[0];
TPOctets(itsSTP)^[4] := TPOctets(@index)^[1];
END;
{Report success to higher levels and let it copy the tables it may desire before we destroy them}
CallFinishedProc(DefaultFinishedProc, 0);
pClasses
:= NIL;
pSTables
:= NIL;
pAuthors
:= NIL;
pAliases
:= NIL;
pMethods
:= NIL;
{Just to keep things clean and consistent}
pHashName
:= NIL;
pHashUnit
:= NIL;
{Disable UnitAuthor, ClassAuthor, ClassVersion, ClassSize, and FinishedProc}
classesInitialized := TRUE;
{Exit from %_Pgm1, finally freeing its local storage below the TMethodArray}
%_ExitPoppingTo(mAllocAddr);
END;
{Each unit ends with:
.PROC unit#i
JSR %_Unit
; Defined below
JSR unit#x
; for every unit USEd by the unit within $CLASSES+ (in order USEd)...
...
JSR unit#z
JSR class-init#1 ; for every class implemented in unit#i...
...
JSR class-init#k
RTS
}

Apple Lisa ToolKit 3.0 Source Code Listing -- 49 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

PROCEDURE %_Unit;
VAR unitPC:
hashUNIndex:

LONGINT;
INTEGER;

FUNCTION CompareUnit(hashIndex: INTEGER): THashCompare;


VAR pc:
LONGINT;
BEGIN
pc := pHashUnit^[hashIndex];
IF pc = 0 THEN
CompareUnit := cHole
ELSE
IF pc = unitPC THEN
CompareUnit := cMatch
ELSE
CompareUnit := cMismatch;
END;
BEGIN
unitPC := CallPC;
hashUNIndex := LookupInHashArray(maxUnits, unitPC, TRUE, CompareUnit);
IF hashUNIndex > 0 THEN
{first time here -- let the initialization happen}
pHashUnit^[hashUNIndex] := unitPC
ELSE
%_ExitCaller(0);
{exit from .PROC unit#i because we have already initialized this unit}
END;
{toInsert, return: -index if class already there or if table full, index (> 0) if a hole found}
{not toInsert, return: index (> 0) if class found, -index if not there}
{return 0 if table is full}
FUNCTION LookupClassAlpha(keyA8: TA8; toInsert: BOOLEAN): INTEGER;
FUNCTION CompareName(hashIndex: INTEGER): THashCompare;
VAR myIndex:
INTEGER;
BEGIN
myIndex := pHashName^[hashIndex];
IF myIndex = 0 THEN
CompareName := cHole
ELSE
IF pClasses^[myIndex].classAlpha = keyA8 THEN
CompareName := cMatch
ELSE
CompareName := cMismatch;
END;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 50 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

LookupClassAlpha := LookupInHashArray(maxClasses, ORD(keyA8[2])*ORD(keyA8[4])+ORD(keyA8[6]),


toInsert, CompareName);
END;
FUNCTION FillArraysFrom(pc: LONGINT; itsLevelNumber: INTEGER; superSTP: TPSliceTable;
itsSTP: TPSliceTable; itsOddMethods: INTEGER): LONGINT;
{** NO VAR PARAMETERS ALLOWED THAT ARE REFERENCED AFTER CALLING MAllocate **}
VAR impLevelNumber:
INTEGER;
impMethNumber:
INTEGER;
targetLocation:
ProcPtr;
fini:
BOOLEAN;
impMethodArrayPtr:
TPMethodArray;
index:
INTEGER;
level:
INTEGER;
numAtThatLevel:
INTEGER;
superMethodArrayPtr:
TPMethodArray;
canInherit:
BOOLEAN;
methodNumber:
INTEGER;
BEGIN
impLevelNumber := itsLevelNumber;
impMethNumber := 0;
REPEAT
targetLocation := %_NextMethod(pc, impLevelNumber, impMethNumber);
fini := (targetLocation = p%_Class) OR (targetLocation = pJmp%_Class);
IF NOT fini THEN
BEGIN
impMethodArrayPtr := itsSTP^[impLevelNumber];
IF impMethodArrayPtr = NIL THEN
BEGIN
index := numClasses;
level := itsLevelNumber;
{always even}
{$IFC fTrcClascal}
WriteLn('pClasses = ', ORD(pClasses));
WriteLn('Index
Level', ' impLevelNumber = ', impLevelNumber:3);
WriteLn(index:3, level:12);
{$ENDC}
WHILE level > impLevelNumber DO
BEGIN
index := pClasses^[index].superIndex;
level := level - 2;
{$IFC fTrcClascal}
WriteLn(index:3, level:12);
{$ENDC}
END;
{$IFC fTrcClascal}

Apple Lisa ToolKit 3.0 Source Code Listing -- 51 of 1012

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163
001164
001165
001166
001167
001168
001169
001170
001171
001172
001173
001174
001175
001176
001177
001178
001179
001180
001181
001182
001183
001184
001185
001186
001187
001188
001189
001190
001191
001192
001193
001194
001195

WriteLn('-- In FillArrays, making a new method table --');


WriteLn('pc = ', pc:12, ' itsLevelNumber = ', itsLevelNumber:3,
' superSTP = ', ORD(superSTP):12, ' itsSTP = ', ORD(itsSTP):12);
WriteLn(' itsOddMethods = ', itsOddMethods:3,
' impMethNumber = ', impMethNumber:3,
' targetLocation = ', ORD(targetLocation):12);
WriteLn(' index = ', index:3,
' level = ', level:3,
' word[-2] = ', TPWords(pSTables^[index])^[-2]:7,
' word[-1] = ', TPWords(pSTables^[index])^[-1]:7);
{$ENDC}
numAtThatLevel := TPWords(pSTables^[index])^[ORD(ODD(impLevelNumber))-2];
{$IFC fTrcClascal}
WriteLn('numAtThatLevel = ', numAtThatLevel:3);
{$ENDC}
impMethodArrayPtr := TPMethodArray(MAllocate(numAtThatLevel, growMethods));
numMethods := numMethods + numAtThatLevel;
itsSTP^[impLevelNumber] := impMethodArrayPtr;
IF superSTP = NIL THEN
superMethodArrayPtr := NIL
ELSE
superMethodArrayPtr := superSTP^[impLevelNumber]; {may be NIL}
canInherit := (impLevelNumber < itsLevelNumber) AND (superMethodArrayPtr <> NIL);
FOR methodNumber := 1 TO numAtThatLevel DO
IF canInherit THEN
impMethodArrayPtr^[methodNumber] := superMethodArrayPtr^[methodNumber]
ELSE
impMethodArrayPtr^[methodNumber] := ORD(@ _Abstract);
END;
impMethodArrayPtr^[impMethNumber] := ORD(targetLocation);
END;
UNTIL fini;
{For any inherited slice that had no overrides, make it point at the same slice as the superclass}
FOR level := 0 TO itsLevelNumber - 1 DO
IF itsSTP^[level] = NIL THEN
itsSTP^[level] := superSTP^[level]; {may be NIL, too}
{If the odd slice has only ABSTRACT methods, then use a global to tell %_Pgm2 what to do}
IF itsSTP^[itsLevelNumber + 1] = NIL THEN
IF itsOddMethods > biggestAbstractClass THEN
biggestAbstractClass := itsOddMethods;

Apple Lisa ToolKit 3.0 Source Code Listing -- 52 of 1012

Apple Lisa Computer Technical Information


001196
001197
001198
001199
001200
001201
001202
001203
001204
001205
001206
001207
001208
001209
001210
001211
001212
001213
001214
001215
001216
001217
001218
001219
001220
001221
001222
001223
001224
001225
001226
001227
001228
001229
001230
001231
001232
001233
001234
001235
001236
001237
001238
001239
001240
001241
001242
001243

{$IFC fTrcClascal}
DumpArrays;
{$ENDC}

{*************************************************************************}

FillArraysFrom := pc;
END;
{The class-init routine of TFoo = SUBCLASS OF TSuperclass starts with:
JSR %_Class('TFOO
', 'TSUPERCL', @sliceTable, sizeOfEvenSlice, sizeOfOddSlice, objSize); Defined below
JSR method#1(sliceNumber*256 + methodNumber)
; for every method in the IMPLEMENTATION
...
; these calls are not executed: %_Class interprets them
JSR method#r(sliceNumber*256 + methodNumber)
; slice 0 is TObject, method 1 is first method
JSR %_Class
; just a terminator (The first call on %_Class interprets through here)}
PROCEDURE %_Class(itsClassName, itsSuperName: TS8; itsSTP: TPSliceTable;
itsEvenMethods, itsOddMethods, itsObjSize: INTEGER);
{** NO VAR PARAMETERS ALLOWED THAT ARE REFERENCED AFTER CALLING RAllocate & FillArraysFrom **}
VAR i:
INTEGER;
itsAlpha:
TA8;
superAlpha:
TA8;
nameHashIndex:
INTEGER;
superClIndex:
INTEGER;
superSTP:
TPSliceTable;
itsLevelNumber:
INTEGER;
pc:
LONGINT;
level:
INTEGER;
BEGIN
{First class of a unit?}
IF CallCallPC <> currCallCallPC THEN
BEGIN
EndPreviousUnit;
currCallCallPC := CallCallPC;
END;
{Increment numClasses but first be sure there is room in the arrays... this could move ALL the arrays!}
IF numClasses > (limClasses - 2) THEN
BEGIN
i {dummy} := RAllocate(SIZEOF(TClassInfo), numClasses,
growClasses, limClasses, maxClasses, 'Classes', ORD(pClasses));
limClasses := RAllocate(SIZEOF(TPSliceTable), numClasses,
growClasses, limClasses, maxClasses, 'Classes', ORD(pSTables));
END;
numClasses := numClasses + 1;
{Convert names from TS8 to TA8 type}
FOR i := 1 TO 8 DO

Apple Lisa ToolKit 3.0 Source Code Listing -- 53 of 1012

Apple Lisa Computer Technical Information


001244
001245
001246
001247
001248
001249
001250
001251
001252
001253
001254
001255
001256
001257
001258
001259
001260
001261
001262
001263
001264
001265
001266
001267
001268
001269
001270
001271
001272
001273
001274
001275
001276
001277
001278
001279
001280
001281
001282
001283
001284
001285
001286
001287
001288
001289
001290
001291

BEGIN
itsAlpha[i] := itsClassName[i];
superAlpha[i] := itsSuperName[i];
END;
{Enter this class into the name hash table}
nameHashIndex := LookupClassAlpha(itsAlpha, TRUE);
{Temporary variable needed because stack may quake}
IF nameHashIndex > 0 THEN
pHashName^[nameHashIndex] := numClasses
ELSE
{$IFC fDbgClascal}
IF nameHashIndex < 0 THEN
CLABreak('Class name appeared twice', numClasses)
ELSE
CLABreak('Class Name Hash table full', maxClasses);
{$ELSEC}
CLAFail(0);
{$ENDC}
{Hash the name of the superclass}
IF itsSuperName = 'NIL
' THEN
BEGIN
{This class has no superclass (e.g., TObject)}
superClIndex := 0;
itsLevelNumber := 0;
superSTP := NIL;
END
ELSE
BEGIN
superClIndex := pHashName^[LookupClassAlpha(superAlpha, FALSE)];
itsLevelNumber := NumSlices(superClIndex);
superSTP := pSTables^[superClIndex];
END;
{Fill this slice table with NILs for the moment}
FOR level := 0 TO itsLevelNumber + 1 DO
itsSTP^[level] := NIL;
{To be referenced from FillArraysFrom to calculate numAtThatLevel}
TPWords(itsSTP)^[-2] := itsEvenMethods;
TPWords(itsSTP)^[-1] := itsOddMethods;
{Initialize the fields of the class record}
WITH pClasses^[numClasses] DO
BEGIN
classAlpha := itsAlpha;
superIndex := superClIndex;
objectSize := itsObjSize;
{may be changed by a call on ClassSize from the class-init block}
classAlias := 0;
{may be supplied by a call on ClassAuthor from the class-init block}

Apple Lisa ToolKit 3.0 Source Code Listing -- 54 of 1012

Apple Lisa Computer Technical Information


001292
001293
001294
001295
001296
001297
001298
001299
001300
001301
001302
001303
001304
001305
001306
001307
001308
001309
001310
001311
001312
001313
001314
001315
001316
001317
001318
001319

companyAndAuthor := 0;
version := 1;
oldestReadableVersion := 1;
END;

{may be supplied by a call on ClassAuthor or UnitAuthor}


{may be changed by a call on ClassVersion from the class-init block}
{may be changed by a call on ClassVersion from the class-init block}

{Record the slice table pointer}


pSTables^[numClasses] := itsSTP;
{Before running the user's class-init code, be sure there is space for him to add an Alias and two Authors}
IF numAuthors > (limAuthors - 2) THEN
limAuthors := RAllocate(SIZEOF(TA32), numAuthors,
growAuthors, limAuthors, maxAuthors, 'Authors', ORD(pAuthors));
IF numAliases > (limAliases - 1) THEN
limAliases := RAllocate(SIZEOF(TA8), numAliases,
growAliases, limAliases, maxAliases, 'Aliases', ORD(pAliases));
{$IFC fTrcClascal}
WriteLn(' End of %_Class!, stp = ', ORD(itsSTP):5);
{$ENDC}
{[Interpret and] skip the MOVE/JSR pairs after the call of this procedure}
SetCallPC(FillArraysFrom(CallPC, itsLevelNumber, superSTP, itsSTP, itsOddMethods));
END;
END.

End of File -- Lines: 1319 Characters: 44959

Apple Lisa ToolKit 3.0 Source Code Listing -- 55 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UABC.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{UNIT UABC}
{Copyright 1983, 1984, Apple Computer, Inc.}
{ *** METHODS NEED TO BE GROUPED INTO RIGHT CATEGORIES *** }
{ *** ADD reserve IN ALMOST EVERY CLASS ***}
{
{
{
{

UABC2.TEXT
UABC3.TEXT
UABC4.TEXT
UABC5.TEXT

TProcess-TDocDirectory-TDocManager-TClipboard-TCommand-TCutCopyCommand-TPasteCommand}
TImage-TView-TPaginatedView-TPageView-TPrintManager-THeading-TSelection}
TWindow-TDialogBox-TMenuBar-TFont}
TPanel-TBand-TPane-TMarginPad-TBodyPad-TScroller-TScrollBar}

UNIT UABC;
{$SETC IsIntrinsic := TRUE }
{$IFC IsIntrinsic}
INTRINSIC;
{$ENDC}
INTERFACE
USES
{$U UnitStd
} UnitStd,
{Client should not USE UnitStd}
{$U UnitHz
} UnitHz,
{Client should not USE UnitHz and MUST NOT USE Storage}
{$U libtk/UObject
} UObject,
{Client must USE UObject}
{$U -#BOOT-SysCall} SysCall,
{Client may USE SysCall}
{$IFC LibraryVersion > 20}
{$U LIBTK/Passwd} Passwd,
{$ENDC}
{$IFC LibraryVersion <= 20}
{$U FontMgr
} FontMgr,
{Client should USE UFont instead of FontMgr before QuickDraw}
{$ENDC}
{$U QuickDraw
} QuickDraw,
{Client must USE QuickDraw (unless we provide a type-stub for it)}
{$IFC LibraryVersion > 20}
{$U FontMgr
} FontMgr,
{Client should USE UFont instead of FontMgr after QuickDraw}
{$ENDC}
{$U libtk/UDraw
} UDraw,
{Client must USE UDraw}
{$U PMDecl
} PMDecl,
{$IFC libraryVersion <= 20}

{Client need not USE anything below this line}


{ P E P S I }

Apple Lisa ToolKit 3.0 Source Code Listing -- 56 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

{$U PrStd
} PrStd,
{$ENDC}
{$U WM.Events
} Events,
{$U WM.Folders } Folders,
{$U WM.Menus
} Menus,
{$U AlertMgr
} AlertMgr,
{$IFC LibraryVersion <= 20}
{$U PrProcs
} PrProcs,
{$ENDC}
{$U WMLstd
} WMLstd,
{$U WMLCrs
} WMLCrs,
{$U WMLSb
} WMLSb,
{$U WMLGrow
} WMLGrow,
{$U Scrap
} Scrap,
{$IFC libraryVersion <= 20}
{$U PrMgrUtil
} PrMgrUtil,
{$U PrMgr
} PrMgr,
{$ELSEC}
{$U PrStdInfo}
PrStdInfo,
{$U PrPublic}
PrPublic,
{$ENDC}
{$U FilerComm
} FilerComm;
{$SETC fDbgABC
{$SETC fRngABC
{$SETC fSymABC

{ S P R I N G }

:= fDbgOK}{FALSE}
:= fDbgOK}{FALSE}
:= fSymOK}{FALSE}

{$SETC fDebugMethods := fDbgABC} {if VAR also true, trace entries and/or exits}
CONST
maxMenus
maxFonts
maxSegments
maxSegSize
abortChunkSize

=
=
=
=
=

31;
{unfortunate, but menus must be in non-relocatable storage, & this is easiest}
11;
6;
$20000; {128K}
32768; {32k}

iconNameSeparator = '<';{character separating parts of an icon name}


stdHHysteresis
stdVHysteresis

= 9;
= 6;

{amount the mouse must move from anchor before drag starts, unless}
{
TSelection.GetHysteresis is overridden}

noCursor
hiddenCursor
arrowCursor
crossCursor

= -2;
= -1;
= 1;
= 9;

{
{icrsHidden
{icrsInactive
{icrsLCCross

used when you do not set the cursor}


Hides the cursor entirely}
Standard arrow cursor}
LisaCalc cross}

Apple Lisa ToolKit 3.0 Source Code Listing -- 57 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

textCursor
checkCursor
smCrossCursor
fingerCursor

=
=
=
=

10;
12;
13;
14;

firstUserCursor = 100;

{icrsXIBeam
{icrsCheck
{icrsGECross
{icrsLFinger

Standard text I-Beam}


Checkmark}
LisaDraw cross (smaller than crossCursor)}
LisaDraw left-pointing finger}

{ this is the smallest user-defined cursor }

nothingKind

= 0;

noCmdNumber

= 0;

docLdsn
docDsBytes
docExcess

= 3;
= 5120;
= 2048;

{ldsn for the first document data segment}


{default heap size for a document data segment}
{the virtual data segment may be this much larger than needed for the heap}

printLdsn
ascArwDown
ascArwLeft
ascArwRight
ascArwUp
ascBackspace
ascClear
ascEnter
ascReturn
ascTab

=
=
=
=
=
=
=
=
=
=

{ldsn to hand to LisaPrint}

2;
$1F;
$1C;
$1D;
$1E;
$08;
$1B;
$03;
$0D;
$09;

{alert phrase codes must be between 9 and 899}


phWordDelimiters=
phTrouble
phUnknown
phNoText
phNoSel
phNoInsPt
phRevert
phRevBlank
phUnkCmd
phSelCant
phUnchanged
phSaving
phTerminated
phEditClip
phNoClip
phUnkClip
phDialogUp
phCantUndo
phNoCommand

=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=
=

9;
10;
11;
21;
22;
23;
24;
25;
26;
27;
28;
29;
30;
31;
32;
33;
34;
35;
36;

{The tool is having trouble}


{Phrase(error) is undefined for this error}

Apple Lisa ToolKit 3.0 Source Code Listing -- 58 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

phOlderVersion
phNewerVersion
phConverting
phAborting

=
=
=
=

37;
38;
39;
40;

phPage
phTitle

= 41; {+SW+}
= 42; {+SW+}

phCantSave
phCantRevert

= 43;
= 44;

phCountry

= 45;

{command, selection, and phrase indices used by Dialog Building Block}


uCreateLayoutBox = 701;
{Command numbers}
uMoveLayoutBoxes = 702;
uCmdLaunchHeading = 703;
uCmdInstallMargins = 704;
layPickKind = 119;
layEditLegendKind = 133;
frameKind = 161;

{Selection kinds}

phTooManyChars = 101;
phOddEven = 102;
phOddOnly = 103;
phEvenOnly = 104;
phOddOrEven = 105;
phMinPage = 106;
phMaxPage = 107;
phPageAlignment = 108;
phAlignment = 109;
phTopLeft = 110;
phTopCenter = 111;
phTopRight = 112;
phBotLeft = 113;
phBotCenter = 114;
phBotRight = 115;
phLaunchHeading = 116;
phPageMargins = 117;
phUnits = 118;
phInches = 119;
phCentimeters = 120;
phLeft = 121;
phLeftCluster = 122;
phTop = 123;
phTopCluster = 124;

{Phrases}

Apple Lisa ToolKit 3.0 Source Code Listing -- 59 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

phRight = 125;
phRightCluster = 126;
phBottom = 127;
phBotCluster = 128;
phInstallMargins = 129;
phInchTitle= 130;
phCmTitle = 131;
phNewHeading = 132; {+SW+}
phOK = 142;
phCancel = 143;

{client should NOT lightly change the phrases for these, since they are used for}
{determining text and locations of OK/Cancel buttons for built-in ToolKit dialogs}

stdBoxWidth = 17; {dimensions for default checkboxes}


stdBoxHeight = 11;
stdBoxSpacing = 20;
stdCurvH = 18; {for Buttons}
stdCurvV = 14;
stdBtnHeight = 22;
noIDNumber = -2;
noId = '';
IDLength = 9; {the significant length of id strings}
stdTitleHeight = 10;
stdSlimTitleHeight = 6;
stdLeftRightBorder = 3;
stdBottomBorder = 2;

{for layout boxes}

{errcodes of other libraries}


erAborted
erDuplicateName
erInvalidName
erNameNotFound

= 4033; {user typed Apple-.; Desktop Manager}


= 890; {OS & Desktop Manager}
= 971; {OS & Desktop Manager}
= 972; {OS & Desktop Manager}

{ToolKit errCodes must be between 4201 and 4499}


erPassword
erVersion
erBadData
erCantRead
erCantWrite
erDirtyDoc
erNoMoreDocs
erNoMemory
erNoDiskSpace

=
=
=
=
=
=
=
=
=

4201;
4202;
4203;
4304;
4305;
4306;
4307;
4308;
4309;

Apple Lisa ToolKit 3.0 Source Code Listing -- 60 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

erWrongPassword = 4310;
erMaxToolKit
= 4499;
{command codes must be between 101 and 999}
uSetAllAside
uSetAside
uPutAway
uPrFmt
uPrintAsIs
uPrint
uPrMonitor
uSaveVersion
uRevertVersion
utSetAside
uSetClipAside

=
=
=
=
=
=
=
=
=
=
=

101;
102;
103;
104;
111;
105;
106;
107;
108;
109;
110;

{Set Aside ^Document^}

{Typing Buzzword}
uTyping
= 150;
{The toolkit uses
uBackspace
=
uEnter
=
uForwardSpace
=
uReturn
=
uTab
=

the following only as arguments to selection.CantDoCmd}


151;
152;
153;
154;
155;

{The toolkit uses


uSomeCommand
=
uScrolling
=
uSplitting
=
uResizeWindow
=
uResizePanel
=
UMousePress
=
uThumbing
=
uMoveWindow
=
uKeyDown
=

the following only as arguments to process.RememberCommand}


156;
157;
158;
159;
160;
161;
162;
163;
164; {could be made the same as uTyping}

uCopy
uCut
uPaste
uSelAll
uUndoLast
utUndoLast
utRedoLast
uClear

201;
202;
203;
204;
205;
206;
207;
208;

=
=
=
=
=
=
=
=

{Undo ^Last Change^}


{Redo ^Last Change^}

{$IFC LibraryVersion <= 20}

Apple Lisa ToolKit 3.0 Source Code Listing -- 61 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

uFnt0
uFnt1
uFnt2
uFnt3
uFnt4
uFnt5
uFnt6
uFnt7
uFnt8
uFnt9
uFnt10
uFnt11
{$ENDC}
uModern
uClassic

=
=
=
=
=
=
=
=
=
=
=
=

= 320 + famModern - famMin;


= 320 + famClassic - famMin;

{should result in 320}

u20Pitch
u15Pitch
u12Pitch
u10Pitch
u12Point
u14Point
u18Point
u24Point

=
=
=
=
=
=
=
=

330
330
330
330
330
330
330
330

{should result in 330}

uPlain
uBold
uItalic
uUnderline
uShadow
uOutline
uSuperscript
uSubscript

=
=
=
=
=
=
=
=

351;
352;
353;
354;
355;
356;
357;
358;

uPrvwMargins
uPrvwBreaks
uPrvwOff
uDesignPages

=
=
=
=

401;
402;
403;
405;

uShowFullSize
uReduce70Pct
uReduceToFit

= 406;
= 407;
= 408;

uSetHorzBreak
uSetVertBreak
uClearBreaks

= 411;
= 412;
= 413;

uRiseVertically

300;
301;
302;
303;
304;
305;
306;
307;
308;
309;
310;
311;

+
+
+
+
+
+
+
+

size20Pitch
size15Pitch
size12Pitch
size10Pitch
size12Point
size14Point
size18Point
size24Point

sizeMin;
sizeMin;
sizeMin;
sizeMin;
sizeMin;
sizeMin;
sizeMin;
sizeMin;

= 421;

Apple Lisa ToolKit 3.0 Source Code Listing -- 62 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

uRiseHorizontally = 422;
uAddColumnStrip
uAddRowStrip

= 431;
= 432;

uReportEvents

= 501;

uCountHeap

= 506;

uCheckIndices
uDumpGlobals
uDumpPrelude
uExperimenting
uReptGarbage
uFreeGarbage

=
=
=
=
=
=

uMainScramble
uDocScramble

= 515;
= 516;

509;
510;
511;
512;
513;
514;

uEditDialog
= 521;
uStopEditDialog = 522;
{ the standard WantMenu will return FALSE for any menus with menuID >= mBuzzword;
buzzword menus should be assigned IDs >= 100;
debug menus should be assigned IDs 90-99 }
{$IFC fDbgABC}
mBuzzword
{$ELSEC}
mBuzzword
{$ENDC}

= 100;
=

90;

mnuClipFilePrint = 1000;

{special menuID for Clipboard File/Print}

firstPrivateEvent = 100; {first event type that you can use in TProcess.SendEvent}
{$IFC NOT fDbgABC}
fExperimenting =
{$ENDC}

FALSE;

{ not experimenting if debug code if off }

TYPE
TPrinterMetrics = RECORD
paperRect:
Rect;
{the physical rectangle}
printRect:
Rect;
{the printable rectangle}
res:
Point;
{resolution, spots/inch}
reserve:
ARRAY[0..7] OF BYTE;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 63 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

TPreviewMode = (mPrvwMargins, mPrvwBreaks, mPrvwOff);


TDiResponse = (diAccept, diDismissDialogBox, diGiveToMainWindow, diRefuse);
TEnumAbilities = (aBar, aScroll, aSplit);
TAbilities = SET OF TEnumAbilities;

{for TPanel.Divide/CREATE argument}

TUnitsFromEdge = (pixelsFromEdge, percentFromEdge);

{for TPanel.Divide argument}

TAlertArg = 1..5;
TAlertCounter = 7..9;
TAlignment = (aLeft, aRight, aCenter, aJustify);
TPageAlignment = (aTopLeft, aTopCenter, aTopRight, aBottomLeft, aBottomCenter, aBottomRight);
TClickState =

RECORD
where: Point;
when: LONGINT;
clickCount: INTEGER;
fShift, fOption, fApple: BOOLEAN;
END;

TCmdNumber = INTEGER;

{the unique identifier of a command in a menu (or elsewhere)}

TCmdPhase = (doPhase, undoPhase, redoPhase);{doPhase first time, then undoPhase & redoPhase alternately}
TCursorNumber = INTEGER;
TEnumIcons = (iSkewer, iScrollBack, iFlipBack, iGrayA, iThumb, iGrayB, iFlipFwd, iScrollFwd); {TIcon}
TMousePhase = (mPress, mMove, mRelease);
TRevelation = (revealNone, revealSome, revealAll);
TPrReserve = ARRAY [0..127] OF Byte;
{lengthened}
TPrelude =
RECORD
password:
{2} INTEGER;
version:
{2} INTEGER;
{*** Should also do ABC version protection***}
country:
{2} INTEGER;
language:
{2} INTEGER;
preludeSize:
{2} INTEGER;
{SIZEOF(TPrelude), which precedes the heap}
unused:
{6} ARRAY [0..5] OF Byte;
{The above fields should occupy 16 bytes to meet the Lisa standard}
printPref:
{128} TPrReserve;
docSize:
{4} LONGINT;
{sum of the sizes of the consecutive data segments}
numSegments:
{2} INTEGER;
{no. of segments; all but the last are maxSegSize bytes}

Apple Lisa ToolKit 3.0 Source Code Listing -- 64 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

docDirectory:
{4} TDocDirectory;
{Other fields may be added later}
END;

{whence one finds the class table and the window}

TPPrelude = ^TPrelude;
TSBoxID = LONGINT; {THSb alias}
TWindowID = LONGINT; {WindowPtr alias}
TWmgrCmd =
RECORD
cmdNumber:
menuIndex:
itemIndex:
END;

INTEGER;
Byte;
Byte;

{the command number}


{the ordinal number of the menu in its menu bar (or file)}
{the ordinal number of the item in its menu}

TProcess = SUBCLASS OF TObject {only one instance exists (process)}


{Variables}
{Creation/Destruction}
FUNCTION {TProcess.}CREATE(object: TObject; heap: THeap): TProcess;
{Debugging}
{$IFC fDebugMethods}
PROCEDURE {TProcess.}DontDebug;
{$ENDC}
{$IFC fDbgABC}
PROCEDURE {TProcess.}DumpGlobals;
{$ENDC}

{Turn off all debug flags when last document is closed}


{Print most global variables on alternate screen}

{Cursor Tracking}
PROCEDURE {TProcess.}ChangeCursor(cursorNumber: TCursorNumber);
{ applications call ChangeCursor if they want to change the cursor shape }
PROCEDURE {TProcess.}DoCursorChange(cursorNumber: TCursorNumber);
{ applications implement DoCursorChange to test cursorNumber for one of their
cursor shapes; if found, it calls QuickDraw's SetCursor routine, otherwise
it calls the generic TProcess.DoCursorChange }
PROCEDURE {TProcess.}TrackCursor;
{Error Reporting}
PROCEDURE {TProcess.}ArgAlert(whichArg: TAlertArg; argText: S255); {whichArg = 1 to 5}
FUNCTION {TProcess.}Ask(phraseNumber: INTEGER): INTEGER;
PROCEDURE {TProcess.}BeginWait(phraseNumber: INTEGER);
FUNCTION {TProcess.}Caution(phraseNumber: INTEGER): BOOLEAN;

Apple Lisa ToolKit 3.0 Source Code Listing -- 65 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
FUNCTION
PROCEDURE

{TProcess.}CountAlert(whichCtr: TAlertCounter; counter: INTEGER);


{TProcess.}DrawAlert(phraseNumber: INTEGER; marginLRect: LRect);
{TProcess.}EndWait;
{TProcess.}GetAlert(phraseNumber: INTEGER; VAR theText: S255);
{TProcess.}Note(phraseNumber: INTEGER);
{TProcess.}RememberCommand(cmdNumber: TCmdNumber);
{ for ^C and ^K in alerts }
{TProcess.}Phrase(error: INTEGER): INTEGER;
{TProcess.}Stop(phraseNumber: INTEGER);

{Initiate/Terminate}
PROCEDURE {TProcess.}Commence(phraseVersion: INTEGER); {process init after the process object exists}
PROCEDURE {TProcess.}Complete(allIsWell: BOOLEAN);
{Abort Handling}
FUNCTION {TProcess.}AbortRequest: BOOLEAN;
PROCEDURE {TProcess.}AbortXferSequential(whichWay: xReadWrite; pFirst: Ptr;
numBytes, chunkSize: LONGINT; fs: TFileScanner);
{Main Loop}
PROCEDURE {TProcess.}ObeyEvents(FUNCTION StopCondition: BOOLEAN);
{This will return IF: (1) amDying is TRUE (application terminated)
or (2) StopCondition returns TRUE (StopCondition is checked
only when no events are available, before starting to idle.)}
PROCEDURE {TProcess.}ObeyFilerEvent;
PROCEDURE {TProcess.}ObeyTheEvent;
PROCEDURE {TProcess.}Run;
{Private Events (Inter-process communication)}
PROCEDURE {TProcess.}HandlePrivateEvent(typeOfEvent: INTEGER; fromProcess: LONGINT;
when: LONGINT; otherData: LONGINT); DEFAULT;
PROCEDURE {TProcess.}SendEvent(typeOfEvent: INTEGER; targetProcess: LONGINT; otherData: LONGINT);
{Memory Management}
PROCEDURE {TProcess.}BindCurrentDocument;
{Open/Close Window/Document}
FUNCTION {TProcess.}NewDocManager(volumePrefix: TFilePath; openAsTool: BOOLEAN)
: TDocManager; DEFAULT;
{External Document Support}
PROCEDURE {TProcess.}CopyExternalDoc(VAR error: INTEGER;
externalName, volumePrefix: TFilePath); DEFAULT;
{This is called if the application puts icons into the clipboard and the user
then pastes them into a folder or disk.}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 66 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

TDocDirectory = SUBCLASS OF TObject


{Variables}
window:
classWorld:

TWindow;
TClassWorld;

{Creation/Destruction}
FUNCTION {TDocDirectory.}CREATE(object: TObject; heap: THeap; itsWindow: TWindow;
itsClassWorld: TClassWorld): TDocDirectory;
{Version Conversion}
PROCEDURE {TDocDirectory.}Adopt;
END;
TDocManager = SUBCLASS OF TObject
{Variables}
files:
RECORD
volumePrefix:
volume:
{$IFC LibraryVersion > 20}
password:
{$ENDC}
saveExists:
shouldSuspend:
shouldToolSave:
END;
dataSegment:
RECORD
refnum:
preludePtr:
changes:
END;
docHeap:
window:
pendingNote:
openedAsTool:

TFilePath;
TFilePath;

{Desktop Manager volume and prefix of OS files}


{Desktop Manager volume of OS files; -volname-}

TPassword;

{The password for this document}

BOOLEAN;
BOOLEAN;
BOOLEAN;

{whether Save file is known to exist and seem readable}


{should we create suspend files?}
{should we create save files if opened as a tool?}

ARRAY [1..maxSegments] OF INTEGER;


{refnums of its data segments}
TPPrelude;
{a pointer to the prelude of the data segment}
LONGINT;
{How many changes since the last checkpoint}
THeap;
TWindow;
INTEGER;
BOOLEAN;

{the heap starts after the prelude}


{the document's window (it is in the data segment)}
{If <> 0, NOTE alert that was requested while inactive}

{Creation/Destruction}
FUNCTION {TDocManager.}CREATE(object: TObject; heap: THeap; itsPathPrefix: TFilePath): TDocManager;
{Debugging}
{$IFC fDbgABC}
PROCEDURE {TDocManager.}DumpPrelude;

{Print most of prelude on alternate screen}

Apple Lisa ToolKit 3.0 Source Code Listing -- 67 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

{$ENDC}
{Attributes}
FUNCTION {TDocManager.}WindowWithId(wmgrID: TWindowID): TWindow;
{Process Termination}
PROCEDURE {TDocManager.}Complete(allIsWell: BOOLEAN);
{Open/Close Window}
FUNCTION {TDocManager.}NewWindow(heap: THeap; wmgrID: TWindowID): TWindow; DEFAULT;
{Files}
PROCEDURE {TDocManager.}Close(afterSuspend: BOOLEAN);
{ CloseFiles is for the application to override if it has any of its own files that must be
closed }
PROCEDURE {TDocManager.}CloseFiles;
PROCEDURE {TDocManager.}Open(VAR error: INTEGER; wmgrID: TWindowID; VAR OpenedSuspended:Boolean);
PROCEDURE {TDocManager.}OpenBlank(VAR error: INTEGER; wmgrID: TWindowID);
PROCEDURE {TDocManager.}OpenSaved(VAR error: INTEGER; wmgrID: TWindowID);
PROCEDURE {TDocManager.}OpenSuspended(VAR error: INTEGER; wmgrID: TWindowID);
PROCEDURE {TDocManager.}RevertVersion(VAR error: INTEGER; wmgrID: TWindowID);
PROCEDURE {TDocManager.}SaveVersion(VAR error: INTEGER; volumePrefix: TFilePath;
andContinue: BOOLEAN);
PROCEDURE {TDocManager.}Suspend(VAR error: INTEGER);
{Data Segment}
PROCEDURE {TDocManager.}Assimilate(VAR error: INTEGER);
PROCEDURE {TDocManager.}Bind; DEFAULT;
PROCEDURE {TDocManager.}ConserveMemory(maxExcess: LONGINT; fGC: BOOLEAN);
{if fGC is TRUE also do a garbage collect -- on debugging versions,
we just report garbage, on non-debugging versions we free it
also.}
PROCEDURE {TDocManager.}Deactivate;
FUNCTION {TDocManager.}DfltHeapSize: LONGINT;
PROCEDURE {TDocManager.}ExpandMemory(bytesNeeded: LONGINT);
PROCEDURE {TDocManager.}KillSegments(first, last: INTEGER);
PROCEDURE {TDocManager.}MakeSegments(VAR error: INTEGER; oldSegments: INTEGER; newDocSize: LONGINT);
PROCEDURE {TDocManager.}ResumeAfterOpen(VAR error: INTEGER; wmgrID: TWindowID);
PROCEDURE {TDocManager.}SetSegSize(VAR error: INTEGER; minSize, maxExcess: LONGINT);
PROCEDURE {TDocManager.}Unbind; DEFAULT;
END;
TClipboard = SUBCLASS OF TDocManager
{Variables}
hasView:
hasPicture:
hasUniversalText:

BOOLEAN;
BOOLEAN;
BOOLEAN;

{FALSE if no tool-kit-specific representation available}


{FALSE if no universal picture available}
{FALSE if no universal text available}

Apple Lisa ToolKit 3.0 Source Code Listing -- 68 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

hasIcon:
BOOLEAN;
{****NOTE: The only way into or out of
cuttingTool:
LONGINT;
cuttingProcessID:
LONGINT;
clipCopy:
TFileScanner;

{TRUE if there is an icon reference available}


Universal Text is via the Universal Text Building Block****}
{The tool number of the tool that loaded the Clipboard, or 0}
{The OS process ID of the tool that loaded the Clipboard, or 0}
{IF <> NIL a scanner on the file containing a copy of the
clipboard before conversion.}

{Creation/Destruction}
FUNCTION {TClipboard.}CREATE(object: TObject; heap: THeap): TClipboard;
{Editing}
PROCEDURE {TClipboard.}AboutToCut;
PROCEDURE {TClipboard.}BeginCut;
PROCEDURE {TClipboard.}EndCut;

{whether or not data will actually be put in the data seg}

{Undo}
PROCEDURE {TClipboard.}CommitCut;
FUNCTION {TClipboard.}UndoCut: BOOLEAN; {return TRUE if succeeds}
{Identification}
PROCEDURE {TClipboard.}Inspect;
PROCEDURE {TClipboard.}Publicize;
{Data Segment}
{PROCEDURE TClipboard. Bind;}
{PROCEDURE TClipboard. Unbind;}
END;
TCommand = SUBCLASS OF TObject
{Variables}
cmdNumber:

TCmdNumber;

{the command number of the menu item that describes the command;
usually the same one the user chose, but not necessarily}
image:
TImage;
{If non-NIL, affects filtering by image.EachVirtualPart}
undoable:
BOOLEAN;
{TRUE iff this command is undoable}
doing:
BOOLEAN;
{TRUE if Performing or just did doPhase or redoPhase}
revelation:
TRevelation;
{revealNone/Some/All of selection before performing command}
unHiliteBefore: ARRAY [TCmdPhase] OF BOOLEAN; {TRUE -> Toolkit unhilites all selections before
perform}
hiliteAfter:
ARRAY [TCmdPhase] OF BOOLEAN; {TRUE -> Toolkit hilites all selections after perform}

{Creation/Destruction}
FUNCTION {TCommand.}CREATE(object: TObject; heap: THeap; itsCmdNumber: TCmdNumber;
itsImage: TImage; isUndoable: BOOLEAN; itsRevelation: TRevelation): TCommand;
{Filtering}

Apple Lisa ToolKit 3.0 Source Code Listing -- 69 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

PROCEDURE {TCommand.}EachVirtualPart(PROCEDURE DoToObject(filteredObj: TObject));


PROCEDURE {TCommand.}FilterAndDo(actualObj: TObject; PROCEDURE DoToObject(filteredObj: TObject));
{Command Execution}
PROCEDURE {TCommand.}Commit; DEFAULT;
PROCEDURE {TCommand.}Perform(cmdPhase: TCmdPhase); DEFAULT;

{commit a command}
{do, undo, or redo a command}

END;
TCutCopyCommand = SUBCLASS OF TCommand
{Variables}
isCut: BOOLEAN;

{TRUE iff this was a cut; FALSE iff a copy}

{Creation/Destruction}
FUNCTION {TCutCopyCommand.}CREATE(object: TObject; heap: THeap; itsCmdNumber: TCmdNumber;
itsImage: TImage; isCutCmd: BOOLEAN): TCutCopyCommand;
{Command Execution}
{PROCEDURE TCutCopyCommand. Commit;}
PROCEDURE {TCutCopyCommand.}DoCutCopy(clipSelection: TSelection; deleteOriginal: BOOLEAN;
cmdPhase: TCmdPhase); DEFAULT;
{the clipboard is already set up; you only have to load data into it in doPhase}
{PROCEDURE TCutCopyCommand. Perform(cmdPhase: TCmdPhase);}
END;
TPasteCommand = SUBCLASS OF TCommand
{Creation/Destruction}
FUNCTION {TPasteCommand.}CREATE(object: TObject; heap: THeap; itsCmdNumber: TCmdNumber;
itsImage: TImage): TPasteCommand;
{Command Execution}
PROCEDURE {TPasteCommand.}DoPaste(clipSelection: TSelection; pic: PicHandle;
cmdPhase: TCmdPhase); DEFAULT;
{the clipboard is already set up, except in undoPhase sel & pic are NIL}
{PROCEDURE TPasteCommand. Perform(cmdPhase: TCmdPhase);}
END;
TImage = SUBCLASS OF TObject
{Variables}
extentLRect:

LRect;

{the bounding box for updates; also for default hit-testing}

Apple Lisa ToolKit 3.0 Source Code Listing -- 70 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

view:
allowMouseOutside:
{methods}
FUNCTION
FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
FUNCTION
PROCEDURE
FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
FUNCTION

TView;
BOOLEAN;

{If TRUE, TImage.MouseTrack will NOT force the mouse point


to lie within the extentLRect; TImage.CREATE sets this FALSE}

{TImage.}CREATE(object: TObject; heap: THeap; itsExtent: LRect; itsView: TView): TImage;


{TImage.}CursorAt(mouseLPt: lPoint): TCursorNumber; DEFAULT;
{TImage.}Draw; DEFAULT;
{TImage.}EachActualPart(PROCEDURE DoToObject(filteredObj: TObject)); DEFAULT;
{TImage.}EachVirtualPart(PROCEDURE DoToObject(filteredObj: TObject)); DEFAULT;
{TImage.}FilterAndDo(actualObj: TObject; PROCEDURE DoToObject(filteredObj: TObject));
{TImage.}HaveView(view: TView); DEFAULT;
{TImage.}Hit(mouseLPt: lPoint): BOOLEAN; DEFAULT;
{TImage.}Invalidate; {does NOT do it on all pads}
{TImage.}LaunchLayoutBox(view: TView): TImage; DEFAULT;
{TImage.}OffSetBy(deltaLPt: LPoint); DEFAULT;
{TImage.}OffSetTo(newTopLeft: LPoint);
{TImage.}MouseMove(mouseLPt: lPoint); DEFAULT;
{TImage.}MousePress(mouseLPt: lPoint); DEFAULT;
{TImage.}MouseRelease; DEFAULT;
{TImage.}MouseTrack(mPhase: TMousePhase; mouseLPt: LPoint); DEFAULT;
{TImage.}ReactToPrinterChange; DEFAULT;
{TImage.}RecalcExtent; DEFAULT;
{TImage.}Resize(newExtent: LRect); DEFAULT;
{TImage.}SeesSameAs(image: TImage): BOOLEAN; DEFAULT; {$}

END;
TView = SUBCLASS OF TImage
{Variables}
panel:
clickLPt:
printManager:
res:

TPanel;
LPoint;
TPrintManager;
Point;

{The panel in which it is viewed}


{The last place the user clicked the mouse button}
{NIL if view not printable}
{resolution, spots/inch}

screenPad:

TPad;

{like noPad, but scales from view coords to screen coords if view
resolution and screen resolution differ
*** CAUTION -- Only for mapping coordinates-- DO NOT try to
Focus this pad or do Invals, etx ***}

fitPagesPerfectly:

BOOLEAN;

{whether view size should fluctuate automatically so that one always


ends up with an even number of pages}

isPrintable:
isMainView:

BOOLEAN;
BOOLEAN;

{Whether this view can be printed}


{FALSE if an auxiliary view, such as page view or paginated view}

Apple Lisa ToolKit 3.0 Source Code Listing -- 71 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

stdScroll:
scrollPastEnd:

LPoint;
Point;

{Amount we should scroll past the end of the view}

{Creation/Destruction}
FUNCTION {TView.}CREATE(object: TObject; heap: THeap; itsPanel: TPanel; itsExtent: LRect;
itsPrintManager: TPrintManager; itsDfltMargins: LRect; itsFitPagesPerfectly:BOOLEAN;
itsRes: Point; isMainView: BOOLEAN): TView;
{PROCEDURE TView. Free;}
{Attributes}
PROCEDURE {TView.}BeInPanel(panel: TPanel);
PROCEDURE {TView.}GetStdScroll(VAR deltaLStd: LPoint);
FUNCTION {TView.}MaxPageToPrint: LONGINT;
{Pagination}
PROCEDURE {TView.}AddStripOfPages(vhs: VHSelect); DEFAULT;
FUNCTION {TView.}ForceBreakAt(vhs: VHSelect; precedingLocation: LONGINT;
proposedLocation: LONGINT): LONGINT;
PROCEDURE {TView.}RedoBreaks; DEFAULT;
PROCEDURE {TView.}RemapManualBreaks(
FUNCTION NewBreakLocation(vhs: VHSelect; oldBreak: LONGINT): LONGINT);
{Cross-Panel Drag}
FUNCTION {TView.}DoReceive(selection: TSelection; lPtInView: LPoint): BOOLEAN;
{Direct Display Permission -- per panel}
FUNCTION {TView.}OKToDrawIn(lRectInView: LRect): BOOLEAN;

{Default is FALSE; app can override}

{Cursor tracking - per pane}


{FUNCTION TView. CursorAt(mouseLPt: LPoint): TCursorNumber;}
{Resizing}
{PROCEDURE TView. Resize(newExtent: LRect);}
PROCEDURE {TView.}SetMinViewSize(VAR minLRect: LRect);
{Clipboard Setup}
PROCEDURE {TView.}CreateUniversalText;
{Variables embedded in text}
PROCEDURE {TView.}SetFunctionValue(keyword: S255; VAR itsValue: S255);
{Selecting}
FUNCTION {TView.}NoSelection: TSelection;
END;
TPaginatedView = SUBCLASS OF TView

Apple Lisa ToolKit 3.0 Source Code Listing -- 72 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

{Variables}
unpaginatedView:
pageSize:

TView;

{the unpaginated view from whence this derives}

ARRAY[VHSelect] OF LONGINT;

workingInMargins:

{width/height of a page's representation on the screen,


in the same metrics as the regular view -- could still
differ from actual screen space a/c screen horiz/vertical
resolution}

BOOLEAN;

{Creation/Destruction}
FUNCTION {TPaginatedView.}CREATE(object: TObject; heap: THeap;
itsUnpaginatedView: TView): TPaginatedView;
{PROCEDURE
PROCEDURE
{FUNCTION
PROCEDURE
PROCEDURE
{PROCEDURE
{PROCEDURE
PROCEDURE
{PROCEDURE
{PROCEDURE

TPaginatedView. AddStripOfPages(vhs: VHSelect);}


{TPaginatedView.}AdornPageOnScreen;
TPaginatedView. CursorAt(mouseLPt: LPoint): TCursorNumber;}
{TPaginatedView.}DepagifyLPoint(pagLPt: LPoint; VAR unPagLPt: LPoint);
{TPaginatedView.}DoOnPages(focusOnInterior: BOOLEAN; PROCEDURE DoOnAPage);
TPaginatedView. Draw;}
TPaginatedView. MouseTrack(mPhase: TPhase; mouseLPt: LPoint);}
{TPaginatedView.}PagifyLPoint(unPagLPt: LPoint; VAR pagLPt: LPoint);
TPaginatedView. ReactToPrinterChange;}
TPaginatedView. RedoBreaks;}

END;
TPageView = SUBCLASS OF TView
FUNCTION

{TPageView.}CREATE(object: TObject; heap: THeap;


itsPrintManager: TPrintManager): TPageView;
{PROCEDURE TPageView. Draw;}
END;
THeading = SUBCLASS OF TImage
printManager:
pageAlignment:
offsetFromAlignment:
oddOnly:
evenOnly:
minPage:
maxPage:

{a header/footer image}

TPrintManager;
TPageAlignment;
LPoint;

BOOLEAN;
BOOLEAN;
LONGINT;
LONGINT;

{to restrict printing only to odd-numbered pages}


{ ditto even }
{minimum page number to want this heading}
{maximum page number to want it}

Apple Lisa ToolKit 3.0 Source Code Listing -- 73 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

{Creation/Destruction}
FUNCTION {THeading.}CREATE(object: TObject; heap: THeap; itsPrintManager: TPrintManager;
itsExtentLRect: LRect; itsPageAlignment: TPageAlignment;
itsOffsetFromAlignment: LPoint): THeading;
{Attributes}
PROCEDURE {THeading.}ChangePageAlignment(newPageAlignment: TPageAlignment);
{Selective Use}
FUNCTION {THeading.}ShouldDraw(pageNumber: LONGINT): BOOLEAN;
FUNCTION {THeading.}ShouldFrame: BOOLEAN; DEFAULT;
{Display}
PROCEDURE {THeading.}AdjustForPage(pageNumber: LONGINT; editing: BOOLEAN); DEFAULT;
PROCEDURE {THeading.}LocateOnPage(editing: BOOLEAN);
{PROCEDURE THeading. Draw;}
END;
TPrintManager = SUBCLASS OF TObject
view:
TView;
pageView:
TView;
breaks:

ARRAY[VHSelect] OF TArray; {of LONGINT}


{pagebreak representation: absolute value gives location; negative
signifies manual break; nonnegative signifies automatic pagebreak}

pageMargins:

LRect;

headings:

TList; {OF THeading}

canEditPages:
layoutDialogBox:

BOOLEAN;
TDialogBox;

frameBody:
paperLRect:
printableLRect:

BOOLEAN;
LRect;
LRect;

contentLRect:

LRect;

printerMetrics:

TPrinterMetrics;

{in view resolution; top and left are > 0 , bot & right < 0}

{the inner rectangle into which chunks of view are stuffed}


{physical properties of the printer}

pageRiseDirection: VHSelect;
{if 'h', it means that page numbers rise from left to right fastest;
if 'v', it means that page numbers rise from top to bottom fastest;
default value is 'h'}
FUNCTION

{TPrintManager.}CREATE(object: TObject; heap: THeap): TPrintManager;

Apple Lisa ToolKit 3.0 Source Code Listing -- 74 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

PROCEDURE {TPrintManager.}Init(itsMainView: TView; itsDfltMargins: LRect);


{PROCEDURE TPrintmanager. Free;}
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
FUNCTION
FUNCTION
FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

{TPrintManager.}AddStripOfPages(vhs: VHSelect);
{TPrintManager.}ChangeMargins(margins: LRect);
{TPrintManager.}ClearPageBreaks(automatic: BOOLEAN);
{TPrintManager.}DrawBreaks(manualOnly: BOOLEAN);
{TPrintManager.}DrawOneBreak(pageBreak: LONGINT; vhs: vhSelect);
{TPrintManager.}DrawPage;
{TPrintManager.}EnterPageEditing;
{TPrintManager.}GetPageLimits(pageNumber: LONGINT; VAR viewLRect: LRect);
{TPrintManager.}NewPaginatedView(object: TObject): TPaginatedView;
{TPrintManager.}NewPageView(object: TObject): TView;
{TPrintManager.}PageWith(VAR lPtInView: LPoint; VAR strip: Point): LONGINT;
{TPrintManager.}Print(printPref: TPrReserve);
{TPrintManager.}ReactToPrinterChange;
{TPrintManager.}RedoBreaks;
{TPrintManager.}SetBreak(vhs: VHSelect; where: LONGINT; isAutomatic: BOOLEAN);
{TPrintManager.}SetDfltHeadings; DEFAULT;
{TPrintManager.}SkipPage(pageNumber: LONGINT);

END; {TPrintManager definition}


TSelection = SUBCLASS OF TObject
{Variables}
window:
panel:
view:
kind:
anchorLPt:
currLPt:
boundLRect:
coSelection:
canCrossPanels:

TWindow;
TPanel;
TView;
INTEGER;
LPoint;
LPoint;
LRect;
TSelection;
BOOLEAN;

{the window in which it was made}


{the panel in which it was made}
{the view or subview of panel in which it was made}
{0 means no selection, rest of codes are defined by view}
{the place the mouse went down (view-relative)}
{the place the mouse was last tracked}
{bounding box of the selection} {+++LSR+++}
{if non-NIL, a selection to forward unimplemented methods to}
{:=TRUE in MousePress/FALSE in MouseRelease for cross-panel drag}

{Creation/Destruction}
FUNCTION {TSelection.}CREATE(object: TObject; heap: THeap; itsView: TView; itsKind: INTEGER;
itsAnchorLPt: LPoint): TSelection;
{FUNCTION
TSelection. Clone(heap: THeap): TObject;}
{clones coSelection}
FUNCTION {TSelection.}FreedAndReplacedBy(selection: TSelection): TSelection;
{Attributes}
PROCEDURE {TSelection.}GetHysteresis(VAR hysterPt: Point); DEFAULT; {rtns a delta from orig panel pt}
PROCEDURE {TSelection.}HaveView(view: TView);
{Files}

Apple Lisa ToolKit 3.0 Source Code Listing -- 75 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

PROCEDURE {TSelection.}MarkChanged; DEFAULT;

{Increment change counters}

{Command Dispatch}
FUNCTION {TSelection.}CanDoCommand(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN): BOOLEAN; DEFAULT;
PROCEDURE {TSelection.}CantDoCmd(cmdNumber: TCmdNumber); DEFAULT;
PROCEDURE {TSelection.}CantDoIt; DEFAULT;
PROCEDURE {TSelection.}DoKey(ascii: CHAR; keycap: Byte; shiftKey, appleKey, optionKey: BOOLEAN);
FUNCTION {TSelection.}NewCommand(cmdNumber: TCmdNumber): TCommand; DEFAULT;
PROCEDURE {TSelection.}PerformCommand(command: TCommand; cmdPhase: TCmdPhase); DEFAULT;
{Idle}
PROCEDURE {TSelection.}IdleBegin(centiSeconds: LONGINT); DEFAULT;
PROCEDURE {TSelection.}IdleContinue(centiSeconds: LONGINT); DEFAULT;
PROCEDURE {TSelection.}IdleEnd(centiSeconds: LONGINT); DEFAULT;
{Editing -PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

to be overridden by applications}
{TSelection.}KeyBack(fWord: BOOLEAN); DEFAULT;
{TSelection.}KeyChar(ch: CHAR); DEFAULT;
{TSelection.}KeyClear; DEFAULT;
{TSelection.}KeyEnter(dh, dv: INTEGER); DEFAULT;
{TSelection.}KeyForward(fWord: BOOLEAN); DEFAULT;
{TSelection.}KeyPause; DEFAULT; {Pause in typing}
{TSelection.}KeyReturn; DEFAULT;
{TSelection.}KeyTab(fBackward: BOOLEAN); DEFAULT;
{TSelection.}SelectParagraphs;

{Drawing -- per pane}


PROCEDURE {TSelection.}Highlight(highTransit: THighTransit); DEFAULT;
{Selecting}
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

{TSelection.}DeSelect; DEFAULT;
{TSelection.}DrawGhost; DEFAULT;
{TSelection.}MousePress(mouseLPt: LPoint); DEFAULT;
{TSelection.}MouseMove(mouseLPt: LPoint); DEFAULT;
{TSelection.}MouseRelease; DEFAULT;
{TSelection.}MoveBackToAnchor; DEFAULT;
{called when cross-panel drag has been refused}

{Undo Maintenance}
PROCEDURE {TSelection.}Restore; DEFAULT;
PROCEDURE {TSelection.}Save; DEFAULT;
{Scroll into view}
PROCEDURE {TSelection.}Reveal(asMuchAsPossible: BOOLEAN); DEFAULT;
END;
TWindow = SUBCLASS OF TArea

Apple Lisa ToolKit 3.0 Source Code Listing -- 76 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

{Variables}
panels:
panelTree:
dialogBox:
selectPanel:
undoSelPanel:
clickPanel:
undoClickPanel:
selectWindow:

TList {OF TPanel};


TArea;
TDialogBox;
TPanel;
TPanel;
TPanel;
TPanel;
TWindow;

undoSelWindow:
wmgrID:
isResizable:
believeWmgr:

TWindow;
TWindowID;
BOOLEAN;
BOOLEAN;

maxInnerSize:

Point;

changes:
lastCmd:
printerMetrics:
pgSzOK:

LONGINT;
TCommand;
TPrinterMetrics;
BOOLEAN;

pgRgOK:

BOOLEAN;

panelToPrint:

TPanel;

objectToFree:

TObject;

{The panels in the window (at least one)}


{no panels: NIL, one panel: that; else a TBranchArea}
{NIL if SELF IS a dialog box window}
{The panel with the active selection}
{The selectPanel during the last command}
{The panel in which the user last clicked in a pane}
{The clickPanel during the last command}
{The window with the active selection -- either
SELF or its Dialogbox }
{the selectWindow during the last command}
{ORD(Pointer to the Window Manager's GrafPort)}
{Is there a Resize Box}
{TRUE iff the Toolkit should believe the window
manager's idea of the size of the window;
this will be FALSE (for example) if we create
the window object before the window is put on
the screen.}
{The window size the user explicitly set with grow
icon}
{How many changes since the last save}
{last undoable command object}
{Properties of the printer currently formatted for}
{Whether to allow user-defined page-sizes in Fmt For
Printer dialog}
{Whether page-range dialog should be enabled in PRINT...
dialog -- normally TRUE}
{NB: IF >1 printable panel in window, choice should be
made by providing separate menu items}
{used to stash a reference to an object which should be
freed at end of event loop}

{Creation/Destruction}
FUNCTION {TWindow.}CREATE(object: TObject; heap: THeap; itsWmgrID: TWindowID; itsResizability
: BOOLEAN): TWindow;
{PROCEDURE TWindow. Free;}
{$IFC fDbgABC}
{Debugging}
PROCEDURE {TWindow.}ToggleFlag(VAR flag: BOOLEAN); DEFAULT; {Toggle a debug flag in a menu}
{$ENDC}
{Attributes}
{PROCEDURE TWindow. GetMinExtent(VAR minExtent: Point; windowIsResizingIt: BOOLEAN);}
PROCEDURE {TWindow.}GetTitle(VAR title: S255); {Get the window title}
FUNCTION {TWindow.}IsActive: BOOLEAN;
FUNCTION {TWindow.}IsVisible: BOOLEAN;
PROCEDURE {TWindow.}SetWmgrId(itsWmgrId: TWindowID); {Also sets port fields of panes}

Apple Lisa ToolKit 3.0 Source Code Listing -- 77 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

{Buttoning}
PROCEDURE {TWindow.}DownEventAt(mousePt: Point); DEFAULT;
{FUNCTION
TWindow. DownAt(mousePt: Point): BOOLEAN;}
{Dialog Box affairs}
PROCEDURE {TWindow.}PutUpDialogBox(dialogBox: TDialogBox); DEFAULT;
PROCEDURE {TWindow.}TakeDownDialogBox; DEFAULT;
{Display}
{PROCEDURE TWindow. Focus;}
{PROCEDURE TWindow. Frame;}
PROCEDURE {TWindow.}Highlight(highTransit: THighTransit); DEFAULT;
{PROCEDURE TWindow. Refresh(rActions: TActions; highTransit: THighTransit);}
PROCEDURE {TWindow.}Update(doHilite: BOOLEAN); DEFAULT;
{Resizing}
PROCEDURE {TWindow.}DownInSizeBox(mousePt: Point); DEFAULT;
PROCEDURE {TWindow.}Resize(moving: BOOLEAN); DEFAULT; {Reset size from portRect size (w. adjustments)}
PROCEDURE {TWindow.}ResizeTo(newSize: Point); DEFAULT; {callable from application}
{Command Dispatch and Menus}
FUNCTION {TWindow.}CanDoCommand(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN): BOOLEAN; DEFAULT;
FUNCTION {TWindow.}CanDoStdCommand(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN): BOOLEAN; DEFAULT;
PROCEDURE {TWindow.}CommitLast; DEFAULT;
PROCEDURE {TWindow.}DoCommand(cmdNumber: TCmdNumber); DEFAULT;
PROCEDURE {TWindow.}LoadMenuBar; DEFAULT;
PROCEDURE {TWindow.}MenuEventAt(mousePt: Point); DEFAULT;
FUNCTION {TWindow.}NewCommand(cmdNumber: TCmdNumber): TCommand; DEFAULT;
FUNCTION {TWindow.}NewStdCommand(cmdNumber: TCmdNumber): TCommand;
PROCEDURE {TWindow.}PerformCommand(newCommand: TCommand);
PROCEDURE {TWindow.}PerformLast(cmdPhase: TCmdPhase);
PROCEDURE {TWindow.}SaveCommand(command: TCommand); {NOTE: do not use the arg after calling this;
use window.lastCmd instead}
PROCEDURE {TWindow.}SetupMenus;
PROCEDURE {TWindow.}UndoLast;
FUNCTION {TWindow.}WantMenu(menuID: INTEGER; inClipboard: BOOLEAN): BOOLEAN;
{Miscellaneous}
PROCEDURE {TWindow.}AbortEvent; {only QuickPort should override this}
{Selection Maintenance during commands}
PROCEDURE {TWindow.}RestoreSelection;
PROCEDURE {TWindow.}RevealSelection(asMuchAsPossible, doHilite: BOOLEAN);
PROCEDURE {TWindow.}SaveSelection;
{Desktop}
{The following 2 methods assume that we are focused on the window before they are called}

Apple Lisa ToolKit 3.0 Source Code Listing -- 78 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

{TWindow.}Activate;
{TWindow.}Deactivate;
{TWindow.}BlankStationery; DEFAULT;
{TWindow.}StashPicture(highTransit: THighTransit);

{$IFC LibraryVersion > 20}


{Desktop Manager Communication}
PROCEDURE {TWindow.}NameToPrefix(VAR error, offset: INTEGER; VAR name, prefix: TFilePath);
PROCEDURE {TWindow.}PrefixToName(VAR error, offset: INTEGER; VAR prefix, name: TFilePath);
(*Convert between OS prefix (ie., '-volname-{DxxxTyyy}' and an icon pathname (ie.,
'<diskname<foldername1<foldername2<...<iconname'). If an error is returned,
offset will point just beyond the part of the name that caused the error, e.g.
if '<office<forms<expenses' returns erDuplicateName and the offset is 14
(pointing to the third '<') then there is more than one 'forms' folder on the
office disk. Error constants are defined above.
NOTE: these methods will likely take a while to execute, since the Desktop Manager
must be swapped in to process the request. Therefore, you should try to minimize the
number of times these are called.*)

{$ENDC}

{Foci of Attention}
FUNCTION {TWindow.}CursorFeedback: TCursorNumber;
PROCEDURE {TWindow.}PickStdCursor;
{Printing}
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
{Filtering}
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

{TWindow.}AcceptNewPrintingInfo(document: TDocManager; prReserve: TPrReserve);


{TWindow.}ChkPrMismatch;
{TWindow.}GetPrinterMetrics;
{TWindow.}Print(panel: TPanel; nixPgRange: BOOLEAN; nixWholeDialog: BOOLEAN);
{TWindow.}EachActualPart(PROCEDURE DoToObject(filteredObj: TObject)); {For app to implement}
{TWindow.}EachVirtualPart(PROCEDURE DoToObject(filteredObj: TObject));
{TWindow.}FilterAndDo(actualObj: TObject; PROCEDURE DoToObject(filteredObj: TObject));
{TWindow.}FilterDispatch(actualObj: TObject; image: TImage;
PROCEDURE DoToObject(filteredObj: TObject));

{Idle}
PROCEDURE {TWindow.}IdleBegin(centiSeconds: LONGINT);
PROCEDURE {TWindow.}IdleContinue(centiSeconds: LONGINT);
PROCEDURE {TWindow.}IdleEnd(centiSeconds: LONGINT);
END;
TDialogBox = SUBCLASS OF TWindow

Apple Lisa ToolKit 3.0 Source Code Listing -- 79 of 1012

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163
001164
001165
001166
001167
001168
001169
001170
001171
001172
001173
001174
001175
001176
001177
001178
001179
001180
001181
001182
001183
001184
001185
001186
001187
001188
001189
001190
001191
001192
001193
001194
001195

{Variables}
keyResponse:
menuResponse:
downInMainWindowResponse:
freeOnDismissal:

TDiResponse;
TDiResponse;
TDiResponse;
BOOLEAN;

{Creation/Destruction}
FUNCTION {TDialogBox.}CREATE(object: TObject; heap: THeap; itsResizability: BOOLEAN;
itsHeight: INTEGER; itsKeyResponse, itsMenuResponse,
itsDownInMainWindowResponse: TDiResponse): TDialogBox;
{Attributes}
{PROCEDURE TDialogBox. GetMinExtent(VAR minExtent: Point; windowIsResizingIt: BOOLEAN);}
{Display}
PROCEDURE {TDialogBox.}Appear;
PROCEDURE {TDialogBox.}BeDismissed; DEFAULT;
PROCEDURE {TDialogBox.}Disappear; DEFAULT;
END;
TBand = SUBCLASS OF TArea
{Variables}
window:
panes:
panel:
scroller:
scrollDir:

TWindow;
TList {OF TPane};
TPanel;
TScroller;
VHSelect;

{the scroll box}


{v if a row of panes with a vertical bar,
h if a column of panes with a horizontal bar}

{Creation/Destruction}
FUNCTION {TBand.}CREATE(object: TObject; heap: THeap; itsPanel: TPanel; itsInnerRect: Rect;
itsScroller: TScroller; itsDir: VHSelect): TBand;
{PROCEDURE TBand. Free;}
{Attributes}
FUNCTION {TBand.}ViewLCd: LONGINT;
{Scrolling}
PROCEDURE {TBand.}OffsetPanes(deltaLPt: LPoint);
PROCEDURE {TBand.}ScrollBy(deltaLCd: LONGINT);
{A TBand can only scroll in one direction; this also moves the thumb}
PROCEDURE {TBand.}ScrollStep(icon: TEnumIcons; deltaLStd: LONGINT);
PROCEDURE {TBand.}ScrollTo(viewLCd: LONGINT);

Apple Lisa ToolKit 3.0 Source Code Listing -- 80 of 1012

Apple Lisa Computer Technical Information


001196
001197
001198
001199
001200
001201
001202
001203
001204
001205
001206
001207
001208
001209
001210
001211
001212
001213
001214
001215
001216
001217
001218
001219
001220
001221
001222
001223
001224
001225
001226
001227
001228
001229
001230
001231
001232
001233
001234
001235
001236
001237
001238
001239
001240
001241
001242
001243

FUNCTION {TBand.}ThumbPos: INTEGER;


PROCEDURE {TBand.}ThumbTo(newThumbPos: INTEGER);
{Resizing}
{PROCEDURE TBand. ResizeOutside(newOuterRect: Rect);}
PROCEDURE {TBand.}ResizePanes(newViewLCd: LONGINT);
END;
TSideBand = SUBCLASS OF TBand
{Fields}
topOrLeft: BOOLEAN;
{NOTE: SELF.scroller is NIL}
FUNCTION

{TSideBand.}CREATE(object: TObject; heap: THeap; itsPanel: TPanel; itsInnerRect: Rect;


itsDir: VHSelect; itsTopOrLeft: BOOLEAN;
itsViewLCd: LONGINT): TSideBand;

{Attributes}
FUNCTION {TSideBand.}CoBand: TBand;
{returns the band adjacent to SELF}
END;
TPanel = SUBCLASS OF TArea
{Variables}
window:
panes:
currentView:
view:
paginatedView:
selection:
undoSelection:
bands:
scrollBars:
abilities:
minInnerDiagonal:
resizeBranch:
zoomed:
zoomFactor:
previewMode:
lastClick:

{panes
TWindow;
TList {OF TPane};
TView;
TView;
TPaginatedView;
TSelection;
TSelection;
ARRAY[VHSelect] OF TList;
ARRAY[VHSelect] OF TScrollBar;
ARRAY[VHSelect] OF TAbilities;
Point;
TBranchArea;
BOOLEAN;
TScaler;
TPreviewMode;
RECORD
CASE gotPane: BOOLEAN OF
TRUE: (clickPane: TPane);
FALSE: (clickPt: Point);

are listed row-wise in the panes list}


{The view seen through SELF: normal or paginated}
{The unpaginated view seen through SELF }
{NIL if not previewing margins}
{the current selection}
{the selection to be restored for an undo/redo}
{redundant... bands[v].at(1) = top row of panes}
{scrollBars[(v,h)]--the (vert,horiz) scroll bars}
{[aBar, aScroll, aSplit, aResize]}
{the branch that my botRight resizes, or NIL}

{describes the pane the user last clicked}


{the last pane the user clicked on}
{the innerRect.topLeft of lastClick.pane,

Apple Lisa ToolKit 3.0 Source Code Listing -- 81 of 1012

Apple Lisa Computer Technical Information


001244
001245
001246
001247
001248
001249
001250
001251
001252
001253
001254
001255
001256
001257
001258
001259
001260
001261
001262
001263
001264
001265
001266
001267
001268
001269
001270
001271
001272
001273
001274
001275
001276
001277
001278
001279
001280
001281
001282
001283
001284
001285
001286
001287
001288
001289
001290
001291

in the case where the lastClick.pane was


deleted}

END;
contentRect:
Rect;
{part of the innerRect not containing side bands}
tlSideBandSize:
Point; {size of topLeft side bands}
brSideBandSize:
Point;
{NOTE: The sideband sizes refer to the size of the innerRect of the side band;
therefore a size of -1 means there is no side band on that side}
deletedSplits:
TArray; {If NIL, don't remember splits that go away because the panel
shrinks. Otherwise, this should be a TArray with recordBytes
2. This is initialized to NIL in TPanel.CREATE; clients can
allocate an array and change the field if they desire.}
{Creation/Destruction}
FUNCTION {TPanel.}CREATE(object: TObject; heap: THeap; itsWindow: TWindow;
minHeight, minWidth: INTEGER; itsVAbilities, itsHAbilities: TAbilities): TPanel;
{PROCEDURE TPanel. Free;}
PROCEDURE {TPanel.}HaveView(view: TView);
FUNCTION {TPanel.}NewView(object: TObject; itsExtent: LRect; itsPrintManager: TPrintManager;
itsDfltMargins: LRect; itsFitPerfectlyOnPages: BOOLEAN): TView;
FUNCTION {TPanel.}NewStatusView(object: TObject; itsExtent: LRect): TView;
{Attributes}
PROCEDURE {TPanel.}ComputeContentRect;
PROCEDURE {TPanel.}DecideAboutBars(newOuterRect: Rect); {Decide if to have scroll bars & resize icon}
{PROCEDURE TPanel. GetMinExtent(VAR minExtent: Point; windowIsResizingIt: BOOLEAN);}
{PROCEDURE TPanel. GetBorder(VAR border: Rect);}
FUNCTION {TPanel.}FindBranchThatIsResized: TBranchArea;
FUNCTION {TPanel.}PaneShowing(anLRect: LRect): TPane; {Returns first pane showing an part
of anLRect, else NIL}
PROCEDURE {TPanel.}SetInnerRect(newInnerRect: Rect); OVERRIDE;
PROCEDURE {TPanel.}SetOuterRect(newOuterRect: Rect); OVERRIDE;
{Paneling the window}
FUNCTION {TPanel.}Divide(vhs: VHSelect;
fromEdgeOfPanel: INTEGER; units: TUnitsFromEdge;
whoCanResizeIt: TResizability;
minSize: INTEGER; itsVAbilities, itsHAbilities: TAbilities): TPanel;
PROCEDURE {TPanel.}Insert(panel: TPanel; vhs: VHSelect;
fromEdgeOfPanel: INTEGER; units: TUnitsFromEdge;
whoCanResizeIt: TResizability);
{Resizes both to share my space}
PROCEDURE {TPanel.}Remove;
{Does not Free SELF; Expands sibling to fill my space}
PROCEDURE {TPanel.}Replace(panel: TPanel); {Does not Free SELF; Resizes panel to fit my old space}
{Buttoning}
{FUNCTION
TPanel. DownAt(mousePt: Point): BOOLEAN;}
PROCEDURE {TPanel.}DownInSizeBox(mousePt: Point);
PROCEDURE {TPanel.}HitScroller(vhs: VHSelect; mousePt: Point; scroller: TScroller; icon: TEnumIcons);

Apple Lisa ToolKit 3.0 Source Code Listing -- 82 of 1012

Apple Lisa Computer Technical Information


001292
001293
001294
001295
001296
001297
001298
001299
001300
001301
001302
001303
001304
001305
001306
001307
001308
001309
001310
001311
001312
001313
001314
001315
001316
001317
001318
001319
001320
001321
001322
001323
001324
001325
001326
001327
001328
001329
001330
001331
001332
001333
001334
001335
001336
001337
001338
001339

(*

{Selecting}
PROCEDURE {TPanel.}BeginSelection;
PROCEDURE {TPanel.}BeSelectPanel(inSelectWindow: BOOLEAN);
FUNCTION {TPanel.}NoSelection: TSelection; *)
{Cursor tracking}
FUNCTION {TPanel.}CursorAt(mousePt: Point): TCursorNumber;
{Display}
{PROCEDURE TPanel. Frame;}
PROCEDURE {TPanel.}Highlight(selection: TSelection; highTransit: THighTransit);
{ this highlights the selection on all pads }
PROCEDURE {TPanel.}Invalidate;
{ this invalidates the whole panel }
PROCEDURE {TPanel.}InvalLRect(lRectInView: LRect);
{ this invalidates the given LRect on all pads }
FUNCTION {TPanel.}OKToDrawIn(lRectInView: LRect): BOOLEAN;
{ If this returns FALSE, commands must InvalLRect or XOR, not Draw or Erase }
PROCEDURE {TPanel.}OnAllPadsDo(PROCEDURE DoOnThePad);
{PROCEDURE TPanel. Refresh(rActions: TActions; highTransit: THighTransit);}
PROCEDURE {TPanel.}Rescroll;
PROCEDURE {TPanel.}SetZoomFactor(zoomNumerator, zoomDenominator: Point);
{Page-Previewing}
PROCEDURE {TPanel.}Preview(newMode: TPreviewMode);
{Printing}
PROCEDURE {TPanel.}PrintView(printPref: TPrReserve);
{Scrolling}
PROCEDURE {TPanel.}AutoScroll(mousePt: Point);
PROCEDURE {TPanel.}DoScrolling(inArea: TArea; itsPane: TPane;
hOk, vOk: BOOLEAN; VAR deltaLPt: LPoint);
{inArea must be a TBand or a TPane; if a TPane then inArea=itsPane;
if a TBand then itsPane is any one of the band's panes}
FUNCTION {TPanel.}PaneToScroll(VAR anLRect: LRect; hMinToSee, vMinToSee: INTEGER): TPane;
{Returns the pane to scroll for showing the minimum desired part ofLRect;
if that part is already showing, it returns NIL;
NOTE: anLRect is NOT changed}
PROCEDURE {TPanel.}RevealLRect(VAR anLRect: LRect; hMinToSee, vMinToSee: INTEGER);
{Show at least the desired part of the LRect in the pane returned by PaneToShow;
NOTE: anLRect is NOT changed}
{Splitting}
PROCEDURE {TPanel.}CleanUpPanes(deleteList: TList);
PROCEDURE {TPanel.}MakeBand(vhs: VHSelect; scroller, prevScroller: TScroller);
PROCEDURE {TPanel.}MoveSplitBefore(scroller: TScroller; newSkwrCd: INTEGER);

Apple Lisa ToolKit 3.0 Source Code Listing -- 83 of 1012

Apple Lisa Computer Technical Information


001340
001341
001342
001343
001344
001345
001346
001347
001348
001349
001350
001351
001352
001353
001354
001355
001356
001357
001358
001359
001360
001361
001362
001363
001364
001365
001366
001367
001368
001369
001370
001371
001372
001373
001374
001375
001376
001377
001378
001379
001380
001381
001382
001383
001384
001385
001386
001387

FUNCTION
FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

{TPanel.}NewBand(heap: THeap; myInnerRect: Rect;


scroller: TScroller; vhs: VHSelect): TBand;
{TPanel.}NewPane(heap: THeap; innerRect: Rect; viewedLRect: LRect): TPane;
{TPanel.}RemakePanes;
{TPanel.}RememberSplit(vhs: VHSelect; atCd: INTEGER);
{TPanel.}RepaneOrthogonalBands(vhs: VHSelect);
{TPanel.}RestoreSplits;

{Side Bands}
PROCEDURE {TPanel.}ShowSideBand(vhs: VHSelect; topOrLeft: BOOLEAN; size: INTEGER; viewLCd: LONGINT);
PROCEDURE {TPanel.}SideBandRect(vhs: VHSelect; topOrLeft: BOOLEAN; VAR bandRect: Rect);
{returns the innerRect of the side band, given SELF.contentRect}
{Resizing}
PROCEDURE {TPanel.}ResizeBand(vhs: VHSelect; band: TBand; newViewLCd: LONGINT;
fInvalidate: BOOLEAN);
{PROCEDURE TPanel. ResizeInside(newInnerRect: Rect);}
{PROCEDURE TPanel. ResizeOutside(newOuterRect: Rect);}
END;
TPane = SUBCLASS OF TPad
{Variables}
currentView:
panel:

TView;
TPanel;

{The view that is currently}


{The containing panel}

{Creation/Destruction}
FUNCTION {TPane.}CREATE(object: TObject; heap: THeap; itsPanel: TPanel; itsInnerRect: Rect;
itsViewedLRect: LRect): TPane;
PROCEDURE {TPane.}HaveView(view: TView);
{Attributes}
PROCEDURE {TPane.}GetScrollLimits(VAR viewedLRect, scrollableLRect: LRect);
{PROCEDURE TPane. SetZoomFactor(zoomNumerator, zoomDenominator: Point);}
{Selecting}
PROCEDURE {TPane.}MouseTrack(mPhase: TMousePhase; mousePt: Point);
{assumes mousePt is in the pane's innerRect}
{Cursor tracking}
FUNCTION {TPane.}CursorAt(mousePt: Point): TCursorNumber;
{Display}
{PROCEDURE

TPane. Refresh(rActions: TActions; highTransit: THighTransit);}

{Resizing}

Apple Lisa ToolKit 3.0 Source Code Listing -- 84 of 1012

Apple Lisa Computer Technical Information


001388
001389
001390
001391
001392
001393
001394
001395
001396
001397
001398
001399
001400
001401
001402
001403
001404
001405
001406
001407
001408
001409
001410
001411
001412
001413
001414
001415
001416
001417
001418
001419
001420
001421
001422
001423
001424
001425
001426
001427
001428
001429
001430
001431
001432
001433
001434
001435

PROCEDURE {TPane.}Resize(newInnerRect: Rect; vhs: VHSelect);


{Scrolling}
PROCEDURE {TPane.}ScrollBy(VAR deltaLPt: LPoint);
{NOTE: deltaLPt is NOT changed; also moves the thumb(s)}
PROCEDURE {TPane.}ScrollToReveal(VAR anLRect: LRect; hMinToSee, vMinToSee: INTEGER);
{NOTE: anLRect is NOT changed}
END;
TMarginPad = SUBCLASS OF TPad
{Variables}
view:
pageNumber:
bodyPad:

TView;
{The view seen on the BODY of this page}
LONGINT;
TBodyPad;

{Creation/Destruction}
FUNCTION {TMarginPad.}CREATE(object: TObject; heap: THeap): TMarginPad;
PROCEDURE {TMarginPad.}Rework(itsView: TView; itsOrigin: Point; itsRes: Point;
itsPageNumber: LONGINT; itsZoomFactor: TScaler; itsPort: GrafPtr);
PROCEDURE {TMarginPad.}SetForPage(itsPageNumber: LONGINT; itsOrigin: Point);
{Display}
{PROCEDURE

TMarginPad. Focus;}

{Process termination and Debugging Assistance}


{PROCEDURE TMarginPad. Crash;}
{FUNCTION TMarginPad. BindHeap(activeVsClip, doBind: BOOLEAN): THeap;}
END;
TBodyPad = SUBCLASS OF TPad
{Variables}
marginPad:
TMarginPad; {the page shell whose body I am}
nonNullBody: Rect; {the portion of the pad in the range of the mapped view;
BodyPad.innerRect = nonNullBody unless manual pagebreak or end-of-view forces
a shortage of view to map into entire inner rect} {someday make this comment comprehensible}
{Creation/Destruction}
FUNCTION {TBodyPad.}CREATE(object: TObject; heap: THeap; itsMarginPad: TMarginPad): TBodyPad;
PROCEDURE {TBodyPad.}Recompute;
PROCEDURE {TBodyPad.}SetForPage(itsPageNumber: LONGINT);
{Display}

Apple Lisa ToolKit 3.0 Source Code Listing -- 85 of 1012

Apple Lisa Computer Technical Information


001436
001437
001438
001439
001440
001441
001442
001443
001444
001445
001446
001447
001448
001449
001450
001451
001452
001453
001454
001455
001456
001457
001458
001459
001460
001461
001462
001463
001464
001465
001466
001467
001468
001469
001470
001471
001472
001473
001474
001475
001476
001477
001478
001479
001480
001481
001482
001483

{PROCEDURE

TBodyPad. Focus;}

END;
TScroller = SUBCLASS OF TObject
{Variables}
scrollBar:
band:
sBoxID:

TScrollBar;
TBand;
TSBoxID;

{the scroll bar of which it is part}


{the object that can respond to scroll events}
{the scroll-bar-library representation}

{Creation/Destruction}
FUNCTION {TScroller.}CREATE(object: TObject; heap: THeap; itsScrollBar: TScrollBar; itsId: TSBoxID)
: TScroller;
{PROCEDURE TScroller. Free;}
{Attributes}
PROCEDURE {TScroller.}GetSize(VAR boxRect: Rect);
FUNCTION {TScroller.}ScrollDir: VHSelect;
PROCEDURE {TScroller.}SetSize(ownerRect: Rect);
FUNCTION {TScroller.}ThumbRange: INTEGER;
{Buttoning}
PROCEDURE {TScroller.}TrackSkewer(mousePt: Point; VAR newSkwrCd: INTEGER;
VAR scroller, prevScroller: TScroller);
PROCEDURE {TScroller.}TrackThumb(mousePt: Point; VAR oldThumbPos, newThumbPos: INTEGER);
{Display}
PROCEDURE {TScroller.}FillIcon(icon: TEnumIcons; fBlack: BOOLEAN);
PROCEDURE {TScroller.}MoveThumb(newThumbPos: INTEGER);
{Splitting}
PROCEDURE {TScroller.}ResplitAt(newSkwrCd: INTEGER; prevScroller: TScroller);
PROCEDURE {TScroller.}SplitAt(newSkwrCd: INTEGER; VAR nextScroller: TScroller);
END;
TScrollBar = SUBCLASS OF TObject
{Variables}
firstBox:
isVisible:

TScroller;
BOOLEAN;

{the rest are found via the SB Library}


{TRUE iff this scroll bar should be drawn}

{Creation/Destruction}
FUNCTION {TScrollBar.}CREATE(object: TObject; heap: THeap; vhs: VHSelect; outerRect: Rect;
itsVisibility: BOOLEAN): TScrollBar;

Apple Lisa ToolKit 3.0 Source Code Listing -- 86 of 1012

Apple Lisa Computer Technical Information


001484
001485
001486
001487
001488
001489
001490
001491
001492
001493
001494
001495
001496
001497
001498
001499
001500
001501
001502
001503
001504
001505
001506
001507
001508
001509
001510
001511
001512
001513
001514
001515
001516
001517
001518
001519
001520
001521
001522
001523
001524
001525
001526
001527
001528
001529
001530
001531

PROCEDURE {TScrollBar.}ChangeVisibility(needsBothBars: BOOLEAN;


bandOuterRect: Rect; itsAbilities: TAbilities);
{Buttoning}
FUNCTION {TScrollBar.}DownAt(mousePt: Point; VAR scroller: TScroller; VAR icon: TEnumIcons): BOOLEAN;
{Display}
PROCEDURE {TScrollBar.}Draw;
PROCEDURE {TScrollBar.}Erase;
END;
TMenuBar = SUBCLASS OF TObject {only one instance exists (menuBar)}
{Variables}
isLoaded:
mapping:
numMenus:
numCommands:

ARRAY [1..maxMenus] OF BOOLEAN;


TArray {OF TWmgrCmd};
INTEGER;
INTEGER;

{TRUE iff the i'th menu has been inserted}


{maps command number to menu & item indices}
{how many menus}
{how many commands in all menus together}

{Creation/Destruction}
FUNCTION {TMenuBar.}CREATE(object: TObject; heap: THeap; itsScanner: TFileScanner): TMenuBar;
{Attributes}
PROCEDURE {TMenuBar.}Check(cmdNumber: TCmdNumber; checked: BOOLEAN);
PROCEDURE {TMenuBar.}Enable(cmdNumber: TCmdNumber; canBeChosen: BOOLEAN);
PROCEDURE {TMenuBar.}BuildCmdName(destCmd, templateCmd: TCmdNumber; param: TPString);
{if param is NIL, use the default}
FUNCTION {TMenuBar.}GetCmdName(cmdNumber: TCmdNumber; pName: TPString): BOOLEAN;
{returns TRUE iff cmdNumber is found (pName will be empty);
pName can be NIL, which will save the overhead of returning the
menu item, for case where you just want to see if it exists}
PROCEDURE {TMenuBar.}PutCmdName(cmdNumber: TCmdNumber; pName: TPString);
{Buttoning}
FUNCTION {TMenuBar.}CmdKey(ch: CHAR): TCmdNumber;
FUNCTION {TMenuBar.}DownAt(mousePt: Point): TCmdNumber;
{Display}
PROCEDURE {TMenuBar.}Draw;
PROCEDURE {TMenuBar.}EndCmd;
PROCEDURE {TMenuBar.}HighlightMenu(withCmd: TCmdNumber);
{call this when the user presses the CLEAR key for example, to highlight
the appropriate menu title; you should then call window.DoCommand with
an apropriate command number.}
{Loading}

Apple Lisa ToolKit 3.0 Source Code Listing -- 87 of 1012

Apple Lisa Computer Technical Information


001532
001533
001534
001535
001536
001537
001538
001539
001540
001541
001542
001543
001544
001545
001546
001547
001548
001549
001550
001551
001552
001553
001554
001555
001556
001557
001558
001559
001560
001561
001562
001563
001564
001565
001566
001567
001568
001569
001570
001571
001572
001573
001574
001575
001576
001577
001578
001579

PROCEDURE {TMenuBar.}Delete(menuID: INTEGER);


PROCEDURE {TMenuBar.}Insert(menuID, beforeId: INTEGER);
PROCEDURE {TMenuBar.}Unload;
{For Future Use}
FUNCTION {TMenuBar.}MenuWithID(menuID: INTEGER): Ptr;
END;
{$IFC LibraryVersion <= 20 AND FALSE} {do it this way in case we need it back for Pepsi version}
TFont = SUBCLASS OF TObject
{Variables}
family:

INTEGER;

{Font Manager TFam}

{Creation/Destruction}
FUNCTION {TFont.}CREATE(object: TObject; heap: THeap; itsFamily: INTEGER): TFont;
{$ENDC}

END;

{ GLOBAL VARIABLES -- EFFECTIVELY, FIELDS OF CLASS TProcess }


VAR
activeWindowID:
allowAbort:
autoBreakPen:
blinkOffCentiSecs:
blinkOnCentiSecs:
boundClipboard:
boundDocument:
cancelString:
clickState:
clipboard:
clipPrintPref:
closedBySuspend:
closedDocument:
cornerNumberStyle:
countryCode:
currentDocument:

TWindowID;
BOOLEAN;
PenState;
LONGINT;
LONGINT;
TClipboard;
TDocManager;
STRING[20];
TClickState;
TClipboard;
TPrReserve;
BOOLEAN;
TDocManager;
TTypeStyle;
INTEGER;
TDocManager;

currentWindow:
cursorShape:
deferUpdate:
dfltNewHeading:
docList:
eventTime:

TWindow;
TCursorNumber;
BOOLEAN;
STRING[20]; {+SW+}
TList {OF TDocManager};
LONGINT;

{The wmgrID field of the active document, or 0}


{Iff TRUE, allow aborts}
{pen to use to draw automatic page breaks}
{Centiseconds to hide the insertion point}
{Centiseconds to display the insertion point}
{The clipboard whose data segment is bound, or NIL}
{The document whose data segment is bound, or NIL}
{The word "Cancel" for use in buttons}
{Shifts and repeats of the last mouse click}
{The Clipboard document manager}
{the print-preference for the clipboard}
{Iff TRUE, closedDocument was just suspended}
{If not NIL, this document was just put away}
{TypeStyle used for page-numbers in page-preview}
{The country code as read from phrase file}
{The active document OR if running in background, the
document to use; otherwise NIL}
{currentDocument.window, OR NIL}
{The cursor shape as recorded by TProcess.ChangeCursor}
{set TRUE by app to defer updating while typing}
{Default value for newly-created headings}
{The documents that are open}
{The time of the most recent WM event}

Apple Lisa ToolKit 3.0 Source Code Listing -- 88 of 1012

Apple Lisa Computer Technical Information


001580
001581
001582
001583
001584
001585
001586
001587
001588
001589
001590
001591
001592
001593
001594
001595
001596
001597
001598
001599
001600
001601
001602
001603
001604
001605
001606
001607
001608
001609
001610
001611
001612
001613
001614
001615
001616
001617
001618
001619
001620
001621
001622
001623
001624
001625
001626
001627

eventType:
INTEGER;
{The type number of the most recent WM event}
{$IFC fDbgABC}
fExperimenting:
BOOLEAN;
{IF TRUE, enable zoom experimentation etc.}
fCountHeap:
BOOLEAN;
{Iff TRUE and IFC fCheckHeap, count objects once per cmd}
{$ENDC}
{$IFC LibraryVersion <= 20 AND FALSE} {do it this way in case we need it back for the Pepsi version}
fonts:
ARRAY [0..maxFonts] OF TFont;
{$ENDC}
genClipPic:
BOOLEAN;
{Iff TRUE, we are generating the Clipboard picture}
highLevel:
ARRAY [BOOLEAN] OF THighTransit;
{TRUE=>hOffToOn, FALSE=>hOffToDim}
highToggle:
ARRAY [BOOLEAN] OF THighTransit;
{TRUE=>hOffToOn, FALSE=>hOnToOff}
idleTime:
LONGINT;
{The time we finished processing the last user input}
inBackground:
BOOLEAN;
{Iff TRUE, currently running in background}
limboPen:
PenState;
{pen to use to fill limbo area in paginated view}
manualBreakPen:
PenState;
{pen to use to draw manual page breaks}
marginPattern:
LPattern;
{pattern to use to fill margins in paginated view}
menuBar:
TMenuBar;
{The menus of the application and the Clipboard}
myProcessID:
LONGINT;
{The OS ID of this process}
myTool:
LONGINT;
{The tool number of this tool}
normalPen:
PenState;
{pen state resulting from PenNormal}
okString:
STRING[20];
{The word "OK" for use in buttons}
phraseFile:
TFileScanner;
{The Main Phrase File TFileScanner}
process:
TProcess;
{The process object of this process}
screenRightEdge:
scrollRgn:
stdMargins:
suspendSuffix:
theBodyPad:
theMarginPad:
toolName:
toolPrefix:
toolVolume:
varPage:
varTitle:
wordDelimiters:

INTEGER;
{720 for Lisa 1.0 screen}
RgnHandle;
{what needs to be refreshed because of scroll}
LRect;
{standard page-margins, in screen pixels}
ARRAY [1..maxSegments] OF STRING[3];
TBodyPad;
{current BodyPad being written to}
TMarginPad;
{current MarginPad being written to}
STRING[67];
{The name of the tool}
TFilePath;
(*The prefix '{Tnn}' of the OS path name of the tool*)
TFilePath;
{The volume '-name-' on which the tool resides}
STRING[20]; {+SW+}
{The string 'PAGE', for use in heading variables}
STRING[20]; {+SW+}
{The string 'TITLE' for use in heading variables}
STRING[67];
{The delimiters of a Lisa "word" in this language}

PROCEDURE GetPrefixPart(wholeName: S255; VAR filePart: TFilePath); (*'{prefix}'*)


FUNCTION ToolOfFile(wholeName: S255): LONGINT;
FUNCTION ToolOfProcess(processId: LONGINT): LONGINT;
{ Used to insert comments into the Universal Graph of Clipboard, so LisaDraw can understand it;
These procedures only insert comment when we are generating the Universal Graph }
{ beginning of a series of text drawing ops that should be grouped }
PROCEDURE PicTextBegin(alignment: TAlignment);
PROCEDURE PicTextEnd;
{ end of series }
PROCEDURE PicGrpBegin;
{ beginning of a series of grouped objects }

Apple Lisa ToolKit 3.0 Source Code Listing -- 89 of 1012

Apple Lisa Computer Technical Information


001628
001629
001630
001631
001632
001633
001634
001635
001636
001637
001638
001639
001640
001641
001642
001643
001644
001645
001646
001647
001648
001649
001650
001651
001652
001653

PROCEDURE PicGrpEnd;

{ end of series }

PROCEDURE InitProcess;
FUNCTION GetTime: LONGINT;
{This function returns the same "time" as is used in events (see global variable eventTime),
and in the idle loop}
IMPLEMENTATION
{$I LIBTK/UABC2.TEXT}
{$I LIBTK/UABC3.TEXT}
{$I LIBTK/UABC4.TEXT}
{$I LIBTK/UABC5.TEXT}
(**********
{$I UABC2.TEXT}
{$I UABC3.TEXT}
{$I UABC4.TEXT}
{$I UABC5.TEXT}
**********)

{TProcess-TDocDirectory-TDocManager-TClipboard-TCommand-TCutCopyCommandTPasteCommand}
{TImage-TView-TPaginatedView-TPageView-TPrintManager-THeading-TSelection}
{TWindow-TDialogBox-TMenuBar-TFont}
{TPanel-TBand-TPane-TMarginPad-TBodyPad-TScroller-TScrollBar}

{TProcess-TDocDirectory-TDocManager-TClipboard-TCommand-TCutCopyCommand-TPasteCommand}
{TImage-TView-TPaginatedView-TPageView-TPrintManager-THeading-TSelection}
{TWindow-TDialogBox-TMenuBar-TFont}
{TPanel-TBand-TPane-TMarginPad-TBodyPad-TScroller-TScrollBar}

END.

End of File -- Lines: 1653 Characters: 71219

Apple Lisa ToolKit 3.0 Source Code Listing -- 90 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UABC2.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{INCLUDE FILE UABC2 -- IMPLEMENTATION OF UABC}


{Copyright 1983, 1984, Apple Computer, Inc.}
{TProcess-TDocDirectory-TDocManager-TClipboard-TCommand-TCutCopyCommand-TPasteCommand}
{Segments: SgABCini(tialize and Terminate), SgABCres(ident), SgABCc(o)ld, SgABCdbg, SgABCpri(nting)}
{$IFC fRngABC}
{$R+}
{$ELSEC}
{$R-}
{$ENDC}
{$IFC fSymABC}
{$D+}
{$ELSEC}
{$D-}
{$ENDC}
CONST toolKitType = 9;
{ picture comment IDs for pasting into LisaDraw }
cPicGeDwg
=
100;
cPicTxtBegin =
101;
cPicTxtEnd
=
102;
cPicGrpBegin =
103;
cPicGrpEnd
=
104;
TYPE TPrPrfAlias = RECORD
CASE INTEGER OF
{$IFC libraryVersion <= 20}
{ P E P S I }
1: (prPrf: TPrPrf; prIns: TPrIns);
{$ELSEC}
1: (prPrf: TPrRec);
{$ENDC}
{ S P R I N G}
2: (reserve: TPrReserve);
END;
TMapTable = RECORD
header:
table:
END;

{Alias for Print Preference}

{Alias for menuBar.mapping TArray}


TArrayHeader;
ARRAY [1..8000] OF TWmgrCmd;

Apple Lisa ToolKit 3.0 Source Code Listing -- 91 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

TMapPtr = ^TMapTable;
TMapHandle = ^TMapPtr;
VAR

alerts:
event:
{$IFC fDbgABC}
hadToBindClip:
{$ENDC}
scrRgn1ForDrawHdgs:
scrRgn2ForDrawHdgs:
wmgrMenus:
cSelection:
picData:

TAlertFile;
EventRecord;

{The Alert Manager alert handle for the Main Phrase File}
{The last event received by this process}

BOOLEAN;

{BindHeap had to bind the Clipboard}

RgnHandle;
{Reserved for use dy TPaginatedView.AdornPageOnScreen}
RgnHandle;
{Reserved for use dy TPaginatedView.AdornPageOnScreen}
ARRAY [1..maxMenus] OF MenuInfo;
TClass;
{The TClass of TSelection, used by TPasteCmd.Perform}
TH;
{Pre-allocated handle on MainHeap used for picture
comments}

PROCEDURE InAllMenusDo(iffLoaded: BOOLEAN; theCommand: TCmdNumber;


PROCEDURE doProc(VAR menu: MenuInfo; itemIndex: INTEGER)); FORWARD;
{$S sScroll}
PROCEDURE PreSbList(VAR sbList: TSbList; scrollBar: TScrollBar);
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
sbList.hz := POINTER(ORD(scrollBar.Heap));
IF scrollBar.firstBox = NIL THEN
sbList.hsbFst := hsbNil
ELSE
sbList.hsbFst := POINTER(scrollBar.firstBox.sBoxID);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sScroll}
PROCEDURE PostSbList(sbList: TSbList; scrollBar: TScrollBar);
VAR scroller: TScroller;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
IF sbList.hsbFst = hsbNil THEN
scroller := NIL
ELSE
scroller := POINTER(RefconSb(sbList.hsbFst));
scrollBar.firstBox := scroller;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 92 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

{$S sStartup}
PROCEDURE GetPrefixPart{(wholeName: S255; VAR filePart: TFilePath)}; (*'{prefix}'*)
(* This works ONLY on Desktop Manager file names of the form '-volname-{prefix}suffix' *)
VAR centerHyphen: INTEGER;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
centerHyphen := Pos('-{', wholeName);
filePart := Copy(wholeName, centerHyphen+1, Pos('}',wholeName) - centerHyphen);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCldInit}
FUNCTION ToolOfFile{(wholeName: S255): LONGINT};
VAR toolNumber: LONGINT;
toolPrefix: TFilePath;
cvResult:
TConvResult;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
GetPrefixPart(wholeName, toolPrefix);
Delete(toolPrefix, 1, 2); (* The '{T' *)
Delete(toolPrefix, Length(toolPrefix), 1); (* The final '}' *)
StrToLInt(@toolPrefix, toolNumber, cvResult);
IF cvResult <> cvValid THEN
ToolOfFile := 0
ELSE
ToolOfFile := toolNumber;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCldInit}
FUNCTION ToolOfProcess{(processId: LONGINT): LONGINT};
VAR prcsInfo:
ProcInfoRec;
error:
INTEGER;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
Info_Process(error, processID, prcsInfo);
IF error > 0 THEN
ToolOfProcess := 0
ELSE
ToolOfProcess := ToolOfFile(prcsInfo.progPathname);
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDbgABC}
{$S SgABCdbg}

Apple Lisa ToolKit 3.0 Source Code Listing -- 93 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

PROCEDURE ReportEvent;
VAR winTitle:
Str255;
BEGIN
Write(toolName, ' P=#', myProcessId:1, ' received ');
WITH event DO
BEGIN
CASE what OF
buttonDown:
Write('Button-down');
buttonUp:
Write('Button-up');
folderActivate:
Write('Activate');
folderDeactivate:
Write('Deactivate');
folderMoved:
Write('Window-moved');
folderUpdate:
Write('Update');
keyDown:
Write('Key-press');
filerEvent:
Write('Desktop');
OTHERWISE
Write('Miscellaneous');
END;
Write(' event for the ');
IF who = alertFolder THEN
WriteLn('Alert Box')
ELSE
IF who = dialogFolder THEN
WriteLn('Dialog Box')
ELSE
IF who = scrapFolder THEN
WriteLn('Clipboard')
ELSE
IF who = menuFolder THEN
WriteLn('Menu Bar')
ELSE
BEGIN
GetFldrTitle(who, winTitle);
WriteLn('window titled "', winTitle, '"');
END;
END;
END;
{$S SgABCdbg}
PROCEDURE ReportFilerEvent(flrParams: FilerExt);
BEGIN
Write('
');
WITH flrParams DO
BEGIN
CASE theFlrOp OF
fcClose:
fcCopy:

Write('Close
Write('Copy

');
');

Apple Lisa ToolKit 3.0 Source Code Listing -- 94 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

END;
{$ENDC}

fcDfClose:
Write('Doc File Close');
fcNone:
Write('Open Tool
');
fcPut:
Write('Put
');
fcResume:
Write('Open Doc
');
fcShred:
Write('Shred
');
fcSuspend:
Write('Suspend
');
fcTerminate:
Write('Terminate
');
OTHERWISE
Write('Unknown!!!
');
END;
{$IFC LibraryVersion <= 20}
WriteLn(' theErr=', theErr:1, ' theDF=', theDF:1);
WriteLn(' thePrefix="', thePrefix, '"');
{$ELSEC}
WriteLn(' theErr=', theErr:1, ' theOffset=', theOffset:1, '
WriteLn(' thePassword="', thePassword, '"');
WriteLn(' thePrefix="', thePrefix, '"');
WriteLn(' theResult="', theResult, '"');
{$ENDC}
END;

theDF=', theDF:1);

{$S sError}
PROCEDURE AlErrProc;
BEGIN
StopAlert(alerts, 2);
process.Complete(FALSE);
END;
{$S sCldInit}
FUNCTION ExpandHeap(heap: THeap; bytesNeeded: INTEGER): INTEGER;
VAR alias:
RECORD CASE INTEGER OF 1: (address: TPPrelude); 2: (high, low: INTEGER) END;
preludePtr:
TPPrelude;
oldHeapSize:
LONGINT;
newHeapSize:
LONGINT;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
alias.address := POINTER(ORD(heap));
alias.low := 0;
preludePtr := alias.address;
{$IFC fDbgABC}
IF boundDocument.dataSegment.preludePtr <> preludePtr THEN
ABCBreak('boundDocument''s preludePtr <> preludePtr in ExpandHeap', ORD(heap));
{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 95 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

oldHeapSize := CbOfHz(POINTER(ORD(heap)));
boundDocument.ExpandMemory(bytesNeeded);
WITH boundDocument.dataSegment.preludePtr^ DO
newHeapSize := docSize - preludeSize;
ExpandHeap := newHeapSize - oldHeapSize;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
PROCEDURE PicTextBegin{(alignment: TAlignment)};
TYPE
TpByte = ^Byte;
ThByte = ^TpByte;
VAR
FEalign:
Byte;
BEGIN
IF genClipPic THEN
BEGIN
FEalign := ORD(alignment) + 1;
IF FEalign > 3 THEN
FEalign := 1; {aLeft}
ThByte(picData)^^ := FEalign; {currently, picData is always a handle to 1 byte}
{$IFC LibraryVersion <= 20}
PicComment(cPicTxtBegin, SIZEOF(FEalign), Handle(picData));
{$ELSEC}
PicComment(cPicTxtBegin, SIZEOF(FEalign), QDHandle(picData));
{$ENDC}
END;
END;
{$S SgABCcld}
PROCEDURE PicTextEnd;
{ end of series }
BEGIN
IF genClipPic THEN
PicComment(cPicTxtEnd, 0, NIL);
END;
{$S SgABCcld}
PROCEDURE PicGrpBegin;
{ beginning of a series of grouped objects }
BEGIN
IF genClipPic THEN
PicComment(cPicGrpBegin, 0, NIL);
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 96 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

{$S SgABCcld}
PROCEDURE PicGrpEnd;
{ end of series }
BEGIN
IF genClipPic THEN
PicComment(cPicGrpEnd, 0, NIL);
END;
{$S sError}
FUNCTION FilerReason(error: INTEGER): FReason;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
FilerReason := allOk;
IF error > 0 THEN
CASE error OF
309, erNoDiskSpace:
FilerReason := noDiskSpace;
306, 311, 315, erNoMemory:
FilerReason := noMemory;
{$IFC LibraryVersion > 20}
1294, erWrongPassword:
FilerReason := wrongPassword;
{$ENDC}
erBadData:
FilerReason := badData;
erPassword, erVersion,
955, 957, 958, erCantRead:
FilerReason := cantRead;
961, 962, erCantWrite:
FilerReason := cantWrite;
erDirtyDoc:
FilerReason := dirtyDoc;
erNoMoreDocs:
FilerReason := noMoreDocs;
erAborted:
FilerReason := aUserAbort;
OTHERWISE
FilerReason := internalError;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
PROCEDURE InitProcess;
CONST
maxNameLen =
TYPE
TDeskLabel
=

63;
RECORD
version:
name:

{this definition must be consistent with the DeskTop Manager}


{this definition must be consistent with the DeskTop Manager}
INTEGER;
STRING[maxNameLen];

Apple Lisa ToolKit 3.0 Source Code Listing -- 97 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

TPPathName

(** other stuff we are not interested in


kind:
INTEGER;
toolOnly:
BOOLEAN;
multiDoc:
BOOLEAN;
windLoc:
Rect;
{plus there are other fields added for Spring release}
**)
END;
=
^Pathname;

VAR copyright: S255;


prcsInfo:
ProcInfoRec;
progName:
TFilePath;
error:
INTEGER;
toolLabel: TDeskLabel;
actual:
LONGINT;
len:
INTEGER;
pPathName: TPPathname;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
{Tool Kit Library copyright notice (application must have its own notice in addition)}
copyright := 'Copyright 1983, 1984, Apple Computer, Inc.';
{Initialize Various Globals}
idleTime := -1;
inBackground := FALSE;
{$IFC fDbgABC}
fCountHeap := FALSE;
fExperimenting := FALSE;
eventDebug := FALSE;
{Don't trace window manager events}
{$ENDC}
activeWindowID := 0;
allowAbort := TRUE;
boundDocument := NIL;
boundClipboard := NIL;
closedDocument := NIL;
currentWindow := NIL;
currentDocument := NIL;
docList := NIL;
cursorShape := noCursor;
{Assign process and tool globals}
myProcessID := my_id;
Info_Process(error, myProcessID, prcsInfo);
IF error > 0 THEN
InitErrorAbort(error);
progName := prcsInfo.progPathName;
SplitFilePath(progName, toolVolume, toolPrefix);

Apple Lisa ToolKit 3.0 Source Code Listing -- 98 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

GetPrefixPart(progName, toolPrefix); (*'{Tnn}'*)


myTool := ToolOfFile(progName);
{Read name of tool}
pPathName := @progName;
Read_Label(error, pPathName^, ORD(@toolLabel), SIZEOF(toolLabel), actual);
IF (error <= 0) AND (Length(toolLabel.name) > 0) AND (Length(toolLabel.name) <= maxNameLen) THEN
toolName := toolLabel.name
ELSE
BEGIN
LIntToStr(myTool, @toolName);
toolName := CONCAT('Tool ', toolName);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld} {Segmentation ???}
FUNCTION GetTime: LONGINT;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
GetTime := Time;
{$IFC fTrace}EP;{$ENDC}
END;
METHODS OF TProcess;
{$S SgABCini}
FUNCTION {TProcess.}CREATE{(object: TObject; heap: THeap): TProcess};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TProcess(object);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
FUNCTION {TProcess.}AbortRequest{: BOOLEAN};
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
IF allowAbort THEN
AbortRequest := Abort {ask Window Manager}
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 99 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

AbortRequest := FALSE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
{ If allowAbort is FALSE, simply calls fs.XferSequential.
Otherwise, transfers in increments of chunksize and sets fs.Error to erAborted IF command period
is pressed during the transfer. Returns with an incomplete transfer IF command period or any other
error occurs during the transfer. }
PROCEDURE {TProcess.}AbortXferSequential{(whichWay: xReadWrite; pFirst: Ptr;
numBytes, chunksize: LONGINT; fs: TFileScanner)};
VAR xferAmount:
LONGINT;
actual:
LONGINT;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF allowAbort THEN
BEGIN
actual := 0;
WHILE (numBytes > 0) AND (fs.error <= 0) AND
NOT (fs.atEnd AND (whichWay = xRead)) DO
BEGIN
IF numbytes > chunksize THEN
xferAmount := chunksize
ELSE
xferAmount := numbytes;
IF process.AbortRequest THEN
fs.error := erAborted
ELSE
BEGIN
fs.XferSequential(whichWay, pFirst, xferAmount);
xferAmount := fs.actual;
{$IFC fDbgABC}
IF (xferAmount <= 0) AND (fs.error <= 0) THEN
ABCbreak('In TProcess.AbortXferSequential, fs.actual <= 0', xferAmount);
{$ENDC}
actual := actual + xferAmount;
numbytes := numBytes - xferAmount;
pFirst := POINTER(ORD(pFirst) + xferAmount);
END;
END;
fs.actual := actual; {make believe we xferred it all at once}

Apple Lisa ToolKit 3.0 Source Code Listing -- 100 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

END
ELSE
fs.XferSequential(whichWay, pFirst, numBytes);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sAlert}
PROCEDURE {TProcess.}ArgAlert{(whichArg: TArgAlert; argText: S255)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
ArgAlert(whichArg, argText);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sAlert}
FUNCTION {TProcess.}Ask{(phraseNumber: INTEGER): INTEGER};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
ArgAlert(0, toolName);
{$IFC LibraryVersion > 20}
IF activeWindowID = 0 THEN
Ask := BackgroundAlert(alerts, phraseNumber, AskProc)
ELSE
{$ENDC}
Ask := AskAlert(alerts, phraseNumber);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sAlert}
PROCEDURE {TProcess.}BeginWait{(phraseNumber: INTEGER)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
ArgAlert(0, toolName);
WaitAlert(alerts, phraseNumber);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TProcess.}BindCurrentDocument;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF (boundDocument <> currentDocument) AND (boundDocument <> NIL) THEN
boundDocument.Unbind;

Apple Lisa ToolKit 3.0 Source Code Listing -- 101 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

IF (boundClipboard <> currentDocument) AND (boundClipboard <> NIL) THEN


boundClipboard.Unbind;
IF currentDocument <> NIL THEN
currentDocument.Bind;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sAlert}
FUNCTION {TProcess.}Caution{(phraseNumber: INTEGER): BOOLEAN};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
ArgAlert(0, toolName);
{$IFC LibraryVersion > 20}
IF activeWindowID = 0 THEN
Caution := (BackgroundAlert(alerts, phraseNumber, CautionProc) = ORD(TRUE))
ELSE
{$ENDC}
Caution := CautionAlert(alerts, phraseNumber);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TProcess.}ChangeCursor{(cursorNumber: TCursorNumber)};
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
IF cursorNumber <> cursorShape THEN
BEGIN
SELF.DoCursorChange(cursorNumber);
cursorShape := cursorNumber;
END;
IF cursorNumber > icrsLast THEN
SetStdCursor(icrsEscape);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
PROCEDURE {TProcess.}Commence{(phraseVersion: INTEGER)};
VAR aFile:
TFile;
cacheSize: INTEGER;
cacheBytes: INTEGER;
i:
INTEGER;
oneChar:
STRING[1];
manualPat: Pattern;

Apple Lisa ToolKit 3.0 Source Code Listing -- 102 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

error:
prPrfAlias:
str:
convResult:

INTEGER;
TPrPrfAlias;
S255;
TConvResult;

BEGIN
{$IFC fTrace}BP(7);{$ENDC}

{Open Phrase File}


aFile := TFile.CREATE(NIL, mainHeap, CONCAT(toolVolume, toolPrefix, 'PHRASE'), '');
phraseFile := aFile.ScannerFrom(0, [fRead]);
InitErrorAbort(phraseFile.error);
{Read Menus}
menuBar := TMenuBar.CREATE(NIL, mainHeap, phraseFile);
{Initialize and Read Alerts}
cacheSize := phraseFile.ReadNumber(2);
cacheBytes := phraseFile.ReadNumber(2);
InitErrorAbort(phraseFile.error);
InitAlerts(cacheSize, cacheBytes, POINTER(ORD(mainHeap)), NIL, @AlErrProc);
InitErrorAbort(alertError);
alerts := ReadAlerts(phraseFile.refnum, phraseVersion);
InitErrorAbort(alertError);
{Read Word Delimiters}
GetAlert(alerts, phWordDelimiters, @wordDelimiters);
IF Length(wordDelimiters) > 67 THEN
BEGIN
ABCBreak('More than 67 characters in the word delimiter string--phrase number', phWordDelimiters);
{ Set error to something so we don't continue }
InitErrorAbort(erInternal);
END;
{Read "OK" and "Cancel"}
GetButn(0, @cancelString);
StrUpperCased(@cancelString);
GetButn(1, @okString);
StrUpperCased(@okString);
GetAlert(alerts, phNewHeading, @dfltNewHeading); {+SW+}
GetAlert(alerts, phPage, @varPage); {+SW+}
GetAlert(alerts, phTitle, @varTitle); {+SW+}
GetAlert(alerts, phCountry, @str);
StrToInt(@str, countryCode, convResult);
IF convResult <> cvValid THEN
countryCode := 0;

Apple Lisa ToolKit 3.0 Source Code Listing -- 103 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

{Create a handle to use in picture comments}


picData := HAllocate(THz(mainHeap), 1);
(****

****)

{Read Tool Name}


GetAlert(alerts, phToolName, @toolName);
IF Length(toolName) > 67 THEN
BEGIN
ABCBreak('More than 67 characters in the tool name string--phrase number', phToolName);
InitErrorAbort(erInternal);
END;
{Read Tool Name from file label is done in InitProcess}

IF onDesktop THEN
BEGIN
{Initialize Print Manager, while Alert Segment is still Resident}
{$IFC LibraryVersion <= 20}
PrMgrInit(error);
InitErrorAbort(error);
{$ELSEC}
PrMgrInit;
{$ENDC}
END;
{Initialize Scroll Bar and Cursor Library}
InitWmlSb;
InitWmlCrs(error);
InitErrorAbort(error);
{$IFC LibraryVersion <= 20 AND FALSE} {do it this way in case we need it back for the Pepsi version}
{Create fonts}
fonts[ 0] := TFont.CREATE(NIL, mainHeap, sysText);
{System Font
}
fonts[ 1] := TFont.CREATE(NIL, mainHeap, p15Tile);
{15 pitch Gothic }
fonts[ 2] := TFont.CREATE(NIL, mainHeap, p12tile);
{12 pitch Modern }
fonts[ 3] := TFont.CREATE(NIL, mainHeap, elite);
{12 pitch Elite }
fonts[ 4] := TFont.CREATE(NIL, mainHeap, p10tile);
{10 pitch Modern }
fonts[ 5] := TFont.CREATE(NIL, mainHeap, p10cent);
{10 pitch Courier}
fonts[ 6] := TFont.CREATE(NIL, mainHeap, tile12 );
{PS Modern
}
fonts[ 7] := TFont.CREATE(NIL, mainHeap, cent12 );
{PS Executive
}
fonts[ 8] := TFont.CREATE(NIL, mainHeap, tile18 );
{1/4 inch Modern }
fonts[ 9] := TFont.CREATE(NIL, mainHeap, cent18 );
{1/4 inch Classic}
fonts[10] := TFont.CREATE(NIL, mainHeap, tile24 );
{1/3 inch Modern }
fonts[11] := TFont.CREATE(NIL, mainHeap, cent24 );
{1/3 inch Classic}
{$ENDC}
{Specify suspend-file suffixes}
oneChar := '0';

Apple Lisa ToolKit 3.0 Source Code Listing -- 104 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

FOR i := 1 TO maxSegments DO
BEGIN
oneChar[1] := CHR(48+i);
suspendSuffix[i] := CONCAT('$S', oneChar);
END;
{Initialize other globals}
SetPt(zeroPt, 0, 0);
SetRect(zeroRect, 0, 0, 0, 0);
SetRect(hugeRect, 0, 0, $3FFF, $3FFF);
SetLPt(zeroLPt, 0, 0);
SetLRect(zeroLRect, 0, 0, 0, 0);
SetLRect(hugeLRect, 0, 0, $3FFFFFFF, $3FFFFFFF);
orthogonal[v] := h;
orthogonal[h] := v;
docList := TList.CREATE(NIL, mainHeap, 1);
highToggle[FALSE] := hOnToOff;
highToggle[TRUE] := hOffToOn;
highLevel[FALSE] := hOffToDim;
highLevel[TRUE] := hOffToOn;
PenNormal;
GetPenState(normalPen);
PenSize(2, 2);
PenMode(patXor);
PenPat(gray);
GetPenState(highPen[hDimToOff]);
GetPenState(highPen[hOffToDim]);
PenMode(notPatXor);
PenPat(gray);
GetPenState(highPen[hOnToDim]);
GetPenState(highPen[hDimToOn]);
PenMode(patXor);
PenPat(black);
GetPenState(highPen[hOffToOn]);
GetPenState(highPen[hOnToOff]);
PenSize(3, 2);

Apple Lisa ToolKit 3.0 Source Code Listing -- 105 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

PenMode(patXOr);
PenPat(gray);
GetPenState(autoBreakPen);
StuffHex(@manualPat, 'CC663399CC663399');
PenPat(manualPat);
GetPenState(manualBreakPen);
StuffHex(@marginPattern, '8000000008000000');
PenNormal;
PenPat(manualPat);
GetPenState(limboPen);
SetPt(screenRes, 90, 60); {Lisa 1.0 screen}
{better--get from phrase file}
screenRightEdge := 720; {redundant -- screenBits.bounds.right shd be the same}
SetLRect(stdMargins, screenRes.h, screenRes.v, - screenRes.h, -screenRes.v);
PenNormal;
noPad := TPad.CREATE(NIL, mainHeap, zeroRect, hugeLRect, screenRes, screenRes, NIL);
(***** Do this in TPad creation block, via coercion
noPad.PatToLPat(white, lPatWhite);
noPad.PatToLPat(black, lPatBlack);
noPad.PatToLPat(gray, lPatGray);
noPad.PatToLPat(ltGray, lPatLtGray);
noPad.PatToLPat(dkGray, lPatDkGray);
*****)
MakeTypeStyle(famClassic, size18Point, [], cornerNumberStyle);
theMarginPad := TMarginPad.CREATE(NIL, mainHeap);
theBodyPad := theMarginPad.bodyPad;
IF crashPad = NIL THEN
crashPad := theMarginPad;
clipboard := TClipboard.CREATE(NIL, mainHeap);
padRgn := NewRgn;
focusRgn := thePort^.visRgn;
focusStkPtr := 0;
focusArea := NIL;
genClipPic := FALSE;
amPrinting := FALSE;
useAltVisRgn := FALSE;

Apple Lisa ToolKit 3.0 Source Code Listing -- 106 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

altVisRgn := NewRgn;
scrollRgn := NewRgn;
scrRgn1ForDrawHdgs := NewRgn;
scrRgn2ForDrawHdgs := NewRgn;
blinkOnCentiSecs := caretOnTime;
blinkOffCentiSecs := caretOffTime;
PrPrfDefault(prPrfAlias.prPrf);
clipPrintPref := prPrfAlias.reserve;
{ Final check for Abort in init }
InitErrorAbort(0);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
PROCEDURE {TProcess.}Complete{(allIsWell: BOOLEAN)};
VAR s:
TListScanner;
document:
TDocManager;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF NOT (allIsWell OR amDying) THEN
BEGIN
ImDying; {Do this first}
IF (boundClipboard <> NIL) AND (scrapProcess = myProcess) THEN {*** Sufficient & necessary? ***}
BackOutOfScrap;
amDying := TRUE;
END;
{$IFC fDbgABC}
IF NOT allIsWell THEN
ABCBreak('Process.Complete(FALSE)', 0);
{$ENDC}
IF docList <> NIL THEN
BEGIN
s := docList.Scanner;
docList := NIL;
WHILE s.Scan(document) DO
document.Complete(allIsWell);
END;
HALT;
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 107 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

END;
{$S SgABCcld}
PROCEDURE {TProcess.}CopyExternalDoc(VAR error: INTEGER; externalName, volumePrefix: TFilePath);
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
{$IFC fDbgABC}
ABCbreak('TProcess.CopyExternalDoc was not overridden', 0);
{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S sAlert}
PROCEDURE {TProcess.}CountAlert{(whichCtr: TAlertCounter; counter: INTEGER)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
CountAlert(whichCtr, counter);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TProcess.}DoCursorChange{(cursorNumber: TCursorNumber)};
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
SetStdCursor(cursorNumber);
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S SgABCini}
PROCEDURE {TProcess.}DontDebug;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
fCheckIndices := FALSE;
{$IFC fDbgABC}
eventDebug := FALSE;
fCountHeap := FALSE;
fExperimenting := FALSE;
{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 108 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

{$S sAlert}
PROCEDURE {TProcess.}DrawAlert(phraseNumber: INTEGER; marginLRect: LRect);
VAR rectInWindow:
Rect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
ArgAlert(0, toolName);
thePad.LRectToRect(marginLRect, rectInWindow);
DrawAlert(alerts, phraseNumber, rectInWindow);
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDbgABC}
{$S SgABCdbg}
PROCEDURE {TProcess.}DumpGlobals;
VAR str: S8;
PROCEDURE AbortDumpVar(pVariable: Ptr; nameAndType: S255);
BEGIN
IF CheckKeyPress('Process global variable dump') THEN
BEGIN
WriteLn;
WriteLn;
Exit(DumpGlobals);
END;
DumpVar(pVariable, nameAndType);
END;
BEGIN
WriteLn;
WriteLn('--- IMPORTANT GLOBAL VARIABLES OF THE PROCESS ---');
WriteLn;
AbortDumpVar(@activeWindowID, 'activeWindowID: Ptr');
AbortDumpVar(@allowAbort, 'allowAbort: BOOLEAN');
AbortDumpVar(@boundClipboard, 'boundClipboard: TClipboard');
AbortDumpVar(@boundDocument, 'boundDocument: TDocManager');
AbortDumpVar(@clickState, Concat('clickState: RECORD where: Point; when: LONGINT;',
'clickCount: INTEGER; fShift: BOOLEAN; fOption: BOOLEAN; fApple: BOOLEAN END'));
AbortDumpVar(@clipboard, 'clipboard: TClipboard');
AbortDumpVar(@closedBySuspend, 'closedBySuspend: BOOLEAN');
AbortDumpVar(@closedDocument, 'closedDocument: TDocManager');
AbortDumpVar(@currentDocument, 'currentDocument: TDocManager');
AbortDumpVar(@currentWindow, 'currentWindow: TWindow');
AbortDumpVar(@cursorShape, 'cursorShape: INTEGER');
AbortDumpVar(@deferUpdate, 'deferUpdate: BOOLEAN');
AbortDumpVar(@docList, 'docList: TList');
AbortDumpVar(@genClipPic, 'genClipPic: BOOLEAN');
AbortDumpVar(@idleTime, 'idleTime: LONGINT');
AbortDumpVar(@inBackground, 'inBackground: BOOLEAN');
AbortDumpVar(@menuBar, 'menuBar: TMenuBar');

Apple Lisa ToolKit 3.0 Source Code Listing -- 109 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

AbortDumpVar(@myProcessID, 'myProcessID: LONGINT');


AbortDumpVar(@myTool, 'myTool: LONGINT');
AbortDumpVar(@process, 'process: TProcess');
AbortDumpVar(@toolName, 'toolName: STRING[67]');
AbortDumpVar(@toolPrefix, 'toolPrefix: STRING[255]');
AbortDumpVar(@toolVolume, 'toolVolume: STRING[255]');
WriteLn;
WriteLn;
END;
{$ENDC}
{$S sAlert}
PROCEDURE {TProcess.}EndWait;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{$IFC LibraryVersion <= 20}
HideFolder(alertFolder);
{$ELSEC}
EndWaitAlert;
{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S sAlert}
PROCEDURE {TProcess.}GetAlert{(phraseNumber: INTEGER; VAR theText: S255)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
GetAlert(alerts, phraseNumber ,@theText);
{$IFC fTrace}EP;{$ENDC}
END;
{$S Override}
FUNCTION {TProcess.}NewDocManager{(volumePrefix: TFilePath; openAsTool: BOOLEAN): TDocManager};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
NewDocManager := TDocManager.CREATE(NIL, mainHeap, volumePrefix);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sAlert}
PROCEDURE {TProcess.}Note{(phraseNumber: INTEGER)};
{$IFC LibraryVersion > 20}
VAR dummy: INTEGER;
{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 110 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
ArgAlert(0, toolName);
{$IFC LibraryVersion > 20}
IF activeWindowID = 0 THEN
dummy := BackgroundAlert(alerts, phraseNumber, NoteProc)
ELSE
{$ENDC}
NoteAlert(alerts, phraseNumber);
{$IFC fTrace}EP;{$ENDC}
END;
{ NOTE: StopCondition is checked only when no events are available.
NOTE: StopCondition should not assume that a document is bound. If all the process' windows are
inactive, StopCondition will be called before the process is suspended (to give you
a chance to regain control), but all the process' documents will be unbound. You can
check for this situation by testing currentDocument for NIL.}
{$S sStartup}
PROCEDURE {TProcess.}ObeyEvents{(FUNCTION StopCondition: BOOLEAN)};
LABEL 9;
VAR selection:

TSelection;

PROCEDURE StopTest;
BEGIN
IF StopCondition THEN
BEGIN
LetOthersRun;
GOTO 9;
END;
END;
PROCEDURE GetAndObeyEvent;
LABEL
1;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
GetEvent(event);
{$IFC fDbgABC}
IF fExperimenting and eventDebug THEN
WITH event.who^.portRect DO
BEGIN
WriteLn('GetAndObeyEvent (event.who):', ORD(event.who));
WriteLn(left, top, right, bottom);
WriteLn(event.where.h, event.where.v);
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 111 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

{$ENDC}

1:

IF ImActive THEN
IF SELF.AbortRequest THEN
IF event.what IN [keyDown, buttonDown, buttonUp] THEN
GOTO 1;
SELF.ObeyTheEvent;
{$IFC fTrace}EP;{$ENDC}
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{Shouldn't tell Filer initFailed after this}
isInitialized := TRUE;
{Main event loop}
{NOTE: currentWindow <> NIL implies

(1) process is active OR


(2) process is running in the background and has a document }

REPEAT
WHILE NOT (ImActive OR amDying OR (currentWindow <> NIL)) DO
BEGIN
IF NOT EventAvail THEN
StopTest;
GetAndObeyEvent; {may suspend me}
END;
WHILE (ImActive OR (currentWindow <> NIL)) AND NOT amDying DO
IF EventAvail THEN
GetAndObeyEvent
ELSE
BEGIN
StopTest;
currentWindow.Update(TRUE);
IF currentWindow.dialogBox <> NIL THEN
currentWindow.dialogBox.Update(TRUE);
IF NOT (amDying OR eventAvail) THEN
BEGIN
selection := currentWindow.selectWindow.selectPanel.selection;
idleTime := Time;
selection.IdleBegin(idleTime);
WHILE NOT (amDying OR eventAvail) DO
selection.IdleContinue(Time);
IF NOT amDying THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 112 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

selection.IdleEnd(Time);
END;
END;
UNTIL amDying;
9:
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TProcess.}ObeyFilerEvent;
LABEL 1;
TYPE
{$IFC LibraryVersion <= 20}
TFileOpKind = (fopNone, fopSuspend, fopSaveVersion);
{$ELSEC}
TFileOpKind = (fopNone, fopSuspend, fopSaveVersion, fopCopyDoc);
{$ENDC}
VAR reply:
badReply:
reason:
window:
openAsTool:
document:
flrParams:
flrOp:
volumePrefix:
wasSuspended:
fileOpKind:
doSuspend:
doSave:
error:

FReply;
FReply;
FReason;
TWindow;
BOOLEAN;
TDocManager;
FilerExt;
FilerOp;
TFilePath;
BOOLEAN;
TFileOpKind;
BOOLEAN;
BOOLEAN;
INTEGER;

PROCEDURE CheckAbort(abortReason: INTEGER);


VAR i:
INTEGER;
dsPathname: PathName;
BEGIN
IF abortReason = 0 THEN
IF SELF.AbortRequest THEN
abortReason := erAborted
ELSE
Exit(CheckAbort);
{$IFC fDbgABC}
IF abortReason <> erAborted THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 113 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

BEGIN
WriteLn('--------------------');
ReportFilerEvent(flrParams);
ABCbreak('TProcess.ObeyFilerEvent got an error (event listed above)', abortReason);
END;
{$ENDC}
IF (flrOp = fcResume) OR (flrOp = fcNone) THEN
BEGIN
IF window <> NIL THEN
PopFocus;
IF wasSuspended THEN
{ Close but don't kill the datasegs }
BEGIN
FOR i := 1 TO maxSegments DO
IF document.dataSegment.refnum[i] >= 0 THEN
BEGIN
dsPathName := Concat(document.files.volumePrefix, suspendSuffix[i]);
Close_DataSeg(error, document.dataSegment.refnum[i]);
document.dataSegment.refnum[i] := -1;
END
END
ELSE
BEGIN
{ In case the BlankStationery method was called and opened any files }
document.CloseFiles;
{ kill any data segments that were created }
document.KillSegments(1, maxSegments);
END;
{ delete from docList, IF there, and free regardless }
docList.DelObject(document, TRUE);
boundDocument := NIL;
END;
TellFiler(error, badReply, FilerReason(abortReason), event.who);
GOTO 1;
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
wasSuspended := FALSE;
GetAddParams(error, event, flrParams);
IF error > 0 THEN
ABCBreak('GetAddParams', error);
flrOp := flrParams.theFlrOp;
allowAbort := TRUE; {??? should we assume this ???}
{$IFC fDbgABC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 114 of 1012

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163
001164
001165
001166
001167
001168
001169
001170
001171
001172
001173
001174
001175
001176
001177
001178
001179
001180
001181
001182
001183
001184
001185
001186
001187
001188
001189
001190
001191
001192
001193
001194
001195

{$ENDC}

IF eventDebug THEN
ReportFilerEvent(flrParams);
CASE flrOp OF
fcNone, fcResume:
BEGIN
{ The assumption for aborting here is things will, where possible, be cleaned up along the way
by anyone detecting the abort. Things that have already happened after the abort is
detected will be cleaned up in CheckAbort. The process will of course continue after the
abort. }
IF (inBackground) AND (doclist.size > 0) THEN
TellFiler(error, docClosd, noMoreDocs, event.who)

{No multiple doc's in background}

ELSE
BEGIN
{ Set badReply in case Abort is detected }
badReply := docClosd;
TakeWindow(event.who);
WITH flrParams DO
BEGIN
openAsTool := flrOp = fcNone;
IF openAsTool THEN
thePrefix := CONCAT(toolVolume, toolPrefix);
document := SELF.NewDocManager(thePrefix, openAsTool);
{$IFC LibraryVersion > 20}
document.files.password := thePassword;
{$ENDC}
END;
IF document = NIL THEN {application refused the request}
TellFiler(error, docClosd, noMoreDocs, event.who)
ELSE
BEGIN
document.openedAsTool := openAsTool;
SetPort(event.who); {so things like InvalRect in BlankStationery will work}
{ Returns Abort as error = erAborted }
document.Open(error, ORD(event.who), wasSuspended);
window := NIL; {so CheckAbort will not PopFocus}
CheckAbort(error);

Apple Lisa ToolKit 3.0 Source Code Listing -- 115 of 1012

Apple Lisa Computer Technical Information


001196
001197
001198
001199
001200
001201
001202
001203
001204
001205
001206
001207
001208
001209
001210
001211
001212
001213
001214
001215
001216
001217
001218
001219
001220
001221
001222
001223
001224
001225
001226
001227
001228
001229
001230
001231
001232
001233
001234
001235
001236
001237
001238
001239
001240
001241
001242
001243

PushFocus;
window := document.window;
window.Focus;
window.Resize(FALSE);
CheckAbort(0);
InvalRect(window.innerRect);
window.Update(TRUE);
CheckAbort(0);
PopFocus;
IF event.who = activeFolder THEN {already active so we don't get a folderActivate}
BEGIN
PushFocus;
window.Focus; {window.Activate assumes focused}
currentDocument := document; {this must be set before calling TWindow.Activate}
window.Activate;
PopFocus;
END
ELSE
window.StashPicture(hOffToDim);
END;
END;
END; {fcNone/fcResume case}
{ The assumption for aborting here is things will be cleaned up along the way by anyone
detecting the abort. The process will of course continue after the abort. }
fcClose, fcSuspend, fcCopy, fcPut, fcShred:
BEGIN
{$IFC LibraryVersion <= 20}
fileOpKind := fopNone;
document := POINTER(GetFldrRefCon(event.who));
document.Bind;
{$ELSEC}
IF (flrOp = fcCopy) AND (Length(flrParams.theResult) > 0) THEN
BEGIN
fileOpKind := fopCopyDoc;
document := NIL;
END
ELSE
BEGIN
fileOpKind := fopNone;
document := POINTER(GetFldrRefCon(event.who));
document.Bind;
END;
{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 116 of 1012

Apple Lisa Computer Technical Information


001244
001245
001246
001247
001248
001249
001250
001251
001252
001253
001254
001255
001256
001257
001258
001259
001260
001261
001262
001263
001264
001265
001266
001267
001268
001269
001270
001271
001272
001273
001274
001275
001276
001277
001278
001279
001280
001281
001282
001283
001284
001285
001286
001287
001288
001289
001290
001291

CASE flrOp OF
fcClose, fcSuspend, fcShred:
BEGIN
IF flrOp = fcClose THEN
BEGIN
IF document.window.changes <> 0 THEN
fileOpKind := fopSaveVersion;
END
ELSE
fileOpKind := fopSuspend;
volumePrefix := document.files.volumePrefix;
reply := docClosd;
badReply := docNotClosd;
END;
OTHERWISE {fcCopy, fcPut}
BEGIN
{$IFC LibraryVersion <= 20}
fileOpKind := fopSaveVersion;
{$ELSEC}
IF fileOpKind <> fopCopyDoc THEN
fileOpKind := fopSaveVersion;
{$ENDC}
volumePrefix := flrParams.thePrefix;
reply := docXfered;
badReply := docNotXfered;
END;
END;
allowAbort := NOT doSuspend; {for now all ops can be aborted except fcSuspend and fcShred}
CheckAbort(0);
IF document <> NIL THEN
document.ConserveMemory(0, TRUE {GC});
CheckAbort(0);
CASE fileOpKind OF
fopSuspend:
IF document.files.shouldSuspend THEN
document.Suspend(error);
{*** we ignore the volumePrefix !!! ***}
fopSaveVersion:
IF document.files.shouldToolSave OR NOT document.openedAsTool THEN
document.SaveVersion(error, volumePrefix, FALSE);
{$IFC LibraryVersion > 20}
fopCopyDoc:

Apple Lisa ToolKit 3.0 Source Code Listing -- 117 of 1012

Apple Lisa Computer Technical Information


001292
001293
001294
001295
001296
001297
001298
001299
001300
001301
001302
001303
001304
001305
001306
001307
001308
001309
001310
001311
001312
001313
001314
001315
001316
001317
001318
001319
001320
001321
001322
001323
001324
001325
001326
001327
001328
001329
001330
001331
001332
001333
001334
001335
001336
001337
001338
001339

{$ENDC}

SELF.CopyExternalDoc(error, flrParams.theResult, volumePrefix);


END;
{ You cannot abort after SaveVersion or Suspend unless the abort was detected within
SaveVersion or Suspend and indicated by their returned error being erAborted }
IF error > 0 THEN
IF flrOp = fcShred THEN
BEGIN {try to close all files}
document.CloseFiles;
document.KillSegments(1, maxSegments);
error := 0; {always give a good reply to the filer}
END
ELSE
CheckAbort(error);
TellFiler(error, reply, FilerReason(error), event.who);
IF flrOp <> fcCopy THEN
BEGIN
closedDocument := document;
closedBySuspend := doSuspend;
END;
allowAbort := TRUE;
END;
fcDfClose:
BEGIN
badReply := dfNotClosed;
Close_Object(error, flrParams.theDf);
CheckAbort(error);
TellFiler(error, dfClosed, allOk, event.who);
END;
fcTerminate:
amDying := TRUE;
END;

1: {$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TProcess.}ObeyTheEvent;
{NOTE: For the duration of the event, we are focused on the eventWindow}
VAR eventDocument: TDocManager;
eventWindow:
TWindow;

Apple Lisa ToolKit 3.0 Source Code Listing -- 118 of 1012

Apple Lisa Computer Technical Information


001340
001341
001342
001343
001344
001345
001346
001347
001348
001349
001350
001351
001352
001353
001354
001355
001356
001357
001358
001359
001360
001361
001362
001363
001364
001365
001366
001367
001368
001369
001370
001371
001372
001373
001374
001375
001376
001377
001378
001379
001380
001381
001382
001383
001384
001385
001386
001387

dialogBox:
paused:
pkEvent:
{$IFC fCheckHeap}
numObjects:
docHeap:
{$ENDC}

TDialogBox;
BOOLEAN;
EventRecord;
INTEGER;
THeap;

FUNCTION EvtWindow(VAR evt: EventRecord): TWindow;


BEGIN
{$IFC fTrace}BP(1);{$ENDC}
EvtWindow := eventDocument.WindowWithId(ORD(evt.who));
IF evt.what = keyDown THEN
BEGIN
dialogBox := currentWindow.dialogBox;
IF dialogBox <> NIL THEN
IF dialogBox.keyResponse = diDismissDialogBox THEN
dialogBox.BeDismissed
ELSE
{+SW+}
IF (dialogBox.keyResponse = diAccept) AND (currentWindow.selectWindow = dialogBox) THEN
EvtWindow := dialogBox
END;
{$IFC fTrace}EP;{$ENDC}
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
eventTime := event.when;
eventType := event.what;
{$IFC fDbgABC}
IF eventDebug THEN
ReportEvent;
{$ENDC}
WITH event DO
IF what = buttonUp THEN
ELSE
IF what = filerEvent THEN
SELF.ObeyFilerEvent
ELSE
IF who <> alertFolder THEN
BEGIN
IF what = folderActivate THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 119 of 1012

Apple Lisa Computer Technical Information


001388
001389
001390
001391
001392
001393
001394
001395
001396
001397
001398
001399
001400
001401
001402
001403
001404
001405
001406
001407
001408
001409
001410
001411
001412
001413
001414
001415
001416
001417
001418
001419
001420
001421
001422
001423
001424
001425
001426
001427
001428
001429
001430
001431
001432
001433
001434
001435

TakeControl(event, FALSE, FALSE);


eventDocument := currentDocument;
IF who = menuFolder THEN
{much changed}
BEGIN
eventWindow := currentWindow;
dialogBox := currentWindow.dialogBox;
IF dialogBox <> NIL THEN
IF dialogBox.menuResponse = diDismissDialogBox THEN
dialogBox.BeDismissed
ELSE
IF dialogBox.menuResponse = diAccept THEN
eventWindow := currentWindow.selectWindow; {+SW+}
END
ELSE
IF who = dialogFolder THEN
eventWindow := currentWindow.dialogBox
ELSE
IF who = scrapFolder THEN
BEGIN
eventDocument := clipboard;
clipboard.Bind;
eventWindow := clipboard.window;
END
ELSE IF who = NIL THEN {assuming that we cannot receive a private event directed
towards a particular window}
BEGIN
eventWindow := NIL;
process.HandlePrivateEvent(what, fromProcess, when, userData);
END
ELSE
BEGIN
eventDocument := POINTER(GetFldrRefCon(who));
IF eventDocument = NIL THEN
BEGIN
ABCBreak('GetFldrRefCon = NIL', ORD(who));
eventWindow := NIL;
END
ELSE
BEGIN
eventDocument.Bind;
eventWindow := EvtWindow(event);
END;
END;
IF eventWindow <> NIL THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 120 of 1012

Apple Lisa Computer Technical Information


001436
001437
001438
001439
001440
001441
001442
001443
001444
001445
001446
001447
001448
001449
001450
001451
001452
001453
001454
001455
001456
001457
001458
001459
001460
001461
001462
001463
001464
001465
001466
001467
001468
001469
001470
001471
001472
001473
001474
001475
001476
001477
001478
001479
001480
001481
001482
001483

PushFocus;
IF who = menuFolder THEN
eventWindow.Focus
ELSE
BEGIN
SetPort(event.who);
{$IFC fDbgABC}
IF fExperimenting and eventDebug THEN
WITH thePort^.portRect DO
BEGIN
WriteLn('Before LocalToGlobal (thePort):', ORD(thePort));
WriteLn(left, top, right, bottom);
WriteLn(where.h, where.v);
END;
{$ENDC}
LocalToGlobal(where);
eventWindow.Focus;
{$IFC fDbgABC}
IF fExperimenting and eventDebug THEN
WITH thePort^.portRect DO
BEGIN
WriteLn('Before GlobalToLocal (thePort):', ORD(thePort));
WriteLn(left, top, right, bottom);
WriteLn(where.h, where.v);
END;
{$ENDC}
GlobalToLocal(where);
{$IFC fDbgABC}
IF fExperimenting and eventDebug THEN
WITH thePort^.portRect DO
BEGIN
WriteLn('After GlobalToLocal (thePort):', ORD(thePort));
WriteLn(left, top, right, bottom);
WriteLn(where.h, where.v);
END;
{$ENDC}
END;
IF deferUpdate THEN
IF (what <> keyDown) OR appleKey THEN
eventWindow.Update(TRUE);
deferUpdate := FALSE;

Apple Lisa ToolKit 3.0 Source Code Listing -- 121 of 1012

Apple Lisa Computer Technical Information


001484
001485
001486
001487
001488
001489
001490
001491
001492
001493
001494
001495
001496
001497
001498
001499
001500
001501
001502
001503
001504
001505
001506
001507
001508
001509
001510
001511
001512
001513
001514
001515
001516
001517
001518
001519
001520
001521
001522
001523
001524
001525
001526
001527
001528
001529
001530
001531

CASE what OF
abortEvent:
eventWindow.AbortEvent;
buttonDown:
IF who = menuFolder THEN
eventWindow.MenuEventAt(where)
ELSE
eventWindow.DownEventAt(where);
folderActivate:
BEGIN
currentDocument := eventDocument;
eventWindow.Activate;
END;
folderDeactivate:
eventWindow.Deactivate;
folderMoved:
BEGIN
eventWindow.Resize(TRUE);
process.RememberCommand(uMoveWindow);
END;
folderUpdate:
eventWindow.Update(TRUE);
keyDown:
IF eventWindow.selectPanel = NIL THEN
{$IFC fDbgABC} ABCBreak('ObeyTheEvent: selectPanel=NIL', 0) {$ENDC}
ELSE
REPEAT
eventWindow.selectPanel.selection.DoKey(ascii,
keyCap, shiftKey, appleKey, codeKey);
IF PeekEvent(pkEvent) THEN
paused := (ImActive AND SELF.AbortRequest) OR
(eventWindow <> EvtWindow(pkEvent)) OR
(pkEvent.what <> keyDown) OR
((pkEvent.what = keyDown) AND (pkEvent.AppleKey)) {LSR}
ELSE
paused := TRUE;
IF NOT paused THEN
BEGIN
GetEvent(event);
eventTime := event.when;
eventType := event.what;
{$IFC fDbgABC}
IF eventDebug THEN
ReportEvent;
{$ENDC}
END

Apple Lisa ToolKit 3.0 Source Code Listing -- 122 of 1012

Apple Lisa Computer Technical Information


001532
001533
001534
001535
001536
001537
001538
001539
001540
001541
001542
001543
001544
001545
001546
001547
001548
001549
001550
001551
001552
001553
001554
001555
001556
001557
001558
001559
001560
001561
001562
001563
001564
001565
001566
001567
001568
001569
001570
001571
001572
001573
001574
001575
001576
001577
001578
001579

END;

ELSE
IF eventWindow.selectPanel <> NIL THEN
eventWindow.selectPanel.selection.KeyPause;
UNTIL paused;

IF (closedDocument = NIL) AND (currentWindow <> NIL) THEN


BEGIN {+SW+}
IF NOT deferUpdate THEN
BEGIN
IF currentWindow.dialogBox <> NIL THEN
currentWindow.dialogBox.Update(TRUE);
currentWindow.Update(TRUE);
END;
IF currentWindow.objectToFree <> NIL THEN {+SW+}
BEGIN
currentWindow.objectToFree.Free;
currentWindow.objectToFree := NIL
END;
END;
PopFocus;
END;
END;
IF closedDocument <> NIL THEN
BEGIN
closedDocument.Close(closedBySuspend);
closedDocument.Free;
closedDocument := NIL;
END;
process.BindCurrentDocument; {This also unbinds the eventDocument, in the case where
we got an event while inactive.}
{$IFC fCheckHeap AND fDbgABC}
IF fCountHeap AND (event.what <> buttonUp) THEN
BEGIN
numObjects := CountHeap(mainHeap);
Write('mainHeap has ', numObjects:1, ' objects');
IF boundDocument <> NIL THEN
BEGIN
docHeap := boundDocument.docHeap;
IF docHeap <> NIL THEN
BEGIN
numObjects := CountHeap(docHeap);
Write('; boundDocument heap has ', numObjects:1, ' objects');
MarkHeap(docHeap, ORD(boundDocument.dataSegment.preludePtr^.docDirectory));

Apple Lisa ToolKit 3.0 Source Code Listing -- 123 of 1012

Apple Lisa Computer Technical Information


001580
001581
001582
001583
001584
001585
001586
001587
001588
001589
001590
001591
001592
001593
001594
001595
001596
001597
001598
001599
001600
001601
001602
001603
001604
001605
001606
001607
001608
001609
001610
001611
001612
001613
001614
001615
001616
001617
001618
001619
001620
001621
001622
001623
001624
001625
001626
001627

SweepHeap(docHeap, TRUE);
END;
END;
IF boundClipboard <> NIL THEN
BEGIN
docHeap := boundClipboard.docHeap;
IF docHeap <> NIL THEN
BEGIN
numObjects := CountHeap(docHeap);
Write('; boundClipboard heap has ', numObjects:1, ' objects');
END;
END;
WriteLn;
END;
{$ENDC}
{$IFC fDebugMethods}
IF docList.Size = 0 THEN
SELF.DontDebug;
{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S sError}
FUNCTION {TProcess.}Phrase{(error: INTEGER)};
VAR erStr: S255;
BEGIN
{$IFC fTrace}BP(5);{$ENDC}
{client can override}
{also, I should case on os error codes}
CASE error OF
erAborted : Phrase := phTerminated;
OTHERWISE
BEGIN
{$IFC fTrace}
(** SuErrText('OSERRS.ERR', error, @erStr); **)
Writeln;
Writeln('Error # ', error, '; ', erStr);
{$ENDC}
Phrase := phUnknown;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}

Apple Lisa ToolKit 3.0 Source Code Listing -- 124 of 1012

Apple Lisa Computer Technical Information


001628
001629
001630
001631
001632
001633
001634
001635
001636
001637
001638
001639
001640
001641
001642
001643
001644
001645
001646
001647
001648
001649
001650
001651
001652
001653
001654
001655
001656
001657
001658
001659
001660
001661
001662
001663
001664
001665
001666
001667
001668
001669
001670
001671
001672
001673
001674
001675

PROCEDURE {TProcess.}HandlePrivateEvent(typeOfEvent: INTEGER; fromProcess: LONGINT;


when: LONGINT; otherData: LONGINT);
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TProcess.}RememberCommand{(cmdNumber: TCmdNumber)};
LABEL
1;
PROCEDURE CallWouldAlert(VAR menu: MenuInfo; itemIndex: INTEGER);
BEGIN
WouldAlert(menu, itemIndex);
GOTO 1;
END;
BEGIN
{$IFC fTrace}BP(5);{$ENDC}
IF NOT menubar.GetCmdName(cmdNumber, NIL) THEN
cmdNumber := uSomeCommand;
InAllMenusDo(TRUE, cmdNumber, CallWouldAlert);
InAllMenusDo(FALSE, cmdNumber, CallWouldAlert);
1:
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TProcess.}Run;
FUNCTION UntilPowerOff: BOOLEAN;
BEGIN
UntilPowerOff := FALSE;
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.ObeyEvents(UntilPowerOff);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
PROCEDURE {TProcess.}SendEvent(typeOfEvent: INTEGER; targetProcess: LONGINT; otherData: LONGINT);
VAR er: EventRecord;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF typeOfEvent < firstPrivateEvent THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 125 of 1012

Apple Lisa Computer Technical Information


001676
001677
001678
001679
001680
001681
001682
001683
001684
001685
001686
001687
001688
001689
001690
001691
001692
001693
001694
001695
001696
001697
001698
001699
001700
001701
001702
001703
001704
001705
001706
001707
001708
001709
001710
001711
001712
001713
001714
001715
001716
001717
001718
001719
001720
001721
001722
001723

BEGIN
{$IFC fDbgABC}
ABCbreak('Invalid event type passed to TProcess.SendEvent', typeOfEvent);
{$ENDC}
END
ELSE
BEGIN
WITH er DO
BEGIN
who := NIL; {can't tell what window we are sending to}
what := typeOfEvent;
when := Time;
toProcess := targetProcess;
fromProcess := myProcessID;
userData := otherData;
END;
SendEvent(er, targetProcess);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sAlert}
PROCEDURE {TProcess.}Stop{(phraseNumber: INTEGER)};
{$IFC LibraryVersion > 20}
VAR dummy: INTEGER;
{$ENDC}
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
ArgAlert(0, toolName);
{$IFC LibraryVersion > 20}
IF activeWindowID = 0 THEN
dummy := BackgroundAlert(alerts, phraseNumber, StopProc)
ELSE
{$ENDC}
StopAlert(alerts, phraseNumber);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TProcess.}TrackCursor;
{ assumes we are active; can't track the cursor if not }
VAR cursorNumber:
TCursorNumber;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
cursorNumber := noCursor;
IF currentWindow.dialogBox <> NIL THEN
BEGIN
cursorNumber := currentWindow.dialogBox.CursorFeedback;

Apple Lisa ToolKit 3.0 Source Code Listing -- 126 of 1012

Apple Lisa Computer Technical Information


001724
001725
001726
001727
001728
001729
001730
001731
001732
001733
001734
001735
001736
001737
001738
001739
001740
001741
001742
001743
001744
001745
001746
001747
001748
001749
001750
001751
001752
001753
001754
001755
001756
001757
001758
001759
001760
001761
001762
001763
001764
001765
001766
001767
001768
001769
001770
001771

IF cursorNumber = noCursor THEN


IF currentWindow.dialogBox.downInMainWindowResponse = diRefuse THEN
cursorNumber := arrowCursor;
END;
IF cursorNumber = noCursor THEN
cursorNumber := currentWindow.CursorFeedback;
IF cursorNumber = noCursor THEN
cursorNumber := arrowCursor;
SELF.ChangeCursor(cursorNumber);
{$IFC fTrace}EP;{$ENDC}
END;

{was cantDown}

{$S SgABCini}
BEGIN
UnitAuthor('Apple');
InitProcess;
END;
METHODS OF TDocDirectory;
{$S SgABCini}
FUNCTION {TDocDirectory.}CREATE{(object: TObject; heap: THeap; itsWindow: TWindow;
itsClassWorld: TClassWorld): TDocDirectory};
VAR world: TClassWorld;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TDocDirectory(object);
WITH world DO
BEGIN
infRecs := TArray(itsClassWorld.infRecs.Clone(heap));
classes := TArray(itsClassWorld.classes.Clone(heap)); (*^*)
authors := TArray(itsClassWorld.authors.Clone(heap)); (*^*)
aliases := TArray(itsClassWorld.aliases.Clone(heap)); (*^*)
END;
WITH SELF DO
BEGIN
window := itsWindow;
classWorld := world;
END;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 127 of 1012

Apple Lisa Computer Technical Information


001772
001773
001774
001775
001776
001777
001778
001779
001780
001781
001782
001783
001784
001785
001786
001787
001788
001789
001790
001791
001792
001793
001794
001795
001796
001797
001798
001799
001800
001801
001802
001803
001804
001805
001806
001807
001808
001809
001810
001811
001812
001813
001814
001815
001816
001817
001818
001819

{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TDocDirectory.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
Field('window: TWindow');
Field('classList: TList');
END;
{$ENDC}
{$S SgABCcld}
PROCEDURE {TDocDirectory.}Adopt; (*^*)
VAR world: TClassWorld;
heap:
THeap;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
heap := SELF.Heap;
world := SELF.classWorld;
WITH world DO
BEGIN
infRecs.Free;
classes.Free;
authors.Free;
aliases.Free;
infRecs := TArray(myWorld.infRecs.Clone(heap));
classes := TArray(myWorld.classes.Clone(heap));
authors := TArray(myWorld.authors.Clone(heap));
aliases := TArray(myWorld.aliases.Clone(heap));
END;
SELF.classWorld := world;
END;
{$S SgABCini}
END;
METHODS OF TDocManager;
{$S SgABCini}
FUNCTION {TDocManager.}CREATE{(object: TObject; heap: THeap; itsPathPrefix: TFilePath): TDocManager};
VAR itsVolume: TFilePath;
itsFile:
TFilePath;
i:
INTEGER;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 128 of 1012

Apple Lisa Computer Technical Information


001820
001821
001822
001823
001824
001825
001826
001827
001828
001829
001830
001831
001832
001833
001834
001835
001836
001837
001838
001839
001840
001841
001842
001843
001844
001845
001846
001847
001848
001849
001850
001851
001852
001853
001854
001855
001856
001857
001858
001859
001860
001861
001862
001863
001864
001865
001866
001867

{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TDocManager(object);
SplitFilePath(itsPathPrefix, itsVolume, itsFile);
WITH SELF.files DO
BEGIN
volumePrefix := itsPathPrefix;
volume := itsVolume;
{$IFC LibraryVersion > 20}
password := '';
{$ENDC}
shouldSuspend := TRUE;
shouldToolSave := FALSE;
END;
WITH SELF.dataSegment DO
BEGIN
preludePtr := NIL;
FOR i := 1 TO maxSegments DO
refnum[i] := -1;
changes := 0;
END;
WITH SELF DO
BEGIN
window := NIL;
pendingNote := 0;
docHeap := NIL;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TDocManager.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN (* TFilePath = STRING[255]; maxSegments = 6 *)
Field(CONCAT('files: RECORD volumePrefix: STRING[255]; volume: STRING[255]; password: STRING[32];',
'saveExists: BOOLEAN; shouldSuspend: BOOLEAN; shouldToolSave: BOOLEAN; END'));
Field('dataSegment: RECORD refnum: ARRAY [1..6] OF INTEGER; preludePtr: Ptr; changes: LONGINT; END');
Field('docHeap: Ptr');
Field('window: TWindow');
Field('pendingNote: INTEGER');
Field('openedAsTool: BOOLEAN');
Field('');
END;
{$S SgABCres}
{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 129 of 1012

Apple Lisa Computer Technical Information


001868
001869
001870
001871
001872
001873
001874
001875
001876
001877
001878
001879
001880
001881
001882
001883
001884
001885
001886
001887
001888
001889
001890
001891
001892
001893
001894
001895
001896
001897
001898
001899
001900
001901
001902
001903
001904
001905
001906
001907
001908
001909
001910
001911
001912
001913
001914
001915

{$S SgABCcld}
PROCEDURE {TDocManager.}Assimilate{(VAR error: INTEGER)};
VAR hz:
THz;
exDocDirectory: TDocDirectory;
exClasses:
TClassWorld;
doConvert:
BOOLEAN;
olderVersion:
BOOLEAN;
newerVersion:
BOOLEAN;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
hz := POINTER(ORD(SELF.docHeap));
hz^.procCbMore := @ExpandHeap; {The code address may have changed}
error := 0;
WITH SELF.dataSegment.preludePtr^ DO
BEGIN
exDocDirectory := docDirectory;
exClasses := exDocDirectory.classWorld;
IF password <> 25376 THEN {***temporary***}
error := erPassword;
END;
(**)

IF error <= 0 THEN


IF NeedConversion(exClasses, olderVersion, newerVersion) THEN
BEGIN
IF newerVersion THEN
doConvert := process.Caution(phNewerVersion)
ELSE
IF olderVersion THEN
doConvert := process.Caution(phOlderVersion)
ELSE
doConvert := TRUE;
IF doConvert THEN
BEGIN
process.BeginWait(phConverting);
allowAbort := FALSE; {cannot abort the conversion}
ConvertHeap(SELF.docHeap, exClasses);
exDocDirectory.Adopt; (*^*)
SELF.ConserveMemory(docExcess, TRUE {GC});
allowAbort := TRUE;
process.EndWait;
END
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 130 of 1012

Apple Lisa Computer Technical Information


001916
001917
001918
001919
001920
001921
001922
001923
001924
001925
001926
001927
001928
001929
001930
001931
001932
001933
001934
001935
001936
001937
001938
001939
001940
001941
001942
001943
001944
001945
001946
001947
001948
001949
001950
001951
001952
001953
001954
001955
001956
001957
001958
001959
001960
001961
001962
001963

error := erVersion;
END;
{$IFC fTrace}EP;{$ENDC}
END;

(**)

{$S sStartup}
PROCEDURE {TDocManager.}Bind;
VAR i:
INTEGER;
error:
INTEGER;
sched_err: INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF boundDocument <> SELF THEN
BEGIN
IF boundDocument <> NIL THEN
boundDocument.Unbind;
i := 1;
{We must bind segment #1 before we can find out numSegments}
REPEAT
Sched_Class(sched_err, FALSE);
Bind_DataSeg(error, SELF.dataSegment.refnum[i]);
Sched_Class(sched_err, TRUE);
IF error > 0 THEN
ABCBreak('Bind_DataSeg', error);
i := i + 1;
UNTIL i > SELF.dataSegment.preludePtr^.numSegments;
boundDocument := SELF;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
PROCEDURE {TDocManager.}Close{(afterSuspend: BOOLEAN)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF = currentDocument THEN
BEGIN
currentDocument := NIL;
currentWindow := NIL;
activeWindowID := 0;
END;
IF NOT afterSuspend THEN
SELF.KillSegments(1, maxSegments);

Apple Lisa ToolKit 3.0 Source Code Listing -- 131 of 1012

Apple Lisa Computer Technical Information


001964
001965
001966
001967
001968
001969
001970
001971
001972
001973
001974
001975
001976
001977
001978
001979
001980
001981
001982
001983
001984
001985
001986
001987
001988
001989
001990
001991
001992
001993
001994
001995
001996
001997
001998
001999
002000
002001
002002
002003
002004
002005
002006
002007
002008
002009
002010
002011

docList.DelObject(SELF, FALSE);
IF SELF = boundDocument THEN
boundDocument := NIL;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TDocManager.}CloseFiles;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{ For the application to override IF it needs to close any of its own files }
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCini}
PROCEDURE {TDocManager.}Complete{(allIsWell: BOOLEAN)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{**** Try to save the document, code needed here. ****}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TDocManager.}ConserveMemory{(maxExcess: LONGINT; fGC: BOOLEAN)};
VAR heap:
THeap;
hz:
THz;
bytesReduced:
LONGINT;
error:
INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF <> clipboard THEN
BEGIN
heap := SELF.docHeap;
IF fGC THEN
BEGIN
MarkHeap(heap, ORD(SELF.dataSegment.preludePtr^.docDirectory));
{$IFC fDbgABC}
SweepHeap(heap, TRUE);
{Report garbage}
{$ELSEC}
SweepHeap(heap, FALSE);
{Free garbage}

Apple Lisa ToolKit 3.0 Source Code Listing -- 132 of 1012

Apple Lisa Computer Technical Information


002012
002013
002014
002015
002016
002017
002018
002019
002020
002021
002022
002023
002024
002025
002026
002027
002028
002029
002030
002031
002032
002033
002034
002035
002036
002037
002038
002039
002040
002041
002042
002043
002044
002045
002046
002047
002048
002049
002050
002051
002052
002053
002054
002055
002056
002057
002058
002059

{$ENDC}
END;
hz := POINTER(ORD(heap));
REPEAT
bytesReduced := CbShrinkHz(hz, maxSegSize)
UNTIL bytesReduced < maxSegSize;
SELF.SetSegSize(error, CbOfHz(hz) + SELF.dataSegment.preludePtr^.preludeSize, maxExcess);
IF error > 0 THEN
process.Complete(FALSE);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TDocManager.}Deactivate;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF = currentDocument THEN
BEGIN
currentWindow := NIL;
currentDocument := NIL; {so we can unbind the document}
END;
allowAbort := FALSE;
SELF.ConserveMemory(docExcess, FALSE {no GC});
allowAbort := TRUE;
SELF.Unbind;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCini}
FUNCTION {TDocManager.}DfltHeapSize{: LONGINT};
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
DfltHeapSize := docDsBytes;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

Apple Lisa ToolKit 3.0 Source Code Listing -- 133 of 1012

Apple Lisa Computer Technical Information


002060
002061
002062
002063
002064
002065
002066
002067
002068
002069
002070
002071
002072
002073
002074
002075
002076
002077
002078
002079
002080
002081
002082
002083
002084
002085
002086
002087
002088
002089
002090
002091
002092
002093
002094
002095
002096
002097
002098
002099
002100
002101
002102
002103
002104
002105
002106
002107

{$IFC fDbgABC}
{$S SgABCdbg}
PROCEDURE {TDocManager.}DumpPrelude;
VAR preludePtr: TPPrelude; {needed so WITH doesn't complain about $H+}
PROCEDURE AbortDumpVar(pVariable: Ptr; nameAndType: S255);
BEGIN
IF CheckKeyPress('Document prelude dump') THEN
BEGIN
WriteLn;
WriteLn;
Exit(DumpPrelude);
END;
DumpVar(pVariable, nameAndType);
END;
BEGIN
WriteLn;
WriteLn('--- PRELUDE OF THE DOCUMENT ---');
WriteLn;
preludePtr := SELF.dataSegment.preludePtr;
WITH preludePtr^ DO
BEGIN
AbortDumpVar(@password, 'password: INTEGER');
AbortDumpVar(@version, 'version: INTEGER');
AbortDumpVar(@country, 'country: INTEGER');
AbortDumpVar(@language, 'language: INTEGER');
AbortDumpVar(@preludeSize, 'preludeSize: INTEGER');
AbortDumpVar(@docSize, 'docSize: LONGINT');
AbortDumpVar(@numSegments, 'numSegments: INTEGER');
AbortDumpVar(@docDirectory, 'docDirectory: TDocDirectory');
END;
WriteLn;
WriteLn;
END;
{$S SgABCres}
{$ENDC}
{$S sCldInit}
PROCEDURE {TDocManager.}ExpandMemory{(bytesNeeded: LONGINT)};
VAR error:
INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.SetSegSize(error, SELF.dataSegment.preludePtr^.docSize + bytesNeeded, docExcess);
IF error > 0 THEN
process.Complete(FALSE);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 134 of 1012

Apple Lisa Computer Technical Information


002108
002109
002110
002111
002112
002113
002114
002115
002116
002117
002118
002119
002120
002121
002122
002123
002124
002125
002126
002127
002128
002129
002130
002131
002132
002133
002134
002135
002136
002137
002138
002139
002140
002141
002142
002143
002144
002145
002146
002147
002148
002149
002150
002151
002152
002153
002154
002155

{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TDocManager.}KillSegments{(first, last: INTEGER)};
VAR i:
INTEGER;
dsPathname:
PathName;
{$IFC LibraryVersion > 20}
dsPassword:
E_Name;
blankPasswd:
E_Name;
{$ENDC}
error:
INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
error := 0;
{$IFC LibraryVersion > 20}
dsPassword := SELF.files.password;
blankPasswd := '';
{$ENDC}
FOR i := first TO last DO
IF SELF.dataSegment.refnum[i] >= 0 THEN
BEGIN
dsPathName := CONCAT(SELF.files.volumePrefix, suspendSuffix[i]);
{$IFC LibraryVersion > 20}
Change_Password(error, dsPathname, dsPassword, blankPasswd);
{$ENDC}
Kill_DataSeg(error, dsPathname);
Close_DataSeg(error, SELF.dataSegment.refnum[i]);
SELF.dataSegment.refnum[i] := -1;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sCldInit}
PROCEDURE {TDocManager.}MakeSegments{(VAR error: INTEGER; oldSegments: INTEGER; newDocSize: LONGINT)};
TYPE
TempType
= ARRAY [1..MAXINT] OF Byte;
PTempType
= ^TempType;
VAR currDocSize:
LONGINT;
newSegments:
INTEGER;
i:
INTEGER;
ldsn:
INTEGER;
thisSegSize:
LONGINT;
dsPathname:
PathName;
dsRefnum:
INTEGER;
memOrd:
LONGINT;
dsInfo:
DsInfoRec;

Apple Lisa ToolKit 3.0 Source Code Listing -- 135 of 1012

Apple Lisa Computer Technical Information


002156
002157
002158
002159
002160
002161
002162
002163
002164
002165
002166
002167
002168
002169
002170
002171
002172
002173
002174
002175
002176
002177
002178
002179
002180
002181
002182
002183
002184
002185
002186
002187
002188
002189
002190
002191
002192
002193
002194
002195
002196
002197
002198
002199
002200
002201
002202
002203

newSize:
LONGINT;
p:
PTempType;
{$IFC LibraryVersion > 20}
dsPassword:
E_Name;
blankPasswd:
E_Name;
{$ENDC}
sched_err:
INTEGER;

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF (boundDocument <> NIL) AND ((boundDocument <> SELF) OR (oldSegments = 0)) THEN
boundDocument.Unbind;
{*** This may be dispensable ***}
error := 0;
IF (oldSegments > 0) THEN
BEGIN
{expand the current last data segment out to maxSegSize;
we assume that the caller has already checked that a new segment is actually needed}
dsRefnum := SELF.dataSegment.refnum[oldSegments];
Info_DataSeg(error, dsRefnum, dsInfo);
IF error <= 0 THEN
BEGIN
Sched_Class(sched_err, FALSE);
Size_DataSeg(error, dsRefnum, maxSegSize - dsInfo.mem_size, newSize,
maxSegSize - dsInfo.disc_size, newSize);
Sched_Class(sched_err, TRUE);
END
ELSE
ABCbreak('In MakeSegments, error from Info_Dataseg', error);
END;
currDocSize := oldSegments*maxSegSize;
newSegments := oldSegments;
{$IFC LibraryVersion > 20}
dsPassword := SELF.files.password;
blankPasswd := '';
{$ENDC}
WHILE (currDocSize < newDocSize) AND (error <= 0) DO
BEGIN
newSegments := newSegments + 1;
ldsn := newSegments + docLdsn-1;
thisSegSize := Min(newDocSize - currDocSize, maxSegSize);
thisSegSize := LIntMulInt(LIntDivInt(thisSegSize + 511, 512), 512);

Apple Lisa ToolKit 3.0 Source Code Listing -- 136 of 1012

Apple Lisa Computer Technical Information


002204
002205
002206
002207
002208
002209
002210
002211
002212
002213
002214
002215
002216
002217
002218
002219
002220
002221
002222
002223
002224
002225
002226
002227
002228
002229
002230
002231
002232
002233
002234
002235
002236
002237
002238
002239
002240
002241
002242
002243
002244
002245
002246
002247
002248
002249
002250
002251

dsPathname := CONCAT(SELF.files.volumePrefix, suspendSuffix[newSegments]);


{$IFC LibraryVersion > 20}
Change_Password(error, dsPathname, dsPassword, blankPasswd);
{$ENDC}
Open_Dataseg(error, dsPathname, dsRefnum, memOrd, ldsn);
{$IFC fDbgABC}
IF error > 0 THEN
WriteLn('In TDocManager.MakeSegments: error from Open_Dataseg=', error:1);
{$ENDC}
IF error > 0 THEN
BEGIN
Sched_Class(sched_err, FALSE);
Make_Dataseg(error, dsPathname, thisSegSize, thisSegSize, dsRefnum, memOrd, ldsn, ds_shared);
Sched_Class(sched_err, TRUE);
END
ELSE
BEGIN
SetAccess_DataSeg(error, dsRefnum, FALSE); {Make writeable}
IF error <= 0 THEN
BEGIN
Info_DataSeg(error, dsRefnum, dsInfo);
IF error <= 0 THEN
BEGIN
Sched_Class(sched_err, FALSE);
Size_DataSeg(error, dsRefnum, thisSegSize - dsInfo.mem_size, newSize,
thisSegSize - dsInfo.disc_size, newSize);
Sched_Class(sched_err, TRUE);
END;
END;
END;
IF error > 0 THEN
ABCBreak('In TDocManager.MakeSegments: Make_Dataseg', error)
ELSE
BEGIN
{$IFC LibraryVersion > 20}
Change_Password(error, dsPathname, blankPasswd, dsPassword);
IF error > 0 THEN
ABCBreak('In TDocManager.MakeSegments: Change_Password', error);
{$ENDC}
SELF.dataSegment.refnum[newSegments] := dsRefnum;
IF ldsn = docLdsn THEN
p := POINTER(memOrd);

Apple Lisa ToolKit 3.0 Source Code Listing -- 137 of 1012

Apple Lisa Computer Technical Information


002252
002253
002254
002255
002256
002257
002258
002259
002260
002261
002262
002263
002264
002265
002266
002267
002268
002269
002270
002271
002272
002273
002274
002275
002276
002277
002278
002279
002280
002281
002282
002283
002284
002285
002286
002287
002288
002289
002290
002291
002292
002293
002294
002295
002296
002297
002298
002299

END;
currDocSize := currDocSize + thisSegSize;
IF process.AbortRequest THEN
error := erAborted;
END;
IF error <= 0 THEN
WITH SELF.dataSegment DO
BEGIN
IF oldSegments = 0 THEN
BEGIN
boundDocument := SELF;
FOR i := 1 TO SIZEOF(TPrelude) DO
p^[i] := 0;
preludePtr := POINTER(ORD(p));
END;
preludePtr^.docSize := currDocSize;
preludePtr^.numSegments := newSegments;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S Override}
FUNCTION {TDocManager.}NewWindow{(heap: THeap; wmgrID: TWindowID): TWindow};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
NewWindow := TWindow.CREATE(NIL, heap, wmgrID, TRUE);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCldInit}
PROCEDURE {TDocManager.}Open{(VAR error: INTEGER; wmgrID: TWindowID; VAR openedSuspended: BOOLEAN)};
LABEL
1;
VAR aFile:
TFile;
volumePrefix:
TFilePath;
pWindow:
WindowPtr;
window:
TWindow;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
openedSuspended := FALSE;
volumePrefix := SELF.files.volumePrefix;
IF SELF.files.shouldToolSave OR NOT SELF.openedAsTool THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 138 of 1012

Apple Lisa Computer Technical Information


002300
002301
002302
002303
002304
002305
002306
002307
002308
002309
002310
002311
002312
002313
002314
002315
002316
002317
002318
002319
002320
002321
002322
002323
002324
002325
002326
002327
002328
002329
002330
002331
002332
002333
002334
002335
002336
002337
002338
002339
002340
002341
002342
002343
002344
002345
002346
002347

aFile := TFile.CREATE(NIL, mainHeap, volumePrefix, '');


{Look for the save file}
IF NOT aFile.Exists(error) THEN
BEGIN
aFile.Become(TFile.CREATE(NIL, mainHeap, CONCAT(volumePrefix, '$T'), ''));
IF aFile.Exists(error) THEN
aFile.Rename(error, volumePrefix);
END;
aFile.Free;
SELF.files.saveExists := error <= 0;
END
ELSE
SELF.files.saveExists := FALSE;
IF process.AbortRequest THEN
BEGIN
error := erAborted;
GOTO 1;
END;
{Try to open suspend files first, THEN the save file, THEN blank stationery}
IF SELF.files.shouldSuspend THEN
SELF.OpenSuspended(error, wmgrID)
ELSE
{don't even try the suspend file}
error := erNameNotFound;
IF error > 0 THEN
IF error <> erAborted THEN
IF SELF.files.saveExists THEN {won't even try this if we don't create save files}
SELF.OpenSaved(error, wmgrID)
ELSE
SELF.OpenBlank(error, wmgrID)
ELSE
openedSuspended := TRUE
ELSE
openedSuspended := TRUE;
IF error <= 0 THEN
BEGIN
SELF.dataSegment.changes := 0;
window := SELF.dataSegment.preludePtr^.docDirectory.window;
SELF.window := window;
window.SetWmgrId(wmgrID); {changes the wmgrId of the window and the port of the panes}

Apple Lisa ToolKit 3.0 Source Code Listing -- 139 of 1012

Apple Lisa Computer Technical Information


002348
002349
002350
002351
002352
002353
002354
002355
002356
002357
002358
002359
002360
002361
002362
002363
002364
002365
002366
002367
002368
002369
002370
002371
002372
002373
002374
002375
002376
002377
002378
002379
002380
002381
002382
002383
002384
002385
002386
002387
002388
002389
002390
002391
002392
002393
002394
002395

pWindow := POINTER(wmgrID);
SetFldrRefCon(pWindow, ORD(SELF));

1:

docList.InsLast(SELF);
END
ELSE
IF NOT openedSuspended THEN
SELF.KillSegments(1, maxSegments);

{*** Good idea?}

{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sCldInit}
PROCEDURE {TDocManager.}OpenBlank{(VAR error: INTEGER; wmgrID: TWindowID)};
LABEL 1;
VAR heapSize:
LONGINT;
heapStart:
LONGINT;
docHeap:
THeap;
prPrfAlias:
TPrPrfAlias;
objCount:
INTEGER;
docWindow:
TWindow;
docDirectory:
TDocDirectory;
PROCEDURE CheckAbort;
BEGIN
IF process.AbortRequest THEN
BEGIN
error := erAborted;
GOTO 1;
END;
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
heapSize := SELF.DfltHeapSize;
SELF.MakeSegments(error, 0, heapSize + SIZEOF(TPrelude));
IF error <= 0 THEN
BEGIN
heapStart := ORD(SELF.dataSegment.preludePtr) + SIZEOF(TPrelude);
docHeap := POINTER(ORD(HzInit(POINTER(heapStart), POINTER(heapStart+heapSize),
NIL, LIntDivInt(heapSize, 10), 0, @ExpandHeap,
POINTER(procNil), POINTER(procNil), POINTER(procNil))));
{*** DANGER ***}

Apple Lisa ToolKit 3.0 Source Code Listing -- 140 of 1012

Apple Lisa Computer Technical Information


002396
002397
002398
002399
002400
002401
002402
002403
002404
002405
002406
002407
002408
002409
002410
002411
002412
002413
002414
002415
002416
002417
002418
002419
002420
002421
002422
002423
002424
002425
002426
002427
002428
002429
002430
002431
002432
002433
002434
002435
002436
002437
002438
002439
002440
002441
002442
002443

{@ExpandHeap is a pointer outside the data segment}


{TDocManager.Assimilate must guarantee its accuracy}
CheckAbort;
PrPrfDefault(prPrfAlias.prPrf);
WITH SELF.dataSegment.preludePtr^ DO
BEGIN
password := 25376; {*** temporary ***}
version := 1; {*** should be this software's version ***}
country := countryCode;
language := countryCode; {*** same as country code? ***}
preludeSize := SIZEOF(TPrelude);
printPref := prPrfAlias.reserve;
END;
SELF.docHeap := docHeap;
docWindow := SELF.NewWindow(docHeap, wmgrID);
docDirectory := TDocDirectory.CREATE(NIL, docHeap, docWindow, myWorld);
SELF.dataSegment.preludePtr^.docDirectory := docDirectory;
docWindow.BlankStationery;
CheckAbort;
{$IFC fDbgABC}
(*
docWindow.CheckPanels;*** Should check that union of panel rects = window rect ***)
{$ENDC}
END;
1: {$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TDocManager.}OpenSaved{(VAR error: INTEGER; wmgrID: TWindowID)};
VAR volumePrefix:
TFilePath;
aFile:
TFile;
fs:
TFileScanner;
fileSize:
LONGINT;
preludePtr:
TPPrelude;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
volumePrefix := SELF.files.volumePrefix;
{$IFC LibraryVersion <= 20}
aFile := TFile.CREATE(NIL, mainHeap, volumePrefix, '');
{$ELSEC}
aFile := TFile.CREATE(NIL, mainHeap, volumePrefix, SELF.files.password);
{$ENDC}
fs := aFile.ScannerFrom(0, [fRead]);
error := fs.error;

Apple Lisa ToolKit 3.0 Source Code Listing -- 141 of 1012

Apple Lisa Computer Technical Information


002444
002445
002446
002447
002448
002449
002450
002451
002452
002453
002454
002455
002456
002457
002458
002459
002460
002461
002462
002463
002464
002465
002466
002467
002468
002469
002470
002471
002472
002473
002474
002475
002476
002477
002478
002479
002480
002481
002482
002483
002484
002485
002486
002487
002488
002489
002490
002491

IF error <= 0 THEN


BEGIN
fileSize := aFile.size;
SELF.MakeSegments(error, 0, fileSize);
IF error <= 0 THEN
BEGIN
preludePtr := SELF.dataSegment.preludePtr;
process.AbortXferSequential(xRead, POINTER(ORD(preludePtr)), fileSize, abortChunkSize, fs);
error := fs.error;
IF error <= 0 THEN
SELF.ResumeAfterOpen(error, wmgrID);
preludePtr^.docDirectory.window.changes := 0;
END;
fs.Free; {Close the file & free the TFile object}
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCini}
PROCEDURE {TDocManager.}OpenSuspended{(VAR error: INTEGER; wmgrID: TWindowID)};
VAR volumePrefix:
TFilePath;
i:
INTEGER;
ldsn:
INTEGER;
dsPathname:
PathName;
dsRefnum:
INTEGER;
memOrd:
LONGINT;
preludePtr:
TPPrelude;
cease:
BOOLEAN;
{$IFC LibraryVersion > 20}
dsPassword:
E_Name;
blankPasswd:
E_Name;
{$ENDC}
otherError:
INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF boundDocument <> NIL THEN
boundDocument.Unbind;
volumePrefix := SELF.files.volumePrefix;
{$IFC LibraryVersion > 20}
dsPassword := SELF.files.password;
blankPasswd := '';
{$ENDC}
{loop invariant: i = # datasegs already bound + 1}
i := 1;

Apple Lisa ToolKit 3.0 Source Code Listing -- 142 of 1012

Apple Lisa Computer Technical Information


002492
002493
002494
002495
002496
002497
002498
002499
002500
002501
002502
002503
002504
002505
002506
002507
002508
002509
002510
002511
002512
002513
002514
002515
002516
002517
002518
002519
002520
002521
002522
002523
002524
002525
002526
002527
002528
002529
002530
002531
002532
002533
002534
002535
002536
002537
002538
002539

REPEAT
ldsn := i + docLdsn-1;
dsPathname := CONCAT(volumePrefix, suspendSuffix[i]);
IF currentDocument <> NIL THEN
{*** Get around OS anomaly ***}
error := 313
{*** What it should return for Revert ***}
ELSE
{*** Remove these lines when fixed ***}
BEGIN
{$IFC LibraryVersion > 20}
Change_Password(error, dsPathname, dsPassword, blankPasswd);
{$ENDC}
Open_DataSeg(error, dsPathname, dsRefnum, memOrd, ldsn);
END;
IF error <= 0 THEN
BEGIN
SELF.dataSegment.refnum[i] := dsRefnum;
IF ldsn = docLdsn THEN
preludePtr := POINTER(memOrd);
SetAccess_DataSeg(error, dsRefnum, FALSE); {Make writeable}
IF error > 0 THEN
ABCBreak('In TDocManager.OpenSuspended: SetAccess_DataSeg', error);
{$IFC LibraryVersion > 20}
Change_Password(error, dsPathname, blankPasswd, dsPassword);
IF error > 0 THEN
ABCBreak('In TDocManager.OpenSuspended: Change_Password', error);
{$ENDC}
i := i + 1;
END;
IF process.AbortRequest THEN
error := erAborted;
IF error > 0 THEN
cease := TRUE
ELSE
cease := i > preludePtr^.numSegments;
UNTIL cease;
IF error <= 0 THEN
BEGIN
SELF.dataSegment.preludePtr := preludePtr;
boundDocument := SELF;
SELF.ResumeAfterOpen(error, wmgrID);
END
ELSE
WHILE i > 1 DO {back out by unbinding the datasegs}
BEGIN
i := i - 1;

Apple Lisa ToolKit 3.0 Source Code Listing -- 143 of 1012

Apple Lisa Computer Technical Information


002540
002541
002542
002543
002544
002545
002546
002547
002548
002549
002550
002551
002552
002553
002554
002555
002556
002557
002558
002559
002560
002561
002562
002563
002564
002565
002566
002567
002568
002569
002570
002571
002572
002573
002574
002575
002576
002577
002578
002579
002580
002581
002582
002583
002584
002585
002586
002587

Unbind_Dataseg(otherError, SELF.dataSegment.refnum[i]);
{$IFC fDbgABC}
IF otherError > 0 THEN
WriteLn(CHR(7), 'Error unbinding dataseg=', otherError:1);
{$ENDC}
SELF.dataSegment.refnum[i] := -1;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TDocManager.}ResumeAfterOpen{(VAR error: INTEGER; wmgrID: TWindowID)};
VAR preludePtr:
TPPrelude;
docHeap:
THeap;
objCount:
INTEGER;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
error := 0;

(*****

*****)

preludePtr := SELF.dataSegment.preludePtr;
docHeap := POINTER(ORD(preludePtr) + preludePtr^.preludeSize);
SELF.docHeap := docHeap;
SELF.Assimilate(error);
IF NOT fCheckHzOK(POINTER(ORD(docHeap)), objCount) THEN
BEGIN
ABCBreak('fCheckHzOK failed on suspend file: objCount', objCount);
error := erInternal;
END
ELSE
BEGIN
SELF.docHeap := docHeap;
SELF.Assimilate(error);
END;

{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TDocManager.}RevertVersion{(VAR error: INTEGER; wmgrID: TWindowID)};
{ for now, must be the active window to do this }
VAR dontCare:
BOOLEAN;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 144 of 1012

Apple Lisa Computer Technical Information


002588
002589
002590
002591
002592
002593
002594
002595
002596
002597
002598
002599
002600
002601
002602
002603
002604
002605
002606
002607
002608
002609
002610
002611
002612
002613
002614
002615
002616
002617
002618
002619
002620
002621
002622
002623
002624
002625
002626
002627
002628
002629
002630
002631
002632
002633
002634
002635

error := 0;
SELF.Close(FALSE);
{ active/current Window/Document should have been made NIL by SELF.Close }
currentDocument := SELF;
{We could be cleverer and reuse the old data segments, later****}
allowAbort := FALSE; {no abort allowed during revert}
SELF.Open(error, wmgrID, dontCare);
allowAbort := TRUE;
IF error > 0 THEN
BEGIN
{$IFC fDbgABC}
ABCBreak('RevertVersion error opening document', error);
{$ENDC}
END
ELSE
BEGIN
PushFocus;
currentWindow := SELF.window;
activeWindowID := currentWindow.wmgrID;
currentWindow.Focus;
currentWindow.Resize(FALSE);
InvalRect(currentWindow.innerRect);
currentWindow.Update(TRUE);
PopFocus;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TDocManager.}SaveVersion{(VAR error: INTEGER; volumePrefix: TFilePath; andContinue: BOOLEAN)};
VAR tmpFile:
TFile;
fs:
TFileScanner;
saveFile:
TFile;
localError:
INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
error := 0;
SELF.dataSegment.preludePtr^.docDirectory.window := SELF.window;
{Just in case it somehow changed}
IF NOT andContinue THEN
{*** Revert to one pane per panel scrolled to the beginning & no (or standard) selection***};
IF process.AbortRequest THEN
error := erAborted
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 145 of 1012

Apple Lisa Computer Technical Information


002636
002637
002638
002639
002640
002641
002642
002643
002644
002645
002646
002647
002648
002649
002650
002651
002652
002653
002654
002655
002656
002657
002658
002659
002660
002661
002662
002663
002664
002665
002666
002667
002668
002669
002670
002671
002672
002673
002674
002675
002676
002677
002678
002679
002680
002681
002682
002683

BEGIN
{SELF.ReleaseDiskSpace...;
*** TO DO **ONLY IF** WE CAN'T GET ENOUGH SPACE WITHOUT ***}
IF process.AbortRequest THEN
error := erAborted
ELSE
BEGIN
{$IFC LibraryVersion <= 20}
tmpFile := TFile.CREATE(NIL, mainHeap, CONCAT(volumePrefix, '$T'), '');
{$ELSEC}
tmpFile := TFile.CREATE(NIL, mainHeap, CONCAT(volumePrefix, '$T'), SELF.files.password);
{$ENDC}
fs := tmpFile.ScannerFrom(0, [fWrite]);
error := fs.error;
IF error <= 0 THEN
IF process.AbortRequest THEN
error := erAborted;
IF error > 0 THEN
BEGIN
tmpFile.Delete(localError);
fs.Free;
END
ELSE
BEGIN
process.AbortXferSequential(xWrite, POINTER(ORD(SELF.dataSegment.preludePtr)),
SELF.dataSegment.preludePtr^.docSize, abortChunkSize, fs);
fs.Compact;
{*** we should set the logical file size to the logical EOF ***}
error := fs.error;
{*** Be sure buffers are flushed ***}
IF error <= 0 THEN
IF process.AbortRequest THEN
error := erAborted;
IF error > 0 THEN
BEGIN
{$IFC fDbgABC}
ABCbreak('In TDocManager.SaveVersion, error saving file=', error);
{$ENDC}
{this is after we wrote out the file, need a wait alert if user aborted}
IF error = erAborted THEN
process.BeginWait(phAborting);
tmpFile.Delete(localError);

Apple Lisa ToolKit 3.0 Source Code Listing -- 146 of 1012

Apple Lisa Computer Technical Information


002684
002685
002686
002687
002688
002689
002690
002691
002692
002693
002694
002695
002696
002697
002698
002699
002700
002701
002702
002703
002704
002705
002706
002707
002708
002709
002710
002711
002712
002713
002714
002715
002716
002717
002718
002719
002720
002721
002722
002723
002724
002725
002726
002727
002728
002729
002730
002731

{$IFC fDbgABC}
IF localError > 0 THEN
ABCbreak('In TDocManager.SaveVersion, error deleting file=', localError);
{$ENDC}
process.EndWait;
fs.Free;
END
ELSE
BEGIN
fs.FreeObject; {don't free tmpFile yet}
IF SELF.files.saveExists THEN
BEGIN
{$IFC LibraryVersion <= 20}
saveFile := TFile.CREATE(NIL, mainHeap, volumePrefix, '');
{$ELSEC}
saveFile := TFile.CREATE(NIL, mainHeap, volumePrefix, SELF.files.password);
{$ENDC}
saveFile.Delete(localError);
saveFile.Free;
END;
SELF.files.saveExists := TRUE;
tmpFile.Rename(localError, volumePrefix);
{$IFC fDbgABC}
IF localError > 0 THEN
ABCbreak('In TDocManager.SaveVersion, error renaming file=', localError);
{$ENDC}
tmpFile.Free;
SELF.window.changes := 0;
END;
END;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sStartup}
PROCEDURE {TDocManager.}SetSegSize{(VAR error: INTEGER; minSize, maxExcess: LONGINT)};
{Make the memory and disk size of the virtual data segment be at least as indicated, and leave
some excess, but no more than the maximum indicated. Update docSize, numSegments, and the
refnum table. Assumptions:
The virtual data segment exists and is open and bound.
It has at least one real data segment, and has a valid heap that fits in the
lesser of the current diskSize and the new diskSize.

Apple Lisa ToolKit 3.0 Source Code Listing -- 147 of 1012

Apple Lisa Computer Technical Information


002732
002733
002734
002735
002736
002737
002738
002739
002740
002741
002742
002743
002744
002745
002746
002747
002748
002749
002750
002751
002752
002753
002754
002755
002756
002757
002758
002759
002760
002761
002762
002763
002764
002765
002766
002767
002768
002769
002770
002771
002772
002773
002774
002775
002776
002777
002778
002779

All LONG parameters are rounded up IF necessary to a multiple of 512 before they are used.}
VAR preludePtr:
TPPrelude;
dsInfo:
DsInfoRec;
oldMemSize:
LONGINT;
newSize:
LONGINT;
newSegments:
INTEGER;
newSegSize:
LONGINT;
temp:
LONGINT;
sched_err:
INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
error := 0;
minSize := LIntMulInt(LIntDivInt(minSize + 511, 512), 512);
maxExcess := LIntMulInt(LIntDivInt(maxExcess + 511, 512), 512);
preludePtr := SELF.dataSegment.preludePtr;
WITH preludePtr^ DO
BEGIN
Info_DataSeg(error, SELF.dataSegment.refNum[numSegments], dsInfo);
IF error > 0 THEN
ABCBreak('SetSegSize: Info_Dataseg', error);
oldMemSize := dsInfo.mem_size + (maxSegSize*(numSegments-1));
IF (oldMemSize < minSize) OR (oldMemSize > minSize + maxExcess) THEN
{need to adjust the segment size}
BEGIN
newSize := minSize + maxExcess;
newSegments := LIntDivLInt(newSize + maxSegSize - 1, maxSegSize);
{$IFC fDbgABC}
IF (numSegments < 1) OR (numSegments > maxSegments) THEN
ABCBreak('SetSegSize: numSegments NOT IN 1..maxSegments', numSegments);
IF (newSegments < 1) OR (newSegments > maxSegments) THEN
ABCBreak('SetSegSize: newSegments NOT IN 1..maxSegments', newSegments);
{$ENDC}
IF numSegments > newSegments THEN
{kill off whole segments we don't need anymore}
SELF.KillSegments(newSegments + 1, numSegments)
ELSE
IF numSegments < newSegments THEN
SELF.MakeSegments(error, numSegments, newSize);
{this sets all the segment sizes correctly}

Apple Lisa ToolKit 3.0 Source Code Listing -- 148 of 1012

Apple Lisa Computer Technical Information


002780
002781
002782
002783
002784
002785
002786
002787
002788
002789
002790
002791
002792
002793
002794
002795
002796
002797
002798
002799
002800
002801
002802
002803
002804
002805
002806
002807
002808
002809
002810
002811
002812
002813
002814
002815
002816
002817
002818
002819
002820
002821
002822
002823
002824
002825
002826
002827

{resize the new last segment}


newSegSize := newSize - (maxSegSize*(newSegments-1));
{total doc size - size of all segments before last one}
Info_DataSeg(error, SELF.dataSegment.refNum[newSegments], dsInfo);
IF error > 0 THEN
ABCBreak('SetSegSize: Info_Dataseg', error);
WITH dsInfo DO
BEGIN
Sched_Class(sched_err, FALSE);
Size_Dataseg(error, SELF.dataSegment.refnum[newSegments],
newSegSize-mem_size, temp, newSegSize-disc_size, temp);
Sched_Class(sched_err, TRUE);
END;
{$IFC fDbgABC}
IF fExperimenting THEN
BEGIN
WriteLn('In SetSegSize: newSize=', newSize:1, ' newSegments=', newSegments:1);
WITH dsInfo DO
WriteLn('newSegSize=',newSegSize:1, ' mem_size=', mem_size:1,
' disc_size=', disc_size:1);
END;
{$ENDC}
IF error > 0 THEN
BEGIN
{$IFC fDbgABC}
WriteLn('In SetSegSize: newSize=', newSize:1, ' newSegments=', newSegments:1);
WITH dsInfo DO
WriteLn('newSegSize=',newSegSize:1, ' mem_size=', mem_size:1,
' disc_size=', disc_size:1);
{$ENDC}
ABCBreak('In TDocManager.SetSegSize: Size_Dataseg', error);
END
ELSE
BEGIN
docSize := newSize;
numSegments := newSegments;
END;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

Apple Lisa ToolKit 3.0 Source Code Listing -- 149 of 1012

Apple Lisa Computer Technical Information


002828
002829
002830
002831
002832
002833
002834
002835
002836
002837
002838
002839
002840
002841
002842
002843
002844
002845
002846
002847
002848
002849
002850
002851
002852
002853
002854
002855
002856
002857
002858
002859
002860
002861
002862
002863
002864
002865
002866
002867
002868
002869
002870
002871
002872
002873
002874
002875

{$S SgABCcld}
PROCEDURE {TDocManager.}Suspend{(VAR error: INTEGER)};
LABEL 1;
VAR lastSegClosed: INTEGER;
osErr:
INTEGER;
(*********** THESE VARIABLES ARE NEEDED ONLY IF SUSPEND IS ABORTABLE
volumePrefix:
TFilePath;
ldsn:
INTEGER;
dsPathname:
PathName;
dsRefnum:
INTEGER;
memOrd:
LONGINT;
reopenedSeg:
INTEGER;
**********)
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{$IFC fDbgABC}
IF SELF <> boundDocument THEN
ABCBreak('Suspend not-bound document', error);
{$ENDC}
SELF.dataSegment.preludePtr^.docDirectory.window := SELF.window; {In case it somehow changed}
error := 0;

{*** error return here not very meaningful yet ***}

FOR lastSegClosed := 1 TO SELF.dataSegment.preludePtr^.numSegments DO


BEGIN
Close_Dataseg(osErr, SELF.dataSegment.refnum[lastSegClosed]);
LatestError(osErr, error);
SELF.dataSegment.refnum[lastSegClosed] := -1;
(********** DOES IT MAKE ANY SENSE FOR SUSPEND TO BE ABORTABLE ???? **********
IF process.AbortRequest THEN
BEGIN
volumePrefix := SELF.files.volumePrefix;
FOR reopenedSeg := 1 TO lastSegClosed DO
BEGIN
ldsn := reopenedSeg + docLdsn-1;
dsPathname := CONCAT(volumePrefix, suspendSuffix[reopenedSeg]);
Open_DataSeg(osErr, dsPathname, dsRefnum, memOrd, ldsn);
LatestError(osErr, error);
IF osErr <= 0 THEN
BEGIN
SELF.dataSegment.refnum[reopenedSeg] := dsRefnum;
SetAccess_DataSeg(osErr, dsRefnum, FALSE); {Make writeable}
IF osErr > 0 THEN
ABCBreak('ReopenDatasegs, SetAccess_DataSeg', osErr);
END
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 150 of 1012

Apple Lisa Computer Technical Information


002876
002877
002878
002879
002880
002881
002882
002883
002884
002885
002886
002887
002888
002889
002890
002891
002892
002893
002894
002895
002896
002897
002898
002899
002900
002901
002902
002903
002904
002905
002906
002907
002908
002909
002910
002911
002912
002913
002914
002915
002916
002917
002918
002919
002920
002921
002922
002923

**********)

GOTO 1;
END;
IF error <= 0 THEN
error := erAborted;
GOTO 1;
END;

END;
SELF.dataSegment.changes := 0;
boundDocument := NIL;
1: {$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

{$S SgABCcld}
PROCEDURE {TDocManager.}Unbind;
VAR error: INTEGER;
i:
INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF = boundDocument THEN
BEGIN
(***** See how things work without this check
{$IFC fDbgABC}
IF SELF = currentDocument THEN
ABCBreak('Unbind currentDocument', ORD(SELF));
{$ENDC}
*****)
FOR i := 1 TO SELF.dataSegment.preludePtr^.numSegments DO
BEGIN
Unbind_DataSeg(error, SELF.dataSegment.refnum[i]);
IF error > 0 THEN
ABCBreak('Unbind_DataSeg', error);
END;
boundDocument := NIL;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
FUNCTION {TDocManager.}WindowWithId{(wmgrID: TWindowID): TWindow};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.window.wmgrID = wmgrID THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 151 of 1012

Apple Lisa Computer Technical Information


002924
002925
002926
002927
002928
002929
002930
002931
002932
002933
002934
002935
002936
002937
002938
002939
002940
002941
002942
002943
002944
002945
002946
002947
002948
002949
002950
002951
002952
002953
002954
002955
002956
002957
002958
002959
002960
002961
002962
002963
002964
002965
002966
002967
002968
002969
002970
002971

WindowWithId := SELF.window
ELSE
WindowWithId := NIL;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
END;
METHODS OF TClipboard;
{$S SgABCini}
FUNCTION {TClipboard.}CREATE{(object: TObject; heap: THeap): TClipboard};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TClipboard(TDocManager.CREATE(object, heap, '--CLIPBOARD'));
WITH SELF DO
BEGIN
hasView := FALSE;
hasPicture := FALSE;
hasUniversalText := FALSE;
hasIcon := FALSE;
cuttingTool := 0;
cuttingProcessID := 0;
clipCopy := NIL;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TClipboard.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
TDocManager.Fields(Field);
Field('hasView: BOOLEAN');
Field('hasPicture: BOOLEAN');
Field('hasUniversalText: BOOLEAN');
Field('hasIcon: BOOLEAN');
Field('cuttingTool: LONGINT');
Field('cuttingProcessID: LONGINT');
Field('clipCopy: TFileScanner;');

Apple Lisa ToolKit 3.0 Source Code Listing -- 152 of 1012

Apple Lisa Computer Technical Information


002972
002973
002974
002975
002976
002977
002978
002979
002980
002981
002982
002983
002984
002985
002986
002987
002988
002989
002990
002991
002992
002993
002994
002995
002996
002997
002998
002999
003000
003001
003002
003003
003004
003005
003006
003007
003008
003009
003010
003011
003012
003013
003014
003015
003016
003017
003018
003019

END;
{$S SgABCres}
{$ENDC}
{$S sCut}
PROCEDURE {TClipboard.}AboutToCut;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
InheritScrap(TRUE);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCut}
PROCEDURE {TClipboard.}BeginCut;
LABEL
1;
VAR heap:
THeap;
window:
TWindow;
panel:
TPanel;
view:
TView;
selection: TSelection;
error:
INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF boundClipboard = NIL THEN
boundClipboard := SELF
ELSE
ABCBreak('BeginCut: Clipboard already bound', 0);
EraseScrapData(error);
IF error > 0 THEN
BEGIN
ABCBreak('EraseScrapData', error);
BackOutOfScrap;
{need to put up alert that cut was not put into scrap and pass this info back up the ladder}
GOTO 1;
END;
{Obtain write access}
StartPutScrap(error);
IF error > 0 THEN
BEGIN
ABCBreak('StartPutScrap', error);
BackOutOfScrap;
{need to put up alert that cut was not put into scrap and pass this info back up the ladder}
GOTO 1;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 153 of 1012

Apple Lisa Computer Technical Information


003020
003021
003022
003023
003024
003025
003026
003027
003028
003029
003030
003031
003032
003033
003034
003035
003036
003037
003038
003039
003040
003041
003042
003043
003044
003045
003046
003047
003048
003049
003050
003051
003052
003053
003054
003055
003056
003057
003058
003059
003060
003061
003062
003063
003064
003065
003066
003067

{Find out where the Clipboard heap is}


heap := POINTER(ORD(hzOfScrap));
SELF.docHeap := heap;
{Create a standard window onto the Clipboard}
window := SELF.NewWindow(heap, ORD(scrapFolder));
SELF.window := window;
panel := TPanel.CREATE(NIL, heap, window, 0, 0, [aScroll, aSplit], [aScroll, aSplit]);
{Create a dummy view to be replaced by the application's view}
view := panel.NewStatusView(NIL, zeroLRect);
1:

clipPrintPref := boundDocument.dataSegment.preludePtr^.printPref;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sPaste}
PROCEDURE {TClipboard.}Bind;
VAR which:
ScrapType;
what:
TH;
docDirectory:
TDocDirectory;
olderVersion:
BOOLEAN;
newerVersion:
BOOLEAN;
error:
INTEGER;
PROCEDURE CopyScrap;
VAR aFile:
TFile;
fs:
TFileScanner;
dsInfo:
DsInfoRec;
BEGIN
aFile := TFile.CREATE(NIL, mainHeap, 'TKScrapCopy', '');
fs := aFile.Scanner;
SELF.clipCopy := fs;
Info_Dataseg(error, DSegOfScrap, dsInfo);
{$IFC fDbgABC}
IF error > 0 THEN
ABCbreak('CopyScrap: error from Info_Dataseg', error);
{$ENDC}
WITH dsInfo DO
fs.XferSequential(xWrite, Ptr(AddrOfScrapDSeg), mem_size);
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 154 of 1012

Apple Lisa Computer Technical Information


003068
003069
003070
003071
003072
003073
003074
003075
003076
003077
003078
003079
003080
003081
003082
003083
003084
003085
003086
003087
003088
003089
003090
003091
003092
003093
003094
003095
003096
003097
003098
003099
003100
003101
003102
003103
003104
003105
003106
003107
003108
003109
003110
003111
003112
003113
003114
003115

IF boundClipboard <> SELF THEN


BEGIN
IF boundClipboard <> NIL THEN
boundClipboard.Unbind;
boundClipboard := SELF;
{Open the clipboard data segment}
StartGetScrap(error);
IF error > 0 THEN
BEGIN
ABCBreak('StartGetScrap', error);
BackOutOfScrap;
{need to put up alert that scrap cannot be bound and pass this info back up the ladder}
END
ELSE
BEGIN
{Obtain write access}
SetAccess_DataSeg(error, DSegOfScrap, FALSE);
IF error > 0 THEN
ABCBreak('SetAccess_DataSeg', error);
{Find out what is there to be pasted}
GetScrap(which, what);
SELF.window := NIL;
{$IFC LibraryVersion > 20}
IF scrapProcess = myProcessID THEN
IF which = scrapRef THEN
BEGIN
which := toolKitType;
what := Pointer(Ord(GetFldrRefCon(scrapFolder)));
END;
{$ENDC}
IF which = toolKitType THEN
BEGIN
docDirectory := POINTER(ORD(what));
(**)
(*^*)
IF scrapProcess <> myProcessID THEN {Don't waste time checking if I put it there myself}
IF NeedConversion(docDirectory.classWorld, olderVersion, newerVersion) THEN
BEGIN
CopyScrap;
{*** Should defer until app likes selection class ***}
(*** ClaimScrap; ***) (*^*)
ConvertHeap(POINTER(ORD(HzOfScrap)), docDirectory.classWorld);
docDirectory.Adopt; (*^*)

Apple Lisa ToolKit 3.0 Source Code Listing -- 155 of 1012

Apple Lisa Computer Technical Information


003116
003117
003118
003119
003120
003121
003122
003123
003124
003125
003126
003127
003128
003129
003130
003131
003132
003133
003134
003135
003136
003137
003138
003139
003140
003141
003142
003143
003144
003145
003146
003147
003148
003149
003150
003151
003152
003153
003154
003155
003156
003157
003158
003159
003160
003161
003162
003163

(**)

END;
SELF.window := docDirectory.window;
END;

{Record attributes of the clipboard data that the application might want to inquire about}
SELF.Inspect;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCut}
PROCEDURE {TClipboard.}CommitCut;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
AcceptInheritScrap;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCut}
PROCEDURE {TClipboard.}EndCut;
VAR window:
TWindow;
clipSel:
TSelection;
docDirectory:
TDocDirectory;
error:
INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
window := SELF.window;
clipSel := window.selectPanel.selection;
IF clipSel.kind = nothingKind THEN
BEGIN
{$IFC fDbgABC}
ABCBreak('No selection in Clipboard at EndCut', 0);
{$ENDC}
BackOutOfScrap;
{need to put up an alert and pass info up the ladder}
END
ELSE
BEGIN
{Display the Clipboard}
PushFocus;
window.Focus;
window.Refresh([rErase, rFrame, rBackground, rDraw], hNone);
PopFocus;

Apple Lisa ToolKit 3.0 Source Code Listing -- 156 of 1012

Apple Lisa Computer Technical Information


003164
003165
003166
003167
003168
003169
003170
003171
003172
003173
003174
003175
003176
003177
003178
003179
003180
003181
003182
003183
003184
003185
003186
003187
003188
003189
003190
003191
003192
003193
003194
003195
003196
003197
003198
003199
003200
003201
003202
003203
003204
003205
003206
003207
003208
003209
003210
003211

{Inform others of what TWindow is there to be pasted}


docDirectory := TDocDirectory.CREATE(NIL, SELF.docHeap, window, myWorld);
PutScrap(toolKitType, POINTER(ORD(docDirectory)), error);
{Record attributes of the clipboard data that the application might want to inquire about}
SELF.Inspect;
{Relinquish write access}
EndPutScrap(error);
IF error > 0 THEN
ABCBreak('EndPutScrap', error);
END;
SELF.window := NIL;
boundClipboard := NIL;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCldInit}
PROCEDURE {TClipboard.}Inspect;
VAR which:
ScrapType;
what:
TH;
pic:
PicHandle;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{$H-} SELF.docHeap := POINTER(ORD(HzOfScrap)); {$H+}
GetScrap(which, what);
SELF.hasView := which = toolKitType;
{$H-} GetGrScrap(pic); {$H+}
SELF.hasPicture := pic <> NIL;
SELF.hasUniversalText := (scrapCs IN currScrapSet);
{$IFC LibraryVersion > 20}
SELF.hasIcon := which = scrapRef;
{$ENDC}
SELF.cuttingProcessID := scrapProcess;
{$H-} SELF.cuttingTool := ToolOfProcess(scrapProcess); {$H+}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
PROCEDURE {TClipboard.}Publicize;
VAR window:
TWindow;
panel:
TPanel;
pane:
TPane;
viewExtentLRect:
LRect;

Apple Lisa ToolKit 3.0 Source Code Listing -- 157 of 1012

Apple Lisa Computer Technical Information


003212
003213
003214
003215
003216
003217
003218
003219
003220
003221
003222
003223
003224
003225
003226
003227
003228
003229
003230
003231
003232
003233
003234
003235
003236
003237
003238
003239
003240
003241
003242
003243
003244
003245
003246
003247
003248
003249
003250
003251
003252
003253
003254
003255
003256
003257
003258
003259

info:
picLRect:
tempHeap:
picRect:
tempPad:
pic:
error:

WindowInfo;
LRect;
THeap;
Rect;
TPad;
PicHandle;
INTEGER;

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF scrapProcess = myProcessID THEN
BEGIN
SELF.Bind;

window := SELF.window;
IF window <> NIL THEN {LSR}
BEGIN {LSR}
panel := TPanel(window.panels.First);
pane := TPane(panel.panes.First);
viewExtentLRect := window.selectPanel.view.extentLRect;
{Let the Window Manager have a picture to display while inactive [if open]}
GetWindInfo(POINTER(window.wmgrID), info);
IF info.visible THEN
window.StashPicture(hNone);
{Let others have a picture to paste}
noPad.RectToLRect(hugeRect, picLRect);
IF SectLRect(viewExtentLRect, picLRect, picLRect) AND NOT EmptyLRect(picLRect) THEN
BEGIN
GetHeap(tempHeap);
SetHeap(POINTER(ORD(HzOfScrap)));
{Before calling Focus, set up everything for unclipped drawing of the view}
tempPad := TPad.CREATE(NIL, mainHeap, hugeRect, picLRect, screenRes,
screenRes, thePort);
tempPad.LRectToRect(picLRect, picRect);
RectRgn(altVisRgn, picRect);
useAltVisRgn := TRUE;
{ enable clipping to whole picture }
{Focus on the Clipboard}
PushFocus;
tempPad.Focus;
focusArea := NIL;

{To trap illegal attempts to Push/PopFocus during


TView.Draw}

{Generate the Universal Picture}


pic := OpenPicture(picRect);

Apple Lisa ToolKit 3.0 Source Code Listing -- 158 of 1012

Apple Lisa Computer Technical Information


003260
003261
003262
003263
003264
003265
003266
003267
003268
003269
003270
003271
003272
003273
003274
003275
003276
003277
003278
003279
003280
003281
003282
003283
003284
003285
003286
003287
003288
003289
003290
003291
003292
003293
003294
003295
003296
003297
003298
003299
003300
003301
003302
003303
003304
003305
003306
003307

genClipPic := TRUE;
PicComment(cPicGeDwg, 0, NIL);
PicGrpBegin;
panel.view.Draw;
PicGrpEnd;

{
{
{
{

enable putting comments into picture }


needed for pasting into LisaDraw }
every LisaDraw picture from other apps is a group }
tell the application to draw now }

ClosePicture;
{Put it in the Clipboard}
PutGrScrap(pic, error);
IF error > 0 THEN
ABCBreak('PutGrScrap', error);
{Generate the Universal Text}
panel.view.CreateUniversalText;
{Unravel}
genClipPic := FALSE;
useAltVisRgn := FALSE;
PopFocus;
tempPad.Free;
SetHeap(tempHeap);
END;
END; {LSR}

{ disable putting comments into picture }


{ disable clipping to whole window }

SELF.Unbind;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sPaste}
PROCEDURE {TClipboard.}Unbind;
VAR error:
INTEGER;
PROCEDURE RestoreScrap;
VAR fs: TFileScanner;
BEGIN
fs := SELF.clipCopy;
IF fs <> NIL THEN
BEGIN
fs.XferRandom(xRead, Ptr(AddrOfScrapDSeg), fs.actual, fAbsolute, 0);
fs.Free;
SELF.clipCopy := NIL;
END;
END;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 159 of 1012

Apple Lisa Computer Technical Information


003308
003309
003310
003311
003312
003313
003314
003315
003316
003317
003318
003319
003320
003321
003322
003323
003324
003325
003326
003327
003328
003329
003330
003331
003332
003333
003334
003335
003336
003337
003338
003339
003340
003341
003342
003343
003344
003345
003346
003347
003348
003349
003350
003351
003352
003353
003354
003355

{$IFC fTrace}BP(7);{$ENDC}
IF SELF = boundClipboard THEN
BEGIN
RestoreScrap;
{$IFC fDbgABC}
IF SELF = currentDocument THEN
ABCBreak('TClipboard.Unbind currentDocument', ORD(SELF));
{$ENDC}
boundClipboard := NIL;
{Relinquish access}
SELF.window := NIL;
EndGetScrap(error);
IF error > 0 THEN
ABCBreak('EndGetScrap', error);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCut}
FUNCTION {TClipboard.}UndoCut{: BOOLEAN};
VAR clipErr:
INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
UndoInheritScrap(clipErr);
SELF.Inspect;
{so app can inquire}
(*

*)

IF (clipErr <= 0) AND SELF.hasView THEN * WRONG BECAUSE SELF.window MAY BELONG TO ANOTHER TK APP *
BEGIN
SELF.Bind;
SELF.window.Resize(FALSE); {in case clipboard resized between the cut and the undo-cut}
SELF.Unbind;
END;
UndoCut := clipErr <= 0;
{$IFC fTrace}EP;{$ENDC}
END;

{$S SgABCini}
END;
METHODS OF TCommand;

Apple Lisa ToolKit 3.0 Source Code Listing -- 160 of 1012

Apple Lisa Computer Technical Information


003356
003357
003358
003359
003360
003361
003362
003363
003364
003365
003366
003367
003368
003369
003370
003371
003372
003373
003374
003375
003376
003377
003378
003379
003380
003381
003382
003383
003384
003385
003386
003387
003388
003389
003390
003391
003392
003393
003394
003395
003396
003397
003398
003399
003400
003401
003402
003403

{$S sCommand}
FUNCTION {TCommand.}CREATE{(object: TObject; heap: THeap; itsCmdNumber: TCmdNumber;
itsImage: TImage; isUndoable: BOOLEAN; itsRevelation: TRevelation): TCommand};
VAR cmdPhase:
TCmdPhase;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TCommand(object);
WITH SELF DO
BEGIN
cmdNumber := itsCmdNumber;
image := itsImage;
undoable := isUndoable;
doing := FALSE;
revelation := itsRevelation;
FOR cmdPhase := doPhase TO redoPhase DO
BEGIN
unHiliteBefore[cmdPhase] := TRUE;
hiliteAfter[cmdPhase] := TRUE;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TCommand.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
Field('cmdNumber: INTEGER');
Field('image: TImage');
Field('undoable: BOOLEAN');
Field('doing: BOOLEAN');
Field('revelation: Byte');
Field('unHiliteBefore: ARRAY[0..2] OF BOOLEAN');
Field('hiliteAfter: ARRAY[0..2] OF BOOLEAN');
Field('');
END;
{$S SgABCres}
{$ENDC}
{$S sCommand}
PROCEDURE {TCommand.}Commit;

Apple Lisa ToolKit 3.0 Source Code Listing -- 161 of 1012

Apple Lisa Computer Technical Information


003404
003405
003406
003407
003408
003409
003410
003411
003412
003413
003414
003415
003416
003417
003418
003419
003420
003421
003422
003423
003424
003425
003426
003427
003428
003429
003430
003431
003432
003433
003434
003435
003436
003437
003438
003439
003440
003441
003442
003443
003444
003445
003446
003447
003448
003449
003450
003451

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S sFilter}
PROCEDURE {TCommand.}EachVirtualPart{(PROCEDURE DoToObject(filteredObj: TObject))};
PROCEDURE DoToFilteredObject(actualObj: TObject);
BEGIN
SELF.FilterAndDo(actualObj, DoToObject);
END;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.image <> NIL THEN
SELF.image.EachActualPart(DoToFilteredObject)
ELSE
currentWindow.EachActualPart(DoToObject);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sFilter}
PROCEDURE {TCommand.}FilterAndDo{(actualObj: TObject; PROCEDURE DoToObject(filteredObj: TObject))};
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
DoToObject(actualObj);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCommand}
PROCEDURE {TCommand.}Perform{(cmdPhase: TCmdPhase)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
END;
{$S SgABCres}
METHODS OF TCutCopyCommand;

Apple Lisa ToolKit 3.0 Source Code Listing -- 162 of 1012

Apple Lisa Computer Technical Information


003452
003453
003454
003455
003456
003457
003458
003459
003460
003461
003462
003463
003464
003465
003466
003467
003468
003469
003470
003471
003472
003473
003474
003475
003476
003477
003478
003479
003480
003481
003482
003483
003484
003485
003486
003487
003488
003489
003490
003491
003492
003493
003494
003495
003496
003497
003498
003499

{$S sCut}
FUNCTION {TCutCopyCommand.}CREATE{(object: TObject; heap: THeap; itsCmdNumber: TCmdNumber;
itsImage: TImage; isCutCmd: BOOLEAN): TCutCopyCommand};
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TCutCopyCommand(TCommand.CREATE(object, heap, itsCmdNumber, itsImage, TRUE, revealAll));
SELF.isCut := isCutCmd;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TCutCopyCommand.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
SUPERSELF.Fields(Field);
Field('isCut: BOOLEAN');
Field('');
END;
{$S SgABCcld}
{$ENDC}
{$S sCut}
PROCEDURE {TCutCopyCommand.}Commit;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
clipboard.CommitCut;
{$IFC fTrace}EP;{$ENDC}
END;
{$S Override}
PROCEDURE {TCutCopyCommand.}DoCutCopy{(clipSelection: TSelection; deleteOriginal: BOOLEAN;
cmdPhase: TCmdPhase)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCut}
PROCEDURE {TCutCopyCommand.}Perform{(cmdPhase: TCmdPhase)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 163 of 1012

Apple Lisa Computer Technical Information


003500
003501
003502
003503
003504
003505
003506
003507
003508
003509
003510
003511
003512
003513
003514
003515
003516
003517
003518
003519
003520
003521
003522
003523
003524
003525
003526
003527
003528
003529
003530
003531
003532
003533
003534
003535
003536
003537
003538
003539
003540
003541
003542
003543
003544
003545
003546
003547

CASE cmdPhase OF
doPhase:
BEGIN
clipboard.AboutToCut;
clipboard.BeginCut;
SELF.DoCutCopy(clipboard.window.selectPanel.selection, SELF.isCut, cmdPhase);
clipboard.EndCut;
END;
undoPhase:
BEGIN
IF SELF.isCut THEN
BEGIN
IF NOT clipboard.hasView THEN
ABCbreak('undoing Cut but clipboard has no view', 0)
ELSE
BEGIN
clipboard.Bind;
IF clipboard.window = NIL THEN
ABCbreak('undoing Cut but clipboard.window = NIL', 0)
ELSE
SELF.DoCutCopy(clipboard.window.selectPanel.selection, TRUE, cmdPhase);
clipboard.Unbind;
END;
END
ELSE
SELF.DoCutCopy(NIL, FALSE, cmdPhase);
IF NOT clipboard.UndoCut THEN
BEGIN
{$IFC fDbgABC}
ABCbreak('clipboard.UndoCut returns FALSE', 0);
{$ENDC}
END;
END;
redoPhase:
BEGIN
IF NOT clipBoard.UndoCut THEN
BEGIN
ABCbreak('clipboard.UndoCut returns FALSE', 0);
END
ELSE
BEGIN
clipboard.Bind;
IF NOT clipboard.hasView THEN
ABCbreak('re-doing Cut/Copy but clipboard has no view', 0)
ELSE
SELF.DoCutCopy(clipboard.window.selectPanel.selection, SELF.isCut, cmdPhase);
clipboard.Unbind;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 164 of 1012

Apple Lisa Computer Technical Information


003548
003549
003550
003551
003552
003553
003554
003555
003556
003557
003558
003559
003560
003561
003562
003563
003564
003565
003566
003567
003568
003569
003570
003571
003572
003573
003574
003575
003576
003577
003578
003579
003580
003581
003582
003583
003584
003585
003586
003587
003588
003589
003590
003591
003592
003593
003594
003595

END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
END;
{$S SgABCres}
METHODS OF TPasteCommand;
{$S sPaste}
FUNCTION {TPasteCommand.}CREATE{(object: TObject; heap: THeap; itsCmdNumber: TCmdNumber;
itsImage: TImage): TPasteCommand};
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TPasteCommand(TCommand.CREATE(object, heap, itsCmdNumber, itsImage, TRUE, revealAll));
{$IFC fTrace}EP;{$ENDC}
END;
{$S Override}
PROCEDURE {TPasteCommand.}DoPaste{(clipSelection: TSelection; pic: PicHandle; cmdPhase: TCmdPhase)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S sPaste}
PROCEDURE {TPasteCommand.}Perform{(cmdPhase: TCmdPhase)};
VAR window:
TWindow;
pic:
PicHandle;
selection: TSelection;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
CASE cmdPhase OF
doPhase, redoPhase:
IF NOT (clipboard.hasPicture OR clipboard.hasView OR clipboard.hasUniversalText) THEN
IF currScrapSet = [] THEN
process.Stop(phNoClip)
ELSE
process.Stop(phUnkClip)

Apple Lisa ToolKit 3.0 Source Code Listing -- 165 of 1012

Apple Lisa Computer Technical Information


003596
003597
003598
003599
003600
003601
003602
003603
003604
003605
003606
003607
003608
003609
003610
003611
003612
003613
003614
003615
003616
003617
003618
003619
003620
003621
003622
003623
003624

ELSE
BEGIN
clipboard.Bind;
{$H-} GetGrScrap(pic); {$H+}
window := clipboard.window;
IF window = NIL THEN
SELF.DoPaste(NIL, pic, cmdPhase)
ELSE
BEGIN
selection := window.selectPanel.selection;
IF selection.Class = cSelection THEN
SELF.DoPaste(NIL, pic, cmdPhase)
ELSE
SELF.DoPaste(selection, pic, cmdPhase);
END;
clipboard.Unbind;
END;
undoPhase:
SELF.DoPaste(NIL, NIL, cmdPhase);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
END;
{$S SgABCres}

End of File -- Lines: 3624 Characters: 116410

Apple Lisa ToolKit 3.0 Source Code Listing -- 166 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UABC3.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{INCLUDE FILE UABC3 -- IMPLEMENTATION OF UABC}


{Copyright 1983, 1984, Apple Computer, Inc.}
{TImage-TView-TPaginatedView-TPageView-TPrintManager-THeading-TSelection}

METHODS OF TImage;
{$S SgABCini}
FUNCTION {TImage.}CREATE{(object: TObject; heap: THeap; itsExtent: LRect; itsView: TView): TImage};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TImage(object);
WITH SELF DO
BEGIN
extentLRect := itsExtent;
view := itsView;
allowMouseOutside := FALSE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TImage.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
Field('extentLRect: LRect');
Field('view: TView');
Field('allowMouseOutside: BOOLEAN');
Field('');
END;
{$S SgABCres}
{$ENDC}
{$S Override}

Apple Lisa ToolKit 3.0 Source Code Listing -- 167 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

FUNCTION {TImage.}CursorAt{(mouseLPt: LPoint): TCursor};


BEGIN
{$IFC fTrace}BP(3);{$ENDC}
CursorAt := NoCursor;
{$IFC fTrace}EP;{$ENDC}
END;
{$S Override}
PROCEDURE {TImage.}Draw;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S Override}
PROCEDURE {TImage.}EachActualPart{(PROCEDURE DoToObject(filteredObj: TObject))};
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.view.panel.window.EachActualPart(DoToObject);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sFilter}
PROCEDURE {TImage.}EachVirtualPart{(PROCEDURE DoToObject(filteredObj: TObject))};
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.view.panel.window.FilterDispatch(NIL, SELF, DoToObject);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sFilter}
PROCEDURE {TImage.}FilterAndDo{(actualObj: TObject; PROCEDURE DoToObject(filteredObj: TObject))};
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.view.panel.window.FilterDispatch(actualObj, SELF, DoToObject);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCldInit}
PROCEDURE {TImage.}HaveView{(view: TView)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.view := view; {fancier subclasses do fancier things here}

Apple Lisa ToolKit 3.0 Source Code Listing -- 168 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
FUNCTION {TImage.}Hit{(mouseLPt: LPoint): BOOLEAN};
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
Hit := LRectHasLPt(SELF.extentLRect, mouseLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TImage.}Invalidate;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
IF thePad <> NIL THEN
thePad.InvalLRect(SELF.extentLRect);
{$IFC fTrace}EP;{$ENDC}
END;
{$S Override}
FUNCTION {TImage.}LaunchLayoutBox{(view: TView): TImage};
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
LaunchLayoutBox := NIL;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TImage.}OffSetBy{(deltaLPt: LPoint)};
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
{$H-} OffsetLRect(SELF.extentLRect, deltaLPt.h, deltaLPt.v); {$H+}
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TImage.}OffSetTo{(newTopLeft: LPoint)};
VAR deltaLPt:
LPoint;
curTopLeft: LPoint;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
curTopLeft := SELF.extentLRect.topLeft;

Apple Lisa ToolKit 3.0 Source Code Listing -- 169 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

SetLPt(deltaLPt, newTopLeft.h - curTopLeft.h, newTopLeft.v - curTopLeft.v);


SELF.OffsetBy(deltaLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TImage.}MouseMove{(mouseLPt: LPoint)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.view.panel <> NIL THEN
SELF.view.panel.selection.MouseMove(mouseLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TImage.}MousePress{(mouseLPt: LPoint)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.view.panel <> NIL THEN
SELF.view.panel.selection.MousePress(mouseLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TImage.}MouseRelease;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.view.panel <> NIL THEN
SELF.view.panel.selection.MouseRelease;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TImage.}MouseTrack{(mPhase: TMousePhase; mouseLPt: LPoint)};
VAR panel: TPanel;
window: TWindow;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
panel := SELF.view.panel;
IF panel <> NIL THEN
BEGIN
IF NOT (panel.selection.canCrossPanels OR SELF.allowMouseOutside) THEN
LRectHaveLPt(SELF.extentLRect, mouseLPt);
window := panel.window;

Apple Lisa ToolKit 3.0 Source Code Listing -- 170 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

window.clickPanel := panel;
END;
SELF.view.clickLPt := mouseLPt; {e.g., for Set Page Breaks use}
CASE mPhase OF
mPress:
SELF.MousePress(mouseLPt);
mMove:
SELF.MouseMove(mouseLPt);
mRelease:
BEGIN
SELF.MouseMove(mouseLPt);
window.Update(TRUE);
SELF.MouseRelease;
END;
END;
window.Update(TRUE);
{$IFC fTrace}EP;{$ENDC}
END;
{$S Override}
PROCEDURE {TImage.}ReactToPrinterChange;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S Override}
PROCEDURE {TImage.}RecalcExtent;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TImage.}Resize{(newExtent: LRect)};
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.extentLRect := newExtent;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
FUNCTION {TImage.}SeesSameAs{(image: TImage): BOOLEAN; DEFAULT};
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SeesSameAs := image = SELF;

{$}

Apple Lisa ToolKit 3.0 Source Code Listing -- 171 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
END;

METHODS OF TView;
{$S SgABCini}
FUNCTION {TView.}CREATE{(object: TObject; heap: THeap; itsPanel: TPanel; itsExtent: LRect;
itsPrintManager: TPrintManager; itsDfltMargins: LRect; itsFitPagesPerfectly:BOOLEAN;
itsRes: Point; isMainView: BOOLEAN): TView};
VAR screenPad: TPad;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TView(TImage.CREATE(object, heap, itsExtent, NIL));
WITH SELF DO
BEGIN
view := SELF;
panel := itsPanel;
printManager := itsPrintManager;
res := itsRes;
clickLPt := itsExtent.topLeft;
fitPagesPerfectly := itsFitPagesPerfectly;
{$H-}
SetPt(scrollPastEnd, 60, 40);
{$H+}
END;
SELF.isMainView := isMainView;
SELF.isPrintable := (itsPrintManager <> NIL) AND isMainView;
screenPad := TPad.CREATE(NIL, heap, zeroRect, zeroLRect, screenRes, SELF.res, NIL);
SELF.screenPad := screenPad;
{$H-}SetLPt(SELF.stdScroll, (16 * SELF.res.h) DIV screenRes.h, (11 * SELF.res.v) DIV screenRes.v); {$H+}
IF isMainView THEN
BEGIN
itsPanel.HaveView(SELF);
IF itsPrintmanager <> NIL THEN
itsPrintManager.Init(SELF, itsDfltMargins);

Apple Lisa ToolKit 3.0 Source Code Listing -- 172 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

SELF.ReactToPrinterChange;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

{$S SgABCini}
PROCEDURE {TView.}Free;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.isMainView THEN
Free(SELF.printManager);
Free(SELF.screenPad);
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TView.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
TImage.Fields(Field);
Field('panel: TPanel');
Field('clickLPt: LPoint');
Field('printManager: TPrintManager');
Field('res: Point');
Field('screenPad: TPad');
Field('fitPagesPerfectly: BOOLEAN');
Field('isPrintable: BOOLEAN');
Field('isMainView: BOOLEAN');
Field('stdScroll: LPoint');
Field('scrollPastEnd: Point');
Field('');
END;
{$S SgABCres}
{$ENDC}
{$S SgABCpri}
PROCEDURE {TView.}AddStripOfPages{(vhs: VHSelect)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.printManager <> NIL THEN
SELF.printManager.AddStripOfPages(vhs);

Apple Lisa ToolKit 3.0 Source Code Listing -- 173 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sCldInit}
PROCEDURE {TView.}BeInPanel{(panel: TPanel)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.panel := panel;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TView.}CreateUniversalText;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sRes}
FUNCTION {TView.}CursorAt{(mouseLPt: LPoint): TCursorNumber};
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
CursorAt := arrowCursor;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgDRWres}
FUNCTION {TView.}DoReceive{(selection: TSelection; lPtInView: LPoint): BOOLEAN};
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
DoReceive := FALSE; {Default is to refuse cross-panel drag}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sStartup}
FUNCTION {TView.}ForceBreakAt{(vhs: VHSelect; precedingLocation: LONGINT;
proposedLocation: LONGINT): LONGINT};
BEGIN
{$IFC fTrace}BP(11);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 174 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

ForceBreakAt := proposedLocation;
{$IFC fTrace}EP;{$ENDC}
END;

{default is to accept the proposal; client can override}

{$S sScroll}
PROCEDURE {TView.}GetStdScroll{(VAR deltaLStd: LPoint)};
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
IF NOT SELF.panel.zoomed THEN
deltaLStd := SELF.stdScroll
ELSE
WITH SELF.panel.zoomFactor DO
{$H-} BEGIN
deltaLStd.h := LIntOvrInt(LIntMulInt(ORD4(SELF.stdScroll.h), denominator.h), numerator.h);
deltaLStd.v := LIntOvrInt(LIntMulInt(ORD4(SELF.stdScroll.v), denominator.v), numerator.v);
{$H+} END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCpri}
FUNCTION {TView.}MaxPageToPrint{: LONGINT};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
MaxPageToPrint := SELF.printManager.breaks[v].size * SELF.printManager.breaks[h].size;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sStartup}
FUNCTION {TView.}NoSelection{: TSelection};
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
NoSelection := TSelection.CREATE(NIL, SELF.Heap, SELF, nothingKind, zeroLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
FUNCTION {TView.}OKToDrawIn{(lRectInView: LRect): BOOLEAN};
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
OKToDrawIn := FALSE;
{The default is to assume the worst, unless the application overrides}
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 175 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

{$S sCldInit}
PROCEDURE {TView.}ReactToPrinterChange;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.printManager <> NIL THEN
SELF.printManager.ReactToPrinterChange;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sStartup}
PROCEDURE {TView.}RedoBreaks;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF SELF.printManager <> NIL THEN
SELF.printManager.RedoBreaks;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
PROCEDURE {TView.}RemapManualBreaks{(
FUNCTION NewBreakLocation(vhs: VHSelect; oldBreak: LONGINT): LONGINT)};
VAR printManager:
TPrintManager;
oldLoc:
LONGINT;
newLoc:
LONGINT;
oldIndex:
LONGINT;
vhs:
VHSelect;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
printManager := SELF.printManager;
IF printManager <> NIL THEN
BEGIN
printManager.ClearPageBreaks(TRUE);
FOR vhs := v TO h DO
FOR oldIndex := 1 TO printManager.breaks[vhs].size - 1 DO
BEGIN
oldLoc := TpLONGINT(printManager.breaks[vhs].At(oldIndex))^;
newLoc := - NewBreakLocation(vhs, ABS(oldLoc));
printManager.breaks[vhs].PutAt(oldIndex, @newLoc);
END;
SELF.RedoBreaks;
END;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 176 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

{$S sCldInit}
PROCEDURE {TView.}Resize{(newExtent: LRect)};
VAR s:
TListScanner;
pageBreak:
LONGINT;
vhs:
VHSelect;
oldLimit:
LONGINT;
newLimit:
LONGINT;
breakIndex:
INTEGER;
breakArray:
TArray;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
IF NOT (SELF.isMainView) OR NOT(SELF.isPrintable) THEN
SUPERSELF.Resize(newExtent)
ELSE
IF NOT EqualLRect(SELF.extentLRect, newExtent) THEN
BEGIN
FOR vhs := v TO h DO
BEGIN
oldLimit := SELF.extentLRect.botRight.vh[orthogonal[vhs]];
newLimit := newExtent.botRight.vh[orthogonal[vhs]];
breakIndex := 1;
breakArray := SELF.printManager.breaks[vhs];
WHILE breakIndex <= breakArray.size DO
BEGIN
pageBreak := TpLONGINT(breakArray.At(breakIndex))^;
IF pageBreak = oldLimit THEN
BEGIN
{reset the end-of-view pagebreak to new limit}
pageBreak := newLimit;
breakArray.PutAt(breakIndex, @pageBreak);
END
ELSE
IF ABS(pageBreak) >= newLimit THEN
{discard other now-too-big pagebreaks}
BEGIN
breakArray.DelAt(breakIndex);
breakIndex := breakIndex - 1;
END;
breakIndex := breakIndex + 1;
{ELSE pagebreak still valid; do nothing}
END;
END;
SELF.extentLRect := newExtent;
SELF.panel.Rescroll;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 177 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TView.}SetFunctionValue{(keyword: S255; VAR itsValue: S255)};
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
StrUpperCased(@keyword);
IF keyword = varPage THEN {+SW+}
LIntToStr(theMarginPad.pageNumber, @itsValue)
ELSE
IF keyword = varTitle THEN {+SW+}
SELF.panel.window.GetTitle(itsValue)
{ELSE
IF keyword = ....

*** this is where to add more predefined functions ***}

ELSE {didn't parse}


itsValue := keyword;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TView.}SetMinViewSize{(VAR minLRect: LRect)};
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
minLRect := SELF.extentLRect; {client may override this to inspect his view for other ideas}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
END;
{$S SgABCres}

METHODS OF TPaginatedView;
{$S SgABCpri}
FUNCTION {TPaginatedView.}CREATE{(object: TObject; heap: THeap; itsUnpaginatedView: TView)
: TPaginatedView};
VAR viewExtent:
LRect;

Apple Lisa ToolKit 3.0 Source Code Listing -- 178 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

pgsPerRowStrip:
pgsPerColStrip:
pageWidth:
pageHeight:
printerMetrics:
pageList:
rowStrip:
colStrip:
pageOrigin:

INTEGER;
INTEGER;
LONGINT;
LONGINT;
TPrinterMetrics;
TList;
INTEGER;
INTEGER;
LPoint;

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
printerMetrics := itsUnpaginatedView.printManager.printerMetrics;
pgsPerRowStrip := itsUnpaginatedView.printManager.breaks[v].size;
pgsPerColStrip := itsUnpaginatedView.printManager.breaks[h].size;
WITH printerMetrics, paperRect DO
BEGIN
pageWidth := LIntOvrInt(LIntMulInt(ORD4(right - left), itsUnpaginatedView.res.h),
printerMetrics.res.h);
pageHeight:= LIntOvrInt(LIntMulInt(ORD4(bottom - top), itsUnpaginatedView.res.v),
printerMetrics.res.v);
END;
SetLRect(viewExtent, 0, 0, pgsPerRowStrip * ORD4(pageWidth), pgsPerColStrip * ORD4(pageHeight));
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TPaginatedView(TView.CREATE(object, heap, itsUnpaginatedView.panel, viewExtent,
itsUnpaginatedView.printManager, zeroLRect, FALSE,
itsUnpaginatedView.res, FALSE));
WITH SELF DO
BEGIN
unpaginatedView := itsUnpaginatedView;
pageSize[h] := pageWidth;
pageSize[v] := pageHeight;
workingInMargins := FALSE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TPaginatedView.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
TView.Fields(Field);

Apple Lisa ToolKit 3.0 Source Code Listing -- 179 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

Field('unPaginatedView: TView');
Field('pageSize: ARRAY[0..1] OF LONGINT');
Field('workingInMargins: BOOLEAN');
Field('');
END;
{$S SgABCcld}
{$ENDC}
{$S SgABCpri}
PROCEDURE {TPaginatedView.}AddStripOfPages{(vhs: VHSelect)};
VAR panel: TPanel;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
panel := SELF.panel;
panel.Preview(mPrvwOff); {get back to main-view metrics in the panes}
{Don't refer to SELF after this, since Preview has deallocated me}
panel.view.printManager.AddStripOfPages(vhs);
panel.Preview(mPrvwMargins); {creates fresh paginated view with correct info}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCpri}
PROCEDURE {TPaginatedView.}AdornPageOnScreen;
CONST
{$IFC LibraryVersion <= 20}
lrOffset = 10;
topOffset = 22;
bottomOffset = 9;

{$ELSEC}

{$ENDC}

{+SW+} {now using CONSTs to tune layout of pg numbers}

lrOutset = 6;
topOutset = 4;
bottomOutset = 2;
lrOffset = 10;
topOffset = 22;
bottomOffset = 9;
lrOutset = 6;
topOutset = 1; {+SW+}
bottomOutset = 1;

VAR pgNum:
r:
tempRect:
paperRect:
contentRect:

S255;
Rect;
Rect;
Rect;
Rect;

Apple Lisa ToolKit 3.0 Source Code Listing -- 180 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

pat:
{$IFC LibraryVersion <= 20}
fInfo:
{$ELSEC}
fInfo:
{$ENDC}
numberLength:
printManager:

pattern;
TFInfo;
FontInfo;
INTEGER;
TPrintManager;

PROCEDURE DistinguishScreenFeedback(theString: S255; h, v: INTEGER);


VAR box: Rect;
BEGIN
WITH box, fInfo DO
BEGIN
left := h - lrOutset;
right := h + StringWidth(theString) + lrOutset;
top := v - ascent - leading - topOutset;
bottom := v + descent + leading + bottomOutset;
END;
FillRoundRect(box, 10, 10, white);{*** These constants won't stand up under zooming! ***}
MoveTo(h, v);
DrawString(theString);
InvertRoundRect(box, 10, 10);
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
printManager := SELF.unpaginatedView.printManager;
IF focusArea <> theMarginPad THEN
theMarginPad.Focus;

{need to refocus onto the exterior...}

{frame the overall page}


penNormal;
penMode(patOr);
penSize(3,2);
FrameLRect(printManager.paperLRect);
{draw a very light-gray pattern everywhere in the margins}
theMarginPad.LRectToRect(printManager.paperLRect, paperRect);
RectRgn(padRgn, paperRect);
theMarginPad.LRectToRect(printManager.contentLRect, contentRect);
RectRgn(scrRgn1ForDrawHdgs, contentRect);
DiffRgn(padRgn, scrRgn1ForDrawHdgs, scrRgn1ForDrawHdgs);
PenMode(patOr);
theMarginPad.LPatToPat(marginPattern, pat);
PenPat(pat);
PaintRgn(scrRgn1ForDrawHdgs);

Apple Lisa ToolKit 3.0 Source Code Listing -- 181 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

IF NOT EqualRect(theBodyPad.nonNullBody, theBodyPad.innerRect) THEN


BEGIN
RectRgn(scrRgn1ForDrawHdgs, theBodyPad.innerRect);
RectRgn(scrRgn2ForDrawHdgs, theBodyPad.nonNullBody);
DiffRgn(scrRgn1ForDrawHdgs, scrRgn2ForDrawHdgs, scrRgn1ForDrawHdgs);
{Both theBodyPad.innerRect & theBodyPad.nonNullBody are expressed in (0,0)-origined
window coordinates; since we are focused on theMarginPad now, must offset the
rgn by its origin.}
WITH theMarginPad.origin DO
{$H-}
OffsetRgn(scrRgn1ForDrawHdgs, h, v);
{$H+}
thePad.SetPen(limboPen);
PaintRgn(scrRgn1ForDrawHdgs);
END;
{Frame the content rectangle--normally directly abuts the margin}
penNormal;
penMode(patOr);
FrameRect(contentRect);
{draw page numbers in corners}
IntToStr(theMarginPad.pageNumber, @pgNum);
SetQDTypeStyle(cornerNumberStyle);
numberLength := StringWidth(pgNum);
r := paperRect;
GetFontInfo(fInfo);
DistinguishScreenFeedback(pgNum, r.left + lrOffset, r.top + topOffset);
DistinguishScreenFeedback(pgNum, r.right - numberLength - lrOffset, r.top + topOffset);
DistinguishScreenFeedback(pgNum, r.right - numberLength - lrOffset, r.bottom - bottomOffset);
DistinguishScreenFeedback(pgNum, r.left + lrOffset, r.bottom - bottomOffset);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

{$S SgABCpri}
FUNCTION {TPaginatedView.}CursorAt{(mouseLPt: LPoint): TCursorNumber};
{later deal with cursor for margins}
VAR unPagLPt: LPoint;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
SELF.DepagifyLPoint(mouseLPt, unPagLPt);
CursorAt := SELF.unpaginatedView.CursorAt(unPagLPt);

Apple Lisa ToolKit 3.0 Source Code Listing -- 182 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE {TPaginatedView.}DepagifyLPoint{(pagLPt: LPoint; VAR unPagLPt: LPoint)};
{Given a point in the paginated view, determine the nearest corresponding point in the unpaginated view}
VAR printManager:
meatLRect:
vhs:
breakArray:
strip:
breakLocation:
pageBreak:
nextBreak:
pageOrigin:
strips:
lOffsetPt:

TPrintManager;
LRect;
{the portion of the page that displays a part of the main view}
VHSelect;
TArray {OF LONGINT};
INTEGER;
{the ordinal number of the strip containing the page}
LONGINT;
{the coordinate of the start of the page}
LONGINT; {the page break at the beginning of the page}
LONGINT; {the page break at the end of the page}
LPoint;
{the top left corner of the page, in the paginated view}
Point;
{the strip numbers in each direction, stored as a Point}
LPoint;
{the top left corner of the meat rect of the page, in the main view}

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
LRectHaveLPt(SELF.extentLRect, pagLPt);
printManager := SELF.unpaginatedView.printManager;
meatLRect := printManager.contentLRect;
FOR vhs := v TO h DO
BEGIN
breakArray := printManager.breaks[orthogonal[vhs]];
{compute strip number}
strip := Min(LIntDivLInt(pagLPt.vh[vhs], SELF.pageSize[vhs]) + 1, breakArray.size);
{compute breakLocation, being the location in the main view of the top-leftmost
content point of the page in which our boy was found}
IF strip = 1 THEN
breakLocation := 0
ELSE
BEGIN
pageBreak := TpLONGINT(breakArray.At(strip - 1))^;
breakLocation := ABS(pageBreak);
END;
{recompute end of meatLRect (limbo boundary)}
nextBreak := TpLONGINT(breakArray.At(strip))^;
meatLRect.botRight.vh[vhs] := meatLRect.topLeft.vh[vhs] + ABS(nextBreak) - breakLocation;
{compute pageOrigin -- the location in the paginated view of the topleft corner of this page}

Apple Lisa ToolKit 3.0 Source Code Listing -- 183 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

pageOrigin.vh[vhs] := LIntMulInt(SELF.pageSize[vhs], strip - 1);


{stuff strip and breakLocation into points for future reference}
strips.vh[vhs] := strip;
lOffsetPt.vh[vhs] := breakLocation;
END;
{project the point into the (0,0)-origined space that the printManager rectangles are in}
LPtMinusLPt(pagLPt, pageOrigin, pagLPt);
LRectHaveLPt(meatLRect, pagLPt); {force it to meat rectangle}
LPtMinusLPt(pagLPt, meatLRect.topLeft, pagLPt); {get offset from inner corner}
LPtPlusLPt(pagLPt, lOffsetPt, unPagLPt); {project onto main view}
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE {TPaginatedView.}DoOnPages{(focusOnInterior: BOOLEAN; PROCEDURE DoOnAPage))};
VAR pgsPerStrip:
INTEGER; {pages per row-strip if pageRiseDirection = h}
firstRowStrip: INTEGER;
firstColStrip: INTEGER;
lastRowStrip:
INTEGER;
lastColStrip:
INTEGER;
row:
INTEGER;
column:
INTEGER;
pageNumber:
LONGINT;
lOrigin:
LPoint;
origin:
Point;
anLRect:
LRect;
incomingPane:
TPane;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
incomingPane := TPane(thePad);
anLRect := thePad.visLRect;
IF SectLRect(anLRect, SELF.extentLRect, anLRect) THEN
{thanks for the lovely intersection};
IF EqualLRect(anLRect, zeroLRect) THEN
BEGIN
{$IFC fTrace}EP;{$ENDC}
EXIT(DoOnPages);
END;
pgsPerStrip := SELF.printManager.breaks[
orthogonal[SELF.printManager.pageRiseDirection]].size;
WITH anLRect, SELF DO
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 184 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

{$H-}

{$H+}

firstRowStrip := LIntDivLInt(topLeft.v, pageSize[v]) + 1;


firstColStrip := LIntDivLInt(topLeft.h, pageSize[h]) + 1;
lastRowStrip := MIN(LIntDivLInt(botRight.v, pageSize[v]) + 1,
SELF.printManager.breaks[h].size);
lastColStrip := MIN(LIntDivLInt(botRight.h, pageSize[h]) + 1,
SELF.printManager.breaks[v].size);
END;

PushFocus;
IF (theMarginPad.view <> SELF.unpaginatedView) OR (theMarginPad.port = printerPseudoPort) THEN
theMarginPad.Rework(SELF.unpaginatedView, zeroPt, screenRes, 1,
SELF.panel.zoomFactor, POINTER(SELF.panel.window.wmgrId));
FOR row := firstRowStrip TO lastRowStrip DO
FOR column := firstColStrip to lastColStrip DO
BEGIN
IF SELF.printManager.pageRiseDirection = h THEN
pageNumber := (row - 1) * pgsPerStrip + column
ELSE
pageNumber := (column - 1) * pgsPerStrip + row;
SetLPt(lOrigin,
LIntMulInt(SELF.pageSize[h], column - 1) - incomingPane.scrollOffset.h,
LIntMulInt(SELF.pageSize[v], row - 1)
- incomingPane.scrollOffset.v);
SELF.screenPad.LPtToPt(lOrigin, origin);
theMarginPad.SetForPage(pageNumber, origin);
theMarginPad.ClipFurtherTo(incomingPane.innerRect); {clip page down to pane}
theBodyPad.ClipFurtherTo(incomingPane.innerRect);
{ditto page body}
IF focusOnInterior THEN
theBodyPad.Focus
ELSE
theMarginPad.Focus;
DoOnAPage;
END;
PopFocus;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE {TPaginatedView.}Draw;
PROCEDURE DrawPageOnScreen;
BEGIN
SELF.printManager.DrawPage;
SELF.AdornPageOnScreen;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 185 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

BEGIN
{$IFC fTrace}BP(9);{$ENDC}
SELF.DoOnPages(FALSE, DrawPageOnScreen);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE {TPaginatedView.}MouseTrack{(mPhase: TPhase; mouseLPt: LPoint)};
VAR unPagLPt: LPoint;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
SELF.DepagifyLPoint(mouseLPt, unPagLPt);
SELF.unpaginatedView.MouseTrack(mphase, unPagLPt);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE {TPaginatedView.}PagifyLPoint{(unPagLPt: LPoint; VAR pagLPt: LPoint)};
VAR pageBreak: LONGINT;
strip:
Point;
vhs:
VHSelect;
pageNumber: LONGINT;
orthoVhs:
VHSelect;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
pageNumber := SELF.printManager.PageWith(unPagLPt, strip);
FOR vhs := v TO h DO
BEGIN
orthoVhs := orthogonal[vhs];
IF (strip.vh[orthoVhs] < 1) OR (strip.vh[orthoVhs] > SELF.printManager.breaks[orthoVhs].Size) THEN
ABCBreak('PagifyLPt: strip=', strip.vh[orthoVHs])
{only for short-term debugging}
ELSE
IF strip.vh[orthoVhs] = 1 THEN
pagLPt.vh[vhs] := unPagLPt.vh[vhs] + SELF.printManager.contentLRect.topLeft.vh[vhs]
ELSE
BEGIN
pageBreak := TpLONGINT(SELF.printManager.breaks[orthoVhs].At(strip.vh[orthoVhs] - 1))^;
pagLPt.vh[vhs] := unPagLPt.vh[vhs] + SELF.printManager.contentLRect.topLeft.vh[vhs]
+ LIntMulInt(SELF.pageSize[vhs], strip.vh[orthoVhs] - 1) - ABS(pageBreak);
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;

{$S SgABCpri}
PROCEDURE {TPaginatedView.}ReactToPrinterChange;

Apple Lisa ToolKit 3.0 Source Code Listing -- 186 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

VAR panel: TPanel;


BEGIN
{$IFC fTrace}BP(9);{$ENDC}
panel := SELF.panel;
panel.Preview(mPrvwOff); {get back to main-view metrics in the panes}
{Don't refer to SELF after this, since Preview has deallocated me}
panel.view.ReactToPrinterChange;
panel.Preview(mPrvwMargins); {creates fresh paginated view with correct info}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
PROCEDURE {TPaginatedView.}RedoBreaks;
VAR panel: TPanel;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
panel := SELF.panel;
panel.Preview(mPrvwOff); {get back to main-view metrics in the panes}
{Don't refer to SELF after this, since Preview has deallocated me}
panel.view.ReDoBreaks;
panel.Preview(mPrvwMargins); {creates fresh paginated view with correct info}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
END;
{$S SgABCres}
METHODS OF TPageView;
{$S sCldInit}
FUNCTION {TPageView.}CREATE{(object: TObject; heap: THeap; itsPrintManager: TPrintManager): TPageView};
VAR view:
TView;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
view := itsPrintManager.view;
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TPageView(TView.CREATE(object, heap, view.panel, itsPrintManager.paperLRect,
itsPrintManager, zeroLRect, FALSE, view.res, FALSE));
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

Apple Lisa ToolKit 3.0 Source Code Listing -- 187 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

{$S SgABCpri}
PROCEDURE {TPageView.}Draw;
VAR s:
TListScanner;
heading:
THeading;
pageNumber: LONGINT;
outerFrame: LRect;
headings:
TList;
editing:
BOOLEAN;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
PenNormal;
IF SELF.printManager.frameBody THEN {body should be framed...}
IF amPrinting THEN
FrameLRect(SELF.printManager.contentLRect);
editing := (SELF.printManager.layoutDialogBox <> NIL) AND
(SELF.printManager.view.panel.window.dialogBox = SELF.printManager.layoutDialogBox);
headings := SELF.printManager.headings;
IF headings <> NIL THEN
BEGIN
pageNumber := theMarginPad.pageNumber;
s := headings.Scanner;
{tell each Heading to draw itself}
WHILE s.Scan(heading) DO
IF heading.ShouldDraw(pageNumber) THEN
BEGIN
IF NOT editing THEN
BEGIN
heading.AdjustForPage(pageNumber, FALSE);
{client changes contents/extent}
heading.LocateOnPage(FALSE);
{...then we adjust to page}
END;
heading.Draw;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCini}
END;
{$S SgABCres}
{$S SgABCini}
METHODS OF TPrintManager;

Apple Lisa ToolKit 3.0 Source Code Listing -- 188 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

FUNCTION {TPrintManager.}CREATE{(object: TObject; heap: THeap): TPrintManager};


BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TPrintManager(object);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE {TPrintManager.}Init{(itsMainView: TView; itsDfltMargins: LRect)};
VAR paperLRect: LRect;
l:
TArray;
vhs:
VHSelect;
pageView:
TView;
pageBreak: LONGINT;
newList:
TList;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
newList := TList.CREATE(NIL, itsMainView.Heap, 0); {the Headings}
WITH SELF DO
BEGIN
view := itsMainView;
headings := newList;
pageRiseDirection := h;
frameBody := FALSE;
layoutDialogBox := NIL;
canEditPages := FALSE;
END;

{subclass may make true}

FOR vhs := v TO h DO
BEGIN
l := TArray.CREATE(NIL, itsMainView.Heap, 1, SIZEOF(LONGINT));
pageBreak := itsMainView.extentLRect.botRight.vh[orthogonal[vhs]];
l.InsFirst(@pageBreak);
SELF.breaks[vhs] := l;
END;
WITH itsDfltMargins DO
BEGIN {$H-}
left := ABS(left);
top := ABS(top);
right := - ABS(right);
bottom := - ABS(bottom);
END; {$H+}
SELF.pageMargins := itsDfltMargins;

Apple Lisa ToolKit 3.0 Source Code Listing -- 189 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

pageView := SELF.NewPageView(NIL);
SELF.pageView := pageView;
SELF.SetDfltHeadings;
{$IFC fTrace}EP;{$ENDC}
END;

{NB: TView.CREATE will, after calling me, call ReactToPrinterChange;


until that's done, things are not necessarily in synch}

{$S SgABCini}
PROCEDURE {TPrintManager.}Free;
VAR vhs:
VHSelect;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
FOR vhs := v TO h DO
IF SELF.breaks[vhs] <> NIL THEN
SELF.breaks[vhs].Free;
Free(SELF.pageView);
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TPrintManager.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
Field('view: TView');
Field('pageView: TPageView');
Field('breaks: ARRAY[0..1] OF TArray');
Field('pageMargins: LRect');
Field('headings: TList');
Field('canEditPages: BOOLEAN');
Field('layoutDialogBox: TDialogBox');
Field('frameBody: BOOLEAN');
Field('paperLRect: LRect');
Field('printableLRect: LRect');
{safeLRect out}
Field('contentLRect: LRect');
Field(CONCAT('printerMetrics: RECORD paperRect: Rect; printRect: Rect; ',
'res: Point; reserve: ARRAY[0..7] OF Byte END'));
Field('pageRiseDirection: BOOLEAN');
Field('');
END;
{$S SgABCres}
{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 190 of 1012

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163
001164
001165
001166
001167
001168
001169
001170
001171
001172
001173
001174
001175
001176
001177
001178
001179
001180
001181
001182
001183
001184
001185
001186
001187
001188
001189
001190
001191
001192
001193
001194
001195

{$S SgABCpri}
PROCEDURE {TPrintManager.}AddStripOfPages{(vhs: VHSelect)};
VAR newExtentLRect: LRect;
adjustment:
LONGINT;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
WITH SELF.contentLRect DO {cd save a mote by flipping vhs just before this}
adjustment := botRight.vh[orthogonal[vhs]] - topLeft.vh[orthogonal[vhs]];
WITH SELF.view.extentLRect DO
IF vhs = v THEN
{$H-}
SetLRect(newExtentLRect, left, top, right + adjustment, bottom)
ELSE
SetLRect(newExtentLRect, left, top, right, bottom + adjustment); {$H+}
SELF.view.Resize(newExtentLRect);
SELF.RedoBreaks;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCpri}
PROCEDURE {TPrintManager.}ChangeMargins{(margins: LRect)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
WITH margins DO
BEGIN {$H-}
left := ABS(left);
top := ABS(top);
right := - ABS(right);
bottom := - ABS(bottom);
END; {$H+}
SELF.pageMargins := margins;
SELF.view.panel.currentView.ReactToPrinterChange;
SELF.view.panel.Invalidate;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sCldInit}
PROCEDURE {TPrintManager.}ClearPageBreaks{(automatic: BOOLEAN)};
VAR s:
TListScanner;
break:
LONGINT;
vhs:
VHSelect;
endOfView: LONGINT;
breakIndex:
INTEGER;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 191 of 1012

Apple Lisa Computer Technical Information


001196
001197
001198
001199
001200
001201
001202
001203
001204
001205
001206
001207
001208
001209
001210
001211
001212
001213
001214
001215
001216
001217
001218
001219
001220
001221
001222
001223
001224
001225
001226
001227
001228
001229
001230
001231
001232
001233
001234
001235
001236
001237
001238
001239
001240
001241
001242
001243

{$IFC fTrace}BP(9);{$ENDC}
{ Clears all page breaks of the specified kind EXCEPT for the one marking the end of the view }
FOR vhs := v TO h DO
BEGIN
endOfView := SELF.view.extentLRect.botRight.vh[orthogonal[vhs]];
breakIndex := 1;
WHILE breakIndex < SELF.breaks[vhs].size DO
BEGIN
break := TpLONGINT(SELF.breaks[vhs].At(breakIndex))^;
IF (break >= 0) = automatic THEN
IF ABS(break) < endOfView THEN
BEGIN
SELF.breaks[vhs].DelAt(breakIndex);
breakIndex := breakIndex - 1;
END;
breakIndex := breakIndex + 1;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
PROCEDURE {TPrintManager.}DrawBreaks{(manualOnly: BOOLEAN)};
VAR wLPt1:
LPoint;
wLPt2:
LPoint;
vhs:
VHSelect;
dir:
VHSelect;
viewEnd:
LONGINT;
visEnd:
LONGINT;
widthAdjust:
INTEGER;
showing:
BOOLEAN;
limit:
LONGINT;
pageBreak:
LONGINT;
breakIndex:
INTEGER;
finished:
BOOLEAN;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
thePad.DistToLDist(autoBreakPen.pnSize, wLPt1);
thePad.DistToLDist(manualBreakPen.pnSize, wLPt2);
IF NOT amPrinting THEN
FOR vhs := v TO h DO
BEGIN
{Inhibit display of breaks to the top/left of the pane}
dir := orthogonal[vhs];
viewEnd := SELF.view.extentLRect.botRight.vh[dir];
visEnd := thePad.visLRect.botRight.vh[dir];
widthAdjust := Max(wLPt1.vh[dir], wLPt2.vh[dir]) + 1;

{add 1 in case of roundoff

Apple Lisa ToolKit 3.0 Source Code Listing -- 192 of 1012

Apple Lisa Computer Technical Information


001244
001245
001246
001247
001248
001249
001250
001251
001252
001253
001254
001255
001256
001257
001258
001259
001260
001261
001262
001263
001264
001265
001266
001267
001268
001269
001270
001271
001272
001273
001274
001275
001276
001277
001278
001279
001280
001281
001282
001283
001284
001285
001286
001287
001288
001289
001290
001291

problems}
showing := FALSE;
limit := thePad.visLRect.topLeft.vh[dir];
breakIndex := 1;
finished := FALSE;
WHILE (breakIndex <= SELF.breaks[vhs].size) AND NOT finished DO
BEGIN
pageBreak := TpLONGINT(SELF.breaks[vhs].At(breakIndex))^;
IF ABS(pageBreak) >= limit THEN
BEGIN
IF NOT showing THEN
{Start displaying breaks; reset limit to where we'll stop}
limit := Min(viewEnd, visEnd + widthAdjust);
showing := ABS(pageBreak) < limit;
IF NOT showing THEN
{Stop displaying breaks}
finished := TRUE;
END;
IF showing THEN
IF NOT ( (pageBreak >= 0) AND manualOnly) THEN
SELF.DrawOneBreak(pageBreak, vhs);
breakIndex := breakIndex + 1;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE {TPrintManager.}DrawOneBreak{(pageBreak: LONGINT; vhs: vhSelect)};
VAR lPt1:
LPoint;
lPt2:
LPoint;
pt:
Point;
wPt:
Point; {width of line}
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF pageBreak >= 0 THEN
thePad.SetPen(autoBreakPen)
ELSE
thePad.SetPen(manualBreakPen);
lPt1 := zeroLPt;
lPt2 := SELF.view.extentLRect.botRight;
lPt1.vh[orthogonal[vhs]] := ABS(pageBreak);
lPt2.vh[orthogonal[vhs]] := ABS(pageBreak);
wPt := thePort^.pnSize;
wPt.vh[vhs] := 0;

Apple Lisa ToolKit 3.0 Source Code Listing -- 193 of 1012

Apple Lisa Computer Technical Information


001292
001293
001294
001295
001296
001297
001298
001299
001300
001301
001302
001303
001304
001305
001306
001307
001308
001309
001310
001311
001312
001313
001314
001315
001316
001317
001318
001319
001320
001321
001322
001323
001324
001325
001326
001327
001328
001329
001330
001331
001332
001333
001334
001335
001336
001337
001338
001339

thePad.LPtToPt(lPt1, pt);
MoveTo(pt.h - wPt.h, pt.v - wPt.v); {wPt adjustment to hang line off top/left, not bot/right}
thePad.LPtToPt(lPt2, pt);
LineTo(pt.h - wPt.h, pt.v - wPt.v); {wPt adjustment to hang line off top/left, not bot/right}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCpri}
PROCEDURE {TPrintManager.}DrawPage;
VAR
heading:
THeading;
contentRect:
Rect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF (amPrinting) AND (SELF.frameBody) THEN {client wants frame drawn on printed page}
BEGIN
theMarginPad.LRectToRect(SELF.contentLRect, contentRect);
PenNormal;
PenSize(3,2);
PenMode(patOr);
InsetRect(contentRect, -1, -1);
FrameRect(contentRect);
END;
SELF.pageView.Draw;

{will draw headings and possibly frame body}

theBodyPad.Focus;
SELF.view.Draw;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCpri}
PROCEDURE {TPrintManager.}EnterPageEditting;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCpri}
PROCEDURE {TPrintManager.}GetPageLimits{(pageNumber: LONGINT; VAR viewLRect: LRect)};
{ NB:
The default is that page numbers go up from left-to-right, as illustrated by:

Apple Lisa ToolKit 3.0 Source Code Listing -- 194 of 1012

Apple Lisa Computer Technical Information


001340
001341
001342
001343
001344
001345
001346
001347
001348
001349
001350
001351
001352
001353
001354
001355
001356
001357
001358
001359
001360
001361
001362
001363
001364
001365
001366
001367
001368
001369
001370
001371
001372
001373
001374
001375
001376
001377
001378
001379
001380
001381
001382
001383
001384
001385
001386
001387

|--------|--------|--------|
| page 1 | page 2 | page 3 |
|--------|--------|--------|
| page 4 | page 5 | page 6 |
|--------|--------|--------|

This is what is obtained by leaving TPrintManager.pageRiseDirection


at its default value of 'h'; to get the transpose, set pageRiseDirection 'v'
VAR

totalStrips:

INTEGER;

{if pageRiseDirection is h, this is the total number of column


strips}

pageRiseDirection:
orthoDirection:
strips:
vhs:
breakArray:
strip:
nextLocation:
pageBreak:

VHSelect;
VHSelect;
Point;
VHSelect;
TArray {OF LONGINT};
INTEGER;
LONGINT;
LONGINT;

BEGIN
{$IFC fTrace}BP(9);{$ENDC}
pageRiseDirection := SELF.pageRiseDirection;
orthoDirection := orthogonal[pageRiseDirection];
totalStrips := SELF.breaks[orthoDirection].size;
strips.vh[orthoDirection] := ((pageNumber - 1) DIV totalStrips) + 1;
strips.vh[pageRiseDirection] := pageNumber - ((strips.vh[orthoDirection] - 1) * totalStrips);
FOR vhs := v TO h DO
BEGIN
breakArray := SELF.breaks[orthogonal[vhs]];
strip := strips.vh[vhs];
IF strip = 1 THEN
nextLocation := 0
ELSE
BEGIN
pageBreak := TpLONGINT(breakArray.At(strip - 1))^;
nextLocation := ABS(pageBreak);
END;
viewLRect.topLeft.vh[vhs] := nextLocation;
pageBreak := TpLONGINT(breakArray.At(strip))^;
viewLRect.botRight.vh[vhs] := ABS(pageBreak);
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 195 of 1012

Apple Lisa Computer Technical Information


001388
001389
001390
001391
001392
001393
001394
001395
001396
001397
001398
001399
001400
001401
001402
001403
001404
001405
001406
001407
001408
001409
001410
001411
001412
001413
001414
001415
001416
001417
001418
001419
001420
001421
001422
001423
001424
001425
001426
001427
001428
001429
001430
001431
001432
001433
001434
001435

{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
FUNCTION {TPrintManager.}NewPageView{(object: TObject): NewPageView};
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
NewPageView := TPageView.CREATE(object, SELF.Heap, SELF);
{$IFC fTrace}EP;{$ENDC}
END;
FUNCTION {TPrintManager.}NewPaginatedView{(object: TObject): TPaginatedView};
{Building Block or Client reimplements this to install own flavor of paginated view}
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
NewPaginatedView := TPaginatedView.CREATE(object, SELF.Heap, SELF.view);
{$IFC fTrace}EP;{$ENDC}
END;
FUNCTION {TPrintManager.}PageWith{(VAR lPtInView: LPoint; VAR strip: Point): LONGINT};
VAR pageBreak: LONGINT;
curStrip:
INTEGER;
vhs:
VHSelect;
finished:
BOOLEAN;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
LRectHaveLPt(SELF.view.extentLRect, lPtInView);
FOR vhs := v TO h DO
BEGIN
finished := FALSE;
curStrip := 1;
WHILE (curStrip <= SELF.breaks[orthogonal[vhs]].size) AND NOT finished DO
BEGIN
pageBreak := TpLONGINT(SELF.breaks[orthogonal[vhs]].At(curStrip))^;
IF lPtInView.vh[vhs] <= ABS(pageBreak) THEN
BEGIN
strip.vh[orthogonal[vhs]] := curStrip;
finished := TRUE;
END
ELSE
curStrip := curStrip + 1;
END;
END;
PageWith := (strip.vh[SELF.pageRiseDirection] - 1) *
SELF.breaks[orthogonal[SELF.pageRiseDirection]].size

Apple Lisa ToolKit 3.0 Source Code Listing -- 196 of 1012

Apple Lisa Computer Technical Information


001436
001437
001438
001439
001440
001441
001442
001443
001444
001445
001446
001447
001448
001449
001450
001451
001452
001453
001454
001455
001456
001457
001458
001459
001460
001461
001462
001463
001464
001465
001466
001467
001468
001469
001470
001471
001472
001473
001474
001475
001476
001477
001478
001479
001480
001481
001482
001483

* strip.vh[orthogonal[SELF.pageRiseDirection]];
{$IFC fTrace}EP;{$ENDC}
END;
{Note:

The Pepsi and the Spring versions of the following procedure are completely different}

{$IFC libraryVersion <= 20}


{ P E P S I }
{$S SgABCpri}
PROCEDURE {TPrintManager.}Print{(printPref: TPrReserve)};
LABEL 1,2,3,4,5,6; {as demanded by Print Manager}
VAR scaleOne:
TScaler;
pageNumber:
LONGINT;
rBand:
Rect;
pgsTotal:
LONGINT;
printerMetrics: TPrinterMetrics;
error:
INTEGER;
dispatchCode:
INTEGER; {dispatch code from LisaPrint}
fSpool:
BOOLEAN;
prPrfAlias:
TPrPrfAlias;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
prPrfAlias.reserve := printPref;
printerMetrics := SELF.printerMetrics;
SetPt(ScaleOne.numerator, 1, 1);
SetPt(ScaleOne.denominator, 1, 1);
pgsTotal := SELF.view.MaxPageToPrint; {by default, # of rowBreaks * # of colBreaks}
fSpool := TRUE;
1:
PrDocStart(dispatchCode, prPrfAlias.prIns, printLDSN);
{open the printer}
CASE PrCheckErr(dispatchCode) OF
PrGoDocStart:
BEGIN
fSpool := FALSE;
GOTO 1;
END;
PrGoDocEnd:
PrGoExit:
END; { case }

GOTO 5;
GOTO 6;

theMarginPad.Rework
(SELF.view, zeroPt, printerMetrics.res, 1,
scaleOne, printerPseudoPort); {set up margin/body pads...}
pageNumber := 0;
REPEAT

Apple Lisa ToolKit 3.0 Source Code Listing -- 197 of 1012

Apple Lisa Computer Technical Information


001484
001485
001486
001487
001488
001489
001490
001491
001492
001493
001494
001495
001496
001497
001498
001499
001500
001501
001502
001503
001504
001505
001506
001507
001508
001509
001510
001511
001512
001513
001514
001515
001516
001517
001518
001519
001520
001521
001522
001523
001524
001525
001526
001527
001528
001529
001530
001531

pageNumber := pageNumber + 1;
2:

3:

PrStartPage(dispatchCode);
CASE PrCheckErr(dispatchCode) OF
prGoDocStart:

BEGIN
fSpool := FALSE;
GOTO 1;
END;

prGoStartPage:

GOTO 2;

prGoEndPage:

BEGIN
SELF.SkipPage(pageNumber); {read on to start of next page, without
printing this one}
GOTO 4;
END;

prGoDocEnd:
prGoExit:

GOTO 5;
GOTO 6;

prGoCont:
{actually print the page}
BEGIN
theMarginPad.SetForPage(pageNumber, zeroPt);
WHILE PrNextBand(rBand) DO
BEGIN
theMarginPad.ClipFurtherTo(rBand);
theMarginPad.Focus;
SELF.DrawPage;
PrDumpBand(dispatchCode);
CASE PrCheckErr(dispatchCode) OF
PrGoDocStart:
BEGIN
fSpool := FALSE;
GOTO 1;
END;
PrGoStartPage: ABCBreak('PrGoStartPage received; page #=', pageNumber);
PrGoDumpBand : GOTO 3;
PrGoEndPage : GOTO 4;
PrGoDocEnd
: GOTO 5;
PrGoExit
: GOTO 6;
END; { CASE }
END;
{WHILE PrNextBand}
END; {prGoCont dispatch code from prStartPage}
END; {case on Err from StartPage}

4:

PrEndPage(dispatchCode);

Apple Lisa ToolKit 3.0 Source Code Listing -- 198 of 1012

Apple Lisa Computer Technical Information


001532
001533
001534
001535
001536
001537
001538
001539
001540
001541
001542
001543
001544
001545
001546
001547
001548
001549
001550
001551
001552
001553
001554
001555
001556
001557
001558
001559
001560
001561
001562
001563
001564
001565
001566
001567
001568
001569
001570
001571
001572
001573
001574
001575
001576
001577
001578
001579

CASE PrCheckErr(dispatchCode) OF
PrGoDocStart: BEGIN
fSpool := FALSE;
GOTO 1;
END;
PrGoExit:
END; { case }

GOTO 2;

UNTIL pageNumber = pgsTotal;


5:

PrDocEnd(dispatchCode);
CASE PrCheckErr(dispatchCode) OF
PrGoDocStart:

PrGoStartPage:
PrGoDocEnd
PrGoExit
END; { case }

:
:

BEGIN
fSpool := FALSE;
GOTO 1;
END;
ABCBreak('PrGoStartPage received; page #=', pageNumber);
GOTO 5;
GOTO 6;

6:

{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{ END of Pepsi-release version of TPrintmanager.Print }
(*********************************************************************************************************)
{$ELSEC}
{spring-release version of TPrintManager.Print follows}
{$S SgABCpri}
PROCEDURE {TPrintManager.}Print{(printPref: TPrReserve)};
VAR unzoomed:
TScaler;
pageNumber:
LONGINT;
pgsTotal:
LONGINT;
prPort:
TPrPort;
prPrfAlias:
TPrPrfAlias;
resPageEnd:
BOOLEAN;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
prPrfAlias.reserve := printPref;
SetPt(unzoomed.numerator, 1, 1);
SetPt(unzoomed.denominator, 1, 1);
pgsTotal := SELF.view.MaxPageToPrint; {by default, # of rowBreaks * # of colBreaks}

Apple Lisa ToolKit 3.0 Source Code Listing -- 199 of 1012

Apple Lisa Computer Technical Information


001580
001581
001582
001583
001584
001585
001586
001587
001588
001589
001590
001591
001592
001593
001594
001595
001596
001597
001598
001599
001600
001601
001602
001603
001604
001605
001606
001607
001608
001609
001610
001611
001612
001613
001614
001615
001616
001617
001618
001619
001620
001621
001622
001623
001624
001625
001626
001627

{$IFC LibraryVersion < 30}


prPrfAlias.prPrf.prLdsn := printLDSN;
IF PrDocStart(prPrfAlias.prPrf, prPort {, printLDSN} ) THEN {open the printer}
{++}
{NB ldsn param not currently in spring interface, but Eric Z says it's going back in}
{$ELSEC}
IF PrDocStart(prPrfAlias.prPrf, prPort , printLDSN, TRUE) THEN {open the printer}
{++}
{$ENDC}
BEGIN
theMarginPad.Rework
(SELF.view, zeroPt, SELF.printerMetrics.res, 1,
unzoomed, printerPseudoPort); {set up margin/body pads...}
RectRgn(altVisRgn, hugeRect);
useAltVisRgn := TRUE;
pageNumber := 0;
REPEAT
pageNumber := pageNumber + 1;
IF NOT PrPageStart(prPrfAlias.prPrf, prPort) THEN {+SW+}
SELF.SkipPage(pageNumber) {read on to start of next page, without printing this one}
ELSE
BEGIN
theMarginPad.SetForPage(pageNumber, zeroPt);
theMarginPad.Focus;
SELF.DrawPage;
END;
resPageEnd := PrPageEnd(prPrfAlias.prPrf, prPort);
UNTIL
resPageEnd OR (pageNumber >= pgsTotal);
PrDocEnd(prPrfAlias.prPrf, prPort);
{??? Do we need to stuff the prRec back into the doc?? Must ask Bayles}
useAltVisRgn := FALSE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$ENDC} {End of Spring-Release version of TPrintManager.Print}
{$S sCldInit}
PROCEDURE {TPrintManager.}ReactToPrinterChange;
VAR newExtent:
LRect;
minViewLRect:
LRect;
s:
TListScanner;
pageBreak:
LONGINT;

{several changes}

Apple Lisa ToolKit 3.0 Source Code Listing -- 200 of 1012

Apple Lisa Computer Technical Information


001628
001629
001630
001631
001632
001633
001634
001635
001636
001637
001638
001639
001640
001641
001642
001643
001644
001645
001646
001647
001648
001649
001650
001651
001652
001653
001654
001655
001656
001657
001658
001659
001660
001661
001662
001663
001664
001665
001666
001667
001668
001669
001670
001671
001672
001673
001674
001675

vhs:
curLPt:
pageIncrement:
metrics:

VHSelect;
LPoint;
LONGINT;
TPrinterMetrics;

PROCEDURE ScaleToViewedSpace(printRect: Rect;


BEGIN
SetLRect(viewedLRect,
LIntOvrInt(ORD4(printRect.left)
*
LIntOvrInt(ORD4(printRect.top)
*
LIntOvrInt(ORD4(printRect.right) *
LIntOvrInt(ORD4(printRect.bottom) *
END;

VAR viewedLRect: LRect);


SELF.view.res.h,
SELF.view.res.v,
SELF.view.res.h,
SELF.view.res.v,

metrics.res.h),
metrics.res.v),
metrics.res.h),
metrics.res.v));

BEGIN
{$IFC fTrace}BP(9);{$ENDC}
{ SELF.InvalidatePageBreaks, or some such ???}
SELF.view.panel.window.GetPrinterMetrics; {except maybe for view in first Panel created, this will
be an unnecessary (but inexpensive) step}
metrics := SELF.view.panel.window.printerMetrics;
SELF.printerMetrics := metrics;

{$H-}

WITH SELF, printerMetrics DO


BEGIN
ScaleToViewedSpace(paperRect, paperLRect);
ScaleToViewedSpace(printRect, printableLRect);
END;
LRectPlusLRect(SELF.paperLRect, SELF.pageMargins, SELF.contentLRect); {$H+}

SELF.pageView.Resize(SELF.paperLRect);
SELF.view.SetMinViewSize(newExtent); {++}
SELF.view.Resize(newExtent);
{set view back to its min size}
SELF.RedoBreaks;
{may resize the view upwards again by a bit}
{SELF.InvalidatePageBreaks again -- to force update where new breaks are to be shown}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sCldInit}
PROCEDURE {TPrintManager.}RedoBreaks;
VAR vhs:
VHSelect;
maxViewPixelsPerPage: INTEGER;
curLocation:
LONGINT;
onePixelTooMuch:
LONGINT;
endOfView:
LONGINT;
s:
TListScanner;
nextPageBreak:
LONGINT;

Apple Lisa ToolKit 3.0 Source Code Listing -- 201 of 1012

Apple Lisa Computer Technical Information


001676
001677
001678
001679
001680
001681
001682
001683
001684
001685
001686
001687
001688
001689
001690
001691
001692
001693
001694
001695
001696
001697
001698
001699
001700
001701
001702
001703
001704
001705
001706
001707
001708
001709
001710
001711
001712
001713
001714
001715
001716
001717
001718
001719
001720
001721
001722
001723

breakIndex:
penultimatePageBreak:
newViewExtent:

INTEGER;
LONGINT;
LRect;

BEGIN
{$IFC fTrace}BP(9);{$ENDC}
newViewExtent := SELF.view.extentLRect;
SELF.ClearPageBreaks(TRUE); {clear out old automatic breaks}
FOR vhs := v TO h DO
BEGIN
WITH SELF.contentLRect DO
IF vhs = v THEN
maxViewPixelsPerPage := right - left
ELSE
maxViewPixelsPerPage := bottom - top;
endOfView := SELF.view.extentLRect.botRight.vh[orthogonal[vhs]];
breakIndex := 1;
curLocation := 0;
WHILE curLocation < endOfView DO
BEGIN
nextPageBreak := TpLONGINT(SELF.breaks[vhs].At(breakIndex))^;
onePixelTooMuch := Min(curLocation + MaxViewPixelsPerPage, endOfView);
IF ABS(nextPageBreak) <= onePixelTooMuch THEN
curLocation := ABS(nextPageBreak)
ELSE {no manual page break; impose an automatic one -- propose onePixelTooMuch}
BEGIN
curLocation := SELF.view.ForceBreakAt(vhs, curLocation, onePixelTooMuch);
SELF.breaks[vhs].InsAt(breakIndex, @curLocation);
END;
breakIndex := breakIndex + 1;
END;
IF SELF.view.fitPagesPerfectly THEN {make minor adjustment upward}
BEGIN
IF (SELF.breaks[vhs].size > 1) THEN
penultimatePageBreak := TpLONGINT(SELF.breaks[vhs].At(SELF.breaks[vhs].size - 1))^
ELSE
penultimatePageBreak := 0;
newViewExtent.botRight.vh[orthogonal[vhs]] := ABS(penultimatePageBreak) +
maxViewPixelsPerPage;
END;
END; {for vhs := v to h}
SELF.view.Resize(newViewExtent);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

Apple Lisa ToolKit 3.0 Source Code Listing -- 202 of 1012

Apple Lisa Computer Technical Information


001724
001725
001726
001727
001728
001729
001730
001731
001732
001733
001734
001735
001736
001737
001738
001739
001740
001741
001742
001743
001744
001745
001746
001747
001748
001749
001750
001751
001752
001753
001754
001755
001756
001757
001758
001759
001760
001761
001762
001763
001764
001765
001766
001767
001768
001769
001770
001771

{$S SgABCpri}
PROCEDURE {TPrintManager.}SetBreak{(vhs: VHSelect; where: LONGINT; isAutomatic: BOOLEAN)};
VAR s:
TListScanner;
break:
LONGINT;
{comment gone}
prevBreakLoc: LONGINT;
breakIndex:
INTEGER;
finished:
BOOLEAN;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
prevBreakLoc := 0;
breakIndex := 1;
finished := FALSE;
WHILE (breakIndex <= SELF.breaks[vhs].size) AND NOT finished DO
BEGIN
break := TpLONGINT(SELF.breaks[vhs].At(breakIndex))^;
IF ABS(break) > where THEN
{found where to insert!}
BEGIN
where := SELF.view.ForceBreakAt(vhs, prevBreakLoc, where);
break := where;
IF NOT isAutomatic THEN
break := - break;
SELF.breaks[vhs].InsAt(breakIndex, @break);
finished := TRUE;
END
ELSE
IF ABS(break) = where THEN
{replace an existing page break}
BEGIN
break := where;
IF NOT isAutomatic THEN
break := - break;
SELF.breaks[vhs].PutAt(breakIndex, @break);
finished := TRUE;
END
ELSE
prevBreakLoc := ABS(break);
breakIndex := breakIndex + 1;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}

Apple Lisa ToolKit 3.0 Source Code Listing -- 203 of 1012

Apple Lisa Computer Technical Information


001772
001773
001774
001775
001776
001777
001778
001779
001780
001781
001782
001783
001784
001785
001786
001787
001788
001789
001790
001791
001792
001793
001794
001795
001796
001797
001798
001799
001800
001801
001802
001803
001804
001805
001806
001807
001808
001809
001810
001811
001812
001813
001814
001815
001816
001817
001818
001819

PROCEDURE {TPrintManager.}SetDfltHeadings;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

{client redefines}

{$S SgABCpri}
PROCEDURE {TPrintManager.}SkipPage{(pageNumber: LONGINT)};
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

{client may want to redefine}

{$S SgABCini}
END;
{$S SgABCres}

METHODS OF THeading;
{$S SgABCini}
FUNCTION {THeading.}CREATE{(object: TObject; heap: THeap; itsPrintManager: TPrintManager;
itsExtentLRect: LRect; itsPageAlignment: TPageAlignment; itsOffsetFromAlignment: LPoint): THeading};
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := THeading(TImage.CREATE(object, heap, itsExtentLRect, itsPrintManager.pageView));
WITH SELF DO
BEGIN
printManager := itsPrintManager;
pageAlignment := itsPageAlignment;
offsetFromAlignment := itsOffsetFromAlignment;
oddOnly := FALSE;
evenOnly := FALSE;
minPage := 2;
maxPage := MAXLINT;
END;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 204 of 1012

Apple Lisa Computer Technical Information


001820
001821
001822
001823
001824
001825
001826
001827
001828
001829
001830
001831
001832
001833
001834
001835
001836
001837
001838
001839
001840
001841
001842
001843
001844
001845
001846
001847
001848
001849
001850
001851
001852
001853
001854
001855
001856
001857
001858
001859
001860
001861
001862
001863
001864
001865
001866
001867

{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {THeading.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
TImage.Fields(Field);
Field('printManager: TPrintManager');
Field('pageAlignment: Byte'); {enumerated type}
Field('offsetFromAlignment: LPoint');
Field('oddOnly: BOOLEAN');
Field('evenOnly: BOOLEAN');
Field('minPage: LONGINT');
Field('maxPage: LONGINT');
Field('');
END;
{$S SgABCcld}
{$ENDC}
PROCEDURE {THeading.}AdjustForPage{(pageNumber: LONGINT; editing: BOOLEAN)};
{will be overridden in Subclass if meaningful}
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE {THeading.}ChangePageAlignment{(newPageAlignment: TPageAlignment)};
VAR newOffset:
LPoint;
FUNCTION Mid(anLRect: LRect; vhs: VHSelect): LONGINT;
BEGIN
Mid := (anLRect.topLeft.vh[vhs] + anLRect.botRight.vh[vhs]) DIV 2;
END;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
IF SELF.pageAlignment <> newPageAlignment THEN
BEGIN
CASE newPageAlignment OF
aTopLeft, aBottomLeft:
newOffset.h := SELF.extentLRect.left - SELF.view.extentLRect.left;
aTopCenter, aBottomCenter:
newOffset.h := Mid(SELF.extentLRect, h) - Mid(SELF.view.extentLRect, h);
aTopRight, aBottomRight:
newOffset.h := SELF.extentLRect.right - SELF.view.extentLRect.right;
END;
CASE newPageAlignment OF
aTopLeft, aTopCenter, aTopRight:
newOffset.v := SELF.extentLRect.top - SELF.view.extentLRect.top;

Apple Lisa ToolKit 3.0 Source Code Listing -- 205 of 1012

Apple Lisa Computer Technical Information


001868
001869
001870
001871
001872
001873
001874
001875
001876
001877
001878
001879
001880
001881
001882
001883
001884
001885
001886
001887
001888
001889
001890
001891
001892
001893
001894
001895
001896
001897
001898
001899
001900
001901
001902
001903
001904
001905
001906
001907
001908
001909
001910
001911
001912
001913
001914
001915

aBottomLeft, aBottomCenter, aBottomRight:


newOffset.v := SELF.extentLRect.bottom - SELF.view.extentLRect.bottom;
END;
SELF.offsetFromAlignment := newOffset;
SELF.pageAlignment := newPageAlignment;
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE {THeading.}Draw; {will be overridden in Subclass if meaningful}
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
IF SELF.shouldFrame THEN
FrameLRect(SELF.extentLRect);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE {THeading.}LocateOnPage{(editing: BOOLEAN)};
{called after client has adjusted the extentLRect and (possibly) the offsetFromAlignment}
VAR currentH, currentV, targetH, targetV:
LONGINT;
offset: LPoint;
pmgr:
TPrintManager;
(* CIRCUMVENT COMPILER BUG *)
{NB: Someday someone could use vhs and other tricks to tighten this up}
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
WITH SELF DO
BEGIN
(* CIRCUMVENT COMPILER BUG *)
pmgr := SELF.printManager;
(* CIRCUMVENT COMPILER BUG *)
WITH pmgr, paperLRect DO
BEGIN
CASE {SELF.}pageAlignment OF
aTopLeft,
aBottomLeft:
BEGIN
currentH := {SELF.}extentLRect.left;
targetH := {paperLRect.}left;
END;
aTopCenter,
aBottomCenter:
BEGIN
currentH := (extentLRect.right + extentLRect.left) DIV 2;
targetH := {paperLRect.}(right + left) DIV 2;
END;
aTopRight,
aBottomRight:
BEGIN
currentH := extentLRect.right;
targetH := right;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 206 of 1012

Apple Lisa Computer Technical Information


001916
001917
001918
001919
001920
001921
001922
001923
001924
001925
001926
001927
001928
001929
001930
001931
001932
001933
001934
001935
001936
001937
001938
001939
001940
001941
001942
001943
001944
001945
001946
001947
001948
001949
001950
001951
001952
001953
001954
001955
001956
001957
001958
001959
001960
001961
001962
001963

END;
CASE {SELF.}pageAlignment OF
aTopLeft,
aTopCenter,
aTopRight:
BEGIN
currentV := extentLRect.top;
targetV := top;
END;
aBottomLeft,
aBottomCenter,
aBottomRight:
BEGIN
currentV := extentLRect.bottom;
targetV := bottom;
END;
END;
END;
END;
(* CIRCUMVENT COMPILER BUG *)
WITH SELF.offsetFromAlignment DO
{$H-}SetLPt(offset, targetH - currentH + h, targetV - currentV + v); {$H+}
SELF.OffsetBy(offset);
{$IFC fTrace}EP;{$ENDC}
END;
FUNCTION {THeading.}ShouldDraw{(pageNumber:
VAR judgment: BOOLEAN;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
WITH SELF DO
IF (oddOnly AND NOT ODD(pageNumber))
(evenOnly AND ODD(pageNumber))
(pageNumber < minPage)
(pageNumber > maxPage)
THEN
judgment := FALSE
ELSE
judgment := TRUE;
ShouldDraw := judgment;
{$IFC fTrace}EP;{$ENDC}
END;

LONGINT): BOOLEAN};

OR
OR
OR

FUNCTION {THeading.}ShouldFrame{: BOOLEAN};


BEGIN
{$IFC fTrace}BP(9);{$ENDC}
ShouldFrame := NOT amPrinting; {default}
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 207 of 1012

Apple Lisa Computer Technical Information


001964
001965
001966
001967
001968
001969
001970
001971
001972
001973
001974
001975
001976
001977
001978
001979
001980
001981
001982
001983
001984
001985
001986
001987
001988
001989
001990
001991
001992
001993
001994
001995
001996
001997
001998
001999
002000
002001
002002
002003
002004
002005
002006
002007
002008
002009
002010
002011

END;
{$S SgABCini}
END;
{$S SgABCres}

METHODS OF TSelection;
{$S sStartup}
FUNCTION {TSelection.}CREATE{(object: TObject; heap: THeap; itsView: TView; itsKind: INTEGER;
itsAnchorLPt: LPoint): TSelection};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TSelection(object);
WITH SELF DO
BEGIN
currLPt := itsAnchorLPt;
anchorLPt := itsAnchorLPt;
boundLRect := hugeLRect;
kind := itsKind;
view := itsView;
panel := view.panel;
IF panel <> NIL THEN
window := panel.window;
coSelection := NIL;
canCrossPanels := FALSE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
FUNCTION {TSelection.}Clone{(heap: Theap): TObject};
VAR selection:
TSelection;
coSelection:
Tselection;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
selection := TSelection(SUPERSELF.Clone(heap));
IF SELF.coSelection <> NIL THEN
BEGIN
coSelection := TSelection(SELF.coSelection.Clone(heap));
selection.coSelection := coSelection;

Apple Lisa ToolKit 3.0 Source Code Listing -- 208 of 1012

Apple Lisa Computer Technical Information


002012
002013
002014
002015
002016
002017
002018
002019
002020
002021
002022
002023
002024
002025
002026
002027
002028
002029
002030
002031
002032
002033
002034
002035
002036
002037
002038
002039
002040
002041
002042
002043
002044
002045
002046
002047
002048
002049
002050
002051
002052
002053
002054
002055
002056
002057
002058
002059

END;
Clone := selection;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}Free;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
Free(SELF.coSelection);
TObject.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
FUNCTION {TSelection.}FreedAndReplacedBy{(selection: TSelection): TSelection};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.Become(selection);
FreedAndReplacedBy := SELF;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TSelection.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
Field('window: TWindow');
Field('panel: TPanel');
Field('view: TView');
Field('kind: INTEGER');
Field('anchorLPt: LPoint');
Field('currLPt: LPoint');
Field('boundLRect: LRect'); {+++LSR+++}
Field('coSelection: TSelection');
Field('canCrossPanels: BOOLEAN');
Field('');
END;
{$S SgABCres}
{$ENDC}
{$S sRes}
FUNCTION {TSelection.}CanDoCommand{(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN): BOOLEAN};
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 209 of 1012

Apple Lisa Computer Technical Information


002060
002061
002062
002063
002064
002065
002066
002067
002068
002069
002070
002071
002072
002073
002074
002075
002076
002077
002078
002079
002080
002081
002082
002083
002084
002085
002086
002087
002088
002089
002090
002091
002092
002093
002094
002095
002096
002097
002098
002099
002100
002101
002102
002103
002104
002105
002106
002107

{$IFC fTrace}BP(6);{$ENDC}
IF SELF.coSelection <> NIL THEN
CanDoCommand := SELF.coSelection.CanDoCommand(cmdNumber, checkIt)
ELSE
CanDoCommand := SELF.window.CanDoCommand(cmdNumber, checkIt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sAlert}
PROCEDURE {TSelection.}CantDoCmd{(cmdNumber: TCmdNumber)};
VAR cmdStr: S255;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF menuBar.GetCmdName(cmdNumber, @cmdStr) THEN
BEGIN
process.ArgAlert(1, cmdStr);
process.Stop(phUnkCmd);
END
ELSE
SELF.CantDoIt;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sAlert}
PROCEDURE {TSelection.}CantDoIt;
VAR ph: INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.kind = nothingKind THEN
ph := phNoSel
ELSE
ph := phSelCant;
process.Stop(ph);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}Deselect;
VAR selection: TSelection;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.panel.Highlight(SELF, hOnToOff);
selection := SELF.FreedAndReplacedBy(SELF.view.NoSelection);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 210 of 1012

Apple Lisa Computer Technical Information


002108
002109
002110
002111
002112
002113
002114
002115
002116
002117
002118
002119
002120
002121
002122
002123
002124
002125
002126
002127
002128
002129
002130
002131
002132
002133
002134
002135
002136
002137
002138
002139
002140
002141
002142
002143
002144
002145
002146
002147
002148
002149
002150
002151
002152
002153
002154
002155

{$S SgABCcld}
PROCEDURE {TSelection.}DrawGhost;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}DoKey{(ascii: CHAR; keycap: Byte; shiftKey, appleKey, optionKey: BOOLEAN)};
VAR cmdNumber:
TCmdNumber;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF appleKey THEN
BEGIN
SELF.window.SetupMenus;
cmdNumber := menuBar.CmdKey(ascii);
SELF.window.DoCommand(cmdNumber);
END
ELSE
IF currentDocument = clipboard THEN
process.Stop(phEditClip)
ELSE
IF SELF.kind = nothingKind THEN
process.Stop(phNoSel)
ELSE
BEGIN
CASE ORD(ascii) OF
ascArwDown:
SELF.KeyEnter(0, 1);
ascArwLeft:
SELF.KeyEnter(-1, 0);
ascArwRight:
SELF.KeyEnter(1, 0);
ascArwUp:
SELF.KeyEnter(0, -1);
ascClear:
SELF.KeyClear;
ascEnter:
SELF.KeyEnter(0, 0);
OTHERWISE
CASE ORD(ascii) OF
ascBackspace:
IF shiftKey THEN
SELF.KeyForward(appleKey)
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 211 of 1012

Apple Lisa Computer Technical Information


002156
002157
002158
002159
002160
002161
002162
002163
002164
002165
002166
002167
002168
002169
002170
002171
002172
002173
002174
002175
002176
002177
002178
002179
002180
002181
002182
002183
002184
002185
002186
002187
002188
002189
002190
002191
002192
002193
002194
002195
002196
002197
002198
002199
002200
002201
002202
002203

SELF.KeyBack(appleKey);
ascReturn:
SELF.KeyReturn;
ascTab:
SELF.KeyTab(shiftKey);
OTHERWISE
SELF.KeyChar(ascii);
END;

END;
IF ORD(ascii) <> ascClear THEN
process.RememberCommand(uKeyDown); {clear is special}
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}GetHysteresis{(VAR hysterPt: Point)};
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SetPt(hysterPt, stdHHysteresis, stdVHysteresis);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCpri}
PROCEDURE {TSelection.}HaveView{(view: TView)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.view := view;
IF SELF.coSelection <> NIL THEN
SELF.coSelection.HaveView(view);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TSelection.}Highlight{(highTransit: THighTransit)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.coSelection <> NIL THEN
SELF.coSelection.Highlight(highTransit);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}IdleBegin{(centiSeconds: LONGINT)};

Apple Lisa ToolKit 3.0 Source Code Listing -- 212 of 1012

Apple Lisa Computer Technical Information


002204
002205
002206
002207
002208
002209
002210
002211
002212
002213
002214
002215
002216
002217
002218
002219
002220
002221
002222
002223
002224
002225
002226
002227
002228
002229
002230
002231
002232
002233
002234
002235
002236
002237
002238
002239
002240
002241
002242
002243
002244
002245
002246
002247
002248
002249
002250
002251

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.coSelection <> NIL THEN
SELF.coSelection.IdleBegin(centiSeconds)
ELSE
SELF.window.IdleBegin(centiSeconds);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}IdleContinue{(centiSeconds: LONGINT)};
BEGIN
{$IFC fTrace}BP(5);{$ENDC}
IF SELF.coSelection <> NIL THEN
SELF.coSelection.IdleContinue(centiSeconds)
ELSE
SELF.window.IdleContinue(centiSeconds);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}IdleEnd{(centiSeconds: LONGINT)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.coSelection <> NIL THEN
SELF.coSelection.IdleEnd(centiSeconds)
ELSE
SELF.window.IdleEnd(centiSeconds);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}KeyBack{(fWord: BOOLEAN)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.coSelection <> NIL THEN
SELF.coSelection.KeyBack(fWord)
ELSE
SELF.CantDoCmd(uBackspace);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}KeyChar{(ch: CHAR)};

Apple Lisa ToolKit 3.0 Source Code Listing -- 213 of 1012

Apple Lisa Computer Technical Information


002252
002253
002254
002255
002256
002257
002258
002259
002260
002261
002262
002263
002264
002265
002266
002267
002268
002269
002270
002271
002272
002273
002274
002275
002276
002277
002278
002279
002280
002281
002282
002283
002284
002285
002286
002287
002288
002289
002290
002291
002292
002293
002294
002295
002296
002297
002298
002299

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.coSelection <> NIL THEN
SELF.coSelection.KeyChar(ch)
ELSE
SELF.CantDoCmd(uTyping);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}KeyClear;
VAR dummy: BOOLEAN;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.coSelection <> NIL THEN
SELF.coSelection.KeyClear
ELSE IF (menubar.GetCmdName(uClear, NIL))
(SELF.CanDoCommand(uClear, dummy))
BEGIN
menuBar.HighlightMenu(uClear);
SELF.window.DoCommand(uClear);
END
ELSE
BEGIN
SELF.CantDoCmd(uClear);
process.RememberCommand(uClear);
END;
{$IFC fTrace}EP;{$ENDC}
END;

{there is a CLEAR menu item} AND


{the selection says it can do it} THEN
{make believe the user chose the menu item}

{$S sRes}
PROCEDURE {TSelection.}KeyEnter{(dh, dv: INTEGER)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.coSelection <> NIL THEN
SELF.coSelection.KeyEnter(dh, dv)
ELSE
SELF.CantDoCmd(uEnter);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}KeyForward{(fWord: BOOLEAN)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 214 of 1012

Apple Lisa Computer Technical Information


002300
002301
002302
002303
002304
002305
002306
002307
002308
002309
002310
002311
002312
002313
002314
002315
002316
002317
002318
002319
002320
002321
002322
002323
002324
002325
002326
002327
002328
002329
002330
002331
002332
002333
002334
002335
002336
002337
002338
002339
002340
002341
002342
002343
002344
002345
002346
002347

IF SELF.coSelection <> NIL THEN


SELF.coSelection.KeyForward(fWord)
ELSE
SELF.CantDoCmd(uForwardSpace);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}KeyPause;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.coSelection <> NIL THEN
SELF.coSelection.KeyPause;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}KeyReturn;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.coSelection <> NIL THEN
SELF.coSelection.KeyReturn
ELSE
SELF.CantDoCmd(uReturn);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}KeyTab{(fBackward: BOOLEAN)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.coSelection <> NIL THEN
SELF.coSelection.KeyTab(fBackward)
ELSE
SELF.CantDoCmd(uTab);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
PROCEDURE {TSelection.}MarkChanged;
VAR delta:
INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.panel.window = currentWindow THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 215 of 1012

Apple Lisa Computer Technical Information


002348
002349
002350
002351
002352
002353
002354
002355
002356
002357
002358
002359
002360
002361
002362
002363
002364
002365
002366
002367
002368
002369
002370
002371
002372
002373
002374
002375
002376
002377
002378
002379
002380
002381
002382
002383
002384
002385
002386
002387
002388
002389
002390
002391
002392
002393
002394
002395

BEGIN
IF currentWindow.lastCmd = NIL THEN
delta := 1
ELSE
IF currentWindow.lastCmd.doing THEN
delta := 1
ELSE
delta := -1;
currentWindow.changes := currentWindow.changes + delta;
IF boundDocument = currentDocument THEN
WITH boundDocument DO
dataSegment.changes := dataSegment.changes + delta;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}MousePress{(mouseLPt: LPoint)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.coSelection <> NIL THEN
SELF.coSelection.MousePress(mouseLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}MouseMove{(mouseLPt: LPoint)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.coSelection <> NIL THEN
SELF.coSelection.MouseMove(mouseLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}MouseRelease;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.coSelection <> NIL THEN
SELF.coSelection.MouseRelease;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 216 of 1012

Apple Lisa Computer Technical Information


002396
002397
002398
002399
002400
002401
002402
002403
002404
002405
002406
002407
002408
002409
002410
002411
002412
002413
002414
002415
002416
002417
002418
002419
002420
002421
002422
002423
002424
002425
002426
002427
002428
002429
002430
002431
002432
002433
002434
002435
002436
002437
002438
002439
002440
002441
002442
002443

{$S SgABCcld}
PROCEDURE {TSelection.}MoveBackToAnchor;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;

{dest panel of cross-panel drag refused DoReceive}

{$S sRes}
FUNCTION {TSelection.}NewCommand{(cmdNumber: TCmdNumber): TCommand};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.coSelection <> NIL THEN
NewCommand := SELF.coSelection.NewCommand(cmdNumber)
ELSE
NewCommand := SELF.window.NewCommand(cmdNumber);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}PerformCommand{(command: TCommand; cmdPhase: TCmdPhase)};{+sw+}
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
command.doing := (cmdPhase <> undoPhase);
command.Perform(cmdPhase);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}Restore;
{SELF should be undoSelection}
VAR selection: TSelection;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
selection := SELF.panel.selection.FreedAndReplacedBy(
TSelection(SELF.panel.undoSelection.Clone(SELF.Heap))); {$}
selection := SELF.panel.undoSelection.FreedAndReplaceBy(SELF.view.NoSelection);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}Reveal(asMuchAsPossible: BOOLEAN);
TYPE TXLRect = PACKED ARRAY [1..SIZEOF(LRect)] OF CHAR;
VAR lr:
LRect;
hMin:
INTEGER;
vMin:
INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 217 of 1012

Apple Lisa Computer Technical Information


002444
002445
002446
002447
002448
002449
002450
002451
002452
002453
002454
002455
002456
002457
002458
002459
002460
002461
002462
002463
002464
002465
002466
002467
002468
002469
002470
002471
002472
002473
002474
002475
002476
002477
002478
002479
002480
002481
002482
002483
002484
002485
002486
002487
002488
002489
002490
002491

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.coSelection <> NIL THEN
SELF.coSelection.Reveal(asMuchAsPossible)
ELSE
BEGIN
lr := SELF.boundLRect;
IF TXLRect(lr) <> TXLRect(hugeLRect) THEN
BEGIN
IF NOT asMuchAsPossible THEN
BEGIN
hMin := 30;
vMin := 20;
END
ELSE
WITH lr DO
BEGIN
hMin := Min(MAXINT, right - left + 6);
vMin := Min(MAXINT, bottom - top + 4);
END;
SELF.panel.RevealLRect(lr, hMin, vMin);
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}Save;
VAR selection: TSelection;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
selection := SELF.panel.undoSelection.FreedAndReplacedBy(TSelection(SELF.Clone(SELF.Heap)));
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TSelection.}SelectParagraphs;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.coSelection <> NIL THEN
SELF.coSelection.SelectParagraphs;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}

Apple Lisa ToolKit 3.0 Source Code Listing -- 218 of 1012

Apple Lisa Computer Technical Information


002492
002493
002494
002495
002496
002497
002498
002499
002500
002501
002502
002503
002504
002505
002506

BEGIN
cSelection := THISCLASS;
END;
{$S SgABCres}

End of File -- Lines: 2506 Characters: 78752

Apple Lisa ToolKit 3.0 Source Code Listing -- 219 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UABC4.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{INCLUDE FILE UABC4 -- IMPLEMENTATION OF UABC}


{Copyright 1983, 1984, Apple Computer, Inc.}
{TWindow-TDialogBox-TMenuBar-TFont}
{changed 05/07/84 17:45 Fixed (hopefully) a bug in binary search of InAllMenusDo.}
METHODS OF TWindow;
{$S SgABCini}
FUNCTION {TWindow.}CREATE{(object: TObject; heap: THeap; itsWmgrID: TWindowID; itsResizability: BOOLEAN)
: TWindow};
VAR pWindow:
WindowPtr;
panels:
TList;
info:
WindowInfo;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TWindow(object);
GetWindInfo(WindowPtr(itsWmgrID), info);
WITH SELF DO
BEGIN
panelTree := NIL;
dialogBox := NIL;
selectPanel := NIL;
undoSelPanel := NIL;
clickPanel := NIL;
undoClickPanel := NIL;
wmgrID := itsWmgrID;
isResizable := itsResizability;
believeWmgr := info.visible;
changes := 0;
selectWindow := SELF ;
undoSelWindow := NIL; {+SW+}
lastCmd := NIL;
parentBranch := NIL;
pgSzOK := TRUE;
{client can explicitly set this to FALSE if bothered}
pgRgOK := TRUE;
{client can explicitly set this to FALSE if does own page-ranging}

Apple Lisa ToolKit 3.0 Source Code Listing -- 220 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

panelToPrint := NIL;
objectToFree := NIL; {+SW+}
END;
panels := TList.CREATE(NIL, heap, 1);
SELF.panels := panels;
IF itsWmgrID = 0 THEN
SELF.SetInnerRect(zeroRect)
ELSE
BEGIN
pWindow := POINTER(itsWmgrID);
SELF.SetInnerRect(pWindow^.portRect);
END;
{$H-} SELF.maxInnerSize := Point(FDiagRect(SELF.innerRect)); {$H+}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCini}
PROCEDURE {TWindow.}Free;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
Free(SELF.dialogBox);
SELF.panels.Free;
TArea.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TWindow.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
TArea.Fields(Field);
Field('panels: TList');
Field('panelTree: TArea');
Field('dialogBox: TDialogBox');
Field('selectPanel: TPanel');
Field('undoSelPanel: TPanel');
Field('clickPanel: TPanel');
Field('undoClickPanel: TPanel');
Field('selectWindow: TWindow');
Field('undoSelWindow: TWindow'); {+SW+}
Field('wmgrID: Ptr');

Apple Lisa ToolKit 3.0 Source Code Listing -- 221 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

Field('isResizable: BOOLEAN');
Field('believeWmgr: BOOLEAN');
Field('maxInnerSize: Point');
Field('changes: LONGINT');
Field('lastCmd: TCommand');
Field(CONCAT('printerMetrics: RECORD paperRect: Rect; printRect: Rect;',
'res: Point; reserve: ARRAY[0..3] OF INTEGER END'));
Field('pgSzOK: BOOLEAN');
Field('pgRgOK: BOOLEAN');
Field('panelToPrint: TPanel');
Field('objectToFree: TObject'); {+SW+}
Field('');
END;
{$S SgABCres}
{$ENDC}
{$S SgABCcld}
PROCEDURE {TWindow.}AbortEvent;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCpri}
PROCEDURE {TWindow.}AcceptNewPrintingInfo{(document: TDocManager; prReserve: TPrReserve)};
VAR s:
TListScanner;
panel:
TPanel;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
SELF.selectPanel.selection.MarkChanged;
IF document = clipboard THEN
{first, stuff the revised print record back in document}
clipPrintPref := prReserve
ELSE
document.dataSegment.preludePtr^.printPref := prReserve;
SELF.GetPrinterMetrics;
s := SELF.panels.Scanner;
WHILE s.Scan(panel) DO
panel.currentView.ReactToPrinterChange;
{tell each view that printer style changed}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sStartup}
PROCEDURE {TWindow.}Activate; {assumes we are focused on the window already}

Apple Lisa ToolKit 3.0 Source Code Listing -- 222 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF NOT SELF.believeWmgr THEN {is this needed????}
SELF.Resize(FALSE);
SELF.Update(TRUE);
currentWindow := SELF;

{force update in case just opened from an icon}

{NOTE: currentDocument has already been set}


activeWindowID := SELF.wmgrID;
SELF.Refresh([rFrame], hDimToOn);
IF currentDocument <> clipboard then
SELF.ChkPrMismatch;
SELF.PickStdCursor;
clipboard.Inspect;
IF SELF.dialogBox <> NIL THEN
SELF.dialogBox.Appear;
IF currentDocument.pendingNote <> 0 THEN
BEGIN
process.Note(currentDocument.pendingNote);
currentDocument.pendingNote := 0;
END;
{reset undo}
SELF.LoadMenuBar;
menuBar.Draw;
SetPt(clickState.where, -MAXINT, -MAXINT);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S Override}
PROCEDURE {TWindow.}BlankStationery;
VAR panel: TPanel;
view:
TView;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
panel := TPanel.CREATE(NIL, SELF.Heap, SELF, 0, 0, [aScroll, aSplit], [aScroll, aSplit]);
view := panel.NewStatusView(NIL, zeroLRect);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sCommand}

Apple Lisa ToolKit 3.0 Source Code Listing -- 223 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

FUNCTION {TWindow.}CanDoCommand{(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN): BOOLEAN};


BEGIN
{$IFC fTrace}BP(6);{$ENDC}
CanDoCommand := currentWindow.CanDoStdCommand(cmdNumber, checkIt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCommand}
FUNCTION {TWindow.}CanDoStdCommand{(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN): BOOLEAN};
VAR previewMode:
TPreviewMode;
couldPrint:
BOOLEAN;
panelToUse:
TPanel;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
CanDoStdCommand := FALSE;
couldPrint := (SELF.panelToPrint <> NIL);
IF couldPrint THEN
IF SELF.selectPanel.view.isPrintable THEN
panelToUse := SELF.selectPanel
ELSE
panelToUse := SELF.panelToPrint;
IF couldPrint THEN
previewMode := panelToUse.previewMode;
CASE cmdNumber OF
{File/Print}
uSetAllAside, uSetAside, uSetClipAside:
CanDoStdCommand := TRUE;
uPutAway, uRevertVersion:
CanDoStdCommand := clipboard.window <> SELF;
uSaveVersion:
CanDoStdCommand := (clipboard.window <> SELF) AND
(currentDocument.files.shouldToolSave OR
NOT currentDocument.openedAsTool);
{$IFC LibraryVersion <= 20}
uPrFmt, uPrint:
CanDoStdCommand := onDesktop AND (SELF.dialogBox = NIL) AND couldPrint;
{$ELSEC}
uPrFmt, uPrint, uPrintAsIs:
CanDoStdCommand := onDesktop AND (SELF.dialogBox = NIL) AND couldPrint;

Apple Lisa ToolKit 3.0 Source Code Listing -- 224 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

{$ENDC}
uPrMonitor:
CanDoStdCommand := onDesktop AND (SELF.dialogBox = NIL);

{**temporary**}

{Edit}
uUndoLast:
IF SELF.lastCmd = NIL THEN
CanDoStdCommand := FALSE
ELSE
CanDoStdCommand := SELF.lastCmd.undoable;
{Page Layout}
uPrvwMargins, uPrvwBreaks,
IF couldPrint THEN
BEGIN
CanDoStdCommand :=
CASE cmdNumber OF
uPrvwMargins:
checkIt :=
uPrvwBreaks:
checkIt :=
uPrvwOff:
checkIt :=
END;
END;

uPrvwOff, uAddColumnStrip, uAddRowStrip:


TRUE;

{or they wouldnt've been in the phrase file}

previewMode = mPrvwMargins;
previewMode = mPrvwBreaks;
previewMode = mPrvwOff;

uDesignPages:
IF couldPrint THEN
BEGIN
CanDoStdCommand := (SELF.dialogBox = NIL);
checkIt := (SELF.dialogBox = panelToUse.view.printManager.layoutDialogBox)
AND (SELF.dialogBox <> NIL);
END;
uSetHorzBreak, uSetVertBreak, uClearBreaks:
CanDoStdCommand := SELF.clickPanel.view.isPrintable;
uShowFullSize, uReduce70Pct, uReduceToFit:
CanDoStdCommand := fExperimenting;

{**temporary**}

uRiseVertically, uRiseHorizontally:
IF couldPrint THEN
BEGIN
CanDoStdCommand := TRUE;
checkIt := panelToUse.view.printManager.pageRiseDirection =

Apple Lisa ToolKit 3.0 Source Code Listing -- 225 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

END
ELSE
CanDoStdCommand := FALSE;

VHSelect(cmdNumber = uRiseHorizontally);

{$IFC fDbgABC}
{Debug}
uReportEvents, uCountHeap, uCheckIndices,
uExperimenting, uDumpGlobals, uDumpPrelude,
uMainScramble, uDocScramble:
BEGIN
CanDoStdCommand := TRUE;
CASE cmdNumber OF
uReportEvents:
checkIt := eventDebug;
uCountHeap:
checkIt := fCountHeap;
uCheckIndices:
checkIt := fCheckIndices;
uExperimenting:
checkIt := fExperimenting;
uMainScramble:
checkIt := THz(mainHeap)^.fScramble;
uDocScramble:
IF currentDocument <> NIL THEN
checkIt := THz(currentDocument.docHeap)^.fScramble
ELSE
CanDoStdCommand := FALSE;
END;
END;
uReptGarbage, uFreeGarbage:
CanDoStdCommand := clipboard.window <> SELF;
{$ENDC}

{Debug}

END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sStartup}
PROCEDURE {TWindow.}ChkPrMismatch;
VAR styleDidChange: BOOLEAN;
prPrfAlias:
TPrPrfAlias;
s:
TListScanner;
panel:
TPanel;

Apple Lisa ToolKit 3.0 Source Code Listing -- 226 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

error:
document:

INTEGER;
TDocManager;

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF currentDocument <> NIL THEN
document := currentDocument
ELSE
document := boundDocument;
IF document = clipboard THEN
prPrfAlias.reserve := clipPrintPref
ELSE
prPrfAlias.reserve := document.dataSegment.preludePtr^.PrintPref;
{$IFC libraryVersion <= 20}
{ P E P S I }
IF FPrArbRqd(prPrfAlias.prPrf) THEN
BEGIN
PrArbDlg(error, prPrfAlias.prPrf, styleDidChange);
{$ELSEC}
{ S P R I N G }
IF NOT fPrPrfValid(prPrfAlias.prPrf) THEN
BEGIN
PrPrfDlg(prPrfAlias.prPrf, styleDidChange, NOT SELF.pgSzOK);
{$ENDC}
IF styleDidChange THEN
SELF.AcceptNewPrintingInfo(document, prPrfAlias.reserve);
END;
{?? Do we need to worry about refreshing the window when needed?}
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCommand}
PROCEDURE {TWindow.}CommitLast;
VAR lastCmd:
TCommand;
lastView:
TView; {+SW+}
selection: TSelection; {+SW+}
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF <> currentWindow THEN
currentWindow.CommitLast
ELSE
BEGIN
lastCmd := SELF.lastCmd;
IF lastCmd <> NIL THEN
BEGIN
IF lastCmd.doing THEN
lastCmd.Commit;
(*****
IF lastCmd.image <> NIL THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 227 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

*****)

BEGIN
lastView := lastCmd.image.view;
selection := lastView.panel.undoSelection.FreedAndReplacedBy(lastView.NoSelection);
END;

lastCmd.Free;
SELF.lastCmd := NIL;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
FUNCTION {TWindow.}CursorFeedback{: TCursorNumber};
VAR s:
TListScanner;
panel:
TPanel;
cursorNumber:
TCursorNumber;
mousePt:
Point;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
PushFocus;
SELF.Focus;
cursorNumber := noCursor;
GetMouse(mousePt);
IF RectHasPt(SELF.innerRect, mousePt) THEN
IF SELF.isResizable AND fGrowHit(mousePt) THEN
cursorNumber := arrowCursor
ELSE
BEGIN
s := SELF.panels.Scanner;
WHILE s.Scan(panel) DO
BEGIN
cursorNumber := panel.CursorAt(mousePt);
IF cursorNumber <> noCursor THEN
s.Done;
END;
IF cursorNumber = noCursor THEN
cursorNumber := arrowCursor;
END;
PopFocus;
CursorFeedback := cursorNumber;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
PROCEDURE {TWindow.}Deactivate; {assumes we are focused on the window already}

Apple Lisa ToolKit 3.0 Source Code Listing -- 228 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
(******************** these lines are needed for the Extra Window feature *)
IF currentWindow <> SELF THEN
BEGIN
GiveControl(event); {This must be last}
{$IFC fTrace}EP;{$ENDC}
EXIT(Deactivate);
END;
(* ********************)
SELF.CommitLast;
IF SELF.dialogBox <> NIL THEN
SELF.dialogBox.Disappear;
activeWindowID := 0; {must precede StashPicture and Refresh so scroll bars are white}
SELF.Refresh([rFrame], hOnToDim); {do first to give user feedback}
SELF.StashPicture(hOfftoDim);
IF (SELF.wmgrId <> ORD(scrapFolder)) AND (event.fromProcess <> myProcessID) THEN
clipboard.Publicize;
focusArea := NIL;
IF NOT inBackground THEN
currentDocument.Deactivate;
GiveControl(event); {This must be last}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sCommand}
PROCEDURE {TWindow.}DoCommand{(cmdNumber: TCmdNumber)};
VAR command: TCommand;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF cmdNumber <> 0 THEN
BEGIN
IF cmdNumber = uUndoLast THEN
SELF.UndoLast
ELSE
BEGIN
command := SELF.selectPanel.selection.NewCommand(cmdNumber);
IF command <> NIL THEN
{NOTE: If NewCommand Frees SELF (this window), it MUST return NIL}
SELF.PerformCommand(command);
END;
process.RememberCommand(cmdNumber);

Apple Lisa ToolKit 3.0 Source Code Listing -- 229 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

END;
menuBar.EndCmd;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sClick}
FUNCTION {TWindow.}DownAt{(mousePt: Point): BOOLEAN};
VAR s:
TListScanner;
panel: TPanel;
b:
BOOLEAN;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
b := FALSE;
IF RectHasPt(SELF.innerRect, mousePt) THEN
BEGIN
IF SELF.isResizable THEN
IF fGrowHit(mousePt) THEN
BEGIN
SELF.DownInSizeBox(mousePt);
b := TRUE;
process.RememberCommand(uResizeWindow);
END;
IF NOT b THEN
BEGIN
b := TRUE;
s := SELF.panels.Scanner;
WHILE s.Scan(panel) DO
IF panel.DownAt(mousePt) THEN
s.Done;
END;
END;
DownAt := b;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sClick}
PROCEDURE {TWindow.}DownEventAt{(mousePt: Point)};
VAR clickNeighborhood: Rect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.Update(TRUE); {In case an alert box was dismissed by the click}
{ given that previous click was at (0,0), clickNeighborhood is a rectangle in which
this click must fall for it to have a chance at being a double click }
SetRect(clickNeighborhood, -9, -6, 9, 6);
{ clickNeighborhood should be a method call;
how much flexibility is needed???? }

Apple Lisa ToolKit 3.0 Source Code Listing -- 230 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

IF ((event.when - clickState.when) < clickDelay) AND


(RectHasPt(clickNeighborhood, Point(FPtMinusPt(event.where, clickState.where)))) THEN
clickState.clickCount := Min(clickState.clickCount + 1, 3)
ELSE
BEGIN
clickState.clickCount := 1;
clickState.fShift := event.shiftKey;
clickState.fOption := event.codeKey;
clickState.fApple := event.appleKey;
END;
clickState.when := event.when;
clickState.where := event.where;
IF SELF.DownAt(mousePt) THEN;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sClick}
PROCEDURE {TWindow.}DownInSizeBox{(mousePt: Point)};
VAR oldRect:
Rect;
fullRect:
Rect;
{includes title tab}
minExtent:
Point;
minBotRight:
Point;
maxBotRight:
Point;
savePort:
GrafPtr;
newBotRight:
Point;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
oldRect := SELF.innerRect;
SELF.GetMinExtent(minExtent, TRUE);
minBotRight := Point(FPtPlusPt(oldRect.topLeft, minExtent));
LocalToGlobal(minBotRight);
LocalToGlobal(mousePt);
LocalToGlobal(oldRect.topLeft);
LocalToGlobal(oldRect.botRight);
maxBotRight := Point(FPtMaxPt(minBotRight, screenBits.bounds.botRight));
fullRect := oldRect;
fullRect.top := fullRect.top - dvSBox; {allow for title tab}
GetPort(savePort);
SetPort(deskPort);
ResizeFeedback(mousePt, minBotRight, maxBotRight, fullRect, dvSBox, dhSBox, dvSBox, newBotRight);
SetPort(savePort);

Apple Lisa ToolKit 3.0 Source Code Listing -- 231 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

SELF.ResizeTo(Point(FPtMinusPt(newBotRight, oldRect.topLeft)));
{$IFC fTrace}EP;{$ENDC}
END;
{$S sFilter} {+SW+}
PROCEDURE {TWindow.}EachActualPart{(PROCEDURE DoToObject(filteredObj: TObject))};
VAR n:
INTEGER;
cmdWindow: TWindow;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{$IFC fDbgABC}
IF SELF = currentWindow.dialogBox THEN
cmdWindow := currentWindow
ELSE
cmdWindow := SELF;
IF cmdWindow.lastCmd = NIL THEN
n := 0
ELSE
n := cmdWindow.lastCmd.cmdNumber;
ABCBreak('A View or Window tried to filter but did not implement EachActualPart: lastCmd =', n);
{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sFilter}
PROCEDURE {TWindow.}EachVirtualPart{(PROCEDURE DoToObject(filteredObj: TObject))};
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.FilterDispatch(NIL, NIL, DoToObject);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sFilter}
PROCEDURE {TWindow.}FilterAndDo{(actualObj: TObject; PROCEDURE DoToObject(filteredObj: TObject))};
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.FilterDispatch(actualObj, NIL, DoToObject);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sFilter}
PROCEDURE {TWindow.}FilterDispatch{(actualObj: TObject; image: TImage;

Apple Lisa ToolKit 3.0 Source Code Listing -- 232 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

PROCEDURE DoToObject(filteredObj: TObject))};


VAR filterCommand: TCommand;
filtering:
BOOLEAN;
cmdWindow:
TWindow;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
cmdWindow := SELF;
IF currentWindow <> NIL THEN
IF SELF = currentWindow.dialogBox THEN
cmdWindow := currentWindow;
filterCommand := cmdWindow.lastCmd;
filtering := FALSE;
IF filterCommand <> NIL THEN
IF filterCommand.doing THEN
IF filterCommand.image <> NIL THEN
filtering := filterCommand.image.SeesSameAs(image);
IF filtering THEN
IF actualObj <> NIL THEN
filterCommand.FilterAndDo(actualObj, DoToObject)
ELSE
filterCommand.EachVirtualPart(DoToObject)
ELSE
IF actualObj <> NIL THEN
DoToObject(actualObj)
ELSE
IF image <> NIL THEN
image.EachActualPart(DoToObject)
ELSE
SELF.EachActualPart(DoToObject);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TWindow.}Focus;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
SetPort(POINTER(SELF.wmgrID));
SetOrigin(0, 0);
ClipRect(thePort^.portRect);
IF useAltVisRgn THEN
focusRgn := altVisRgn
{Instigated by TWindow.StashPicture or TClipboard.Publicize}
ELSE
focusRgn := thePort^.visRgn;
focusArea := SELF;

Apple Lisa ToolKit 3.0 Source Code Listing -- 233 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sStartup}
PROCEDURE {TWindow.}Frame;
VAR growRect: Rect;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF SELF.isResizable THEN
BEGIN
GetGrowRect(growRect);
IF RectIsVisible(growRect) THEN
IF SELF.IsActive THEN
PaintGrow
ELSE
FillRect(growRect, white);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sCldInit}
PROCEDURE {TWindow.}GetPrinterMetrics;
VAR prPrfAlias:
TPrPrfAlias;
prInfo:
TPrInfo;
tkDevice:
INTEGER;
document:
TDocManager;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
IF currentDocument <> NIL THEN
document := currentDocument
ELSE
document := boundDocument;
IF document = clipboard THEN
prPrfAlias.reserve := clipPrintPref
ELSE
prPrfAlias.reserve := document.dataSegment.preludePtr^.printPref;
{$IFC libraryVersion <= 20}
{ P E P S I }
PrMetrics(prPrfAlias.prPrf, prInfo);
{$ELSEC}
{ S P R I N G }
prInfo := prPrfAlias.prPrf.prInfo; {this looks odd, but the prPrf is of type prRec really}
{$ENDC}
WITH SELF.printerMetrics, prInfo DO
BEGIN
printRect := rPrintable;

Apple Lisa ToolKit 3.0 Source Code Listing -- 234 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

paperRect := rPaper;
END;
SELF.printerMetrics.res.h := prInfo.hRes;
SELF.printerMetrics.res.v := prInfo.vRes;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sStartup}
PROCEDURE {TWindow.}GetMinExtent{(VAR minExtent: Point; windowIsResizingIt: BOOLEAN)};
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
SELF.panelTree.GetMinExtent(minExtent, windowIsResizingIt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sRes}
PROCEDURE {TWindow.}GetTitle{(VAR title: S255)};
VAR kludge: Str255;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
GetFldrTitle(POINTER(SELF.wmgrID), kludge);
title := kludge;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TWindow.}Highlight{(highTransit: THighTransit)};
PROCEDURE HilitePanel(obj: TObject);
BEGIN
TPanel(obj).Highlight(TPanel(obj).selection, highTransit);
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.panels.Each(HilitePanel);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sRes}
PROCEDURE {TWindow.}IdleBegin{(centiSeconds: LONGINT)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 235 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

LetOthersRun;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TWindow.}IdleContinue{(centiSeconds: LONGINT)};
BEGIN
{$IFC fTrace}BP(5);{$ENDC}
IF SELF.IsActive THEN
process.TrackCursor;
LetOthersRun;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TWindow.}IdleEnd{(centiSeconds: LONGINT)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
FUNCTION {TWindow.}IsActive{: BOOLEAN};
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
IF activeWindowID = 0 THEN {nothing is active}
IsActive := FALSE
ELSE IF currentWindow = NIL THEN
BEGIN
IsActive := FALSE;
{$IFC fDbgABC}
Writeln(CHR(7), '********************');
Writeln('In TWindow.IsActive, activeWindowID <> 0 AND currentWindow = NIL');
Writeln('activeWindowID=', activeWindowID:1, '
currentWindow=', ORD(currentWindow):1);
Writeln('********************');
{$ENDC}
END
ELSE
IsActive := (SELF.wmgrID = activeWindowID) OR (SELF.wmgrID = ORD(dialogFolder));
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
FUNCTION {TWindow.}IsVisible{: BOOLEAN};

Apple Lisa ToolKit 3.0 Source Code Listing -- 236 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

VAR info:
WindowInfo;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
GetWindInfo(WindowPtr(SELF.wmgrID), info);
IsVisible := info.visible;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sStartup}
PROCEDURE {TWindow.}LoadMenuBar;
VAR i:
INTEGER;
menuID:
INTEGER;
inClipboard:
BOOLEAN;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
inClipboard := activeWindowID = ORD(scrapFolder);
FOR i := 1 TO menuBar.numMenus DO
BEGIN
menuID := wmgrMenus[i].menuID;
IF SELF.WantMenu(menuID, inClipboard) THEN
menuBar.Insert(menuID, 0);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sRes}
PROCEDURE {TWindow.}MenuEventAt{(mousePt: Point)};
VAR cmdNumber: TCmdNumber;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.SetupMenus;
cmdNumber := menuBar.DownAt(mousePt);
IF SELF.selectPanel = NIL THEN
{$IFC fDbgABC} ABCBreak('ObeyTheEvent: selectPanel=NIL', 0) {$ENDC}
ELSE
SELF.DoCommand(cmdNumber);
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC LibraryVersion > 20}
{$S SgABCcld}
PROCEDURE {TWindow.}NameToPrefix(VAR error, offset: INTEGER; VAR name, prefix: TFilePath);

Apple Lisa ToolKit 3.0 Source Code Listing -- 237 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
NameToPrefix(error, offset, WindowPtr(SELF.wmgrID), Pathname(name), Pathname(prefix));
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$ENDC}
{$S sCommand}
FUNCTION {TWindow.}NewCommand{(cmdNumber: TCmdNumber): TCommand};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
NewCommand := currentWindow.NewStdCommand(cmdNumber);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCommand}
FUNCTION {TWindow.}NewStdCommand{(cmdNumber: TCmdNumber): TCommand};
VAR document:
TDocManager;
didStyleChange: BOOLEAN;
{$IFC LibraryVersion <= 20}
prPrf:
TPrPrf;
{$ENDC}
prPrfAlias:
TprPrfAlias;
shouldPrint:
BOOLEAN;
error:
INTEGER;
str:
S255;
permCmd:
BOOLEAN;
{ TRUE iff the command is a permanent one }
command:
TCommand;
s:
TListScanner;
panel:
TPanel;
zoomNum:
Point;
zoomDen:
Point;
selectPanel:
TPanel;
clickPanel:
TPanel;
selection:
TSelection;
vhs:
VHSelect;
andContinue:
BOOLEAN;
excessBytes:
INTEGER;
printManager:
TPrintManager;
panelToUse:
TPanel;
FUNCTION RevertConfirmed: BOOLEAN;
VAR s:
TParamAlert;
ph:
INTEGER;
{$IFC LibraryVersion <= 20}

Apple Lisa ToolKit 3.0 Source Code Listing -- 238 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

{$ELSEC}
{$ENDC}

info:

fs_info;

info:

Q_Info;

osErr:
pPath:
osDT:

INTEGER;
^Pathname;
LONGINT;

BEGIN
RevertConfirmed := FALSE;

IF SELF.changes = 0 THEN
process.Note(phUnchanged)
ELSE
BEGIN
IF document.files.saveExists THEN
BEGIN
pPath := @document.files.volumePrefix;
{$IFC LibraryVersion <= 20}
Lookup(osErr, pPath^, info);
{$ELSEC}
Quick_Lookup(osErr, pPath^, info);
{$ENDC}
IF osErr <= 0 THEN
osDT := info.DTM
ELSE
osDT := -1;
{$IFC LibraryVersion < 13}
DTAlert(osDT, s);
{$ELSEC}
DTAlert(alerts, osDT, s);
{$ENDC}
process.ArgAlert(1, s);
ph := phRevert;
END
ELSE
ph := phRevBlank;
IF process.Caution(ph) THEN
RevertConfirmed := TRUE;
END;

END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
document := currentDocument;
{$IFC fDbgABC}
IF SELF.wmgrID <> document.window.wmgrID THEN
ABCbreak('In TWindow.NewStdCommand: SELF.wmgrID <> document.window.wmgrID; document=',

Apple Lisa ToolKit 3.0 Source Code Listing -- 239 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

ORD(document));
{$ENDC}
selectPanel := SELF.selectPanel;
clickPanel := SELF.clickPanel;
selection := selectPanel.selection;
IF selectPanel.view.isPrintable THEN
panelToUse := selectPanel
ELSE
panelToUse := SELF.panelToPrint;
error := 0;
NewStdCommand := NIL; {the default return value}
permCmd := FALSE; {if set to TRUE, make a permanent command object}
allowAbort := TRUE; {??? should we assume this ???}
CASE cmdNumber OF
{File/Print Menu}
uSetAllAside:
BEGIN
SELF.CommitLast;
DoFilingCmd(cmdClosAll);
permCmd := TRUE;
END;
uSetAside, uSetClipAside:
BEGIN
SELF.CommitLast;
DoFilingCmd(cmdClose);
permCmd := TRUE;
END;
uPutAway, uSaveVersion: {must be the active window to do this}
BEGIN
andContinue := cmdNumber = uSaveVersion;
SELF.CommitLast;
IF andContinue THEN
excessBytes := docExcess
ELSE
excessBytes := 0;
document.ConserveMemory(excessBytes, TRUE {do GC});
IF (document.window.changes <> 0) AND
(document.files.shouldToolSave OR NOT document.openedAsTool) THEN
BEGIN
process.BeginWait(phSaving);
document.SaveVersion(error, document.files.volumePrefix, andContinue);
process.EndWait;
END

Apple Lisa ToolKit 3.0 Source Code Listing -- 240 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

ELSE IF andContinue THEN


process.Note(phUnchanged);
{shouldn't we put up a message on Save & Put Away even if document is unchanged???}
IF (error <= 0) AND NOT andContinue THEN
{*** some cases worse! ***}
BEGIN
TellFiler(error, docClosd, docPutBack, POINTER(activeWindowID));
IF error > 0 THEN
BEGIN
ABCBreak('TellFiler', error);
error := 0;
END;
closedDocument := document;
closedBySuspend := FALSE;
END;
{do something if there was an error}
IF error = erAborted THEN
process.Stop(phTerminated)
ELSE IF error > 0 THEN
process.Stop(phCantSave);
error := 0; {we already put up the alert}
permCmd := TRUE;
END;
uRevertVersion:
IF RevertConfirmed THEN
BEGIN
document.RevertVersion(error, activeWindowID);
{do something if there was an error}
IF error = erAborted THEN
process.Stop(phTerminated)
ELSE IF error > 0 THEN
BEGIN
process.Stop(phCantRevert);
process.Complete(FALSE); {nothing else to do: we unbound out data segments}
END;
error := 0; {we already put up the alert}
permCmd := TRUE; {no need to CommitLast}
END;
{long-standing commented-out code now out}

uPrFmt:
BEGIN
IF document = clipboard THEN
prPrfAlias.reserve := clipPrintPref
ELSE
prPrfAlias.reserve := document.dataSegment.preludePtr^.printPref;
PushFocus;

Apple Lisa ToolKit 3.0 Source Code Listing -- 241 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

{$IFC libraryVersion <= 20}


{ P E P S I }
PrPrfDlg(error, prPrfAlias.prPrf, didStyleChange);
{$ELSEC}
{ S P R I N G }
PrPrfDlg(prPrfAlias.prPrf, didStyleChange, NOT SELF.pgSzOK);
{$ENDC}
PopFocus;
IF didStyleChange THEN
BEGIN
SELF.AcceptNewPrintingInfo(document, prPrfAlias.reserve);
permCmd := TRUE;
END;
END;
uPrint:
SELF.Print(panelToUse, NOT SELF.pgRgOK, FALSE {put up dialog} );
uPrintAsIs:
SELF.Print(panelToUse, TRUE {suppress page range}, TRUE {suppress dialog});
uPrMonitor:
BEGIN
PushFocus;
{$IFC libraryVersion <= 20}
{ P E P S I }
PrBgdDlg(error, TRUE);
{$ELSEC}
{ S P R I N G }
PrBgdDlg;
{$ENDC}
PopFocus;
END;
{Zooming & previewing pages}
{some or all of these must become command objects}
uPrvwMargins:
panelToUse.Preview(mPrvwMargins);
uPrvwBreaks:
panelToUse.Preview(mPrvwBreaks);
uPrvwOff:
panelToUse.Preview(mPrvwOff);
uDesignPages:
BEGIN
printManager := panelToUse.view.printManager;
IF printManager <> NIL THEN
printManager.EnterPageEdit;
END;
uRiseVertically,

Apple Lisa ToolKit 3.0 Source Code Listing -- 242 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

uRiseHorizontally:
BEGIN
IF cmdNumber = uRiseVertically THEN
panelToUse.view.printManager.pageRiseDirection := v
ELSE
panelToUse.view.printManager.pageRiseDirection := h;
IF panelToUse.previewMode = mPrvwMargins THEN
panelToUse.Invalidate;
END;
uAddColumnStrip,
uAddRowStrip:
BEGIN
IF cmdNumber = uAddColumnStrip THEN
vhs := v
ELSE
vhs := h;
panelToUse.currentView.AddStripOfPages(vhs);
END;
uShowFullSize:
BEGIN
SetPt(zoomNum, 1, 1);
selectPanel.SetZoomFactor(zoomNum, zoomNum);
selectPanel.Invalidate;
END;

{++ should this be panelToUse?? ++}

uReduce70Pct:
BEGIN
WITH selectPanel.zoomFactor DO
IF numerator.h = 1 THEN
BEGIN
zoomNum.h := 7;
zoomDen.h := denominator.h * 10;
zoomNum.v := 7;
zoomDen.v := denominator.v * 10;
END
ELSE {numerator not 1, must be 7}
BEGIN
zoomNum.h := 1;
zoomDen.h := denominator.h DIV 5;
zoomNum.v := 1;
zoomDen.v := denominator.v DIV 5;
END;
selectPanel.SetZoomFactor(zoomNum, zoomDen);
selectPanel.Invalidate;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 243 of 1012

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163
001164
001165
001166
001167
001168
001169
001170
001171
001172
001173
001174
001175
001176
001177
001178
001179
001180
001181
001182
001183
001184
001185
001186
001187
001188
001189
001190
001191
001192
001193
001194
001195

uReduceToFit:
{?} {can't do it now--how to express?} ;
uSetHorzBreak:
IF clickPanel.view.isPrintable THEN
BEGIN
clickPanel.view.printManager.SetBreak(h, clickPanel.view.clickLPt.v, FALSE);
clickPanel.currentView.ReDoBreaks;
clickPanel.Invalidate;
END;
uSetVertBreak:
IF clickPanel.view.isPrintable THEN
BEGIN
clickPanel.view.printManager.SetBreak(v, clickPanel.view.clickLPt.h, FALSE);
clickPanel.currentView.ReDoBreaks;
clickPanel.Invalidate; {later, do a more selective inval}
END;
uClearBreaks:
IF clickPanel.view.isPrintable THEN
BEGIN
clickPanel.view.printManager.ClearPageBreaks(FALSE);
clickPanel.currentView.ReDoBreaks;
clickPanel.Invalidate; {later, do a more selective inval}
END;
{$IFC fDbgABC}
{Debug Menu}
uReportEvents:
SELF.ToggleFlag(eventDebug);
uCountHeap:
SELF.ToggleFlag(fCountHeap);
uCheckIndices:
SELF.ToggleFlag(fCheckIndices);
uDumpGlobals:
{dump process variables}
process.DumpGlobals;
uDumpPrelude:
{dump active document's prelude}
document.DumpPrelude;
uExperimenting:
SELF.ToggleFlag(fExperimenting);
uReptGarbage, uFreeGarbage:
IF document <> clipboard THEN
BEGIN
MarkHeap(document.docHeap, ORD(document.dataSegment.preludePtr^.docDirectory));
SweepHeap(document.docHeap, cmdNumber = uReptGarbage);
END;
uMainScramble:

Apple Lisa ToolKit 3.0 Source Code Listing -- 244 of 1012

Apple Lisa Computer Technical Information


001196
001197
001198
001199
001200
001201
001202
001203
001204
001205
001206
001207
001208
001209
001210
001211
001212
001213
001214
001215
001216
001217
001218
001219
001220
001221
001222
001223
001224
001225
001226
001227
001228
001229
001230
001231
001232
001233
001234
001235
001236
001237
001238
001239
001240
001241
001242
001243

THz(mainHeap)^.fScramble := NOT THz(mainHeap)^.fScramble;


uDocScramble:
IF currentDocument <> NIL THEN
THz(currentDocument.docHeap)^.fScramble :=
NOT THz(currentDocument.docHeap)^.fScramble;
{$ENDC}
OTHERWISE
BEGIN
IF menuBar.GetCmdName(cmdNumber, @str) THEN
process.ArgAlert(1, str)
ELSE
BEGIN
{$IFC fDbgABC}
ABCbreak('called new command, but no command in menu', cmdNumber);
{$ENDC}
process.ArgAlert(1, 'Unknown Command');
END;
IF selection.kind = nothingKind THEN
process.Stop(phNoSel)
ELSE
process.Stop(phUnkCmd);
END;
END;
IF permCmd THEN
BEGIN
command := TCommand.CREATE(NIL, SELF.Heap, cmdNumber, NIL, FALSE, revealNone);
WITH command DO
BEGIN
unHiliteBefore[doPhase] := FALSE;
hiliteAfter[doPhase] := FALSE;
END;
NewStdCommand := command;
END;
IF error > 0 THEN
process.Stop(process.Phrase(error));
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sCommand}
PROCEDURE {TWindow.}PerformCommand{(newCommand: TCommand)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 245 of 1012

Apple Lisa Computer Technical Information


001244
001245
001246
001247
001248
001249
001250
001251
001252
001253
001254
001255
001256
001257
001258
001259
001260
001261
001262
001263
001264
001265
001266
001267
001268
001269
001270
001271
001272
001273
001274
001275
001276
001277
001278
001279
001280
001281
001282
001283
001284
001285
001286
001287
001288
001289
001290
001291

IF newCommand <> NIL THEN {this is a command that changes the document}
BEGIN
{commit the previous command}
SELF.CommitLast;
{save the new command & get rid of the old one}
SELF.SaveCommand(newCommand);
{execute the new command}
SELF.PerformLast(doPhase);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sCommand}
PROCEDURE {TWindow.}PerformLast{(cmdPhase: TCmdPhase)}; {+SW+} {LSR: Your version below, commented out}
VAR image:
TImage;
lastCmd:
TCommand;
lastWindow: TWindow;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF <> currentWindow THEN
currentWindow.PerformLast(cmdPhase)
ELSE
BEGIN
lastCmd := SELF.lastCmd;
image := lastCmd.image;
IF image = NIL THEN
lastWindow := SELF
ELSE
lastWindow := image.view.panel.window; {+SW+}
{UnHighlight all selections before performing the command (unless command object says otherwise)}
IF lastCmd.unHiliteBefore[cmdPhase] THEN
currentWindow.selectWindow.Highlight(hOnToOff); {+sw+}
IF cmdPhase <> doPhase THEN
lastWindow.RestoreSelection;{+sw+}
IF lastCmd.revelation <> revealNone THEN
lastWindow.RevealSelection(lastCmd.revelation = revealAll,
NOT lastCmd.unHiliteBefore[cmdPhase]);
lastWindow.selectPanel.selection.PerformCommand(lastCmd, cmdPhase);

{+sw+}

{Save selection in each panel; hilite if necessary}

Apple Lisa ToolKit 3.0 Source Code Listing -- 246 of 1012

Apple Lisa Computer Technical Information


001292
001293
001294
001295
001296
001297
001298
001299
001300
001301
001302
001303
001304
001305
001306
001307
001308
001309
001310
001311
001312
001313
001314
001315
001316
001317
001318
001319
001320
001321
001322
001323
001324
001325
001326
001327
001328
001329
001330
001331
001332
001333
001334
001335
001336
001337
001338
001339

SELF.SaveSelection;
IF NOT deferUpdate THEN
IF lastCmd.HiliteAfter[cmdPhase] THEN
BEGIN
lastWindow.Update(FALSE);{+sw+}
lastWindow.Highlight(hOffToOn);{+sw+}
END
ELSE
lastWindow.Update(TRUE);{+sw+}
END;
{$IFC fTrace}EP;{$ENDC}
END;
(*

PROCEDURE {TWindow.}PerformLast{(cmdPhase: TCmdPhase)};


VAR lastCmd:
TCommand;
PROCEDURE PerformIt;
BEGIN
{UnHighlight all selections before performing the command (unless command object says otherwise)}
IF lastCmd.unHiliteBefore[cmdPhase] THEN
SELF.Highlight(hOnToOff);
IF cmdPhase <> doPhase THEN
SELF.RestoreSelection;
IF lastCmd.revelation <> revealNone THEN
SELF.RevealSelection(lastCmd.revelation = revealAll, NOT lastCmd.unHiliteBefore[cmdPhase]);
lastCmd.doing := cmdPhase <> undoPhase;
lastCmd.Perform(cmdPhase);
{Save selection in each panel; hilite if necessary}
SELF.SaveSelection;
IF lastCmd.HiliteAfter[cmdPhase] THEN
BEGIN
SELF.Update(FALSE);
SELF.Highlight(hOffToOn);
END
ELSE
SELF.Update(TRUE);
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF <> currentWindow THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 247 of 1012

Apple Lisa Computer Technical Information


001340
001341
001342
001343
001344
001345
001346
001347
001348
001349
001350
001351
001352
001353
001354
001355
001356
001357
001358
001359
001360
001361
001362
001363
001364
001365
001366
001367
001368
001369
001370
001371
001372
001373
001374
001375
001376
001377
001378
001379
001380
001381
001382
001383
001384
001385
001386
001387

*)

currentWindow.PerformLast(cmdPhase)
ELSE
BEGIN
lastCmd := SELF.lastCmd;
PerformIt;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TWindow.}PickStdCursor;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SetStdCursor(arrowCursor);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

{$IFC LibraryVersion > 20}


{$S SgABCcld}
PROCEDURE {TWindow.}PrefixToName(VAR error, offset: INTEGER; VAR prefix, name: TFilePath);
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
PrefixToName(error, offset, WindowPtr(SELF.wmgrID), Pathname(prefix), Pathname(name));
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$ENDC}
{$S SgABCpri}
PROCEDURE {TWindow.}Print{(panel: TPanel; nixPgRange: BOOLEAN; nixWholeDialog: BOOLEAN)};
VAR prPrfAlias:
TPrPrfAlias;
indeedPrint:
BOOLEAN;
isNewStyle:
BOOLEAN;
document:
TDocManager;
{$IFC libraryVersion <= 20}
{ P E P S I }
error:
INTEGER;
prIns:
TPrIns;
{$ELSEC}
{ S P R I N G }
prIns:
TPrRec;
prMode:
PrMenuSuppress;
{$ENDC}
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF currentDocument <> NIL THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 248 of 1012

Apple Lisa Computer Technical Information


001388
001389
001390
001391
001392
001393
001394
001395
001396
001397
001398
001399
001400
001401
001402
001403
001404
001405
001406
001407
001408
001409
001410
001411
001412
001413
001414
001415
001416
001417
001418
001419
001420
001421
001422
001423
001424
001425
001426
001427
001428
001429
001430
001431
001432
001433
001434
001435

document := currentDocument
ELSE
document := boundDocument;
IF document = clipboard THEN
prPrfAlias.reserve := clipPrintPref
ELSE
prPrfAlias.reserve := document.dataSegment.preludePtr^.PrintPref;
PushFocus;
{$IFC libraryVersion <= 20}
{ P E P S I }
indeedPrint := FPrInsDlg(error, prPrfAlias.prPrf, prPrfAlias.prIns, isNewStyle);
{$ELSEC}
{ S P R I N G }
IF nixWholeDialog THEN
prMode := ePrDialogSuppress
ELSE
IF nixPgRange THEN
prMode := ePgRangeSuppress
ELSE
prMode := ePrNormal;
{$ENDC}

indeedPrint := FPrInsDlg(prPrfAlias.prPrf, isNewStyle, prMode);


PopFocus;

{$IFC libraryVersion <= 20}


{ P E P S I }
IF error > 0 THEN
process.Stop(phUnknown)
{PrMgr passed on an OS error}
ELSE
{$ENDC}
BEGIN
IF isNewStyle THEN {style changed during print-instance dialog}
SELF.AcceptNewPrinterInfo(document, prPrfAlias.reserve);
IF indeedPrint THEN
BEGIN
amPrinting := TRUE;
PushFocus;
panel.PrintView(prPrfAlias.reserve);
amPrinting := FALSE;
PopFocus;
SELF.Update(TRUE); {clear out white area from RECORDING box}
{$IFC libraryVersion <= 20}
{ P E P S I }
PrBgdDlg(error, FALSE);
{put up background dialog}
{$ENDC} {NB: For Spring, user-interface says we go back to the app, not to the background dialog}
END;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 249 of 1012

Apple Lisa Computer Technical Information


001436
001437
001438
001439
001440
001441
001442
001443
001444
001445
001446
001447
001448
001449
001450
001451
001452
001453
001454
001455
001456
001457
001458
001459
001460
001461
001462
001463
001464
001465
001466
001467
001468
001469
001470
001471
001472
001473
001474
001475
001476
001477
001478
001479
001480
001481
001482
001483

{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

(*

{$S SgABCcld}
PROCEDURE {TWindow.}PutUpDialogBox{(dialogBox: TDialogBox)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.CommitLast;
SELF.dialogBox := dialogBox;
IF dialogBox.selectWindow <> NIL THEN
SELF.selectWindow := dialogBox.selectWindow; *) {+SW+}
dialogBox.Appear;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

{$S sStartup}
PROCEDURE {TWindow.}Refresh{(rActions: TActions; highTransit: THighTransit)};
PROCEDURE RefreshPanel(obj: TObject);
VAR panel: TPanel;
BEGIN
panel := TPanel(obj);
IF RectIsVisible(panel.outerRect) THEN
panel.Refresh(rActions, highTransit);
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF = clipboard.window THEN
highTransit := hNone;
{$IFC fDbgABC}
IF (rBackground IN rActions) AND (highTransit > hOffToOn) THEN
ABCBreak('Refresh: rBackground requested, but highTransit does not start from Off', 0);
{$ENDC}
IF rFrame IN rActions THEN
SELF.Frame;
SELF.panels.Each(RefreshPanel);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sStartup}
PROCEDURE {TWindow.}Resize{(moving: BOOLEAN)};

Apple Lisa ToolKit 3.0 Source Code Listing -- 250 of 1012

Apple Lisa Computer Technical Information


001484
001485
001486
001487
001488
001489
001490
001491
001492
001493
001494
001495
001496
001497
001498
001499
001500
001501
001502
001503
001504
001505
001506
001507
001508
001509
001510
001511
001512
001513
001514
001515
001516
001517
001518
001519
001520
001521
001522
001523
001524
001525
001526
001527
001528
001529
001530
001531

{Make the Tool Kit data structures agree with the window manager's idea of the window size;
also, ensure that bottom right corner of window is on the screen}
VAR oldOuterRect:
Rect;
myGrafPort:
GrafPtr;
newScreenRect:
Rect;
proposedSize:
Point;
minExtent:
Point;
newOuterRect:
Rect;
currentlyVisible:
BOOLEAN;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
PushFocus;
SELF.Focus;
currentlyVisible := SELF.IsVisible;
myGrafPort:= POINTER(SELF.wmgrID);
IF currentlyVisible THEN
BEGIN
{ Find out where the window is on the screen }
newScreenRect := myGrafPort^.portRect;
proposedSize := Point(FDiagRect(newScreenRect));
IF NOT SELF.believeWmgr THEN
WITH SELF DO
BEGIN
maxInnerSize := proposedSize;
believeWmgr := TRUE;
END;
IF moving THEN { Constrain it to the maximum explicitly set by the user }
BEGIN
LocalToGlobal(newScreenRect.topLeft);
{ Propose the window botRight be at the screen botRight }
proposedSize := Point(FPtMinPt(Point(FPtMinusPt(screenBits.bounds.botRight,
newScreenRect.topLeft)),
SELF.maxInnerSize));
END;
END
ELSE
proposedSize := Point(FDiagRect(SELF.innerRect));
{ But be sure it is at least the minimum size }
SELF.GetMinExtent(minExtent, TRUE);
proposedSize := Point(FPtMaxPt(proposedSize, minExtent));
IF NOT moving THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 251 of 1012

Apple Lisa Computer Technical Information


001532
001533
001534
001535
001536
001537
001538
001539
001540
001541
001542
001543
001544
001545
001546
001547
001548
001549
001550
001551
001552
001553
001554
001555
001556
001557
001558
001559
001560
001561
001562
001563
001564
001565
001566
001567
001568
001569
001570
001571
001572
001573
001574
001575
001576
001577
001578
001579

SELF.maxInnerSize := proposedSize;
oldOuterRect := SELF.outerRect;
SetRect(newScreenRect, 0, 0, proposedSize.h, proposedSize.v);
IF currentlyVisible THEN
{ finally set the wmgr window ("folder") size. }
FolderSize(myGrafPort, proposedSize.h, proposedSize.v, FALSE);
{ Reset our idea of window's size }
SELF.SetInnerRect(newScreenRect);
ClipRect(SELF.innerRect);
focusRgn := thePort^.visRgn;
newOuterRect := SELF.outerRect;
IF NOT EqualPt(oldOuterRect.botRight, newOuterRect.botRight) THEN
SELF.panelTree.ResizeOutside(newOuterRect);
PopFocus;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TWindow.}ResizeTo{(newSize: Point)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF NOT EqualPt(Point(FDiagRect(SELF.innerRect)), newSize) THEN
BEGIN
FolderSize(POINTER(SELF.wmgrID), newSize.h, newSize.v, FALSE);
SELF.Resize(FALSE);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

{$S sRes}
PROCEDURE {TWindow.}RestoreSelection;
PROCEDURE RestoreSel(obj: TObject);
BEGIN
TPanel(obj).undoSelection.Restore;
END;

{$}

BEGIN
{$IFC fTrace}BP(7);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 252 of 1012

Apple Lisa Computer Technical Information


001580
001581
001582
001583
001584
001585
001586
001587
001588
001589
001590
001591
001592
001593
001594
001595
001596
001597
001598
001599
001600
001601
001602
001603
001604
001605
001606
001607
001608
001609
001610
001611
001612
001613
001614
001615
001616
001617
001618
001619
001620
001621
001622
001623
001624
001625
001626
001627

SELF.selectPanel := SELF.undoSelPanel;
SELF.clickPanel := SELF.undoClickPanel;
SELF.selectWindow := SELF.undoSelWindow; {+SW+}
SELF.panels.Each(RestoreSel);
IF SELF.dialogBox <> NIL THEN
SELF.dialogBox.RestoreSelection;
{$IFC fTrace}EP;{$ENDC}
END;

{$S sCommand}
PROCEDURE {TWindow.}RevealSelection(asMuchAsPossible, doHilite: BOOLEAN);
PROCEDURE RevlSel(obj: TObject);
BEGIN
TPanel(obj).selection.Reveal(asMuchAsPossible);
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.Update(doHilite);
SELF.panels.Each(RevlSel);
SELF.Update(doHilite);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCommand}
PROCEDURE {TWindow.}SaveCommand{(command: TCommand)};
PROCEDURE SaveUndoSelection(obj: TObject);
VAR panel: TPanel;
sel:
TSelection;
BEGIN
panel := TPanel(obj);
sel := panel.undoSelection.FreedAndReplacedBy(TSelection(panel.selection.Clone(SELF.Heap)));
END;
BEGIN {Called by PerformCommand between NewCommand & PerformLast to establish an undo-point}
{$IFC fTrace}BP(7);{$ENDC}
IF SELF <> currentWindow THEN
currentWindow.SaveCommand(command) {probably this is a dialog box}
ELSE
IF SELF.lastCmd <> NIL THEN
SELF.lastCmd.Become(command)
ELSE
SELF.lastCmd := command;

Apple Lisa ToolKit 3.0 Source Code Listing -- 253 of 1012

Apple Lisa Computer Technical Information


001628
001629
001630
001631
001632
001633
001634
001635
001636
001637
001638
001639
001640
001641
001642
001643
001644
001645
001646
001647
001648
001649
001650
001651
001652
001653
001654
001655
001656
001657
001658
001659
001660
001661
001662
001663
001664
001665
001666
001667
001668
001669
001670
001671
001672
001673
001674
001675

SELF.panels.Each(SaveUndoSelection);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCommand}
PROCEDURE {TWindow.}SaveSelection;
PROCEDURE SaveSel(obj: TObject);
BEGIN
TPanel(obj).selection.Save;
END;

{$}

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.panels.Each(SaveSel);
SELF.undoSelPanel := SELF.selectPanel;
SELF.undoClickPanel := SELF.clickPanel;
SELF.undoSelWindow := SELF.selectWindow; {+SW+}
IF SELF.dialogBox <> NIL THEN
SELF.dialogBox.SaveSelection;
{$IFC fTrace}EP;{$ENDC}
END;

{$S sCommand}
PROCEDURE {TWindow.}SetupMenus;
VAR anS255:
S255;
undoTempl: TCmdNumber;
mapHandle: TMapHandle;
selection: TSelection;
i:
INTEGER;
wmgrCmd:
TWmgrCmd;
checkIt:
BOOLEAN;
mainWindow: TWindow;
BEGIN {NOTE: wmgrMenus[menuIndex] can not be assigned to a local variable because it is passed as a VAR}
{$IFC fTrace}BP(5);{$ENDC}
mainWindow := currentWindow;
{First, change the text of the Set Aside and Undo items.}
mainWindow.GetTitle(anS255); {don't use SELF because we might be a dialog box}
anS255 := CONCAT('"', anS255, '"');
menuBar.BuildCmdName(uSetAside, utSetAside, @anS255);
menuBar.BuildCmdName(uSetClipAside, utSetAside, @anS255);
IF mainWindow.lastCmd = NIL THEN {the mainWindow always has the last command}
menuBar.BuildCmdName(uUndoLast, utUndoLast, NIL)
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 254 of 1012

Apple Lisa Computer Technical Information


001676
001677
001678
001679
001680
001681
001682
001683
001684
001685
001686
001687
001688
001689
001690
001691
001692
001693
001694
001695
001696
001697
001698
001699
001700
001701
001702
001703
001704
001705
001706
001707
001708
001709
001710
001711
001712
001713
001714
001715
001716
001717
001718
001719
001720
001721
001722
001723

BEGIN
IF mainWindow.lastCmd.doing THEN
undoTempl := utUndoLast
ELSE
undoTempl := utRedoLast;
IF menuBar.GetCmdName(mainWindow.lastCmd.cmdNumber, @anS255) THEN
BEGIN
anS255 := CONCAT('"', anS255, '"');
menuBar.BuildCmdName(uUndoLast, undoTempl, @anS255);
END
ELSE
menuBar.BuildCmdName(uUndoLast, undoTempl, NIL);
END;
{Then enable and check the appropriate items}
mapHandle := TMapHandle(menuBar.mapping);
selection := SELF.selectPanel.selection;
FOR i := 1 TO menuBar.numCommands DO
BEGIN
wmgrCmd := mapHandle^^.table[i];
WITH wmgrCmd DO
IF menuBar.isLoaded[menuIndex] THEN
BEGIN
checkIt := FALSE;
(**********
IF selection.CanDoCommand(cmdNumber, checkIt) THEN
EnableItem(wmgrMenus[menuIndex], itemIndex)
ELSE
DisableItem(wmgrMenus[menuIndex], itemIndex);
**********)
{The following line is an optimization for the preceding}
wmgrMenus[menuIndex].enableFlags[itemIndex] :=
selection.CanDoCommand(cmdNumber, checkit);
CheckItem(wmgrMenus[menuIndex], itemIndex, checkIt);
END;

END;
{$IFC fTrace}EP;{$ENDC}
END;

{$S SgABCini}
PROCEDURE {TWindow.}SetWmgrId{(itsWmgrId: TWindowID)};
VAR panelScanner:
TListScanner;
panel:
TPanel;

Apple Lisa ToolKit 3.0 Source Code Listing -- 255 of 1012

Apple Lisa Computer Technical Information


001724
001725
001726
001727
001728
001729
001730
001731
001732
001733
001734
001735
001736
001737
001738
001739
001740
001741
001742
001743
001744
001745
001746
001747
001748
001749
001750
001751
001752
001753
001754
001755
001756
001757
001758
001759
001760
001761
001762
001763
001764
001765
001766
001767
001768
001769
001770
001771

paneScanner:
TListScanner;
pane:
TPane;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.wmgrId := itsWmgrId;
panelScanner := SELF.panels.Scanner;
WHILE panelScanner.Scan(panel) DO
BEGIN
paneScanner := panel.panes.Scanner;
WHILE paneScanner.Scan(pane) DO
pane.port := POINTER(itsWmgrId);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TWindow.}StashPicture{(highTransit: THighTransit)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
RectRgn(altVisRgn, SELF.outerRect);
useAltVisRgn := TRUE;
{Make TPad.Focus use altVisRgn instead of visRgn}
PushFocus;
SELF.Focus;
WMOpenPicture(POINTER(SELF.wmgrID));
SELF.Refresh([rErase, rFrame, rBackground, rDraw], highTransit); {recorded & not displayed}
WMClosePicture;
useAltVisRgn := FALSE;
PopFocus;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TWindow.}TakeDownDialogBox; {+sw+}
VAR dialogBox: TDialogBox;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{Don't CommitLast here, because the Dialog Box may have created a command that can be undone later}
dialogBox := SELF.dialogBox;
IF dialogBox <> NIL THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 256 of 1012

Apple Lisa Computer Technical Information


001772
001773
001774
001775
001776
001777
001778
001779
001780
001781
001782
001783
001784
001785
001786
001787
001788
001789
001790
001791
001792
001793
001794
001795
001796
001797
001798
001799
001800
001801
001802
001803
001804
001805
001806
001807
001808
001809
001810
001811
001812
001813
001814
001815
001816
001817
001818
001819

IF SELF.lastCmd <> NIL THEN


IF SELF.lastCmd.image <> NIL THEN
IF SELF.lastCmd.image.view.panel.window = dialogBox THEN
SELF.CommitLast; {+sw+}
dialogBox.Disappear;
IF dialogBox.freeOnDismissal THEN
SELF.objectToFree := dialogBox; {+SW+}
{will be freed at end of event loop}
SELF.dialogBox := NIL;
SELF.selectWindow := SELF;
END
ELSE
ABCBreak('TakeDownDialogBox, but none up', 0);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$IFC fDbgABC}
{$S SgABCdbg}
PROCEDURE {TWindow.}ToggleFlag{(VAR flag: BOOLEAN)};
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
flag := NOT flag;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$ENDC}
{$S SgABCcld}
PROCEDURE {TWindow.}UndoLast;
VAR lastCmd:
TCommand;
str:
S255;
cmdPhase:
TCmdPhase;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF <> currentWindow THEN
currentWindow.UndoLast
ELSE
BEGIN
lastCmd := SELF.lastCmd;
IF lastCmd = NIL THEN
process.Stop(phNoCommand)
ELSE
IF NOT lastCmd.undoable THEN
BEGIN
IF NOT menuBar.GetCmdName(lastCmd.cmdNumber, @str) THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 257 of 1012

Apple Lisa Computer Technical Information


001820
001821
001822
001823
001824
001825
001826
001827
001828
001829
001830
001831
001832
001833
001834
001835
001836
001837
001838
001839
001840
001841
001842
001843
001844
001845
001846
001847
001848
001849
001850
001851
001852
001853
001854
001855
001856
001857
001858
001859
001860
001861
001862
001863
001864
001865
001866
001867

BEGIN
{$IFC fDbgABC} ABCbreak('TCommand.cmdNumber not in menu', lastCmd.cmdNumber); {$ENDC}
str := 'Last Command';
END;
process.ArgAlert(1, str);
process.Stop(phCantUndo);
END
ELSE
IF lastCmd.doing THEN
SELF.PerformLast(undoPhase)
ELSE
SELF.PerformLast(redoPhase);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sStartup}
PROCEDURE {TWindow.}Update{(doHilite: BOOLEAN)};
VAR pWindow:
WindowPtr;
updateRgn:
RgnHandle;
highTransit:
THighTransit;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
PushFocus;
SELF.Focus;
pWindow := POINTER(SELF.wmgrID);
BeginUpdate(pWindow);
updateRgn := pWindow^.visRgn;
IF NOT EmptyRgn(updateRgn) THEN
BEGIN
IF doHilite THEN
highTransit := highLevel[SELF.isActive]
ELSE
highTransit := hNone;
FillRgn(updateRgn, white);
SELF.Refresh([rFrame, rBackground, rDraw], highTransit);
END;
EndUpdate(pWindow);
PopFocus;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sStartup}
FUNCTION {TWindow.}WantMenu{(menuID: INTEGER; inClipboard: BOOLEAN): BOOLEAN};

Apple Lisa ToolKit 3.0 Source Code Listing -- 258 of 1012

Apple Lisa Computer Technical Information


001868
001869
001870
001871
001872
001873
001874
001875
001876
001877
001878
001879
001880
001881
001882
001883
001884
001885
001886
001887
001888
001889
001890
001891
001892
001893
001894
001895
001896
001897
001898
001899
001900
001901
001902
001903
001904
001905
001906
001907
001908
001909
001910
001911
001912
001913
001914
001915

BEGIN
{$IFC fTrace}BP(3);{$ENDC}
IF inClipboard THEN
WantMenu := menuID = mnuClipFilePrint
ELSE
WantMenu := (menuID < mBuzzword);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCini}
END;
{$S SgABCres}
METHODS OF TDialogBox;
{$S SgABCcld}
FUNCTION {TDialogBox.}CREATE{(object: TObject; heap: THeap; itsResizability: BOOLEAN; itsHeight: INTEGER;
itsKeyResponse, itsMenuResponse,
itsDownInMainWindowResponse: TDiResponse): TDialogBox};
VAR diBxRect: Rect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TDialogBox(TWindow.CREATE(object, heap, ORD(dialogFolder), itsResizability));
WITH SELF DO
BEGIN
keyResponse := itsKeyResponse;
menuResponse := itsMenuResponse;
downInMainWindowResponse := itsDownInMainWindowResponse;
freeOnDismissal := FALSE; {+SW+}
END;
SELF.GetPrinterMetrics; {mostly just so that these won't be total garbage in debug output}
SetRect(diBxRect, 0, 0, screenBits.bounds.right, itsHeight);
SELF.SetInnerRect(diBxRect);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TDialogBox.}Fields{(PROCEDURE Field(nameAndType: S255))};

Apple Lisa ToolKit 3.0 Source Code Listing -- 259 of 1012

Apple Lisa Computer Technical Information


001916
001917
001918
001919
001920
001921
001922
001923
001924
001925
001926
001927
001928
001929
001930
001931
001932
001933
001934
001935
001936
001937
001938
001939
001940
001941
001942
001943
001944
001945
001946
001947
001948
001949
001950
001951
001952
001953
001954
001955
001956
001957
001958
001959
001960
001961
001962
001963

BEGIN
TWindow.Fields(Field);
Field('keyResponse: Byte');
Field('menuResponse: Byte');
Field('downInMainWindowResponse: Byte');
Field('freeOnDismissal: BOOLEAN'); {+SW+}
Field('');
END;
{$S SgABCres}
{$ENDC}
{$S SgABCcld}
PROCEDURE {TDialogBox.}Appear;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
DialogHeight(LengthRect(SELF.innerRect, v), TRUE);
SELF.outerRect.bottom := SELF.outerRect.top; {force Resize to recalculate everything}
SELF.Resize(FALSE);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
PROCEDURE {TDialogBox.}BeDismissed;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
currentWindow.TakeDownDialogBox;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
PROCEDURE {TDialogBox.}Disappear;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
DialogHeight(0, FALSE);
SELF.believeWmgr := FALSE; {the window's innerRect is known to NOT match the size of the dialog box}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
PROCEDURE {TDialogBox.}GetMinExtent{(VAR minExtent: Point; windowIsResizingIt: BOOLEAN)};
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
SUPERSELF.GetMinExtent(minExtent, windowIsResizingIt);
minExtent.h := screenBits.bounds.right;

Apple Lisa ToolKit 3.0 Source Code Listing -- 260 of 1012

Apple Lisa Computer Technical Information


001964
001965
001966
001967
001968
001969
001970
001971
001972
001973
001974
001975
001976
001977
001978
001979
001980
001981
001982
001983
001984
001985
001986
001987
001988
001989
001990
001991
001992
001993
001994
001995
001996
001997
001998
001999
002000
002001
002002
002003
002004
002005
002006
002007
002008
002009
002010
002011

{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
FUNCTION {TDialogBox.}IsVisible{: BOOLEAN};
VAR info:
WindowInfo;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
IF SUPERSELF.IsVisible THEN
IsVisible := currentWindow.dialogBox = SELF
ELSE
IsVisible := FALSE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCini}
END;
{$S SgABCres}
{SUBROUTINES OF TMenuBar}
{$S sRes}
PROCEDURE InAllMenusDo{(iffLoaded: BOOLEAN; theCommand: TCmdNumber;
PROCEDURE doProc(VAR menu: MenuInfo; itemIndex: INTEGER))};
VAR i:
INTEGER;
lowIDX:
INTEGER;
highIDX:
INTEGER;
mapHandle: TMapHandle;
fFound:
BOOLEAN;
BEGIN
fFound := FALSE;
mapHandle := TMapHandle(menuBar.mapping);
lowIDX := 1;
highIDX := menuBar.numCommands;
WHILE NOT fFound AND (lowIdx <= highIdx) DO
BEGIN
i := (lowIDX+highIDX) DIV 2;
{$R-} WITH mapHandle^^.table[i] DO {$IFC fRngABC}{$R+}{$ENDC} { OK to do this because once
we call doProc, we don't refer to this record any more }
IF theCommand = cmdNumber THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 261 of 1012

Apple Lisa Computer Technical Information


002012
002013
002014
002015
002016
002017
002018
002019
002020
002021
002022
002023
002024
002025
002026
002027
002028
002029
002030
002031
002032
002033
002034
002035
002036
002037
002038
002039
002040
002041
002042
002043
002044
002045
002046
002047
002048
002049
002050
002051
002052
002053
002054
002055
002056
002057
002058
002059

END;

fFound := TRUE;
IF menuBar.isLoaded[menuIndex] = iffLoaded THEN
doProc(wmgrMenus[menuIndex], itemIndex);
END
ELSE
IF theCommand > cmdNumber THEN
lowIDX := i+1
ELSE
highIDX := i-1;
END;

{$S sCommand}
FUNCTION CmdFromWmgr(menuId, itemIndex: INTEGER): TCmdNumber;
VAR wmgrCmd:
TWmgrCmd;
cmdNumber: TCmdNumber;
i:
INTEGER;
mapHandle: TMapHandle;
BEGIN {does not need to be very fast}
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
IF itemIndex < 0 THEN
CmdFromWmgr := -itemIndex {this is how we will implement graphical menus}
ELSE
BEGIN
mapHandle := TMapHandle(menuBar.mapping);
FOR i := 1 TO menuBar.numCommands DO
BEGIN
{$R-}
wmgrCmd := mapHandle^^.table[i];
{$IFC fRngABC}{$R+}{$ENDC}
IF wmgrCmd.itemIndex = itemIndex THEN
IF menuBar.isLoaded[wmgrCmd.menuIndex] THEN
IF wmgrMenus[wmgrCmd.menuIndex].menuId = menuId THEN
BEGIN
CmdFromWmgr := wmgrCmd.cmdNumber;
EXIT(CmdFromWmgr);
END;
END;
CmdFromWmgr := 0;
END;
END;
{$S sRes}
FUNCTION FindMenu(menuID: INTEGER): INTEGER;
{ given a menuID (the number in the phrase file) return the menuIndex into

Apple Lisa ToolKit 3.0 Source Code Listing -- 262 of 1012

Apple Lisa Computer Technical Information


002060
002061
002062
002063
002064
002065
002066
002067
002068
002069
002070
002071
002072
002073
002074
002075
002076
002077
002078
002079
002080
002081
002082
002083
002084
002085
002086
002087
002088
002089
002090
002091
002092
002093
002094
002095
002096
002097
002098
002099
002100
002101
002102
002103
002104
002105
002106
002107

our array of menuInfo records }


VAR menuIndex: INTEGER;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
FOR menuIndex := 1 TO menuBar.numMenus DO
IF wmgrMenus[menuIndex].menuID = menuID THEN
BEGIN
FindMenu := menuIndex;
EXIT(FindMenu);
END;
FindMenu := 0;
END;
METHODS OF TMenuBar;
{$S SgABCini}
FUNCTION {TMenuBar.}CREATE{(object: TObject; heap: THeap; itsScanner: TFileScanner): TMenuBar};
VAR menu:
MenuInfo;
numMenus:
INTEGER;
i:
INTEGER;
numBytes:
INTEGER;
mapping:
TArray;
numCommands:
INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TMenuBar(object);
menu.drawProc := @drawTxtMenu;
menu.chooseProc := @chooseTxtItem;
numMenus := itsScanner.ReadNumber(2);
SELF.numMenus := numMenus;
FOR i := 1 TO numMenus DO
BEGIN
menu.menuId := itsScanner.ReadNumber(2);
itsScanner.XferSequential(xRead, @menu.enableFlags, 4);
numBytes := itsScanner.ReadNumber(2);
menu.menuData := POINTER(ORD(HAllocate(POINTER(ORD(heap)), numBytes)));
itsScanner.XferSequential(xRead, @menu.menuData^^, numBytes);
CalcMenuSize(menu);
wmgrMenus[i] := menu;
SELF.isLoaded[i] := FALSE;
END;
mapping := POINTER(ORD(itsScanner.ReadArray(heap, SIZEOF(TWmgrCmd))));

Apple Lisa ToolKit 3.0 Source Code Listing -- 263 of 1012

Apple Lisa Computer Technical Information


002108
002109
002110
002111
002112
002113
002114
002115
002116
002117
002118
002119
002120
002121
002122
002123
002124
002125
002126
002127
002128
002129
002130
002131
002132
002133
002134
002135
002136
002137
002138
002139
002140
002141
002142
002143
002144
002145
002146
002147
002148
002149
002150
002151
002152
002153
002154
002155

SELF.mapping := mapping;
numCommands := mapping.Size;
SELF.numCommands := numCommands;
InitErrorAbort(itsScanner.error);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TMenuBar.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
Field('isLoaded: ARRAY [1..31] OF BOOLEAN');
(* MaxMenus = 31 *)
Field('mapping: TArray');
Field('numMenus: INTEGER');
Field('numCommands: INTEGER');
END;
{$S SgABCres}
{$ENDC}
{$S sRes}
PROCEDURE {TMenuBar.}BuildCmdName{(destCmd, templateCmd: TCmdNumber; param: TPString)};
VAR templ: S255;
xStart: INTEGER;
xEnd:
INTEGER;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
IF SELF.GetCmdName(templateCmd, @templ) THEN
BEGIN
xStart := POS('^', templ);
IF xStart > 0 THEN
BEGIN
DELETE(templ, xStart, 1);
xEnd := POS('^', templ);
IF xEnd > 0 THEN
DELETE(templ, xEnd,1)
ELSE
xEnd := LENGTH(templ) + 1;
IF param <> NIL THEN
BEGIN
DELETE(templ, xStart, xEnd-xStart);
INSERT(param^, templ, xStart);
END;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 264 of 1012

Apple Lisa Computer Technical Information


002156
002157
002158
002159
002160
002161
002162
002163
002164
002165
002166
002167
002168
002169
002170
002171
002172
002173
002174
002175
002176
002177
002178
002179
002180
002181
002182
002183
002184
002185
002186
002187
002188
002189
002190
002191
002192
002193
002194
002195
002196
002197
002198
002199
002200
002201
002202
002203

SELF.PutCmdName(destCmd, @templ);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TMenuBar.}Check{(cmdNumber: TCmdNumber; checked: BOOLEAN)};
Label 1;
PROCEDURE DoCheck(VAR menu: MenuInfo; itemIndex: INTEGER);
BEGIN
CheckItem(menu, itemIndex, checked);
Goto 1;
END;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
InAllMenusDo(TRUE, cmdNumber, DoCheck);
1: {$IFC fTrace}EP;{$ENDC}
END;
{$S sCommand}
FUNCTION {TMenuBar.}CmdKey{(ch: CHAR): TCmdNumber};
VAR menuId, itemIndex: INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
MenuKey(ch, menuId, itemIndex);
if menuId <> 0 THEN
HiLiteMenu(menuId);
CmdKey := CmdFromWmgr(menuId, itemIndex);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TMenuBar.}Delete{(menuID: INTEGER)};
VAR menuIndex: INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
DeleteMenu(menuId);
menuIndex := FindMenu(menuID);
IF menuIndex > 0 THEN
SELF.isLoaded[menuIndex] := FALSE;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 265 of 1012

Apple Lisa Computer Technical Information


002204
002205
002206
002207
002208
002209
002210
002211
002212
002213
002214
002215
002216
002217
002218
002219
002220
002221
002222
002223
002224
002225
002226
002227
002228
002229
002230
002231
002232
002233
002234
002235
002236
002237
002238
002239
002240
002241
002242
002243
002244
002245
002246
002247
002248
002249
002250
002251

{$S sCommand}
FUNCTION {TMenuBar.}DownAt{(mousePt: Point): TCmdNumber};
VAR menuId, itemIndex: INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
process.ChangeCursor(arrowCursor);
MenuSelect(mousePt, menuId, itemIndex);
if menuId <> 0 THEN
HiLiteMenu(menuId);
DownAt := CmdFromWmgr(menuId, itemIndex);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TMenuBar.}Draw;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
DrawMenuBar;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TMenuBar.}Enable{(cmdNumber: TCmdNumber; canBeChosen: BOOLEAN)};
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
IF canBeChosen THEN
InAllMenusDo(TRUE, cmdNumber, EnableItem)
ELSE
InAllMenusDo(TRUE, cmdNumber, DisableItem);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TMenuBar.}EndCmd;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
HiLiteMenu(0);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
FUNCTION {TMenuBar.}GetCmdName{(cmdNumber: TCmdNumber; pName: TPString): BOOLEAN};
Label 1;
PROCEDURE DoGet(VAR menu: MenuInfo; itemIndex: INTEGER);

Apple Lisa ToolKit 3.0 Source Code Listing -- 266 of 1012

Apple Lisa Computer Technical Information


002252
002253
002254
002255
002256
002257
002258
002259
002260
002261
002262
002263
002264
002265
002266
002267
002268
002269
002270
002271
002272
002273
002274
002275
002276
002277
002278
002279
002280
002281
002282
002283
002284
002285
002286
002287
002288
002289
002290
002291
002292
002293
002294
002295
002296
002297
002298
002299

VAR kludge: Str255;


BEGIN
IF pName <> NIL THEN
BEGIN
GetItem(menu, itemIndex, @kludge);
XferLeft(@kludge, POINTER(ORD(pName)), LENGTH(kludge)+1);
END;
Goto 1;
END;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
GetCmdName := TRUE;
InAllMenusDo(TRUE, cmdNumber, DoGet);
InAllMenusDo(FALSE, cmdNumber, DoGet);
GetCmdName := FALSE;
IF pName <> NIL THEN
pName^ := '';
1: {$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TMenuBar.}HighlightMenu(withCmd: TCmdNumber);
LABEL
1;

1:

PROCEDURE DoHighlight(VAR menu: MenuInfo; itemIndex: INTEGER);


BEGIN
HiLiteMenu(menu.menuID);
Goto 1;
END;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
InAllMenusDo(TRUE, withCmd, DoHighlight);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TMenuBar.}Insert{(menuID, beforeId: INTEGER)};
VAR menuIndex: INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
menuIndex := FindMenu(menuID);
IF menuIndex > 0 THEN
BEGIN
InsertMenu(wmgrMenus[menuIndex], beforeId);
SELF.isLoaded[menuIndex] := TRUE;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 267 of 1012

Apple Lisa Computer Technical Information


002300
002301
002302
002303
002304
002305
002306
002307
002308
002309
002310
002311
002312
002313
002314
002315
002316
002317
002318
002319
002320
002321
002322
002323
002324
002325
002326
002327
002328
002329
002330
002331
002332
002333
002334
002335
002336
002337
002338
002339
002340
002341
002342
002343
002344
002345
002346
002347

{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
FUNCTION {TMenuBar.}MenuWithID(menuID: INTEGER): Ptr;
VAR menuIndex: INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
menuIndex := FindMenu(menuID);
IF menuIndex > 0 THEN
MenuWithId := @wmgrMenus[menuIndex]
ELSE
MenuWithID := NIL;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TMenuBar.}PutCmdName{(cmdNumber: TCmdNumber; pName: TPString)};
Label 1;
VAR kludge: Str255;
PROCEDURE DoPut(VAR menu: MenuInfo; itemIndex: INTEGER);
BEGIN
SetItem(menu, itemIndex, @kludge);
Goto 1;
END;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
XferLeft(POINTER(ORD(pName)), @kludge, LENGTH(pName^)+1);
InAllMenusDo(TRUE, cmdNumber, DoPut);
InAllMenusDo(FALSE, cmdNumber, DoPut);
1: {$IFC fTrace}EP;{$ENDC}
END;
(**********
{$S SgABCini}
PROCEDURE {TMenuBar.}SetupGrMenu(menuID: INTEGER; width, height: INTEGER;
newChooseProc, newDrawProc: Ptr);
{if either proc is NIL, don't change the current value;
if either width or height is <= 0, don't change the current value;
when the menu is first read in, it is setup to behave like a standard text menu}
VAR menuIndex: INTEGER
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
menuIndex := FindMenu(menuID);
IF menuIndex > 0 THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 268 of 1012

Apple Lisa Computer Technical Information


002348
002349
002350
002351
002352
002353
002354
002355
002356
002357
002358
002359
002360
002361
002362
002363
002364
002365
002366
002367
002368
002369
002370
002371
002372
002373
002374
002375
002376
002377
002378
002379
002380
002381
002382
002383
002384
002385
002386
002387
002388
002389
002390
002391
002392
002393
002394
002395

WITH wmgrMenus[menuIndex] DO
BEGIN
IF width > 0 THEN
menuWidth := width;
IF height > 0 THEN
menuHeight := height;
IF newChooseProc <> NIL THEN
chooseProc := newChooseProc;
IF newDrawProc <> NIL THEN
drawProc := newDrawProc;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
**********)
{$S sRes}
PROCEDURE {TMenuBar.}Unload;
VAR i: INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
ClearMenuBar;
FOR i := 1 TO SELF.numMenus DO
SELF.isLoaded[i] := FALSE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
END;
{$S SgABCres}
{$IFC LibraryVersion <= 20 AND FALSE} {do it this way in case we need it back for the Pepsi version}
METHODS OF TFont;
{$S SgABCini}
FUNCTION {TFont.}CREATE{(object: TObject; heap: THeap; itsFamily: INTEGER): TFont};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TFont(object);
SELF.family := itsFamily;
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 269 of 1012

Apple Lisa Computer Technical Information


002396
002397
002398
002399
002400
002401
002402
002403
002404
002405
002406
002407
002408
002409
002410
002411
002412
002413
002414
002415
002416
002417

END;
{$S SgABCres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TFont.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
Field('family: INTEGER');
END;
{$S SgABCres}
{$ENDC}
{$S SgABCini}
END;
{$S SgABCres}
{$ENDC}

End of File -- Lines: 2417 Characters: 73342

Apple Lisa ToolKit 3.0 Source Code Listing -- 270 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UABC5.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{INCLUDE FILE UABC5 -- IMPLEMENTATION OF UABC}


{Copyright 1983, 1984, Apple Computer, Inc.}
{TPanel-TBand-TPane-TMarginPad-TBodyPad-TScroller-TScrollBar}
{changed 05/11/84 11:25 In TPanel.MoveSplitBefore, if we are creating a new split check the new band's
ViewLCd after creation; if not the same as what we passed in, invalidate the
new band's innerRect.}

{$S sCldInit}
PROCEDURE InvalDiffRect(r1, r2: Rect); {invalidate r1 - r2}
VAR dummyRect: Rect;
rgn1:
RgnHandle;
rgn2:
RgnHandle;
BEGIN
{$IFC fTrace}BP(5);{$ENDC}
IF EmptyRect(r1) THEN
{nothing to do}
ELSE IF SectRect(r1, r2, dummyRect) THEN
BEGIN
rgn1 := NewRgn;
rgn2 := NewRgn;
RectRgn(rgn1, r1);
RectRgn(rgn2, r2);
DiffRgn(rgn1, rgn2, rgn1);
InvalRgn(rgn1);
DisposeRgn(rgn1);
DisposeRgn(rgn2);
END
ELSE
InvalRect(r1);
{$IFC fTrace}EP;{$ENDC}
END;
METHODS OF TPanel;
{$S SgABCini}

Apple Lisa ToolKit 3.0 Source Code Listing -- 271 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

FUNCTION

{TPanel.}CREATE{(object: TObject; heap: THeap; itsWindow: TWindow;


minHeight, minWidth: INTEGER; itsVAbilities, itsHAbilities: TAbilities)
: TPanel};
VAR hasWinResize:
BOOLEAN;
viewedLRect:
LRect;
panes:
TList;
bandOuterRect: Rect;
vhs:
VHSelect;
scrollBar:
TScrollBar;
scroller:
TScroller;
band:
TBand;
bandList:
TList {OF TBand};
aPane:
TPane;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TPanel(object);
IF aSplit IN itsVAbilities THEN
itsVAbilities := itsVAbilities + [aBar];
IF aSplit IN itsHAbilities THEN
itsHAbilities := itsHAbilities + [aBar];
WITH SELF DO
BEGIN
window := itsWindow;
view := NIL;
currentView := NIL;
selection := NIL;
undoSelection := NIL;
minInnerDiagonal.v := minHeight;
minInnerDiagonal.h := minWidth;
abilities[v] := itsVAbilities;
abilities[h] := itsHAbilities;
previewMode := mPrvwOff;
paginatedView := NIL;
parentBranch := NIL;
resizeBranch := NIL;
scrollBars[v] := NIL; {so GetBorder (called by SetOuterRect below) won't blow up}
scrollBars[h] := NIL; {ditto}
{$H-}
SetPt(tlSideBandSize, -1, -1); {+++ LSR +++}
SetPt(brSideBandSize, -1, -1); {+++ LSR +++}
{$H+}
deletedSplits := NIL;

Apple Lisa ToolKit 3.0 Source Code Listing -- 272 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

END;
SELF.zoomed := FALSE;
WITH SELF.zoomFactor DO
{$H-} BEGIN
SetPt(numerator, 1, 1);
SetPt(denominator, 1, 1);
{$H+} END;
SELF.SetOuterRect(itsWindow.outerRect);
noPad.RectToLRect(SELF.innerRect, viewedLRect);
panes := TList.CREATE(NIL, heap, 1);
SELF.panes := panes;
aPane := SELF.NewPane(heap, SELF.innerRect, viewedLRect);
WITH SELF.lastClick DO
BEGIN
gotPane := TRUE;
clickPane := aPane;
END;
SELF.panes.InsLast(aPane);
bandOuterRect := SELF.innerRect;
InsetRect(bandOuterRect, -1, -1);
FOR vhs := v TO h DO
BEGIN
scrollBar := TScrollBar.CREATE(NIL, heap, vhs, bandOuterRect, aBar IN SELF.abilities[vhs]);
SELF.scrollBars[vhs] := scrollBar;
scroller := scrollBar.firstBox;
band := SELF.NewBand(heap, SELF.innerRect, scroller, vhs);
band.panes.InsLast(SELF.panes.First);
bandList := TList.CREATE(NIL, heap, 1);
bandList.InsLast(band);
SELF.bands[vhs] := bandList;
END;
IF itsWindow.panelTree = NIL THEN {The first panel gets inserted automatically}
BEGIN
itsWindow.panelTree := SELF;
itsWindow.panels.InsLast(SELF);
itsWindow.selectPanel := SELF;
itsWindow.clickPanel := SELF;
SELF.DecideAboutBars(SELF.outerRect);
END;
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 273 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

END;
{$S SgABCres}
{$S SgABCini}
PROCEDURE {TPanel.}Free;
VAR vhs: VHSelect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
Free(SELF.selection);
Free(SELF.undoSelection);
Free(SELF.view);
IF SELF.currentView <> SELF.view THEN
Free(SELF.currentView);
FOR vhs := v TO h DO
BEGIN
SELF.bands[vhs].Free;
SELF.scrollBars[vhs].Free;
END;
SELF.panes.Free;
Free(SELF.deletedSplits);
TArea.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TPanel.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
TArea.Fields(Field);
Field('window: TWindow');
Field('panes: TList');
Field('currentView: TView');
Field('view: TView');
Field('paginatedView: TPaginatedView');
Field('selection: TSelection');
Field('undoSelection: TSelection');
Field('bands: ARRAY [0..1] OF TList');
Field('scrollBars: ARRAY [0..1] OF TScrollBar');
Field('abilities: ARRAY [0..1] OF Byte');
Field('minInnerDiagonal: Point');
Field('resizeBranch: TBranchArea');
Field('zoomed: BOOLEAN');
Field('zoomFactor: RECORD numerator: Point; denominator: Point END');
Field('previewMode: Byte');
Field('');

Apple Lisa ToolKit 3.0 Source Code Listing -- 274 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

Field('lastClick: RECORD gotPane: BOOLEAN; clickPane: TPane; END');


Field('contentRect: Rect');
Field('tlSideBandSize: Point');
Field('brSideBandSize: Point');
Field('deletedSplits: TArray');
Field('');
END;
{$S SgABCres}
{$ENDC}
{$S sRes}
PROCEDURE {TPanel.}AutoScroll{(mousePt: Point)};
VAR vhs:
VHSelect;
mouseCd:
INTEGER;
f:
INTEGER;
deltaLPt:
LPoint;
pane:
TPane;
r:
Rect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.currentView.GetStdScroll(deltaLPt);
FOR vhs := v TO h DO
BEGIN
mouseCd := mousePt.vh[vhs];
IF NOT (aScroll IN SELF.abilities[vhs]) THEN
f := 0
ELSE
IF mouseCd < SELF.contentRect.topLeft.vh[vhs] THEN {+++ LSR +++}
f := -1
ELSE
IF mouseCd > SELF.contentRect.botRight.vh[vhs] THEN {+++ LSR +++}
f := 1
ELSE
f := 0;
deltaLPt.vh[vhs] := f * deltaLPt.vh[vhs];
END;
{Find the pane to scroll; make sure it is not in a side band}
r := SELF.contentRect;
InsetRect(r, 1, 1); {Because the outerRects of a side band's panes overlap the contentRect by 1 pixel;
(ChildWithPt checks the outerRect)}
RectHavePt(r, mousePt);
pane := TPane(SELF.ChildWithPt(mousePt, SELF.panes, mousePt));
pane.ScrollBy(deltaLPt);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 275 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

{$S sRes}
PROCEDURE {TPanel.}BeginSelection;
{+SW+}
VAR thisWindow:
TWindow;
companionWindow:
TWindow;
PROCEDURE DeselPanel(obj: TObject);
BEGIN
TPanel(obj).selection.Deselect;
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.BeSelectPanel(TRUE);
thisWindow := SELF.window;
companionWindow := NIL;
IF thisWindow = currentWindow THEN
companionWindow := thisWindow.dialogBox {+SW+}
ELSE
IF thisWindow = currentWindow.dialogBox THEN
IF currentWindow.dialogBox.downInMainWindowResponse = diGiveToMainWindow THEN
companionWindow := currentWindow;
IF companionWindow <> NIL THEN
BEGIN
PushFocus;
companionWindow.Focus;
companionWindow.panels.Each(DeselPanel);
PopFocus;
END;
thisWindow.panels.Each(DeselPanel);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TPanel.}BeSelectPanel{(inSelectWindow: BOOLEAN)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF inSelectWindow THEN
currentWindow.selectWindow := SELF.window;
SELF.window.selectPanel := SELF;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TPanel.}CleanUpPanes{(deleteList: TList)};
VAR s:
TListScanner;

Apple Lisa ToolKit 3.0 Source Code Listing -- 276 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

pane:
bs:
band:
vhs:

TPane;
TListScanner;
TBand;
VHSelect;

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.lastClick.gotPane THEN
IF deleteList.Pos(0, SELF.lastClick.clickPane) > 0 THEN
WITH SELF.lastClick DO
BEGIN
gotPane := FALSE;
clickPt := clickPane.innerRect.topLeft; {+}
END;
s := deleteList.Scanner;
WHILE s.Scan(pane) DO
BEGIN
SELF.panes.DelObject(pane, FALSE);
FOR vhs := v To h DO
BEGIN
bs := SELF.bands[vhs].Scanner;
WHILE bs.Scan(band) DO
band.panes.DelObject(pane, FALSE);
END;
END;
deleteList.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

{$S sRes}
PROCEDURE {TPanel.}ComputeContentRect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
WITH SELF DO
BEGIN
{$H-}
contentRect.topLeft := Point(FPtPlusPt(innerRect.topLeft, tlSideBandSize));
contentRect.botRight := Point(FPtMinusPt(innerRect.botRight, brSideBandSize));
InsetRect(contentRect, 1, 1);
{$H+}
END;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 277 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

{$S sStartup}
FUNCTION {TPanel.}CursorAt{(mousePt: Point): TCursorNumber};
VAR pane:
TPane;
nearestPt: Point;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
IF NOT RectHasPt(SELF.outerRect, mousePt) THEN
CursorAt := noCursor
ELSE
IF currentDocument = clipboard THEN
CursorAt := arrowCursor
ELSE
IF RectHasPt(SELF.innerRect, mousePt) THEN
BEGIN
pane := TPane(SELF.ChildWithPt(mousePt, SELF.panes, nearestPt));
CursorAt := pane.CursorAt(mousePt);
END
ELSE
CursorAt := arrowCursor;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
PROCEDURE {TPanel.}DecideAboutBars{(newOuterRect: Rect)};
VAR branch:
TBranchArea;
needsBothBars: BOOLEAN;
vhs:
VHSelect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
branch := SELF.FindBranchThatIsResized;
SELF.resizeBranch := branch;
needsBothBars := (branch <> NIL) OR
(EqualPt(newOuterRect.botRight, SELF.window.outerRect.botRight) AND SELF.window.isResizable);
FOR vhs := v TO h DO
SELF.scrollBars[vhs].ChangeVisibility(needsBothBars, zeroRect, SELF.abilities[vhs]);
SELF.SetOuterRect(newOuterRect);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
FUNCTION {TPanel.}Divide{(vhs: VHSelect;
fromEdgeOfPanel: INTEGER; units: TUnitsFromEdge;
whoCanResizeIt: TResizability;
minSize: INTEGER; itsVAbilities, itsHAbilities: TAbilities): TPanel};

Apple Lisa ToolKit 3.0 Source Code Listing -- 278 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

VAR itsMinInnerDiag:
panel:

Point;
TPanel;

{the new panel}

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
itsMinInnerDiag := SELF.minInnerDiagonal;
itsMinInnerDiag.vh[vhs] := minSize;
panel := TPanel.CREATE(NIL, SELF.heap, SELF.window,
itsMinInnerDiag.v, itsMinInnerDiag.h, itsVAbilities, itsHAbilities);
SELF.Insert(panel, vhs, fromEdgeOfPanel, units, whoCanResizeIt);
Divide := panel;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sScroll}
PROCEDURE {TPanel.}DoScrolling{(inArea: TArea; itsPane: TPane;
hOk, vOk: BOOLEAN; VAR deltaLPt: LPoint)};
{positive scrolls towards end, (0,0) means invalidate only;
if inArea is a pane then itsPane=inArea
if inArea is a band then itsPane is any one of the band's panes;
hOk & vOk indicate whether scrolling is allowed in that direction;
deltaLPt is set to amount actually scrolled by;
NOTE: assumes we are focused on something at least as big as inArea. }
VAR viewedLRect:
LRect;
resizing:
BOOLEAN;
scrollableLRect:
LRect;
freedomLRect:
LRect;
deltaPt:
Point;
vhs:
VHSelect;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
resizing := EqualLPt(deltaLPt, zeroLPt);
itsPane.GetScrollLimits(viewedLRect, scrollableLRect);
LRectMinusLRect(scrollableLRect, viewedLRect, freedomLRect);
LRectHaveLPt(freedomLRect, deltaLPt);
IF NOT hOk THEN
deltaLPt.h := 0;
IF NOT vOK THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 279 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

deltaLPt.v := 0;
IF NOT EqualLPt(deltaLPt, zeroLPt) THEN
BEGIN
IF resizing OR NOT IsSmallPt(deltaLPt) THEN
InvalRect(inArea.innerRect)
ELSE
BEGIN
itsPane.LDistToDist(deltaLPt, deltaPt);
ScrollRect(inArea.innerRect, -deltaPt.h, -deltaPt.v, scrollRgn);
InvalRgn(scrollRgn);
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
FUNCTION {TPanel.}DownAt{(mousePt: Point): BOOLEAN};
VAR found:
BOOLEAN;
cantDown:
BOOLEAN;
vhs:
VHSelect;
outerRect:
Rect;
innerRect:
Rect;
insetContent:
Rect;
growRect:
Rect;
window:
TWindow;
dialogBox:
TDialogBox;
icon:
TEnumIcons;
scroller:
TScroller;
pane:
TPane;
viewedLRect:
LRect;
hysteresis:
BOOLEAN;
limitRect:
Rect;
hysterPt:
Point;
origPt:
Point;
diffPt:
Point;
nearestPt:
Point;
aheadEvent:
EventRecord;
destPanel:
TPanel;
destView:
TView;
lPtInView:
LPoint;
received:
BOOLEAN;
mouseInContent: BOOLEAN; {TRUE iff mouse is currently in contentRect}
PROCEDURE EnforceHysteresis;
BEGIN
diffPt := Point(FPtMinusPt(mousePt, origPt));

Apple Lisa ToolKit 3.0 Source Code Listing -- 280 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

SELF.selection.GetHysteresis(hysterPt);
IF (ABS(diffPt.h) < hysterPt.h) AND (ABS(diffPt.v) < hysterPt.v) THEN
mousePt := origPt
ELSE
hysteresis := FALSE;
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
outerRect := SELF.outerRect;
innerRect := SELF.innerRect;
insetContent := SELF.contentRect;
InsetRect(insetContent, 1, 1);
IF NOT RectHasPt(innerRect, mousePt) THEN {+}
BEGIN
found := FALSE;
FOR vhs := v TO h DO
IF NOT found THEN
IF SELF.scrollBars[vhs].DownAt(mousePt, scroller, icon) THEN
BEGIN
SELF.HitScroller(vhs, mousePt, scroller, icon);
found := TRUE;
END;
IF NOT found THEN
BEGIN
SetRect(growRect, innerRect.right + 1, innerRect.bottom + 1,
outerRect.right - 1, outerRect.bottom - 1);
IF RectHasPt(growRect, mousePt) THEN
BEGIN
SELF.DownInSizeBox(mousePt);
found := TRUE;
process.RememberCommand(uResizePanel);
END;
END;
DownAt := found;
END
ELSE
BEGIN
DownAt := TRUE;
IF currentDocument = clipboard THEN
process.Stop(phEditClip)
ELSE
BEGIN
window := SELF.window;
dialogBox := window.dialogBox;
IF dialogBox = NIL THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 281 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

cantDown := FALSE
ELSE
IF dialogBox.downInMainWindowResponse = diDismissDialogBox THEN
BEGIN
dialogBox.BeDismissed;
cantDown := FALSE;
END
ELSE
cantDown := (dialogBox.downInMainWindowResponse = diRefuse);
IF cantDown THEN
process.Stop(phDialogUp)
ELSE
BEGIN
{$IFC fDbgABC}
IF SELF.currentView = NIL THEN
ABCBreak('DownAt with no view set', 0);
{$ENDC}
mouseInContent := RectHasPt(insetContent, mousePt);
pane := TPane(SELF.ChildWithPt(mousePt, SELF.panes, nearestPt));
IF mouseInContent THEN
WITH SELF.lastClick DO
BEGIN
gotPane := TRUE;
clickPane := pane;
END;
process.RememberCommand(uMousePress);
pane.MouseTrack(mPress, mousePt);
IF SELF.selection.canCrossPanels THEN
BEGIN
pane.RectToLRect(window.innerRect, viewedLRect);
WITH pane.origin DO {$H-} {convert to (0,0)-origined view coordinates}
OffsetLRect(viewedLRect, h, v); {$H+}
pane := TPane.CREATE(NIL, SELF.Heap, SELF, window.innerRect, viewedLRect);
PushFocus;
pane.Focus;
SELF.selection.DrawGhost;
PopFocus;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 282 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

{Set up some temporaries for the StillDown loop}


limitRect := SELF.contentRect;
{AutoScroll slop}
InsetRect(limitRect, -9, -6); {*** should be more lenient at edges of screen ***}
origPt := mousePt;
hysteresis := TRUE;
WHILE stillDown do
BEGIN
GetMouse(mousePt);
{use pane.outerRect in line below, because ChildWithPt checks the outerRect}
IF NOT (RectHasPt(pane.outerRect, mousePt) OR SELF.selection.canCrossPanels) THEN
BEGIN
IF mouseInContent THEN {autoscrolling allowed}
BEGIN
IF NOT RectHasPt(limitRect, mousePt) THEN
BEGIN
SELF.AutoScroll(mousePt);
window.Update(TRUE);
END;
RectHavePt(insetContent, mousePt); {force mouse point into contentRect}
END;
(**** Do we want this line? Depend on if you want to allow people to down in side band, move into content
and go back to side band
mouseInContent := RectHasPt(insetContent, mousePt);
****)
pane := TPane(SELF.ChildWithPt(mousePt, SELF.panes, mousePt));
hysteresis := FALSE;
END
ELSE
IF hysteresis THEN
EnforceHysteresis;
pane.MouseTrack(mMove, mousePt);
END;
IF PeekEvent(aheadEvent) THEN
BEGIN
IF aheadEvent.what = buttonUp THEN
BEGIN
mousePt := aheadEvent.where; {otherwise, use last polled point}
{check to see if we've crossed the pane boundary
use pane.outerRect in line below, because ChildWithPt checks the outerRect}
IF NOT (RectHasPt(pane.outerRect, mousePt) OR
SELF.selection.canCrossPanels) THEN
BEGIN
IF mouseInContent THEN {force mouse point into contentRect}
RectHavePt(insetContent, mousePt);

Apple Lisa ToolKit 3.0 Source Code Listing -- 283 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

pane := TPane(SELF.ChildWithPt(mousePt, SELF.panes, mousePt));


hysteresis := FALSE;
END;
RectHavePt(pane.innerRect, mousePt);
END;
IF hysteresis THEN
EnforceHysteresis;
END;
pane.MouseTrack(mRelease, mousePt);
IF SELF.selection.canCrossPanels THEN
BEGIN
pane.Free;
destPanel := TPanel(window.ChildWithPt(mousePt, window.panels, nearestPt));
IF PtInRect(mousePt, destPanel.innerRect) THEN
BEGIN
destView := destPanel.view;
pane := TPane(destPanel.ChildWithPt(mousePt, destPanel.panes, nearestPt));
{Account for origin difference between window and pane}
PushFocus;
LocalToGlobal(mousePt);
pane.Focus;
GlobalToLocal(mousePt);
pane.PtToLpt(mousePt, lPtInView);
received := destView.DoReceive(SELF.selection, lPtInView);
PopFocus;
END
ELSE
received := FALSE;
IF NOT received THEN
SELF.selection.MoveBackToAnchor;
END;
END;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sRes}
PROCEDURE {TPanel.}DownInSizeBox{(mousePt: Point)};
VAR branch:
TBranchArea;
outerRect:
Rect;

Apple Lisa ToolKit 3.0 Source Code Listing -- 284 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

oldTopLeft:
oldBotRight:
vhs:
minPt:
maxPt:
elderFirst:
minExtents:
newBotRight:
newCd:

Point;
Point;
VHSelect;
Point;
Point;
BOOLEAN;
ARRAY [FALSE..TRUE] OF Point;
Point;
INTEGER;

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
branch := SELF.resizeBranch;
IF branch <> NIL THEN
BEGIN
outerRect := branch.outerRect;
oldTopLeft := outerRect.topLeft;
oldBotRight := outerRect.botRight;
vhs := branch.arrangement;

{don't resize in the orthogonal direction}


minPt := oldBotRight;
maxPt := oldBotRight;
{limit resizing in the free direction}
elderFirst := branch.elderFirst;
branch.elderChild.GetMinExtent(minExtents[elderFirst], FALSE);
branch.youngerChild.GetMinExtent(minExtents[NOT elderFirst], FALSE);
minPt.vh[vhs] := oldTopLeft.vh[vhs] + minExtents[TRUE].vh[vhs];
maxPt.vh[vhs] := oldBotRight.vh[vhs] - minExtents[FALSE].vh[vhs];
{let the user specify the new botRight}
ResizeFeedback(mousePt, minPt, maxPt, branch.TopLeftChild.outerRect,
0, dhSBox, dvSBox, newBotRight);
newCd := newBotRight.vh[vhs];
IF newCd <> oldBotRight.vh[vhs] THEN
branch.Redivide(newCd);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
FUNCTION {TPanel.}FindBranchThatIsResized{: TBranchArea};
VAR child:
TArea;
fini:
BOOLEAN;
parent:
TBranchArea;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 285 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

{$IFC fTrace}BP(7);{$ENDC}
{ Find the panel branch of which this is the bottom right corner of the top left child }
child := SELF;
fini := FALSE;
REPEAT
parent := child.parentBranch;
IF parent = NIL THEN
fini := TRUE
ELSE
fini := parent.TopLeftChild = child;
child := parent;
UNTIL fini;
FindBranchThatIsResized := NIL;
IF parent <> NIL THEN
IF userCanResizeIt IN parent.resizability THEN
FindBranchThatIsResized := parent;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TPanel.}Frame;
VAR actively:
BOOLEAN;
growRect:
Rect;
branch:
TBranchArea;
vhs:
VHSelect;
{$IFC LibraryVersion > 20}
icon:
Char;
{$ENDC}
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF NOT RectsNest(SELF.innerRect, focusRgn^^.rgnBBox) THEN
BEGIN
TArea.Frame;
actively := SELF.window.IsActive;
IF SELF.scrollBars[v].isVisible OR SELF.scrollBars[h].isVisible THEN
IF NOT EqualPt(SELF.outerRect.botRight, SELF.window.outerRect.botRight) THEN
BEGIN
{Draw the panel's resize box}
SetRect(growRect, SELF.innerRect.right, SELF.innerRect.bottom,
SELF.outerRect.right, SELF.outerRect.bottom);
FillRect(growRect, white);
IF actively THEN
BEGIN
branch := SELF.resizeBranch;
IF branch <> NIL THEN
{Draw a resize icon in the box}
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 286 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

{$IFC LibraryVersion <= 20}


vhs := branch.arrangement;
InsetRect(growRect, 3, 2);
growRect.botRight.vh[vhs] := growRect.topLeft.vh[vhs] + 1;
PenNormal;
FrameRect(growRect);
{$ELSEC}
TextFont(wmFont);
TextFace([]);
MoveTo(growRect.left, growRect.top);
IF branch.arrangement = v THEN
icon := CHR(33)
ELSE
icon := CHR(34);
DrawChar(icon);
{$ENDC}
END;
END;
END;
FOR vhs := v TO h DO
IF actively THEN
SELF.scrollBars[vhs].Draw
ELSE
SELF.scrollBars[vhs].Erase;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sRes}
PROCEDURE {TPanel.}GetBorder{(VAR border: Rect)};
VAR vhs:
VHSelect;
hasBar: BOOLEAN;
d:
ARRAY[VHSelect] OF INTEGER;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
FOR vhs := v TO h DO
BEGIN
IF SELF.scrollBars[vhs] = NIL THEN
hasBar := FALSE
ELSE
hasBar := SELF.scrollBars[orthogonal[vhs]].isVisible;
IF hasBar THEN
d[vhs] := dptSbox.vh[vhs]
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 287 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

IF SELF.outerRect.botRight.vh[vhs] = SELF.window.outerRect.botRight.vh[vhs] THEN


d[vhs] := 1
ELSE
d[vhs] := 0;
END;
SetRect(border, -1, -1, d[h], d[v]);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TPanel.}GetMinExtent{(VAR minExtent: Point; windowIsResizingIt: BOOLEAN)};
VAR borderRect:
Rect;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
RectMinusRect(SELF.outerRect, SELF.contentRect, borderRect);
minExtent := Point(FPtPlusPt(SELF.minInnerDiagonal, Point(FDiagRect(borderRect))));
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sCldInit}
PROCEDURE {TPanel.}HaveView{(view: TView)};
VAR s:
TListScanner;
pane:
TPane;
selection: TSelection;
saveMode:
TPreviewMode;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
saveMode := SELF.previewMode;
SELF.previewMode := mPrvwOff;
SELF.view := view;
SELF.currentView := view;
s := SELF.panes.Scanner;
WHILE s.Scan(pane) DO
pane.HaveView(view);
view.BeInPanel(SELF);
IF SELF.selection = NIL THEN
BEGIN
selection := view.NoSelection;
SELF.selection := selection;
END
ELSE
SELF.selection.HaveView(view);

Apple Lisa ToolKit 3.0 Source Code Listing -- 288 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

IF SELF.undoSelection = NIL THEN


BEGIN
selection := view.NoSelection;
SELF.undoSelection := selection;
END
ELSE
SELF.undoSelection.HaveView(view);
SELF.Preview(saveMode);
SELF.ResizeInside(SELF.innerRect); {mainly needed to force panes of a new one-panel window to size}
IF view.isPrintable THEN
IF SELF.window.panelToPrint = NIL THEN
SELF.window.panelToPrint := SELF;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sRes}
PROCEDURE {TPanel.}Highlight{(selection: TSelection; highTransit: THighTransit)};
PROCEDURE HiliteOnThePad;
BEGIN
selection.Highlight(highTransit);
END;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
SELF.OnAllPadsDo(HiliteOnThePad);
END;
{$S SgABCres}
{$S sScroll}
PROCEDURE {TPanel.}HitScroller{(vhs: VHSelect; mousePt: Point; scroller: TScroller; icon: TEnumIcons)};
VAR oldThumbPos:
INTEGER;
newThumbPos:
INTEGER;
deltaLStd:
LPoint;
band:
TBand;
newSkwrCd:
INTEGER;
aScroller:
TScroller;
prevScroller:
TScroller;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 289 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

{$IFC fTrace}BP(7);{$ENDC}
band := scroller.band;
CASE icon OF
iSkewer:
BEGIN
scroller.TrackSkewer(mousePt, newSkwrCd, aScroller, prevScroller);
SELF.MoveSplitBefore(scroller, newSkwrCd);
process.RememberCommand(uSplitting);
END;
iThumb:
BEGIN
scroller.TrackThumb(mousePt, oldThumbPos, newThumbPos);
IF oldThumbPos <> newThumbPos THEN
BEGIN
band.ThumbTo(newThumbPos);
scroller.MoveThumb(band.ThumbPos);
END;
process.RememberCommand(uThumbing);
END;
iScrollBack, iScrollFwd, iFlipBack, iFlipFwd:
BEGIN
scroller.FillIcon(icon, TRUE);
SELF.currentView.GetStdScroll(deltaLStd);
SetupMvThumb(POINTER(scroller.sBoxID));
REPEAT
band.ScrollStep(icon, deltaLStd.vh[vhs]);
SELF.window.Update(TRUE);
PenNormal;
MoveThumb(band.ThumbPos);
UNTIL NOT StillDown;
scroller.FillIcon(icon, FALSE);
process.RememberCommand(uScrolling);
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
PROCEDURE {TPanel.}Insert{(panel: TPanel; vhs: VHSelect;
fromEdgeOfPanel: INTEGER; units: TUnitsFromEdge;
whoCanResizeIt: TResizability)};
VAR window:
elderFirst:
myOuterRect:
mySize:
itsOuterRect:

TWindow;
BOOLEAN;
Rect;
INTEGER;
Rect;

{TRUE if fromEdgeOfPanel<0 (new panel below or to right of old)}


{SELF.outerRect}
{Length of SELF beforehand}
{will be panel.outerRect}

Apple Lisa ToolKit 3.0 Source Code Listing -- 290 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

newSize:
cdInWindow:
myFormerParent:
ourNewParent:

INTEGER;
{Proposed length of the new panel (in the vh direction)}
INTEGER;
{the coordinate of myOuterRect that is changing}
TBranchArea;
TBranchArea;

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
window := SELF.window;
window.panels.InsLast(panel);
panel.window := window;
elderFirst := fromEdgeOfPanel < 0;
myOuterRect := SELF.outerRect;
mySize := LengthRect(myOuterRect, vhs);
itsOuterRect := myOuterRect;
newSize := ABS(fromEdgeOfPanel);
IF units = percentFromEdge THEN
{convert to pixelsFromEdge}
newSize := LIntDivInt(LIntMulInt(mySize, newSize), 100);
newSize := Max(1, Min(newSize, myOuterRect.botRight.vh[vhs] - myOuterRect.topLeft.vh[vhs] - 1));
IF elderFirst THEN
newSize := -newSize;
cdInWindow := TRectCoords(myOuterRect)[elderFirst].vh[vhs] + newSize;
TRectCoords(myOuterRect)[elderFirst].vh[vhs] := cdInWindow;
TRectCoords(itsOuterRect)[NOT elderFirst].vh[vhs] := cdInWindow;
myFormerParent := SELF.parentBranch;
ourNewParent := TBranchArea.CREATE(NIL, SELF.Heap, vhs, elderFirst, whoCanResizeIt, SELF, panel);
IF myFormerParent = NIL THEN
window.panelTree := ourNewParent
ELSE
myFormerParent.ReplaceChild(SELF, ourNewParent);
panel.SetOuterRect(zeroRect); {since the panel is not on the screen right now,
it shouldn't have any size}
panel.ResizeOutside(itsOuterRect);
SELF.ResizeOutside(myOuterRect);
{Just in case some panel is below its mimimum size, let the window expand if needed}
window.Resize(FALSE);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 291 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

{$S SgABCres}
{$S SgDRWres}
PROCEDURE {TPanel.}Invalidate;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
PushFocus;
SELF.window.Focus;
InvalRect(SELF.innerRect);
PopFocus;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
PROCEDURE {TPanel.}InvalLRect{(lRectInView: LRect)};
PROCEDURE InvalOnThePad;
BEGIN
thePad.InvalLRect(lRectInView);
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.OnAllPadsDo(InvalOnThePad);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
PROCEDURE {TPanel.}MakeBand{(vhs: VHSelect; scroller, prevScroller: TScroller)};
VAR prevBand:
TBand;
band:
TBand;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
prevBand := prevScroller.band;
band := SELF.NewBand(SELF.Heap, zeroRect, scroller, vhs);
band.panes.Become(prevBand.panes.Clone(SELF.Heap));
SELF.bands[vhs].InsAt(SELF.bands[vhs].Pos(0, prevBand) + 1, band);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sSplit}
PROCEDURE {TPanel.}MoveSplitBefore{(scroller: TScroller; newSkwrCd: INTEGER)};
VAR vhs:
VHSelect;

Apple Lisa ToolKit 3.0 Source Code Listing -- 292 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

outsideContent:
hsb:
prevHsb:
prevScroller:
nextScroller:
otherBand:
band:
oldSkwrCd:
newViewLCd:
viewDeltaLCd:
sbRect:
newSkwrPt:
sbList:
limitRect:
r:

BOOLEAN;
THsb;
THsb;
TScroller;
TScroller;
TBand;
TBand;
INTEGER;
LONGINT;
LONGINT;
{-gb}
Rect;
Point;
TSbList;
Rect;
Rect;

PROCEDURE InvalScrollers(firstBand, lastBand: TBand);


VAR firstSbRect:
Rect;
lastSbRect:
Rect;
BEGIN
firstBand.scroller.GetSize(firstSbRect);
lastBand.scroller.GetSize(lastSbRect);
UnionRect(firstSbRect, lastSbRect, firstSbRect);
InvalRect(firstSbRect);
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
vhs := scroller.ScrollDir;
outsideContent := TRUE;
WITH SELF.contentRect DO
IF newSkwrCd <= topLeft.vh[vhs] THEN
newSkwrCd := topLeft.vh[vhs] - 1
ELSE IF newSkwrCd >= botRight.vh[vhs] THEN
newSkwrCd := botRight.vh[vhs] + 1
ELSE
outsideContent := FALSE;
hsb := Pointer(scroller.sBoxID);
prevHsb := HsbPrev(hsb);
IF prevHsb = hsbNil THEN
BEGIN
prevScroller := NIL;
{make scroller refer to the scroller we are going to split}
scroller.GetSize(sbRect);

Apple Lisa ToolKit 3.0 Source Code Listing -- 293 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

newSkwrPt.vh[vhs] := newSkwrCd;
newSkwrPt.vh[orthogonal[vhs]] := sbRect.topLeft.vh[orthogonal[vhs]];
PreSbList(sbList, scroller.scrollBar);
hsb := HsbFromPt(sbList, newSkwrPt);
PostSbList(sbList, scroller.scrollBar);
IF (hsb = hsbNil) {user started to create a new split but changed his mind} OR
outsideContent {new split would be in a side band} THEN
scroller := NIL {user started to create a new split but changed his mind}
ELSE
scroller := TScroller(RefconSb(hsb));
END
ELSE
BEGIN
prevScroller := TScroller(RefconSb(prevHsb));
{don't allow the new position of split to cross another split}
FixRLimits(hsb, limitRect);
WITH limitRect DO
newSkwrCd := Max(topLeft.vh[vhs], Min(botRight.vh[vhs], newSkwrCd));
END;
IF scroller <> NIL THEN
BEGIN
scroller.GetSize(sbRect);
oldSkwrCd := sbRect.topLeft.vh[vhs];
WITH SELF.contentRect DO
IF oldSkwrCd <= topLeft.vh[vhs] THEN
oldSkwrCd := topLeft.vh[vhs] - 1
ELSE IF oldSkwrCd >= botRight.vh[vhs] THEN
oldSkwrCd := botRight.vh[vhs] + 1;
IF newSkwrCd <> oldSkwrCd THEN
BEGIN
band := scroller.band;
viewDeltaLCd := newSkwrCd - oldSkwrCd;
IF SELF.zoomed THEN
{ if zoomed then adjust viewDeltaLCd accordingly }
WITH SELF.zoomFactor DO
{$H-}
viewDeltaCd := LIntOvrInt(LIntMulInt(viewDeltaLCd, denominator.vh[vhs]),
{-gb +++LSR+++} numerator.vh[vhs]);
{$H-}
newViewLCd := band.ViewLCd + viewDeltaLCd;
IF prevScroller = NIL THEN
BEGIN {new band}
IF hsb <> hsbNil THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 294 of 1012

{-gb}
{-gb}
{-gb}

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163
001164
001165
001166
001167
001168
001169
001170
001171
001172
001173
001174
001175
001176
001177
001178
001179
001180
001181
001182
001183
001184
001185
001186
001187
001188
001189
001190
001191
001192
001193
001194
001195

BEGIN
InvalScrollers(band, band);
scroller.SplitAt(newSkwrCd, nextScroller);
SELF.ResizeBand(vhs, band, band.ViewLCd, FALSE);
SELF.MakeBand(vhs, nextScroller, scroller);
otherBand := nextScroller.band;
SELF.ResizeBand(vhs, otherBand, newViewLCd, FALSE);
{must invalidate now (special case)}
IF otherBand.ViewLCd <> newViewLCd THEN {the new band scrolled a bit}
InvalRect(otherBand.innerRect);
Pt2Rect(band.innerRect.botRight, otherBand.innerRect.topLeft, r);
InvalRect(r);
SELF.RepaneOrthogonalBands(vhs);
SELF.RemakePanes;
END;

END
ELSE
BEGIN {resize or delete band}
{If new position of split is outside the contentRect, make it go away}
IF outsideContent THEN
WITH limitRect DO
IF newSkwrCd <= SELF.contentRect.topLeft.vh[vhs] THEN
newSkwrCd := topLeft.vh[vhs]
ELSE
newSkwrCd := botRight.vh[vhs];
scroller.ResplitAt(newSkwrCd, prevScroller);
otherBand := prevScroller.band;
InvalScrollers(otherBand, band);
SELF.ResizeBand(vhs, otherBand, otherBand.ViewLCd, TRUE);
SELF.ResizeBand(vhs, band, newViewLCd, TRUE);
END;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCldInit}
FUNCTION {TPanel.}NewBand{(heap: THeap; myInnerRect: Rect;
scroller: TScroller; vhs: VHSelect): TBand};
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 295 of 1012

Apple Lisa Computer Technical Information


001196
001197
001198
001199
001200
001201
001202
001203
001204
001205
001206
001207
001208
001209
001210
001211
001212
001213
001214
001215
001216
001217
001218
001219
001220
001221
001222
001223
001224
001225
001226
001227
001228
001229
001230
001231
001232
001233
001234
001235
001236
001237
001238
001239
001240
001241
001242
001243

{$IFC fTrace}BP(7);{$ENDC}
NewBand := TBand.CREATE(NIL, heap, SELF, myInnerRect, scroller, vhs);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
FUNCTION {TPanel.}NewStatusView{(object: TObject; itsExtent: LRect): TView};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
NewStatusView := TView.CREATE(object, SELF.Heap, SELF, itsExtent, NIL, zeroLRect,
FALSE, screenRes, TRUE);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sCldInit}
FUNCTION {TPanel.}NewView{(object: TObject; itsExtent: LRect; itsPrintManager: TPrintManager;
itsDfltMargins: LRect; itsFitPerfectlyOnPages: BOOLEAN): TView};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
NewView := TView.CREATE(object, SELF.Heap, SELF, itsExtent, itsPrintManager, itsDfltMargins,
itsFitPerfectlyOnPages, screenRes, TRUE);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sStartup}
FUNCTION {TPanel.}NewPane{(heap: THeap; innerRect: Rect; viewedLRect: LRect): TPane};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
NewPane := TPane.CREATE(NIL, heap, SELF, innerRect, viewedLRect);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
FUNCTION {TPanel.}OKToDrawIn{(lRectInView: LRect): BOOLEAN};
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF NOT SELF.view.OKToDrawIn(lRectInView) THEN
OKToDrawIn := FALSE
ELSE
IF SELF.previewMode = mPrvwBreaks THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 296 of 1012

Apple Lisa Computer Technical Information


001244
001245
001246
001247
001248
001249
001250
001251
001252
001253
001254
001255
001256
001257
001258
001259
001260
001261
001262
001263
001264
001265
001266
001267
001268
001269
001270
001271
001272
001273
001274
001275
001276
001277
001278
001279
001280
001281
001282
001283
001284
001285
001286
001287
001288
001289
001290
001291

OKToDrawIn := FALSE {This will be smarter some day}


ELSE
OKToDrawIn := TRUE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
PROCEDURE {TPanel.}OnAllPadsDo{(PROCEDURE DoOnThePad)};
VAR panes: TList {OF TPane};
pane:
TPane;
PROCEDURE YouDo(obj: TObject);
BEGIN
TPad(obj).Focus;
DoOnThePad;
END;
PROCEDURE YouDoOnPages(obj: TObject);
BEGIN
TPane(obj).Focus;
SELF.paginatedView.DoOnPages(NOT SELF.paginatedView.workingInMargins, DoOnThePad);
{i.e., if we're operating in the margins, do NOT focus on the interior}
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
panes := SELF.panes;
pane := TPane(panes.First);
PushFocus;
IF (panes.Size = 1) AND (SELF.previewMode <> mPrvwMargins) THEN
BEGIN
pane.Focus;
DoOnThePad;
END
ELSE
BEGIN
IF SELF.previewMode = mPrvwMargins THEN
SELF.panes.Each(YouDoOnPages)
ELSE
SELF.panes.Each(YouDo);
END;
PopFocus;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

Apple Lisa ToolKit 3.0 Source Code Listing -- 297 of 1012

Apple Lisa Computer Technical Information


001292
001293
001294
001295
001296
001297
001298
001299
001300
001301
001302
001303
001304
001305
001306
001307
001308
001309
001310
001311
001312
001313
001314
001315
001316
001317
001318
001319
001320
001321
001322
001323
001324
001325
001326
001327
001328
001329
001330
001331
001332
001333
001334
001335
001336
001337
001338
001339

{$S sRes}
FUNCTION {TPanel.}PaneShowing{(anLRect: LRect): TPane};
VAR pane:
TPane;
s:
TListScanner;
viewedLRect:
LRect;
scrollableLRect:
LRect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
PaneShowing := NIL;
s := SELF.panes.Scanner;
WHILE s.Scan(pane) DO
BEGIN
pane.GetScrollLimits(viewedLRect, scrollableLRect);
WITH anLRect DO
BEGIN
LRectHaveLPt(scrollableLRect, topLeft);
LRectHaveLPt(scrollableLRect, botRight);
END;
WITH viewedLRect DO
IF top <= anLRect.bottom THEN
IF bottom >= anLRect.top THEN
IF left <= anLRect.right THEN
IF right >= anLRect.left THEN
BEGIN
s.Done;
PaneShowing := pane;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
FUNCTION {TPanel.}PaneToScroll(VAR anLRect: LRect; hMinToSee, vMinToSee: INTEGER): TPane;
VAR tempLRect:
LRect;
pane:
TPane;
dummyPt:
Point;
BEGIN
{$IFC fTrace}BP(5);{$ENDC}
WITH anLRect DO
BEGIN
tempLRect.top := top + vMinToSee;
tempLRect.bottom := bottom - vMinToSee;
tempLRect.left := left + hMinToSee;

Apple Lisa ToolKit 3.0 Source Code Listing -- 298 of 1012

Apple Lisa Computer Technical Information


001340
001341
001342
001343
001344
001345
001346
001347
001348
001349
001350
001351
001352
001353
001354
001355
001356
001357
001358
001359
001360
001361
001362
001363
001364
001365
001366
001367
001368
001369
001370
001371
001372
001373
001374
001375
001376
001377
001378
001379
001380
001381
001382
001383
001384
001385
001386
001387

tempLRect.right := right - hMinToSee;


END;
pane := SELF.PaneShowing(tempLRect);
IF pane = NIL THEN
BEGIN
pane := SELF.PaneShowing(anLRect);
IF pane = NIL THEN
WITH SELF.lastClick DO
BEGIN
IF NOT gotPane THEN
BEGIN
{$H-}
clickPane := TPane(SELF.ChildWithPt(clickPt, SELF.panes, dummyPt));
{$H+}
gotPane := TRUE;
END;
pane := clickPane;
END;
END
ELSE
pane := NIL; {already showing The Right Stuff}
PaneToScroll := pane;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCldInit}
PROCEDURE {TPanel.}Preview{(newMode: TPreviewMode)};
VAR oldMode:
TPreviewMode;
showMargins:
BOOLEAN;
hideMargins:
BOOLEAN;
noSelection:
TSelection;
paginatedView:
TPaginatedView;
vhs:
VHSelect;
offset:
LPoint;
bs:
TListScanner;
band:
TBand;
firstPane:
TPane;
pagiLPoint:
LPoint;
ps:
TListScanner;
pane:
TPane;
pageEditView:
TView;
unPagLPt:
LPoint;
{and pageLocation out!}

Apple Lisa ToolKit 3.0 Source Code Listing -- 299 of 1012

Apple Lisa Computer Technical Information


001388
001389
001390
001391
001392
001393
001394
001395
001396
001397
001398
001399
001400
001401
001402
001403
001404
001405
001406
001407
001408
001409
001410
001411
001412
001413
001414
001415
001416
001417
001418
001419
001420
001421
001422
001423
001424
001425
001426
001427
001428
001429
001430
001431
001432
001433
001434
001435

PROCEDURE XorBreaksOnThePad;
BEGIN
SELF.view.printManager.DrawBreaks(FALSE);
END;
PROCEDURE ClearSelection;
BEGIN
noSelection := SELF.selection.FreedAndReplacedBy(SELF.view.NoSelection);
END;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
IF SELF.view.isPrintable THEN
{Actually shouldn't be called unless isPrintable}
BEGIN
oldMode := SELF.previewMode;
showMargins := (newMode = mPrvwMargins);
hideMargins := (oldMode = mPrvwMargins);
IF oldMode = newMode THEN
BEGIN
END
ELSE
IF showMargins OR hideMargins
BEGIN

THEN

paginatedView := SELF.paginatedView;
IF showMargins THEN
BEGIN
paginatedView := SELF.view.printManager.NewPaginatedView(NIL);
SELF.currentView := paginatedView;
SELF.paginatedView := paginatedView;
END
ELSE
SELF.currentView := SELF.view; { newMode = show Breaks or show main view }
SELF.previewMode := newMode;
FOR vhs := v TO h DO
BEGIN
offset.vh[orthogonal[vhs]] := 0;
bs := SELF.bands[vhs].Scanner;
WHILE bs.Scan(band) DO
BEGIN
firstPane := TPane(band.panes.First);
IF showMargins THEN
paginatedView.PagifyLPoint(firstPane.viewedLRect.topLeft, pagiLPoint)

Apple Lisa ToolKit 3.0 Source Code Listing -- 300 of 1012

Apple Lisa Computer Technical Information


001436
001437
001438
001439
001440
001441
001442
001443
001444
001445
001446
001447
001448
001449
001450
001451
001452
001453
001454
001455
001456
001457
001458
001459
001460
001461
001462
001463
001464
001465
001466
001467
001468
001469
001470
001471
001472
001473
001474
001475
001476
001477
001478
001479
001480
001481
001482
001483

ELSE
IF hideMargins THEN
paginatedView.DePagifyLPoint(firstPane.viewedLRect.topLeft, pagiLPoint);
offset.vh[vhs] := pagiLPoint.vh[vhs] - firstPane.viewedLRect.topLeft.vh[vhs];
ps := band.panes.Scanner;
WHILE ps.Scan(pane) DO
BEGIN
pane.currentView := SELF.currentView;
pane.OffsetBy(offset);
END;
END;
END;
IF hideMargins THEN
BEGIN
paginatedView.Free;
SELF.paginatedView := NIL;
theMarginPad.view := NIL;
END;
SELF.Rescroll; {Does Invalidate and Moves Thumbs}
END
ELSE
BEGIN
SELF.window.Update(TRUE);
{Update in the old mode, in case regions were invalid}
SELF.previewMode := newMode;
{Set the new mode}
SELF.OnAllPadsDo(XorBreaksOnThePad);
{Xor the page breaks}
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCpri}
PROCEDURE {TPanel.}PrintView{(printPref: TPrReserve)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.view.printManager <> NIL THEN
SELF.view.printManager.Print(printPref);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sStartup}
PROCEDURE {TPanel.}Refresh{(rActions: TActions; highTransit: THighTransit)};

Apple Lisa ToolKit 3.0 Source Code Listing -- 301 of 1012

Apple Lisa Computer Technical Information


001484
001485
001486
001487
001488
001489
001490
001491
001492
001493
001494
001495
001496
001497
001498
001499
001500
001501
001502
001503
001504
001505
001506
001507
001508
001509
001510
001511
001512
001513
001514
001515
001516
001517
001518
001519
001520
001521
001522
001523
001524
001525
001526
001527
001528
001529
001530
001531

PROCEDURE RefreshPane(obj: TObject);


VAR pane: TPane;
BEGIN
pane := TPane(obj);
IF RectIsVisible(pane.outerRect) THEN
pane.Refresh(rActions, highTransit);
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{$IFC fDbgABC}
IF (rBackground IN rActions) AND (highTransit > hOffToOn) THEN
ABCBreak('Refresh: rBackground requested, but highTransit does not start from Off', 0);
{$ENDC}
IF rFrame IN rActions THEN
SELF.Frame;
SELF.panes.Each(RefreshPane);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TPanel.}RemakePanes;
VAR vs, ps: TListScanner;
band: TBand;
pane: TPane;
BEGIN
{assumes they are right in the bands}
{$IFC fTrace}BP(7);{$ENDC}
SELF.panes.DelAll(FALSE);
vs := SELF.bands[v].Scanner;
WHILE vs.Scan(band) DO
BEGIN
ps := band.panes.Scanner;
WHILE ps.Scan(pane) DO
SELF.panes.insLast(pane);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TPanel.}RememberSplit{(vhs: VHSelect; atCd: INTEGER)};
VAR deletedSplits: TArray;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 302 of 1012

Apple Lisa Computer Technical Information


001532
001533
001534
001535
001536
001537
001538
001539
001540
001541
001542
001543
001544
001545
001546
001547
001548
001549
001550
001551
001552
001553
001554
001555
001556
001557
001558
001559
001560
001561
001562
001563
001564
001565
001566
001567
001568
001569
001570
001571
001572
001573
001574
001575
001576
001577
001578
001579

{$IFC fTrace}BP(7);{$ENDC}
deletedSplits := SELF.deletedSplits;
IF deletedSplits <> NIL THEN
BEGIN
{$IFC fDbgABC}
IF deletedSplits.recordBytes <> 2 THEN
ABCbreak('This panel has a deletedSplits array, but its recordBytes <> 2', ORD(SELF));
{$ENDC}
IF vhs = v THEN
atCd := - atCd;
deletedSplits.InsLast(@atCd);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TPanel.}Remove;
VAR itsParent:
TBranchArea;
itsGrandParent: TBranchArea;
itsSibling:
TArea;
itsWindow:
TWindow;
firstPanel:
TPanel;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
itsParent := SELF.parentBranch;
itsWindow := SELF.window;
{$IFC fDbgABC}
IF itsParent = NIL THEN
ABCBreak('You cannot remove the last panel in the window', ORD(SELF));
{$ENDC}
itsGrandParent := itsParent.parentBranch;
itsSibling := itsParent.OtherChild(SELF);
itsSibling.ResizeOutside(itsParent.outerRect);
itsSibling.parentBranch := itsGrandParent;
IF itsGrandParent = NIL THEN
itsWindow.panelTree := itsSibling
ELSE
itsGrandParent.ReplaceChild(itsParent, itsSibling); {also sets my parentBranch to NIL}
SELF.resizeBranch := NIL;

Apple Lisa ToolKit 3.0 Source Code Listing -- 303 of 1012

Apple Lisa Computer Technical Information


001580
001581
001582
001583
001584
001585
001586
001587
001588
001589
001590
001591
001592
001593
001594
001595
001596
001597
001598
001599
001600
001601
001602
001603
001604
001605
001606
001607
001608
001609
001610
001611
001612
001613
001614
001615
001616
001617
001618
001619
001620
001621
001622
001623
001624
001625
001626
001627

firstPanel := TPanel(itsWindow.panels.First);
IF itsWindow.selectPanel = SELF THEN
itsWindow.selectPanel := firstPanel;
IF itsWindow.clickPanel = SELF THEN
itsWindow.clickPanel := firstPanel;
{We do not change undoSelPanel & undoClickPanel because undo may bring them back; so caller beware!}
itsParent.Free;
itsWindow.panels.DelObject(SELF, FALSE);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TPanel.}RepaneOrthogonalBands{(vhs: VHSelect)};
VAR bs, orthoBs, ps: TListScanner;
orthoBands: TList;
band, oBand: TBand;
pane: TPane;
BEGIN
{assumes they are right in the orthogonal band}
{$IFC fTrace}BP(7);{$ENDC}
orthoBands := SELF.bands[orthogonal[vhs]];
orthoBs := orthoBands.Scanner;
while orthoBs.Scan(oBand) do
oBand.panes.DelAll(FALSE);
bs := SELF.bands[vhs].Scanner;
WHILE bs.Scan(band) DO
BEGIN
ps := band.panes.Scanner;
orthoBs := orthoBands.Scanner;
WHILE ps.Scan(pane) AND orthoBs.Scan(oBand) DO
oBand.panes.insLast(pane);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TPanel.}Replace{(panel: TPanel)};
VAR itsParent:
TBranchArea;
itsWindow:
TWindow;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
itsParent := SELF.parentBranch;
itsWindow := SELF.window;

Apple Lisa ToolKit 3.0 Source Code Listing -- 304 of 1012

Apple Lisa Computer Technical Information


001628
001629
001630
001631
001632
001633
001634
001635
001636
001637
001638
001639
001640
001641
001642
001643
001644
001645
001646
001647
001648
001649
001650
001651
001652
001653
001654
001655
001656
001657
001658
001659
001660
001661
001662
001663
001664
001665
001666
001667
001668
001669
001670
001671
001672
001673
001674
001675

itsWindow.panels.DelObject(SELF, FALSE);
itsWindow.panels.InsLast(panel);
IF itsParent = NIL THEN
itsWindow.panelTree := panel
ELSE
itsParent.ReplaceChild(SELF, panel); {also sets my parentBranch to NIL}
SELF.resizeBranch := NIL;
panel.ResizeOutside(SELF.outerRect);
IF itsWindow.selectPanel = SELF THEN
itsWindow.selectPanel := panel;
IF itsWindow.clickPanel = SELF THEN
itsWindow.clickPanel := panel;
{We do not change undoSelPanel & undoClickPanel because undo may bring them back; so caller beware!}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sCldInit}
PROCEDURE {TPanel.}Rescroll;
VAR vhs:
VHSelect;
band:
TBand;
s:
TListScanner;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
InvalRect(SELF.outerRect); {Since the view is changing, no part of the old image is good}
FOR vhs := v TO h DO
BEGIN
s := SELF.bands[vhs].Scanner;
WHILE s.Scan(band) DO
IF band.scroller <> NIL THEN
SetThumb(POINTER(band.scroller.sBoxID), band.ThumbPos);
{since we invalidated everything, just telling the SB library where the
thumb should be is enough}
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TPanel.}ResizeBand{(vhs: VHSelect; band: TBand; newViewLCd: LONGINT;
fInvalidate: BOOLEAN)};

Apple Lisa ToolKit 3.0 Source Code Listing -- 305 of 1012

Apple Lisa Computer Technical Information


001676
001677
001678
001679
001680
001681
001682
001683
001684
001685
001686
001687
001688
001689
001690
001691
001692
001693
001694
001695
001696
001697
001698
001699
001700
001701
001702
001703
001704
001705
001706
001707
001708
001709
001710
001711
001712
001713
001714
001715
001716
001717
001718
001719
001720
001721
001722
001723

VAR scroller:
TScroller;
sbRect:
Rect;
tempRect:
Rect;
toBeDeleted:
TList {OF TPane};
ps:
TListScanner;
pane:
TPane;
oldBandInner:
Rect;
newOuterRect:
Rect;
unchangedRect: Rect;
tempBand:
TBand;
sideBand:
TSideBand;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
scroller := band.scroller;
IF scroller = NIL THEN {band is a side band}
sbRect := band.outerRect
ELSE
BEGIN
scroller.GetSize(sbRect);
WITH sbRect DO {regular bands must lie within the contentRect; the +/- 1 is
because the contentRect corresponds to the innerRect, but
sbRect must be based on the outerRect}
BEGIN
topLeft.vh[vhs] := Max(topLeft.vh[vhs], SELF.contentRect.topLeft.vh[vhs] - 1);
botRight.vh[vhs] := Min(botRight.vh[vhs], SELF.contentRect.botRight.vh[vhs] + 1);
END;
END;
unchangedRect := zeroRect;
IF LengthRect(sbRect, vhs) <= 0 THEN
BEGIN
toBeDeleted := TList.CREATE(NIL, SELF.Heap, band.panes.size);
ps := band.panes.Scanner;
WHILE ps.Scan(pane) DO
toBeDeleted.InsLast(pane);
SELF.bands[vhs].DelObject(band, TRUE);
SELF.CleanUpPanes(toBeDeleted);
END
ELSE
BEGIN
newOuterRect := SELF.innerRect;
InsetRect(newOuterRect, -1, -1);
AlignRect(newOuterRect, sbRect, vhs);
oldBandInner := band.innerRect;
band.SetOuterRect(newOuterRect);
band.ResizePanes(newViewLCd);

Apple Lisa ToolKit 3.0 Source Code Listing -- 306 of 1012

Apple Lisa Computer Technical Information


001724
001725
001726
001727
001728
001729
001730
001731
001732
001733
001734
001735
001736
001737
001738
001739
001740
001741
001742
001743
001744
001745
001746
001747
001748
001749
001750
001751
001752
001753
001754
001755
001756
001757
001758
001759
001760
001761
001762
001763
001764
001765
001766
001767
001768
001769
001770
001771

IF fInvalidate THEN
IF band.ViewLCd = newViewLCd THEN
IF SectRect(oldBandInner, band.innerRect, unchangedRect) THEN;
END;
IF fInvalidate THEN
InvalDiffRect(band.outerRect, unchangedRect);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCldInit}
PROCEDURE {TPanel.}ResizeInside{(newInnerRect: Rect)};
VAR toBeDeleted:
TList {OF TPane};
allBandOuterRect:
Rect;
vhs:
VHSelect;
s:
TListScanner;
nextTopLeft:
INTEGER;
lastBotRight:
INTEGER;
thisBotRight:
INTEGER;
band:
TBand;
ps:
TListScanner;
pane:
TPane;
newBandOuterRect:
Rect;
oldViewLCd:
LONGINT;
firstBand:
TBand;
lastBand:
TBand;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
toBeDeleted := TList.CREATE(NIL, SELF.Heap, 0);
allBandOuterRect := newInnerRect;
InsetRect(allBandOuterRect, -1, -1);
FOR vhs := v TO h DO
BEGIN
firstBand := TBand(SELF.bands[vhs].First);
IF firstBand.scroller = NIL THEN
firstBand := TSideBand(firstBand).CoBand;
lastBand := TBand(SELF.bands[vhs].Last);
IF lastBand.scroller = NIL THEN
lastBand := TSideBand(lastBand).CoBand;
{$H-}
WITH SELF.contentRect DO
BEGIN
nextTopLeft := Max(topLeft.vh[vhs]-1, allBandOuterRect.topLeft.vh[vhs]);
lastBotRight := Min(botRight.vh[vhs]+1, allBandOuterRect.botRight.vh[vhs]);
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 307 of 1012

Apple Lisa Computer Technical Information


001772
001773
001774
001775
001776
001777
001778
001779
001780
001781
001782
001783
001784
001785
001786
001787
001788
001789
001790
001791
001792
001793
001794
001795
001796
001797
001798
001799
001800
001801
001802
001803
001804
001805
001806
001807
001808
001809
001810
001811
001812
001813
001814
001815
001816
001817
001818
001819

{$H+}
s := SELF.bands[vhs].Scanner;
WHILE s.Scan(band) DO
IF band.scroller = NIL THEN {a side band}
BEGIN
IF NOT TSideBand(band).topOrLeft THEN {a bottom/right side band must be moved
into a new position}
BEGIN
SELF.SideBandRect(vhs, FALSE, newBandOuterRect); {.SideBandRect returns an InnerRect}
InsetRect(newBandOuterRect, -1, -1); {outerRect is innerRect outset by 1...}
WITH newBandOuterRect.topLeft DO
vh[vhs] := vh[vhs] + 1;
{... EXCEPT on the top/left}
band.ResizeOutside(newBandOuterRect);
END;

END
ELSE {a regular band}
{Always leave at least one pane}
IF (band <> firstBand) AND (nextTopLeft >= lastBotRight) THEN
BEGIN
ps := band.panes.Scanner;
WHILE ps.Scan(pane) DO
IF toBeDeleted.Pos(0, pane) <= 0 THEN
toBeDeleted.InsLast(pane);
SELF.RememberSplit(vhs, band.outerRect.topLeft.vh[vhs]);
s.Delete(TRUE);
END
ELSE
BEGIN
newBandOuterRect.topLeft.vh[vhs] := nextTopLeft;
IF band = lastBand THEN
thisBotRight := lastBotRight
ELSE
thisBotRight := Min(nextTopLeft + lengthRect(band.outerRect, vhs), lastBotRight);
newBandOuterRect.botRight.vh[vhs] := thisBotRight;
AlignRect(newBandOuterRect, allBandOuterRect, orthogonal[vhs]);
oldViewLCd := band.ViewLCd;
band.ResizeOutside(newBandOuterRect);
IF oldViewLCd <> band.ViewLCd THEN
InvalRect(band.innerRect);
nextTopLeft := newBandOuterRect.botRight.vh[vhs];
END;
END;
SELF.CleanUpPanes(toBeDeleted);
SELF.RestoreSplits; {do this after all the bands have been adjusted}
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 308 of 1012

Apple Lisa Computer Technical Information


001820
001821
001822
001823
001824
001825
001826
001827
001828
001829
001830
001831
001832
001833
001834
001835
001836
001837
001838
001839
001840
001841
001842
001843
001844
001845
001846
001847
001848
001849
001850
001851
001852
001853
001854
001855
001856
001857
001858
001859
001860
001861
001862
001863
001864
001865
001866
001867

{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TPanel.}ResizeOutside{(newOuterRect: Rect)};
VAR oldOuterRect:
Rect;
oldInnerRect:
Rect;
newInnerRect:
Rect;
unchangedRect: Rect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
oldOuterRect := SELF.outerRect;
IF NOT EqualRect(oldOuterRect, newOuterRect) THEN
BEGIN
oldInnerRect := SELF.innerRect;
SELF.DecideAboutBars(newOuterRect);
newInnerRect := SELF.innerRect;
unchangedRect := zeroRect;
IF EqualPt(oldOuterRect.topLeft, newOuterRect.topLeft) THEN
IF SectRect(oldInnerRect, newInnerRect, unchangedRect) THEN;
InvalDiffRect(newOuterRect, unchangedRect);
SELF.ResizeInside(newInnerRect);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sCldInit}
PROCEDURE {TPanel.}RestoreSplits;
VAR deletedSplits: TArray;
contentRect:
Rect;
vhs:
VHSelect;
firstScrollers: ARRAY[VHSelect] OF TScroller;
s:
TArrayScanner;
pInt:
Ptr;
cd:
INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
deletedSplits := SELF.deletedSplits;
IF deletedSplits <> NIL THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 309 of 1012

Apple Lisa Computer Technical Information


001868
001869
001870
001871
001872
001873
001874
001875
001876
001877
001878
001879
001880
001881
001882
001883
001884
001885
001886
001887
001888
001889
001890
001891
001892
001893
001894
001895
001896
001897
001898
001899
001900
001901
001902
001903
001904
001905
001906
001907
001908
001909
001910
001911
001912
001913
001914
001915

{$IFC fDbgABC}
IF deletedSplits.recordBytes <> 2 THEN
ABCbreak('This panel has a deletedSplits array, but its recordBytes <> 2', ORD(SELF));
{$ENDC}
contentRect := SELF.contentRect;
FOR vhs := v TO h DO
firstScrollers[vhs] := SELF.scrollBars[vhs].firstBox;
s := deletedSplits.Scanner;
WHILE s.Scan(pInt) DO
BEGIN
cd := TpInteger(pInt)^;
IF cd < 0 THEN
BEGIN
vhs := v;
cd := - cd;
END
ELSE
vhs := h;
IF (cd > contentRect.topLeft.vh[vhs]) AND
(cd < contentRect.botRight.vh[vhs] - dptSkewer.vh[vhs]) THEN
BEGIN
SELF.MoveSplitBefore(firstScrollers[vhs], cd);
s.Delete;
END;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sRes}
PROCEDURE {TPanel.}RevealLRect(VAR anLRect: LRect; hMinToSee, vMinToSee: INTEGER);
VAR pane:
TPane;
revisedLRect:
LRect;
BEGIN
{$IFC fTrace}BP(5);{$ENDC}
IF SELF.previewMode = mPrvwMargins THEN {need to map coords}
BEGIN
SELF.paginatedView.PagifyLPt(anLRect.topLeft, revisedLRect.topLeft);
SELF.paginatedView.PagifyLPt(anLRect.botRight, revisedLRect.botRight);
END
ELSE
revisedLRect := anLRect;

Apple Lisa ToolKit 3.0 Source Code Listing -- 310 of 1012

Apple Lisa Computer Technical Information


001916
001917
001918
001919
001920
001921
001922
001923
001924
001925
001926
001927
001928
001929
001930
001931
001932
001933
001934
001935
001936
001937
001938
001939
001940
001941
001942
001943
001944
001945
001946
001947
001948
001949
001950
001951
001952
001953
001954
001955
001956
001957
001958
001959
001960
001961
001962
001963

pane := SELF.PaneToScroll(revisedLRect, hMinToSee, vMinToSee);


IF pane <> NIL THEN
pane.ScrollToReveal(revisedLRect, hMinToSee, vMinToSee);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TPanel.}SetInnerRect{(newInnerRect: Rect)};
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SUPERSELF.SetInnerRect(newInnerRect);
SELF.ComputeContentRect;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TPanel.}SetOuterRect{(newOuterRect: Rect)};
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SUPERSELF.SetOuterRect(newOuterRect);
SELF.ComputeContentRect;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
PROCEDURE {TPanel.}SetZoomFactor{(zoomNumerator, zoomDenominator: Point)};
VAR s:
TListScanner;
pane:
TPane;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
Reduce(zoomNumerator.h, zoomDenominator.h); {reduce to lowest terms}
Reduce(zoomNumerator.v, zoomDenominator.v); {reduce to lowest terms}
{$IFC fDbgABC}
IF fExperimenting THEN
WriteLn('New (h) Zoom: ', zoomNumerator.h:1, '/', zoomDenominator.h:1);
{$ENDC}
WITH SELF, zoomFactor DO
BEGIN
numerator := zoomNumerator;
denominator := zoomDenominator;
zoomed := (numerator.h <> denominator.h) OR (numerator.v <> denominator.v);
END;
s := SELF.panes.Scanner;
WHILE s.Scan(pane) DO
pane.SetZoomFactor(zoomNumerator, zoomDenominator);

Apple Lisa ToolKit 3.0 Source Code Listing -- 311 of 1012

Apple Lisa Computer Technical Information


001964
001965
001966
001967
001968
001969
001970
001971
001972
001973
001974
001975
001976
001977
001978
001979
001980
001981
001982
001983
001984
001985
001986
001987
001988
001989
001990
001991
001992
001993
001994
001995
001996
001997
001998
001999
002000
002001
002002
002003
002004
002005
002006
002007
002008
002009
002010
002011

SELF.Rescroll; {Does Invalidate and Moves Thumbs}


{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TPanel.}ShowSideBand{(vhs: VHSelect; topOrLeft: BOOLEAN; size: INTEGER; viewLCd: LONGINT)};
VAR x:
INTEGER;
bandIndex:
INTEGER;
band:
TBand;
contentRect:
Rect;
tempRect:
Rect;
oldSideSize:
INTEGER;
newViewLCd:
LONGINT;
scroller:
TScroller;
s:
TListScanner;
bandVHS:
VHSelect;
bandIsCovered: BOOLEAN;
moveNextSplit: BOOLEAN;
removeCd:
INTEGER;
coBand:
TBand;
BEGIN
{$IFC fTrace}BP(12);{$ENDC}
SELF.SideBandRect(vhs, topOrLeft, tempRect);
oldSideSize := LengthRect(tempRect, vhs);
x := Max(-1, size);
WITH SELF DO
IF topOrLeft THEN
tlSideBandSize.vh[vhs] := x
ELSE
brSideBandSize.vh[vhs] := x;
SELF.ComputeContentRect;
IF size > oldSideSize THEN
BEGIN
SELF.window.Resize(FALSE); {make sure we have enough space for the bigger side band}
{ delete splits that are now covered by the bigger side band }
IF topOrLeft THEN
removeCd := 0
ELSE
removeCd := MAXINT;
moveNextSplit := FALSE;

Apple Lisa ToolKit 3.0 Source Code Listing -- 312 of 1012

Apple Lisa Computer Technical Information


002012
002013
002014
002015
002016
002017
002018
002019
002020
002021
002022
002023
002024
002025
002026
002027
002028
002029
002030
002031
002032
002033
002034
002035
002036
002037
002038
002039
002040
002041
002042
002043
002044
002045
002046
002047
002048
002049
002050
002051
002052
002053
002054
002055
002056
002057
002058
002059

s := SELF.bands[vhs].Scanner;
WHILE s.Scan(band) DO
IF band.scroller <> NIL THEN {not a side band}
BEGIN
bandIsCovered := NOT SectRect(band.innerRect, SELF.contentRect, tempRect);
IF bandIsCovered THEN
s.Delete(FALSE); {delete it from the list before some other method, so our scanner
doesn't get confused; it will still get freed later, though}
IF moveNextSplit OR (bandIsConvered AND NOT topOrLeft) THEN
BEGIN
SELF.RememberSplit(vhs, band.outerRect.topLeft.vh[vhs]);
SELF.MoveSplitBefore(band.scroller, removeCd);
END;

END;

moveNextSplit := bandIsCovered AND topOrLeft;


END;

SELF.SideBandRect(vhs, topOrLeft, tempRect);


{Create/Resize/Delete the sideBand}
IF (oldSideSize = -1) AND (size >= 0) THEN {create}
BEGIN
band := TSideBand.CREATE(NIL, SELF.Heap, SELF, tempRect, vhs, topOrLeft, viewLCd);
coBand := TSideBand(band).Coband;
InvalRect(tempRect);
SELF.RepaneOrthogonalBands(vhs);
SELF.RemakePanes;
{calculate the new viewLCd for the side band's coBand}
newViewLCd := coBand.ViewLCd;
IF topOrLeft THEN
newViewLCd := newViewLCd + size + 1;
END
ELSE IF oldSideSize >= 0 THEN
BEGIN
IF topOrLeft THEN {get the side band to resize into band}
band := TBand(SELF.bands[vhs].First)
ELSE
band := TBand(SELF.bands[vhs].Last);
coband := TSideBand(band).Coband;
band.SetInnerRect(tempRect); {side bands are resized according to their current inner/outerRects}

Apple Lisa ToolKit 3.0 Source Code Listing -- 313 of 1012

Apple Lisa Computer Technical Information


002060
002061
002062
002063
002064
002065
002066
002067
002068
002069
002070
002071
002072
002073
002074
002075
002076
002077
002078
002079
002080
002081
002082
002083
002084
002085
002086
002087
002088
002089
002090
002091
002092
002093
002094
002095
002096
002097
002098
002099
002100
002101
002102
002103
002104
002105
002106
002107

SELF.ResizeBand(vhs, band, band.ViewLCd, TRUE);


{calculate the new viewLCd for the side band's coBand}
newViewLCd := coBand.ViewLCd;
IF topOrLeft THEN
newViewLCd := newViewLCd + size - oldSideSize;
END
ELSE
coBand := NIL;
IF coBand <> NIL THEN
BEGIN
{resize the regular band that is next to the sideBand (coband)}
SELF.ResizeBand(vhs, coBand, newViewLCd, TRUE);
{invalidate the scroller associated with coBand}
coBand.scroller.GetSize(tempRect);
InvalRect(tempRect);
SELF.RestoreSplits;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCcld}
PROCEDURE {TPanel.}SideBandRect{(vhs: VHSelect; topOrLeft: BOOLEAN; VAR bandRect: Rect)};
{gets the innerRect of a side band, given the current contentRect}
VAR contentRect:
Rect;
BEGIN
bandRect := SELF.innerRect;
WITH bandRect DO
IF topOrLeft THEN
botRight.vh[vhs] := topLeft.vh[vhs] + SELF.tlSideBandSize.vh[vhs]
ELSE
topLeft.vh[vhs] := botRight.vh[vhs] - SELF.brSideBandSize.vh[vhs];
END;
{$S SgABCini}
END;
{$S SgABCres}
METHODS OF TBand;

Apple Lisa ToolKit 3.0 Source Code Listing -- 314 of 1012

Apple Lisa Computer Technical Information


002108
002109
002110
002111
002112
002113
002114
002115
002116
002117
002118
002119
002120
002121
002122
002123
002124
002125
002126
002127
002128
002129
002130
002131
002132
002133
002134
002135
002136
002137
002138
002139
002140
002141
002142
002143
002144
002145
002146
002147
002148
002149
002150
002151
002152
002153
002154
002155

{$S sCldInit}
FUNCTION {TBand.}CREATE{(object: TObject; heap: THeap; itsPanel: TPanel; itsInnerRect: Rect;
itsScroller: TScroller; itsDir: VHSelect): TBand};
VAR panes: TList;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TBand(object);
WITH SELF DO
BEGIN
window := itsPanel.window;
panel := itsPanel;
scroller := itsScroller;
scrollDir := itsDir;
parentBranch := NIL;
END;
panes := TList.CREATE(NIL, heap, 1);
SELF.panes := panes;
SELF.SetInnerRect(itsInnerRect);
IF itsScroller <> NIL THEN
itsScroller.band := SELF;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCini}
PROCEDURE {TBand.}Free;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
Free(SELF.scroller);
SELF.panes.FreeObject;
TArea.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TBand.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
TArea.Fields(Field);
Field('window: TWindow');
Field('panes: TList');
Field('panel: TPanel');

Apple Lisa ToolKit 3.0 Source Code Listing -- 315 of 1012

Apple Lisa Computer Technical Information


002156
002157
002158
002159
002160
002161
002162
002163
002164
002165
002166
002167
002168
002169
002170
002171
002172
002173
002174
002175
002176
002177
002178
002179
002180
002181
002182
002183
002184
002185
002186
002187
002188
002189
002190
002191
002192
002193
002194
002195
002196
002197
002198
002199
002200
002201
002202
002203

Field('scroller: TScroller');
Field('scrollDir: Byte');
Field('');
END;
{$S SgABCres}
{$ENDC}
{$S sScroll}
PROCEDURE {TBand.}OffsetPanes{(deltaLPt: LPoint)};
PROCEDURE YouOffset(obj: TObject);
BEGIN
TPane(obj).OffsetBy(deltaLPt);
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.panes.Each(YouOffset);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sCldInit}
PROCEDURE {TBand.}ResizeOutside{(newOuterRect: Rect)};
VAR scroller:
TScroller;
newScrollerSize:
Rect;
unchangedRect:
Rect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF NOT EqualRect(SELF.outerRect, newOuterRect) THEN
BEGIN
unchangedRect := SELF.outerRect;
IF NOT EqualPt(unchangedRect.topLeft, newOuterRect.topLeft) THEN
unchangedRect := zeroRect
ELSE
InsetRect(unchangedRect, 1, 1); {we want unchangedRect to be the old innerRect}
InvalDiffRect(newOuterRect, unchangedRect);
scroller := SELF.scroller;
SELF.SetOuterRect(newOuterRect);
newScrollerSize := SELF.outerRect;
WITH SELF DO
BEGIN
newScrollerSize.botRight.vh[orthogonal[scrollDir]] :=
panel.innerRect.botRight.vh[orthogonal[scrollDir]] + 1;

Apple Lisa ToolKit 3.0 Source Code Listing -- 316 of 1012

Apple Lisa Computer Technical Information


002204
002205
002206
002207
002208
002209
002210
002211
002212
002213
002214
002215
002216
002217
002218
002219
002220
002221
002222
002223
002224
002225
002226
002227
002228
002229
002230
002231
002232
002233
002234
002235
002236
002237
002238
002239
002240
002241
002242
002243
002244
002245
002246
002247
002248
002249
002250
002251

IF innerRect.topLeft.vh[scrollDir] = panel.contentRect.topLeft.vh[scrollDir] THEN


newScrollerSize.topLeft.vh[scrollDir] := panel.innerRect.topLeft.vh[scrollDir] - 1;
IF innerRect.botRight.vh[scrollDir] = panel.contentRect.botRight.vh[scrollDir] THEN
newScrollerSize.botRight.vh[scrollDir] := panel.innerRect.botRight.vh[scrollDir] + 1;
END;
scroller.SetSize(newScrollerSize);
SELF.ResizePanes(SELF.ViewLCd);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sCldInit}
PROCEDURE {TBand.}ResizePanes{(newViewLCd: LONGINT)};
{assumes SELF.innerRect already set}
VAR vhs:
VHSelect;
s:
TListScanner;
pane:
TPane;
viewedLRect:
LRect;
scrollableLRect: LRect;
oldViewLCd:
LONGINT;
deltaLPt:
LPoint;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
vhs := SELF.scrollDir;
s := SELF.panes.Scanner;
WHILE s.Scan(pane) DO
pane.Resize(SELF.innerRect, vhs);
IF SELF.panel.currentView <> NIL THEN
BEGIN
pane := TPane(SELF.panes.First);
pane.GetScrollLimits(viewedLRect, scrollableLRect);
oldViewLCd := SELF.ViewLCd;
newViewLCd := Max(scrollableLRect.topLeft.vh[vhs],
Min(scrollableLRect.botRight.vh[vhs] - LengthLRect(viewedLRect, vhs),
newViewLCd));
deltaLPt.vh[orthogonal[vhs]] := 0;
{$H-} deltaLPt.vh[vhs] := newViewLCd - oldViewLCd; {$H+}
SELF.OffsetPanes(deltaLPt);
SELF.ScrollBy(0);
SetThumb(POINTER(SELF.scroller.sBoxID), SELF.ThumbPos);
{need to set thumb because band changed size}

Apple Lisa ToolKit 3.0 Source Code Listing -- 317 of 1012

Apple Lisa Computer Technical Information


002252
002253
002254
002255
002256
002257
002258
002259
002260
002261
002262
002263
002264
002265
002266
002267
002268
002269
002270
002271
002272
002273
002274
002275
002276
002277
002278
002279
002280
002281
002282
002283
002284
002285
002286
002287
002288
002289
002290
002291
002292
002293
002294
002295
002296
002297
002298
002299

END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sScroll}
PROCEDURE {TBand.}ScrollBy{(deltaLCd: LONGINT)};
{positive scrolls towards end; 0 means resize & don't move thumb}
VAR deltaLPt:
LPoint;
vhs:
VHSelect;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
PushFocus;
SELF.window.Focus;
WITH SELF, deltaLPt DO
BEGIN
vhs := scrollDir;
vh[vhs] := deltaLCd;
vh[orthogonal[vhs]] := 0;
END;
SELF.panel.DoScrolling(SELF, TPane(SELF.panes.First), vhs=h, vhs=v, deltaLPt);
IF NOT EqualLPt(deltaLPt, zeroLPt) THEN
SELF.OffsetPanes(deltaLPt);
IF deltaLCd <> 0 THEN
IF SELF.scroller <> NIL THEN {can this be a side band???}
SELF.scroller.MoveThumb(SELF.ThumbPos);
PopFocus;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sScroll}
PROCEDURE {TBand.}ScrollStep{(icon: TEnumIcons; deltaLStd: LONGINT)};
VAR vhs:
VHSelect;
len:
LONGINT;
deltaLCd:
LONGINT;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
vhs := SELF.scrollDir;
len := LIntDivInt(LengthRect(SELF.innerRect, vhs) * ORD4(SELF.panel.view.res.vh[vhs]),
screenRes.vh[vhs]);

Apple Lisa ToolKit 3.0 Source Code Listing -- 318 of 1012

Apple Lisa Computer Technical Information


002300
002301
002302
002303
002304
002305
002306
002307
002308
002309
002310
002311
002312
002313
002314
002315
002316
002317
002318
002319
002320
002321
002322
002323
002324
002325
002326
002327
002328
002329
002330
002331
002332
002333
002334
002335
002336
002337
002338
002339
002340
002341
002342
002343
002344
002345
002346
002347

CASE icon OF {how far to scroll without regard for overshooting the ends}
iScrollBack:
deltaLCd := -deltaLStd;
iScrollFwd:
deltaLCd := deltaLStd;
iFlipBack:
deltaLCd := Min(deltaLStd - len, -deltaLStd);
iFlipFwd:
deltaLCd := Max(len - deltaLStd, deltaLStd);
END;
SELF.ScrollBy(deltaLCd);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sScroll}
PROCEDURE {TBand.}ScrollTo{(viewLCd: LONGINT)};
VAR pane:
TPane;
deltaLCd:
LONGINT;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
pane := TPane(SELF.panes.First);
deltaLCd := viewLCd - pane.viewedLRect.topLeft.vh[SELF.scrollDir];
SELF.ScrollBy(deltaLCd);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sScroll}
FUNCTION {TBand.}ThumbPos{: INTEGER};
VAR vhs:
VHSelect;
pane:
TPane;
viewedLRect:
LRect;
scrollableLRect:
LRect;
thumbLRange:
LONGINT;
barRange:
INTEGER;
lOffset:
LONGINT;
barPos:
INTEGER;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
vhs := SELF.scrollDir;
pane := TPane(SELF.panes.First);
pane.GetScrollLimits(viewedLRect, scrollableLRect);
thumbLRange := LengthLRect(scrollableLRect, vhs) - LengthLRect(viewedLRect, vhs);
barRange := SELF.scroller.ThumbRange;
IF barRange = 0 THEN
ThumbPos := 0

Apple Lisa ToolKit 3.0 Source Code Listing -- 319 of 1012

Apple Lisa Computer Technical Information


002348
002349
002350
002351
002352
002353
002354
002355
002356
002357
002358
002359
002360
002361
002362
002363
002364
002365
002366
002367
002368
002369
002370
002371
002372
002373
002374
002375
002376
002377
002378
002379
002380
002381
002382
002383
002384
002385
002386
002387
002388
002389
002390
002391
002392
002393
002394
002395

ELSE
BEGIN
lOffset := viewedLRect.topLeft.vh[vhs] - scrollableLRect.topLeft.vh[vhs];
IF thumbLRange > 1 THEN
{Only divide by positive denominators}
barPos := LIntDivLInt(LIntMulInt(lOffset, barRange - 1) + thumbLRange - barRange,
thumbLRange - 1)
ELSE
IF (thumbLRange = 1) AND (lOffset > 0) THEN
{Very rare case: view one pixel bigger
than pane...}
barPos := barRange
{...and scrolled to end}
ELSE
barPos := 0;
{Usually because the view is smaller than the
pane}
{barPos = 0 or barRange only if nowhere to scroll}
ThumbPos := Max(0, Min(1000, LIntDivInt(LIntMulInt(barPos, 1000) + barRange - 1, barRange)));
{ThumbPos = 0 or 1000 only if nowhere to scroll [assumes band is <= 1000 pixels long]}
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sScroll}
PROCEDURE {TBand.}ThumbTo{(newThumbPos: INTEGER)};
VAR vhs:
VHSelect;
thumbLRange:
LONGINT;
pane:
TPane;
viewedLRect:
LRect;
scrollableLRect:
LRect;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
vhs := SELF.scrollDir;
pane := TPane(SELF.panes.First);
pane.GetScrollLimits(viewedLRect, scrollableLRect);
thumbLRange := LengthLRect(scrollableLRect, vhs) - LengthLRect(viewedLRect, vhs);
SELF.ScrollTo(scrollableLRect.topLeft.vh[vhs] +
LIntDivInt(LIntMulInt(thumbLRange, newThumbPos), 1000));
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
FUNCTION {TBand.}ViewLCd{: LONGINT};
VAR pane:
TPane;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
pane := TPane(SELF.panes.First);

Apple Lisa ToolKit 3.0 Source Code Listing -- 320 of 1012

Apple Lisa Computer Technical Information


002396
002397
002398
002399
002400
002401
002402
002403
002404
002405
002406
002407
002408
002409
002410
002411
002412
002413
002414
002415
002416
002417
002418
002419
002420
002421
002422
002423
002424
002425
002426
002427
002428
002429
002430
002431
002432
002433
002434
002435
002436
002437
002438
002439
002440
002441
002442
002443

ViewLCd := pane.viewedLRect.topLeft.vh[SELF.scrollDir];
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
END;
{$S SgABCres}

METHODS OF TSideBand;
{$S SgABCcld}
FUNCTION {TSideBand.}CREATE{(object: TObject; heap: THeap; itsPanel: TPanel; itsInnerRect: Rect;
itsDir: VHSelect; itsTopOrLeft: BOOLEAN;
itsViewLCd: LONGINT): TSideBand};
VAR bandList:
TList;
itsCoBand: TBand;
deltaLPt:
LPoint;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
TSideBand(object).topOrLeft := itsTopOrLeft; {needed to be set before SetInnerRect, which is
done in TBand.CREATE}
SELF := TSideBand(TBand.CREATE(object, heap, itsPanel, itsInnerRect, NIL, itsDir));
bandList := itsPanel.bands[itsDir];
IF itsTopOrLeft THEN
BEGIN
itsCoBand := TBand(bandList.First);
bandList.InsFirst(SELF);
END
ELSE
BEGIN
itsCoBand := TBand(bandList.Last);
bandList.InsLast(SELF);
END;
SELF.panes.Become(itsCoBand.panes.Clone(heap));
SELF.ResizePanes(itsViewLCd);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 321 of 1012

Apple Lisa Computer Technical Information


002444
002445
002446
002447
002448
002449
002450
002451
002452
002453
002454
002455
002456
002457
002458
002459
002460
002461
002462
002463
002464
002465
002466
002467
002468
002469
002470
002471
002472
002473
002474
002475
002476
002477
002478
002479
002480
002481
002482
002483
002484
002485
002486
002487
002488
002489
002490
002491

{$S SgABCcld}
PROCEDURE {TSideBand.}Free;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.scroller := NIL;
{let my coBand free the scroller}
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TSideBand.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SUPERSELF.Fields(Field);
Field('topOrLeft: BOOLEAN');
Field('');
{$IFC fTrace}EP;{$ENDC}
END;
{$ENDC}
{$S SgABCcld}
FUNCTION {TSideBand.}CoBand{: TBand};
VAR bandList:
TList;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
bandList := SELF.panel.bands[SELF.scrollDir];
IF SELF.topOrLeft THEN
CoBand := TBand(bandList.At(2))
ELSE
CoBand := TBand(bandList.At(bandList.Size-1));
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
PROCEDURE {TSideBand.}GetBorder{(VAR border: Rect)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SUPERSELF.GetBorder(border);
WITH SELF, border DO
IF topOrLeft THEN
botRight.vh[scrollDir] := 0
ELSE
topLeft.vh[scrollDir] := 0;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 322 of 1012

Apple Lisa Computer Technical Information


002492
002493
002494
002495
002496
002497
002498
002499
002500
002501
002502
002503
002504
002505
002506
002507
002508
002509
002510
002511
002512
002513
002514
002515
002516
002517
002518
002519
002520
002521
002522
002523
002524
002525
002526
002527
002528
002529
002530
002531
002532
002533
002534
002535
002536
002537
002538
002539

{$S SgABCcld}
PROCEDURE {TSideBand.}ResizeOutside{(newOuterRect: Rect)};
VAR unchangedRect:
Rect;
rectToInval:
Rect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF NOT EqualRect(SELF.outerRect, newOuterRect) THEN
BEGIN
unchangedRect := SELF.outerRect;
IF NOT EqualPt(unchangedRect.topLeft, newOuterRect.topLeft) THEN
unchangedRect := zeroRect
ELSE
InsetRect(unchangedRect, 1, 1); {we want unchangedRect to be the old innerRect}
SELF.SetOuterRect(newOuterRect);
rectToInval := SELF.innerRect;
InsetRect(rectToInval, -1, -1);
InvalDiffRect(rectToInval, unchangedRect);
SELF.ResizePanes(SELF.ViewLCd);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
PROCEDURE {TSideBand.}ResizePanes{(newViewLCd: LONGINT)};
{assumes SELF.innerRect already set}
VAR vhs:
VHSelect;
s:
TListScanner;
pane:
TPane;
viewedLRect:
LRect;
scrollableLRect:
LRect;
oldViewLCd:
LONGINT;
deltaLPt:
LPoint;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
vhs := SELF.scrollDir;
s := SELF.panes.Scanner;
WHILE s.Scan(pane) DO
pane.Resize(SELF.innerRect, vhs);
oldViewLCd := SELF.ViewLCd;

Apple Lisa ToolKit 3.0 Source Code Listing -- 323 of 1012

Apple Lisa Computer Technical Information


002540
002541
002542
002543
002544
002545
002546
002547
002548
002549
002550
002551
002552
002553
002554
002555
002556
002557
002558
002559
002560
002561
002562
002563
002564
002565
002566
002567
002568
002569
002570
002571
002572
002573
002574
002575
002576
002577
002578
002579
002580
002581
002582
002583
002584
002585
002586
002587

deltaLPt.vh[orthogonal[vhs]] := 0;
deltaLPt.vh[vhs] := newViewLCd - oldViewLCd;
SELF.OffsetPanes(deltaLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sError}
PROCEDURE {TSideBand.}ScrollTo{(viewLCd: LONGINT)};
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
ABCBreak('Can not do TSideBand.ScrollTo', 0);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
FUNCTION {TSideBand.}ThumbPos{: INTEGER};
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
ThumbPos := 0;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
END;
{$S SgABCres}

METHODS OF TPane;
{$S sCldInit}
FUNCTION {TPane.}CREATE{(object: TObject; heap: THeap; itsPanel: TPanel; itsInnerRect: Rect;
itsViewedLRect: LRect): TPane};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TPane(TPad.CREATE(object, heap, itsInnerRect, itsViewedLRect, screenRes,
screenRes, POINTER(itsPanel.window.wmgrId)));
SELF.currentView := itsPanel.currentView;
SELF.panel := itsPanel;
{$IFC fTrace}EP;{$ENDC}

{presumably unnecessary because will be done by haveView}

Apple Lisa ToolKit 3.0 Source Code Listing -- 324 of 1012

Apple Lisa Computer Technical Information


002588
002589
002590
002591
002592
002593
002594
002595
002596
002597
002598
002599
002600
002601
002602
002603
002604
002605
002606
002607
002608
002609
002610
002611
002612
002613
002614
002615
002616
002617
002618
002619
002620
002621
002622
002623
002624
002625
002626
002627
002628
002629
002630
002631
002632
002633
002634
002635

END;
{$S SgABCres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TPane.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
TPad.Fields(Field);
Field('currentView: TView');
Field('panel: TPanel');
END;
{$S SgABCres}
{$ENDC}
{$S sRes}
FUNCTION {TPane.}CursorAt{(mousePt: Point): TCursorNumber};
{assumes mousePt is within the pane's innerRect}
VAR mouseLPt:
LPoint;
panePt:
Point; {window-relative, under the coordinate system defined by pane}
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
PushFocus;
panePt := mousePt;
LocalToGlobal(panePt);
SELF.Focus;
GlobalToLocal(panePt); {mousePt is now adjusted for the pane's new origin}
SELF.PtToLPt(panePt, mouseLPt);
IF LRectHasLPt(SELF.currentView.extentLRect, mouseLPt) THEN
CursorAt := SELF.currentView.CursorAt(mouseLPt)
ELSE
CursorAt := arrowCursor;
PopFocus;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TPane.}GetScrollLimits{(VAR viewedLRect, scrollableLRect: LRect)};
VAR extra: Point;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
viewedLRect := SELF.viewedLRect;
WITH SELF.currentView DO
BEGIN
scrollableLRect := extentLRect;
extra := scrollPastEnd;

Apple Lisa ToolKit 3.0 Source Code Listing -- 325 of 1012

Apple Lisa Computer Technical Information


002636
002637
002638
002639
002640
002641
002642
002643
002644
002645
002646
002647
002648
002649
002650
002651
002652
002653
002654
002655
002656
002657
002658
002659
002660
002661
002662
002663
002664
002665
002666
002667
002668
002669
002670
002671
002672
002673
002674
002675
002676
002677
002678
002679
002680
002681
002682
002683

END;
WITH scrollableLRect, extra DO
BEGIN
right := right + Max(0, Min(viewedLRect.right - viewedLRect.left - h, h));
bottom := bottom + Max(0, Min(viewedLRect.bottom - viewedLRect.top - v, v));
END;
{$IFC fTrace}EP;{$ENDC}
END;

{$S sCldInit}
PROCEDURE {TPane.}HaveView{(view: TView)};
VAR deltaLPt:
LPoint;
viewedLRect:
LRect;
paneSize:
Point;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.currentView := view;
IF (view.res.h <> SELF.viewedRes.h) OR (view.res.v <> SELF.viewedRes.v) THEN
BEGIN
PtMinusPt(SELF.innerRect.botRight, SELF.innerRect.topLeft, paneSize);
viewedLRect := view.extentLRect;
viewedLRect.right := viewedLRect.left +
LIntDivInt(ORD4(paneSize.h) * view.res.h, SELF.padRes.h);
viewedLRect.bottom := viewedLRect.top +
LIntDivInt(ORD4(paneSize.v) * view.res.v, SELF.padRes.v);
SELF.Redefine(SELF.innerRect, viewedLRect, SELF.padRes, view.res, SELF.zoomFactor, SELF.port);
END
ELSE
BEGIN
SetLPt(deltaLPt, view.extentLRect.left - SELF.viewedLRect.left,
view.extentLRect.top - SELF.viewedLRect.top);
SELF.OffsetBy(deltaLPt);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sRes}
PROCEDURE {TPane.}MouseTrack{(mPhase: TMousePhase; mousePt: Point)};
{assumes mousePt is within the pane's innerRect;
mousePt is window-relative, (0,0)-origined}
VAR mouseLPt:
LPoint;
panePt:
Point; {window-relative, under the coordinate system defined by pane}
currentView:
TView;

Apple Lisa ToolKit 3.0 Source Code Listing -- 326 of 1012

Apple Lisa Computer Technical Information


002684
002685
002686
002687
002688
002689
002690
002691
002692
002693
002694
002695
002696
002697
002698
002699
002700
002701
002702
002703
002704
002705
002706
002707
002708
002709
002710
002711
002712
002713
002714
002715
002716
002717
002718
002719
002720
002721
002722
002723
002724
002725
002726
002727
002728
002729
002730
002731

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
PushFocus;
panePt := mousePt;
LocalToGlobal(panePt);
SELF.Focus;
GlobalToLocal(panePt); {mousePt is now adjusted for the pane's new origin}
SELF.PtToLPt(panePt, mouseLPt);
currentView := SELF.currentView;
currentView.MouseTrack(mPhase, mouseLPt);
PopFocus;
{ &&& we should optimize the following -- SELF.CursorAt also does the same focusing as above }
process.ChangeCursor(SELF.CursorAt(mousePt));
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
{+++LSR+++} {This whole method is substantially changed}
PROCEDURE {TPane.}Refresh{(rActions: TActions; highTransit: THighTransit)};
VAR panel:
needGray:
viewExtentLRect:
viewedLRect:
tempLRect:

TPanel;
BOOLEAN;
LRect;
LRect;
LRect;

PROCEDURE HighlightOnThePad;
BEGIN
panel.selection.Highlight(highTransit);
END;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
panel := SELF.panel;
viewExtentLRect := SELF.currentView.extentLRect;
viewedLRect := SELF.viewedLRect;
IF rFrame IN rActions THEN
SELF.Frame;
needGray := (rBackground IN rActions) AND
((viewedLRect.right > viewExtentLRect.right) OR
(viewedLRect.bottom > viewExtentLRect.bottom));
IF rErase IN rActions THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 327 of 1012

Apple Lisa Computer Technical Information


002732
002733
002734
002735
002736
002737
002738
002739
002740
002741
002742
002743
002744
002745
002746
002747
002748
002749
002750
002751
002752
002753
002754
002755
002756
002757
002758
002759
002760
002761
002762
002763
002764
002765
002766
002767
002768
002769
002770
002771
002772
002773
002774
002775
002776
002777
002778
002779

SELF.Erase;
IF (rDraw IN rActions) OR (highTransit <> hNone) OR needGray THEN
BEGIN
PushFocus;
SELF.Focus;
IF needGray THEN
BEGIN
PenNormal;
PenSize(2, 2);
{draw the vertical strip of gray ...}
tempLRect := viewedLRect;
tempLRect.left := viewExtentLRect.right;
FillLRect(tempLRect, lPatLtGray);
{... then the horizontal strip ...}
tempLRect := viewedLRect;
tempLRect.top := viewExtentLRect.bottom;
FillLRect(tempLRect, lPatLtGray);
{... then frame the bottom right of the view extent with a 2-pixel line outside the extent;
note that the topLeft does not matter}
tempLRect.topLeft := viewedLRect.topLeft;
tempLRect.botRight := viewExtentLRect.botRight;
InsetLRect(tempLRect, -2, -2);
FrameLRect(tempLRect);
END;
IF rDraw IN rActions THEN
SELF.currentView.Draw;
IF highTransit <> hNone THEN
IF panel.previewMode = mPrvwMargins THEN
panel.paginatedView.DoOnPages(TRUE, HighlightOnThePad)
ELSE
HighlightOnThePad;
IF rDraw IN rActions THEN {Page breaks after highlighting, in case highlighting doesn't XOR}
IF panel.previewMode = mPrvwBreaks THEN {Xors automatic as well as manual page breaks}
SELF.currentView.printManager.DrawBreaks(FALSE);
PopFocus;
END;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 328 of 1012

Apple Lisa Computer Technical Information


002780
002781
002782
002783
002784
002785
002786
002787
002788
002789
002790
002791
002792
002793
002794
002795
002796
002797
002798
002799
002800
002801
002802
002803
002804
002805
002806
002807
002808
002809
002810
002811
002812
002813
002814
002815
002816
002817
002818
002819
002820
002821
002822
002823
002824
002825
002826
002827

{$S SgABCres}
{$S sRes}
PROCEDURE {TPane.}Resize{(newInnerRect: Rect; vhs: VHSelect)};
VAR innerRect:
Rect;
paneLongSize:
LPoint;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
innerRect := SELF.innerRect;
AlignRect(innerRect, newInnerRect, vhs);
SELF.SetInnerRect(innerRect);
SELF.clippedRect := innerRect;
SELF.DistToLDist(Point(FDiagRect(innerRect)), paneLongSize);
{$H-} LPtPlusLPt(SELF.viewedLRect.topLeft, paneLongSize, SELF.viewedLRect.botRight); {$H+}
SELF.availLRect := SELF.viewedLRect;
{$H-} InsetLRect(SELF.availLRect, -8192, -8192); {$H+}
{$IFC fTrace}EP;{$ENDC}
END;
{$S sScroll}
PROCEDURE {TPane.}ScrollBy(VAR deltaLPt: LPoint);
VAR panel:
TPanel;
deltaPt:
Point;
vhs:
VHSelect;
band:
TBand;
tempPt:
Point;
BEGIN
{$IFC fTrace}BP(5);{$ENDC}
panel := SELF.panel;
IF panel.panes.Size = 1 THEN
BEGIN
PushFocus;
SELF.panel.window.Focus;
panel.DoScrolling(SELF, SELF, TRUE, TRUE, deltaLPt);
IF NOT EqualLPt(deltaLPt, zeroLPt) THEN
BEGIN
SELF.OffsetBy(deltaLPt);
FOR vhs := v TO h DO
panel.scrollBars[vhs].firstBox.MoveThumb(TBand(panel.bands[vhs].First).ThumbPos);
END;
PopFocus;
END
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 329 of 1012

Apple Lisa Computer Technical Information


002828
002829
002830
002831
002832
002833
002834
002835
002836
002837
002838
002839
002840
002841
002842
002843
002844
002845
002846
002847
002848
002849
002850
002851
002852
002853
002854
002855
002856
002857
002858
002859
002860
002861
002862
002863
002864
002865
002866
002867
002868
002869
002870
002871
002872
002873
002874
002875

FOR vhs := v TO h DO
BEGIN
band := TBand(panel.ChildWithPt(SELF.innerRect.topLeft, panel.bands[vhs], tempPt));
band.ScrollBy(deltaLPt.vh[vhs]);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sScroll}
PROCEDURE {TPane.}ScrollToReveal(VAR anLRect: LRect; hMinToSee, vMinToSee: INTEGER);
VAR ptMinToSee:
Point;
minToSee:
INTEGER;
viewedLRect:
LRect;
deltaLPt:
LPoint;
vhs:
VHSelect;
lcd:
LONGINT;
BEGIN
{$IFC fTrace}BP(5);{$ENDC}
viewedLRect := SELF.viewedLRect;
SetPt(ptMinToSee, hMinToSee, vMinToSee);
FOR vhs := v TO h DO
BEGIN
minToSee := Min(LengthRect(SELF.innerRect, vhs), ptMinToSee.vh[vhs]);
lcd := anLRect.topLeft.vh[vhs] + minToSee - viewedLRect.botRight.vh[vhs];
IF lcd <= 0 THEN
BEGIN
lcd := anLRect.botRight.vh[vhs] - minToSee - viewedLRect.topLeft.vh[vhs];
IF lcd >= 0 THEN
lcd := 0;
END;
deltaLPt.vh[vhs] := lcd;
END;
SELF.ScrollBy(deltaLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCcld}
PROCEDURE {TPane.}SetZoomFactor{(zoomNumerator, zoomDenominator: Point)};
VAR zoomFactor: TScaler;
newLRight:
LONGINT;
newLBottom: LONGINT;
newViewedLRect: LRect;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 330 of 1012

Apple Lisa Computer Technical Information


002876
002877
002878
002879
002880
002881
002882
002883
002884
002885
002886
002887
002888
002889
002890
002891
002892
002893
002894
002895
002896
002897
002898
002899
002900
002901
002902
002903
002904
002905
002906
002907
002908
002909
002910
002911
002912
002913
002914
002915
002916
002917
002918
002919
002920
002921
002922
002923

{$IFC fTrace}BP(9);{$ENDC}
Reduce(zoomNumerator.h, zoomDenominator.h); {reduce to lowest terms}
Reduce(zoomNumerator.v, zoomDenominator.v);
{adjust viewed lRect}
newLRight := Min(
(SELF.viewedLRect.right * zoomDenominator.h * SELF.zoomFactor.numerator.h)
DIV ( zoomNumerator.h * SELF.zoomFactor.denominator.h),
SELF.currentView.extentLRect.right);
newLBottom := Min(
(SELF.viewedLRect.bottom * zoomDenominator.v * SELF.zoomFactor.numerator.v)
DIV ( zoomNumerator.v * SELF.zoomFactor.denominator.v),
SELF.currentView.extentLRect.bottom);
SetLRect(newViewedLRect, SELF.viewedLRect.left, SELF.viewedLRect.top,
newLRight, newLBottom);
SetPt(zoomFactor.numerator, zoomNumerator.h, zoomNumerator.v);
SetPt(zoomFactor.denominator, zoomDenominator.h, zoomDenominator.v);
SELF.Redefine(SELF.innerRect, newViewedLRect, SELF.padRes, SELF.viewedRes, zoomFactor, SELF.port);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCini}
END;
{$S SgABCres}

METHODS OF TMarginPad;
{$S SgABCini}
FUNCTION {TMarginPad.}CREATE{(object: TObject; heap: THeap): TMarginPad};
VAR bodyPad: TBodyPad;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TMarginPad(object);
bodyPad := TBodyPad.CREATE(NIL, heap, SELF);
SELF.bodyPad := bodyPad;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

Apple Lisa ToolKit 3.0 Source Code Listing -- 331 of 1012

Apple Lisa Computer Technical Information


002924
002925
002926
002927
002928
002929
002930
002931
002932
002933
002934
002935
002936
002937
002938
002939
002940
002941
002942
002943
002944
002945
002946
002947
002948
002949
002950
002951
002952
002953
002954
002955
002956
002957
002958
002959
002960
002961
002962
002963
002964
002965
002966
002967
002968
002969
002970
002971

{$S SgABCpri}
PROCEDURE {TMarginPad.}Rework{(itsView: TView; itsOrigin: Point; itsRes: Point;
itsPageNumber: LONGINT; itsZoomFactor: TScaler; itsPort: GrafPtr)};
VAR itsViewedLRect: LRect;
printerMetrics: TPrinterMetrics;
bodyPad:
TBodyPad;
innerRect:
Rect;
PROCEDURE ScaleToPadSpace(printRect: Rect; VAR padRect: Rect);
VAR padLRect: LRect;
{NB: itsOrigin is a free var in this proc}
BEGIN
SetLRect(padLRect,
LIntOvrInt(ORD4(printRect.left)
* itsRes.h * itsZoomFactor.numerator.h,
printerMetrics.res.h * itsZoomFactor.denominator.h),
LIntOvrInt(ORD4(printRect.top)
* itsRes.v * itsZoomFactor.numerator.v,
printerMetrics.res.v * itsZoomFactor.denominator.v),
LIntOvrInt(ORD4(printRect.right) * itsRes.h * itsZoomFactor.numerator.h,
printerMetrics.res.h * itsZoomFactor.denominator.h),
LIntOvrInt(ORD4(printRect.bottom) * itsRes.v * itsZoomFactor.numerator.v,
printerMetrics.res.v * itsZoomFactor.denominator.v));
noPad.LRectToRect(padLRect, padRect);
OffsetRect(padRect, itsOrigin.h, itsOrigin.v);
END;

{this whole stmt}

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.view := itsView;
printerMetrics := SELF.view.printManager.printerMetrics;
SELF.pageNumber := itsPageNumber;
ScaleToPadSpace(printerMetrics.paperRect, innerRect);
SELF.Redefine(innerRect, SELF.view.printManager.paperLRect,
itsRes,
{pad resolutions}
itsView.res,
{viewed resolutions}
itsZoomFactor, itsPort);
{calls TPad's Redefine method}
{page's 'viewed space' has same metrics as the owning view's}
SELF.bodyPad.Recompute;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCini}
PROCEDURE {TMarginPad.}Free;

Apple Lisa ToolKit 3.0 Source Code Listing -- 332 of 1012

Apple Lisa Computer Technical Information


002972
002973
002974
002975
002976
002977
002978
002979
002980
002981
002982
002983
002984
002985
002986
002987
002988
002989
002990
002991
002992
002993
002994
002995
002996
002997
002998
002999
003000
003001
003002
003003
003004
003005
003006
003007
003008
003009
003010
003011
003012
003013
003014
003015
003016
003017
003018
003019

BEGIN
{$IFC fTrace}BP(6);{$ENDC}
Free(SELF.bodyPad);
TObject.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCpri}
PROCEDURE {TMarginPad.}SetForPage{(itsPageNumber: LONGINT; itsOrigin: Point)};
VAR innerRect: Rect;
newOffset: LPoint;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.pageNumber := itsPageNumber;
innerRect := SELF.innerRect;
OffsetRect(innerRect, itsOrigin.h - SELF.innerRect.left, itsOrigin.v - SELF.innerRect.top);
SELF.SetInnerRect(innerRect);
SELF.clippedRect := innerRect;
WITH innerRect DO
SetLPt(newOffset, - left, - top);
SELF.SetScrollOffset(newOffset);
SELF.bodyPad.SetForPage(itsPageNumber);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TMarginPad.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
TPad.Fields(Field);
Field('view: TView');
Field('pageNumber: LONGINT');
Field('bodyPad: TBodyPad');
Field('');
END;
{$S SgABCres}
{$ENDC}
{$IFC fDbgABC}
{$S SgABCdbg}
FUNCTION TMarginPad.BindHeap{(activeVsClip, doBind: BOOLEAN): THeap}; {called by HeapDump in UOBJECT2}
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 333 of 1012

Apple Lisa Computer Technical Information


003020
003021
003022
003023
003024
003025
003026
003027
003028
003029
003030
003031
003032
003033
003034
003035
003036
003037
003038
003039
003040
003041
003042
003043
003044
003045
003046
003047
003048
003049
003050
003051
003052
003053
003054
003055
003056
003057
003058
003059
003060
003061
003062
003063
003064
003065
003066
003067

{$IFC fMaxTrace}EP;{$ENDC}
BindHeap := NIL;
(* IF activeWindowID <> 0 THEN {don't allow inactive windows to use this} -- WHY NOT????
BEGIN
IF activeVsClip THEN
BEGIN
(*
IF (currentDocument <> NIL) AND doBind THEN
BindHeap := currentDocument.docHeap;
IF (boundDocument <> NIL) AND doBind THEN
BindHeap := boundDocument.docHeap;
END
ELSE
IF currentDocument <> clipboard THEN
IF doBind THEN
BEGIN
hadToBindClip := boundClipboard = NIL;
IF hadToBindClip THEN
clipboard.Bind;
BindHeap := clipboard.docHeap;
END
ELSE IF hadToBindClip THEN
clipboard.Unbind;
END;
END;
{$S SgABCres}
{$ENDC}

*)

*)

{$S SgABCcld}
PROCEDURE {TMarginPad.}Crash;
BEGIN
{SELF = crashPad, presumably, but in any case, someone wants this process to die, so...}
IF isInitialized THEN
process.Complete(FALSE);
END;
{$S SgABCres}
PROCEDURE TMarginPad.SetScrollOffset(VAR newOffset: LPoint);
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF fExperimenting OR NOT amPrinting THEN
SUPERSELF.SetScrollOffset(newOffset)
ELSE
WITH SELF DO
BEGIN
scrollOffset := newOffset;
origin := zeroPt;
cdOffset := newOffset;

{+SW+}

Apple Lisa ToolKit 3.0 Source Code Listing -- 334 of 1012

Apple Lisa Computer Technical Information


003068
003069
003070
003071
003072
003073
003074
003075
003076
003077
003078
003079
003080
003081
003082
003083
003084
003085
003086
003087
003088
003089
003090
003091
003092
003093
003094
003095
003096
003097
003098
003099
003100
003101
003102
003103
003104
003105
003106
003107
003108
003109
003110
003111
003112
003113
003114
003115

END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
END;
{$S SgABCres}
METHODS OF TBodyPad;
{$S SgABCini}
FUNCTION {TBodyPad.}CREATE{(object: TObject; heap: THeap; itsMarginPad: TMarginPad): TBodyPad};
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TBodyPad(object);
SELF.marginPad := itsMarginPad;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TBodyPad.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
TPad.Fields(Field);
Field('marginPad: TMarginPad');
Field('nonNullBody: Rect');
END;
{$S SgABCres}
{$ENDC}
{$S SgABCpri}
PROCEDURE {TBodyPad.}Focus;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
SELF.ClipFurtherTo(SELF.nonNullBody);
TPad.Focus;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

Apple Lisa ToolKit 3.0 Source Code Listing -- 335 of 1012

Apple Lisa Computer Technical Information


003116
003117
003118
003119
003120
003121
003122
003123
003124
003125
003126
003127
003128
003129
003130
003131
003132
003133
003134
003135
003136
003137
003138
003139
003140
003141
003142
003143
003144
003145
003146
003147
003148
003149
003150
003151
003152
003153
003154
003155
003156
003157
003158
003159
003160
003161
003162
003163

{$S SgABCpri}
PROCEDURE {TBodyPad.}Recompute;
VAR myViewedLRect: LRect;
myInnerRect:
Rect;
view:
TView;
marginPad:
TMarginPad;
bodyRect:
Rect;
printManager:
TPrintManager;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
marginPad := SELF.marginPad;
view := marginPad.view;
printManager := view.printManager;
printManager.GetPageLimits(marginPad.pageNumber, myViewedLRect);
marginPad.LRectToRect(printManager.contentLRect, myInnerRect);
WITH marginPad.origin DO {$H-}
OffsetRect(myInnerRect, -h, -v); {$H+}
SELF.Redefine(myInnerRect, myViewedLRect, marginPad.padRes,
view.res, marginPad.zoomFactor, SELF.marginPad.port);
bodyRect.topLeft := SELF.innerRect.topLeft;
SELF.LPtToPt(myViewedLRect.botRight, bodyRect.botRight);
bodyRect.botRight := Point(FPtMinusPt(bodyRect.botRight, SELF.origin));
SELF.nonNullBody := bodyRect;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCpri}
PROCEDURE {TBodyPad.}SetForPage{(itsPageNumber: LONGINT)};
VAR myViewedLRect: LRect;
myInnerRect:
Rect;
bodyRect:
Rect;
printManager:
TPrintManager;
newOffset:
LPoint;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
printManager := SELF.marginPad.view.printManager;
printManager.GetPageLimits(itsPageNumber, myViewedLRect);
SELF.marginPad.LRectToRect(printManager.contentLRect, myInnerRect);
WITH SELF.marginPad.origin DO {$H-}
OffsetRect(myInnerRect, -h, -v); {$H+}

Apple Lisa ToolKit 3.0 Source Code Listing -- 336 of 1012

Apple Lisa Computer Technical Information


003164
003165
003166
003167
003168
003169
003170
003171
003172
003173
003174
003175
003176
003177
003178
003179
003180
003181
003182
003183
003184
003185
003186
003187
003188
003189
003190
003191
003192
003193
003194
003195
003196
003197
003198
003199
003200
003201
003202
003203
003204
003205
003206
003207
003208
003209
003210
003211

SELF.SetInnerRect(myInnerRect);
WITH SELF, newOffset, scaleFactor DO
BEGIN
viewedLRect := myViewedLRect;
availLRect := myViewedLRect;
{$H-} InsetLRect(availLRect, -8192, -8192); {$H+}
clippedRect := myInnerRect;
IF scaled THEN
BEGIN
{$H-}
h := LIntOvrInt(LIntMulInt(myViewedLRect.left, numerator.h), denominator.h) {+++LSR+++}
- myInnerRect.left;
v := LIntOvrInt(LIntMulInt(myViewedLRect.top, numerator.v), denominator.v) {+++LSR+++}
- myInnerRect.top; {$H+}
END
ELSE
BEGIN
h := myViewedLRect.left - myInnerRect.left;
v := myViewedLRect.top - myInnerRect.top;
END;
END;
SELF.SetScrollOffset(newOffset);
SELF.nonNullBody := SELF.innerRect;
SELF.LPtToPt(myViewedLRect.botRight, SELF.nonNullBody.botRight);
SELF.nonNullBody.botRight := Point(FPtMinusPt(SELF.nonNullBody.botRight, SELF.origin)); {$H+}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

{$H-}

PROCEDURE TBodyPad.SetScrollOffset(VAR newOffset: LPoint);


BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF fExperimenting OR NOT amPrinting THEN
SUPERSELF.SetScrollOffset(newOffset)
ELSE
WITH SELF DO
BEGIN
scrollOffset := newOffset;
origin := zeroPt;
cdOffset := newOffset;
END;
{$IFC fTrace}EP;{$ENDC}
END;

{+SW+}

{$S SgABCini}

Apple Lisa ToolKit 3.0 Source Code Listing -- 337 of 1012

Apple Lisa Computer Technical Information


003212
003213
003214
003215
003216
003217
003218
003219
003220
003221
003222
003223
003224
003225
003226
003227
003228
003229
003230
003231
003232
003233
003234
003235
003236
003237
003238
003239
003240
003241
003242
003243
003244
003245
003246
003247
003248
003249
003250
003251
003252
003253
003254
003255
003256
003257
003258
003259

END;
{$S SgABCres}
METHODS OF TScroller;
{$S sCldInit}
FUNCTION {TScroller.}CREATE{(object: TObject; heap: THeap; itsScrollBar: TScrollBar; itsId: TSBoxID)
:TScroller};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TScroller(object);
WITH SELF DO
BEGIN
scrollBar := itsScrollBar;
band := NIL;
sBoxID := itsId;
{$H-} SetSbRefcon(POINTER(sBoxID), ORD(SELF)); {$H+}
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S SgABCini}
PROCEDURE {TScroller.}Free;
VAR sbList: TSbList;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
PreSbList(sbList, SELF.scrollBar);
{$H-} KillSb(sbList, POINTER(SELF.sBoxID)); {$H+}
PostSbList(sbList, SELF.scrollBar);
TObject.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TScroller.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
Field('scrollBar: TScrollBar');
Field('band: TBand');

Apple Lisa ToolKit 3.0 Source Code Listing -- 338 of 1012

Apple Lisa Computer Technical Information


003260
003261
003262
003263
003264
003265
003266
003267
003268
003269
003270
003271
003272
003273
003274
003275
003276
003277
003278
003279
003280
003281
003282
003283
003284
003285
003286
003287
003288
003289
003290
003291
003292
003293
003294
003295
003296
003297
003298
003299
003300
003301
003302
003303
003304
003305
003306
003307

Field('sBoxID: LONGINT');
END;
{$S SgABCres}
{$ENDC}
{$S sScroll}
PROCEDURE {TScroller.}FillIcon{(icon: TEnumIcons; fBlack: BOOLEAN)};
TYPE TIconAlias =
RECORD
CASE INTEGER OF
1: (sblib: TIcon);
2: (abc:
TEnumIcons);
END;
VAR iconAlias:
TIconAlias;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
iconAlias.abc := icon;
PaintArw(POINTER(SELF.sBoxID), iconAlias.sblib, fBlack);
END;
{$S sRes}
PROCEDURE {TScroller.}GetSize{(VAR boxRect: Rect)};
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
GetSbRect(POINTER(SELF.sBoxID), boxRect);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sScroll}
PROCEDURE {TScroller.}MoveThumb{(newThumbPos: INTEGER)};
{NOTE: assumes we are focused on the window, NOT on a pane}
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
IF activeWindowID <> 0 THEN
BEGIN
SetupMvThumb(POINTER(SELF.sboxID));
MoveThumb(newThumbPos);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sSplit}
PROCEDURE {TScroller.}ResplitAt{(newSkwrCd: INTEGER; prevScroller: TScroller)};

Apple Lisa ToolKit 3.0 Source Code Listing -- 339 of 1012

Apple Lisa Computer Technical Information


003308
003309
003310
003311
003312
003313
003314
003315
003316
003317
003318
003319
003320
003321
003322
003323
003324
003325
003326
003327
003328
003329
003330
003331
003332
003333
003334
003335
003336
003337
003338
003339
003340
003341
003342
003343
003344
003345
003346
003347
003348
003349
003350
003351
003352
003353
003354
003355

VAR vhs:
VHSelect;
sbRect:
Rect;
prevSbRect: Rect;
hsb:
THSb;
deltaCd:
INTEGER;
minSize:
INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
vhs := SELF.ScrollDir;
minSize := dptSkewer.vh[vhs];
hsb := POINTER(SELF.sBoxID);
GetSbRect(hsb, sbRect);
prevScroller.GetSize(prevSbRect);
{If either scroller to becomes too small, delete it}
IF newSkwrCd <= prevSbRect.topLeft.vh[vhs] + minSize THEN
newSkwrCd := prevSbRect.topLeft.vh[vhs]
ELSE IF newSkwrCd >= sbRect.botRight.vh[vhs] - minSize THEN
newSkwrCd := sbRect.botRight.vh[vhs];
deltaCd := newSkwrCd - sbRect.topLeft.vh[vhs];
AdjSplitBetween(POINTER(prevScroller.sBoxID), hsb, deltaCd);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sRes}
FUNCTION {TScroller.}ScrollDir{: VHSelect};
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
ScrollDir := TyVHOfSb(POINTER(SELF.sBoxID));
{$IFC fTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE {TScroller.}SetSize{(ownerRect: Rect)};
VAR sbRect: Rect;
vhs: VHSelect;
width: INTEGER;
{ownerRect is the band's outerRect.
For v bar: top/bottom = ownerRect top/bottom
left
= ownerRect right - 1
right
= left + dhSBox}

BEGIN
{$IFC fTrace}BP(7);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 340 of 1012

Apple Lisa Computer Technical Information


003356
003357
003358
003359
003360
003361
003362
003363
003364
003365
003366
003367
003368
003369
003370
003371
003372
003373
003374
003375
003376
003377
003378
003379
003380
003381
003382
003383
003384
003385
003386
003387
003388
003389
003390
003391
003392
003393
003394
003395
003396
003397
003398
003399
003400
003401
003402
003403

vhs := orthogonal[SELF.ScrollDir];
sbRect := ownerRect;
sbRect.topLeft.vh[vhs] := sbRect.botRight.vh[vhs] - 1;
IF SELF.scrollBar.isVisible THEN
width := dptSbox.vh[vhs]
ELSE
width := 0;
sbRect.botRight.vh[vhs] := sbRect.topLeft.vh[vhs] + width;
SetSbRect(POINTER(SELF.sBoxID), sbRect);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sSplit}
PROCEDURE {TScroller.}SplitAt{(newSkwrCd: INTEGER; VAR nextScroller: TScroller)};
VAR newHsb: THsb;
sbList: TSbList;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
PreSbList(sbList, SELF.scrollBar);
SplitSb(sbList, POINTER(SELF.sBoxID), newHsb, newSkwrCd);
PostSbList(sbList, SELF.scrollBar);
nextScroller := TScroller.CREATE(NIL, SELF.Heap, SELF.scrollBar, ORD(newHsb));
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
{$S sScroll}
FUNCTION {TScroller.}ThumbRange{: INTEGER};
VAR posts: TPosts;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
MkPosts(POINTER(SELF.sBoxID), posts);
ThumbRange := posts[iconGryB] - posts[iconPagA] - dptThumb.vh[SELF.ScrollDir];
{$IFC fTrace}EP;{$ENDC}
END;
{$S sSplit}
PROCEDURE {TScroller.}TrackSkewer{(mousePt: Point; VAR newSkwrCd: INTEGER;
VAR scroller, prevScroller: TScroller)};
VAR hsb, prevHsb:
THsb;
sbList:
TSbList;
limitRect:
Rect;
newSkwrPt:
Point;

Apple Lisa ToolKit 3.0 Source Code Listing -- 341 of 1012

Apple Lisa Computer Technical Information


003404
003405
003406
003407
003408
003409
003410
003411
003412
003413
003414
003415
003416
003417
003418
003419
003420
003421
003422
003423
003424
003425
003426
003427
003428
003429
003430
003431
003432
003433
003434
003435
003436
003437
003438
003439
003440
003441
003442
003443
003444
003445
003446
003447
003448
003449
003450
003451

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
hsb := POINTER(SELF.sBoxID);
FixRLimits(hsb, limitRect);
AlignRect(limitRect, SELF.band.outerRect, orthogonal[SELF.ScrollDir]);
DragSkewer(hsb, mousePt, limitRect, newSkwrPt);
newSkwrCd := newSkwrPt.vh[SELF.ScrollDir];
prevHsb:= HsbPrev(hsb);
IF prevHsb = hsbNil THEN
BEGIN
PreSbList(sbList, SELF.scrollBar);
hsb := HsbFromPt(sbList, newSkwrPt);
PostSbList(sbList, SELF.scrollBar);
IF hsb = hsbNil THEN
scroller := NIL
ELSE
scroller := POINTER(RefconSb(hsb));
prevScroller := NIL;
END
ELSE
BEGIN
scroller := SELF;
prevScroller := POINTER(RefconSb(prevHsb));
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sScroll}
PROCEDURE {TScroller.}TrackThumb{(mousePt: Point; VAR oldThumbPos, newThumbPos: INTEGER)};
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
oldThumbPos := CThumbPos(POINTER(SELF.sBoxID));
DragThumb(POINTER(SELF.sBoxID), mousePt, newThumbPos);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
END;
{$S SgABCres}
METHODS OF TScrollBar;
{$S SgABCini}
FUNCTION {TScrollBar.}CREATE{(object: TObject; heap: THeap; vhs: VHSelect; outerRect: Rect;

Apple Lisa ToolKit 3.0 Source Code Listing -- 342 of 1012

Apple Lisa Computer Technical Information


003452
003453
003454
003455
003456
003457
003458
003459
003460
003461
003462
003463
003464
003465
003466
003467
003468
003469
003470
003471
003472
003473
003474
003475
003476
003477
003478
003479
003480
003481
003482
003483
003484
003485
003486
003487
003488
003489
003490
003491
003492
003493
003494
003495
003496
003497
003498
003499

itsVisibility: BOOLEAN): TScrollBar};


VAR sbList:
TSbList;
hsb:
THSb;
firstBox:
TScroller;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TScrollBar(object);
InitSbList(sbList, POINTER(ORD(heap)));
hsb := SbCreate(sbList, hsbNil, vhs, zeroPt, 0);
PostSbList(sbList, SELF);
firstBox := TScroller.CREATE(NIL, heap, SELF, ORD(hsb));
SELF.firstBox := firstBox;
SELF.ChangeVisibility(itsVisibility, outerRect, []);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}

{The band's outerRect}

{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE {TScrollBar.}Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN
Field('firstBox: TScroller');
Field('isVisible: BOOLEAN');
Field('');
END;
{$S SgABCres}
{$ENDC}
{$S sCldInit}
PROCEDURE {TScrollBar.}ChangeVisibility{(needsBothBars: BOOLEAN;
bandOuterRect: Rect; itsAbilities: TAbilities)};
VAR hsb:
THsb;
scroller:
TScroller;
needsThisBar:
BOOLEAN;
icons:
TSIcon;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
needsThisBar := needsBothBars OR (aBar IN itsAbilities);
SELF.isVisible := needsThisBar;
icons := [];
IF needsThisBar THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 343 of 1012

Apple Lisa Computer Technical Information


003500
003501
003502
003503
003504
003505
003506
003507
003508
003509
003510
003511
003512
003513
003514
003515
003516
003517
003518
003519
003520
003521
003522
003523
003524
003525
003526
003527
003528
003529
003530
003531
003532
003533
003534
003535
003536
003537
003538
003539
003540
003541
003542
003543
003544
003545
003546
003547

BEGIN {if no bar, then no icons}


IF aScroll IN itsAbilities THEN
icons := icons + [iconArwA, iconArwB, iconThumb, iconPagA, iconPagB];
IF aSplit IN itsAbilities THEN
icons := icons + [iconSkewer];
END;
hsb := POINTER(SELF.firstBox.sBoxID);
WHILE hsb <> hsbNil DO
BEGIN
scroller := TScroller(RefconSb(hsb));
IF scroller.band <> NIL THEN
bandOuterRect := scroller.band.outerRect;
scroller.SetSize(bandOuterRect);
SetSbIcons(hsb, icons);
hsb := HsbNext(hsb);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sScroll}
FUNCTION {TScrollBar.}DownAt{(mousePt: Point; VAR scroller: TScroller; VAR icon: TEnumIcons): BOOLEAN};
TYPE TIconAlias =
RECORD
CASE INTEGER OF
1: (sblib: TIcon);
2: (abc:
TEnumIcons);
END;
VAR iconAlias:
TIconAlias;
hsbHit:
THSb;
sbList:
TSbList;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
DownAt := FALSE;
IF SELF.isVisible THEN
BEGIN
PreSbList(sbList, SELF);
{$H-} IF FSbHit(sbList, mousePt, hsbHit, iconAlias.sbLib) {$H+} THEN
BEGIN
DownAt := TRUE;
scroller := POINTER(RefconSb(hsbHit));
icon := iconAlias.abc;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 344 of 1012

Apple Lisa Computer Technical Information


003548
003549
003550
003551
003552
003553
003554
003555
003556
003557
003558
003559
003560
003561
003562
003563
003564
003565
003566
003567
003568
003569
003570
003571
003572
003573

{$S sStartup}
PROCEDURE {TScrollBar.}Draw;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.isVisible THEN
PaintSbar(POINTER(SELF.firstBox.sBoxID));
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE {TScrollBar.}Erase;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.isVisible THEN
EraseSBar(POINTER(SELF.firstBox.sBoxID));
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
END;
{$S SgABCres}
{$S SgABCini}

End of File -- Lines: 3573 Characters: 114796

Apple Lisa ToolKit 3.0 Source Code Listing -- 345 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UDIALOG.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

(*

>>>>>>>>

U D I A L O G

<<<<<<<<

*)
{$SETC forOS := TRUE}
UNIT UDialog;
{04/25/84 0015
{04/23/84 1210

{Copyright 1984 by Apple Computer, Inc}


Added field TEditLegendSelection.tripleClick, and methods TEditLegendSelection.
MousePress, MouseMove, and MouseRelease}
Removed all references to 'underEdit' field of TDialogImage}

{$Setc IsIntrinsic := TRUE }


{$IFC IsIntrinsic}
INTRINSIC;
{$ENDC}
INTERFACE
USES
{$U libtk/UObject}
UObject,
{$IFC LibraryVersion <= 20}
{$U UFont}
UFont,
{$ENDC}
{$U QuickDraw}
QuickDraw,
{$U libtk/UDraw}
UDraw,
{$U libtk/UABC}
{$U libtk/UUnivText}
{$U libtk/UText}
CONST
UDialogVersion
(*

UABC,
UTKUniversalText,
UText;

= 'UDialog 25Apr84 16:30';


-----

Dialog Building Block for the ToolKit ------

The Dialog Building Block provides the following standard kinds of dialog Images:

Apple Lisa ToolKit 3.0 Source Code Listing -- 346 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

Button
Checkbox
Cluster
InputFrame
Legend

A
A
A
A
A

Lisa-style button (a round-cornered Rectangle for pushing, with text inside it)
checkbox (a box for checking, plus an optional associated textual label)
set of related checkboxes of which only one is selected at a time
place for keyboard input to be inhaled
character string, together with font & face information

TextDialogImage
PicObject

A box of text managed by the Text editor (largely untested)


A QuickDraw picture (never tested; probably not bankable; status uncertain)

The basic bankable dialog entity which can be stashed into/retrieved from a Resource File
is the class TDialog. For each different kind of dialog box you want, you will typically define
another subclass of TDialog.
To EDIT a dialog interactively, you must:
(1) Have the menu items 'Edit Dialog' and 'Stop Editing Dialog' in your phrase-file
(2) If the dialog is viewed in your main window rather than in a dialog box, (such as Preferences)
then your own main Window.CanDoCmd should enable uEditDialog whenever the dialog to be editted
is unambiguously selected in the window and there is not a dialog box up; in this
case, the dialog editting takes place in a dialog box whereas the dialog itself resides
in the main window.
CAUTION: Until Resource Files are incoporated, the edits to a dialog are local to the document
in which you made the edits, as well as documents made from a stationery pad made from
that document.
How to have your own view be a subclass of TDialogView, and still do all of its normal View things,
while having the Dialog Building Block handle everything that occurs which is relevant to
its dialogs:
(a) To draw the non-dialog parts of the view, implement method TDialogView.XDraw
(b) To set the cursor in the non-dialog parts of the view, implement method TDialogView.XCursorAt
(c) Implement XMousePress, XMouseMove, and XMouseRelease instead of their non-x counterparts
*)
TYPE
S4 = STRING[4];
TId = STRING[IDLength];
TButtonMetrics =
RECORD
height:
curvH:
curvV:

INTEGER;
INTEGER;
INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 347 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

typeStyle:

TTypeStyle;

expandNum:
expandDen:

INTEGER;
INTEGER;

{a button's min width is its text's with times this numerator}


{
... divided by this denominator}

INTEGER;
PenState;

{for drawing the round-rect}

absMinWidth:
penState:
END;
TStringKey =

RECORD
trueKey:
key:
END;

{Keys for Dialogs in Resource Files}


LONGINT;
S4;

{-------------------------------------------------------------------------------------------------------}
{ ********* CLASSES ********* }
{ -------------------------------- classes implemented in file UDialog2 ------------------------------- }
TDialogWindow = SUBCLASS of TDialogBox
controlPanel:
dialogView:
mainDialog:

TPanel;
TDialogView;
TDialog;

{which itself is in UABC}

{One with a dialogView in it; may be told to push its dflt button}
{the view installed in SELF.controlPanel}
{the first dialog installed in SELF.dialogView}

{Creation/Destruction}
FUNCTION TDialogWindow.CREATE(object: TObject; heap: THeap; itsResizability: BOOLEAN;
itsHeight: INTEGER; itsKeyResponse, itsMenuResponse, itsDownInMainWindowResponse: TDiResponse)
: TDialogWindow;
{Showing and Hiding}
PROCEDURE TDialogWindow.Appear; OVERRIDE;
PROCEDURE TDialogWindow.BeDismissed; OVERRIDE;
FUNCTION TDialogWindow.CanDoCommand(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN): BOOLEAN;
PROCEDURE TDialogWindow.Disappear; OVERRIDE;

OVERRIDE;

{Commands}
FUNCTION TDialogWindow.NewCommand(cmdNumber: TCmdNumber): TCommand; OVERRIDE;
END;

{TDialogWindow interface}

{-------------------------------------------------------------------------------------------------------}

Apple Lisa ToolKit 3.0 Source Code Listing -- 348 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

TDialogView = SUBCLASS OF TView

{a view which contains dialog images as well as, possibly, other things}

rootDialog:

TDialog;

{The children of this object are the constituent Dialogs of this view}

nonDialogExtent:

LRect;

{intinsic overall extent, dialog + non-dialog actually}

currentDialogImage: TDialogImage; {which descendent owns the mouse during drag}


defaultButton:
hitButton:
isShowing:

TButton;
TButton;
BOOLEAN;

{which if any button is the default}


{which Button was last chosen}
{used to suppress meaningless screen actions for not-yet-showing box}

paintFreeBoxes:
paintSense:
startedPainting:

BOOLEAN;
BOOLEAN;
BOOLEAN;

{whether free-checkboxes are to be painted in one sense only}


{ ... and if so, in which sense }
{whether we've begun to paint and hence established paintSense}

styleSheet:

TStyleSheet; {for use by text images seen in the view}

mouseIsDown:
magnetCursor:

BOOLEAN;
TCursorNumber; {to force CursorAt to return this value until mouseIsDown is FALSE}

{ *** Public Interface *** }


{Creation/Destruction}
FUNCTION TDialogView.CREATE(object: TObject; heap: THeap; itsExtentLRect: LRect; itsPanel: TPanel;
itsPrintManager: TPrintManager; itsRes: Point): TDialogView;
PROCEDURE TDialogView.Free; OVERRIDE;
{Installing, Removing, Activating, Deactivating dialogs}
PROCEDURE TDialogView.AddDialog(dialog: TDialog);
FUNCTION TDialogView.AddNewDialog(itsKey: S4): TDialog;
PROCEDURE TDialogView.ActivateDialog(dialog: TDialog; whichWay: BOOLEAN);
PROCEDURE TDialogView.RemoveDialog(dialog: TDialog; andFree: BOOLEAN);
PROCEDURE TDialogView.ReplaceDialog(oldDialog, newDialog: TDialog);
{Methods which client should redefine to get a dialogView also to have non-dialog behaviour}
FUNCTION TDialogView.XCursorAt(mouseLPt: LPoint): TCursorNumber; DEFAULT;
PROCEDURE TDialogView.XDraw; DEFAULT;
PROCEDURE TDialogView.XMousePress(mouseLPt: LPoint); DEFAULT;
PROCEDURE TDialogView.XMouseMove(mouseLPt: LPoint); DEFAULT;
PROCEDURE TDialogView.XMouseRelease; DEFAULT;
{Buttons and
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

checkboxes}
TDialogView.AbandonThatButton;
TDialogView.ButtonPushed(button: TButton);
{normally, TDialog's ButtonPushed is used}
TDialogView.CheckboxHit(checkbox: TCheckbox; toggleDirection: BOOLEAN);
TDialogView.PushButton(button: TButton);
{client or ToolKit may call}
TDialogView.SetDefaultButton(button: TButton);

Apple Lisa ToolKit 3.0 Source Code Listing -- 349 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

{NB:

PushButton sets the dialogView's hitButton to the requested button, assures that it
is highlighted, and then calls the client's ButtonPushed method of the TDialog which
is the parent of the button}

{ *** Private
FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
END;

Interface *** (Methods not expected to be redefined or called by client)}


TDialogView.CursorAt(mouseLPt: LPoint): TCursorNumber; OVERRIDE;
TDialogView.Draw; OVERRIDE;
TDialogView.EachActualPart(PROCEDURE DoToObject(filteredObj: TObject)); OVERRIDE;
TDialogView.MouseMove(mouseLPt: LPoint); OVERRIDE;
TDialogView.MousePress(mouseLPt: LPoint); OVERRIDE;
TDialogView.MouseRelease; OVERRIDE;
TDialogView.RecalcExtent; OVERRIDE;

{TDialogView interface}

{-------------------------------------------------------------------------------------------------------}
TDialogImage = SUBCLASS OF TImage
parent:
isActive:
isEditable:
withID:

TDialogImage;
BOOLEAN;
BOOLEAN;
BOOLEAN;

{Creation/destruction}
FUNCTION TDialogImage.CREATE(object: TObject; heap: THeap; itsExtent: LRect; itsId: S255;
itsView: TView; withChildren: BOOLEAN): TDialogImage;
PROCEDURE
FUNCTION
PROCEDURE
PROCEDURE
FUNCTION
PROCEDURE
PROCEDURE
FUNCTION

TDialogImage.ControlHit(control: TDialogImage; toggleDirection: BOOLEAN); DEFAULT;


TDialogImage.DownAt(mouseLPt: LPoint): TDialogImage; DEFAULT;
TDialogImage.Draw; OVERRIDE;
TDialogImage.DrawJustMe; {called by Draw after children, if any, are told to draw} DEFAULT;
TDialogImage.LaunchLayoutBox(view: TView): TImage; OVERRIDE;
TDialogImage.PrepareToAppear;
TDialogImage.RecalcExtent; OVERRIDE;
TDialogImage.StillMyMouse(mouseLPt: LPoint): BOOLEAN; DEFAULT;

{The following methods are stubs, redefined in TImageWithID}


PROCEDURE TDialogImage.AddImage(dialogImage: TDialogImage); DEFAULT;
PROCEDURE TDialogImage.ActivateImage(dialogImage: TDialogImage; whichWay: BOOLEAN); DEFAULT;
PROCEDURE TDialogImage.BringToFront(dialogImage: TDialogImage); DEFAULT;
PROCEDURE TDialogImage.ComeForward; DEFAULT;
PROCEDURE TDialogImage.DeleteImage(dialogImage: TDialogImage; andFree: BOOLEAN); DEFAULT;
PROCEDURE TDialogImage.EachActualPart(PROCEDURE DoToObject(filteredObj: TObject)); OVERRIDE;
FUNCTION TDialogImage.HasId(id: S255): BOOLEAN; DEFAULT;
FUNCTION TDialogImage.ObjectWithIDNumber(idNumber: INTEGER): TDialogImage; DEFAULT;
FUNCTION TDialogImage.ObjWithId(id: S255): TDialogImage; DEFAULT;

Apple Lisa ToolKit 3.0 Source Code Listing -- 350 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

PROCEDURE TDialogImage.ReplaceImage(replacee, newValue: TDialogImage); DEFAULT;


END;
TImageWithID = SUBCLASS OF TDialogImage
children:
id:
idNumber:

{same interface as TDialogImage, basically}

TList; {of TDialogImage}


TId;
INTEGER;

FUNCTION

TImageWithID.CREATE(object: TObject; heap: THeap; itsExtent: LRect; itsId: S255;


itsView: TView; withChildren: BOOLEAN): TImageWithID;
FUNCTION TImageWithID.Clone(heap: THeap): TObject;
OVERRIDE;
PROCEDURE TImageWithID.Free; OVERRIDE;
PROCEDURE
PROCEDURE
PROCEDURE
FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
FUNCTION
PROCEDURE
FUNCTION
FUNCTION
FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
FUNCTION

TImageWithID.AddImage(dialogImage: TDialogImage); OVERRIDE;


TImageWithID.ActivateImage(dialogImage: TDialogImage; whichWay: BOOLEAN); OVERRIDE;
TImageWithID.BringToFront(dialogImage: TDialogImage); OVERRIDE;
TImageWithID.CursorAt(mouseLPt: LPoint): TCursorNumber; OVERRIDE;
TImageWithID.DeleteImage(dialogImage: TDialogImage; andFree: BOOLEAN); OVERRIDE;
TImageWithID.Draw; OVERRIDE;
TImageWithID.EachActualPart(PROCEDURE DoToObject(filteredObj: TObject)); OVERRIDE;
TImageWithID.EachVirtualPart(PROCEDURE DoToObject(filteredObj: TObject)); OVERRIDE;
TImageWithID.HasId(id: S255): BOOLEAN; OVERRIDE;
TImageWithID.HaveView(view: TView); OVERRIDE;
TImageWithID.LaunchLayoutBox(view: TView): TImage; OVERRIDE;
TImageWithID.ObjectWithIDNumber(idNumber: INTEGER): TDialogImage; OVERRIDE;
TImageWithID.ObjWithId(id: S255): TDialogImage; OVERRIDE;
TImageWithID.OffSetBy(deltaLPt: LPoint); OVERRIDE;
TImageWithID.RecalcExtent;
OVERRIDE;
TImageWithID.ReplaceImage(replacee, newValue: TDialogImage); OVERRIDE;
TImageWithID.StillMyMouse(mouseLPt : LPoint): BOOLEAN; OVERRIDE;

END;
{-------------------------------------------------------------------------------------------------------}
TDialog = SUBCLASS OF TImageWithID
stringKey:

TStringKey;

{essentially a unique 4-character ID by which this dialog is known}

{Creation}
FUNCTION

TDialog.CREATE(object: TObject; heap: THeap; itsKey: S4; itsView: TView): TDialog;

{Creation of the basic dialog elements:}

Apple Lisa ToolKit 3.0 Source Code Listing -- 351 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

{Elements originating from phrase file; in each case, the text for the legend associated with the
component, if any, as well as a LOCATION for the component, are obtained from the same entry
in the phrase file, with the syntax
<text>@<h-coordinate>,<v-coordinate>
EXAMPLE:

Suppose the following 2 lines are in the Phrase File:

449
Next@430,50
If we call NewButton(449, ...), then a button is created, with the text 'Next' inside it;
the button is given idNumber 449, and is located at (430, 50)}
{***************************** PUBLIC INTERFACE -- USE THESE METHODS ************************************}
FUNCTION

TDialog.NewButton(itsPhrase: INTEGER; itsMetrics: TButtonMetrics; sameSizedButton: TButton;


itsCmdNumber: TCmdNumber): TButton;

FUNCTION

TDialog.NewCluster(itsPhrase: INTEGER): TCluster;

FUNCTION TDialog.NewFreeCheckbox(itsPhrase: INTEGER; boxWidth: INTEGER;


boxHeight: INTEGER; wantLabel: BOOLEAN; labelOffset: Point; itsTypeStyle: TTypeStyle): TCheckBox;
FUNCTION TDialog.NewInputFrame(itsPhrase: INTEGER; promptTypeStyle: TTypeStyle;
inputOffset: Point; inputTypeStyle: TTypeStyle;
maxInputChars: INTEGER; itsBorders: Rect; drawInputLRect: BOOLEAN;
drawHitLRect: BOOLEAN): TInputFrame;
FUNCTION

TDialog.NewLegend(itsPhrase: INTEGER; itsTypeStyle: TTypeStyle): TLegend;

FUNCTION TDialog.NewRowOfBoxes(itsPhrase: INTEGER; numberOfBoxes: INTEGER;


startingIDNumber: INTEGER; boxWidth: INTEGER; boxHeight: INTEGER; boxSpacing: INTEGER): TCluster;
{controls}
PROCEDURE TDialog.ButtonPushed(button: TButton); DEFAULT; {client overrides often}
PROCEDURE TDialog.CheckboxHit(checkbox: TCheckbox; toggleDirection: BOOLEAN); DEFAULT;
{client overrides sometimes}
PROCEDURE TDialog.ControlHit(control: TDialogImage; toggleDirection: BOOLEAN); OVERRIDE;
PROCEDURE TDialog.PushButton(button: TButton);
{client or ToolKit may call}
PROCEDURE TDialog.SelectInputFrame(inputFrame: TInputFrame);
PROCEDURE TDialog.SetDefaultButton(button: TButton);
{************************************** PRIVATE INTERFACE **********************************************}
{These methods of TDialog are largely either for internal use of the building block, or maintained for

Apple Lisa ToolKit 3.0 Source Code Listing -- 352 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

backward compatability with earlier versions of the dialog building block}


{"Standard" elements:}
FUNCTION TDialog.AddStdButton(itsId: S255; itsXLoc, itsYLoc: LONGINT; sameSizedButton: TButton;
itsCmdNumber: TCmdNumber): TButton;
PROCEDURE TDialog.AddOKButton(cmdNumber: TCmdNumber);
{OK Button}
PROCEDURE TDialog.AddCancelButton(cmdNumber: TCmdNumber); {Cancel Button}
FUNCTION TDialog.AddStdCluster(itsId: S255; itsXLoc, itsYLoc: LONGINT): TCluster;
FUNCTION TDialog.AddStdFreeCheckbox(itsId: S255; itsXLoc, itsYLoc: LONGINT): TCheckBox;
FUNCTION TDialog.AddStdInputFrame(itsId: S255; itsXLoc: LONGINT;
itsYLoc: LONGINT; maxInputChars : INTEGER): TInputFrame;
FUNCTION TDialog.AddStdLegend(itsId: S255; itsXLoc, itsYLoc: LONGINT;
itsTypeStyle: TTypeStyle): TLegend;
FUNCTION TDialog.AddSysLegend(itsId: S255; itsXLoc, itsYLoc: LONGINT): TLegend;
{General creation of dialogImages}
FUNCTION TDialog.AddButton(itsId: S255; itsLocation: LPoint; itsMetrics: TButtonMetrics;
sameSizedButton: TButton; itsCmdNumber: TCmdNumber): TButton;
FUNCTION TDialog.AddFreeCheckbox(itsID: S255; itsXLoc, itsYLoc: LONGINT; boxWidth: INTEGER;
boxHeight: INTEGER; wantLabel: BOOLEAN; labelOffset: Point; itsTypeStyle: TTypeStyle): TCheckbox;
FUNCTION

TDialog.AddBigFreeCheckbox(itsId: S255; itsXLoc, itsYLoc: LONGINT): TCheckbox;

FUNCTION TDialog.AddRowOfBoxes(itsID: S255; itsXLoc, itsYLoc: LONGINT; numberOfBoxes: INTEGER;


startingIDNumber: INTEGER; boxWidth: INTEGER; boxHeight: INTEGER; boxSpacing: INTEGER): TCluster;
FUNCTION TDialog.AddInputFrame(itsId: S255;
promptLocation: LPoint; promptTypeStyle: TTypeStyle;
inputLocation: LPoint; inputTypeStyle: TTypeStyle;
maxInputChars: INTEGER; itsBorders: Rect; drawInputLRect: BOOLEAN;
drawHitLRect: BOOLEAN): TInputFrame;
FUNCTION TDialog.DownAt(mouseLPt: LPoint): TDialogImage; OVERRIDE;
PROCEDURE TDialog.RecalcExtent; OVERRIDE;
END;
{-------------------------------------------------------------------------------------------------------}
TButton = SUBCLASS OF TImageWithID
cmdNumber:
minWidth:
isHighlighted:
nextSameSizedButton:

TCmdNumber;
INTEGER;
BOOLEAN;
TButton;

Apple Lisa ToolKit 3.0 Source Code Listing -- 353 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

legend:
buttonMetrics:

TLegend;
TButtonMetrics;

{Creation/Destruction}
FUNCTION TButton.CREATE(object: TObject; heap: THeap; itsId: S255; itsView: TView;
itsLocation: LPoint; itsMetrics: TButtonMetrics; sameSizedButton: TButton;
itsCmdNumber: TCmdNumber): TButton;
PROCEDURE
PROCEDURE
FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
FUNCTION

TButton.DrawJustMe; OVERRIDE;
TButton.Highlight(highTransit: THighTransit);
TButton.LaunchLayoutBox(view: TView): TImage; OVERRIDE;
TButton.MousePress(mouseLPt: LPoint); OVERRIDE;
TButton.MouseRelease; OVERRIDE;
TButton.RecalcExtent; OVERRIDE;
TButton.Recompute(minWidth: INTEGER);
TButton.StillMyMouse(mouseLPt: LPoint): BOOLEAN; OVERRIDE;

END; {TButton interface}


{-------------------------------------------------------------------------------------------------------}
TCheckbox = SUBCLASS of TImageWithID
isSelected:

BOOLEAN;

rectImage:
legend:

TRectImage;
TLegend;

{also a child}
{if nonnil, also a child}

FUNCTION TCheckbox.CREATE(object: TObject; heap: THeap; itsId: S255; itsView: TView;


itsLocation: LPoint; boxWidth: INTEGER; boxHeight: INTEGER; wantLabel: BOOLEAN;
labelOffset: Point; itsTypeStyle: TTypeStyle): TCheckbox;
PROCEDURE
FUNCTION
PROCEDURE
FUNCTION
PROCEDURE
PROCEDURE
END;

TCheckbox.ChangeLabel(newS255: S255);
TCheckbox.CursorAt(mouseLPt: LPoint): TCursorNumber; OVERRIDE;
TCheckbox.Draw; OVERRIDE;
TCheckbox.LaunchLayoutBox(view: TView): TImage; OVERRIDE;
TCheckbox.MousePress(mouseLPt: LPoint); OVERRIDE;
TCheckbox.Toggle;

{TCheckbox interface}

{-------------------------------------------------------------------------------------------------------}
TCluster = SUBCLASS of TImageWithID
{children:

TList;

location:

LPoint;

(of TCheckbox) }
{only used for adding the first aligned checkbox}

Apple Lisa ToolKit 3.0 Source Code Listing -- 354 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

hitBox:
hiLitBox:
lastBox:
FUNCTION
{******
******
******
******
******
******

TCheckbox;
TCheckbox;
TCheckBox;

{which one was just successfully queried by Hit}


{which one is highlighted}
{the checkbox most recently added checkbox}

TCluster.CREATE(object: TObject; heap: THeap; itsId: S255; itsView: TView;


itsLocation : LPoint): TCluster;

PUBLIC INTERFACE:
Create a cluster using TDialog.NewCluster; add checkboxes to it by calling any of the following
three methods. To change which box is selected in the cluster programmatically, call SelectBox
To find out which box is selected in a cluster, look at cluster.hiLitBox.idNumber}

FUNCTION
FUNCTION

TCluster.NewAlignedCheckbox(itsPhrase: INTEGER; selectThisOne: BOOLEAN): TCheckbox;


TCluster.NewCheckbox(itsPhrase: INTEGER; boxWidth: INTEGER;
boxHeight: INTEGER; wantLabel: BOOLEAN; labelOffset: Point; itsTypeStyle: TTypeStyle;
selectThisOne: BOOLEAN): TCheckbox;
PROCEDURE TCluster.AddRowOfBoxes(numberOfBoxes: INTEGER; startingIDNumber: INTEGER;
boxWidth: INTEGER; boxHeight: INTEGER; boxSpacing: INTEGER);
PROCEDURE TCluster.SelectBox(checkbox: TCheckbox); {select this box, deselecting others}
{****** PRIVATE INTERFACE:
******
****** These remaining methods of TCluster are for primarily for internal use:}
FUNCTION
FUNCTION

TCluster.AddAlignedCheckbox(itsId: S255; selectThisOne: BOOLEAN): TCheckbox;


TCluster.AddCheckbox(itsID: S255; itsLocation: LPoint; boxWidth: INTEGER;
boxHeight: INTEGER; wantLabel: BOOLEAN; labelOffset: Point; itsTypeStyle: TTypeStyle;
selectThisOne: BOOLEAN): TCheckbox;
FUNCTION TCluster.Hit(mouseLPt: LPoint): BOOLEAN; OVERRIDE;
PROCEDURE TCluster.MousePress(mouseLPt: LPoint); OVERRIDE;
FUNCTION TCluster.StillMyMouse(mouseLPt: LPoint): BOOLEAN; OVERRIDE;
END; {TCluster interface}
{-------------------------------------------------------------------------------------------------------}
TInputFrame = SUBCLASS OF TImageWithID
textDialogImage:
prompt:

TTextDialogImage;
TLegend;

borders:

Rect;

drawInputLRect:

BOOLEAN;

{whether or not to draw a faint box around the input LRect}

Apple Lisa ToolKit 3.0 Source Code Listing -- 355 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

drawHitLRect:
maxInputChars:
inputTypeStyle:

BOOLEAN; {whether or not to frame the hit rectangle}


INTEGER;
TTypeStyle;

FUNCTION TInputFrame.CREATE(object: TObject; heap: THeap; itsId: S255; itsView: TView;


promptLocation: LPoint; promptTypeStyle: TTypeStyle;
inputLocation: LPoint; inputTypeStyle: TTypeStyle; maxInputChars: INTEGER;
itsBorders: Rect; drawInputLRect: BOOLEAN; drawHitLRect: BOOLEAN
): TInputFrame;
{ *********************************************** PUBLIC INTERFACE **************************************** }
{Create an input frame by calling TDialog.NewInputFrame; use GetContents and SupplantContents
to find out what has been typed, and to change what appears in the typing area}
PROCEDURE TInputFrame.GetContents(VAR theStr: S255);
PROCEDURE TInputFrame.SupplantContents(newStr: S255);

{inspect current frame contents}


{change current frame contents}

{ ********************************************** PRIVATE INTERFACE **************************************** }


FUNCTION
PROCEDURE
FUNCTION
PROCEDURE
PROCEDURE
FUNCTION
END;

TInputFrame.CursorAt(mouseLPt: LPoint): TCursorNumber; OVERRIDE;


TInputFrame.Draw; OVERRIDE;
TInputFrame.LaunchLayoutBox(view: TView): TImage; OVERRIDE;
TInputFrame.MousePress(mouseLPt: LPoint); OVERRIDE;
TInputFrame.RecalcExtent; OVERRIDE;
TInputFrame.StillMyMouse(mouseLPt: LPoint): BOOLEAN; OVERRIDE;

{TInputFrame interface}

{-------------------------------------------------------------------------------------------------------}
TLegend = SUBCLASS OF TDialogImage
location:
paragraph:
wouldBeDraggable:
usesSysFont:

LPoint;
TParagraph;
BOOLEAN;
BOOLEAN;

{whether, during layout, it should itself be draggable}


{whether it is in system font -- a special case}

FUNCTION TLegend.CREATE(object: TObject; heap: THeap; itsChars: S255; itsView: TView;


itsLocation: LPoint; itsTypeStyle: TTypeStyle): TLegend;
PROCEDURE TLegend.Free; OVERRIDE;
{ *********************************************** PUBLIC INTERFACE **************************************** }
PROCEDURE TLegend.ChangeToPhrase(newPhrase: INTEGER); {for getting new text from phrase file}
PROCEDURE TLegend.ChangeString(newString: S255);
{for getting new text from a string}
PROCEDURE TLegend.GetString(VAR itsString: S255); {determine current chars residing in the legend}

Apple Lisa ToolKit 3.0 Source Code Listing -- 356 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

{ ********************************************** PRIVATE INTERFACE **************************************** }


PROCEDURE TLegend.Draw; OVERRIDE;
PROCEDURE TLegend.GetBoxRight;
{sets extent based on current chars & location}
FUNCTION TLegend.LaunchLayoutBox(view: TView): TImage; OVERRIDE;
PROCEDURE TLegend.OffsetBy(deltaLPt: LPoint); OVERRIDE;
PROCEDURE TLegend.RecalcExtent; OVERRIDE;
END;
{ ------------------------------- classes implemented in file UDialog3 -------------------------------}

TPicObject = SUBCLASS OF TImageWithID {An Object which holds a QD Picture File} {CAUTION: totally untested}
picture:
boxAtCreation:

PicHandle;
Rect;
{need to get itsView parameter into all these guys}

FUNCTION TPicObject.CREATE(object: TObject; heap: THeap; itsId: S255;


itsView: TView; itsLocation: LPoint; itsPicHandle: PicHandle): TPicObject;
PROCEDURE TPicObject.Free; OVERRIDE;
PROCEDURE TPicObject.Draw; OVERRIDE;
END;
{-------------------------------------------------------------------------------------------------------}
TRectImage = SUBCLASS OF TDialogImage

{a rectangle packaged as a object}

penState: PenState;
FUNCTION TRectImage.CREATE(object: TObject; heap: THeap; itsExtent: LRect; itsId: S255;
itsView: TView; itsPenState: PenState; withChildren: BOOLEAN): TRectImage;
PROCEDURE TRectImage.Draw; OVERRIDE;
FUNCTION TRectImage.LaunchLayoutBox(view: TView): TImage; OVERRIDE;
END;
{-------------------------------------------------------------------------------------------------------}
TTextDialogImage = SUBCLASS OF TImageWithID
textImage:
wouldBeDraggable:
refCount:

TTextImage;
BOOLEAN;
INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 357 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

FUNCTION

TTextDialogImage.CREATE(object: TObject; heap: THeap; itsExtent: LRect; itsId: S255;


itsView: TView; itsTypeStyle: TTypeStyle;
itsInitialChars: S255): TTextDialogImage;
PROCEDURE TTextDialogImage.Free; OVERRIDE;
PROCEDURE
FUNCTION
PROCEDURE
FUNCTION
PROCEDURE
PROCEDURE
END;

TTextDialogImage.ChangeRefCountBy(delta: INTEGER);
TTextDialogImage.CursorAt(mouseLPt: LPoint): TCursorNumber; OVERRIDE;
TTextDialogImage.Draw; OVERRIDE;
TTextDialogImage.LaunchLayoutBox(view: TView): TImage; OVERRIDE;
TTextDialogImage.MousePress(mouseLPt: LPoint); OVERRIDE;
TTextDialogImage.OffsetBy(deltaLPt: LPoint); OVERRIDE;

{-------------------------------------------------------------------------------------------------------}
TFrameSelection = SUBCLASS OF TSelection
inputFrame: TInputFrame;

{the phony selection covering TextSelection in an input frame}

{the input frame in which the selection occurs}

FUNCTION

TFrameSelection.CREATE(object: TObject; heap: THeap; itsInputFrame: TInputFrame)


: TFrameSelection;

FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

TFrameSelection.CanDoCommand(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN): BOOLEAN; OVERRIDE;


TFrameSelection.KeyChar(ch: CHAR); OVERRIDE;
TFrameSelection.KeyEnter(dh, dv: INTEGER); OVERRIDE;
TFrameSelection.KeyReturn; OVERRIDE;
TFrameSelection.KeyTab(fBackward: BOOLEAN); OVERRIDE;
TFrameSelection.MousePress(mouseLPt: LPoint); OVERRIDE;
TFrameSelection.PerformCommand(command: TCommand; cmdPhase: TCmdPhase); OVERRIDE;
TFrameSelection.Restore; OVERRIDE;

END;

{TFrameSelection interface}

TPlannerView = SUBCLASS OF TDialogView

{a view within which images are laid out}

{Variables}
viewBeingPlanned:

TView;

allowSketching:
retainPickedBox:
currentLayoutBox:

BOOLEAN;
{for internal use of the layout mechanism}
BOOLEAN;
TLayoutBox;

{Creation/Destruction}
FUNCTION TPlannerView.CREATE(object: TObject; heap: THeap; itsViewBeingPlanned: TView;
itsPanel: TPanel; itsAllowSketching: BOOLEAN; itsRetainPickedBox: BOOLEAN): TPlannerView;

Apple Lisa ToolKit 3.0 Source Code Listing -- 358 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

PROCEDURE TPlannerView.Init(itsListOfImages: TList);


FUNCTION TPlannerView.NewLayoutBox(image: TImage): TLayoutBox; {return NIL if element not to be shown}
PROCEDURE TPlannerView.Free; OVERRIDE;
{Display}
PROCEDURE TPlannerView.Draw; OVERRIDE;
{Mouse Tracking}
FUNCTION TPlannerView.CursorAt(mouseLPt: LPoint): TCursorNumber; OVERRIDE;
PROCEDURE TPlannerView.MouseMove(mouseLPt: LPoint); OVERRIDE;
PROCEDURE TPlannerView.MousePress(mouseLPt: LPoint); OVERRIDE;
PROCEDURE TPlannerView.MouseRelease; OVERRIDE;
{Enumeration of components}
PROCEDURE TPlannerView.EachActualPart(PROCEDURE DoToObject(filteredObj: TObject)); OVERRIDE;
END;
{-------------------------------------------------------------------------------------------------------}
TLayoutBox = SUBCLASS OF TImageWithID
{Variables}
manipulee:
titleTab:

TImage;
TTitleTab;

suppressDrawingManipulee:

BOOLEAN;

isResizable:
borders:
wouldMakeSelection:

BOOLEAN;
Rect;
BOOLEAN;

isDraggable:
shouldFrame:

BOOLEAN;
BOOLEAN;

hasDraggee:

BOOLEAN;

{client must directly set if not wanting default 'FALSE'}

{Creation/Destruction}
FUNCTION TLayoutBox.CREATE(object: TObject; heap: THeap; baseExtent: LRect; itsID: S255;
itsParent: TLayoutBox; itsView: TView; itsManipulee: TImage; itsBorders: Rect;
itsResizable: BOOLEAN; itsSuppression: BOOLEAN; withChildren: BOOLEAN): TLayoutBox;
PROCEDURE TLayoutBox.Free; OVERRIDE;
{Change and Display}
PROCEDURE TLayoutBox.ChangeDragState(enteringDrag: BOOLEAN);
PROCEDURE TLayoutBox.ConsiderMouse(mouseLPt: LPoint; VAR madeSelection: BOOLEAN;

Apple Lisa ToolKit 3.0 Source Code Listing -- 359 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

VAR pickedLayoutBox: TLayoutBox); DEFAULT;


TLayoutBox.CursorAt(mouseLPt: LPoint): TCursorNumber; OVERRIDE;
TLayoutBox.Draw; OVERRIDE;
TLayoutBox.DrawJustMe; OVERRIDE;
TLayoutBox.FreeManipulee;
TLayoutBox.Highlight(highTransit: THighTransit);
TLayoutBox.MousePress(mouseLPT: LPoint); OVERRIDE;
TLayoutBox.Move(deltaLPt: LPoint); DEFAULT;
TLayoutBox.NoTitleTab(heap: THeap): TTitleTab;
TLayoutBox.OffsetBy(deltaLPt: LPoint); OVERRIDE;
TLayoutBox.OffsetLayoutBoxBy(deltaLPt: LPoint; textImageAsWell: BOOLEAN); DEFAULT;
TLayoutBox.RecalcExtent; OVERRIDE;
TLayoutBox.Resize(newExtent: LRect); OVERRIDE;
TLayoutBox.TabGrabbed; DEFAULT;

END;
TLegendLayoutBox = SUBCLASS OF TLayoutBox
textDialogImage:

{manipulee is a TLegend}

TTextDialogImage;

{Creation/Destruction}
FUNCTION TLegendLayoutBox.CREATE(object: TObject; heap: THeap; itsView: TView; itsLegend: TLegend
): TLegendLayoutBox;
FUNCTION TLegendLayoutBox.CursorAt(mouseLPt: LPoint): TCursorNumber; OVERRIDE;
PROCEDURE TLegendLayoutBox.Draw; OVERRIDE;
PROCEDURE TLegendLayoutBox.OffsetBy(deltaLPt: LPoint); OVERRIDE;
PROCEDURE TLegendLayoutBox.OffsetLayoutBoxBy(deltaLPt: LPoint; textImageAsWell: BOOLEAN); OVERRIDE;
{use of the second argument is strange and non self-explanatory; comments in the internal
documentation may help. Nobody should be calling this old boy from outside, anyway}
PROCEDURE TLegendLayoutBox.MousePress(mouseLPT: LPoint); OVERRIDE;
PROCEDURE TLegendLayoutBox.RecalcExtent; OVERRIDE;
END;
TButtonLayoutBox = SUBCLASS OF TLayoutBox
{Variables}
nextSameSizedBox:
oldLegendTopLeft:

{manipulee is a TButton}

TButtonLayoutBox;
LPoint;

{Creation/Destruction}
FUNCTION TButtonLayoutBox.CREATE(object: TObject; heap: THeap; itsButton: TButton;
itsView: TView): TButtonLayoutBox;
{Other Methods}

Apple Lisa ToolKit 3.0 Source Code Listing -- 360 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

PROCEDURE TButtonLayoutBox.ConsiderMouse(mouseLPt: LPoint; VAR madeSelection: BOOLEAN;


VAR pickedLayoutBox: TLayoutBox); OVERRIDE;
FUNCTION TButtonLayoutBox.CursorAt(mouseLPt: LPoint): TCursorNumber; OVERRIDE;
PROCEDURE TButtonLayoutBox.DrawJustMe; OVERRIDE;
PROCEDURE TButtonLayoutBox.OffsetBy(deltaLPt: LPoint); OVERRIDE;
PROCEDURE TButtonLayoutBox.RecalcExtent; OVERRIDE;
PROCEDURE TButtonLayoutBox.RecalcJustMe;
END;
TTitleTab = SUBCLASS OF TImage
layoutBox:
legend:
shouldDrawLegend:

TLayoutBox;
TLegend;
BOOLEAN; {FALSE if string is too wide to fit}

FUNCTION TTitleTab.CREATE(object: TObject; heap: THeap; itsLayoutBox: TLayoutBox; itsHeight: INTEGER;


itsCaption: S255): TTitleTab;
PROCEDURE TTitleTab.Free; OVERRIDE;
PROCEDURE TTitleTab.Draw; OVERRIDE;
PROCEDURE TTitleTab.OffsetBy(deltaLPt: LPoint); OVERRIDE;
PROCEDURE TTitleTab.Resize(newExtent: LRect); OVERRIDE;
END;
TLayPickSelection = SUBCLASS OF TSelection
{Variables}
layoutBox:

TLayoutBox;

FUNCTION

TLayPickSelection.CREATE(object: TObject; heap: THeap; itsView: TPlannerView;


itsKind: INTEGER; itsLayoutBox: TLayoutBox; itsAnchorLPt: LPoint): TLayPickSelection;

FUNCTION

TLayPickSelection.CanDoCommand(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN)


: BOOLEAN; OVERRIDE;
TLayPickSelection.Deselect; OVERRIDE;
TLayPickSelection.Highlight(highTransit: THighTransit); OVERRIDE;
TLayPickSelection.KeyClear; OVERRIDE;
TLayPickSelection.MouseMove(mouseLPt: LPoint); OVERRIDE;
TLayPickSelection.MouseRelease; OVERRIDE;
TLayPickSelection.Restore; OVERRIDE;

PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
END;

TLayMoveCmd = SUBCLASS OF TCommand

Apple Lisa ToolKit 3.0 Source Code Listing -- 361 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

{Variables}
layoutBox:
hOffset:
vOffset:
{Creation}
FUNCTION

TLayoutBox;
LONGINT;
LONGINT;

TLayMoveCmd.CREATE(object: TObject; heap: THeap; itsLayoutBox: TLayoutBox;


itsHOffset, itsVOffset: LONGINT): TLayMoveCmd;

{Command Execution}
PROCEDURE TLayMoveCmd.Perform(cmdPhase: TCmdPhase); OVERRIDE;
END;
TEditLegendSelection = SUBCLASS OF TSelection
{Variables}
legendLayoutBox:
hostLegend:
textDialogImage:
suppressHost:
tripleClick:

TLegendLayoutBox;
TLegend;
TTextDialogImage;
BOOLEAN;
BOOLEAN; {+SW+}

{Creation/Destruction}
FUNCTION TEditLegendSelection.CREATE(object: TObject; heap: THeap; itsLegendLayoutBox:
TLegendLayoutBox; itsAnchorLPt: LPoint): TEditLegendSelection;
FUNCTION TEditLegendSelection.Clone(heap: THeap): TObject; OVERRIDE;
PROCEDURE TEditLegendSelection.Deselect; OVERRIDE;
PROCEDURE TEditLegendSelection.Free; OVERRIDE;
{Udders}
FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE

TEditLegendSelection.CanDoCommand(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN)


: BOOLEAN; OVERRIDE;
TEditLegendSelection.KeyBack(fWord: BOOLEAN); OVERRIDE;
TEditLegendSelection.KeyChar(ch: CHAR); OVERRIDE;
TEditLegendSelection.KeyEnter(dh, dv: INTEGER); OVERRIDE;
TEditLegendSelection.KeyReturn; OVERRIDE;
TEditLegendSelection.MouseMove(mouseLPt: LPoint); OVERRIDE; {+SW+}
TEditLegendSelection.MousePress(mouseLPt: LPoint); OVERRIDE; {+SW+}
TEditLegendSelection.MouseRelease; OVERRIDE; {+SW+}
TEditLegendSelection.NewCommand(cmdNumber: TCmdNumber): TCommand; OVERRIDE;
TEditLegendSelection.PerformCommand(command: TCommand; cmdPhase: TCmdPhase); OVERRIDE;
TEditLegendSelection.Restore; OVERRIDE;
TEditLegendSelection.Reveal(asMuchAsPossible: BOOLEAN); OVERRIDE;

END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 362 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

TDialogDesignWindow = SUBCLASS OF TDialogWindow


hostWindow:
hostDialogView:
fromDialogBox:
FUNCTION

TWindow;
TDialogView;
BOOLEAN;

TDialogDesignWindow.CREATE(object: TObject; heap: THeap;


itsHostDialogView: TDialogView): TDialogDesignWindow;

FUNCTION

TDialogDesignWindow.CanDoCommand(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN)


: BOOLEAN; OVERRIDE;
FUNCTION TDialogDesignWindow.NewCommand(cmdNumber: TCmdNumber): TCommand; OVERRIDE;
PROCEDURE TDialogDesignWindow.RelinquishControl;
PROCEDURE TDialogDesignWindow.Resize(moving: BOOLEAN); OVERRIDE;
PROCEDURE TDialogDesignWindow.SeizeControl;
END;

{ ------------------------------- classes implemented in file UDialog4 -------------------------------}


TStdPrintManager = SUBCLASS OF TPrintManager
FUNCTION

TStdPrintManager.CREATE(object: TObject; heap: THeap): TStdPrintManager;

PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

TStdPrintManager.EnterPageEditting; OVERRIDE;
TStdPrintManager.Init(itsMainView: TView; itsDfltMargins: LRect); OVERRIDE;
TStdPrintManager.ReactToPrinterChange; OVERRIDE;
TStdPrintManager.SetDfltHeadings; OVERRIDE;

END;
TLegendHeading = SUBCLASS OF THeading
masterLegend:
currentLegend:

TLegend;
TLegend;

topToBaseline:
borders:

INTEGER; {offset from box top to baseline}


Rect;
{size by which box exceeds legend's extent}

{Creation/Destruction}
FUNCTION TLegendHeading.CREATE(object: TObject; heap: THeap; itsPrintManager: TPrintManager;
itsString: S255; itsTypeStyle: TTypeStyle;
itsPageAlignment: TPageAlignment; itsOffsetFromAlignment: LPoint;

Apple Lisa ToolKit 3.0 Source Code Listing -- 363 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

itsBorders: Rect): TLegendHeading;


PROCEDURE TLegendHeading.Free; OVERRIDE;
{Nyingine}
PROCEDURE
PROCEDURE
FUNCTION
PROCEDURE
PROCEDURE
FUNCTION

TLegendHeading.AdjustForPage(pageNumber: LONGINT; editing: BOOLEAN); OVERRIDE;


TLegendHeading.Draw; OVERRIDE;
TLegendHeading.LaunchLayoutBox(view: TView): TImage; OVERRIDE;
TLegendHeading.OffsetBy(deltaLPt: LPoint); OVERRIDE;
TLegendHeading.RecalcExtent; OVERRIDE;
TLegendHeading.ShouldFrame: BOOLEAN; OVERRIDE;

END;
TPageDesignWindow = SUBCLASS OF TDialogWindow
hostView:
layoutPanel:
FUNCTION

TView; {the view whose pages are being designed in this dialog}
TPanel; {my controlPanel is the status panel}

TPageDesignWindow.CREATE(object: TObject; heap: THeap; itsHostView: TView): TPageDesignWindow;

PROCEDURE TPageDesignWindow.Disappear; OVERRIDE;


FUNCTION TPageDesignWindow.NewCommand(cmdNumber: TCmdNumber): TCommand;

OVERRIDE;

END;
TPagePlannerView = SUBCLASS OF TPlannerView
FUNCTION TPagePlannerView.CREATE(object: TObject; heap: THeap; itsPrintManager: TPrintManager;
itsPanel: TPanel): TPagePlannerView;
PROCEDURE TPagePlannerView.Draw; OVERRIDE;
END;
TPageStatusDialog = SUBCLASS OF TDialog
currentHeading:

THeading;

oddEvenCluster:
minPageFrame:
maxPageFrame:
alignCluster:
unitsCluster:
marginTitle:

TCluster;
TInputFrame;
TInputFrame;
TCluster;
TCluster;
TLegend;

Apple Lisa ToolKit 3.0 Source Code Listing -- 364 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

leftCluster:
topCluster:
rightCluster:
bottomCluster:

TCluster;
TCluster;
TCluster;
TCluster;

{Creation/Destruction}
FUNCTION TPageStatusDialog.CREATE(object: TObject; heap: THeap; itsPanel: TPanel): TPageStatusDialog;
{Sonst}
PROCEDURE
PROCEDURE
FUNCTION
PROCEDURE
PROCEDURE

TPageStatusDialog.ButtonPushed(button: TButton); OVERRIDE;


TPageStatusDialog.CheckboxHit(checkbox: TCheckbox; toggleDirection: BOOLEAN); OVERRIDE;
TPageStatusDialog.DownAt(mouseLPt: LPoint): TDialogImage; OVERRIDE;
TPageStatusDialog.Draw; OVERRIDE;
TPageStatusDialog.InspectHeadingParms(VAR oddOnly, evenOnly: BOOLEAN;
VAR pageAlignment: TPageAlignment; VAR minPage, maxPage: LONGINT);
PROCEDURE TPageStatusDialog.SetHeadingParms(oddOnly, evenOnly: BOOLEAN;
pageAlignment: TPageAlignment; minPage, maxPage: LONGINT);
END;

TPageLayoutBox = SUBCLASS OF TLayoutBox


{Creation/Destruction}
FUNCTION TPageLayoutBox.CREATE(object: TObject; heap: THeap; itsView: TView; itsHeading: THeading;
itsResizable: BOOLEAN): TPageLayoutBox;
PROCEDURE TPageLayoutBox.FreeManipulee; OVERRIDE;
PROCEDURE TPageLayoutBox.TabGrabbed; OVERRIDE;
END;
TLgHdngLayoutBox = SUBCLASS OF TPageLayoutBox
legendLayoutBox: TLegendLayoutBox;
FUNCTION TLgHdngLayoutBox.CREATE(object: TObject; heap: THeap; itsView: TView;
itsLegendHeading: TLegendHeading): TLgHdngLayoutBox;
FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

TLgHdngLayoutBox.CursorAt(mouseLPt: LPoint): TCursorNumber; OVERRIDE;


TLgHdngLayoutBox.Draw; OVERRIDE;
TLgHdngLayoutBox.MousePress(mouseLPT: LPoint); OVERRIDE;
TLgHdngLayoutBox.Move(deltaLPt: LPoint); OVERRIDE;
TLgHdngLayoutBox.RecalcExtent; OVERRIDE;

END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 365 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

VAR

stdFrameBorders:
stdHdngBorders:
stdHdngTypeStyle:
stdIDBorders:
stdInputTypeStyle:
stdFrmeOffset:
stdLabelOffset:

Rect;
Rect;
TTypeStyle;
Rect;
TTypeStyle;
Point;
Point;

{extra space around an input-frame and its text}


{extra space around a standard heading}
{tile 12 monospaced, normal faces, for titles}
{a title tab with string, and a small border on the other 3 sides}
{std input font/faces}
{std distance between input frame's prompt and input rect}
{offset from top-left corner of a checkbox to leftmost pt of
baseline of label}
stdPlainBorders:
Rect;
{a slim captionless title tab, and a small border on the other
3 sides}
stdThinBorders:
Rect;
{a slim captionless title tab above; no other borders}
titleTypeStyle:
TTypeStyle;
{tile 15 monospaced, for titles of layout boxes}
{NB: All the above are initialized in the creation block of TDialogWindow}
stdButtonMetrics:

TButtonMetrics; {reinitialized in TDialog.CREATE each time}

{Unit-Global Procedures}
FUNCTION

NewStdDialogWindow(heap: THeap; itsHeight: INTEGER; itsKeyResponse, itsMenuResponse,


itsDownInMainWindowResponse: TDiResponse): TDialogWindow;
{sets up a standard, nonresizable, dialogWindow, and installs a single Panel into it, into
which it installs a single DialogView}

FUNCTION

NewStdLegend(heap: THeap; itsChars: S255; itsXLoc, itsYLoc: LONGINT; itsView: TView;


itsTypeStyle: TTypeStyle): TLegend;

FUNCTION

NewSysLegend(heap: THeap; itsChars: S255; itsXLoc, itsYLoc: LONGINT; itsView: TView): TLegend;

PROCEDURE SetParaExtent(paragraph: TParagraph; view: TView; location: LPoint; VAR extentLRect: LRect);
PROCEDURE LRectAddBorders(baseLRect: LRect; borders: Rect; VAR resultLRect: LRect);
PROCEDURE GetTextAndLocation(phraseNumber: INTEGER; VAR itsChars: S255; VAR itsLocation: LPoint);
IMPLEMENTATION
{$I LIBTK/UDialog2}
{$I LIBTK/UDialog3}
{$I LIBTK/UDialog4}
(**********
{$I UDialog2}
{$I UDialog3}
{$I UDialog4}
**********)

{dialogs}
{layout}
{page margins}

{dialogs}
{layout}
{page margins}

Apple Lisa ToolKit 3.0 Source Code Listing -- 366 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006

END.

{unit UDialog}

End of File -- Lines: 1006 Characters: 43015

Apple Lisa ToolKit 3.0 Source Code Listing -- 367 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UDIALOG2.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

(*

Copyright 1984 by Apple Computer, Inc

UDialog2
TDialogWindow -- TDialogView -- TDialogImage -- TImageWithID
TButton -- TCheckbox -- TCluster -- TInputFrame -- TLegend

-- TDialog

--

*)
{04/23/84
{04/23/84
{04/15/84
{04/04/84
{01/29/84
{12/22/83

1210
1210
2345
2300
1750
1927

SetParaExtent uses thePad rather than view's screenPad if amPrinting}


Removed all references to 'underEdit' field of TDialogImage}
Spring Release latest}
Spring Prelim Release}
RELEASE TK8D}
RELEASE TK8A}

{$IFC fRngABC}
{$R+}
{$ELSEC}
{$R-}
{$ENDC}
{$IFC fSymABC}
{$D+}
{$ELSEC}
{$D-}
{$ENDC}
VAR copyRight: STRING[45];
{----------------------------------------------------------------------------------------------------------}
{$S DlgAlloc}
PROCEDURE GetTextAndLocation(phraseNumber: INTEGER; VAR itsChars: S255; VAR itsLocation: LPoint);
VAR rawPhrase: S255;
restOfIt:
S255;
morsel:
S255;
semiColon: INTEGER;
comma:
INTEGER;
aLocation: LPoint;
FUNCTION OKIntegerValue(Str: S255; VAR itsValue: LONGINT): BOOLEAN;
VAR result: TConvResult;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 368 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

StrToLInt(@str, itsValue, result);


OkIntegerValue := (result = cvValid);
END;
BEGIN {someone please optimize this someday}
{$IFC fTrace}BP(11);{$ENDC}
process.GetAlert(phraseNumber, rawPhrase);
semiColon := POS('@',rawPhrase);
IF semiColon = 0 THEN
semiColon := LENGTH(rawPhrase) + 1;
itsChars := COPY(rawPhrase, 1, semiColon - 1);
restOfIt := COPY(rawPhrase, semiColon + 1, LENGTH(rawPhrase) - semiColon);
comma := POS( ',', restOfIt);
morsel := COPY(restOfIt, 1, comma - 1);
IF OKIntegerValue(morsel, aLocation.h) THEN
BEGIN
morsel := COPY(restOfIt, comma + 1, LENGTH(restOfIt) - comma);
IF NOT OKIntegerValue(morsel, aLocation.v) THEN
aLocation.v := 100;
END
ELSE
SetLPt(aLocation, 100, 100);
itsLocation := aLocation;
{$IFC fTrace}EP;{$ENDC}
END;
{$S TK2Start}
PROCEDURE LRectAddBorders(baseLRect: LRect; borders: Rect; VAR resultLRect: LRect);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
resultLRect.left := baseLRect.left + borders.left;
resultLRect.top := baseLRect.top + borders.top;
resultLRect.right := baseLRect.right + borders.right;
resultLRect.bottom := baseLRect.bottom + borders.bottom;
{$IFC fTrace}EP;{$ENDC}
END;
{$S TK2Start}
{"temporary" implementation, slow, unwieldy}
PROCEDURE SetParaExtent(paragraph: TParagraph; view: TView; location: LPoint; VAR extentLRect: LRect);
VAR extent:
Rect;
lExtent:
LRect;
pad:
TPad; {+SW+}
BEGIN
{$IFC fTrace}BP(11);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 369 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

(*

paragraph.BuildExtentLRect(zeroLPt, lExtent); {assumes grafPort device is SCREEN for textWidth}


noPad.LRectToRect(lExtent, extent);
view.screenPad.RectToLRect(extent, extentLRect); *)
IF amPrinting THEN
pad := thePad
ELSE
pad := view.screenPad;
pad.RectToLRect(extent, extentLRect);
{+SW+}
OffsetLRect(extentLRect, location.h, location.v);
{$IFC fTrace}EP;{$ENDC}
END;

{$S DlgAlloc}
FUNCTION NewStdDialogWindow(heap: THeap; itsHeight: INTEGER; itsKeyResponse,
itsMenuResponse, itsDownInMainWindowResponse: TDiResponse): TDialogWindow;
VAR dialogWindow:
TDialogWindow;
panel:
TPanel;
dialogView:
TDialogView;
extentLRect:
LRect;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
dialogWindow := TDialogWindow.CREATE(NIL, heap, FALSE {not resizable}, itsHeight,
itsKeyResponse, itsMenuResponse, itsDownInMainWindowResponse);
panel := TPanel.CREATE(NIL, heap, dialogWindow, 0, screenBits.bounds.right, [], []);
dialogWindow.controlPanel := panel;
SetLRect(extentLRect, 0, 0, screenBits.bounds.right, screenBits.bounds.bottom - 40);
dialogView := TDialogView.CREATE(NIL, heap, extentLRect, panel, NIL, screenRes);
dialogWindow.dialogView := dialogView;
NewStdDialogWindow := dialogWindow;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION NewSysLegend(heap: THeap; itsChars: S255; itsXLoc, itsYLoc: LONGINT; itsView: TView): TLegend;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
NewSysLegend := NewStdLegend(heap, itsChars, itsXLoc, itsYLoc, itsView, sysTypeStyle);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION NewStdLegend(heap: THeap; itsChars: S255; itsXLoc, itsYLoc: LONGINT; itsView: TView;
itsTypeStyle: TTypeStyle): TLegend;
VAR itsString:
S255;

Apple Lisa ToolKit 3.0 Source Code Listing -- 370 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

itsLocation:
LPoint;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SetLPt(itsLocation, itsXLoc, itsYLoc); {=}
NewStdLegend := TLegend.CREATE(NIL, heap, itsChars, itsView, itsLocation, itsTypeStyle);
{$IFC fTrace}EP;{$ENDC}
END;

METHODS OF TDialogWindow;
{$S DlgAlloc}
FUNCTION TDialogWindow.CREATE(object: TObject; heap: THeap; itsResizability: BOOLEAN; itsHeight: INTEGER;
itsKeyResponse, itsMenuResponse, itsDownInMainWindowResponse: TDiResponse): TDialogWindow;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TDialogWindow(TDialogBox.CREATE(object, heap, itsResizability, itsHeight, itsKeyResponse,
itsMenuResponse, itsDownInMainWindowResponse));
SELF.controlPanel := SELF.selectPanel; {If not holding a TDialogView, client must reset}
SELF.dialogView := NIL;
SELF.mainDialog := NIL;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TDialogWindow.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('controlPanel: TPanel');
Field('dialogView: TDialogView');
Field('mainDialog: TDialog');
Field('');
END;
{$ENDC}
{$S DlgHot}
PROCEDURE TDialogWindow.Appear;
PROCEDURE TellYourView(obj: TObject);
PROCEDURE YouPrepare(obj: TObject);
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 371 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

TDialogImage(obj).PrepareToAppear;
END;

BEGIN
IF InClass(TPanel(obj).view, TDialogView) THEN
TDialogView(TPanel(obj).view).EachActualPart(YouPrepare);
END;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SUPERSELF.Appear;
SELF.panels.Each(TellYourView);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogWindow.BeDismissed;
VAR dialogView:
TDialogView;
defaultButton: TButton;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
PushFocus;
SELF.Focus;
IF InClass(SELF.controlPanel.view, TDialogView) THEN
BEGIN
dialogView := TDialogView(SELF.controlPanel.view);
defaultButton := dialogView.defaultButton;
IF defaultButton <> NIL THEN
dialogView.PushButton(defaultButton)
{may want to put in a delay loop here to assure hilit button seen}
ELSE {dialog box has no default button; just take it down}
currentWindow.TakeDownDialogBox;
END
ELSE
{not a dialogView up there--must be a layout view}
currentWindow.TakeDownDialogBox;
PopFocus;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TDialogWindow.CanDoCommand(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN): BOOLEAN;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
CASE cmdNumber OF
uEditDialog:
CanDoCommand := TRUE;
OTHERWISE

Apple Lisa ToolKit 3.0 Source Code Listing -- 372 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

CanDoCommand := currentWindow.CanDoCommand(cmdNumber, checkIt);


END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogWindow.Disappear;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SUPERSELF.Disappear;
IF SELF.controlPanel <> NIL THEN
IF InClass(SELF.controlPanel.view, TDialogView) THEN
TDialogView(SELF.controlPanel.view).isShowing := FALSE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TDialogWindow.NewCommand(cmdNumber: TCmdNumber): TCommand;
BEGIN
{$IFC fTrace}BP(12);{$ENDC}
CASE cmdNumber OF
uEditDialog:
BEGIN
IF SELF.controlPanel = NIL THEN
{$IFC fDbgOK}
ABCBreak('DialogWindow.NewCommand NIL ctl pnl', 0)
{$ENDC}
ELSE
IF NOT InClass(SELF.controlPanel.view, TDialogView) THEN
{$IFC fDbgOK}
ABCBreak('DialogWindow.NewCommand, not a dialog view', 0)
{$ENDC}
ELSE
TDialogDesignWindow.CREATE(NIL, SELF.Heap, TDialogView(SELF.controlPanel.view)).SeizeControl;
NewCommand := NIL;
END;
OTHERWISE
NewCommand := currentWindow.NewCommand(cmdNumber);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
BEGIN
SetRect(stdPlainBorders, - stdLeftRightMargin, -stdSlimTitleHeight - stdBottomBorder, stdLeftRightMargin,

Apple Lisa ToolKit 3.0 Source Code Listing -- 373 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

stdBottomBorder);
SetRect(stdIDBorders , - stdLeftRightMargin, -stdTitleHeight - stdBottomBorder, stdLeftRightMargin,
stdBottomBorder);
SetRect(stdThinBorders , 0, -stdSlimTitleHeight, 0, 0);
SetPt(stdLabelOffset, 8, -2);
SetPt(stdFrmeOffset, 20, 0);
SetRect(stdFrameBorders, -30, -16, 30, 16);
SetRect(stdHdngBorders, -6, -12, 6, 4);
MakeTypeStyle(famModern, size12Pitch, [], stdInputTypeStyle);
MakeTypeStyle(famModern, size15Pitch, [], titleTypeStyle);
MakeTypeStyle(famModern, size12Pitch, [], stdHdngTypeStyle);
copyright := 'Copyright 1983, 1984 by Apple Computer, Inc.';
END;
METHODS OF TDialogView;
{$S DlgAlloc}
FUNCTION TDialogView.CREATE{(object: TObject; heap: THeap; itsExtentLRect: LRect; itsPanel: TPanel;
itsPrintManager: TPrintManager; itsRes: Point)};
VAR rootDialog:
TDialog;
dialogWindow:
TDialogWindow;
styleSheet:
TStyleSheet;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TDialogView(TView.CREATE(object, heap, itsPanel, itsExtentLRect, itsPrintManager, stdMargins,
(itsPrintManager <> NIL), itsRes, TRUE));
SELF.nonDialogExtent := itsExtentLRect;
rootDialog := TDialog.CREATE(NIL, heap, 'ROOT', SELF);
SELF.rootDialog := rootDialog; {create an empty master}
styleSheet := TStyleSheet.CREATE(NIL, heap);
SELF.styleSheet := styleSheet;
WITH SELF DO
BEGIN
isShowing := FALSE; {not yet actually put up}
currentDialogImage := NIL;
defaultButton := NIL;

Apple Lisa ToolKit 3.0 Source Code Listing -- 374 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

hitButton := NIL;
paintFreeBoxes := FALSE; {client can set this to TRUE after the CREATE call}
paintSense := FALSE;
startedPainting := FALSE;
mouseIsDown := FALSE;
magnetCursor := noCursor;
END;
IF InClass(itsPanel.window, TDialogWindow) THEN
BEGIN
dialogWindow := TDialogWindow(itsPanel.window);
IF dialogWindow.controlPanel = NIL THEN
dialogWindow.controlPanel := itsPanel;
IF dialogWindow.dialogView = NIL THEN
dialogWindow.dialogView := SELF;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgCold}
PROCEDURE TDialogView.Free;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
Free(SELF.rootDialog);
Free(SELF.styleSheet);
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TDialogView.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('rootDialog: TDialog');
Field('nonDialogExtent: LRect');
Field('currentDialogImage: TDialogImage');
Field('defaultButton: TButton');
Field('hitButton: TButton');
Field('isShowing: BOOLEAN');
Field('paintFreeBoxes: BOOLEAN');
Field('paintSense: BOOLEAN');
Field('startedPainting: BOOLEAN');
Field('styleSheet: TStyleSheet');

Apple Lisa ToolKit 3.0 Source Code Listing -- 375 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

Field('mouseIsDown: BOOLEAN');
Field('magnetCursor: INTEGER');
Field('');
END;
{$ENDC}
{$S DlgHot}
PROCEDURE TDialogView.AbandonThatButton;
PROCEDURE TurnOutTheLights;
BEGIN
SELF.hitButton.Highlight(hOnToOff);
END;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.hitButton <> NIL THEN
BEGIN
SELF.panel.OnAllPadsDo(TurnOutTheLights);
IF SELF.currentDialogImage = SELF.hitButton THEN
SELF.currentDialogImage := NIL;
SELF.hitButton := NIL;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
PROCEDURE TDialogView.AddDialog(dialog: TDialog);
VAR dialogWindow:
TDialogWindow;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.rootDialog.AddImage(dialog);
IF InClass(SELF.panel.window, TDialogWindow) THEN
BEGIN
dialogWindow := TDialogWindow(SELF.panel.window);
IF dialogWindow.mainDialog = NIL THEN
dialogWindow.mainDialog := dialog;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TDialogView.AddNewDialog(itsKey: S4): TDialog;
VAR dialogWindow:
TDialogWindow;
dialog:
TDialog;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 376 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

dialog := TDialog.CREATE(NIL, SELF.Heap, itsKey, SELF);


SELF.AddDialog(dialog);
AddNewDialog := dialog;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
PROCEDURE TDialogView.ActivateDialog(dialog: TDialog; whichWay: BOOLEAN);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.rootDialog.ActivateImage(dialog, whichWay);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogView.ButtonPushed(button: TButton);
CONST
delayTime = 50000;
VAR dialogView: TDialogView;
command:
TCommand;
sink:
LONGINT;
i:
LONGINT;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF currentWindow.dialogBox <> NIL THEN
BEGIN
dialogView := TDialogView(TDialogWindow(currentWindow.dialogBox).controlPanel.view);
command := NIL;
IF dialogView = SELF THEN
BEGIN
sink := 124395;
FOR i := 1 TO delayTime DO
sink := sink - sink;
dialogView.AbandonThatButton; {turn off highlighting just in case the dialog will be reused}
IF button.cmdNumber <> noCmdNumber THEN
command := currentWindow.selectPanel.selection.NewCommand(button.cmdNumber);
currentWindow.TakeDownDialogBox;
IF command <> NIL THEN
currentWindow.PerformCommand(command);
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogView.CheckboxHit(checkbox: TCheckbox; toggleDirection: BOOLEAN);

Apple Lisa ToolKit 3.0 Source Code Listing -- 377 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

{The client will occasionally want to override this, in order to change the display as an
immediate consequence of a Checkbox being toggled}
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{ ... }
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TDialogView.CursorAt(mouseLPt: LPoint): TCursorNumber;
VAR cursorNumber:
TCursorNumber;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
cursorNumber := noCursor;
IF SELF.mouseIsDown AND (SELF.magnetCursor <> noCursor) THEN
cursorNumber := SELF.magnetCursor
ELSE
BEGIN
IF LRectHasLPt(SELF.rootDialog.extentLRect, mouseLPt) THEN
cursorNumber := SELF.rootDialog.CursorAt(mouseLPt);
IF cursorNumber = noCursor THEN
cursorNumber := SELF.XCursorAt(mouseLPt);
END;
CursorAt := cursorNumber;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogView.Draw;
VAR s:
TListScanner;
dialogImage:
TDialogImage;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.isShowing := TRUE; {update event triggered this}
SELF.rootDialog.Draw; {draw dialogs}
SELF.XDraw;
{draw other stuff}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogView.EachActualPart(PROCEDURE DoToObject(filteredObj: TObject));
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.rootDialogImage.EachActualPart(doToObject);

Apple Lisa ToolKit 3.0 Source Code Listing -- 378 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogView.MouseMove(mouseLPt: LPoint);
VAR currentDialogImage: TDialogImage;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
currentDialogImage := SELF.currentDialogImage;
IF currentDialogImage <> NIL THEN
IF NOT currentDialogImage.StillMyMouse(mouseLPt) THEN
currentDialogImage := NIL;
IF currentDialogImage = NIL THEN
BEGIN
currentDialogImage := SELF.rootDialog.DownAt(mouseLPt);
IF currentDialogImage = NIL THEN
SELF.XMouseMove(mouseLPt);
END;
SELF.currentDialogImage := currentDialogImage;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogView.MousePress(mouseLPt: LPoint);
VAR panel:
TPanel;
takenBySelection:
BOOLEAN;
currentDialogImage: TDialogImage;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
panel := SELF.panel;
SELF.startedPainting := FALSE;
takenBySelection := FALSE;
SELF.mouseIsDown := TRUE;
SELF.magnetCursor := noCursor;
currentDialogImage := SELF.currentDialogImage;
IF (currentDialogImage <> NIL) AND (SELF.panel.selection.kind <> nothingKind) THEN
IF currentDialogImage.Hit(mouseLPt) THEN
BEGIN
SELF.panel.selection.MousePress(mouseLPt);
takenBySelection := TRUE;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 379 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

IF NOT takenBySelection THEN


BEGIN
panel.BeginSelection;
currentDialogImage := SELF.rootDialog.DownAt(mouseLPt);
IF currentDialogImage = NIL THEN
SELF.XMousePress(mouseLPt)
END;
SELF.currentDialogImage := currentDialogImage;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogView.MouseRelease;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.mouseIsDown := FALSE;
SELF.magnetCursor := noCursor;
IF SELF.currentDialogImage <> NIL THEN
SELF.currentDialogImage.MouseRelease
ELSE
SELF.XMouseRelease;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogView.PushButton(button: TButton);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF InClass(button.parent, TDialog) THEN
TDialog(button.parent).PushButton(button);
{$IFC fTrace}EP;{$ENDC}
END;

{client or ToolKit may call}

{$S DlgAlloc}
PROCEDURE TDialogView.RecalcExtent;
VAR newExtent: LRect;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF NOT EmptyLRect(SELF.rootDialog.extentLRect) THEN
BEGIN
IF NOT EmptyLRect(SELF.nonDialogExtent) THEN
UnionLRect(SELF.rootDialog.extentLRect, SELF.nonDialogExtent, newExtent);
SELF.Resize(newExtent);

Apple Lisa ToolKit 3.0 Source Code Listing -- 380 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
PROCEDURE TDialogView.RemoveDialog(dialog: TDialog; andFree: BOOLEAN);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.rootDialog.DeleteImage(dialog, andFree);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
PROCEDURE TDialogView.ReplaceDialog(oldDialog, newDialog: TDialog);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.rootDialog.ReplaceImage(oldDialog, newDialog);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
PROCEDURE TDialogView.SetDefaultButton(button: TButton);
VAR thickPnSize:
point;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.defaultButton := button;
SetPt(thickPnSize, 3, 2);
IF button <> NIL THEN
button.buttonMetrics.penState.pnSize := thickPnSize;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TDialogView.XCursorAt(mouseLPt: LPoint): TCursorNumber;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
XCursorAt := arrowCursor;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogView.XDraw;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 381 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

{$IFC fTrace}BP(11);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogView.XMousePress(mouseLPt: LPoint);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogView.XMouseMove(mouseLPt: LPoint);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogView.XMouseRelease;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
{----------------------------------------------------------------------------------------------------------}
METHODS OF TDialogImage;
{$S TK2Start}
FUNCTION TDialogImage.CREATE(object: TObject; heap: THeap; itsExtent: LRect; itsId: S255;
itsView: TView; withChildren: BOOLEAN): TDialogImage;
VAR newList:
TList;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TDialogImage(TImage.CREATE(object, heap, itsExtent, itsView));

Apple Lisa ToolKit 3.0 Source Code Listing -- 382 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

WITH SELF DO
BEGIN
parent := NIL;
isActive := TRUE;
isEditable := TRUE;
withID := FALSE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TDialogImage.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('parent: TDialogImage');
Field('isActive: BOOLEAN');
Field('isEditable: BOOLEAN');
Field('withID: BOOLEAN');
Field('');
END;
{$ENDC}
{$S DlgCold}
PROCEDURE TDialogImage.AddImage(dialogImage: TDialogImage);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
PROCEDURE TDialogImage.ActivateImage(dialogImage: TDialogImage; whichWay: BOOLEAN);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF dialogImage.isActive <> whichWay THEN {state needs to change}
BEGIN
dialogImage.isActive := whichWay;
SELF.view.panel.InvalLRect(dialogImage.extentLRect); {??? Want to recalc my extent here???}
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgCold}
PROCEDURE TDialogImage.BringToFront(dialogImage: TDialogImage);

Apple Lisa ToolKit 3.0 Source Code Listing -- 383 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgCold}
PROCEDURE TDialogImage.ComeForward;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.parent <> NIL THEN
SELF.parent.BringToFront(SELF);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogImage.ControlHit(control: TDialogImage; toggleDirection: BOOLEAN);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.parent <> NIL THEN
SELF.parent.ControlHit(control, toggleDirection);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
PROCEDURE TDialogImage.DeleteImage(dialogImage: TDialogImage; andFree: BOOLEAN);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TDialogImage.DownAt(mouseLPt: LPoint):
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.Hit(mouseLPt) THEN
BEGIN
SELF.MousePress(mouseLPt);
DownAt := SELF;
END
ELSE
DownAt := NIL;
{$IFC fTrace}EP;{$ENDC}
END;

TDialogImage;

Apple Lisa ToolKit 3.0 Source Code Listing -- 384 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

{$S DlgHot}
PROCEDURE TDialogImage.Draw;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.DrawJustMe;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgDbg} {by design}
PROCEDURE TDialogImage.DrawJustMe;
BEGIN
{$IFC fTrace}BP(113);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogImage.EachActualPart(PROCEDURE DoToObject(filteredObj: TObject));
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{overrides TImage's version, does specifically Nothing; TImageWithID redefines}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TDialogImage.HasId(id: S255): BOOLEAN;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
HasID := FALSE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
FUNCTION TDialogImage.LaunchLayoutBox(view: TView): TImage;
VAR myLayoutBox:
TLayoutBox;
plannerView:
TPlannerView;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF NOT SELF.isActive THEN
LaunchLayoutBox := NIL
ELSE
LaunchLayoutBox := TLayoutBox.CREATE(NIL, view.Heap, SELF.extentLRect, '', NIL,
view, SELF, stdPlainBorders, FALSE, FALSE, FALSE);
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 385 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

END;
{$S DlgHot}
FUNCTION TDialogImage.ObjectWithIDNumber(idNumber: INTEGER):
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
ObjectWithIDNumber := NIL;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TDialogImage.ObjWithId(id: S255):
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
ObjWithId := NIL;
{$IFC fTrace}EP;{$ENDC}
END;

TDialogImage;

TDialogImage;

{$S DlgHot}
PROCEDURE TDialogImage.PrepareToAppear;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialogImage.RecalcExtent;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.parent <> NIL THEN
SELF.parent.RecalcExtent;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgCold}
PROCEDURE TDialogImage.ReplaceImage(replacee, newValue: TDialogImage);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TDialogImage.StillMyMouse(mouseLPt: LPoint): BOOLEAN;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 386 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

{$IFC fTrace}BP(11);{$ENDC}
IF SELF.Hit(mouseLPt) THEN
StillMyMouse := TRUE {I've handled it}
ELSE
StillMyMouse := FALSE; {give it to someone else}
{default; this will usually be overridden in subclass}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;

METHODS OF TImageWithID;
{$S DlgHot}
FUNCTION TImageWithID.CREATE(object: TObject; heap: THeap; itsExtent: LRect; itsId: S255;
itsView: TView; withChildren: BOOLEAN): TImageWithID;
VAR newList:
TList;
newID:
TId;
cState:
TConvResult;
newIDNumber:
INTEGER;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TImageWithID(TDialogImage.CREATE(object, heap, itsExtent, itsID, itsView, withChildren));
newID := Copy(itsId, 1, MIN(idLength, LENGTH(itsId)));
StrUpperCased(@newID);
StrToInt(@newID, newIDNumber, cState);
IF cState <> cvValid THEN
newIDNumber := noIDNumber;
WITH SELF DO
BEGIN
id := newID;
idNumber := newIDNumber;
withId := TRUE;
END;
IF withChildren THEN
BEGIN
newList := TList.CREATE(NIL, heap, 0);
SELF.children := newList;
END
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 387 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

SELF.children := NIL;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgWarm}
FUNCTION TImageWithID.Clone(heap: THeap): TObject;
VAR children:
TList;
copyOfMyself:
TImageWithID;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
copyOfMyself := TImageWithID(SUPERSELF.Clone(heap));
IF SELF.children <> NIL THEN
BEGIN
children := TList(SELF.children.Clone(heap));
copyOfMyself.children := children;
END;
Clone := copyOfMyself;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgWarm}
PROCEDURE TImageWithID.Free;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
Free(SELF.children);
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TImageWithID.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('children: TList');
Field('id: STRING[9]');
Field('idNumber: INTEGER');
Field('');
END;
{$ENDC}
{$S DlgHot}
PROCEDURE TImageWithID.ActivateImage(dialogImage: TDialogImage; whichWay: BOOLEAN);
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 388 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

{$IFC fTrace}BP(11);{$ENDC}
IF dialogImage.isActive <> whichWay THEN {state needs to change}
BEGIN
dialogImage.isActive := whichWay;
SELF.view.panel.InvalLRect(dialogImage.extentLRect);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TImageWithID.AddImage(dialogImage: TDialogImage);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.children.InsLast(dialogImage);
dialogImage.parent := SELF;
dialogImage.HaveView(SELF.view);
IF EmptyLRect(SELF.extentLRect) THEN
SELF.extentLRect := dialogImage.extentLRect
ELSE
{$H-}
UnionLRect(SELF.extentLRect, dialogImage.extentLRect, SELF.extentLRect); {$H+}
IF SELF.parent <> NIL THEN
SELF.parent.RecalcExtent;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TImageWithID.BringToFront(dialogImage: TDialogImage);
VAR s:
TListScanner;
image: TDialogImage;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.children <> NIL THEN
BEGIN
s := SELF.children.Scanner;
WHILE s.Scan(image) DO
IF image = dialogImage THEN
BEGIN
s.Delete(FALSE);
s.Done;
SELF.children.insLast(dialogImage);
END;
END;
IF SELF.parent <> NIL THEN
SELF.parent.BringToFront(SELF);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 389 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

{$S DlgHot}
FUNCTION TImageWithID.CursorAt(mouseLPt: LPoint): TCursorNumber;
VAR s:
TListScanner;
dialogImage:
TDialogImage;
cursorNumber:
TCursorNumber;
{default: just passes the request on to children until one sets it}
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
cursorNumber := noCursor;
IF LRectHasLPt(SELF.extentLRect, mouseLPt) THEN
IF SELF.children <> NIL THEN
BEGIN
s := SELF.children.Scanner;
WHILE s.Scan(dialogImage) DO
IF dialogImage.isActive THEN
BEGIN
cursorNumber := dialogImage.CursorAt(mouseLPt);
IF cursorNumber <> noCursor THEN
s.Done;
END;
END;
CursorAt := cursorNumber;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgCold}
PROCEDURE TImageWithID.DeleteImage(dialogImage: TDialogImage; andFree: BOOLEAN);
{deletes the indicated dialogImage from my children}
VAR s:
TListScanner;
aDialogImage:
TDialogImage;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
s:= SELF.children.Scanner;
WHILE s.Scan(aDialogImage) DO
IF aDialogImage = dialogImage THEN
BEGIN
IF (TDialogView(SELF.view).isShowing) AND (dialogImage.isActive) THEN
SELF.view.panel.InvalLRect(dialogImage.extentLRect);
s.Delete(andFree);
s.Done;
END;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 390 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

{$S DlgHot}
PROCEDURE TImageWithID.Draw;
PROCEDURE YouDraw(obj: TObject);
VAR dialogImage: TDialogImage;
BEGIN
dialogImage := TDialogImage(obj);
IF dialogImage.isActive THEN
dialogImage.Draw;
END;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF LRectIsVisible(SELF.extentLRect) THEN
BEGIN
SELF.EachActualPart(YouDraw);
SELF.DrawJustMe;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TImageWithID.EachActualPart(PROCEDURE DoToObject(filteredObj: TObject));
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.children <> NIL THEN
SELF.children.Each(DoToObject);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TImageWithID.EachVirtualPart(PROCEDURE DoToObject(filteredObj: TObject));
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.EachActualPart(DoToObject); {???}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TImageWithID.HasId(id: S255): BOOLEAN;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{$H-} id := Copy(id, 1, MIN(idLength, LENGTH(id))); {$H+}
StrUpperCased(@id);
IF SELF.id = id THEN
HasId := TRUE

Apple Lisa ToolKit 3.0 Source Code Listing -- 391 of 1012

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163
001164
001165
001166
001167
001168
001169
001170
001171
001172
001173
001174
001175
001176
001177
001178
001179
001180
001181
001182
001183
001184
001185
001186
001187
001188
001189
001190
001191
001192
001193
001194
001195

ELSE
HasId := FALSE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TImageWithID.HaveView(view: TView);
PROCEDURE YouHaveView(obj: TObject);
VAR dialogImage: TDialogImage;
BEGIN
dialogImage := TDialogImage(obj);
dialogImage.HaveView(view);
END;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.view := view;
SELF.EachActualPart(YouHaveView);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
FUNCTION TImageWithID.LaunchLayoutBox(view: TView): TImage;
VAR dialogImage:
TDialogImage;
newExtent:
LRect;
boxTitle:
S255;
theString:
TLegend;
childsLayoutBox:
TLayoutBox;
myLayoutBox:
TLayoutBox;
plannerView:
TPlannerView;
postChildExtent:
LRect;
withChildren:
BOOLEAN;
PROCEDURE YouMakeLayoutBoxes(obj: TObject);
VAR dialogImage:
TDialogImage;
interimImage:
TImage;
BEGIN
dialogImage := TDialogImage(obj);
interimImage := dialogImage.LaunchLayoutBox(view);
IF interimImage <> NIL THEN
BEGIN
childsLayoutBox := TLayoutBox(interimImage);
myLayoutBox.AddImage(childsLayoutBox);
UnionLRect(postChildExtent, childsLayoutBox.extentLRect, postChildExtent);
END;
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 392 of 1012

Apple Lisa Computer Technical Information


001196
001197
001198
001199
001200
001201
001202
001203
001204
001205
001206
001207
001208
001209
001210
001211
001212
001213
001214
001215
001216
001217
001218
001219
001220
001221
001222
001223
001224
001225
001226
001227
001228
001229
001230
001231
001232
001233
001234
001235
001236
001237
001238
001239
001240
001241
001242
001243

IF NOT SELF.isActive THEN


LaunchLayoutBox := NIL
ELSE
BEGIN {=}
plannerView := TPlannerView(view);
IF SELF.ID <> '' THEN
boxTitle := SELF.id
ELSE
IF SELF.idNumber = noIDNumber THEN
boxTitle := ''
ELSE
IntToString(SELF.idNumber, @boxTitle);
withChildren := (SELF.children <> NIL);
IF withChildren THEN
withChildren := SELF.children.Size > 0;
myLayoutBox := TLayoutBox.CREATE(NIL, SELF.Heap, SELF.extentLRect, boxTitle, NIL, plannerView, SELF,
stdIDBorders, FALSE, withChildren, withChildren);
{default for a dialogImage is for the layout box to SUPPRESS drawing the manipulee}
postChildExtent := SELF.extentLRect; {i.e., WITHOUT my borders}
SELF.EachActualPart(YouMakeLayoutBoxes); {tells my children to make their own layout
boxes; may grow postChildExtent}
myLayoutBox.RecalcExtent;
LaunchLayoutBox := myLayoutBox;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TImageWithID.ObjectWithIDNumber(idNumber: INTEGER): TDialogImage;
VAR s:
TListScanner;
dialogImage:
TDialogImage;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
ObjectWithIDNumber := NIL;
IF SELF.children <> NIL THEN
BEGIN
s := SELF.children.Scanner;
WHILE s.Scan(dialogImage) DO
IF dialogImage.withID THEN
IF TImageWithID(dialogImage).idNumber = idNumber THEN
BEGIN
ObjectWithIDNumber := dialogImage;
s.Done;

Apple Lisa ToolKit 3.0 Source Code Listing -- 393 of 1012

Apple Lisa Computer Technical Information


001244
001245
001246
001247
001248
001249
001250
001251
001252
001253
001254
001255
001256
001257
001258
001259
001260
001261
001262
001263
001264
001265
001266
001267
001268
001269
001270
001271
001272
001273
001274
001275
001276
001277
001278
001279
001280
001281
001282
001283
001284
001285
001286
001287
001288
001289
001290
001291

END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TImageWithID.ObjWithId(id: S255): TDialogImage;
VAR s:
TListScanner;
dialogImage:
TDialogImage;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
id := Copy(id, 1, MIN(idLength, LENGTH(id)));
StrUpperCased(@id);
ObjWithId := NIL;
IF SELF.children <> NIL THEN
BEGIN
s := SELF.children.Scanner;
WHILE s.Scan(dialogImage) DO
IF dialogImage.withID THEN
IF TImageWithID(dialogImage).id = id THEN
BEGIN
ObjWithId := dialogImage;
s.Done;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TImageWithID.OffSetBy(deltaLPt: LPoint);
PROCEDURE YouOffset(obj: TObject);
BEGIN
TDialogImage(obj).OffsetBy(deltaLPt);
END;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{$H-} OffsetLRect(SELF.extentLRect, deltaLPt.h, deltaLPt.v); {$H+}
SELF.EachActualPart(YouOffset); {tells children}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgWarm}
PROCEDURE TImageWithID.RecalcExtent;
VAR s:

TListScanner;

{a bottom-up communication line; child who changes tells


his parent, who changes himself and then tells HIS parent}

Apple Lisa ToolKit 3.0 Source Code Listing -- 394 of 1012

Apple Lisa Computer Technical Information


001292
001293
001294
001295
001296
001297
001298
001299
001300
001301
001302
001303
001304
001305
001306
001307
001308
001309
001310
001311
001312
001313
001314
001315
001316
001317
001318
001319
001320
001321
001322
001323
001324
001325
001326
001327
001328
001329
001330
001331
001332
001333
001334
001335
001336
001337
001338
001339

dialogImage:
newExtent:

TDialogImage;
LRect;

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{can be speeded up}
IF SELF.children <> NIL THEN
IF SELF.children.Size > 0 THEN
BEGIN
newExtent := zeroLRect;
s := SELF.children.Scanner;
WHILE s.Scan(dialogImage) DO
IF EmptyLRect(newExtent) THEN
newExtent := dialogImage.extentLRect
ELSE
UnionLRect(newExtent, dialogImage.extentLRect, newExtent);
SELF.Resize(newExtent);
END;
IF SELF.parent <> NIL THEN
SELF.parent.RecalcExtent;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgCold}
PROCEDURE TImageWithID.ReplaceImage(replacee, newValue: TDialogImage);
{make this such that it puts back at same place; or use Become}
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.DeleteImage(replacee, TRUE);
SELF.AddImage(newValue);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TImageWithID.StillMyMouse(mouseLPt : LPoint): BOOLEAN;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.Hit(mouseLPt) THEN
StillMyMouse := TRUE {I've handled it}
ELSE
StillMyMouse := FALSE; {give it to someone else}
{default; this will usually be overridden in subclass}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}

Apple Lisa ToolKit 3.0 Source Code Listing -- 395 of 1012

Apple Lisa Computer Technical Information


001340
001341
001342
001343
001344
001345
001346
001347
001348
001349
001350
001351
001352
001353
001354
001355
001356
001357
001358
001359
001360
001361
001362
001363
001364
001365
001366
001367
001368
001369
001370
001371
001372
001373
001374
001375
001376
001377
001378
001379
001380
001381
001382
001383
001384
001385
001386
001387

END;
METHODS OF TDialog;
{$S DlgAlloc}
FUNCTION TDialog.CREATE(object: TObject; heap: THeap; itsKey: S4; itsView: TView): TDialog;
VAR itsStringKey:
TStringKey;
itsExtent:
LRect;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
WITH stdButtonMetrics DO
BEGIN
height := stdBtnHeight;
curvH := stdCurvH;
curvV := stdCurvV;
typeStyle := sysTypeStyle;
penState := normalPen;
expandNum := 4;
expandDen := 3;
absMinWidth := 80;
END;
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TDialog(TImageWithID.CREATE(object, heap, zeroLRect, itsKey, itsView, TRUE));
XferLeft(Ptr(ORD(@itsKey)+1), @itsStringKey.trueKey, 4); {get it into LONGINT form}
itsStringKey.key := itsKey;
SELF.stringKey := itsStringKey;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TDialog.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('stringKey: RECORD trueKey: LONGINT; key: STRING[4] END');
Field('');
END;
{$ENDC}
{$S DlgAlloc}
FUNCTION TDialog.NewButton(itsPhrase: INTEGER; itsMetrics: TButtonMetrics; sameSizedButton: TButton;
itsCmdNumber: TCmdNumber): TButton;
VAR itsID:
S255;

Apple Lisa ToolKit 3.0 Source Code Listing -- 396 of 1012

Apple Lisa Computer Technical Information


001388
001389
001390
001391
001392
001393
001394
001395
001396
001397
001398
001399
001400
001401
001402
001403
001404
001405
001406
001407
001408
001409
001410
001411
001412
001413
001414
001415
001416
001417
001418
001419
001420
001421
001422
001423
001424
001425
001426
001427
001428
001429
001430
001431
001432
001433
001434
001435

itsLocation:
button:

LPoint;
TButton;

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
GetTextAndLocation(itsPhrase, itsID, itsLocation);
button := SELF.AddButton(itsID, itsLocation, itsMetrics, sameSizedButton, itsCmdNumber);
button.idNumber := itsPhrase;
NewButton := button;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TDialog.NewCluster(itsPhrase: INTEGER): TCluster;
VAR itsID:
S255;
itsLocation:
LPoint;
cluster:
TCluster;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
GetTextAndLocation(itsPhrase, itsID, itsLocation);
cluster := SELF.AddStdCluster(itsID, itsLocation.h, itsLocation.v);
cluster.idNumber := itsPhrase;
NewCluster := cluster;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TDialog.NewFreeCheckbox(itsPhrase: INTEGER; boxWidth: INTEGER;
boxHeight: INTEGER; wantLabel: BOOLEAN; labelOffset: Point; itsTypeStyle: TTypeStyle): TCheckBox;
VAR itsID:
S255;
itsLocation:
LPoint;
checkbox:
TCheckbox;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
GetTextAndLocation(itsPhrase, itsID, itsLocation);
checkbox := SELF.AddFreeCheckbox(itsID, itsLocation.h, itsLocation.v, boxWidth, boxHeight,
wantLabel, labelOffset, itsTypeStyle);
checkbox.idNumber := itsPhrase;
NewFreeCheckbox := checkbox;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TDialog.NewInputFrame(itsPhrase: INTEGER; promptTypeStyle: TTypeStyle;
inputOffset: Point; inputTypeStyle: TTypeStyle;
maxInputChars: INTEGER; itsBorders: Rect; drawInputLRect: BOOLEAN;

Apple Lisa ToolKit 3.0 Source Code Listing -- 397 of 1012

Apple Lisa Computer Technical Information


001436
001437
001438
001439
001440
001441
001442
001443
001444
001445
001446
001447
001448
001449
001450
001451
001452
001453
001454
001455
001456
001457
001458
001459
001460
001461
001462
001463
001464
001465
001466
001467
001468
001469
001470
001471
001472
001473
001474
001475
001476
001477
001478
001479
001480
001481
001482
001483

drawHitLRect: BOOLEAN): TInputFrame;


VAR itsID:
S255;
itsLocation:
LPoint;
inputFrame:
TInputFrame;
inputLocation: LPoint;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
GetTextAndLocation(itsPhrase, itsID, itsLocation);
SetQDTypeStyle(promptTypeStyle);
WITH inputLocation DO
BEGIN
h := itsLocation.h + StringWidth(itsID) + inputOffset.h;
v := itsLocation.v + inputOffset.v;
END;
inputFrame := SELF.AddInputFrame(itsID, itsLocation, promptTypeStyle,
inputLocation, inputTypeStyle, maxInputChars, itsBorders, drawInputLRect,
drawHitLRect);
inputFrame.idNumber := itsPhrase;
NewInputFrame := inputFrame;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TDialog.NewLegend(itsPhrase: INTEGER; itsTypeStyle: TTypeStyle): TLegend;
VAR itsID:
S255;
itsLocation:
LPoint;
legend:
TLegend;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
GetTextAndLocation(itsPhrase, itsID, itsLocation);
legend := SELF.AddStdLegend(itsID, itsLocation.h, itsLocation.v, itsTypeStyle);
NewLegend := legend;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TDialog.NewRowOfBoxes(itsPhrase: INTEGER; numberOfBoxes: INTEGER;
startingIDNumber: INTEGER; boxWidth: INTEGER; boxHeight: INTEGER; boxSpacing: INTEGER): TCluster;
VAR itsID:
S255;
itsLocation:
LPoint;
cluster:
TCluster;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
GetTextAndLocation(itsPhrase, itsID, itsLocation);

Apple Lisa ToolKit 3.0 Source Code Listing -- 398 of 1012

Apple Lisa Computer Technical Information


001484
001485
001486
001487
001488
001489
001490
001491
001492
001493
001494
001495
001496
001497
001498
001499
001500
001501
001502
001503
001504
001505
001506
001507
001508
001509
001510
001511
001512
001513
001514
001515
001516
001517
001518
001519
001520
001521
001522
001523
001524
001525
001526
001527
001528
001529
001530
001531

cluster := SELF.AddRowOfBoxes(itsID, itsLocation.h, itsLocation.v, numberOfBoxes,


startingIDNumber, boxWidth, boxHeight, boxSpacing);
cluster.idNumber := itsPhrase;
NewRowOfBoxes := cluster;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
PROCEDURE TDialog.AddOKButton(cmdNumber: TCmdNumber);
VAR button: TButton;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
button := SELF.NewButton(phOK, stdButtonMetrics,
TButton(SELF.ObjectWithIDNumber(phCancel)), cmdNumber);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
PROCEDURE TDialog.AddCancelButton(cmdNumber: TCmdNumber);
VAR button: TButton;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
button := SELF.NewButton(phCancel, stdButtonMetrics,
TButton(SELF.ObjectWithIDNumber(phOK)), cmdNumber);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TDialog.AddBigFreeCheckbox(itsId: S255; itsXLoc, itsYLoc: LONGINT): TCheckbox; {---}
VAR location:
LPoint;
itsChars:
S255;
newBox:
TCheckbox;
labelOffset:
Point;
typeStyle:
TTypeStyle;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SetLPt(location, itsXLoc, itsYLoc);
SetPt(labelOffset, 20, -4);
MakeTypeStyle(famClassic, size18Point, [], typeStyle);
newBox := TCheckbox.CREATE(NIL, SELF.Heap, itsId, SELF.view, location, 36, 24, TRUE,
labelOffset, typeStyle);
SELF.AddImage(newBox);
AddBigFreeCheckbox := newBox;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 399 of 1012

Apple Lisa Computer Technical Information


001532
001533
001534
001535
001536
001537
001538
001539
001540
001541
001542
001543
001544
001545
001546
001547
001548
001549
001550
001551
001552
001553
001554
001555
001556
001557
001558
001559
001560
001561
001562
001563
001564
001565
001566
001567
001568
001569
001570
001571
001572
001573
001574
001575
001576
001577
001578
001579

{$S DlgAlloc}
FUNCTION TDialog.AddButton(itsId: S255; itsLocation: LPoint; itsMetrics: TButtonMetrics;
sameSizedButton: TButton; itsCmdNumber: TCmdNumber): TButton;
VAR button: TButton;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
button := TButton.CREATE(NIL, SELF.Heap, itsId, SELF.view, itsLocation, itsMetrics,
sameSizedButton, itsCmdNumber);
SELF.AddImage(button);
AddButton := button;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TDialog.AddStdButton(itsId: S255; itsXLoc, itsYLoc: LONGINT; sameSizedButton: TButton;
itsCmdNumber: TCmdNumber): TButton;
VAR location:
LPoint;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SetLPt(location, itsXLoc, itsYLoc);
AddStdButton := SELF.AddButton(itsID, location, stdButtonMetrics, sameSizedButton, itsCmdNumber);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TDialog.AddStdFreeCheckbox(itsId: S255; itsXLoc, itsYLoc: LONGINT): TCheckBox;
VAR legend:
TLegend;
location:
LPoint;
checkbox:
TCheckbox;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SetLPt (location, itsXLoc, itsYLoc);
checkbox := TCheckbox.CREATE(NIL, SELF.Heap, itsId, SELF.view, location, stdBoxWidth,
stdBoxHeight, TRUE, stdLabelOffset, sysTypeStyle);
SELF.AddImage(checkbox);
AddStdFreeCheckbox := checkbox;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TDialog.AddStdCluster(itsId: S255; itsXLoc, itsYLoc: LONGINT): TCluster;
VAR location:
LPoint;
cluster:
TCluster;

Apple Lisa ToolKit 3.0 Source Code Listing -- 400 of 1012

Apple Lisa Computer Technical Information


001580
001581
001582
001583
001584
001585
001586
001587
001588
001589
001590
001591
001592
001593
001594
001595
001596
001597
001598
001599
001600
001601
001602
001603
001604
001605
001606
001607
001608
001609
001610
001611
001612
001613
001614
001615
001616
001617
001618
001619
001620
001621
001622
001623
001624
001625
001626
001627

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SetLPt(location, itsXLoc, itsYLoc);
cluster :=TCluster.CREATE(NIL, SELF.Heap, itsId, SELF.view, location);
SELF.AddImage(cluster);
AddStdCluster := cluster;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TDialog.AddFreeCheckbox(itsID: S255; itsXLoc, itsYLoc: LONGINT; boxWidth: INTEGER;
boxHeight: INTEGER; wantLabel: BOOLEAN; labelOffset: Point; itsTypeStyle: TTypeStyle): TCheckbox;
VAR location:
LPoint;
checkbox:
TCheckbox;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SetLPt(location, itsXLoc, itsYLoc);
checkbox := TCheckbox.CREATE(NIL, SELF.Heap, itsID, SELF.view, location, boxWidth, boxHeight,
wantLabel, labelOffset, itsTypeStyle);
SELF.AddImage(checkbox);
AddFreeCheckbox := checkbox;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TDialog.AddInputFrame(itsId: S255;
promptLocation: LPoint; promptTypeStyle: TTypeStyle;
inputLocation: LPoint; inputTypeStyle: TTypeStyle;
maxInputChars: INTEGER; itsBorders: Rect; drawInputLRect: BOOLEAN;
drawHitLRect: BOOLEAN): TInputFrame;
VAR inputFrame: TInputFrame;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
inputFrame := TInputFrame.CREATE(NIL, SELF.Heap, itsID, SELF.view, promptLocation, promptTypeStyle,
inputLocation, inputTypeStyle, maxInputChars, itsBorders,
drawInputLRect, drawHitLRect);
SELF.AddImage(inputFrame);
AddInputFrame := inputFrame;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TDialog.AddRowOfBoxes(itsID: S255; itsXLoc, itsYLoc: LONGINT; numberOfBoxes: INTEGER;
startingIDNumber: INTEGER; boxWidth: INTEGER; boxHeight: INTEGER; boxSpacing: INTEGER): TCluster;
VAR currentIDNumber: INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 401 of 1012

Apple Lisa Computer Technical Information


001628
001629
001630
001631
001632
001633
001634
001635
001636
001637
001638
001639
001640
001641
001642
001643
001644
001645
001646
001647
001648
001649
001650
001651
001652
001653
001654
001655
001656
001657
001658
001659
001660
001661
001662
001663
001664
001665
001666
001667
001668
001669
001670
001671
001672
001673
001674
001675

checkbox:
newLocation:
newID:
cluster:

TCheckbox;
LPoint;
S255;
TCluster;

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
cluster := SELF.AddStdCluster(itsID, itsXLoc, itsYLoc);
FOR currentIDNumber := startingIDNumber TO (startingIDNumber + numberOfBoxes - 1) DO
BEGIN
IF cluster.lastBox = NIL THEN {this is the first to be inserted}
newLocation := cluster.location
ELSE { There is already at least one box in the cluster -- align to right of it}
WITH newLocation DO
BEGIN
h := cluster.lastBox.rectImage.extentLRect.right + boxSpacing; {??}
v := cluster.lastBox.rectImage.extentLRect.top;
END;
IntToString(currentIDNumber, @newID);
checkbox := cluster.AddCheckbox(newID, newLocation, boxWidth, boxHeight, FALSE, zeroPt,
sysTypeStyle, FALSE);
checkBox.IDNumber := currentIDNumber;
END;
AddRowOfBoxes := cluster;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TDialog.AddStdInputFrame(itsId: S255; itsXLoc: LONGINT;
itsYLoc: LONGINT; maxInputChars : INTEGER): TInputFrame;
VAR promptLocation: LPoint;
inputLocation: LPoint;
inputFrame:
TInputFrame;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SetLPt(promptLocation, itsXLoc, itsYLoc);
SetQDTypeStyle(sysTypeStyle);
WITH inputLocation DO
BEGIN
h := itsXLoc + StringWidth(itsID) + 20;
v := itsYLoc;
END;
inputFrame := TInputFrame.CREATE(NIL, SELF.Heap, itsId, SELF.view, promptLocation, sysTypeStyle,
inputLocation, stdInputTypeStyle, maxInputChars,
stdFrameBorders, TRUE {draw input LRect}, TRUE {draw HitLRect});

Apple Lisa ToolKit 3.0 Source Code Listing -- 402 of 1012

Apple Lisa Computer Technical Information


001676
001677
001678
001679
001680
001681
001682
001683
001684
001685
001686
001687
001688
001689
001690
001691
001692
001693
001694
001695
001696
001697
001698
001699
001700
001701
001702
001703
001704
001705
001706
001707
001708
001709
001710
001711
001712
001713
001714
001715
001716
001717
001718
001719
001720
001721
001722
001723

SELF.AddImage(inputFrame);
AddStdInputFrame := inputFrame;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TDialog.AddStdLegend(itsId: S255; itsXLoc, itsYLoc: LONGINT;
itsTypeStyle: TTypeStyle): TLegend;
VAR newString: TLegend;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
newString := NewStdLegend(SELF.Heap, itsID, itsXLoc, itsYLoc, SELF.view, itsTypeStyle);
SELF.AddImage(newString);
AddStdLegend := newString;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TDialog.AddSysLegend(itsId: S255; itsXLoc, itsYLoc: LONGINT): TLegend;
VAR newString: TLegend;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
newString := NewSysLegend(SELF.Heap, itsID, itsXLoc, itsYLoc, SELF.view);
SELF.AddImage(newString);
AddSysLegend := newString;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialog.ButtonPushed(button: TButton); {usually'll be called through SUPERSELF}
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.parent <> NIL THEN
TDialog(SELF.parent).ButtonPushed(button)
ELSE
TDialogView(SELF.view).ButtonPushed(button);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialog.CheckboxHit(checkbox: TCheckbox; toggleDirection: BOOLEAN);
{default--passes up the line; client can reimplement}
BEGIN
{$IFC fTrace}BP(11);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 403 of 1012

Apple Lisa Computer Technical Information


001724
001725
001726
001727
001728
001729
001730
001731
001732
001733
001734
001735
001736
001737
001738
001739
001740
001741
001742
001743
001744
001745
001746
001747
001748
001749
001750
001751
001752
001753
001754
001755
001756
001757
001758
001759
001760
001761
001762
001763
001764
001765
001766
001767
001768
001769
001770
001771

IF SELF.parent <> NIL THEN


BEGIN
IF InClass(SELF.parent, TDialog) THEN
TDialog(SELF.parent).CheckboxHit(checkbox, toggleDirection)
ELSE
SELF.parent.ControlHit(checkbox, toggleDirection);
END
ELSE
TDialogView(SELF.view).CheckboxHit(checkbox, toggleDirection);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialog.ControlHit(control: TDialogImage; toggleDirection: BOOLEAN);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF InClass(control, TButton) THEN
SELF.ButtonPushed(TButton(control)) {this branch perhaps not achievable in current design}
ELSE
IF InClass(control, TCheckbox) THEN
SELF.CheckboxHit(TCheckbox(control), toggleDirection);
{Client can add own kinds by redefining this}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TDialog.DownAt(mouseLPt: LPoint): TDialogImage;
VAR s:
TListScanner;
dialogImage:
TDialogImage;
currentDialogImage: TDialogImage;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
currentDialogImage := NIL;
IF SELF.Hit(mouseLPt) THEN
BEGIN
s := SELF.children.Scanner;
WHILE s.Scan(dialogImage) DO
IF dialogImage.isActive THEN
BEGIN
currentDialogImage := dialogImage.DownAt(mouseLPt);
IF currentDialogImage <> NIL THEN
s.Done;
END;
END;
DownAt := currentDialogImage;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 404 of 1012

Apple Lisa Computer Technical Information


001772
001773
001774
001775
001776
001777
001778
001779
001780
001781
001782
001783
001784
001785
001786
001787
001788
001789
001790
001791
001792
001793
001794
001795
001796
001797
001798
001799
001800
001801
001802
001803
001804
001805
001806
001807
001808
001809
001810
001811
001812
001813
001814
001815
001816
001817
001818
001819

{$S DlgHot}
PROCEDURE TDialog.PushButton(button: TButton);
PROCEDURE TurnOnTheJuice;
BEGIN
button.Highlight(hOffToOn);
END;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF NOT button.isHighlighted THEN
SELF.view.panel.OnAllPadsDo(TurnOnTheJuice);
TDialogView(SELF.view).hitButton := button;
SELF.ButtonPushed(button);
{$IFC fTrace}EP;{$ENDC}
END;

{client or ToolKit may call}

{$S DlgWarm}
PROCEDURE TDialog.RecalcExtent;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SUPERSELF.RecalcExtent; {build up my size as the sum of the sizes of my children}
IF SELF.parent = NIL THEN
SELF.view.RecalcExtent;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
PROCEDURE TDialog.SetDefaultButton(button: TButton);
VAR thickPnSize:
point;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.parent <> NIL THEN
TDialog(SELF.parent).SetDefaultButton(button)
ELSE
TDialogView(SELF.view).SetDefaultButton(button);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TDialog.SelectInputFrame(inputFrame: TInputFrame);
VAR panel:
TPanel;
newFrameSel:
TFrameSelection;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 405 of 1012

Apple Lisa Computer Technical Information


001820
001821
001822
001823
001824
001825
001826
001827
001828
001829
001830
001831
001832
001833
001834
001835
001836
001837
001838
001839
001840
001841
001842
001843
001844
001845
001846
001847
001848
001849
001850
001851
001852
001853
001854
001855
001856
001857
001858
001859
001860
001861
001862
001863
001864
001865
001866
001867

panel := SELF.view.panel;
panel.BeginSelection;
newFrameSel := TFrameSelection(panel.selection.FreedAndReplacedBy(
TFrameSelection.CREATE(NIL, SELF.Heap, inputFrame)));
newFrameSel.coSelection.Become(
inputFrame.textDialogImage.textImage.text.SelectAll(
inputFrame.textDialogImage.textImage));
panel.Highlight(panel.selection.coSelection, hOffToOn);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
{-------------------------------------------------------------------------------------------------------}
METHODS OF TButton;
{$S DlgAlloc}
FUNCTION TButton.CREATE(object: TObject; heap: THeap; itsId: S255; itsView: TView;
itsLocation: LPoint; itsMetrics: TButtonMetrics;
sameSizedButton: TButton; itsCmdNumber: TCmdNumber): TButton;
VAR buttonLRect:
LRect;
itsLegend:
TLegend;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SetLRect(buttonLRect, -1, 0, 1, 1);
OffsetLRect(buttonLRect, itsLocation.h, itsLocation.v);
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TButton(TImageWithID.CREATE(object, heap, buttonLRect, itsId, itsView, TRUE));
WITH SELF DO
BEGIN
cmdNumber := itsCmdNumber;
buttonMetrics := itsMetrics;
isHighlighted := FALSE;
{minWidth will be set by RecalcExtent}
END;
IF sameSizedButton <> NIL THEN {weave me into chain of same-sized buttons}
BEGIN
SELF.nextSameSizedButton := sameSizedButton.nextSameSizedButton;

Apple Lisa ToolKit 3.0 Source Code Listing -- 406 of 1012

Apple Lisa Computer Technical Information


001868
001869
001870
001871
001872
001873
001874
001875
001876
001877
001878
001879
001880
001881
001882
001883
001884
001885
001886
001887
001888
001889
001890
001891
001892
001893
001894
001895
001896
001897
001898
001899
001900
001901
001902
001903
001904
001905
001906
001907
001908
001909
001910
001911
001912
001913
001914
001915

sameSizedButton.nextSameSizedButton := SELF;
END
ELSE
SELF.nextSameSizedButton := SELF;
itsLegend := NewStdLegend(heap, itsID, itsLocation.h, itsLocation.v, SELF.view,
itsMetrics.typeStyle);
SELF.AddImage(itsLegend);
SELF.Resize(buttonLRect); {the AddImage will've made things out of balance}
SELF.legend := itsLegend;
itsLegend.wouldBeDraggable := FALSE; {as an entity unto itself during layout}
SELF.RecalcExtent;

{performs lots of magic}

{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TButton.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('cmdNumber: INTEGER');
Field('minWidth: INTEGER');
Field('isHighlighted: BOOLEAN');
Field('nextSameSizedButton: TButton');
Field('legend: TLegend');
Field(CONCAT('buttonMetrics: RECORD height: INTEGER; curvH: INTEGER; curvV: INTEGER;',
'typeStyle: LONGINT; expandNum: INTEGER; expandDen: INTEGER;',
'absMinWidth: INTEGER; penState: ARRAY[1..18] OF Byte END'));
Field('');
END;
{$ENDC}
{$S DlgHot}
PROCEDURE TButton.DrawJustMe;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SetPenState(SELF.buttonMetrics.penState);
FrameLRRect(SELF.extentLRect, SELF.buttonMetrics.curvH, SELF.buttonMetrics.curvV);
IF SELF.isHighlighted THEN
InvrtLRRect(SELF.extentLRect, SELF.buttonMetrics.curvH, SELF.buttonMetrics.curvV);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 407 of 1012

Apple Lisa Computer Technical Information


001916
001917
001918
001919
001920
001921
001922
001923
001924
001925
001926
001927
001928
001929
001930
001931
001932
001933
001934
001935
001936
001937
001938
001939
001940
001941
001942
001943
001944
001945
001946
001947
001948
001949
001950
001951
001952
001953
001954
001955
001956
001957
001958
001959
001960
001961
001962
001963

{$S DlgHot}
PROCEDURE TButton.Highlight(highTransit: THighTransit);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
InvrtLRRect(SELF.extentLRect, SELF.buttonMetrics.curvH, SELF.buttonMetrics.curvV);
SELF.isHighLighted := (highTransit = hOffToOn);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgLayout}
FUNCTION TButton.LaunchLayoutBox(view: TView): TImage;
VAR layoutBox:
TLayoutBox;
layBoxExtent:
LRect;
s:
TListScanner;
childLayoutBox: TLayoutBox;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
LaunchLayoutBox := TButtonLayoutBox.CREATE(NIL, SELF.Heap, SELF, view);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TButton.MousePress(mouseLPt: LPoint);
PROCEDURE TurnOnButton;
BEGIN
SELF.HighLight(hOffToOn);
END;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.view.panel.OnAllPadsDo(TurnOnButton);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TButton.MouseRelease;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
TDialog(SELF.parent).PushButton(SELF);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
PROCEDURE TButton.RecalcExtent;
VAR dialogView:
TDialogView;

Apple Lisa ToolKit 3.0 Source Code Listing -- 408 of 1012

Apple Lisa Computer Technical Information


001964
001965
001966
001967
001968
001969
001970
001971
001972
001973
001974
001975
001976
001977
001978
001979
001980
001981
001982
001983
001984
001985
001986
001987
001988
001989
001990
001991
001992
001993
001994
001995
001996
001997
001998
001999
002000
002001
002002
002003
002004
002005
002006
002007
002008
002009
002010
002011

curWidth:
INTEGER;
timesThrough:
INTEGER;
nextButton:
TButton;
legend:
TLegend;
paraImage:
TParaImage;
width:
INTEGER;
styleIndex:
INTEGER;
oldLegendLoc:
LPoint;
lRectToInval:
LRect;
legLength:
INTEGER;
textDialogImage:
TTextDialogImage;
editLegendSelection:TEditLegendSelection;
paraExtent:
LRect;

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
lRectToInval := SELF.extentLRect;
legend := TLegend(SELF.children.First);
oldLegendLoc := legend.location;

WITH legend.extentLRect DO
legLength := right - left;
WITH SELF, buttonMetrics DO
{$H-}
minWidth := MAX(absMinWidth, (legLength * expandNum) DIV expandDen);

{$H+}

curWidth := SELF.minWidth;
FOR timesThrough := 1 TO 2 DO
BEGIN
nextButton := SELF.nextSameSizedButton;
WHILE nextButton <> SELF DO {send this round my circle of same-sized buttons}
BEGIN
nextButton.Recompute(curWidth);
WITH nextButton.extentLRect DO
curWidth := right - left;
nextButton := nextButton.nextSameSizedButton;
END;
SELF.Recompute(curWidth);
END;
UnionLRect(lRectToInval, SELF.extentLRect, lRectToInval);
IF TDialogView(SELF.view).isShowing THEN
SELF.view.panel.InvalLRect(lRectToInval);
IF SELF.parent <> NIL THEN
SELF.parent.RecalcExtent;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 409 of 1012

Apple Lisa Computer Technical Information


002012
002013
002014
002015
002016
002017
002018
002019
002020
002021
002022
002023
002024
002025
002026
002027
002028
002029
002030
002031
002032
002033
002034
002035
002036
002037
002038
002039
002040
002041
002042
002043
002044
002045
002046
002047
002048
002049
002050
002051
002052
002053
002054
002055
002056
002057
002058
002059

{$S DlgAlloc}
PROCEDURE TButton.Recompute(minWidth: INTEGER);
VAR buttonWidth:
INTEGER;
labelWidth:
INTEGER;
legend:
TLegend;
topLeft:
LPoint;
shape:
LRect;
offset:
LPoint;
width:
INTEGER;
curLegendWidth: INTEGER;
textExtent:
LRect;
topCenter:
LPoint;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
legend := SELF.legend;
topLeft := SELF.extentLRect.topLeft;
WITH topCenter, SELF.extentLRect DO
BEGIN
v := top;
h := (left + right) DIV 2;
END;
buttonWidth := SELF.minWidth;
IF buttonWidth < minWidth THEN
buttonWidth := minWidth;
SetParaExtent(legend.paragraph, SELF.view, zeroLPt, textExtent);
curLegendWidth := textExtent.right;
SetLPt(offset, (topCenter.h - (curLegendWidth DIV 2)) - legend.location.h,
(topCenter.v +
((SELF.buttonMetrics.height DIV 2) + 3)) - legend.location.v);
legend.OffsetBy(offset);
SetLRect(shape, 0, 0, buttonWidth, SELF.buttonMetrics.height);
OffSetLRect(shape, topCenter.h - (buttonWidth DIV 2), topCenter.v);
SELF.Resize(shape);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TButton.StillMyMouse(mouseLPt: LPoint): BOOLEAN;
{Called when the mouse which went down in me has moved; possibly it is no longer in me}
PROCEDURE TurnOffButton;
BEGIN
SELF.Highlight(hOnToOff);

Apple Lisa ToolKit 3.0 Source Code Listing -- 410 of 1012

Apple Lisa Computer Technical Information


002060
002061
002062
002063
002064
002065
002066
002067
002068
002069
002070
002071
002072
002073
002074
002075
002076
002077
002078
002079
002080
002081
002082
002083
002084
002085
002086
002087
002088
002089
002090
002091
002092
002093
002094
002095
002096
002097
002098
002099
002100
002101
002102
002103
002104
002105
002106
002107

END;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.Hit(mouseLPt) THEN
StillMyMouse := TRUE {still in same button -- do nothing}
ELSE { no longer in the button ; need to unhilight and remove claim }
BEGIN
SELF.view.panel.OnAllPadsDo(TurnOffButton);
StillMyMouse := FALSE; {see if anyone else wants this guy}
END ;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
{-------------------------------------------------------------------------------------------------------}
METHODS OF TCheckbox;
{$S DlgAlloc}
FUNCTION TCheckbox.CREATE(object: TObject; heap: THeap; itsId: S255; itsView: TView;
itsLocation: LPoint; boxWidth: INTEGER; boxHeight: INTEGER; wantLabel: BOOLEAN;
labelOffset: Point; itsTypeStyle: TTypeStyle): TCheckbox;
VAR extentLRect:
LRect;
tempLRect:
LRect;
rectImage:
TRectImage;
stringLoc:
LPoint;
itsString:
TLegend;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SetLRect(extentLRect, 0, 0, boxWidth, boxHeight);
OffsetLRect(extentLRect, itsLocation.h, itsLocation.v);
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TCheckbox(TImageWithID.CREATE(object, heap, extentLRect, itsId, itsView, TRUE));
SELF.isSelected := FALSE;
rectImage := TRectImage.CREATE(NIL, heap, extentLRect, noID, itsView, normalPen, FALSE);
SELF.AddImage(rectImage);
SELF.rectImage := rectImage;

Apple Lisa ToolKit 3.0 Source Code Listing -- 411 of 1012

Apple Lisa Computer Technical Information


002108
002109
002110
002111
002112
002113
002114
002115
002116
002117
002118
002119
002120
002121
002122
002123
002124
002125
002126
002127
002128
002129
002130
002131
002132
002133
002134
002135
002136
002137
002138
002139
002140
002141
002142
002143
002144
002145
002146
002147
002148
002149
002150
002151
002152
002153
002154
002155

IF wantLabel THEN
BEGIN
itsString := NewStdLegend(SELF.Heap, itsID, extentLRect.right + labelOffset.h,
extentLRect.bottom + labelOffset.v, itsView, itsTypeStyle);
SELF.AddImage(itsString);
SELF.legend := itsString;
END
ELSE
SELF.legend := NIL;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TCheckbox.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('isSelected: BOOLEAN');
Field('rectImage: TRectImage');
Field('legend: TLegend');
Field('');
END;
{$ENDC}
{$S DlgHot}
PROCEDURE TCheckbox.ChangeLabel(newS255: S255);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.legend = NIL THEN
{$IFC fDbgOK}
ABCBreak('No legend to chg', 0) {later could perhaps launch a new label}
{$ENDC}
ELSE
SELF.legend.ChangeString(newS255);
SELF.RecalcExtent;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TCheckbox.CursorAt(mouseLPt: LPoint): TCursorNumber;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.Hit(mouseLPt) THEN
CursorAt := checkCursor
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 412 of 1012

Apple Lisa Computer Technical Information


002156
002157
002158
002159
002160
002161
002162
002163
002164
002165
002166
002167
002168
002169
002170
002171
002172
002173
002174
002175
002176
002177
002178
002179
002180
002181
002182
002183
002184
002185
002186
002187
002188
002189
002190
002191
002192
002193
002194
002195
002196
002197
002198
002199
002200
002201
002202
002203

CursorAt := noCursor;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TCheckbox.Draw;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
PenNormal;
IF SELF.IsSelected THEN
FillLRect(SELF.rectImage.extentLRect, lPatBlack)
{fill with black if selected}
ELSE
FillLRect(SELF.rectImage.extentLRect, lPatWhite);
SELF.rectImage.Draw;
{draw the outline box in any case}
IF SELF.legend <> NIL THEN
SELF.legend.Draw;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgLayout}
FUNCTION TCheckbox.LaunchLayoutBox(view: TView): TImage;
VAR layoutBox:
TLayoutBox;
childLayoutBox: TLayoutBox;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.legend <> NIL THEN {has string; use normal layout box}
LaunchLayoutBox := SUPERSELF.LaunchLayoutBox(view)
ELSE
BEGIN {a checkbox without an associated string}
childLayoutBox := TLayoutBox(SELF.rectImage.LaunchLayoutBox(view));
layoutBox := TLayoutBox.CREATE(NIL, SELF.Heap, childLayoutBox.extentLRect, noID, NIL,
view, SELF, zeroRect, FALSE, FALSE, TRUE);
layoutBox.AddImage(childLayoutBox);
LaunchLayoutBox := layoutBox;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TCheckbox.MousePress(mouseLPt: LPoint);
{This proc is only called for mouspresses within "free check boxes", which is to say Checkboxes
which are componenents of a dialogView -- NOT for Checkboxes which are subdialogImages of another dialogImage}
VAR carryOutTheToggle: BOOLEAN;
dialogView:
TDialogView;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 413 of 1012

Apple Lisa Computer Technical Information


002204
002205
002206
002207
002208
002209
002210
002211
002212
002213
002214
002215
002216
002217
002218
002219
002220
002221
002222
002223
002224
002225
002226
002227
002228
002229
002230
002231
002232
002233
002234
002235
002236
002237
002238
002239
002240
002241
002242
002243
002244
002245
002246
002247
002248
002249
002250
002251

{$IFC fTrace}BP(11);{$ENDC}
carryOutTheToggle := TRUE;
dialogView := TDialogView(SELF.view);
IF dialogView.paintFreeBoxes THEN {need to worry about only toggling if in current sense}
BEGIN
IF dialogView.startedPainting THEN {have already started 'painting' free checkboxes}
BEGIN
IF dialogView.paintSense = SELF.isSelected THEN
carryOutTheToggle := FALSE {already in the sense being painted--do nothing}
END
ELSE {just starting painting; establish the painting sense}
BEGIN
dialogView.startedPainting := TRUE;
dialogView.paintSense := NOT SELF.isSelected;
END;
END;
IF carryOutTheToggle THEN
BEGIN
SELF.Toggle;
dialogView.panel.InvalLRect(SELF.rectImage.extentLRect);
SELF.ControlHit(SELF, SELF.isSelected); {pass it up to cluster and Dialog and even DialogView}
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TCheckbox.Toggle;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.isSelected := NOT SELF.isSelected;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
{-------------------------------------------------------------------------------------------------------}
METHODS OF TCluster;
{$S DlgAlloc}
FUNCTION TCluster.CREATE(object: TObject; heap: THeap; itsId: S255; itsView: TView;
itsLocation: LPoint): TCluster;
VAR extentLRect: LRect;

Apple Lisa ToolKit 3.0 Source Code Listing -- 414 of 1012

Apple Lisa Computer Technical Information


002252
002253
002254
002255
002256
002257
002258
002259
002260
002261
002262
002263
002264
002265
002266
002267
002268
002269
002270
002271
002272
002273
002274
002275
002276
002277
002278
002279
002280
002281
002282
002283
002284
002285
002286
002287
002288
002289
002290
002291
002292
002293
002294
002295
002296
002297
002298
002299

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
WITH itsLocation DO
SetLRect(extentLRect, h, v, h + 1, v + 1); {include that pt in ultimate extent}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TCluster(TImageWithID.CREATE(object, heap, extentLRect, itsId, itsView, TRUE));
WITH SELF DO
BEGIN
location := itsLocation;
hitBox := NIL;
hiLitBox := NIL;
lastBox := NIL;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TCluster.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('location: LPoint');
Field('hitBox: TCheckBox');
Field('hiLitBox: TCheckBox');
Field('lastBox: TCheckBox');
Field('');
END;
{$ENDC}
{$S DlgAlloc}
FUNCTION TCluster.AddAlignedCheckbox(itsId: S255; selectThisOne: BOOLEAN): TCheckbox;
CONST
stdIncrement = 20;
VAR lastBox:
TCheckbox;
location:
LPoint;
itsBoxWidth:
INTEGER;
itsBoxHeight:
INTEGER;
checkBox:
TCheckbox;
wantLabel:
BOOLEAN;
labelOffset:
Point;
vhs:
VHSelect;
itsTypeStyle:
TTypeStyle;
styleChange:
TStyleChange;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 415 of 1012

Apple Lisa Computer Technical Information


002300
002301
002302
002303
002304
002305
002306
002307
002308
002309
002310
002311
002312
002313
002314
002315
002316
002317
002318
002319
002320
002321
002322
002323
002324
002325
002326
002327
002328
002329
002330
002331
002332
002333
002334
002335
002336
002337
002338
002339
002340
002341
002342
002343
002344
002345
002346
002347

itsTypeStyle := sysTypeStyle;
wantLabel := (itsID <> noID);
labelOffset := stdLabelOffset;
itsBoxWidth := stdBoxWidth;
itsBoxHeight := stdBoxHeight;
lastBox := SELF.lastBox;
IF lastBox = NIL THEN {this is the first to be inserted}
location := SELF.location
ELSE
{there is already at least one box in the cluster -- align to right of it & use its params}
BEGIN
WITH location DO
BEGIN
h := lastBox.extentLRect.right + stdIncrement;
v := lastBox.rectImage.extentLRect.top;
END;
WITH lastBox.rectImage.extentLRect DO
BEGIN
itsBoxWidth := right - left;
itsBoxHeight := bottom - top;
END;
IF wantLabel THEN
BEGIN
IF lastBox.legend <> NIL THEN
{use same type style and label Offset as prev guy}
BEGIN
lastBox.legend.paragraph.typeStyles.GetAt(1, @styleChange);
WITH lastBox, legend DO
BEGIN
itsTypeStyle := styleChange.newStyle;
FOR vhs := v TO h DO
labelOffset.vh[vhs] := location.vh[vhs] rectImage.extentLRect.botRight.vh[vhs];
END;
END
ELSE
wantLabel := FALSE; {last box did not have a label, so I won't either}
END;
END;
checkBox := SELF.AddCheckbox(itsID, location, itsBoxWidth, itsBoxHeight,
wantLabel, labelOffset, itsTypeStyle, selectThisOne);
IF lastBox <> NIL THEN
checkbox.idNumber := lastBox.idNumber + 1;
AddAlignedCheckbox := checkbox;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 416 of 1012

Apple Lisa Computer Technical Information


002348
002349
002350
002351
002352
002353
002354
002355
002356
002357
002358
002359
002360
002361
002362
002363
002364
002365
002366
002367
002368
002369
002370
002371
002372
002373
002374
002375
002376
002377
002378
002379
002380
002381
002382
002383
002384
002385
002386
002387
002388
002389
002390
002391
002392
002393
002394
002395

{$S DlgAlloc}
FUNCTION TCluster.NewAlignedCheckbox(itsPhrase: INTEGER; selectThisOne: BOOLEAN): TCheckbox;
VAR itsID:
S255;
itsLocation:
LPoint;
checkbox:
TCheckbox;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
GetTextAndLocation(itsPhrase, itsID, itsLocation);
checkbox := SELF.AddAlignedCheckbox(itsID, selectThisOne);
checkbox.idNumber := itsPhrase;
NewAlignedCheckbox := checkbox;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TCluster.AddCheckbox(itsID: S255; itsLocation: LPoint; boxWidth: INTEGER;
boxHeight: INTEGER; wantLabel: BOOLEAN; labelOffset: Point;
itsTypeStyle: TTypeStyle; selectThisOne: BOOLEAN): TCheckbox;
VAR location:
LPoint;
checkbox:
TCheckbox;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
checkbox := TCheckbox.CREATE(NIL, SELF.Heap, itsID, SELF.view, itsLocation, boxWidth,
boxHeight, wantLabel, labelOffset, itsTypeStyle);
SELF.AddImage(checkbox);
SELF.lastBox := checkbox;
IF selectThisOne THEN
BEGIN
IF NOT checkbox.isSelected THEN
checkbox.Toggle;
SELF.hiLitBox := checkbox;
END;
AddCheckbox := checkbox;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TCluster.NewCheckbox(itsPhrase: INTEGER; boxWidth: INTEGER;
boxHeight: INTEGER; wantLabel: BOOLEAN; labelOffset: Point; itsTypeStyle: TTypeStyle;
selectThisOne: BOOLEAN): TCheckbox;
VAR itsID:
S255;
itsLocation:
LPoint;
checkbox:
TCheckbox;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 417 of 1012

Apple Lisa Computer Technical Information


002396
002397
002398
002399
002400
002401
002402
002403
002404
002405
002406
002407
002408
002409
002410
002411
002412
002413
002414
002415
002416
002417
002418
002419
002420
002421
002422
002423
002424
002425
002426
002427
002428
002429
002430
002431
002432
002433
002434
002435
002436
002437
002438
002439
002440
002441
002442
002443

GetTextAndLocation(itsPhrase, itsID, itsLocation);


checkbox := SELF.AddCheckbox(itsID, itsLocation, boxWidth, boxHeight, wantLabel,
itsTypeStyle, selectThisOne);
checkbox.idNumber := itsPhrase;
NewCheckbox := checkbox;
{$IFC fTrace}EP;{$ENDC}
END;

labelOffset,

{$S DlgAlloc}
PROCEDURE TCluster.AddRowOfBoxes(numberOfBoxes: INTEGER; startingIDNumber: INTEGER;
boxWidth: INTEGER; boxHeight: INTEGER; boxSpacing: INTEGER);
VAR currentIDNumber: INTEGER;
checkbox:
TCheckbox;
newLocation:
LPoint;
newID:
S255;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
FOR currentIDNumber := startingIDNumber TO (startingIDNumber + numberOfBoxes - 1) DO
BEGIN
IF SELF.lastBox = NIL THEN {this is the first to be inserted}
newLocation := SELF.location
ELSE { There is already at least one box in the cluster -- align to right of it}
WITH newLocation DO
BEGIN
h := SELF.lastBox.rectImage.extentLRect.right + boxSpacing; {??}
v := SELF.lastBox.rectImage.extentLRect.top;
END;
IntToString(currentIDNumber, @newID);
checkbox := SELF.AddCheckbox(newID, newLocation, boxWidth, boxHeight, FALSE, zeroPt,
sysTypeStyle, FALSE);
checkBox.IDNumber := currentIDNumber;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TCluster.Hit(mouseLPt: LPoint): BOOLEAN;
VAR checkbox:
TCheckbox;
s:
TListScanner;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
Hit := FALSE;
IF LRectHasLPt(SELF.extentLRect, mouseLPt) THEN
BEGIN
s := SELF.children.Scanner;
WHILE s.Scan(checkbox) DO

{passes coarsest hit test; look more deeply now}

Apple Lisa ToolKit 3.0 Source Code Listing -- 418 of 1012

Apple Lisa Computer Technical Information


002444
002445
002446
002447
002448
002449
002450
002451
002452
002453
002454
002455
002456
002457
002458
002459
002460
002461
002462
002463
002464
002465
002466
002467
002468
002469
002470
002471
002472
002473
002474
002475
002476
002477
002478
002479
002480
002481
002482
002483
002484
002485
002486
002487
002488
002489
002490
002491

IF checkbox.Hit(mouseLPt) THEN
BEGIN
Hit := TRUE;
SELF.hitBox := checkbox;
s.Done;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TCluster.MousePress(mouseLPt: LPoint);
{We are assured that when this is called, it will have been immediately
preceded by a successful call to TCluster.Hit . Hence, the field
TCluster.hitBox will correctly point to which guy was hit.}
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.SelectBox(SELF.hitBox); {will deselect any other}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TCluster.SelectBox(checkbox: TCheckbox); {select this box, deselecting others}
PROCEDURE DrawUnHiLitBoxOnThePad;
BEGIN
SELF.hiLitBox.Draw; {redraw old box unhilit}
END;
PROCEDURE DrawHiLitBoxOnThePad;
BEGIN
checkbox.Draw;
{toggle the newly selected one on}
END;

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF (SELF.hiLitBox <> checkbox) AND (checkbox <> NIL) THEN
BEGIN
IF SELF.hiLitBox <> NIL THEN
BEGIN
SELF.hiLitBox.Toggle;
SELF.view.panel.OnAllPadsDo(DrawUnHiLitBoxOnThePad);
SELF.ControlHit(SELF.hiLitBox, FALSE);
END;
SELF.hiLitBox := checkbox;
{set new box as the currently hilit one}
checkbox.Toggle;
SELF.view.panel.OnAllPadsDo(DrawHiLitBoxOnThePad);
SELF.ControlHit(checkbox, TRUE);

Apple Lisa ToolKit 3.0 Source Code Listing -- 419 of 1012

Apple Lisa Computer Technical Information


002492
002493
002494
002495
002496
002497
002498
002499
002500
002501
002502
002503
002504
002505
002506
002507
002508
002509
002510
002511
002512
002513
002514
002515
002516
002517
002518
002519
002520
002521
002522
002523
002524
002525
002526
002527
002528
002529
002530
002531
002532
002533
002534
002535
002536
002537
002538
002539

END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TCluster.StillMyMouse(mouseLPt: LPoint): BOOLEAN;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.Hit(mouseLPt) THEN {mouse is in a box of the cluster}
BEGIN
SELF.SelectBox(SELF.hitBox);
{will toggle any alternate box off}
StillMyMouse := TRUE;
END
ELSE {mouse not in any of my box's hit areas at the moment}
StillMyMouse := FALSE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
METHODS OF TInputFrame;
{$S DlgAlloc}
FUNCTION TInputFrame.CREATE(object: TObject; heap: THeap; itsId: S255; itsView: TView;
promptLocation: LPoint; promptTypeStyle: TTypeStyle;
inputLocation: LPoint; inputTypeStyle: TTypeStyle; maxInputChars: INTEGER;
itsBorders: Rect; drawInputLRect: BOOLEAN; drawHitLRect: BOOLEAN): TInputFrame;
VAR textExtent:
LRect;
myOwnExtentLRect:
LRect;
prompt:
TLegend;
textDialogImage:
TTextDialogImage;
{$IFC libraryVersion <= 20}
{* * * P E P S I * * *}
fInfo:
TFInfo;
{$ELSEC}
{* * S P R I N G * *}
fInfo:
FontInfo;
{$ENDC}
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
prompt := TLegend.CREATE(NIL, heap, itsID, itsView, promptLocation, promptTypeStyle);
SetQDTypeStyle(inputTypeStyle);
GetFontInfo(fInfo);
WITH fInfo DO

Apple Lisa ToolKit 3.0 Source Code Listing -- 420 of 1012

Apple Lisa Computer Technical Information


002540
002541
002542
002543
002544
002545
002546
002547
002548
002549
002550
002551
002552
002553
002554
002555
002556
002557
002558
002559
002560
002561
002562
002563
002564
002565
002566
002567
002568
002569
002570
002571
002572
002573
002574
002575
002576
002577
002578
002579
002580
002581
002582
002583
002584
002585
002586
002587

SetLRect(textExtent, 0, -ascent - leading, maxInputChars * widMax,

descent + leading);

OffsetLRect(textExtent, inputLocation.h, inputLocation.v);


textDialogImage := TTextDialogImage.CREATE(NIL, heap, textExtent, 'input', itsView,
inputTypeStyle, '');
UnionLRect(prompt.extentLRect, textDialogImage.extentLRect, myOwnExtentLRect);
LRectAddBorders(myOwnExtentLRect, itsBorders, myOwnExtentLRect);
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TInputFrame(TImageWithID.CREATE(object, heap, myOwnExtentLRect, itsId, itsView, TRUE));
SELF.prompt := prompt;
SELF.AddImage(prompt);
SELF.textDialogImage := textDialogImage;
SELF.AddImage(textDialogImage);
SELF.inputTypeStyle := inputTypeStyle;
SELF.maxInputChars := maxInputChars;
SELF.drawHitLRect := drawHitLRect;
SELF.drawInputLRect := drawInputLRect;
SELF.borders := itsBorders;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TInputFrame.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('textDialogImage: TTextDialogImage');
Field('prompt: TLegend');
Field('borders: Rect');
Field('drawInputLRect: BOOLEAN');
Field('drawHitLRect: BOOLEAN');
Field('maxInputChars: INTEGER');
Field('inputTypeStyle: LONGINT');
{make this right someday}
Field('');
END;
{$ENDC}
{$S DlgText}
FUNCTION TInputFrame.CursorAt(mouseLPt: LPoint): TCursorNumber;

Apple Lisa ToolKit 3.0 Source Code Listing -- 421 of 1012

Apple Lisa Computer Technical Information


002588
002589
002590
002591
002592
002593
002594
002595
002596
002597
002598
002599
002600
002601
002602
002603
002604
002605
002606
002607
002608
002609
002610
002611
002612
002613
002614
002615
002616
002617
002618
002619
002620
002621
002622
002623
002624
002625
002626
002627
002628
002629
002630
002631
002632
002633
002634
002635

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.Hit(mouseLPt) THEN
CursorAt := textCursor
ELSE
CursorAt := noCursor;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgText}
PROCEDURE TInputFrame.Draw;
VAR tempLRect: LRect;
pat:
pattern;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.prompt <> NIL THEN
SELF.prompt.Draw;
SELF.textDialogImage.Draw;
{draw the current input characters lying there...}
IF SELF.drawInputLRect THEN
BEGIN
tempLRect := SELF.textDialogImage.textImage.extentLRect;
InsetLRect(tempLRect, -6, -4);
PenNormal;
thePad.LPatToPat(lPatGray, pat);
PenPat(pat);
PenSize(1,1);
FrameLRect(tempLRect); {mostly for debugging reassurance...}
END;
IF SELF.drawHitLRect THEN
FrameLRect(SELF.extentLRect);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgLayout}
FUNCTION TInputFrame.LaunchLayoutBox(view: TView): TImage;
{In the future, if there were one, we would want to allow resizing of the hit area during
layout, and would here launch a special type of layout box, TInptFrmLayoutBox, to do layout just right}
VAR layoutBox:
TLayoutBox;
layBoxExtent:
LRect;
s:
TListScanner;
childLayoutBox: TLayoutBox;
newBorders:
Rect;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
layoutBox := TLayoutBox(SUPERSELF.LaunchLayoutBox(view)); {i.e., TImageWithID's launch}
WITH layoutBox.borders DO

Apple Lisa ToolKit 3.0 Source Code Listing -- 422 of 1012

Apple Lisa Computer Technical Information


002636
002637
002638
002639
002640
002641
002642
002643
002644
002645
002646
002647
002648
002649
002650
002651
002652
002653
002654
002655
002656
002657
002658
002659
002660
002661
002662
002663
002664
002665
002666
002667
002668
002669
002670
002671
002672
002673
002674
002675
002676
002677
002678
002679
002680
002681
002682
002683

BEGIN
top := SELF.borders.top;
right := SELF.borders.right - right;
bottom := SELF.borders.bottom - bottom;
left := SELF.borders.left - left;
END;
layoutBox.RecalcExtent;
LaunchLayoutBox := layoutBox;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgText}
PROCEDURE TInputFrame.MousePress(mouseLPt: LPoint);
VAR frameSelection: TFrameSelection;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
LRectHaveLPt(SELF.textDialogImage.textImage.extentLRect, mouseLPt);
TDialogView(SELF.view).magnetCursor := textCursor;
frameSelection := TFrameSelection(SELF.view.panel.selection.FreedAndReplacedBy(
TFrameSelection.CREATE(NIL, SELF.Heap, SELF)));
SELF.textDialogImage.textImage.MousePress(mouseLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgText}
PROCEDURE TInputFrame.GetContents(VAR theStr: S255);
VAR paraImage: TParaImage;
paragraph: TParagraph;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
paraImage := TParaImage(SELF.textDialogImage.textImage.imageList.First);
paragraph := paraImage.paragraph;
paragraph.ToPStr(@theStr);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgLayout}
PROCEDURE TInputFrame.RecalcExtent;
VAR newExtent: LRect;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.prompt <> NIL THEN
UnionLRect(SELF.prompt.extentLRect, SELF.textDialogImage.extentLRect, newExtent)
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 423 of 1012

Apple Lisa Computer Technical Information


002684
002685
002686
002687
002688
002689
002690
002691
002692
002693
002694
002695
002696
002697
002698
002699
002700
002701
002702
002703
002704
002705
002706
002707
002708
002709
002710
002711
002712
002713
002714
002715
002716
002717
002718
002719
002720
002721
002722
002723
002724
002725
002726
002727
002728
002729
002730
002731

newExtent := SELF.textDialogImage.extentLRect;
LRectAddBorders(newExtent, SELF.borders, newExtent);
SELF.Resize(newExtent);
IF SELF.parent <> NIL THEN
SELF.parent.RecalcExtent;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgText}
FUNCTION TInputFrame.StillMyMouse(mouseLPt: LPoint): BOOLEAN;
{in this implementation, once the insertion point has been dropped, we don't give up
control even if user now strays outside our hit area}
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
LRectHaveLPt(SELF.textDialogImage.textImage.extentLRect, mouseLPt);
SELF.view.panel.selection.coSelection.MouseMove(mouseLPt); {currently, just pass it on to the
text selection}
StillMyMouse := TRUE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgText}
PROCEDURE TInputFrame.SupplantContents(newStr: S255);
VAR paragraph: TParagraph;
paraImage: TParaImage;
textImage: TTextImage;
oldCount:
INTEGER;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
textImage := SELF.textDialogImage.textImage;
paraImage := TParaImage(textImage.imageList.First);
paragraph := paraImage.paragraph;
oldCount := paragraph.size;
paragraph.ReplPString(0, oldCount, @newStr);
paraImage.changed := TRUE;
paraImage.InvalLinesWith(0, MAXINT);
textImage.RecomputeImages(actionNone, TRUE);
IF TDialogView(SELF.view).isShowing THEN
SELF.view.panel.InvalLRect(SELF.textDialogImage.extentLRect);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 424 of 1012

Apple Lisa Computer Technical Information


002732
002733
002734
002735
002736
002737
002738
002739
002740
002741
002742
002743
002744
002745
002746
002747
002748
002749
002750
002751
002752
002753
002754
002755
002756
002757
002758
002759
002760
002761
002762
002763
002764
002765
002766
002767
002768
002769
002770
002771
002772
002773
002774
002775
002776
002777
002778
002779

{$S DlgInit}
END;
METHODS OF TLegend;
{$S TK2Start}
FUNCTION TLegend.CREATE(object: TObject; heap: THeap; itsChars: S255; itsView: TView;
itsLocation: LPoint; itsTypeStyle: TTypeStyle): TLegend;
VAR itsExtent:
LRect;
height:
INTEGER;
itsParagraph:
TParagraph;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
itsParagraph := TParagraph.CREATE(NIL, heap, LENGTH(itsChars), itsTypeStyle);
itsParagraph.InsPStrAt(1, @itsChars);
SetParaExtent(itsParagraph, itsView, itsLocation, itsExtent);
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TLegend(TDialogImage.CREATE(object, heap, itsExtent, noID, itsView, FALSE));
WITH SELF DO
BEGIN
location := itsLocation;
paragraph := itsParagraph;
wouldBeDraggable := TRUE;
usesSysFont := (itsTypeStyle.font.fontFamily = famSystem);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgCold}
PROCEDURE TLegend.Free;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
Free(SELF.paragraph);
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TLegend.Fields(PROCEDURE Field(nameAndType: S255));

Apple Lisa ToolKit 3.0 Source Code Listing -- 425 of 1012

Apple Lisa Computer Technical Information


002780
002781
002782
002783
002784
002785
002786
002787
002788
002789
002790
002791
002792
002793
002794
002795
002796
002797
002798
002799
002800
002801
002802
002803
002804
002805
002806
002807
002808
002809
002810
002811
002812
002813
002814
002815
002816
002817
002818
002819
002820
002821
002822
002823
002824
002825
002826
002827

BEGIN
SUPERSELF.Fields(Field);
Field('location: LPoint');
Field('paragraph: TParagraph');
Field('wouldBeDraggable: BOOLEAN');
Field('usesSysFont: BOOLEAN');
Field('');
END;
{$ENDC}
{$S DlgHot}
PROCEDURE TLegend.ChangeToPhrase(newPhrase: INTEGER);
VAR newString: S255;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
process.GetAlert(newPhrase, newString);
SELF.ChangeString(newString);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TLegend.ChangeString(newString: S255);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.view.panel.InvalLRect(SELF.extentLRect); {invalidate old string's bounding box}
SELF.paragraph.DelAll;
SELF.paragraph.InsPStrAt(1, @newString);
SELF.GetBoxRight;
SELF.view.panel.InvalLRect(SELF.extentLRect); {invalidate new string's bounding box}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TLegend.Draw;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
MoveToL(SELF.location.h, SELF.location.v);
SELF.paragraph.Draw(1, SELF.paragraph.size);
{$IFC fTrace}EP;{$ENDC}
END;
{$S TK2Start}
PROCEDURE TLegend.GetBoxRight;
VAR newExtent:
LRect;

Apple Lisa ToolKit 3.0 Source Code Listing -- 426 of 1012

Apple Lisa Computer Technical Information


002828
002829
002830
002831
002832
002833
002834
002835
002836
002837
002838
002839
002840
002841
002842
002843
002844
002845
002846
002847
002848
002849
002850
002851
002852
002853
002854
002855
002856
002857
002858
002859
002860
002861
002862
002863
002864
002865
002866
002867
002868
002869
002870
002871
002872
002873
002874
002875

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SetParaExtent(SELF.paragraph, SELF.view, SELF.location, newExtent);
SELF.Resize(newExtent);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TLegend.GetString(VAR itsString: S255);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.paragraph.ToPStr(@itsString);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
FUNCTION TLegend.LaunchLayoutBox(view: TView): TImage;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.isEditable THEN
LaunchLayoutBox := TLegendLayoutBox.CREATE(NIL, SELF.Heap, view, SELF)
ELSE
LaunchLayoutBox := SUPERSELF.LaunchLayoutBox(view);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TLegend.OffsetBy(deltaLPt: LPoint);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{$H-} LPtPlusLPt(SELF.location, deltaLPt, SELF.location); {$H+}
SUPERSELF.OffsetBy(deltaLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TLegend.RecalcExtent;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.GetBoxRight;
IF SELF.parent <> NIL THEN
SELF.parent.RecalcExtent;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 427 of 1012

Apple Lisa Computer Technical Information


002876
002877
002878
002879

{$S DlgInit}
END;

End of File -- Lines: 2879 Characters: 81055

Apple Lisa ToolKit 3.0 Source Code Listing -- 428 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UDIALOG3.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{UDialog3}
(*

{COPYRIGHT 1984 BY APPLE COMPUTER, INC}

TPicObject -- TRectImage -- TTextDialogImage - TFrameSelection TPlannerView - TLayoutBox - TLegendLayoutBox - ButtonLayoutBox - TTitleTab TLayPickSelection - TLayMoveCommand - TEditLegendSelection - TDialogDesignWindow

*)
{04/25/84 1610
{04/25/84 0015
{04/23/84 1210

{04/17/84 2130

{04/17/84
{04/15/84
{01/29/84
{12/22/83

2000
2000
1754
1927

Switched back to using a paraImage in call to FilterAndDo, as per JKD's latest change,
in TLegendLayoutBox.RecalcExtent
Removed the inval in TLegendLayoutBox.MousePress, fExperimenting or not}
Added TEditLegendSelection.MousePress, MouseMove and MouseRelease and field tripleClick,
to trap triple-click and do a SelectAll with it}
Removed all references to 'underEdit' field of TDialogImage
TEditLegendSelection.Deselect, Free, and Restore changed.
Removed some commented-out code and some unused VAR declarations in the TEditLegendSel
methods changed}
In TEditLegendSelection.CREATE doesn't inval unless fExperimenting
Removed ABCBreak calls in TEditLegendSelection.CREATE, TFrameSelection.KeyChar
TLegendLayoutBox.Draw always keys on existence of SELF.textDialogImage, ignoring
underEdit flag; underEdit, if this is okay, can vanish completely from the architecture}
In TLegendLayoutBox.RecalcExtent, try to use TImage.FilterAndDo correctly}
Spring Prelim Release}
RELEASE TK8D}
RELEASE TK8A}

METHODS OF TPicObject;
{$S DlgCold}
FUNCTION TPicObject.CREATE(object: TObject; heap: THeap; itsId: S255;
itsView: TView; itsLocation: LPoint; itsPicHandle: PicHandle):
VAR tempHz:
THeap;
frameInView:
LRect;
myPicHandle:
PicHandle;
boxAtCreation: Rect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
boxAtCreation:= itsPicHandle^^.picFrame;
noPad.rectToLRect(boxAtCreation, frameInView);
OffsetLRect(frameInView, itsLocation.h, itsLocation.v);

TPicObject;

Apple Lisa ToolKit 3.0 Source Code Listing -- 429 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

IF object = NIL THEN


object := NewObject(heap, THISCLASS);
SELF := TPicObject(TImageWithID.CREATE(object, heap, frameInView, itsId, itsView, FALSE {no children}));
SELF.isEditable := FALSE;
SELF.boxAtCreation := boxAtCreation;
GetHeap(tempHz);
SetHeap(SELF.Heap);
myPicHandle := OpenPicture(SELF.boxAtCreation);
SELF.picture := myPicHandle;
DrawPicture(itsPicHandle, SELF.boxAtCreation);
ClosePicture;
SetHeap(tempHz);
{restore normal heap}
{$IFC fTrace}EP;{$ENDC}
END;

{replay the incoming picture file onto our own heap}

{$S DlgCold}
PROCEDURE TPicObject.Free;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
KillPicture(SELF.picture);
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TPicObject.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('picHandle: LONGINT');
Field('boxAtCreation: Rect');
Field('');
END;
{$ENDC}
{$S DlgCold}
PROCEDURE TPicObject.Draw;
VAR boxOnPad:
Rect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
thePad.LRectToRect(SELF.extentLRect, boxOnPad);
DrawPicture(SELF.picture, boxOnPad);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 430 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

{$S DlgInit}
END;
METHODS OF TRectImage;
{$S DlgAlloc}
FUNCTION TRectImage.CREATE(object: TObject; heap: THeap; itsExtent: LRect; itsId: S255;
itsView: TView; itsPenState: PenState; withChildren: BOOLEAN): TRectImage;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TRectImage(TDialogImage.CREATE(object, heap, itsExtent, itsId, itsView, withChildren));
SELF.penState := itsPenState;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TRectImage.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field(CONCAT('penState: RECORD pnLoc: Point; pnSize: Point; pnMode: INTEGER;',
'pnPat: ARRAY[0..7] OF Byte END'));
{actually a packed array--fix}
Field('');
END;
{$ENDC}
{$S DlgHot}
PROCEDURE TRectImage.Draw;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SetPenState(SELF.penState); {could first want to scale the pen size, via the Pad...}
FrameLRect(SELF.extentLRect);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgLayout}
FUNCTION TRectImage.LaunchLayoutBox(view: TView): TImage;
VAR newBox: TLayoutBox;

Apple Lisa ToolKit 3.0 Source Code Listing -- 431 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
newBox := TLayoutBox.CREATE(NIL, SELF.Heap, SELF.extentLRect, noID, NIL,
view, SELF, stdThinBorders, TRUE, TRUE, FALSE);
LaunchLayoutBox := newBox;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
{-------------------------------------------------------------------------------------------------------}
METHODS OF TTextDialogImage;
{$S DlgText}
FUNCTION TTextDialogImage.CREATE(object: TObject; heap: THeap; itsExtent: LRect; itsId: S255;
itsView: TView; itsTypeStyle: TTypeStyle; itsInitialChars: S255): TTextDialogImage;
VAR textimage: TTextImage;
editPara:
TEditPara;
paraFormat: TParaFormat;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TTextDialogImage(TImageWithID.CREATE(object, heap, itsExtent, itsId, itsView, FALSE));
textImage := TTextImage.CREATE(NIL, heap, itsView, itsExtent,
TText.CREATE(NIL, heap, TDialogView(itsView).styleSheet), TRUE);
textImage.text.txtImgList.InsLast(textImage);
paraFormat := TParaFormat.CREATE(NIL, heap, NIL);
paraFormat.dfltTStyle := itsTypeStyle;
editPara := TEditPara.CREATE(NIL, heap, 0, paraFormat);
textImage.imageList.InsLast(textImage.NewParaImage(editPara, itsExtent, 0, 0));
textImage.text.paragraphs.InsLast(editPara);
editPara.ReplPString(0, editPara.size, @itsInitialChars);
SELF.textImage := textImage;
textImage.RecomputeImages(actionNone, TRUE);
SELF.wouldBeDraggable := TRUE;

Apple Lisa ToolKit 3.0 Source Code Listing -- 432 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

SELF.refCount := 1;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtRes}
PROCEDURE TTextDialogImage.Free;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.textImage.text.Free;
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TTextDialogImage.ChangeRefCountBy(delta: INTEGER);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.refCount := SELF.refCount + delta;
IF SELF.refCount <= 0 THEN
SELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TTextDialogImage.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('textImage: TTextImage');
Field('wouldBeDraggable: BOOLEAN');
Field('refCount: INTEGER');
Field('');
END;
{$ENDC}
{$S DlgHot}
FUNCTION TTextDialogImage.CursorAt(mouseLPt: LPoint): TCursorNumber;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.Hit(mouseLPt) THEN
CursorAt := textCursor
ELSE {not mine}
CursorAt := noCursor;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 433 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

{$S SgTxtRes}
PROCEDURE TTextDialogImage.Draw;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.textImage.Draw;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgLayout}
FUNCTION TTextDialogImage.LaunchLayoutBox(view: TView): TImage;
VAR borders:
Rect;
newBox:
TLayoutBox;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{dubious--formerly intended uses in abeyance}
IF SELF.wouldBeDraggable THEN
borders := stdPlainBorders
ELSE
borders := zeroRect;
newBox := TLayoutBox.CREATE(NIL, SELF.Heap, SELF.extentLRect, noID, NIL {parent},
view, SELF, borders, FALSE, FALSE, FALSE);
newBox.wouldMakeSelection := TRUE;
newBox.suppressDrawingManipulee := FALSE;
newBox.isDraggable := SELF.wouldBeDraggable;
LaunchLayoutBox := newBox;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtRes}
PROCEDURE TTextDialogImage.MousePress(mouseLPt: LPoint);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.textImage.MousePress(mouseLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtRes}
PROCEDURE TTextDialogImage.OffsetBy(deltaLPt: LPoint);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.textImage.OffsetBy(deltaLPt);
SUPERSELF.OffsetBy(deltaLPt);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 434 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

{$S DlgInit}
END;
METHODS OF TFrameSelection;
{$S DlgHot}
FUNCTION TFrameSelection.CREATE(object: TObject; heap: THeap;
itsInputFrame: TInputFrame): TFrameSelection;
VAR coSelection:
TSelection;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TFrameSelection(TSelection.CREATE(object, heap, itsInputFrame.view,
frameKind, zeroLPt));
SELF.inputFrame := itsInputFrame;
SELF.boundLRect := itsInputFrame.textDialogImage.extentLRect;
coSelection := itsInputFrame.view.NoSelection; {put non-NIL coSelection}
SELF.coSelection := coSelection;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
FUNCTION TFrameSelection.CanDoCommand(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN): BOOLEAN;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
CASE cmdNumber OF
uModern, uClassic,u20Pitch, u15Pitch, u12Pitch, u10Pitch, u12Point, u14Point, u18Point, u24Point,
uPlain, uBold, uItalic, uUnderline, uShadow, uOutline:
CanDoCommand := FALSE;
{before coSelection could set to TRUE}
OTHERWISE
CanDoCommand := SUPERSELF.CanDoCommand(cmdNumber, checkIt);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TFrameSelection.KeyChar(ch: CHAR);
VAR paraImage:
TParaImage;
maxCharsString: S255;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 435 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

{$IFC fTrace}BP(11);{$ENDC}
paraImage := TParaImage(SELF.inputFrame.textDialogImage.textImage.imageList.First);
IF (SELF.inputFrame.maxInputChars > paraImage.paragraph.size) OR
(NOT InClass(SELF.coSelection, TInsertionPoint)) THEN {can accept more}
SELF.coSelection.KeyChar(ch)
ELSE
BEGIN
IntToStr(SELF.inputFrame.maxInputChars, @maxCharsString);
process.ArgAlert(1, maxCharsString);
process.Stop(phTooManyChars);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TFrameSelection.KeyEnter(dh, dv: INTEGER);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF (dh <> 0) OR (dv <> 0) THEN
SELF.KeyTab((dh < 0) OR (dv < 0)); {right and down keys are Forward}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TFrameSelection.KeyReturn;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.KeyTab(FALSE);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TFrameSelection.KeyTab(fBackward: BOOLEAN);
VAR dialogView:
TDialogView;
dialogImage:
TDialogImage;
s:
TListScanner;
passedGo:
BOOLEAN;
foundSuccessor: BOOLEAN;
prevInputFrame: TInputFrame;
nextInputFrame: TInputFrame;
newFrameSel:
TFrameSelection;
dialog:
TDialog;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
dialogView := TDialogView(SELF.view);

Apple Lisa ToolKit 3.0 Source Code Listing -- 436 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

prevInputFrame := NIL;
passedGo := FALSE;
foundSuccessor := FALSE;
dialog := TDialog(SELF.inputFrame.parent);
s := dialog.children.Scanner;
WHILE s.Scan(dialogImage) DO
BEGIN
IF dialogImage = SELF.inputFrame THEN {found current frame}
BEGIN
IF not fBackward THEN
passedGo := TRUE
ELSE {back-tab; use most recent input frame, if any}
BEGIN
IF prevInputFrame = NIL THEN {there is none; can't do anything}
s.Done {with foundSuccessor still FALSE}
ELSE {found somebody!}
BEGIN
nextInputFrame := prevInputFrame;
foundSuccessor := TRUE;
END;
END;
END;
IF InClass(dialogImage, TInputFrame) THEN
IF (passedGo AND (dialogImage <> SELF.inputFrame)) OR foundSuccessor THEN
BEGIN
IF passedGo THEN
nextInputFrame := TInputFrame(dialogImage); {else it's already set, if back-tab}
SELF.KeyPause;
dialog.SelectInputFrame(nextInputFrame);
foundSuccessor := TRUE;
s.Done;
END
{forward tabbing actually done}
ELSE
prevInputFrame := TInputFrame(dialogImage);
END; {scan of dialogImages}
IF NOT foundSuccessor THEN
SELF.CantDoIt;
{ELSE
SELF.window.CommitLast};
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TFrameSelection.MousePress(mouseLPt: LPoint);
{called only if mouse comes BACK down inside alredy-selected Input Frame}

Apple Lisa ToolKit 3.0 Source Code Listing -- 437 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SUPERSELF.MousePress(mouseLPt);
TDialogView(SELF.view).magnetCursor := textCursor;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TFrameSelection.PerformCommand(command: TCommand; cmdPhase: TCmdPhase);
VAR paragraph:
TParagraph;
textImage:
TTextImage;
paraImage:
TParaImage;
noSelection:
TSelection;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
textImage := SELF.inputFrame.textDialogImage.textImage;
SUPERSELF.PerformCommand(command, cmdPhase);
paraImage := TParaImage(textImage.imageList.First);
paragraph := paraImage.paragraph;
paragraph.NewStyle(0, paragraph.Size, SELF.inputFrame.inputTypeStyle);
IF paragraph.size > SELF.inputFrame.maxInputChars THEN
BEGIN {may need temp para here}
paragraph.ReplPara(0, paragraph.size, paragraph, 0, SELF.inputFrame.maxInputChars);
paraImage.changed := TRUE;
paraImage.InvalLinesWith(0, MAXINT);
textImage.RecomputeImages(actionNone, TRUE);
SELF.window.CommitLast;
noSelection := SELF.FreedAndReplacedBy(SELF.view.NoSelection);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgHot}
PROCEDURE TFrameSelection.Restore;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
TDialogView(SELF.view).currentDialogImage := SELF.inputFrame;
SUPERSELF.Restore;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 438 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

METHODS OF TPlannerView;
{$S SgLayout}
FUNCTION TPlannerView.CREATE(object: TObject; heap: THeap; itsViewBeingPlanned: TView;
itsPanel: TPanel; itsAllowSketching: BOOLEAN;
itsRetainPickedBox: BOOLEAN): TPlannerView;
VAR newList:
TList;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TPlannerView(TDialogView.CREATE(object, heap, itsViewBeingPlanned.extentLRect, itsPanel,
NIL, itsViewBeingPlanned.res));
WITH SELF DO
BEGIN
viewBeingPlanned := itsViewBeingPlanned;
allowSketching := itsAllowSketching;
retainPickedBox := itsRetainPickedBox;
currentLayoutBox := NIL;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TPlannerView.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('viewBeingPlanned: TView');
Field('allowSketching: BOOLEAN');
Field('retainPickedBox: BOOLEAN');
Field('currentLayoutBox: TLayoutBox');
Field('');
END;
{$ENDC}
{$S SgLayout}
FUNCTION TPlannerView.CursorAt(mouseLPt: LPoint): TCursorNumber;
VAR s:
TListScanner;
layoutBox: TLayoutBox;
curCursor: TCursorNumber;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.mouseIsDown AND (SELF.magnetCursor <> noCursor) THEN
CursorAt := SELF.magnetCursor

Apple Lisa ToolKit 3.0 Source Code Listing -- 439 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

ELSE
BEGIN
curCursor := noCursor;
s := SELF.rootDialog.children.Scanner;
WHILE s.Scan(layoutBox) DO
BEGIN
curCursor := layoutBox.CursorAt(mouseLPt);
IF curCursor <> noCursor THEN
s.Done
END;
CursorAt := curCursor;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TPlannerView.Draw;
PROCEDURE DrawLayoutBox(obj: TObject);
VAR layoutBox:
TLayoutBox;
BEGIN
layoutBox := TLayoutBox(obj);
layoutBox.Draw;
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.EachActualPart(DrawLayoutBox);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TPlannerView.EachActualPart(PROCEDURE DoToObject(filteredObj: TObject));
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.rootDialog.children.Each(DoToObject);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
PROCEDURE TPlannerView.Init(itsListOfImages: TList);
VAR s:
TListScanner;
t:
TListScanner;
image:
TImage;
layoutBox:
TLayoutBox;
otherLayoutBox:
TLayoutBox;
nextButton:
TButton;

Apple Lisa ToolKit 3.0 Source Code Listing -- 440 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF itsListOfImages <> NIL THEN
BEGIN
s := itsListOfImages.Scanner;
{create parallel structure}
WHILE s.Scan(image) DO
BEGIN
layoutBox := SELF.NewLayoutBox(image);
IF layoutBox <> NIL THEN
SELF.rootDialog.AddImage(layoutBox); {it may well have its own children, already created}
END;
END;
IF InClass(SELF.viewBeingPlanned, TDialogView) THEN {get buttonLayoutBoxes correctly entwined}
BEGIN
s := SELF.rootDialog.children.Scanner;
WHILE s.Scan(layoutBox) DO
IF InClass(layoutBox, TButtonLayoutBox) THEN
BEGIN
nextButton := TButton(layoutBox.manipulee).nextSameSizedButton;
t := SELF.rootDialog.children.Scanner;
WHILE t.Scan(otherLayoutBox) DO
IF otherLayoutBox.manipulee = nextButton THEN {found it}
BEGIN
TButtonLayoutBox(layoutBox).nextSameSizedBox := TButtonLayoutBox(otherLayoutBox);
t.Done;
END;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
FUNCTION TPlannerView.NewLayoutBox(image: TImage): TLayoutBox;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
NewLayoutBox := TLayoutBox(image.LaunchLayoutBox(SELF));
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgLayout}
PROCEDURE TPlannerView.MousePress(mouseLPt: LPoint);
VAR panel:
TPanel;
layPickSelection:
TLayPickSelection;
pickedBox:
TLayoutBox;
s:
TListScanner;

Apple Lisa ToolKit 3.0 Source Code Listing -- 441 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

layoutBox:
TLayoutBox;
madeSelection:
BOOLEAN;
editLegendSelection:
TEditLegendSelection;
PROCEDURE InvrtOnThePad;
BEGIN
pickedBox.Highlight(hOffToOn);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.mouseIsDown := TRUE;
SELF.magnetCursor := noCursor;
panel := SELF.panel;
madeSelection := FALSE;
IF (panel.selection.kind <> nothingKind) AND (panel.selection.kind <> layPickKind) THEN
BEGIN
IF clickState.fShift THEN
madeSelection := TRUE
ELSE
IF InClass(panel.selection, TEditLegendSelection) THEN
BEGIN
editLegendSelection := TEditLegendSelection(panel.selection);
IF LPtInLRect(mouseLPt, editLegendSelection.legendLayoutBox.extentLRect) THEN
IF NOT LPtInLRect(mouseLPt, editLegendSelection.legendLayoutBox.titleTab.extentLRect) THEN
BEGIN
madeSelection := TRUE;
SELF.magnetCursor := textCursor;
END;
END;
END;
IF madeSelection THEN
panel.selection.MousePress(mouseLPt)
ELSE
BEGIN
panel.BeginSelection;
pickedBox := NIL; {find who wants the mouse}
s := SELF.rootDialog.children.Scanner;
WHILE s.Scan(layoutBox) DO
BEGIN
layoutBox.ConsiderMouse(mouseLPt, madeSelection, pickedBox);
IF pickedBox <> NIL THEN
pickedBox.ComeForward;
IF madeSelection THEN
s.Done
ELSE
IF (pickedBox <> NIL) THEN {got the title tab of somebody}
BEGIN
pickedBox.ChangeDragState(TRUE);

Apple Lisa ToolKit 3.0 Source Code Listing -- 442 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

(*

layPickSelection := TLayPickSelection(panel.selection.FreedAndReplacedBy(
TLayPickSelection.CREATE(NIL, SELF.Heap, SELF, layPickKind, pickedBox,
mouseLPt)));
panel.OnAllPadsDo(InvrtOnThePad);
SELF.magnetCursor := arrowCursor;
s.Done;
END
END;
NB: Here, when/if we allow sketching in layout, we would add code like:
IF pickedBox = NIL THEN
IF SELF.allowSketching THEN
LaySketchSelection := TLaySketchSelection(panel.selection.FreedAndReplacedBy(
TLaySketchSelection.CREATE(NIL, SELF.Heap, SELF, mouseLPt)))
END;
{$IFC fTrace}EP;{$ENDC}
END;

{$S DlgLayout}
PROCEDURE TPlannerView.MouseMove(mouseLPt: LPoint);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
TView.MouseMove(mouseLPt); {do NOT do what TDialogView would do}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TPlannerView.MouseRelease;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.mouseIsDown := FALSE;
SELF.magnetCursor := noCursor;
TView.MouseRelease;
{do NOT do what TDialogView would do except for the above}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
METHODS OF TLayoutBox;
{$S SgLayout}
FUNCTION TLayoutBox.CREATE(object: TObject; heap: THeap; baseExtent: LRect; itsID: S255;

Apple Lisa ToolKit 3.0 Source Code Listing -- 443 of 1012

*)

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

itsParent: TLayoutBox; itsView: TView; itsManipulee: TImage; itsBorders: Rect;


itsResizable: BOOLEAN; itsSuppression: BOOLEAN; withChildren: BOOLEAN): TLayoutBox;
VAR itsTitleTab:
TTitleTab;
itsExtentLRect: LRect;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
LRectAddBorders(baseExtent, itsBorders, itsExtentLRect);
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TLayoutBox(TImageWithID.CREATE(object, heap, itsExtentLRect, itsID, itsView, withChildren));
IF itsBorders.top = 0 THEN
itsTitleTab := SELF.NoTitleTab(SELF.Heap)
ELSE
itsTitleTab := TTitleTab.CREATE(NIL, heap, SELF,
itsID);

- itsBorders.bottom - itsBorders.top + 1,

WITH SELF DO
BEGIN
parent := itsParent;
titleTab := itsTitleTab;
manipulee := itsManipulee;
suppressDrawingManipulee := itsSuppression;
wouldMakeSelection := FALSE;
isResizable := itsResizable;
isDraggable := TRUE;
shouldFrame := TRUE;
borders := itsBorders;
hasDraggee := FALSE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TLayoutBox.Free;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
Free(SELF.titleTab);
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TLayoutBox.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);

Apple Lisa ToolKit 3.0 Source Code Listing -- 444 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

Field('manipulee: TImage');
Field('titleTab: TTitleTab');
Field('suppressDrawingManipulee: BOOLEAN');
Field('isResizable: BOOLEAN');
Field('borders: Rect');
Field('wouldMakeSelection: BOOLEAN');
Field('isDraggable: BOOLEAN');
Field('shouldFrame: BOOLEAN');
Field('hasDraggee: BOOLEAN');
Field('');
END;
{$S SgLayout}
{$ENDC}
PROCEDURE TLayoutBox.ChangeDragState(enteringDrag: BOOLEAN);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.hasDraggee := enteringDrag;
IF SELF.parent <> NIL THEN
IF InClass(SELF.parent, TLayoutBox) THEN
TLayoutBox(SELF.parent).ChangeDragState(enteringDrag);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TLayoutBox.ConsiderMouse(mouseLPt: LPoint; VAR madeSelection: BOOLEAN;
VAR pickedLayoutBox: TLayoutBox);
VAR s:
TListScanner;
layoutBox: TLayoutBox;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
pickedLayoutBox := NIL;
madeSelection := FALSE;
IF NOT SELF.Hit(mouseLPt) THEN
{it ain't me}
ELSE
BEGIN
IF LRectHasLPt(SELF.titleTab.extentLRect, mouseLPt) THEN
BEGIN
pickedLayoutBox := SELF;
SELF.TabGrabbed;
{so that page status dialog can react now}
END
ELSE
IF SELF.wouldMakeSelection THEN
BEGIN
madeSelection := TRUE;
pickedLayoutBox := SELF;

Apple Lisa ToolKit 3.0 Source Code Listing -- 445 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

SELF.MousePress(mouseLPt);
END
ELSE
{not my title tab, and I myself don't make selections; how about it, kids?}
BEGIN
IF SELF.children <> NIL THEN
BEGIN
s := SELF.children.Scanner;
WHILE s.Scan(layoutBox) DO
BEGIN
layoutBox.ConsiderMouse(mouseLPt, madeSelection, pickedLayoutBox);
IF madeSelection OR (pickedLayoutBox <> NIL) THEN
s.Done;
END;
END;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
FUNCTION TLayoutBox.CursorAt(mouseLPt: LPoint): TCursorNumber;
VAR s:
TListScanner;
layoutBox: TLayoutBox;
curCursor: TCursorNumber;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
curCursor := noCursor;
IF SELF.Hit(mouseLPt) THEN
BEGIN
IF SELF.titleTab <> NIL THEN
IF SELF.titleTab.Hit(mouseLPt) THEN
curCursor := arrowCursor;
IF curCursor = noCursor THEN
IF SELF.children <> NIL THEN
BEGIN
s := SELF.children.Scanner;
WHILE s.Scan(layoutBox) DO
BEGIN
curCursor := layoutBox.CursorAt(mouseLPt);
IF curCursor <> noCursor THEN
s.Done;
END;
END;
END;
CursorAt := curCursor;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 446 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

PROCEDURE TLayoutBox.Draw;
PROCEDURE YouDraw(obj: TObject);
VAR dialogImage: TDialogImage;
BEGIN
dialogImage := TDialogImage(obj);
IF dialogImage.isActive THEN
dialogImage.Draw;
END;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF LRectIsVisible(SELF.extentLRect) OR SELF.hasDraggee THEN
BEGIN
SELF.EachActualPart(YouDraw);
SELF.DrawJustMe;
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TLayoutBox.DrawJustMe;
VAR titleTab:
TTitleTab;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF LRectIsVisible(SELF.extentLRect) THEN
BEGIN
titleTab := SELF.titleTab;
IF titleTab <> NIL THEN {currently every layout box MUST have a title tab, so this is
unnecessary}
IF NOT EmptyLRect(titleTab.extentLRect) THEN
titleTab.Draw;
IF NOT SELF.suppressDrawingManipulee THEN
IF SELF.manipulee <> NIL THEN
SELF.manipulee.Draw;
PenNormal;
IF SELF.IsDraggable AND SELF.shouldFrame THEN
FrameLRect(SELF.extentLRect); {draw overall box}
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TLayoutBox.FreeManipulee;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 447 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

Free(SELF.manipulee);
SELF.manipulee := NIL;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TLayoutBox.Highlight(highTransit: THighTransit);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF (SELF.titleTab <> NIL) THEN
BEGIN
InvrtLRect(SELF.titleTab.extentLRect);
PenNormal;
FrameLRect(SELF.titleTab.extentLRect);
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TLayoutBox.MousePress(mouseLPT: LPoint);
VAR layoutBox: TLayoutBox;
s:
TListScanner;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.children <> NIL THEN
BEGIN
s := SELF.children.Scanner;
WHILE s.Scan(layoutBox) DO
IF layoutBox.DownAt(mouseLPt) <> NIL THEN
s.Done;
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TLayoutBox.Move(deltaLPt: LPoint);
VAR oldLRect:
LRect;
newLRect:
LRect;
heading:
THeading;
PROCEDURE InvalOnThePad;
BEGIN
thePad.InvalLRect(oldLRect);
thePad.InvalLRect(newLRect);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
oldLRect := SELF.extentLRect;
SELF.OffsetBy(deltaLPt);

Apple Lisa ToolKit 3.0 Source Code Listing -- 448 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

newLRect := SELF.extentLRect;
SELF.view.panel.OnAllPadsDo(InvalOnThePad);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgDbg}
FUNCTION TLayoutBox.NoTitleTab(heap: THeap): TTitleTab;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
NoTitleTab := TTitleTab.CREATE(NIL, heap, SELF, 0, noID);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TLayoutBox.OffsetBy(deltaLPt: LPoint);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF SELF.manipulee <> NIL THEN
SELF.manipulee.OffsetBy(deltaLPt);
{offset MY manipulee, but not my children's, since my
my manipulee's OffsetBy will have done that already}
SELF.OffsetLayoutBoxBy(deltaLPt, TRUE);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TLayoutBox.OffsetLayoutBoxBy(deltaLPt: LPoint; textImageAsWell: BOOLEAN);
{does NOT offset manipulee}
PROCEDURE YouOffset(obj: TObject);
VAR layoutBox: TLayoutBox;
BEGIN
layoutBox := TLayoutBox(obj);
layoutBox.OffsetLayoutBoxBy(deltaLPt, textImageAsWell);
END;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.titleTab <> NIL THEN
SELF.titleTab.OffsetBy(deltaLPt);
{$H-} OffsetLRect(SELF.extentLRect, deltaLPt.h, deltaLPt.v); {$H+}
SELF.EachActualPart(YouOffset); {tells children}
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TLayoutBox.RecalcExtent;
VAR s:
TListScanner;
newExtent:
LRect;

Apple Lisa ToolKit 3.0 Source Code Listing -- 449 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

layoutBox:
TLayoutBox;
oldExtent:
LRect;
PROCEDURE InvalOldAndNew;
BEGIN
thePad.InvalLRect(oldExtent);
thePad.InvalLRect(newExtent);
END;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
oldExtent := SELF.extentLRect;
newExtent := SELF.manipulee.extentLRect;
IF SELF.children <> NIL THEN
IF SELF.children.Size > 0 THEN
BEGIN
newExtent := zeroLRect;
s := SELF.children.Scanner;
WHILE s.Scan(layoutBox) DO
IF EmptyLRect(newExtent) THEN
newExtent := layoutBox.extentLRect
ELSE
UnionLRect(newExtent, layoutBox.extentLRect, newExtent);
END;
LRectAddBorders(newExtent, SELF.borders, newExtent);
IF NOT equalLRect(oldExtent, newExtent) THEN
BEGIN
SELF.Resize(newExtent);
SELF.view.panel.OnAllPadsDo(InvalOldAndNew);
END;
IF SELF.parent <> NIL THEN
SELF.parent.RecalcExtent;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TLayoutBox.Resize(newExtent: LRect);
VAR newTitleExtent: LRect;
titleTab:
TTitleTab;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
titleTab := SELF.titleTab;
IF titleTab <> NIL THEN
BEGIN
newTitleExtent := newExtent;
newTitleExtent.bottom := newTitleExtent.top +
(titleTab.extentLRect.bottom - titleTab.extentLRect.top); {i.e., preserve old height}

Apple Lisa ToolKit 3.0 Source Code Listing -- 450 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

titleTab.Resize(newTitleExtent);
END;
SUPERSELF.Resize(newExtentLRect);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TLayoutBox.TabGrabbed;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
METHODS OF TLegendLayoutBox;
{$S SgLayout}
FUNCTION TLegendLayoutBox.CREATE(object: TObject; heap: THeap; itsView: TView; itsLegend: TLegend
): TLegendLayoutBox;
VAR itsTitleTab:
TTitleTab;
itsExtentLRect: LRect;
myBorders:
Rect;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF itsLegend.wouldBeDraggable THEN
myBorders := stdPlainBorders
ELSE
myBorders := zeroRect;
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TLegendLayoutBox(TLayoutBox.CREATE(object, heap, itsLegend.extentLRect, noID, NIL,
itsView, itsLegend, myBorders, FALSE, FALSE, FALSE));
WITH SELF DO
BEGIN
isDraggable := itsLegend.wouldBeDraggable;
shouldFrame := itsLegend.wouldBeDraggable;
textDialogImage := NIL;
wouldMakeSelection := TRUE;
{client could override, somehow?}
END;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 451 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TLegendLayoutBox.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('textDialogImage: TTextDialogImage');
Field('');
END;
{$S SgLayout}
{$ENDC}
FUNCTION TLegendLayoutBox.CursorAt(mouseLPt: LPoint): TCursorNumber;
VAR curCursor: TCursorNumber;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
curCursor := noCursor;
IF SELF.Hit(mouseLPt) THEN
IF SELF.titleTab.Hit(mouseLPt) THEN
curCursor := arrowCursor
ELSE
IF SELF.wouldMakeSelection THEN
curCursor := textCursor;
CursorAt := curCursor;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TLegendLayoutBox.Draw;
VAR titleTab:
TTitleTab;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF LRectIsVisible(SELF.extentLRect) THEN
BEGIN
IF SELF.isDraggable THEN
SELF.titleTab.Draw;
IF SELF.textDialogImage <> NIL THEN {+SW+}
SELF.textDialogImage.Draw
ELSE
SELF.manipulee.Draw;
PenNormal;
IF SELF.IsDraggable AND SELF.shouldFrame THEN
FrameLRect(SELF.extentLRect); {draw overall box}
END;
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 452 of 1012

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163
001164
001165
001166
001167
001168
001169
001170
001171
001172
001173
001174
001175
001176
001177
001178
001179
001180
001181
001182
001183
001184
001185
001186
001187
001188
001189
001190
001191
001192
001193
001194
001195

END;
PROCEDURE TLegendLayoutBox.MousePress(mouseLPT: LPoint);
VAR editLegendSelection:
TEditLegendSelection;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
TPlannerView(SELF.view).magnetCursor := textCursor;
LRectHaveLPt(SELF.manipulee.extentLRect, mouseLPt);
editLegendSelection := TEditLegendSelection(SELF.view.panel.selection.FreedAndReplacedBy(
TEditLegendSelection.CREATE(NIL, SELF.Heap, SELF, mouseLPT)));
editLegendSelection.textDialogImage.MousePress(mouseLPt);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TLegendLayoutBox.OffsetLayoutBoxBy(deltaLPt: LPoint; textImageAsWell: BOOLEAN);
{does NOT offset manipulee}
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SUPERSELF.OffsetLayoutBoxBy(deltaLPt, textImageAsWell);
IF NOT textImageAsWell THEN
deltaLPt.v := 0; {don't do it vertically}
IF SELF.textDialogImage <> NIL THEN
SELF.textDialogImage.OffsetBy(deltaLPt);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TLegendLayoutBox.RecalcExtent;
VAR newExtent:
LRect;
oldExtent:
LRect;
paraImage:
TParaImage;
textDialogImage:
TTextDialogImage;
legPara:
TParagraph;
PROCEDURE InvalOldAndNew;
BEGIN
thePad.InvalLRect(oldExtent);
thePad.InvalLRect(newExtent);
END;
PROCEDURE PourItBack(obj: TObject);
VAR paragraph: TParagraph;
BEGIN
paragraph := TParaImage(obj).paragraph;
legPara.ReplPara(0, legPara.size, paragraph, 0, paragraph.size);
END;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 453 of 1012

Apple Lisa Computer Technical Information


001196
001197
001198
001199
001200
001201
001202
001203
001204
001205
001206
001207
001208
001209
001210
001211
001212
001213
001214
001215
001216
001217
001218
001219
001220
001221
001222
001223
001224
001225
001226
001227
001228
001229
001230
001231
001232
001233
001234
001235
001236
001237
001238
001239
001240
001241
001242
001243

textDialogImage := SELF.textDialogImage;
IF textDialogImage <> NIL THEN
BEGIN
paraImage := TParaImage(textDialogImage.textImage.imageList.First);
legPara := TLegend(SELF.manipulee).paragraph;
textDialogImage.textImage.FilterAndDo(paraImage, PourItBack);
END;
TLegend(SELF.manipulee).RecalcExtent;
oldExtent := SELF.extentLRect;
newExtent := SELF.manipulee.extentLRect;
LRectAddBorders(newExtent, SELF.borders, newExtent);
IF NOT equalLRect(oldExtent, newExtent) THEN
BEGIN
SELF.Resize(newExtent);
SELF.view.panel.OnAllPadsDo(InvalOldAndNew);
END;
IF SELF.parent <> NIL THEN
SELF.parent.RecalcExtent;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
METHODS OF TButtonLayoutBox;
{$S DlgLayout}
FUNCTION TButtonLayoutBox.CREATE(object: TObject; heap: THeap; itsButton: TButton;
itsView: TView): TButtonLayoutBox;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TButtonLayoutBox(TLayoutBox.CREATE(object, heap, itsButton.extentLRect, itsButton.id, NIL,
itsView, itsButton, stdIDBorders, FALSE, TRUE, TRUE));
SELF.nextSameSizedBox := SELF; {will be correctly set by TPlannerView.CREATE after all layout
boxes made}
SELF.oldLegendTopLeft := itsButton.legend.extentLRect.topLeft;
SELF.AddImage(TDialogImage(itsButton.legend.LaunchLayoutBox(itsView)));
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 454 of 1012

Apple Lisa Computer Technical Information


001244
001245
001246
001247
001248
001249
001250
001251
001252
001253
001254
001255
001256
001257
001258
001259
001260
001261
001262
001263
001264
001265
001266
001267
001268
001269
001270
001271
001272
001273
001274
001275
001276
001277
001278
001279
001280
001281
001282
001283
001284
001285
001286
001287
001288
001289
001290
001291

{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TButtonLayoutBox.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('nextSameSizedBox: TButtonLayoutBox');
Field('oldLegendTopLeft: LPoint');
Field('');
END;
{$ENDC}
{$S DlgLayout}
PROCEDURE TButtonLayoutBox.ConsiderMouse(mouseLPt: LPoint; VAR madeSelection: BOOLEAN;
VAR pickedLayoutBox: TLayoutBox);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
pickedLayoutBox := NIL;
madeSelection := FALSE;
IF SELF.Hit(mouseLPt) THEN
BEGIN
pickedLayoutBox := SELF;
IF NOT LRectHasLPt(SELF.titleTab.extentLRect, mouseLPt) THEN
{hit on interior -- hence, editing button text}
BEGIN
madeSelection := TRUE;
LRectHaveLPt(TLayoutBox(SELF.children.First).extentLRect, mouseLPt);
SELF.MousePress(mouseLPt);
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgLayout}
FUNCTION TButtonLayoutBox.CursorAt(mouseLPt: LPoint): TCursorNumber;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF NOT SELF.Hit(mouseLPt) THEN
CursorAt := noCursor
ELSE
IF SELF.titleTab.Hit(mouseLPt) THEN
CursorAt := arrowCursor
ELSE
CursorAt := textCursor;
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 455 of 1012

Apple Lisa Computer Technical Information


001292
001293
001294
001295
001296
001297
001298
001299
001300
001301
001302
001303
001304
001305
001306
001307
001308
001309
001310
001311
001312
001313
001314
001315
001316
001317
001318
001319
001320
001321
001322
001323
001324
001325
001326
001327
001328
001329
001330
001331
001332
001333
001334
001335
001336
001337
001338
001339

END;
{$S DlgLayout}
PROCEDURE TButtonLayoutBox.DrawJustMe;
VAR s:
TListScanner;
layoutBox: TLayoutBox;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF LRectIsVisible(SELF.extentLRect) THEN
BEGIN
SELF.titleTab.Draw;
TButton(SELF.manipulee).DrawJustMe; {draws just the roundRect; my child will draw the text}
PenNormal;
FrameLRect(SELF.extentLRect); {draw overall box}
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TButtonLayoutBox.OffsetBy(deltaLPt: LPoint);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SUPERSELF.OffsetBy(deltaLPt);
{$H-} LPtPlusLPt(SELF.oldLegendTopLeft, deltaLPt, SELF.oldLegendTopLeft); {$H+}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgLayout}
PROCEDURE TButtonLayoutBox.RecalcExtent;
VAR nextBox:
TButtonLayoutBox;
oldLegendTopLeft: LPoint;
newLegendTopLeft: LPoint;
deltaLPt:
LPoint;
legendBox:
TLegendLayoutBox;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
legendBox := TLegendLayoutBox(SELF.children.First);
newLegendTopLeft := legendBox.manipulee.extentLRect.topLeft;
oldLegendTopLeft := SELF.oldLegendTopLeft;
IF NOT EqualLPt(oldLegendTopLeft, newLegendTopLeft) THEN
BEGIN
LPtMinusLPt(newLegendTopLeft, oldLegendTopLeft, deltaLPt);
legendBox.OffsetLayoutBoxBy(deltaLPt, TRUE);
SELF.oldLegendTopLeft := newLegendTopLeft;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 456 of 1012

Apple Lisa Computer Technical Information


001340
001341
001342
001343
001344
001345
001346
001347
001348
001349
001350
001351
001352
001353
001354
001355
001356
001357
001358
001359
001360
001361
001362
001363
001364
001365
001366
001367
001368
001369
001370
001371
001372
001373
001374
001375
001376
001377
001378
001379
001380
001381
001382
001383
001384
001385
001386
001387

nextBox := SELF;
REPEAT
nextBox.RecalcJustMe;
nextBox := nextBox.nextSameSizedBox;
UNTIL
nextBox = SELF;
IF SELF.parent <> NIL THEN
SELF.parent.RecalcExtent;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgLayout}
PROCEDURE TButtonLayoutBox.RecalcJustMe; {my manipulee's size may've changed}
VAR nextBox:
TButtonLayoutBox;
oldExtent: LRect;
newExtent: LRect;
PROCEDURE InvalOldAndNew;
BEGIN
thePad.InvalLRect(oldExtent);
thePad.InvalLRect(newExtent);
END;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
oldExtent := SELF.extentLRect;
newExtent := SELF.manipulee.extentLRect;
LRectAddBorders(newExtent, SELF.borders, newExtent);
SELF.Resize(newExtent);
SELF.view.panel.OnAllPadsDo(InvalOldAndNew);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
METHODS OF TTitleTab;
{$S SgLayout}
FUNCTION TTitleTab.CREATE(object: TObject; heap: THeap; itsLayoutBox: TLayoutBox; itsHeight: INTEGER;
itsCaption: S255): TTitleTab;
VAR extentLRect:
LRect;
legend:
TLegend;
location:
LPoint;
{$IFC libraryVersion <= 20}
{* * * P E P S I * * *}

Apple Lisa ToolKit 3.0 Source Code Listing -- 457 of 1012

Apple Lisa Computer Technical Information


001388
001389
001390
001391
001392
001393
001394
001395
001396
001397
001398
001399
001400
001401
001402
001403
001404
001405
001406
001407
001408
001409
001410
001411
001412
001413
001414
001415
001416
001417
001418
001419
001420
001421
001422
001423
001424
001425
001426
001427
001428
001429
001430
001431
001432
001433
001434
001435

{$ELSEC}
{$ENDC}

fInfo:
fInfo:

TFInfo;
{* * S P R I N G
FontInfo;

width:
newLegTopLeft:

INTEGER;
LPoint;

* *}

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
WITH itsLayoutBox.extentLRect DO
{$H-}
SetLRect(extentLRect, left, top, right, top + itsHeight);

{$H+}

IF object = NIL THEN


object := NewObject(heap, THISCLASS);
SELF := TTitleTab(TImage.CREATE(object, heap, extentLRect, itsLayoutBox.view));
SELF.layoutBox := itsLayoutBox;
IF itsCaption <> '' THEN {need to create a TLegend object for it}
BEGIN
legend := TLegend.CREATE(NIL, SELF.Heap, itsCaption, SELF.view, zeroLPt, titleTypeStyle);
WITH itsLayoutBox.extentLRect DO
{$H-}
SetLPt(newLegTopLeft, (right + left - legend.extentLRect.right) DIV 2,
top + (SELF.view.res.v DIV 30));
{$H+}
legend.OffsetTo(newLegTopLeft);
SELF.legend := legend;
WITH legend.extentLRect DO
IF right - left > SELF.extentLRect.right - SELF.extentLRect.left THEN
SELF.shouldDrawLegend := FALSE
ELSE
SELF.shouldDrawLegend := TRUE;
END
ELSE
BEGIN
SELF.legend := NIL;
SELF.shouldDrawLegend := FALSE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TTitleTab.Free;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
Free(SELF.legend);
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 458 of 1012

Apple Lisa Computer Technical Information


001436
001437
001438
001439
001440
001441
001442
001443
001444
001445
001446
001447
001448
001449
001450
001451
001452
001453
001454
001455
001456
001457
001458
001459
001460
001461
001462
001463
001464
001465
001466
001467
001468
001469
001470
001471
001472
001473
001474
001475
001476
001477
001478
001479
001480
001481
001482
001483

END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TTitleTab.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('layoutBox: TLayoutBox');
Field('legend: TLegend');
Field('shouldDrawLegend: BOOLEAN');
Field('');
END;
{$S SgLayout}
{$ENDC}
{$S SgLayout}
PROCEDURE TTitleTab.Draw;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
PenNormal;
FillLRect(SELF.extentLRect, lPatWhite);
FrameLRect(SELF.extentLRect);
IF SELF.shouldDrawLegend THEN
{it exists and is small enough to fit}
SELF.legend.Draw;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TTitleTab.OffsetBy(deltaLPt: LPoint);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.legend <> NIL THEN
SELF.legend.OffsetBy(deltaLPt);
SUPERSELF.OffsetBy(deltaLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TTitleTab.Resize{(newExtent: LRect)};
VAR myCaption:
S255;
{$IFC libraryVersion <= 20}
{* * * P E P S I * * *}
fInfo:
TFInfo;
{$ELSEC}
{* * S P R I N G * *}
fInfo:
FontInfo;

Apple Lisa ToolKit 3.0 Source Code Listing -- 459 of 1012

Apple Lisa Computer Technical Information


001484
001485
001486
001487
001488
001489
001490
001491
001492
001493
001494
001495
001496
001497
001498
001499
001500
001501
001502
001503
001504
001505
001506
001507
001508
001509
001510
001511
001512
001513
001514
001515
001516
001517
001518
001519
001520
001521
001522
001523
001524
001525
001526
001527
001528
001529
001530
001531

{$ENDC}

strLocation:
captionWidth:
deltaLPt:
typeStyle:

LPoint;
INTEGER;
LPoint;
TTypeStyle;

BEGIN
{$IFC fTrace}BP(11);{$ENDC} {this does the wrong thing for high view resolutions; must fix}
IF SELF.legend <> NIL THEN
BEGIN
SELF.legend.GetString(myCaption);
SELF.legend.paragraph.StyleAt(0, typeStyle);
SetQDTypeStyle(typeStyle);
GetFontInfo(fInfo);
captionWidth := StringWidth(myCaption);
{$H-}
WITH newExtentLRect, fInfo DO
SetLPt(strLocation, ((left + right - captionWidth) DIV 2),
bottom - descent);
{had had a -2 here}
{$H+}
SetLPt(deltaLPt, strLocation.h - SELF.legend.location.h,
strLocation.v - SELF.legend.location.v);
SELF.legend.OffsetBy(deltaLPt); {do more cleverly -- maybe TLegend.OffsetTo}
WITH SELF.legend.extentLRect DO
IF right - left > newExtent.right - newExtent.left THEN
SELF.shouldDrawLegend := FALSE
ELSE
SELF.shouldDrawLegend := TRUE;
END;
SELF.extentLRect := newExtentLRect;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
METHODS OF TLayPickSelection;
{$S SgLayout}
FUNCTION TLayPickSelection.CREATE(object: TObject; heap: THeap; itsView: TPlannerView; itsKind: INTEGER;
itsLayoutBox: TLayoutBox; itsAnchorLPt: LPoint): TLayPickSelection;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TLayPickSelection(TSelection.CREATE(object, heap, itsView, itsKind, itsAnchorLPt));

Apple Lisa ToolKit 3.0 Source Code Listing -- 460 of 1012

Apple Lisa Computer Technical Information


001532
001533
001534
001535
001536
001537
001538
001539
001540
001541
001542
001543
001544
001545
001546
001547
001548
001549
001550
001551
001552
001553
001554
001555
001556
001557
001558
001559
001560
001561
001562
001563
001564
001565
001566
001567
001568
001569
001570
001571
001572
001573
001574
001575
001576
001577
001578
001579

SELF.layoutBox := itsLayoutBox;
SELF.boundLRect := itsLayoutBox.extentLRect;
itsView.currentLayoutBox := itsLayoutBox;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TLayPickSelection.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('layoutBox: TLayoutBox');
Field('');
END;
{$S SgLayout}
{$ENDC}
{$S SgLayout}
FUNCTION TLayPickSelection.CanDoCommand(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN): BOOLEAN;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
CASE cmdNumber OF
uClear:
CanDoCommand := TRUE;
OTHERWISE
CanDoCommand := SUPERSELF.CanDoCommand(cmdNumber, checkIt);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TLayPickSelection.Deselect;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
TPlannerView(SELF.view).currentLayoutBox := NIL;
SELF.layoutBox.ChangeDragState(FALSE);
SUPERSELF.Deselect;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TLayPickSelection.Highlight(highTransit: THighTransit);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 461 of 1012

Apple Lisa Computer Technical Information


001580
001581
001582
001583
001584
001585
001586
001587
001588
001589
001590
001591
001592
001593
001594
001595
001596
001597
001598
001599
001600
001601
001602
001603
001604
001605
001606
001607
001608
001609
001610
001611
001612
001613
001614
001615
001616
001617
001618
001619
001620
001621
001622
001623
001624
001625
001626
001627

SELF.layoutBox.Highlight(highTransit);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TLayPickSelection.MouseMove(mouseLPt: LPoint);
VAR diffLPt:
LPoint;
diffLRect:
LRect;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{How far did mouse move?}
LPtMinusLPt(mouseLPt, SELF.currLPt, diffLPt);
{Don't move past view boundaries}
LRectMinusLRect(SELF.view.extentLRect, SELF.layoutBox.extentLRect, diffLRect);
LRectHaveLPt(diffLRect, diffLPt);
{Move it if delta is nonzero}
IF NOT EqualLPt(diffLPt, zeroLPt) THEN
BEGIN
{$H-} OffsetLRect(SELF.boundLRect, diffLPt.h, diffLPt.v); {$H+}
LPtPlusLPt(SELF.currLPt, diffLPt, mouseLPt);
SELF.currLPt := mouseLPt;

{probably discard}

SELF.layoutBox.Move(diffLPt);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TLayPickSelection.MouseRelease;
VAR deltaLPt:
LPoint;
noSelection:
TSelection;
manipulee:
TImage;
parent:
TDialogImage;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF NOT EqualLPt(SELF.currLPt, SELF.anchorLPt) THEN
BEGIN
LPtMinusLPt(SELF.currLPt, SELF.anchorLPt, deltaLPt);
SELF.window.PerformCommand(TLayMoveCmd.CREATE(NIL, SELF.Heap,
SELF.layoutBox, deltaLPt.h, deltaLPt.v));
END;
manipulee := SELF.layoutBox.manipulee;
IF manipulee <> NIL THEN
manipulee.RecalcExtent; {will send it up the line to its parents}

Apple Lisa ToolKit 3.0 Source Code Listing -- 462 of 1012

Apple Lisa Computer Technical Information


001628
001629
001630
001631
001632
001633
001634
001635
001636
001637
001638
001639
001640
001641
001642
001643
001644
001645
001646
001647
001648
001649
001650
001651
001652
001653
001654
001655
001656
001657
001658
001659
001660
001661
001662
001663
001664
001665
001666
001667
001668
001669
001670
001671
001672
001673
001674
001675

parent := SELF.layoutBox.parent;
IF parent <> NIL THEN {now send it up the line to my own parents}
IF InClass(parent, TLayoutBox) THEN
parent.RecalcExtent;
IF NOT TPlannerView(SELF.layoutBox.view).retainPickedBox THEN
SELF.Deselect;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TLayPickSelection.Restore;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
TPlannerView(SELF.view).currentLayoutBox := SELF.layoutBox;
SUPERSELF.Restore;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
METHODS OF TLayMoveCmd;
{$S SgLayout}
FUNCTION TLayMoveCmd.CREATE{(object: TObject; heap: THeap; itsLayoutBox: TLayoutBox;
itsHOffset, itsVOffset: LONGINT): TLayMoveCmd};
VAR retainPickedBox:
BOOLEAN;
cmdPhase:
TCmdPhase;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TLayMoveCmd(TCommand.CREATE(object, heap, uMoveLayoutBoxes, itsLayoutBox.view,
TRUE, revealSome));
WITH SELF DO
BEGIN
layoutBox := itsLayoutbox;
hOffset := itsHOffset;
vOffset := itsVOffset;
retainPickedBox := TPlannerView(itsLayoutBox.view).retainPickedBox;
WITH SELF DO
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 463 of 1012

Apple Lisa Computer Technical Information


001676
001677
001678
001679
001680
001681
001682
001683
001684
001685
001686
001687
001688
001689
001690
001691
001692
001693
001694
001695
001696
001697
001698
001699
001700
001701
001702
001703
001704
001705
001706
001707
001708
001709
001710
001711
001712
001713
001714
001715
001716
001717
001718
001719
001720
001721
001722
001723

unHiliteBefore[doPhase] := FALSE;
hiliteAfter[doPhase] := FALSE;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TLayMoveCmd.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('layoutBox: TLayoutBox');
Field('hOffset: LONGINT');
Field('vOffset: LONGINT');
Field('');
END;
{$ENDC}
{$S SgLayout}
PROCEDURE TLayMoveCmd.Perform(cmdPhase: TCmdPhase);
VAR plannerView:
TPlannerView;
panel:
TPanel;
diffLPt:
LPoint;
BEGIN
{$IFC fTrace}BP(12);{$ENDC}
IF cmdPhase <> doPhase THEN
BEGIN
WITH SELF DO {$H-}
CASE cmdPhase OF
redoPhase:
SetLPt(diffLPt, hOffset, vOffset);
undoPhase:
SetLPt(diffLPt, -hOffset, -vOffset);
END; {$H+}
SELF.layoutBox.Move(diffLPt);
SELF.layoutBox.manipulee.RecalcExtent;
SELF.layoutBox.RecalcExtent;
IF NOT TPlannerView(SELF.layoutBox.view).retainPickedBox THEN
SELF.layoutBox.view.panel.selection.Deselect;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}

Apple Lisa ToolKit 3.0 Source Code Listing -- 464 of 1012

Apple Lisa Computer Technical Information


001724
001725
001726
001727
001728
001729
001730
001731
001732
001733
001734
001735
001736
001737
001738
001739
001740
001741
001742
001743
001744
001745
001746
001747
001748
001749
001750
001751
001752
001753
001754
001755
001756
001757
001758
001759
001760
001761
001762
001763
001764
001765
001766
001767
001768
001769
001770
001771

END;
METHODS OF TEditLegendSelection;
{$S SgLayout}
FUNCTION TEditLegendSelection.CREATE(object: TObject; heap: THeap; itsLegendLayoutBox:
TLegendLayoutBox; itsAnchorLPt: LPoint): TEditLegendSelection;
VAR coSelection:
TSelection;
paragraph:
TParagraph;
paraImage:
TParaImage;
hostLegend:
TLegend;
textDialogImage:
TTextDialogImage;
textImage:
TTextImage;
textExtent:
LRect;
typeStyle:
TTypeStyle;
hostParagraph:
TParagraph;
PROCEDURE FindBiggestFont(VAR biggestTypeStyle: TTypeStyle);
VAR styleChange:
TStyleChange;
{$IFC libraryVersion <= 20}
{* * * P E P S I * * *}
fInfo:
TFInfo;
{$ELSEC}
{* * S P R I N G * *}
fInfo:
FontInfo;
{$ENDC}
i:
INTEGER;
oldTallest:
INTEGER;
BEGIN
oldTallest := 0;
FOR i := 1 TO hostParagraph.typeStyles.size - 1 DO
BEGIN
hostParagraph.typeStyles.GetAt(i, @styleChange);
hostParagraph.SetTypeStyle(styleChange.newStyle);
GetFontInfo(fInfo);
WITH fInfo DO
IF oldTallest < ascent + descent + leading THEN
BEGIN
oldTallest := ascent + descent + leading;
biggestTypeStyle := styleChange.newStyle;
END;
END;
END;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);

Apple Lisa ToolKit 3.0 Source Code Listing -- 465 of 1012

Apple Lisa Computer Technical Information


001772
001773
001774
001775
001776
001777
001778
001779
001780
001781
001782
001783
001784
001785
001786
001787
001788
001789
001790
001791
001792
001793
001794
001795
001796
001797
001798
001799
001800
001801
001802
001803
001804
001805
001806
001807
001808
001809
001810
001811
001812
001813
001814
001815
001816
001817
001818
001819

SELF := TEditLegendSelection(TSelection.CREATE(object, heap, itsLegendLayoutBox.view,


layEditLegendSelectionKind, itsAnchorLPt));
IF itsLegendLayoutBox.parent <> NIL THEN
SELF.boundLRect := itsLegendLayoutBox.parent.extentLRect
ELSE
SELF.boundLRect := itsLegendLayoutBox.extentLRect;
SELF.legendLayoutBox := itsLegendLayoutBox;
hostLegend := TLegend(itsLegendLayoutBox.manipulee);
SELF.hostLegend := hostLegend;
hostParagraph := hostLegend.paragraph;
SELF.suppressHost := itsLegendLayoutBox.suppressDrawingManipulee;
coSelection := SELF.panel.view.NoSelection;
SELF.coSelection := coSelection;

{put non-NIL coSelection}

hostLegend.paragraph.StyleAt(0, typeStyle); {use paragraph's default if none else}


FindBiggestFont(typeStyle);
SetParaExtent(hostLegend.paragraph, SELF.view, hostLegend.location, textExtent);
textExtent.right := textExtent.left + 10 * SELF.view.res.h;
{ten inches wide}
textDialogImage := TTextDialogImage.CREATE(NIL, heap, textExtent, noID, SELF.view,
typeStyle, '');
{start off with an empty guy}
SELF.textDialogImage := textDialogImage;
textImage := textDialogImage.textImage;
paraImage := TParaImage(textImage.imageList.First);
paragraph := paraImage.paragraph;
paragraph.ReplPara(0,
paragraph.size, hostLegend.paragraph, 0, hostLegend.paragraph.size);
paraImage.changed := TRUE;
paraImage.InvalLinesWith(0, MAXINT);
textImage.RecomputeImages(actionNone, TRUE);
itsLegendLayoutBox.textDialogImage := textDialogImage;
SELF.textDialogImage := textDialogImage;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
FUNCTION TEditLegendSelection.Clone(heap: THeap): TObject;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.textDialogImage.ChangeRefCountBy(1);

Apple Lisa ToolKit 3.0 Source Code Listing -- 466 of 1012

Apple Lisa Computer Technical Information


001820
001821
001822
001823
001824
001825
001826
001827
001828
001829
001830
001831
001832
001833
001834
001835
001836
001837
001838
001839
001840
001841
001842
001843
001844
001845
001846
001847
001848
001849
001850
001851
001852
001853
001854
001855
001856
001857
001858
001859
001860
001861
001862
001863
001864
001865
001866
001867

Clone := TEditLegendSelection(SUPERSELF.Clone(heap));
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TEditLegendSelection.Deselect;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.legendLayoutBox.textDialogImage := NIL; {+SW+}
SUPERSELF.Deselect;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TEditLegendSelection.Free;
VAR textDialogImage:
TTextDialogImage;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
textDialogImage := SELF.textDialogImage; {+SW+} {five lines out}
SUPERSELF.Free;
textDialogImage.ChangeRefCountBy(-1);
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TEditLegendSelection.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('legendLayoutBox: TLegendLayoutBox');
Field('hostLegend: TLegend');
Field('textDialogImage: TTextDialogImage');
Field('suppressHost: BOOLEAN');
Field('tripleClick: BOOLEAN'); {+SW+}
Field('');
END;
{$ENDC}
{$S SgLayout}
FUNCTION TEditLegendSelection.CanDoCommand(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN): BOOLEAN;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
CASE cmdNumber OF
uModern, uClassic,u20Pitch, u15Pitch, u12Pitch, u10Pitch, u12Point, u14Point, u18Point, u24Point,

Apple Lisa ToolKit 3.0 Source Code Listing -- 467 of 1012

Apple Lisa Computer Technical Information


001868
001869
001870
001871
001872
001873
001874
001875
001876
001877
001878
001879
001880
001881
001882
001883
001884
001885
001886
001887
001888
001889
001890
001891
001892
001893
001894
001895
001896
001897
001898
001899
001900
001901
001902
001903
001904
001905
001906
001907
001908
001909
001910
001911
001912
001913
001914
001915

uPlain, uBold, uItalic, uUnderline, uShadow, uOutline:


IF SELF.hostLegend.usesSysFont THEN
CanDoCommand := FALSE
ELSE
CanDoCommand := SUPERSELF.CanDoCommand(cmdNumber, checkIt);
OTHERWISE
CanDoCommand := SUPERSELF.CanDoCommand(cmdNumber, checkIt);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TEditLegendSelection.KeyBack(fWord: BOOLEAN);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.coSelection.KeyBack(fWord);
SELF.legendLayoutBox.RecalcExtent; {will determine current width of the textDialogImage and
adjust layout box + parents accordingly}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TEditLegendSelection.KeyChar(ch: CHAR);
VAR newExtent:
LRect;
width:
INTEGER;
paragraph:
TParagraph;
i:
INTEGER;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
paragraph := TParaImage(SELF.textDialogImage.textImage.imageList.First).paragraph;
IF (paragraph.size < 255) OR
(NOT InClass(SELF.coSelection, TInsertionPoint)) THEN {can accept more}
BEGIN
SELF.coSelection.KeyChar(ch);
SELF.legendLayoutBox.RecalcExtent; {will determine current width of the textDialogImage and
adjust layout box + parents accordingly}
END
ELSE
BEGIN
process.ArgAlert(1, '255');
process.Stop(phTooManyChars);
END;
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 468 of 1012

Apple Lisa Computer Technical Information


001916
001917
001918
001919
001920
001921
001922
001923
001924
001925
001926
001927
001928
001929
001930
001931
001932
001933
001934
001935
001936
001937
001938
001939
001940
001941
001942
001943
001944
001945
001946
001947
001948
001949
001950
001951
001952
001953
001954
001955
001956
001957
001958
001959
001960
001961
001962
001963

END;
{$S SgLayout}
PROCEDURE TEditLegendSelection.KeyEnter(dh, dv: INTEGER);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF (dh <> 0) OR (dv <> 0) THEN
SELF.KeyTab((dh < 0) OR (dv < 0)); {right and down keys are Forward}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TEditLegendSelection.KeyReturn;
VAR selection: TSelection;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.Deselect;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TEditLegendSelection.MousePress(mouseLPT: LPoint); {+SW+}
VAR selection: TSelection;
textImage: TTextImage;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF clickState.clickCount < 3 THEN
SUPERSELF.MousePress(mouseLPt)
ELSE {triple click; force SelectAll}
BEGIN
SELF.tripleClick := TRUE;
textImage := SELF.textDialogImage.textImage;
SELF.Highlight(hOnToOff);
SELF.coSelection.Become(
textImage.text.SelectAll(textImage));
SELF.Highlight(hOffToOn);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TEditLegendSelection.MouseMove(mouseLPT: LPoint); {+SW+}
BEGIN
{$IFC fTrace}BP(11);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 469 of 1012

Apple Lisa Computer Technical Information


001964
001965
001966
001967
001968
001969
001970
001971
001972
001973
001974
001975
001976
001977
001978
001979
001980
001981
001982
001983
001984
001985
001986
001987
001988
001989
001990
001991
001992
001993
001994
001995
001996
001997
001998
001999
002000
002001
002002
002003
002004
002005
002006
002007
002008
002009
002010
002011

IF NOT SELF.tripleClick THEN


SUPERSELF.MouseMove(mouseLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TEditLegendSelection.MouseRelease; {+SW+}
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.tripleClick THEN
SELF.tripleClick := FALSE
ELSE
SUPERSELF.MouseRelease;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TEditLegendSelection.PerformCommand(command: TCommand; cmdPhase: TCmdPhase);
VAR paragraph: TParagraph;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SUPERSELF.PerformCommand(command, cmdPhase);
IF SELF.hostLegend.usesSysFont THEN
BEGIN
paragraph := TParaImage(SELF.textDialogImage.textImage.imageList.First).paragraph;
paragraph.NewStyle(0, paragraph.Size, sysTypeStyle);
END;
SELF.legendLayoutBox.RecalcExtent; {will determine current width of the textDialogImage and
adjust layout box + parents accordingly}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TEditLegendSelection.Restore;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.legendLayoutBox.textDialogImage := SELF.textDialogImage;
SUPERSELF.Restore;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgLayout}
PROCEDURE TEditLegendSelection.Reveal(asMuchAsPossible: BOOLEAN);
TYPE TXLRect = PACKED ARRAY [1..SIZEOF(LRect)] OF CHAR;

Apple Lisa ToolKit 3.0 Source Code Listing -- 470 of 1012

Apple Lisa Computer Technical Information


002012
002013
002014
002015
002016
002017
002018
002019
002020
002021
002022
002023
002024
002025
002026
002027
002028
002029
002030
002031
002032
002033
002034
002035
002036
002037
002038
002039
002040
002041
002042
002043
002044
002045
002046
002047
002048
002049
002050
002051
002052
002053
002054
002055
002056
002057
002058
002059

VAR lr:
LRect;
hMin:
INTEGER;
vMin:
INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.coselection.boundLRect := SELF.boundLRect;
SUPERSELF.Reveal(asMuchAsPossible);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
METHODS OF TDialogDesignWindow;
{$S DlgAlloc}
FUNCTION TDialogDesignWindow.CREATE(object: TObject; heap: THeap;
itsHostDialogView: TDialogView): TDialogDesignWindow;
VAR fromBox:
BOOLEAN;
window:
TWindow;
htLPt:
LPoint;
height:
INTEGER;
htPt:
Point;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
window := itsHostDialogView.panel.window;
fromBox := InClass(window, TDialogBox);
IF fromBox THEN
height := window.outerRect.bottom - window.outerRect.top + 15
ELSE
BEGIN
WITH itsHostDialogView.extentLRect DO
{$H-}
SetLPt(htLPt, 0, bottom - top); {$H+}
itsHostDialogView.screenPad.LPtToPt(htLPt, htPt);
height := MIN(htPt.v + 15, screenBits.bounds.bottom - 30);
END;
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TDialogDesignWindow(TDialogWindow.CREATE(object, heap, TRUE, height,
diAccept, diAccept, diRefuse));
WITH SELF DO
BEGIN
hostWindow := window;

Apple Lisa ToolKit 3.0 Source Code Listing -- 471 of 1012

Apple Lisa Computer Technical Information


002060
002061
002062
002063
002064
002065
002066
002067
002068
002069
002070
002071
002072
002073
002074
002075
002076
002077
002078
002079
002080
002081
002082
002083
002084
002085
002086
002087
002088
002089
002090
002091
002092
002093
002094
002095
002096
002097
002098
002099
002100
002101
002102
002103
002104
002105
002106
002107

hostDialogView := itsHostDialogView;
fromDialogBox := fromBox;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TDialogDesignWindow.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('hostWindow: TWindow');
Field('hostDialogView: TDialogView');
Field('fromDialogBox: BOOLEAN');
Field('');
END;
{$ENDC}
{$S DlgLayout}
FUNCTION TDialogDesignWindow.CanDoCommand(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN): BOOLEAN;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
CASE cmdNumber OF
uEditDialog:
CanDoCommand := FALSE; {override SUPERSELF}
uStopEditDialog:
CanDoCommand := TRUE;
OTHERWISE
CanDoCommand := SUPERSELF.CanDoCommand(cmdNumber, checkIt);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgLayout}
FUNCTION TDialogDesignWindow.NewCommand(cmdNumber: TCmdNumber): TCommand;
BEGIN
{$IFC fTrace}BP(12);{$ENDC}
CASE cmdNumber OF
uStopEditDialog:
BEGIN
SELF.RelinquishControl;
NewCommand := NIL;
END;
OTHERWISE
NewCommand := SUPERSELF.NewCommand(cmdNumber);

Apple Lisa ToolKit 3.0 Source Code Listing -- 472 of 1012

Apple Lisa Computer Technical Information


002108
002109
002110
002111
002112
002113
002114
002115
002116
002117
002118
002119
002120
002121
002122
002123
002124
002125
002126
002127
002128
002129
002130
002131
002132
002133
002134
002135
002136
002137
002138
002139
002140
002141
002142
002143
002144
002145
002146
002147
002148
002149
002150
002151
002152
002153
002154
002155

END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgLayout}
PROCEDURE TDialogDesignWindow.RelinquishControl;
{not yet: install in resourceFile}
VAR panel:
TPanel;
plannerView:
TPlannerView;
dialogWindow:
TDialogWindow;
newHeight:
INTEGER;
noSelection:
TSelection;
newBotRight:
point;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
panel := SELF.selectPanel;
panel.selection.Deselect;
{should incorporate last text edit, if any}
panel.window.CommitLast;
panel.BeginSelection;
{previous didn't really quite do it yet}
currentWindow.TakeDownDialogBox;

{take down layout dialog}

IF SELF.fromDialogBox THEN {editing a dialog box--copy the resizing back to the dialog Window}
BEGIN
plannerView := TPlannerView(panel.currentView);
newHeight := panel.innerRect.bottom;
dialogWindow := TDialogWindow(plannerView.viewBeingPlanned.panel.window);
SetPt(newBotRight, screenBits.bounds.right, newHeight);
{transfer its current...}
currentWindow.PutUpDialogBox(dialogWindow);
dialogWindow.ResizeTo(newBotRight);
{height to main dialog}
IF dialogWindow.selectPanel.selection.kind <> nothingKind THEN
currentWindow.selectWindow := dialogWindow; {=}
END;
SELF.selectPanel.view := NIL;
{kludge to avoid clobbering the main view}
currentWindow.Focus; {necessary to avoid a later popFocus trying to focus our now departed
DialogDesignWindow}
SELF.Free; {!}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgLayout}
PROCEDURE TDialogDesignWindow.Resize(moving: BOOLEAN);
VAR view:
TView;
extentLRect:
LRect;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 473 of 1012

Apple Lisa Computer Technical Information


002156
002157
002158
002159
002160
002161
002162
002163
002164
002165
002166
002167
002168
002169
002170
002171
002172
002173
002174
002175
002176
002177
002178
002179
002180
002181
002182
002183
002184
002185
002186
002187
002188
002189
002190
002191
002192
002193
002194
002195
002196
002197
002198
002199
002200
002201
002202
002203

{$IFC fTrace}BP(11);{$ENDC}
SUPERSELF.Resize(moving); {moving is always FALSE of course}
IF SELF.hostWindow.isResizable THEN
{do nothing, I guess}
ELSE
BEGIN
view := SELF.selectPanel.currentView;
extentLRect := view.extentLRect;
extentLRect.bottom := SELF.selectPanel.innerRect.bottom;
view.Resize(extentLRect);
{that'll be the layout view}
SELF.hostDialogView.Resize(extentLRect);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgLayout}
PROCEDURE TDialogDesignWindow.SeizeControl;
VAR dialogView:
TDialogView;
panel:
TPanel;
children:
TList;
imageList:
TList;
dialogBox:
TDialogBox;
savedSetting:
BOOLEAN;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
dialogView := SELF.hostDialogView;
children := dialogView.rootDialog.children;
IF SELF.fromDialogBox THEN
BEGIN
dialogBox := currentWindow.dialogBox;
savedSetting := dialogBox.freeOnDismissal;
dialogBox.freeOnDismissal := FALSE;
currentWindow.TakeDownDialogBox;
dialogBox.freeOnDismissal := savedSetting;
END;
panel := TPanel.CREATE(NIL, SELF.Heap, SELF, 0, SELF.innerRect.right - 23, [aScroll, aBar],
[aScroll, aBar]);
SELF.controlPanel := panel;
CASE children.Size OF
0:
ABCBreak('SeizeControl, empty children of dialog view', 0);
1:
imageList := TDialog(children.First).children;
OTHERWISE
imageList := children;
END; {case}

Apple Lisa ToolKit 3.0 Source Code Listing -- 474 of 1012

Apple Lisa Computer Technical Information


002204
002205
002206
002207
002208
002209
002210
002211
002212
002213
002214

TPlannerView.CREATE(NIL, SELF.Heap, dialogView, panel, FALSE, FALSE).Init(imageList);


currentWindow.PutUpDialogBox(SELF);
panel.BeginSelection;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;

End of File -- Lines: 2214 Characters: 68581

Apple Lisa ToolKit 3.0 Source Code Listing -- 475 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UDIALOG4.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{UDialog4}

{Handles Page Headings & Page Margins}

{Copyright 1984 by Apple Computer, INC}

(*
ORDER OF METHODS:
CLASS
-----------------TStdPrintManager
TLegendHeading
TPageDesignWindow
TPagePlannerView
TPageLayoutBox
TLgHdngLayoutBox
TPageStatusDialog

SUBCLASS OF
------------TPrintManager
THeading
TDialogWindow
TPlannerView
TLayoutBox
TPageLayoutBox
TDialog

WHICH IS IN
----------UABC3
UABC3
UDialog2
UDialog3
UDialog3
UDialog4
UDialog2

*)
{04/25/84 19:00 TLgHdngLayoutBox.MousePress -- don't invalidate the layout box
TPageStatusDialog.CREATE explicitly sets extentLRect's topLeft to zeroLPt}
{04/24/84 23:51 TPageDesignWindow.CREATE sets the status view's scrollPastEnd to zeroPt}
{04/24/84 18:00 TPageDesignWindow.CREATE allows scrolling in the status panel}
{04/23/84 12:18 In TStdPrintManager.SetDfltHeadings, supply a blank space before and after the
the '{TITLE)', so that a select-all followed by a font change will result in
the new font applying to the substituted string at print or page-preview time}
{04/17/84 17:16 Make the TPagePlannerView show no gray at the end.}
{04/15/84 0200
TPageDesignWindow.NewCommand frees panel's undoSelection as well as main selection}
{04/14/84 03:00 Removed pilotHeading from TPageLayoutBox; removed TPageLayoutBox.Free, consequently,
as well as TPageLayoutBox.Fields
Offset master as well as current Legend in TLegendHeading.OffsetBy}
{changed 04/14/84 0102 Major rewrite of TLgHdngLayoutBox.RecalcExtent & TP }
{changed 04/13/84 2230 TLgHdngLayoutBox.RecalcExtent doesn't call SetParaExtent; just uses legend's extent
& TPageLayoutBox.FreeManipulee sets SELF.manipulee to NIL after freeing
& TPageDesignWindow.NewCommand sets plannerView.currentLayoutBox to NIL
after freeing the LgHdngLayoutBox...}
{changed 04/13/84 1630 Changed to not using bolding on the margins-dialog heading}
{changed 04/11/84 2315 Do TopToBaseLine stuff in hdngs recalculation only if not fExperimenting...}
{changed 04/11/84 1700 Use dfltNewHeading global var in laucnhing new heading in TDialogDesignWindow.NewCmd,
and varPage and varTitle in TStdPrintManager.SetDfltHeadings;
In TPageStatusDialog.CREATE, use a CONST depending on libraryVersion to determine
the spacing between the boxes in the margins checkbox dialog}
{04/04/84 2300 Spring Prelim Release}
{01/29/84 1800 RELEASE TK8D}
{12/21/83 1657 RELEASE TK8A}

Apple Lisa ToolKit 3.0 Source Code Listing -- 476 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

METHODS OF TStdPrintManager;
{$S DlgAlloc}
FUNCTION TStdPrintManager.CREATE(object: TObject; heap: THeap): TStdPrintManager;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TStdPrintManager(TPrintManager.CREATE(object, heap));
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
PROCEDURE
CONST

TStdPrintManager.SetDfltHeadings;
topFudge = 0;
bottomFudge = 0;
VAR anOffset:
LPoint;
margins:
LRect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
margins := SELF.pageMargins;
SetLPt(anOffset, 0, (margins.top + topFudge) DIV 2);
SELF.headings.InsLast(TLegendHeading.CREATE(NIL, SELF.Heap, SELF, CONCAT(' {', varTitle, '} '), {+SW+}
stdHdngTypeStyle, aTopCenter, anOffset, stdHdngBorders));
SetLPt(anOffset, 0, - (ABS(margins.bottom + bottomFudge) DIV 2));
SELF.headings.InsLast(TLegendHeading.CREATE(NIL, SELF.Heap, SELF,
stdHdngTypeStyle, aBottomCenter, anOffset, stdHdngBorders));

CONCAT('-{', varPage, '}-'),

{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgAlloc}
PROCEDURE TStdPrintManager.Init(itsMainView: TView; itsDfltMargins: LRect);
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SUPERSELF.Init(itsMainView, itsDfltMargins);
SELF.canEditPages := TRUE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S HdgMarg}

Apple Lisa ToolKit 3.0 Source Code Listing -- 477 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

PROCEDURE TStdPrintManager.EnterPageEditting;
VAR window:
TWindow;
pageDesignWindow:
TPageDesignWindow;
pagePlannerView:
TPagePlannerView;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
window := SELF.view.panel.window;
window.CommitLast;
IF SELF.layoutDialogBox = NIL THEN
BEGIN
pageDesignWindow := TPageDesignWindow.CREATE(NIL, SELF.Heap, SELF.view);
SELF.layoutDialogBox := pageDesignWindow;
END;
window.PutUpDialogBox(SELF.layoutDialogBox);
{$IFC fTrace}EP;{$ENDC}
END;
{$S TK2Start}
PROCEDURE TStdPrintManager.ReactToPrinterChange;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SUPERSELF.ReactToPrinterChange;
IF SELF.layoutDialogBox <> NIL THEN
TPageDesignWindow(SELF.layoutDialogBox).layoutPanel.view.Resize(SELF.pageView.extentLRect);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
METHODS OF TLegendHeading;
{$S DlgAlloc}
FUNCTION TLegendHeading.CREATE(object: TObject; heap: THeap; itsPrintManager: TPrintManager;
itsString: S255; itsTypeStyle: TTypeStyle;
itsPageAlignment: TPageAlignment; itsOffsetFromAlignment: LPoint;
itsBorders: Rect): TLegendHeading;
VAR newMaster: TLegend;
newCurrent: TLegend;
extent:
LRect;
view:
TView;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
view := itsPrintManager.pageView;
SetLRect(extent, 0, 0, 100, 100); {meaningless at this point}

Apple Lisa ToolKit 3.0 Source Code Listing -- 478 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

IF object = NIL THEN


object := NewObject(heap, THISCLASS);
SELF := TLegendHeading(THeading.CREATE(object, heap, itsPrintManager, extent, itsPageAlignment,
itsOffsetFromAlignment));
newMaster:= TLegend.CREATE(NIL, heap, itsString, view, zeroLPt, itsTypeStyle);
newCurrent := TLegend.CREATE(NIL, heap, itsString, view, zeroLPt, itsTypeStyle);
newMaster.HaveView(view);
newCurrent.HaveView(view);
SetParaExtent(newMaster.paragraph, view, zeroLPt, extent);
WITH SELF DO
BEGIN
masterLegend := newMaster;
currentLegend := newCurrent;
borders := itsBorders;
minPage := 1;
{readjusts from std 2, for demo purposes}
topToBaseline := - itsBorders.top - extent.top; {both tops are negative}
END;
newMaster.wouldBeDraggable := FALSE;
newCurrent.wouldBeDraggable := FALSE;
SELF.RecalcExtent;
{$IFC fTrace}EP;{$ENDC}
END;
{$S HdgMarg}
PROCEDURE TLegendHeading.Free;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
Free(SELF.masterLegend);
Free(SELF.currentLegend);
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TLegendHeading.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('masterLegend: TLegend');
Field('currentLegend: TLegend');

Apple Lisa ToolKit 3.0 Source Code Listing -- 479 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

Field('topToBaseline: INTEGER');
Field('borders: Rect');
Field('');
END;
{$ENDC}
{$S DlgRes}
PROCEDURE TLegendHeading.AdjustForPage(pageNumber: LONGINT; editing: BOOLEAN);
VAR currS255:
S255;
aVariable:
S255;
leftBracePos:
INTEGER;
rightBracePos:
INTEGER;
newValue:
S255;
restOfString:
S255;
newExtent:
LRect;
currentParagraph:
TParagraph;
masterParagraph:
TParagraph;
substituted:
BOOLEAN;
lastPosition:
INTEGER;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
substituted := FALSE; {still flawed}
lastPosition := 0;
SELF.masterLegend.GetString(currS255);
currentParagraph := SELF.currentLegend.paragraph;
masterParagraph := SELF.masterLegend.paragraph;
currentParagraph.ReplPara(0, currentParagraph.size, masterParagraph, 0,
masterParagraph.size); {download entire master into current}
IF NOT editing THEN
BEGIN
REPEAT
leftBracePos := POS('{', currS255);
IF leftBracePos > 0 THEN
IF leftBracePos < lastPosition THEN {was within the previous variable}
currS255[leftBracePos] := '$'
{... so we won't get it next time}
ELSE
BEGIN
restOfString := COPY(currS255, leftBracePos + 1, LENGTH(currS255) - leftBracePos);
rightBracePos := POS('}', restOfString);
IF rightBracePos > 0 THEN
BEGIN
aVariable := COPY(restOfString, 1, rightBracePos - 1);
SELF.printManager.view.SetFunctionValue(aVariable, newValue);
substituted := TRUE;
currentParagraph.ReplPString(leftBracePos - 1, rightBracePos + 1,
@newValue);

Apple Lisa ToolKit 3.0 Source Code Listing -- 480 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

DELETE(currS255, leftBracePos, rightBracePos + 1); {get rid of the var code}


INSERT(newValue, currS255, leftBracePos); {substitute the variable's value}
currS255[leftBracePos] := '$';
lastPosition := leftBracePos + LENGTH(newValue);
END
ELSE
lastPosition := LENGTH(currS255) + 1;
END;

UNTIL
leftBracePos = 0;
END

{not editing}

ELSE {editing}
SELF.masterLegend.GetBoxRight;
SELF.RecalcExtent; {tells currentLegend to get box right, then adds in my borders}
{we only need worry about our extentLRect, our location, and our current legend all
being in synch; THeading.LocateOnPage will then find the exact page location,
taking into account my offsetFromAlignment}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgRes}
PROCEDURE TLegendHeading.Draw;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
IF SELF.ShouldFrame THEN
FrameLRect(SELF.extentLRect);
SELF.currentLegend.Draw;
{$IFC fTrace}EP;{$ENDC}
END;
{$S HdgMarg}
FUNCTION TLegendHeading.LaunchLayoutBox(view: TView): TImage;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
LaunchLayoutBox := TLgHdngLayoutBox.CREATE(NIL, SELF.Heap, view, SELF);
{$IFC fTrace}EP;{$ENDC}
END;
{$S HdgMarg}
PROCEDURE TLegendHeading.OffsetBy(deltaLPt: LPoint);
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 481 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

{$IFC fTrace}BP(9);{$ENDC}
SELF.currentLegend.OffsetBy(deltaLPt);
SUPERSELF.OffsetBy(deltaLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S TK2Start}
PROCEDURE TLegendHeading.RecalcExtent;
VAR newExtent: LRect;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
SELF.currentLegend.GetBoxRight;
LRectAddBorders(SELF.currentLegend.extentLRect, SELF.borders, newExtent);
SELF.Resize(newExtent);
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgRes}
FUNCTION TLegendHeading.ShouldFrame;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
ShouldFrame := FALSE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
METHODS OF TPageDesignWindow;
{$S DlgAlloc}
FUNCTION TPageDesignWindow.CREATE(object: TObject; heap: THeap; itsHostView: TView): TPageDesignWindow;
CONST
cPgWindowHeight = 340;
cPgControlHeight = 130; {height of the control (status) panel}
cHtStatusView = 220;
VAR controlPanel:
layoutPanel:
hdngDialog:
plannerView:
dialogView:
extentLRect:
BEGIN

TPanel;
TPanel;
THeadingDialog;
TPlannerView;
TDialogView;
LRect;

Apple Lisa ToolKit 3.0 Source Code Listing -- 482 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TPageDesignWindow(TDialogWindow.CREATE(object, heap, TRUE, cPgWindowHeight, diAccept,
diAccept, diRefuse));
SELF.hostView := itsHostView;
layoutPanel := TPanel.CREATE(NIL, heap, SELF, 0, 0, [aScroll, aSplit], [aScroll, aSplit]);
plannerView := TPagePlannerView.CREATE(NIL, heap, itsHostView.printManager, layoutPanel);
SELF.layoutPanel := layoutPanel;
controlPanel := layoutPanel.Divide(v, cPgControlHeight, pixelsFromEdge,
[userCanResizeIt], 10 {min size}, [aScroll], [aScroll]); {+SW+}
SELF.controlPanel := controlPanel;
SetLRect(extentLRect, 0, 0, screenBits.bounds.right, cHtStatusView);
dialogView := TDialogView.CREATE(NIL, heap, extentLRect, controlPanel, NIL, screenRes);
dialogView.scrollPastEnd := zeroPt; {+SW+}
dialogView.AddDialog(TPageStatusDialog.CREATE(NIL, heap, dialogView.panel));
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
PROCEDURE TPageDesignWindow.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('hostView: TView');
Field('layoutPanel: TPanel');
Field('');
END;
{$ENDC}
PROCEDURE TPageDesignWindow.Disappear;
VAR panel: TPanel;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
panel := TPagePlannerView(SELF.layoutPanel.view).viewBeingPlanned.panel;
IF panel.previewMode = mPrvwMargins THEN {make sure headings are updated}
panel.Invalidate;
SUPERSELF.Disappear;
{$IFC fTrace}EP;{$ENDC}
END;
{$S HdgMarg}

Apple Lisa ToolKit 3.0 Source Code Listing -- 483 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

FUNCTION TPageDesignWindow.NewCommand(cmdNumber: TCmdNumber): TCommand;


{unusually, uClear is armed by TLayPickSelection.NewCommand but dealt with by the PageDesignWindow}
VAR s:
TListScanner;
layoutBox:
TLayoutBox;
plannerView:
TPlannerView;
noSelection:
TSelection;
command:
TCommand;
selectedBox:
TLayoutBox;
panel:
TPanel;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
CASE cmdNumber OF
uClear: {not undoable at present...}
BEGIN
SELF.CommitLast; {The committal might require a to-be-freed textImage}
plannerView := TPlannerView(SELF.layoutPanel.view);
panel := plannerView.panel;
selectedBox := plannerView.currentLayoutBox;
s := plannerView.rootDialogImage.children.Scanner;
WHILE s.Scan(layoutBox) DO
IF layoutBox = selectedBox THEN
BEGIN
panel.selection.Deselect;
noSelection := panel.undoSelection.FreedAndReplacedBy(panel.view.NoSelection);
panel.InvalLRect(layoutBox.extentLRect);
layoutBox.FreeManipulee;
{Delete heading from the printManager}
s.Delete(TRUE);
{Delete heading's layout box from the plannerView}
s.Done;
END;
command := TCommand.CREATE(NIL, plannerView.Heap, uClear, plannerView, FALSE,
revealNone);
NewCommand := command;
plannerView.currentLayoutBox := NIL;
TPageStatusDialog(SELF.mainDialog).currentHeading := NIL;
END;
OTHERWISE
NewCommand := SUPERSELF.NewCommand(cmdNumber);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
METHODS OF TPagePlannerView;

Apple Lisa ToolKit 3.0 Source Code Listing -- 484 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

{$S DlgAlloc}
FUNCTION TPagePlannerView.CREATE(object: TObject; heap: THeap; itsPrintManager: TPrintManager;
itsPanel: TPanel): TPagePlannerView;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TPagePlannerView(TPlannerView.CREATE(object, heap, itsPrintManager.pageView, itsPanel,
FALSE, TRUE));
PushFocus;
TPane(itsPrintManager.view.panel.panes.First).Focus; {so that thePad will be set to something}
SELF.Init(itsPrintManager.headings);
PopFocus;
SELF.scrollPastEnd := zeroPt;
{$IFC fTrace}EP;{$ENDC}
END;
{$S HdgMarg}
PROCEDURE TPagePlannerView.Draw;
VAR contentLRect:
LRect;
pat:
Pattern;
contentRect:
Rect;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
contentLRect := SELF.viewBeingPlanned.printManager.contentLRect;
thePad.LPatToPat(marginPattern, pat);
thePad.LRectToRect(contentLRect, contentRect);
FillRect(contentRect, pat);

{screen embellishments}

PenNormal;
FrameLRect(SELF.extentLRect);
FrameLRect(contentLRect);
SUPERSELF.Draw;
{draw LayoutBoxes}
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
METHODS OF TPageLayoutBox;
{$S HdgMarg}

Apple Lisa ToolKit 3.0 Source Code Listing -- 485 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

FUNCTION

TPageLayoutBox.CREATE(object: TObject; heap: THeap; itsView: TView; itsHeading: THeading;


itsResizable: BOOLEAN): TPageLayoutBox;
VAR baseExtent: LRect;

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
baseExtent := itsHeading.extentLRect;
baseExtent.top := baseExtent.top + stdSlimTitleHeight;
IF object = NIL THEN
object := NewObject(itsHeading.Heap, THISCLASS);
SELF := TPageLayoutBox(TLayoutBox.CREATE(object, heap, baseExtent, noID, NIL,
itsView, itsHeading, stdPlainBorders, itsResizable,
TRUE, TRUE));
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TPageLayoutBox.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('');
END;
{$ENDC}
{$S HdgMarg}
PROCEDURE TPageLayoutBox.FreeManipulee;
VAR s:
TListScanner;
heading:
THeading;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
s := TPlannerView(SELF.view).viewBeingPlanned.view.printManager.headings.Scanner;
WHILE s.Scan(heading) DO
IF heading = SELF.manipulee THEN
BEGIN
s.Delete(TRUE);
s.Done;
SELF.manipulee := NIL;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S HdgMarg}
PROCEDURE TPageLayoutBox.TabGrabbed;
VAR heading:
THeading;
pageStatusDialog:
TPageStatusDialog;

Apple Lisa ToolKit 3.0 Source Code Listing -- 486 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

BEGIN
{$IFC fTrace}BP(10);{$ENDC}
heading := THeading(SELF.manipulee);
pageStatusDialog := TPageStatusDialog(TDialogView(TDialogWindow(SELF.view.panel.window
).controlPanel.view).rootDialog.children.First);
IF heading <> pageStatusDialog.currentHeading THEN
BEGIN
WITH heading DO
{$H-}
pageStatusDialog.SetHeadingParms(oddOnly, evenOnly, pageAlignment, minPage, maxPage); {$H+}
pageStatusDialog.currentHeading := heading;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S DlgInit}
END;
METHODS OF TLgHdngLayoutBox;
{$S HdgMarg}
FUNCTION

TLgHdngLayoutBox.CREATE(object: TObject; heap: THeap; itsView: TView;


itsLegendHeading: TLegendHeading): TLgHdngLayoutBox;
VAR myExtent:
LRect;
itsTitleTab:
TTitleTab;
masterLegend:
TLegend;
legendLayoutBox:
TLegendLayoutBox; {= SELF.children.First}
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
itsLegendHeading.AdjustForPage(0, TRUE);
itsLegendHeading.LocateOnPage(TRUE);
masterLegend := itsLegendHeading.masterLegend;
masterLegend.location := itsLegendHeading.currentLegend.location;
masterLegend.GetBoxRight;
LRectAddBorders(masterLegend.extentLRect, itsLegendHeading.borders, myExtent);
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TLgHdngLayoutBox(TImageWithID.CREATE(object, heap, myExtent, noID,
itsView, TRUE));
itsTitleTab := TTitleTab.CREATE(NIL, heap, SELF,

stdSlimTitleHeight, noID);

WITH SELF DO
BEGIN
titleTab := itsTitleTab;

Apple Lisa ToolKit 3.0 Source Code Listing -- 487 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

manipulee := itsLegendHeading;
suppressDrawingManipulee := TRUE;
wouldMakeSelection := TRUE;
isResizable := FALSE;
isDraggable := TRUE;
shouldFrame := TRUE;
borders := zeroRect;
END;
legendLayoutBox := TLegendLayoutBox(itsLegendHeading.masterLegend.LaunchLayoutBox(itsView));
SELF.legendLayoutBox := legendLayoutBox;
SELF.AddImage(legendLayoutBox);
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TLgHdngLayoutBox.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('legendLayoutBox: TLegendLayoutBox');
Field('');
END;
{$ENDC}
{$S HdgMarg}
FUNCTION TLgHdngLayoutBox.CursorAt(mouseLPt: LPoint): TCursorNumber;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF SELF.Hit(mouseLPt) THEN
IF SELF.titleTab.Hit(mouseLPt) THEN
CursorAt := arrowCursor
ELSE
CursorAt := textCursor
ELSE
CursorAt := noCursor;
{$IFC fTrace}EP;{$ENDC}
END;
{$S HdgMarg}
PROCEDURE TLgHdngLayoutBox.Draw;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF LRectIsVisible(SELF.extentLRect) THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 488 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

BEGIN
SELF.titleTab.Draw;
PenNormal;
FrameLRect(SELF.extentLRect);
SELF.legendLayoutBox.Draw;
END;
{$IFC fTrace}EP;{$ENDC}
END;

{draw overall box}

{$S HdgMarg}
PROCEDURE TLgHdngLayoutBox.MousePress(mouseLPT: LPoint);
VAR layoutBox:
TLayoutBox;
s:
TListScanner;
editLegendSelection:
TEditLegendSelection;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
LRectHaveLPt(SELF.legendLayoutBox.extentLRect, mouseLPt);
editLegendSelection := TEditLegendSelection(SELF.view.panel.selection.FreedAndReplacedBy(
TEditLegendSelection.CREATE(NIL, SELF.Heap,
SELF.legendLayoutBox,
mouseLPT)));
SELF.TabGrabbed; {get report on me right in the page status panel}
editLegendSelection.textDialogImage.MousePress(mouseLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S HdgMarg}
PROCEDURE TLgHdngLayoutBox.Move(deltaLPt: LPoint);
VAR legendHeading: TLegendHeading;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SUPERSELF.Move(deltaLPt); {offsets and invalidates}
legendHeading := TLegendHeading(SELF.manipulee);
legendHeading.masterLegend.OffsetBy(deltaLPt);
{$H-} LPtPlusLPt(legendHeading.offsetFromAlignment, deltaLPt, legendHeading.offsetFromAlignment);
{$IFC fTrace}EP;{$ENDC}
END;
{$S HdgMarg}
PROCEDURE TLgHdngLayoutBox.RecalcExtent;
VAR newExtent:
LRect;
oldExtent:
LRect;
deltaLPt:
LPoint;
newBaseLPoint:
LPoint;
borders:
Rect;

Apple Lisa ToolKit 3.0 Source Code Listing -- 489 of 1012

{$H+}

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

masterLegend:
TLegend;
oldTopToBaseline:
LONGINT;
newTopToBaseline:
LONGINT;
legendHeading:
TLegendHeading;
textExtent:
LRect;
alignedToTop:
BOOLEAN;
oldDescent:
INTEGER;
PROCEDURE InvalOldAndNew;
BEGIN
thePad.InvalLRect(oldExtent);
thePad.InvalLRect(newExtent);
END;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
oldExtent := SELF.extentLRect;
legendHeading := TLegendHeading(SELF.manipulee);
masterLegend := legendHeading.masterLegend;
borders := legendHeading.borders;
oldTopToBaseline := legendHeading.topToBaseline;
SetParaExtent(masterLegend.paragraph, SELF.view, zeroLpt, textExtent);
newTopToBaseline := - borders.top - textExtent.top;
alignedToTop := legendHeading.pageAlignment IN [aTopLeft, aTopCenter, aTopRight];
IF newTopToBaseline <> oldTopToBaseline THEN
BEGIN
IF alignedToTop THEN
legendHeading.offsetFromAlignment.v := legendHeading.offsetFromAlignment.v +
oldTopToBaseline - newTopToBaseline
ELSE {bottom alignment}
BEGIN
WITH oldExtent DO
oldDescent := bottom - top - oldTopToBaseline;
legendHeading.offsetFromAlignment.v := legendHeading.offsetFromAlignment.v textExtent.bottom + oldDescent;
END;
legendHeading.topToBaseline := newTopToBaseline;
END;
LRectAddBorders(SELF.legendLayoutBox.extentLRect, borders, newExtent);
legendHeading.Resize(newExtent);
legendHeading.LocateOnPage(TRUE);
newExtent := legendHeading.extentLRect;
SetLPt(newBaseLPoint, newExtent.left - borders.left, newExtent.top + newTopToBaseline);

Apple Lisa ToolKit 3.0 Source Code Listing -- 490 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

masterLegend.location := newBaseLPoint;
masterLegend.GetBoxRight;
SELF.Resize(newExtent);
LPtMinusLPt(newExtent.topLeft, oldExtent.topLeft, deltaLPt);
SELF.legendLayoutBox.OffsetLayoutBoxBy(deltaLPt, FALSE);
{its manipulee already ok}
IF NOT equalLRect(oldExtent, newExtent) THEN
SELF.view.panel.OnAllPadsDo(InvalOldAndNew);
SELF.TabGrabbed; {update page-status-dialog report panel}
{$IFC fTrace}EP;{$ENDC}
END;

{$S DlgInit}
END;
METHODS OF TPageStatusDialog;

{the status dialog in the PageDesign window}

{$S DlgAlloc}
FUNCTION TPageStatusDialog.CREATE(object: TObject; heap: THeap; itsPanel: TPanel): TPageStatusDialog;
CONST
{$IFC libraryVersion <= 20}
spcAdjustment = -1;
{$ELSEC}
{ S P R I N G }
spcAdjustment = -1;
{$ENDC}
VAR cluster:
TCluster;
aNumberString: S255;
inputFrame:
TInputFrame;
button:
TButton;
promptLoc:
LPoint;
inputLoc:
LPoint;
borders:
Rect;
checkbox:
TCheckbox;
newImage:
TDialogImage;
typeStyle:
TTypeStyle;
labelOffset:
Point;
legend:
TLegend;
boxSpacing:
INTEGER;
itsID:
S255;
itsLocation:
LPoint;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 491 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TPageStatusDialog(TDialog.CREATE(object, heap, 'PAGE', itsPanel.view));
SELF.currentHeading := NIL;
MakeTypeStyle(famModern, size12Pitch, [], typeStyle);
SetPt(labelOffset, 6, 0);
cluster := SELF.NewCluster(phOddEven);
checkbox := cluster.NewCheckbox(phOddOnly, stdBoxWidth - 3, stdBoxHeight - 2,
TRUE, labelOffset, typeStyle, FALSE);
checkbox := cluster.NewAlignedCheckbox(phEvenOnly, FALSE);
checkbox := cluster.NewAlignedCheckbox(phOddOrEven, TRUE);
SELF.oddEvenCluster := cluster;
SetRect(borders, -18, -2, 18, 2);
inputFrame := SELF.NewInputFrame(phMinPage, typeStyle, stdFrmeOffset, stdInputTypeStyle, 6,
borders, FALSE, FALSE);
LIntToStr(2, @aNumberString);
inputFrame.SupplantContents(aNumberString);
SELF.minPageFrame := inputFrame;
inputFrame := SELF.NewInputFrame(phMaxPage, typeStyle, stdFrmeOffset, stdInputTypeStyle, 6,
borders, FALSE, FALSE);
inputFrame.SupplantContents('------');
SELF.maxPageFrame := inputFrame;
cluster := SELF.NewCluster(phAlignment);
checkbox := cluster.NewCheckbox(phTopLeft, stdBoxWidth - 3, stdBoxHeight - 2, TRUE,
labelOffset, typeStyle, FALSE);
checkbox := cluster.NewAlignedCheckbox(phTopCenter, TRUE);
checkbox := cluster.NewAlignedCheckbox(phTopRight, FALSE);
checkbox := cluster.NewCheckbox(phBotLeft, stdBoxWidth - 3, stdBoxHeight - 2, TRUE,
labelOffset, typeStyle, FALSE); {for second row}
checkbox := cluster.NewAlignedCheckbox(phBotCenter, FALSE);
checkbox := cluster.NewAlignedCheckbox(phBotRight, FALSE);
SELF.alignCluster := cluster;
button := SELF.NewButton(phLaunchHeading, stdButtonMetrics, NIL, NoCmdNumber);
SELF.AddOKButton(noCmdNumber);
MakeTypeStyle(famModern, size10Pitch, [bold], typeStyle);
legend := SELF.NewLegend(phPageMargins, typeStyle);
MakeTypeStyle(famModern, size12Pitch, [bold], typeStyle);

Apple Lisa ToolKit 3.0 Source Code Listing -- 492 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

cluster := SELF.NewCluster(phUnits);
SELF.unitsCluster := cluster;
checkbox := cluster.NewCheckbox(phInches, stdBoxWidth - 3, stdBoxHeight - 2, TRUE,
labelOffset, typeStyle, TRUE);
checkbox := cluster.NewAlignedCheckbox(phCentimeters, FALSE);
MakeTypeStyle(famModern, size15Pitch, [], typeStyle);
legend := SELF.AddStdLegend('0.25 0.50 0.75 1.00 1.25
96, 140, typeStyle);
SELF.marginTitle := legend;

1.50

1.75

2.00

2.25

2.50',

boxSpacing := stdBoxSpacing + spcAdjustment;


legend := SELF.NewLegend(phLeft, sysTypeStyle);
cluster := SELF.NewRowOfBoxes(phLeftCluster, 10, 100, stdBoxWidth,
stdBoxHeight, boxSpacing);
cluster.selectBox(TCheckbox(cluster.ObjectWithIDNumber(103))); {make this the real thing someday}
SELF.leftCluster := cluster;
legend := SELF.NewLegend(phTop, sysTypeStyle);
cluster := SELF.NewRowOfBoxes(phTopCluster, 10, 200, stdBoxWidth, stdBoxHeight, boxSpacing);
cluster.selectBox(TCheckbox(cluster.ObjectWithIDNumber(203))); {make this the real thing someday}
SELF.topCluster := cluster;
legend := SELF.NewLegend(phRight, sysTypeStyle);
cluster := SELF.NewRowOfBoxes(phRightCluster, 10, 300, stdBoxWidth, stdBoxHeight, boxSpacing);
cluster.selectBox(TCheckbox(cluster.ObjectWithIDNumber(303))); {make this the real thing someday}
SELF.rightCluster := cluster;
legend := SELF.NewLegend(phBottom, sysTypeStyle);
cluster := SELF.NewRowOfBoxes(phBotCluster, 10, 400, stdBoxWidth, stdBoxHeight, boxSpacing);
cluster.selectBox(TCheckbox(cluster.ObjectWithIDNumber(403))); {make this the real thing someday}
SELF.bottomCluster := cluster;
button := SELF.NewButton(phInstallMargins, stdButtonMetrics, NIL, noCmdNumber);
SELF.extentLRect.topLeft := zeroLPt; {+SW+}
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S DlgDbg}
PROCEDURE TPageStatusDialog.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('currentHeading: THeading');
Field('oddEvenCluster: TCluster');
Field('minPageFrame: TInputFrame');

Apple Lisa ToolKit 3.0 Source Code Listing -- 493 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

Field('maxPageFrame: TInputFrame');
Field('alignCluster: TCluster');
Field('unitsCluster: TCluster');
Field('marginTitle: TLegend');
Field('leftCluster: TCluster');
Field('topCluster: TCluster');
Field('rightCluster: TCluster');
Field('bottomCluster: TCluster');
Field('');
END;
{$ENDC}
{$S HdgMarg}
PROCEDURE TPageStatusDialog.ButtonPushed(button: TButton);
VAR heading:
THeading;
cluster:
TCluster;
hitBoxID:
INTEGER;
theS255:
S255;
inputFrame:
TInputFrame;
minPage:
LONGINT;
maxPage:
LONGINT;
pane:
TPane;
pageDesignWindow:
TPageDesignWindow;
plannerView:
TPlannerView;
offset:
LPoint;
layoutBox:
TLayoutBox;
pageAlignment: TPageAlignment;
checkbox:
TCheckbox;
oddOnly:
BOOLEAN;
evenOnly:
BOOLEAN;
newMargins:
LRect;
panel:
TPanel;
inches:
BOOLEAN;
plannerPanel:
TPanel;
editLegendSelection: TEditLegendSelection;
noSelection:
TSelection;
FUNCTION Margin(cluster: TCluster; baseID: INTEGER; vhs: vhSelect): INTEGER;
VAR hitBox: TCheckbox;
boxOrd: INTEGER;
BEGIN
hitBox := cluster.hiLitBox;
IF hitBox = NIL THEN
boxOrd := 1
ELSE
boxOrd := hitBox.idNumber - baseID + 1;
IF inches THEN
Margin := (pageDesignWindow.hostView.res.vh[vhs] * boxOrd) DIV 4

Apple Lisa ToolKit 3.0 Source Code Listing -- 494 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

{because it's in quarter of inches right now}


ELSE {operating in centimeters}
Margin := LIntDivInt(pageDesignWindow.hostView.res.vh[vhs] * boxOrd * ORD4(100), 508);
END;

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
pageDesignWindow := TPageDesignWindow(SELF.view.panel.window);
plannerView := TPlannerView(pageDesignWindow.layoutPanel.view);
IF button.idNumber = phLaunchHeading THEN {launch a heading AND a corresponding new layout box}
BEGIN
offset := zeroLPt; {default in case no ...}
cluster := SELF.alignCluster;
IF cluster.hiLitBox = NIL THEN
cluster.SelectBox(TCheckbox(cluster.ObjectWithIDNumber(phTopCenter)));

{bulletproofing?}

SELF.InspectHeadingParms(oddOnly, evenOnly, pageAlignment, minPage, maxPage);


CASE pageAlignment OF
aTopLeft:
SetLPt(offset,
aTopCenter:
SetLPt(offset,
aTopRight:
SetLPt(offset,
aBottomLeft:
SetLPt(offset,
aBottomCenter: SetLPt(offset,
aBottomRight:
SetLPt(offset,
END; {CASE}
IF minPage = maxPage THEN
IF odd(minPage) THEN
evenOnly := FALSE
ELSE
oddOnly := FALSE;

80, 30);
0, 30);
-80, 30);
80, -30);
0, -30);
-80, -30);

{keep user from launching a nowhere-printable heading}

heading := TLegendHeading.CREATE(NIL, SELF.Heap, pageDesignWindow.hostView.printManager,


dfltNewHeading, stdHdngTypeStyle, pageAlignment, offset, stdHdngBorders);
heading.minPage := minPage;
heading.maxPage := maxPage;
heading.oddOnly := oddOnly;
heading.evenOnly := evenOnly;
PushFocus;
TPane(SELF.view.panel.panes.First).Focus;

{so that thePad will be set to something}

pageDesignWindow.hostView.printManager.headings.InsLast(heading);
heading.AdjustForPage(0, TRUE);
heading.LocateOnPage(TRUE);

Apple Lisa ToolKit 3.0 Source Code Listing -- 495 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

SELF.currentHeading := heading;
layoutBox := plannerView.NewLayoutBox(heading);
IF layoutBox <> NIL THEN
BEGIN
plannerPanel := plannerView.panel;
plannerView.rootDialog.AddImage(layoutBox);
plannerPanel.BeginSelection;
editLegendSelection := TEditLegendSelection(plannerPanel.selection.FreedAndReplacedBy(
TEditLegendSelection.CREATE(NIL, SELF.Heap,
TLgHdngLayoutBox(layoutBox).legendLayoutBox, zeroLPt)));
editLegendSelection.coSelection.Become(
editLegendSelection.textDialogImage.textImage.text.SelectAll(
editLegendSelection.textDialogImage.textImage));
plannerPanel.InvalLRect(layoutBox.extentLRect);
plannerView.currentLayoutBox := layoutBox;
END;
TDialogView(SELF.view).AbandonThatButton; {turn off highlighting}
PopFocus;
currentWindow.PerformCommand(TCommand.CREATE(NIL, SELF.Heap, uCmdLaunchHeading, plannerView,
FALSE, revealAll));
END
ELSE
IF button.idNumber = phInstallMargins THEN
BEGIN
inches := SELF.unitsCluster.hilitBox.idNumber = phInches;
newMargins.left := Margin(SELF.leftCluster, 100, h);
newMargins.top := Margin(SELF.topCluster, 200, v);
newMargins.right := Margin(SELF.rightCluster, 300, h);
newMargins.bottom := Margin(SELF.bottomCluster, 400, v);
pageDesignWindow.hostView.printManager.ChangeMargins(newMargins);
TDialogView(SELF.view).AbandonThatButton; {turn off highlighting}
plannerView.panel.InvalLRect(plannerView.extentLRect);
{redraw layout panel with chgd margins}
currentWindow.PerformCommand(TCommand.CREATE(NIL, SELF.Heap, uCmdInstallMargins, plannerView,
FALSE, revealNone));
END
ELSE

{ok button}

BEGIN
panel := plannerView.panel;
panel.window.CommitLast;
noSelection := panel.undoSelection.FreedAndReplacedBy(panel.view.NoSelection);

Apple Lisa ToolKit 3.0 Source Code Listing -- 496 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

panel.selection.Deselect;
SUPERSELF.ButtonPushed(button);
END;

{will give OK dismissal to dialog}

{$IFC fTrace}EP;{$ENDC}
END;
{$S HdgMarg}
PROCEDURE TPageStatusDialog.InspectHeadingParms(VAR oddOnly, evenOnly: BOOLEAN;
VAR pageAlignment: TPageAlignment; VAR minPage, maxPage: LONGINT);
VAR heading:
THeading;
newPageAlignment:
TPageAlignment;
theS255:
S255;
checkbox:
TCheckbox;
cState:
TConvResult;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
checkbox := SELF.oddEvenCluster.hiLitBox;
IF checkbox = NIL THEN
BEGIN
oddOnly := FALSE;
evenOnly := FALSE;
END
ELSE
BEGIN
oddOnly := (checkbox.idNumber = phOddOnly);
evenOnly := (checkbox.idNumber = phEvenOnly);
END;
checkbox := SELF.alignCluster.hiLitBox;
IF checkbox = NIL THEN
pageAlignment := aTopCenter
ELSE
CASE checkbox.idNumber OF
phTopLeft:
pageAlignment := aTopLeft;
phTopCenter:
pageAlignment := aTopCenter;
phTopRight:
pageAlignment := aTopRight;
phBotLeft:
pageAlignment := aBottomLeft;
phBotCenter:
pageAlignment := aBottomCenter;
phBotRight:
pageAlignment := aBottomRight;
END;
SELF.maxPageFrame.GetContents(theS255);
StrToLInt(@theS255, maxPage, cState);
IF (cState <> cvValid) OR (maxPage <= 0) THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 497 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

maxPage := MAXLINT;
SELF.maxPageFrame.SupplantContents('------');
END;
SELF.minPageFrame.GetContents(theS255);
StrToLInt(@theS255, minPage, cState);
IF (cState <> cvValid) OR (minPage > maxPage) THEN
BEGIN
minPage := 1;
SELF.minPageFrame.SupplantContents('1');
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S HdgMarg}
PROCEDURE TPageStatusDialog.SetHeadingParms(oddOnly, evenOnly: BOOLEAN;
pageAlignment: TPageAlignment; minPage, maxPage: LONGINT);
VAR heading:
THeading;
newPageAlignment:
TPageAlignment;
theS255:
S255;
checkbox:
TCheckbox;
targetID:
INTEGER;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF oddOnly THEN
targetID := phOddOnly
ELSE
IF evenOnly THEN
targetID := phEvenOnly
ELSE
targetID := phOddOrEven;
SELF.oddEvenCluster.SelectBox(TCheckbox(SELF.oddEvenCluster.ObjectWithIDNumber(targetID)));
CASE pageAlignment OF
aTopLeft:
targetID
aTopCenter:
targetID
aTopRight:
targetID
aBottomLeft:
targetID
aBottomCenter: targetID
aBottomRight:
targetID
END;

:=
:=
:=
:=
:=
:=

phTopLeft;
phTopCenter;
phTopRight;
phBotLeft;
phBotCenter;
phBotRight;

SELF.alignCluster.SelectBox(TCheckbox(SELF.alignCluster.ObjectWithIDNumber(targetID)));
IntToStr(minPage, @theS255);
SELF.minPageFrame.SupplantContents(theS255);

Apple Lisa ToolKit 3.0 Source Code Listing -- 498 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

IF maxPage = maxLInt THEN


theS255 := '------'
ELSE
IntToStr(maxPage, @theS255);
SELF.maxPageFrame.SupplantContents(theS255);
{$IFC fTrace}EP;{$ENDC}
END;
{$S HdgMarg}
PROCEDURE TPageStatusDialog.CheckboxHit(checkbox: TCheckbox; toggleDirection: BOOLEAN);
VAR heading:
THeading;
newPageAlignment:
TPageAlignment;
newTitle:
S255;
phIndex:
INTEGER;
dummy:
LPoint;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF checkBox.parent = SELF.unitsCluster THEN
BEGIN
IF checkbox.idNumber = phInches THEN
phIndex := phInchTitle
ELSE
phIndex := phCmTitle;
GetTextAndLocation(phIndex, newTitle, dummy);
SELF.marginTitle.ChangeString(newTitle);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S HdgMarg}
FUNCTION TPageStatusDialog.DownAt(mouseLPt: LPoint): TDialogImage;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.currentHeading := NIL;
DownAt := SUPERSELF.DownAt(mouseLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S HdgMarg}
PROCEDURE TPageStatusDialog.Draw;
CONST
horizLine = 100;
vertLine = 570;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 499 of 1012

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163

SUPERSELF.Draw; {draw the dialog}


MoveToL(0, horizLine);
PenNormal;
PenSize(3, 2);
LineToL(SELF.view.extentLRect.right, horizLine);
MoveToL(vertLine, 0);
LineToL(vertLine, horizLine);
{$IFC fTrace}EP;{$ENDC}
END;

{$S DlgInit}
END;

End of File -- Lines: 1163 Characters: 41596

Apple Lisa ToolKit 3.0 Source Code Listing -- 500 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UDRAW.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

UNIT UDraw;
{Copyright 1983, 1984, Apple Computer, Inc.}
{changed 05/01 1503 Changes to allow people to use Clascal on the Workshop}
{$Setc IsIntrinsic := TRUE }
{$IFC IsIntrinsic}
INTRINSIC;
{$ENDC}
INTERFACE
USES
{$U UnitStd
} UnitStd,
{Client should not USE UnitStd}
{$U UnitHz
} UnitHz,
{Client should not USE UnitHz and MUST NOT USE Storage}
{$U libtk/UObject} UObject,
{Client must USE UObject}
{$U -#BOOT-SysCall} SysCall,
{Client may USE SysCall}
{$IFC LibraryVersion > 10}
{$U LIBPL/PaslibCall} PaslibCall,
{$U LIBPL/PPasLibc } PPasLibC,
{$ENDC}
{$IFC LibraryVersion <= 20}
{$U FontMgr
} FontMgr,
{Client should USE UFont instead of FontMgr before QuickDraw}
{$ENDC}
{$U QuickDraw
} QuickDraw,
{Client must USE QuickDraw (unless we provide a type-stub for it)}
{$IFC LibraryVersion > 20}
{$U FontMgr
} FontMgr,
{Client should USE UFont instead of FontMgr after QuickDraw}
{$ENDC}
{$U WM.Events
} Events,
{$U WM.Folders } Folders,
{$U FilerComm
} FilerComm;
{$SETC fDbgDraw
{$SETC fRngDraw
{$SETC fSymDraw

:= fDbgOK}
:= fDbgOK}
:= fSymOK}

{$SETC fDebugMethods := fDbgDraw} {if VAR also true, trace entries and/or exits}
CONST
{there should be at most 10 families and they should be in consecutive order; otherwise
the command number constants in UABC should be changed}
famSystem
=
0;

Apple Lisa ToolKit 3.0 Source Code Listing -- 501 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

famMin
famModern
famClassic
famMax

=
=
=
=

{there should be at
the command
sizeMin
=
size20Pitch
=
size15Pitch
=
size12Pitch
=
size10Pitch
=
size12Point
=
size14Point
=
size18Point
=
size24Point
=
sizeMax
=

1;
1;
2;
2;

{minimum family number that appears in the font menu}

most 20 families and they should be in consecutive order; otherwise


number constants in UABC should be changed}
1;
1; { 8 Point 20 Pitch
NOTE: Modern available only}
2; { 8 Point 15 Pitch
NOTE: Modern available only}
3; {10 Point 12 Pitch}
4; {12 Point 10 Pitch}
5; {12 Point proportional}
6; {14 Point proportional}
7; {18 Point proportional}
8; {24 Point proportional}
8;

{font IDs to be used in QuickDraw}


fIDSystem
=
0;
{Reserved for application generated text, that cannot be edited by user;
does not print properly}
fID20Pitch
=
19;
fID15Pitch
=
7;
fIDm12Pitch
=
8;
fIDc12Pitch
=
13;
fIDm10Pitch
=
9;
fIDc10Pitch
=
14;
fIDm12Point
=
4;
fIDc12Point
=
10;
fIDm14Point
=
15;
fIDc14Point
=
16;
fIDm18Point
=
5;
fIDc18Point
=
11;
fIDm24Point
=
6;
fIDc24Point
=
12;
fIDRulers

25;

{Ruler Icons}

{fontIDs below this line are to be used only in special cases, there is no guarantee that these
will print properly}
fIDSysPatterns =
2;
{System Patterns, ie. LisaDraw}
fIDSysCursors
=
3;
{System Cursors}
fIDLT20Graphics =
23;
{LisaTerminal 20 Pitch VT100 graphics}
fIDLT12Graphics =
17;
{LisaTerminal 12 Pitch VT100 graphics}
fIDLT20Text
=
27;
{LisaTerminal 20 Pitch VT100 text}
fIDLT12Text
=
26;
{LisaTerminal 12 Pitch VT100 text}
fIDDeskIcons
=
22;
{Desktop Icon font}

Apple Lisa ToolKit 3.0 Source Code Listing -- 502 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

fIDWM
fIDCalculator
fIDIconName
fIDMarker
fIDLisaGuide

=
=
=
=
=

1;
18;
21;
20;
24;

{Window Manager font}


{Calculator font}
{Icon Name font}
{Marker Font}
{LisaGuide Font}

TYPE
TFontIDArray = ARRAY[famMin..famMax, sizeMin..sizeMax] OF INTEGER;
TScaler =
RECORD
{scale-definition}
numerator:
point; {numerator.h DIV denominator.h is the scale factor in horiz direction}
denominator:
point; {numerator.v DIV denominator.v is the scale factor in the vert. direction}
END;
TRectCoords = ARRAY[FALSE..TRUE] OF Point; {TRectCoords(aRect)[FALSE] = aRect.topLeft; [TRUE] = botRight}
LPoint =
RECORD
CASE INTEGER OF
0: (v, h: LONGINT);
1: (vh: ARRAY [VHSelect] OF LONGINT)
END;
LRect =

RECORD
CASE INTEGER OF
0: (top, left, bottom, right: LONGINT);
1: (topLeft, botRight: LPoint)
END;

LPattern = PACKED ARRAY[0..7] OF 0..255;


TLRectCoords = ARRAY[FALSE..TRUE] OF LPoint; {TLRectCoords(anLRect)[FALSE] = anLRect.topLeft; etc.}
TEnumActions = (rErase, rFrame, rBackground, rDraw);
TActions = SET OF TEnumActions;
THighTransit = (hNone, hOffToDim, hOffToOn, hDimToOn, hDimToOff, hOnToOff, hOnToDim);
{Refresh assumes that the last four and only the last four start with already-highlighted stuff}
TEnumResizability = (userCanResizeIt, windowCanResizeIt);
TResizability = SET OF TEnumResizability;
{arg for TBranchArea.CREATE & TPanel.Divide}
TFontRecord =
PACKED RECORD

Apple Lisa ToolKit 3.0 Source Code Listing -- 503 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

CASE BOOLEAN OF
FALSE: (fontNum:
TRUE:
(fontFamily:
fontSize:
END;

INTEGER);
Byte;
Byte)

TTypeStyle =
RECORD
{$IFC LibraryVersion <= 20}
onFaces:
TSeteface;
{$ELSEC}
onFaces:
Style;
{$ENDC}
font:
TFontRecord;
END;
TArea = SUBCLASS OF TObject
{Variables}
innerRect:
outerRect:
parentBranch:

Rect;
Rect;
TBranchArea;

{window(usually)-relative bounds excluding borders}


{bounding box in ancestral coordinates}
{only used for TPanels and TBranchAreas}

{Creation/Destruction}
FUNCTION TArea.CREATE(object: TObject; heap: THeap; itsRect: Rect): TArea; ABSTRACT;
{Attributes}
FUNCTION TArea.ChildWithPt(pt: Point; childList: TList; VAR nearestPt: Point): TArea;
PROCEDURE TArea.GetBorder(VAR border: Rect); DEFAULT;
{Return the deltas of the border bars, etc. (outer=inner+border)}
{windows, bands, panes: 1 all around;
panels: 1 on left/top, scroll bars on right/bottom}
PROCEDURE TArea.GetMinExtent(VAR minExtent: Point; windowIsResizingIt: BOOLEAN); ABSTRACT;
PROCEDURE TArea.SetOuterRect(newOuterRect: Rect);
PROCEDURE TArea.SetInnerRect(newInnerRect: Rect);
{Display}
PROCEDURE TArea.Erase;

{Other methods assume grafPort, origin, & clipping were preset by Focus}

{Erase the interior}


PROCEDURE TArea.Focus; ABSTRACT;
{Set up the grafPort for this window or pad}
PROCEDURE TArea.Frame; DEFAULT;
{Draw outlines, scroll bars, etc. outside the bounding box}
PROCEDURE TArea.Refresh(rActions: TActions; highTransit: THighTransit); ABSTRACT;

{Buttoning}
FUNCTION TArea.DownAt(mousePt: Point): BOOLEAN; ABSTRACT;

Apple Lisa ToolKit 3.0 Source Code Listing -- 504 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

{Resizing}
PROCEDURE TArea.ResizeInside(newInnerRect: Rect); ABSTRACT;
PROCEDURE TArea.ResizeOutside(newOuterRect: Rect); ABSTRACT;
END;
TPad = SUBCLASS OF TArea
{Variables}
port:
viewedLRect:
visLRect:
availLRect:
scrollOffset:
origin:
cdOffset:
clippedRect:

GrafPtr;
LRect;
LRect;
LRect;
LPoint;
Point;
LPoint;
rect;

{the GrafPort used by this pad}


{The portion of view that is displayed in innerRect}
{viewedLRect sect visRgn while focused}
{The larger part of view that fits in a 16-bit Rect}
{The distance scrolled from the view topLeft}
{What to set the grafport origin to when focused}
{What to subtract from coordinates to get port coords}
{additional clipping to apply at Focus time}

padRes:
viewedRes:

Point;
Point;

{spots/inch in the pad coordinate space}


{spots/inch in the 32-bit space being projected}

scaled:
scaleFactor:

BOOLEAN;
TScaler;

{the net scale factor, combining zooming}


{and aspect ratio, etc.}

zoomFactor:

TScaler;

{Creation/Destruction}
FUNCTION TPad.CREATE(object: TObject; heap: THeap; itsInnerRect: Rect; itsViewedLRect: LRect;
itsPadRes, itsViewRes: Point;
itsPort: GrafPtr): TPad;
PROCEDURE TPad.Redefine(itsInnerRect: Rect; itsViewedLRect: LRect;
itsPadRes, itsViewRes: Point;
itsZoomFactor: TScaler; itsPort: GrafPtr);
{Coordinate
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

Mapping -- grafPort to view}


TPad.DistToLDist(distInPort: Point; VAR lDistInView: LPoint);
TPad.PatToLPat(patInPort: Pattern; VAR lPatInView: LPattern);
TPad.PtToLPt(ptInPort: Point; VAR lPtInView: LPoint);
TPad.RectToLRect(rectInPort: Rect; VAR lRectInView: LRect);

{Coordinate
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

Mapping -- view to grafPort}


TPad.LDistToDist(lDistInView: LPoint; VAR distInPort: Point);
TPad.LPatToPat(lPatInView: LPattern; VAR patInPort: Pattern);
TPad.LPtToPt(lPtInView: LPoint; VAR ptInPort: Point);
TPad.LRectToRect(lRectInView: LRect; VAR rectInPort: Rect);

Apple Lisa ToolKit 3.0 Source Code Listing -- 505 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

{Scrolling}
PROCEDURE TPad.OffsetBy(deltaLPt: LPoint);
{offset viewedLRect -- no effect on display}
PROCEDURE TPad.SetScrollOffset(VAR newOffset: LPoint);
{recalculates the origin and cdOffset fields; does not change arg}
{Display}
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

TPad.ClipFurtherTo(rBand: rect); {narrows down clip area at next Focus}


TPad.Focus; OVERRIDE;
TPad.InvalLRect(r: LRect);
{Force redraw of r at next update}
TPad.InvalRect(r: Rect);
{Force redraw of r at next update}
TPad.SetPen(pen: PenState);
{NB: We should later augment this so that it scales
pensizes}
PROCEDURE TPad.SetPenToHighlight(highTransit: THighTransit); {SetPenState to highlight this way}
PROCEDURE TPad.SetZoomFactor(zoomNumerator, zoomDenominator: point); DEFAULT;

{Drawing}
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

TPad.DrawLText(textBuf: Ptr; startByte, numBytes: INTEGER);


TPad.DrawLLine(newLPt: LPoint);
TPad.DrawLPicture(pic: PicHandle; r:LRect);
TPad.DrawLRect(verb: GrafVerb; r: LRect);
TPad.DrawLRRect(verb: GrafVerb; r: LRect; ovalWidth, ovalHeight: INTEGER);
TPad.DrawLOval(verb: GrafVerb; r: LRect);
TPad.DrawLArc(verb: GrafVerb; r: LRect; startAngle, arcAngle: INTEGER);
TPad.DrawLBits(VAR srcBits: BitMap; VAR srcRect: Rect;
VAR dstLRect: LRect; mode: INTEGER; maskRgn: RgnHandle);

{Process termination and Debugging Assistance}


PROCEDURE TPad.Crash; ABSTRACT;
FUNCTION TPad.BindHeap(activeVsClip, doBind: BOOLEAN): THeap; ABSTRACT;
END;
TBranchArea = SUBCLASS OF TArea
{Variables}
arrangement:
elderFirst:
resizability:
elderChild:
youngerChild:

VHSelect;
BOOLEAN;
TResizability;
TArea;
TArea;

{v means above one another}


{TRUE IFF elderChild is above or to the left of youngerChild}

{Creation/Destruction}
FUNCTION TBranchArea.CREATE(object: TObject; heap: THeap; vhs: VHSelect; hasElderFirst: BOOLEAN;
whoCanResizeIt: TResizability;
itsElderChild, itsYoungerChild: TArea): TBranchArea;

Apple Lisa ToolKit 3.0 Source Code Listing -- 506 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

{Attributes}
PROCEDURE TBranchArea.GetMinExtent(VAR minExtent: Point; windowIsResizingIt: BOOLEAN); OVERRIDE;
FUNCTION TBranchArea.OtherChild(child: TArea): TArea;
PROCEDURE TBranchArea.ReplaceChild(child, newChild: TArea);
FUNCTION TBranchArea.TopLeftChild: TArea;
{Resizing}
PROCEDURE TBranchArea.ResizeOutside(newOuterRect: Rect); OVERRIDE;
PROCEDURE TBranchArea.Redivide(newCd: INTEGER);
END;

VAR
amPrinting:

BOOLEAN;

{Iff TRUE, we are currently printing rather than drawing}

zeroPt:
zeroRect:
hugeRect:

Point;
Rect;
Rect;

{(0,0)}
{(0,0)-(0,0)}
{(0,0)-(MAXINT/2,MAXINT/2)}

zeroLPt:
zeroLRect:
hugeLRect:

LPoint;
LRect;
LRect;

{(0,0)}
{(0,0)-(0,0)}
{(0,0)-(MAXLINT/2,MAXLINT/2)}

orthogonal:

ARRAY [v..h] OF VHSelect;

{Maps v to h and vice versa}

highPen:

ARRAY [THighTransit] OF PenState; {standard highlight-feedback transitions}

lPatWhite:
lPatBlack:
lPatGray:
lPatLtGray:
lPatDkGray:

LPattern;
LPattern;
LPattern;
LPattern;
LPattern;

{Maps
{Maps
{Maps
{Maps
{Maps

focusStack:
focusStkPtr:
focusArea:
focusRgn:
padRgn:
altVisRgn:
useAltVisRgn:
thePad:

ARRAY [1..10] OF TArea;


INTEGER;
TArea;
RgnHandle;
RgnHandle;
RgnHandle;
BOOLEAN;
TPad;

{PushFocus pushes and PopFocus pops focusArea}


{Index of last thing on focusStack}
{The currently focused area}
{either padRgn or visRgn}
{intersection of pane and visRgn}
{If useAltVisRgn, use this instead of visRgn in Focus}
{If TRUE, use altVisRgn instead of visRgn in Focus}
{focusArea, if a TPad, else NIL}

noPad:
crashPad:

TPad;
TPad;

{maps every point to itself}


{an object willing to handle process termination}

to
to
to
to
to

QuickDraw
QuickDraw
QuickDraw
QuickDraw
QuickDraw

pattern
pattern
pattern
pattern
pattern

white}
black}
gray}
ltGray}
dkGray}

Apple Lisa ToolKit 3.0 Source Code Listing -- 507 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

screenRes:

Point;

{screen resolution, pixels per inch}

sysTypeStyle:

TTypeStyle; {system font, normal face}

printerPseudoPort:

GrafPtr;

cArea:
cPad:
cBranchArea:

TClass;
TClass;
TClass;

{The next four are declared EXTERNAL in UOBJECT2}


PROCEDURE InitQDWM;
PROCEDURE TrmntExceptionHandler;
PROCEDURE InitErrorAbort(error: INTEGER);
{$IFC fDbgDraw}
FUNCTION BindHeap(activeVsClip, doBind: BOOLEAN): THeap;
{$ENDC}
PROCEDURE Reduce(VAR numerator, denominator: INTEGER);

{reduce fraction to lowest terms}

FUNCTION
FUNCTION

FPtPlusPt(operand1, operand2: Point): LONGINT;


FPtMinusPt(operand1, operand2: Point): LONGINT;

{
p3 := Point(FPtPlusPt(p1, p2));
{ F stands for FUNCTION }

FUNCTION
FUNCTION

FPtMulInt(operand1: Point; operand2: INTEGER): LONGINT;


FPtDivInt(operand1: Point; operand2: INTEGER): LONGINT;
{e.g.:
center := Point(FPtDivInt(POINT(FPtPlusPt(p1, p2)), 2);

FUNCTION
FUNCTION

FPtMaxPt(operand1, operand2: Point): LONGINT;


FPtMinPt(operand1, operand2: Point): LONGINT;

{ each coordinate is max'ed separately }

FUNCTION

FDiagRect(operand1: Rect): LONGINT;

{ FPtMinusPt(botRight-topLeft) }

PROCEDURE BoolToStr(bool: BOOLEAN; str: TPstring);


FUNCTION
FUNCTION
FUNCTION

LIntDivLInt(i, j: LONGINT): LONGINT;


LIntDivInt(i: LONGINT; j: INTEGER): LONGINT;
LIntMulInt(i: LONGINT; j: INTEGER): LONGINT;

FUNCTION LIntOvrInt(i: LONGINT; j: INTEGER): LONGINT;


{This returns LIntDivInt(i+(j DIV 2), j) if i>0 and
LIntDivInt(i-(j DIV 2), j) if i<0}
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

PtPlusPt(operand1, operand2: Point; VAR result: Point);


PtMinusPt(operand1, operand2: Point; VAR result: Point);
PtMulInt(operand1: Point; operand2: INTEGER; VAR result: Point);
PtDivInt(operand1: Point; operand2: INTEGER; VAR result: Point);

Apple Lisa ToolKit 3.0 Source Code Listing -- 508 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

{$IFC LibraryVersion <= 20}


FUNCTION EqualPt(operand1, operand2: Point): BOOLEAN;
{$ENDC}

{Will be in QuickDraw eventually}

PROCEDURE RectPlusRect(operand1, operand2: Rect; VAR result: Rect);


PROCEDURE RectMinusRect(operand1, operand2: Rect; VAR result: Rect);
{$IFC LibraryVersion <= 20}
FUNCTION EqualRect(rectA, rectB: Rect): BOOLEAN;
{Will be in QuickDraw eventually}
FUNCTION EmptyRect(r: Rect): BOOLEAN;
{Will be in QuickDraw eventually}
{$ENDC}
PROCEDURE
FUNCTION
FUNCTION
PROCEDURE
FUNCTION
PROCEDURE
FUNCTION

AlignRect(VAR dstRect: Rect; srcRect: Rect; vhs: VHSelect);


LengthRect(r: Rect; vhs: VHSelect): INTEGER;
RectHasPt(dstRect: Rect; pt: Point): BOOLEAN;
RectHavePt(dstRect: Rect; VAR pt: Point);
{change pt so that topLeft <= pt <= botRight}
RectsNest(outer, inner: Rect): BOOLEAN;
RectifyRect(VAR dstRect: Rect);
{exchange coordinates until topLeft <= botRight}
RectIsVisible(rectInPort: Rect): BOOLEAN;

PROCEDURE PointToStr(pt: Point; str: TPstring);


PROCEDURE RectToStr(r: Rect; str: TPstring);

{Referenced as EXTERNAL by UABC2}


{Referenced as EXTERNAL by UABC2}

PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
FUNCTION

LPtPlusLPt(operand1, operand2: LPoint; VAR result: LPoint);


LPtMinusLPt(operand1, operand2: LPoint; VAR result: LPoint);
LPtMulInt(operand1: LPoint; operand2: INTEGER; VAR result: LPoint);
LPtDivInt(operand1: LPoint; operand2: INTEGER; VAR result: LPoint);
EqualLPt(operand1, operand2: LPoint): BOOLEAN;

PROCEDURE
PROCEDURE
FUNCTION
FUNCTION

LRectPlusLRect(operand1, operand2: LRect; VAR result: LRect);


LRectMinusLRect(operand1, operand2: LRect; VAR result: LRect);
EqualLRect(rectA, rectB: LRect): BOOLEAN;
EmptyLRect(r: LRect): BOOLEAN;

PROCEDURE
FUNCTION
FUNCTION
PROCEDURE
FUNCTION
PROCEDURE
FUNCTION

AlignLRect(VAR destLRect: LRect; srcLRect: LRect; vhs: VHSelect);


LengthLRect(r: LRect; vhs: VHSelect): LONGINT;
LRectHasLPt(destLRect: LRect; pt: LPoint): BOOLEAN;
LRectHaveLPt(destLRect: LRect; VAR pt: LPoint);
{change pt so that topLeft <= pt <= botRight}
LRectsNest(outer, inner: LRect): BOOLEAN;
RectifyLRect(VAR destLRect: LRect);
{exchange coordinates until topLeft <= botRight}
LRectIsVisible(srcLRect: LRect): BOOLEAN;

PROCEDURE LPointToStr(pt: LPoint; str: TPstring);


PROCEDURE LRectToStr(r: LRect; str: TPstring);
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

{Referenced as EXTERNAL by UOBJECT2}


{Referenced as EXTERNAL by UOBJECT2}

SetLPt(VAR destPt: LPoint; itsH, itsV: LONGINT);


SetLRect(VAR dstRect: LRect; itsLeft, itsTop, itsRight, itsBottom: LONGINT);
OffsetLRect(VAR dstRect: LRect; dh, dv: LONGINT);
InsetLRect(VAR dstRect: LRect; dh, dv: LONGINT);

Apple Lisa ToolKit 3.0 Source Code Listing -- 509 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

FUNCTION SectLRect(srcRectA, srcRectB: LRect; VAR dstRect: LRect): BOOLEAN;


PROCEDURE UnionLRect(srcRectA, srcRectB: LRect; VAR dstRect: LRect);
FUNCTION LPtInLRect(pt: LPoint; r: LRect): BOOLEAN;
FUNCTION
FUNCTION

IsSmallPt(srcPt: LPoint): BOOLEAN;


IsSmallRect(srcRect: LRect): BOOLEAN;

(*PROCEDURE ClipLRect(r: LRect);

{Not yet implementable}*)

{Drawing text}
PROCEDURE DrawLText(textBuf: Ptr; startByte, numBytes: INTEGER);
{Drawing lines, rectangles, and ovals}
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

MoveToL(h, v:
MoveL(dh, dv:
LineToL(h, v:
LineL(dh, dv:

LONGINT);
LONGINT);
LONGINT);
LONGINT);

PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

FrameLRect(r: LRect);
PaintLRect(r: LRect);
EraseLRect(r: LRect);
InvrtLRect(r: LRect);
FillLRect(r: LRect; lPat: LPattern);

PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

FrameLOval(r: LRect);
PaintLOval(r: LRect);
EraseLOval(r: LRect);
InvrtLOval(r: LRect);
FillLOval(r: LRect; lPat: LPattern);

PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

FrameLRRect(r: LRect; ovalWidth, ovalHeight: INTEGER);


PaintLRRect(r: LRect; ovalWidth, ovalHeight: INTEGER);
EraseLRRect(r: LRect; ovalWidth, ovalHeight: INTEGER);
InvrtLRRect(r: LRect; ovalWidth, ovalHeight: INTEGER);
FillLRRect(r: LRect; ovalWidth, ovalHeight: INTEGER; lPat: LPattern);

PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

FrameLArc(r: LRect; startAngle, arcAngle: INTEGER);


PaintLArc(r: LRect; startAngle, arcAngle: INTEGER);
EraseLArc(r: LRect; startAngle, arcAngle: INTEGER);
InvrtLArc(r: LRect; startAngle, arcAngle: INTEGER);
FillLArc(r: LRect; startAngle, arcAngle: INTEGER; lPat: LPattern);

FUNCTION

ClonePicture(pic: PicHandle; toHeap: THeap): PicHandle;

Apple Lisa ToolKit 3.0 Source Code Listing -- 510 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504

PROCEDURE ResizeFeedback(mousePt: Point; minPt, maxPt: Point; outerRect: Rect;


tabHeight, sbWidth, sbHeight: INTEGER; VAR newPt: Point);
PROCEDURE PushFocus;
PROCEDURE PopFocus;

{Save old focusArea on focusStack}


{Restore old focusArea from focusStack and focus on it}

{$IFC LibraryVersion <= 20}


PROCEDURE MakeTypeStyle(itsFamily: INTEGER; itsSize: INTEGER;
itsFaces: TSetEFace;
VAR typeStyle: TTypeStyle);
{$ELSEC}
PROCEDURE MakeTypeStyle(itsFamily: INTEGER; itsSize: INTEGER;
itsFaces: Style;
VAR typeStyle: TTypeStyle);
{$ENDC}
FUNCTION QDFontNumber(typeStyle: TTypeStyle): INTEGER;
PROCEDURE SetQDTypeStyle(typeStyle: TTypeStyle);
IMPLEMENTATION
{$I libtk/UDRAW2.TEXT}
END.

End of File -- Lines: 504 Characters: 20727

Apple Lisa ToolKit 3.0 Source Code Listing -- 511 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UDRAW2.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{INCLUDE FILE UDRAW2 -- IMPLEMENTATION OF UDRAW}


{Copyright 1983, 1984, Apple Computer, Inc.}
{changed 05/01 1503 Changes to allow people to use Clascal on the Workshop}
{Segments: SgABCini(tialize and Terminate), SgDRWres(ident), SgABCc(o)ld, SgABCdbg}
{$IFC fRngDraw}
{$R+}
{$ELSEC}
{$R-}
{$ENDC}
{$IFC fSymDraw}
{$D+}
{$ELSEC}
{$D-}
{$ENDC}
CONST
magicNumber

32768;

VAR fontID: TFontIDArray;


{$S SgDRWres}
{$S SgABCini}
PROCEDURE TrmntExceptionHandler;
VAR ch:
CHAR;
error: INTEGER;
BEGIN
IF onDesktop THEN
ImDying; {This must be done first}
IF NOT amDying THEN
BEGIN
{$IFC fDbgDraw}
WriteLn('TrmntExceptionHandler');
{$ENDC}
amDying := TRUE;

Apple Lisa ToolKit 3.0 Source Code Listing -- 512 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

IF crashPad <> NIL THEN


crashPad.Crash;
END;
{$IFC fDbgDraw}
{Flush the input queue in case there was user typeahead to the alternate screen}
WHILE KeyPress DO
Read(ch);
{$ENDC}
IF NOT onDesktop THEN
MoveConsole(error, mainscreen);
END;
{$S SgDRWres}
{$S SgABCini}
PROCEDURE QkDrError(error: INTEGER);
BEGIN
{$IFC fDbgDraw}
ABCbreak('QkDrError', error);
{$ENDC}
HALT;
END;
{$S SgDRWres}
{$S SgABCini}
PROCEDURE InitQDWM;
VAR error:
INTEGER;
workDir:
Pathname;
bootVol:
e_name;
bootDir:
Pathname;
{$IFC LibraryVersion < 30}
bootPort:
tports;
{$ENDC}
BEGIN
{$IFC libraryVersion <= 20}
InitGraf(@thePort, @QkDrError);
{$ELSEC}
InitGraf(@thePort);
{$ENDC}
crashPad := NIL;
IF onDesktop THEN
BEGIN
OpenWM;

Apple Lisa ToolKit 3.0 Source Code Listing -- 513 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

SetPort(deskPort);
wmIsInitialized := TRUE;
END
ELSE
BEGIN
{move WriteLns to alternate screen}
MoveConsole(error, alscreen);
{$IFC fDbgDraw}
IF error > 0 THEN
ABCBreak('MoveConsole error', error);
{$ENDC}
{ set work directory to boot volume for FMOpen}
Get_Working_Dir(error, workDir);
{$IFC fDbgDraw}
IF error > 0 THEN
ABCBreak('Get_Working_Dir error', error);
{$ENDC}
{$IFC LibraryVersion < 30}
bootPort := OSBootVol(error);
{$IFC fDbgDraw}
IF error > 0 THEN
ABCBreak('OSBootVol error', error);
{$ENDC}
Get_Config_Name(error, bootPort, bootVol);
{$IFC fDbgDraw}
IF error > 0 THEN
ABCBreak('Get_Config_Name error', error);
{$ENDC}
{$ELSEC}
OSBootVol(error, bootVol);
{$IFC fDbgDraw}
IF error > 0 THEN
ABCBreak('OSBootVol error', error);
{$ENDC}
{$ENDC}
bootDir := CONCAT('-', bootVol);
Set_Working_Dir(error, bootDir);
{$IFC fDbgDraw}
IF error > 0 THEN
ABCBreak('Set_Working_Dir to boot vol error', error);
{$ENDC}
FMOpen(error);
{$IFC fDbgDraw}

Apple Lisa ToolKit 3.0 Source Code Listing -- 514 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

{$ENDC}

IF error > 0 THEN


ABCBreak('FMOpen error = ', error);

{ Set work directory back after OpenWM }


Set_Working_Dir(error, workDir);
{$IFC fDbgDraw}
IF error > 0 THEN
ABCBreak('Set_Working_Dir back to prefix error = ', error);
{$ENDC}
END;
END;
{$S SgDRWres}
{$S SgABCdbg}
FUNCTION BindHeap(activeVsClip, doBind: BOOLEAN): THeap;
BEGIN
IF crashPad = NIL THEN
BindHeap := NIL
{no UABC to do it for me}
ELSE
BindHeap := crashPad.BindHeap(activeVsClip, doBind);
END;
{$S SgDRWres}
{$S SgABCcld}
FUNCTION FilerReason(error: INTEGER):
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
FilerReason := allOk;
IF error > 0 THEN
CASE error OF
309:
FilerReason :=
315:
FilerReason :=
4001:
FilerReason :=
OTHERWISE
FilerReason :=
END;
END;
{$S SgDRWres}

FReason;

noDiskSpace;
noMemory;
badData;
internalError;

{$S SgABCini}
PROCEDURE InitErrorAbort(error: INTEGER);
BEGIN
IF error > 0 THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 515 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

{$IFC fDbgDraw}
ABCbreak('InitErrorAbort', error);
{$ENDC}
IF onDesktop THEN
TellFiler(error, initFailed, FilerReason(error), NIL);
HALT;
END
ELSE
IF wmIsInitialized THEN
IF Abort THEN
BEGIN
IF onDesktop THEN
TellFiler(error, initFailed, aUserAbort, NIL);
HALT;
END;
END;
{$S SgDRWres}
{$S SgDRWres}
PROCEDURE Reduce(VAR numerator, denominator: INTEGER);
{reduce fraction to lowest terms}
VAR factor: INTEGER;
maxFactor: INTEGER; {also makes cosmetics}
smallerNumerator:
INTEGER;
smallerDenominator: INTEGER;
BEGIN {very crude at the moment}
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
maxFactor := MIN(numerator, denominator);
FOR factor := maxFactor DOWNTO 2 DO
BEGIN
smallerNumerator := numerator DIV factor;
smallerDenominator := denominator DIV factor;
IF (factor * smallerNumerator = numerator) AND (factor * smallerDenominator = denominator) THEN
BEGIN
numerator := smallerNumerator;
denominator := smallerDenominator;
END;
END;
END;
{$S SgDRWres}
FUNCTION FPtPlusPt(operand1, operand2: Point): LONGINT;
VAR result: Point;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 516 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

result.h := operand1.h + operand2.h;


result.v := operand1.v + operand2.v;
FPtPlusPt := LONGINT(result);
END;
{$S SgDRWres}
FUNCTION FPtMinusPt(operand1, operand2: Point): LONGINT;
VAR result: Point;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.h := operand1.h - operand2.h;
result.v := operand1.v - operand2.v;
FPtMinusPt := LONGINT(result);
END;
{$S SgABCdat}
FUNCTION FPtMulInt(operand1: Point; operand2: INTEGER): LONGINT;
VAR result: Point;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.h := operand1.h * operand2;
result.v := operand1.v * operand2;
FPtMulInt := LONGINT(result);
END;
{$S SgABCdat}
FUNCTION FPtDivInt(operand1: Point; operand2: INTEGER): LONGINT;
VAR result: Point;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.h := operand1.h DIV operand2;
result.v := operand1.v DIV operand2;
FPtDivInt := LONGINT(result);
END;
{$S SgDRWres}
FUNCTION FPtMaxPt(operand1, operand2: Point): LONGINT;
VAR result: Point;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 517 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

result.h := Max(operand1.h, operand2.h);


result.v := Max(operand1.v, operand2.v);
FPtMaxPt := LONGINT(result);
END;
{$S SgDRWres}
FUNCTION FPtMinPt(operand1, operand2: Point): LONGINT;
VAR result: Point;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.h := Min(operand1.h, operand2.h);
result.v := Min(operand1.v, operand2.v);
FPtMinPt := LONGINT(result);
END;
{$S SgDRWres}
FUNCTION FDiagRect(operand1: Rect): LONGINT;
VAR result: Point;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.h := operand1.right - operand1.left;
result.v := operand1.bottom - operand1.top;
FDiagRect := LONGINT(result);
END;
{$S SgABCdat}
PROCEDURE BoolToStr(bool: BOOLEAN; str: TPstring);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
IF bool THEN
str^ := 'TRUE'
ELSE
str^ := 'FALSE';
END;
FUNCTION LIntDivLInt(i, j: LONGINT): LONGINT;
EXTERNAL;
FUNCTION LIntDivInt(i: LONGINT; j: INTEGER): LONGINT;
EXTERNAL;

Apple Lisa ToolKit 3.0 Source Code Listing -- 518 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

FUNCTION LIntMulInt(i: LONGINT; j: INTEGER): LONGINT;


EXTERNAL;
{$S SgDRWres}
FUNCTION LIntOvrInt(i: LONGINT; j: INTEGER): LONGINT;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
IF i>0 THEN
LIntOvrInt := LIntDivInt(i+(j DIV 2), j)
ELSE
LIntOvrInt := LIntDivInt(i-(j DIV 2), j);
END;
{$S SgABCdat}
PROCEDURE PtPlusPt(operand1, operand2: Point; VAR result: Point);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.h := operand1.h + operand2.h;
result.v := operand1.v + operand2.v;
END;
{$S SgABCdat}
PROCEDURE PtMinusPt(operand1, operand2: Point; VAR result: Point);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.h := operand1.h - operand2.h;
result.v := operand1.v - operand2.v;
END;
{$S SgABCdat}
PROCEDURE PtMulInt(operand1: Point; operand2: INTEGER; VAR result: Point);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.h := operand1.h * operand2;
result.v := operand1.v * operand2;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 519 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

{$S SgABCdat}
PROCEDURE PtDivInt(operand1: Point; operand2: INTEGER; VAR result: Point);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.h := operand1.h DIV operand2;
result.v := operand1.v DIV operand2;
END;
{$IFC LibraryVersion <= 20}
FUNCTION EqualPt(operand1, operand2: Point): BOOLEAN;
BEGIN
EqualPt := (operand1.h = operand2.h) AND (operand1.v = operand2.v);
END;
{$ENDC}
{$S SgDRWres}
PROCEDURE RectPlusRect(operand1, operand2: Rect; VAR result: Rect);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.left := operand1.left + operand2.left;
result.top := operand1.top + operand2.top;
result.right := operand1.right + operand2.right;
result.bottom := operand1.bottom + operand2.bottom;
END;
{$S SgDRWres}
PROCEDURE RectMinusRect(operand1, operand2: Rect; VAR result: Rect);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.left := operand1.left - operand2.left;
result.top := operand1.top - operand2.top;
result.right := operand1.right - operand2.right;
result.bottom := operand1.bottom - operand2.bottom;
END;
{$IFC LibraryVersion <= 20}
{$S SgDRWres}
FUNCTION EqualRect(rectA, rectB: Rect): BOOLEAN;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 520 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

EqualRect := (rectA.left=rectB.left) AND (rectA.top=rectB.top) AND


(rectA.right=rectB.right) AND (rectA.bottom=rectB.bottom);
END;
{$S SgDRWres}
FUNCTION EmptyRect(r: Rect): BOOLEAN;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
WITH r DO
EmptyRect := (left >= right) OR (top >= bottom);
END;
{$ENDC}
{$S SgDRWres}
PROCEDURE AlignRect(VAR dstRect: Rect; srcRect: Rect; vhs: VHSelect);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
dstRect.topLeft.vh[vhs] := srcRect.topLeft.vh[vhs];
dstRect.botRight.vh[vhs] := srcRect.botRight.vh[vhs];
END;
{$S SgDRWres}
FUNCTION LengthRect(r: Rect; vhs: VHSelect): INTEGER;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
LengthRect := r.botRight.vh[vhs] - r.topLeft.vh[vhs];
END;
{$S SgDRWres}
FUNCTION RectsNest(outer, inner: Rect): BOOLEAN;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
RectsNest := RectHasPt(outer, inner.topLeft) AND RectHasPt(outer, inner.botRight);
END;
{$S SgDRWres}
FUNCTION RectHasPt(dstRect: Rect; pt: Point): BOOLEAN;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 521 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

{$IFC fMaxTrace}EP;{$ENDC}
RectHasPt := (dstRect.left <= pt.h) AND (pt.h <= dstRect.right) AND
(dstRect.top <= pt.v) AND (pt.v <= dstRect.bottom);
END;
{$S SgDRWres}
PROCEDURE RectHavePt(dstRect: Rect; VAR pt: Point);
BEGIN {if dstRect is negative size, left/top is forced}
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
pt.h := Max(dstRect.left, Min(dstRect.right, pt.h));
pt.v := Max(dstRect.top, Min(dstRect.bottom, pt.v));
END;
{$S SgDRWres}
PROCEDURE RectifyRect(VAR dstRect: Rect);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
Pt2Rect(dstRect.topLeft, dstRect.botRight, dstRect);
END;
{$S SgDRWres}
FUNCTION RectIsVisible(rectInPort: Rect): BOOLEAN;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
RectIsVisible := RectInRgn(rectInPort, focusRgn);
END;
{$S SgABCdbg}
PROCEDURE PointToStr(pt: Point; str: TPstring);
VAR s: S255;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
IntToStr(pt.h, str);
IntToStr(pt.v, @s);
str^ := CONCAT('(', str^, ',', s, ')');
END;
{$S SgABCdbg}
PROCEDURE RectToStr(r: Rect; str: TPstring);

Apple Lisa ToolKit 3.0 Source Code Listing -- 522 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

VAR s: S255;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
PointToStr(r.topLeft, str);
PointToStr(r.botRight, @s);
str^ := CONCAT('[', str^, ',', s, ']');
END;
{$S SgDRWres}
{$S SgDRWres}
PROCEDURE LPtPlusLPt(operand1, operand2: LPoint; VAR result: LPoint);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.h := operand1.h + operand2.h;
result.v := operand1.v + operand2.v;
END;
{$S SgDRWres}
PROCEDURE LPtMinusLPt(operand1, operand2: LPoint; VAR result: LPoint);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.h := operand1.h - operand2.h;
result.v := operand1.v - operand2.v;
END;
{$S SgABCdat}
PROCEDURE LPtMulInt(operand1: LPoint; operand2: INTEGER; VAR result: LPoint);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.h := operand1.h * operand2;
result.v := operand1.v * operand2;
END;
{$S SgABCdat}
PROCEDURE LPtDivInt(operand1: LPoint; operand2: INTEGER; VAR result: LPoint);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.h := LIntDivInt(operand1.h, operand2);
result.v := LIntDivInt(operand1.v, operand2);

Apple Lisa ToolKit 3.0 Source Code Listing -- 523 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

END;
{$S SgDRWres}
FUNCTION EqualLPt(operand1, operand2: LPoint): BOOLEAN;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
EqualLPt := (operand1.h = operand2.h) AND (operand1.v = operand2.v);
END;
{$S SgDRWres}
PROCEDURE LRectPlusLRect(operand1, operand2: LRect; VAR result: LRect);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.left := operand1.left + operand2.left;
result.top := operand1.top + operand2.top;
result.right := operand1.right + operand2.right;
result.bottom := operand1.bottom + operand2.bottom;
END;
{$S SgDRWres}
PROCEDURE LRectMinusLRect(operand1, operand2: LRect; VAR result: LRect);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
result.left := operand1.left - operand2.left;
result.top := operand1.top - operand2.top;
result.right := operand1.right - operand2.right;
result.bottom := operand1.bottom - operand2.bottom;
END;
{$S SgDRWres}
FUNCTION EqualLRect(rectA, rectB: LRect): BOOLEAN;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
EqualLRect := (rectA.left=rectB.left) AND (rectA.top=rectB.top) AND
(rectA.right=rectB.right) AND (rectA.bottom=rectB.bottom);
END;
{$S SgDRWres}
FUNCTION EmptyLRect(r: LRect): BOOLEAN;

Apple Lisa ToolKit 3.0 Source Code Listing -- 524 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

BEGIN

{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
WITH r DO
EmptyLRect := (left >= right) OR (top >= bottom);
END;
{$S SgDRWres}
PROCEDURE AlignLRect(VAR destLRect: LRect; srcLRect: LRect; vhs: VHSelect);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
destLRect.topLeft.vh[vhs] := srcLRect.topLeft.vh[vhs];
destLRect.botRight.vh[vhs] := srcLRect.botRight.vh[vhs];
END;
{$S SgDRWres}
FUNCTION LengthLRect(r: LRect; vhs: VHSelect): LONGINT;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
LengthLRect := r.botRight.vh[vhs] - r.topLeft.vh[vhs];
END;
{$S SgDRWres}
FUNCTION LRectsNest(outer, inner: LRect): BOOLEAN;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
LRectsNest := LRectHasLPt(outer, inner.topLeft) AND LRectHasLPt(outer, inner.botRight);
END;
{$S SgDRWres}
FUNCTION LRectHasLPt(destLRect: LRect; pt: LPoint): BOOLEAN;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
LRectHasLPt := (destLRect.left <= pt.h) AND (pt.h <= destLRect.right) AND
(destLRect.top <= pt.v) AND (pt.v <= destLRect.bottom);
END;
{$S SgDRWres}
PROCEDURE LRectHaveLPt(destLRect: LRect; VAR pt: LPoint);

Apple Lisa ToolKit 3.0 Source Code Listing -- 525 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

BEGIN {if destLRect is negative size, left/top is forced}


{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
pt.h := Max(destLRect.left, Min(destLRect.right, pt.h));
pt.v := Max(destLRect.top, Min(destLRect.bottom, pt.v));
END;
{$S SgDRWres}
PROCEDURE RectifyLRect(VAR destLRect: LRect);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
SetLRect(destLRect, Min(destLRect.left, destLRect.right), Min(destLRect.top, destLRect.bottom),
Max(destLRect.left, destLRect.right), Max(destLRect.top, destLRect.bottom));
END;
{$S SgDRWres}
FUNCTION LRectIsVisible(srcLRect: LRect): BOOLEAN;
VAR rectInPort: Rect;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
thePad.LRectToRect(srcLRect, rectInPort);
IF EmptyRect(rectInPort) THEN
LRectIsVisible := FALSE
ELSE
LRectIsVisible := RectInRgn(rectInPort, focusRgn);
END;
{$S SgABCdbg}
PROCEDURE LPointToStr(pt: LPoint; str: TPstring);
VAR s: S255;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
LIntToStr(pt.h, str);
LIntToStr(pt.v, @s);
str^ := CONCAT('(', str^, ',', s, ')');
END;
{$S SgABCdbg}
PROCEDURE LRectToStr(r: LRect; str: TPstring);
VAR s: S255;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 526 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
LPointToStr(r.topLeft, str);
LPointToStr(r.botRight, @s);
str^ := CONCAT('[', str^, ',', s, ']');
END;
{$S SgDRWres}
{$S SgDRWres}
PROCEDURE SetLPt(VAR destPt: LPoint; itsH, itsV: LONGINT);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
WITH destPt DO
BEGIN
h := itsH;
v := itsV;
END;
END;
{$S SgDRWres}
PROCEDURE SetLRect(VAR dstRect: LRect; itsLeft, itsTop, itsRight, itsBottom: LONGINT);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
WITH dstRect DO
BEGIN
left := itsLeft;
top := itsTop;
right := itsRight;
bottom := itsBottom;
END;
END;
{$S SgDRWres}
PROCEDURE OffsetLRect(VAR dstRect: LRect; dh, dv: LONGINT);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
WITH dstRect DO
BEGIN
left := left + dh;
top := top + dv;
right := right + dh;
bottom := bottom + dv;

Apple Lisa ToolKit 3.0 Source Code Listing -- 527 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

END;

END;

{$S SgDRWres}
PROCEDURE InsetLRect(VAR dstRect: LRect; dh, dv: LONGINT);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
WITH dstRect DO
BEGIN
left := left + dh;
top := top + dv;
right := right - dh;
bottom := bottom - dv;
IF (left >= right) OR (top >= bottom) THEN
BEGIN
left := 0;
top := 0;
right := 0;
bottom := 0;
END;
END;
END;
{$S SgABCres}
FUNCTION SectLRect(srcRectA, srcRectB: LRect; VAR dstRect: LRect): BOOLEAN;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
WITH dstRect DO
BEGIN
left := Max(srcRectA.left, srcRectB.left);
top := Max(srcRectA.top, srcRectB.top);
right := Min(srcRectA.right, srcRectB.right);
bottom := Min(srcRectA.bottom, srcRectB.bottom);
IF (left >= right) OR (top >= bottom) THEN
BEGIN
SectLRect := FALSE;
left := 0;
top := 0;
right := 0;
bottom := 0;
END
ELSE
SectLRect := TRUE;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 528 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

END;
{$S SgDRWres}
PROCEDURE UnionLRect(srcRectA, srcRectB: LRect; VAR dstRect: LRect);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
WITH dstRect DO
BEGIN
left := Min(srcRectA.left, srcRectB.left);
top := Min(srcRectA.top, srcRectB.top);
right := Max(srcRectA.right, srcRectB.right);
bottom := Max(srcRectA.bottom, srcRectB.bottom);
END;
END;
{$S SgDRWres}
FUNCTION LPtInLRect(pt: LPoint; r: LRect): BOOLEAN;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
LPtInLRect := (r.left <= pt.h) AND (pt.h < r.right) AND
(r.top <= pt.v) AND (pt.v < r.bottom);
END;
{$S SgABCdat}
FUNCTION IsSmallPt(srcPt: LPoint): BOOLEAN;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
IsSmallPt := (ABS(srcPt.h) < MAXINT) AND (ABS(srcPt.v) < MAXINT);
END;
{$S SgABCdat}
FUNCTION IsSmallRect(srcRect: LRect): BOOLEAN;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
IsSmallRect := IsSmallPt(srcRect.topLeft) AND IsSmallPt(srcRect.botRight);
END;
{Drawing Text}

Apple Lisa ToolKit 3.0 Source Code Listing -- 529 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

{$S SgABCdat}
PROCEDURE DrawLText(textBuf: Ptr; startByte, numBytes: INTEGER);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
{$IFC libraryVersion > 20}
IF thePad.scaled THEN
thePad.DrawLText(textBuf, startByte, numBytes)
ELSE
DrawText(QDPtr(textBuf), startByte, numBytes);
{$ELSEC}
DrawText(WordPtr(textBuf), startByte, numBytes);
{$ENDC}
END;
{Drawing lines, rectangles, and ovals}
{$S SgDRWres}
PROCEDURE MoveToL(h, v: LONGINT);
VAR lPtInView: LPoint;
ptInPort:
Point;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
SetLPt(lPtInView, h, v);
thePad.LPtToPt(lPtInView, ptInPort);
MoveTo(ptInPort.h, ptInPort.v);
END;
{$S SgDRWres}
PROCEDURE MoveL(dh, dv: LONGINT);
VAR lPtInView: LPoint;
ptInPort:
Point;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
SetLPt(lPtInView, dh, dv);
thePad.LDistToDist(lPtInView, ptInPort);
Move(ptInPort.h, ptInPort.v);
END;
{$S SgDRWres}
PROCEDURE LineToL(h, v: LONGINT);
VAR lPtInView:
LPoint;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 530 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

END;

{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
SetLPt(lPtInView, h, v);
thePad.DrawLLine(lPtInView);

{$S SgDRWres}
PROCEDURE LineL(dh, dv: LONGINT);
VAR lPtInView: LPoint;
ptInPort:
Point;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
SetLPt(lPtInView, dh, dv);
thePad.LDistToDist(lPtInView, ptInPort);
Line(ptInPort.h, ptInPort.v);
END;
{$S SgDRWres}
PROCEDURE FrameLRect(r: LRect);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
thePad.DrawLRect(frame, r);
END;
{$S SgDRWres}
PROCEDURE PaintLRect(r: LRect);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
thePad.DrawLRect(paint, r);
END;
{$S SgDRWres}
PROCEDURE EraseLRect(r: LRect);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
thePad.DrawLRect(erase, r);
END;
{$S SgDRWres}

Apple Lisa ToolKit 3.0 Source Code Listing -- 531 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

PROCEDURE InvrtLRect(r: LRect);


BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
thePad.DrawLRect(invert, r);
END;
{$S SgDRWres}
PROCEDURE FillLRect(r: LRect; lPat: LPattern);
VAR pat:
Pattern;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
IF amPrinting THEN
thePad.LPatToPat(lPat, pat);
{$IFC LibraryVersion <= 20}
thePat := Pattern(lPat);
{$ELSEC}
thePort^.fillPat := Pattern(lPat);
{$ENDC}
thePad.DrawLRect(fill, r);
END;
{$S SgDRWres}
PROCEDURE FrameLOval(r: LRect);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
thePad.DrawLOval(frame, r);
END;
{$S SgDRWres}
PROCEDURE PaintLOval(r: LRect);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
thePad.DrawLOval(paint, r);
END;
{$S SgDRWres}
PROCEDURE EraseLOval(r: LRect);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 532 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

END;

thePad.DrawLOval(erase, r);

{$S SgDRWres}
PROCEDURE InvrtLOval(r: LRect);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
thePad.DrawLOval(invert, r);
END;
{$S SgDRWres}
PROCEDURE FillLOval(r: LRect; lPat: LPattern);
VAR pat:
Pattern;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
IF amPrinting THEN
thePad.LPatToPat(lPat, pat);
{$IFC LibraryVersion <= 20}
thePat := Pattern(lPat);
{$ELSEC}
thePort^.fillPat := Pattern(lPat);
{$ENDC}
thePad.DrawLOval(fill, r);
END;
PROCEDURE FrameLRRect(r: LRect; ovalWidth, ovalHeight: INTEGER);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
thePad.DrawLRRect(frame, r, ovalWidth, ovalHeight);
END;
PROCEDURE PaintLRRect(r: LRect; ovalWidth, ovalHeight: INTEGER);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
thePad.DrawLRRect(paint, r, ovalWidth, ovalHeight);
END;
PROCEDURE EraseLRRect(r: LRect; ovalWidth, ovalHeight: INTEGER);
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 533 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

END;

{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
thePad.DrawLRRect(erase, r, ovalWidth, ovalHeight);

PROCEDURE InvrtLRRect(r: LRect; ovalWidth, ovalHeight: INTEGER);


BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
thePad.DrawLRRect(invert, r, ovalWidth, ovalHeight);
END;
PROCEDURE FillLRRect(r: LRect; ovalWidth, ovalHeight: INTEGER; lPat: LPattern);
VAR pat:
Pattern;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
IF amPrinting THEN
thePad.LPatToPat(lPat, pat);
{$IFC LibraryVersion <= 20}
thePat := Pattern(lPat);
{$ELSEC}
thePort^.fillPat := Pattern(lPat);
{$ENDC}
thePad.DrawLRRect(fill, r, ovalWidth, ovalHeight)
END;
PROCEDURE FrameLArc(r: LRect; startAngle, arcAngle: INTEGER);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
thePad.DrawLArc(frame, r, startAngle, arcAngle);
END;
PROCEDURE PaintLArc(r: LRect; startAngle, arcAngle: INTEGER);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
thePad.DrawLArc(paint, r, startAngle, arcAngle);
END;
PROCEDURE EraseLArc(r: LRect; startAngle, arcAngle: INTEGER);
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 534 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

END;

{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
thePad.DrawLArc(erase, r, startAngle, arcAngle);

PROCEDURE InvrtLArc(r: LRect; startAngle, arcAngle: INTEGER);


BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
thePad.DrawLArc(invert, r, startAngle, arcAngle);
END;
PROCEDURE FillLArc(r: LRect; startAngle, arcAngle: INTEGER; lPat: LPattern);
VAR pat:
Pattern;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
IF amPrinting THEN
thePad.LPatToPat(lPat, pat);
{$IFC LibraryVersion <= 20}
thePat := Pattern(lPat);
{$ELSEC}
thePort^.fillPat := Pattern(lPat);
{$ENDC}
thePad.DrawLArc(fill, r, startAngle, arcAngle);
END;
PROCEDURE RotatePattern(pInPat, pOutPat: Ptr; dh, dv: LONGINT);
EXTERNAL;
{$S SgABCdat}
FUNCTION ClonePicture(pic: PicHandle; toHeap: THeap): PicHandle;
VAR h: TH;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
h := HAllocate(THz(toHeap), pic^^.picSize);
XferLeft(Ptr(pic^), Ptr(h^), pic^^.picSize);
ClonePicture := PicHandle(h);
END;
{$S SgDRWres}
PROCEDURE ResizeFeedback(mousePt: Point; minPt, maxPt: Point; outerRect: Rect;

Apple Lisa ToolKit 3.0 Source Code Listing -- 535 of 1012

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163
001164
001165
001166
001167
001168
001169
001170
001171
001172
001173
001174
001175
001176
001177
001178
001179
001180
001181
001182
001183
001184
001185
001186
001187
001188
001189
001190
001191
001192
001193
001194
001195

tabHeight, sbWidth, sbHeight: INTEGER; VAR newPt: Point);


VAR rFrame:
limitRect:
oldMousePt:
innerTop:
fTab:
fHscroll:
fVScroll:
event:
savePort:

Rect;
Rect;
Point;
INTEGER;
BOOLEAN;
BOOLEAN;
BOOLEAN;
EventRecord;
GrafPtr;

PROCEDURE InitXorFrame;
BEGIN
fTab := TRUE;
fHScroll := TRUE;
fVScroll := TRUE;
{ set up scroll bar and tab widths }
{ the +1 's are to account for enlarging rFrame by one pixel }
IF sbWidth > 0 THEN
sbWidth := sbWidth+1
ELSE
fVScroll := FALSE;
IF sbHeight > 0 THEN
sbHeight := sbHeight+1
ELSE
fHScroll := FALSE;
IF tabHeight > 0 THEN
tabHeight := tabHeight+1
ELSE
fTab := FALSE;
{ setup rFrame - the outer rect for XORing
rFrame := outerRect;
InsetRect(rFrame, -1, -1);

limitRect.topLeft := minPt;
limitRect.botRight := maxPt;
IF fTab THEN innerTop := rFrame.top+tabHeight
ELSE innerTop := rFrame.top;
{ Setup the pen }
PenNormal;
PenPat(gray);

Apple Lisa ToolKit 3.0 Source Code Listing -- 536 of 1012

Apple Lisa Computer Technical Information


001196
001197
001198
001199
001200
001201
001202
001203
001204
001205
001206
001207
001208
001209
001210
001211
001212
001213
001214
001215
001216
001217
001218
001219
001220
001221
001222
001223
001224
001225
001226
001227
001228
001229
001230
001231
001232
001233
001234
001235
001236
001237
001238
001239
001240
001241
001242
001243

PenMode(notPatXor);
END;
PROCEDURE XorFrame;
BEGIN
rFrame.botRight := newPt;
FrameRect(rFrame);
IF fTab THEN
BEGIN
MoveTo(rFrame.left, innerTop);
LineTo(rFrame.right-1, innerTop);
END;
IF fHScroll THEN
BEGIN
MoveTo(rFrame.left, newPt.v-sbHeight);
LineTo(rFrame.right-1, newPt.v-sbHeight);
END;
IF fVScroll THEN
BEGIN
MoveTo(newPt.h - sbWidth, innerTop);
LineTo(newPt.h - sbWidth, rFrame.bottom-1);
END;
END;
PROCEDURE DoDragFrame;
VAR nxtPt:
Point;
BEGIN
nxtPt := Point(FPtPlusPt(newPt, Point(FPtMinusPt(mousePt, oldMousePt))));
RectHavePt(limitRect, nxtPt);
mousePt := Point(FPtPlusPt(Point(FPtMinusPt(nxtPt, newPt)), oldMousePt));
IF NOT EqualPt(nxtPt, newPt) THEN
BEGIN
XorFrame; { hide old }
newPt := nxtPt;
XorFrame; { draw new }
END;
END;
BEGIN

{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
InitXorFrame; { sets rFrame }
newPt := rFrame.botRight;
XorFrame;

Apple Lisa ToolKit 3.0 Source Code Listing -- 537 of 1012

Apple Lisa Computer Technical Information


001244
001245
001246
001247
001248
001249
001250
001251
001252
001253
001254
001255
001256
001257
001258
001259
001260
001261
001262
001263
001264
001265
001266
001267
001268
001269
001270
001271
001272
001273
001274
001275
001276
001277
001278
001279
001280
001281
001282
001283
001284
001285
001286
001287
001288
001289
001290
001291

oldMousePt := mousePt;
WHILE StillDown DO
BEGIN
GetMouse(mousePt);
DoDragFrame;
oldMousePt := mousePt;
END;
IF PeekEvent(event) AND (event.what = buttonUp) THEN
BEGIN
GetPort(savePort);
SetPort(event.who);
mousePt := event.where;
LocalToGlobal(mousePt);
SetPort(savePort);
GlobalToLocal(mousePt);
END
ELSE
GetMouse(mousePt);
DoDragFrame;
XorFrame;
{ hide last }
newPt.h := newPt.h - 1;
newPt.v := newPt.v - 1;
END; { ResizeFeedback }
{$S SgABCres}
PROCEDURE PopFocus;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
SetEmptyRgn(padRgn); {To save memory space}
focusArea := focusStack[focusStkPtr];
thePad := NIL;
IF focusArea <> NIL THEN
focusArea.Focus;
focusStkPtr := focusStkPtr - 1;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
PROCEDURE PushFocus;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
focusStkPtr := focusStkPtr + 1;
focusStack[focusStkPtr] := focusArea;

Apple Lisa ToolKit 3.0 Source Code Listing -- 538 of 1012

Apple Lisa Computer Technical Information


001292
001293
001294
001295
001296
001297
001298
001299
001300
001301
001302
001303
001304
001305
001306
001307
001308
001309
001310
001311
001312
001313
001314
001315
001316
001317
001318
001319
001320
001321
001322
001323
001324
001325
001326
001327
001328
001329
001330
001331
001332
001333
001334
001335
001336
001337
001338
001339

{$IFC fTrace}EP;{$ENDC}
END;
{$S SgDRWres}
PROCEDURE MakeTypeStyle{(itsFamily: INTEGER; itsSize: INTEGER; itsFaces: TSetEFace/Style;
VAR typeStyle: TTypeStyle)};
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
WITH typeStyle DO
BEGIN
onFaces := itsFaces;
font.fontFamily := itsFamily;
font.fontSize := itsSize;
END;
{$IFC fTrace}EP;{$ENDC}
END;
FUNCTION QDFontNumber{(typeStyle: TTypeStyle): INTEGER};
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
WITH typeStyle.font DO
IF fontFamily = famSystem THEN
QDFontNumber := fIDSystem
ELSE
QDFontNumber := fontID[fontFamily, fontSize];
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE SetQDTypeStyle{(typeStyle: TTypeStyle)};
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
TextFont(QDFontNumber(typeStyle));
TextFace(typeStyle.onFaces);
{$IFC fTrace}EP;{$ENDC}
END;
METHODS OF TArea;
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE TArea.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
Field('innerRect: Rect');

Apple Lisa ToolKit 3.0 Source Code Listing -- 539 of 1012

Apple Lisa Computer Technical Information


001340
001341
001342
001343
001344
001345
001346
001347
001348
001349
001350
001351
001352
001353
001354
001355
001356
001357
001358
001359
001360
001361
001362
001363
001364
001365
001366
001367
001368
001369
001370
001371
001372
001373
001374
001375
001376
001377
001378
001379
001380
001381
001382
001383
001384
001385
001386
001387

Field('outerRect: Rect');
Field('parentBranch: TBranchArea');
END;
{$S SgDRWres}
{$ENDC}
FUNCTION TArea.ChildWithPt(pt: Point; childList: TList; VAR nearestPt: Point): TArea;
VAR foundArea: TArea;
s:
TListScanner;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
RectHavePt(SELF.innerRect, pt);
s := childList.scanner;
WHILE s.Scan(foundArea) DO
IF RectHasPt(foundArea.outerRect, pt) THEN
s.Done;
IF foundArea = NIL THEN
BEGIN
{$IFC fDbgDraw}
ABCbreak('ChildWithPt found no area', 0);
{$ENDC}
foundArea := TArea(childList.First);
END;
RectHavePt(foundArea.innerRect, pt);
nearestPt := pt;
ChildWithPt := foundArea;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TArea.Erase;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
FillRect(SELF.innerRect, white);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TArea.Frame;
VAR innerRect:
Rect;
borderRect:
Rect;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
innerRect := SELF.innerRect;
IF NOT RectsNest(innerRect, focusRgn^^.rgnBBox) THEN
BEGIN
PenNormal;

Apple Lisa ToolKit 3.0 Source Code Listing -- 540 of 1012

Apple Lisa Computer Technical Information


001388
001389
001390
001391
001392
001393
001394
001395
001396
001397
001398
001399
001400
001401
001402
001403
001404
001405
001406
001407
001408
001409
001410
001411
001412
001413
001414
001415
001416
001417
001418
001419
001420
001421
001422
001423
001424
001425
001426
001427
001428
001429
001430
001431
001432
001433
001434
001435

PenSize(1, 1);
borderRect := innerRect;
InsetRect(borderRect, -1, -1);
FrameRect(borderRect);
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TArea.GetBorder(VAR border: Rect);
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SetRect(border, -1, -1, 1, 1);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TArea.SetInnerRect(newInnerRect: Rect);
VAR border: Rect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.innerRect := newInnerRect;
SELF.GetBorder(border);
{$H-} RectPlusRect(SELF.innerRect, border, SELF.outerRect); {$H+}
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TArea.SetOuterRect(newOuterRect: Rect);
VAR border: Rect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.outerRect := newOuterRect;
SELF.GetBorder(border);
{$H-} RectMinusRect(SELF.outerRect, border, SELF.innerRect); {$H+}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCini}
BEGIN
fontID[famModern,
fontID[famModern,
fontID[famModern,
fontID[famModern,
fontID[famModern,
fontID[famModern,
fontID[famModern,

size20Pitch]
size15Pitch]
size10Pitch]
size12Pitch]
size12Point]
size14Point]
size18Point]

:=
:=
:=
:=
:=
:=
:=

fID20Pitch;
fID15Pitch;
fIDm10Pitch;
fIDm12Pitch;
fIDm12Point;
fIDm14Point;
fIDm18Point;

Apple Lisa ToolKit 3.0 Source Code Listing -- 541 of 1012

Apple Lisa Computer Technical Information


001436
001437
001438
001439
001440
001441
001442
001443
001444
001445
001446
001447
001448
001449
001450
001451
001452
001453
001454
001455
001456
001457
001458
001459
001460
001461
001462
001463
001464
001465
001466
001467
001468
001469
001470
001471
001472
001473
001474
001475
001476
001477
001478
001479
001480
001481
001482
001483

fontID[famModern, size24Point] := fIDm24Point;


fontID[famClassic,
fontID[famClassic,
fontID[famClassic,
fontID[famClassic,
fontID[famClassic,
fontID[famClassic,
fontID[famClassic,
fontID[famClassic,

size20Pitch]
size15Pitch]
size10Pitch]
size12Pitch]
size12Point]
size14Point]
size18Point]
size24Point]

:=
:=
:=
:=
:=
:=
:=
:=

fID20Pitch;
fID15Pitch;
fIDc10Pitch;
fIDc12Pitch;
fIDc12Point;
fIDc14Point;
fIDc18Point;
fIDc24Point;

MakeTypeStyle(famSystem, 0 {dummy}, [], sysTypeStyle);


END;
{$S SgDRWres}
METHODS OF TPad;
{$S sCldInit}
FUNCTION TPad.CREATE(object: TObject; heap: THeap; itsInnerRect: Rect; itsViewedLRect: LRect;
itsPadRes, itsViewRes: Point;
itsPort: GrafPtr): TPad;
VAR zoomFactor: TScaler;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TPad(object);
SELF.parentBranch := NIL;
SetPt(zoomFactor.numerator, 1, 1);
SetPt(zoomFactor.denominator, 1, 1);
SELF.Redefine(itsInnerRect, itsViewedLRect, itsPadRes, itsViewRes,
zoomFactor, itsPort);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgDRWres}
{$S sCldInit}
PROCEDURE TPad.Redefine(itsInnerRect: Rect; itsViewedLRect: LRect;
itsPadRes, itsViewRes: Point;
itsZoomFactor: TScaler; itsPort: GrafPtr);
VAR vhs:
VHSelect;
newOffset: LPoint;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.SetInnerRect(itsInnerRect);

Apple Lisa ToolKit 3.0 Source Code Listing -- 542 of 1012

Apple Lisa Computer Technical Information


001484
001485
001486
001487
001488
001489
001490
001491
001492
001493
001494
001495
001496
001497
001498
001499
001500
001501
001502
001503
001504
001505
001506
001507
001508
001509
001510
001511
001512
001513
001514
001515
001516
001517
001518
001519
001520
001521
001522
001523
001524
001525
001526
001527
001528
001529
001530
001531

WITH SELF, scaleFactor DO


{$H-} BEGIN
port := itsPort;
viewedLRect := itsViewedLRect;
availLRect := itsViewedLRect;
InsetLRect(availLRect, -8192, -8192);
clippedRect := itsInnerRect;
zoomFactor := itsZoomFactor;
{install new Resolutions}
padRes := itsPadRes;
viewedRes := itsViewRes;
{compute scale factor from resolutions and zoom factor}
FOR vhs := v TO h DO
BEGIN
numerator.vh[vhs]
:= itsPadRes.vh[vhs] * zoomFactor.numerator.vh[vhs];
denominator.vh[vhs] := itsViewRes.vh[vhs] * zoomFactor.denominator.vh[vhs];
Reduce(numerator.vh[vhs], denominator.vh[vhs]);
END;
scaled := (numerator.h <> denominator.h) OR (numerator.v <> denominator.v);
{compute scroll offset}
FOR vhs := v TO h DO
newOffset.vh[vhs] :=
LIntOvrInt(LIntMulInt(itsViewedLRect.topLeft.vh[vhs],
numerator.vh[vhs]),
denominator.vh[vhs]) - itsInnerRect.topLeft.vh[vhs];
SELF.SetScrollOffset(newOffset);
{$H+} END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgDRWres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE TPad.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
TArea.Fields(Field);
Field('port: Ptr');
Field('viewedLRect: LRect');
Field('visLRect: LRect');
Field('availLRect: LRect');
Field('scrollOffset: LPoint');

Apple Lisa ToolKit 3.0 Source Code Listing -- 543 of 1012

Apple Lisa Computer Technical Information


001532
001533
001534
001535
001536
001537
001538
001539
001540
001541
001542
001543
001544
001545
001546
001547
001548
001549
001550
001551
001552
001553
001554
001555
001556
001557
001558
001559
001560
001561
001562
001563
001564
001565
001566
001567
001568
001569
001570
001571
001572
001573
001574
001575
001576
001577
001578
001579

Field('origin: Point'); {+LSR+}


Field('cdOffset: LPoint'); {+LSR+}
Field('clippedRect: rect');
Field('padRes: Point');
Field('viewedRes: Point');
Field('scaled: BOOLEAN');
Field('scaleFactor: RECORD numerator: Point; denominator: Point END');
Field('zoomFactor: RECORD numerator: Point; denominator: Point END');
END;
{$S SgDRWres}
{$ENDC}
PROCEDURE TPad.ClipFurtherTo(rBand: rect); {narrows down clip area at next Focus}
VAR grafRect: Rect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{$H-} IF SectRect(rBand, SELF.clippedRect, SELF.clippedRect) THEN; {$H+}
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TPad.DistToLDist(distInPort: Point; VAR lDistInView: LPoint);
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF SELF.scaled THEN
WITH SELF.scaleFactor DO
{$H-} BEGIN
lDistInView.h := LIntOvrInt(LIntMulInt(distInPort.h, denominator.h), numerator.h);
lDistInView.v := LIntOvrInt(LIntMulInt(distInPort.v, denominator.v), numerator.v);
{$H+} END
ELSE
BEGIN
lDistInView.h := distInPort.h;
lDistInView.v := distInPort.v;
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TPad.DrawLLine(newLPt: LPoint);
VAR newGrafPt: Point;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
SELF.LPtToPt(newLPt, newGrafPt);
StdLine(newGrafPt);
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 544 of 1012

Apple Lisa Computer Technical Information


001580
001581
001582
001583
001584
001585
001586
001587
001588
001589
001590
001591
001592
001593
001594
001595
001596
001597
001598
001599
001600
001601
001602
001603
001604
001605
001606
001607
001608
001609
001610
001611
001612
001613
001614
001615
001616
001617
001618
001619
001620
001621
001622
001623
001624
001625
001626
001627

{$IFC LibraryVersion <= 20}


{This is still not the right implementation when we are printing}
PROCEDURE TPad.DrawLPicture(pic: PicHandle; r:LRect);
VAR rectInPort: Rect;
BEGIN
SELF.LRectToRect(r, rectInPort);
DrawPicture(pic, rectInPort);
END;
{$ELSEC}
PROCEDURE TKStdText(byteCount: INTEGER; textBuf: QDPtr; numer, denom: Point);
BEGIN
StdText(byteCount, textBuf, numer, numer);
END;
PROCEDURE TKStdComment(kind, datasize: INTEGER; dataHandle: QDHandle);
CONST
picForeColor
=
108;
picBackColor
=
109;
VAR pData:

TpLongint;

BEGIN
IF dataHandle <> NIL THEN
IF dataSize <> 4 THEN
BEGIN
pData := TpLongint(ORD(dataHandle^));

END;

CASE kind OF
picForeColor:
ForeColor(pData^);
picBackColor:
BackColor(pData^);
END;
END;

{This is still not the right implementation when we are printing}


PROCEDURE TPad.DrawLPicture(pic: PicHandle; r:LRect);
VAR rectInPort:
Rect;
oldProcsPtr:
QDProcsPtr;
TKProcs:
QDProcs;
oldTextProc:
QDPtr;
oldCommentProc: QDPtr;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 545 of 1012

Apple Lisa Computer Technical Information


001628
001629
001630
001631
001632
001633
001634
001635
001636
001637
001638
001639
001640
001641
001642
001643
001644
001645
001646
001647
001648
001649
001650
001651
001652
001653
001654
001655
001656
001657
001658
001659
001660
001661
001662
001663
001664
001665
001666
001667
001668
001669
001670
001671
001672
001673
001674
001675

WITH thePort^ DO
BEGIN
oldProcsPtr := grafprocs;
IF oldProcsPtr = NIL THEN
BEGIN
SetStdProcs(TKProcs);
grafprocs := @TKProcs;
END;
WITH grafprocs^ DO
BEGIN
oldTextProc := textProc;
oldCommentProc := commentProc;
IF amPrinting THEN
BEGIN
textProc := @TKStdText;
commentProc := @TKStdComment;
END;
END;
END;
SELF.LRectToRect(r, rectInPort);
DrawPicture(pic, rectInPort);
WITH thePort^ DO
BEGIN
IF oldProcsPtr <> NIL THEN
WITH grafprocs^ DO
BEGIN
textProcs := oldTextProc;
commentProc := oldCommentProc;
END;
grafProcs := oldProcsPtr;
END;
END;
{$ENDC}
PROCEDURE TPad.DrawLRect(verb: GrafVerb; r: LRect);
VAR rectInPort: Rect;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
SELF.LRectToRect(r, rectInPort);
StdRect(verb, rectInPort);
END;
PROCEDURE TPad.DrawLRRect(verb: GrafVerb; r: LRect; ovalWidth, ovalHeight: INTEGER);

Apple Lisa ToolKit 3.0 Source Code Listing -- 546 of 1012

Apple Lisa Computer Technical Information


001676
001677
001678
001679
001680
001681
001682
001683
001684
001685
001686
001687
001688
001689
001690
001691
001692
001693
001694
001695
001696
001697
001698
001699
001700
001701
001702
001703
001704
001705
001706
001707
001708
001709
001710
001711
001712
001713
001714
001715
001716
001717
001718
001719
001720
001721
001722
001723

VAR rectInPort: Rect;


BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
SELF.LRectToRect(r, rectInPort);
StdRRect(verb, rectInPort, ovalWidth, ovalHeight);
END;
PROCEDURE TPad.DrawLOval(verb: GrafVerb; r: LRect);
VAR rectInPort: Rect;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
SELF.LRectToRect(r, rectInPort);
StdOval(verb, rectInPort);
END;
PROCEDURE TPad.DrawLArc(verb: GrafVerb; r: LRect; startAngle, arcAngle: INTEGER);
VAR rectInPort: Rect;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
SELF.LRectToRect(r, rectInPort);
StdArc(verb, rectInPort, startAngle, arcAngle);
END;
PROCEDURE TPad.DrawLBits(VAR srcBits: BitMap; VAR srcRect: Rect;
VAR dstLRect: LRect; mode: INTEGER; maskRgn: RgnHandle);
VAR dstGrafRect: Rect;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
SELF.LRectToRect(dstLRect, dstGrafRect);
StdBits(srcBits, srcRect,dstGrafRect, mode, maskRgn);
END;
{$S SgABCres}
PROCEDURE TPad.Focus;
VAR visRgn: RgnHandle;
origin: Point;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF SELF.Port <> printerPseudoPort THEN
SetPort(SELF.port);
{for the moment anyway don't tamper if being controlled by LisaPrint}

Apple Lisa ToolKit 3.0 Source Code Listing -- 547 of 1012

Apple Lisa Computer Technical Information


001724
001725
001726
001727
001728
001729
001730
001731
001732
001733
001734
001735
001736
001737
001738
001739
001740
001741
001742
001743
001744
001745
001746
001747
001748
001749
001750
001751
001752
001753
001754
001755
001756
001757
001758
001759
001760
001761
001762
001763
001764
001765
001766
001767
001768
001769
001770
001771

SetOrigin(0, 0);

{so thePort^.visRgn will be relative to a (0,0)-origined space, to match


SELF.clippedRect and altVisRgn}

RectRgn(padRgn, SELF.clippedRect);
IF useAltVisRgn THEN
visRgn := altVisRgn
{Instigated by TWindow.StashPicture or TClipboard.Publicize}
ELSE
visRgn := thePort^.visRgn;
SectRgn(padRgn, visRgn, padRgn);
origin := SELF.origin;
WITH origin DO {+LSR+}
BEGIN
SetOrigin(h, v);
OffsetRgn(padRgn, h, v);
END;
SetClip(padRgn);
focusRgn := padRgn;

{focusRgn is an alias for either padRgn or visRgn}

focusArea := SELF;
thePad := SELF;
WITH SELF DO
{$H-} BEGIN
SELF.RectToLRect(focusRgn^^.rgnBBox, visLRect);
IF SectLRect(viewedLRect, visLRect, visLRect) THEN
BEGIN END;
{$H+} END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TPad.InvalLRect(r: LRect);
VAR rectInPort: Rect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.LRectToRect(r, rectInPort);
SELF.InvalRect(rectInPort);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TPad.InvalRect(r: Rect);
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 548 of 1012

Apple Lisa Computer Technical Information


001772
001773
001774
001775
001776
001777
001778
001779
001780
001781
001782
001783
001784
001785
001786
001787
001788
001789
001790
001791
001792
001793
001794
001795
001796
001797
001798
001799
001800
001801
001802
001803
001804
001805
001806
001807
001808
001809
001810
001811
001812
001813
001814
001815
001816
001817
001818
001819

{$IFC fTrace}BP(7);{$ENDC}
IF SectRect(r, focusRgn^^.rgnBBox, r) THEN
InvalRect(r);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgDRWres}
PROCEDURE TPad.LDistToDist(lDistInView: LPoint; VAR distInPort: Point);
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF SELF.scaled THEN
WITH SELF.scaleFactor DO
{$H-} BEGIN
distInPort.h := LIntOvrInt(LIntMulInt(lDistInView.h, numerator.h), denominator.h);
distInPort.v := LIntOvrInt(LIntMulInt(lDistInView.v, numerator.v), denominator.v);
{$H+} END
ELSE
BEGIN
distInPort.h := lDistInView.h;
distInPort.v := lDistInView.v;
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TPad.LPatToPat(lPatInView: LPattern; VAR patInPort: Pattern);
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF amPrinting THEN
RotatePattern(@lPatInView, @patInPort, SELF.cdOffset.h, SELF.cdOffset.v)
ELSE
patInPort := Pattern(lPatInView); {+LSR+}
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TPad.LPtToPt(lPtInView: LPoint; VAR ptInPort: Point);
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
LRectHaveLPt(SELF.availLRect, lPtInView);
WITH SELF, cdOffset, scaleFactor DO {+LSR+}
IF scaled THEN
{$H-} BEGIN
ptInPort.h := LIntOvrInt(LIntMulInt(lPtInView.h, numerator.h), denominator.h) - h;
ptInPort.v := LIntOvrInt(LIntMulInt(lPtInView.v, numerator.v), denominator.v) - v;
{$H+} END
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 549 of 1012

Apple Lisa Computer Technical Information


001820
001821
001822
001823
001824
001825
001826
001827
001828
001829
001830
001831
001832
001833
001834
001835
001836
001837
001838
001839
001840
001841
001842
001843
001844
001845
001846
001847
001848
001849
001850
001851
001852
001853
001854
001855
001856
001857
001858
001859
001860
001861
001862
001863
001864
001865
001866
001867

BEGIN
ptInPort.h := lPtInView.h - h;
ptInPort.v := lPtInView.v - v;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
PROCEDURE TPad.LRectToRect(lRectInView: LRect; VAR rectInPort: Rect);
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
LRectHaveLPt(SELF.availLRect, lRectInView.topLeft);
LRectHaveLPt(SELF.availLRect, lRectInView.botRight);
WITH SELF, cdOffset, scaleFactor DO {+LSR+}
IF scaled THEN
{$H-} BEGIN
rectInPort.left := LIntOvrInt(LIntMulInt(lRectInView.left, numerator.h), denominator.h) - h;
rectInPort.top := LIntOvrInt(LIntMulInt(lRectInView.top, numerator.v), denominator.v) - v;
rectInPort.right := LIntOvrInt(LIntMulInt(lRectInView.right, numerator.h), denominator.h) - h;
rectInPort.bottom := LIntOvrInt(LIntMulInt(lRectInView.bottom, numerator.v), denominator.v)
- v;
{$H+} END
ELSE
BEGIN
rectInPort.left := lRectInView.left - h;
rectInPort.top := lRectInView.top - v;
rectInPort.right := lRectInView.right - h;
rectInPort.bottom := lRectInView.bottom - v;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgDRWres}
PROCEDURE TPad.OffsetBy(deltaLPt: LPoint);
VAR vhs:
VHSelect;
newOffset: LPoint;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
WITH SELF, deltaLPt DO
{$H-} BEGIN
OffsetLRect(viewedLRect, h, v);
OffsetLRect(availLRect, h, v);
{$H+} END;
FOR vhs := v TO h DO {$H-} {+LSR+}
WITH SELF, scaleFactor DO

Apple Lisa ToolKit 3.0 Source Code Listing -- 550 of 1012

Apple Lisa Computer Technical Information


001868
001869
001870
001871
001872
001873
001874
001875
001876
001877
001878
001879
001880
001881
001882
001883
001884
001885
001886
001887
001888
001889
001890
001891
001892
001893
001894
001895
001896
001897
001898
001899
001900
001901
001902
001903
001904
001905
001906
001907
001908
001909
001910
001911
001912
001913
001914
001915

newOffset.vh[vhs] := LIntOvrInt(LIntMulInt(viewedLRect.topLeft.vh[vhs],
numerator.vh[vhs]),
denominator.vh[vhs]) - innerRect.topLeft.vh[vhs];

{$H+}
SELF.SetScrollOffset(newOffset);
{$IFC fTrace}EP;{$ENDC}
END;

PROCEDURE TPad.PatToLPat(patInPort: Pattern; VAR lPatInView: LPattern);


BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF amPrinting THEN
RotatePattern(@patInPort, @lPatInView, -SELF.cdOffset.h, -SELF.cdOffset.v)
ELSE
LPatInView := LPattern(patInPort); {+LSR+}
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TPad.PtToLPt(ptInPort: Point; VAR lPtInView: LPoint);
{$IFC fDbgDraw}
VAR pt: Point;
s: S255;
{$ENDC}
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
WITH SELF, cdOffset, scaleFactor DO {+LSR+}
IF scaled THEN
{$H-} BEGIN
lPtInView.h := LIntOvrInt(LIntMulInt(ptInPort.h + h, denominator.h), numerator.h);
lPtInView.v := LIntOvrInt(LIntMulInt(ptInPort.v + v, denominator.v), numerator.v);
{$H+} END
ELSE
BEGIN
lPtInView.h := ptInPort.h + h;
lPtInView.v := ptInPort.v + v;
END;
{$IFC fDbgDraw}
SELF.LPtToPt(lPtInView, pt);
IF NOT EqualPt(pt, ptInPort) THEN
BEGIN
PointToStr(ptInPort, @s);
writeln('ptInPort:', s);
LPointToStr(lPtInView, @s);
writeln('lPtInView:',s);
PointToStr(pt, @s);
writeln('pt:', s);

Apple Lisa ToolKit 3.0 Source Code Listing -- 551 of 1012

Apple Lisa Computer Technical Information


001916
001917
001918
001919
001920
001921
001922
001923
001924
001925
001926
001927
001928
001929
001930
001931
001932
001933
001934
001935
001936
001937
001938
001939
001940
001941
001942
001943
001944
001945
001946
001947
001948
001949
001950
001951
001952
001953
001954
001955
001956
001957
001958
001959
001960
001961
001962
001963

WrObj(SELF, 1, '');
writeln;
ABCbreak('Error in TPad.PtToLPt', 0);
END;
{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCres}
PROCEDURE TPad.RectToLRect(rectInPort: Rect; VAR lRectInView: LRect);
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
WITH SELF, cdOffset, scaleFactor DO {+LSR+}
IF scaled THEN
{$H-} BEGIN
lRectInView.left :=
LIntOvrInt(LIntMulInt(rectInPort.left + h, denominator.h), numerator.h);
lRectInView.top :=
LIntOvrInt(LIntMulInt(rectInPort.top + v, denominator.v), numerator.v);
lRectInView.right :=
LIntOvrInt(LIntMulInt(rectInPort.right + h, denominator.h), numerator.h);
lRectInView.bottom :=
LIntOvrInt(LIntMulInt(rectInPort.bottom + v, denominator.v), numerator.v);
{$H+} END
ELSE
BEGIN
lRectInView.left := rectInPort.left + h;
lRectInView.top := rectInPort.top + v;
lRectInView.right := rectInPort.right + h;
lRectInView.bottom := rectInPort.bottom + v;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgDRWres}
PROCEDURE TPad.SetPen(pen: PenState);
VAR lPat:
LPattern;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF amPrinting THEN
BEGIN
noPad.PatToLPat(pen.pnPat, lPat);
SELF.LPatToPat(lPat, pen.pnPat);
END;
SetPenState(pen);
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 552 of 1012

Apple Lisa Computer Technical Information


001964
001965
001966
001967
001968
001969
001970
001971
001972
001973
001974
001975
001976
001977
001978
001979
001980
001981
001982
001983
001984
001985
001986
001987
001988
001989
001990
001991
001992
001993
001994
001995
001996
001997
001998
001999
002000
002001
002002
002003
002004
002005
002006
002007
002008
002009
002010
002011

END;

PROCEDURE TPad.SetPenToHighlight(highTransit: THighTransit);


BEGIN
{$IFC fTrace}BP(7);{$ENDC}
SELF.SetPen(highPen[highTransit]);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TPad.SetScrollOffset(VAR newOffset: LPoint);
{recalculates the origin and cdOffset fields; does not change arg}
VAR vhs:
VHSelect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
WITH SELF DO
BEGIN
scrollOffset := newOffset;
FOR vhs := v TO h DO
BEGIN
origin.vh[vhs] := newOffset.vh[vhs] MOD magicNumber;
cdOffset.vh[vhs] := newOffset.vh[vhs] - origin.vh[vhs];
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S Override}
PROCEDURE TPad.SetZoomFactor; {.... ONLY SEEMS TO BE RELEVANT FOR PANE--NONSENSE HERE FOR NOW}
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TPad.DrawLText(textBuf: Ptr; startByte, numBytes: INTEGER);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
WITH SELF.zoomFactor DO {$H-}
{$IFC libraryVersion > 20}
StdText(numBytes, QDPtr(ORD(textBuf) + startByte), numerator, denominator);
{$ELSEC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 553 of 1012

Apple Lisa Computer Technical Information


002012
002013
002014
002015
002016
002017
002018
002019
002020
002021
002022
002023
002024
002025
002026
002027
002028
002029
002030
002031
002032
002033
002034
002035
002036
002037
002038
002039
002040
002041
002042
002043
002044
002045
002046
002047
002048
002049
002050
002051
002052
002053
002054
002055
002056
002057
002058
002059

DrawText(WordPtr(textBuf), startByte, numBytes);


{$ENDC} {$H+}
END;
{$S SgDRWres}
{$S SgABCini}
BEGIN
UnitAuthor('Apple');
printerPseudoPort := POINTER(0);
crashPad := NIL;
SetPt(screenRes, 90, 60);
lPatWhite
lPatBlack
lPatGray
lPatLtGray
lPatDkGray

:=
:=
:=
:=
:=

LPattern(white);
LPattern(black);
LPattern(gray);
LPattern(ltGray);
LPattern(dkGray);

amPrinting := FALSE;
END;
{$S SgDRWres}
METHODS OF TBranchArea;
{$S SgABCcld}
FUNCTION TBranchArea.CREATE(object: TObject; heap: THeap; vhs: VHSelect; hasElderFirst: BOOLEAN;
whoCanResizeIt: TResizability;
itsElderChild, itsYoungerChild: TArea): TBranchArea;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TBranchArea(object);
WITH SELF DO
BEGIN
outerRect := itsElderChild.outerRect;
parentBranch := itsElderChild.parentBranch;
arrangement := vhs;
elderFirst := hasElderFirst;
resizability := whoCanResizeIt;
elderChild := itsElderChild;
youngerChild := itsYoungerChild;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 554 of 1012

Apple Lisa Computer Technical Information


002060
002061
002062
002063
002064
002065
002066
002067
002068
002069
002070
002071
002072
002073
002074
002075
002076
002077
002078
002079
002080
002081
002082
002083
002084
002085
002086
002087
002088
002089
002090
002091
002092
002093
002094
002095
002096
002097
002098
002099
002100
002101
002102
002103
002104
002105
002106
002107

itsElderChild.parentBranch := SELF;
itsYoungerChild.parentBranch := SELF;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgDRWres}
{$IFC fDebugMethods}
{$S SgABCdbg}
PROCEDURE TBranchArea.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
TArea.Fields(Field);
Field('arrangement: Byte');
Field('elderFirst: BOOLEAN');
Field('resizability: Byte');
Field('elderChild: TArea');
Field('youngerChild: TArea');
END;
{$S SgDRWres}
{$ENDC}
{$S SgABCcld}
PROCEDURE TBranchArea.GetMinExtent(VAR minExtent: Point; windowIsResizingIt: BOOLEAN);
VAR elderMinSize:
Point;
youngerMinSize: Point;
vhs:
VHSelect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
vhs := SELF.arrangement;
SELF.elderChild.GetMinExtent(elderMinSize, TRUE);
SELF.youngerChild.GetMinExtent(youngerMinSize, TRUE);
IF windowIsResizingIt AND NOT (windowCanResizeIt IN SELF.resizability) THEN
youngerMinSize.vh[vhs] := LengthRect(SELF.youngerChild.outerRect, vhs);
minExtent.vh[vhs] := elderMinSize.vh[vhs] + youngerMinSize.vh[vhs];
vhs := orthogonal[vhs];
minExtent.vh[vhs] := Max(elderMinSize.vh[vhs], youngerMinSize.vh[vhs]);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgDRWres}
{$S SgABCcld}
FUNCTION TBranchArea.OtherChild(child: TArea): TArea;

Apple Lisa ToolKit 3.0 Source Code Listing -- 555 of 1012

Apple Lisa Computer Technical Information


002108
002109
002110
002111
002112
002113
002114
002115
002116
002117
002118
002119
002120
002121
002122
002123
002124
002125
002126
002127
002128
002129
002130
002131
002132
002133
002134
002135
002136
002137
002138
002139
002140
002141
002142
002143
002144
002145
002146
002147
002148
002149
002150
002151
002152
002153
002154
002155

BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.elderChild = child THEN
OtherChild := SELF.youngerChild
ELSE
{$IFC fDbgDraw}
IF SELF.youngerChild = child THEN
OtherChild := SELF.elderChild
ELSE
ABCBreak('This panel branch does not have a child that is', ORD(child));
{$ELSEC}
OtherChild := SELF.elderChild;
{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgDRWres}
{$S SgABCcld}
PROCEDURE TBranchArea.Redivide(newCd: INTEGER);
VAR elderRect:
Rect;
youngerRect:
Rect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
elderRect := SELF.elderChild.outerRect;
youngerRect := SELF.youngerChild.outerRect;
TRectCoords(elderRect)[SELF.elderFirst].vh[SELF.arrangement] := newCd;
TRectCoords(youngerRect)[NOT SELF.elderFirst].vh[SELF.arrangement] := newCd;
SELF.elderChild.ResizeOutside(elderRect);
SELF.youngerChild.ResizeOutside(youngerRect);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgDRWres}
{$S SgABCcld}
PROCEDURE TBranchArea.ReplaceChild(child, newChild: TArea);
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.elderChild = child THEN
SELF.elderChild := newChild
ELSE
{$IFC fDbgDraw}
IF SELF.youngerChild = child THEN
SELF.youngerChild := newChild
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 556 of 1012

Apple Lisa Computer Technical Information


002156
002157
002158
002159
002160
002161
002162
002163
002164
002165
002166
002167
002168
002169
002170
002171
002172
002173
002174
002175
002176
002177
002178
002179
002180
002181
002182
002183
002184
002185
002186
002187
002188
002189
002190
002191
002192
002193
002194
002195
002196
002197
002198
002199
002200
002201
002202
002203

ABCBreak('This panel branch does not have a child that is', ORD(child));
{$ELSEC}
SELF.youngerChild := newChild;
{$ENDC}
newChild.parentBranch := SELF;
IF child.parentBranch = SELF THEN
child.parentBranch := NIL;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgDRWres}
{$S SgABCcld}
PROCEDURE TBranchArea.ResizeOutside(newOuterRect: Rect);
VAR formerRect:
Rect;
elderChild:
TArea;
youngerChild:
TArea;
elderRect:
Rect;
youngerRect:
Rect;
vhs:
VHSelect;
eldFirst:
BOOLEAN;
minExtents:
ARRAY [FALSE..TRUE] OF Point;
newCd:
INTEGER;
deltaRect:
Rect;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
formerRect := SELF.outerRect;
elderChild := SELF.elderChild;
youngerChild := SELF.youngerChild;
elderRect := elderChild.outerRect;
youngerRect := youngerChild.outerRect;
vhs := SELF.arrangement;
eldFirst := SELF.elderFirst;
IF windowCanResizeIt IN SELF.resizability THEN
BEGIN
{both children resize proportionally}
MapRect(elderRect, formerRect, newOuterRect);
MapRect(youngerRect, formerRect, newOuterRect);
elderChild.GetMinExtent(minExtents[NOT eldFirst], TRUE);
youngerChild.GetMinExtent(minExtents[eldFirst], TRUE);
IF (minExtents[FALSE].vh[vhs] + minExtents[TRUE].vh[vhs]) < LengthRect(newOuterRect, vhs) THEN
BEGIN
{It is possible to satisfy both min constraints, so do so}

Apple Lisa ToolKit 3.0 Source Code Listing -- 557 of 1012

Apple Lisa Computer Technical Information


002204
002205
002206
002207
002208
002209
002210
002211
002212
002213
002214
002215
002216
002217
002218
002219
002220
002221
002222
002223
002224
002225
002226
002227
002228
002229
002230
002231
002232
002233
002234
002235
002236
002237
002238
002239
002240
002241
002242
002243
002244
002245
002246
002247

END

newCd := Max(newOuterRect.topLeft.vh[vhs] + minExtents[FALSE].vh[vhs],


Min(newOuterRect.botRight.vh[vhs] - minExtents[TRUE].vh[vhs],
TRectCoords(elderRect)[eldFirst].vh[vhs]));
TRectCoords(elderRect)[eldFirst].vh[vhs] := newCd;
TRectCoords(youngerRect)[NOT eldFirst].vh[vhs] := newCd;
END;

ELSE
BEGIN
{only elder child resizes in my direction}
RectMinusRect(newOuterRect, formerRect, deltaRect);
RectPlusRect(elderRect, deltaRect, elderRect);
TRectCoords(deltaRect)[NOT eldFirst].vh[vhs] := TRectCoords(deltaRect)[eldFirst].vh[vhs];
RectPlusRect(youngerRect, deltaRect, youngerRect);
END;
youngerChild.ResizeOutside(youngerRect);
elderChild.ResizeOutside(elderRect);
SELF.outerRect := newOuterRect;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgDRWres}
{$S SgABCcld}
FUNCTION TBranchArea.TopLeftChild: TArea;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF SELF.elderFirst THEN
TopLeftChild := SELF.elderChild
ELSE
TopLeftChild := SELF.youngerChild;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgDRWres}
{$S SgABCini}
END;
{$S SgDRWres}
{$S SgABCini}

End of File -- Lines: 2247 Characters: 58490

Apple Lisa ToolKit 3.0 Source Code Listing -- 558 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UOBJECT.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

UNIT UObject;
{Copyright 1983, 1984, Apple Computer, Inc.}
{Implementation is in UOBJECT2-3-4}
{$SETC IsIntrinsic := TRUE}
{$IFC IsIntrinsic}
INTRINSIC;
{$ENDC}
{$SETC ErrsToFile := TRUE }
{$IFC ErrsToFile}
{$E+}
{****************************************}
{$ENDC}

{$E ERRS.TEXT}

{****************************************}

{NOTE: The implementation of class TObject is quite obscure because this is actually system-type code}
{Segments: SgABCini(tialize), SgABCdat(a structures), SgABCdbg}
{
=========================================== SPECIFICALLY IN UObject =========================================
----------CLASSES------

------------------VARIABLES-------------------- ------------- COMMENTS ----------

TObject
TCollection

size dynOffset holeStart holeSize holeStd

TList
TArray

recordBytes

TString
TFile
TScanner

path scanners
collection position increment scanDone atEnd

TListScanner
TArrayScanner
TStringScanner
TFileScanner

error actual
accesses refnum

-- indexed access (At, InsAt,


Each)
-- contains object handles
-- contains records (even
lengths)
-- contains characters
-- disk file (Exists, Rename)
-- sequential access (Scan,
Insert)
-- an object at a time
-- a record at a time
-- a character at a time (Xfer)
-- through a whole TFile

Apple Lisa ToolKit 3.0 Source Code Listing -- 559 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

========================================= IN ALL DATA STRUCTURE UNITS =======================================


=== KEY ===>
----------CLASSES----------

$ = in UObject

@ = in UHuge

* in UDb

# in UMac

---------------VARIABLES------------------- ------------- COMMENTS ----------

$ TObject
$
$
$
$
$

TCollection
@
@
@
*
*
*
*

TList
TLinkList
THugeList
TArray
THugeArray
TString
TFile
TDb
TDbFile
TRsFile
TDbRsFile
#

$
$
$
$
$

TMcRsFile

size dynOffset holeStart holeSize holeStd -- indexed access (At, InsAt,


Each)
-- contains object handles
head tail
-- stored in TLinks
hugeArray
-- stored in linked blocks
recordBytes
-- contains records (even
lengths)
minBlockLength maxBlockLength blocks
-- impl. with linked blocks
-- contains characters
path scanners
-- disk file (Exists, Rename)
-- contains keyed records
file rScanDesc
-- key is a PAOC/String
endIncrement firstKey lastKey scanners
-- key is a LONGINT (SwapIn)
dbFile
-- implemented with a
TDbFile
???
-- implemented in the Mac
ROM

TScanner
@
@
@
*
*
*
*
*

collection position increment scanDone atEnd -- sequential access (Scan,


Insert)
TListScanner
-- an object at a time
TLnkLstScanner
scanLink
THgeLstScanner
blkArrScanner
TArrayScanner
-- a record at a time
THgeArrScanner
cacheBlock cacheIndex
-- through a THugeArray
TStringScanner
error actual
-- a character at a time (Xfer)
TFileScanner
accesses refnum
-- through a whole TFile
TRsScanner
whichWay key buffer
-- through a single resource
TDbScanner
error
-- a key at a time
TDbFiScanner
rScanDesc
-- through a TDbFile
TRsFiScanner
-- a resource at a time
TDbRsFiScanner
dbRecSeq dbRecSize
-- through a TDbRsFile
#
TMcRsFiScanner
???
-- implemented in the Mac
ROM

@ TLink

element next

-- has one element of a TLinkList

INTERFACE
{$SETC LibraryVersion := 30 } { 10 = 1.0 libraries; 13 = 1.3 libraries; 20 = Pepsi,

Apple Lisa ToolKit 3.0 Source Code Listing -- 560 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

29 = V12.0 Libraries, 30 = V13.0+ libraries }


{$SETC compatibleLists := FALSE }
USES
UnitStd,
UnitHz,
{$U -#BOOT-SysCall
} SysCall,
{$IFC LibraryVersion > 20}
{$U LIBTK/Passwd } Passwd,
{$ENDC}
{$IFC LibraryVersion <= 20}
{$U UClascal}
UClascal,
{$ELSEC} {$IFC LibraryVersion < 30}
{$U LIBTK/UClascal}
UClascal,
{Needed for interface}
{$ELSEC}
{$U LIBPL/UClascal}
UClascal,
{Needed for interface}
{$ENDC}
{$ENDC}
{ The next units needed to find out where the printer is located, from parameter memory,
so we can tell Paslib where it is. (Needed for debugger Output Redirect.) }
PmDecl,
Pmm,
{$IFC LibraryVersion > 10}
{$U LIBPL/PaslibCall} PaslibCall,
{$U LIBPL/PPasLibc } PPasLibC,
{$ENDC}
{$U HWInt}

HWInt;

{$SETC fDbgOK := TRUE}{FALSE} {override UnitStd to test Tool Kit}


{$SETC fSymOK := TRUE}{FALSE} {override UnitStd to test Tool Kit}
{$SETC fDbgObject
{$SETC fRngObject
{$SETC fSymObject

:= fDbgOK}
:= fDbgOK}
:= fSymOK}

{$SETC fDebugMethods := fDbgObject} {include debugging methods in the compilation}


{$SETC fCheckHeap
{$SETC fTrace
{$SETC fMaxTrace

:= fDbgObject} {if VAR also true, check heap}


:= fDbgObject} {if VAR also true, trace entries/exits}
:= fTrace AND FALSE} {if TRUE trace entries/exits on minor procedures too}

{$SETC fCheckIndices := fDbgObject} {if VAR also true, check subscripts}


CONST

Apple Lisa ToolKit 3.0 Source Code Listing -- 561 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

prcsLdsn
prcsDsBytes

= 1;
= 15000;

MaxBreaks

= 10;

outputRMargin
erInternal

= 85;
= 4200;

MAXLINT

= $7FFFFFFF;

{ldsn for the process data segment}


{default heap size for a process data segment}

{Stolen from list of errors in UABC for newHeap}

TYPE
{Aliases needed to compile QuickDraw}
Ptr = ^LONGINT;
ProcPtr = Ptr;
Handle = ^Ptr;
{Aliases for commonly used types}
S8 = STRING[8];
S255 = STRING[255];
TFilePath = S255;

{Increased from 66 because of the new hierarchical file system;


corresponds to Pathname in SYSCALL}
TFilePart = STRING[32]; {length of each level in a pathname; corresponds to e_name in SYSCALL}
TPassword = TFilePart;
THeap = Ptr;
TClass = Ptr;

{alias for THz in UnitHz}


{alias for TPSliceTable in UClascal}

Byte = -128..127;
TPString = ^S255;
TpINTEGER = ^INTEGER;
TpLONGINT = ^LONGINT;
TAuthorName = STRING[32];
TClassName = STRING[8];
TClassWorld = RECORD
infRecs:
TArray
classes:
TArray
authors:
TArray
aliases:
TArray
END;

{Alias for TWorld in IMPLEMENTATION}


{OF name, size, author, & version information};
{OF TClass -- the pointer in each Clascal object};
{OF PACKED ARRAY [1..SIZEOF(TAuthorName)] OF CHAR};
{OF PACKED ARRAY [1..SIZEOF(TClassName)] OF CHAR};

TEnumAccesses = (fRead, fWrite, fAppend, fPrivate); {not allowing global_refnum at this time}

Apple Lisa ToolKit 3.0 Source Code Listing -- 562 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

TAccesses = SET OF TEnumAccesses;


TIOMode = (fAbsolute, fRelative, fSequential);
xReadWrite = (xRead, xWrite);
SizeOfNumber = 1..4;
TScanDirection = (scanForward, scanBackward);
TConvResult = (cvValid, cvNoNumber, cvBadNumber, cvOverflow);
{Classes}
TObject = SUBCLASS OF NIL
{Creation and Destruction}
FUNCTION TObject.CREATE(object: TObject; heap: THeap):
PROCEDURE TObject.Become(object: TObject);
FUNCTION TObject.Class: TClass;
FUNCTION TObject.CloneObject(heap: THeap): TObject;
FUNCTION TObject.Clone(heap: THeap): TObject; DEFAULT;
PROCEDURE TObject.FreeObject; DEFAULT;
PROCEDURE TObject.Free; DEFAULT;
FUNCTION TObject.Heap: THeap;
FUNCTION TObject.HeapBytes: INTEGER;
PROCEDURE TObject.Read(s: TStringScanner);
PROCEDURE TObject.Write(s: TStringScanner);

TObject; ABSTRACT;
{SELF becomes obj and former SELF is freed}
{its class pointer}
{clones just the object, not its dependents}
{clones the object and its known dependents}
{frees just the object, not its dependents}
{frees the object and its known dependents}
{which heap it is in}
{number of bytes occupied in that heap}
{reads the object & its known dependents}
{writes the object & its known dependents}

{Debugging}
{$IFC fDebugMethods}
PROCEDURE TObject.Fields(PROCEDURE Field(nameAndType: S255)); DEFAULT; {See end of file for comment}
PROCEDURE TObject.Debug(numLevels: INTEGER; memberTypeStr: S255); DEFAULT;
{writes an object down to numLevels:
numLevels=0 => write only class;
numLevels=1 => write class, non-Object fields, and class of Object fields
etc.}
{$ENDC}
{Version Conversion}
PROCEDURE TObject.Convert(fromVersion: Byte); {Override it to finish conversion from an old version}
FUNCTION TObject.JoinClass(newClass: TClass): TObject;
{Called for you by version conversion}
END;
TCollecHeader =
classPtr:
size:
dynStart:

RECORD
TClass;
LONGINT;
INTEGER;

{number of real elements, not counting the hole}


{bytes from the class ptr to the dynamic data; MAXINT if none allowed}

Apple Lisa ToolKit 3.0 Source Code Listing -- 563 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

holeStart:
holeSize:
holeStd:
END;

INTEGER;
INTEGER;
INTEGER;

{0 = at the beginning, size = at the end; MAXINT = none allowed}


{measured in MemberBytes units}
{if the holeSize goes to 0, how much to grow the collection by}

TFastString = RECORD
{only access ch[i] when hole is at end & TString is not subclassed}
header:
TCollecHeader;
ch:
PACKED ARRAY[1..32740] OF CHAR;
END;
TPFastString = ^TFastString;
THFastString = ^TPFastString;
TArrayHeader = RECORD
classPtr:
TClass;
size:
LONGINT;
dynStart:
INTEGER;
holeStart:
INTEGER;
holeSize:
INTEGER;
holeStd:
INTEGER;
recordBytes:
INTEGER;
END;

{number of real elements, not counting the hole}


{bytes from the class ptr to the dynamic data}
{0 means hole at the beginning, size means hole at the end}
{measured in MemberBytes units}
{if the holeSize goes to 0, how much to grow the collection by}

TCollection = SUBCLASS OF TObject


{Variables}
size:
dynStart:
holeStart:
holeSize:
holeStd:

LONGINT;
INTEGER;
INTEGER;
INTEGER;
INTEGER;

{number of real elements, not counting the hole}


{bytes from the class ptr to the dynamic data}
{0 means hole at the beginning, size means hole at the end}
{measured in MemberBytes units}
{if the holeSize goes to 0, how much to grow the collection by}

{The field "size" is a LONGINT for the benefit of huge collections like remote data bases.
It is always in the INTEGER range for non-subclassed TLists, TArrays, and TStrings.
The field "dynStart" is an offset from Handle(collection)^ and tells where the dynamic part
of the data is stored, if any. This convention allows subclasses to add fields.
When editing a collection, there may be an unused "hole" somewhere in the storage block. The
fields "holeStart" and "holeSize" specify (in member-sized units) the starting index of the
hole and the length of the hole. When holeSize is zero, there is no hole. If members are
added when there is no hole, the storage block is expanded to allow for at least another
"holeStd" members.
CREATE has an argument that lets the initial collection have a hole at the end, so that
Ins- methods can be called to initialize the collection without any storage allocation.
StartEdit sets holeStd to its argument, which forces subsequent edit methods to leave intact

Apple Lisa ToolKit 3.0 Source Code Listing -- 564 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

any hole they might form. StopEdit squeezes out the hole and sets holeStd to zero, which
forces subsequent edit methods that get called with no hole to squeeze out any hole they may form.
Thus, every StartEdit that has a nonzero argument should be terminated by a call on StopEdit to
save space.}
{Creation and Destruction}
FUNCTION TCollection.CREATE(object: TObject; heap: THeap; initialSlack: INTEGER): TCollection;
FUNCTION TCollection.Clone(heap: THeap): TObject; OVERRIDE;
{Attributes}
FUNCTION TCollection.MemberBytes: INTEGER; ABSTRACT;
FUNCTION TCollection.Equals(otherCollection: TCollection): BOOLEAN;
{Slack control}
PROCEDURE TCollection.StartEdit(withSlack: INTEGER);
PROCEDURE TCollection.StopEdit;
{Generic Inserts}
PROCEDURE TCollection.InsManyAt(i: LONGINT; otherCollection: TCollection; index, howMany: LONGINT);
PROCEDURE TCollection.InsNullsAt(i, howMany: LONGINT);
(* BEGIN CONCEPTUAL METHODS (parameter types differ in subclasses; sometimes extra parameters required)
{Enumerate members}
PROCEDURE TCollection.Each(PROCEDURE DoToMember(member: "TMember")); CONCEPTUAL;
FUNCTION TCollection.Pos(after: LONGINT; member: "TMember"): LONGINT; CONCEPTUAL;
FUNCTION TCollection.Scanner: TScanner; CONCEPTUAL;
{c.ScannerFrom(-MaxLInt, scanForward)}
FUNCTION TCollection.ScannerFrom(firstToScan: LONGINT; scanDirection: TScanDirection)
: TScanner; CONCEPTUAL;
{Inspect members}
FUNCTION TCollection.At(i: LONGINT): "TMember"; CONCEPTUAL;
FUNCTION TCollection.First: "TMember"; CONCEPTUAL;
FUNCTION TCollection.Last: "TMember"; CONCEPTUAL;
FUNCTION TCollection.ManyAt(i, howMany: LONGINT): "TCollection"; CONCEPTUAL;
{Insert members}
PROCEDURE TCollection.InsAt(i: LONGINT; member: "TMember"); CONCEPTUAL;
PROCEDURE TCollection.InsFirst(member: "TMember"); CONCEPTUAL;
PROCEDURE TCollection.InsLast(member: "TMember"); CONCEPTUAL;
{Delete members}
PROCEDURE TCollection.DelAll; CONCEPTUAL;
PROCEDURE TCollection.DelAt(i: LONGINT); CONCEPTUAL;
PROCEDURE TCollection.DelFirst; CONCEPTUAL;
PROCEDURE TCollection.DelLast; CONCEPTUAL;
PROCEDURE TCollection.DelManyAt(i, howMany: LONGINT); CONCEPTUAL;

Apple Lisa ToolKit 3.0 Source Code Listing -- 565 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

{Change member}
PROCEDURE TCollection.PutAt(i: LONGINT; member: "TMember"); CONCEPTUAL;
END CONCEPTUAL METHODS *)
{Private methods -- to be called by subclasses only!!!}
{$IFC fRngObject}
PROCEDURE TCollection.CheckIndex(index: LONGINT);
{$ENDC}
FUNCTION TCollection.AddrMember(i: LONGINT): LONGINT;
{The address is only valid momentarily}
PROCEDURE TCollection.CopyMembers(dstAddr, startIndex, howMany: LONGINT);
PROCEDURE TCollection.EditAt(atIndex: LONGINT; deltaMembers: INTEGER);
{Transfers no data}
PROCEDURE TCollection.ResizeColl(membersPlusHole: INTEGER);
{Resizes at end, no fields changed}
PROCEDURE TCollection.ShiftColl(afterSrcIndex, afterDstIndex, howMany: INTEGER); {No fields changed}
END;
TList = SUBCLASS OF TCollection
{Variables}
{Creation and Destruction}
FUNCTION TList.CREATE(object: TObject; heap: THeap; initialSlack: INTEGER): TList;
FUNCTION TList.Clone(heap: THeap): TObject; OVERRIDE;
PROCEDURE TList.Free; OVERRIDE;
{Debugging}
{$IFC fDebugMethods}
PROCEDURE TList.Debug(numLevels: INTEGER; memberTypeStr: S255); OVERRIDE;
{ numLevels=0
print just class of list;
1
also print size of list;
2
also print compacted list of member classes
>=3
print class, size, and call Debug(numLevels-1) on members
}
PROCEDURE TList.DebugMembers;
{$ENDC}
{Attributes}
FUNCTION TList.MemberBytes: INTEGER; OVERRIDE;
{Enumerate members}
PROCEDURE TList.Each(PROCEDURE DoToObject(object: TObject)); DEFAULT;
FUNCTION TList.Pos(after: LONGINT; object: TObject): LONGINT;
FUNCTION TList.Scanner: TListScanner;
FUNCTION TList.ScannerFrom(firstToScan: LONGINT; scanDirection: TScanDirection)
: TListScanner; DEFAULT;
{Inspect members}

Apple Lisa ToolKit 3.0 Source Code Listing -- 566 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

FUNCTION
FUNCTION
FUNCTION
FUNCTION

TList.At(i: LONGINT): TObject; DEFAULT;


TList.First: TObject; DEFAULT;
TList.Last: TObject; DEFAULT;
TList.ManyAt(i, howMany: LONGINT): TList; DEFAULT;

{Insert members}
PROCEDURE TList.InsAt(i: LONGINT; object: TObject); DEFAULT;
PROCEDURE TList.InsFirst(object: TObject);
PROCEDURE TList.InsLast(object: TObject);
{Delete members}
PROCEDURE TList.DelAll(freeOld: BOOLEAN); DEFAULT;
PROCEDURE TList.DelAt(i: LONGINT; freeOld: BOOLEAN); DEFAULT;
PROCEDURE TList.DelFirst(freeOld: BOOLEAN);
PROCEDURE TList.DelLast(freeOld: BOOLEAN);
PROCEDURE TList.DelManyAt(i, howMany: LONGINT; freeOld: BOOLEAN); DEFAULT;
PROCEDURE TList.DelObject(object: TObject; freeOld: BOOLEAN);
FUNCTION TList.PopLast: TObject;
{Change member}
PROCEDURE TList.PutAt(i: LONGINT; object: TObject; freeOld: BOOLEAN); DEFAULT;
END;
TArray = SUBCLASS OF TCollection

{*** WARNING: The Ptrs below become invalid if the heap compacts!!!}

{Variables}
recordBytes: INTEGER;
{Creation and Destruction}
FUNCTION TArray.CREATE(object: TObject; heap: THeap; initialSlack, bytesPerRecord: INTEGER): TArray;
{Attributes}
FUNCTION TArray.MemberBytes: INTEGER; OVERRIDE;
{Enumerate members}
PROCEDURE TArray.Each(PROCEDURE DoToRecord(pRecord: Ptr)); DEFAULT;
FUNCTION TArray.Pos(after: LONGINT; pRecord: Ptr): LONGINT;
FUNCTION TArray.Scanner: TArrayScanner;
FUNCTION TArray.ScannerFrom(firstToScan: LONGINT; scanDirection: TScanDirection)
: TArrayScanner; DEFAULT;
{Inspect members}
FUNCTION TArray.At(i: LONGINT): Ptr; DEFAULT;
FUNCTION TArray.First: Ptr;
PROCEDURE TArray.GetAt(i: LONGINT; pRecord: Ptr); DEFAULT; {Sort of: pRecord^ := SELF.At(i)^}
FUNCTION TArray.Last: Ptr;
FUNCTION TArray.ManyAt(i, howMany: LONGINT): TArray; DEFAULT;

Apple Lisa ToolKit 3.0 Source Code Listing -- 567 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

{Insert members}
PROCEDURE TArray.InsAt(i: LONGINT; pRecord: Ptr); DEFAULT;
PROCEDURE TArray.InsFirst(pRecord: Ptr);
PROCEDURE TArray.InsLast(pRecord: Ptr);
{Delete members}
PROCEDURE TArray.DelAll; DEFAULT;
PROCEDURE TArray.DelAt(i: LONGINT); DEFAULT;
PROCEDURE TArray.DelFirst;
PROCEDURE TArray.DelLast;
PROCEDURE TArray.DelManyAt(i, howMany: LONGINT); DEFAULT;
{Change member}
PROCEDURE TArray.PutAt(i: LONGINT; pRecord: Ptr); DEFAULT;
END;
TString = SUBCLASS OF TCollection
{Variables}
{Creation and Destruction}
FUNCTION TString.CREATE(object: TObject; heap: THeap; initialSlack: INTEGER): TString;
{Attributes}
FUNCTION TString.MemberBytes: INTEGER; OVERRIDE;
{Enumerate members}
PROCEDURE TString.Each(PROCEDURE DoToCharacter(character: CHAR));
FUNCTION TString.Pos(after: LONGINT; character: CHAR): LONGINT;
FUNCTION TString.Scanner: TStringScanner;
FUNCTION TString.ScannerFrom(firstToScan: LONGINT; scanDirection: TScanDirection): TStringScanner;
{Inspect members}
FUNCTION TString.At(i: LONGINT): CHAR;
FUNCTION TString.First: CHAR;
FUNCTION TString.Last: CHAR;
FUNCTION TString.ManyAt(i, howMany: LONGINT): TString;
PROCEDURE TString.ToPStr(pStr: TPString);
PROCEDURE TString.ToPStrAt(i, howMany: LONGINT; pStr: TPString);
{Insert members}
PROCEDURE TString.InsAt(i: LONGINT; character: CHAR);
PROCEDURE TString.InsFirst(character: CHAR);
PROCEDURE TString.InsLast(character: CHAR);
PROCEDURE TString.InsPStrAt(i: LONGINT; pStr: TPString);

Apple Lisa ToolKit 3.0 Source Code Listing -- 568 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

{Delete members}
PROCEDURE TString.DelAll;
PROCEDURE TString.DelAt(i: LONGINT);
PROCEDURE TString.DelFirst;
PROCEDURE TString.DelLast;
PROCEDURE TString.DelManyAt(i, howMany: LONGINT);
{Change member}
PROCEDURE TString.PutAt(i: LONGINT; character: CHAR);
{QuickDraw}
PROCEDURE TString.Draw(i: LONGINT; howMany: INTEGER);
FUNCTION TString.Width(i: LONGINT; howMany: INTEGER): INTEGER;
END;
TFile = SUBCLASS OF TCollection
{Variables}
path:
password:

scanners:

TFilePath;
TPassword;

TList {OF TScanner};

{The current password protecting this file, and used for all
accesses to it; client is responsible for setting this
field after the TFile is created; ignored if
LibraryVersion <= 20}

{Creation and Destruction}


FUNCTION TFile.CREATE(object: TObject; heap: THeap; itsPath: TFilePath;
itsPassword: TPassword): TFile;
{itsPassword is ignored from LibraryVersion <= 20}
PROCEDURE TFile.Free; OVERRIDE;
FUNCTION TFile.Clone(heap: THeap): TObject; OVERRIDE;

{Frees the scanners as well}


{Illegal}

{Attributes}
FUNCTION TFile.MemberBytes: INTEGER; OVERRIDE;
{Enumerate members}
FUNCTION TFile.Scanner: TFileScanner;
{f.ScannerFrom(0, [fRead, fWrite])}
FUNCTION TFile.ScannerFrom(firstToScan: LONGINT; manip: TAccesses): TFileScanner;
{Catalog}
PROCEDURE TFile.ChangePassword(VAR error: INTEGER; newPassword: TPassword);
{also changes the password field, if successful}
PROCEDURE TFile.Delete(VAR error: INTEGER);
FUNCTION TFile.Exists(VAR error: INTEGER): BOOLEAN;
FUNCTION TFile.WhenModified(VAR error: INTEGER): LONGINT;
PROCEDURE TFile.Rename(VAR error: INTEGER; newFileName: TFilePath);

Apple Lisa ToolKit 3.0 Source Code Listing -- 569 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

FUNCTION

TFile.VerifyPassword(VAR error: INTEGER; password: TPassword): BOOLEAN;

END;
TScanner = SUBCLASS OF TObject
{Variables}
collection:
position:
increment:
scanDone:
atEnd:
FUNCTION

TCollection; {The collection being scanned}


LONGINT;
{The current position (between members: 0=before first, size+1=after
last)}
INTEGER;
{1 if scanning forward, -1 if scanning backward}
BOOLEAN;
{TRUE if next .Scan call should return FALSE, leaving its VAR
parameter alone}
BOOLEAN;
{TRUE if next .Scan call will return FALSE because at end of collection}

TScanner.CREATE(object: TObject; itsCollection: TCollection; itsInitialPosition: LONGINT;


scanDirection: TScanDirection): TScanner;

{Close and Reopen}


PROCEDURE TScanner.Close; DEFAULT;
PROCEDURE TScanner.Open; DEFAULT;

{If disk-based, flush buffers and tell OS to close file,


else no-op}
{If disk-based, tell OS to reopen file and fill first buffer}

{Slack Control}
PROCEDURE TScanner.Allocate(slack: LONGINT); DEFAULT;
PROCEDURE TScanner.Compact; DEFAULT;

{Like collection.StartEdit(slack)}
{Like collection.StopEdit}

{Positioning}
FUNCTION TScanner.Advance(PROCEDURE DoToCurrent(anotherMember: BOOLEAN)): BOOLEAN;
PROCEDURE TScanner.Done; DEFAULT;
{Set scanDone so that Scan will return FALSE}
PROCEDURE TScanner.Reverse; DEFAULT;
{Reverse the scan direction}
PROCEDURE TScanner.Seek(newPosition: LONGINT); DEFAULT; {Forces to legal places}
PROCEDURE TScanner.Skip(deltaPos: LONGINT); DEFAULT;
{Forces to legal places}
(* BEGIN CONCEPTUAL METHODS (parameter types differ in subclasses; sometimes extra parameters required)
{Data Transfer}
FUNCTION TScanner.Obtain: "TMember"; CONCEPTUAL; {Return previous member (redundant right after
Scan)}
FUNCTION TScanner.Scan(VAR member: "TMember"): BOOLEAN; CONCEPTUAL; {Return next & advance past it}
{Editing}
PROCEDURE TScanner.Append(member: "TMember"); CONCEPTUAL;
PROCEDURE TScanner.Delete; CONCEPTUAL;
PROCEDURE TScanner.DeleteRest; CONCEPTUAL;
PROCEDURE TScanner.Replace(member: "TMember"); CONCEPTUAL;

{Add a new member after position, scan


past it}
{Delete previous member and adjust
position}
{Delete everything after SELF.position}
{Replace previous member and maintain

Apple Lisa ToolKit 3.0 Source Code Listing -- 570 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

position}
END CONCEPTUAL METHODS *)
END;
TListScanner = SUBCLASS OF TScanner
{Variables}
{Creation and Destruction}
FUNCTION TListScanner.CREATE(object: TObject; itsList: TList; itsInitialPosition: LONGINT;
itsScanDirection: TScanDirection): TListScanner;
PROCEDURE TListScanner.Free; OVERRIDE;
{Traversal}
FUNCTION TListScanner.Obtain: TObject; DEFAULT; {Return previous member (redundant right after Scan)}
FUNCTION TListScanner.Scan(VAR nextObject: TObject): BOOLEAN; DEFAULT;{Return next, advance past it}
{Editing}
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

TListScanner.Append(object: TObject); DEFAULT;


{Add object after position, scan past it}
TListScanner.Delete(freeOld: BOOLEAN); DEFAULT; {Delete previous object, adjust position}
TListScanner.DeleteRest(freeOld: BOOLEAN); DEFAULT; {Delete all objects after position}
TListScanner.Replace(object: TObject; freeOld: BOOLEAN); DEFAULT;
{Replace previous}

END;
TArrayScanner = SUBCLASS OF TScanner
{Variables}
{Creation and Destruction}
FUNCTION TArrayScanner.CREATE(object: TObject; itsArray: TArray; itsInitialPosition: LONGINT;
itsScanDirection: TScanDirection): TArrayScanner;
PROCEDURE TArrayScanner.Free; OVERRIDE;
{Traversal}
FUNCTION TArrayScanner.Obtain: Ptr; DEFAULT; {Return previous member (redundant right after Scan)}
FUNCTION TArrayScanner.Scan(VAR pNextRecord: Ptr): BOOLEAN; DEFAULT; {Return next & advance past it}
{Editing}
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

TArrayScanner.Append(pRecord: Ptr); DEFAULT; {Add a new record after position, scan past it}
TArrayScanner.Delete; DEFAULT;
{Delete previous record and adjust position}
TArrayScanner.DeleteRest; DEFAULT;
{Delete all records after position}
TArrayScanner.Replace(pRecord: Ptr); DEFAULT;{Replace previous record and maintain position}

END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 571 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

TStringScanner = SUBCLASS OF TScanner


{Variables}
actual: LONGINT;

{no. bytes last xfered}

{Creation and Destruction}


FUNCTION TStringScanner.CREATE(object: TObject; itsString: TString; itsInitialPosition: LONGINT;
itsScanDirection: TScanDirection): TStringScanner;
PROCEDURE TStringScanner.Free; OVERRIDE;
{Traversal}
FUNCTION TStringScanner.Obtain: CHAR; DEFAULT; {Return previous member (redundant right after Scan)}
FUNCTION TStringScanner.Scan(VAR nextChar: CHAR): BOOLEAN; DEFAULT;
{Return next & advance past it}
{Editing}
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

TStringScanner.Append(character: CHAR); DEFAULT; {Add char after position, scan past it}
TStringScanner.Delete; DEFAULT;
{Delete previous char, adjust position}
TStringScanner.DeleteRest; DEFAULT;
{Delete all chars after position}
TStringScanner.Replace(character: CHAR); DEFAULT;{Replace previous char, maintain position}

{Typed Sequential Data Transfer: characters are read/written from left to right regardless of increment}
FUNCTION TStringScanner.ReadArray(heap: THeap; bytesPerRecord: INTEGER): TArray; {reads size first}
FUNCTION TStringScanner.ReadNumber(numBytes: SizeOfNumber): LONGINT; {iff numBytes is even
then signed}
FUNCTION TStringScanner.ReadObject(heap: THeap): TObject;
{tells object to Read(SELF)}
PROCEDURE TStringScanner.WriteArray(a: TArray); {inverse of ReadArray: writes size but not
recordBytes}
PROCEDURE TStringScanner.WriteNumber(value: LONGINT; numBytes: SizeOfNumber);{does not write size}
PROCEDURE TStringScanner.WriteObject(object: TObject); {tells object to Write(SELF)}
PROCEDURE TStringScanner.XferContiguous(whichWay: xReadWrite; collection: TCollection);
{xfers the size and members, non-recursively; xRead appends what it reads}
PROCEDURE TStringScanner.XferFields(whichWay: xReadWrite; object: TObject); {xfers all but the class}
PROCEDURE TStringScanner.XferPString(whichWay: xReadWrite; pStr: TPString); {it better be long enough}
{Untyped Data Transfer: characters are read/written from left to right regardless of increment}
PROCEDURE TStringScanner.XferSequential(whichWay: xReadWrite; pFirst: Ptr; numBytes:
LONGINT); DEFAULT;
PROCEDURE TStringScanner.XferRandom(whichWay: xReadWrite; pFirst: Ptr; numBytes: LONGINT;
mode: TIOMode; offset: LONGINT); DEFAULT;
END;
TFileScanner = SUBCLASS OF TStringScanner
{Variables}
accesses:
refnum:
error:

TAccesses;
INTEGER;
INTEGER;

{EOF is not an error}

{[fRead, fWrite, fAppend, fPrivate]}


{OS file refnum, or -1 if not open now}
{first error (or warning if no error) encountered}

Apple Lisa ToolKit 3.0 Source Code Listing -- 572 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

{Creation and Destruction}


FUNCTION TFileScanner.CREATE(object: TObject; itsFile: TFile; manip: TAccesses): TFileScanner;
PROCEDURE TFileScanner.FreeObject; OVERRIDE;
{also closes the OS file}
PROCEDURE TFileScanner.Free; OVERRIDE;
{if the last scanner, frees the TFile, too}
{Close and Reopen}
PROCEDURE TFileScanner.Close; OVERRIDE;
PROCEDURE TFileScanner.Open; OVERRIDE;
{Slack Control}
PROCEDURE TFileScanner.Allocate(slack: LONGINT); OVERRIDE; {Get slack DIV pageSize unused disk pages}
PROCEDURE TFileScanner.Compact; OVERRIDE;
{Return unused disk pages to free space}
{Positioning}
PROCEDURE TFileScanner.Seek(newPosition: LONGINT); OVERRIDE;
PROCEDURE TFileScanner.Skip(deltaPos: LONGINT); OVERRIDE;
{Traversal}
FUNCTION TFileScanner.Obtain: CHAR; OVERRIDE; {Return previous member (redundant right after Scan)}
FUNCTION TFileScanner.Scan(VAR nextChar: CHAR): BOOLEAN; OVERRIDE;
{Return next & advance past it}
{Editing}
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

TFileScanner.Append(character: CHAR); OVERRIDE; {Acts like: Replace; Skip(1)}


TFileScanner.Delete; OVERRIDE;
{Acts like: Skip(-1)}
TFileScanner.DeleteRest; OVERRIDE;
{Shorten file size to SELF.position}
TFileScanner.Replace(character: CHAR); OVERRIDE;{Replace previous member and maintain
position}

{Untyped Data Transfer: characters are read/written from left to right regardless of increment}
PROCEDURE TFileScanner.XferSequential(whichWay: xReadWrite; pFirst: Ptr; numBytes: LONGINT); OVERRIDE;
PROCEDURE TFileScanner.XferRandom(whichWay: xReadWrite; pFirst: Ptr; numBytes: LONGINT;
mode: TIOMode; offset: LONGINT); OVERRIDE;
END;
{$IFC compatibleLists}
{Backward compatibility classes}
TDynamicArray = SUBCLASS OF TArray
ch: {UNPACKED} ARRAY [0..16370] OF CHAR;
FUNCTION TDynamicArray.CREATE(object: TObject; heap: THeap; bytesPerRecord: INTEGER;
initialSize: INTEGER): TDynamicArray;
FUNCTION TDynamicArray.NumRecords: INTEGER;
PROCEDURE TDynamicArray.BeSize(newSize: INTEGER);
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 573 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

TIndexList = SUBCLASS OF TList


elements: ARRAY[1..1] OF TObject;
FUNCTION TIndexList.CREATE(object: TObject; heap: THeap; initialSize: INTEGER): TIndexList;
FUNCTION TIndexList.numElements: INTEGER;
END;
TLinkList = SUBCLASS OF TList
FUNCTION TLinkList.CREATE(object: TObject; heap: THeap): TLinkList;
FUNCTION TLinkList.numElements: INTEGER;
END;
TBlockList = SUBCLASS OF TList
FUNCTION TBlockList.CREATE(object: TObject; heap: THeap; itsMinBlockSize: INTEGER): TBlockList;
FUNCTION TBlockList.numElements: INTEGER;
END;
TFileStream = SUBCLASS OF TFileScanner
FUNCTION TFileStream.CREATE(object: TObject; heap: THeap; path: S255; manip: TAccesses): TFileStream;
FUNCTION TFileStream.Size: LONGINT;
END;
{$ENDC}
VAR
mainDsRefnum:
mainHeap:
mainLdsn:
fCheckIndices:

INTEGER;
THeap;
INTEGER;
BOOLEAN;

{refnum of the process data segment}


{heap of the process}
{ldsn of the process data segment}

onDesktop:
wmIsInitialized:
isInitialized:
amDying:

BOOLEAN;
BOOLEAN;
BOOLEAN;
BOOLEAN;

{Is there a DM (Desktop Manager) to talk to?}


{Has OpenWM been done?}
{Iff TRUE, shouldn't tell DM initFailed any more}
{Iff TRUE, I have called ImDying}

myWorld:

TClassWorld;

{For Version Conversion}

{ Variables for Debugging }


indentTrace:
INTEGER;
{ stuff for the intelligent output }
currXPos:
INTEGER;
outputIndent:
INTEGER;
{$IFC fTrace}
{ TRUE if we want to inhibit tracing; client must save and restore its value;

Apple Lisa ToolKit 3.0 Source Code Listing -- 574 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

normally this is needed only if you override the Debug method }


fDebugRecursion:
BOOLEAN;
{ how often to call KeyPress from debugger to check for user interrupt }
keyPresLimit:
INTEGER;
{$ENDC}
{$IFC fCheckHeap}
FUNCTION CountHeap(heap: THeap): INTEGER;
{$ENDC}
FUNCTION
FUNCTION

Min(i, j: LONGINT): LONGINT;


Max(i, j: LONGINT): LONGINT;

PROCEDURE XferLeft(source, dest: Ptr; nBytes: INTEGER);


PROCEDURE XferRight(source, dest: Ptr; nBytes: INTEGER);
FUNCTION EqualBytes(source, dest: Ptr; nBytes: INTEGER): BOOLEAN;
FUNCTION
FUNCTION
FUNCTION

LIntAndLInt(i, j: LONGINT): LONGINT;


LIntOrLInt(i, j: LONGINT): LONGINT;
LIntXorLInt(i, j: LONGINT): LONGINT;

FUNCTION
FUNCTION
PROCEDURE
FUNCTION
PROCEDURE
PROCEDURE

NewObject(heap: THeap; itsClass: TClass): TObject;


NewDynObject(heap: THeap; itsClass: TClass; dynBytes: INTEGER): TObject;
ResizeDynObject(object: TObject; newTotalBytes: INTEGER);
NewOrRecycledObject(heap: THeap; itsClass: TClass; VAR chainHead: TObject): TObject;
RecycleObject(object: TObject; VAR chainHead: TObject);
Free(object: TObject);

{$IFC compatibleLists}
{Backward compatibility procedures}
FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
FUNCTION
{$ENDC}

SubObject(super: TObject; itsClass: TClass): TObject;


FileDelete(path: S255);
FileLookup(VAR error: INTEGER; path: S255);
FileRename(oldPath, newPath: S255);
FileModified(path: S255): LONGINT;

FUNCTION
FUNCTION

Superclass(class: TClass): TClass;


ClassDescendsFrom(descendant, ancestor: TClass): BOOLEAN;

PROCEDURE NameOfClass(class: TClass; VAR className: TClassName);


FUNCTION SizeOfClass(class: TClass): INTEGER;
{The next 3 can only be called from a class-init block or a subroutine of a class-init block}
PROCEDURE UnitAuthor(companyAndAuthor: TAuthorName);
{required once per unit}
PROCEDURE ClassAuthor(companyAndAuthor: TAuthorName; classAlias: TClassName);
{optional}

Apple Lisa ToolKit 3.0 Source Code Listing -- 575 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

PROCEDURE ClassVersion(itsVersion, oldestItCanRead: Byte);


FUNCTION

{optional}

ValidObject(hndl: Handle): BOOLEAN;

PROCEDURE ABCBreak(s: S255; errCode: LONGINT);


PROCEDURE ClascalError(error: INTEGER);
{Some useful procedures; we should decide once and for all whether or not to keep any or all of these}
PROCEDURE LIntToHex(decNumber: LONGINT; hexNumber: TPString);
{NOTE: hexNumber must be >= 8 characters, regardless of size of decNumber}
PROCEDURE LIntToStr(decNumber: LONGINT; str: TPString);
{NOTE: str must be >= 11 characters (sign + 10 digits), regardless of size of decNumber}
PROCEDURE IntToStr(decNumber: INTEGER; str: TPString);
{NOTE: str must be >= 6 characters (sign + 5 digits), regardless of size of decNumber}
PROCEDURE HexStrToLInt(hexString: TPString; VAR decNumber: LONGINT; VAR result: TConvResult);
PROCEDURE StrToLInt(str: TPString; VAR decNumber: LONGINT; VAR result: TConvResult);
PROCEDURE StrToInt(str: TPString; VAR decNumber: INTEGER; VAR result: TConvResult);
PROCEDURE TrimBlanks(str: TPString);
FUNCTION CharUpperCased(ch: CHAR): CHAR;
PROCEDURE StrUpperCased(str: TPString);
PROCEDURE SplitFilePath(VAR fullPath, itsCatalog, itsFilePart: TFilePath);
{fullPath = CONCAT(itsCatalog, itsFilePart}
PROCEDURE LatestError(newError: INTEGER; VAR previousError: INTEGER);
{This is used to handle error codes returned by multiple operations, so that you end up with
the first error number or warning number (error code < 0) if there was no error.
You should pass in the latest error as 'newError' and the variable that is to be the final
error code as 'previousError'. Here is the actual code of LatestError:

IF ((newError > 0) AND (previousError <= 0) OR


(newError < 0) AND (previousError = 0)) THEN
previousError := newError

{$IFC fDbgObject}
PROCEDURE EntDebugger(inputStr, enterReason: S255);
PROCEDURE DumpVar(pVariable: Ptr; nameAndType: S255); {used mainly by TProcess.DumpGlobals}
PROCEDURE WrStr(str: S255);
{ write a string with wrap-around }
PROCEDURE WrLn;
{ goto next line, and output indent }
{$IFC fDebugMethods}
PROCEDURE WrObj(object: TObject; numLevels: INTEGER; memberTypeStr: S255);
{$ENDC}
{$ENDC}
{$IFC fDbgObject OR fDebugMethods}

Apple Lisa ToolKit 3.0 Source Code Listing -- 576 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

FUNCTION CheckKeyPress(routine: S255): BOOLEAN;


{$ENDC}
FUNCTION
FUNCTION

NewHeap(VAR error: INTEGER; heapStart, numBytes: LONGINT; numObjects: INTEGER): THeap;


MakeDataSegment(VAR error, dsRefnum: INTEGER; firstTryVolume, thenTryVolume: TFilePath;
ldsn, memBytes, diskBytes: INTEGER): LONGINT;

PROCEDURE SetHeap(heap: THeap);


PROCEDURE GetHeap(VAR heap: THeap);
{We can't USE Unit Storage because of type name conflicts (Ptr, Handle, ProcPtr)}
FUNCTION NeedConversion(exClassWorld: TClassWorld; VAR olderVersion, newerVersion: BOOLEAN): BOOLEAN;
PROCEDURE ConvertHeap(heap: THeap; exClassWorld: TClassWorld);
PROCEDURE MarkHeap(heap: THeap; mpAddress: LONGINT);
PROCEDURE SweepHeap(heap: THeap; report: BOOLEAN);
{$IFC fTrace}
PROCEDURE BP(MyTraceLevel:integer);
{Trace entry to method and write SELF (unless CREATE, Debug, or FreeObject)}
PROCEDURE EP; {Trace entry from method and write SELF (unless CREATE, Debug, FreeObject, or Free)}
{$ENDC}
(* ========================

RULES FOR WRITING A Fields FUNCTION

====================

This function must be defined in every class until the compiler generates this info automatically!
PROCEDURE TWhatever.Fields{(PROCEDURE Field(nameAndType: S255))};
BEGIN {THE FIELDS MUST BE LISTED IN DECLARED ORDER, NONE OMITTED AND NONE ADDED}
{Tell the superclass first (unnecessary if it is TObject)}
SUPERSELF.Fields(Field);
{The following type names are recognized by the parser}
Field('flag: BOOLEAN');
Field('coCode: Byte');
Field('inputChar: CHAR');
Field('version: INTEGER');
Field('width: LONGINT');
Field('viewLPt: LPoint');
Field('boundLRect: LRect');
Field('size: Point');
Field('ptr: Ptr');
Field('boundRect: Rect');
Field('someName: STRING[100]');
{If the last field is a Byte or a BOOLEAN, force padding to a word boundary by...
Field('');
{Every Registered Class name is recognized}

Apple Lisa ToolKit 3.0 Source Code Listing -- 577 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942

*)

Field('miscObj: TObject');
Field('myPanel: TPanel');
Field('mySel: TMySelection');
Field('appSpecific: TAppSpecific');
{You may report more than one field in a single call to reduce code space}
Field('boundLRect: LRect; size: Point; ptr: Ptr; mySel: TMySelection');
{Unpacked invariant RECORDs are recognized}
Field('info: RECORD version: INTEGER; size: Point END');
{If the record has variants, select among them before calling Field()}
CASE SELF.variant OF
flavor1: Field('RECORD version: INTEGER; size: Point END');
flavor2: Field('RECORD viewLPt: LPoint END');
END;
{Unpacked ARRAYs with literal bounds are recognized}
Field('desc: ARRAY [1..99] OF RECORD version: INTEGER; id: ARRAY [1..2] OF CHAR END');
{Other constructs and type names are NOT recognized; substitute one of the above forms}
{As a last resort, use ARRAY [1..SIZEOF(SELF.fieldName)] OF Byte}
END;

IMPLEMENTATION
{$I LIBTK/UOBJECT2.text}
{$I LIBTK/UOBJECT3.text}
{$I LIBTK/UOBJECT4.text}
(**********
{$I UOBJECT2.text}
{$I UOBJECT3.text}
{$I UOBJECT4.text}
**********)

{Objects, Classes, Streams, and Resources}


{Arrays and Lists}
{Debugger}

{Objects, Classes, Streams, and Resources}


{Arrays and Lists}
{Debugger}

END.

End of File -- Lines: 942 Characters: 42428

Apple Lisa ToolKit 3.0 Source Code Listing -- 578 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UOBJECT2.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{INCLUDE FILE UOBJECT3 -- OBJECTS, CLASSES, RESOURCES, AND STREAMS}


{Copyright 1983, 1984, Apple Computer, Inc.}
{changed 05/01 1503 Changes to allow people to use Clascal on the Workshop}
{Segments: SgCLAini(tialize and Terminate), SgCLAres(ident), SgCLAc(o)ld, SgCLAdbg}
{$%+}
{$IFC fRngObject}
{$R+}
{$ELSEC}
{$R-}
{$ENDC}
{$IFC fSymObject}
{$D+}
{$ELSEC}
{$D-}
{$ENDC}
CONST
trLevMemory = 60;
{ The std value of keyPresLimit, overridable by chaging the variable keyPresLimit }
stdKeyPresLimit = 10;
maxTallies = 3000; { < 32K DIV SIZEOF(TTally) }
TYPE
S16 = STRING[16];
TPS8 = ^S8;
TPByte = ^Byte;
TPAOC = PACKED ARRAY[1..32767] OF CHAR;
TpPAOC = ^TPAOC;
TppINTEGER = ^TpINTEGER;
TPObject = ^TObject;
TPPathName = ^PathName;
TPEName = ^E_Name;

Apple Lisa ToolKit 3.0 Source Code Listing -- 579 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

TRecycleChain = RECORD
classPtr:
TClass;
chainLink: TObject;
END;
TPRecycleChain = ^TRecycleChain;
THRecycleChain = ^TPRecycleChain;
UnsignedByte = 0..255;
TTypeCode = (yBoolean, yHexByte, yByte, yChar, yHexInteger, yInteger, yLongInt, yLongReal,
yLPoint, yLRect, yObject, yPoint, yPtr, yReal, yRect, yString, yArray);
{We can't USE Unit UDRAW because it USES us; these are needed in EXTERNAL decls below for KitBug}
FakePoint = RECORD v, h: INTEGER END;
FakeRect = RECORD top, left, bottom, right: INTEGER END;
FakeLPoint = RECORD v, h: LONGINT END;
FakeLRect = RECORD top, left, bottom, right: LONGINT END;
{$IFC LibraryVersion < 20}
{ The following definitions come from PasLibCall and PPasLibC; if those files change, these
will have to be changed too !!!! }
dsProcCode = (dsResProg, dsSoftPwbtn, dsPrintDev, dsSetGPrefix, dsEnbDisk);
dsProcParam = record
case ProcCode : dsProcCode of
dsResProg : (RProcessId : longint);
dsSoftPwbtn : (SPButton : boolean);
dsPrintDev
: (PrDevice : e_name);
dsSetGPrefix : (errnum : INTEGER;
prefix : pathname);
dsEnbDisk
: (DiskEvent : boolean);
end;
{$ENDC}
{Tallying}
TTally = RECORD
count:
microseconds:
epPC:
END;

INTEGER;
LONGINT;
LONGINT;

TTallyArray = ARRAY [1..maxTallies] OF TTally;


TDTallyArray = RECORD
header: TArrayHeader;
recs:
TTallyArray;

{name "recs" must be different from "records" in THIdxArray}

Apple Lisa ToolKit 3.0 Source Code Listing -- 580 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

END;
TPDTallyArray = ^TDTallyArray;
THTallies = ^TPDTallyArray;

{An alias for a TArray of TTally}

{Version Conversion Types}


TDClasses = RECORD
header:
TArrayHeader;
records:
TClassArray;
END;
TPDClasses = ^TDClasses;
THClasses = ^TPDClasses;

{An alias for a TArray of TClassInfo}

TDSTables = RECORD
header:
TArrayHeader;
records:
TSTableArray;
END;
TPDSTables = ^TDSTables;
THSTables = ^TPDSTables;

{An alias for a TArray of TPSliceTable}

TDAuthorArray = RECORD
header:
TArrayHeader;
records:
TAuthorArray;
END;
TPDAuthorArray = ^TDAuthorArray;
THAuthors = ^TPDAuthorArray;
{An alias for a TArray of TA32 (company and author)}
TDAliasArray = RECORD
header:
TArrayHeader;
records:
TAliasArray;
END;
TPDAliasArray = ^TDAliasArray;
THAliases = ^TPDAliasArray;
{An alias for a TArray of TA8 (class alias)}
TIdxArray = ARRAY [1..16000] OF INTEGER;
TDIdxArray = RECORD
header:
TArrayHeader;
records:
TIdxArray;
END;
TPDIdxArray = ^TDIdxArray;
THIdxArray = ^TPDIdxArray;

{An alias for a TArray of INTEGER}

TWorld = RECORD
hExClasses:
hExSTables:
hExAuthors:
hExAliases:

{hExClasses^^
{hExSTables^^
{hExAuthors^^
{hExAliases^^

THClasses;
THSTables;
THAuthors;
THAliases;

.records[i]
.records[i]
.records[i]
.records[i]

is
is
is
is

the
the
the
the

TClassInfo of class no. i}


TPSliceTable of class no. i}
i'th companyAndAuthor encountered}
i'th classAlias encountered}

Apple Lisa ToolKit 3.0 Source Code Listing -- 581 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

END;
VAR
hMyClasses:
hMySTables:
hMyAuthors:
hMyAliases:
hMyHashName:

THClasses;
THSTables;
THAuthors;
THAliases;
THIdxArray;

{hMyClasses^^ .records[i] is the TClassInfo of class no. i}


{hMySTables^^ .records[i] is the TPSliceTable of class no. i}
{hMyAuthors^^ .records[i] is the i'th companyAndAuthor encountered}
{hMyAliases^^ .records[i] is the i'th classAlias encountered}
{hMyHashName^^.records[hashIndex] is 0 or the index i of a class}

cObject:

TClass;

{The TClass of TObject}

{$IFC compatibleLists} {For TDynamicArray.Class and TIndexList.Class}


cArray:
TClass;
{The TClass of TArray}
cList:
TClass;
{The TClass of TList}
{$ENDC}
availListScanner:
TListScanner;
{Heads of preallocated Scanner chains}
availArrayScanner: TArrayScanner;
availStringScanner: TStringScanner;
{$IFC fTrace}
fTraceEnabled, fTraceSelf, fTraceClass: BOOLEAN;
{ Current method nesting level }
tabLevel:
INTEGER;
{ So EP calls don't have to pass a trace level parameter, it is saved here on the corresponding
BP call. }
traceLevels:
ARRAY [0..trLevMemory] OF INTEGER;
{indexed by tabLevel}
{ So EP can check for matching BP. }
traceFrames:
ARRAY [0..trLevMemory] OF LONGINT;
{indexed by tabLevel}
{ To time procedure durations. }
traceTimes:
ARRAY [0..trLevMemory] OF LONGINT;
{indexed by tabLevel}
{ kpcntr counts number of times AKeyPress has been called and only calls KeyPress every
keyPresLimit times for performance reasons. }
kpcntr:
INTEGER;
{ TRUE IF returning to main screen after leaving debugger }
returnToMain:
BOOLEAN;
{ traceCount of 0 -> no tracing, traceCount of 1 means you have traced through defTraceCount methods
so time to enter the debugger. }
traceCount, defTraceCount: INTEGER;
{ Set with the Level command }
curTraceLevel:
INTEGER;
{ Break when you come to one of these methods }
breakMethods:
ARRAY [1..maxBreaks] OF RECORD
brClass, brMethod: S8;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 582 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

{ The number of valid break methods currently active }


breakMCount:
INTEGER;
{ TRUE IF showing the debugger prompt }
showPrompt:
BOOLEAN;
{ TRUE if BP is tallying procedure calls }
tallyingCalls:
BOOLEAN;
{ A hash table if tallyingCalls }
tallies:
THTallies;
(*
(*

tallyOverhead:
debugTime:
startTime:
stopTime:
segNames:

LONGINT;
{usual time spent calling and returning from BP, EP, or Tally} *)
LONGINT;
{cumulative time spend in BP and EP since tallying started} *)
LONGINT;
{when tallying started}
LONGINT;
{when tallying last paused}
TArray{[1..127] OF S8};

{ Used to avoid break point checking on methods we have already checked }


lastBpPc:
LONGINT;
lastEpPc:
LONGINT;
{$ENDC}
{ ==================================== EXTERNAL AND FORWARD PROCEDURES ==================================== }
{$IFC LibraryVersion < 20}
{So we don't need to use PasLibCall or PPasLibC; this may have to change if those .OBJ files change !!!!}
PROCEDURE OutputRedirect (VAR errnum : INTEGER; VAR outfile : pathname; stopoutput : BOOLEAN); EXTERNAL;
PROCEDURE DSPaslibCall (VAR ProcParam : dsProcParam); EXTERNAL;
{$ENDC}
{We can't USE Unit UDRAW because it USES us}
PROCEDURE InitErrorAbort(error: INTEGER); EXTERNAL;
PROCEDURE TrmntExceptionHandler; EXTERNAL;
{$IFC fDbgObject}
FUNCTION BindHeap(activeVsClip, doBind: BOOLEAN): THeap; EXTERNAL;
{$ENDC}
{We can't USE Unit UDRAW because it USES us}
PROCEDURE PointToStr(pt: FakePoint; str: TPstring); EXTERNAL;
PROCEDURE RectToStr(r: FakeRect; str: TPstring); EXTERNAL;
PROCEDURE LPointToStr(pt: FakeLPoint; str: TPstring); EXTERNAL;
PROCEDURE LRectToStr(r: FakeLRect; str: TPstring); EXTERNAL;
{We can't USE Unit Storage because of type name conflicts (Ptr, Handle, ProcPtr)}
PROCEDURE SetHeap(heap: THeap); EXTERNAL;
PROCEDURE GetHeap(VAR heap: THeap); EXTERNAL;

Apple Lisa ToolKit 3.0 Source Code Listing -- 583 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

{We can't USE Unit QuickDraw because we can't use Storage; nor WM without using QuickDraw; nor UDraw, so...}
PROCEDURE InitQDWM; EXTERNAL; {in UDraw}
PROCEDURE DrawText(textBuf: TpINTEGER; firstByte, byteCount: INTEGER); EXTERNAL;
FUNCTION TextWidth(textBuf: TpINTEGER; firstByte, byteCount: INTEGER): INTEGER; EXTERNAL;
PROCEDURE DrawLText(textBuf: TpINTEGER; firstByte, byteCount: INTEGER); EXTERNAL;
{The rest are assembler routines in XFER and ARE declared in the INTERFACE of this unit}
FUNCTION LIntAndLInt(i, j: LONGINT): LONGINT; EXTERNAL;
FUNCTION LIntOrLInt(i, j: LONGINT): LONGINT; EXTERNAL;
FUNCTION LIntXorLInt(i, j: LONGINT): LONGINT; EXTERNAL;
PROCEDURE XferLeft(source, dest: Ptr; nBytes: INTEGER); EXTERNAL;
PROCEDURE XferRight(source, dest: Ptr; nBytes: INTEGER); EXTERNAL;
FUNCTION EqualBytes(source, dest: Ptr; nBytes: INTEGER): BOOLEAN; EXTERNAL;
{The rest are assembler routines in CLASLIB and are NOT declared in the INTERFACE of this unit}
FUNCTION %_GetA5: LONGINT; EXTERNAL;
PROCEDURE %_GoLisabug; EXTERNAL;
{Forward}
{$IFC fDebugMethods}
PROCEDURE WriteDRecord(numLevels: INTEGER; hDRecord: Handle; posInDRecord: INTEGER;
PROCEDURE SupplyFields(PROCEDURE Field(nameAndType: S255))); FORWARD;
{$ENDC}
{ ====================================== COLD UTILITIES ====================================== }

{$S SgCLAcld}
FUNCTION MakeIdxArray(numElements: INTEGER; sparse: BOOLEAN): THIdxArray;
VAR anArray:
TArray;
i:
INTEGER;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
IF sparse THEN
numElements := (((numElements + 6) * 4) DIV 3);
anArray := TArray.CREATE(NIL, mainHeap, numElements, SIZEOF(INTEGER));
anArray.InsNullsAt(1, numElements);
MakeIdxArray := THIdxArray(anArray);
(*****
hArray := THIdxArray(TDynamicArray.CREATE(NIL, mainHeap, SIZEOF(INTEGER), numElements));
FOR i := 1 TO numElements DO
hArray^^.records[i] := 0;
MakeIdxArray := hArray;
*****)

Apple Lisa ToolKit 3.0 Source Code Listing -- 584 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

END;
{$S SgCLAcld}
PROCEDURE EachObject(heap: THeap; PROCEDURE DoToObject(object: TObject));
VAR hz:
THz;
{ The heap as a UnitHz type }
mpFirst:
LONGINT;
{ The address of the first master pointer }
mpLast:
LONGINT;
{ The address of the last master pointer }
mpIndex:
LONGINT;
{ An index variable used for stepping through the master pointers }
mp:
LONGINT;
{ the value of the master pointer at mpIndex }
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
hz := THz(heap);
mpFirst := ORD(@hz^.argpPool);
mpLast := mpFirst + 4 * ((hz^.ipPoolMac) - 1);
{Step through each master pointer in heap}
mpIndex := mpFirst;
WHILE mpIndex <= mpLast DO
BEGIN
mp := ORD(Handle(mpIndex)^);
IF NOT (((mp >= mpFirst) AND (mp <= mpLast)) OR (mp = 1)) THEN {not on the free list}
DoToObject(POINTER(ORD(mpIndex))); { Pass it to DoToObject as a TObject, but don't coerce
directly to a TObject because of run-time checking. }
mpIndex := mpIndex + 4;
{ advance to the next master pointer }
END;
END;
{ ====================================== HOT UTILITIES ====================================== }

{$S sHotUtil}
FUNCTION Min(i, j: LONGINT): LONGINT;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
IF i < j THEN
Min := i
ELSE
Min := j;
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sHotUtil}

Apple Lisa ToolKit 3.0 Source Code Listing -- 585 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

FUNCTION Max(i, j: LONGINT): LONGINT;


BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
IF i > j THEN
Max := i
ELSE
Max := j;
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sHotUtil}
PROCEDURE LatestError(newError: INTEGER; VAR previousError: INTEGER);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
IF ((newError > 0) AND (previousError <= 0) OR
(newError < 0) AND (previousError = 0)) THEN
previousError := newError;
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sHotUtil}
FUNCTION ClassPtr(hndl: Handle): TClass;
VAR stp: RECORD
CASE INTEGER OF
1: (asLong: LONGINT);
2: (asBytes: PACKED ARRAY [0..3] OF TByte);
3: (asClass: TClass);
END;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
stp.asLong := hndl^^;
stp.asBytes[0] := 0;
ClassPtr := stp.asClass;
END;
{$S sUtil}
PROCEDURE LIntToHex(decNumber: LONGINT; hexNumber: TPString);
{NOTE: hexNumber must be >= 8 characters, regardless of size of decNumber}
(*
(*
(*
(*
(*

This PROCEDURE accepts a binary LONGINT, decNumber, and returns the equivalent hexadecimal *)
number by means of the output parameter hexNumber. Note that if the equivalent hexadecimal number is *)
of a sufficiently small magnitude that it does not require all of the digits in the hex field to be *)
expressed (e.g. if 8 digits are allocated in the hex field and the hex number if 58A7, which is only *)
4 digits), then the hexadecimal number will be right-justified with leading zeros to pad the field. So, *)

Apple Lisa ToolKit 3.0 Source Code Listing -- 586 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

(* for example, 58A7 will be returned as 000058A7 if 8 digits are allocated for hexadecimal numbers via the *)
(* constant hexFieldSize.
To change the number of digits in the hex field, change the constant *)
(* hexFieldSize. *)
{NOTE: many users of LIntToHex pass in a pointer to a variable declared as S8; therefore, it is important
that LIntToHex not return more than 8 digits }
CONST
hexFieldSize = 8;

(* the number of digits which are to appear in a hexadecimal field; leading zeros
*)
(* may be used to pad small hexadecimal numbers (e.g. if hexFieldSize is 8, then the
(* hex number FA9 would appear as 00000FA9) *)

VAR hexDigits: S16;


(* a list which is to contain all hexadecimal digits *)
i:
1..hexFieldSize;
(* a variable for indexing individual digits of the hex number's field *)
fudge:
INTEGER;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
hexDigits := '0123456789ABCDEF';
(* Initialize the list of hexadecimal digits *)
{$R-}hexNumber^[0] := CHR(hexFieldSize); {$IFC fRngObject}{$R+}{$ENDC}
IF decNumber < 0 THEN
BEGIN
fudge := 16;
{reverse hexDigit indexes}
decNumber := decNumber + 1; {correct for two's complement}
END
ELSE
fudge := 1;
FOR i := hexFieldSize DOWNTO 1 DO
BEGIN
hexNumber^[i] := hexDigits[(decNumber MOD 16) + fudge];
decNumber := decNumber DIV 16;
END;
{$IFC fMaxTrace}EP;{$ENDC}
END;
(* LIntToHex *)
{$S sUtil}
PROCEDURE LIntToStr(decNumber: LONGINT; str: TPString);
{NOTE: str must be >= 11 characters, regardless of size of number}
VAR neg : BOOLEAN;
pos : INTEGER;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$R-} str^[0] := CHR(11); {$IFC fRngObject} {$R+} {$ENDC}
pos := 11;
neg := (decNumber < 0);

Apple Lisa ToolKit 3.0 Source Code Listing -- 587 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

decNumber := ABS (decNumber);


REPEAT
str^[pos] := CHR(ORD('0') + (decNumber MOD 10));
pos := pos - 1;
decNumber := decNumber DIV 10;
UNTIL decNumber = 0;
IF neg THEN
BEGIN
str^[pos] := '-';
pos := pos - 1;
END;
DELETE (str^, 1, pos);
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sUtil}
PROCEDURE IntToStr(decNumber: INTEGER; str: TPString);
{NOTE: str must be >= 6 characters (sign + 5 digits), regardless of size of decNumber}
VAR s11:
STRING[11];
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
LIntToStr(decNumber, @s11);
XferLeft(Ptr(@s11), Ptr(str), Length(s11) + 1); { str length + 1 size byte }
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sUtil}
PROCEDURE HexStrToLInt(hexString: TPString; VAR decNumber: LONGINT; VAR result: TConvResult);
(*
(*
(*
(*
(*
(*
(*
(*

This PROCEDURE accepts a STRING of hexadecimal digits, hexString, and returns a long-INTEGER decimal
equivalent by means of the variable parameter decNumber. Information concerning the acceptability of
the hexadecimal STRING is returned via the variable parameter result.
Note that this PROCEDURE ignores any leading or trailing blanks which may be present in the given
hexString, and the presence of lower-case hexadecimal digits in the hex STRING does not adversely
affect conversion. Also, if the first non-blank character of the STRING is a dollar sign, then that
dollar sign is ignored and not considered during conversion (it is, effectively, deleted from the
STRING).

VAR numDigits:
digit:
i:
digitValue:
hexDigits:

0..255;
CHAR;
INTEGER;
INTEGER;
S16;

(* The number of digits in the hex STRING *)


(* index variable *)
(* index variable *)
(* an array which is to contain a list of hexadecimal digits *)

Apple Lisa ToolKit 3.0 Source Code Listing -- 588 of 1012

*)
*)
*)
*)
*)
*)
*)
*)

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

BEGIN
(* HexStrToLInt *)
{$IFC fMaxTrace}BP(1);{$ENDC}
(* Delete any trailing blanks *)
TrimBlanks(POINTER(ORD(hexstring)));
{ Remove any leading zeros, except keep at least 1 digit; also, remove any leading $ }
IF Length(hexString^) > 0 THEN
WHILE ((Length(hexString^) > 1) AND (hexString^[1] = '0')) OR (hexString^[1] = '$') DO
Delete(hexString^, 1, 1);
numDigits := Length(hexString^);
decNumber := 0;
IF numDigits = 0 THEN
(* if the given hex STRING is empty... *)
result := cvNoNumber
ELSE
IF Length (hexString^) > 8 THEN (* if can't fit in LONGINT *)
result := cvOverflow
ELSE
result := cvValid;
(* innocent until proven guilty *)
FOR i := 1 TO numDigits DO
BEGIN
digit := hexString^[i];
IF digit IN ['0'..'9'] THEN
digitValue := ORD(digit) - ORD('0')
ELSE
IF digit IN ['A'..'F'] THEN
digitValue := ORD(digit) - ORD('A') + 10
ELSE
IF digit IN ['a'..'f'] THEN
digitValue := ORD(digit) - ORD('a') + 10
ELSE
BEGIN
digitValue := 0;
result := cvBadNumber;
END;
decNumber := decNumber * 16 + digitValue;
END;
{$IFC fMaxTrace}EP;{$ENDC}
END;
(* HexStrToLInt *)
{$S sUtil}
PROCEDURE StrToLInt(str: TPString; VAR decNumber: LONGINT; VAR result: TConvResult);
LABEL
1;

Apple Lisa ToolKit 3.0 Source Code Listing -- 589 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

VAR s:
S255;
pos:
INTEGER;
neg:
BOOLEAN;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
result := cvValid;
XferLeft(Ptr(str), Ptr(@s), Length(str^) + 1);
TrimBlanks(@s);
decNumber := 0;
neg := FALSE;
IF s='' THEN
result := cvNoNumber
ELSE IF (s[1]='-') OR (s[1]='+') THEN
BEGIN
neg := s[1] = '-';
Delete(s, 1, 1);
IF s='' THEN
result := cvBadNumber;
END;
pos := 1;
WHILE pos <= Length(s) DO
BEGIN
IF ('0' > s[pos]) OR (s[pos] > '9') THEN {invalid numeric character}
BEGIN
result := cvBadNumber;
GOTO 1;
END;
{check for overflow}
IF pos > 10 THEN {more than 10 digits guarantees an overflow}
BEGIN
result := cvOverflow;
GOTO 1;
END;
IF pos = 10 THEN
IF ORD(s[pos]) > ORD('7') THEN
IF decNumber > 214748363 THEN
BEGIN
result := cvOverflow;
GOTO 1;
END
ELSE
{ okay }
ELSE { 10th digit is 7 or less }

Apple Lisa ToolKit 3.0 Source Code Listing -- 590 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

IF decNumber > 214748364 THEN


BEGIN
result := cvOverflow;
GOTO 1;
END;
decNumber := (10 * decNumber) + (ORD(s[pos]) - ORD('0'));
pos := pos + 1;
END;

1:

IF neg THEN
decNumber := -decNumber;

{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sUtil}
PROCEDURE StrToInt(str: TPString; VAR decNumber: INTEGER; VAR result: TConvResult);
VAR l: LONGINT;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fDbgObject}
{$0V+} {make sure we don't screw up}
{$ENDC}
StrToLint(str, l, result);
IF result = cvValid THEN
IF (l < -MAXINT-1) OR (l > MAXINT) THEN
result := cvOverflow
ELSE
decNumber := INTEGER(l);
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sUtil}
PROCEDURE TrimBlanks(str: TPString);
LABEL
1, 10;
CONST
tabCh = CHR(9);
VAR i:

INTEGER;

BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
i := 1;

Apple Lisa ToolKit 3.0 Source Code Listing -- 591 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

WHILE i <= Length(str^) DO


BEGIN
IF str^[i] <> ' ' THEN
IF str^[i] <> tabCh THEN
BEGIN {delete all the leading stuff we have found}
Delete(str^, 1, i-1);
GOTO 1;
END;
i := i + 1;
END;
{ we fell thru -- either '' or all blanks or tabs }
str^ := '';
GOTO 10;
1:

10:

{now trim the trailing blanks}


i := Length(str^);
WHILE i > 0 DO
BEGIN
IF (str^[i] = ' ') OR (str^[i] = tabCh) THEN
Delete(str^, i, 1)
ELSE
GOTO 10;
i := i - 1;
END;

{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sUtil}
FUNCTION CharUpperCased(ch: CHAR): CHAR;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
CharUpperCased := ch;
IF 'a' <= ch THEN
IF ch <= 'z' THEN
CharUpperCased := CHR(ORD(ch) - 32);
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sUtil}
PROCEDURE StrUpperCase(str: TPString);
VAR i: INTEGER;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 592 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

i := Length(str^);
WHILE i > 0 DO
BEGIN
str^[i] := CharUpperCased(str^[i]);
i := i - 1;
END;
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sUtil}
PROCEDURE SplitFilePath(VAR fullPath, itsCatalog, itsFilePart: TFilePath);
LABEL
1;
VAR i: INTEGER;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
itsCatalog := '';
itsFilePart := fullPath;

1:

FOR i := Length(itsFilePart) DOWNTO 1 DO


IF itsFilePart[i] = '-' THEN
BEGIN
itsCatalog := COPY(itsFilePart, 1, i);
DELETE(itsFilePart, 1, i);
GOTO 1;
END;

{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE SetCp(object: TObject; itsClass: TClass);
VAR index: INTEGER;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
Handle(object)^^ := ORD(itsClass);
{Install slice table
index := CiOfCp(TPSliceTable(itsClass));
{Determine its class
IF index < 256 THEN
{If it will fit in a
{$R-}
TPByte(Handle(object)^)^ := index;
{...to speed version
{$IFC fRngObject}{$R+}{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
END;

pointer}
index}
byte, store it...}
conversion (cf ConvertHeap: FindClasses)}

{$S sStartup}
FUNCTION NewDynObject(heap: THeap; itsClass: TClass; dynBytes: INTEGER): TObject;
VAR nBytes: INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 593 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

object: TObject;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
nBytes := SizeOfCp(TPSliceTable(itsClass)) + dynBytes;
object := POINTER(ORD(HAllocate(THz(heap), nBytes)));
{TObject() won't work until after SetCp}
IF ORD(object) = ORD(hNIL) THEN
BEGIN
{$IFC fDbgObject}
WriteLn(CbOfHz(THz(heap)):1, ' bytes in the heap');
{$ENDC}
ABCBreak('NewObject: Heap full, can''t make an object of size', nBytes);
END;
SetCp(object, itsClass);
NewDynObject := object;
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sStartup}
FUNCTION NewObject(heap: THeap; itsClass: TClass): TObject;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
NewObject := NewDynObject(heap, itsClass, 0);
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE ResizeDynObject(object: TObject; newTotalBytes: INTEGER);
VAR i: INTEGER;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
IF (newTotalBytes < 0) OR (newTotalBytes > (MAXINT-20)) THEN
ABCBreak('New size must lie between 0 and 32K-20, not', newTotalBytes);
ChangeSizeH(THz(object.Heap), TH(object), newTotalBytes);
IF CbDataOfH(THz(object.Heap), TH(object)) < newTotalBytes THEN
ABCBreak('ResizeDynObject: Heap full, size can''t change to', newTotalBytes);
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$IFC compatibileLists}
FUNCTION SubObject(super: TObject; itsClass: TClass): TObject;
BEGIN
ResizeDynObject(super, SizeOfCp(TPSliceTable(itsClass)));
SetCP(super, itsClass);
SubObject := super;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 594 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

{$ENDC}
{$S sStartup}
FUNCTION NewOrRecycledObject(heap: THeap; itsClass: TClass; VAR chainHead: TObject): TObject;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
IF chainHead = NIL THEN
NewOrRecycledObject := NewObject(heap, itsClass)
ELSE
BEGIN
{$IFC fDbgObject}
IF (chainHead.Class <> itsClass) OR (chainHead.Heap <> heap) THEN
ABCBreak('NewOrRecycledObject: chainHead contains an alien object', ORD(chainHead));
{$ENDC}
NewOrRecycledObject := chainHead;
chainHead := THRecycleChain(chainHead)^^.chainLink;
END;
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE RecycleObject(object: TObject; VAR chainHead: TObject);
{$IFC fDbgObject}
VAR chainMember: TObject;
{$ENDC}
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fDbgObject}
IF object.HeapBytes < 8 THEN
ABCBreak('RecycleObject: object is too small for a chainHead link', ORD(object));
chainMember := chainHead;
WHILE chainMember <> NIL DO
BEGIN
IF chainMember = object THEN
ABCBreak('RecycleObject: object freed twice', ORD(object));
chainMember := THRecycleChain(chainMember)^^.chainLink;
END;
{$ENDC}
THRecycleChain(object)^^.chainLink := chainHead;
chainHead := object;
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE Recreate(object: TObject; oldSize, newSize: INTEGER; newSTP: TPSliceTable);

Apple Lisa ToolKit 3.0 Source Code Listing -- 595 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

VAR extraPtr:
TPByte;
hz:
THz;
cb:
INTEGER;
bk:
LONGINT;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
SetCP(object, TClass(newSTP));
{Install the new slice-table pointer}
IF newSize <> oldSize THEN
{Default extra fields to 0/NIL}
BEGIN
hz := HzFromH(TH(object));
cb := CbDataOfH(hz, TH(object));
bk := ORD(Handle(object)^);
IF (cb > oldSize) AND (newSize < oldSize) THEN
{There is a variable-length part & we're shrinking}
XferLeft(Ptr(bk + oldSize), Ptr(bk + newSize), cb - oldSize);
ChangeSizeH(hz, TH(object), cb + newSize - oldSize);
IF (cb > oldSize) AND (newSize > oldSize) THEN
{There is a variable-length part & we're expanding}
XferRight(Ptr(bk + oldSize), Ptr(bk + newSize), cb - oldSize);
IF newSize > oldSize THEN
{Default extra fields to 0/NIL}
BEGIN
extraPtr := TPByte(bk + oldSize + 1);
extraPtr^ := 0;
{Store one zero and let XferLeft copy it repeatedly}
XferLeft(Ptr(extraPtr), Ptr(ORD(extraPtr) + 1), newSize - oldSize - 1);
END;
END;
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sRes}
FUNCTION Superclass(class: TClass): TClass;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$R-} Superclass := TClass(TPSliceTable(class)^[-1]); {$IFC fRngObject}{$R+}{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sRes}
FUNCTION ClassDescendsFrom(descendant, ancestor: TClass): BOOLEAN;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
WHILE (descendant <> ancestor) AND (descendant <> NIL) DO
{$R-} descendant := TClass(TPSliceTable(descendant)^[-1]); {$IFC fRngObject}{$R+}{$ENDC}
ClassDescendsFrom := descendant <> NIL;

Apple Lisa ToolKit 3.0 Source Code Listing -- 596 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sRes}
PROCEDURE NameOfClass(class: TClass; VAR className: TClassName);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
CpToCn(TPSliceTable(class), TS8(className));
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sRes}
FUNCTION SizeOfClass(class: TClass): INTEGER;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
SizeOfClass := SizeOfCp(TPSliceTable(class));
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S SgCLAres}
{toInsert, return: -1 if class already there or if table full, index if a hole found}
{not toInsert, return: index (> 0) if class found, -1 if not there}
FUNCTION LookupName(classAlpha: TA8; toInsert: BOOLEAN): INTEGER;
FUNCTION CompareName(hashIndex: INTEGER): THashCompare;
VAR myIndex:
INTEGER;
trialName: TS8;
BEGIN
myIndex := hMyHashName^^.records[hashIndex];
IF myIndex = 0 THEN
CompareName := cHole
ELSE
IF classAlpha = hMyClasses^^.records[myIndex].classAlpha THEN
CompareName := cMatch
ELSE
CompareName := cMismatch;
END;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
LookupName := LookupInHashArray(hMyHashName^^.header.size,
ORD(classAlpha[2])*ORD(classAlpha[4])+ORD(classAlpha[6]),
toInsert, CompareName);
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 597 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

{$S SgCLAres}
FUNCTION ValidDataAddress(addr: LONGINT): BOOLEAN;
{Returns TRUE iff: addr is in a data segment (stack seg doesn't qualify)
AND is it an even address
AND is it within the bounds of the data segment}
CONST

dsMaxSize

= $00020000; {128K}

VAR error: INTEGER;


refnum: INTEGER;
dsInfo: dsInfoRec;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
ValidDataAddress := FALSE;
IF NOT ODD(addr) THEN
BEGIN
Info_Address(error, addr, refnum);
IF error <= 0 THEN
BEGIN
Info_Dataseg(error, refnum, dsInfo);
IF error <= 0 THEN
IF (addr MOD dsMaxSize) < dsInfo.mem_size THEN
ValidDataAddress := TRUE;
END;
END;
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE Free(object: TObject);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
IF object <> NIL THEN
object.Free;
{$IFC fMaxTrace}EP;{$ENDC}
END;
{*** THE FOLLOWING TWO ROUTINES ASSUME THAT THE hHashName AND hMyClasses TABLES ARE ALWAYS AROUND ***}
{*** IF THEY START SWAPPING OUT, WRITE LINEAR SEARCH ROUTINES TO REPLACE THESE ***}
{$S SgCLAres}
FUNCTION CiOfAlpha(classAlpha: TA8): INTEGER;

{convert class title TA8 to class index}

Apple Lisa ToolKit 3.0 Source Code Listing -- 598 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

VAR hashIndex: INTEGER;


i:
INTEGER;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
hashIndex := LookupName(classAlpha, FALSE);
IF hashIndex <= 0 THEN
CiOfAlpha := 0
ELSE
CiOfAlpha := hMyHashName^^.records[hashIndex];
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S SgCLAres}
FUNCTION CiOfCn(className: S8): INTEGER;
{convert upper-case class title S8 to class index}
VAR a8: TA8;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
FillChar(a8, 8, ' ');
XferLeft(Ptr(ORD(@className)+1), @a8, Length(className));
CiOfCn := CiOfAlpha(a8);
{$IFC fMaxTrace}EP;{$ENDC}
END;

{ ====================================== INITIALIZATION ====================================== }


{$S sError}
PROCEDURE CheckInitError(error: INTEGER);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
IF error > 0 THEN {Can only call with error > 0 before TProcess class-init has run}
InitErrorAbort(error);
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sInit1}
FUNCTION NewHeap(VAR error: INTEGER; heapStart, numBytes: LONGINT; numObjects: INTEGER): THeap;
VAR heap:
THeap;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
heap := THeap(HzInit(POINTER(heapStart), POINTER(heapStart+numBytes),
NIL, numObjects, 0, POINTER(procNil),
POINTER(procNil), POINTER(procNil), POINTER(procNil)));

Apple Lisa ToolKit 3.0 Source Code Listing -- 599 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

IF heap = POINTER(1) THEN


BEGIN
error := erInternal;
ABCBreak('NewHeap could not make a heap of size', numBytes);
heap := NIL;
END
ELSE
error := 0;
NewHeap := heap;
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sInit1}
FUNCTION MakeDataSegment(VAR error, dsRefnum: INTEGER; firstTryVolume, thenTryVolume: TFilePath;
ldsn, memBytes, diskBytes: INTEGER): LONGINT;
VAR startAddress: LONGINT;
PROCEDURE TryMakeDataSegment(volumePart: TFilePath);
VAR dsPathname: PathName;
BEGIN
dsPathname := Concat(volumePart, 'ds_private');
Make_Dataseg(error, dsPathname, memBytes, diskBytes, dsRefnum, startAddress, ldsn, ds_private);
END;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
TryMakeDataSegment(firstTryVolume);
IF error = 309 THEN
IF firstTryVolume <> thenTryVolume THEN
TryMakeDataSegment(thenTryVolume);
IF error >0 THEN
BEGIN
ABCBreak('MakeDataSegment', error);
startAddress := 0;
END;
MakeDataSegment := startAddress;
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S sInit1}
PROCEDURE InitObject;
VAR dsp:
excepName:
error:

DsProcParam;
T_Ex_Name;
INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 600 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

prcsInfo:
heapBase:
progVolume:

ProcInfoRec;
LONGINT;
PathName;

BEGIN
{Until we call InitQDWM, NOTHING CAN FAIL!!!!}
isInitialized := FALSE;
amDying := FALSE;
wmIsInitialized := FALSE;

{An interface variable set true at a higher level: e.g., by TProcess.Run}


{An interface variable set true at a higher level when ImDying is called}
{An interface variable set true at a higher level: e.g., by InitQDWM}

{$IFC fTrace}
fTraceEnabled := FALSE;
fDebugRecursion := FALSE;
tabLevel := -1;
curTraceLevel := 1;
traceCount := 0;
defTraceCount := 0;
breakMCount := 0;
kpcntr := 0;
keyPresLimit := stdKeyPresLimit;
returnToMain := TRUE;
showPrompt := TRUE;
outputIndent := 0;
currXPos := 0;
tallyingCalls := FALSE;
tallies := NIL;
segNames := NIL;
{$ENDC}
{Determine environment and program volume name}
Info_Process(error, My_id, prcsInfo);
{get my volume name as '-volname-'; assumes that the OS gives us back a program name of the form:
'-volname-progname'}
Delete(prcsInfo.progPathName, 1, 1); {the first '-'}
progVolume := Concat('-', Copy(prcsInfo.progPathName, 1, Pos('-', prcsInfo.progPathName)));
{$IFC LibraryVersion <= 20}
{Yu Ying has a better way to know if we are on the desktop or in the workshop, but meanwhile...}
IF prcsInfo.father_Id > 1 THEN
BEGIN
Info_Process(error, prcsInfo.father_Id, prcsInfo);
{this assumes that the OS returns a program name of the form '-volname-progname'}
Delete(prcsInfo.progPathName, 1, 1); {the first '-'}
Delete(prcsInfo.progPathName, 1, Pos('-', prcsInfo.progPathName)); {the 'volname-'}
StrUpperCased(@prcsInfo.progPathName);

Apple Lisa ToolKit 3.0 Source Code Listing -- 601 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

onDesktop := prcsInfo.progPathName = 'SHELL.OFFICE SYSTEM';


END
ELSE
BEGIN
onDesktop := FALSE;
END;
{$ELSEC}
dsp.procCode := dsGetDiskEnbF;
DSPaslibCall(dsp);
onDesktop := NOT dsp.diskEnbF;
{$ENDC}
InitQDWM;

{must be the first thing before any operations that could fail;
when running on the Workshop, it also sets up the FontMgr & writeln to alternate screen.}

{$IFC fDbgObject}
Write('Running on the ');
IF onDesktop THEN
WriteLn('desktop')
ELSE
WriteLn('workshop');
{$ENDC}
{Declare an OS Exception Handler}
excepName := 'SYS_TERMINATE';
Declare_Excep_Hdl(error, excepName, @TrmntExceptionHandler);
CheckInitError(error);
{$IFC fDbgObject}
GoToXY(0,31);
{$ENDC}
{Create data segment and heap}
mainLdsn := prcsLdsn;
heapBase := MakeDataSegment(error, mainDsRefnum, '', progVolume, mainLdsn, prcsDsBytes, prcsDsBytes);
CheckInitError(error);
mainHeap := NewHeap(error, heapBase, prcsDsBytes, prcsDsBytes DIV 20);
CheckInitError(error);
SetHeap(mainHeap);
END;
{$S sInit1}
PROCEDURE UnitAuthor(companyAndAuthor: TAuthorName);
VAR a32:
TA32;

{required once per unit}

Apple Lisa ToolKit 3.0 Source Code Listing -- 602 of 1012

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163
001164
001165
001166
001167
001168
001169
001170
001171
001172
001173
001174
001175
001176
001177
001178
001179
001180
001181
001182
001183
001184
001185
001186
001187
001188
001189
001190
001191
001192
001193
001194
001195

BEGIN
StrUpperCased(@companyAndAuthor);
FillChar(a32, 32, ' ');
XferLeft(Ptr(ORD(@companyAndAuthor)+1), @a32, LENGTH(companyAndAuthor));
QUnitAuthor(a32);
END;
{$S sInit1}
PROCEDURE ClassAuthor(companyAndAuthor: TAuthorName; classAlias: TClassName);
VAR a32:
TA32;
a8:
TA8;
BEGIN
IF LENGTH(companyAndAuthor) > 0 THEN
BEGIN
StrUpperCased(@companyAndAuthor);
FillChar(a32, 32, ' ');
XferLeft(Ptr(ORD(@companyAndAuthor)+1), @a32, LENGTH(companyAndAuthor));
QClassAuthor(a32);
END;

{optional}

IF LENGTH(classAlias) > 0 THEN


BEGIN
StrUpperCased(@classAlias);
FillChar(a8, 8, ' ');
XferLeft(Ptr(ORD(@classAlias)+1), @a8, LENGTH(classAlias));
QClassAlias(a8);
END;
END;
{$S sInit1}
PROCEDURE ClassVersion(itsVersion, oldestItCanRead: Byte);
{optional}
BEGIN
IF (itsVersion < 0) OR (itsVersion > 127) OR (oldestItCanRead < 0) OR (oldestItCanRead > 127) OR
(oldestItCanRead > itsVersion) THEN
ABCBreak('Version numbers must be in the range 0..127 and oldestItCanRead <= itsVersion',
itsVersion);
QClassVersion(itsVersion, oldestItCanRead);
END;
{ ====================================== VERSION CONVERSION ====================================== }
{$S SgCLAcld}
PROCEDURE ConvClass(object: TObject; exWorld: TWorld; exIndex, myIndex: INTEGER);
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 603 of 1012

Apple Lisa Computer Technical Information


001196
001197
001198
001199
001200
001201
001202
001203
001204
001205
001206
001207
001208
001209
001210
001211
001212
001213
001214
001215
001216
001217
001218
001219
001220
001221
001222
001223
001224
001225
001226
001227
001228
001229
001230
001231
001232
001233
001234
001235
001236
001237
001238
001239
001240
001241
001242
001243

{$IFC fMaxTrace}BP(1);{$ENDC}
Recreate(object, exWorld.hExClasses^^.records[exIndex].objectSize, (*^*)
hMyClasses^^.records[myIndex].objectSize, hMySTables^^.records[myIndex]); (*^*)
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S SgCLAcld}
FUNCTION IndexOfExClass(exWorld: TWorld; exIndex: INTEGER): INTEGER;
LABEL 1,2;
VAR exAuthor:
TA32;
exAlias:
TA8;
exAlpha:
TA8;
coCode:
INTEGER;
alCode:
INTEGER;
index:
INTEGER;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
IndexOfExClass := 0;
WITH exWorld, hExClasses^^.records[exIndex] DO (*^*)(* WHOLE BLOCK CHANGED *)
BEGIN
exAlpha := classAlpha;
IF classAlias = 0 THEN
exAlias := classAlpha
ELSE
exAlias := hExAliases^^.records[classAlias];

1:

IF companyAndAuthor <> 0 THEN


BEGIN
exAuthor := hExAuthors^^.records[companyAndAuthor];
WITH hMyAuthors^^ DO
FOR coCode := 1 TO numAuthors DO
IF records[coCode] = exAuthor THEN (*^*)
GOTO 1;
END;
coCode := 0;
END;

{If that class name is in my alias list, do it the hard way}


WITH hMyAliases^^ DO
FOR alCode := 1 TO numAliases DO
IF records[alCode] = exAlias THEN
GOTO 2;

Apple Lisa ToolKit 3.0 Source Code Listing -- 604 of 1012

Apple Lisa Computer Technical Information


001244
001245
001246
001247
001248
001249
001250
001251
001252
001253
001254
001255
001256
001257
001258
001259
001260
001261
001262
001263
001264
001265
001266
001267
001268
001269
001270
001271
001272
001273
001274
001275
001276
001277
001278
001279
001280
001281
001282
001283
001284
001285
001286
001287
001288
001289
001290
001291

{If that class name is one of mine, too, do it the easy way}
index := CiOfAlpha(exAlpha);
IF index <> 0 THEN (*^*)
IF hMyClasses^^.records[index].companyAndAuthor = coCode THEN
BEGIN (*^*)
IndexOfExClass := index;
EXIT(IndexOfExClass); (*^*)
END; (*^*)
{Different company name or never heard of that class name at all, return 0}
EXIT(IndexOfExClass); (*^*)
2:
{The hard way: exhaustive search, because we may be using different names for the same class}
WITH hMyClasses^^ DO
FOR index := 1 TO numClasses DO
WITH records[index] DO
IF coCode = companyAndAuthor THEN
IF alCode = classAlias THEN
BEGIN
IndexOfExClass := index;
EXIT(IndexOfExClass);
END;
END;
{$S SgCLAcld}
FUNCTION NeedConversion(exClassWorld: TClassWorld; VAR olderVersion, newerVersion: BOOLEAN): BOOLEAN;
VAR someDifference:
BOOLEAN;
exWorld:
TWorld;
numExClasses:
INTEGER;
exIndex:
INTEGER;
exInfo:
TClassInfo;
exSize:
INTEGER;
exSTP:
TPSliceTable;
myIndex:
INTEGER;
myInfo:
TClassInfo;
mySize:
INTEGER;
mySTP:
TPSliceTable;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
someDifference := FALSE;
olderVersion := FALSE;
newerVersion := FALSE;
exWorld := TWorld(exClassWorld);
WITH exWorld DO

{Separate statement because of a compiler bug}

Apple Lisa ToolKit 3.0 Source Code Listing -- 605 of 1012

Apple Lisa Computer Technical Information


001292
001293
001294
001295
001296
001297
001298
001299
001300
001301
001302
001303
001304
001305
001306
001307
001308
001309
001310
001311
001312
001313
001314
001315
001316
001317
001318
001319
001320
001321
001322
001323
001324
001325
001326
001327
001328
001329
001330
001331
001332
001333
001334
001335
001336
001337
001338
001339

BEGIN
numExClasses := hExClasses^^.header.size;
IF numClasses <> numExClasses THEN
someDifference := TRUE;
FOR exIndex := 1 TO numExClasses DO
BEGIN
myIndex := IndexOfExClass(exWorld, exIndex);
IF myIndex = 0 THEN
newerVersion := TRUE
ELSE
BEGIN
exInfo := hExClasses^^.records[exIndex];
exSize := exInfo.objectSize;
exSTP := hExSTables^^.records[exIndex];
myInfo := hMyClasses^^.records[myIndex];
mySize := myInfo.objectSize;
mySTP := hMySTables^^.records[myIndex];
IF (myInfo.version < exInfo.version) OR (mySize < exSize) THEN
newerVersion := TRUE;
IF (myInfo.version > exInfo.version) OR (mySize > exSize) THEN
olderVersion := TRUE;
IF (mySTP <> exSTP) OR (myInfo.oldestReadableVersion <> exInfo.oldestReadableVersion) THEN
someDifference := TRUE;
IF exInfo.superIndex = 0 THEN
BEGIN
IF myInfo.superIndex <> 0 THEN
newerVersion := TRUE;
END
ELSE
IF myInfo.superIndex <> IndexOfExClass(exWorld, exInfo.superIndex) THEN
newerVersion := TRUE;
END;
END;
END;
NeedConversion := someDifference OR olderVersion OR newerVersion;
END;
{$S SgCLAcld}
PROCEDURE ConvertHeap(heap: THeap; exClassWorld: TClassWorld);

Apple Lisa ToolKit 3.0 Source Code Listing -- 606 of 1012

Apple Lisa Computer Technical Information


001340
001341
001342
001343
001344
001345
001346
001347
001348
001349
001350
001351
001352
001353
001354
001355
001356
001357
001358
001359
001360
001361
001362
001363
001364
001365
001366
001367
001368
001369
001370
001371
001372
001373
001374
001375
001376
001377
001378
001379
001380
001381
001382
001383
001384
001385
001386
001387

{*** VERSION CONVERSION ***


Convert all the contents of heap from its classes to ours.
The job is done in two passes through heap:
(1) ConvertClass changes the method-table pointer of each object, and may change its size.
If the object grows, extra fields are defaulted to 0/NIL.
(2) ConvertFields tells each object to "Convert(oldVersion)", thus giving the application a
chance to calculate extra fields or otherwise modify the converted object.}
VAR exWorld:
needPassTwo:
numExClasses:
hExHashSTP:
hExEquivalent:
exIndex:

TWorld;
BOOLEAN;
INTEGER;
THIdxArray;
THIdxArray;
INTEGER;

{toInsert, return: -1 if sliceTable already there or if table full, index if a hole found}
{not toInsert, return: index (> 0) if sliceTable found, -1 if not there}
FUNCTION LookupSTP(stp: TPSliceTable; toInsert: BOOLEAN): INTEGER;
FUNCTION CompareSTP(hashIndex: INTEGER): THashCompare;
VAR myIndex:
INTEGER;
BEGIN
myIndex := hExHashSTP^^.records[hashIndex];
IF myIndex = 0 THEN
CompareSTP := cHole
ELSE
IF exWorld.hExSTables^^.records[myIndex] = stp THEN
CompareSTP := cMatch
ELSE
CompareSTP := cMismatch;
END;
BEGIN
LookupSTP := LookupInHashArray(hExHashSTP^^.header.size, ORD(stp), toInsert, CompareSTP);
END;
FUNCTION EquivIndex(exIndex: INTEGER): INTEGER;
VAR tblIndex:
INTEGER;
myIndex:
INTEGER;
BEGIN
tblIndex := exIndex;
WITH exWorld DO
WHILE tblIndex <> 0 DO
WITH hExClasses^^.records[tblIndex] DO
BEGIN
myIndex := IndexOfExClass(exWorld, tblIndex);

Apple Lisa ToolKit 3.0 Source Code Listing -- 607 of 1012

Apple Lisa Computer Technical Information


001388
001389
001390
001391
001392
001393
001394
001395
001396
001397
001398
001399
001400
001401
001402
001403
001404
001405
001406
001407
001408
001409
001410
001411
001412
001413
001414
001415
001416
001417
001418
001419
001420
001421
001422
001423
001424
001425
001426
001427
001428
001429
001430
001431
001432
001433
001434
001435

IF myIndex <> 0 THEN


IF version >= hMyClasses^^.records[myIndex].oldestReadableVersion THEN
BEGIN
EquivIndex := myIndex;
EXIT(EquivIndex);
END;
tblIndex := superIndex;
END;
{$IFC fDbgObject}
ABCBreak('No common superclass', exIndex);
{$ENDC}
EquivIndex := 0;
END;
FUNCTION FindClasses(object: TObject; VAR exIndex, myIndex: INTEGER; VAR moreConversion: BOOLEAN)
: BOOLEAN;
{Given an object, return the original and my class index}
VAR stp:
TPSliceTable;
pStp:
^TPSliceTable;(*^*)
exHashIndex:
INTEGER;
exVersion:
INTEGER;
exSize:
INTEGER;
BEGIN
FindClasses := FALSE;
{Determine the original class of the object from its method table ptr}
stp := TPSliceTable(Handle(object)^^);
(*^*)

{Obtain access to its high byte}


pStp := @stp;
{stp probably has its exIndex stored in its high byte (unless > 255 or not a Clascal object)}
exIndex := TPByte(pStp)^;
TPByte(pStp)^ := 0;
{So the stp comparisons below will be uncluttered}
IF exIndex < 0 THEN
exIndex := 256 + exIndex;

{Undo sign extension caused by TPByte^}

IF exIndex <> 0 THEN


{It might be a class pointer}
IF exIndex > numExClasses THEN
exIndex := 0
{Not a real class pointer}
ELSE
{Could not use "WITH exWorld" here because code generator balked}
IF exWorld.hExSTables^^.records[exIndex] <> stp THEN
exIndex := 0;
{Not a real class pointer}
(*^*){Also added next 3 comments below}
IF exIndex = 0 THEN

{It is not a class pointer, or exIndex>255}

Apple Lisa ToolKit 3.0 Source Code Listing -- 608 of 1012

Apple Lisa Computer Technical Information


001436
001437
001438
001439
001440
001441
001442
001443
001444
001445
001446
001447
001448
001449
001450
001451
001452
001453
001454
001455
001456
001457
001458
001459
001460
001461
001462
001463
001464
001465
001466
001467
001468
001469
001470
001471
001472
001473
001474
001475
001476
001477
001478
001479
001480
001481
001482
001483

IF numExClasses > 255 THEN


{It might be a class pointer after all}
BEGIN
{Look in the hash table}
exHashIndex := LookupSTP(stp, FALSE);
IF exHashIndex <= 0 THEN
{Not a Clascal object}
Exit(FindClasses);
exIndex := hExHashSTP^^.records[exHashIndex];
END
ELSE
Exit(FindClasses); {not a Clascal object}
{Determine the equivalent class in my process}
myIndex := hExEquivalent^^.records[exIndex];
FindClasses := TRUE;
WITH exWorld.hExClasses^^.records[exIndex] DO
BEGIN
exVersion := version;
exSize := objectSize;
END;
WITH hMyClasses^^.records[myIndex] DO
moreConversion := (exVersion < version) OR (exSize < objectSize);
(**** Replaced the following line by the preceding because it is too complicated for the
Spring Release code generator:
WITH exWorld.hExClasses^^ DO
moreConversion := (records[exIndex].version < hMyClasses^^.records[myIndex].version) OR
(records[exIndex].objectSize < hMyClasses^^.records[myIndex].objectSize);

****)
END;

PROCEDURE ConvertClass(object: TObject);


{Pass 1: Map the method-table ptr from the original to mine and change the object size}
VAR exIndex:
INTEGER;
myIndex:
INTEGER;
moreConverson: BOOLEAN;
BEGIN
{Determine both the original and my class}
IF FindClasses(object, exIndex, myIndex, moreConversion) THEN
BEGIN
{Convert the method table pointer, change the size, default extra fields to 0/NIL}
ConvClass(object, exWorld, exIndex, myIndex);
IF moreConversion THEN {a second pass will be needed to let the app do special defaulting}
needPassTwo := TRUE;
END;
END;
PROCEDURE ConvertFields(object: TObject);

Apple Lisa ToolKit 3.0 Source Code Listing -- 609 of 1012

Apple Lisa Computer Technical Information


001484
001485
001486
001487
001488
001489
001490
001491
001492
001493
001494
001495
001496
001497
001498
001499
001500
001501
001502
001503
001504
001505
001506
001507
001508
001509
001510
001511
001512
001513
001514
001515
001516
001517
001518
001519
001520
001521
001522
001523
001524
001525
001526
001527
001528
001529
001530
001531

{Pass 2: Default extra fields; a separate pass so the application can follow pointers if need be}
VAR exIndex:
INTEGER;
myIndex:
INTEGER;
moreConverson: BOOLEAN;
BEGIN
{Determine both the original and my class}
IF FindClasses(object, exIndex, myIndex, moreConversion) THEN
IF moreConversion THEN
{Let the app supply extra fields etc.}
object.Convert(exWorld.hExClasses^^.records[exIndex].version);
END;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
exWorld := TWorld(exClassWorld);
WITH exWorld DO
BEGIN
numExClasses := hExClasses^^.header.size;
{Make temporary arrays that will speed up reconciliation of the two worlds}
hExEquivalent := MakeIdxArray(numExClasses, FALSE);
FOR exIndex := 1 TO numExClasses DO
hExEquivalent^^.records[exIndex] := EquivIndex(exIndex);
IF numExClasses > 255 THEN
BEGIN
hExHashSTP := MakeIdxArray(numExClasses - 255, TRUE);
FOR exIndex := 256 TO numExClasses DO
hExHashSTP^^.records[LookupSTP(hExSTables^^.records[exIndex], TRUE)] := exIndex;
END;
END;
needPassTwo := FALSE;
{Pass One -- convert method table pointers (STPs)}
EachObject(heap, ConvertClass);
{Pass Two -- let application default extra fields}
IF needPassTwo THEN
EachObject(heap, ConvertFields);
{Free the temporary arrays}
FreeH(THz(mainHeap), TH(hExEquivalent));
IF numExClasses > 255 THEN (*^*)
FreeH(THz(mainHeap), TH(hExHashSTP));
END;
{$S sError}
PROCEDURE ClascalReason(error: INTEGER; VAR s: S255);
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 610 of 1012

Apple Lisa Computer Technical Information


001532
001533
001534
001535
001536
001537
001538
001539
001540
001541
001542
001543
001544
001545
001546
001547
001548
001549
001550
001551
001552
001553
001554
001555
001556
001557
001558
001559
001560
001561
001562
001563
001564
001565
001566
001567
001568
001569
001570
001571
001572
001573
001574
001575
001576
001577
001578
001579

CASE error OF
OTHERWISE s := 'Some kind of problem';
END;
END;

{** Need more cases **}

{$S sInit1}
PROCEDURE ClascalError(error: INTEGER); {called with error = 0 after successful Clascal initialization}
VAR s: S255;
i: INTEGER;
BEGIN
IF error > 0 THEN
BEGIN
{$IFC fDbgObject}
ClascalReason(error, s);
{$ENDC}
IF isInitialized THEN
BEGIN
{$IFC fDbgObject}
ABCBreak(s, error);
{$ENDC}
TrmntExceptionHandler;
END
ELSE
BEGIN
{$IFC fDbgObject}
WriteLn('Clascal error: ', s);
{$ENDC}
IF wmIsInitialized THEN
InitErrorAbort(error)
ELSE
{$IFC fDbgObject}
%_GoLisaBug;
{ELSEC}
HALT;
{$ENDC}
END;
END
ELSE
IF NOT classesInitialized THEN
BEGIN
{*** STILL TO DO: The first time the program runs, write to the tool resource file ***}
{Save conversion information not obtainable from UClascal in permanent arrays}
(*****

hMyClasses := THClasses(TDynamicArray.CREATE(NIL, mainHeap, SIZEOF(TClassInfo), numClasses));


XferLeft(Ptr(pClasses), @hMyClasses^^.records, numClasses * SIZEOF(TClassInfo));

Apple Lisa ToolKit 3.0 Source Code Listing -- 611 of 1012

Apple Lisa Computer Technical Information


001580
001581
001582
001583
001584
001585
001586
001587
001588
001589
001590
001591
001592
001593
001594
001595
001596
001597
001598
001599
001600
001601
001602
001603
001604
001605
001606
001607
001608
001609
001610
001611
001612
001613
001614
001615
001616
001617
001618
001619
001620
001621
001622
001623
001624
001625
001626
001627

hMySTables := THSTables(TDynamicArray.CREATE(NIL, mainHeap, SIZEOF(TPSliceTable), numClasses));


XferLeft(Ptr(pSTables), @hMySTables^^.records, numClasses * SIZEOF(TPSliceTable));
hMyAuthors := THAuthors(TDynamicArray.CREATE(NIL, mainHeap, SIZEOF(TA32), numAuthors));
XferLeft(Ptr(pAuthors), @hMyAuthors^^.records, numAuthors * SIZEOF(TA32));

*****)

hMyAliases := THAliases(TDynamicArray.CREATE(NIL, mainHeap, SIZEOF(TA8), numAliases));


XferLeft(Ptr(pAliases), @hMyAliases^^.records, numAliases * SIZEOF(TA8));
hMyClasses := THClasses(TArray.CREATE(NIL, mainHeap, numClasses, SIZEOF(TClassInfo)));
TArray(hMyClasses).EditAt(1, numClasses);
XferLeft(Ptr(pClasses), @hMyClasses^^.records, numClasses * SIZEOF(TClassInfo));
hMySTables := THSTables(TArray.CREATE(NIL, mainHeap, numClasses, SIZEOF(TPSliceTable)));
TArray(hMySTables).EditAt(1, numClasses);
XferLeft(Ptr(pSTables), @hMySTables^^.records, numClasses * SIZEOF(TPSliceTable));
hMyAuthors := THAuthors(TArray.CREATE(NIL, mainHeap, numAuthors, SIZEOF(TA32)));
TArray(hMyAuthors).EditAt(1, numAuthors);
XferLeft(Ptr(pAuthors), @hMyAuthors^^.records, numAuthors * SIZEOF(TA32));
hMyAliases := THAliases(TArray.CREATE(NIL, mainHeap, numAliases, SIZEOF(TA8)));
TArray(hMyAliases).EditAt(1, numAliases);
XferLeft(Ptr(pAliases), @hMyAliases^^.records, numAliases * SIZEOF(TA8));
WITH myWorld DO
BEGIN
infRecs := TArray(hMyClasses);
classes := TArray(hMySTables);
authors := TArray(hMyAuthors);
aliases := TArray(hMyAliases);
END;

END;

{&&& field names are a bit confusing}

hMyHashName := MakeIdxArray(numClasses, TRUE);


FOR i := 1 TO numClasses DO
hMyHashName^^.records[LookupName(hMyClasses^^.records[i].classAlpha, TRUE)] := i;
END;

{ ====================================== METHODS OF CLASSES ====================================== }

METHODS OF TObject;

Apple Lisa ToolKit 3.0 Source Code Listing -- 612 of 1012

Apple Lisa Computer Technical Information


001628
001629
001630
001631
001632
001633
001634
001635
001636
001637
001638
001639
001640
001641
001642
001643
001644
001645
001646
001647
001648
001649
001650
001651
001652
001653
001654
001655
001656
001657
001658
001659
001660
001661
001662
001663
001664
001665
001666
001667
001668
001669
001670
001671
001672
001673
001674
001675

{$S sStartup}
PROCEDURE TObject.Become(object: TObject);
LABEL
1;
VAR hSelf: TH;
hObj:
TH;
bkSelf: TBk;
bkObj: TBk;
p:
TP;
{$IFC LibraryVersion <= 20}
oh:
TC;
{$ELSEC}
tempBP: TBp;
{$ENDC}
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
IF SELF.Heap <> object.Heap THEN
BEGIN
{$IFC fDbgObject}
WriteLn(ORD(SELF));
ABCBreak('Attempt to Become an object on another heap', ORD(object));
{$ENDC}
GOTO 1;
END;
hSelf := TH(SELF);
hObj := TH(object);
bkSelf := TBk(ORD(hSelf^) - 4);
bkObj := TBk(ORD(hObj^) - 4);
p := hSelf^;
hSelf^ := hObj^;
hObj^ := p;
{$IFC LibraryVersion <= 20}
oh := bkSelf^.oh;
bkSelf^.oh := bkObj^.oh;
bkObj^.oh := oh;
{$ELSEC}
tempBP := bkSelf^.bp;
bkSelf^.bp := bkObj^.bp;
bkObj^.bp := tempBP;
{$ENDC}
object.Free;

Apple Lisa ToolKit 3.0 Source Code Listing -- 613 of 1012

Apple Lisa Computer Technical Information


001676
001677
001678
001679
001680
001681
001682
001683
001684
001685
001686
001687
001688
001689
001690
001691
001692
001693
001694
001695
001696
001697
001698
001699
001700
001701
001702
001703
001704
001705
001706
001707
001708
001709
001710
001711
001712
001713
001714
001715
001716
001717
001718
001719
001720
001721
001722
001723

1:

{$IFC fTrace}EP;{$ENDC}
END;

{$S sStartup}
FUNCTION
BEGIN
{$IFC
Class
{$IFC
END;
{$S sRes}
FUNCTION
BEGIN
{$IFC
Clone
{$IFC
END;

TObject.Class: TClass;
fMaxTrace}BP(1);{$ENDC}
:= ClassPtr(Handle(SELF));
fMaxTrace}EP;{$ENDC}

TObject.Clone(heap: THeap): TObject;


fMaxTrace}BP(1);{$ENDC}
:= SELF.CloneObject(heap);
fMaxTrace}EP;{$ENDC}

{$S sRes}
FUNCTION TObject.CloneObject(heap: THeap): TObject;
VAR hz:
THz;
size:
INTEGER;
source: TH;
dest:
TH;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
hz := THz(heap);
source := TH(SELF);
size := cbDataOfH(hz, source);
dest := HAllocate(hz, size);
XferLeft(@source^^, @dest^^, size);
CloneObject := TObject(dest);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
PROCEDURE TObject.Free;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.FreeObject;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 614 of 1012

Apple Lisa Computer Technical Information


001724
001725
001726
001727
001728
001729
001730
001731
001732
001733
001734
001735
001736
001737
001738
001739
001740
001741
001742
001743
001744
001745
001746
001747
001748
001749
001750
001751
001752
001753
001754
001755
001756
001757
001758
001759
001760
001761
001762
001763
001764
001765
001766
001767
001768
001769
001770
001771

{$S sStartup}
PROCEDURE TObject.FreeObject;
VAR heap:
THeap;
numObjects: INTEGER;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
heap := SELF.Heap;
FreeH(THz(heap), TH(SELF));
{$IFC fTrace}EP;{$ENDC}
END;
{$S sStartup}
FUNCTION TObject.Heap: THeap;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
Heap := THeap(HzFromH(TH(SELF)));
END;
{$S sRes}
FUNCTION TObject.HeapBytes: INTEGER;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
HeapBytes := CbDataOfH(HzFromH(TH(SELF)), TH(SELF));
{$IFC fTrace}EP;{$ENDC}
END;
{$S sLOX}
PROCEDURE TObject.Read(s: TStringScanner);
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
s.XferFields(xRead, SELF);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sLOX}
PROCEDURE TObject.Write(s: TStringScanner);
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
s.XferFields(xWrite, SELF);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 615 of 1012

Apple Lisa Computer Technical Information


001772
001773
001774
001775
001776
001777
001778
001779
001780
001781
001782
001783
001784
001785
001786
001787
001788
001789
001790
001791
001792
001793
001794
001795
001796
001797
001798
001799
001800
001801
001802
001803
001804
001805
001806
001807
001808
001809
001810
001811
001812
001813
001814
001815
001816
001817
001818
001819

{$IFC fDebugMethods}
{$S SgCLAdbg}
PROCEDURE TObject.Debug(numLevels: INTEGER; memberTypeStr: S255);
VAR class:
TClass;
name:
TClassName;
str:
S255;
{$IFC fTrace}
oldFlag:
BOOLEAN;
{$ENDC}
PROCEDURE SupplyObjFields(PROCEDURE Field(nameAndType: S255));
BEGIN
SELF.Fields(Field);
END;
BEGIN
{$IFC fTrace}
oldFlag := fDebugRecursion;
fDebugRecursion := TRUE;
{$ENDC}
class := SELF.Class;
CpToCn(TPSliceTable(class), TS8(name));
TrimBlanks(@name);
WrStr(Concat(name, ' '));
{$IFC fDebugMethods}
IF numLevels > 0 THEN
WriteDRecord(numLevels, Handle(SELF), 4, SupplyObjFields);
{$ELSEC}
LIntToHex(ORD(SELF), @str);
str := Concat('-- $', str);
IF NOT ValidObject(Handle(SELF)) THEN
str := Concat('Invalid Object', str);
WrStr(str);
{$ENDC}

{4 skips method table ptr}

{$IFC fTrace}
fDebugRecursion := oldFlag;
{$ENDC}
END;
{$S SgCLAres}
{$ENDC}
{$IFC fDebugMethods}

Apple Lisa ToolKit 3.0 Source Code Listing -- 616 of 1012

Apple Lisa Computer Technical Information


001820
001821
001822
001823
001824
001825
001826
001827
001828
001829
001830
001831
001832
001833
001834
001835
001836
001837
001838
001839
001840
001841
001842
001843
001844
001845
001846
001847
001848
001849
001850
001851
001852
001853
001854
001855
001856
001857
001858
001859
001860
001861
001862
001863
001864
001865
001866
001867

{$S SgCLAdbg}
PROCEDURE TObject.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
END;
{$S SgCLAres}
{$ENDC}
{$S SgCLAcld}
PROCEDURE TObject.Convert(fromVersion: Byte);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
END;
{$S SgCLAres}
{$S SgCLAcld}
FUNCTION TObject.JoinClass(newClass: TClass): TObject;
VAR oldClass:
TClass;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
oldClass := SELF.Class;
IF NOT ClassDescendsFrom(oldClass, newClass) THEN
IF ClassDescendsFrom(newClass, oldClass) THEN
Recreate(SELF, SizeOfCp(TPSliceTable(oldClass)),
SizeOfCP(TPSliceTable(newClass)), TPSliceTable(newClass)) (*^*)
ELSE
{$IFC fDbgObject}
ABCBreak('An Object cannot move to an unrelated class', ORD(newClass))
{$ENDC};
JoinClass := SELF;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
{$S sInit1}
BEGIN {Class Initialization}
InitClascal(ClascalError);
InitObject;

{Provide an error routine in case of errors in Clascal run-time support}


{Do remaining initialization}

UnitAuthor('Apple');
cObject := THISCLASS;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 617 of 1012

Apple Lisa Computer Technical Information


001868
001869
001870
001871
End of File -- Lines: 1871 Characters: 57741

Apple Lisa ToolKit 3.0 Source Code Listing -- 618 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UOBJECT3.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{INCLUDE FILE UOBJECT3 -- COLLECTIONS}


{Copyright 1983, 1984, Apple Computer, Inc.}
{Segments: SgCLAini(tialize and Terminate), SgCLAres(ident), SgCLAc(o)ld, SgCLAdbg}
{$S sResDat}
PROCEDURE XferContiguous(whichWay: xReadWrite; collection: TCollection; alsoSkip: INTEGER; s: TStringScanner);
{Transfer the size (as an INTEGER), class-specific fields (after alsoSkip bytes), and all members.
Do not recur on the members.
Do not transfer the class, the dynStart (=SizeOfClass), or the hole info (=zero).
When reading, append the elements that are read.
This only works for contiguous objects up to 32K members in size.}
VAR size:
INTEGER;
numToXfer: INTEGER;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
size := collection.size;
collection.StopEdit;
CASE whichWay OF
xRead:
BEGIN
numToXfer := s.ReadNumber(2);
collection.EditAt(size + 1, numToXfer);
size := collection.size;
END;
xWrite:
BEGIN
numToXfer := size;
s.WriteNumber(numToXfer, 2);
END;
END;
s.XferSequential(whichWay,
Ptr(ORD(Handle(collection)^) + SIZEOF(TCollection) + alsoSkip),
size * collection.MemberBytes);
{$IFC fTrace}EP;{$ENDC}
END;
{INVARIANT ON TCollections:
given a collection c,
the elements of the collection are stored at physical indices:
[1..c.holeStart] and [c.holeStart+c.holeSize+1..c.Size+c.holeSize]
the hole occupies physical indices:

Apple Lisa ToolKit 3.0 Source Code Listing -- 619 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

[c.holeStart+1..c.holeStart+c.holeSize]

METHODS OF TCollection;
{$S sResDat}
FUNCTION TCollection.CREATE(object: TObject; heap: THeap; initialSlack: INTEGER): TCollection;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
IF object = NIL THEN
ABCBreak('TCollection.CREATE must be passed an already-allocated object by a subclass CREATE', 0);
SELF := TCollection(object);
WITH SELF DO
BEGIN
size := 0;
{$H-} dynStart := SizeOfClass(SELF.Class); {$H+}
holeStart := 0;
holeSize := initialSlack;
holeStd := 0;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
FUNCTION TCollection.Clone(heap: THeap): TObject;
VAR numMembers: INTEGER;
collection: TCollection;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
numMembers := SELF.size;
collection := TCollection(NewDynObject(heap, SELF.Class, numMembers * SELF.MemberBytes));
XferLeft(Ptr(Handle(SELF)^), Ptr(Handle(collection)^), SELF.dynStart);
collection := TCollection.CREATE(collection, heap, numMembers);
collection.InsManyAt(1, SELF, 1, numMembers);
Clone := collection;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S SgCLAdbg}
PROCEDURE TCollection.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('size: LONGINT');
Field('dynStart: INTEGER');

Apple Lisa ToolKit 3.0 Source Code Listing -- 620 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

Field('holeStart: INTEGER');
Field('holeSize: INTEGER');
Field('holeStd: INTEGER');
END;
{$S SgCLAres}
{$ENDC}
{$IFC fCheckIndices}
{$S SgCLAdbg}
PROCEDURE TCollection.CheckIndex(index: LONGINT);
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
IF (index < 1) OR (index > SELF.size) THEN
ABCBreak('CheckIndex', index);
END;
{$S SgCLAres}
{$ENDC}
{$S sResDat}
FUNCTION TCollection.AddrMember(i: LONGINT): LONGINT;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
{$IFC fDbgObject}
IF SELF.dynStart = MAXINT THEN
ABCBreak('No dynamic part', i);
{$ENDC}
{$IFC fCheckIndices}
IF fCheckIndices THEN
IF (i < 1) OR (i > SELF.size+1) THEN
ABCBreak('CheckIndex', i);
{$ENDC}
IF i > SELF.holeStart THEN
i := i + SELF.holeSize;
{i is now a physical index}
AddrMember := TpLONGINT(SELF)^ + SELF.dynStart + (SELF.MemberBytes * (i - 1));
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
PROCEDURE TCollection.CopyMembers(dstAddr, startIndex, howMany: LONGINT);
VAR memberBytes:
INTEGER;
beforeHole:
INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 621 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

srcAddr:
j:
offset:
numBytes:

LONGINT;
INTEGER;
INTEGER;
INTEGER;

BEGIN
{$IFC fTrace}BP(3);{$ENDC}
IF startIndex < 1 THEN
startIndex := 1;
howMany := Min(howMany, SELF.size + 1 - startIndex);
IF (howMany > 0) AND (startIndex <= SELF.size) THEN
BEGIN
memberBytes := SELF.MemberBytes;
beforeHole := Min(howMany, SELF.holeStart + 1 - startIndex);
srcAddr := SELF.AddrMember(startIndex);
IF beforeHole > 0 THEN
BEGIN
numBytes := beforeHole * memberBytes;
XferLeft(Ptr(srcAddr), Ptr(dstAddr), numBytes);
dstAddr := dstAddr + numBytes;
END
ELSE
beforeHole := 0;
IF beforeHole < howMany THEN
BEGIN
srcAddr := SELF.AddrMember(startIndex + beforeHole);
XferLeft(Ptr(srcAddr), Ptr(dstAddr), (howMany - beforeHole) * memberBytes);
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
{AFTER EXECUTING THIS METHOD:
IF deltaMembers >= 0,
physical positions [atIndex..atIndex+deltaMembers-1] are available for adding new members.
IF deltaMembers < 0,
actual members [atIndex..atIndex-deltaMembers+1] have been removed.
NOTE: This routine does not preserve the TCollection invariant.
}
PROCEDURE TCollection.EditAt(atIndex: LONGINT; deltaMembers: INTEGER);

Apple Lisa ToolKit 3.0 Source Code Listing -- 622 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

VAR oldHoSize:
INTEGER;
newHoSize:
INTEGER;
oldHoStart:
INTEGER;
newHoStart:
INTEGER;
maxHoStart:
INTEGER;
minHoStart:
INTEGER;
size:
INTEGER;
b:
0..1;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
{$IFC fDbgObject}
IF SELF.dynStart = MAXINT THEN
ABCBreak('No dynamic part', atIndex);
{$ENDC}

{Removes any hole it creates unless holdStd <> 0}

{Force atIndex and deltaMembers into the valid range}


atIndex := Max(1, Min(atIndex, SELF.size + 1));
IF deltaMembers < 0 THEN
deltaMembers := Min(0, Max(deltaMembers, atIndex - SELF.size - 1));
(***** Range checks not necessary with the above code
{$IFC fCheckIndices}
IF fCheckIndices THEN
BEGIN
IF atIndex <> (SELF.size + 1) THEN
SELF.CheckIndex(atIndex);
IF deltaMembers < 0 THEN
SELF.CheckIndex(atIndex - 1 - deltaMembers);
END;
{$ENDC}
*****)
oldHoSize := SELF.holeSize;
oldHoStart := SELF.holeStart;
IF (deltaMembers < 0) AND ((oldHoStart + 1) = atIndex) THEN {the hole is right before the deletion}
SELF.holeStart := oldHoStart - deltaMembers {deltaMembers is going to be added in again later}
ELSE
BEGIN
newHoStart := atIndex - 1 - Min(deltaMembers, 0);
IF (deltaMembers > oldHoSize) OR (newHoStart <> oldHoStart) THEN
BEGIN
maxHoStart := Max(oldHoStart, newHoStart);
newHoSize := Max(oldHoSize, deltaMembers);
IF newHoSize > oldHoSize THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 623 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

{increase the space allocated to the collection, and shift the collection so that the
the last real element is at the end of the space allocated to the collection;
but only move REAL elements that will end up after the hole}
size := SELF.size;
newHoSize := Max(newHoSize, SELF.holeStd);
SELF.ResizeColl(size + newHoSize);
SELF.ShiftColl(maxHoStart + oldHoSize, maxHoStart + newHoSize, size - maxHoStart);
{Explanation of the above line:
maxHoStart = max # real elements before the hole (in initial and final collections)
size = # real elements in the initial collection
therefore, size - maxHoStart is min # real elements after the hole, which
is the right number of elements to move
the allocated size of the collection is size + newHoSize (from SELF.ResizeColl)
to get the last real element we are moving to be at the end of the allocated space,
we need to move the first element to
allocated size of collection - # elements moving
=
size + newHoSize - (size - maxHoStart)
=
maxHoStart + newHoSize
we increased the size of the collection by newHoSize - oldHoSize
therefore the first source element must be
first destination element - (newHoSize - oldHoSize)
=
maxHoStart + newHoSize - (newHoSize - oldHoSize)
=
maxHoStart + oldHoSize

}
END;

IF newHoStart <> oldHoStart THEN


BEGIN
b := ORD(newHoStart > oldHoStart);

{1 if hole is moving right and data is moving left,


0 otherwise}
minHoStart := Min(oldHoStart, newHoStart);
SELF.ShiftColl(minHoStart + oldHoSize*b, minHoStart + newHoSize*(1-b),
maxHoStart - minHoStart);
END;

SELF.holeStart := newHoStart;
SELF.holeSize := newHoSize;
END;
END;
WITH SELF DO
BEGIN
size := size + deltaMembers;
holeSize := holeSize - deltaMembers;

Apple Lisa ToolKit 3.0 Source Code Listing -- 624 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

holeStart := holeStart + deltaMembers;


IF oldHoSize = 0 THEN
IF holeStd = 0 THEN
IF holeSize > 0 THEN
{$H-}
SELF.StopEdit; {$H+}
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TCollection.Equals(otherCollection: TCollection): BOOLEAN;
LABEL 1;
VAR memberBytes: INTEGER;
size:
INTEGER;
i:
INTEGER;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
Equals := FALSE;
memberBytes := SELF.MemberBytes;
size := SELF.size;
IF SELF = otherCollection THEN
Equals := TRUE
ELSE
IF size = otherCollection.size THEN
IF memberBytes = otherCollection.MemberBytes THEN
BEGIN
FOR i := 1 TO size DO
IF NOT EqualBytes(Ptr(SELF.AddrMember(i)), Ptr(otherCollection.AddrMember(i)),
memberBytes) THEN
GOTO 1;
Equals := TRUE;
END;
1:
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
PROCEDURE TCollection.InsManyAt(i: LONGINT; otherCollection: TCollection; index, howMany: LONGINT);
BEGIN
{Stops edit if it wasn't explicitly started}
{$IFC fTrace}BP(3);{$ENDC}
{$IFC fDbgObject}
IF SELF.dynStart = MAXINT THEN
ABCBreak('No dynamic part', i);
{$ENDC}
{$IFC fCheckIndices}

Apple Lisa ToolKit 3.0 Source Code Listing -- 625 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

IF fCheckIndices AND (howMany > 0) THEN


BEGIN {i is checked by EditAt}
IF SELF.memberBytes <> otherCollection.MemberBytes THEN
BEGIN
WriteLn;
WriteLn('*** ERROR: Tried to insert ', otherCollection.MemberBytes:1,
'-byte Members into a TCollection with ', SELF.memberBytes, '-byte Members');
ABCbreak('InsManyAt', howMany);
END;
(***** Dont need range checks anymore
otherCollection.CheckIndex(index);
otherCollection.CheckIndex(index + howMany - 1);
*****)
END;
{$ENDC}
IF howMany > 0 THEN
BEGIN
SELF.EditAt(i, howMany);
otherCollection.CopyMembers(SELF.AddrMember(i), index, howMany);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TCollection.InsNullsAt(i, howMany: LONGINT);
VAR dstAddr:
LONGINT;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
{$IFC fDbgObject}
IF SELF.dynStart = MAXINT THEN
ABCBreak('No dynamic part', i);
{$ENDC}
SELF.EditAt(i, howMany);
IF howMany > 0 THEN
BEGIN
dstAddr := SELF.AddrMember(i);
TPByte(dstAddr)^ := 0;
XferLeft(Ptr(dstAddr), Ptr(dstAddr + 1), howMany * SELF.MemberBytes-1);
{WARNING: The success of the preceding line depends on the fact the XferLeft
copies data 1 byte at a time; use of a routine that tries to optimize the
transfer will negatively impact the correctness of this method.}
END;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 626 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

{$S sResDat}
{NOTE: This routine does not preserve the TCollection invariant.}
PROCEDURE TCollection.ResizeColl(membersPlusHole: INTEGER);
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
{$IFC fDbgObject}
IF SELF.dynStart = MAXINT THEN
ABCBreak('No dynamic part', membersPlusHole);
{$ENDC}
IF membersPlusHole <> (SELF.size + SELF.holeSize) THEN
ResizeDynObject(SELF, SELF.dynStart + (membersPlusHole * SELF.MemberBytes));
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
{NOTE: This routine does not preserve the TCollection invariant.}
PROCEDURE TCollection.ShiftColl(afterSrcIndex, afterDstIndex, howMany: INTEGER);
VAR memberBytes:
INTEGER;
numBytes:
INTEGER;
startAddr:
LONGINT;
srcAddr:
LONGINT;
dstAddr:
LONGINT;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
{$IFC fDbgObject}
IF SELF.dynStart = MAXINT THEN
ABCBreak('No dynamic part', howMany);
{$ENDC}
IF (howMany > 0) AND (afterSrcIndex <> afterDstIndex) THEN
BEGIN
memberBytes := SELF.MemberBytes;
numBytes := howMany * memberBytes;
startAddr := TpLONGINT(SELF)^ + SELF.dynStart;
srcAddr := startAddr + afterSrcIndex * memberBytes;
dstAddr := startAddr + afterDstIndex * memberBytes;
IF afterSrcIndex < afterDstIndex THEN
XferRight(Ptr(srcAddr), Ptr(dstAddr), numBytes)
ELSE
XferLeft(Ptr(srcAddr), Ptr(dstAddr), numBytes);

Apple Lisa ToolKit 3.0 Source Code Listing -- 627 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TCollection.StartEdit(withSlack: INTEGER);
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
{$IFC fDbgObject}
IF SELF.dynStart = MAXINT THEN
ABCBreak('No dynamic part', withSlack);
{$ENDC}
SELF.holeStd := withSlack;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
PROCEDURE TCollection.StopEdit;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
{$IFC fDbgObject}
IF SELF.dynStart = MAXINT THEN
ABCBreak('No dynamic part', 0);
{$ENDC}
IF SELF.holeStart < SELF.size THEN
SELF.EditAt(SELF.size + 1, 0);
SELF.ResizeColl(SELF.size);
SELF.holeStd := 0;
SELF.holeSize := 0;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sInit1}
BEGIN
{$IFC fCheckIndices}
fCheckIndices := FALSE;
{$ENDC}
END;
{$S SgCLAres}

Apple Lisa ToolKit 3.0 Source Code Listing -- 628 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

METHODS OF TList;
{$S sResDat}
FUNCTION TList.CREATE(object: TObject; heap: THeap; initialSlack: INTEGER): TList;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
IF object = NIL THEN
object := NewDynObject(heap, THISCLASS, initialSlack * SIZEOF(Handle));
SELF := TList(TCollection.CREATE(object, heap, initialSlack));
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
PROCEDURE TList.Free;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
SELF.Each(Free);
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TList.Clone(heap: THeap): TObject;
VAR l: TList;
j: INTEGER;
x: TObject;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
l := TList(SUPERSELF.Clone(heap));
FOR j := 1 TO l.size DO
BEGIN
x := SELF.At(j);
IF x <> NIL THEN
l.PutAt(j, x.Clone(heap), FALSE);
END;
Clone := l;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S SgCLAdbg}
PROCEDURE TList.Debug(numLevels: INTEGER; memberTypeStr: S255);
VAR s:
TListScanner;
obj:
TObject;

Apple Lisa ToolKit 3.0 Source Code Listing -- 629 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

str:
S8;
first:
BOOLEAN;
{$IFC fTrace}
oldFlag:
BOOLEAN;
{$ENDC}
BEGIN
{$IFC fTrace}
oldFlag := fDebugRecursion;
fDebugRecursion := TRUE;
{$ENDC}
SUPERSELF.Debug(numLevels, '');
{ this prints other fields of the list }
IF numLevels > 0 THEN
BEGIN
WrStr('(');
IF numLevels = 1 THEN
{ compressed list of classes }
SELF.DebugMembers
ELSE
{ list of classes and their handles }
BEGIN
s := SELF.Scanner;
IF s.position = SELF.holeStart THEN
Write('<=HOLE=>');
first := TRUE;
WHILE s.Scan(obj) DO
BEGIN
IF NOT first THEN
WrStr(', ');
first := FALSE;
IF obj = NIL THEN
WrStr('NIL')
ELSE IF ValidObject(Handle(obj)) THEN
obj.Debug(numLevels-2, '')
ELSE
WrStr('<Invalid Object>');
IF numLevels = 2 THEN
BEGIN
LIntToHex(ORD4(obj), @str);
WrStr(CONCAT(': $', str));
END;
IF s.position = SELF.holeStart THEN
Write('<=HOLE=>');
END;
END;
WrStr(')');
END;
{$IFC fTrace}
fDebugRecursion := oldFlag;

Apple Lisa ToolKit 3.0 Source Code Listing -- 630 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

{$ENDC}
END;
{$S SgCLAres}
{$S SgCLAdbg}
PROCEDURE TList.DebugMembers;
VAR y:
TObject;
s:
TListScanner;
str:
S8;
initial:
BOOLEAN;
class:
TClass;
thisClass:
TClassName;
prevClass:
TClassName;
sameClass:
INTEGER;
charCount:
INTEGER;
PROCEDURE WriteMembers;
VAR charsNeeded:
INTEGER;
BEGIN
IF sameClass = 0 THEN EXIT(WriteMembers);
IF sameClass = 1 THEN
charsNeeded := 10
ELSE
charsNeeded := 13;
IF initial THEN
initial := FALSE
ELSE IF (charCount + charsNeeded) > 70 THEN
BEGIN
WrStr(',');
WrLn;
WrStr('
');
charCount := 10;
END
ELSE
WrStr(', ');
str := prevClass;
WrStr(str);
IF sameClass > 1 THEN
BEGIN
IntToStr(sameClass, @str);
WrStr(CONCAT('*', str));
END;
charCount := charCount + charsNeeded;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 631 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

BEGIN
IF SELF.size > 0 THEN {prevent initialization anomaly in BP(i)/EP}
BEGIN
charCount := cMin(indentTrace, 20) + 30;
initial := TRUE;
sameClass := 0;
prevClass := '';
s := SELF.Scanner;
WHILE s.Scan(y) DO
BEGIN
IF y = NIL THEN
thisClass := 'NIL'
ELSE IF ValidObject(Handle(y)) THEN
BEGIN
class := y.Class;
CpToCn(TPSliceTable(class), TS8(thisClass));
END
ELSE
thisClass := '????????';
IF thisClass <> prevClass THEN
BEGIN
WriteMembers;
sameClass := 1;
END
ELSE
sameClass := sameClass + 1;
prevClass := thisClass;
END;
WriteMembers;
END;

END;
{$S SgCLAres}
{$ENDC}

{$S sResDat}
FUNCTION TList.At(i: LONGINT): TObject;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
{$IFC fCheckIndices}
IF fCheckIndices THEN
SELF.CheckIndex(i);
{$ENDC}
{At := TPObject(SELF.AddrMember(i))^;

but for speed...}

Apple Lisa ToolKit 3.0 Source Code Listing -- 632 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

IF i > SELF.holeStart THEN


i := i + SELF.holeSize;
At := TPObject(TpLONGINT(SELF)^ + SELF.dynStart + (4 * (i - 1)))^;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TList.DelAll(freeOld: BOOLEAN);
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
IF freeOld THEN
SELF.Each(Free);
SELF.EditAt(1, -SELF.size);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TList.DelAt(i: LONGINT; freeOld: BOOLEAN);
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
{$IFC fCheckIndices}
IF fCheckIndices THEN
SELF.CheckIndex(i);
{$ENDC}
IF freeOld THEN
Free(SELF.At(i));
SELF.EditAt(i, -1);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TList.DelFirst(freeOld: BOOLEAN);
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.DelAt(1, freeOld);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TList.DelLast(freeOld: BOOLEAN);
BEGIN
{$IFC fTrace}BP(3);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 633 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

SELF.DelAt(SELF.size, freeOld);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TList.DelManyAt(i, howMany: LONGINT; freeOld: BOOLEAN);
VAR j: INTEGER;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
IF howMany > 0 THEN
BEGIN
{$IFC fCheckIndices}
IF fCheckIndices THEN
BEGIN
SELF.CheckIndex(i);
SELF.CheckIndex(i+howMany-1);
END;
{$ENDC}
IF freeOld THEN
FOR j := 0 TO howMany - 1 DO
Free(SELF.At(i + j));
SELF.EditAt(i, -howMany);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TList.DelObject(object: TObject; freeOld: BOOLEAN);
VAR y: TObject;
s: TListScanner;
BEGIN
{If there is more than one occurrence, and editing is off, this calls StopEdit more than once}
{$IFC fTrace}BP(4);{$ENDC}
s := SELF.Scanner;
WHILE s.Scan(y) DO
IF y = object THEN
s.Delete(FALSE);
IF freeOld THEN
Free(object);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
PROCEDURE TList.Each(PROCEDURE DoToObject(object: TObject));
VAR holeStart: INTEGER;
offset:
INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 634 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

j:
pObject:

INTEGER;
TPObject;

BEGIN
{$IFC fTrace}BP(4);{$ENDC}
holeStart := SELF.holeStart;
offset := SELF.dynStart;
FOR j := 0 TO SELF.size - 1 DO
BEGIN
IF j = holeStart THEN
offset := offset + 4 * SELF.holeSize;
pObject := TPObject(TpLONGINT(SELF)^ + offset);
DoToObject(pObject^);
offset := offset + 4;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
FUNCTION
BEGIN
{$IFC
First
{$IFC
END;

TList.First: TObject;
fTrace}BP(3);{$ENDC}
:= SELF.At(1);
fTrace}EP;{$ENDC}

{$S sResDat}
PROCEDURE TList.InsAt(i: LONGINT; object: TObject);
VAR pObject:
TPObject;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
SELF.EditAt(i, 1);
pObject := TPObject(SELF.AddrMember(i));
pObject^ := object;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TList.InsFirst(object: TObject);
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.InsAt(1, object);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 635 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

{$S sResDat}
PROCEDURE TList.InsLast(object: TObject);
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.InsAt(SELF.size + 1, object);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
FUNCTION TList.Last: TObject;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
Last := SELF.At(SELF.size);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TList.ManyAt(i, howMany: LONGINT): TList;
VAR list: TList;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
list := TList.CREATE(NIL, SELF.Heap, howMany);
list.InsManyAt(1, SELF, i, howMany);
ManyAt := list;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
FUNCTION TList.MemberBytes: INTEGER;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
MemberBytes := 4;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TList.PopLast: TObject;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
PopLast := SELF.Last;
SELF.DelLast(FALSE);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 636 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

{$S sResDat}
FUNCTION TList.Pos(after: LONGINT; object: TObject): LONGINT;
VAR y: TObject;
s: TListScanner;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
Pos := after;
s := SELF.ScannerFrom(after, scanForward);
WHILE s.Scan(y) DO
IF object = y THEN
BEGIN
Pos := s.position;
s.Done;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TList.PutAt(i: LONGINT; object: TObject; freeOld: BOOLEAN);
VAR pObject:
TPObject;
oldObject: TObject;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
{$IFC fCheckIndices}
IF fCheckIndices THEN
SELF.CheckIndex(i);
{$ENDC}
{pObject := TPObject(SELF.AddrMember(i));

but for speed...}

IF i > SELF.holeStart THEN


i := i + SELF.holeSize;
pObject := TPObject(TpLONGINT(SELF)^ + SELF.dynStart + (4 * (i - 1)));
oldObject := pObject^;
pObject^ := object;
IF freeOld THEN
IF object <> oldObject THEN
Free(oldObject);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}

Apple Lisa ToolKit 3.0 Source Code Listing -- 637 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

FUNCTION TList.Scanner: TListScanner;


BEGIN
{$IFC fTrace}BP(2);{$ENDC}
Scanner := TListScanner.CREATE(NIL, SELF, 0, scanForward);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
FUNCTION TList.ScannerFrom(firstToScan: LONGINT; scanDirection: TScanDirection): TListScanner;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
ScannerFrom := TListScanner.CREATE(NIL, SELF, firstToScan, scanDirection);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sInit1}
{$IFC compatibleLists} {For TIndexList.Class}
BEGIN
cList := THISCLASS;
{$ENDC}
END;
{$S SgCLAres}
METHODS OF TArray;
{$S sResDat}
FUNCTION TArray.CREATE(object: TObject; heap: THeap; initialSlack, bytesPerRecord: INTEGER): TArray;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
IF ODD(bytesPerRecord) THEN
bytesPerRecord := bytesPerRecord + 1;
IF object = NIL THEN
object := NewDynObject(heap, THISCLASS, initialSlack * bytesPerRecord);
SELF := TArray(TCollection.CREATE(object, heap, initialSlack));
SELF.recordBytes := bytesPerRecord;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S SgCLAdbg}
PROCEDURE TArray.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);

Apple Lisa ToolKit 3.0 Source Code Listing -- 638 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

Field('recordBytes: INTEGER');
END;
{$S SgCLAres}
{$ENDC}
{$IFC fDebugMethods}
{$S SgCLAdbg}
PROCEDURE TArray.Debug(numLevels: INTEGER; memberTypeStr: S255);
VAR s:
TArrayScanner;
pRecord:
Ptr;
i:
INTEGER;
j:
INTEGER;
str:
S255;
hexOrd:
S8;
PROCEDURE SupplyMember(PROCEDURE Field(nameAndType: S255));
BEGIN
Field(Concat(str, ': ', memberTypeStr));
END;
BEGIN
SUPERSELF.Debug(numLevels, '');
{ this prints other fields of the array }
IF (numLevels > 1) OR ((numLevels = 1) AND (memberTypeStr <> '')) THEN
BEGIN
WrStr('{ ');
i := 0;
s := SELF.Scanner;
IF s.position = SELF.holeStart THEN
WrStr(' <=HOLE=> ');
WHILE s.Scan(pRecord) DO
BEGIN
IF i > 0 THEN
WrStr(', ');
i := i + 1;
IntToStr(i, @str);
IF memberTypeStr = '' THEN
BEGIN
str := CONCAT(str, ': ');
FOR j := 0 TO SELF.recordBytes-1 DO
BEGIN
LIntToHex(TPByte(ORD(pRecord)+j)^, @hexOrd);
str := CONCAT(str, Copy(hexOrd, 7, 2));
END;
WrStr(str);
END
ELSE
WriteDRecord(numLevels - 1, @pRecord, 0, SupplyMember);

Apple Lisa ToolKit 3.0 Source Code Listing -- 639 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

IF s.position = SELF.holeStart THEN


WrStr(', <=HOLE=> ');
END;
WrStr(' }');
END;

END;
{$S SgCLAres}
{$ENDC}

{$S sResDat}
FUNCTION TArray.At(i: LONGINT): Ptr;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
{$IFC fCheckIndices}
IF fCheckIndices THEN
SELF.CheckIndex(i);
{$ENDC}
{ At := Ptr(SELF.AddrMember(i));

but for speed...}

IF i > SELF.holeStart THEN


i := i + SELF.holeSize;
At := Ptr(TpLONGINT(SELF)^ + SELF.dynStart + (SELF.recordBytes * (i - 1)));
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TArray.DelAll;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
SELF.EditAt(1, -SELF.size);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TArray.DelAt(i: LONGINT);
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
SELF.EditAt(i, -1);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}

Apple Lisa ToolKit 3.0 Source Code Listing -- 640 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

PROCEDURE TArray.DelFirst;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.DelAt(1);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TArray.DelLast;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.DelAt(SELF.size);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TArray.DelManyAt(i, howMany: LONGINT);
VAR j: INTEGER;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
IF howMany > 0 THEN
SELF.EditAt(i, -howMany);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TArray.Each(PROCEDURE DoToRecord(pRecord: Ptr));
VAR holeStart:
INTEGER;
offset:
INTEGER;
recordBytes:
INTEGER;
j:
INTEGER;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
holeStart := SELF.holeStart;
offset := SELF.dynStart;
recordBytes := SELF.recordBytes;
FOR j := 0 TO SELF.size - 1 DO
BEGIN
IF j = holeStart THEN
offset := offset + recordBytes * SELF.holeSize;
DoToRecord(Ptr(TpLONGINT(SELF)^ + offset));
offset := offset + recordBytes;
END;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 641 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

{$S SgABCdat}
FUNCTION
BEGIN
{$IFC
First
{$IFC
END;

TArray.First: Ptr;
fTrace}BP(3);{$ENDC}
:= SELF.At(1);
fTrace}EP;{$ENDC}

{$S sResDat}
PROCEDURE TArray.GetAt(i: LONGINT; pRecord: Ptr);
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
{$IFC fCheckIndices}
IF fCheckIndices THEN
SELF.CheckIndex(i);
{$ENDC}
XferLeft(Ptr(SELF.AddrMember(i)), pRecord, SELF.recordBytes);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
PROCEDURE TArray.InsAt(i: LONGINT; pRecord: Ptr);
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
SELF.EditAt(i, 1);
SELF.PutAt(i, pRecord);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
PROCEDURE TArray.InsFirst(pRecord: Ptr);
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.InsAt(1, pRecord);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
PROCEDURE TArray.InsLast(pRecord: Ptr);
BEGIN
{$IFC fTrace}BP(3);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 642 of 1012

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163
001164
001165
001166
001167
001168
001169
001170
001171
001172
001173
001174
001175
001176
001177
001178
001179
001180
001181
001182
001183
001184
001185
001186
001187
001188
001189
001190
001191
001192
001193
001194
001195

SELF.InsAt(SELF.size + 1, pRecord);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TArray.Last: Ptr;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
Last := SELF.At(SELF.size);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TArray.ManyAt(i, howMany: LONGINT): TArray;
VAR arr: TArray;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
arr := TArray.CREATE(NIL, SELF.Heap, howMany, SELF.recordBytes);
arr.InsManyAt(1, SELF, i, howMany);
ManyAt := arr;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
FUNCTION TArray.MemberBytes: INTEGER;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
MemberBytes := SELF.recordBytes;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TArray.Pos(after: LONGINT; pRecord: Ptr): LONGINT;
VAR y: Ptr;
s: TArrayScanner;
FUNCTION EqualRecords(p, q: Ptr; n: INTEGER): BOOLEAN; {n is even}
VAR i: INTEGER;
BEGIN
EqualRecords := FALSE;
i := 0;
WHILE i < n DO
BEGIN
IF TpINTEGER(ORD(p) + i)^ <> TpINTEGER(ORD(q) + i)^ THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 643 of 1012

Apple Lisa Computer Technical Information


001196
001197
001198
001199
001200
001201
001202
001203
001204
001205
001206
001207
001208
001209
001210
001211
001212
001213
001214
001215
001216
001217
001218
001219
001220
001221
001222
001223
001224
001225
001226
001227
001228
001229
001230
001231
001232
001233
001234
001235
001236
001237
001238
001239
001240
001241
001242
001243

EXIT(EqualRecords);
i := i + 2;
END;
EqualRecords := TRUE;
END;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
Pos := after;
s := SELF.ScannerFrom(after, scanForward);
WHILE s.Scan(y) DO
IF EqualRecords(pRecord, y, SELF.recordBytes) THEN
BEGIN
Pos := s.position;
s.Done;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
PROCEDURE TArray.PutAt(i: LONGINT; pRecord: Ptr);
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
{$IFC fCheckIndices}
IF fCheckIndices THEN
SELF.CheckIndex(i);
{$ENDC}
XferLeft(pRecord, Ptr(SELF.AddrMember(i)), SELF.recordBytes);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TArray.Scanner: TArrayScanner;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
Scanner := TArrayScanner.CREATE(NIL, SELF, 0, scanForward);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TArray.ScannerFrom(firstToScan: LONGINT; scanDirection: TScanDirection): TArrayScanner;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
ScannerFrom := TArrayScanner.CREATE(NIL, SELF, firstToScan, scanDirection);

Apple Lisa ToolKit 3.0 Source Code Listing -- 644 of 1012

Apple Lisa Computer Technical Information


001244
001245
001246
001247
001248
001249
001250
001251
001252
001253
001254
001255
001256
001257
001258
001259
001260
001261
001262
001263
001264
001265
001266
001267
001268
001269
001270
001271
001272
001273
001274
001275
001276
001277
001278
001279
001280
001281
001282
001283
001284
001285
001286
001287
001288
001289
001290
001291

{$IFC fTrace}EP;{$ENDC}
END;
{$S sInit1}
{$IFC compatibleLists} {For TDynamicArray.Class}
BEGIN
cArray := THISCLASS;
{$ENDC}
END;
METHODS OF TString;
{$S sResDat}
FUNCTION TString.CREATE(object: TObject; heap: THeap; initialSlack: INTEGER): TString;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
IF ODD(initialSlack) THEN
initialSlack := initialSlack + 1;
IF object = NIL THEN
object := NewDynObject(heap, THISCLASS, initialSlack);
SELF := TString(TCollection.CREATE(object, heap, initialSlack));
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S SgCLAdbg}
PROCEDURE TString.Debug(numLevels: INTEGER; memberTypeStr: S255);
VAR s:
TStringScanner;
ch:
CHAR;
str:
S8;
BEGIN
SUPERSELF.Debug(numLevels, '');
{ this prints other fields of the list }
IF numLevels > 0 THEN
BEGIN
WrStr('''');
s := SELF.Scanner;
IF s.position = SELF.holeStart THEN
WrStr('<=HOLE=>');
str := 'x';
WHILE s.Scan(ch) DO
BEGIN
str[1] := ch;
WrStr(str);
IF s.position = SELF.holeStart THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 645 of 1012

Apple Lisa Computer Technical Information


001292
001293
001294
001295
001296
001297
001298
001299
001300
001301
001302
001303
001304
001305
001306
001307
001308
001309
001310
001311
001312
001313
001314
001315
001316
001317
001318
001319
001320
001321
001322
001323
001324
001325
001326
001327
001328
001329
001330
001331
001332
001333
001334
001335
001336
001337
001338
001339

WrStr('<=HOLE=>');
END;
WrStr('''');
END;

END;
{$S SgCLAres}
{$ENDC}

{$S SgCLAres}
FUNCTION TString.At(i: LONGINT): CHAR;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
{$IFC fCheckIndices}
IF fCheckIndices THEN
SELF.CheckIndex(i);
{$ENDC}
IF i > SELF.holeStart THEN
i := i + SELF.holeSize;
At := TpPAOC(TpLONGINT(SELF)^ + SELF.dynStart)^[i];
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
PROCEDURE TString.DelAll;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
SELF.EditAt(1, -SELF.size);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
PROCEDURE TString.DelAt(i: LONGINT);
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
SELF.EditAt(i, -1);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
PROCEDURE TString.DelFirst;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.DelAt(1);

Apple Lisa ToolKit 3.0 Source Code Listing -- 646 of 1012

Apple Lisa Computer Technical Information


001340
001341
001342
001343
001344
001345
001346
001347
001348
001349
001350
001351
001352
001353
001354
001355
001356
001357
001358
001359
001360
001361
001362
001363
001364
001365
001366
001367
001368
001369
001370
001371
001372
001373
001374
001375
001376
001377
001378
001379
001380
001381
001382
001383
001384
001385
001386
001387

{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
PROCEDURE TString.DelLast;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.DelAt(SELF.size);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
PROCEDURE TString.DelManyAt(i, howMany: LONGINT);
VAR j: INTEGER;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
IF howMany > 0 THEN
SELF.EditAt(i, -howMany);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
PROCEDURE TString.Draw(i: LONGINT; howMany: INTEGER);
VAR beforeHole: INTEGER;
pWord1:
TpINTEGER;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
beforeHole := Min(SELF.holeStart - (i - 1), howMany);
pWord1 := TpINTEGER(TpLONGINT(SELF)^ + SELF.dynStart);
IF beforeHole > 0 THEN
DrawLText(pWord1, i - 1, beforeHole);
IF beforeHole < howMany THEN
DrawLText(pWord1, SELF.holeStart + SELF.holeSize - Min(beforeHole, 0),
howMany - Max(beforeHole, 0));
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
FUNCTION TString.Width(i: LONGINT; howMany: INTEGER): INTEGER;
VAR beforeHole: INTEGER;
pWord1:
TpINTEGER;
totalWidth: INTEGER;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 647 of 1012

Apple Lisa Computer Technical Information


001388
001389
001390
001391
001392
001393
001394
001395
001396
001397
001398
001399
001400
001401
001402
001403
001404
001405
001406
001407
001408
001409
001410
001411
001412
001413
001414
001415
001416
001417
001418
001419
001420
001421
001422
001423
001424
001425
001426
001427
001428
001429
001430
001431
001432
001433
001434
001435

beforeHole := Min(SELF.holeStart - (i - 1), howMany);


pWord1 := TpINTEGER(TpLONGINT(SELF)^ + SELF.dynStart);
totalWidth := 0;
IF beforeHole > 0 THEN
totalWidth := TextWidth(pWord1, i - 1, beforeHole);
IF beforeHole < howMany THEN
totalWidth := totalWidth + TextWidth(pWord1, SELF.holeStart + SELF.holeSize - Min(beforeHole, 0),
howMany - Max(beforeHole, 0));
Width := totalWidth;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
PROCEDURE TString.Each(PROCEDURE DoToCharacter(character: CHAR));
VAR holeStart:
INTEGER;
offset:
INTEGER;
j:
INTEGER;
pChars:
TpPAOC;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
holeStart := SELF.holeStart;
pChars := TpPAOC(TpLONGINT(SELF)^ + SELF.dynStart);
offset := 1;
FOR j := 0 TO SELF.size - 1 DO
BEGIN
IF j = holeStart THEN
offset := offset + SELF.holeSize;
DoToCharacter(pChars^[offset]);
offset := offset + 1;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
FUNCTION
BEGIN
{$IFC
First
{$IFC
END;

TString.First: CHAR;
fTrace}BP(3);{$ENDC}
:= SELF.At(1);
fTrace}EP;{$ENDC}

{$S SgCLAres}
PROCEDURE TString.InsAt(i: LONGINT; character: CHAR);
VAR pPAOC:
TpPAOC;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 648 of 1012

Apple Lisa Computer Technical Information


001436
001437
001438
001439
001440
001441
001442
001443
001444
001445
001446
001447
001448
001449
001450
001451
001452
001453
001454
001455
001456
001457
001458
001459
001460
001461
001462
001463
001464
001465
001466
001467
001468
001469
001470
001471
001472
001473
001474
001475
001476
001477
001478
001479
001480
001481
001482
001483

{$IFC fTrace}BP(4);{$ENDC}
SELF.EditAt(i, 1);
pPAOC := TpPAOC(TpLONGINT(SELF)^ + SELF.dynStart);
pPAOC^[i] := character;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
PROCEDURE TString.InsFirst(character: CHAR);
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.InsAt(1, character);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
PROCEDURE TString.InsLast(character: CHAR);
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.InsAt(SELF.size + 1, character);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
PROCEDURE TString.InsPStrAt(i: LONGINT; pStr: TPString);
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.EditAt(i, Length(pStr^));
XferLeft(Ptr(ORD(pStr)+1), Ptr(SELF.AddrMember(i)), Length(pStr^));
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
FUNCTION TString.Last: CHAR;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
Last := SELF.At(SELF.size);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
FUNCTION TString.ManyAt(i, howMany: LONGINT): TString;

Apple Lisa ToolKit 3.0 Source Code Listing -- 649 of 1012

Apple Lisa Computer Technical Information


001484
001485
001486
001487
001488
001489
001490
001491
001492
001493
001494
001495
001496
001497
001498
001499
001500
001501
001502
001503
001504
001505
001506
001507
001508
001509
001510
001511
001512
001513
001514
001515
001516
001517
001518
001519
001520
001521
001522
001523
001524
001525
001526
001527
001528
001529
001530
001531

VAR str: TString;


BEGIN
{$IFC fTrace}BP(4);{$ENDC}
str := TString.CREATE(NIL, SELF.Heap, howMany);
str.InsManyAt(1, SELF, i, howMany);
ManyAt := str;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
FUNCTION TString.MemberBytes: INTEGER;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
MemberBytes := 1;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
FUNCTION TString.Pos(after: LONGINT; character: CHAR): LONGINT;
VAR y: CHAR;
s: TStringScanner;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
Pos := after;
s := SELF.ScannerFrom(after, scanForward);
WHILE s.Scan(y) DO
IF y = character THEN
BEGIN
Pos := s.position;
s.Done;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
PROCEDURE TString.PutAt(i: LONGINT; character: CHAR);
VAR pPAOC: TpPAOC;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
{$IFC fCheckIndices}
IF fCheckIndices THEN
SELF.CheckIndex(i);
{$ENDC}
IF i > SELF.holeStart THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 650 of 1012

Apple Lisa Computer Technical Information


001532
001533
001534
001535
001536
001537
001538
001539
001540
001541
001542
001543
001544
001545
001546
001547
001548
001549
001550
001551
001552
001553
001554
001555
001556
001557
001558
001559
001560
001561
001562
001563
001564
001565
001566
001567
001568
001569
001570
001571
001572
001573
001574
001575
001576
001577
001578
001579

i := i + SELF.holeSize;
pPAOC := TpPAOC(TpLONGINT(SELF)^ + SELF.dynStart);
pPAOC^[i] := character;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
FUNCTION TString.Scanner: TStringScanner;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
Scanner := TStringScanner.CREATE(NIL, SELF, 0, scanForward);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
FUNCTION TString.ScannerFrom(firstToScan: LONGINT; scanDirection: TScanDirection): TStringScanner;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
ScannerFrom := TStringScanner.CREATE(NIL, SELF, firstToScan, scanDirection);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
PROCEDURE TString.ToPStr(pStr: TPString);
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.ToPStrAt(1, SELF.size, pStr);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
PROCEDURE TString.ToPStrAt(i, howMany: LONGINT; pStr: TPString);
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
{$IFC fCheckIndices}
IF howMany > 255 THEN
ABCBreak('ToPStrAt: Too many characters', howMany);
{$ENDC}
SELF.EditAt(i + howMany, 0);
XferLeft(Ptr(SELF.AddrMember(i)), Ptr(ORD(pStr)+1), howMany);
{$R-} pStr^[0] := CHAR(howMany); {$IFC fRngObject}{$R+}{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 651 of 1012

Apple Lisa Computer Technical Information


001580
001581
001582
001583
001584
001585
001586
001587
001588
001589
001590
001591
001592
001593
001594
001595
001596
001597
001598
001599
001600
001601
001602
001603
001604
001605
001606
001607
001608
001609
001610
001611
001612
001613
001614
001615
001616
001617
001618
001619
001620
001621
001622
001623
001624
001625
001626
001627

{$S sInit1}
END;
{$S SgCLAres}
METHODS OF TFile;
{$S sResDat}
FUNCTION

TFile.CREATE(object: TObject; heap: THeap; itsPath: TFilePath;


itsPassword: TPassword): TFile;
VAR pPath:
TPPathname;
error:
INTEGER;
{$IFC LibraryVersion <= 20}
fsInfo:
FS_Info;
{$ELSEC}
fsInfo:
Q_Info;
{$ENDC}
itsScanners:
TList;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TFile(TCollection.CREATE(object, heap, 0)); {Just to initialize those ignored fields}
pPath := @itsPath;
{$IFC LibraryVersion <= 20}
Lookup(error, pPath^, fsInfo);
{$ELSEC}
Quick_Lookup(error, pPath^, fsInfo);
{$ENDC}
itsScanners := TList.CREATE(NIL, heap, 0);
WITH SELF DO
BEGIN
dynStart := MAXINT;
IF error > 0 THEN
size := 0
ELSE
size := fsInfo.size;
path := itsPath;
password := itsPassword;
scanners := itsScanners;
END;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 652 of 1012

Apple Lisa Computer Technical Information


001628
001629
001630
001631
001632
001633
001634
001635
001636
001637
001638
001639
001640
001641
001642
001643
001644
001645
001646
001647
001648
001649
001650
001651
001652
001653
001654
001655
001656
001657
001658
001659
001660
001661
001662
001663
001664
001665
001666
001667
001668
001669
001670
001671
001672
001673
001674
001675

{$S sResDat}
PROCEDURE TFile.Free;
BEGIN
{$IFC fTrace}BP(5);{$ENDC}
SELF.scanners.Free;
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}

{Free frees the scanners as well}

{$IFC fDbgObject}
{$S SgCLAdbg}
FUNCTION TFile.Clone(heap: THeap): TObject;
BEGIN
ABCBreak('A TFile cannot Clone', 0);
END;
{$S SgCLAres}
{$ENDC}
{$IFC fDebugMethods}
{$S SgCLAdbg}
PROCEDURE TFile.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('path: STRING[255]');
Field('password: STRING[32]');
Field('scanners: TList');
END;
{$S SgCLAres}
{$ENDC}
{$S SgCLAcld}
PROCEDURE TFile.ChangePassword(VAR error: INTEGER; newPassword: TPassword);
VAR pPath:
TPPathname;
pPass:
TPEName;
pNPass:
TPEName;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
{$IFC LibraryVersion <= 20}
error := -1293; {warning: file is not password protected}
{$ELSEC}
pPath := @SELF.path;
pPass := @SELF.password;

Apple Lisa ToolKit 3.0 Source Code Listing -- 653 of 1012

Apple Lisa Computer Technical Information


001676
001677
001678
001679
001680
001681
001682
001683
001684
001685
001686
001687
001688
001689
001690
001691
001692
001693
001694
001695
001696
001697
001698
001699
001700
001701
001702
001703
001704
001705
001706
001707
001708
001709
001710
001711
001712
001713
001714
001715
001716
001717
001718
001719
001720
001721
001722
001723

pNPass := @newPassword;
Change_Password(error, pPath^, pPass^, pNPass^);
{$ENDC}
IF error <= 0 THEN
SELF.password := newPassword;
END;
{$S SgCLAres}
{$S SgCLAcld}
PROCEDURE TFile.Delete(VAR error: INTEGER);
VAR pPath:
TPPathname;
{$IFC LibraryVersion > 20}
pPass:
TPEName;
{$ENDC}
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
pPath := @SELF.path;
{$IFC LibraryVersion <= 20}
Kill_Object(error, pPath^);
{$ELSEC}
pPass := @SELF.password;
Kill_Secure(error, pPath^, pPass^);
{$ENDC}
END;
{$S SgCLAres}
{$S sResDat}
FUNCTION TFile.Exists(VAR error: INTEGER): BOOLEAN;
{$IFC LibraryVersion <= 20}
VAR refInfo:
FS_Info;
{$ELSEC}
VAR refInfo:
Q_Info;
{$ENDC}
pPath:
TPPathname;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
pPath := @SELF.path;
{$IFC LibraryVersion <= 20}
Lookup(error, pPath^, refInfo);
{$ELSEC}
Quick_Lookup(error, pPath^, refInfo);
{$ENDC}
Exists := error <= 0;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 654 of 1012

Apple Lisa Computer Technical Information


001724
001725
001726
001727
001728
001729
001730
001731
001732
001733
001734
001735
001736
001737
001738
001739
001740
001741
001742
001743
001744
001745
001746
001747
001748
001749
001750
001751
001752
001753
001754
001755
001756
001757
001758
001759
001760
001761
001762
001763
001764
001765
001766
001767
001768
001769
001770
001771

{$S SgCLAres}
{$S SgABCdat}
FUNCTION TFile.MemberBytes: INTEGER;
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
MemberBytes := 1;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAcld}
PROCEDURE TFile.Rename(VAR error: INTEGER; newFileName: TFilePath);
{the volume of newFileName is ignored}
VAR pPath:
TPPathname;
vol:
TFilePath;
name:
TFilePath;
pEName:
TPEname;
{$IFC LibraryVersion > 20}
pPass:
TPEName;
{$ENDC}
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
pPath := @SELF.path;
SplitFilePath(newFileName, vol, name);
pEName := @name;
{$IFC LibraryVersion <= 20}
Rename_Entry(error, pPath^, pEName^);
{$ELSEC}
pPass := @SELF.password;
Rename_Secure(error, pPath^, pEName^, pPass^);
{$ENDC}
END;
{$S SgCLAres}
{$S SgCLAcld}
FUNCTION TFile.Scanner: TFileScanner;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
Scanner := SELF.ScannerFrom(0, [fRead, fWrite]);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}

Apple Lisa ToolKit 3.0 Source Code Listing -- 655 of 1012

Apple Lisa Computer Technical Information


001772
001773
001774
001775
001776
001777
001778
001779
001780
001781
001782
001783
001784
001785
001786
001787
001788
001789
001790
001791
001792
001793
001794
001795
001796
001797
001798
001799
001800
001801
001802
001803
001804
001805
001806
001807
001808
001809
001810
001811
001812
001813
001814
001815
001816
001817
001818
001819

{$S sResDat}
FUNCTION TFile.ScannerFrom(firstToScan: LONGINT; manip: TAccesses): TFileScanner;
VAR s: TFileScanner;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
s := TFileScanner.CREATE(NIL, SELF, manip);
s.Seek(firstToScan);
ScannerFrom := s;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
{$S SgCLAcld}
FUNCTION TFile.VerifyPassword(VAR error: INTEGER; password: TPassword): BOOLEAN;
VAR pPath: TPPathname;
pPass: TPEName;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
{$IFC LibraryVersion <= 20}
error := -1293; {warning file is not password protected}
VerifyPassword := TRUE;
{$ELSEC}
pPath := @SELF.path;
pPass := @password;
Verify_Password(error, pPath^, pPass^);
VerifyPassword := error <= 0;
{$ENDC}
END;
{$S SgCLAres}
{$S SgCLAcld}
FUNCTION TFile.WhenModified(VAR error: INTEGER): LONGINT;
{$IFC LibraryVersion <= 20}
VAR refInfo:
FS_Info;
{$ELSEC}
VAR refInfo:
Q_Info;
{$ENDC}
pPath:
TPPathname;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
pPath := @SELF.path;
{$IFC LibraryVersion <= 20}
Lookup(error, pPath^, refInfo);
{$ELSEC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 656 of 1012

Apple Lisa Computer Technical Information


001820
001821
001822
001823
001824
001825
001826
001827
001828
001829
001830
001831
001832
001833
001834
001835
001836
001837
001838
001839
001840
001841
001842
001843
001844
001845
001846
001847
001848
001849
001850
001851
001852
001853
001854
001855
001856
001857
001858
001859
001860
001861
001862
001863
001864
001865
001866
001867

Quick_Lookup(error, pPath^, refInfo);


{$ENDC}
IF error <= 0 THEN
WhenModified := refInfo.DTM
ELSE
WhenModified := -1;
END;
{$S SgCLAres}
{$S sInit1}
END;
{$S SgCLAres}
METHODS OF TScanner;
{$S sResDat}
FUNCTION

TScanner.CREATE(object: TObject; itsCollection: TCollection;


itsInitialPosition: LONGINT; scanDirection: TScanDirection): TScanner;

BEGIN
{$IFC fTrace}BP(1);{$ENDC}
IF object = NIL THEN
ABCBreak('TScanner.CREATE must be passed an already-allocated object by a subclass CREATE', 0);
SELF := TScanner(object);
WITH SELF DO
BEGIN
collection := itsCollection;
{$H-} position := Max(0, Min(collection.size+1, itsInitialPosition)); {$H+}
scanDone := FALSE;
IF scanDirection = scanForward THEN
BEGIN
increment := 1;
atEnd := position >= collection.size;
END
ELSE
BEGIN
increment := -1;
atEnd := position <= 1;
END;
END;
SELF.Seek(itsInitialPosition);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 657 of 1012

Apple Lisa Computer Technical Information


001868
001869
001870
001871
001872
001873
001874
001875
001876
001877
001878
001879
001880
001881
001882
001883
001884
001885
001886
001887
001888
001889
001890
001891
001892
001893
001894
001895
001896
001897
001898
001899
001900
001901
001902
001903
001904
001905
001906
001907
001908
001909
001910
001911
001912
001913
001914
001915

{$IFC fDebugMethods}
{$S SgCLAdbg}
PROCEDURE TScanner.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('collection: TCollection');
Field('position: LONGINT');
Field('increment: INTEGER');
Field('scanDone: BOOLEAN');
Field('atEnd: BOOLEAN');
END;
{$S SgCLAres}
{$ENDC}
{$S SgABCdat}
FUNCTION TScanner.Advance(PROCEDURE DoToCurrent(anotherMember: BOOLEAN)): BOOLEAN;
VAR moreToScan: BOOLEAN;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
WITH SELF DO
IF scanDone THEN
moreToScan := FALSE
{don't reassign nextObject}
ELSE
BEGIN
IF atEnd THEN
moreToScan := FALSE
ELSE
BEGIN
moreToScan := TRUE;
position := position + increment;
IF increment > 0 THEN
atEnd := position >= collection.size
ELSE
atEnd := position <= 1;
END;
{$H-} DoToCurrent(moreToScan); {$H+}
END;
IF NOT moreToScan THEN
SELF.Free;
Advance := moreToScan;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 658 of 1012

Apple Lisa Computer Technical Information


001916
001917
001918
001919
001920
001921
001922
001923
001924
001925
001926
001927
001928
001929
001930
001931
001932
001933
001934
001935
001936
001937
001938
001939
001940
001941
001942
001943
001944
001945
001946
001947
001948
001949
001950
001951
001952
001953
001954
001955
001956
001957
001958
001959
001960
001961
001962
001963

{$S SgABCdat}
PROCEDURE TScanner.Allocate(slack: LONGINT);
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
SELF.collection.StartEdit(slack);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TScanner.Close;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TScanner.Compact;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
SELF.collection.StopEdit;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
PROCEDURE TScanner.Done;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
SELF.scanDone := TRUE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TScanner.Open;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TScanner.Reverse;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
SELF.increment := - SELF.increment;

Apple Lisa ToolKit 3.0 Source Code Listing -- 659 of 1012

Apple Lisa Computer Technical Information


001964
001965
001966
001967
001968
001969
001970
001971
001972
001973
001974
001975
001976
001977
001978
001979
001980
001981
001982
001983
001984
001985
001986
001987
001988
001989
001990
001991
001992
001993
001994
001995
001996
001997
001998
001999
002000
002001
002002
002003
002004
002005
002006
002007
002008
002009
002010
002011

{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
PROCEDURE TScanner.Seek(newPosition: LONGINT);
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
WITH SELF DO
BEGIN
{$H-} position := Max(0, Min(collection.size+1, newPosition)); {$H+}
atEnd := ((position >= collection.size) AND (increment > 0)) OR
((position <= 1) AND (increment < 0));
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TScanner.Skip(deltaPos: LONGINT);
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
SELF.Seek(SELF.position + deltaPos);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sInit1}
END;
{$S SgCLAres}
METHODS OF TListScanner;
{$S sResDat}
FUNCTION

TListScanner.CREATE(object: TObject; itsList: TList;


itsInitialPosition: LONGINT; itsScanDirection: TScanDirection)
: TListScanner;

BEGIN
{$IFC fTrace}BP(1);{$ENDC}
IF object = NIL THEN
object := NewOrRecycledObject(mainHeap, THISCLASS, availListScanner);
SELF := TListScanner(TScanner.CREATE(object, itsList, itsInitialPosition, itsScanDirection));
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 660 of 1012

Apple Lisa Computer Technical Information


002012
002013
002014
002015
002016
002017
002018
002019
002020
002021
002022
002023
002024
002025
002026
002027
002028
002029
002030
002031
002032
002033
002034
002035
002036
002037
002038
002039
002040
002041
002042
002043
002044
002045
002046
002047
002048
002049
002050
002051
002052
002053
002054
002055
002056
002057
002058
002059

{$S sResDat}
PROCEDURE TListScanner.Free;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
RecycleObject(SELF, availListScanner);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TListScanner.Append(object: TObject);
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
TList(SELF.collection).InsAt(SELF.position + 1, object);
SELF.position := SELF.position + 1;
(***** removed the following line: .InsAt should have set the collection size
{$H-} SELF.collection.size := Max(SELF.collection.size, SELF.position); {$H+}
*****)
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TListScanner.Delete(freeOld: BOOLEAN);
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
TList(SELF.collection).DelAt(SELF.position, freeOld);
WITH SELF DO
IF increment > 0 THEN
position := position - 1;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TListScanner.DeleteRest(freeOld: BOOLEAN);
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
WITH SELF DO
IF increment > 0 THEN
{$H-}
TList(collection).DelManyAt(position + 1, collection.size - position, freeOld)
ELSE
TList(collection).DelManyAt(1, position - 1, freeOld); {$H+}
WITH SELF DO
BEGIN
collection.size := position;
atEnd := TRUE;

Apple Lisa ToolKit 3.0 Source Code Listing -- 661 of 1012

Apple Lisa Computer Technical Information


002060
002061
002062
002063
002064
002065
002066
002067
002068
002069
002070
002071
002072
002073
002074
002075
002076
002077
002078
002079
002080
002081
002082
002083
002084
002085
002086
002087
002088
002089
002090
002091
002092
002093
002094
002095
002096
002097
002098
002099
002100
002101
002102
002103
002104
002105
002106
002107

END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TListScanner.Obtain: TObject;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
Obtain := TList(SELF.collection).At(SELF.position);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TListScanner.Replace(object: TObject; freeOld: BOOLEAN);
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
TList(SELF.collection).PutAt(SELF.position, object, freeOld);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
FUNCTION TListScanner.Scan(VAR nextObject: TObject): BOOLEAN;
VAR actIndex:
LONGINT;
{an actual index into the list, INCLUDING the hole as part of the list}
(*
PROCEDURE AssignListScanVariable(anotherObject: BOOLEAN);
BEGIN
IF anotherObject THEN
nextObject := TList(SELF.collection).At(SELF.position)
ELSE
nextObject := NIL;
END;

*)

BEGIN
{$IFC fTrace}BP(1);{$ENDC}
Scan := SELF.Advance(AssignListScanVariable);
{$IFC fTrace}EP;{$ENDC}
END;
VAR moreToScan: BOOLEAN;
BEGIN {speedier version}
{$IFC fTrace}BP(1);{$ENDC}
WITH SELF DO
IF scanDone THEN
moreToScan := FALSE
ELSE

{don't reassign nextObject}

Apple Lisa ToolKit 3.0 Source Code Listing -- 662 of 1012

Apple Lisa Computer Technical Information


002108
002109
002110
002111
002112
002113
002114
002115
002116
002117
002118
002119
002120
002121
002122
002123
002124
002125
002126
002127
002128
002129
002130
002131
002132
002133
002134
002135
002136
002137
002138
002139
002140
002141
002142
002143
002144
002145
002146
002147
002148
002149
002150
002151
002152
002153
002154
002155

BEGIN
IF atEnd THEN
moreToScan := FALSE
ELSE
BEGIN
moreToScan := TRUE;
position := position + increment;
IF increment > 0 THEN
atEnd := position >= collection.size
ELSE
atEnd := position <= 1;
END;
IF moreToScan THEN
BEGIN
IF position > collection.holeStart THEN
actIndex := position + collection.holeSize
ELSE
actIndex := position;
nextObject := TPObject(TpLONGINT(collection)^ + collection.dynStart
+ (4 * (actIndex - 1)))^;
END
ELSE
nextObject := NIL;
END;
IF NOT moreToScan THEN
SELF.Free;
Scan := moreToScan;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sInit1}
BEGIN
availListScanner := NIL;
END;
{$S SgCLAres}
METHODS OF TArrayScanner;
{$S SgABCdat}
FUNCTION TArrayScanner.CREATE(object: TObject; itsArray: TArray;

Apple Lisa ToolKit 3.0 Source Code Listing -- 663 of 1012

Apple Lisa Computer Technical Information


002156
002157
002158
002159
002160
002161
002162
002163
002164
002165
002166
002167
002168
002169
002170
002171
002172
002173
002174
002175
002176
002177
002178
002179
002180
002181
002182
002183
002184
002185
002186
002187
002188
002189
002190
002191
002192
002193
002194
002195
002196
002197
002198
002199
002200
002201
002202
002203

itsInitialPosition: LONGINT; itsScanDirection: TScanDirection)


: TArrayScanner;

BEGIN
{$IFC fTrace}BP(1);{$ENDC}
IF object = NIL THEN
object := NewOrRecycledObject(mainHeap, THISCLASS, availArrayScanner);
SELF := TArrayScanner(TScanner.CREATE(object, itsArray, itsInitialPosition, itsScanDirection));
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TArrayScanner.Free;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
RecycleObject(SELF, availArrayScanner);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TArrayScanner.Append(pRecord: Ptr);
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
TArray(SELF.collection).InsAt(SELF.position + 1, pRecord);
SELF.position := SELF.position + 1;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TArrayScanner.Delete;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
TArray(SELF.collection).DelAt(SELF.position);
WITH SELF DO
IF increment > 0 THEN
position := position - 1;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TArrayScanner.DeleteRest;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
WITH SELF DO
IF increment > 0 THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 664 of 1012

Apple Lisa Computer Technical Information


002204
002205
002206
002207
002208
002209
002210
002211
002212
002213
002214
002215
002216
002217
002218
002219
002220
002221
002222
002223
002224
002225
002226
002227
002228
002229
002230
002231
002232
002233
002234
002235
002236
002237
002238
002239
002240
002241
002242
002243
002244
002245
002246
002247
002248
002249
002250
002251

{$H-}
TArray(collection).DelManyAt(position + 1, collection.size - position)
ELSE
TArray(collection).DelManyAt(1, position - 1); {$H+}
WITH SELF DO
BEGIN
collection.size := position;
atEnd := TRUE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TArrayScanner.Obtain: Ptr;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
Obtain := TArray(SELF.collection).At(SELF.position);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TArrayScanner.Replace(pRecord: Ptr);
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
TArray(SELF.collection).PutAt(SELF.position, pRecord);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TArrayScanner.Scan(VAR pNextRecord: Ptr): BOOLEAN;
PROCEDURE AssignArrayScanVariable(anotherRecord: BOOLEAN);
BEGIN
IF anotherRecord THEN
pNextRecord := TArray(SELF.collection).At(SELF.position)
ELSE
pNextRecord := NIL;
END;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
Scan := SELF.Advance(AssignArrayScanVariable);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 665 of 1012

Apple Lisa Computer Technical Information


002252
002253
002254
002255
002256
002257
002258
002259
002260
002261
002262
002263
002264
002265
002266
002267
002268
002269
002270
002271
002272
002273
002274
002275
002276
002277
002278
002279
002280
002281
002282
002283
002284
002285
002286
002287
002288
002289
002290
002291
002292
002293
002294
002295
002296
002297
002298
002299

{$S sInit1}
BEGIN
availArrayScanner := NIL;
END;
{$S SgCLAres}
METHODS OF TStringScanner;
{$S SgABCdat}
FUNCTION TStringScanner.CREATE(object: TObject; itsString: TString;
itsInitialPosition: LONGINT; itsScanDirection: TScanDirection)
: TStringScanner;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
IF object = NIL THEN
object := NewOrRecycledObject(mainHeap, THISCLASS, availStringScanner);
SELF := TStringScanner(TScanner.CREATE(object, itsString, itsInitialPosition, itsScanDirection));
SELF.actual := 0;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TStringScanner.Free;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
RecycleObject(SELF, availStringScanner);
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$S SgCLAdbg}
PROCEDURE TStringScanner.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('actual: LONGINT');
END;
{$S SgCLAres}
{$ENDC}
{$S SgABCdat}

Apple Lisa ToolKit 3.0 Source Code Listing -- 666 of 1012

Apple Lisa Computer Technical Information


002300
002301
002302
002303
002304
002305
002306
002307
002308
002309
002310
002311
002312
002313
002314
002315
002316
002317
002318
002319
002320
002321
002322
002323
002324
002325
002326
002327
002328
002329
002330
002331
002332
002333
002334
002335
002336
002337
002338
002339
002340
002341
002342
002343
002344
002345
002346
002347

PROCEDURE TStringScanner.Append(character: CHAR);


BEGIN
{$IFC fTrace}BP(2);{$ENDC}
TString(SELF.collection).InsAt(SELF.position + 1, character);
SELF.position := SELF.position + 1;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TStringScanner.Delete;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
TString(SELF.collection).DelAt(SELF.position);
WITH SELF DO
IF increment > 0 THEN
position := position - 1;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TStringScanner.DeleteRest;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
WITH SELF DO
IF increment > 0 THEN
{$H-}
TString(collection).DelManyAt(position + 1, collection.size - position)
ELSE
TString(collection).DelManyAt(1, position - 1); {$H+}
WITH SELF DO
BEGIN
collection.size := position;
atEnd := TRUE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TStringScanner.Obtain: CHAR;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
Obtain := TString(SELF.collection).At(SELF.position);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 667 of 1012

Apple Lisa Computer Technical Information


002348
002349
002350
002351
002352
002353
002354
002355
002356
002357
002358
002359
002360
002361
002362
002363
002364
002365
002366
002367
002368
002369
002370
002371
002372
002373
002374
002375
002376
002377
002378
002379
002380
002381
002382
002383
002384
002385
002386
002387
002388
002389
002390
002391
002392
002393
002394
002395

{$S SgABCdat}
PROCEDURE TStringScanner.Replace(character: CHAR);
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
TString(SELF.collection).PutAt(SELF.position, character);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TStringScanner.Scan(VAR nextChar: CHAR): BOOLEAN;
PROCEDURE AssignStringScanVariable(anotherChar: BOOLEAN);
BEGIN
IF anotherChar THEN
nextChar := TString(SELF.collection).At(SELF.position)
ELSE
nextChar := CHAR(0);
END;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
Scan := SELF.Advance(AssignStringScanVariable);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
FUNCTION TStringScanner.ReadArray(heap: THeap; bytesPerRecord: INTEGER): TArray;
VAR a: TArray;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
a := TArray.CREATE(NIL, heap, 0, bytesPerRecord);
XferContiguous(xRead, a, 2, SELF);
ReadArray := a;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
FUNCTION TStringScanner.ReadNumber(numBytes: SizeOfNumber): LONGINT;
VAR v:
RECORD
CASE INTEGER OF
1: (signExtension, short: INTEGER);
2: (long: LONGINT);
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 668 of 1012

Apple Lisa Computer Technical Information


002396
002397
002398
002399
002400
002401
002402
002403
002404
002405
002406
002407
002408
002409
002410
002411
002412
002413
002414
002415
002416
002417
002418
002419
002420
002421
002422
002423
002424
002425
002426
002427
002428
002429
002430
002431
002432
002433
002434
002435
002436
002437
002438
002439
002440
002441
002442
002443

BEGIN
{$IFC fTrace}BP(2);{$ENDC}
v.long := 0;
SELF.XferSequential(xRead, Ptr(ORD(@v)+4-numBytes), numBytes);
IF numBytes=2 THEN
IF v.short < 0 THEN
v.signExtension := -1;
ReadNumber := v.long;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TStringScanner.ReadObject(heap: THeap): TObject;
VAR class: TClass;
object: TObject;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
class := TClass(SELF.ReadNumber(4));
object := NewObject(heap, class);
object.Read(SELF);
ReadObject := object;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TStringScanner.WriteArray(a: TArray);
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
XferContiguous(xWrite, a, 2, SELF);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TStringScanner.WriteNumber(value: LONGINT; numBytes: SizeOfNumber);
BEGIN
{$IFC fTrace}BP(3);{$ENDC}
SELF.XferSequential(xWrite, Ptr(ORD(@value)+4-numBytes), numBytes);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TStringScanner.WriteObject(object: TObject);
BEGIN
{$IFC fTrace}BP(2);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 669 of 1012

Apple Lisa Computer Technical Information


002444
002445
002446
002447
002448
002449
002450
002451
002452
002453
002454
002455
002456
002457
002458
002459
002460
002461
002462
002463
002464
002465
002466
002467
002468
002469
002470
002471
002472
002473
002474
002475
002476
002477
002478
002479
002480
002481
002482
002483
002484
002485
002486
002487
002488
002489
002490
002491

SELF.WriteNumber(ORD(object.Class), 4);
object.Write(SELF);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TStringScanner.XferContiguous(whichWay: xReadWrite; collection: TCollection);
VAR numToXfer: INTEGER;
BEGIN
{Transfer the size (as an INTEGER), class-specific fields, and members.
Do not recur on the members.
Do not transfer the class, the dynStart (=SizeOfClass), or the hole info (=zero).
When reading, append the elements that are read.
This only works for contiguous objects up to 32K members in size.}
{$IFC fTrace}BP(3);{$ENDC}
XferContiguous(whichWay, collection, 0, SELF);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TStringScanner.XferFields(whichWay: xReadWrite; object: TObject);
BEGIN
{Transfers the bits of a TObject, excluding the class pointer and any dynamic part}
{$IFC fTrace}BP(3);{$ENDC}
SELF.XferSequential(whichWay,
Ptr(ORD(TH(object)^) + SIZEOF(TObject)),
SizeOfClass(object.Class) - SIZEOF(TObject));
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TStringScanner.XferPString(whichWay: xReadWrite; pStr: TPString);
VAR size: Byte;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
IF whichWay = xWrite THEN
size := Length(pStr^);
SELF.XferSequential(whichWay, @size, 1);
SELF.XferSequential(whichWay, Ptr(ORD(pStr)+1), size);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TStringScanner.XferRandom(whichWay: xReadWrite; pFirst: Ptr; numBytes: LONGINT;
mode: TIOMode; offset: LONGINT);
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 670 of 1012

Apple Lisa Computer Technical Information


002492
002493
002494
002495
002496
002497
002498
002499
002500
002501
002502
002503
002504
002505
002506
002507
002508
002509
002510
002511
002512
002513
002514
002515
002516
002517
002518
002519
002520
002521
002522
002523
002524
002525
002526
002527
002528
002529
002530
002531
002532
002533
002534
002535
002536
002537
002538
002539

{$IFC fTrace}BP(1);{$ENDC}
CASE mode OF
fAbsolute: SELF.Seek(offset);
fRelative: SELF.Skip(offset);
END;
SELF.XferSequential(whichWay, pFirst, numBytes);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TStringScanner.XferSequential(whichWay: xReadWrite; pFirst: Ptr; numBytes: LONGINT);
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
WITH SELF, collection DO
BEGIN
{$H-} actual := Min(size - position, numBytes); {$H+}
{$H-} collection.EditAt(size + 1, 0); {$H+} {Maybe we should xfer in two steps instead}
END;
WITH SELF DO
BEGIN
{$H-} XferLeft(pFirst, Ptr(collection.AddrMember(position + 1)), actual); {$H+}
position := position + actual;
atEnd := position = collection.size;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sInit1}
BEGIN
availStringScanner := NIL;
END;
{$S SgCLAres}
METHODS OF TFileScanner;
{$S sResDat}
FUNCTION TFileScanner.CREATE(object: TObject; itsFile: TFile; manip: TAccesses): TFileScanner;
BEGIN
{$IFC fTrace}BP(5);{$ENDC}
IF object = NIL THEN
object := NewObject(itsFile.Heap, THISCLASS);
SELF := TFileScanner(TScanner.CREATE(object, itsFile, 0, scanForward));

Apple Lisa ToolKit 3.0 Source Code Listing -- 671 of 1012

Apple Lisa Computer Technical Information


002540
002541
002542
002543
002544
002545
002546
002547
002548
002549
002550
002551
002552
002553
002554
002555
002556
002557
002558
002559
002560
002561
002562
002563
002564
002565
002566
002567
002568
002569
002570
002571
002572
002573
002574
002575
002576
002577
002578
002579
002580
002581
002582
002583
002584
002585
002586
002587

SELF.actual := 0;
SELF.accesses := manip;
SELF.Open;
TFile(SELF.collection).scanners.InsLast(SELF);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgCLAres}
{$IFC fDebugMethods}
{$S SgCLAdbg}
PROCEDURE TFileScanner.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('accesses: Byte');
Field('refnum: INTEGER');
Field('error: INTEGER');
END;
{$S SgCLAres}
{$ENDC}
{$S SgABCdat}
PROCEDURE TFileScanner.FreeObject; {use FreeObject, rather than Free, so that we close the
file if the user says fs.FreeObject (as in
TDocManager.OpenSaved), as well as fs.Free}
BEGIN
{$IFC fTrace}BP(5);{$ENDC}
SELF.Close;
TFile(SELF.collection).scanners.DelObject(SELF, FALSE);
SUPERSELF.FreeObject;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TFileScanner.Free;
{Free frees the TFile as well, if no other scanners still exist}
VAR itsFile: TFile;
BEGIN
{$IFC fTrace}BP(5);{$ENDC}
itsFile := TFile(SELF.collection);
SELF.FreeObject;
IF itsFile.scanners.size = 0 THEN
itsFile.Free;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 672 of 1012

Apple Lisa Computer Technical Information


002588
002589
002590
002591
002592
002593
002594
002595
002596
002597
002598
002599
002600
002601
002602
002603
002604
002605
002606
002607
002608
002609
002610
002611
002612
002613
002614
002615
002616
002617
002618
002619
002620
002621
002622
002623
002624
002625
002626
002627
002628
002629
002630
002631
002632
002633
002634
002635

{$S SgABCdat}
PROCEDURE TFileScanner.Allocate(slack: LONGINT);
VAR fsInfo:
FS_Info;
pages:
LONGINT;
actual:
LONGINT;
newErr:
INTEGER;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
Info(newErr, SELF.refnum, fsInfo);
WITH fsInfo DO
pages := ((size + slack + lpSize - 1) DIV lpSize) - ((pSize + lpSize - 1) DIV lpSize);
IF pages > 0 THEN
Allocate(newErr, SELF.refnum, TRUE, pages, actual);
IF (newErr <= 0) AND (actual < pages) THEN
Allocate(newErr, SELF.refnum, FALSE, pages - actual, actual);
{$H-} LatestError(newErr, SELF.error); {$H+}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TFileScanner.Close;
VAR newErr: INTEGER;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
Close_Object(newErr, SELF.refnum);
{$H-} LatestError(newErr, SELF.error); {$H+}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TFileScanner.Compact;
VAR newErr:
INTEGER;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
Compact(newErr, SELF.refnum);
{$H-} LatestError(newErr, SELF.error); {$H+}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TFileScanner.Delete;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
SELF.Skip(-1);
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 673 of 1012

Apple Lisa Computer Technical Information


002636
002637
002638
002639
002640
002641
002642
002643
002644
002645
002646
002647
002648
002649
002650
002651
002652
002653
002654
002655
002656
002657
002658
002659
002660
002661
002662
002663
002664
002665
002666
002667
002668
002669
002670
002671
002672
002673
002674
002675
002676
002677
002678
002679
002680
002681
002682
002683

END;
{$S SgABCdat}
PROCEDURE TFileScanner.DeleteRest;
VAR newErr:
INTEGER;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
Truncate(newErr, SELF.refnum);
{$H-} LatestError(newErr, SELF.error); {$H+}
WITH SELF DO
BEGIN
collection.size := position;
atEnd := TRUE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TFileScanner.Append(character: CHAR);
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
SELF.XferSequential(xWrite, Ptr(ORD(@character)+1), 1);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TFileScanner.Obtain: CHAR;
VAR character: CHAR;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
SELF.XferRandom(xRead, Ptr(ORD(@character) + 1), 1, fRelative, -1);
Obtain := character;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
{$IFC LibraryVersion <= 20}
PROCEDURE TFileScanner.Open;
VAR pPath:
TPPathName;
itsFile:
TFile;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
itsFile := TFile(SELF.collection);
pPath := @itsFile.path;
{$H-} Open(SELF.error, pPath^, SELF.refnum, MSet(SELF.accesses)); {$H+}

Apple Lisa ToolKit 3.0 Source Code Listing -- 674 of 1012

Apple Lisa Computer Technical Information


002684
002685
002686
002687
002688
002689
002690
002691
002692
002693
002694
002695
002696
002697
002698
002699
002700
002701
002702
002703
002704
002705
002706
002707
002708
002709
002710
002711
002712
002713
002714
002715
002716
002717
002718
002719
002720
002721
002722
002723
002724
002725
002726
002727
002728
002729
002730
002731

IF (SELF.error = 948) and (fWrite in SELF.accesses) then


BEGIN
{$H-}
Make_File(SELF.error, pPath^, 0);
IF SELF.error <= 0 then
Open(SELF.error, pPath^, SELF.refnum, MSet(SELF.accesses)); {$H+}
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$ELSEC}
PROCEDURE TFileScanner.Open;
VAR pPath:
TPPathName;
itsFile:
TFile;
pPass:
TPEName;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
itsFile := TFile(SELF.collection);
pPath := @itsFile.path;
pPass := @itsFile.password;
{$H-} Open_Secure(SELF.error, pPath^, SELF.refnum, MSet(SELF.accesses), pPass^); {$H+}
IF (SELF.error = 948) and (fWrite in SELF.accesses) then
BEGIN
{$H-}
Make_Secure(SELF.error, pPath^, pPass^);
IF SELF.error <= 0 then
Open_Secure(SELF.error, pPath^, SELF.refnum, MSet(SELF.accesses), pPass^); {$H+}
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$ENDC}
{$S SgABCdat}
PROCEDURE TFileScanner.Replace(character: CHAR);
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
SELF.XferRandom(xWrite, Ptr(ORD(@character) + 1), 1, fRelative, -1);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
FUNCTION TFileScanner.Scan(VAR nextChar: CHAR): BOOLEAN;
PROCEDURE AssignFileScanVariable(anotherChar: BOOLEAN);
BEGIN
IF anotherChar THEN
SELF.XferSequential(xRead, Ptr(ORD(@nextChar) + 1), 1)

Apple Lisa ToolKit 3.0 Source Code Listing -- 675 of 1012

Apple Lisa Computer Technical Information


002732
002733
002734
002735
002736
002737
002738
002739
002740
002741
002742
002743
002744
002745
002746
002747
002748
002749
002750
002751
002752
002753
002754
002755
002756
002757
002758
002759
002760
002761
002762
002763
002764
002765
002766
002767
002768
002769
002770
002771
002772
002773
002774
002775
002776
002777
002778
002779

ELSE
nextChar := CHAR(0);
END;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
Scan := SELF.Advance(AssignFileScanVariable);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
PROCEDURE TFileScanner.Seek(newPosition: LONGINT);
VAR dummy: INTEGER;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
SELF.XferRandom(xRead, @dummy, 0, fAbsolute, newPosition);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgABCdat}
PROCEDURE TFileScanner.Skip(deltaPos: LONGINT);
VAR dummy: INTEGER;
BEGIN
{$IFC fTrace}BP(2);{$ENDC}
SELF.XferRandom(xRead, @dummy, 0, fRelative, deltaPos);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
PROCEDURE TFileScanner.XferRandom(whichWay: xReadWrite; pFirst: Ptr; numBytes: LONGINT;
mode: TIOMode; offset: LONGINT);
VAR newErr:
INTEGER;
osMode:
IOMode;
fsInfo:
FS_Info;
sched_err: INTEGER;
BEGIN
{$IFC fTrace}BP(4);{$ENDC}
osMode := IOMode(mode);
WITH SELF DO {$H-}
IF error <= 0 THEN
BEGIN
CASE whichWay OF
xRead: BEGIN
Sched_Class(sched_err, FALSE);
Read_Data(newErr, refnum, ord(pFirst), numBytes, actual, osMode, offset);

Apple Lisa ToolKit 3.0 Source Code Listing -- 676 of 1012

Apple Lisa Computer Technical Information


002780
002781
002782
002783
002784
002785
002786
002787
002788
002789
002790
002791
002792
002793
002794
002795
002796
002797
002798
002799
002800
002801
002802
002803
002804
002805
002806
002807
002808
002809
002810
002811
002812
002813
002814
002815
002816
002817
002818
002819
002820
002821
002822
002823
002824
002825
002826
002827

Sched_Class(sched_err, TRUE);
END;
xWrite: BEGIN
Sched_Class(sched_err, FALSE);
Write_Data(newErr, refnum, ord(pFirst), numBytes, actual, osMode, offset);
Sched_Class(sched_err, TRUE);
collection.size := Max(position + actual, collection.size);
END;
END;
IF (newErr = 956) OR (newErr = 963) OR (newErr = 883) OR (newErr = 882) OR
(newErr = 848) THEN {EOF}
newErr := 0;
IF mode = fSequential THEN {do it fast}
position := position + actual
ELSE
{play it safe}
BEGIN
Info(newErr, refnum, fsInfo);
position := fsInfo.fMark;
collection.size := fsInfo.size;
END;
atEnd := position = collection.size;
LatestError(newErr, error); {$H+}
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sResDat}
PROCEDURE TFileScanner.XferSequential(whichWay: xReadWrite; pFirst: Ptr; numBytes: LONGINT);
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
SELF.XferRandom(whichWay, pFirst, numBytes, fSequential, 0);
{$IFC fTrace}EP;{$ENDC}
END;
{$S sInit1}
END;
{$S SgCLAres}
{$IFC compatibleLists} {Backward Compatibility}
METHODS OF TDynamicArray;

Apple Lisa ToolKit 3.0 Source Code Listing -- 677 of 1012

Apple Lisa Computer Technical Information


002828
002829
002830
002831
002832
002833
002834
002835
002836
002837
002838
002839
002840
002841
002842
002843
002844
002845
002846
002847
002848
002849
002850
002851
002852
002853
002854
002855
002856
002857
002858
002859
002860
002861
002862
002863
002864
002865
002866
002867
002868
002869
002870
002871
002872
002873
002874
002875

FUNCTION

TDynamicArray.CREATE(object: TObject; heap: THeap; bytesPerRecord: INTEGER;


initialSize: INTEGER): TDynamicArray;

BEGIN
{$IFC fTrace}BP(1);{$ENDC}
IF ODD(bytesPerRecord) THEN
bytesPerRecord := bytesPerRecord + 1;
SELF := POINTER(ORD(TArray.CREATE(object, heap, initialSize, bytesPerRecord))); {NB reversed args}
Handle(SELF)^^ := ORD(THISCLASS);
SELF.EditAt(1, initialSize);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TDynamicArray.BeSize(newSize: INTEGER);
BEGIN
SELF.EditAt(SELF.size + 1, newSize - SELF.size);
END;
FUNCTION TDynamicArray.Class: TClass; {So New- & Resize- DynObject will use correct object size}
BEGIN
Class := cArray;
END;
FUNCTION TDynamicArray.numRecords: INTEGER;
BEGIN
numRecords := SELF.size;
END;
{$S sInit1}
END;
{$S SgCLAres}
METHODS OF TIndexList;
FUNCTION TIndexList.CREATE(object: TObject; heap: THeap; initialSize: INTEGER): TIndexList;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
SELF := POINTER(ORD(TList.CREATE(object, heap, initialSize)));
Handle(SELF)^^ := ORD(THISCLASS);
SELF.EditAt(1, initialSize);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 678 of 1012

Apple Lisa Computer Technical Information


002876
002877
002878
002879
002880
002881
002882
002883
002884
002885
002886
002887
002888
002889
002890
002891
002892
002893
002894
002895
002896
002897
002898
002899
002900
002901
002902
002903
002904
002905
002906
002907
002908
002909
002910
002911
002912
002913
002914
002915
002916
002917
002918
002919
002920
002921
002922
002923

FUNCTION TIndexList.Class: TClass; {So New- & Resize- DynObject will use correct object size}
BEGIN
Class := cList;
END;
FUNCTION TIndexList.numElements: INTEGER;
BEGIN
numElements := SELF.size;
END;
{$S sInit1}
END;
{$S SgCLAres}
METHODS OF TLinkList;
FUNCTION TLinkList.CREATE(object: TObject; heap: THeap): TLinkList;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
SELF := POINTER(ORD(TList.CREATE(object, heap, 0)));
Handle(SELF)^^ := ORD(THISCLASS);
{$IFC fTrace}EP;{$ENDC}
END;
FUNCTION TLinkList.numElements: INTEGER;
BEGIN
numElements := SELF.size;
END;
{$S sInit1}
END;
{$S SgCLAres}
METHODS OF TBlockList;
FUNCTION TBlockList.CREATE(object: TObject; heap: THeap; itsMinBlockSize: INTEGER): TBlockList;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
SELF := POINTER(ORD(TList.CREATE(object, heap, 0)));

Apple Lisa ToolKit 3.0 Source Code Listing -- 679 of 1012

Apple Lisa Computer Technical Information


002924
002925
002926
002927
002928
002929
002930
002931
002932
002933
002934
002935
002936
002937
002938
002939
002940
002941
002942
002943
002944
002945
002946
002947
002948
002949
002950
002951
002952
002953
002954
002955
002956
002957
002958
002959
002960
002961
002962
002963
002964
002965
002966
002967
002968
002969
002970
002971

Handle(SELF)^^ := ORD(THISCLASS);
{$IFC fTrace}EP;{$ENDC}
END;
FUNCTION TBlockList.numElements: INTEGER;
BEGIN
numElements := SELF.size;
END;
{$S sInit1}
END;
{$S SgCLAres}
METHODS OF TFileStream;
FUNCTION TFileStream.CREATE(object: TObject; heap: THeap; path: S255; manip: TAccesses): TFileStream;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TFileStream(TFileScanner.CREATE(object, TFile.CREATE(NIL, heap, path, ''), manip));
{$IFC fTrace}EP;{$ENDC}
END;
FUNCTION TFileStream.Size: LONGINT;
BEGIN
{$IFC fTrace}BP(1);{$ENDC}
Size := SELF.collection.size;
{$IFC fTrace}EP;{$ENDC}
END;
{$S sInit1}
END;
{$S SgCLAres}
{$S SgCLAcld}
PROCEDURE FileDelete(path: S255);
VAR osPath:
Pathname;
error:
INTEGER;
BEGIN
osPath := path;
{ THIS IS THE SECOND TIME WE COPY THE STRING !!!! }

Apple Lisa ToolKit 3.0 Source Code Listing -- 680 of 1012

Apple Lisa Computer Technical Information


002972
002973
002974
002975
002976
002977
002978
002979
002980
002981
002982
002983
002984
002985
002986
002987
002988
002989
002990
002991
002992
002993
002994
002995
002996
002997
002998
002999
003000
003001
003002
003003
003004
003005
003006
003007
003008
003009
003010
003011
003012
003013
003014
003015
003016
003017
003018
003019

Kill_Object(error, osPath);
END;
{$S SgCLAres}
{$S SgCLAcld}
PROCEDURE FileLookup(VAR error: INTEGER; path: S255);
VAR refInfo:
FS_Info;
osPath:
Pathname;
BEGIN
osPath := path;
{ THIS IS THE SECOND TIME WE COPY THE STRING !!!! }
Lookup(error, osPath, refInfo);
END;
{$S SgCLAres}
{$S SgCLAcld}
PROCEDURE FileRename(oldPath, newPath: S255);
VAR osPath:
Pathname;
osEname:
E_Name;
error:
INTEGER;
centerHyphen:
INTEGER;
BEGIN
osPath := oldPath;
centerHyphen := pos('-{', newPath);
osEname := copy(newPath, centerHyphen+1, length(newPath)-centerHyphen);
Rename_Entry(error, osPath, osEname);
END;
{$S SgCLAres}
{$S SgCLAcld}
FUNCTION FileModified(path: S255): LONGINT;
VAR refInfo:
FS_Info;
osPath:
Pathname;
error:
INTEGER;
BEGIN
osPath := path;
{ THIS IS THE SECOND TIME WE COPY THE STRING !!!! }
Lookup(error, osPath, refInfo);
IF error <= 0 THEN
FileModified := refInfo.DTM
ELSE
FileModified := -1;
END;
{$S SgCLAres}
{$ENDC} {Backward Compatibility}

Apple Lisa ToolKit 3.0 Source Code Listing -- 681 of 1012

Apple Lisa Computer Technical Information


003020
003021
003022
003023
End of File -- Lines: 3023 Characters: 79889

Apple Lisa ToolKit 3.0 Source Code Listing -- 682 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UOBJECT4.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{INCLUDE FILE UOBJECT4 -- KITBUG}


{Copyright 1983, 1984, Apple Computer, Inc.}
{changed 04/30 1412 In GetDollarD make sure the constants we are searching for don't appear in the
body of the procedure}
{ ====================================== VALIDITY CHECKS ====================================== }
{$S SgCLAcld}
FUNCTION ValidGlobalAddress(addr: LONGINT): BOOLEAN;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
ValidGlobalAddress := (%_GetA5 > addr) AND (addr > ORD(@addr));
END;
FUNCTION ValidSTP(stAddr: LONGINT): BOOLEAN;
VAR count: INTEGER;
hiWord: INTEGER;
BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
IF ValidGlobalAddress(stAddr) AND ValidGlobalAddress(stAddr+3) AND NOT ODD(stAddr) THEN
BEGIN
count := 100;
{Prevent infinite loops}
hiWord := 0;
WHILE ValidGlobalAddress(stAddr-4) AND ValidGlobalAddress(stAddr-1) AND NOT ODD(stAddr) AND
(count > 0) DO
BEGIN
{$R-} hiWord := TpINTEGER(stAddr-4)^;
stAddr := TpLONGINT(stAddr-4)^; {$IFC fRngObject}{$R+}{$ENDC}
count := count - 1;
END;
ValidSTP := hiWord = -1;
END
ELSE
ValidSTP := FALSE;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 683 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

FUNCTION ValidObject(hndl: Handle): BOOLEAN;


BEGIN
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
ValidObject := FALSE;
IF (hndl <> NIL) AND (cObject <> NIL) THEN
IF ValidDataAddress(ORD(hndl)) THEN
IF ValidDataAddress(ORD(hndl^)) THEN
IF ValidSTP(ORD(ClassPtr(hndl))) THEN
ValidObject := TRUE;
END;

{Not NIL; and we have made a heap}


{Handle reasonable}
{Master ptr reasonable}
{Reasonable stp}
{Go for it}

{ ====================================== GARBAGE COLLECTOR ====================================== }


{$S SgCLAcld}
PROCEDURE MarkHeap{(heap: THeap; mpAddress: LONGINT)};
{ MarkHeap accepts two parameters: (1) a pointer (heap) to the document heap and (2) the address, }
{ (mpAddress) of a "root" master pointer from which all other accessible objects on heap can be reached. }
{ MarkHeap marks all objects that are "in-use" by marking the root object, all objects that the root object }
{ has a handle on, all objects that those objects have handles on, etc. Marking is accomplished by setting }
{ the high order bit (bit 31) of the master pointer that points to the object which is to be marked. }
{
{
{
{

Although MarkHeap operates depth-first, it is NOT recursive. Thus, it can mark long chains of objects }
without causing stack expansion. If w.e => x, x.f => y and y.g => z, then while y is being scanned, }
x.f => w.e. Thus, when y returns to x for further marking starting after f, x can know where it will }
have to return to when its scan is complete. The comments below assume that the scan has reached y.g }
TYPE TOffsets = RECORD
objectOffset:
fieldOffset:
END;

INTEGER;
INTEGER;

VAR hz: THz;


mpFirst: LONGINT;
mpLast: LONGINT;
blockPtr: TBk;
sizeInWords: INTEGER;

{ x - mpFirst: where the object's master ptr is in the heap }


{ @x.f - @x^^: where the field is in the object }

{ heap as a UnitHz type }


{ The address of the first master pointer in the heap }
{ The address of the last master pointer in the heap }
{ A pointer to the first (size) word of the storage block of y}
{ The size found there }

firstFieldAddress: LONGINT; { @y^^, the address of y's first data field (usually a method-table ptr)}
lastFieldAddress: LONGINT; { The upper limit of the fieldAddress loop--the last 4-byte field of y }

Apple Lisa ToolKit 3.0 Source Code Listing -- 684 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

mpPtr: TpLONGINT;
mp: LONGINT;

{ A handle as a pointer to a LONGINT (the master pointer) }


{ The master pointer value, z^, i.e., the object data address }

fieldOffset: INTEGER;
fieldAddress: LONGINT;

{ @y.g - @y^^ }
{ The address of the field y.g, which may or may not be a handle.
It increases by twos because a handle can start on any even address}
{ Two offsets representing @x.f: x - mpFirst & @x.f - @x^^.
A pointer to x.f will be stashed there while z is scanned,
in the form of two offsets (see "previous") }

previous: TOffsets;

BEGIN

hndlAddress: LONGINT;

{ The handle z found in or to be replaced in y.g }

goodHandleFound: BOOLEAN;

{ TRUE if a handle to an unmarked object was found in the fields of


the present object; otherwise, FALSE. }

{ MarkHeap }
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}

hz := THz(heap);
{ A pointer to the heap }
mpFirst := ORD(@hz^.argpPool);
{ The address of the first master pointer }
mpLast := mpFirst + (4 * (hz^.ipPoolMac - 1));
{ The address of the last master pointer }
fieldOffset := 0;
goodHandleFound := TRUE;
previous.objectOffset := 1;

{ The offset from firstFieldAddress of the first field to


consider }
{ An illegal value to flag the end of the entire marking operation }

{$IFC LibraryVersion > 20}


{Mark the hrgpnob field of the Hz}
mpPtr := TpLONGINT(hz^.hrgpnob);
mpPtr^ := mpPtr^ + $80000000;
{Mark the hScramble field of the Hz}
mpPtr := TpLONGINT(hz^.hScramble);
mpPtr^ := mpPtr^ + $80000000;
{$ENDC}
mpPtr := TpLONGINT(mpAddress);
mpPtr^ := mpPtr^ + $80000000;

{ The handle of y }
{ Mark the master pointer which points to the present object }

REPEAT

{ Loop through all accessible objects}

firstFieldAddress := mpPtr^;
{ The
blockPtr := TBk(firstFieldAddress - 4);
{ The
sizeInWords := blockPtr^.hdr.cw;
{ The
lastFieldAddress := firstFieldAddress + sizeInWords +

address of the first field of y }


size word of the header of the object }
size of the object, in words }
sizeInWords - 6; { The last 4-byte field }

Apple Lisa ToolKit 3.0 Source Code Listing -- 685 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

fieldAddress := firstFieldAddress + fieldOffset;

{ Where to start or resume the scan of y

IF (NOT goodHandleFound) THEN


BEGIN
{ We have just returned to y after scanning z }
previous := TOffsets(TpLONGINT(fieldAddress)^);{ Restore previous offsets from field y.g }
TpLONGINT(fieldAddress)^ := hndlAddress;
{ Restore the original contents of y.g, which
was z }
fieldAddress := fieldAddress + 2;
fieldOffset := fieldOffset + 2;
END;
goodHandleFound := FALSE;

{ Advance to the next potential handle }

{ No handle to an unmarked object has been found yet }

{ Scan the fields of the present object in search of a handle to an unmarked object }
WHILE ((fieldAddress <= lastFieldAddress) AND (NOT goodHandleFound)) DO
BEGIN
hndlAddress := TpLONGINT(fieldAddress)^;
{ Get what may be the address of a master pointer }
IF (hndlAddress >= mpFirst) THEN
IF (hndlAddress <= mpLast) THEN
IF (LIntAndLInt(hndlAddress - mpFirst, 3) = 0) THEN
BEGIN
{ if the address of the alleged master pointer lies between the }
{ addresses of the first and last master pointers, inclusive, and if }
{ the address of the alleged master pointer lies a multiple of 4 bytes }
{ (the length of a master pointer) from the address of the first }
{ master pointer, then the given address is the address of a master }
{ pointer (i.e. it is a valid handle).}
mpPtr := TpLONGINT(hndlAddress); { Get a handle on the validated master pointer }
mp := ORD(mpPtr^);
IF (mp >= 0) THEN { unmarked }
IF NOT (((mp >= mpFirst) AND (mp <= mpLast)) OR (mp = 1)) THEN
BEGIN { not on the free list; it must be in the heap proper }
goodHandleFound := TRUE;
{ A handle to an unmarked object has been found }
TOffsets(TpLONGINT(fieldAddress)^) := previous; { Save offsets in the
field y.g }
previous.fieldOffset := fieldOffset;

{ y's current offsets are z's


previous ones }
previous.objectOffset := mpAddress - mpFirst;

END;

mpAddress := hndlAddress;
END;

{ The handle of z }

Apple Lisa ToolKit 3.0 Source Code Listing -- 686 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

fieldAddress := fieldAddress + 2;
fieldOffset := fieldOffset + 2;
END;

{ Advance to the next potential handle }


{ Set offset to next potential handle }

IF goodHandleFound THEN
{ y.g contained the handle of z }
BEGIN
mpPtr^ := mpPtr^ + $80000000;
{ Mark the master pointer of z }
fieldOffset := 0;
{ Prepare to scan z }
END
ELSE
BEGIN
{ Finished examining the fields of y. Prepare to return to x.f
hndlAddress := mpAddress;
{ The handle y will be put back into x.f
fieldOffset := previous.fieldOffset;
{ Restore fieldOffset to
mpAddress := mpFirst + previous.objectOffset;
{ Restore mpAddress to x
mpPtr := TpLONGINT(mpAddress);
{ The handle of y }
END;
END;

UNTIL previous.objectOffset = 1;
{ MarkHeap }

}
where it belongs }
@x.f - @x^^ }
}

{ until all the fields of the original object have been examined }

PROCEDURE SweepHeap{(heap: THeap; report: BOOLEAN)};


{ This procedure sweeps through all existing objects on the document heap specified by the handle heap. }
{ If the parameter report has the value TRUE, then the classes of all unmarked objects are displayed on the }
{ alternate screen; otherwise, if report is FALSE, the unmarked objects are quietly freed-up. }
VAR tempPtr: TpLONGINT; { a temporary pointer used either to carry out simple indirection or to mark a }
{ master pointer }
PROCEDURE CollectGarbage (obj: TObject);
{
{
{
{

This procedure accepts a handle, obj, to an object and frees or reports that object (depending on the }
value of SweepHeap's parameter, report) if its master pointer is not marked. If, the }
object's master pointer is marked, then this procedure unmarks the object's master pointer but }
otherwise leaves the object alone. }
VAR mpAddress:
clsName:
hexOrd:

BEGIN

LONGINT;
{ the address of the master pointer specified by the handle obj }
TClassName; { the name of that class }
S8;
{ the handle of the object, as a hex string }

{ CollectGarbage }

mpAddress := ORD(obj);
tempPtr := TpLONGINT(obj);
{ get a handle of the right type on the given object OBJ }
IF (tempPtr^ < 0) THEN
BEGIN
{ if the given object OBJ is marked }

Apple Lisa ToolKit 3.0 Source Code Listing -- 687 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

tempPtr := TpLONGINT(mpAddress);
{ Unmark the master pointer that points to the present object }
tempPtr^ := tempPtr^ - $80000000; { Note: 2^31 = $80000000 }
END
ELSE IF report THEN
BEGIN
WriteLn;
IF ValidObject(Handle(obj)) THEN
CpToCn(TPSliceTable(ClassPtr(Handle(obj))), TS8(clsName))
ELSE
clsName := '????????';
LIntToHex(ORD(obj), @hexOrd);
Write (CHR(7), 'Found garbage object $', hexOrd, ' of class ', clsName);
END
ELSE
FreeH(THz(heap), TH(obj)); { It is unmarked, i.e., garbage. Free it. }
END;

{ Report the garbage }

{ CollectGarbage }

BEGIN

{ SweepHeap }
{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
EachObject(heap, CollectGarbage);
END;
{ SweepHeap }
{ ====================================== ABCBREAK ====================================== }
{$IFC fDbgObject}
PROCEDURE TallyZero; FORWARD;
{$ENDC}
{$S sError}
PROCEDURE ABCBreak{(s: S255; errCode: LONGINT)};
VAR asHex: S8;
BEGIN
{$IFC fDbgObject}
WriteLn;
Write(CHR(7), s);
{Beep}
IF errCode <> 0 THEN
BEGIN
LIntToHex(errCode, @asHex);
Write(': ', errCode:1, ' = $', asHex);
END;
WriteLn;
{Turn off all tracing, tallying, etc.}

Apple Lisa ToolKit 3.0 Source Code Listing -- 688 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

tallyingCalls := FALSE;
TallyZero;
fTraceEnabled := FALSE;
defTraceCount := 0;
traceCount := defTraceCount;
returnToMain := TRUE;
EntDebugger(' ', 'Error caused ABCBreak call');
{$ELSEC}
HALT;
{$ENDC}
END;
{$S SgCLAcld}
{ ====================================== $D DECODING ====================================== }
{$IFC fTrace OR fDebugMethods}
{$S SgCLAdbg}
FUNCTION GetDollarD(pFrame: TppINTEGER;
VAR nameOfClass: TClassName; VAR nameOfMethod: S8; VAR nextPC: LONGINT): BOOLEAN;
LABEL 1;
VAR pname:
pPC:
pc:
startOfSegment:
endOfSegment:
pcl:
fBothClassAndProc:

TPByte;
TppINTEGER;
TpINTEGER;
TpLONGINT;
TpINTEGER;
TpLONGINT;
BOOLEAN;

PROCEDURE SwapIn(valueString: S8);


BEGIN
END;
PROCEDURE CopyName(VAR anyName: S8);
VAR j: INTEGER;
BEGIN
anyName := '12345678';
FOR j := 1 TO 8 DO
BEGIN
anyName[j] := CHR(Wand(pname^, 127));
pname := TPByte(ORD(pname)+1);
END;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 689 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

PROCEDURE AdvancePC;
BEGIN
IF ORD(pc) >= ORD(endOfSegment) THEN
GOTO 1;
pc := TpInteger(ORD(pc)+2);
END;
BEGIN

{$IFC fMaxTrace}BP(1);{$ENDC}
{$IFC fMaxTrace}EP;{$ENDC}
pPC := TppINTEGER(ORD(pFrame) + 4);
pc := pPC^;
nameOfClass := '';
nameOfMethod := '';
nextPC := 0;
GetDollarD := FALSE;
IF ORD(pc) <> 0 THEN
BEGIN
{$R-} SwapIn(TPS8(pc)^); {$IFC fRngObject} {$R+} {$ENDC} {Be sure the code is swapped in}
startOfSegment := TpLONGINT(LIntAndLint(LONGINT(PC), $FFFE0000));
endOfSegment := TpINTEGER(LONGINT(startOfSegment) + LIntAndLint(startOfSegment^, $00FFFFFF) {length} );
{We add the -1 to the following tests so that the things we are searching for don't
appear in the body of the procedure.}
WHILE (pc^-1) <> ($4E5E-1) DO
{search for UNLK A6}
IF ORD(pc) >= ORD(endOfSegment) THEN
GOTO 1
ELSE
pc := TpINTEGER(ORD(pc)+2);
WHILE ((pc^-1) <> ($4E75-1)) AND
((pc^-1) <> ($4ED0-1)) DO
{search for RTS or JMP (A0)}
IF ORD(pc) >= ORD(endOfSegment) THEN
GOTO 1
ELSE
pc := TpINTEGER(ORD(pc)+2);
nextPC := ORD(pc);
GetDollarD := TRUE;
pname := TPByte(ORD(pc)+3);
fBothClassAndProc := pname^ < 0;
pname := TPByte(ORD(pname)-1);
CopyName(nameOfMethod);
IF fBothClassAndProc THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 690 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

1:
END;
{$ENDC}

CopyName(S8(nameOfClass))
ELSE
nameOfClass := '';
END;

{ ==================================== CALL TALLY ==================================== }


{$IFC fTrace}
{$S SgCLAini}

*** NB ***

Is this Sg necessary?

PROCEDURE TallyStart;
VAR timeNow:
LONGINT;
i:
INTEGER;
arrSize:
INTEGER;
elapsed:
LONGINT; (*^*)
BEGIN
IF tallies = NIL THEN
BEGIN
{array size must be <= maxTallies; imposed by declaration of tallies global variable.}
arrSize := Min(numMethods, maxTallies);
tallies := THTallies(TArray.CREATE(NIL, mainHeap, arrSize, SIZEOF(TTally)));
TArray(tallies).InsNullsAt(1, arrSize);
elapsed := 0;(*^*)
END
ELSE {continuing}
elapsed := stopTime - startTime;(*^*)
timeNow := MicroTimer;
startTime := timeNow - elapsed; (*^*)
FOR i := 0 TO tabLevel DO
{BP's already passed}
traceTimes[i] := timeNow; (*^*)
stopTime := timeNow;
tallyingCalls := TRUE;
END;
PROCEDURE TallyZero;
BEGIN
IF tallies <> NIL THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 691 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

END;

BEGIN
Free(TArray(tallies));
tallies := NIL;
END;

FUNCTION TallySlot(pc: LONGINT): INTEGER;


FUNCTION ComparePC(hashIndex: INTEGER): THashCompare;
VAR myPC:
LONGINT;
BEGIN
myPC := tallies^^.recs[hashIndex].epPC;
IF myPC = 0 THEN
ComparePC := cHole
ELSE
IF myPC = pc THEN
ComparePC := cMatch
ELSE
ComparePC := cMismatch;
END;
BEGIN
TallySlot := LookupInHashArray(tallies^^.header.size, pc, FALSE, ComparePC);
END;
PROCEDURE Tally(pc, micSecs: LONGINT);
VAR slot:
INTEGER;
segNum:
INTEGER;
pPC:
TpByte;
BEGIN
pPC := TPByte(@pc);
pPC^ := 0; {occasionally, a return addr hibyte is nonzero! no one knows why...}
slot := TallySlot(pc);
WITH tallies^^.recs[ABS(slot)] DO
IF slot > 0 THEN
BEGIN
count := count + 1;
microseconds := microseconds + micsecs;
END
ELSE
IF slot < 0 THEN
BEGIN
segNum := TpINTEGER(pPC)^ DIV 2;
IF segNum = 0 THEN
ABCBreak('Impossible Tally PC', pc)

Apple Lisa ToolKit 3.0 Source Code Listing -- 692 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

END;

ELSE
BEGIN
epPC := pc;
count:= 1;
microseconds := micSecs;
END;
END
ELSE
BEGIN
ABCBreak('Tally table full--more non-method procedures had EP''s than expected',
tallies^^.header.size);
tallyingCalls := FALSE;
END;

PROCEDURE TallyReport;
VAR totalCalls:
totalTime:
callees:
slot:
calls:
micSecs:
roundoff:
i:
j:
sortKeys:
segCount:
segTime:
pc:
sortBy:
swapem:
sloti:
slotj:
pctg:
elapsed:
segName:
segNum:
cState:
wantCalled:
clsName:
mthName:
nextPC:
inStr:
hexPC:

LONGINT;
LONGINT;
INTEGER;
INTEGER;
INTEGER;
LONGINT;
LONGINT;
INTEGER;
INTEGER;
THIdxArray;
ARRAY [0..127] OF LONGINT;
ARRAY [0..127] OF LONGINT;
LONGINT;
INTEGER;
BOOLEAN;
INTEGER;
INTEGER;
INTEGER;
LONGINT;
S8;
INTEGER;
TConvResult;
BOOLEAN;
TClassName;
S8;
LONGINT;
S255;
S8;

PROCEDURE ReadSegNames;
CONST

Apple Lisa ToolKit 3.0 Source Code Listing -- 693 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

bSegTable = $9A;
bEOFMark = $00;
bModuleName = $80;
bCodeBlock = $85;
modNameSkip = 8; {# bytes to skip in module name block, to get segment name}
allBlanks = '
'; {8 blanks}
blankSeg = 'BLANKSEG';
TYPE
SegTblEntry = RECORD
SegName:
PACKED ARRAY[1..8] OF CHAR;
SegNumber:
INTEGER;
Version1:
LONGINT;
Version2:
LONGINT;
END;
VAR prcsInfo:
error:
aFile:
scanner:
blkType:
blkSize:
nSegments:
segblk:
addr:
i:

ProcInfoRec;
INTEGER;
TFile;
TFileScanner;
LONGINT;
LONGINT;
LONGINT;
SegTblEntry;
LONGINT;
INTEGER;

BEGIN
Info_Process(error, My_id, prcsInfo);
IF error <= 0 THEN
BEGIN
segName := allBlanks;
segNames := TArray.CREATE(NIL, mainHeap, 127, SIZEOF(S8));
segNames.InsNullsAt(1, 127);
aFile := TFile.CREATE(NIL, mainHeap, prcsInfo.progPathName, '');
scanner := TFileScanner.CREATE(NIL, aFile, [fRead]);
WriteLn('Reading segment numbers and names from ', prcsInfo.progPathName);
WriteLn;
REPEAT
blkType := scanner.ReadNumber(1);
blkSize := scanner.ReadNumber(3) - 4;
CASE blkType OF
bSegTable:

Apple Lisa ToolKit 3.0 Source Code Listing -- 694 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

BEGIN
nSegments := scanner.ReadNumber(2);
blkSize := blkSize-2;
FOR i := 1 TO nSegments DO
BEGIN
scanner.XferSequential(xRead, @segblk, SIZEOF(SegTblEntry));
blkSize := blkSize - scanner.actual;
XferLeft(Ptr(@segblk.segName), Ptr(ORD(@segName)+1), 8);
segNames.PutAt(segblk.SegNumber, @segName);
END;
END;
bModuleName:
BEGIN
scanner.Skip(modNameSkip);
blkSize := blkSize-modNameSkip;
scanner.XferSequential(xRead, Ptr(ORD(@segName)+1), 8);
blkSize := blkSize - scanner.actual;
IF segName = allBlanks THEN
segName := blankSeg;
END;
bCodeBlock:
BEGIN
addr := scanner.ReadNumber(4);
blkSize := blkSize - 4;
segNames.PutAt(addr DIV $20000, @segName);
END;
END;
scanner.Skip(blkSize);
UNTIL scanner.atEnd OR (blkType = bEOFMark);

END;

scanner.Close;
END;

(**********
PROCEDURE ReadSegNames;
LABEL
1;
VAR prcsInfo:
error:
progVolume:
fileName:
progExt:

ProcInfoRec;
INTEGER;
TFilePath;
TFilePath;
TFilePath;

Apple Lisa ToolKit 3.0 Source Code Listing -- 695 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

segNameFile:
i:
segName:
segNum:

1:

TEXT;
INTEGER;
S8;
INTEGER;

BEGIN
Info_Process(error, My_id, prcsInfo);
IF error <= 0 THEN
BEGIN
i := Length(prcsInfo.progPathName);
WHILE i > 0 DO
IF (prcsInfo.progPathName[i] = '}') OR (prcsInfo.progPathName[i] = '.') THEN
GOTO 1
ELSE
i := i - 1;
IF i > 0 THEN
filename := Concat(Copy(prcsInfo.progPathName, 1, i), 'SegNames.Text');
Reset(segNameFile, fileName);
i := IoResult;
IF i > 0 THEN
WriteLn('Unable to open ', fileName, ' because of error number ', i:1)
ELSE
BEGIN
WriteLn('Reading segment numbers and names from ', fileName);
WriteLn;
segNames := TArray.CREATE(NIL, mainHeap, 127, SIZEOF(S8));
segNames.InsNullsAt(1, 127);
WHILE (i = 0) AND NOT Eof(segNameFile) DO
BEGIN
segNum := 0;
ReadLn(segNameFile, segNum, inStr);
i := IoResult;
IF (i <= 0) AND (1 <= segNum) AND (segNum <= 127) THEN
BEGIN
TrimBlanks(@inStr);
segName := Copy(Concat(inStr, '
'), 1, 8);
segNames.PutAt(segNum, @segName);
END
ELSE
IF i > 0 THEN
WriteLn('*** IoError number ', i:1, ' reading ', fileName)
ELSE
IF NOT Eof(segNameFile) THEN
WriteLn('*** Bad segment number: ', segNum:1, ' in file ', fileName);
END;
segName := '????????';

Apple Lisa ToolKit 3.0 Source Code Listing -- 696 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

FOR segNum := 1 TO 127 DO


IF TPByte(segNames.At(segNum))^ = 0 THEN
segNames.PutAt(segNum, @segName);
END;

END;
**********)

WriteLn;
WriteLn;
Close(segNameFile);
END;

PROCEDURE WriteName;
BEGIN
IF mthName = '' THEN
BEGIN
LIntToHex(pc, @hexPC);
Write('$', hexPC, '
');
END
ELSE
IF clsName = '' THEN
Write(mthName, '
')
ELSE
Write(clsName, '.', mthName);
END;
FUNCTION TallyRange(pc1, pc2: LONGINT): INTEGER;
VAR slot:
INTEGER;
BEGIN
{If this proves too slow, make the sortarray by PC and binary search it}
FOR slot := 1 TO tallies^^.header.size DO
WITH tallies^^.recs[slot] DO
IF count > 0 THEN
IF pc1 < epPC THEN
IF epPC <= pc2 THEN
BEGIN
TallyRange := slot;
EXIT(TallyRange);
END;
TallyRange := 0;
END;
PROCEDURE SwapIn(valueString: S8);
BEGIN
END;
BEGIN
FOR j := tabLevel - 1 DOWNTO 0 DO (*^*)
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 697 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

elapsed := stopTime - traceTimes[j];


FOR i := j - 1 DOWNTO 0 DO (*^*)
traceTimes[i] := traceTimes[i] + elapsed;
Tally(TpLONGINT(traceFrames[j] + 4)^, elapsed);
END;

(*

totalTime := stopTime - startTime(* - debugTime*);


WriteLn;
WriteLn((totalTime + 500) DIV 1000:1, ' milliseconds have elapsed since tallying began');
WriteLn((totalTime + 500) DIV 1000:1, ' milliseconds have elapsed since tallying began, not counting ',
debugTime:1, ' ms. in debug code.');*)
WriteLn;
totalCalls := 0;
callees := 0;
FOR segNum := 1 TO 127 DO
BEGIN
segCount[segNum] := 0;
segTime[segNum] := 0;
END;
FOR slot := 1 TO tallies^^.header.size DO
WITH tallies^^.recs[slot] DO
IF count > 0 THEN
BEGIN
totalCalls := totalCalls + count;
callees := callees + 1;
segNum := TpINTEGER(@epPC)^ DIV 2;
segCount[segNum] := segCount[segNum] + count;
segTime[segNum] := segTime[segNum] + microseconds;
END;
IF totalCalls = 0 THEN
WriteLn('All tallies are zero.')
ELSE
BEGIN {totalCalls > 0}
roundOff := totalTime DIV 2;
WriteLn(callees:1, ' methods were called
WriteLn;

a total of ', totalCalls:1, ' times.');

IF segNames = NIL THEN


ReadSegNames;
WriteLn('
WriteLn;

SEGMENT USAGE');

Apple Lisa ToolKit 3.0 Source Code Listing -- 698 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

WriteLn('No. of calls
WriteLn('-----------WriteLn;

% of time
---------

Segment
-------

SegSize
-------

Seg#');
----');

FOR segNum := 1 TO 127 DO


IF segCount[segNum] > 0 THEN
BEGIN
IF segNames = NIL THEN
segName := '????????'
ELSE
segName := TPString(segNames.At(segNum))^;
{Be sure the code is swapped in, before getting the size of the segment}
{$R-} SwapIn(TpS8($20000 * segNum)^); {$IFC fRngObject} {$R+} {$ENDC}
WriteLn(segCount[segNum]:8, ' ....... ',
(LONGINT(segTime[segNum]) * 100 + roundOff) DIV totalTime:3, '% ...
segName,
LIntAndLint(TpLONGINT($20000 * segNum)^, $00FFFFFF):8,
segNum:7);
END;

',

REPEAT
WriteLn;
WriteLn;
Write('Report procedure executions sorted by (C = # Calls; T = % of Time; S = Segment)? ');
ReadLn(inStr);
StrUpperCased(@inStr);
TrimBlanks(@inStr);
IF inStr = '' THEN
sortBy := -1
ELSE
IF inStr[1] = 'C' THEN
sortBy := 1
ELSE
IF inStr[1] = 'T' THEN
sortBy := 2
ELSE
IF inStr[1] = 'S' THEN
sortBy := 3
ELSE
sortBy := 0;
IF sortBy > 0 THEN
BEGIN {sortBy > 0}
sortKeys := MakeIdxArray(callees, FALSE);

Apple Lisa ToolKit 3.0 Source Code Listing -- 699 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

{$R-}
WITH sortKeys^^, tallies^^ DO
BEGIN {with}
i := 0;
FOR slot := 1 TO header.size DO
IF recs[slot].count > 0 THEN
BEGIN
i := i + 1;
records[i] := slot;
END;
FOR i := 1 TO callees-1 DO
BEGIN
sloti := records[i];
FOR j := i+1 TO callees DO
BEGIN
slotj := records[j];
CASE sortBy OF
1: swapem := recs[sloti].count > recs[slotj].count;
2: swapem := recs[sloti].microseconds > recs[slotj].microseconds;
3: swapem := TpINTEGER(@recs[sloti].epPC)^ DIV 2 >
TpINTEGER(@recs[slotj].epPC)^ DIV 2;
END;
IF swapem THEN
BEGIN
records[i] := slotj;
records[j] := sloti;
sloti := records[i];
slotj := records[j];
END;
END;
END;
END; {with}
{$IFC fRngObject}{$R+}{$ENDC}
WriteLn('No. of calls
WriteLn('-----------WriteLn;

% of time
---------

Routine name
-----------------

PC
--------

Segment');
-------');

FOR i := callees DOWNTO 1 DO


BEGIN
slot := sortKeys^^.records[i];
WITH tallies^^.recs[slot] DO
BEGIN
calls := count;
micSecs := microseconds;
pc := epPC;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 700 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

j := TpINTEGER(@pc)^ DIV 2;
IF sortBy = 3 THEN {if by segment}
IF i < callees THEN {if not first line printed}
IF j <> segNum THEN {if different from segment of previous line}
WriteLn; {then leave a blank line}
segNum := j;
Write(calls:8, ' ....... ');
pctg := (LONGINT(micSecs) * 100 + roundOff) DIV totalTime;
IF pctg = 0 THEN
Write('
')
ELSE
Write(pctg:3, '%');
Write(' ... ');
IF GetDollarD(TppINTEGER(ORD(@pc)-4), clsName, mthName, nextPC) THEN;
WriteName;
LIntToHex(pc, @hexPC);
Write('
', hexPC);
IF segNames = NIL THEN
Write(segNum:10)
ELSE
BEGIN
segName := TPString(segNames.At(segNum))^;
IF segName = '????????' THEN
Write(segNum:10)
ELSE
Write('
', segName);
END;
WriteLn;
IF CheckKeyPress('Tally and Time Listing') THEN
i := 1;
END; {for i}
TArray(sortKeys).Free;
END; {IF sortBy > 0}
UNTIL sortBy < 0;
IF segNames <> NIL THEN {segNames will be non-NIL except in case of an IO error}
REPEAT
Write('List procedures that were and weren''t called in segment [name or number]? ');

Apple Lisa ToolKit 3.0 Source Code Listing -- 701 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

ReadLn(inStr);
TrimBlanks(@inStr);
StrUpperCased(@inStr);
IF inStr = '?' THEN
BEGIN
WriteLn('List of all segments used by application:');
i := 0; {# output so far}
FOR segnum := 1 TO 127 DO
BEGIN
segname := TPString(segNames.At(segnum))^;
IF segname <> '' THEN
BEGIN
Write(segnum:3, ':', segname, ' ');
i := i+1;
IF i MOD 5 = 0 THEN
WriteLn;
END;
END;
WriteLn;
END
ELSE
IF inStr <> '' THEN
BEGIN
StrToInt(@inStr, segNum, cState);
IF cState <> cvValid THEN
BEGIN
segNum := 0;
FOR i := 1 TO 127 DO
BEGIN
segName := TPString(segNames.At(i))^;
StrUpperCased(@segName);
IF segName = inStr THEN
segNum := i;
END; {For i}
END {invalid number}
ELSE IF (segNum>=1) AND (segNum<=127) THEN{make sure the segment number is OK}
BEGIN
segName := TPString(segNames.At(segNum))^;
IF segName = '' THEN
segNum := 0;
END
ELSE
segNum := 0;
IF segNum = 0 THEN
WriteLn('No such segment')
ELSE
FOR wantCalled := TRUE DOWNTO FALSE DO

Apple Lisa ToolKit 3.0 Source Code Listing -- 702 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

BEGIN
WriteLn;
Write('PROCEDURES THAT WERE ');
IF wantCalled THEN
Write('CALLED')
ELSE
Write('NOT CALLED OR HAD NO BP/EP');
Write(' IN SEGMENT');
IF segNames <> NIL THEN
Write(': ', TPString(segNames.At(segNum))^);
WriteLn(' #', segNum:1, '--');
WriteLn;
pc := segNum * $20000;
j := 0;
WHILE GetDollarD(TppINTEGER(ORD(@pc)-4), clsName, mthName, nextPC) DO
BEGIN
IF (TallyRange(pc, nextPC) > 0) = wantCalled THEN
BEGIN
WriteName;
Write('
');
j := j + 1;
IF j = 4 THEN
BEGIN
j := 0;
WriteLn;
END;
END;
pc := nextPC;
IF CheckKeyPress('Segment Listing') THEN
pc := 0;
END;
WriteLn;
WriteLn;
END; {FOR wantCalled}
END; {inStr <> ''}
UNTIL inStr = '';
END; {totalCalls > 0}
WriteLn;
END;
{$ENDC}
{ ============================================================================================= }

Apple Lisa ToolKit 3.0 Source Code Listing -- 703 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

{$S SgCLAdbg} {for rest of file}


{ ====================================== "FIELDS" METHODS ====================================== }
{$IFC fDebugMethods}
PROCEDURE ParseDecl(inStr: S255;
PROCEDURE FoundName(token: S8);
PROCEDURE FoundType(token: S8; typeCode: TTypeCode; numBytes: INTEGER;
{for arrays only:} lowerBound, upperBound: INTEGER; memberTypeStr: S255);
PROCEDURE FoundUnexpected(token, wanted: S8));
VAR p:
INTEGER;
token:
S8;
eoi:
INTEGER;
alpha:
BOOLEAN;
start:
INTEGER;
{where the last token started}
inhibited: BOOLEAN;
PROCEDURE NextToken;
BEGIN
{Skip leading blanks}
WHILE (p <= eoi) AND (inStr[p] <= ' ') DO
p := p + 1;
start := p;
IF p > eoi THEN
token := ''
ELSE
BEGIN
WHILE (p <= eoi) AND (inStr[p] IN ['-', '0'..'9', 'A'..'Z', 'a'..'z']) DO
p := p + 1;
alpha := p > start;
IF NOT alpha THEN {A single non-alphanumeric nonblank character}
p := p + 1;
token := Copy(inStr, start, CMin(8, p - start));
END;
END;

{Form a word or number}

PROCEDURE Expect(str: S8);


BEGIN
StrUpperCased(@token);
IF token <> str THEN
FoundUnexpected(token, str);
NextToken;

Apple Lisa ToolKit 3.0 Source Code Listing -- 704 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

END;
FUNCTION ParseNumber: LONGINT;
VAR k:
LONGINT;
cState: TConvResult;
BEGIN
StrToLint(@token, k, cState);
IF cState = cvValid THEN
ParseNumber := k
ELSE
FoundUnexpected(token, 'a number');
NextToken;
END;
PROCEDURE ParseField; FORWARD;
PROCEDURE ParseType(inhibit: BOOLEAN);
VAR typeName:
S8;
upName:
S8;
alphaName:
BOOLEAN;
word:
S8;
lowerBound:
INTEGER;
upperBound:
INTEGER;
pp:
INTEGER;
i:
INTEGER;
len:
INTEGER;
wasInhibited:
BOOLEAN;
BEGIN
wasInhibited := inhibited;
IF inhibit THEN
inhibited := TRUE;
typeName := token;
upName := token;
StrUpperCased(@upName);
alphaName := alpha;
NextToken;
IF NOT alphaName THEN
FoundUnexpected(typeName, 'typename')
ELSE
IF upName = 'RECORD' THEN
BEGIN
REPEAT
ParseField;
word := token;
StrUpperCased(@word);
UNTIL (word = 'END') OR (word = '');
Expect('END');
END

Apple Lisa ToolKit 3.0 Source Code Listing -- 705 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

ELSE
IF upName = 'ARRAY' THEN
BEGIN
Expect('[');
lowerBound := ParseNumber;
Expect('.');
Expect('.');
upperBound := ParseNumber;
Expect(']');
pp := p;
Expect('OF');
ParseType(TRUE);
IF NOT inhibited THEN
FoundType('ARRAY', yArray, 0, lowerBound, upperBound, Copy(inStr, pp, start - pp));
END
ELSE
IF upName = 'STRING' THEN
BEGIN
Expect('[');
len := ParseNumber;
Expect(']');
IF NOT inhibited THEN
FoundType('STRING', yString, len + 1, 0, 0, '');
END
ELSE
IF upName = 'BOOLEAN' THEN
BEGIN
IF NOT inhibited THEN
FoundType(typeName, yBoolean, 1, 0, 0, '');
END
ELSE
IF upName = 'CHAR' THEN
BEGIN
IF NOT inhibited THEN
FoundType(typeName, yChar, 2, 0, 0, '')
END
ELSE
IF upName = 'BYTE' THEN
BEGIN
IF NOT inhibited THEN
FoundType(typeName, yByte, 1, 0, 0, '')
END
ELSE
IF upName = 'HEXBYTE' THEN
BEGIN
IF NOT inhibited THEN
FoundType(typeName, yHexByte, 1, 0, 0, '')
END

Apple Lisa ToolKit 3.0 Source Code Listing -- 706 of 1012

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163
001164
001165
001166
001167
001168
001169
001170
001171
001172
001173
001174
001175
001176
001177
001178
001179
001180
001181
001182
001183
001184
001185
001186
001187
001188
001189
001190
001191
001192
001193
001194
001195

ELSE
IF upName = 'INTEGER' THEN
BEGIN
IF NOT inhibited THEN
FoundType(typeName,
END
ELSE
IF upName = 'HEXINTEG' THEN
BEGIN
IF NOT inhibited THEN
FoundType(typeName,
END
ELSE
IF upName = 'LONGINT' THEN
BEGIN
IF NOT inhibited THEN
FoundType(typeName,
END
ELSE
IF upName = 'REAL' THEN
BEGIN
IF NOT inhibited THEN
FoundType(typeName,
END
ELSE
IF upName = 'POINT' THEN
BEGIN
IF NOT inhibited THEN
FoundType(typeName,
END
ELSE
IF upName = 'PTR' THEN
BEGIN
IF NOT inhibited THEN
FoundType(typeName,
END
ELSE
IF upName = 'LONGREAL' THEN
BEGIN
IF NOT inhibited THEN
FoundType(typeName,
END
ELSE
IF upName = 'LPOINT' THEN
BEGIN
IF NOT inhibited THEN
FoundType(typeName,
END

yInteger, 2, 0, 0, '')

yHexInteger, 1, 0, 0, '')

yLongInt, 4, 0, 0, '')

yReal, 4, 0, 0, '')

yPoint, 4, 0, 0, '')

yPtr, 4, 0, 0, '')

yLongReal, 8, 0, 0, '')

yLPoint, 8, 0, 0, '')

Apple Lisa ToolKit 3.0 Source Code Listing -- 707 of 1012

Apple Lisa Computer Technical Information


001196
001197
001198
001199
001200
001201
001202
001203
001204
001205
001206
001207
001208
001209
001210
001211
001212
001213
001214
001215
001216
001217
001218
001219
001220
001221
001222
001223
001224
001225
001226
001227
001228
001229
001230
001231
001232
001233
001234
001235
001236
001237
001238
001239
001240
001241
001242
001243

ELSE
IF upName = 'RECT' THEN
BEGIN
IF NOT inhibited THEN
FoundType(typeName, yRect, 8, 0, 0, '')
END
ELSE
IF upName = 'LRECT' THEN
BEGIN
IF NOT inhibited THEN
FoundType(typeName, yLRect, 16, 0, 0, '')
END
ELSE
BEGIN
IF CiOfCn(upName) > 0 THEN
BEGIN
word := token;
StrUpperCased(@word);
IF word = 'OF' THEN
BEGIN
pp := p;
NextToken;
ParseType(TRUE);
IF NOT inhibited THEN
FoundType(typeName, yObject, SIZEOF(Handle), 0, 0, Copy(inStr, pp, start - pp));
END
ELSE
IF NOT inhibited THEN
FoundType(typeName, yObject, SIZEOF(Handle), 0, 0, '');
END
ELSE
FoundUnexpected(typeName, 'typename');
END;
inhibited := wasInhibited;
END;
PROCEDURE ParseField;
BEGIN
IF NOT alpha THEN
BEGIN
FoundUnexpected(token, 'var name');
NextToken;
END
ELSE
BEGIN
IF NOT inhibited THEN
FoundName(token);
NextToken;

Apple Lisa ToolKit 3.0 Source Code Listing -- 708 of 1012

Apple Lisa Computer Technical Information


001244
001245
001246
001247
001248
001249
001250
001251
001252
001253
001254
001255
001256
001257
001258
001259
001260
001261
001262
001263
001264
001265
001266
001267
001268
001269
001270
001271
001272
001273
001274
001275
001276
001277
001278
001279
001280
001281
001282
001283
001284
001285
001286
001287
001288
001289
001290
001291

END;

Expect(':');
ParseType(FALSE);
IF token = ';' THEN
NextToken
ELSE
IF (token <> '') AND (token <> 'END') THEN
FoundUnexpected(token, '; or END');
END;

BEGIN
inhibited := FALSE;
p := 1;
eoi := Length(inStr);
Insert(' ', inStr, Length(inStr) + 1); {So that inStr[eoi+1] won't blow up}
NextToken;
WHILE token <> '' DO
ParseField;
END;
PROCEDURE WriteDRecord{(numLevels: INTEGER; hDRecord: Handle; posInDRecord: INTEGER;
PROCEDURE SupplyFields(PROCEDURE Field(nameAndType: S255)))};
VAR fieldInDRecord: INTEGER;
PROCEDURE WrCkAbort;
BEGIN
IF KeyPress THEN
BEGIN
WrStr('...abort...');
EXIT(WriteDRecord);
END;
END;
PROCEDURE DeclName(token: S8);
BEGIN
WrCkAbort;
WrStr(Concat(token, ': '));
END;
PROCEDURE SkipName(token: S8);
BEGIN
WrCkAbort;
END;
PROCEDURE DeclBad(token, wanted: S8);
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 709 of 1012

Apple Lisa Computer Technical Information


001292
001293
001294
001295
001296
001297
001298
001299
001300
001301
001302
001303
001304
001305
001306
001307
001308
001309
001310
001311
001312
001313
001314
001315
001316
001317
001318
001319
001320
001321
001322
001323
001324
001325
001326
001327
001328
001329
001330
001331
001332
001333
001334
001335
001336
001337
001338
001339

WrCkAbort;
WrLn;
WrStr('<<The Field proc expected:');
WrStr(Concat(' ''', wanted, ''' '));
WrStr('but encountered:');
WrStr(Concat(' ''', token, '''>>'));
END;
PROCEDURE DeclType(token: S8; typeCode: TTypeCode; numBytes: INTEGER;
lowerBound, upperBound: INTEGER; memberTypeStr: S255); FORWARD;
PROCEDURE DeclArray(token: S8; lowerBound, upperBound: INTEGER; memberTypeStr: S255);
VAR str1:
S8;
str2:
S8;
i:
INTEGER;
origPos:
INTEGER;
BEGIN
IF Odd(posInDRecord) THEN
posInDRecord := posInDRecord + 1;
IntToStr(lowerBound, @str1);
IntToStr(upperBound, @str2);
WrStr(Concat(token, ' [', str1, '..', str2, '] = {'));
FOR i := lowerBound TO upperBound DO
BEGIN
IF i > lowerBound THEN
WrStr(', ');
origPos := posInDRecord;
IntToStr(i, @str1);
ParseDecl(CONCAT(str1, ': ', memberTypeStr), DeclName, DeclType, DeclBad);
(*****
IF Odd(posInDRecord) THEN
posInDRecord := posInDRecord + 1;
*****)
END;
WrStr('}');
END;
PROCEDURE DeclType(token: S8; typeCode: TTypeCode; numBytes: INTEGER;
lowerBound, upperBound: INTEGER; memberTypeStr: S255);
TYPE
TAlias =
RECORD
CASE TTypeCode OF
yByte:
(asByte:
Byte);
yChar:
(asChar:
CHAR);
yInteger:
(asInteger: INTEGER);
yLongInt:
(asLongInt: LONGINT);
yLPoint:
(asLPoint: FakeLPoint);

Apple Lisa ToolKit 3.0 Source Code Listing -- 710 of 1012

Apple Lisa Computer Technical Information


001340
001341
001342
001343
001344
001345
001346
001347
001348
001349
001350
001351
001352
001353
001354
001355
001356
001357
001358
001359
001360
001361
001362
001363
001364
001365
001366
001367
001368
001369
001370
001371
001372
001373
001374
001375
001376
001377
001378
001379
001380
001381
001382
001383
001384
001385
001386
001387

yLRect:
(asLRect:
yObject:
(asObject:
yPoint:
(asPoint:
yReal:
(asReal:
yRect:
(asRect:
yString:
(asString:
END;
^TAlias;
{a bona
TObject;
S255;
INTEGER;

FakeLRect);
TObject);
FakePoint);
REAL);
FakeRect);
S255);

VAR alias:
fide use for aliasing instead of typecasting}
obj:
str:
i:
BEGIN
IF typeCode = yArray THEN
BEGIN
DeclArray(token, lowerBound, upperBound, memberTypeStr);
EXIT(DeclType);
END;
IF token <> '' THEN
WrStr(Concat(token, ' = '));
IF numBytes > 1 THEN
IF Odd(posInDRecord) THEN
posInDRecord := posInDRecord + 1;
alias := POINTER(ORD(hDRecord^) + posInDRecord); {Careful, this is a relocatable location!}
str := '';
CASE typeCode OF
yPtr:
BEGIN
LIntToHex(alias^.asLongInt, @str);
str := Concat('$', str);
END;
yBoolean:
IF alias^.asByte = ORD(FALSE) THEN
str := 'FALSE'
ELSE
str := 'TRUE';
yByte:
IntToStr(alias^.asByte, @str);
yHexByte:
BEGIN
LIntToHex(alias^.asByte, @str);
str := CONCAT('$', Copy(str, 7, 2));
END;
yChar:
BEGIN
str := 'A';
str[1] := alias^.asChar;
END;
yInteger:
IntToStr(alias^.asInteger, @str);
yHexInteger:BEGIN
LIntToHex(alias^.asInteger, @str);

Apple Lisa ToolKit 3.0 Source Code Listing -- 711 of 1012

Apple Lisa Computer Technical Information


001388
001389
001390
001391
001392
001393
001394
001395
001396
001397
001398
001399
001400
001401
001402
001403
001404
001405
001406
001407
001408
001409
001410
001411
001412
001413
001414
001415
001416
001417
001418
001419
001420
001421
001422
001423
001424
001425
001426
001427
001428
001429
001430
001431
001432
001433
001434
001435

yLongInt:
yLPoint:
yLRect:
yObject:

yPoint:
yRect:
yString:

yReal:

OTHERWISE
END;

str := CONCAT('$', Copy(str, 5, 4));


END;
LIntToStr(alias^.asLongInt, @str);
LPointToStr(alias^.asLPoint, @str);
LRectToStr(alias^.asLRect, @str);
BEGIN
obj := alias^.asObject;
LIntToHex(ORD(obj), @str);
str := Concat('$', str, ' -- ');
IF obj = NIL THEN
str := 'NIL'
ELSE IF NOT ValidObject(Handle(obj)) THEN
str := Concat(str, 'Invalid Object')
ELSE
BEGIN
WrStr(str);
str := '';
obj.Debug(numLevels - 1, memberTypeStr);
END;
END;
PointToStr(alias^.asPoint, @str);
RectToStr(alias^.asRect, @str);
BEGIN
str := Concat('''', alias^.asString, '''');
IF Odd(numBytes) THEN
numBytes := numBytes + 1;
END;
BEGIN
LIntToStr(Round(alias^.asReal * 1000.0), @str);
FOR i := LENGTH(str) TO 3 DO
Insert('0', str, 1);
Insert('.', str, LENGTH(str)-2);
END;
DeclBad(token, 'typename');

WrCkAbort;
IF str <> '' THEN
WrStr(Concat(str, ' '));
posInDRecord := posInDRecord + numBytes;
END;
PROCEDURE DebugField(nameAndType: S255);
BEGIN
IF nameAndType <> '' THEN
BEGIN
fieldInDRecord := fieldInDRecord + 1;

Apple Lisa ToolKit 3.0 Source Code Listing -- 712 of 1012

Apple Lisa Computer Technical Information


001436
001437
001438
001439
001440
001441
001442
001443
001444
001445
001446
001447
001448
001449
001450
001451
001452
001453
001454
001455
001456
001457
001458
001459
001460
001461
001462
001463
001464
001465
001466
001467
001468
001469
001470
001471
001472
001473
001474
001475
001476
001477
001478
001479
001480
001481
001482
001483

IF fieldInDRecord > 1 THEN


WrStr('; ');
ParseDecl(nameAndType, DeclName, DeclType, DeclBad);
WrCkAbort;
END
ELSE
{Empty string signifies padding to a word boundary, if necessary}
IF Odd(posInDRecord) THEN
posInDRecord := posInDRecord + 1;
END;
BEGIN
IF KeyPress THEN
Exit(WriteDRecord);
fieldInDRecord := 0;
WrStr('[ ');
SupplyFields(DebugField);
WrStr('] ');
END;
PROCEDURE DumpVar{(pVariable: Ptr; nameAndType: S255)};
PROCEDURE SupplyVar(PROCEDURE Field(nameAndType: S255));
BEGIN
Field(nameAndType);
END;
BEGIN
currXPos := 0;
outputIndent := 20;
WriteDRecord(1, @pVariable, 0, SupplyVar);
outputIndent := 0;
WrLn;
END;
{$ENDC}
{ ====================================== KITBUG ====================================== }
{$IFC fDbgObject}
PROCEDURE WrStr{(str: S255)};
VAR start: INTEGER;
maxLen: INTEGER;
len:
INTEGER;
total: INTEGER;
BEGIN

{ Write a STRING with word-wrap }

Apple Lisa ToolKit 3.0 Source Code Listing -- 713 of 1012

Apple Lisa Computer Technical Information


001484
001485
001486
001487
001488
001489
001490
001491
001492
001493
001494
001495
001496
001497
001498
001499
001500
001501
001502
001503
001504
001505
001506
001507
001508
001509
001510
001511
001512
001513
001514
001515
001516
001517
001518
001519
001520
001521
001522
001523
001524
001525
001526
001527
001528
001529
001530
001531

total := Length(str);
start := 1;
WHILE start <= total DO
BEGIN
len := total - start + 1;
maxLen := outputRMargin - currXPos;
IF len > maxLen THEN
BEGIN
len := maxLen;
WHILE (len > 0) AND (str[len] <> ' ') DO
len := len - 1;
IF (len = 0) AND (currXPos = outputIndent) THEN
len := maxLen;
END;
IF len > 0 THEN
BEGIN
Write(Copy(str, start, len));
currXPos := currXPos + len;
start := start + len;
END;
IF (currXPos >= outputRMargin) OR (start <= total) THEN
WrLn;
END;
END;
PROCEDURE WrLn;
BEGIN
WriteLn;
IF outputIndent > 0 THEN
BEGIN
Write(' ':outputIndent);
currXPos := outputIndent;
END
ELSE
currXPos := 0;
END;

{ goto next line and output indentation }

FUNCTION CheckKeyPress{(routine: S255): BOOLEAN};


VAR ch: CHAR;
BEGIN
IF KeyPress THEN
BEGIN
IF routine <> '' THEN
BEGIN
WriteLn;
WriteLn('
-- ', routine, ' stopped because you typed a key --');

Apple Lisa ToolKit 3.0 Source Code Listing -- 714 of 1012

Apple Lisa Computer Technical Information


001532
001533
001534
001535
001536
001537
001538
001539
001540
001541
001542
001543
001544
001545
001546
001547
001548
001549
001550
001551
001552
001553
001554
001555
001556
001557
001558
001559
001560
001561
001562
001563
001564
001565
001566
001567
001568
001569
001570
001571
001572
001573
001574
001575
001576
001577
001578
001579

WriteLn;
END;
(* commented out and should be removed if paslib bug has been fixed
{ flush characters; because of PASLIB bug, also stop when user types a ~ }
ch := ' ';
WHILE KeyPress AND (ch<>'~') DO
IF EOLn THEN
ReadLn
ELSE
Read(ch);
*)
CheckKeyPress := TRUE;
END
ELSE
CheckKeyPress := FALSE;
END;
{$IFC fDebugMethods}
PROCEDURE WrObj(object: TObject; numLevels: INTEGER; memberTypeStr: S255);
BEGIN
WriteLn;
currXPos := 0;
outputIndent := 0;
IF ValidObject(Handle(object)) THEN
BEGIN
object.Debug(numLevels, memberTypeStr);
IF CheckKeyPress('Display of the object') THEN;
END
ELSE
Write('Not an object: ', ORD(object):1);
END;
{$ENDC}
{$S SgCLAini}
PROCEDURE DumpHeap(heap: THeap; wantedSTP: LONGINT; wantedReference: LONGINT; fPrintSelf: BOOLEAN);
VAR hz:
THz;
cb:
TC;
hndl:
Handle;
obj:
TObject;
heapSize:
LONGINT;
numObjects:
LONGINT;
{Clascal objects only}
objOvhdSize:
LONGINT;
{includes master, header, and class pointer}
objDataSize:
LONGINT;
numOther:
LONGINT;
{Non-Clascal objects}
otherSize:
LONGINT;
numFree:
LONGINT;

Apple Lisa ToolKit 3.0 Source Code Listing -- 715 of 1012

Apple Lisa Computer Technical Information


001580
001581
001582
001583
001584
001585
001586
001587
001588
001589
001590
001591
001592
001593
001594
001595
001596
001597
001598
001599
001600
001601
001602
001603
001604
001605
001606
001607
001608
001609
001610
001611
001612
001613
001614
001615
001616
001617
001618
001619
001620
001621
001622
001623
001624
001625
001626
001627

freeSize:
bigFreeSize:
bk:
dumpIt:
valid:
offset:
base:
hStr:
class:
className:

BEGIN
WriteLn;

LONGINT;
LONGINT;
TBk;
BOOLEAN;
BOOLEAN;
INTEGER;
LONGINT;
S8;
TClass;
TClassName;

IF heap = NIL THEN


BEGIN
WriteLn('The heap pointer is NIL');
WriteLn;
EXIT(DumpHeap);
END;
hz := THz(heap);
heapSize := cbOfHz(hz);
numObjects := 0;
objOvhdSize := 0;
objDataSize := 0;
numOther := 0;
otherSize := 0;
numFree := 0;
freeSize := 0;
bigFreeSize := 0;
WriteLn('Heap size in bytes: ', heapSize:6);
WriteLn('Bytes free:
', hz^.cbFree:6);
WriteLn;
WriteLn('Heap contents (handle, size in bytes):');
WriteLn;
{ setup indentation for writing objects }
outputIndent := 17; { '$', ORD(hndl):8, cb:6, ': ' }
bk := hz^.bkFst;
WHILE (ORD(bk) >= ORD(hz^.bkFst)) AND (ORD(bk) <= ORD(hz^.bkLst)) DO
BEGIN
IF bk^.hdr.tybk <> tybkFree THEN
cb := bk^.hdr.cw * 2
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 716 of 1012

Apple Lisa Computer Technical Information


001628
001629
001630
001631
001632
001633
001634
001635
001636
001637
001638
001639
001640
001641
001642
001643
001644
001645
001646
001647
001648
001649
001650
001651
001652
001653
001654
001655
001656
001657
001658
001659
001660
001661
001662
001663
001664
001665
001666
001667
001668
001669
001670
001671
001672
001673
001674
001675

cb := bk^.cwFree * 2;
IF cb <= 0 THEN
BEGIN
WriteLn('FREE BLOCK ', ORD(bk):1, ' HAS LENGTH', cb);
EXIT(DumpHeap);
END;
CASE bk^.hdr.tybk OF
tybkStd:
BEGIN
{$IFC LibraryVersion <= 20}
hndl := Handle(ORD(hz) + bk^.oh);
{$ELSEC}
hndl := Handle(ORD(@hz^.argpPool) + (LONGINT(bk^.bp.ip)*4));
{$ENDC}
valid := ValidObject(hndl);
IF wantedSTP > 0 THEN
IF valid THEN
{looks like a class pointer; pray that it is!}
dumpIt := %_InObCp(ORD(hndl), wantedSTP)
ELSE
dumpIt := FALSE
ELSE
IF wantedReference <> 0 THEN
BEGIN
offset := 0;
base := ORD(hndl^);
WHILE (offset < cb) AND (TpLONGINT(base + offset)^ <> wantedReference) DO
offset := offset + 2;
dumpIt := offset < cb;
END
ELSE
dumpIt := TRUE;
IF dumpIt THEN
BEGIN
LIntToHex(ORD(hndl), @hStr);
Write('$', hStr, cb:6, ': ');
IF bk <> TBk(ORD(hndl^) - 4) THEN
BEGIN
WriteLn('INCORRECT BACK POINTER FOR bk = ', ORD(bk):1);
EXIT(DumpHeap);
END;
IF valid THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 717 of 1012

Apple Lisa Computer Technical Information


001676
001677
001678
001679
001680
001681
001682
001683
001684
001685
001686
001687
001688
001689
001690
001691
001692
001693
001694
001695
001696
001697
001698
001699
001700
001701
001702
001703
001704
001705
001706
001707
001708
001709
001710
001711
001712
001713
001714
001715
001716
001717
001718
001719
001720
001721
001722
001723

obj := TObject(hndl);
currXPos := outputIndent;
{$IFC fDebugMethods}
IF fPrintSelf THEN
obj.Debug(1, '')
ELSE
obj.Debug(0, '');
{$ELSEC}
class := obj.Class;
CpToCn(TPSliceTable(class), TS8(className));
TrimBlanks(@className);
Write(className);
{$ENDC}
numObjects := numObjects + 1;
objOvhdSize := objOvhdSize + 12; {master=4, header=4, classPtr=4}
objDataSize := objDataSize + cb-4;
{classPtr=4}
END
ELSE
BEGIN
numOther := numOther + 1;
otherSize := otherSize + cb;
Write('???');
END;
WriteLn;
END;
bk := TBk(ORD(hndl^) - 4); {in case the heap compacted during obj.Debug}
END;
tybkFree:
BEGIN
numFree := numFree + 1;
freeSize := freeSize + cb;
IF cb > bigFreeSize THEN
bigFreeSize := cb;
END;
OTHERWISE
BEGIN
numOther := numOther + 1;
otherSize := otherSize + cb;
END;
END;
bk := TBk(ORD(bk) + cb);

Apple Lisa ToolKit 3.0 Source Code Listing -- 718 of 1012

Apple Lisa Computer Technical Information


001724
001725
001726
001727
001728
001729
001730
001731
001732
001733
001734
001735
001736
001737
001738
001739
001740
001741
001742
001743
001744
001745
001746
001747
001748
001749
001750
001751
001752
001753
001754
001755
001756
001757
001758
001759
001760
001761
001762
001763
001764
001765
001766
001767
001768
001769
001770
001771

IF CheckKeyPress('HeapDump') THEN
EXIT(DumpHeap);
END;
WriteLn;
IF numObjects > 0 THEN
BEGIN
WriteLn('Number of Clascal objects:
', numObjects:6);
IF wantedReference = 0 THEN
BEGIN
WriteLn('Bytes in their headers & masters: ', objOvhdSize:12);
WriteLn('Bytes in their records:
', objDataSize:12);
IF objDataSize+objOvhdSize > 0 THEN
WriteLn('Header and master overhead:
',
(100 * objOvhdSize) DIV (objDataSize+objOvhdSize):5, '%');
END;
WriteLn;
END;
IF (wantedSTP <= 0) AND (wantedReference = 0) THEN
BEGIN
WriteLn('Number of free blocks:
', numFree:6);
WriteLn('Largest free block:
', bigFreeSize:6);
WriteLn('Bytes in free blocks:
', freeSize:12);
WriteLn;
WriteLn('Number of other blocks:
', numOther:6);
WriteLn('Bytes in those blocks:
', otherSize:12);
WriteLn;
WriteLn('Other overhead:
', heapSize-objOvhdSize-objDataSize-freeSize-otherSize:12);
WriteLn('Total heap size in bytes:
', heapSize:12);
WriteLn;
END;
END;
{$S SgCLAini}
PROCEDURE GoKitBug; {intended to be called from LisaBug}
BEGIN
EntDebugger(' ', 'Called from GoKitBug');
END;
{$S SgCLAini}
PROCEDURE EntDebugger{(inputStr, enterReason: S255)};
LABEL 99;
CONST
null = CHR(0);
VAR token:
S255;

Apple Lisa ToolKit 3.0 Source Code Listing -- 719 of 1012

Apple Lisa Computer Technical Information


001772
001773
001774
001775
001776
001777
001778
001779
001780
001781
001782
001783
001784
001785
001786
001787
001788
001789
001790
001791
001792
001793
001794
001795
001796
001797
001798
001799
001800
001801
001802
001803
001804
001805
001806
001807
001808
001809
001810
001811
001812
001813
001814
001815
001816
001817
001818
001819

cState:
timeToGo:
brClass:
brMethod:

TConvResult;
BOOLEAN;
S8;
S8;

PROCEDURE GetToken;
VAR endOfToken: INTEGER;
BEGIN
token := '';
WHILE Pos(' ', inputStr) = 1 DO
Delete(inputStr,1,1);
endOfToken := Pos(' ', inputStr)-1;
IF endOfToken <= 0 THEN
endOfToken := Length(inputStr);
token := Copy(inputStr, 1, endOfToken);
Delete(inputStr, 1, endOfToken);
END;
PROCEDURE DebugStatus;
VAR i: INTEGER;
BEGIN
IntToStr(curTraceLevel, @token);
Write('Watch Level = ',token);
IntToStr(defTraceCount, @token);
WriteLn(', Watch Count = ',token);
FOR i := 1 TO breakMCount DO
WITH breakMethods[i] DO
IF (brClass <> '') OR (brMethod <> '') THEN
WriteLn(i:3, ': ', brClass:8,'.',brMethod:8)
END;
PROCEDURE ClearBreaks;
VAR brNumber:
INTEGER;
cState:
TConvResult;
BEGIN
GetToken;
IF token = '' THEN
BEGIN
Write('Clear which breakpoint [A for all breakpoints]? ');
ReadLn(token);
END;
TrimBlanks(@token);
StrUpperCased(@token);
IF token <> '' THEN
IF token[1] = 'A' THEN
breakMCount := 0

Apple Lisa ToolKit 3.0 Source Code Listing -- 720 of 1012

Apple Lisa Computer Technical Information


001820
001821
001822
001823
001824
001825
001826
001827
001828
001829
001830
001831
001832
001833
001834
001835
001836
001837
001838
001839
001840
001841
001842
001843
001844
001845
001846
001847
001848
001849
001850
001851
001852
001853
001854
001855
001856
001857
001858
001859
001860
001861
001862
001863
001864
001865
001866
001867

ELSE
BEGIN
StrToInt(@token, brNumber, cState);
IF cState = cvValid THEN
IF (brNumber >= 1) AND (brNumber <= breakMCount) THEN
WITH breakMethods[brNumber] DO
BEGIN
brClass := '';
brMethod := '';

END;

END;

IF brNumber = breakMCount THEN


breakMCount := breakMCount - 1;
END;

{ get input up to the first '.'; if non-null convert to 8 characters;


prompt user with argument if there is no pending input }
PROCEDURE GetOne(prompt: S255);
VAR i: INTEGER;
BEGIN
GetToken;
IF token = '' THEN
BEGIN
Write(prompt);
ReadLn(token);
END;
i := Pos('.', token);
IF i > 0 THEN
BEGIN
inputStr := Concat(Copy(token, i + 1, Length(token) - i), inputStr);
token := Copy(token, 1, i - 1);
END;
TrimBlanks(@token);
IF token <> '' THEN
BEGIN
StrUpperCased(@token);
token := Copy(Concat(token, '
END;
END;

'), 1, 8);

PROCEDURE BrSetup(prompt: S255);


VAR brNumber:
INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 721 of 1012

Apple Lisa Computer Technical Information


001868
001869
001870
001871
001872
001873
001874
001875
001876
001877
001878
001879
001880
001881
001882
001883
001884
001885
001886
001887
001888
001889
001890
001891
001892
001893
001894
001895
001896
001897
001898
001899
001900
001901
001902
001903
001904
001905
001906
001907
001908
001909
001910
001911
001912
001913
001914
001915

FUNCTION MoreThanAClass: Boolean;


BEGIN
MoreThanAClass := TRUE;
IF length(inputstr) > 0 THEN
IF inputstr[length(inputstr)] = '.' THEN
BEGIN
GetOne(Concat(prompt,' what Class?'));
WITH breakMethods[brNumber] DO
BEGIN
brClass := token;
brMethod := '';
END;
MoreThanAClass := FALSE;
END;
END;
BEGIN
FOR brNumber := 1 TO maxBreaks DO
WITH breakMethods[brNumber] DO
IF (brNumber > breakMCount) OR ((brClass='') AND (brMethod='')) THEN
BEGIN
IF MoreThanAClass THEN
BEGIN
GetOne(Concat(prompt,' what Class?'));
brClass := token;
GetOne(Concat(prompt,' what Method?'));
brMethod := token;
END;
IF (brClass <> '') OR (brMethod <> '') THEN
breakMCount := Max(breakMCount, brNumber);
lastBpPc := 0;
lastEpPc := 0;
EXIT(BrSetup);
END;
WriteLn('Too Many Breaks Defined, you must first clear a breakpoint')
END;
PROCEDURE TraceOrNot;
VAR i: INTEGER;
BEGIN
GetToken;
StrToInt(@token, i, cState);
IF cState = cvValid THEN
BEGIN
defTraceCount := i;
GetToken;
END

Apple Lisa ToolKit 3.0 Source Code Listing -- 722 of 1012

Apple Lisa Computer Technical Information


001916
001917
001918
001919
001920
001921
001922
001923
001924
001925
001926
001927
001928
001929
001930
001931
001932
001933
001934
001935
001936
001937
001938
001939
001940
001941
001942
001943
001944
001945
001946
001947
001948
001949
001950
001951
001952
001953
001954
001955
001956
001957
001958
001959
001960
001961
001962
001963

ELSE
defTraceCount := 0;
returnToMain := TRUE;
fTraceSelf := FALSE;
fTraceClass := FALSE;
WHILE token <> '' DO
BEGIN
StrUpperCased(@token);
IF token[1] = 'A' THEN {Stay on Alternate Screen During Trace}
returnToMain := FALSE
ELSE
IF token[1] = 'C' THEN {Print Class with Trace}
fTraceClass := TRUE
ELSE
IF token[1] = 'F' THEN {Print Fields with Trace}
fTraceSelf := TRUE;
GetToken;
END;
fTraceEnabled := TRUE;
traceCount := defTraceCount;
END;
PROCEDURE Level;
VAR i: INTEGER;
BEGIN
GetToken;
IF token = '' THEN
BEGIN
Write('Lowest BP level to watch (1..9999)? ');
ReadLn(token);
END;
StrToInt(@token, i, cState);
IF cState = cvValid THEN
IF (i >= 1) AND (i <= 32000) THEN
curTraceLevel := i;
END;
FUNCTION YesNo(prompt: S255): BOOLEAN;
BEGIN
REPEAT
GetOne(Concat(prompt, '? [Y/N]: '));
IF token = '' THEN
GOTO 99;
UNTIL token[1] IN ['Y', 'N'];
YesNo := token[1] = 'Y';
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 723 of 1012

Apple Lisa Computer Technical Information


001964
001965
001966
001967
001968
001969
001970
001971
001972
001973
001974
001975
001976
001977
001978
001979
001980
001981
001982
001983
001984
001985
001986
001987
001988
001989
001990
001991
001992
001993
001994
001995
001996
001997
001998
001999
002000
002001
002002
002003
002004
002005
002006
002007
002008
002009
002010
002011

PROCEDURE PromptOnOff;
BEGIN
showPrompt := YesNo('Show Debugger Prompt');
END;
{$IFC fDebugMethods}
PROCEDURE Inspect;
VAR lh: LONGINT;
d: INTEGER;
BEGIN
GetToken;
IF token = '' THEN
BEGIN
Write('Handle to inspect [depth] [member decl]? ');
Readln(inputStr);
GetToken;
END;
HexStrToLInt(@token, lh, cState);
IF cState <> cvValid THEN
BEGIN
WriteLn('Not a hex number');
Exit(Inspect);
END
ELSE
GetToken;
StrToInt(@token, d, cState);
IF cState <> cvValid THEN
d := 1;
IF ValidObject(Handle(lh)) THEN
BEGIN
WrObj(TObject(lh), d, inputStr);
Writeln;
END
ELSE
Writeln('Invalid Object');
Writeln;
END;
{$ENDC}
PROCEDURE TallyAndTime;
BEGIN
tallyingCalls := FALSE;
IF tallies <> NIL THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 724 of 1012

Apple Lisa Computer Technical Information


002012
002013
002014
002015
002016
002017
002018
002019
002020
002021
002022
002023
002024
002025
002026
002027
002028
002029
002030
002031
002032
002033
002034
002035
002036
002037
002038
002039
002040
002041
002042
002043
002044
002045
002046
002047
002048
002049
002050
002051
002052
002053
002054
002055
002056
002057
002058
002059

BEGIN
IF YesNo('Do you want to see performance measurements now') THEN
TallyReport;
IF YesNo('Do you want to zero the tallies and times') THEN
TallyZero;
END;
IF YesNo('Do you want to continue execution and measure its performance') THEN
TallyStart;
WriteLn;
END;
PROCEDURE RefsToObject;
VAR lh: LONGINT;
BEGIN
GetToken;
IF token = '' THEN
BEGIN
Write('Handle of the object whose every Reference from the same heap should be dumped? ');
Readln(inputStr);
GetToken;
END;
HexStrToLInt(@token, lh, cState);
IF cState <> cvValid THEN
BEGIN
WriteLn('Not a hex number');
Exit(RefsToObject);
END;
IF ValidObject(Handle(lh)) THEN
DumpHeap(TObject(lh).Heap, -1, lh, TRUE)
ELSE
Writeln('Invalid Object');
Writeln;
END;
FUNCTION StackFrame(whichFrame: INTEGER): LONGINT;
{ Returns address of stack frame 'whichFrame' (>=-1);
whichFrame < 0 returns -1.
whichFrame = 1 is the top frame not belonging to the debugger itself.
When called from ABCBREAK, the caller of ABCBREAK is frame 1;
When called from BEPSN, the caller of BP or EP is frame 1.
whichFrame = 2 is the caller of frame 1, and so on.
If whichFrame is greater than # frames, returns -1.
If neither ABCBREAK nor BEPSN is on the stack, returns -1.}
VAR dummy:
INTEGER;
{ must be first local and two bytes long }
RA6:
LONGINT;
RA5:
LONGINT;

Apple Lisa ToolKit 3.0 Source Code Listing -- 725 of 1012

Apple Lisa Computer Technical Information


002060
002061
002062
002063
002064
002065
002066
002067
002068
002069
002070
002071
002072
002073
002074
002075
002076
002077
002078
002079
002080
002081
002082
002083
002084
002085
002086
002087
002088
002089
002090
002091
002092
002093
002094
002095
002096
002097
002098
002099
002100
002101
002102
002103
002104
002105
002106
002107

i:
className:
procName:
startCount:
frameReference:
nextPC:

INTEGER;
TClassName;
S8;
BOOLEAN;
INTEGER;
LONGINT;

BEGIN
StackFrame := -1;
frameReference := 0;
startCount := FALSE;

{ default return }

RA5 := %_GetA5;
RA6 := ORD(@dummy)+2;
{ stack frame called by current one; start with my stack frame }
WHILE (whichFrame >= frameReference) AND (RA6 <> RA5) DO
BEGIN
IF NOT startCount THEN
BEGIN
IF GetDollarD(TppINTEGER(RA6), className, procName, nextPC) THEN { is this frame 0? }
IF (className = '') AND ((procName = 'BEPSN
') OR (procName = 'ABCBREAK'))THEN
BEGIN
startCount := TRUE; { yes }
IF procName = 'BEPSN
' THEN
frameReference := -1;
END;
END;
RA6 := TpLONGINT(RA6)^;

END;

{ preceding stack frame }

IF startCount THEN
BEGIN
IF whichFrame = frameReference THEN
StackFrame := RA6;
whichFrame := whichFrame - 1;
END;
END;

PROCEDURE WrMemory(start: LONGINT; numBytes: INTEGER; checkAddresses: BOOLEAN);


VAR addr:
LONGINT;
str:
S255;
asChars:
STRING[16];
extdWord:
LONGINT;
overflow:
BOOLEAN;
fullBytes: INTEGER;
FUNCTION Byte2Char(n: INTEGER): CHAR;
BEGIN
IF (n < 32) OR (n > ORD('~')) THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 726 of 1012

Apple Lisa Computer Technical Information


002108
002109
002110
002111
002112
002113
002114
002115
002116
002117
002118
002119
002120
002121
002122
002123
002124
002125
002126
002127
002128
002129
002130
002131
002132
002133
002134
002135
002136
002137
002138
002139
002140
002141
002142
002143
002144
002145
002146
002147
002148
002149
002150
002151
002152
002153
002154
002155

Byte2Char := ''
ELSE
Byte2Char := CHR(n);
END;
{$R-}
PROCEDURE AddCh(s: TPString; ch: CHAR; maxStrLeng: INTEGER; VAR overflow: BOOLEAN);
BEGIN
overflow := TRUE;
IF Length(s^) < maxStrLeng THEN
BEGIN
overflow := FALSE;
s^[0] := CHR(ORD(s^[0]) + 1);
s^[ORD(s^[0])] := ch;
END;
END;
{$IFC fRngObject} {$R+} {$ENDC}
BEGIN
{ start at an even address and fullBytes a multiple of 16 >= numBytes }
addr := (start DIV 2) * 2;
IF checkAddresses THEN
IF NOT ValidDataAddress(addr) THEN
IF NOT ValidGlobalAddress(addr) THEN
BEGIN
WriteLn;
Write('*** That address is neither in a data segment nor in the stack/global segment. ');
WriteLn('***');
EXIT(WrMemory);
END;
fullBytes := ((numBytes + 15) DIV 16) * 16;
WHILE fullBytes > 0 DO
BEGIN
IF fullBytes MOD 16 = 0 THEN
BEGIN
LIntToHex(addr, @str);
Write(' ', str, '
');
asChars := '';
END;
IF checkAddresses THEN
IF NOT ValidDataAddress(addr) THEN
IF NOT ValidGlobalAddress(addr) THEN
WHILE numBytes > 0 DO

Apple Lisa ToolKit 3.0 Source Code Listing -- 727 of 1012

Apple Lisa Computer Technical Information


002156
002157
002158
002159
002160
002161
002162
002163
002164
002165
002166
002167
002168
002169
002170
002171
002172
002173
002174
002175
002176
002177
002178
002179
002180
002181
002182
002183
002184
002185
002186
002187
002188
002189
002190
002191
002192
002193
002194
002195
002196
002197
002198
002199
002200
002201
002202
002203

BEGIN
Write(' ');
AddCh(@asChars, '', 16, overflow);
AddCh(@asChars, '', 16, overflow);
numBytes := numBytes - 2;
fullBytes := fullBytes - 2;
END;
IF numBytes <= 0 THEN
WHILE fullBytes > 0 DO
BEGIN
Write('
');
AddCh(@asChars, ' ', 16, overflow);
AddCh(@asChars, ' ', 16, overflow);
fullBytes := fullBytes - 2;
END;
IF fullBytes > 0 THEN
BEGIN
extdWord := LIntAndLInt(TpINTEGER(addr)^, $0000FFFF);
LIntToHex(extdWord, @str);
Delete(str, 1, 4); {4 leading zeros}
Write(str, ' ');
AddCh(@asChars, Byte2Char(extdWord DIV 256), 16, overflow);
AddCh(@asChars, Byte2Char(extdWord MOD 256), 16, overflow);
addr := addr + 2;
fullBytes := fullBytes - 2;
numBytes := numBytes - 2;
END;
IF fullBytes MOD 16 = 0 THEN
WriteLn('
|', asChars, '|');
END;
WriteLn;
END;
FUNCTION WrFrame(whichFrame: INTEGER; full: BOOLEAN): BOOLEAN;
{ Write a frame given its number; return TRUE if that frame exists }
VAR RA5:
LONGINT;
calledA6:
LONGINT;
addr:
LONGINT;
laterA6:
LONGINT;
earlierA6:
LONGINT;
hexStr:
S8;
gotMainProg:
BOOLEAN;

Apple Lisa ToolKit 3.0 Source Code Listing -- 728 of 1012

Apple Lisa Computer Technical Information


002204
002205
002206
002207
002208
002209
002210
002211
002212
002213
002214
002215
002216
002217
002218
002219
002220
002221
002222
002223
002224
002225
002226
002227
002228
002229
002230
002231
002232
002233
002234
002235
002236
002237
002238
002239
002240
002241
002242
002243
002244
002245
002246
002247
002248
002249
002250
002251

className:
methName:
procName:
procStart:
frameSELF:
class:
nextPC:
localBytes:
paramBytes:
selfBytes:

TClassName;
S8;
S255;
LONGINT;
TObject;
TClass;
LONGINT;
INTEGER;
INTEGER;
INTEGER;

PROCEDURE SwapIn(valueString: S8);


BEGIN
END;
BEGIN
RA5 := %_GetA5;
calledA6 := StackFrame(whichFrame-1);
{ A6 of frame called by desired frame }
IF (whichFrame < 1) OR (calledA6 = -1) OR (calledA6 = RA5) THEN
BEGIN
WrFrame := FALSE;
EXIT(WrFrame);
END;
WrFrame := TRUE;
addr := calledA6;
LIntToHex(TpLONGINT(addr)^, @hexStr);
Write('Frame # ', whichFrame:3, ' @ $', hexStr, ' ');
gotMainProg := TpLONGINT(addr)^ = RA5;
{ stack frame for main prog starts at A5 }
{ find called-from address }
IF GetDollarD(TppINTEGER(calledA6), className, methName, nextPC) THEN
IF className = '' THEN
procName := methName
ELSE
procName := Concat(className, '.', methName)
ELSE
procName := '';
IF procName <> '' THEN
BEGIN
Write(procName:17);
{ search back in code for TST.W <n>(A7) and LINK A6,<m> instructions }
addr := calledA6+4;
addr := TpLONGINT(addr)^;
{$R-} SwapIn(TPS8(addr)^); {$IFC fRngObject} {$R+} {$ENDC} {Be sure the code is swapped in}
procStart := 0;

Apple Lisa ToolKit 3.0 Source Code Listing -- 729 of 1012

Apple Lisa Computer Technical Information


002252
002253
002254
002255
002256
002257
002258
002259
002260
002261
002262
002263
002264
002265
002266
002267
002268
002269
002270
002271
002272
002273
002274
002275
002276
002277
002278
002279
002280
002281
002282
002283
002284
002285
002286
002287
002288
002289
002290
002291
002292
002293
002294
002295
002296
002297
002298
002299

WHILE procStart = 0 DO
BEGIN
addr := addr - 2;
IF TpINTEGER(addr)^ = $4E56 { LINK A6,<n> } THEN
{ found LINK, so numLocal is now set correctly, and
start of PROCEDURE is 4 bytes back (auto stack expansion) }
procStart := addr - 4;
END;
IF gotMainProg THEN
procStart := procStart + 4;

{ main prog has no stack expansion }

addr := calledA6+4;
LintToHex(TpLONGINT(addr)^-4 - procStart, @hexStr);
Delete(hexStr, 1, Length(hexStr)-4);
{ only want the lower 4 digits of hex number }
Write('+ $', hexStr);
{ advance to next stack frame now, so we can get at its variables }
laterA6 := calledA6;
calledA6 := TpLONGINT(laterA6)^;
IF calledA6 = RA5 THEN
earlierA6 := RA5
ELSE
earlierA6 := TpLONGINT(calledA6)^;
frameSELF := NIL;
IF (className <> '') AND (procName <> 'CREATE ') THEN { regular method }
BEGIN
addr := calledA6+8;
IF ValidObject(Handle(TpLONGINT(addr)^)) THEN
frameSELF := TObject(TpLONGINT(addr)^);
END;
IF frameSELF <> NIL THEN
BEGIN
LIntToHex(ORD(frameSELF), @hexStr);
class := frameSELF.Class;
CpToCn(TPSliceTable(class), TS8(className));
Write(' (', className, ': $', hexStr, ')');
END;
IF full THEN
BEGIN
{$IFC fDebugMethods}
WriteLn;
IF frameSELF <> NIL THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 730 of 1012

Apple Lisa Computer Technical Information


002300
002301
002302
002303
002304
002305
002306
002307
002308
002309
002310
002311
002312
002313
002314
002315
002316
002317
002318
002319
002320
002321
002322
002323
002324
002325
002326
002327
002328
002329
002330
002331
002332
002333
002334
002335
002336
002337
002338
002339
002340
002341
002342
002343
002344
002345
002346
002347

Write('SELF = ');
currXPos := 7;
outputIndent := 7;
frameSELF.Debug(1, '');
WriteLn;
END;
{$ENDC}
localBytes := Max(0, Min(ORD(calledA6 - (laterA6 + 8)), $50));
paramBytes := Max(0, Min(ORD(earlierA6 - (calledA6 + 8)), $50));
selfBytes := 4 * ORD(frameSELF <> NIL);
WriteLn;
WriteLn('LOCALS (First declared local is listed last):');
WrMemory(calledA6 - localBytes, localBytes, FALSE);
WriteLn('PARAMETERS (Last declared parameter is listed first):');
WrMemory(calledA6 + 8 + selfBytes, paramBytes - selfBytes, FALSE);
END;
END;
WriteLn;
END;
PROCEDURE StackCrawl;
VAR frNum:
INTEGER;
BEGIN
frNum := 1;
WHILE WrFrame(frNum, FALSE) DO
frNum := frNum + 1;
WriteLn;
END;
PROCEDURE FrameDump;
VAR i:
INTEGER;
frame: LONGINT;
BEGIN
GetToken;
IF token = '' THEN
BEGIN
Write('Frame number to dump? ');
ReadLn(token);
END;
StrToInt(@token,i,cState);
IF cState = cvValid THEN
BEGIN
IF (i >= 1) THEN
IF NOT WrFrame(i, TRUE) THEN
WriteLn('Frame number was too large');
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 731 of 1012

Apple Lisa Computer Technical Information


002348
002349
002350
002351
002352
002353
002354
002355
002356
002357
002358
002359
002360
002361
002362
002363
002364
002365
002366
002367
002368
002369
002370
002371
002372
002373
002374
002375
002376
002377
002378
002379
002380
002381
002382
002383
002384
002385
002386
002387
002388
002389
002390
002391
002392
002393
002394
002395

WriteLn;
END;
PROCEDURE ToPrinter;
VAR errnum:
INTEGER;
outfname:
PathName;
{$IFC LibraryVersion <= 20}
{ Paslib initialization done in the WorkShop that is not done in the DeskTop manager }
PROCEDURE TellPaslibPrinterLocation;
CONST
AlreadyMounted = 1052;
VAR

errnum:
tp:
devname:
vname:
password:
tdt:
tdi:
dsp:
DevControl:
path:

INTEGER;
TPORTS;
E_Name;
E_Name;
E_Name;
TDeviceType;
TDeviceInfo;
DsProcParam;
DcType;
PathName;

{ error return }

BEGIN
FOR tp := uppertwig TO t_extra3 DO
BEGIN
Get_config_name(errnum,tp,devname);
IF errnum <= 0 THEN
BEGIN
PMReadConfig(tp,tdt,tdi);
IF tdt IN [DMPrinter,Typer] THEN
BEGIN
Mount(errnum, vname, password, devname);
IF (errnum <= 0) or (errnum = AlreadyMounted) THEN
BEGIN
dsp.proccode := dsPrintDev;
dsp.PrDevice := Concat('-', devname);
DSPaslibCall(dsp);
WITH DevControl DO
BEGIN
path := Concat('-',devname,'-x'); {OD}
dcversion := 2;
dccode := 17;
{auto LF disable}
dcdata[0] := 1;
Device_Control(errnum,path,DevControl);
CASE tp OF

Apple Lisa ToolKit 3.0 Source Code Listing -- 732 of 1012

Apple Lisa Computer Technical Information


002396
002397
002398
002399
002400
002401
002402
002403
002404
002405
002406
002407
002408
002409
002410
002411
002412
002413
002414
002415
002416
002417
002418
002419
002420
002421
002422
002423
002424
002425
002426
002427
002428
002429
002430
002431
002432
002433
002434
002435
002436
002437
002438
002439
002440
002441
002442
002443

seriala,serialb:
BEGIN
dccode := 5;
dcdata[0] := 9600;
Device_control(errnum,path,devcontrol);
dccode := 2;
Device_control(errnum,path,devcontrol);
dccode := 1;
dcdata[0] := 0;
Device_control(errnum,path,devcontrol);
dccode := 12;
dcdata[0] := 60;
Device_control(errnum,path,devcontrol);
dccode := 10;
dcdata[0] := 0;
dcdata[1] := -128;
Device_control(errnum,path,devcontrol);
END;
END {CASE}
END;
EXIT(TellPaslibPrinterLocation);
END
ELSE
WriteLn('Error number ',errnum,' mounting ',devname);
END;

{baud rate}
{DTR}
{8-bit no-parity}
{time out}

{disconnect detect}

END
END;
END { TellPaslibPrinterLocation };
{$ELSEC} {Spring Version}
{ Paslib initialization done in the WorkShop that is not done in the DeskTop manager }
PROCEDURE TellPaslibPrinterLocation;
CONST
AlreadyMounted = 1052;
cdSerialCable = 32;
TYPE
TExtWords = PACKED RECORD
isPrinter: BOOLEAN;
isDefault: BOOLEAN;
driverID:
-8192..8191;
END;
VAR

errnum:
nextEntry:
config:
pExtWords:
vname:

INTEGER; { error return }


LONGINT;
ConfigDev;
^TExtWords;
E_Name;

Apple Lisa ToolKit 3.0 Source Code Listing -- 733 of 1012

Apple Lisa Computer Technical Information


002444
002445
002446
002447
002448
002449
002450
002451
002452
002453
002454
002455
002456
002457
002458
002459
002460
002461
002462
002463
002464
002465
002466
002467
002468
002469
002470
002471
002472
002473
002474
002475
002476
002477
002478
002479
002480
002481
002482
002483
002484
002485
002486
002487
002488
002489
002490
002491

password:
devControl:
dsp:
path:

E_Name;
DcType;
DsProcParam;
Pathname;

BEGIN
nextEntry := 0;
REPEAT
PmReadConfig(errnum, nextEntry, config);
IF errnum <= 0 THEN
IF config.nExtWords >= 1 THEN
BEGIN
pExtWords := @config.extWords[1];
IF pExtWords^.isPrinter THEN
BEGIN
Mount(errnum, vname, password, config.devname);
IF (errnum <= 0) or (errnum = AlreadyMounted) THEN
BEGIN
dsp.proccode := dsPrintDev;
dsp.PrDevice := Concat('-', config.devname);
DSPaslibCall(dsp);
WITH devControl DO
BEGIN
path := Concat('-', config.devname, '-x'); {OD}
dcversion := 2;
dccode := 17;
{auto LF disable}
dcdata[0] := 1;
Device_Control(errnum, path, devControl);
IF config.driverID = cdSerialCable THEN
BEGIN
dccode := 5;
dcdata[0] := 9600;
Device_control(errnum,path,devcontrol); {baud rate}
dccode := 2;
Device_control(errnum,path,devcontrol); {DTR}
dccode := 1;
dcdata[0] := 0;
Device_control(errnum,path,devcontrol); {8-bit no-parity}
dccode := 12;
dcdata[0] := 60;
Device_control(errnum,path,devcontrol); {time out}
dccode := 10;
dcdata[0] := 0;
dcdata[1] := -128;
Device_control(errnum,path,devcontrol); {disconnect detect}
END; {IF config.driverID = cdSerialCable}
END; {WITH devControl DO}
END {IF (errnum <= 0) or (errnum = AlreadyMounted) THEN}

Apple Lisa ToolKit 3.0 Source Code Listing -- 734 of 1012

Apple Lisa Computer Technical Information


002492
002493
002494
002495
002496
002497
002498
002499
002500
002501
002502
002503
002504
002505
002506
002507
002508
002509
002510
002511
002512
002513
002514
002515
002516
002517
002518
002519
002520
002521
002522
002523
002524
002525
002526
002527
002528
002529
002530
002531
002532
002533
002534
002535
002536
002537
002538
002539

{$ENDC}

ELSE
WriteLn('Error number ', errnum, ' mounting ', config.devname);
END; {IF pExtWords^.isPrinter THEN}
END; {IF config.nExtWords >= 1 THEN}
UNTIL errnum > 0;
END { TellPaslibPrinterLocation };

BEGIN
GetToken;
outfname := token;
IF token = '' THEN
BEGIN
Write('Name of file to send output to? [-console] ');
ReadLn(outfname);
END;
IF outfname = '' THEN
OutputRedirect(errnum,outfname,TRUE)
ELSE
BEGIN
StrUpperCased(@outfname);
IF outfname = '-PRINTER' THEN
TellPaslibPrinterLocation;
OutputRedirect(errnum,outfname,FALSE);
END;
IF errnum > 0 THEN
BEGIN
IF outfname = '' THEN
outfname := '-CONSOLE';
WriteLn('Error number ',errnum,' redirecting output to ',outfname);
END;
END;
PROCEDURE MemoryDump;
VAR start:
LONGINT;
numBytes:
LONGINT;
BEGIN
GetToken;
IF token = '' THEN
BEGIN
Write('Starting address [# bytes]? ');
Readln(inputStr);
GetToken;
END;
HexStrToLInt(@token, start, cState);
IF cState <> cvValid THEN
Exit(MemoryDump)

Apple Lisa ToolKit 3.0 Source Code Listing -- 735 of 1012

Apple Lisa Computer Technical Information


002540
002541
002542
002543
002544
002545
002546
002547
002548
002549
002550
002551
002552
002553
002554
002555
002556
002557
002558
002559
002560
002561
002562
002563
002564
002565
002566
002567
002568
002569
002570
002571
002572
002573
002574
002575
002576
002577
002578
002579
002580
002581
002582
002583
002584
002585
002586
002587

ELSE
GetToken;
HexStrToLInt(@token, numBytes, cState);
IF cState <> cvValid THEN
numBytes := $10;
WrMemory(start, numBytes, TRUE);
END;
PROCEDURE HeapDump;
VAR allInfo:
wantedSTP:
allHeaps:
index:
heap:
dumpDocHeap:
BEGIN
allInfo := TRUE;
wantedSTP := -1;
allHeaps := TRUE;

BOOLEAN;
LONGINT; {-1 for all classes}
BOOLEAN;
INTEGER;
THeap;
BOOLEAN;

GetToken;
IF token <> '' THEN
BEGIN
allHeaps := FALSE;
TrimBlanks(@token);
StrUpperCased(@token);
index := CiOfCn(Copy(Concat(token, '
'), 1, 8));
IF index > 0 THEN
wantedSTP := ORD(hMySTables^^.records[index])
ELSE
BEGIN
WriteLn('No such class!');
EXIT(HeapDump);
END;
END;
IF allHeaps THEN
IF NOT YesNo('All classes') THEN
WHILE wantedSTP <= 0 DO
BEGIN
GetOne('Which class?');
IF token = '' THEN
GOTO 99
ELSE
BEGIN
index := CiOfCn(token);

Apple Lisa ToolKit 3.0 Source Code Listing -- 736 of 1012

Apple Lisa Computer Technical Information


002588
002589
002590
002591
002592
002593
002594
002595
002596
002597
002598
002599
002600
002601
002602
002603
002604
002605
002606
002607
002608
002609
002610
002611
002612
002613
002614
002615
002616
002617
002618
002619
002620
002621
002622
002623
002624
002625
002626
002627
002628
002629
002630
002631
002632
002633
002634
002635

IF index > 0 THEN


wantedSTP := ORD(hMySTables^^.records[index])
ELSE
WriteLn('No such class!');
END;
END;
{$IFC fDebugMethods}
IF wantedSTP <= 0 THEN
allInfo := YesNo('Dump fields as well as class of each object');
{$ELSEC}
allInfo := FALSE;
{$ENDC}
IF allHeaps THEN
IF YesNo('Dump Process Heap') THEN
DumpHeap(mainHeap, wantedSTP, 0, allInfo);
IF isInitialized THEN
BEGIN
IF allHeaps THEN
dumpDocHeap := YesNo('Dump Active Document Heap')
ELSE
dumpDocHeap := TRUE;
IF dumpDocHeap THEN
BEGIN
heap := BindHeap(TRUE, TRUE);
IF heap = NIL THEN
BEGIN
WriteLn('There is no active document heap!');
WriteLn;
WriteLn;
END
ELSE
DumpHeap(heap, wantedSTP, 0, allInfo);
END;
IF allHeaps THEN
IF YesNo('Dump Clipboard Heap') THEN
BEGIN
heap := BindHeap(FALSE, TRUE);
IF heap = NIL THEN
BEGIN
WriteLn('There is no clipboard heap!
WriteLn;
END
ELSE

Maybe no cut/copy has been done since booting.');

Apple Lisa ToolKit 3.0 Source Code Listing -- 737 of 1012

Apple Lisa Computer Technical Information


002636
002637
002638
002639
002640
002641
002642
002643
002644
002645
002646
002647
002648
002649
002650
002651
002652
002653
002654
002655
002656
002657
002658
002659
002660
002661
002662
002663
002664
002665
002666
002667
002668
002669
002670
002671
002672
002673
002674
002675
002676
002677
002678
002679
002680
002681
002682
002683

DumpHeap(heap, wantedSTP, 0, allInfo);


heap := BindHeap(FALSE, FALSE);
END;

END
ELSE
BEGIN
WriteLn('There is no document or clipboard heap because the process is not fully initialized');
WriteLn;
END;
END;
BEGIN {EntDebugger}
SetScreenKeybd(altscrn);
traceCount := defTraceCount;
timeToGo := FALSE;
WriteLn;
WriteLn('ToolKit Debugger - ',enterReason);
(*
*)

{ flush characters; because of PASLIB bug, also stop when user types a ~ }
commented out as a test case to see if still needed here
IF CheckKeyPress('') THEN;
IF tallyingCalls THEN
BEGIN
TallyAndTime;
returnToMain := tallyingCalls;
END;
IF NOT tallyingCalls THEN
BEGIN
REPEAT
IF NOT timeToGo THEN
BEGIN
IF showPrompt THEN
BEGIN
WriteLn('B)reakpoint, C)learBreakpoints [breakpoint #/ALL], D)ebugStatus, E)nterLisabug,');
{$IFC fDebugMethods}
WriteLn('
F)rameDump, G)o, H)eapDump [class], I)nspectObject, L)evelsToWatch,');
{$ELSEC}
WriteLn('
F)rameDump, G)o, H)eapDump [class], L)evelsToWatch,');
{$ENDC}
WriteLn('
M)emoryDump <location> [# bytes], O)utputTo, P)rompt [Y/N], R)efsToObject,');
WriteLn('
S)tackCrawl, T)ally & Time, W)atch [count] [A)ltScreen] [C)lass] [F)ields]');
END;
Write('-->');
ReadLn(inputStr);
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 738 of 1012

Apple Lisa Computer Technical Information


002684
002685
002686
002687
002688
002689
002690
002691
002692
002693
002694
002695
002696
002697
002698
002699
002700
002701
002702
002703
002704
002705
002706
002707
002708
002709
002710
002711
002712
002713
002714
002715
002716
002717
002718
002719
002720
002721
002722
002723
002724
002725
002726
002727
002728
002729
002730
002731

GetToken;
IF token <> '' THEN
CASE CharUpperCased(token[1]) OF
null:
GoKitBug;
{don't expect people to type this command, but this
will guarantee that the Linker does not flush
the GoKitBug procedure}
'B':
BrSetup('Break on');
'C':
ClearBreaks;
'D':
DebugStatus;
'E':
%_GoLisabug;
'F':
FrameDump;
'G':
BEGIN
fTraceEnabled := FALSE;
defTraceCount := 0;
traceCount := defTraceCount;
returnToMain := TRUE;
timeToGo := TRUE;
END;
'H':
HeapDump;
{$IFC fDebugMethods}
'I':
Inspect;
{$ENDC}
'L':
Level;
'M':
MemoryDump;
'O':
ToPrinter;
'P':
PromptOnOff;
'R':
RefsToObject;
'S':
StackCrawl;
'T':
BEGIN
TallyAndTime;
timeToGo := tallyingCalls;
END;
'W':

BEGIN
TraceOrNot;
timeToGo := TRUE;
END;

'X':
END;

timeToGo := TRUE;

99:
UNTIL timeToGo;
END;
IF tallyingCalls THEN
BEGIN
fTraceEnabled := FALSE;

Apple Lisa ToolKit 3.0 Source Code Listing -- 739 of 1012

Apple Lisa Computer Technical Information


002732
002733
002734
002735
002736
002737
002738
002739
002740
002741
002742
002743
002744
002745
002746
002747
002748
002749
002750
002751
002752
002753
002754
002755
002756
002757
002758
002759
002760
002761
002762
002763
002764
002765
002766
002767
002768
002769
002770
002771
002772
002773
002774
002775
002776
002777
002778
002779

defTraceCount := 0;
traceCount := defTraceCount;
returnToMain := TRUE;
END;
IF returnToMain THEN
SetScreenKeybd(priscrn);
END; {EntDebugger}
{$S SgCLAdbg}
FUNCTION AKeyPress: BOOLEAN;
VAR tb: BOOLEAN;
BEGIN
AKeyPress := FALSE;
IF kpcntr >= keyPresLimit THEN
BEGIN
tb := KeyPress;
{ force call to keyPress until press is dealt with }
IF NOT tb THEN
kpcntr := 0;
AKeyPress := tb;
END
ELSE
kpcntr := kpcntr + 1
END;
{ ====================================== BP -- EP ====================================== }
{$IFC fTrace}
PROCEDURE BEPSN(odummy:
VAR receiver:
caller:
i:
className:
procName:
toDebugger:
nextPC:

LONGINT; fBegin, displayIt: BOOLEAN);


TObject;
TpLONGINT;
INTEGER;
TClassName;
S8;
BOOLEAN;
LONGINT;

{ See if this is the method to start tracing at }


PROCEDURE BreakHere;
VAR ts:
S16;
i:
INTEGER;
found: BOOLEAN;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 740 of 1012

Apple Lisa Computer Technical Information


002780
002781
002782
002783
002784
002785
002786
002787
002788
002789
002790
002791
002792
002793
002794
002795
002796
002797
002798
002799
002800
002801
002802
002803
002804
002805
002806
002807
002808
002809
002810
002811
002812
002813
002814
002815
002816
002817
002818
002819
002820
002821
002822
002823
002824
002825
002826
002827

found := FALSE;
FOR i := 1 TO breakMCount DO
BEGIN
WITH breakMethods[i] DO
{ NOTE: if both brClass and brMethod are '', then the iTH breakpoint is unassigned }
IF brClass = '' THEN
found := (brMethod = procName) AND (brMethod <> '')
ELSE
IF brMethod = '' THEN
found := brClass = className
ELSE
found := (brClass = className) AND (brMethod = procName);
IF found THEN
BEGIN
displayIt := TRUE;
toDebugger := TRUE;
returnToMain := TRUE;
fTraceSelf := FALSE;
fTraceClass := TRUE;
lastBpPc := 0;
lastEpPc := 0;
EXIT(BreakHere)
END
END
END;
PROCEDURE WriteOutDebugInfo;
CONST maxIndent = 70;
VAR i:
INTEGER;
hexStr: S8;
BEGIN
WriteLn;
indentTrace := CMin(tabLevel, maxIndent + 5);
IF tabLevel <= trLevMemory THEN
Write(traceLevels[tablevel]:4, ' ')
ELSE
Write('
');
Write(' ': CMin(tabLevel, maxIndent));
IF tabLevel > maxIndent + 5 THEN
Write(tabLevel:4, ' ')
ELSE
IF indentTrace > maxIndent THEN
Write(' ': indentTrace - maxIndent);
IF fBegin THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 741 of 1012

Apple Lisa Computer Technical Information


002828
002829
002830
002831
002832
002833
002834
002835
002836
002837
002838
002839
002840
002841
002842
002843
002844
002845
002846
002847
002848
002849
002850
002851
002852
002853
002854
002855
002856
002857
002858
002859
002860
002861
002862
002863
002864
002865
002866
002867
002868
002869
002870
002871
002872
002873
002874
002875

Write('BEGIN ')
ELSE
Write('END
');
{$IFC fDebugMethods}
currXPos := indentTrace + 11 {5 for level #; 6 for BEGIN/END};
{$ENDC}
IF className<>'' THEN
BEGIN
Write(className, '.');
{$IFC fDebugMethods}
currXpos := currXPos + 9;
{$ENDC}
END;
Write(procName);
{$IFC fDebugMethods}
currXPos := currXPos + 8;
{$ENDC}
IF (fTraceSelf OR fTraceClass) AND (receiver <> NIL) THEN
IF (procName<>'DEBUGOBJ') AND (procName<>'DEBUG
') AND (procName<>'FIELDS
(fBegin OR ((procName<>'FREEOBJE') AND (procName<>'FREE
'))) THEN
BEGIN
{$IFC fDebugMethods}
Write('(');
currXPos := currXPos + 1;

') AND

IF (procName <> 'FREEOBJE') AND fTraceSelf THEN


BEGIN
outputIndent := currXPos;
receiver.Debug(1, '');
END
ELSE
BEGIN
receiver.Debug(0, '');
LIntToHex(LONGINT(receiver), @hexStr);
Write(': $', hexStr);
END;

END;

Write(')');
{$ENDC}
END;

PROCEDURE TraceStuff;
VAR nextPC: LONGINT;
BEGIN
IF traceCount = 1 THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 742 of 1012

Apple Lisa Computer Technical Information


002876
002877
002878
002879
002880
002881
002882
002883
002884
002885
002886
002887
002888
002889
002890
002891
002892
002893
002894
002895
002896
002897
002898
002899
002900
002901
002902
002903
002904
002905
002906
002907
002908
002909
002910
002911
002912
002913
002914
002915
002916
002917
002918
002919
002920
002921
002922
002923

EntDebugger(' ','Count methods displayed')


ELSE
traceCount := traceCount - 1
END;
BEGIN
toDebugger := FALSE;
IF fDebugRecursion THEN
EXIT(BEPSN);
fDebugRecursion := TRUE;
caller := TpLONGINT(odummy + 4);
receiver := NIL;
IF GetDollarD(TppINTEGER(caller), className, procName, nextPC) THEN
IF (className <> '') AND (procName <> 'CREATE ') THEN
IF ValidObject(Handle(TpLONGINT(caller^+8)^)) THEN
receiver := TObject(TpLONGINT(caller^+8)^);
IF breakMCount > 0 THEN
BreakHere;
IF displayIt THEN
WriteOutDebugInfo;
IF toDebugger THEN
EntDebugger(' ','Breakpoint found')
ELSE
BEGIN
IF displayIt THEN
toDebugger := KeyPress
ELSE
toDebugger := AKeyPress;
IF toDebugger THEN
EntDebugger(' ','Key pressed on alternate screen')
ELSE
IF (traceCount > 0) and (displayIt) THEN
TraceStuff;
END;
fDebugRecursion := FALSE;
END;
PROCEDURE BP{(myTraceLevel: INTEGER)};
VAR dummy:
LONGINT;
{Must be first VAR}
bpFrame:
TpLONGINT;

Apple Lisa ToolKit 3.0 Source Code Listing -- 743 of 1012

Apple Lisa Computer Technical Information


002924
002925
002926
002927
002928
002929
002930
002931
002932
002933
002934
002935
002936
002937
002938
002939
002940
002941
002942
002943
002944
002945
002946
002947
002948
002949
002950
002951
002952
002953
002954
002955
002956
002957
002958
002959
002960
002961
002962
002963
002964
002965
002966
002967
002968
002969
002970
002971

callerPC:
departed:

LONGINT;
LONGINT;

BEGIN
IF tallyingCalls THEN
stopTime := MicroTimer(* - debugTime*);
tabLevel := tabLevel + 1; {Increment first because BEPSN can be reentrant}
callerPC := TpLONGINT(ORD(@dummy) + 8)^;
IF tabLevel <= trLevMemory THEN
BEGIN
traceLevels[tabLevel] := myTraceLevel;
bpFrame := TpLONGINT(ORD(@dummy) + 4);
traceFrames[tabLevel] := LIntAndLInt(bpFrame^, $00FFFFFF);
END;
IF fTraceEnabled AND (myTraceLevel >= curTraceLevel) THEN
BEPSN(ORD(@dummy), TRUE, TRUE)
ELSE
IF (breakMCount > 0) OR AKeyPress THEN
IF callerPC <> lastBpPc THEN
BEPSN(ORD(@dummy), TRUE, FALSE);
lastBpPc := callerPC;
IF tallyingCalls THEN
BEGIN
departed := MicroTimer;
(*
debugTime := debugTime + departed - stopTime + tallyOverhead; *)
IF tabLevel <= trLevMemory THEN
traceTimes[tabLevel] := departed (*- debugTime*);
END;
END;
PROCEDURE EP;
VAR dummy:
LONGINT;
{Must be first VAR and 4 bytes long}
epFrame:
LONGINT;
doTrace:
BOOLEAN;
i:
INTEGER;
callerPC:
LONGINT;
elapsed:
LONGINT;
BEGIN
callerPC := TpLONGINT(ORD(@dummy) + 8)^;
IF tallyingCalls THEN
BEGIN
stopTime := MicroTimer (*- debugTime*);
IF tabLevel <= trLevMemory THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 744 of 1012

Apple Lisa Computer Technical Information


002972
002973
002974
002975
002976
002977
002978
002979
002980
002981
002982
002983
002984
002985
002986
002987
002988
002989
002990
002991
002992
002993
002994
002995
002996
002997
002998
002999
003000
003001
003002
003003
003004
003005
003006
003007
003008
003009
003010
003011
003012
003013
003014
003015
003016
003017
003018
003019

BEGIN
elapsed := stopTime - traceTimes[tabLevel];
FOR i := tabLevel - 1 DOWNTO 1 DO
traceTimes[i] := traceTimes[i] + elapsed;
Tally(callerPC, elapsed);
END
ELSE
BEGIN
WriteLn('Stack bigger than performance measurement can handle! ', tablevel:1);
tallyingCalls := FALSE;
END;
END;
IF tabLevel < 0 THEN
BEGIN
tabLevel := 0;
Writeln('--------------------------');
BEPSN(ORD(@dummy), FALSE, TRUE);
ABCBreak('The above EP had no BP at all', 0);
doTrace := FALSE;
END
ELSE IF tabLevel <= trLevMemory THEN
BEGIN
epFrame := LIntAndLInt(TpLONGINT(ORD(@dummy) + 4)^, $00FFFFFF);
IF traceFrames[tabLevel] <> epFrame THEN
BEGIN
i := tabLevel - 1;
{Try to resynchronize}
WHILE (tabLevel <> i) AND (i >= 0) DO
IF traceFrames[i] = epFrame THEN
BEGIN
Writeln('--------------------------');
ABCBreak('There was a BP with no EP', 0);
tabLevel := i;
END
ELSE
i := i - 1;
IF tabLevel <> i THEN
BEGIN
Writeln('--------------------------');
BEPSN(ORD(@dummy), FALSE, TRUE);
ABCBreak('The above EP had no BP', 0);
END;
END;
doTrace := fTraceEnabled AND (traceLevels[tablevel] >= curTraceLevel);
END
ELSE
doTrace := FALSE;

Apple Lisa ToolKit 3.0 Source Code Listing -- 745 of 1012

Apple Lisa Computer Technical Information


003020
003021
003022
003023
003024
003025
003026
003027
003028
003029
003030
003031
003032
003033
003034
003035
003036
003037
003038
003039
003040
003041
003042
003043
003044
003045
003046
003047
003048
003049
003050
003051
003052
003053
003054
003055
003056
003057

IF doTrace THEN
BEPSN(ORD(@dummy), FALSE, TRUE)
ELSE
IF (breakMCount > 0) OR AKeyPress THEN
IF callerPC <> lastEpPc THEN
BEPSN(ORD(@dummy), FALSE, FALSE);
IF tabLevel >= 0 THEN
tabLevel := tabLevel - 1;
lastEpPc := callerPC;
(*

IF tallyingCalls THEN
debugTime := MicroTimer - stopTime + tallyOverhead;
*)
END;
{$ENDC}
{$ENDC}
{ ====================================== COUNTHEAP ====================================== }
{$IFC fCheckHeap}
FUNCTION CountHeap{(heap: THeap): INTEGER};
VAR hz:
THz;
numObjects: INTEGER;
BEGIN
hz := THz(heap);
IF FCheckHzOK(hz, numObjects) THEN ;
CountHeap := numObjects;
END;
{$ENDC}
{$S sInit1}

End of File -- Lines: 3057 Characters: 100113

Apple Lisa ToolKit 3.0 Source Code Listing -- 746 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UTEXT.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

UNIT UText;
{$SETC IsIntrinsic := TRUE }
{$IFC IsIntrinsic}
INTRINSIC;
{$ENDC}
{Multiple Paragraph Building Block for the Tool Kit}
{changed
{changed
{changed
{changed
{changed
{changed

04/25/84
04/18/84
04/16/84
04/13/84
04/12/84
04/10/84

1437
1652
1135
0209
2344
1400

Added TTextImage.TxtImgForClipBoard method}


Added firstLinePixel, useFirstPixel fields to TTextImage}
Added styleSheet field to TParaFormat}
Added TTextImage.NewEditPara}
Changed parameter list of TParagraph.UpdateRuns}
Changed TEditPara.images field back to a TList}

INTERFACE
{$DECL fUseUnivText}
{$SETC fUseUnivText := TRUE}
USES
{$U libtk/UObject}
UObject,
{$IFC LibraryVersion <= 20}
{$U UFont}
UFont,
{$ENDC}
{$U QuickDraw}
QuickDraw,
{$U libtk/UDraw}
UDraw,
{$IFC fUseUnivText}
{$U libtk/UUnivText}
UTKUniversalText,
{$ENDC}
{$U UABC}
UABC;
{$DECL
{$SETC
{$DECL
{$SETC
{$DECL
{$SETC

fTextTrace}
fTextTrace := fDbgOK}
fParaTrace}
fParaTrace := fDbgOK}
fRngText}
fRngText := fDbgOK}

CONST
cVertMargin = 4;

Apple Lisa ToolKit 3.0 Source Code Listing -- 747 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

cHorizMargin = 6;
somethingKind = 1;
TYPE
TStyleChange = RECORD
lp:
INTEGER;
newStyle:
TTypeStyle;
END;
TTxtTabDescriptor = RECORD
xCoord:
INTEGER;
quad:
TAlignment;
{MORE LATER}
END;
TDrawAction = (actionDraw, actionInval, actionNone);
{ PARAGRAPH SUBCLASSES }
TParaFormat = SUBCLASS OF TObject
dfltTStyle:
TTypeStyle;
wordWrap:
BOOLEAN;
quad:
TAlignment;
firstIndent:
INTEGER;
leftIndent:
INTEGER;
rightIndent:
INTEGER;
spaceAbovePara:
INTEGER;
spaceBelowPara:
INTEGER;
lineSpacing:
INTEGER;
tabs:
TArray;
refCount:
permanent:
styleSheet:

INTEGER;
BOOLEAN;
TStyleSheet;

{default type style}

{number of paragraphs referencing this paraFormat}


{TRUE -> don't free when refcount goes to zero}
{NIL if format not in a styleSheet}

FUNCTION TParaFormat.CREATE(object: TObject; heap: THeap; itsStyleSheet: TStyleSheet): TParaFormat;


{$IFC fParaTrace}
PROCEDURE TParaFormat.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
PROCEDURE TParaFormat.SetTypeStyle(tStyle: TTypeStyle);
PROCEDURE TParaFormat.ChangeRefCountBy(delta: INTEGER);
END;
TParagraph = SUBCLASS OF TString
typeStyles:
TArray; { of TStyleChange }

Apple Lisa ToolKit 3.0 Source Code Listing -- 748 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

{Creation/Destruction}
FUNCTION TParagraph.CREATE(object: TObject; heap: THeap;
initialSize: INTEGER; initialTypeStyle: TTypeStyle): TParagraph;
PROCEDURE TParagraph.Free; OVERRIDE;
{Debugging}
{$IFC fParaTrace}
PROCEDURE TParagraph.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{Overridden TString methods}
PROCEDURE TParagraph.Draw(i: LONGINT; howMany: INTEGER); OVERRIDE;
FUNCTION TParagraph.Width(i: LONGINT; howMany: INTEGER): INTEGER; OVERRIDE;
{This method is used by TParagraph.Draw and TParagraph.Width to interpret the typeStyles array}
PROCEDURE TParagraph.DrawLine(startLP, endLP: INTEGER; fDraw: BOOLEAN; fWidth: BOOLEAN;
VAR width: INTEGER; VAR styleIndex: INTEGER);
{Type Style Maintainence}
PROCEDURE TParagraph.ChangeStyle(startLP, endLP: INTEGER; PROCEDURE Change(VAR typeStyle: TTypeStyle);
VAR styleOfStartLP: TTypeStyle);
{These four routines all call ChangeStyle}
PROCEDURE TParagraph.ChgFace(startLP, endLP: INTEGER;
newOnFaces: {$IFC LibraryVersion <= 20}TSeteface{$ELSEC}Style{$ENDC};
VAR styleOfStartLP: TTypeStyle);
PROCEDURE TParagraph.ChgFontSize(startLP, endLP: INTEGER; newFontSize: Byte;
VAR styleOfStartLP: TTypeStyle);
PROCEDURE TParagraph.ChgFontFamily(startLP, endLP: INTEGER; newFontFamily: Byte;
VAR styleOfStartLP: TTypeStyle);
PROCEDURE TParagraph.NewStyle(startLP, endLP: INTEGER; newTypeStyle: TTypeStyle);
PROCEDURE TParagraph.CleanRuns;
PROCEDURE TParagraph.UpdateRuns(atLP: INTEGER; replacedChars: INTEGER; insertedChars: INTEGER);
{Character Maintainence}
PROCEDURE TParagraph.ReplPara(fPos, numChars: INTEGER;
otherPara: TParagraph; otherFPos, otherNumChars: INTEGER);
PROCEDURE TParagraph.ReplTString(fPos, numChars: INTEGER;
otherString: TString; otherFPos, otherNumChars: INTEGER);
PROCEDURE TParagraph.ReplPString(fPos, numChars: INTEGER; pStr: TPString);
{Utilities}
{BuildExtentLRect takes an LPoint that indicates the baseline of the paragraph. It returns
in extentLRect the bounding rectangle whose height is based on the tallest font in the
paragraph and width is the width of the characters in the paragraph. Specifically:
top
:= baseLPt.v - tallestFontInfo.ascent;
bottom := baseLPt.v + tallestFontInfo.descent + tallestFontInfo.leading;

Apple Lisa ToolKit 3.0 Source Code Listing -- 749 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

left
:= baseLPt.h;
right := baseLpt.h + paragraph.Width;}
PROCEDURE TParagraph.BuildExtentLRect(baseLPt: LPoint; VAR extentLRect: LRect);
FUNCTION TParagraph.FixLP(LP: INTEGER): INTEGER;
PROCEDURE TParagraph.SetTypeStyle(tStyle: TTypeStyle);
PROCEDURE TParagraph.StyleAt(lp: INTEGER; VAR typeStyle: TTypeStyle);
{Word Selection}
PROCEDURE TParagraph.FindWordBounds(orig: INTEGER; VAR first, last: INTEGER);
FUNCTION TParagraph.Qualifies(pos: INTEGER): BOOLEAN;
END;
{Editable Paragraph}
TEditPara = SUBCLASS OF TParagraph
{ character stuff }
bsCount:
INTEGER;
{ formatting stuff }
nestLevel:
INTEGER;
format:
TParaFormat;
{ paraImage stuff }
beingFiltered: BOOLEAN;
(*
maxImage:
numImages:
images:
*)
images:

{ TRUE when a type style command has just been


performed on this paragraph}

INTEGER;
INTEGER;
ARRAY [1..1] OF TParaImage;
TList;

{THIS MUST BE LAST FIELD !}

{ Users may subclass TEditPara }

{Creation/Destruction}
FUNCTION TEditPara.CREATE(object: TObject; heap: THeap; initialSize: INTEGER;
itsFormat: TParaFormat): TEditPara;
PROCEDURE TEditPara.Free; OVERRIDE;
{Debugging}
{$IFC fParaTrace}
PROCEDURE TEditPara.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{Special Editing}
PROCEDURE TEditPara.BeginInsertion(atLP: INTEGER; size:INTEGER);
PROCEDURE TEditPara.EndInsertion;
FUNCTION TEditPara.GrowSize: INTEGER;
PROCEDURE TEditPara.InsertOneChar(ch: CHAR; atLP: INTEGER);

Apple Lisa ToolKit 3.0 Source Code Listing -- 750 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

{Utility}
PROCEDURE TEditPara.SetTypeStyle(tStyle: TTypeStyle); OVERRIDE;
{ParaImage Maintenance}
PROCEDURE TEditPara.EachImage(PROCEDURE ImageProc(paraImage: TParaImage));
PROCEDURE TEditPara.DelImage(delImage: TParaImage; fFree: BOOLEAN);
PROCEDURE TEditPara.InsImage(paraImage: TParaImage);
PROCEDURE TEditPara.DelImgIF(FUNCTION ShouldDelete(paraImage: TParaImage): BOOLEAN);
END;
TLineInfo = SUBCLASS OF TObject
valid:
BOOLEAN;
startLP:
INTEGER;
lastDrawnLP:
INTEGER; {last character in line to draw: may omit trailing spaces}
endLP:
INTEGER; {last character in line: equals next lineInfo.startLP - 1}
lineLRect:
LRect;
lineAscent:
INTEGER;
FUNCTION TLineInfo.CREATE(object: TObject; heap: THeap): TLineInfo;
{$IFC fParaTrace}
PROCEDURE TLineInfo.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{Used by subclassers who don't like the way the hilite/update
rectangle is chosen so they can overrride it}
FUNCTION TLineInfo.LeftCoord(proposedLeftPixel: LONGINT): LONGINT;
FUNCTION TLineInfo.RightCoord(proposedRightPixel: LONGINT): LONGINT;
END;
TParaImage = SUBCLASS OF TImage
paragraph:
TEditPara;
height:
INTEGER;
{ pixel height of the paragraph}
lineList:
changed:
tickCount:
startLP:
endLP:
textImage:
wasOffset:
{Creation}
FUNCTION

TList;
BOOLEAN;
INTEGER;
INTEGER;
INTEGER;

{ of TLineInfo}
{ incremented (mod MAXINT) every time image is drawn }

{ while drawing, this is the LP of the beginning of the next line


which, when drawing is finished, may be in another image if the
paragraph is split }
TTextImage; { the textImage that this image belongs to }
BOOLEAN;
{ used by Building block to determine when to invalidate}

TParaImage.CREATE(object: TObject; heap: THeap; itsView: TView;

Apple Lisa ToolKit 3.0 Source Code Listing -- 751 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

itsParagraph: TEditPara; itsLRect: LRect;


lineTop: LONGINT; lineLeft: LONGINT): TParaImage;
PROCEDURE TParaImage.Free; OVERRIDE;
{Debugging}
{$IFC fParaTrace}
PROCEDURE TParaImage.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{Routines}
PROCEDURE TParaImage.ComputeLineInfo(curLine: TLineInfo; maxLineLen: INTEGER;
VAR nextLP: INTEGER; VAR lRectNeeded: LRect);
FUNCTION TParaImage.DfltLineInfo(lineTop: LONGINT; lineLeft: LONGINT): TLineInfo;
PROCEDURE TParaImage.DrawLine(startLP: INTEGER; fDraw: BOOLEAN;
stopWidth, wrapWidth: INTEGER;
VAR lineWidth, lastToDraw, endLP: INTEGER);
PROCEDURE TParaImage.DrawParaImage(limitLRect: LRect; startLP: INTEGER; drawAction: TDrawAction;
invalBits: BOOLEAN; VAR drawnLRect: LRect);
PROCEDURE TParaImage.Draw; OVERRIDE;
PROCEDURE TParaImage.FastDrawLine(startLP, endLP: INTEGER; fDraw: BOOLEAN; fWidth: BOOLEAN;
VAR width: INTEGER; VAR styleIndex: INTEGER);
FUNCTION TParaImage.GetFormat: TParaFormat;
PROCEDURE TParaImage.LineWithLPt(pt: LPoint; VAR lineIndex: INTEGER; VAR lineInfo: TLineInfo);
PROCEDURE TParaImage.LocateLP(LP: INTEGER; VAR lineIndex: INTEGER; VAR pixel: LONGINT);
FUNCTION TParaImage.LpWithLPt(pt: LPoint): INTEGER;
PROCEDURE TParaImage.OffSetBy(deltaLPt: LPoint); OVERRIDE;
FUNCTION TParaImage.ParaTextWidth(startLP, endLP: INTEGER): INTEGER;
PROCEDURE TParaImage.RedrawLines(startLine: INTEGER; endLine: INTEGER);
FUNCTION TParaImage.SeesSameAs(image: TImage): BOOLEAN; OVERRIDE;
{validation/invalidation procs}
PROCEDURE TParaImage.InvalLinesWith(startLP, endLP: INTEGER);
PROCEDURE TParaImage.AdjustLineLPs(atLP, deltaLP: INTEGER);
END;

{ MULTI-PARAGRAPH SUBCLASSES }
TStyleSheet = SUBCLASS OF TObject
formats:
TList; {of TParaFormat}
{Creation}
FUNCTION TStyleSheet.CREATE(object: TObject; heap: THeap): TStyleSheet;
PROCEDURE TStyleSheet.Free; OVERRIDE;
{Installs Default paraFormat into formats list}
PROCEDURE TStyleSheet.InitDefault;

Apple Lisa ToolKit 3.0 Source Code Listing -- 752 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

{Debugging}
{$IFC fParaTrace}
PROCEDURE TStyleSheet.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
END;
TTextRange = SUBCLASS OF TObject
firstPara: TEditPara;
firstIndex: LONGINT;
firstLP:
INTEGER;
lastPara:
TEditPara;
lastIndex: LONGINT;
lastLP:
INTEGER;
{Creation}
FUNCTION

TTextRange.CREATE(object: TObject; heap: THeap;


beginPara: TEditPara; beginIndex: LONGINT; beginLP: INTEGER;
endPara: TEditPara; endIndex: LONGINT; endLP: INTEGER): TTextRange;

{Debugging}
{$IFC fParaTrace}
PROCEDURE TTextRange.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{AdjustBy adjust the fields of TTextRange by the value of delta (where delta is in LPs)}
PROCEDURE TTextRange.AdjustBy(delta: INTEGER);
END;
TText = SUBCLASS OF TObject
paragraphs: TList; {of TEditPara }
styleSheet: TStyleSheet;
txtImgList: TList;

{of TTextImages that point to this text;


IMPORTANT: If the multiple linked textImage feature is used as described in
TTextImage below, the application should only store the
head text image in this list. This list is intended for
textImages that are viewing the same text object independently
(ie in different panels)}

{Creation/Freeing}
FUNCTION TText.CREATE(object: TObject; heap: THeap; itsStyleSheet: TStyleSheet): TText;
{DfltTextImage can be called after CREATE to create and return a single textImage. It also
creates one empty paragraph using the first paraFormat in SELF.styleSheet. It installs the
textImage in txtImgList and the paragraph in paragraphs. This routine calls
textImage.RecomputeImages to set up the first paraImage.}
FUNCTION TText.DfltTextImage(view: TView; imageLRect: LRect; imgIsGrowable: BOOLEAN): TTextImage;

Apple Lisa ToolKit 3.0 Source Code Listing -- 753 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

{TText.Free frees all paragraphs that belong to this text object and all textImages that
reference this text object}
PROCEDURE TText.Free; OVERRIDE;
PROCEDURE TText.FreeSelf(freeParas: BOOLEAN);
{Debugging}
{$IFC fParaTrace}
PROCEDURE TText.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{Calls to textImage procs get routed through these}
PROCEDURE TText.ChangeSelInOtherPanels(textSelection: TTextSelection);
PROCEDURE TText.DelPara(delPara: TEditPara; fFree: BOOLEAN);
PROCEDURE TText.Draw;
PROCEDURE TText.HiliteRange(highTransit: THighTransit; textRange: TTextRange; wholePara: BOOLEAN);
PROCEDURE TText.HiliteParagraphs(highTransit: THighTransit;
startIndex: LONGINT; startLP: INTEGER;
endIndex: LONGINT; endLP: INTEGER; wholePara: BOOLEAN);
PROCEDURE TText.InsParaAfter(existingPara: TEditPara; newPara: TEditPara);
PROCEDURE TText.Invalidate;
PROCEDURE TText.MarkChanged(textRange: TTextRange);
PROCEDURE TText.RecomputeImages;
FUNCTION TText.SelectAll(textImage: TTextImage): TTextSelection;
END;

TTextImage = SUBCLASS OF TImage


text:
TText;
imageList:
TList;
tickCount:
INTEGER;
growsDynamically:
BOOLEAN;
minHeight:

INTEGER;

formerBottom:

LONGINT;

updateLRect:

LRect;

firstLinePixel:
useFirstPixel:

LONGINT;
BOOLEAN;

{complete list of paragraphs}


{paraImages for some range of paragraphs in text}
{TRUE --> extentLRect bottom grows as more text entered;
FALSE -> text is truncated at last line that fits}
{the minimum height to shrink (if growsDynamically=TRUE);
defaults to height of original extentLRect}
{Used by Invalidate when the displayed paragraphs get shorter
and text at end needs to be erased}
{ "
"
"
"}
{Used by Text BB to limit what gets erased on first update line}

{ The following fields support multiple linked text images displaying a single text object,
where the text "flows" from one box to the next. APPLICATIONS ARE RESPONSIBLE FOR
MAINTAINING THESE FIELDS. This Building Block uses these fields for drawing, etc.
All text images in a chain should have growsDynamically set to FALSE (except possibly
for the last text image in a chain).

Apple Lisa ToolKit 3.0 Source Code Listing -- 754 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

For applications that DO NOT use this feature, the fields will always be as follows:
startLP = 0;
endLP =
LP of last character in last paragraph; (if growsDynamically = TRUE)
LP of last character that fit in extentLRect; (if growsDynamically = FALSE)
prevTxtImg, nextTxtImg = NIL;
headTxtImg = SELF;
tailTxtImg = SELF;
}
firstIndex:
LONGINT;
{index of paragraph at SELF.imageList.First}
startLP:
INTEGER;
{startLP of paragraph at SELF.imageList.First}
endLP:
INTEGER;
{endLP of paragraph at SELF.imageList.Last}
prevTxtImg:
nextTxtImg:
headTxtImg:
tailTxtImg:
{Creation}
FUNCTION

TTextImage;
TTextImage;
TTextImage;
TTextImage;

{ for linking textImages that display different parts of }


{ the same text object. eg: columns}
{points to first text image in this list}
{points to last text image in this list}

TTextImage.CREATE(object: TObject; heap: THeap; itsView: TView;


itsLRect: LRect; itsText: TText; isGrowable: BOOLEAN): TTextImage;

{TTextImage.Free frees all text images and their paraImages in the text image chain.
It does NOT free any paragraphs, text objects, or paraFormats. Call this only once
for each text image chain (NOT for each text image in the chain). Note that TText.Free
frees its textImages so calling this routine is not necessary in most cases}
PROCEDURE TTextImage.Free; OVERRIDE;
{TTextImage.FreeOneTextImage frees just one text image from the chain. It pays no attention
to links or whether this is the head text image. Maintenance of these fields must be
handled by the caller before calling this routine. Those who do not use linked text images
should always call TTextImage.Free above, NOT this routine}
PROCEDURE TTextImage.FreeOneTextImage;
{Debugging}
{$IFC fParaTrace}
PROCEDURE TTextImage.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{Drawing}
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE

TTextImage.Draw; OVERRIDE;
TTextImage.DrawImages(fDraw: BOOLEAN);
TTextImage.DrawOrInval(invalBits: BOOLEAN);
TTextImage.HiliteText(highTransit: THighTransit;
startIndex: LONGINT; startLP: INTEGER;
endIndex: LONGINT; endLP: INTEGER; wholePara: BOOLEAN);

{Locating}
PROCEDURE TTextImage.FindParaAndLp(LPt: LPoint; VAR paraImage: TParaImage;

Apple Lisa ToolKit 3.0 Source Code Listing -- 755 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

VAR paraIndex: LONGINT; VAR aLP: INTEGER);


FUNCTION TTextImage.FindTextImage(VAR mouseLPt: LPoint; VAR firstTxtImg: TTextImage): TTextImage;
FUNCTION TTextImage.ImageBottom: LONGINT;
PROCEDURE TTextImage.GetImageRange(firstIndex: LONGINT; VAR firstLP: INTEGER;
lastIndex: LONGINT; VAR lastLP: INTEGER;
VAR firstImage, lastImage: TParaImage);
FUNCTION TTextImage.ImageWith(paragraph: TEditPara; lp: INTEGER): TParaImage;
PROCEDURE TTextImage.MousePress(mouseLPt: LPoint); OVERRIDE;
PROCEDURE TTextImage.OffsetBy(deltaLPt: LPoint); OVERRIDE;
{Image maintenence}
PROCEDURE TTextImage.AddImage(paraImage: TParaImage);
PROCEDURE TTextImage.DelImagesWith(delPara: TEditPara);
PROCEDURE TTextImage.InsertNewPara(existingPara, newPara: TEditPara);
PROCEDURE TTextImage.InvalAll;
PROCEDURE TTextImage.Invalidate; OVERRIDE; {Invalidate changed lineLRects in changed paraimages}
PROCEDURE TTextImage.MarkChanged(startIndex: LONGINT; startLP: INTEGER;
endIndex: LONGINT; endLP: INTEGER);
FUNCTION TTextImage.NewTextSelection(firstPara: TEditPara; firstIndex: LONGINT; firstLP: INTEGER;
lastPara: TEditPara; lastIndex: LONGINT; lastLP: INTEGER
): TTextSelection;
PROCEDURE TTextImage.RecomputeImages(drawAction: TDrawAction; invalBits: BOOLEAN);
PROCEDURE TTextImage.Resize(newExtent: LRect); OVERRIDE;
FUNCTION TTextImage.SeesSameAs(image: TImage): BOOLEAN; OVERRIDE;
{By default SetFirstIndex just sets firstIndex to 0, but subclassers may override this
if they want the display to start from other than the first paragraph}
PROCEDURE TTextImage.SetFirstIndex;
{These routines are provided so that users can subclass the appropriate class and
then override these methods so that the building block will create the user's subclass
when generating new instances of that class. }
FUNCTION TTextImage.NewEditPara(initialSize: INTEGER; itsFormat: TParaFormat): TEditPara;
FUNCTION TTextImage.NewParaImage(itsParagraph: TEditPara; itsLRect: LRect;
lineTop: LONGINT; lineLeft: LONGINT): TParaImage;
FUNCTION TTextImage.NewTextImage(heap: THeap; itsView: TView; itsLRect: LRect;
itsText:TText; isGrowable: BOOLEAN): TTextImage;
FUNCTION TTextImage.TxtImgForClipBoard(heap: THeap; itsView: TView; itsLRect: LRect;
itsText:TText; isGrowable: BOOLEAN): TTextImage;
END;
{Clipboard Text View}
TTextView = SUBCLASS OF TView
textImage: TTextImage;
valid:
BOOLEAN;

{If FALSE, calls Recompute before Drawing}

{Creation}

Apple Lisa ToolKit 3.0 Source Code Listing -- 756 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

FUNCTION

TTextView.CREATE(object: TObject; heap: THeap; itsPanel: TPanel; itsExtent: LRect)


: TTextView;

{Debugging}
{$IFC fParaTrace}
PROCEDURE TTextView.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{$IFC fUseUnivText}
PROCEDURE TTextView.CreateUniversalText; OVERRIDE;
{$ENDC}
PROCEDURE TTextView.Draw; OVERRIDE;
PROCEDURE TTextView.MousePress(mouseLPt: LPoint); OVERRIDE;
END;
{$IFC fUseUnivText}
TTextWriteUnivText = SUBCLASS OF TTKWriteUnivText
textSelection: TTextSelection;
currIndex:
LONGINT;
currPara:
TEditPara;
currLP:
INTEGER;
currStyleIndex: INTEGER;
currTStyles:
TArray;
{Creation}
FUNCTION TTextWriteUnivText.CREATE(object: TObject; heap: THeap;
itsString: TString; itsDataSize: INTEGER;
itsTextSel: TTextSelection): TTextWriteUnivText;
{Debugging}
{$IFC fParaTrace}
PROCEDURE TTextWriteUnivText.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
PROCEDURE TTextWriteUnivText.FillParagraph; OVERRIDE;
END;
{$ENDC}
TTextSelection = SUBCLASS OF TSelection
textImage:
TTextImage;
textRange:
TTextRange;
isWordSelection:
BOOLEAN;
isParaSelection:
BOOLEAN;
viewTick:
INTEGER;
amTyping:
BOOLEAN;
currTypeStyle:
TTypeStyle;

Apple Lisa ToolKit 3.0 Source Code Listing -- 757 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

FUNCTION

TTextSelection.CREATE(object: TObject; heap: THeap; itsView: TView;


itsTextImage: TTextImage; itsAnchorLPt: LPoint;
beginPara: TEditPara; beginIndex: LONGINT; beginLP: INTEGER;
endPara: TEditPara; endIndex: LONGINT; endLP: INTEGER
): TTextSelection;

{Debugging}
{$IFC fParaTrace}
PROCEDURE TTextSelection.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{Commands}
PROCEDURE TTextSelection.KeyText;
FUNCTION TTextSelection.NewCommand(cmdNumber: TCmdNumber): TCommand; OVERRIDE;
FUNCTION TTextSelection.NewStyleCmd(heap: THeap; cmdNumber: TCmdNumber;
textImage: TTextImage): TCommand;
FUNCTION TTextSelection.NewCutCopyCmd(heap: THeap; cmdNumber: TCmdNumber;
textImage: TTextImage): TCommand; DEFAULT;
PROCEDURE TTextSelection.StyleFromContext; DEFAULT;
PROCEDURE TTextSelection.DoChangeStyle(cmdNumber: TCmdNumber; paragraph: TParagraph;
firstLP: INTEGER; lastLP: INTEGER; VAR newStyle: TTypeStyle);
PROCEDURE TTextSelection.ChangeStyle(cmdNumber: TCmdNumber); DEFAULT;
{Editing}
PROCEDURE TTextSelection.ChangeText(PROCEDURE TextEdit; PROCEDURE Adjust); DEFAULT;
FUNCTION TTextSelection.CopySelf(heap: THeap; view: TView): TMultiParaSelection; DEFAULT;
PROCEDURE TTextSelection.CutCopy(clipSelection: TSelection; deleteOriginal: BOOLEAN); DEFAULT;
PROCEDURE TTextSelection.DeleteAndFree; DEFAULT;
FUNCTION TTextSelection.DeleteButSave: TText; DEFAULT;
{Highlighting}
PROCEDURE TTextSelection.Highlight(highTransit: THighTransit); OVERRIDE;
{Selecting}
FUNCTION
PROCEDURE
PROCEDURE
FUNCTION

TTextSelection.BecomeInsertionPoint: TInsertionPoint;
TTextSelection.GetHysteresis(VAR hysterPt: Point); OVERRIDE;
TTextSelection.MousePress(mouseLPt: LPoint); OVERRIDE;
TTextSelection.SelSize: INTEGER; ABSTRACT;

{Invalidation}
PROCEDURE TTextSelection.Invalidate; DEFAULT;
{Generate Text Selection in another panel (ie. another Text Image)}
FUNCTION TTextSelection.ReplicateForOtherPanel(itsTextImage: TTextImage): TTextSelection;
END;
TInsertionPoint = SUBCLASS OF TTextSelection

Apple Lisa ToolKit 3.0 Source Code Listing -- 758 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

typingCmd:
styleCmdNumber:

TTypingCmd;
INTEGER;

newestLP:
justReturned:

INTEGER;
BOOLEAN;

nextHighTransit:
nextTransitTime:

THighTransit;
LONGINT;

{the current typing command (if user is typing)}


{Set to cmdNumber when a type style item is chosen,
set to zero otherwise}
{the lp position as updated between KeyPause's}
{flag that prevents redundant update in KeyPause}

{Creation/Freeing}
FUNCTION TInsertionPoint.CREATE(object: TObject; heap: THeap; itsView: TView;
itsTextImage: TTextImage; itsAnchorLPt: LPoint; itsParagraph: TEditPara;
itsIndex: LONGINT; itsLP: INTEGER): TInsertionPoint;
{Debugging}
{$IFC fParaTrace}
PROCEDURE TInsertionPoint.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{Commands}
PROCEDURE
PROCEDURE
PROCEDURE
FUNCTION

TInsertionPoint.IdleBegin(centiSeconds: LONGINT); OVERRIDE;


TInsertionPoint.IdleContinue(centiSeconds: LONGINT); OVERRIDE;
TInsertionPoint.IdleEnd(centiSeconds: LONGINT); OVERRIDE;
TInsertionPoint.NewCutCopyCmd(heap: THeap; cmdNumber: TCmdNumber;
textImage: TTextImage): TCommand; OVERRIDE;
PROCEDURE TInsertionPoint.StyleFromContext; OVERRIDE;

{Editing}
PROCEDURE TInsertionPoint.CutCopy(clipSelection: TSelection; deleteOriginal: BOOLEAN); OVERRIDE;
PROCEDURE TInsertionPoint.FinishPaste(clipSelection: TSelection; pic: PicHandle);
PROCEDURE TInsertionPoint.InsertText(text: TText; isParaSelection: BOOLEAN; isWordSelection: BOOLEAN;
universalText: BOOLEAN);
PROCEDURE TInsertionPoint.KeyBack(fWord: BOOLEAN); OVERRIDE;
PROCEDURE TInsertionPoint.KeyChar(ch: CHAR); OVERRIDE;
PROCEDURE TInsertionPoint.KeyClear; OVERRIDE;
PROCEDURE TInsertionPoint.KeyForward(fWord: BOOLEAN); OVERRIDE;
{Selecting}
PROCEDURE TInsertionPoint.MouseMove(mouseLPt: LPoint); OVERRIDE;
PROCEDURE TInsertionPoint.MousePress(mouseLPt: LPoint); OVERRIDE;
PROCEDURE TInsertionPoint.MouseRelease; OVERRIDE;
END;
TOneParaSelection = SUBCLASS OF TTextSelection
anchorBegin:
INTEGER;
anchorEnd:
INTEGER;
{anchorBegin <> anchorEnd iff double or triple click}

Apple Lisa ToolKit 3.0 Source Code Listing -- 759 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

{Creation/Freeing}
FUNCTION TOneParaSelection.CREATE(object: TObject; heap: THeap; itsView: TView;
itsTextImage: TTextImage; itsAnchorLPt: LPoint; itsParagraph: TEditPara;
itsIndex: LONGINT; oldLP: INTEGER; currLP: INTEGER): TOneParaSelection;
{Debugging}
{$IFC fParaTrace}
PROCEDURE TOneParaSelection.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{Commands}
PROCEDURE TOneParaSelection.StyleFromContext; OVERRIDE;
{Editing}
FUNCTION TOneParaSelection.CopySelf(heap: THeap; view: TView): TMultiParaSelection; OVERRIDE;
PROCEDURE TOneParaSelection.DeleteAndFree; OVERRIDE;
FUNCTION TOneParaSelection.DeleteButSave: TText; OVERRIDE;
{Selecting}
PROCEDURE TOneParaSelection.MouseMove(mouseLPt: LPoint); OVERRIDE;
PROCEDURE TOneParaSelection.MouseRelease; OVERRIDE;
END;
TMultiParaSelection
anchorPara:
anchorIndex:
anchorBegin:
anchorEnd:

= SUBCLASS OF TTextSelection
TEditPara;
LONGINT;
INTEGER;
INTEGER;
{anchorBegin <> anchorEnd iff double or triple click}

{Creation/Freeing}
FUNCTION TMultiParaSelection.CREATE(object: TObject; heap: THeap; itsView: TView;
itsTextImage: TTextImage; itsAnchorLPt: LPoint;
beginPara: TEditPara; beginIndex: LONGINT; beginLP: INTEGER;
endPara: TEditPara; endIndex: LONGINT; endLP: INTEGER;
beginIsAnchor: BOOLEAN): TMultiParaSelection;
{Debugging}
{$IFC fParaTrace}
PROCEDURE TMultiParaSelection.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{Commands}
PROCEDURE TMultiParaSelection.StyleFromContext; OVERRIDE;
{Editing}

Apple Lisa ToolKit 3.0 Source Code Listing -- 760 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

FUNCTION
FUNCTION
PROCEDURE
FUNCTION

TMultiParaSelection.CopySelf(heap:
TMultiParaSelection.Delete(saveIt:
TMultiParaSelection.DeleteAndFree;
TMultiParaSelection.DeleteButSave:

THeap; view: TView): TMultiParaSelection; OVERRIDE;


BOOLEAN): TText;
OVERRIDE;
TText; OVERRIDE;

{Selecting}
PROCEDURE TMultiParaSelection.MouseMove(mouseLPt: LPoint); OVERRIDE;
PROCEDURE TMultiParaSelection.MouseRelease; OVERRIDE;
END;
{-------------

COMMANDS

-----------------}

TClearTextCmd = SUBCLASS OF TCommand


{Variables}
savedText:
text:
{Creation}
FUNCTION

TText;
TText;

{save the cleared text for undo}


{the text object we are clearing}

{TClearTextCmd.}CREATE(object: TObject; heap: THeap; itsCmdNumber: TCmdNumber;


itsImage: TImage; itsText: TText): TClearTextCmd;

PROCEDURE TClearTextCmd.Free; OVERRIDE;


{$IFC fParaTrace}
PROCEDURE TClearTextCmd.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{Command Execution}
PROCEDURE TClearTextCmd.Commit; OVERRIDE;
PROCEDURE TClearTextCmd.Perform(cmdPhase: TCmdPhase); OVERRIDE;
END;
TStyleCmd = SUBCLASS OF TCommand
{Variables}
text:
textSelection:
firstFiltParaIndex:
lastFiltParaIndex:
filtFirstLP:
filtLastLP:
currFilteredPara:
filteredStyles:
{Creation}
FUNCTION

TText;
TTextSelection;
LONGINT;
LONGINT;
INTEGER;
INTEGER;
TEditPara;
{handle to most recently filtered paragraph}
TArray;
{changed type styles of most recently filtered paragraph}

TStyleCmd.CREATE(object: TObject; heap: THeap; itsCmdNumber: TCmdNumber;


itsImage: TImage;

Apple Lisa ToolKit 3.0 Source Code Listing -- 761 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

itsFirstIndex: LONGINT; itsLastIndex: LONGINT;


itsLPFirst: INTEGER; itsLPLast: INTEGER;
itsSelection: TTextSelection): TStyleCmd;
PROCEDURE TStyleCmd.Free; OVERRIDE;
{$IFC fParaTrace}
PROCEDURE TStyleCmd.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{Command Execution}
PROCEDURE TStyleCmd.Commit; OVERRIDE;
PROCEDURE TStyleCmd.FilterAndDo(actualObject: TObject;
PROCEDURE DoToObject(filteredObject: TObject)); OVERRIDE;
PROCEDURE TStyleCmd.Perform(cmdPhase: TCmdPhase); OVERRIDE;
END;
TTextCutCopy = SUBCLASS OF TCutCopyCommand
{Variables}
text:
TText;
{Creation}
FUNCTION

TTextCutCopy.CREATE(object: TObject; heap: THeap; itsCmdNumber: TCmdNumber;


itsImage: TImage;
isCutCmd: BOOLEAN; itsText: TText): TTextCutCopy;

PROCEDURE TTextCutCopy.Free; OVERRIDE;


{$IFC fParaTrace}
PROCEDURE TTextCutCopy.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{Command Execution}
PROCEDURE TTextCutCopy.DoCutCopy(clipSelection: TSelection; deleteOriginal: BOOLEAN;
cmdPhase: TCmdPhase); OVERRIDE;
END;
TTextPaste = SUBCLASS OF TPasteCommand
{Variables}
savedText:
pasteRange:
text:
origIsPara:
origIsWord:
clipIsPara:
{Creation}
FUNCTION

TText;
TTextRange;
TText;
BOOLEAN;
BOOLEAN;
BOOLEAN;

{The text range spanned by the pasted text}

TTextPaste.CREATE(object: TObject; heap: THeap; itsImage: TImage;


itsText: TText): TTextPaste;

Apple Lisa ToolKit 3.0 Source Code Listing -- 762 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

PROCEDURE TTextPaste.Free; OVERRIDE;


{$IFC fParaTrace}
PROCEDURE TTextPaste.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{Command Execution}
PROCEDURE TTextPaste.Commit; OVERRIDE;
PROCEDURE TTextPaste.DoPaste(clipSelection: TSelection; pic: PicHandle; cmdPhase: TCmdPhase);
OVERRIDE;
END;
TTypingCmd = SUBCLASS OF TCommand
{Variables}
savedText:
text:
newCharCount:
newParaCount:
typingRange:
otherInsPts:
{Creation}
FUNCTION

TText;
TText;
INTEGER;
INTEGER;
TTextRange;
TList;

{The text range spanned by the typed characters}

TTypingCmd.CREATE(object: TObject; heap: THeap; itsImage: TImage;


itsText: TText): TTypingCmd;

PROCEDURE TTypingCmd.Free; OVERRIDE;


{$IFC fParaTrace}
PROCEDURE TTypingCmd.Fields(PROCEDURE Field(nameAndType: S255)); OVERRIDE;
{$ENDC}
{Command Execution}
PROCEDURE TTypingCmd.Commit; OVERRIDE;
PROCEDURE TTypingCmd.Perform(cmdPhase: TCmdPhase); OVERRIDE;
END;
VAR fParaTrace:
fTextTrace:

BOOLEAN;
BOOLEAN;

IMPLEMENTATION
(*
{$I UTEXT2.text}
{$I UTEXT3.text}
{$I UTEXT4.text}
*)

{Paragraph classes}
{TStyleSheet, TText, TTextImage, TTextView}
{Text Selections and Commands}

{$I LibTK/UTEXT2.text}

{Paragraph classes}

Apple Lisa ToolKit 3.0 Source Code Listing -- 763 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815

{$I LibTK/UTEXT3.text}
{$I LibTK/UTEXT4.text}
END.

{TStyleSheet, TText, TTextImage, TTextView}


{Text Selections and Commands}

End of File -- Lines: 815 Characters: 35994

Apple Lisa ToolKit 3.0 Source Code Listing -- 764 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UTEXT2.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{UText2}
{changed
{changed
{changed
{changed

{Paragraph Classes}
05/11/84
04/25/84
04/18/84
04/17/84

1135
1250
1652
1806

{changed 04/16/84 1135


{changed 04/16/84 1033
{changed
{changed
{changed
{changed
{changed
{changed
{changed

04/13/84
04/13/84
04/12/84
04/11/84
04/11/84
04/10/84
04/10/84

1739
1537
2344
1527
1454
1400
1158

Added TParagraph.Clone}
Changed FilterAndDo calls back to filtering TParaImage for Compugraphic}
Use TTextImage.firstLinePixel in DrawParaImage}
Put call to ReplTString outside of IF in ReplPara;
Put more parameter checks in ReplTString}
Added styleSheet field to TParaFormat; use it in ChangeRefCountBy}
Put PicTextBegin, End in TParagraph.DrawLine;
Put PicGrpBegin, End in TParaImage.RedrawLines;
Removed picture comments from TParaImage.DrawLine}
Set paraformat.refcount = 0 in TParaFormat.Clone}
Changed calls to FilterAndDo to pass TEditPara rather than TParaImage}
Modified UpdateRuns to use new parameter list}
Call UpdateRuns after deleting characters in TParagraph.ReplPString and ReplTString}
Debug statement in Qualifies to check bug involving special characters}
Changed TEditPara.images field back to a TList and adusted references to it}
Put calls to TParaFormat.ChangeRefCountBy in TEditPara.CREATE, Free}

{$IFC fRngABC}
{$R+}
{$ELSEC}
{$R-}
{$ENDC}
{$IFC fSymABC}
{$D+}
{$ELSEC}
{$D-}
{$ENDC}
TYPE
TScanState = (cBeforeRange, cInRange, cAfterRange);
TFakeTStyle = PACKED ARRAY[1..SIZEOF(TTypeStyle)] OF CHAR;
{$IFC LibraryVersion <= 20}
Style = TSeteface;
FontInfo = TFinfo;
{$ENDC}
{$S SgTxtHot}
VAR nextHighTransit:

THighTransit;

Apple Lisa ToolKit 3.0 Source Code Listing -- 765 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

nextTransitTime:
uvFont:

LONGINT;
ARRAY [1..14] OF TFontRecord;

METHODS OF TParaFormat;
{$S SgTxtIni}
FUNCTION TParaFormat.CREATE(object: TObject; heap: THeap; itsStyleSheet: TStyleSheet): TParaFormat;
VAR tabArray:
TArray;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TParaFormat(object);
tabArray := TArray.CREATE(NIL, heap, 0, SIZEOF(TTxtTabDescriptor));
WITH SELF DO
BEGIN
{$H-}
MakeTypeStyle(famModern, size12Pitch, [], dfltTstyle);
{$H+}
wordWrap := TRUE;
quad := aLeft;
firstIndent := 0;
leftIndent := 0;
rightIndent := 0;
spaceAbovePara := 0;
spaceBelowPara := 0;
lineSpacing := 0;
tabs := tabArray;
permanent := FALSE;
refCount := 0;
styleSheet := itsStyleSheet;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TParaFormat.Free;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
Free(SELF.tabs);
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
FUNCTION TParaFormat.Clone(heap: THeap): TObject;

Apple Lisa ToolKit 3.0 Source Code Listing -- 766 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

VAR tabs:
TArray;
paraFormat: TParaFormat;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
tabs := TArray(SELF.tabs.Clone(heap));
paraFormat := TParaFormat(SUPERSELF.Clone(heap));
paraFormat.tabs := tabs;
paraFormat.refCount := 0;
Clone := paraFormat;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{$IFC fParaTrace}
PROCEDURE TParaFormat.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('dfltTstyle: RECORD onFaces: HexByte; filler: HexByte; fontFamily: Byte; fontSize: Byte END');
Field('wordWrap: BOOLEAN');
Field('quad: HexByte');
Field('firstIndent: INTEGER');
Field('leftIndent: INTEGER');
Field('rightIndent: INTEGER');
Field('spaceAbovePara: INTEGER');
Field('spaceBelowPara: INTEGER');
Field('lineSpacing: INTEGER');
Field('tabs: TArray');
Field('refCount: INTEGER');
Field('permanent: BOOLEAN');
Field('styleSheet: BOOLEAN');
Field('');
END;
{$ENDC}
{$S SgTxtCld}
PROCEDURE TParaFormat.ChangeRefCountBy(delta: INTEGER);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.refCount := SELF.refCount + delta;
IF (SELF.refCount <= 0) AND NOT SELF.permanent THEN
BEGIN
IF SELF.styleSheet <> NIL THEN
SELF.styleSheet.formats.DelObject(SELF, TRUE)
ELSE
SELF.Free;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 767 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TParaFormat.SetTypeStyle(tStyle: TTypeStyle);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SetQDTypeStyle(tStyle);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
BEGIN
UnitAuthor('Apple');
END;
METHODS OF TParagraph;
{$S SgTxtIni}
FUNCTION TParagraph.CREATE(object: TObject; heap: THeap;
initialSize: INTEGER; initialTypeStyle: TTypeStyle): TParagraph;
VAR ts:
TArray;
styleChange:
TStyleChange;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF object = NIL THEN
object := NewDynObject(heap, THISCLASS, initialSize);
SELF := TParagraph(TString.CREATE(object, heap, initialSize));
ts := TArray.CREATE(NIL, heap, 0, SIZEOF(TStyleChange));
styleChange.lp := MAXINT; { -sentinel- }
styleChange.newStyle := initialTypeStyle;
ts.InsAt(1, @styleChange);
styleChange.lp := -1;
ts.InsAt(1, @styleChange);
SELF.typeStyles := ts;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TParagraph.Free;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 768 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

Free(SELF.typeStyles);
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
FUNCTION TParagraph.Clone(heap: THeap): TObject;
VAR paragraph: TParagraph;
styles:
TArray;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
styles := TArray(SELF.typeStyles.Clone(heap));
paragraph := TParagraph(SUPERSELF.Clone(heap));
paragraph.typeStyles := styles;
Clone := paragraph;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{$IFC fParaTrace}
PROCEDURE TParagraph.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field(CONCAT('typeStyles: TArray OF RECORD lp: INTEGER; onFaces: HexByte; ',
'filler: HexByte; fontFamily: Byte; fontSize: Byte END'));
Field('');
END;
{$ENDC}
{$S TK2Start}
{BuildExtentLRect takes an LPoint that indicates the baseline of the paragraph. It returns
in extentLRect the bounding rectangle whose height is based on the tallest font in the
paragraph and width is the width of the characters in the paragraph.}
PROCEDURE TParagraph.BuildExtentLRect(baseLPt: LPoint; VAR extentLRect: LRect);
VAR styleChange:
TStyleChange;
fInfo:
FontInfo;
i:
INTEGER;
tallestFont:
FontInfo;
width:
INTEGER;
oldTallest:
INTEGER;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
oldTallest := 0;
FOR i := 1 to SELF.typeStyles.size - 1 DO
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 769 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

SELF.typeStyles.GetAt(i, @styleChange);
SELF.SetTypeStyle(styleChange.newStyle);
GetFontInfo(fInfo);
WITH fInfo DO
IF oldTallest < ascent + descent + leading THEN
BEGIN
oldTallest := ascent + descent + leading;
tallestFont := fInfo;
END;
END;
width := SELF.Width(1, SELF.size);
WITH extentLRect, baseLPt, tallestFont DO
BEGIN
top := v - ascent;
bottom := v + descent + leading;
left := h;
right := h + width;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TParagraph.ChangeStyle(startLP, endLP: INTEGER; PROCEDURE Change(VAR typeStyle: TTypeStyle);
VAR styleOfStartLP: TTypeStyle);
VAR firstChange:
TStyleChange;
tempChange:
TStyleChange;
prevChange:
TStyleChange;
styles:
TArray;
styleIndex:
INTEGER;
newStyle:
TTypeStyle;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
{$IFC fParaTrace}
IF fParaTrace THEN
BEGIN
WriteLn('=== Entering TParagraph.ChangeStyle: startLP=', startLP:1, ' endLP=', endLP:1);
END;
{$ENDC}
styles := SELF.typeStyles;
styleIndex := 1;
REPEAT
styleIndex := styleIndex + 1;
styles.GetAt(styleIndex, @tempChange);
UNTIL tempChange.lp >= startLP;
{If the change is on a run boundary, just remember the changed style at the beginning so

Apple Lisa ToolKit 3.0 Source Code Listing -- 770 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

we can set styleOfStartLP later}


IF tempChange.lp = startLP THEN
BEGIN
firstChange := tempChange;
Change(firstChange.newStyle);
END
ELSE
BEGIN
{Insert new run descriptor for beginning of changed characters}
styles.GetAt(styleIndex - 1, @firstChange);
prevChange := firstChange;
firstChange.lp := startLP;
Change(firstChange.newStyle);
styles.InsAt(styleIndex, @firstChange);
styleIndex := styleIndex + 1;
END;
{Change existing runs}
WHILE (tempChange.lp < endLP) DO
BEGIN
prevChange := tempChange;
Change(tempChange.newStyle);
styles.PutAt(styleIndex, @tempChange);
styleIndex := styleIndex + 1;
styles.GetAt(styleIndex, @tempChange);
END;
{Don't restore old run info if new run info goes to end of para or ends on old run boundary}
IF endLP < SELF.size THEN
IF tempChange.lp <> endLP THEN
BEGIN
prevChange.lp := endLP;
styles.InsAt(styleIndex, @prevChange);
END;
SELF.CleanRuns;
{return typestyle of beginning of run}
styleOfStartLP := firstChange.newStyle;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TParagraph.ChgFace(startLP, endLP: INTEGER;
newOnFaces: {$IFC LibraryVersion <= 20}TSeteface{$ELSEC}Style{$ENDC};
VAR styleOfStartLP: TTypeStyle);
PROCEDURE ChangeFace(VAR typeStyle: TTypeStyle);

Apple Lisa ToolKit 3.0 Source Code Listing -- 771 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

BEGIN
IF newOnFaces = [] THEN
typeStyle.onFaces := []
ELSE
typeStyle.onFaces := typeStyle.onFaces + newOnFaces;
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.ChangeStyle(startLP, endLP, ChangeFace, styleOfStartLP);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TParagraph.ChgFontFamily(startLP, endLP: INTEGER; newFontFamily: Byte;
VAR styleOfStartLP: TTypeStyle);
PROCEDURE ChangeFamily(VAR typeStyle: TTypeStyle);
BEGIN
typeStyle.font.fontFamily := newFontFamily;
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.ChangeStyle(startLP, endLP, ChangeFamily, styleOfStartLP);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TParagraph.ChgFontSize(startLP, endLP: INTEGER; newFontSize: Byte;
VAR styleOfStartLP: TTypeStyle);
PROCEDURE ChangeSize(VAR typeStyle: TTypeStyle);
BEGIN
typeStyle.font.fontSize := newFontSize;
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.ChangeStyle(startLP, endLP, ChangeSize, styleOfStartLP);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{Deletes redundant run information}
PROCEDURE TParagraph.CleanRuns;
VAR styleChange:
TStyleChange;
prevChange:
TStyleChange;
styles:
TArray;
styleIndex:
INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 772 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

BEGIN
{$IFC fTrace}BP(10);{$ENDC}
styles := SELF.typeStyles;
styles.GetAt(1, @prevChange);
styleIndex := 2;
{Iterate through the style changes and delete any that have either the same lp as the previous
change or the same font and faces info}
WHILE styleIndex < styles.Size DO
BEGIN
styles.GetAt(styleIndex, @styleChange);
IF (styleChange.lp = prevChange.lp) OR
((styleChange.newStyle.onFaces = prevChange.newStyle.onFaces) AND
(styleChange.newStyle.font.fontNum = prevChange.newStyle.font.fontNum)) THEN
styles.DelAt(styleIndex)
ELSE
styleIndex := styleIndex + 1;
prevChange := styleChange;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TParagraph.Draw(i: LONGINT; howMany: INTEGER);
VAR dumInt:
INTEGER;
dumIndex:
INTEGER;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
dumIndex := 1;
SELF.DrawLine(i-1, i + howMany - 2, TRUE, FALSE, dumInt, dumIndex);
{$IFC fTrace}EP;{$ENDC}
END;
{$S TK2Start}
PROCEDURE TParagraph.DrawLine(startLP, endLP: INTEGER; fDraw: BOOLEAN; fWidth: BOOLEAN;
VAR width: INTEGER; VAR styleIndex: INTEGER);
{If fDraw = TRUE, draws a line of characters from startLP to endLP; does not worry about word wrap.
If fWidth = TRUE, returns width of characters. Also accepts an initial styleIndex (index into
run array) to make typestyle scanning faster. Returns styleIndex of run of last character drawn.}
{IDEAS TO MAKE THIS FASTER:
special check to see if there are no typestyle changes in this para?
}
VAR startPP:
endPP:

INTEGER;
INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 773 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

styleChange:
TStyleChange;
prevChange:
TStyleChange;
tStyles:
TArray;
drawCount:
INTEGER;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
{$IFC fParaTrace}
IF fParaTrace THEN
BEGIN
writeln('>> DrawLine: startLP=', startLP:1, ' endLP=', endLP:1,
' styleIndex=', styleIndex:1);
WriteLn('>> DrawLine: fDraw=', fDraw, ' holeStart =', SELF.holeStart:1,
' holeSize =', SELF.holeSize:1);
END;
{$ENDC}
width := 0;
tStyles := SELF.typeStyles;
IF (styleIndex < 1) OR (styleIndex > tStyles.size) THEN
styleIndex := 1;
tStyles.GetAt(styleIndex, @styleChange);
prevChange := styleChange;
WHILE styleChange.lp < startLP DO
BEGIN
prevChange := styleChange;
styleIndex := styleIndex + 1;
tStyles.GetAt(styleIndex, @styleChange);
END;
PicTextBegin(aLeft);
SELF.SetTypeStyle(prevChange.newStyle);
{$IFC fParaTrace}
IF fParaTrace THEN
writeln('>> DrawLine: starting to Draw');
{$ENDC}
WHILE startLP <= endLP DO
BEGIN
drawCount := MIN(styleChange.lp, endLP+1) - startLP;
IF fWidth THEN
width := width + TString.Width(startLP+1, drawCount);
IF fDraw THEN
BEGIN
{$IFC fParaTrace}
IF fParaTrace THEN
writeln('>> DrawLine: About to call DrawText; startLP,drawCount=', startLP:1,
',', drawCount:1);

Apple Lisa ToolKit 3.0 Source Code Listing -- 774 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

{$ENDC}
TString.Draw(startLP+1, drawCount);
END;
startLP := startLP + drawCount;
IF startLP = styleChange.lp THEN
BEGIN
{$IFC fParaTrace}
IF fParaTrace THEN
writeln('>> DrawLine: found a typestyle change at LP=', startLP:1);
{$ENDC}
SELF.SetTypeStyle(styleChange.newStyle);
styleIndex := styleIndex+1;
tStyles.GetAt(styleIndex, @styleChange)
END;
END;
PicTextEnd;
styleIndex := styleIndex-1; {return styleIndex of current typeStyle run}
{$IFC fParaTrace}
IF fParaTrace THEN
BEGIN
Writeln('>> DrawLine: Finished, width=', width:1);
WriteLn;
END;
{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtWrm}
PROCEDURE TParagraph.FindWordBounds(orig: INTEGER; VAR first, last: INTEGER);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
first := orig;
last := orig;
IF SELF.Qualifies(orig) THEN
BEGIN
WHILE SELF.Qualifies(first - 1) DO first := first - 1;
WHILE SELF.Qualifies(last + 1) DO last := last + 1;
END;
IF last < SELF.size THEN
last := last+1; {always selects at least one character, except at end of para}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
FUNCTION TParagraph.FixLP(LP: INTEGER): INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 775 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF LP < 0 THEN
FixLP := 0
ELSE IF LP >= SELF.size THEN
FixLP := SELF.size
ELSE
FixLP := LP;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TParagraph.NewStyle(startLP, endLP: INTEGER; newTypeStyle: TTypeStyle);
VAR styleOfStartLP: TTypeStyle;
PROCEDURE ChgStyle(VAR typeStyle: TTypeStyle);
BEGIN
typeStyle := newTypeStyle;
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.ChangeStyle(startLP, endLP, ChgStyle, styleOfStartLP);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtWrm}
FUNCTION TParagraph.Qualifies(pos: INTEGER): BOOLEAN;
VAR i,j:
INTEGER;
left, this, right: CHAR;
FUNCTION CharClass(ch: CHAR): CHAR;
VAR c: INTEGER;
BEGIN
c := ORD(ch);
IF c IN [65..90, 97..122, 128..159, 167, 174..175,
187..188, 190..191, 202] THEN ch := 'A'
ELSE IF (48 <= c) AND (c <= 57) THEN ch := '9'
ELSE IF (c = 162) OR (c = 163) OR (c = 180) THEN ch := '$';
CharClass := ch;
END;
FUNCTION CharAt(i: INTEGER): CHAR;
BEGIN
IF i < 0 THEN
CharAt := ' '
ELSE IF i >= SELF.size THEN
CharAt := ' '

Apple Lisa ToolKit 3.0 Source Code Listing -- 776 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

ELSE
CharAt := SELF.At(i+1);
END;
BEGIN {Qualifies}
{$IFC fTrace}BP(9);{$ENDC}
left := CharClass(CharAt(pos-1));
this := CharClass(CharAt(pos));
right := CharClass(CharAt(pos+1));
{$IFC fParaTrace}
IF fParaTrace THEN
WriteLn('IN QUALIFIES: left, this, right = (', left:1, this:1, right:1, ')
ORD(left):1, ',', ORD(this):1, ',', ORD(right):1, ']');
{$ENDC}

=> [',

FOR i := 1 TO (LENGTH(wordDelimiters) + 1) DIV 4 DO


BEGIN
j := 4*i-2; { FOR j := 2 TO LENGTH(wordDelimiters) STEP 4 DO }
IF ((wordDelimiters[j-1]=left) OR (wordDelimiters[j-1] = 'x')) AND
(wordDelimiters[j] = this) AND
((wordDelimiters[j+1]=right) OR (wordDelimiters[j+1]='x')) THEN
BEGIN
Qualifies := TRUE;
{$IFC fTrace}EP;{$ENDC}
EXIT(Qualifies);
END;
END;
Qualifies := FALSE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtWrm}
PROCEDURE TParagraph.ReplPara(fPos, numChars: INTEGER;
otherPara: TParagraph; otherFPos, otherNumChars: INTEGER);
VAR styles:
TArray;
otherStyles:
TArray;
styleIndex:
INTEGER;
otherIndex:
INTEGER;
styleChange:
TStyleChange;
otherChange:
TStyleChange;
prevStyle:
TTypeStyle;
diff:
INTEGER;
endLP:
INTEGER;
nextLP:
INTEGER;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
otherPara.StopEdit;

Apple Lisa ToolKit 3.0 Source Code Listing -- 777 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

SELF.ReplTString(fPos, numChars, otherPara, otherFPos, otherNumChars);


IF otherNumChars > 0 THEN
BEGIN
{COPY THE TYPESTYLE RUN INFO TO SELF.typeStyles}
otherStyles := otherPara.typeStyles;
styles := SELF.typeStyles;
{Find out what run we're in in SELF}
styleIndex := 1;
REPEAT
styleIndex := styleIndex+1;
styles.GetAt(styleIndex, @styleChange);
UNTIL fPos <= styleChange.lp;
nextLP := styleChange.lp;
IF fPos < nextLP THEN
styles.GetAt(styleIndex-1, @styleChange); {back up one to get current run}
{Find the first run in otherPara}
otherIndex := 1;
REPEAT
otherIndex := otherIndex+1;
otherStyles.GetAt(otherIndex, @otherChange);
UNTIL otherFPos < otherChange.lp;
otherStyles.GetAt(otherIndex-1, @otherChange);
diff := fPos - otherFPos;
endLP := otherfPos + otherNumChars;
prevStyle := styleChange.newStyle;
{Insert the new run info but avoid consecutive run descriptors of the same info}
otherChange.lp := otherFPos;
WHILE otherChange.lp <= endLP DO
BEGIN
IF TFakeTStyle(otherChange.newStyle) <> TFakeTStyle(prevStyle) THEN
BEGIN
otherChange.lp := otherChange.lp + diff;
styles.InsAt(styleIndex, @otherChange);
styleIndex := styleIndex + 1;
prevStyle := otherChange.newStyle;
END;
otherStyles.GetAt(otherIndex, @otherChange);
otherIndex := otherIndex + 1;
END;
{Insert descriptor of original run after the inserted info, unless we were on a run boundary
or the last run has the same font and faces as the original run}
IF fPos < nextLP THEN
IF TFakeTStyle(styleChange.newStyle) <> TFakeTStyle(prevStyle) THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 778 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

styleChange.lp := fPos+otherNumChars;
styles.InsAt(styleIndex, @styleChange);
END;

END;
{$IFC fTrace}EP;{$ENDC}
END;

{$S SgTxtHot}
PROCEDURE TParagraph.ReplPString(fPos, numChars: INTEGER; pStr: TPString);
VAR otherNumChars: INTEGER;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
{ make fPos lie within [0..# chars in paragraph] }
fPos := SELF.fixLP(fPos);
IF pStr = NIL THEN
otherNumChars := 0
ELSE
otherNumChars := Length(pStr^);
SELF.StartEdit(otherNumChars);
SELF.DelManyAt(fPos + 1, numChars);
(*
SELF.UpdateRuns(fPos,-numChars);
*)
IF pStr <> NIL THEN
SELF.InsPStrAt(fPos + 1, pStr);
SELF.StopEdit;
SELF.UpdateRuns(fPos, numChars, otherNumChars);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TParagraph.ReplTString(fPos, numChars: INTEGER;
otherString: TString; otherFPos, otherNumChars: INTEGER);
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
{ make fPos lie within [0..# chars in paragraph] }
fPos := SELF.fixLP(fPos);
SELF.StartEdit(otherNumChars);
IF numChars > 0 THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 779 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

SELF.DelManyAt(fPos + 1, numChars);
IF (otherString <> NIL) AND (otherNumChars > 0) THEN
SELF.InsManyAt(fPos + 1, otherString, otherFPos + 1, otherNumChars);
SELF.StopEdit;
SELF.UpdateRuns(fPos, numChars, otherNumChars);
{$IFC fTrace}EP;{$ENDC}
END;
{$S TK2Start}
PROCEDURE TParagraph.SetTypeStyle(tStyle: TTypeStyle);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SetQDTypeStyle(tStyle);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TParagraph.StyleAt(lp: INTEGER; VAR typeStyle: TTypeStyle);
VAR styleChange:
TStyleChange;
styles:
TArray;
styleIndex:
INTEGER;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
styles := SELF.typeStyles;
styleIndex := 1;
styles.GetAt(1, @styleChange);
WHILE styleChange.lp <= lp DO
BEGIN
typeStyle := styleChange.newStyle;
styleIndex := styleIndex+1;
styles.GetAt(styleIndex, @styleChange);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TParagraph.UpdateRuns(atLP: INTEGER; replacedChars: INTEGER; insertedChars: INTEGER);
VAR tStyles:
TArray;
i:
INTEGER;
aChange:
TStyleChange;
tempChange:
TStyleChange;
prevStyle:
TTypeStyle;
lastDeleted:
INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 780 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

BEGIN
{$IFC fTrace}BP(8);{$ENDC}
tStyles := SELF.typeStyles;
lastDeleted := -1;
i := 1;
WHILE i <= tStyles.size DO
BEGIN
tStyles.GetAt(i, @aChange);
IF atLP <= aChange.lp THEN
BEGIN
IF i < tStyles.size THEN
aChange.lp := aChange.lp - replacedChars;
{if we deleted some chars, we must delete associated run info}
IF aChange.lp <= atLP THEN
BEGIN
{save type style since we may have deleted only part of this run}
tempChange := aChange;
{assume whole run deleted, reinsert later if not}
tStyles.DelAt(i);
lastDeleted := i;
i := i-1;
END
ELSE
BEGIN
IF i = lastDeleted THEN
{put back run info for last run deleted if part of it still remains and is not
the same as the run before the changes}
IF (aChange.lp <> atLP) AND
(TFakeTStyle(tempChange.newStyle) <> TFakeTStyle(prevStyle)) THEN
BEGIN
tempChange.lp := atLP + insertedChars;
tStyles.InsAt(i, @tempChange);
i := i+1;
END;
IF i < tStyles.size THEN
BEGIN
aChange.lp := aChange.lp + insertedChars;
tStyles.PutAt(i, @aChange);
END;
END;
END
ELSE
prevStyle := aChange.newStyle;
i := i+1;
END;
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 781 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

END;
{$S TK2Start}
FUNCTION TParagraph.Width(i: LONGINT; howMany: INTEGER): INTEGER;
VAR theWidth:
INTEGER;
dumIndex:
INTEGER;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
dumIndex := 1;
SELF.DrawLine(i-1, i + howMany - 2, FALSE, TRUE, theWidth, dumIndex);
Width := theWidth;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
BEGIN
fParaTrace := FALSE;
END;
METHODS OF TEditPara;
{$S SgTxtCld}
FUNCTION TEditPara.CREATE(object: TObject; heap: THeap; initialSize: INTEGER;
itsFormat: TParaFormat): TEditPara;
VAR imgList:
TList;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF object = NIL THEN
object := NewDynObject(heap, THISCLASS, initialSize);
SELF := TEditPara(TParagraph.CREATE(object, heap, initialSize, itsFormat.dfltTStyle));
imgList := TList.CREATE(NIL, heap, 0);
WITH SELF DO
BEGIN
bsCount := 0;
nestLevel := 0;
format := itsFormat;
beingFiltered := FALSE;
(*
numImages := 0;
maxImages := 1;
images[1] := NIL;
*)
images := imgList;
END;
itsFormat.ChangeRefCountBy(1);
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 782 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

END;
{$S SgTxtCld}
PROCEDURE TEditPara.Free;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.format.ChangeRefCountBy(-1);
SELF.images.FreeObject; {Free the list, but not its members}
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{$IFC fParaTrace}
PROCEDURE TEditPara.Fields(PROCEDURE Field(nameAndType: S255));
VAR str:
STR255;
BEGIN
SUPERSELF.Fields(Field);
Field('bsCount: INTEGER');
Field('nestLevel: INTEGER');
Field('format: TParaFormat');
Field('beingFiltered: BOOLEAN');
(*
Field('maxImages: INTEGER');
Field('numImages: INTEGER');
IntToStr(SELF.numImages, @str);
Field(CONCAT('images: ARRAY[1..', CONCAT(str, '] OF TParaImage')));
*)
Field('images: TList');
Field('');
END;
{$ENDC}
{$S SgTxtHot}
PROCEDURE TEditPara.BeginInsertion(atLP: INTEGER; size:INTEGER);
{Changes the text buffer so that the empty space is located at position
expands the buffer (if necessary) so that there is at least size empty
(size = 0 means about to backspace; this does nothing if the paragraph
setup to backspace at atLP.)
}
BEGIN
{$IFC fTrace} BP(6); {$ENDC}
IF (atLP <> SELF.holeStart) OR (size <> 0) THEN {nothing to do--must be
BEGIN
SELF.EditAt(atLP + 1, size);
SELF.bsCount := 0;
END;

atLP;
characters.
is already

backspacing}

Apple Lisa ToolKit 3.0 Source Code Listing -- 783 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

{$IFC fTrace} EP; {$ENDC}


END;
{$S SgTxtCld}
PROCEDURE TEditPara.DelImage(delImage: TParaImage; fFree: BOOLEAN);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.images.DelObject(delImage, fFree);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{Selectively delete paraImages from list based on Function Parameter}
PROCEDURE TEditPara.DelImgIF(FUNCTION ShouldDelete(paraImage: TParaImage): BOOLEAN);
VAR s:
TListScanner;
paraImage: TParaImage;
(*
i:
INTEGER;
numDeleted: INTEGER;
*)
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
s := SELF.images.Scanner;
WHILE s.Scan(paraImage) DO
IF ShouldDelete(paraImage) THEN
s.Delete(FALSE);
(*
numDeleted := 0;
WITH SELF DO
BEGIN
i := 1;
WHILE i <= numImages DO
BEGIN
{$R-} {$H-}
IF ShouldDelete(images[i]) THEN
numDeleted := numDeleted+1
ELSE IF numDeleted > 0 THEN
images[i-numDeleted] := images[i];
{$IFC fRngText}{$R+}{$ENDC} {$H+}
i := i+1;
END;
IF numDeleted > 0 THEN
BEGIN
FOR i := (numImages-numDeleted+1) TO numImages DO
{$R-}
images[numImages] := NIL;

Apple Lisa ToolKit 3.0 Source Code Listing -- 784 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

{$IFC fRngText}{$R+}{$ENDC}
numImages := numImages-numDeleted;
END;
END;

*)
{$IFC fTrace}EP;{$ENDC}
END;

{$S SgTxtCld}
PROCEDURE TEditPara.EachImage(PROCEDURE ImageProc(paraImage: TParaImage));
(*
VAR i: INTEGER;
*)
PROCEDURE DoIt(object: TObject);
BEGIN
ImageProc(TParaImage(object));
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.images.Each(DoIt);
(*
FOR i := 1 TO SELF.numImages DO
{$R-} ImageProc(SELF.images[i]); {$IFC fRngText}{$R+}{$ENDC}
*)
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TEditPara.EndInsertion;
{After calling this:
holeStart = emptyPos = # chars in paragraph
}
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
SELF.StopEdit;
SELF.bsCount := 0;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
FUNCTION TEditPara.GrowSize: INTEGER;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
GrowSize := 200;
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 785 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

END;
{$S SgTxtHot}
PROCEDURE TEditPara.InsertOneChar(ch: CHAR; atLP: INTEGER);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.BeginInsertion(atLP, 1);
{UNDO}
{ now we have SELF.holeStart = atLP }
SELF.PutAt(atLP+1, ch);
SELF.UpdateRuns(atLP, 0, 1);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TEditPara.InsImage(paraImage: TParaImage);
(*
VAR i:
INTEGER;
found: BOOLEAN;
*)
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.images.InsLast(paraImage);
(*
IF SELF.numImages = SELF.maxImages THEN
BEGIN
SELF.ResizeCollection(SELF.size + SELF.holeSize + 4);
SELF.ShiftCollection(0, 4, SELF.size + SELF.holeSize);
WITH SELF DO
BEGIN
dynStart := dynStart + 4;
maxImages := maxImages + 1;
END;
END;
WITH SELF DO
BEGIN
numImages := numImages + 1;
{$R-}
images[numImages] := paraImage;
{$IFC fRngText}{$R+}{$ENDC}
END;
*)
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TEditPara.SetTypeStyle(tStyle: TTypeStyle);

Apple Lisa ToolKit 3.0 Source Code Listing -- 786 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.format.SetTypeStyle(tStyle);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
END;
METHODS OF TLineInfo;
{$S SgTxtWrm}
FUNCTION TLineInfo.CREATE(object: TObject; heap: THeap): TLineInfo;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TLineInfo(object);
WITH SELF DO
BEGIN
valid := FALSE;
startLP := 0;
lastDrawnLP := 0;
endLP := 0;
lineLRect := zeroLRect;
lineAscent := 0;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{$IFC fParaTrace}
PROCEDURE TLineInfo.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('valid: BOOLEAN');
Field('startLP: INTEGER');
Field('lastDrawnLP: INTEGER');
Field('endLP: INTEGER');
Field('lineLRect: LRect');
Field('lineAscent: INTEGER');
Field('');
END;
{$ENDC}
{$S SgTxtHot}
FUNCTION TLineInfo.LeftCoord(proposedLeftPixel: LONGINT): LONGINT;

Apple Lisa ToolKit 3.0 Source Code Listing -- 787 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

BEGIN
{$IFC fTrace}BP(9);{$ENDC}
{Default is to not change the parameter; TLineInfo subclassers may choose to do otherwise}
LeftCoord := proposedLeftPixel;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
FUNCTION TLineInfo.RightCoord(proposedRightPixel: LONGINT): LONGINT;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
{Default is to not change the parameter; TLineInfo subclassers may choose to do otherwise}
RightCoord := proposedRightPixel;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
END;
METHODS OF TParaImage;
{$S SgTxtWrm}
FUNCTION TParaImage.CREATE(object: TObject; heap: THeap; itsView: TView; itsParagraph: TEditPara;
itsLRect: LRect; lineTop: LONGINT; lineLeft: LONGINT): TParaImage;
VAR aLineList: TList;
lineInfo:
TLineInfo;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TParaImage(TImage.CREATE(object, heap, itsLRect, itsView));
SELF.paragraph := itsParagraph;
SELF.extentLRect := itsLRect;
aLineList := TList.CREATE(NIL, heap, 0);
lineInfo := SELF.DfltLineInfo(lineTop, lineLeft);
aLineList.InsLast(lineInfo);
WITH SELF DO
BEGIN
height := lineInfo.lineLRect.bottom - lineInfo.lineLRect.top;
lineList := aLineList;
tickcount := 0;
changed := TRUE;
startLP := 0;
endLP := 0;

Apple Lisa ToolKit 3.0 Source Code Listing -- 788 of 1012

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163
001164
001165
001166
001167
001168
001169
001170
001171
001172
001173
001174
001175
001176
001177
001178
001179
001180
001181
001182
001183
001184
001185
001186
001187
001188
001189
001190
001191
001192
001193
001194
001195

textImage := NIL;
wasOffset := FALSE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtWrm}
PROCEDURE TParaImage.Free;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
Free(SELF.lineList);
(* Since caller of this may be scanning the paragraph's image list we can't delete it from the
list here lest we screw up the caller's scanner. So the caller will have to to do this}
SELF.paragraph.DelImage(SELF, FALSE);
*)
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{$IFC fParaTrace}
PROCEDURE TParaImage.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('paragraph: TEditPara');
Field('height: INTEGER');
Field('lineList: TList');
Field('changed: BOOLEAN');
Field('tickCount: INTEGER');
Field('startLP: INTEGER');
Field('endLP: INTEGER');
Field('textImage: TTextImage');
Field('wasOffset: BOOLEAN');
Field('');
END;
{$ENDC}
{$S SgTxtHot}
PROCEDURE TParaImage.AdjustLineLPs(atLP, deltaLP: INTEGER);
{positive deltaLP implies character(s) were inserted, negative deltaLP implies they were deleted}
PROCEDURE AdjustLP(obj: TObject);
BEGIN
WITH TLineInfo(obj) DO
BEGIN
{$H-}
IF startLP > atLP THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 789 of 1012

Apple Lisa Computer Technical Information


001196
001197
001198
001199
001200
001201
001202
001203
001204
001205
001206
001207
001208
001209
001210
001211
001212
001213
001214
001215
001216
001217
001218
001219
001220
001221
001222
001223
001224
001225
001226
001227
001228
001229
001230
001231
001232
001233
001234
001235
001236
001237
001238
001239
001240
001241
001242
001243

startLP := Max(atLP, startLP + deltaLP);


IF lastDrawnLP > atLP THEN
lastDrawnLP := Max(atLP, lastDrawnLP + deltaLP);
IF endLP > atLP THEN
endLP := Max(atLP, endLP + deltaLP);
{$H+}
END;

END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.lineList.Each(AdjustLP);
WITH SELF DO
BEGIN
{$H-}
IF startLP > atLP THEN
startLP := Max(atLP, startLP + deltaLP);
IF endLP >= atLP THEN
endLP := Max(atLP, endLP + deltaLP);
{$H+}
END;
{$IFC fTrace}EP;{$ENDC}
END;

{$S SgTxtHot}
PROCEDURE TParaImage.ComputeLineInfo(curLine: TLineInfo; maxLineLen: INTEGER;
VAR nextLP: INTEGER; VAR lRectNeeded: LRect);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtWrm}
FUNCTION TParaImage.DfltLineInfo(lineTop: LONGINT; lineLeft: LONGINT): TLineInfo;
VAR lineInfo:
TLineInfo;
fInfo:
FontInfo;
i:
INTEGER;
format:
TParaFormat;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
lineInfo := TLineInfo.CREATE(NIL, SELF.Heap);
format := SELF.GetFormat;
format.SetTypeStyle(format.dfltTStyle);
GetFontInfo(fInfo);
i := SELF.paragraph.size;

Apple Lisa ToolKit 3.0 Source Code Listing -- 790 of 1012

Apple Lisa Computer Technical Information


001244
001245
001246
001247
001248
001249
001250
001251
001252
001253
001254
001255
001256
001257
001258
001259
001260
001261
001262
001263
001264
001265
001266
001267
001268
001269
001270
001271
001272
001273
001274
001275
001276
001277
001278
001279
001280
001281
001282
001283
001284
001285
001286
001287
001288
001289
001290
001291

WITH lineInfo, fInfo, format DO


BEGIN
lastDrawnLP := i;
endLP := i;
lineAscent := ascent;
{$H-}
SetLRect(lineLRect, lineLeft, lineTop, lineLeft,
spaceAbovePara + lineTop + ascent + descent + leading + spaceBelowPara);
OffsetLRect(lineLRect, SELF.extentLRect.left + firstIndent, SELF.extentLRect.top);
{$H+}
END;
DfltLineInfo := lineInfo;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TParaImage.DrawLine(startLP: INTEGER; fDraw: BOOLEAN; stopWidth, wrapWidth: INTEGER;
VAR lineWidth, lastToDraw, endLP: INTEGER);
{Figures out what characters to draw based on a variety of input constraints.
Returns:
lineWidth: the width of the line calculated (including trailing spaces) [??]
lastToDraw: the lp of the last non blank character in the line
endLP:
the lp of the last character in the line (may be a blank)
}
{NOTE: the wrapWidth parameter may eventually be dropped and instead calculated from SELF.extentLRect
and certain format fields}
LABEL
1;
VAR c:
CHAR;
startPP:
INTEGER;
curIndex:
INTEGER;
styleChange:
TStyleChange;
prevChange:
TStyleChange;
styles:
TArray;
styleIndex:
INTEGER;
firstStyleIndex:INTEGER;
cWidth:
INTEGER;
maxPP:
INTEGER;
endPP:
INTEGER;
breakIndex:
INTEGER;
breakCount:
INTEGER;
breakLen:
INTEGER;
paragraph:
TEditPara;
format:
TParaFormat;
drawStart:
INTEGER;
drawCount:
INTEGER;
dummy:
INTEGER;

{ PP of last character looked at }

Apple Lisa ToolKit 3.0 Source Code Listing -- 791 of 1012

Apple Lisa Computer Technical Information


001292
001293
001294
001295
001296
001297
001298
001299
001300
001301
001302
001303
001304
001305
001306
001307
001308
001309
001310
001311
001312
001313
001314
001315
001316
001317
001318
001319
001320
001321
001322
001323
001324
001325
001326
001327
001328
001329
001330
001331
001332
001333
001334
001335
001336
001337
001338
001339

maxLP:
INTEGER;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
{$IFC fParaTrace}
IF fParaTrace THEN
writeln('** DrawLine: startLP=', startLP:1, ', maxLP=',maxLP:1, ', fDraw=', fDraw,
', stopWidth=',stopWidth:1, ', wrapWidth=',wrapWidth:1);
{$ENDC}
maxLP := SELF.paragraph.size-1;
IF maxLP < startLP THEN
BEGIN
lineWidth := 0;
lastToDraw := maxLP;
endLP := maxLP;
END
ELSE
BEGIN
paragraph := SELF.paragraph;
format := SELF.GetFormat;
breakIndex := 0;
lastToDraw := 0;
lineWidth := 0;
cWidth := 0;
curIndex := paragraph.FixLP(startLP);
styles := paragraph.typeStyles;
styles.GetAt(1, @styleChange);
styleIndex := 1;
REPEAT
prevChange := styleChange;
styleIndex := styleIndex + 1;
styles.GetAt(styleIndex, @styleChange);
UNTIL curIndex < styleChange.lp;
format.SetTypeStyle(prevChange.newStyle);
firstStyleIndex := styleIndex-1;
startPP := curIndex;
maxPP := MIN(paragraph.size, paragraph.FixLP(maxLP));
{$IFC fParaTrace}
IF fParaTrace THEN
writeln('** DrawLine: About enter loop, maxPP =',maxPP:1,'
' holeSize=',paragraph.holeSize:1);
{$ENDC}
WHILE curIndex <= maxPP DO
BEGIN

holeStart=',paragraph.holeStart:1,

Apple Lisa ToolKit 3.0 Source Code Listing -- 792 of 1012

Apple Lisa Computer Technical Information


001340
001341
001342
001343
001344
001345
001346
001347
001348
001349
001350
001351
001352
001353
001354
001355
001356
001357
001358
001359
001360
001361
001362
001363
001364
001365
001366
001367
001368
001369
001370
001371
001372
001373
001374
001375
001376
001377
001378
001379
001380
001381
001382
001383
001384
001385
001386
001387

IF curIndex = styleChange.lp THEN


BEGIN
format.SetTypeStyle(styleChange.newStyle);
styleIndex := styleIndex+1;
styles.GetAt(styleIndex, @styleChange)
END;
c := paragraph.At(curIndex+1);
cWidth := CharWidth(c);
{$IFC fParaTrace AND FALSE}
IF fParaTrace THEN
writeln('curIndex=', curIndex:1, ', char=', c, ', cWidth=',
cWidth:1, ', lineWidth=',lineWidth:1);
{$ENDC}
{Drop out of loop if lineWidth > stopWidth unless
we're at end of line and have trailing spaces}
IF (lineWidth + cWidth > stopWidth) THEN
IF format.wordWrap AND (stopWidth = wrapWidth) THEN
IF (c <> ' ') THEN
GOTO 1
ELSE
ELSE
GOTO 1;
IF format.wordWrap AND (c = ' ') THEN
BEGIN
IF (breakIndex + 1) < curIndex THEN
lastToDraw := curIndex-1;
breakIndex := curIndex;
breakLen := lineWidth;
END;

1:

{so we don't draw trailing blanks}

lineWidth := lineWidth + cWidth;


curIndex := curIndex + 1;
cWidth := 0;
END;
curIndex := curIndex - 1;
IF format.wordWrap AND (lineWidth + cWidth > wrapWidth) AND (breakIndex > 0) THEN
{ PRIMITIVE WORD WRAP! }
BEGIN
lineWidth := breakLen;
curIndex := breakIndex;
END
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 793 of 1012

Apple Lisa Computer Technical Information


001388
001389
001390
001391
001392
001393
001394
001395
001396
001397
001398
001399
001400
001401
001402
001403
001404
001405
001406
001407
001408
001409
001410
001411
001412
001413
001414
001415
001416
001417
001418
001419
001420
001421
001422
001423
001424
001425
001426
001427
001428
001429
001430
001431
001432
001433
001434
001435

lastToDraw := curIndex;
{$IFC fParaTrace}
IF fParaTrace THEN
writeln('** DrawLine: About to figure endLP, curIndex =',curIndex:1);
{$ENDC}
endLP := curIndex;
{$IFC fParaTrace}
IF fParaTrace THEN
writeln('** DrawLine: endLP figured =',endLP:1);
{$ENDC}
IF (lastToDraw >= 0) AND fDraw THEN
SELF.FastDrawLine(paragraph.fixLP(startLP), lastToDraw, TRUE,
FALSE, dummy, firstStyleIndex);
END;
{$IFC fParaTrace}
IF fParaTrace THEN
BEGIN
writeln('** DrawLine done: endLP=',endLP:1,', lineWidth=',lineWidth:1);
writeln('** DrawLine done: final lastToDraw=',lastToDraw:1);
WriteLn;
END;
{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TParaImage.DrawParaImage(limitLRect: LRect; startLP: INTEGER; drawAction: TDrawAction;
invalBits: BOOLEAN; VAR drawnLRect: LRect);
{Note: DrawParaImage now assumes that the paragraph was changed}
LABEL 1;
VAR paragraph:
TEditPara;
fInfo:
FontInfo;
lineInfo:
TLineInfo;
firstLineInfo: TLineInfo;
lineList:
TList;
lineSpacing:
INTEGER;
curBase:
LONGINT;
leftMargin:
LONGINT;
curLP:
INTEGER;
endLP:
INTEGER;
numChars:
INTEGER;
lineLen:
INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 794 of 1012

Apple Lisa Computer Technical Information


001436
001437
001438
001439
001440
001441
001442
001443
001444
001445
001446
001447
001448
001449
001450
001451
001452
001453
001454
001455
001456
001457
001458
001459
001460
001461
001462
001463
001464
001465
001466
001467
001468
001469
001470
001471
001472
001473
001474
001475
001476
001477
001478
001479
001480
001481
001482
001483

maxLineLen:
INTEGER;
lineIndex:
INTEGER;
pixel:
LONGINT;
lastDrawnLP:
INTEGER;
testLPoint:
LPoint;
format:
TParaFormat;
firstFudge:
INTEGER;
startOfNewPara: BOOLEAN;
anLRect:
LRect;
sLine:
TListScanner;
genRest:
BOOLEAN;
genBefore:
BOOLEAN;
oldEndLP:
INTEGER;
prevLineInfo:
TLineInfo;
prevLen:
INTEGER;
prevPImage:
TParaImage;
prevTxtImage:
TTextImage;
origStart:
INTEGER;
dummy:
INTEGER;
styleIndex:
INTEGER;
r:
LRect;
{$IFC fParaTrace}
str:
STR255;
{$ENDC}
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
{$IFC fParaTrace}
IF fParaTrace THEN
BEGIN
WITH limitLRect DO
WriteLn('## Entering DrawParaImage: limitLRect=[(',left:1,',',top:1,'),(',
right:1,',', bottom:1,')]');
LIntToHex(ORD(SELF), @str);
WriteLn(
'
SELF = ', str,' startLP=',startLP:1,' drawAction=',ORD(drawAction));
END;
{$ENDC}
drawnLRect := limitLRect;
endLP := startLP;
paragraph := SELF.paragraph;
format := SELF.GetFormat;
IF drawAction = actionDraw THEN WITH SELF DO
tickCount := (tickCount+1) MOD MAXINT;
PicGrpBegin;
PenNormal;
genRest := FALSE;

Apple Lisa ToolKit 3.0 Source Code Listing -- 795 of 1012

Apple Lisa Computer Technical Information


001484
001485
001486
001487
001488
001489
001490
001491
001492
001493
001494
001495
001496
001497
001498
001499
001500
001501
001502
001503
001504
001505
001506
001507
001508
001509
001510
001511
001512
001513
001514
001515
001516
001517
001518
001519
001520
001521
001522
001523
001524
001525
001526
001527
001528
001529
001530
001531

genBefore := FALSE;
curLP := startLP;
numChars := paragraph.size;
SELF.startLP := curLP;
format.SetTypeStyle(format.dfltTStyle);
GetFontInfo(fInfo);
WITH fInfo DO
lineSpacing := ascent + descent + leading + format.lineSpacing;
lineList := SELF.lineList;
curBase := limitLRect.top;
prevLineInfo := NIL;
IF lineList.Size > 0 THEN
BEGIN
sLine := lineList.Scanner;
{If existing lineInfo's start after startLP then we need to generate preceeding lineInfo's}
IF TLineInfo(lineList.First).startLP > startLP THEN
BEGIN
origStart := TLineInfo(lineList.First).startLP;
genBefore := TRUE;
END
ELSE WHILE sLine.Scan(lineInfo) DO
BEGIN
{delete lineinfo's that start before the startLP parameter}
IF lineInfo.endLP < startLP THEN
sLine.Delete(TRUE)
ELSE
BEGIN
IF lineInfo.valid THEN
BEGIN
prevLineInfo := lineInfo;
curBase := lineInfo.lineLRect.bottom;
END
ELSE
GOTO 1;
END;
END;
END
ELSE
lineInfo := NIL;
1:
IF NOT genBefore THEN
IF lineInfo = NIL THEN
BEGIN
genRest := TRUE;
curLP := Max(startLP, SELF.endLP);

Apple Lisa ToolKit 3.0 Source Code Listing -- 796 of 1012

Apple Lisa Computer Technical Information


001532
001533
001534
001535
001536
001537
001538
001539
001540
001541
001542
001543
001544
001545
001546
001547
001548
001549
001550
001551
001552
001553
001554
001555
001556
001557
001558
001559
001560
001561
001562
001563
001564
001565
001566
001567
001568
001569
001570
001571
001572
001573
001574
001575
001576
001577
001578
001579

END
ELSE
curLP := Max(startLP, lineInfo.startLP);
startOfNewPara := curLP = 0;
curBase := curBase + fInfo.ascent;
IF startOfNewPara THEN
BEGIN
curBase := curBase + format.spaceAbovePara;
leftMargin := limitLRect.left + format.firstIndent;
{ The first line maxLineLen might be different (due to firstIndent)}
firstFudge := format.firstIndent - format.leftIndent;
END
ELSE
BEGIN
leftMargin := limitLRect.left + format.leftIndent;
firstFudge := 0;
END;
limitLRect.left := limitLRect.left + format.leftIndent;
limitLRect.right := limitLRect.right - format.rightIndent;
maxLineLen := lengthLRect(limitLRect, h) - firstFudge;

{if firstIndent is to left of


leftIndent, fudge will be negative}

SetLPt(testLPoint, limitLRect.left, curBase + fInfo.descent);


{$IFC fParaTrace}
IF fParaTrace THEN
BEGIN
WriteLn('## DrawParaImage: Entering DrawLine loop -- leftMargin=',leftMargin:1,
' curBase=',curBase:1);
END;
{$ENDC}
{don't bother going into the loop if we can't fit the first line or we've run out
of characters already (eg: empty para)}
IF (NOT LPtInLRect(testLPoint, limitLRect)) OR (curLP >= numChars) THEN
BEGIN
SELF.extentLRect := drawnLRect;
IF NOT genRest THEN
BEGIN
r := lineInfo.lineLRect;
r.left := lineInfo.LeftCoord(SELF.textImage.extentLRect.left-1);
r.right := lineInfo.RightCoord(SELF.textImage.extentLRect.right+1);
lineInfo := SELF.DfltLineInfo(0,0);
r.bottom := lineInfo.lineLRect.bottom;

Apple Lisa ToolKit 3.0 Source Code Listing -- 797 of 1012

Apple Lisa Computer Technical Information


001580
001581
001582
001583
001584
001585
001586
001587
001588
001589
001590
001591
001592
001593
001594
001595
001596
001597
001598
001599
001600
001601
001602
001603
001604
001605
001606
001607
001608
001609
001610
001611
001612
001613
001614
001615
001616
001617
001618
001619
001620
001621
001622
001623
001624
001625
001626
001627

sLine.Replace(lineInfo, TRUE);
genRest := NOT sLine.Scan(lineInfo);
END;
{These two assignments distinguish (for the calling routine) whether an empty
paragraph did or did not fit in the limitLRect. Assuming curLP = 0, SELF.endLP
will be 0 for a paragraph that did fit and -1 for one that did not fit. The calling
routine checks this value against paragraph.size to see if the paragraph fit}
IF LPtInLRect(testLPoint, limitLRect) THEN
BEGIN
SELF.endLP := curLP;
{Erase the old line}
IF drawAction = actionDraw THEN
FillLRect(r, lPatWhite)
ELSE IF drawAction = actionInval THEN
thePad.InvalLRect(r);
END
ELSE
SELF.endLP := curLP-1;
{$IFC fParaTrace}
IF fParaTrace THEN
BEGIN
WriteLn('## DrawParaImage: Empty para or cannot fit; endLP set to ',SELF.endLP:1);
END;
{$ENDC}
END
{Otherwise, set up lineLRect and call DrawLine while there are still characters to display
and we still fit in limitLRect}
ELSE
BEGIN
{Layout line previous to first invalid line to see if characters from the
invalid line can wrap back. First, however, we must check for special case
of the previous line being in another textImage.}
IF NOT startOfNewPara AND (prevLineInfo = NIL) THEN
BEGIN
prevTxtImage := SELF.textImage.prevTxtImg;
IF prevTxtImage <> NIL THEN
BEGIN
prevPImage := TParaImage(prevTxtImage.imageList.Last);
prevLineInfo := TLineInfo(prevPImage.lineList.Last);
prevLen := LengthLRect(prevPImage.extentLRect, h) - format.leftIndent
- format.rightIndent;
END;
END
ELSE
BEGIN
prevLen := maxLineLen;
prevPImage := SELF;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 798 of 1012

Apple Lisa Computer Technical Information


001628
001629
001630
001631
001632
001633
001634
001635
001636
001637
001638
001639
001640
001641
001642
001643
001644
001645
001646
001647
001648
001649
001650
001651
001652
001653
001654
001655
001656
001657
001658
001659
001660
001661
001662
001663
001664
001665
001666
001667
001668
001669
001670
001671
001672
001673
001674
001675

IF prevLineInfo <> NIL THEN


BEGIN
oldEndLP := prevLineInfo.endLP;
IF prevLineInfo.startLP = 0 THEN
prevLen := prevLen - (format.firstIndent - format.leftIndent);
prevPImage.DrawLine(prevLineInfo.startLP, FALSE, prevLen, prevLen,
lineLen, lastDrawnLP, endLP);
IF endLP <> oldEndLP THEN
BEGIN
SELF.textImage.useFirstPixel := FALSE;
r := prevLineInfo.lineLRect;
r.left := prevLineInfo.LeftCoord(prevPImage.textImage.extentLRect.left-1);
r.right := prevLineInfo.RightCoord(prevPImage.textImage.extentLRect.right+1);
IF drawAction = actionDraw THEN
BEGIN
FillLRect(r, lPatWhite);
styleIndex := 1;
MoveToL(prevLineInfo.lineLRect.left,
prevLineInfo.lineLRect.top+prevLineInfo.lineAscent);
SELF.FastDrawLine(prevLineInfo.startLP, lastDrawnLP, TRUE,
FALSE, dummy, styleIndex);
END
ELSE IF drawAction = actionInval THEN
thePad.InvalLRect(r);
WITH prevLineInfo.lineLRect DO
BEGIN
prevLineInfo.valid := invalBits;
right := left + lineLen;
prevLineInfo.lastDrawnLP := lastDrawnLP;
prevLineInfo.endLP := endLP;
curLP := endLP + 1;
prevPImage.endLP := curLP;
IF curLP >= numChars THEN
IF (bottom + format.spaceBelowPara) <= limitLRect.bottom THEN
BEGIN
r.top := bottom;
bottom := bottom + format.spaceBelowPara;
r.bottom := bottom;
{$H-}
IF drawAction = actionDraw THEN
FillLRect(r, lPatWhite)
ELSE IF drawAction = actionInval THEN
thePad.InvalLRect(r);
{$H+}

Apple Lisa ToolKit 3.0 Source Code Listing -- 799 of 1012

Apple Lisa Computer Technical Information


001676
001677
001678
001679
001680
001681
001682
001683
001684
001685
001686
001687
001688
001689
001690
001691
001692
001693
001694
001695
001696
001697
001698
001699
001700
001701
001702
001703
001704
001705
001706
001707
001708
001709
001710
001711
001712
001713
001714
001715
001716
001717
001718
001719
001720
001721
001722
001723

END;
END;
END;
END;
WITH fInfo DO
SetLRect(anLRect, leftMargin, curBase - ascent,
leftMargin + maxlineLen, curBase + descent + leading);
leftMargin := limitLRect.left;
{Setup GrafPort for first line (after prev line)}
IF drawAction = actionDraw THEN
MoveToL(leftMargin + firstFudge, curBase);
WHILE (curLP < numChars) AND (LPtInLRect(testLPoint, limitLRect)) DO
BEGIN
IF genRest OR genBefore THEN
lineInfo := TLineInfo.CREATE(NIL, paragraph.heap);
IF NOT lineInfo.valid THEN
BEGIN
WITH fInfo, lineInfo DO
BEGIN
startLP := curLP;
lineAscent := ascent;
lineLRect := anLRect;
END;
r := anLRect;
r.left := lineInfo.LeftCoord(SELF.textImage.extentLRect.left-1);
IF SELF.textImage.useFirstPixel THEN
BEGIN
r.left := Max(r.left, SELF.textImage.firstLinePixel);
SELF.textImage.useFirstPixel := FALSE;
END;
r.right := lineInfo.RightCoord(SELF.textImage.extentLRect.right+1);
IF drawAction = actionDraw THEN
FillLRect(r, lPatWhite)
ELSE IF drawAction = actionInval THEN
thePad.InvalLRect(r);
oldEndLP := lineInfo.endLP;
SELF.DrawLine(curLP, drawAction = actionDraw, maxLineLen, maxLineLen,
lineLen, lastDrawnLP, endLP);
{$IFC fParaTrace}
IF (curLP > endLP) AND (curLP < numChars)THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 800 of 1012

Apple Lisa Computer Technical Information


001724
001725
001726
001727
001728
001729
001730
001731
001732
001733
001734
001735
001736
001737
001738
001739
001740
001741
001742
001743
001744
001745
001746
001747
001748
001749
001750
001751
001752
001753
001754
001755
001756
001757
001758
001759
001760
001761
001762
001763
001764
001765
001766
001767
001768
001769
001770
001771

ABCbreak('loop in DrawParaImage; curLP=',curLP);


endLP := curLP + 1;
END;
{$ENDC}
{finish setting up new lineInfo}
WITH fInfo, lineInfo.lineLRect DO
BEGIN
lineInfo.lastDrawnLP := lastDrawnLP;
lineInfo.endLP := endLP;
right := left + lineLen;
{if this is last line in paragraph, add spaceBelowPara, unless that extra amount
would put it ouside of the limitLRect}
IF (endLP+1) >= numChars THEN
IF (bottom + format.spaceBelowPara) <= limitLRect.bottom THEN
BEGIN
r.top := bottom;
bottom := bottom + format.spaceBelowPara;
r.bottom := bottom;
{$H-}
IF drawAction = actionDraw THEN
FillLRect(r, lPatWhite)
ELSE IF drawAction = actionInval THEN
thePad.InvalLRect(r);
{$H+}
END;
END;
{If the word being typed wrapped down to the next line, we need to erase
the piece of the word that was on this line.}
IF r.left > lineInfo.lineLRect.right THEN
BEGIN
r.left := lineInfo.lineLRect.right;
IF drawAction = actionDraw THEN
FillLRect(r, lPatWhite)
ELSE IF drawAction = actionInval THEN
thePad.InvalLRect(r);
END;
IF genRest THEN
lineList.InsLast(lineInfo)
ELSE IF genBefore THEN
sLine.Append(lineInfo); {leaves scanner poised before the original first lineInfo}
lineInfo.valid := invalBits;
END
ELSE {lineInfo is valid}

Apple Lisa ToolKit 3.0 Source Code Listing -- 801 of 1012

Apple Lisa Computer Technical Information


001772
001773
001774
001775
001776
001777
001778
001779
001780
001781
001782
001783
001784
001785
001786
001787
001788
001789
001790
001791
001792
001793
001794
001795
001796
001797
001798
001799
001800
001801
001802
001803
001804
001805
001806
001807
001808
001809
001810
001811
001812
001813
001814
001815
001816
001817
001818
001819

BEGIN
endLP := lineInfo.endLP;
oldEndLP := endLP;
END;
{This field is used by caller in case the entire paragraph didn't fit, so that the
caller knows where to start subsequent display}
SELF.endLP := endLP + 1;
{Setup for next line}
curLP := endLP+1;
curBase := curBase + lineSpacing;
maxLineLen := maxLineLen + firstFudge;
firstFudge := 0;
IF genBefore THEN
genBefore := origStart > curLP;
IF NOT (genRest OR genBefore) THEN
BEGIN
IF sLine.Scan(lineInfo) THEN
IF lineInfo.startLP <> curLP THEN
lineInfo.valid := FALSE
ELSE
ELSE
genRest := TRUE;
END;
{ setup GrafPort and lineRect for next line}
IF drawAction = actionDraw THEN
MoveToL(leftMargin, curBase);
WITH fInfo DO
SetLRect(anLRect,
leftMargin, curBase - ascent,
leftMargin + maxLineLen, curBase + descent + leading);
SetLPt(testLPoint, leftMargin, testLPoint.v + lineSpacing);
END; {WHILE}
END; {IF}
{We don't want to delete the lineInfo we just sLine.appended so advance scanner}
IF genBefore THEN
sLine.Skip(1);
IF NOT genRest THEN
REPEAT
sLine.Delete(TRUE);
UNTIL NOT sLine.Scan(lineInfo);
IF SELF.changed THEN
SELF.changed := NOT invalBits;
PicGrpEnd;

Apple Lisa ToolKit 3.0 Source Code Listing -- 802 of 1012

Apple Lisa Computer Technical Information


001820
001821
001822
001823
001824
001825
001826
001827
001828
001829
001830
001831
001832
001833
001834
001835
001836
001837
001838
001839
001840
001841
001842
001843
001844
001845
001846
001847
001848
001849
001850
001851
001852
001853
001854
001855
001856
001857
001858
001859
001860
001861
001862
001863
001864
001865
001866
001867

lineInfo := TLineInfo(SELF.lineList.Last);
firstLineInfo := TLineInfo(SELF.lineList.First);
SELF.height := lineInfo.lineLRect.bottom - firstLineInfo.lineLRect.top;
drawnLRect.bottom := lineInfo.lineLRect.bottom;
SELF.extentLRect := drawnLRect;
{$IFC fParaTrace}
IF fParaTrace THEN
BEGIN
WITH drawnLRect DO
WriteLn('## Exiting DrawParaImage: drawnLRect=[(',left:1,',',top:1,'),(',
right:1,',', bottom:1,')]',
'; height = ',SELF.height:1);
END;
{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TParaImage.Draw;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.RedrawLines(0, MAXINT);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TParaImage.FastDrawLine(startLP, endLP: INTEGER; fDraw: BOOLEAN; fWidth: BOOLEAN;
VAR width: INTEGER; VAR styleIndex: INTEGER);
{If fDraw = TRUE, draws a line of characters from startLP to endLP; does not worry about word wrap.
If fWidth = TRUE, returns width of characters. Also accepts an initial styleIndex (index into
run array) to make typestyle scanning faster. Returns styleIndex of run of last character drawn.}
VAR saveFormat: TParaFormat;
paragraph: TEditPara;
format:
TParaformat;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
paragraph := SELF.paragraph;
saveFormat := paragraph.format;
format := SELF.GetFormat;
paragraph.format := format;
paragraph.DrawLine(startLP, endLP, fDraw, fWidth, width, styleIndex);

Apple Lisa ToolKit 3.0 Source Code Listing -- 803 of 1012

Apple Lisa Computer Technical Information


001868
001869
001870
001871
001872
001873
001874
001875
001876
001877
001878
001879
001880
001881
001882
001883
001884
001885
001886
001887
001888
001889
001890
001891
001892
001893
001894
001895
001896
001897
001898
001899
001900
001901
001902
001903
001904
001905
001906
001907
001908
001909
001910
001911
001912
001913
001914
001915

paragraph.format := saveFormat;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
{Returns paragraph's paraFormat; can be overriden by application}
FUNCTION TParaImage.GetFormat: TParaFormat;
VAR styleIndex:
INTEGER;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
GetFormat := SELF.paragraph.format;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TParaImage.InvalLinesWith(startLP, endLP: INTEGER);
VAR s:
TListScanner;
lineInfo:
TLineInfo;
prevLineInfo:
TLineInfo;
numChars:
INTEGER;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
SELF.changed := TRUE;
s := SELF.lineList.Scanner;
IF s.Scan(prevLineInfo) THEN
BEGIN
WHILE s.Scan(lineInfo) DO
BEGIN
{If its already invalid, don't muck with it}
IF prevLineInfo.valid THEN
prevLineInfo.valid := (lineInfo.startLP <= startLP) OR (prevLineInfo.startLP > endLP);
prevLineInfo := lineInfo;
END;
{last line}
IF prevLineInfo.valid THEN
BEGIN
numChars := SELF.paragraph.size;
prevLineInfo.valid := (numChars < startLP) OR (prevLineInfo.startLP > endLP);
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtWrm}

Apple Lisa ToolKit 3.0 Source Code Listing -- 804 of 1012

Apple Lisa Computer Technical Information


001916
001917
001918
001919
001920
001921
001922
001923
001924
001925
001926
001927
001928
001929
001930
001931
001932
001933
001934
001935
001936
001937
001938
001939
001940
001941
001942
001943
001944
001945
001946
001947
001948
001949
001950
001951
001952
001953
001954
001955
001956
001957
001958
001959
001960
001961
001962
001963

PROCEDURE TParaImage.LineWithLPt(pt: LPoint; VAR lineIndex: INTEGER; VAR lineInfo: TLineInfo);


VAR s:
TListScanner;
nxtLnInfo: TLineInfo;
BEGIN
{$IFC fTrace}BP(8);{$ENDC}
{$IFC fParaTrace}
IF fParaTrace THEN
writeln('in LineWithLPt, point=(,',pt.h:1,', ',pt.v:1,')');
{$ENDC}
s := SELF.lineList.scanner; {&&& maybe could use TList.scannerFrom(index)}
lineIndex := 1;
{This has been modified to allow for the possibility of multiple lineRects at the same
vertical coordinate }
IF s.Scan(lineInfo) THEN
WHILE s.scan(nxtLnInfo) DO
BEGIN
IF (pt.v < lineInfo.lineLRect.bottom) AND
((pt.h < lineInfo.lineLRect.right) OR (pt.v < nxtLnInfo.lineLRect.top)) THEN
s.Done
ELSE
BEGIN
lineIndex := lineIndex + 1;
lineInfo := nxtLnInfo;
END;
END
ELSE
BEGIN
{$IFC fParaTrace}
IF fParaTrace THEN
writeln(chr(7), 'LineWithLPt: no TLineInfo in TParaImage, lineIndex=0');
{$ENDC}
lineIndex := 1;
lineInfo := SELF.DfltLineInfo(0, 0);
SELF.lineList.InsLast(lineInfo);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TParaImage.LocateLP(LP: INTEGER; VAR lineIndex: INTEGER; VAR pixel: LONGINT);
VAR s:
TListScanner;
lstLnInfo: TLineInfo;
lineInfo:
TLineInfo;
BEGIN
{$IFC fTrace}BP(8);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 805 of 1012

Apple Lisa Computer Technical Information


001964
001965
001966
001967
001968
001969
001970
001971
001972
001973
001974
001975
001976
001977
001978
001979
001980
001981
001982
001983
001984
001985
001986
001987
001988
001989
001990
001991
001992
001993
001994
001995
001996
001997
001998
001999
002000
002001
002002
002003
002004
002005
002006
002007
002008
002009
002010
002011

IF LP < 0 THEN
LP := 0;
s := SELF.lineList.Scanner;
lineIndex := 0;
WHILE s.Scan(lineInfo) DO
BEGIN
IF LP < lineInfo.startLP THEN
s.Done
ELSE
BEGIN
lineIndex := lineIndex + 1;
lstLnInfo := lineInfo;
END;
END;
IF lineIndex=0 THEN
BEGIN
{$IFC fParaTrace}
IF fParaTrace THEN
writeln(chr(7), 'LocateLP: no TLineInfo in TParaImage, lineIndex=0');
{$ENDC}
lineIndex := 1;
lineInfo := SELF.DfltLineInfo(0, 0);
pixel := lineInfo.lineLRect.left - 1;
{ leave 1 pixel space before character }
SELF.lineList.InsLast(lineInfo);
END
ELSE
BEGIN
pixel := lstLnInfo.lineLRect.left + SELF.ParaTextWidth(lstLnInfo.startLP, LP-1) - 1;
{ leave 1 pixel space before character }
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
FUNCTION TParaImage.LpWithLPt(pt: LPoint): INTEGER;
VAR lineIndex: INTEGER;
lineInfo:
TLineInfo;
endLP:
INTEGER;
lineLen:
INTEGER;
charWid:
INTEGER;
paragraph: TEditPara;
wrapMargin: INTEGER;
lastLP:
INTEGER;
PROCEDURE DrawLine(obj: TObject); {This routine gets filtered after a type style change}
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 806 of 1012

Apple Lisa Computer Technical Information


002012
002013
002014
002015
002016
002017
002018
002019
002020
002021
002022
002023
002024
002025
002026
002027
002028
002029
002030
002031
002032
002033
002034
002035
002036
002037
002038
002039
002040
002041
002042
002043
002044
002045
002046
002047
002048
002049
002050
002051
002052
002053
002054
002055
002056
002057
002058
002059

SELF.DrawLine(lineInfo.startLP, FALSE, pt.h-lineInfo.lineLRect.left, wrapMargin,


lineLen, lastLP, endLP);
END;
BEGIN
{$IFC fTrace}BP(8);{$ENDC}
SELF.LineWithLPt(pt, lineIndex, lineInfo);
IF pt.v < lineInfo.lineLRect.top THEN
pt := lineInfo.lineLRect.topLeft
ELSE IF pt.v > lineInfo.lineLRect.bottom THEN
pt := lineInfo.lineLRect.botRight
ELSE
LRectHaveLPt(lineInfo.lineLRect, pt);
paragraph := SELF.paragraph;
wrapMargin := lengthLRect(SELF.extentLRect, h);
SELF.FilterAndDo(SELF, DrawLine);
{ endLP is now the LP of the character before the character the cursor was over}
lineLen := lineLen + lineInfo.lineLRect.left;
{ lineLen is now the x-coord of screen position of endLP (right pixel) }
endLP := MIN(endLP+1, paragraph.size);
charWid := SELF.paraTextWidth(endLP, endLP);
{ find width of the char under cursor }
{$IFC fParaTrace}
IF fParaTrace THEN
writeln('LpWithLPt: endLP=', endLP:1, ' pt.h=', pt.h:1, ' lineLen=', lineLen:1,
' charWid=', charWid:1);
{$ENDC}
IF 2*(pt.h-lineLen) >= charWid THEN { pt is right of center of char }
LpWithLPt := paragraph.fixLP(endLP+1)
ELSE
{ pt is left of center of char }
LpWithLPt := paragraph.fixLP(endLP);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TParaImage.OffsetBy(deltaLPt: LPoint);
VAR s:
TListScanner;
lineInfo:
TLineInfo;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
{&&& should make sure the results falls within view}
WITH deltaLPt DO
BEGIN
{$H-}
OffsetLRect(SELF.extentLRect, h, v);
{$H+}
s := SELF.lineList.Scanner;

Apple Lisa ToolKit 3.0 Source Code Listing -- 807 of 1012

Apple Lisa Computer Technical Information


002060
002061
002062
002063
002064
002065
002066
002067
002068
002069
002070
002071
002072
002073
002074
002075
002076
002077
002078
002079
002080
002081
002082
002083
002084
002085
002086
002087
002088
002089
002090
002091
002092
002093
002094
002095
002096
002097
002098
002099
002100
002101
002102
002103
002104
002105
002106
002107

WHILE s.Scan(lineInfo) DO
{$H-}
OffsetLRect(lineInfo.lineLRect, h, v);
END;
{$IFC fTrace}EP;{$ENDC}
END;

{$H+}

{$S SgTxtHot}
{Returns width of characters in range startLP, endLP. (NOTE: startLP=endLP for width of one char)}
FUNCTION TParaImage.ParaTextWidth(startLP, endLP: INTEGER): INTEGER;
VAR styleIndex:
INTEGER;
width:
INTEGER;
PROCEDURE FastDraw(obj: TObject); {This routine gets filtered after a type style change}
BEGIN
SELF.FastDrawLine(startLP, endLP, FALSE, TRUE, width, styleIndex);
END;
BEGIN
{$IFC fTrace}BP(8);{$ENDC}
styleIndex := 1;
IF endLP < startLP THEN
width := 0
ELSE
SELF.FilterAndDo(SELF, FastDraw);
ParaTextWidth := width;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TParaImage.RedrawLines(startLine: INTEGER; endLine: INTEGER);
VAR s:
TListScanner;
i:
INTEGER;
lineInfo:
TLineInfo;
prevLineInfo:
TLineInfo;
styleIndex:
INTEGER;
dummy:
INTEGER;
PROCEDURE FastDraw(obj: TObject); {This routine gets filtered after a type style change}
BEGIN
SELF.FastDrawLine(lineInfo.startLP, lineInfo.lastDrawnLP, TRUE,
FALSE, dummy, styleIndex);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
PicGrpBegin;
s := SELF.lineList.Scanner;
i := 0;
endLine := Min(endLine, SELF.lineList.Size);
startLine := Max(startLine, 1);

Apple Lisa ToolKit 3.0 Source Code Listing -- 808 of 1012

Apple Lisa Computer Technical Information


002108
002109
002110
002111
002112
002113
002114
002115
002116
002117
002118
002119
002120
002121
002122
002123
002124
002125
002126
002127
002128
002129
002130
002131
002132
002133
002134
002135
002136
002137
002138
002139
002140
002141
002142
002143
002144
002145
002146
002147
002148
002149
002150
002151

styleIndex := 1;
WHILE s.scan(lineInfo) DO
BEGIN
i := i+1;
IF i < startLine THEN {nothing}
ELSE
BEGIN
IF LRectIsVisible(lineInfo.lineLRect) THEN
BEGIN
{$IFC fParaTrace}
IF fParaTrace THEN
writeln('## ReDrawLines: About to call FastDraw; i=', i:1);
{$ENDC}
MoveToL(lineInfo.lineLRect.left, lineInfo.lineLRect.top+lineInfo.lineAscent);
SELF.FilterAndDo(SELF, FastDraw);
END;
IF i = endLine THEN
s.Done;
END;
END;
PicGrpEnd;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
FUNCTION TParaImage.SeesSameAs(image: TImage): BOOLEAN;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF SELF = image THEN
SeesSameAs := TRUE
ELSE IF NOT InClass(image, TParaImage) THEN
SeesSameAs := FALSE
ELSE
SeesSameAs := SELF.paragraph = TParaImage(image).paragraph;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
END;
{$S SgTxtIni}

End of File -- Lines: 2151 Characters: 71585

Apple Lisa ToolKit 3.0 Source Code Listing -- 809 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UTEXT3.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{UText3}
{TStyleSheet, TText, TTextImage, TTextView, TTextWriteUnivText}
{changed
{changed
{changed
{changed
{changed
{changed

05/11/84
04/26/84
04/25/84
04/25/84
04/24/84
04/20/84

1135
1308
1250
1135
1637
1102

{changed 04/17/84 1349


{changed
{changed
{changed
{changed
{changed

04/17/84
04/16/84
04/16/84
04/16/84
04/13/84

1110
1539
1446
1015
1818

{changed
{changed
{changed
{changed

04/13/84
04/13/84
04/10/84
04/09/84

1537
0209
1400
1337

Changed TTextImage.InvalAll to call panel.InvalLRect}


Changed TTextWriteUnivText.FillRun to TTextWriteUnivText.FillParagraph}
Changed FilterAndDo calls back to filtering TParaImage for Compugraphic}
Do same for TText.MarkChanged as for HiliteParagraphs below}
Make TText.HiliteParagraphs use selection's textImage to call HiliteText}
Modified TTextImage.ImageWith so that if it finds an image whose endLP equals
the passed lp then it may continue the scan, favoring the paraImage whose
textImage equals SELF}
Erase/Invalidate bottom of textImage BEFORE calling nextTxtImg.RecomputeImages;
Fix boundary condition bug in TTextImage.RecomputeImages}
Numerous additional explicit deletions of paraImages from paragraph.images}
Set last parameter in NewView call in TTextView.CREATE to FALSE}
Put picture comments in TTextImage.Draw}
Explicitly delete paraImages from paragraph.images in TTextImage.RecomputeImages}
Removed test to see if any paraImages in first textImage in TText.HiliteText and
TText.MarkChanged}
Changed calls to FilterAndDo to pass TEditPara rather than TParaImage}
Added TTextImage.NewEditPara}
Changed references to TEditPara.images in DelPara, DelImagesWith, and ImageWith}
Use deferUpdate in DrawOrInval and Recompute to decide if we should draw now}

{$S SgTxtHot}
METHODS OF TStyleSheet;
{$S SgTxtIni}
FUNCTION TStyleSheet.CREATE(object: TObject; heap: THeap): TStyleSheet;
VAR aList: TList;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TStyleSheet(object);
aList := TList.CREATE(NIL, heap, 0);
SELF.formats := aList;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}

Apple Lisa ToolKit 3.0 Source Code Listing -- 810 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

PROCEDURE TStyleSheet.Free;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
Free(SELF.formats);
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
PROCEDURE TStyleSheet.InitDefault;
VAR paraFormat: TParaFormat;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
paraFormat := TParaFormat.CREATE(NIL, SELF.Heap, SELF);
SELF.formats.InsLast(paraFormat);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{$IFC fTextTrace}
PROCEDURE TStyleSheet.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('formats: TList');
Field('');
END;
{$ENDC}
{$S SgTxtIni}
END; {Methods of TStyleSheet}
METHODS OF TTextRange;
{$S SgTxtHot}
FUNCTION TTextRange.CREATE(object: TObject; heap: THeap;
beginPara: TEditPara; beginIndex: LONGINT; beginLP: INTEGER;
endPara: TEditPara; endIndex: LONGINT; endLP: INTEGER): TTextRange;
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TTextRange(object);
WITH SELF DO
BEGIN
firstPara := beginPara;

Apple Lisa ToolKit 3.0 Source Code Listing -- 811 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

firstIndex := beginIndex;
firstLP := beginLP;
lastPara := endPara;
lastIndex := endIndex;
lastLP := endLP;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{$IFC fTextTrace}
PROCEDURE TTextRange.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('firstPara: TEditPara');
Field('firstIndex: LONGINT');
Field('firstLP: INTEGER');
Field('lastPara: TEditPara');
Field('lastIndex: LONGINT');
Field('lastLP: INTEGER');
Field('');
END;
{$ENDC}
{$S SgTxtCld}
PROCEDURE TTextRange.AdjustBy(delta: INTEGER);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;

{$S SgTxtIni}
END;
METHODS OF TText;
{$S SgTxtIni}
FUNCTION TText.CREATE(object: TObject; heap: THeap; itsStyleSheet: TStyleSheet): TText;
VAR aList:
TList;
anotherList:
TList;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);

Apple Lisa ToolKit 3.0 Source Code Listing -- 812 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

SELF := TText(object);
aList := TList.CREATE(NIL, heap, 0);
anotherList := TList.CREATE(NIL, heap, 0);
WITH SELF DO
BEGIN
paragraphs := aList;
txtImgList := anotherList;
styleSheet := itsStyleSheet;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TText.Free;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.FreeSelf(TRUE);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{$IFC fTextTrace}
PROCEDURE TText.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('paragraphs: TList');
Field('styleSheet: TStyleSheet');
Field('txtImgList: TList');
Field('');
END;
{$ENDC}
{$S SgTxtCld}
PROCEDURE TText.FreeSelf(freeParas: BOOLEAN);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.txtImgList.Free;
IF freeParas THEN
Free(SELF.paragraphs)
{Free the paragraphs}
ELSE IF SELF.paragraphs <> NIL THEN
{ OR }
SELF.paragraphs.FreeObject;
{Just Free the list}
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 813 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

{$S SgTxtWrm}
PROCEDURE TText.ChangeSelInOtherPanels(textSelection: TTextSelection);
PROCEDURE ChngPanelSel(obj: TObject);
VAR textImage: TTextImage;
selection: TSelection;
panel:
TPanel;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
textImage := TTextImage(obj);
panel := textImage.view.panel;
selection := panel.selection;
{We only unhighlight and replace the last non-NIL coSelection. In most cases, where
there is no coSelection, we unhighlight and replace the panel selection and
everything is hunky-dory}
WHILE selection.coSelection <> NIL DO
selection := selection.coSelection;
{Don't change selection in same panel}
IF selection.panel <> textSelection.panel THEN
selection := selection.FreedAndReplacedBy(textSelection.ReplicateForOtherPanel(textImage));
{$IFC fTrace}EP;{$ENDC}
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF SELF.txtImgList.size > 1 THEN
SELF.txtImgList.Each(ChngPanelSel);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TText.DelPara(delPara: TEditPara;
VAR (*
i:
INTEGER;
numImages: INTEGER;
*)
s:
TListScanner;
paraImage: TParaImage;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
(*
numImages := delPara.NumImages;
FOR i := 1 TO numImages DO
*)
s := delPara.images.Scanner;
WHILE s.Scan(paraImage) DO

fFree: BOOLEAN);

Apple Lisa ToolKit 3.0 Source Code Listing -- 814 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

BEGIN
(*
paraImage := delPara.images[1];
*)
paraImage.textImage.imageList.DelObject(paraImage, FALSE);
s.Delete(FALSE);
paraImage.Free;
END;
{NOTE: We do not delete the paragraph from our own paragraphs list because this is usually
called while scanning that list and we would screw up its scanner if we removed the
paragraph from the list}
IF fFree THEN
delPara.free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TText.Draw;
PROCEDURE DrawInImage(obj: TObject);
VAR textImage: TTextImage;
PROCEDURE DrawOnPad;
BEGIN
textImage.Draw;
END;
BEGIN
textImage := TTextImage(obj);
textImage.view.panel.OnAllPadsDo(DrawOnPad)
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.txtImgList.Each(DrawInImage);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TText.HiliteRange(highTransit: THighTransit; textRange: TTextRange; wholePara: BOOLEAN);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
WITH textRange DO
{$H-}
SELF.HiliteParagraphs(highTransit, firstIndex, firstLP, lastIndex, lastLP, wholePara);
{$H+}
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 815 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

{$S SgTxtHot}
{ TText.HiliteParagraphs tells each text image to hilite its panel's text selection on each pad. It
calls TTextImage.HiliteText which assumes we are already focussed on a pad }
PROCEDURE TText.HiliteParagraphs(highTransit: THighTransit;
startIndex: LONGINT; startLP: INTEGER;
endIndex: LONGINT; endLP: INTEGER; wholePara: BOOLEAN);
PROCEDURE HiliteInImage(obj: TObject);
VAR selection: TSelection;
textImage: TTextImage;
PROCEDURE HiliteOnPad;
BEGIN
textImage.HiliteText(highTransit, startIndex, startLP, endIndex, endLP, wholePara);
END;
BEGIN
selection := TTextImage(obj).view.panel.selection;
WHILE selection.coSelection <> NIL DO
selection := selection.coSelection;
textImage := TTextSelection(selection).textImage;
textImage.view.panel.OnAllPadsDo(HiliteOnPad);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.txtImgList.Each(HiliteInImage);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
FUNCTION TText.DfltTextImage(view: TView; imageLRect: LRect; imgIsGrowable: BOOLEAN): TTextImage;
VAR textImage: TTextImage;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
textImage := TTextImage.CREATE(NIL, SELF.Heap, view, imageLRect, SELF, imgIsGrowable);
SELF.txtImgList.InsLast(textImage);
SELF.paragraphs.InsLast(textImage.NewEditPara(0, TParaFormat(SELF.styleSheet.formats.First)));
SELF.RecomputeImages;
DfltTextImage := textImage;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TText.InsParaAfter(existingPara: TEditPara;

newPara: TEditPara);

PROCEDURE InsertPara(obj: TObject);


BEGIN
TTextImage(obj).InsertNewPara(existingPara, newPara);

Apple Lisa ToolKit 3.0 Source Code Listing -- 816 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.txtImgList.Each(InsertPara);
SELF.paragraphs.InsAt(SELF.paragraphs.Pos(0, existingPara) + 1, newPara);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TText.Invalidate;
PROCEDURE InvalInImage(obj: TObject);
VAR textImage: TTextImage;
PROCEDURE InvalOnPad;
BEGIN
textImage.Invalidate;
END;
BEGIN
textImage := TTextImage(obj);
IF textImage.imageList.Size > 0 THEN
textImage.view.panel.OnAllPadsDo(InvalOnPad);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.txtImgList.Each(InvalInImage);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TText.MarkChanged(textRange: TTextRange);
PROCEDURE Mark(obj: TObject);
VAR textImage: TTextImage;
selection: TSelection;
BEGIN
selection := TTextImage(obj).view.panel.selection;
WHILE selection.coSelection <> NIL DO
selection := selection.coSelection;
textImage := TTextSelection(selection).textImage;
WITH textRange DO
{$H-}
textImage.MarkChanged(firstIndex, firstLP, lastIndex, lastLP);
{$H+}
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 817 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

SELF.txtImgList.Each(Mark);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TText.RecomputeImages;
PROCEDURE ReImage(obj: TObject);
VAR textImage: TTextImage;
padCount:
INTEGER;
numPads:
INTEGER;
PROCEDURE ImageOnPad;
BEGIN
padCount := padCount+1;
{The first parameter in textImage.RecomputeImages says we want to draw, but it will
call view.OKToDrawIn to be sure its Okay.
The last parameter is TRUE when we are drawing on the last pad. RecomputeImages
and DrawOrInval will then set the valid bits on the images to TRUE}
IF padCount = 1 THEN
textImage.RecomputeImages(actionDraw, (numPads = 1))
ELSE
textImage.DrawOrInval(padCount = numPads);
END;
BEGIN
textImage := TTextImage(obj);
numPads := textImage.view.panel.panes.size;
padCount := 0;
textImage.view.panel.OnAllPadsDo(ImageOnPad);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.txtImgList.Each(ReImage);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtWrm}
FUNCTION TText.SelectAll(textImage: TTextImage): TTextSelection;
VAR lastPara:
TEditPara;
textSelection:
TTextSelection;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
lastPara := TEditPara(SELF.paragraphs.Last);
textSelection := textImage.NewTextSelection(TEditPara(SELF.paragraphs.First), 1, 0,
lastPara, SELF.paragraphs.Size, lastPara.size);
SelectAll := textSelection;
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 818 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

END;
{$S SgTxtIni}
BEGIN
fTextTrace := FALSE;
END; {Methods of TText}
METHODS OF TTextImage;
{$S SgTxtIni}
FUNCTION TTextImage.CREATE(object: TObject; heap: THeap; itsView: TView;
itsLRect: LRect; itsText: TText; isGrowable: BOOLEAN): TTextImage;
VAR imgList:
TList;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TTextImage(TImage.CREATE(object, heap, itsLRect, itsView));
imgList := TList.CREATE(NIL, heap, 0);
WITH SELF DO
BEGIN
text := itsText;
imageList := imgList;
tickCount := 0;
growsDynamically := isGrowable;
minHeight := itsLRect.bottom - itsLRect.top;
formerBottom := itsLRect.top;
updateLRect := zeroLRect;
firstLinePixel := 0;
useFirstPixel := FALSE;
firstIndex := 1;
startLP := 0;
endLP := 0;
{app must set these properly if using multiple linked text images}
prevTxtImg := NIL;
nextTxtImg := NIL;
headTxtImg := SELF;
tailTxtImg := SELF;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{This frees all text images and their paraImages in the text image chain.
It does NOT free any paragraphs, text objects, or paraFormats. Call this only once
for each text image chain (NOT for each text image in the chain}

Apple Lisa ToolKit 3.0 Source Code Listing -- 819 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

PROCEDURE TTextImage.Free;
VAR textImage: TTextImage;
next:
TTextImage;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF SELF.headTxtImg = SELF THEN
{Think about freeing text here if this is its only text image, but beware of circular frees}
BEGIN
textImage := SELF;
WHILE textImage <> NIL DO
BEGIN
textImage.imageList.Free;
next := textImage.nextTxtImg;
textImage.FreeObject;
textImage := next;
END;
END
ELSE
SELF.headTxtImg.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{Frees just one text image in the chain; pays no attention to links}
PROCEDURE TTextImage.FreeOneTextImage;
VAR textImage: TTextImage;
next:
TTextImage;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.imageList.Free;
SELF.FreeObject;
{$IFC fTrace}EP;{$ENDC}
END;

{$S SgTxtCld}
{$IFC fTextTrace}
PROCEDURE TTextImage.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('text: TText');
Field('imageList: TList');
Field('tickCount: INTEGER');
Field('growsDynamically: BOOLEAN');
Field('minHeight: INTEGER');
Field('formerBottom: LONGINT');

Apple Lisa ToolKit 3.0 Source Code Listing -- 820 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

Field('updateLRect: LRect');
Field('firstLinePixel: LONGINT');
Field('useFirstPixel: BOOLEAN');
Field('firstIndex: LONGINT');
Field('startLP: INTEGER');
Field('endLP: INTEGER');
Field('prevTxtImg: TTextImage');
Field('nextTxtImg: TTextImage');
Field('headTxtImg: TTextImage');
Field('tailTxtImg: TTextImage');
Field('');
END;
{$ENDC}
{$S SgTxtCld}
PROCEDURE TTextImage.AddImage(paraImage: TParaImage);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.imageList.InsLast(paraImage);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TTextImage.DelImagesWith(delPara: TEditPara);
VAR (*
i,j:
INTEGER;
numImages: INTEGER;
*)
s:
TListScanner;
paraImage: TParaImage;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
s := delPara.images.Scanner;
WHILE s.Scan(paraImage) DO
IF paraImage.textImage.headTxtImg = SELF.headTxtImg THEN
BEGIN
paraImage.textImage.imageList.DelObject(paraImage, FALSE);
s.Delete(FALSE);
paraImage.Free;
END;
(*
numImages := delPara.NumImages;
j := 1;
FOR i := 1 TO numImages DO
BEGIN
{paraImage.Free calls paragraph.DelImage which shifts rest

Apple Lisa ToolKit 3.0 Source Code Listing -- 821 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

of images left so next image will always be at position j}


paraImage := delPara.images[j];
IF paraImage.textImage.headTxtImg = SELF.headTxtImg THEN
paraImage.textImage.imageList.DelObject(paraImage, TRUE)
ELSE
j := j + 1;
END;

*)
{$IFC fTrace}EP;{$ENDC}
END;

{$S SgTxtWrm}
PROCEDURE TTextImage.Draw;
PROCEDURE ReDraw(obj: TObject);
BEGIN
IF LRectIsVisible(TParaImage(obj).extentLRect) THEN
TParaImage(obj).RedrawLines(0, MAXINT);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
PicGrpBegin;
SELF.imageList.Each(ReDraw);
{Now tell the next textImage in the chain to draw itself}
IF SELF.nextTxtImg <> NIL THEN
SELF.nextTxtImg.Draw;
PicGrpEnd;
{$IFC fTrace}EP;{$ENDC}
END; {Draw}
{$S SgTxtCld}
PROCEDURE TTextImage.DrawImages(fDraw: BOOLEAN);
PROCEDURE ReDraw(obj: TObject);
BEGIN
IF LRectIsVisible(TParaImage(obj).extentLRect) THEN
TParaImage(obj).RedrawLines(0, MAXINT);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.imageList.Each(ReDraw);
{Now tell the next textImage in the chain to draw itself}
IF SELF.nextTxtImg <> NIL THEN
SELF.nextTxtImg.DrawImages(fDraw);
{$IFC fTrace}EP;{$ENDC}
END; {DrawImages}

Apple Lisa ToolKit 3.0 Source Code Listing -- 822 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

{$S SgTxtCld}
PROCEDURE TTextImage.DrawOrInval(invalBits: BOOLEAN);
VAR fDraw:
BOOLEAN;
r:
LRect;
PROCEDURE DrawFiltImage(obj: TObject);
VAR paraImage: TParaImage;
PROCEDURE DrawImage(obj: TObject);
VAR leftPixel: LONGINT;
rightPixel: LONGINT;
styleIndex: INTEGER;
PROCEDURE DrawLine(obj: TObject);
VAR lineInfo:
TLineInfo;
dummy:
INTEGER;
BEGIN
lineInfo := TLineInfo(obj);
IF NOT lineInfo.valid THEN
BEGIN
r := lineInfo.lineLRect;
r.left := lineInfo.leftCoord(leftPixel);
r.right := lineInfo.leftCoord(rightPixel);
IF fDraw THEN
BEGIN
FillLRect(r, lPatWhite);
IF lineInfo.startLP <> lineInfo.lastDrawnLP THEN
BEGIN
MoveToL(lineInfo.lineLRect.left, lineInfo.lineLRect.top+lineInfo.lineAscent);
paraImage.FastDrawLine(lineInfo.startLP, lineInfo.lastDrawnLP, TRUE,
FALSE, dummy, styleIndex);
END;
END
ELSE
thePad.InvalLRect(r);
lineInfo.valid := invalBits;
END;
END;
BEGIN
IF paraImage.wasOffset THEN
BEGIN
{possibly use ScrollRect here later?}
r := paraImage.extentLRect;
InsetLRect(r, -1, 0);
IF fDraw THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 823 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

FillLRect(r, lPatWhite);
paraImage.RedrawLines(0, MAXINT);
END
ELSE
thePad.InvalLRect(r);
paraImage.wasOffset := NOT invalBits;
END
ELSE IF paraImage.changed THEN
BEGIN
leftPixel := paraImage.extentLRect.left-1;
rightPixel := paraImage.extentLRect.right+1;
styleIndex := 1;
paraImage.lineList.Each(DrawLine);
paraImage.changed := NOT invalBits;
END;
END;
BEGIN
paraImage := TParaImage(obj);
SELF.FilterAndDo(paraImage, DrawImage);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
fDraw := SELF.view.OKToDrawIn(SELF.extentLRect) AND NOT deferUpdate;
SELF.imageList.Each(DrawFiltImage);
IF NOT EmptyLRect(SELF.updateLRect) THEN
BEGIN
IF fDraw THEN
FillLRect(SELF.updateLRect, lPatWhite)
ELSE
thePad.InvalLRect(SELF.updateLRect);
IF invalBits THEN
SELF.updateLRect := zeroLRect;
END;
{Now tell the next textImage in the chain to draw itself}
IF SELF.nextTxtImg <> NIL THEN
SELF.nextTxtImg.DrawOrInval(invalBits);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TTextImage.FindParaAndLp(lPt: LPoint; VAR paraImage: TParaImage;
VAR paraIndex: LONGINT; VAR aLP: INTEGER);
VAR distanceDown:
INTEGER;
s:
TListScanner;

Apple Lisa ToolKit 3.0 Source Code Listing -- 824 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

{$IFC fTextTrace}
str:
STR255;
{$ENDC}
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
{It is assumed that the caller of this routine has already determined that lPt is in this
textImage, so we will not check nextTextImg if the image list is exhausted}
distanceDown := SELF.extentLRect.top;
s := SELF.imageList.Scanner;
WHILE s.Scan(paraImage) DO
BEGIN
distanceDown := distanceDown + paraImage.height;
paraIndex := s.Position;
IF lPt.v <= distanceDown THEN
s.Done;
END;
paraIndex := paraIndex + SELF.firstIndex - 1;
IF lPt.v > distanceDown THEN
paraImage := TParaImage(SELF.imageList.Last);
aLP := paraImage.LpWithLPt(lPt);
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
LIntToHex(ORD(paraImage), @str);
writeln('*** End FindParaAndLp: lPt= (',lPt.v:4, ',', lPt.h:4, ');
str, ',', paraIndex:1, ',', aLP:3, ')');
END;
{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;

paraImage, index, lp = (',

{$S SgTxtHot}
FUNCTION TTextImage.FindTextImage(VAR mouseLPt: LPoint; VAR firstTxtImg: TTextImage): TTextImage;
VAR textImage:
TTextImage;
stillLooking:
BOOLEAN;
foundIt:
BOOLEAN;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
{This looks around for a textImage that contains the mouseLPt and has some images. If it
finds a textImage that contains the point but does not have any images, then it
returns the first previous textImage that does have some images and changes mouseLPt to be
the bottom right point of that textImage.

Apple Lisa ToolKit 3.0 Source Code Listing -- 825 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

If it doesn't find any textImages that contain the point it returns the first previous
textImage that does have some images. Also, it returns which of the textImages
(SELF or the found one) that comes first in the textImage chain}
firstTxtImg := SELF;
{Start with most common case and then try others}
IF (SELF.imageList.Size > 0) AND
(LPtInLRect(mouseLPt, SELF.extentLRect) OR SELF.growsDynamically) THEN
FindTextImage := SELF
ELSE
BEGIN
textImage := SELF;
stillLooking := TRUE;
foundIt := FALSE;
WHILE stillLooking DO
BEGIN
{First look in following boxes}
IF LPtInLRect(mouseLPt, textImage.extentLRect) THEN
BEGIN
{if box found but no images in it, then link back}
WHILE (textImage <> textImage.headTxtImg) AND (textImage.imageList.Size = 0) DO
BEGIN
textImage := textImage.prevTxtImg;
mouseLPt := textImage.extentLRect.botRight;
END;
foundIt := TRUE;
stillLooking := FALSE;
END
ELSE IF textImage.nextTxtImg <> NIL THEN
textImage := textImage.nextTxtImg
ELSE stillLooking := FALSE;
END;
IF foundIt THEN
FindTextImage := textImage
ELSE
{Still didn't find it? Look in previous boxes}
BEGIN
stillLooking := TRUE;
WHILE stillLooking DO
BEGIN
IF LPtInLRect(mouseLPt, textImage.extentLRect) THEN
BEGIN
WHILE (textImage <> textImage.headTxtImg) AND (textImage.imageList.Size = 0) DO
BEGIN
textImage := textImage.prevTxtImg;
mouseLPt := textImage.extentLRect.botRight;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 826 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

foundIt := TRUE;
stillLooking := FALSE;
END
ELSE IF textImage.prevTxtImg <> NIL THEN
textImage := textImage.prevTxtImg
ELSE stillLooking := FALSE;
END;
IF foundIt THEN
BEGIN
FindTextImage := textImage;
firstTxtImage := textImage;
END
ELSE
BEGIN
{mouseLPt didn't fall in any of the text images, so return SELF or the first previous
text image that has a paraimage}
textImage := SELF;
WHILE (textImage <> textImage.headTxtImg) AND (textImage.imageList.Size = 0) DO
BEGIN
textImage := textImage.prevTxtImg;
mouseLPt := textImage.extentLRect.botRight;
END;
FindTextImage := textImage;
END;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TTextImage.GetImageRange(firstIndex: LONGINT; VAR firstLP: INTEGER;
lastIndex: LONGINT; VAR lastLP: INTEGER;
VAR firstImage, lastImage: TParaImage);
{Diagram of input vs output:

--- = characters not displayed by this textImage chain;


xxx = characters that are displayed by this textImage chain;

------------xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx---------^
^
^
^
^
^ ^
1
2
3
4
5
6 7
input
1,2
1,3
1,4
1,5

imageWith
N,N
N,3
N,4
N,5

output
N,N
N,3
3,4
3,5

Apple Lisa ToolKit 3.0 Source Code Listing -- 827 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

1,6
3,3
3,4
4,5
4,6
5,5
5,6
6,7

N,N
3,3
3,4
4,5
4,N
5,5
5,N
N,N

3,5
3,3
3,4
4,5
4,5
5,5
5,N
N,N

N = NIL

FUNCTION GetFirstOrLast(index: LONGINT; VAR lp: INTEGER): TParaImage;


VAR paraImage: TParaImage;
lastTxtImg: TTextImage;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF (index < SELF.headTxtImg.firstIndex) OR
((index = SELF.headTxtImg.firstIndex) AND (lp < SELF.headTxtImg.startLP)) THEN
BEGIN
paraImage := TParaImage(SELF.headTxtImg.imageList.First);
lp := paraImage.startLP;
END
ELSE
BEGIN
lastTxtImg := SELF.tailTxtImg;
WHILE lastTxtImg.imageList.Size <= 0 DO
lastTxtImg := lastTxtImg.prevTxtImg;
paraImage := TParaImage(lastTxtImg.imageList.Last);
lp := paraImage.endLP;
END;
GetFirstOrLast := paraImage;
{$IFC fTrace}EP;{$ENDC}
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
firstImage := SELF.ImageWith(TEditPara(SELF.text.paragraphs.At(firstIndex)), firstLP);
lastImage := SELF.ImageWith(TEditPara(SELF.text.paragraphs.At(lastIndex)), lastLP);
IF (firstImage = NIL) OR (lastImage = NIL) THEN
BEGIN
IF firstImage = NIL THEN
IF lastImage <> NIL THEN
BEGIN
firstImage := GetFirstOrLast(firstIndex, firstLP);
IF (firstImage = lastImage) THEN
IF (firstLP = lastLP) THEN
firstImage := NIL;
END
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 828 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

BEGIN
firstImage := GetFirstOrLast(firstIndex, firstLP);
lastImage := GetFirstOrLast(lastIndex, lastLP);
IF (firstImage = lastImage) AND (firstLP = lastLP) THEN
BEGIN
firstImage := NIL;
lastImage := NIL;
END;
END

ELSE
BEGIN
lastImage := GetFirstOrLast(lastIndex, lastLP);
IF (firstImage = lastImage) THEN
IF (firstLP = lastLP) THEN
lastImage := NIL;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;

{$S SgTxtHot}
PROCEDURE TTextImage.HiliteText(highTransit: THighTransit;
startIndex: LONGINT; startLP: INTEGER;
endIndex: LONGINT; endLP: INTEGER; wholePara: BOOLEAN);
LABEL 1;
VAR startImage:
TParaImage;
endImage:
TParaImage;
r:
LRect;
lineInfo:
TLineInfo;
paraImage:
TParaImage;
sImg, sViewSt: TListScanner;
startLine:
INTEGER;
endLine:
INTEGER;
startPixel:
LONGINT;
endPixel:
LONGINT;
lMargPixel:
LONGINT;
rMargPixel:
LONGINT;
i:
INTEGER;
textImage:
TTextImage;
stillOkay:
BOOLEAN;
{$IFC fTextTrace}
str1:
STR255;
{for debug output}
str2:
STR255;
{for debug output}
{$ENDC}
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
{$IFC fTextTrace}

Apple Lisa ToolKit 3.0 Source Code Listing -- 829 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

IF fTextTrace THEN
BEGIN
Writeln('*** In HiliteText:

[(', startIndex:1, ',', startLP:1, ') , (',


endIndex:1, ',', endLP:1,
')]; highTransit = ', ORD(highTransit):2);
LIntToHex(ORD(SELF), @str1);
WriteLn('*** SELF = ', str1, ' SELF.endLP=', SELF.endLP:1);
END;
{$ENDC}
IF (startIndex = endIndex) AND (startLP = endLP) THEN
BEGIN
startImage := SELF.ImageWith(TEditPara(SELF.text.paragraphs.At(startIndex)), startLP);
endImage := startImage;
stillOkay := startImage <> NIL;
END
ELSE
BEGIN
SELF.GetImageRange(startIndex, startLP, endIndex, endLP, startImage, endImage);
stillOkay := (startImage <> NIL) AND (endImage <> NIL);
END;
IF stillOkay THEN
BEGIN
textImage := startImage.textImage;
lMargPixel := textImage.extentLRect.left - 1;
rMargPixel := textImage.extentLRect.right + 1;
IF highTransit = hDimToOn THEN
BEGIN
SELF.HiliteText(hDimToOff, startIndex, startLP, endIndex, endLP, wholePara);
highTransit := hOffToOn;
END
ELSE IF highTransit = hOffToDim THEN
BEGIN
SELF.HiliteText(hOffToOn, startIndex, startLP, endIndex, endLP, wholePara);
highTransit := hOnToDim;
END;
IF highTransit <> hNone THEN
BEGIN
SetPenState(highPen[highTransit]);
IF highTransit = hOnToDim THEN
PenMode(notPatBic); { hOnToDim

=> change background from black to gray }

sImg := textImage.imageList.Scanner;
WHILE sImg.Scan(paraImage) DO

Apple Lisa ToolKit 3.0 Source Code Listing -- 830 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

IF paraImage = startImage THEN


GOTO 1;
1:
paraImage.LocateLP(startLP, startLine, startPixel);
sViewSt := paraImage.lineList.Scanner;
i := 0;
REPEAT
IF sViewSt.Scan(lineInfo) THEN
i := i+1;
UNTIL i = startLine;
r := lineInfo.lineLRect;
IF wholePara THEN
r.left := lineInfo.LeftCoord(lMargPixel)
ELSE
r.left := startPixel;
r.right := lineInfo.RightCoord(rMargPixel);
WHILE paraImage <> endImage DO
BEGIN
WHILE sViewSt.Scan(lineInfo) DO
BEGIN
PaintLRect(r);
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
WriteLn('*** Within HiliteText: about to paintLRect: [(', r.left:1, ',',
r.top:1,'),(', r.left:1,',',r.right:1,')]' );
LIntToHex(ORD(paraImage), @str1);
WriteLn('*** current paraImage=',str1);
END;
{$ENDC}
r := lineInfo.lineLRect;
r.left := lineInfo.LeftCoord(lMargPixel);
r.right := lineInfo.RightCoord(rMargPixel);
END;
IF sImg.Scan(paraImage) THEN
sViewSt := paraImage.lineList.Scanner
ELSE
BEGIN
textImage := textImage.nextTxtImage;
lMargPixel := textImage.extentLRect.left-1;
rMargPixel := textImage.extentLRect.right+1;
sImg := textImage.imageList.Scanner;
IF sImg.Scan(paraImage) THEN
sViewSt := paraImage.lineList.Scanner;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 831 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

END;
paraImage.LocateLP(endLP, endLine, endPixel);
IF startImage <> endImage THEN
BEGIN
PaintLRect(r);
sViewSt := paraImage.lineList.Scanner;
IF sViewSt.Scan(lineInfo) THEN
BEGIN
r := lineInfo.lineLRect;
r.left := lineInfo.LeftCoord(lMargPixel);
r.right := lineInfo.RightCoord(rMargPixel);
END;
i := 1;
END;
WHILE i <> endLine DO
BEGIN
PaintLRect(r);
IF sViewSt.Scan(lineInfo) THEN
BEGIN
r := lineInfo.lineLRect;
r.left := lineInfo.LeftCoord(lMargPixel);
r.right := lineInfo.RightCoord(rMargPixel);
END;
i := i+1;
END;
IF wholePara THEN
r.right := lineInfo.RightCoord(rMargPixel)
ELSE
BEGIN
r.right := endPixel;
{Add extra pixel if this is insertion point}
IF (startImage = endImage) AND (startLP = endLP) THEN
r.right := r.right + 1;
END;
PaintLRect(r);
Free(sViewSt);
Free(sImg);
IF highTransit = hDimToOff THEN { XORing out gray leaves holes in chars }
BEGIN
{later, we'll minimize this, if necessary}
SELF.Draw;
{ so redraw characters }
END;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 832 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

END
ELSE
BEGIN
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
Writeln('*** In HiliteText:
END;
{$ENDC}
END;
{$IFC fTrace}EP;{$ENDC}
END; {HiliteText}

Images NIL (DID NOT HILITE))');

{$S SgTxtHot}
{Given a paragraph and lp finds the paraImage that displays it in this textImage chain.
Returns NIL if not found.}
FUNCTION TTextImage.ImageWith(paragraph: TEditPara; lp: INTEGER): TParaImage;
VAR paraImage:
TParaImage;
altParaImage:
TParaImage;
s:
TListScanner;
(*
i:
INTEGER;
*)
{$IFC fTextTrace}
str:
STR255;
{$ENDC}
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
LIntToHex(ORD(paragraph), @str);
WriteLn('$$$ In ImageWith: paragraph,lp = (',str, ',', lp:1, ')' );
END;
{$ENDC}
altParaImage := NIL;
s := paragraph.images.Scanner;
WHILE s.Scan(paraImage) DO
IF ((paraImage.textImage.headTxtImg = SELF.headTxtImg) AND
(paraImage.startLP <= lp) AND
(lp <= paraImage.endLP)) THEN
IF lp = paraImage.endLP THEN
IF paraImage.textImage <> SELF THEN
altParaImage := paraImage
ELSE
s.Done

Apple Lisa ToolKit 3.0 Source Code Listing -- 833 of 1012

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163
001164
001165
001166
001167
001168
001169
001170
001171
001172
001173
001174
001175
001176
001177
001178
001179
001180
001181
001182
001183
001184
001185
001186
001187
001188
001189
001190
001191
001192
001193
001194
001195

ELSE
s.Done;
IF paraImage = NIL THEN
paraImage := altParaImage;
(*
i := 1;
WITH paragraph DO
{$R-}
WHILE (i <= numImages) DO
IF ((images[i].textImage.headTxtImg = SELF.headTxtImg) AND
(images[i].startLP <= lp) AND
(lp <= images[i].endLP)) THEN
BEGIN
paraImage := images[i];
i := MAXINT;
END
ELSE
i := i + 1;
{$IFC fRngText}{$R+}{$ENDC}
*)
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
LIntToHex(ORD(paraImage), @str);
WriteLn('$$$ In ImageWith: paraImage found= ',str);
END;
{$ENDC}
ImageWith := paraImage;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
FUNCTION TTextImage.ImageBottom: LONGINT;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
IF SELF.imageList.Size > 0 THEN
ImageBottom := TParaImage(SELF.imageList.Last).extentLRect.bottom
ELSE
ImageBottom := SELF.extentLRect.top;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}

Apple Lisa ToolKit 3.0 Source Code Listing -- 834 of 1012

Apple Lisa Computer Technical Information


001196
001197
001198
001199
001200
001201
001202
001203
001204
001205
001206
001207
001208
001209
001210
001211
001212
001213
001214
001215
001216
001217
001218
001219
001220
001221
001222
001223
001224
001225
001226
001227
001228
001229
001230
001231
001232
001233
001234
001235
001236
001237
001238
001239
001240
001241
001242
001243

PROCEDURE TTextImage.InsertNewPara(existingPara, newPara: TEditPara);


VAR paraImage:
TParaImage;
lastImage:
TParaImage;
newParaImage:
TParaImage;
textImage:
TTextImage;
{$IFC fTextTrace}
str:
STR255;
{$ENDC}
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
{Try to find the image with the proper lp, but, failing that, see if there is any image that
points to existingPara}
paraImage := SELF.ImageWith(existingPara, existingPara.size - 1);
IF paraImage = NIL THEN
paraImage := SELF.ImageWith(existingPara, 0);
IF paraImage = NIL THEN
BEGIN
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
LIntToHex(ORD(existingPara), @str);
WriteLn('@@@ In InsertNewPara: existingPara = (',str,')' );
WriteLn('@@@
ImageWith returned NIL!!');
END;
{$ENDC}
END
ELSE
BEGIN
textImage := paraImage.textImage;
lastImage := TParaImage(textImage.imageList.Last);
newParaImage := textImage.NewParaImage(newPara, paraImage.extentLRect, 0, 0);
textImage.imageList.InsAt(textImage.imageList.Pos(0, paraImage) + 1, newParaImage);
{If we inserted the new paraImage at the end of the current image list and if the
last paragraph was previously split between two or more paraImages, then set the paragraph
field in the first image of the next text image to the new paragraph, and adjust the
paragraphs' images accordingly}
IF (paraImage = lastImage) THEN
BEGIN
textImage := paraImage.textImage.nextTxtImg;
WHILE (textImage <> NIL) DO
IF textImage.imageList.Size > 0 THEN
BEGIN
paraImage := TParaImage(textImage.imageList.First);
IF paraImage.paragraph = lastImage.paragraph THEN
BEGIN
paraImage.paragraph := newPara;
newPara.InsImage(paraImage);
{|}

Apple Lisa ToolKit 3.0 Source Code Listing -- 835 of 1012

Apple Lisa Computer Technical Information


001244
001245
001246
001247
001248
001249
001250
001251
001252
001253
001254
001255
001256
001257
001258
001259
001260
001261
001262
001263
001264
001265
001266
001267
001268
001269
001270
001271
001272
001273
001274
001275
001276
001277
001278
001279
001280
001281
001282
001283
001284
001285
001286
001287
001288
001289
001290
001291

lastImage.paragraph.DelImage(paraImage, FALSE); {|}


textImage := textImage.nextTxtImg;
END
ELSE
textImage := NIL
END
ELSE
textImage := NIL
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TTextImage.InvalAll;
VAR r:
LRect;
textImage: TTextImage;
PROCEDURE Inval(obj: TObject);
BEGIN
TParaImage(obj).InvalLinesWith(0, MAXINT);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
textImage := SELF.headTxtImg;
WHILE textImage <> NIL DO
BEGIN
textImage.imageList.Each(Inval);
r := textImage.extentLRect;
InsetLRect(r, -1, 0);
SELF.view.panel.InvalLRect(r);
textImage := textImage.nextTxtImg;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TTextImage.Invalidate;
VAR r:
LRect;
s, sLine:
TListScanner;
paraImage: TParaImage;
lineInfo:
TLineInfo;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
s := SELF.imageList.Scanner;
WHILE s.Scan(paraImage) DO

Apple Lisa ToolKit 3.0 Source Code Listing -- 836 of 1012

Apple Lisa Computer Technical Information


001292
001293
001294
001295
001296
001297
001298
001299
001300
001301
001302
001303
001304
001305
001306
001307
001308
001309
001310
001311
001312
001313
001314
001315
001316
001317
001318
001319
001320
001321
001322
001323
001324
001325
001326
001327
001328
001329
001330
001331
001332
001333
001334
001335
001336
001337
001338
001339

IF paraImage.wasOffset THEN
BEGIN
r := paraImage.extentLRect;
InsetLRect(r, -1, 0);
thePad.InvalLRect(r);
paraImage.wasOffset := FALSE;
paraImage.changed := FALSE;
END
ELSE IF paraImage.changed THEN
BEGIN
paraImage.changed := FALSE;
sLine := paraImage.lineList.Scanner;
WHILE sLine.Scan(lineInfo) DO
IF NOT lineInfo.valid THEN
BEGIN
lineInfo.valid := TRUE;
r := lineInfo.lineLRect;
r.left := paraImage.extentLRect.left;
r.right := paraImage.extentLRect.right;
InsetLRect(r, -1, 0);
thePad.InvalLRect(r);
END;
END;
IF NOT EmptyLRect(SELF.updateLRect) THEN
BEGIN
thePad.InvalLRect(SELF.updateLRect);
SELF.updateLRect := zeroLRect;
END;
IF SELF.nextTxtImg <> NIL THEN
SELF.nextTxtImg.Invalidate;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TTextImage.MarkChanged(startIndex: LONGINT; startLP: INTEGER;
endIndex: LONGINT; endLP: INTEGER);
VAR sImg:
TListScanner;
firstImage: TParaImage;
lastImage: TParaImage;
paraImage: TParaImage;
found:
BOOLEAN;
finished:
BOOLEAN;
textImage: TTextImage;
tempLP:
INTEGER;
stillOkay: BOOLEAN;

Apple Lisa ToolKit 3.0 Source Code Listing -- 837 of 1012

Apple Lisa Computer Technical Information


001340
001341
001342
001343
001344
001345
001346
001347
001348
001349
001350
001351
001352
001353
001354
001355
001356
001357
001358
001359
001360
001361
001362
001363
001364
001365
001366
001367
001368
001369
001370
001371
001372
001373
001374
001375
001376
001377
001378
001379
001380
001381
001382
001383
001384
001385
001386
001387

BEGIN
{$IFC fTrace}BP(10);{$ENDC}
stillOkay := TRUE;
IF (startIndex = endIndex) AND (startLP = endLP) THEN
BEGIN
firstImage := SELF.ImageWith(TEditPara(SELF.text.paragraphs.At(startIndex)), startLP);
lastImage := firstImage;
stillOkay := firstImage <> NIL;
END
ELSE
BEGIN
SELF.GetImageRange(startIndex, startLP, endIndex, endLP, firstImage, lastImage);
IF firstImage = NIL THEN
IF lastImage = NIL THEN
stillOkay := FALSE
ELSE
BEGIN
firstImage := lastImage;
startLP := endLP;
END
ELSE IF lastImage = NIL THEN
BEGIN
lastImage := firstImage;
endLP := startLP;
END;
END;
IF stillOkay THEN
BEGIN
IF firstImage = lastImage THEN
firstImage.InvalLinesWith(startLP, endLP)
ELSE
BEGIN
textImage := firstImage.textImage;
found := FALSE;
finished := FALSE;
WHILE NOT finished AND (textImage <> NIL) DO
BEGIN
sImg := textImage.imageList.Scanner;
WHILE sImg.Scan(paraImage) DO
BEGIN
found := found OR (paraImage = firstImage);
IF found THEN
BEGIN
IF paraImage = lastImage THEN
BEGIN
tempLP := endLP;
finished := TRUE;

Apple Lisa ToolKit 3.0 Source Code Listing -- 838 of 1012

Apple Lisa Computer Technical Information


001388
001389
001390
001391
001392
001393
001394
001395
001396
001397
001398
001399
001400
001401
001402
001403
001404
001405
001406
001407
001408
001409
001410
001411
001412
001413
001414
001415
001416
001417
001418
001419
001420
001421
001422
001423
001424
001425
001426
001427
001428
001429
001430
001431
001432
001433
001434
001435

sImg.Done;
END
ELSE
tempLP := paraImage.endLP;
paraImage.InvalLinesWith(startLP, tempLP);
startLP := 0;
END;
END;
textImage := textImage.nextTxtImg;
END;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TTextImage.MousePress(mouseLPt: LPoint);
VAR currParaImage: TParaImage;
currLP:
INTEGER;
textImage:
TTextImage;
firstTxtImg:
TTextImage;
selection:
TSelection;
paraIndex:
LONGINT;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
selection := SELF.view.panel.selection;
WHILE selection.coSelection <> NIL DO
selection := selection.coSelection;
IF (clickState.fShift OR (clickState.clickCount > 1)) AND InClass(selection, TTextSelection) THEN
{ let the selection extend itself }
selection.MousePress(mouseLPt)
ELSE
BEGIN
textImage := SELF.FindTextImage(mouseLPt, firstTxtImg);
textImage.FindParaAndLp(mouseLPt, currParaImage, paraIndex, currLP);
{If we are a coSelection then BeginSelection should already have been called when
panel selection was created}
IF SELF.view.panel.selection.coSelection = NIL THEN
SELF.view.panel.BeginSelection
ELSE
selection.Highlight(hOnToOff);
selection := selection.FreedAndReplacedBy(TInsertionPoint.CREATE(NIL,
SELF.Heap, SELF.view, textImage, mouseLPt,
currParaImage.paragraph, paraIndex, currLP));

Apple Lisa ToolKit 3.0 Source Code Listing -- 839 of 1012

Apple Lisa Computer Technical Information


001436
001437
001438
001439
001440
001441
001442
001443
001444
001445
001446
001447
001448
001449
001450
001451
001452
001453
001454
001455
001456
001457
001458
001459
001460
001461
001462
001463
001464
001465
001466
001467
001468
001469
001470
001471
001472
001473
001474
001475
001476
001477
001478
001479
001480
001481
001482
001483

SELF.text.ChangeSelInOtherPanels(TTextSelection(selection));
SELF.text.HiliteParagraphs(hOffToOn, paraIndex, currLP, paraIndex, currLP, FALSE);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
FUNCTION TTextImage.NewEditPara(initialSize: INTEGER; itsFormat: TParaFormat): TEditPara;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
NewEditPara := TEditPara.CREATE(NIL, SELF.Heap, initialSize, itsFormat);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
FUNCTION TTextImage.NewParaImage(itsParagraph: TEditPara; itsLRect: LRect;
lineTop: LONGINT; lineLeft: LONGINT): TParaImage;
VAR paraImage: TParaImage;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
paraImage := TParaImage.CREATE(NIL, SELF.Heap, SELF.view, itsParagraph, itsLRect, lineTop, lineLeft);
paraImage.textImage := SELF;
itsParagraph.InsImage(paraImage);
NewParaImage := paraImage;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
FUNCTION TTextImage.NewTextImage(heap: THeap; itsView: TView; itsLRect: LRect;
itsText:TText; isGrowable: BOOLEAN): TTextImage;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
NewTextImage := TTextImage.CREATE(NIL, heap, itsView, itsLRect, itsText, isGrowable);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
FUNCTION TTextImage.NewTextSelection(firstPara: TEditPara; firstIndex: LONGINT; firstLP: INTEGER;
lastPara: TEditPara; lastIndex: LONGINT; lastLP: INTEGER
): TTextSelection;
VAR textSel:
TTextSelection;
heap:
THeap;
view:
TView;
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 840 of 1012

Apple Lisa Computer Technical Information


001484
001485
001486
001487
001488
001489
001490
001491
001492
001493
001494
001495
001496
001497
001498
001499
001500
001501
001502
001503
001504
001505
001506
001507
001508
001509
001510
001511
001512
001513
001514
001515
001516
001517
001518
001519
001520
001521
001522
001523
001524
001525
001526
001527
001528
001529
001530
001531

{$IFC fTrace}BP(10);{$ENDC}
heap := SELF.Heap;
view := SELF.view;
IF firstPara = lastPara THEN
IF firstLP = lastLP THEN
textSel := TInsertionPoint.CREATE(NIL, heap, view, SELF, zeroLPt,
firstPara, firstIndex, firstLP)
ELSE
textSel := TOneParaSelection.CREATE(NIL, heap, view, SELF, zeroLPt,
firstPara, firstIndex, firstLP, lastLP)
ELSE
textSel := TMultiParaSelection.CREATE(NIL, heap, view, SELF, zeroLPt,
firstPara, firstIndex, firstLP,
lastPara, lastIndex, lastLP, TRUE);
NewTextSelection := textSel;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TTextImage.OffsetBy(deltaLPt: LPoint);
{ Can be used to quickly move a text image }
PROCEDURE OffsetImage(obj: TObject);
BEGIN
TParaImage(obj).OffsetBy(deltaLPt);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
WITH deltaLPt DO
{$H-} OffsetLRect(SELF.extentLRect, h, v); {$H+}
SELF.imageList.Each(OffsetImage);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TTextImage.RecomputeImages(drawAction: TDrawAction; invalBits: BOOLEAN);
LABEL
1;
VAR drawLRect: LRect;
lastLP:
INTEGER;
lastDrawnImage: TParaImage;
nextTxtImg:
TTextImage;
paraImage:
TParaImage;
s:
TListScanner;
tempList:
TList;
beginAtLP:
INTEGER;
returnLRect:
LRect;
lastImage:
TParaImage;

Apple Lisa ToolKit 3.0 Source Code Listing -- 841 of 1012

Apple Lisa Computer Technical Information


001532
001533
001534
001535
001536
001537
001538
001539
001540
001541
001542
001543
001544
001545
001546
001547
001548
001549
001550
001551
001552
001553
001554
001555
001556
001557
001558
001559
001560
001561
001562
001563
001564
001565
001566
001567
001568
001569
001570
001571
001572
001573
001574
001575
001576
001577
001578
001579

firstImage:
TParaImage;
lastOneChanged: BOOLEAN;
deltaLPt:
LPoint;
currParaIndex: LONGINT;
paragraph:
TEditPara;
newBottom:
LONGINT;
realAction:
TDrawAction;
r:
LRect;
{$IFC fTextTrace}
str:
STR255;
{$ENDC}
FUNCTION OnlyPartDrawn(pImage: TParaImage): BOOLEAN;
VAR wontFit:
BOOLEAN;
sLine:
TListScanner;
deleteRest: BOOLEAN;
lineInfo:
TLineInfo;
PROCEDURE DrawPImage(obj: TObject);
VAR action: TDrawAction;
bits:
BOOLEAN;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
bits := invalBits;
action := realAction;
{If the paragraph was offset, we don't want DrawPara to draw the changed lines, so
we display the offset paragraph case below and pass actionNone to DrawPara.
However, we must pass FALSE for invalBits since we still need the wasOffset flag
set for the display code below}
IF pImage.wasOffset THEN
BEGIN
action := actionNone;
bits := FALSE;
END;
pImage.DrawParaImage(drawLRect, beginAtLP, action, bits, returnLRect);
{$IFC fTrace}EP;{$ENDC}
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
wontFit := FALSE;
lastOneChanged := FALSE;
pImage.textImage := SELF;
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
LIntToHex(ORD(pImage), @str);
WriteLn('++ Entering OnlyPartDrawn: pImage =', str);
WriteLn('++
: deltaLPt.v =', deltaLPt.v:1, ' drawLRect.top = ',

Apple Lisa ToolKit 3.0 Source Code Listing -- 842 of 1012

Apple Lisa Computer Technical Information


001580
001581
001582
001583
001584
001585
001586
001587
001588
001589
001590
001591
001592
001593
001594
001595
001596
001597
001598
001599
001600
001601
001602
001603
001604
001605
001606
001607
001608
001609
001610
001611
001612
001613
001614
001615
001616
001617
001618
001619
001620
001621
001622
001623
001624
001625
001626
001627

END;
{$ENDC}

drawLRect.top:1);

{offset pImage before recalculating so that unchanged lineInfo's get offset}


IF drawLRect.top <> pImage.extentLRect.top THEN
BEGIN
deltaLPt.v := drawLRect.top - pImage.extentLRect.top;
pImage.OffsetBy(deltaLPt);
pImage.wasOffset := TRUE;
{so that we know what to redraw/invalidate}
{If we moved the last paraImage up, maybe more will fit, so force call to DrawPara
by setting changed TRUE}
IF (deltaLPt.v < 0) AND (pImage = SELF.imageList.Last) THEN
BEGIN
lastOneChanged := TRUE;
pImage.changed := TRUE;
END;
END;
IF pImage.changed THEN
BEGIN
lastLP := pImage.endLP;
{$IFC fTextTrace}
IF fTextTrace THEN
WriteLn('++ OnlyPartDrawn: pImage changed, about to call DrawPara; old endLP =',
lastLP:1);
{$ENDC}
SELF.FilterAndDo(pImage, DrawPImage);
{$IFC fTextTrace}
IF fTextTrace THEN
WriteLn('++ OnlyPartDrawn: DrawPara just called; pImage.endLP =',
pImage.endLP:1, ' para size = ', pImage.paragraph.size:1);
{$ENDC}
lastOneChanged := lastOneChanged OR (pImage.endLP <> lastLP);
END
ELSE IF deltaLPt.v > 0 THEN
BEGIN
{$IFC fTextTrace}
IF fTextTrace THEN
WriteLn('++ OnlyPartDrawn: pImage.extentLRect.bottom =', pImage.extentLRect.bottom:1,
' drawLRect.bottom = ', drawLRect.bottom:1);
{$ENDC}
wontFit := pImage.extentLRect.bottom > drawLRect.bottom;
IF wontFit THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 843 of 1012

Apple Lisa Computer Technical Information


001628
001629
001630
001631
001632
001633
001634
001635
001636
001637
001638
001639
001640
001641
001642
001643
001644
001645
001646
001647
001648
001649
001650
001651
001652
001653
001654
001655
001656
001657
001658
001659
001660
001661
001662
001663
001664
001665
001666
001667
001668
001669
001670
001671
001672
001673
001674
001675

{Ideally, if textImages are same width, just insert extra lineInfo's


into first paraImage of next textImage; If they are not same width, we
still insert them but mark them invalid. For now just delete them}
lastOneChanged := TRUE;
sLine := pImage.lineList.Scanner;
deleteRest := FALSE;
WHILE sLine.Scan(lineInfo) DO
IF deleteRest THEN
sLine.Delete(TRUE)
ELSE IF lineInfo.lineLRect.bottom > drawLRect.bottom THEN
BEGIN
{If the first lineInfo won't fit then set pImage.endLP to -1, indicating that
none of the paragraph fit}
IF sLine.Position = 1 THEN
BEGIN
sLine.Done;
pImage.endLP := -1;
END
ELSE
BEGIN
pImage.extentLRect.bottom := lineInfo.lineLRect.top;
pImage.endLP := lineInfo.startLP;
sLine.Delete(TRUE);
deleteRest := TRUE;
END;
END;
END;
END;
drawLRect.top := pImage.extentLRect.bottom;
lastLP := pImage.endLP;
wontFit := wontFit OR (pImage.endLP <> pImage.paragraph.size);
IF pImage.wasOffset AND (lastLP >= 0) THEN
BEGIN
r := pImage.extentLRect;
InsetLRect(r, -1, 0);
IF realAction = actionDraw THEN
BEGIN
FillLRect(r, lPatWhite);
pImage.RedrawLines(0, MAXINT);
END
ELSE IF realAction = actionInval THEN
thePad.InvalLRect(r);
pImage.wasOffset := NOT invalBits;
pImage.changed := FALSE;
END;
{after the first paragraph is drawn, reset beginAtLP}

Apple Lisa ToolKit 3.0 Source Code Listing -- 844 of 1012

Apple Lisa Computer Technical Information


001676
001677
001678
001679
001680
001681
001682
001683
001684
001685
001686
001687
001688
001689
001690
001691
001692
001693
001694
001695
001696
001697
001698
001699
001700
001701
001702
001703
001704
001705
001706
001707
001708
001709
001710
001711
001712
001713
001714
001715
001716
001717
001718
001719
001720
001721
001722
001723

beginAtLP := 0;
IF NOT wontFit THEN
currParaIndex := currParaIndex + 1;
{$IFC fTextTrace}
IF fTextTrace THEN
WriteLn('++ EXITING OnlyPartDrawn: deltaLPt.v =', deltaLPt.v:1, '
{$ENDC}

wontFit = ', wontFit);

{return TRUE when a paragraph does not get completely displayed}


OnlyPartDrawn := wontFit;
{$IFC fTrace}EP;{$ENDC}
END;
BEGIN {RecomputeIMages}
{$IFC fTrace}BP(10);{$ENDC}
IF SELF = SELF.headTxtImg THEN
SELF.SetFirstIndex;
currParaIndex := SELF.firstIndex;
drawLRect := SELF.extentLRect;
IF SELF.growsDynamically THEN
drawLRect.bottom := SELF.view.extentLRect.bottom;
realAction := drawAction;
IF drawAction = actionDraw THEN
IF NOT SELF.view.OKToDrawIn(drawLRect) OR deferUpdate THEN
realAction := actionInval;
beginAtLP := SELF.startLP;
deltaLPt := zeroLPt;
{Recompute paragraphs until we reach the end of our imageList or no more will fit}
{Use GOTO so we can hold on to the scanner if needed}
s := SELF.imageList.Scanner;
WHILE s.Scan(lastDrawnImage) DO
IF OnlyPartDrawn(lastDrawnImage) THEN
GOTO 1;
1:
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
LIntToHex(ORD(lastDrawnImage), @str);
WriteLn('++ RecomputeImages: Just fell out of OnlyPartDrawn loop: lastDrawnImage=',
str, ' lastOneChanged=', lastOneChanged);
END;
{$ENDC}
{At this point, lastDrawnImage will be NIL iff the scan went through the entire list

Apple Lisa ToolKit 3.0 Source Code Listing -- 845 of 1012

Apple Lisa Computer Technical Information


001724
001725
001726
001727
001728
001729
001730
001731
001732
001733
001734
001735
001736
001737
001738
001739
001740
001741
001742
001743
001744
001745
001746
001747
001748
001749
001750
001751
001752
001753
001754
001755
001756
001757
001758
001759
001760
001761
001762
001763
001764
001765
001766
001767
001768
001769
001770
001771

and OnlyPartDrawn never returned TRUE}


{Hence, if lastDrawnImage is NIL, then we displayed all our paraImages and there may
still be some space left, so steal the next textImage's paraImages (if any). Continue
this in the Repeat loop until we use up the space or exhaust the paraImages. Note that we
don't need to check nextTxtImg if none of the paraImages changed and had to be recalculated}
nextTxtImg := SELF.nextTxtImg;
IF lastDrawnImage = NIL THEN
BEGIN
IF lastOneChanged OR TRUE THEN {<-- temporary!!??}
REPEAT
IF nextTxtImg <> NIL THEN
BEGIN
s := nextTxtImg.imageList.Scanner;
{Delete the first paraImage in the next textImage if it pointed to the same
paragraph as the current textImage's last paraImage, since, if we got to
this point, we must have already displayed the whole paragraph}
IF (nextTxtImg.imageList.Size > 0) AND (SELF.imageList.Size > 0) THEN
BEGIN
firstImage := TParaImage(nextTxtImg.imageList.First);
lastImage := TParaImage(SELF.imageList.Last);
IF firstImage.paragraph = lastImage.paragraph THEN
IF s.Scan(paraImage) THEN
BEGIN
paraImage.paragraph.images.DelObject(paraImage, FALSE);
s.Delete(TRUE);
END;
END;
WHILE s.Scan(lastDrawnImage) DO
BEGIN
lastDrawnImage.InvalLinesWith(0, MAXINT);
deltaLPt.v := 0;
IF OnlyPartDrawn(lastDrawnImage) THEN
BEGIN
{if we didn't stop between paragraphs, install the paraImage in our list,
replace the next textImage's first paraImage with a copy of this one,
then terminate the scan. Note that the extentLRect and
height fields of the next TextImage's first paraImage are now incorrect,
but will be rectified when nextTxtImg.RecomputeImage is called}
IF (lastLP >= 0) THEN
BEGIN
SELF.imageList.InsLast(lastDrawnImage);
paraImage := nextTxtImg.NewParaImage(lastDrawnImage.paragraph,
lastDrawnImage.extentLRect, 0, 0);
s.Replace(paraImage, FALSE);
END;
s.Done;

Apple Lisa ToolKit 3.0 Source Code Listing -- 846 of 1012

Apple Lisa Computer Technical Information


001772
001773
001774
001775
001776
001777
001778
001779
001780
001781
001782
001783
001784
001785
001786
001787
001788
001789
001790
001791
001792
001793
001794
001795
001796
001797
001798
001799
001800
001801
001802
001803
001804
001805
001806
001807
001808
001809
001810
001811
001812
001813
001814
001815
001816
001817
001818
001819

END
ELSE
BEGIN
{remove lastDrawnImage from nextTxtImg.imageList and install in
SELF.imageList}
s.Delete(FALSE);
SELF.imageList.InsLast(lastDrawnImage);
END;
END;
IF lastDrawnImage = NIL THEN
nextTxtImg := nextTxtImg.nextTxtImg;
END;
UNTIL (lastDrawnImage <> NIL) OR (nextTxtImg = NIL);
IF lastDrawnImage = NIL THEN
BEGIN
{We exhausted all of the images and there is still potentially some room, so
look at the paragraph list and see if there are some paragraphs for which no
paraImages have yet been generated.
NOTE: this is where initial imaging of text without paraImages will be routed}
IF currParaIndex <= SELF.text.paragraphs.Size THEN
BEGIN
s := SELF.text.paragraphs.ScannerFrom(currParaIndex-1, scanForward);
WHILE s.Scan(paragraph) DO
BEGIN
lastDrawnImage := SELF.NewParaImage(paragraph, drawLRect, 0, 0);
IF OnlyPartDrawn(lastDrawnImage) THEN
s.Done;
IF lastdrawnImage.endLP >= 0 THEN
SELF.imageList.InsLast(lastDrawnImage)
ELSE
BEGIN
lastDrawnImage.paragraph.images.DelObject(lastDrawnImage, TRUE);
lastDrawnImage := NIL;
END;
END;
END;
END;
END
ELSE IF nextTxtImg <> NIL THEN
BEGIN
IF lastOneChanged THEN
BEGIN
{we stopped displaying in the middle of a paragraph, so give the rest of our
paraImages to the next textImage (note that the scanner (s) is still valid
because we jumped out of scan loop above)}
{put rest of SELF.imageList paraImages in tempList, then insert tempList into nextTxtImg}
tempList := TList.CREATE(NIL, SELF.Heap, 0);

Apple Lisa ToolKit 3.0 Source Code Listing -- 847 of 1012

Apple Lisa Computer Technical Information


001820
001821
001822
001823
001824
001825
001826
001827
001828
001829
001830
001831
001832
001833
001834
001835
001836
001837
001838
001839
001840
001841
001842
001843
001844
001845
001846
001847
001848
001849
001850
001851
001852
001853
001854
001855
001856
001857
001858
001859
001860
001861
001862
001863
001864
001865
001866
001867

{if we didn't display any of the current paraImage then delete it from this list}
IF lastLP < 0 THEN
BEGIN
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
LIntToHex(ORD(lastDrawnImage), @str);
WriteLn('++ RecomputeImages: lastLP < 0; lastdrawnImage=', str);
END;
{$ENDC}
s.Delete(FALSE);
paraImage := lastDrawnImage;
paraImage.endLP := 0;
END
ELSE
BEGIN
paraImage := nextTxtImg.NewParaImage(lastDrawnImage.paragraph,
lastDrawnImage.extentLRect, 0, 0);
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
LIntToHex(ORD(paraImage), @str);
WriteLn('++ RecomputeImages: copy of lastDrawnImage =', str);
END;
{$ENDC}
END;
tempList.InsLast(paraImage);
{put the paraImages into tempList in reverse order so that we can scan it and insert
the images at the beginning of nextTxtImg.imageList (a double-reverse)}
WHILE s.Scan(paraImage) DO
BEGIN
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
LIntToHex(ORD(paraImage), @str);
WriteLn('++ RecomputeImages: appending to tempList and deleting from SELF pImg=', str);
END;
{$ENDC}
tempList.InsFirst(paraImage);
s.Delete(FALSE);
END;
{Delete the last paraImage inserted in the tempList if it pointed to the same
paragraph as the next textImage's first paraImage}
IF nextTxtImg.imageList.Size > 0 THEN
BEGIN
firstImage := TParaImage(nextTxtImg.imageList.First);
lastImage := TParaImage(tempList.First);

Apple Lisa ToolKit 3.0 Source Code Listing -- 848 of 1012

Apple Lisa Computer Technical Information


001868
001869
001870
001871
001872
001873
001874
001875
001876
001877
001878
001879
001880
001881
001882
001883
001884
001885
001886
001887
001888
001889
001890
001891
001892
001893
001894
001895
001896
001897
001898
001899
001900
001901
001902
001903
001904
001905
001906
001907
001908
001909
001910
001911
001912
001913
001914
001915

IF firstImage.paragraph = lastImage.paragraph THEN


BEGIN
firstImage.InvalLinesWith(0, MAXINT);
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
LIntToHex(ORD(lastImage), @str);
WriteLn('++ RecomputeImages: ', str,
' points to same para as nxtTxt.firstImg, so tempList.del');
END;
{$ENDC}
IF lastDrawnImage = lastImage THEN
lastDrawnImage := NIL;
lastImage.paragraph.images.DelObject(lastImage, FALSE);
tempList.DelFirst(TRUE);
END;
END;
{$IFC fTextTrace}
IF fTextTrace THEN
WriteLn('++ RecomputeImages: About to insert rest of pimages into nextTImage; list size=',
tempList.Size:1);
{$ENDC}
s := tempList.Scanner;
WHILE s.Scan(paraImage) DO
BEGIN
paraImage.textImage := nextTxtImg;
paraImage.InvalLinesWith(0, MAXINT);
nextTxtImg.imageList.InsFirst(paraImage);
s.Delete(FALSE);
END;
tempList.Free;
END; {lastOneChanged}
END {nxtTxtImg <> NIL}
ELSE
{If we have stopped displaying in the middle of a paragraph and there is no next
text image to display the excess, then delete the remaining paraImages}
BEGIN
IF lastLP < 0 THEN
BEGIN
lastDrawnImage.paragraph.images.DelObject(lastDrawnImage, FALSE);
s.Delete(TRUE);
END;
WHILE s.Scan(paraImage) DO
BEGIN
paraImage.paragraph.images.DelObject(paraImage, FALSE);
s.Delete(TRUE);
END;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 849 of 1012

Apple Lisa Computer Technical Information


001916
001917
001918
001919
001920
001921
001922
001923
001924
001925
001926
001927
001928
001929
001930
001931
001932
001933
001934
001935
001936
001937
001938
001939
001940
001941
001942
001943
001944
001945
001946
001947
001948
001949
001950
001951
001952
001953
001954
001955
001956
001957
001958
001959
001960
001961
001962
001963

{Set up new bottom and erase any garbage due to text moving up}
newBottom := SELF.ImageBottom;
IF newBottom < SELF.formerBottom THEN
WITH SELF, extentLRect DO
{$H-}
BEGIN
SetLRect(updateLRect, left-1, newBottom, right+1, formerBottom);
IF realAction = actionDraw THEN
FillLRect(updateLRect, lPatWhite)
ELSE IF realAction = actionInval THEN
thePad.invalLRect(updateLRect);
IF invalBits THEN
updateLRect := zeroLRect;
END;
{$H+}
SELF.formerBottom := newBottom;
IF SELF.growsDynamically THEN
WITH SELF, extentLRect DO
{$H-}
bottom := Max(newBottom, top + minHeight);
{$H+}
{Now tell the next textImage in the chain to recompute itself}
nextTxtImg := SELF.nextTxtImg;
IF nextTxtImg <> NIL THEN
BEGIN
{$IFC fTextTrace}
IF fTextTrace THEN
WriteLn('++ RecomputeImages: About to call RecomputeImages for nextTxtImg; nTI.imgLst.Size=',
nextTxtImg.imageList.Size:1);
{$ENDC}
IF lastDrawnImage = NIL THEN
nextTxtImg.startLP := 0
ELSE
{$H-} nextTxtImg.startLP := Max(0, lastDrawnImage.endLP); {$H+}
nextTxtImg.firstIndex := currParaIndex;
nextTxtImg.RecomputeImages(drawAction, invalBits);
END;
{$IFC fTrace}EP;{$ENDC}
END; {RecomputeImages}
{$S SgTxtCld}
PROCEDURE TTextImage.Resize(newExtent: LRect);
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 850 of 1012

Apple Lisa Computer Technical Information


001964
001965
001966
001967
001968
001969
001970
001971
001972
001973
001974
001975
001976
001977
001978
001979
001980
001981
001982
001983
001984
001985
001986
001987
001988
001989
001990
001991
001992
001993
001994
001995
001996
001997
001998
001999
002000
002001
002002
002003
002004
002005
002006
002007
002008
002009
002010
002011

{$IFC fTrace}BP(10);{$ENDC}
SELF.extentLRect := newExtent;
SELF.InvalAll;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
FUNCTION TTextImage.SeesSameAs(image: TImage): BOOLEAN;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
IF SELF = image THEN
SeesSameAs := TRUE
ELSE IF InClass(image, TParaImage) THEN
SeesSameAs := SELF.text = TParaImage(image).textImage.text
ELSE IF InClass(image, TTextImage) THEN
SeesSameAs := SELF.text = TTextImage(image).text
ELSE
SeesSameAs := FALSE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TTextImage.SetFirstIndex;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.firstIndex := 1;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtWrm}
FUNCTION TTextImage.TxtImgForClipBoard(heap: THeap; itsView: TView; itsLRect: LRect;
itsText:TText; isGrowable: BOOLEAN): TTextImage;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
TxtImgForClipBoard := TTextImage.CREATE(NIL, heap, itsView, itsLRect, itsText, isGrowable);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
END; {Methods of TTextImage}
METHODS OF TTextView;
{$S SgTxtCld}
FUNCTION TTextView.CREATE(object: TObject; heap: THeap; itsPanel: TPanel; itsExtent: LRect): TTextView;

Apple Lisa ToolKit 3.0 Source Code Listing -- 851 of 1012

Apple Lisa Computer Technical Information


002012
002013
002014
002015
002016
002017
002018
002019
002020
002021
002022
002023
002024
002025
002026
002027
002028
002029
002030
002031
002032
002033
002034
002035
002036
002037
002038
002039
002040
002041
002042
002043
002044
002045
002046
002047
002048
002049
002050
002051
002052
002053
002054
002055
002056
002057
002058
002059

BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TTextView(itsPanel.NewView(object, itsExtent, TPrintManager.CREATE(NIL, heap),
stdMargins, FALSE {, Damnit!}));
SELF.textImage := NIL;
SELF.valid := FALSE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{$IFC fTextTrace}
PROCEDURE TTextView.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('textImage: TTextImage');
Field('valid: BOOLEAN');
Field('');
END;
{$ENDC}
{$S SgTxtCld}
{$IFC fUseUnivText}
PROCEDURE TTextView.CreateUniversalText;
VAR univText:
TTextWriteUnivText;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF NOT clipBoard.hasUniversalText THEN
BEGIN
univText := TTextWriteUnivText.CREATE(NIL, mainHeap, NIL, 512,
TTextSelection(SELF.panel.selection));
univText.Free;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$ENDC}
{$S SgTxtCld}
FUNCTION TTextView.CursorAt(mouseLPt: LPoint): TCursorNumber;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF LPtInLRect(mouseLPt, SELF.textImage.extentLRect) THEN
CursorAt := textCursor
ELSE
CursorAt := arrowCursor;
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 852 of 1012

Apple Lisa Computer Technical Information


002060
002061
002062
002063
002064
002065
002066
002067
002068
002069
002070
002071
002072
002073
002074
002075
002076
002077
002078
002079
002080
002081
002082
002083
002084
002085
002086
002087
002088
002089
002090
002091
002092
002093
002094
002095
002096
002097
002098
002099
002100
002101
002102
002103
002104
002105
002106
002107

END;
{$S SgTxtCld}
PROCEDURE TTextView.Draw;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF NOT SELF.valid THEN
BEGIN
SELF.textImage.RecomputeImages(actionNone, TRUE);
SELF.valid := TRUE;
END;
SELF.textImage.Draw;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TTextView.MousePress(mouseLPt: LPoint);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.textImage.MousePress(mouseLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
END; {Methods of TTextView}
{$S SgTxtCld}
{$IFC fUseUnivText}
METHODS OF TTextWriteUnivText;
{$S SgTxtCld}
FUNCTION TTextWriteUnivText.CREATE(object: TObject; heap: THeap;
itsString: TString; itsDataSize: INTEGER;
itsTextSel: TTextSelection): TTextWriteUnivText;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
WITH TTextWriteUnivText(object) DO
BEGIN
textSelection := itsTextSel;
currIndex := 1;
currPara := itsTextSel.textRange.firstPara;
currLP := 0;
currStyleIndex := 1;
currTStyles := itsTextSel.textRange.firstPara.typeStyles;

Apple Lisa ToolKit 3.0 Source Code Listing -- 853 of 1012

Apple Lisa Computer Technical Information


002108
002109
002110
002111
002112
002113
002114
002115
002116
002117
002118
002119
002120
002121
002122
002123
002124
002125
002126
002127
002128
002129
002130
002131
002132
002133
002134
002135
002136
002137
002138
002139
002140
002141
002142
002143
002144
002145
002146
002147
002148
002149
002150
002151
002152
002153
002154
002155

END;
SELF := TTKWriteUnivText.CREATE(object, heap, itsString, itsDataSize);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{$IFC fTextTrace}
PROCEDURE TTextWriteUnivText.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('textSelection: TTextSelection');
Field('currIndex: LONGINT');
Field('currPara: TEditPara');
Field('currLP: INTEGER');
Field('currStyleIndex: INTEGER');
Field('currTStyles: TArray');
Field('');
END;
{$ENDC}
{$S SgTxtCld}
PROCEDURE TTextWriteUnivText.FillParagraph;
VAR startPos:
INTEGER;
endPos:
INTEGER;
currChange: TStyleChange;
nextChange: TStyleChange;
numChars:
INTEGER;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
WriteLn('<-> Entering FillRun: Current fields are:');
WriteLn('<->
currIndex = ', SELF.currIndex:1, ' currStyleIndex = ', SELF.currStyleIndex:1);
WriteLn('<->
currLP = ', SELF.currLP:1);
END;
{$ENDC}
SELF.data.DelAll;
IF SELF.currIndex <= SELF.textSelection.textRange.lastIndex THEN
BEGIN
WITH SELF.paragraphDescriptor, SELF.currPara.format DO
BEGIN
paragraphStart := SELF.textSelection.isParaSelection AND {LSR}
(SELF.currLP = 0);
firstLineMargin := firstIndent;
bodyMargin := leftIndent;
rightMargin := rightMargin - rightIndent; {????}

Apple Lisa ToolKit 3.0 Source Code Listing -- 854 of 1012

Apple Lisa Computer Technical Information


002156
002157
002158
002159
002160
002161
002162
002163
002164
002165
002166
002167
002168
002169
002170
002171
002172
002173
002174
002175
002176
002177
002178
002179
002180
002181
002182
002183
002184
002185
002186
002187
002188
002189
002190
002191
002192
002193
002194
002195
002196
002197
002198
002199
002200
002201
002202
002203

paraLeading := spaceBelowPara;
END;
IF SELF.currPara.size = 0 THEN
BEGIN
endPos := 0;
numChars := 0;
END
ELSE
BEGIN
REPEAT
SELF.currTStyles.GetAt(SELF.currStyleIndex, @currChange);
WITH SELF.characterDescriptor DO
BEGIN
{$H-}
font := QDFontNumber(currChange.newStyle);
{$H+}
face := currChange.newStyle.onFaces;
END;
startPos := Max(SELF.currLP, currChange.lp) + 1;
SELF.currTStyles.GetAt(SELF.currStyleIndex+1, @nextChange);
endPos := Min(SELF.currPara.size, nextChange.lp);
numChars := endPos - startPos + 1;
IF numChars = 0 THEN
SELF.currStyleIndex := SELF.currStyleIndex + 1;
UNTIL numChars > 0;
SELF.data.InsManyAt(1, SELF.currPara, startPos, numChars);
END;
IF endPos = SELF.currPara.size THEN
BEGIN
SELF.currIndex := SELF.currIndex + 1;
WITH SELF DO
IF currIndex <= textSelection.textRange.lastIndex THEN
BEGIN
currLP := 0;
currStyleIndex := 1;
{$H-}
currPara := TEditPara(SELF.textSelection.textImage.text.paragraphs.At(
SELF.currIndex));
{$H+}
currTStyles := currPara.typeStyles;
{$H-}
SELF.data.InsAt(numChars+1, CHR(ascReturn)); {last statement in IF!!}
{$H+}
END
ELSE IF textSelection.isParaSelection THEN
{$H-}
SELF.data.InsAt(numChars+1, CHR(ascReturn)); {last statement in IF!!}
{$H+}

Apple Lisa ToolKit 3.0 Source Code Listing -- 855 of 1012

Apple Lisa Computer Technical Information


002204
002205
002206
002207
002208
002209
002210
002211
002212
002213
002214
002215
002216
002217
002218
002219
002220
002221
002222
002223
002224
002225
002226
002227
002228
002229
002230
002231
002232

END
ELSE
BEGIN
SELF.currLP := SELF.currLP + numChars;
SELF.paragraphDescriptor.additionalChrInParagraph := {LSR}
SELF.currPara.size - endPos + 1;
END;
END;
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
WriteLn;
WriteLn('>-< EXITING FillRun: Current fields are:');
WriteLn('>-<
currIndex = ', SELF.currIndex:1, ' currStyleIndex = ', SELF.currStyleIndex:1);
WriteLn('>-<
currLP = ', SELF.currLP:1);
WriteLn('----------------------------------------------------------------');
END;
{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
END; {Methods of TTextWriteUnivText}
{$ENDC}
{$S SgTxtIni}

End of File -- Lines: 2232 Characters: 80799

Apple Lisa ToolKit 3.0 Source Code Listing -- 856 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UTEXT4.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{UText4}

{changed
{changed
{changed
{changed
{changed
{changed
{changed
{changed
{changed

{TEXT SELECTION TYPES AND COMMANDS}


04/27/84
04/25/84
04/25/84
04/19/84
04/17/84
04/16/84
04/16/84
04/16/84
04/13/84

1307
1406
1250
1308
1720
1414
1322
1024
1736

{changed 04/13/84 1531


{changed 04/13/84 1102
{changed
{changed
{changed
{changed

04/13/84
04/09/84
04/09/84
04/09/84

0209
1530
1337
1202

Change to TTypingCmd.Perform}
Got rid of IF numParas = 1 in Adjust proc in InsertText}
Changed TStyleCmd.FilterAndDo back to filtering TParaImage for Compugraphic}
Set up fields for partial line erasing in KeyPause}
In TTextSelection.CutCopy, changed "IF firstLP >= 0" to "IF firstLP > 0"}
Set viewLRect origined at (0,0) in TTextSelection.CutCopy}
Set textImage.minHeight to 0 in TOnePara and TMultiPara.CopySelf}
Call recomputeImages in TOnePara and TMultiPara.CopySelf to set clipView size}
First parameter decremented in calls to TParagraph.StyleAt;
No longer set unHighlightBefore[doPhase] to FALSE in typingCmd;
Set TInsertionPoint.justReturned to FALSE in all Key methods (except KeyReturn);
Call StyleFromContext in TStyleCmd.Perform}
TStyleCmd.FilterAndDo now filters a TEditPara rather than a TParaImage;
Call StyleFromContext through a filter in TTextSelection.CREATE}
TInsertion.MousePress: Allow selecting of word when double click on last half
of last character in word}
Changed all calls to TEditPara.CREATE to TTextImage.NewEditPara}
Set highlightAfter[doPhase] FALSE in TTypingCmd.CREATE}
Set deferUpdate TRUE in TTypingCmd.Perform (do phase)}
TInsertion.MousePress: Made sure all insertion points had their isPara flags
set when triple click on an empty paragraph;
TInsertionPoint.MouseMove: Don't unHighlight if isPara was TRUE}

{$S SgTxtHot}
METHODS OF TTextSelection;
{$S SgTxtHot}
FUNCTION TTextSelection.CREATE(object: TObject; heap: THeap; itsView: TView;
itsTextImage: TTextImage; itsAnchorLPt: LPoint;
beginPara: TEditPara; beginIndex: LONGINT; beginLP: INTEGER;
endPara: TEditPara; endIndex: LONGINT; endLP: INTEGER
): TTextSelection;
{Need to filter paragraph before asking about its type styles}
PROCEDURE FindFilteredStyle(obj: TObject);

Apple Lisa ToolKit 3.0 Source Code Listing -- 857 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

BEGIN
SELF.StyleFromContext;
END;
VAR range: TTextRange;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TTextSelection(TSelection.CREATE(object, heap, itsView, somethingKind, itsAnchorLPt));
range := TTextRange.CREATE(NIL, heap, beginPara, beginIndex, beginLP, endPara, endIndex, endLP);
WITH SELF DO
BEGIN
textImage := itsTextImage;
textRange := range;
isWordSelection := FALSE;
isParaSelection := FALSE;
amTyping := FALSE;
viewTick := -1; { force recalculation of selection range }
END;
SELF.textImage.FilterAndDo(TParaImage(beginPara.images.First), FindFilteredStyle);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TTextSelection.Free;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.textRange.Free;
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtWrm}
FUNCTION TTextSelection.Clone(heap: THeap): TObject;
VAR textSel:
TTextSelection;
range:
TTextRange;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
range := TTextRange(SELF.textRange.Clone(heap));
textSel := TTextSelection(SUPERSELF.Clone(heap));
textSel.textRange := range;
Clone := textSel;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 858 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

{$S SgTxtCld}
{$IFC fTextTrace}
PROCEDURE TTextSelection.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('textImage: TTextImage');
Field('textRange: TTextRange');
Field('isWordSelection: BOOLEAN');
Field('isParaSelection: BOOLEAN');
Field('viewTick: INTEGER');
Field('amTyping: BOOLEAN');
Field('onFaces: INTEGER');
Field('font: INTEGER');
Field('');
END;
{$ENDC}
{$S SgTxtHot}
FUNCTION TTextSelection.BecomeInsertionPoint: TInsertionPoint;
VAR insertionPt:
TInsertionPoint;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
insertionPt := TInsertionPoint(SELF.FreedAndReplacedBy(
TInsertionPoint.CREATE(NIL, SELF.Heap,
SELF.view, SELF.textImage, SELF.anchorLPt,
SELF.textRange.firstPara,
SELF.textRange.firstIndex,
SELF.textRange.firstLP)));
SELF.textImage.text.ChangeSelInOtherPanels(insertionPt);
BecomeInsertionPoint := insertionPt;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtWrm}
FUNCTION TTextSelection.CanDoCommand(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN): BOOLEAN;
VAR typeStyle: TTypeStyle;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
CASE cmdNumber OF
uModern, uClassic:
BEGIN
CanDoCommand := TRUE;
typeStyle := SELF.currTypeStyle;
checkIt := (cmdNumber - uModern + 1) = typeStyle.font.fontFamily;

Apple Lisa ToolKit 3.0 Source Code Listing -- 859 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

END;
u20Pitch, u15Pitch, u12Pitch, u10Pitch, u12Point, u14Point, u18Point, u24Point:
BEGIN
CanDoCommand := TRUE;
typeStyle := SELF.currTypeStyle;
checkIt := (cmdNumber - u20Pitch + 1) = typeStyle.font.fontSize;
END;
{$IFC LibraryVersion <= 20}
uFnt0, uFnt1, uFnt2, uFnt3, uFnt4, uFnt5, uFnt6, uFnt7, uFnt8, uFnt9, uFnt10, uFnt11:
BEGIN
CanDoCommand := TRUE;
WITH SELF.currTypeStyle.font DO
CASE cmdNumber OF
uFnt0:
checkIt := fontFamily = famSystem;
uFnt1:
checkIt := (fontFamily = famModern) AND (fontSize = size15Pitch);
uFnt2:
checkIt := (fontFamily = famModern) AND (fontSize = size12Pitch);
uFnt3:
checkIt := (fontFamily = famClassic) AND (fontSize = size12Pitch);
uFnt4:
checkIt := (fontFamily = famModern) AND (fontSize = size10Pitch);
uFnt5:
checkIt := (fontFamily = famModern) AND (fontSize = size14Point);
uFnt6:
checkIt := (fontFamily = famModern) AND (fontSize = size12Point);
uFnt7:
checkIt := (fontFamily = famClassic) AND (fontSize = size12Point);
uFnt8:
checkIt := (fontFamily = famModern) AND (fontSize = size18Point);
uFnt9:
checkIt := (fontFamily = famClassic) AND (fontSize = size18Point);
uFnt10: checkIt := (fontFamily = famModern) AND (fontSize = size24Point);
uFnt11: checkIt := (fontFamily = famClassic) AND (fontSize = size24Point);
END;
END;
{$ENDC}
uPlain, uBold, uItalic, uUnderline, uShadow, uOutline:
BEGIN
CanDoCommand := TRUE;
typeStyle := SELF.currTypeStyle;
WITH typeStyle DO
CASE cmdNumber OF
uPlain:
checkIt := onFaces=[];
uBold:
checkIt := (bold
in onFaces);
uItalic:
checkIt := (italic
in onFaces);
uUnderline: checkIt := (underlined in onFaces);
uShadow:
checkIt := (shadow
in onFaces);
uOutline:
checkIt := (outline
in onFaces);
END;
END;
uCut, uCopy, uClear:
CanDoCommand := TRUE;

Apple Lisa ToolKit 3.0 Source Code Listing -- 860 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

uPaste:
BEGIN
clipboard.Inspect;
IF (clipboard.hasView) OR (clipBoard.hasUniversalText) THEN
CanDoCommand := TRUE;
END;
OTHERWISE
CanDoCommand := SUPERSELF.CanDoCommand(cmdNumber, checkIt);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TTextSelection.ChangeStyle(cmdNumber: TCmdNumber);
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
Write(chr(7),'Change typestyle not implemented for this selection type. ');
WriteLn ('(cmdNumber= ',cmdNumber:1,')');
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TTextSelection.ChangeText(PROCEDURE TextEdit; PROCEDURE Adjust);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.MarkChanged;
TextEdit;
Adjust;
IF NOT deferUpdate THEN
BEGIN
SELF.textImage.text.RecomputeImages;
(*SELF.textImage.text.Invalidate;*)
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
FUNCTION TTextSelection.CopySelf(heap: THeap; view: TView): TMultiParaSelection;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
CopySelf := NIL;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 861 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

{$S SgTxtCld}
PROCEDURE TTextSelection.CutCopy(clipSelection: TSelection; deleteOriginal: BOOLEAN);
VAR clipHeap:
THeap;
clipPanel:
TPanel;
clipView:
TTextView;
viewLRect:
LRect;
text:
TText;
insPt:
TInsertionPoint;
clipTextSelection: TMultiParaSelection;
selSize:
INTEGER;
checkLast:
BOOLEAN;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
clipHeap := clipSelection.heap;
clipPanel := clipSelection.panel;
viewLRect := SELF.textImage.extentLRect;
SetLRect(viewLRect, 0, 0, viewLRect.right - viewLRect.left + 2 * cHorizMargin,
viewLRect.bottom - viewLRect.top + 2 * cVertMargin);
clipView := TTextView.CREATE(NIL, clipHeap, clipPanel, viewLRect);
clipTextSelection := TMultiParaSelection(clipSelection.FreedAndReplacedBy(
SELF.CopySelf(clipHeap, clipView)));
clipView.valid := TRUE;
clipTextSelection.isParaSelection := SELF.isParaSelection;
clipTextSelection.isWordSelection := SELF.isWordSelection;
{Intelligence!! Even if word flag not set, let's see if we qualify as a word selection anyway}
IF NOT SELF.isWordSelection THEN
WITH SELF.textRange DO
{$H-}
clipTextSelection.isWordSelection := firstPara.Qualifies(firstLP) AND
lastPara.Qualifies(lastLP-1) AND
NOT firstPara.Qualifies(firstLP-1) AND
NOT lastPara.Qualifies(lastLP);
{$H+}
clipView.textImage := clipTextSelection.textImage;
IF deleteOriginal THEN
BEGIN
{Intelligent Cut: Delete extra space}
IF clipTextSelection.isWordSelection THEN
WITH SELF.textRange DO
BEGIN
{$H-}
checkLast := TRUE;
IF firstLP > 0 THEN
IF firstPara.At(firstLp) = ' ' THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 862 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

firstLP := firstLP - 1;
checkLast := FALSE;
END;
IF checkLast AND (lastLP < lastPara.size) THEN
IF lastPara.At(lastLP + 1) = ' ' THEN
lastLP := lastLP + 1;
{$H+}
END;
SELF.DeleteAndFree;
insPt := SELF.BecomeInsertionPoint;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TTextSelection.DeleteAndFree;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
FUNCTION TTextSelection.DeleteButSave: TText;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
DeleteButSave := NIL;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TTextSelection.DoChangeStyle(cmdNumber: TCmdNumber; paragraph: TParagraph;
firstLP: INTEGER; lastLP: INTEGER; VAR newStyle: TTypeStyle);
VAR onFaces:
{$IFC LibraryVersion <= 20}TSeteface{$ELSEC}Style{$ENDC};
faceChange: BOOLEAN;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
WriteLn('_+_ Entering TTextSelection.DoChangeStyle: firstLP = ', firstLP:1,
' lastLP = ', lastLP:1);
END;
{$ENDC}
faceChange := TRUE;
CASE cmdNumber OF

Apple Lisa ToolKit 3.0 Source Code Listing -- 863 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

uPlain:
onFaces
uBold:
onFaces
uItalic:
onFaces
uUnderline:
onFaces
uShadow:
onFaces
uOutline:
onFaces

:= [];
:= [bold];
:= [italic];
:= [underlined];
:= [shadow];
:= [outline];

uModern, uClassic:
BEGIN
faceChange := FALSE;
paragraph.ChgFontFamily(firstLP, lastLP, cmdNumber - uModern + 1, newStyle);
END;
{$IFC LibraryVersion <= 20}
uFnt0, uFnt1, uFnt2, uFnt3, uFnt4, uFnt5, uFnt6, uFnt7, uFnt8, uFnt9, uFnt10, uFnt11:
BEGIN
faceChange := FALSE;
CASE cmdNumber OF
uFnt0:
paragraph.ChgFontFamily(firstLP, lastLP, famSystem, newStyle);
uFnt1:
BEGIN
paragraph.ChgFontFamily(firstLP, lastLP, famModern, newStyle);
paragraph.ChgFontSize(firstLP, lastLP, size15Pitch, newStyle);
END;
uFnt2:
BEGIN
paragraph.ChgFontFamily(firstLP, lastLP, famModern, newStyle);
paragraph.ChgFontSize(firstLP, lastLP, size12Pitch, newStyle);
END;
uFnt3:
BEGIN
paragraph.ChgFontFamily(firstLP, lastLP, famClassic, newStyle);
paragraph.ChgFontSize(firstLP, lastLP, size12Pitch, newStyle);
END;
uFnt4:
BEGIN
paragraph.ChgFontFamily(firstLP, lastLP, famModern, newStyle);
paragraph.ChgFontSize(firstLP, lastLP, size10Pitch, newStyle);
END;
uFnt5:
BEGIN
paragraph.ChgFontFamily(firstLP, lastLP, famModern, newStyle);

Apple Lisa ToolKit 3.0 Source Code Listing -- 864 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

paragraph.ChgFontSize(firstLP, lastLP, size14Point, newStyle);


END;
uFnt6:
BEGIN
paragraph.ChgFontFamily(firstLP, lastLP, famModern, newStyle);
paragraph.ChgFontSize(firstLP, lastLP, size12Point, newStyle);
END;
uFnt7:
BEGIN
paragraph.ChgFontFamily(firstLP, lastLP, famClassic, newStyle);
paragraph.ChgFontSize(firstLP, lastLP, size12Point, newStyle);
END;
uFnt8:
BEGIN
paragraph.ChgFontFamily(firstLP, lastLP, famModern, newStyle);
paragraph.ChgFontSize(firstLP, lastLP, size18Point, newStyle);
END;
uFnt9:
BEGIN
paragraph.ChgFontFamily(firstLP, lastLP, famClassic, newStyle);
paragraph.ChgFontSize(firstLP, lastLP, size18Point, newStyle);
END;
uFnt10:
BEGIN
paragraph.ChgFontFamily(firstLP, lastLP, famModern, newStyle);
paragraph.ChgFontSize(firstLP, lastLP, size24Point, newStyle);
END;
uFnt11:
BEGIN
paragraph.ChgFontFamily(firstLP, lastLP, famClassic, newStyle);
paragraph.ChgFontSize(firstLP, lastLP, size24Point, newStyle);
END;
END;
END;
{$ENDC}
OTHERWISE
BEGIN
faceChange := FALSE;
paragraph.ChgFontSize(firstLP, lastLP, cmdNumber - u20Pitch + 1, newStyle);
END;
END;
IF faceChange THEN
paragraph.ChgFace(firstLP, lastLP, onFaces, newStyle);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 865 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

{$S SgTxtCld}
PROCEDURE TTextSelection.GetHysteresis(VAR hysterPt: Point);
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
hysterPt := zeroPt;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TTextSelection.Highlight(highTransit: THighTransit);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
{Note that this is called from TPanel.Highlight which does an OnAllPadsDo, thus we do not
call TText.HiliteParagraphs, but rather we call TTextImage.HiliteText }
IF SELF.textImage.imageList.size > 0 THEN
WITH SELF.textRange DO
{$H-}
SELF.textImage.headTxtImg.HiliteText(highTransit, firstIndex, firstLP, lastIndex, lastLP,
SELF.isParaSelection);
{$H+}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TTextSelection.Invalidate;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.textImage.text.Invalidate;
{$IFC fTrace}EP;{$ENDC}
END;
(* This is now done automatically by the ToolKit
{$S SgTxtHot}
PROCEDURE TTextSelection.KeyClear;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.window.PerformCommand(TClearTextCmd.CREATE(NIL, SELF.Heap, uClear,
SELF.textImage, SELF.textImage.text));
{$IFC fTrace}EP;{$ENDC}
END;
*)
{$S SgTxtHot}

Apple Lisa ToolKit 3.0 Source Code Listing -- 866 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

PROCEDURE TTextSelection.KeyBack(fWord: BOOLEAN);


BEGIN
{$IFC fTrace}BP(10);{$ENDC}
{This will create the typing command, which deletes any selected text}
SELF.KeyText;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TTextSelection.KeyChar(ch: CHAR);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.KeyText;
SELF.KeyChar(ch); {!!! Assumes SELF was converted to insertion point}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtWrm}
PROCEDURE TTextSelection.KeyReturn;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.KeyText;
SELF.KeyReturn; {!!! Assumes SELF was converted to insertion point}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TTextSelection.KeyText;
BEGIN
{$IFC fTrace}BP(7);{$ENDC}
IF NOT SELF.amTyping THEN
SELF.window.PerformCommand(TTypingCmd.CREATE(NIL, SELF.Heap,
SELF.textImage, SELF.textImage.text));
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TTextSelection.MarkChanged;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SUPERSELF.MarkChanged;
SELF.textImage.text.MarkChanged(SELF.textRange);
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 867 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

{$S SgTxtCld}
PROCEDURE TTextSelection.MousePress(mouseLPt: LPoint);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF clickState.fShift THEN
SELF.MouseMove(mouseLPt)
ELSE
SELF.textImage.MousePress(mouseLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TTextSelection.MouseRelease;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
ObscureCursor;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
FUNCTION TTextSelection.NewCommand(cmdNumber: TCmdNumber): TCommand;
VAR heap:
THeap;
textImage:
TTextImage;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
NewCommand := NIL;
heap := SELF.heap;
textImage := SELF.textImage;
CASE cmdNumber OF
u20Pitch, u15Pitch, u12Pitch, u10Pitch, u12Point, u14Point, u18Point, u24Point,
uModern, uClassic,
uPlain, uBold, uItalic, uUnderline, uShadow, uOutline:
NewCommand := SELF.NewStyleCmd(heap, cmdNumber, textImage);
{$IFC LibraryVersion <= 20}
uFnt0, uFnt1, uFnt2, uFnt3, uFnt4, uFnt5, uFnt6, uFnt7, uFnt8, uFnt9, uFnt10, uFnt11:
NewCommand := SELF.NewStyleCmd(heap, cmdNumber, textImage);
{$ENDC}
uCut, uCopy:
NewCommand := SELF.NewCutCopyCmd(heap, cmdNumber, textImage);
uClear:
NewCommand := TClearTextCmd.CREATE(NIL, SELF.Heap, uClear, textImage, textImage.text);

Apple Lisa ToolKit 3.0 Source Code Listing -- 868 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

uPaste:
NewCommand := TTextPaste.CREATE(NIL, heap, textImage, textImage.text);
{cFormatChanges:}
OTHERWISE
NewCommand := SUPERSELF.NewCommand(cmdNumber);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
FUNCTION TTextSelection.NewCutCopyCmd(heap: THeap; cmdNumber: TCmdNumber;
textImage: TTextImage): TCommand;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
NewCutCopyCmd := TTextCutCopy.CREATE(NIL, heap, cmdNumber, textImage,
cmdNumber=uCut, textImage.text);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
FUNCTION TTextSelection.NewStyleCmd(heap: THeap; cmdNumber: TCmdNumber;
textImage: TTextImage): TCommand;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
WITH SELF.textRange DO
{$H-}
NewStyleCmd := TStyleCmd.CREATE(NIL, heap, cmdNumber, textImage, firstIndex, lastIndex,
firstLP, lastLP, SELF);
{$H+}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
FUNCTION TTextSelection.ReplicateForOtherPanel(itsTextImage: TTextImage): TTextSelection;
VAR sel:
TTextSelection;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
WITH SELF.textRange DO
{$H-}
sel := itsTextImage.NewTextSelection(firstPara, firstIndex, firstLP,
lastPara, lastIndex, lastLP);
{$H+}

Apple Lisa ToolKit 3.0 Source Code Listing -- 869 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

sel.isParaSelection := SELF.isParaSelection;
sel.isWordSelection := SELF.isWordSelection;
ReplicateForOtherPanel := sel;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TTextSelection.StyleFromContext;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
END; {METHODS OF TTextSelection}
METHODS OF TInsertionPoint;
{$S SgTxtHot}
FUNCTION TInsertionPoint.CREATE(object: TObject; heap: THeap; itsView: TView; itsTextImage: TTextImage;
itsAnchorLPt: LPoint; itsParagraph: TEditPara; itsIndex: LONGINT;
itsLP: INTEGER): TInsertionPoint;
VAR s:
TListScanner;
paragraph: TEditPara;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
IF itsIndex <= 0 THEN
BEGIN
s := itsTextImage.text.paragraphs.Scanner;
WHILE s.Scan(paragraph) DO
IF paragraph = itsParagraph THEN
BEGIN
itsIndex := s.position;
s.Done;
END;
END;
SELF := TInsertionPoint(TTextSelection.CREATE(object, heap, itsView, itsTextImage, itsAnchorLPt,
itsParagraph, itsIndex, itsLP, itsParagraph, itsIndex, itsLP));
itsParagraph.bsCount := 0;
WITH SELF DO

Apple Lisa ToolKit 3.0 Source Code Listing -- 870 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

BEGIN
typingCmd := NIL;
styleCmdNumber := 0;
newestLP := itsLP;
nextHighTransit := hOnToOff;
justReturned := FALSE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TInsertionPoint.Free;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF SELF.typingCmd <> NIL THEN
WITH SELF, typingCmd.typingRange DO
BEGIN
lastPara := textrange.firstPara;
lastIndex := textrange.firstIndex;
lastLP := textrange.firstLP;
END;
(*
SELF.textRange.firstPara.StopEdit;
*)
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtWrm}
FUNCTION TInsertionPoint.Clone(heap: THeap): TObject;
VAR insPt: TInsertionPoint;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
insPt := TInsertionPoint(SUPERSELF.Clone(heap));
insPt.typingCmd := NIL;
insPt.amTyping := FALSE;
Clone := insPt;
{$IFC fTrace}EP;{$ENDC}
END;

{$S SgTxtCld}
{$IFC fTextTrace}
PROCEDURE TInsertionPoint.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 871 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

TTextSelection.Fields(Field);
Field('typingCmd: TTypingCmd');
Field('styleCmdNumber: INTEGER');
Field('newestLP: INTEGER');
Field('justReturned: BOOLEAN');
Field('nextHighTransit: Byte');
Field('nextTransitTime: LONGINT');
Field('');
END;
{$ENDC}
{$S SgTxtHot}
FUNCTION TInsertionPoint.BecomeInsertionPoint: TInsertionPoint;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
BecomeInsertionPoint := SELF;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtWrm}
FUNCTION TInsertionPoint.CanDoCommand(cmdNumber: TCmdNumber; VAR checkIt: BOOLEAN): BOOLEAN;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
CASE cmdNumber OF
uCut, uCopy:
CanDoCommand := FALSE;
OTHERWISE
CanDoCommand := SUPERSELF.CanDoCommand(cmdNumber, checkIt);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TInsertionPoint.CutCopy(clipSelection: TSelection; deleteOriginal: BOOLEAN);
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
(* Staged Alert *)
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TInsertionPoint.FinishPaste(clipSelection: TSelection; pic: PicHandle);
VAR clipTextSelection: TMultiParaSelection;

Apple Lisa ToolKit 3.0 Source Code Listing -- 872 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF InClass(clipSelection, TMultiParaSelection) THEN
BEGIN
clipTextSelection := TMultiParaSelection(clipSelection);
SELF.InsertText(clipTextSelection.textImage.text, clipTextSelection.isParaSelection,
clipTextSelection.isWordSelection, FALSE);
END
{$IFC fUseUnivText}
ELSE IF clipBoard.hasUniversalText THEN
SELF.InsertText(NIL, FALSE, FALSE, TRUE)
{$ENDC};
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TInsertionPoint.IdleBegin(centiSeconds: LONGINT);
{Assumes highlighting is already on}
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF (SELF.kind = nothingKind) OR SELF.isParaSelection THEN
SELF.nextHighTransit := hNone
ELSE
BEGIN
SELF.textImage.text.HiliteRange(hOnToOff, SELF.textRange, FALSE);
SELF.nextHighTransit := hOffTOOn;
SELF.nextTransitTime := centiSeconds+blinkOffTime;
END;
SUPERSELF.IdleBegin(centiSeconds);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TInsertionPoint.IdleContinue(centiSeconds: LONGINT);
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF (SELF.nextHighTransit<>hNone) AND (centiSeconds > SELF.nextTransitTime) THEN
BEGIN
SELF.textImage.text.HiliteRange(SELF.nextHighTransit, SELF.textRange, FALSE);
WITH SELF DO
IF nextHighTransit = hOnToOff THEN
BEGIN
nextHighTransit := hOffToOn;
nextTransitTime := centiSeconds+blinkOffCentiSecs;

Apple Lisa ToolKit 3.0 Source Code Listing -- 873 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

END
ELSE
BEGIN
nextHighTransit := hOnToOff;
nextTransitTime := centiSeconds+blinkOnCentiSecs;
END;
END;
SUPERSELF.IdleContinue(centiSeconds);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TInsertionPoint.IdleEnd(centiSeconds: LONGINT);
{ end with highlighting on }
BEGIN
{$IFC fTrace}BP(6);{$ENDC}
IF SELF.nextHighTransit=hOffToOn THEN
SELF.textImage.text.HiliteRange(hOffToOn, SELF.textRange, FALSE);
SELF.nextHighTransit := hNone;
SUPERSELF.IdleEnd(centiSeconds);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TInsertionPoint.InsertText(text: TText; isParaSelection: BOOLEAN; isWordSelection: BOOLEAN;
universalText: BOOLEAN);
VAR s:
TListScanner;
prevPara:
TEditPara;
newPara:
TEditPara;
aParagraph:
TEditPara;
newLP:
INTEGER;
textImage:
TTextImage;
insertIt:
BOOLEAN;
done:
BOOLEAN;
newParaImage:
TParaImage;
paraIndex:
LONGINT;
delta:
INTEGER;
numParas:
INTEGER;
needSpRight:
BOOLEAN;
{$IFC fUseUnivText}
readUnivText:
TTKReadUnivText;
univPara:
TEditPara;
univFormat:
TParaFormat;
{$ENDC}
PROCEDURE StartPaste;

Apple Lisa ToolKit 3.0 Source Code Listing -- 874 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF universalText THEN
BEGIN
{$IFC fUseUnivText}
univFormat := TParaFormat.CREATE(NIL, SELF.Heap, SELF.textImage.text.styleSheet);
univPara := textImage.NewEditPara(0, prevPara.format);
readUnivText := TTKReadUnivText.CREATE(NIL, SELF.Heap, NIL, 512,
[UTCharacters, UTParagraphs]);
numParas := 0;
{$ENDC}
END
ELSE
BEGIN
numParas := text.paragraphs.size;
s := text.paragraphs.Scanner;
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE EndPaste;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF universalText THEN
BEGIN
{$IFC fUseUnivText}
univPara.Free;
readUnivText.Free;
{$ENDC}
END;
{$IFC fTrace}EP;{$ENDC}
END;
FUNCTION GetParagraph(VAR paragraph: TEditPara): BOOLEAN;
VAR currPos:
INTEGER;
done:
BOOLEAN;
runSize:
INTEGER;
wasSomeText:
BOOLEAN;
ch:
CHAR;
typeStyle:
TTypeStyle;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
If universalText THEN
BEGIN
{$IFC fUseUnivText}
univPara.ReplPString(0, univPara.Size, NIL);
currPos := 0;
wasSomeText := FALSE;

Apple Lisa ToolKit 3.0 Source Code Listing -- 875 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

done := FALSE;
REPEAT
readUnivText.ReadRun;
runSize := readUnivText.data.size;
IF runSize > 0 THEN
BEGIN
IF NOT wasSomeText THEN
BEGIN
WITH univFormat, readUnivText.paragraphDescriptor DO
BEGIN
firstIndent := firstLineMargin;
leftIndent := bodyMargin;
(* Can't use this because it's given as distance from left rather than
indent from right and I don't know what value of right edge of paper is.
rightIndent := rightMargin;
*)
spaceBelowPara := paraLeading;
END;
univPara.format := univFormat;
END;
wasSomeText := TRUE;
ch := readUnivText.data.At(runSize);
IF ORD(ch) = ascReturn THEN
BEGIN
readUnivText.data.DelAt(runSize);
runSize := runSize - 1;
numParas := numParas + 1;
done := TRUE;
END;
univPara.ReplTString(currPos, 0, readUnivText.data, 0, runSize);
typeStyle.onFaces := readUnivText.characterDescriptor.face;
typeStyle.font.fontFamily := uvFont[readUnivText.characterDescriptor.font].fontFamily;
typeStyle.font.fontSize := uvFont[readUnivText.characterDescriptor.font].fontSize;
univPara.NewStyle(currPos, currPos+runSize, typeStyle);
currPos := currPos + runSize;
END
ELSE
BEGIN
IF wasSomeText THEN
numParas := numParas + 1;
done := TRUE;
END;
UNTIL done;
IF wasSomeText THEN
paragraph := univPara
ELSE
paragraph := NIL;
GetParagraph := wasSomeText;

Apple Lisa ToolKit 3.0 Source Code Listing -- 876 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

{$ELSEC}
paragraph := NIL;
GetParagraph := FALSE;
{$ENDC}
END
ELSE
GetParagraph := s.Scan(paragraph);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE InsText;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
delta := 0;
textImage := SELF.textImage;
newLP := SELF.textRange.firstLP;
newPara := SELF.textRange.firstPara;
prevPara := newPara;
insertIt := FALSE;
IF isWordSelection THEN
BEGIN
needSpRight := newPara.Qualifies(newLP);
IF newPara.Qualifies(newLP-1) THEN
BEGIN
newPara.InsertOneChar(' ', newLP);
newLP := newLP + 1;
delta := 1;
END;
END;
(*

*)

{special case: if first paragraph in text is designated a whole paragraph (by isParaSelection) AND
if the insertion point (SELF) is at the end of the paragraph then we want to make a new
paragraph rather than append it to the current paragraph and consequently set the flag that
was supposed to prevent the first paragraph from being inserted}
IF isParaSelection AND (prevPara.size = newLP) THEN
BEGIN
newPara := textImage.NewEditPara(0, prevPara.format);
newLP := 0;
insertIt := TRUE;
END;
done := FALSE;
StartPaste;
IF GetParagraph(aParagraph) THEN
BEGIN
delta := delta + aParagraph.size;
REPEAT

Apple Lisa ToolKit 3.0 Source Code Listing -- 877 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

newPara.ReplPara(newLP, 0, aParagraph, 0, aParagraph.size);


newLP := newLP + aParagraph.size;
IF insertIt THEN
textImage.text.InsParaAfter(prevPara, newPara);
insertIt := TRUE;
prevPara := newPara;
IF GetParagraph(aParagraph) THEN
BEGIN
newPara := textImage.NewEditPara(prevPara.size-newLP,
TParaFormat(aParagraph.format.Clone(SELF.Heap)));
{For now, so we don't get garbage (if aParagraph later deleted), put cloned
format on to styleSheet list}
SELF.textImage.text.styleSheet.formats.InsLast(newPara.format);
newPara.StartEdit(newPara.GrowSize);
newPara.ReplPara(0, 0, prevPara, newLp, prevPara.size - newLp);
prevPara.ReplPString(newLp, prevPara.size-newLP, NIL);
prevPara.StopEdit;
newLP := 0;
END
ELSE
done := TRUE;
UNTIL done;
END;
IF isParaSelection THEN
BEGIN
newPara := textImage.NewEditPara(prevPara.size - newLP, prevPara.format);
newPara.StartEdit(newPara.GrowSize);
newPara.ReplPara(0, 0, prevPara, newLp, prevPara.size - newLp);
prevPara.ReplPString(newLp, prevPara.size - newLP, NIL);
prevPara.StopEdit;
textImage.text.InsParaAfter(prevPara, newPara);
newPara := TEditPara(textImage.text.paragraphs.At(SELF.textRange.firstIndex + numParas));
numParas := numParas+1;
newLP := 0;
END
ELSE IF isWordSelection THEN
IF needSpRight THEN
BEGIN
newPara.InsertOneChar(' ', newLP);
newLP := newLP + 1;
delta := delta + 1;
END;
EndPaste;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 878 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

PROCEDURE Adjust;
PROCEDURE AddDelta(paraImage: TParaImage);
BEGIN
paraImage.AdjustLineLPs(SELF.textRange.firstLP, delta);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.textRange.firstPara.EachImage(AddDelta);
WITH SELF, textRange DO
BEGIN
firstPara := newPara;
lastPara := newPara;
firstLP := newLP;
lastLP := newLP;
firstIndex := firstIndex + numParas - 1;
lastIndex := firstIndex;
newestLP := newLP;
amTyping := FALSE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF (text <> NIL) OR universalText THEN
SELF.ChangeText(InsText, Adjust);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TInsertionPoint.KeyBack(fWord: BOOLEAN);
VAR paragraph:
TEditPara;
savedPara:
TEditPara;
lp:
INTEGER;
typingCmd:
TTypingCmd;
prevPara:
TEditPara;
textRange:
TTextRange;
PROCEDURE Adjust;
VAR c: CHAR;
PROCEDURE DelOne(paraImage: TParaImage);
BEGIN
paraImage.AdjustLineLPs(lp, -1);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 879 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

paragraph := SELF.textRange.firstPara;
lp := SELF.newestLP;
IF fWord THEN
{&&& Move textRange.firstLP back to start of word};
paragraph.BeginInsertion(lp, 0);
IF (paragraph.holeStart < 1) AND (SELF.textRange.firstIndex = 1) THEN
SELF.CantDoIt
ELSE
BEGIN
prevPara := NIL;
IF paragraph.holeStart < 1 THEN
BEGIN
{Backspacing over beginning of paragraph}
textRange := SELF.textRange;
textRange.firstIndex := textRange.firstIndex - 1;
prevPara := TEditPara(SELF.textImage.text.paragraphs.At(textRange.firstIndex));
WITH textRange DO
BEGIN
firstPara := prevPara;
firstLP := prevPara.size;
lastIndex := firstIndex;
lastPara := firstPara;
lastLP := firstLP;
SELF.newestLP := firstLP;
END;
prevPara.ReplPara(prevPara.size, 0, paragraph, 0, paragraph.size);
SELF.textImage.text.DelPara(paragraph, FALSE);
SELF.textImage.text.paragraphs.DelObject(paragraph, FALSE);
END
ELSE
BEGIN
paragraph.bsCount := paragraph.bsCount + 1;
c := paragraph.At(paragraph.holeStart);
paragraph.DelAt(paragraph.holeStart);
paragraph.UpdateRuns(lp-1, 1, 0);
SELF.newestLP := lp-1;
END;
typingCmd := SELF.typingCmd;
IF prevPara = NIL THEN
BEGIN
typingCmd.newCharCount := typingCmd.newCharCount - 1;
IF typingCmd.newCharCount < 0 THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 880 of 1012

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163
001164
001165
001166
001167
001168
001169
001170
001171
001172
001173
001174
001175
001176
001177
001178
001179
001180
001181
001182
001183
001184
001185
001186
001187
001188
001189
001190
001191
001192
001193
001194
001195

typingCmd.typingRange.firstLP := typingCmd.typingRange.firstLP - 1;
typingCmd.newCharCount := 0;
savedPara := TEditPara(typingCmd.savedText.paragraphs.First);
{$R-}
savedPara.InsertOneChar(c, 0);
{$IFC fRngText}{$R+}{$ENDC}
END;

END
ELSE
BEGIN
typingCmd.newParaCount := typingCmd.newParaCount - 1;
IF typingCmd.newParaCount < 0 THEN
BEGIN
typingCmd.typingRange.firstIndex := textRange.firstIndex;
typingCmd.typingRange.firstPara := textRange.firstPara;
typingCmd.typingRange.firstLP := textRange.firstLP;
typingCmd.savedText.paragraphs.InsFirst(paragraph);
paragraph.ReplPString(0, paragraph.size, NIL);
typingCmd.newCharCount := 0;
typingCmd.newParaCount := 0;
END
ELSE
paragraph.Free;
END;
deferUpdate := TRUE;
SELF.justReturned := FALSE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.KeyText;
Adjust;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TInsertionPoint.KeyChar(ch: CHAR);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.KeyText;
SELF.textRange.firstPara.InsertOneChar(ch, SELF.newestLP);

Apple Lisa ToolKit 3.0 Source Code Listing -- 881 of 1012

Apple Lisa Computer Technical Information


001196
001197
001198
001199
001200
001201
001202
001203
001204
001205
001206
001207
001208
001209
001210
001211
001212
001213
001214
001215
001216
001217
001218
001219
001220
001221
001222
001223
001224
001225
001226
001227
001228
001229
001230
001231
001232
001233
001234
001235
001236
001237
001238
001239
001240
001241
001242
001243

IF SELF.styleCmdNumber <> 0 THEN


BEGIN
SELF.textRange.firstPara.NewStyle(SELF.newestLP, SELF.newestLP+1, SELF.currTypeStyle);
SELF.styleCmdNumber := 0;
END;
WITH SELF.typingCmd DO
newCharCount := newCharCount + 1;
SELF.newestLP := SELF.newestLP + 1;
SELF.justReturned := FALSE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TInsertionPoint.KeyEnter;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.textImage.text.RecomputeImages;
(*SELF.textImage.text.Invalidate;*)
deferUpdate := FALSE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TInsertionPoint.KeyForward(fWord: BOOLEAN);
VAR paragraph:
TEditPara;
savedPara:
TEditPara;
lp:
INTEGER;
{NOTE: This first stab at KeyForward does NOT properly restore typestyles !!}
PROCEDURE Adjust;
PROCEDURE AddOne(paraImage: TParaImage);
BEGIN
paraImage.AdjustLineLPs(lp, 1);
END;
BEGIN
paragraph := SELF.textRange.firstPara;
lp := SELF.newestLP;
IF (lp = paragraph.holeStart) AND (paragraph.bsCount > 0) THEN
BEGIN
IF fWord THEN
{&&& Recover word};

Apple Lisa ToolKit 3.0 Source Code Listing -- 882 of 1012

Apple Lisa Computer Technical Information


001244
001245
001246
001247
001248
001249
001250
001251
001252
001253
001254
001255
001256
001257
001258
001259
001260
001261
001262
001263
001264
001265
001266
001267
001268
001269
001270
001271
001272
001273
001274
001275
001276
001277
001278
001279
001280
001281
001282
001283
001284
001285
001286
001287
001288
001289
001290
001291

WITH paragraph DO
BEGIN
bsCount := paragraph.bsCount - 1;
holeStart := paragraph.holeStart + 1;
holeSize := paragraph.holeSize - 1;
size := size + 1;
END;
paragraph.UpdateRuns(lp-1, 0, 1);
SELF.newestLP := lp+1;
WITH SELF.typingCmd DO
newCharCount := newCharCount + 1;
deferUpdate := TRUE;
END;
SELF.justReturned := FALSE;
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.KeyText;
Adjust;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TInsertionPoint.KeyPause;
{Called by ToolKit when there are no keystrokes pending}
VAR text:
TText;
diff:
INTEGER;
lp:
INTEGER;
textImage: TTextImage;
paraImage: TParaImage;
startLine: INTEGER;
startPixel: LONGINT;
PROCEDURE AddDiff(paraImage: TParaImage);
BEGIN
paraImage.AdjustLineLPs(lp, diff);
END;
PROCEDURE AdjustOtherInsPts(obj: TObject);
VAR insertPt:
TInsertionPoint;
BEGIN
insertPt := TInsertionPoint(obj);

Apple Lisa ToolKit 3.0 Source Code Listing -- 883 of 1012

Apple Lisa Computer Technical Information


001292
001293
001294
001295
001296
001297
001298
001299
001300
001301
001302
001303
001304
001305
001306
001307
001308
001309
001310
001311
001312
001313
001314
001315
001316
001317
001318
001319
001320
001321
001322
001323
001324
001325
001326
001327
001328
001329
001330
001331
001332
001333
001334
001335
001336
001337
001338
001339

paraImage := insertPt.textImage.ImageWith(SELF.textRange.firstPara, lp);


IF paraImage <> NIL THEN
BEGIN
paraImage.LocateLP(lp, startLine, startPixel);
insertPt.textImage.firstLinePixel := startPixel;
insertPt.textImage.useFirstPixel := TRUE;
END
ELSE
insertPt.textImage.useFirstPixel := FALSE;
WITH SELF, insertPt.textRange DO
BEGIN
firstLP := newestLP;
lastLP := newestLP;
IF firstIndex <> textRange.firstIndex THEN
BEGIN
firstIndex := textRange.firstIndex;
lastIndex := textRange.lastIndex;
firstPara := textRange.firstPara;
lastPara := textRange.lastPara;
END;
END;
END;
PROCEDURE HiliteOtherInsPts(obj: TObject);
VAR insertPt:
TInsertionPoint;
BEGIN
insertPt := TInsertionPoint(obj);
IF insertPt.view.OKToDrawIn(insertPt.textImage.extentLRect) THEN
insertPt.panel.Highlight(insertPt, hOffToOn);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF SELF.amTyping AND NOT SELF.justReturned THEN
BEGIN
textImage := SELF.textImage;
text := textImage.text;
diff := SELF.newestLP - SELF.textRange.firstLP;
lp := Min(SELF.textRange.firstLP, SELF.newestLP);
SELF.MarkChanged;
SELF.textRange.firstPara.EachImage(AddDiff);
{set up textImage fields for minimum rectangle erase of first update line}
paraImage := textImage.ImageWith(SELF.textRange.firstPara, lp);
IF paraImage <> NIL THEN
BEGIN
paraImage.LocateLP(lp, startLine, startPixel);
textImage.firstLinePixel := startPixel;

Apple Lisa ToolKit 3.0 Source Code Listing -- 884 of 1012

Apple Lisa Computer Technical Information


001340
001341
001342
001343
001344
001345
001346
001347
001348
001349
001350
001351
001352
001353
001354
001355
001356
001357
001358
001359
001360
001361
001362
001363
001364
001365
001366
001367
001368
001369
001370
001371
001372
001373
001374
001375
001376
001377
001378
001379
001380
001381
001382
001383
001384
001385
001386
001387

textImage.useFirstPixel := TRUE;
END
ELSE
textImage.useFirstPixel := FALSE;
SELF.textRange.firstLP := SELF.newestLP;
SELF.textRange.lastLP := SELF.newestLP;
IF SELF.typingCmd <> NIL THEN
IF SELF.typingCmd.otherInsPts <> NIL THEN
SELF.typingCmd.otherInsPts.Each(AdjustOtherInsPts);
text.RecomputeImages;
{If view.OKToDrawIn was TRUE then we won't be going through the update cycle and hence the
ToolKit won't tell us to highlight, so we'll have to highlight ourselves}
IF SELF.view.OKToDrawIn(SELF.textImage.extentLRect) THEN
SELF.panel.Highlight(SELF, hOffToOn);
IF SELF.typingCmd <> NIL THEN
IF SELF.typingCmd.otherInsPts <> NIL THEN
SELF.typingCmd.otherInsPts.Each(HiliteOtherInsPts);
END;
deferUpdate := FALSE;
SELF.justReturned := FALSE;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtWrm}
PROCEDURE TInsertionPoint.KeyReturn;
VAR para1:
TEditPara;
newPara:
TEditPara;
selSize:
INTEGER;
PROCEDURE InsPara;
VAR styleChange:
TStyleChange;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
para1 := SELF.textRange.firstPara;
selSize := para1.size - SELF.textRange.firstLP;
newPara := SELF.textImage.NewEditPara(selSize, para1.format);
newPara.StartEdit(newPara.GrowSize);
newPara.ReplPara(0, 0, para1, SELF.textRange.firstLP, selSize);
IF TFakeTStyle(newPara.format.dfltTStyle) <> TFakeTStyle(SELF.currTypeStyle) THEN
BEGIN
styleChange.lp := -1;
styleChange.newStyle := SELF.currTypeStyle;
newPara.typeStyles.PutAt(1, @styleChange);
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 885 of 1012

Apple Lisa Computer Technical Information


001388
001389
001390
001391
001392
001393
001394
001395
001396
001397
001398
001399
001400
001401
001402
001403
001404
001405
001406
001407
001408
001409
001410
001411
001412
001413
001414
001415
001416
001417
001418
001419
001420
001421
001422
001423
001424
001425
001426
001427
001428
001429
001430
001431
001432
001433
001434
001435

para1.ReplPString(SELF.textRange.firstLP, selSize, NIL);


para1.StopEdit;
SELF.textImage.text.InsParaAfter(para1, newPara);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE Adjust;
PROCEDURE AdjustOtherInsPts(obj: TObject);
VAR insertPt:
TInsertionPoint;
BEGIN
insertPt := TInsertionPoint(obj);
WITH insertPt, textRange DO
BEGIN
firstLP := 0;
lastLP := 0;
firstIndex := SELF.textRange.firstIndex;
lastIndex := firstIndex;
firstPara := newPara;
lastPara := newPara;
END;
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
WITH SELF.textRange DO
BEGIN
firstPara := newPara;
lastPara := newPara;
firstIndex := firstIndex + 1;
lastIndex := firstIndex;
firstLP := 0;
lastLP := 0;
END;
SELF.newestLP := 0;
SELF.justReturned := TRUE;
WITH SELF.typingCmd DO
newParaCount := newParaCount + 1;
IF SELF.typingCmd.otherInsPts <> NIL THEN
SELF.typingCmd.otherInsPts.Each(AdjustOtherInsPts);
deferUpdate := FALSE;
SELF.textImage.useFirstPixel := FALSE;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE HiliteOtherInsPts(obj: TObject);
VAR insertPt:
TInsertionPoint;
BEGIN
insertPt := TInsertionPoint(obj);

Apple Lisa ToolKit 3.0 Source Code Listing -- 886 of 1012

Apple Lisa Computer Technical Information


001436
001437
001438
001439
001440
001441
001442
001443
001444
001445
001446
001447
001448
001449
001450
001451
001452
001453
001454
001455
001456
001457
001458
001459
001460
001461
001462
001463
001464
001465
001466
001467
001468
001469
001470
001471
001472
001473
001474
001475
001476
001477
001478
001479
001480
001481
001482
001483

IF insertPt.view.OKToDrawIn(insertPt.textImage.extentLRect) THEN
insertPt.panel.Highlight(insertPt, hOffToOn);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.KeyText;
SELF.ChangeText(InsPara, Adjust);
{If view.OKToDrawIn was TRUE then we won't be going through the update cycle and hence the
ToolKit won't tell us to highlight, so we'll have to highlight ourselves}
IF SELF.view.OKToDrawIn(SELF.textImage.extentLRect) THEN
SELF.panel.Highlight(SELF, hOffToOn);
IF SELF.typingCmd.otherInsPts <> NIL THEN
SELF.typingCmd.otherInsPts.Each(HiliteOtherInsPts);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TInsertionPoint.KeyTab;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.KeyChar(' ');
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TInsertionPoint.MarkChanged;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF SELF.newestLP < SELF.textRange.firstLP THEN
BEGIN
SELF.textRange.firstLP := SELF.newestLP;
SELF.textRange.lastLP := SELF.newestLP;
SUPERSELF.MarkChanged;
END
ELSE
BEGIN
SUPERSELF.MarkChanged;
SELF.textRange.firstLP := SELF.newestLP;
SELF.textRange.lastLP := SELF.newestLP;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}

Apple Lisa ToolKit 3.0 Source Code Listing -- 887 of 1012

Apple Lisa Computer Technical Information


001484
001485
001486
001487
001488
001489
001490
001491
001492
001493
001494
001495
001496
001497
001498
001499
001500
001501
001502
001503
001504
001505
001506
001507
001508
001509
001510
001511
001512
001513
001514
001515
001516
001517
001518
001519
001520
001521
001522
001523
001524
001525
001526
001527
001528
001529
001530
001531

PROCEDURE TInsertionPoint.MouseMove(mouseLPt: LPoint);


VAR currPImage:
TParaImage;
currLP:
INTEGER;
multiParaSelection: TMultiParaSelection;
oneParaSelection:
TOneParaSelection;
textImage:
TTextImage;
firstTxtImg:
TTextImage;
paraIndex:
LONGINT;
wasParaSel:
BOOLEAN;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.currLPt := mouseLPt;
IF NOT EqualLPt(mouseLPt, SELF.anchorLPt) THEN
BEGIN
textImage := SELF.textImage.FindTextImage(mouseLPt, firstTxtImg);
textImage.FindParaAndLp(mouseLPt, currPImage, paraIndex, currLP);
IF (currPImage.paragraph <> SELF.textRange.firstPara) THEN
BEGIN
{Turn insertion point off if necessary}
wasParaSel := SELF.isParaSelection;
IF NOT wasParaSel AND (paraIndex > SELF.textRange.firstIndex) THEN
SELF.textImage.text.HiliteRange(hOnToOff, SELF.textRange, FALSE);
{call new with same paragraph, followed by MouseMove so highlighting will work correctly
and so MouseMove can figure out if currPImage is before of after SELF.textRange.firstPara}
WITH SELF, textRange DO
{$H-} {ought to be safe: no VAR params, etc}
multiParaSelection := TMultiParaSelection(SELF.FreedAndReplacedBy(
TMultiParaSelection.CREATE(NIL, SELF.Heap,
view, firstTxtImg, anchorLPt,
firstPara, firstIndex, firstLP,
firstPara, firstIndex, firstLP, TRUE)));
{$H+}
multiParaSelection.isParaSelection := wasParaSel;
multiParaSelection.MouseMove(mouseLPt);
END
ELSE IF (currLP <> SELF.textRange.firstLP) THEN
BEGIN
{Turn insertion point off first}
SELF.textImage.text.HiliteRange(hOnToOff, SELF.textRange, FALSE);
{call CREATE with same LP for begin and end,
followed by MouseMove so highlighting will work correctly}
WITH SELF, textRange DO
{$H-} {ought to be safe: no VAR params, etc}
oneParaSelection := TOneParaSelection(SELF.FreedAndReplacedBy(
TOneParaSelection.CREATE(NIL, SELF.Heap,
view, firstTxtImg, anchorLPt,

Apple Lisa ToolKit 3.0 Source Code Listing -- 888 of 1012

Apple Lisa Computer Technical Information


001532
001533
001534
001535
001536
001537
001538
001539
001540
001541
001542
001543
001544
001545
001546
001547
001548
001549
001550
001551
001552
001553
001554
001555
001556
001557
001558
001559
001560
001561
001562
001563
001564
001565
001566
001567
001568
001569
001570
001571
001572
001573
001574
001575
001576
001577
001578
001579

firstPara, firstIndex, firstLP, firstLP)));


{$H+}
oneParaSelection.MouseMove(mouseLPt);
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtWrm}
PROCEDURE TInsertionPoint.MousePress(mouseLPt: LPoint);
VAR first, last:
INTEGER;
oneParaSelection:
TOneParaSelection;
funnnyInsPoint:
TInsertionPoint;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF clickState.fShift THEN
SELF.MouseMove(mouseLPt)
ELSE IF clickState.clickCount = 2 THEN {double click}
BEGIN
{This check should solve the problem of double clicking on the last half of the last
character of a word and not getting the word selected}
WITH SELF.textRange DO
BEGIN
first := firstLP;
{$H-}
IF NOT firstPara.Qualifies(first) THEN
IF first > 0 THEN
first := first - 1;
{$H+}
END;
SELF.textRange.firstPara.FindWordBounds(first, first, last);
IF first <> last THEN
BEGIN
{Turn insertion point off first}
SELF.textImage.text.HiliteRange(hOnToOff, SELF.textRange, FALSE);
WITH SELF, textRange DO
{$H-}
oneParaSelection := TOneParaSelection(SELF.FreedAndReplacedBy(
TOneParaSelection.CREATE(NIL, SELF.Heap,
view, textImage, anchorLPt,
firstPara, firstIndex, first, last)));
{$H+}
WITH oneParaSelection DO
BEGIN
anchorbegin := first;
anchorEnd := last;
isWordSelection := TRUE;

Apple Lisa ToolKit 3.0 Source Code Listing -- 889 of 1012

Apple Lisa Computer Technical Information


001580
001581
001582
001583
001584
001585
001586
001587
001588
001589
001590
001591
001592
001593
001594
001595
001596
001597
001598
001599
001600
001601
001602
001603
001604
001605
001606
001607
001608
001609
001610
001611
001612
001613
001614
001615
001616
001617
001618
001619
001620
001621
001622
001623
001624
001625
001626
001627

END;
oneParaSelection.textImage.text.HiliteRange(hOffToOn, oneParaSelection.textRange, FALSE);
END;

END
ELSE IF clickState.clickCount = 3 THEN {triple click, happens if double click didn't select word}
BEGIN
{Turn insertion point off first}
SELF.textImage.text.HiliteRange(hOnToOff, SELF.textRange, SELF.isParaSelection);
IF SELF.textRange.firstPara.size = 0 THEN
{This case precipitates the odd notion of an "insertion point" the width of the textImage;
(ie. when one triple clicks on an empty paragraph) A special check in IdleBegin makes sure
it doesn't blink.}
BEGIN
WITH SELF, textRange DO
{$H-}
funnnyInsPoint := TInsertionPoint(SELF.FreedAndReplacedBy(
TInsertionPoint.CREATE(NIL, SELF.Heap,
view, textImage, anchorLPt,
firstPara, firstIndex, 0)));
{$H+}
WITH funnnyInsPoint DO
BEGIN
isParaSelection := TRUE;
isWordSelection := FALSE;
END;
funnnyInsPoint.textImage.text.HiliteRange(hOffToOn, SELF.textRange, TRUE);
END
ELSE
BEGIN
WITH SELF, textRange DO
{$H-}
oneParaSelection := TOneParaSelection(SELF.FreedAndReplacedBy(
TOneParaSelection.CREATE(NIL, SELF.Heap,
view, textImage, anchorLPt,
firstPara, firstIndex, 0, firstPara.size)));
{$H+}
WITH oneParaSelection DO
BEGIN
isParaSelection := TRUE;
isWordSelection := FALSE;
anchorBegin := 0;
anchorEnd := textRange.lastLP;
END;
oneParaSelection.textImage.text.HiliteRange(hOffToOn, oneParaSelection.textRange, TRUE);
END;
END
ELSE

Apple Lisa ToolKit 3.0 Source Code Listing -- 890 of 1012

Apple Lisa Computer Technical Information


001628
001629
001630
001631
001632
001633
001634
001635
001636
001637
001638
001639
001640
001641
001642
001643
001644
001645
001646
001647
001648
001649
001650
001651
001652
001653
001654
001655
001656
001657
001658
001659
001660
001661
001662
001663
001664
001665
001666
001667
001668
001669
001670
001671
001672
001673
001674
001675

SELF.textImage.MousePress(mouseLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
FUNCTION TInsertionPoint.NewStyleCmd(heap: THeap; cmdNumber: TCmdNumber;
textImage: TTextImage): TCommand;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
{Do stuff but set NewStyleCmd NIL so last cmd not committed};
SELF.styleCmdNumber := cmdNumber;
WITH SELF.currTypeStyle, font DO
CASE cmdNumber OF
uPlain:
onFaces := [];
uBold:
onFaces := onFaces + [bold];
uItalic:
onFaces := onFaces + [italic];
uUnderline:
onFaces := onFaces + [underlined];
uShadow:
onFaces := onFaces + [shadow];
uOutline:
onFaces := onFaces + [outline];
uModern, uClassic:
font.fontFamily := cmdNumber - uModern + 1;
{$IFC LibraryVersion <= 20}
uFnt0, uFnt1, uFnt2, uFnt3, uFnt4, uFnt5, uFnt6, uFnt7, uFnt8, uFnt9, uFnt10, uFnt11:
CASE cmdNumber OF
uFnt0:
fontFamily := famSystem;
uFnt1:
BEGIN
fontFamily := famModern;
fontSize := size15Pitch;
END;
uFnt2:
BEGIN
fontFamily := famModern;
fontSize := size12Pitch;
END;
uFnt3:
BEGIN
fontFamily := famClassic;
fontSize := size12Pitch;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 891 of 1012

Apple Lisa Computer Technical Information


001676
001677
001678
001679
001680
001681
001682
001683
001684
001685
001686
001687
001688
001689
001690
001691
001692
001693
001694
001695
001696
001697
001698
001699
001700
001701
001702
001703
001704
001705
001706
001707
001708
001709
001710
001711
001712
001713
001714
001715
001716
001717
001718
001719
001720
001721
001722
001723

{$ENDC}

uFnt4:
BEGIN
fontFamily := famModern;
fontSize := size10Pitch;
END;
uFnt5:
BEGIN
fontFamily := famModern;
fontSize := size14Point;
END;
uFnt6:
BEGIN
fontFamily := famModern;
fontSize := size12Point;
END;
uFnt7:
BEGIN
fontFamily := famClassic;
fontSize := size12Point;
END;
uFnt8:
BEGIN
fontFamily := famModern;
fontSize := size18Point;
END;
uFnt9:
BEGIN
fontFamily := famClassic;
fontSize := size18Point;
END;
uFnt10:
BEGIN
fontFamily := famModern;
fontSize := size24Point;
END;
uFnt11:
BEGIN
fontFamily := famClassic;
fontSize := size24Point;
END;
END;

OTHERWISE
font.fontSize := cmdNumber - u20Pitch + 1;
END;
NewStyleCmd := NIL;
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 892 of 1012

Apple Lisa Computer Technical Information


001724
001725
001726
001727
001728
001729
001730
001731
001732
001733
001734
001735
001736
001737
001738
001739
001740
001741
001742
001743
001744
001745
001746
001747
001748
001749
001750
001751
001752
001753
001754
001755
001756
001757
001758
001759
001760
001761
001762
001763
001764
001765
001766
001767
001768
001769
001770
001771

END;

{$S SgTxtCld}
FUNCTION TInsertionPoint.NewCutCopyCmd(heap: THeap; cmdNumber: TCmdNumber;
textImage: TTextImage): TCommand;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
{don't create a new command object for insertion point style change}
NewCutCopyCmd := NIL;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
FUNCTION TInsertionPoint.SelSize: INTEGER;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
SelSize := 0;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TInsertionPoint.StyleFromContext;
VAR typeStyle:
TTypeSTyle;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
SELF.textRange.firstPara.StyleAt(Max(SELF.textRange.firstLP - 1, 0), typeStyle);
SELF.currTypeStyle := typeStyle;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
BEGIN
{temp patch to get fonts from universal text}
uvFont[4].fontFamily := famModern;
uvFont[5].fontFamily := famModern;
uvFont[6].fontFamily := famModern;
uvFont[7].fontFamily := famModern;
uvFont[8].fontFamily := famModern;
uvFont[9].fontFamily := famModern;
uvFont[10].fontFamily := famClassic;
uvFont[11].fontFamily := famClassic;
uvFont[12].fontFamily := famClassic;
uvFont[13].fontFamily := famClassic;

Apple Lisa ToolKit 3.0 Source Code Listing -- 893 of 1012

Apple Lisa Computer Technical Information


001772
001773
001774
001775
001776
001777
001778
001779
001780
001781
001782
001783
001784
001785
001786
001787
001788
001789
001790
001791
001792
001793
001794
001795
001796
001797
001798
001799
001800
001801
001802
001803
001804
001805
001806
001807
001808
001809
001810
001811
001812
001813
001814
001815
001816
001817
001818
001819

uvFont[14].fontFamily := famClassic;
uvFont[4].fontSize := 5;
uvFont[5].fontSize := 7;
uvFont[6].fontSize := 8;
uvFont[7].fontSize := 2;
uvFont[8].fontSize := 3;
uvFont[9].fontSize := 4;
uvFont[10].fontSize := 5;
uvFont[11].fontSize := 7;
uvFont[12].fontSize := 8;
uvFont[13].fontSize := 3;
uvFont[14].fontSize := 6;
END; {Methods of TInsertionPoint}
METHODS OF TOneParaSelection;
{$S SgTxtHot}
FUNCTION TOneParaSelection.CREATE(object: TObject; heap: THeap; itsView: TView; itsTextImage: TTextImage;
itsAnchorLPt: LPoint; itsParagraph: TEditPara; itsIndex: LONGINT;
oldLP: INTEGER; currLP: INTEGER): TOneParaSelection;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TOneParaSelection(TTextSelection.CREATE(object, heap, itsView, itsTextImage, itsAnchorLPt,
itsParagraph, itsIndex, Min(oldLP, currLP),
itsParagraph, itsIndex, Max(oldLP, currLP)));
WITH SELF DO
BEGIN
anchorBegin := oldLP;
anchorEnd := oldLP;
viewTick := -1; { force recalculation of extent }
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{$IFC fTextTrace}
PROCEDURE TOneParaSelection.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
TTextSelection.Fields(Field);
Field('anchorBegin: INTEGER');
Field('anchorEnd: INTEGER');
Field('');
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 894 of 1012

Apple Lisa Computer Technical Information


001820
001821
001822
001823
001824
001825
001826
001827
001828
001829
001830
001831
001832
001833
001834
001835
001836
001837
001838
001839
001840
001841
001842
001843
001844
001845
001846
001847
001848
001849
001850
001851
001852
001853
001854
001855
001856
001857
001858
001859
001860
001861
001862
001863
001864
001865
001866
001867

{$ENDC}
{$S SgTxtCld}
PROCEDURE TOneParaSelection.ChangeStyle(cmdNumber: TCmdNumber);
VAR newTypeStyle:
TTypeStyle;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
WITH SELF.textRange DO
{$H-}
SELF.DoChangeStyle(cmdNumber, firstPara, firstLP, lastLP, newTypeStyle);
{$H+}
SELF.currTypeStyle := newTypeStyle;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{CopySelf is used for copying to the clipboard}
FUNCTION TOneParaSelection.CopySelf(heap: THeap; view: TView): TMultiParaSelection;
VAR paragraph:
TEditPara;
selSize:
INTEGER;
newImage:
TParaImage;
lastLine:
TLineInfo;
textImage:
TTextImage;
text:
TText;
imageLRect:
LRect;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
text := TText.CREATE(NIL, heap, TStyleSheet.CREATE(NIL, heap));
imageLRect := view.extentLRect;
InsetLRect(imageLRect, cHorizMargin, cVertMargin);
textImage := SELF.textImage.TxtImgForClipBoard(heap, view, imageLRect, text, TRUE);
textImage.minHeight := 0;
text.txtImgList.InsLast(textImage);
selSize := SELF.textRange.lastLP-SELF.textRange.firstLP;
paragraph := textImage.NewEditPara(selSize, TParaFormat(SELF.textRange.firstPara.format.Clone(heap)));
paragraph.ReplPara(0, 0, SELF.textRange.firstPara, SELF.textRange.firstLP, selSize);
newImage := textImage.NewParaImage(paragraph, textImage.extentLRect, 0, 0);
textImage.imageList.InsLast(newImage);
textImage.text.paragraphs.InsLast(paragraph);
{ make view extentLRect exactly fit the lines }
textImage.RecomputeImages(actionNone, TRUE);
WITH textImage.extentLRect DO
view.extentLRect.bottom := bottom - top + 2 * cVertMargin;

Apple Lisa ToolKit 3.0 Source Code Listing -- 895 of 1012

Apple Lisa Computer Technical Information


001868
001869
001870
001871
001872
001873
001874
001875
001876
001877
001878
001879
001880
001881
001882
001883
001884
001885
001886
001887
001888
001889
001890
001891
001892
001893
001894
001895
001896
001897
001898
001899
001900
001901
001902
001903
001904
001905
001906
001907
001908
001909
001910
001911
001912
001913
001914
001915

CopySelf := TMultiParaSelection.CREATE(NIL, heap, view, textImage, zeroLPt, paragraph, 1, 0,


paragraph, 1, selSize, TRUE);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtWrm}
PROCEDURE TOneParaSelection.DeleteAndFree;
VAR delta: INTEGER;
PROCEDURE DelText;
BEGIN
IF SELF.isParaSelection AND
(SELF.textRange.firstIndex <> SELF.textImage.text.paragraphs.size) THEN
BEGIN
SELF.textImage.text.DelPara(SELF.textRange.firstPara, FALSE);
SELF.textImage.text.paragraphs.DelObject(SELF.textRange.firstPara, TRUE);
END
ELSE
SELF.textRange.firstPara.ReplPString(SELF.textRange.firstLP,
SELF.textRange.lastLP-SELF.textRange.firstLP, NIL);
END;
PROCEDURE Adjust;
PROCEDURE Subtract(paraImage: TParaImage);
BEGIN
paraImage.AdjustLineLPs(SELF.textRange.firstLP, delta);
END;
BEGIN
IF NOT SELF.isParaSelection THEN
BEGIN
delta := SELF.textRange.firstLP - SELF.textRange.lastLP;
SELF.textRange.firstPara.EachImage(Subtract);
END;
WITH SELF.textRange DO
BEGIN
IF SELF.isParaSelection THEN
BEGIN
{$H-}
firstPara := TEditPara(SELF.textImage.text.paragraphs.At(firstIndex));
{$H+}
firstLP := 0;
lastPara := firstPara;
END;
lastLP := firstLP;
END;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 896 of 1012

Apple Lisa Computer Technical Information


001916
001917
001918
001919
001920
001921
001922
001923
001924
001925
001926
001927
001928
001929
001930
001931
001932
001933
001934
001935
001936
001937
001938
001939
001940
001941
001942
001943
001944
001945
001946
001947
001948
001949
001950
001951
001952
001953
001954
001955
001956
001957
001958
001959
001960
001961
001962
001963

BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.ChangeText(DelText, Adjust);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
FUNCTION TOneParaSelection.DeleteButSave: TText;
VAR oldPara:
TEditPara;
selSize:
INTEGER;
newPara:
TEditPara;
text:
TText;
PROCEDURE DelText;
BEGIN
oldPara := SELF.textRange.firstPara;
IF SELF.isParaSelection AND
(SELF.textRange.firstIndex <> SELF.textImage.text.paragraphs.size) THEN
BEGIN
SELF.textImage.text.DelPara(oldPara, FALSE);
SELF.textImage.text.paragraphs.DelObject(oldPara, FALSE);
newPara := oldPara;
END
ELSE
BEGIN
selSize := SELF.textRange.lastLP-SELF.textRange.firstLP;
newPara := SELF.textImage.NewEditPara(selSize, oldPara.format);
newPara.ReplPara(0, 0, oldPara, SELF.textRange.firstLP, selSize);
oldPara.ReplPString(SELF.textRange.firstLP, selSize, NIL);
END;
text := TText.CREATE(NIL, SELF.Heap, NIL);
text.paragraphs.InsLast(newpara);
END;
PROCEDURE Adjust;
PROCEDURE Subtract(paraImage: TParaImage);
BEGIN
paraImage.AdjustLineLPs(SELF.textRange.firstLP, -selSize);
END;
BEGIN
WITH SELF.textRange DO
BEGIN
IF SELF.isParaSelection THEN
BEGIN
{$H-}
firstPara := TEditPara(SELF.textImage.text.paragraphs.At(firstIndex));
{$H+}
firstLP := 0;

Apple Lisa ToolKit 3.0 Source Code Listing -- 897 of 1012

Apple Lisa Computer Technical Information


001964
001965
001966
001967
001968
001969
001970
001971
001972
001973
001974
001975
001976
001977
001978
001979
001980
001981
001982
001983
001984
001985
001986
001987
001988
001989
001990
001991
001992
001993
001994
001995
001996
001997
001998
001999
002000
002001
002002
002003
002004
002005
002006
002007
002008
002009
002010
002011

lastPara := firstPara;
END;
lastLP := firstLP;
END;
IF NOT SELF.isParaSelection THEN
SELF.textRange.firstPara.EachImage(Subtract);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.ChangeText(DelText, Adjust);
DeleteButSave := text;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TOneParaSelection.MouseMove(mouseLPt: LPoint);
{ assumes highlighting is ON }
VAR currPImage:
TParaImage;
currLP:
INTEGER;
oldLP:
INTEGER;
{ end (ie. not the anchor) of indication }
multiParaSelection: TMultiParaSelection;
textImage:
TTextImage;
firstTxtImg:
TTextImage;
first, last:
INTEGER;
paraSelect:
BOOLEAN;
paraIndex:
LONGINT;
PROCEDURE HiExtOnPads(highTransit: THighTransit; startLP,endLP: INTEGER);
BEGIN
SELF.textImage.text.HiliteParagraphs(highTransit, SELF.textRange.firstIndex, startLP,
SELF.textRange.firstIndex, endLP,
SELF.isParaSelection);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.currLPt := mouseLPt;
textImage := SELF.textImage.FindTextImage(mouseLPt, firstTxtImg);
textImage.FindParaAndLp(mouseLPt, currPImage, paraIndex, currLP);
IF currPImage.paragraph <> SELF.textRange.firstPara THEN
BEGIN
{call new with same paraImage, followed by MouseMove so highlighting will work correctly}
paraSelect := SELF.isParaSelection;
first := SELF.anchorBegin;
last := SELF.anchorEnd;
WITH SELF, textRange DO

Apple Lisa ToolKit 3.0 Source Code Listing -- 898 of 1012

Apple Lisa Computer Technical Information


002012
002013
002014
002015
002016
002017
002018
002019
002020
002021
002022
002023
002024
002025
002026
002027
002028
002029
002030
002031
002032
002033
002034
002035
002036
002037
002038
002039
002040
002041
002042
002043
002044
002045
002046
002047
002048
002049
002050
002051
002052
002053
002054
002055
002056
002057
002058
002059

{$H-}
multiParaSelection := TMultiParaSelection(SELF.FreedAndReplacedBy(
TMultiParaSelection.CREATE(NIL, SELF.Heap,
view, firstTxtImg, anchorLPt,
firstPara, firstIndex, firstLP,
firstPara, firstIndex, lastLP, firstLP = anchorBegin)));
{$H+}
WITH multiParaSelection DO
BEGIN
isParaSelection := paraSelect;
anchorBegin := first;
anchorEnd := last;
isWordSelection := NOT paraSelect AND (first <> last);
END;
multiParaSelection.MouseMove(mouseLPt);
END
ELSE IF NOT SELF.isParaSelection THEN
BEGIN
IF SELF.isWordSelection THEN
BEGIN
{So dragging over last half of last character of word doesn't select space}
WITH SELF.textRange DO
BEGIN
{$H-}
IF NOT firstPara.Qualifies(currLP) THEN
IF currLP > 0 THEN
currLP := currLP - 1;
{$H+}
END;
SELF.textRange.firstPara.FindWordBounds(currLP, first, last);
IF first <= SELF.anchorBegin THEN
currLP := first
ELSE
currLP := last;
END;
IF currLP <= SELF.anchorBegin THEN
BEGIN
oldLP := SELF.textRange.firstLP;
IF SELF.anchorEnd <> SELF.textRange.lastLP THEN
HiExtOnPads(hOnToOff, SELF.anchorEnd, SELF.textRange.lastLP);
SELF.textRange.firstLP := currLP;
SELF.textRange.lastLP := SELF.anchorEnd;
END
ELSE
BEGIN
oldLP := SELF.textRange.lastLP;
IF SELF.anchorBegin <> SELF.textRange.firstLP THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 899 of 1012

Apple Lisa Computer Technical Information


002060
002061
002062
002063
002064
002065
002066
002067
002068
002069
002070
002071
002072
002073
002074
002075
002076
002077
002078
002079
002080
002081
002082
002083
002084
002085
002086
002087
002088
002089
002090
002091
002092
002093
002094
002095
002096
002097
002098
002099
002100
002101
002102
002103
002104
002105
002106
002107

HiExtOnPads(hOnToOff, SELF.textRange.firstLP, SELF.anchorBegin);


SELF.textRange.firstLP := SELF.anchorBegin;
SELF.textRange.lastLP := currLP;
END;
IF currLP <> oldLP THEN
IF currLP < oldLP THEN
HiExtOnPads(hOffToOn, currLP, oldLP)
ELSE
HiExtOnPads(hOffToOn, oldLP, currLP);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TOneParaSelection.MousePress(mouseLPt: LPoint);
VAR first, last:
INTEGER;
oneParaSelection:
TOneParaSelection;
multiParaSelection: TMultiParaSelection;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF clickState.fShift THEN
SELF.MouseMove(mouseLPt)
ELSE IF clickState.clickCount = 2 THEN {double click}
BEGIN
{should select words at beginning and end of current selection (later)}
SELF.textRange.firstPara.FindWordBounds(SELF.anchorBegin, first, last);
SELF.textImage.text.HiliteRange(hOnToOff, SELF.textRange, SELF.isParaSelection);
WITH SELF, textRange DO
{$H-}
oneParaSelection := TOneParaSelection(SELF.FreedAndReplacedBy(
TOneParaSelection.CREATE(NIL, SELF.Heap,
view, textImage, anchorLPt,
firstPara, firstIndex, first, last)));
{$H+}
WITH oneParaSelection DO
BEGIN
anchorBegin := first;
anchorEnd := last;
isWordSelection := TRUE;
END;
oneParaSelection.textImage.text.HiliteRange(hOnToOff, oneParaSelection.textRange,
SELF.isParaSelection);
END
ELSE IF clickState.clickCount = 3 THEN {triple click}
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 900 of 1012

Apple Lisa Computer Technical Information


002108
002109
002110
002111
002112
002113
002114
002115
002116
002117
002118
002119
002120
002121
002122
002123
002124
002125
002126
002127
002128
002129
002130
002131
002132
002133
002134
002135
002136
002137
002138
002139
002140
002141
002142
002143
002144
002145
002146
002147
002148
002149
002150
002151
002152
002153
002154
002155

{Turn current highlighting off first}


SELF.textImage.text.HiliteRange(hOnToOff, SELF.textRange, SELF.isParaSelection);
WITH SELF, textRange DO
{$H-}
oneParaSelection := TOneParaSelection(SELF.FreedAndReplacedBy(
TOneParaSelection.CREATE(NIL, SELF.Heap,
view, textImage, anchorLPt,
firstPara, firstIndex, 0, firstPara.size)));
{$H+}
WITH oneParaSelection DO
BEGIN
isParaSelection := TRUE;
isWordSelection := FALSE;
anchorBegin := 0;
anchorEnd := textRange.lastLP;
END;
oneParaSelection.textImage.text.HiliteRange(hOnToOff, oneParaSelection.textRange, TRUE);
END
ELSE
SELF.textImage.MousePress(mouseLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtHot}
PROCEDURE TOneParaSelection.MouseRelease;
VAR insPt: TInsertionPoint;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF SELF.textRange.firstLP = SELF.textRange.lastLP THEN
BEGIN
insPt := SELF.BecomeInsertionPoint;
insPt.textImage.text.HiliteRange(hOffToOn, insPt.textRange, SELF.isParaSelection);
END
ELSE
SELF.textImage.text.ChangeSelInOtherPanels(SELF);
SUPERSELF.MouseRelease;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
FUNCTION TOneParaSelection.SelSize: INTEGER;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
SelSize := SELF.textRange.lastLP - SELF.textRange.firstLP;
{$IFC fTrace}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 901 of 1012

Apple Lisa Computer Technical Information


002156
002157
002158
002159
002160
002161
002162
002163
002164
002165
002166
002167
002168
002169
002170
002171
002172
002173
002174
002175
002176
002177
002178
002179
002180
002181
002182
002183
002184
002185
002186
002187
002188
002189
002190
002191
002192
002193
002194
002195
002196
002197
002198
002199
002200
002201
002202
002203

{$S SgTxtHot}
PROCEDURE TOneParaSelection.StyleFromContext;
VAR typeStyle: TTypeStyle;
BEGIN
{$IFC fTrace}BP(8);{$ENDC}
SELF.textRange.firstPara.StyleAt(SELF.textRange.firstLP, typeStyle);
SELF.currTypeStyle := typeStyle;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
END; {Methods of TOneParaSelection}
METHODS OF TMultiParaSelection;
{$S SgTxtCld}
FUNCTION TMultiParaSelection.CREATE(object: TObject; heap: THeap; itsView: TView;
itsTextImage: TTextImage; itsAnchorLPt: LPoint;
beginPara: TEditPara; beginIndex: LONGINT; beginLP: INTEGER;
endPara: TEditPara; endIndex: LONGINT; endLP: INTEGER;
beginIsAnchor: BOOLEAN): TMultiParaSelection;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TMultiParaSelection(TTextSelection.CREATE(object, heap, itsView, itsTextImage, itsAnchorLPt,
beginPara, beginIndex, beginLP,
endPara, endIndex, endLP));
WITH SELF DO
BEGIN
IF beginIsAnchor THEN
BEGIN
anchorPara := beginPara;
anchorIndex := beginIndex;
anchorBegin := beginLP;
anchorEnd := beginLP;
END
ELSE
BEGIN
anchorPara := endPara;
anchorIndex := endIndex;
anchorBegin := endLP;

Apple Lisa ToolKit 3.0 Source Code Listing -- 902 of 1012

Apple Lisa Computer Technical Information


002204
002205
002206
002207
002208
002209
002210
002211
002212
002213
002214
002215
002216
002217
002218
002219
002220
002221
002222
002223
002224
002225
002226
002227
002228
002229
002230
002231
002232
002233
002234
002235
002236
002237
002238
002239
002240
002241
002242
002243
002244
002245
002246
002247
002248
002249
002250
002251

anchorEnd := endLP;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{$IFC fTextTrace}
PROCEDURE TMultiParaSelection.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
TTextSelection.Fields(Field);
Field('anchorPara: TEditPara');
Field('anchorIndex: LONGINT');
Field('anchorBegin: INTEGER');
Field('anchorEnd: INTEGER');
Field('');
END;
{$ENDC}
{$S SgTxtCld}
PROCEDURE TMultiParaSelection.ChangeStyle(cmdNumber: TCmdNumber);
VAR newTypeStyle:
TTypeStyle;
s:
TListScanner;
paragraph:
TEditPara;
lastPara:
TEditPara;
endRng:
INTEGER;
paraImage:
TParaImage;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
newTypeStyle := SELF.currTypeStyle;
lastPara := SELF.textRange.lastPara;
s := SELF.textImage.text.paragraphs.ScannerFrom(SELF.textRange.firstIndex-1, scanForward);
WHILE s.Scan(paragraph) DO
IF paragraph = SELF.textRange.firstPara THEN
BEGIN
SELF.DoChangeStyle(cmdNumber, paragraph, SELF.textRange.firstLP,
paragraph.size, newTypeStyle);
SELF.currTypeStyle := newTypeStyle;
IF paragraph = lastPara THEN
s.Done;
END
ELSE
BEGIN
IF paragraph = lastPara THEN
BEGIN
endRng := SELF.textRange.lastLP;
s.Done;

Apple Lisa ToolKit 3.0 Source Code Listing -- 903 of 1012

Apple Lisa Computer Technical Information


002252
002253
002254
002255
002256
002257
002258
002259
002260
002261
002262
002263
002264
002265
002266
002267
002268
002269
002270
002271
002272
002273
002274
002275
002276
002277
002278
002279
002280
002281
002282
002283
002284
002285
002286
002287
002288
002289
002290
002291
002292
002293
002294
002295
002296
002297
002298
002299

END
ELSE
endRng := paragraph.size;
SELF.DoChangeStyle(cmdNumber, paragraph, 0, endRng, newTypeStyle);
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{CopySelf is used for copying to the clipboard}
FUNCTION TMultiParaSelection.CopySelf(heap: THeap; view: TView): TMultiParaSelection;
VAR srcPara:
TEditPara;
cpyPara:
TEditPara;
cpyFirstPara:
TEditPara;
srcLastPara:
TEditPara;
cpyLastPara:
TEditPara;
selSize1:
INTEGER;
selSize2:
INTEGER;
textImage:
TTextImage;
s:
TListScanner;
text:
TText;
textRange:
TTextRange;
imageLRect:
LRect;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
text := TText.CREATE(NIL, heap, TStyleSheet.CREATE(NIL, heap));
imageLRect := view.extentLRect;
InsetLRect(imageLRect, cHorizMargin, cVertMargin);
textImage := SELF.textImage.TxtImgForClipBoard(heap, view, imageLRect, text, TRUE);
textImage.minHeight := 0;
text.txtImgList.InsLast(textImage);
textRange := SELF.textRange;
srcPara := textRange.firstPara;
selSize1 := srcPara.size-textRange.firstLP;
cpyPara := textImage.NewEditPara(selSize1, TParaFormat(srcPara.format.clone(heap)));
cpyPara.ReplPara(0, 0, srcPara, textRange.firstLP, selSize1);
cpyFirstPara := cpyPara;
textImage.text.paragraphs.InsLast(cpyFirstPara);
IF textRange.firstPara <> textRange.lastPara THEN
BEGIN
srcLastPara := textRange.lastPara;
selSize2 := textRange.lastLP;
cpyLastPara := textImage.NewEditPara(selSize2, TParaFormat(srcLastPara.format.clone(heap)));

Apple Lisa ToolKit 3.0 Source Code Listing -- 904 of 1012

Apple Lisa Computer Technical Information


002300
002301
002302
002303
002304
002305
002306
002307
002308
002309
002310
002311
002312
002313
002314
002315
002316
002317
002318
002319
002320
002321
002322
002323
002324
002325
002326
002327
002328
002329
002330
002331
002332
002333
002334
002335
002336
002337
002338
002339
002340
002341
002342
002343
002344
002345
002346
002347

cpyLastPara.ReplPara(0, 0, srcLastPara, 0, selSize2);


{skip first paragraph by not subtracting one from firstIndex}
s := SELF.textImage.text.paragraphs.ScannerFrom(textRange.firstIndex, scanForward);
WHILE s.Scan(srcPara) DO
BEGIN
IF srcPara = textRange.lastPara THEN
BEGIN
cpyPara := cpyLastPara;
s.Done;
END
ELSE
BEGIN
cpyPara := textImage.NewEditPara(srcPara.size,
TParaFormat(srcPara.format.clone(heap)));
cpyPara.ReplPara(0, 0, srcPara, 0, srcPara.size);
END;
textImage.text.paragraphs.InsLast(cpyPara);
END;
END;
textImage.RecomputeImages(actionNone, TRUE);
WITH textImage.extentLRect DO
view.extentLRect.bottom := bottom - top + 2 * cVertMargin;
CopySelf := TMultiParaSelection.CREATE(NIL, heap, view, textImage, zeroLPt,
TEditPara(textImage.text.paragraphs.First), 1, 0,
TEditPara(textImage.text.paragraphs.Last),
textRange.lastIndex - textRange.firstIndex + 1,
selSize2, TRUE);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
FUNCTION TMultiParaSelection.Delete(saveIt: BOOLEAN): TText;
VAR firstPara:
TEditPara;
lastPara:
TEditPara;
paragraph:
TEditPara;
text:
TText;
paraList:
TList;
s:
TListScanner;
selSize:
INTEGER;
textRange:
TTextRange;
numParas:
INTEGER;
PROCEDURE DelText;

Apple Lisa ToolKit 3.0 Source Code Listing -- 905 of 1012

Apple Lisa Computer Technical Information


002348
002349
002350
002351
002352
002353
002354
002355
002356
002357
002358
002359
002360
002361
002362
002363
002364
002365
002366
002367
002368
002369
002370
002371
002372
002373
002374
002375
002376
002377
002378
002379
002380
002381
002382
002383
002384
002385
002386
002387
002388
002389
002390
002391
002392
002393
002394
002395

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
{If saveIt is TRUE, we want to save the text we're deleting, so create a text object}
IF saveIt THEN
BEGIN
text := TText.CREATE(NIL, SELF.Heap, NIL);
paraList := text.paragraphs;
END
ELSE
text := NIL;
textRange := SELF.textRange;
firstPara := textRange.firstPara;
lastPara := textRange.lastPara;
numParas := SELF.textImage.text.paragraphs.size;
{If the last paragraph is selected, treat this like a non-para selection, so that one
empty para will be left at the end after the delete}
IF textRange.lastIndex = numParas THEN
SELF.isParaSelection := FALSE;
s := SELF.textImage.text.paragraphs.ScannerFrom(textRange.firstIndex-1, scanForward);
WHILE s.Scan(paragraph) DO
IF paragraph = firstPara THEN
BEGIN
IF SELF.isParaSelection THEN
{If isParaSelection is TRUE then insert it in our save list and
delete it from the textImage's list}
BEGIN
IF saveIt THEN
paraList.InsLast(firstPara);
SELF.textImage.text.DelPara(firstPara, FALSE);
s.Delete(NOT saveIt);
END
ELSE
{If the beginning of the selection is part of a paragraph, then save
the characters in a new paragraph and delete them in the old}
BEGIN
selSize := firstPara.size - textRange.firstLP;
IF saveIt THEN
BEGIN
paragraph := SELF.textImage.NewEditPara(selSize, firstPara.format);
paragraph.ReplPara(0, 0, firstPara, textRange.firstLP, selSize);
paraList.InsLast(paragraph);
END;
firstPara.ReplPString(textRange.firstLP, selSize, NIL);
END;
IF firstPara = lastPara THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 906 of 1012

Apple Lisa Computer Technical Information


002396
002397
002398
002399
002400
002401
002402
002403
002404
002405
002406
002407
002408
002409
002410
002411
002412
002413
002414
002415
002416
002417
002418
002419
002420
002421
002422
002423
002424
002425
002426
002427
002428
002429
002430
002431
002432
002433
002434
002435
002436
002437
002438
002439
002440
002441
002442
002443

s.Done
END
ELSE
BEGIN
s.Delete(FALSE);
IF paragraph = lastPara THEN
BEGIN
s.Done;
IF NOT SELF.isParaSelection THEN
{If the end of the selection is a part of a paragraph, then save the
selected characters in a new paragraph and append the rest to the
first paragraph. Finally, delete and free the last paragraph }
BEGIN
selSize := textRange.lastLP;
IF saveIt THEN
BEGIN
paragraph := SELF.textImage.NewEditPara(selSize, lastPara.format);
paragraph.ReplPara(0, 0, lastPara, 0, selSize);
END;
firstPara.ReplPara(firstPara.size, 0, lastPara, selSize,
lastPara.size-selSize);
SELF.textImage.text.DelPara(lastPara, TRUE);
END
ELSE
SELF.textImage.text.DelPara(paragraph, NOT saveIt);
END
ELSE
{Delete entire intermediate paragraphs from the textImage}
SELF.textImage.text.DelPara(paragraph, NOT saveIt);
IF saveIt THEN
paraList.InsLast(paragraph);
END;
{$IFC fTrace}EP;{$ENDC}
END; {DelText}
PROCEDURE SetRange;
BEGIN
WITH SELF, textRange DO
IF isParaSelection THEN
BEGIN
{$H-}
firstPara := TEditPara(textImage.text.paragraphs.At(firstIndex));
{$H+}
firstLP := 0;
END;
WITH SELF.textRange DO
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 907 of 1012

Apple Lisa Computer Technical Information


002444
002445
002446
002447
002448
002449
002450
002451
002452
002453
002454
002455
002456
002457
002458
002459
002460
002461
002462
002463
002464
002465
002466
002467
002468
002469
002470
002471
002472
002473
002474
002475
002476
002477
002478
002479
002480
002481
002482
002483
002484
002485
002486
002487
002488
002489
002490
002491

END;

lastPara := firstPara;
lastIndex := firstIndex;
lastLP := firstLP;
END;

BEGIN
{$IFC fTrace}BP(11);{$ENDC}
SELF.ChangeText(DelText, SetRange);
Delete := text;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TMultiParaSelection.DeleteAndFree;
VAR text:
TText; {dummy var since Delete returns TText; will always be NIL}
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
text := SELF.Delete(FALSE);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
FUNCTION TMultiParaSelection.DeleteButSave: TText;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
DeleteButSave := SELF.Delete(TRUE);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TMultiParaSelection.MouseMove(mouseLPt: LPoint);
{ assumes highlighting is ON }
VAR endPara:
TEditPara;
currPara:
TEditPara;
currPImage:
TParaImage;
oldPImage:
TParaImage;
oldPara:
TEditPara;
paragraph:
TEditPara;
textrange:
TTextRange;
textImage:
TTextImage;
firstTxtImg:
TTextImage;
s:
TListScanner;
paraImage:
TParaImage;
newText:
TText;

Apple Lisa ToolKit 3.0 Source Code Listing -- 908 of 1012

Apple Lisa Computer Technical Information


002492
002493
002494
002495
002496
002497
002498
002499
002500
002501
002502
002503
002504
002505
002506
002507
002508
002509
002510
002511
002512
002513
002514
002515
002516
002517
002518
002519
002520
002521
002522
002523
002524
002525
002526
002527
002528
002529
002530
002531
002532
002533
002534
002535
002536
002537
002538
002539

currLP:
oldLP:
mouseBeforeAnchor:
oldBeforeCurr:
beginIsAnchor:
currIndex:
oldIndex:
startIndex:
endIndex:
startLP:
endLP:
first, last:
selChanged:
{$IFC fTextTrace}
str1:
str2:
{$ENDC}

INTEGER;
INTEGER;
BOOLEAN;
BOOLEAN;
BOOLEAN;
LONGINT;
LONGINT;
LONGINT;
LONGINT;
INTEGER;
INTEGER;
INTEGER;
BOOLEAN;

{ end (ie. not the anchor) of indication }


{ is mouse LPt before the anchor LPt }
{ is old end LPt before curr LPt }

STR255;
STR255;

PROCEDURE NextIndex(oldIndex: LONGINT; oldLP: INTEGER; VAR newIndex: LONGINT; VAR newLP: INTEGER);
BEGIN
IF oldIndex < SELF.textImage.text.paragraphs.size THEN
BEGIN
newIndex := oldIndex + 1;
newLP := 0;
END
ELSE
BEGIN
newIndex := oldIndex;
newLP := oldLP;
END;
END;
PROCEDURE PrevIndex(oldIndex: LONGINT; oldLP: INTEGER; VAR newIndex: LONGINT; VAR newLP: INTEGER);
BEGIN
IF oldIndex > 1 THEN
BEGIN
newIndex := oldIndex - 1;
newLP := TEditPara(SELF.textImage.text.paragraphs.At(newIndex)).size;
END
ELSE
BEGIN
newIndex := oldIndex;
newLP := oldLP;
END;
END;
PROCEDURE HiExtOnPads(highTransit: THighTransit;
startIndex: LONGINT; startLP: INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 909 of 1012

Apple Lisa Computer Technical Information


002540
002541
002542
002543
002544
002545
002546
002547
002548
002549
002550
002551
002552
002553
002554
002555
002556
002557
002558
002559
002560
002561
002562
002563
002564
002565
002566
002567
002568
002569
002570
002571
002572
002573
002574
002575
002576
002577
002578
002579
002580
002581
002582
002583
002584
002585
002586
002587

endIndex: LONGINT; endLP: INTEGER);


BEGIN
SELF.textImage.text.HiliteParagraphs(highTransit, startIndex, startLP, endIndex, endLP,
SELF.isParaSelection);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.currLPt := mouseLPt;
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
LIntToHex(ORD(SELF.textRange.firstPara), @str1);
LIntToHex(ORD(SELF.textRange.lastPara), @str2);
Writeln;
Writeln('*** MultiPara MouseMove: firstPara, lastPara = (', str1, ',', str2, ')');
Writeln('*** About to call FindParaAndLp');
END;
{$ENDC}
textRange := SELF.textRange;
textImage := SELF.textImage.FindTextImage(mouseLPt, firstTxtImg);
SELF.textImage := firstTxtImg;
textImage.FindParaAndLp(mouseLPt, currPImage, currIndex, currLP);
currPara := currPImage.paragraph;
IF SELF.isParaSelection THEN
BEGIN
IF currIndex < SELF.anchorIndex THEN
currLP := 0
ELSE
currLP := currPara.size;
END
ELSE IF SELF.isWordSelection THEN
BEGIN
currPara.FindWordBounds(currLP, first, last);
IF currIndex < SELF.anchorIndex THEN
currLP := first
ELSE IF currIndex > SELF.anchorIndex THEN
currLP := last
ELSE IF first <= SELF.anchorBegin THEN
currLP := first
ELSE
currLP := last;
END;
IF currIndex = SELF.anchorIndex THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 910 of 1012

Apple Lisa Computer Technical Information


002588
002589
002590
002591
002592
002593
002594
002595
002596
002597
002598
002599
002600
002601
002602
002603
002604
002605
002606
002607
002608
002609
002610
002611
002612
002613
002614
002615
002616
002617
002618
002619
002620
002621
002622
002623
002624
002625
002626
002627
002628
002629
002630
002631
002632
002633
002634
002635

mouseBeforeAnchor := currLP < SELF.anchorBegin


ELSE
mouseBeforeAnchor := currIndex < SELF.anchorIndex;
beginIsAnchor := (textRange.firstIndex = SELF.anchorIndex) AND (textRange.firstLP = SELF.anchorBegin);
{After determining if the mouse is before or after the anchor position, set up variables for
higlighting below and dehilite any text that was on other side of the anchor previous to this
mouse move}
IF mouseBeforeAnchor THEN
BEGIN
oldIndex := textRange.firstIndex;
oldLP := textRange.firstLP;
IF beginIsAnchor THEN
{current Position is on other side of anchor, so must dehighlight}
BEGIN
IF SELF.isParaSelection THEN
IF SELF.anchorIndex = textRange.lastIndex THEN
startIndex := -1
ELSE
NextIndex(SELF.anchorIndex, SELF.anchorEnd, startIndex, startLP)
ELSE
BEGIN
startIndex := SELF.anchorIndex;
startLP := SELF.anchorEnd;
END;
IF startIndex > 0 THEN
HiExtOnPads(hOnToOff, startIndex, startLP, textRange.lastIndex, textRange.lastLP);
END;
WITH SELF, textRange DO
BEGIN
firstPara := currPara;
firstIndex := currIndex;
lastPara := anchorPara;
lastIndex := anchorIndex;
firstLP := currLP;
lastLP := anchorEnd;
END;
END
ELSE
BEGIN
oldIndex := textRange.lastIndex;
oldLp := textRange.lastLP;
IF NOT beginIsAnchor THEN
BEGIN
{current Position is on other side of anchor, so must dehighlight}
IF SELF.isParaSelection THEN
PrevIndex(SELF.anchorIndex, SELF.anchorBegin, startIndex, startLP)

Apple Lisa ToolKit 3.0 Source Code Listing -- 911 of 1012

Apple Lisa Computer Technical Information


002636
002637
002638
002639
002640
002641
002642
002643
002644
002645
002646
002647
002648
002649
002650
002651
002652
002653
002654
002655
002656
002657
002658
002659
002660
002661
002662
002663
002664
002665
002666
002667
002668
002669
002670
002671
002672
002673
002674
002675
002676
002677
002678
002679
002680
002681
002682
002683

ELSE
BEGIN
startIndex := SELF.anchorIndex;
startLP := SELF.anchorBegin;
END;
HiExtOnPads(hOnToOff, textRange.firstIndex, textRange.firstLP, startIndex, startLP);
END;
WITH SELF, textRange DO
BEGIN
lastPara := currPara;
lastIndex := currIndex;
firstPara := anchorPara;
firstIndex := anchorIndex;
firstLP := anchorBegin;
lastLP := currLP;
END;
END;
IF mouseBeforeAnchor = beginIsAnchor THEN
oldBeforeCurr := NOT mouseBeforeAnchor
ELSE IF currIndex = oldIndex THEN
oldBeforeCurr := oldLP < currLP
ELSE
oldBeforeCurr := oldIndex < currIndex;
IF oldBeforeCurr THEN
BEGIN
startIndex := oldIndex;
startLP := oldLP;
endIndex := currIndex;
endLP := currLP;
END
ELSE
BEGIN
startIndex := currIndex;
startLP := currLP;
endIndex := oldIndex;
endLP := oldLP;
END;
selChanged := TRUE;
IF SELF.isParaSelection THEN
IF startIndex = endIndex THEN
selChanged := FALSE
ELSE IF mouseBeforeAnchor THEN
PrevIndex(endIndex, endLP, endIndex, endLP)
ELSE
NextIndex(startIndex, startLP, startIndex, startLP)

Apple Lisa ToolKit 3.0 Source Code Listing -- 912 of 1012

Apple Lisa Computer Technical Information


002684
002685
002686
002687
002688
002689
002690
002691
002692
002693
002694
002695
002696
002697
002698
002699
002700
002701
002702
002703
002704
002705
002706
002707
002708
002709
002710
002711
002712
002713
002714
002715
002716
002717
002718
002719
002720
002721
002722
002723
002724
002725
002726
002727
002728
002729
002730
002731

ELSE
selChanged := (startIndex <> endIndex) OR (startLP <> endLP);
IF selChanged THEN
HiExtOnPads(hOffToOn, startIndex, startLP, endIndex, endLP);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TMultiParaSelection.MousePress(mouseLPt: LPoint);
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF clickState.fShift THEN
SELF.MouseMove(mouseLPt)
ELSE IF clickState.clickCount > 1 THEN
BEGIN
{For now do nothing if some jerk starts double/triple clicking while dragging}
END
ELSE
SELF.textImage.MousePress(mouseLPt);
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
PROCEDURE TMultiParaSelection.MouseRelease;
VAR insPt:
TInsertionPoint;
oneParaSel: TOneParaSelection;
first,last: INTEGER;
isPara:
BOOLEAN;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF SELF.textRange.firstPara = SELF.textRange.lastPara THEN
BEGIN
isPara := SELF.isParaSelection;
IF SELF.textRange.firstLP = SELF.textRange.lastLP THEN
BEGIN
insPt := SELF.BecomeInsertionPoint;
insPt.isParaSelection := isPara;
IF NOT isPara THEN
insPt.textImage.text.HiliteRange(hOffToOn, insPt.textRange, FALSE);
END
ELSE
BEGIN
first := SELF.anchorBegin;
last := SELF.anchorEnd;

Apple Lisa ToolKit 3.0 Source Code Listing -- 913 of 1012

Apple Lisa Computer Technical Information


002732
002733
002734
002735
002736
002737
002738
002739
002740
002741
002742
002743
002744
002745
002746
002747
002748
002749
002750
002751
002752
002753
002754
002755
002756
002757
002758
002759
002760
002761
002762
002763
002764
002765
002766
002767
002768
002769
002770
002771
002772
002773
002774
002775
002776
002777
002778
002779

WITH SELF, textRange DO


{$H-}
oneParaSel := TOneParaSelection(SELF.FreedAndReplacedBy(TOneParaSelection.CREATE(NIL,
SELF.Heap, view, textImage, anchorLPoint,
firstPara, firstIndex, firstLP, lastLP)));
{$H+}
WITH oneParaSel DO
BEGIN
anchorBegin := first;
anchorEnd := last;
isParaSelection := isPara;
isWordSelection := NOT isPara AND (first <> last);
END;
SELF.textImage.text.ChangeSelInOtherPanels(oneParaSel);
END;

END
ELSE
SELF.textImage.text.ChangeSelInOtherPanels(SELF);
SUPERSELF.MouseRelease;
{$IFC fTrace}EP;{$ENDC}
END;

{$S SgTxtCld}
FUNCTION TMultiParaSelection.SelSize: INTEGER;
VAR size:
INTEGER;
s:
TListScanner;
paragraph: TEditPara;
BEGIN
{$IFC fTrace}BP(9);{$ENDC}
IF SELF.textRange.firstPara = SELF.textRange.lastPara THEN
size := SELF.textRange.lastLP - SELF.textRange.firstLP
ELSE
BEGIN
size := SELF.textRange.firstPara.size - SELF.textRange.firstLP;
{skip first paragraph by not subtracting one from firstIndex}
s := SELF.textImage.text.paragraphs.ScannerFrom(SELF.textRange.firstIndex, scanForward);
WHILE s.Scan(paragraph) DO
IF paragraph = SELF.textRange.lastPara THEN
BEGIN
size := size + SELF.textRange.lastLP;
s.Done;
END
ELSE
size := size + paragraph.size;
END;
SelSize := size;
{$IFC fTrace}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 914 of 1012

Apple Lisa Computer Technical Information


002780
002781
002782
002783
002784
002785
002786
002787
002788
002789
002790
002791
002792
002793
002794
002795
002796
002797
002798
002799
002800
002801
002802
002803
002804
002805
002806
002807
002808
002809
002810
002811
002812
002813
002814
002815
002816
002817
002818
002819
002820
002821
002822
002823
002824
002825
002826
002827

END;
{$S SgTxtCld}
PROCEDURE TMultiParaSelection.StyleFromContext;
VAR typeStyle: TTypeStyle;
BEGIN
{$IFC fTrace}BP(8);{$ENDC}
SELF.textRange.firstPara.StyleAt(SELF.textRange.firstLP, typeStyle);
SELF.currTypeStyle := typeStyle;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
END; {Methods of TMultiParaSelection}
{$S SgTxtCld}
METHODS OF TClearTextCmd;
FUNCTION TClearTextCmd.CREATE(object: TObject; heap: THeap; itsCmdNumber: TCmdNumber;
itsImage: TImage; itsText: TText): TClearTextCmd;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TClearTextCmd(TCommand.CREATE(object, heap, itsCmdNumber, itsImage, TRUE, revealAll));
WITH SELF DO
BEGIN
savedText := NIL;
text := itsText;
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TClearTextCmd.Free;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF SELF.savedText <> NIL THEN
SELF.savedText.FreeSelf(FALSE);
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fTextTrace}
PROCEDURE TClearTextCmd.Fields(PROCEDURE Field(nameAndType: S255));

Apple Lisa ToolKit 3.0 Source Code Listing -- 915 of 1012

Apple Lisa Computer Technical Information


002828
002829
002830
002831
002832
002833
002834
002835
002836
002837
002838
002839
002840
002841
002842
002843
002844
002845
002846
002847
002848
002849
002850
002851
002852
002853
002854
002855
002856
002857
002858
002859
002860
002861
002862
002863
002864
002865
002866
002867
002868
002869
002870
002871
002872
002873
002874
002875

BEGIN
SUPERSELF.Fields(Field);
Field('savedText: TText');
Field('text: TText');
Field('');
END;
{$ENDC}
PROCEDURE TClearTextCmd.Commit;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
Free(SELF.savedText);
SELF.savedText := NIL;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TClearTextCmd.Perform(cmdPhase: TCmdPhase);
var textSel:
TTextSelection;
insertionPt:
TInsertionPoint;
text:
TText;
selection:
TSelection;
panel:
TPanel;
{$IFC fTextTrace}
junk:
TObject;
str1:
STR255;
str2:
STR255;
{$ENDC}
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
panel := SELF.image.view.panel;
text := SELF.text;
CASE cmdPhase OF
doPhase, redoPhase:
BEGIN
selection := panel.selection;
WHILE selection.coSelection <> NIL DO
selection := selection.coSelection;
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
LIntToHex(ORD(selection), @str1);
Writeln('*** Clear Cmd Perfrom; panel last coselection = ', str1);
junk := SELF.text.paragraphs.First; {So can set break point here}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 916 of 1012

Apple Lisa Computer Technical Information


002876
002877
002878
002879
002880
002881
002882
002883
002884
002885
002886
002887
002888
002889
002890
002891
002892
002893
002894
002895
002896
002897
002898
002899
002900
002901
002902
002903
002904
002905
002906
002907
002908
002909
002910
002911
002912
002913
002914
002915
002916
002917
002918
002919
002920
002921
002922
002923

{$ENDC}
textSel := TTextSelection(selection.FreedAndReplacedBy(
text.SelectAll(TTextSelection(selection).textImage)));
text.ChangeSelInOtherPanels(textSel);
text.HiliteRange(hOffToOn, textSel.textRange, FALSE);
text := textSel.DeleteButSave;
SELF.savedText := text;
insertionPt := textSel.BecomeInsertionPoint;
{$IFC fTextTrace}
IF fTextTrace THEN
BEGIN
LIntToHex(ORD(insertionPt), @str1);
Writeln('*** Clear Cmd Perfrom; final insertionPt = ', str1);
junk := SELF.text.paragraphs.First; {So can set break point here}
END;
{$ENDC}
END;
undoPhase:
BEGIN
selection := panel.selection;
WHILE selection.coSelection <> NIL DO
selection := selection.coSelection;
insertionPt := TInsertionPoint(selection);
insertionPt.InsertText(SELF.savedText, FALSE, FALSE, FALSE);
Free(SELF.savedText);
SELF.savedtext := NIL;
{$$ Need to hilte before, after?}
SELF.text.ChangeSelInOtherPanels(insertionPt);
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
END; {METHODS OF TClearTextCmd}
{$S SgTxtCld}
METHODS OF TStyleCmd;
FUNCTION TStyleCmd.CREATE(object: TObject; heap: THeap; itsCmdNumber: TCmdNumber;
itsImage: TImage;
itsFirstIndex: LONGINT; itsLastIndex: LONGINT;
itsLPFirst: INTEGER; itsLPLast: INTEGER;
itsSelection: TTextSelection): TStyleCmd;

Apple Lisa ToolKit 3.0 Source Code Listing -- 917 of 1012

Apple Lisa Computer Technical Information


002924
002925
002926
002927
002928
002929
002930
002931
002932
002933
002934
002935
002936
002937
002938
002939
002940
002941
002942
002943
002944
002945
002946
002947
002948
002949
002950
002951
002952
002953
002954
002955
002956
002957
002958
002959
002960
002961
002962
002963
002964
002965
002966
002967
002968
002969
002970
002971

VAR sel:
TTextSelection;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TStyleCmd(TCommand.CREATE(object, heap, itsCmdNumber, itsImage, TRUE, revealSome));
sel := TTextSelection(itsSelection.Clone(SELF.Heap));
WITH SELF DO
BEGIN
textSelection := sel;
text := sel.textImage.text;
firstFiltParaIndex := itsFirstIndex;
lastFiltParaIndex := itsLastIndex;
filtFirstLP := itsLPFirst;
filtLastLP := itsLPLast;
currFilteredPara := NIL;
filteredStyles := NIL;
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TStyleCmd.Free;
VAR sPar:
TListScanner;
paragraph: TEditPara;
paraImage: TParaImage;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
sPar := SELF.text.paragraphs.ScannerFrom(SELF.firstFiltParaIndex - 1, scanForward);
WHILE sPar.Scan(paragraph) DO
BEGIN
paragraph.beingFiltered := FALSE;
IF sPar.position = SELF.lastFiltParaIndex THEN
sPar.Done;
END;
SELF.textSelection.Free;
Free(SELF.filteredStyles);
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fTextTrace}
PROCEDURE TStyleCmd.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('text: TText');
Field('textSelection: TTextSelection');
Field('firstFiltParaIndex: LONGINT');

Apple Lisa ToolKit 3.0 Source Code Listing -- 918 of 1012

Apple Lisa Computer Technical Information


002972
002973
002974
002975
002976
002977
002978
002979
002980
002981
002982
002983
002984
002985
002986
002987
002988
002989
002990
002991
002992
002993
002994
002995
002996
002997
002998
002999
003000
003001
003002
003003
003004
003005
003006
003007
003008
003009
003010
003011
003012
003013
003014
003015
003016
003017
003018
003019

Field('lastFiltParaIndex: LONGINT');
Field('filtFirstLP: INTEGER');
Field('filtLastLP: INTEGER');
Field('currFilteredPara: TEditPara');
Field('filteredStyles: TArray');
Field('');
END;
{$ENDC}
PROCEDURE TStyleCmd.Commit;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.textSelection.ChangeStyle(SELF.cmdNumber);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TStyleCmd.FilterAndDo(actualObject: TObject;
PROCEDURE DoToObject(filteredObject: TObject));
VAR savedStyles:
TArray;
paragraph:
TEditPara;
typeStyle:
TTypeStyle;
firstLP:
INTEGER;
lastLP:
INTEGER;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
paragraph := TParaImage(actualObject).paragraph;
IF paragraph.beingFiltered THEN
BEGIN
IF paragraph = SELF.currFilteredPara THEN
BEGIN
savedStyles := paragraph.typeStyles;
paragraph.typeStyles := SELF.filteredStyles;
END
ELSE
BEGIN
IF paragraph = TEditPara(SELF.text.paragraphs.At(SELF.firstFiltParaIndex)) THEN
firstLP := SELF.filtFirstLP
ELSE
firstLP := 0;
IF paragraph = TEditPara(SELF.text.paragraphs.At(SELF.lastFiltParaIndex)) THEN
lastLP := SELF.filtLastLP
ELSE
lastLP := paragraph.size;
Free(SELF.filteredStyles);
savedStyles := TArray(paragraph.typeStyles.Clone(SELF.heap));
SELF.textSelection.DoChangeStyle(SELF.cmdNumber, paragraph, firstLP, lastLP, typeStyle);

Apple Lisa ToolKit 3.0 Source Code Listing -- 919 of 1012

Apple Lisa Computer Technical Information


003020
003021
003022
003023
003024
003025
003026
003027
003028
003029
003030
003031
003032
003033
003034
003035
003036
003037
003038
003039
003040
003041
003042
003043
003044
003045
003046
003047
003048
003049
003050
003051
003052
003053
003054
003055
003056
003057
003058
003059
003060
003061
003062
003063
003064
003065
003066
003067

SELF.currFilteredPara := paragraph;
SELF.filteredStyles := paragraph.typeStyles;
END;
DoToObject(TParaImage(actualObject));
paragraph.typeStyles := savedStyles;
END
ELSE
DoToObject(TParaImage(actualObject));
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TStyleCmd.Perform(cmdPhase: TCmdPhase);
VAR textSelection: TTextSelection;
selection:
TSelection;
sPar:
TListScanner;
paragraph:
TEditPara;
{Need to filter paragraph before asking about its type styles}
PROCEDURE FindFilteredStyle(obj: TObject);
BEGIN
textSelection.StyleFromContext;
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
selection := SELF.image.view.panel.selection;
WHILE selection.coSelection <> NIL DO
selection := selection.coSelection;
textSelection := TTextSelection(selection);
IF cmdPhase = doPhase THEN
BEGIN
sPar := SELF.text.paragraphs.ScannerFrom(SELF.firstFiltParaIndex - 1, scanForward);
WHILE sPar.Scan(paragraph) DO
BEGIN
paragraph.beingFiltered := TRUE;
IF sPar.position = SELF.lastFiltParaIndex THEN
sPar.Done;
END;
END;
textSelection.MarkChanged;
textSelection.textImage.text.RecomputeImages;
SELF.FilterAndDo(TParaImage(TEditPara(SELF.text.paragraphs.At(
SELF.firstFiltParaIndex)).images.First), FindFilteredStyle);
(*textSelection.Invalidate;*)

Apple Lisa ToolKit 3.0 Source Code Listing -- 920 of 1012

Apple Lisa Computer Technical Information


003068
003069
003070
003071
003072
003073
003074
003075
003076
003077
003078
003079
003080
003081
003082
003083
003084
003085
003086
003087
003088
003089
003090
003091
003092
003093
003094
003095
003096
003097
003098
003099
003100
003101
003102
003103
003104
003105
003106
003107
003108
003109
003110
003111
003112
003113
003114
003115

{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
END; {METHODS OF TStyleCmd}
{$S SgTxtCld}
METHODS OF TTextCutCopy;
FUNCTION TTextCutCopy.CREATE(object: TObject; heap: THeap; itsCmdNumber: TCmdNumber;
itsImage: TImage; isCutCmd: BOOLEAN; itsText: TText): TTextCutCopy;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TTextCutCopy(TCutCopyCommand.CREATE(object, heap, itsCmdNumber, itsImage, isCutCmd));
WITH SELF DO
BEGIN
text := itsText;
IF itsCmdNumber = uCopy THEN
BEGIN
unHiliteBefore[doPhase] := FALSE;
hiliteAfter[doPhase] := FALSE;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fTextTrace}
PROCEDURE TTextCutCopy.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
TCutCopyCommand.Fields(Field);
Field('text: TText');
Field('');
END;
{$ENDC}
PROCEDURE TTextCutCopy.DoCutCopy(clipSelection: TSelection; deleteOriginal: BOOLEAN;
cmdPhase: TCmdPhase);
VAR textSel:
TTextSelection;
insertionPt:
TInsertionPoint;
multiParaSel:
TMultiParaSelection;
heap:
THeap;
firstPara:
TEditPara;
firstLP:
INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 921 of 1012

Apple Lisa Computer Technical Information


003116
003117
003118
003119
003120
003121
003122
003123
003124
003125
003126
003127
003128
003129
003130
003131
003132
003133
003134
003135
003136
003137
003138
003139
003140
003141
003142
003143
003144
003145
003146
003147
003148
003149
003150
003151
003152
003153
003154
003155
003156
003157
003158
003159
003160
003161
003162
003163

panel:
selection:
saveTextSel:
firstIndex:

TPanel;
TSelection;
TTextSelection;
LONGINT;

BEGIN
{$IFC fTrace}BP(10);{$ENDC}
heap := SELF.Heap;
panel := SELF.image.view.panel;
CASE cmdPhase OF
doPhase, redoPhase:
BEGIN
selection := panel.selection;
{we know that the last coSelection must be the textSelection since textSelections
do not have coSelections}
WHILE selection.coSelection <> NIL DO
selection := selection.coSelection;
textSel := TTextSelection(selection);
IF (cmdPhase = redoPhase) AND deleteOriginal THEN
SELF.text.HiliteRange(hOffToOn, textSel.textRange, textSel.isParaSelection);
textSel.CutCopy(clipSelection, deleteOriginal);
END;
undoPhase:
BEGIN
IF deleteOriginal THEN
BEGIN
selection := panel.selection;
WHILE selection.coSelection <> NIL DO
selection := selection.coSelection;
insertionPt := TInsertionPoint(selection);
firstPara := insertionPt.textRange.firstPara;
firstLP := insertionPt.textRange.firstLP;
firstIndex := insertionPt.textRange.firstIndex;
{get the cut text from the clipboard and insert it back into the text}
multiParaSel := TMultiParaSelection(clipSelection);
insertionPt.InsertText(multiParaSel.textImage.text, multiParaSel.isParaSelection,
multiParaSel.isWordSelection, FALSE);
IF multiParaSel.isParaSelection THEN
BEGIN
WITH insertionPt DO
IF textRange.firstIndex > 1 THEN
BEGIN
textRange.firstIndex := textRange.firstIndex - 1;

Apple Lisa ToolKit 3.0 Source Code Listing -- 922 of 1012

Apple Lisa Computer Technical Information


003164
003165
003166
003167
003168
003169
003170
003171
003172
003173
003174
003175
003176
003177
003178
003179
003180
003181
003182
003183
003184
003185
003186
003187
003188
003189
003190
003191
003192
003193
003194
003195
003196
003197
003198
003199
003200
003201
003202
003203
003204
003205
003206
003207
003208
003209
003210
003211

{$H-}
textRange.firstPara := TEditPara(SELF.text.paragraphs.At(textRange.firstIndex));
textRange.firstLP := textRange.firstPara.size;
{$H+}
END;

END
ELSE IF multiParaSel.isWordSelection THEN
{don't want to select extra blank generated by insert}
WITH insertionPt DO
{$H-}
IF firstPara.At(firstLP + 1) = ' ' THEN
firstLP := firstLP + 1
ELSE IF textRange.firstPara.At(textRange.firstLP) = ' ' THEN
textRange.firstLP := textRange.firstLP - 1;
{$H+}

{build the original selection}


textSel := TTextSelection(selection.FreedAndReplacedBy(
insertionPt.textImage.NewTextSelection(
firstPara, firstIndex, firstLP, insertionPt.textRange.firstPara,
insertionPt.textRange.firstIndex, insertionPt.textRange.firstLP)));
textSel.isParaSelection := multiParaSel.isParaSelection;
SELF.text.ChangeSelInOtherPanels(textSel);
END;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
END; {METHODS OF TTextCutCopy}
{$S SgTxtCld}
METHODS OF TTextPaste;
FUNCTION TTextPaste.CREATE(object: TObject; heap: THeap; itsImage: TImage;
itsText: TText): TTextPaste;
VAR range: TTextRange;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TTextPaste(TPasteCommand.CREATE(object, heap, uPaste, itsImage));
{need noSelection since it gets FreedAndReplacedBy'ed}
range := TTextRange.CREATE(NIL, heap, NIL, 0, 0, NIL, 0, 0); {Perform initializes}
WITH SELF DO

Apple Lisa ToolKit 3.0 Source Code Listing -- 923 of 1012

Apple Lisa Computer Technical Information


003212
003213
003214
003215
003216
003217
003218
003219
003220
003221
003222
003223
003224
003225
003226
003227
003228
003229
003230
003231
003232
003233
003234
003235
003236
003237
003238
003239
003240
003241
003242
003243
003244
003245
003246
003247
003248
003249
003250
003251
003252
003253
003254
003255
003256
003257
003258
003259

BEGIN
pasteRange := range;
text := itsText;
savedText := NIL;
origIsPara := FALSE;
origIsWord := FALSE;
clipIsPara := FALSE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TTextPaste.Free;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF SELF.savedText <> NIL THEN
SELF.savedText.FreeSelf(FALSE);
Free(SELF.pasteRange);
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$IFC fTextTrace}
PROCEDURE TTextPaste.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('savedText: TText');
Field('pasteRange: TTextRange');
Field('text: TText');
Field('origIsPara: BOOLEAN');
Field('origIsWord: BOOLEAN');
Field('clipIsPara: BOOLEAN');
Field('');
END;
{$ENDC}
PROCEDURE TTextPaste.Commit;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
Free(SELF.savedText);
SELF.savedText := NIL;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TTextPaste.DoPaste(clipSelection: TSelection; pic: PicHandle; cmdPhase: TCmdPhase);
VAR heap:
THeap;
textSel:
TTextSelection;
saveTextSel:
TTextSelection;
insertionPt:
TInsertionPoint;

Apple Lisa ToolKit 3.0 Source Code Listing -- 924 of 1012

Apple Lisa Computer Technical Information


003260
003261
003262
003263
003264
003265
003266
003267
003268
003269
003270
003271
003272
003273
003274
003275
003276
003277
003278
003279
003280
003281
003282
003283
003284
003285
003286
003287
003288
003289
003290
003291
003292
003293
003294
003295
003296
003297
003298
003299
003300
003301
003302
003303
003304
003305
003306
003307

insPtBefore:
TInsertionPoint;
insPtAfter:
TInsertionPoint;
text:
TText;
firstPara:
TEditPara; {bad choice of var names; change later (screws up WITH's)}
firstLP:
INTEGER;
firstIndex:
LONGINT;
panel:
TPanel;
selection:
TSelection;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
heap := SELF.Heap;
panel := SELF.image.view.panel;
CASE cmdPhase OF
doPhase, redoPhase:
BEGIN
IF InClass(clipSelection, TTextSelection) OR (clipBoard.hasUniversalText) THEN
BEGIN
selection := panel.selection;
{we know that the last coSelection must be the textSelection since textSelections
do not have coSelections}
WHILE selection.coSelection <> NIL DO
selection := selection.coSelection;
textSel := TTextSelection(selection);
SELF.origIsPara := textSel.isParaSelection;
SELF.origIsWord := textSel.isWordSelection;
IF InClass(clipSelection, TTextSelection) THEN
SELF.clipIsPara := TTextSelection(clipSelection).isParaSelection;
{delete the selected text, leaving an insertion point}
text := textSel.DeleteButSave;
SELF.savedText := text;
insertionPt := textSel.BecomeInsertionPoint;
WITH SELF, insertionPt DO
BEGIN
pasteRange.firstPara := textRange.firstPara;
pasteRange.firstIndex := textRange.firstIndex;
pasteRange.firstLP := textRange.firstLP;
END;
insertionPt.FinishPaste(clipSelection, pic);
WITH SELF, insertionPt DO
IF clipIsPara THEN
BEGIN
{$H-}
pasteRange.lastIndex := Max(1, textRange.firstIndex - 1);
pasteRange.lastPara := TEditPara(SELF.text.paragraphs.At(pasteRange.lastIndex));
pasteRange.lastLP := pasteRange.lastPara.size;

Apple Lisa ToolKit 3.0 Source Code Listing -- 925 of 1012

Apple Lisa Computer Technical Information


003308
003309
003310
003311
003312
003313
003314
003315
003316
003317
003318
003319
003320
003321
003322
003323
003324
003325
003326
003327
003328
003329
003330
003331
003332
003333
003334
003335
003336
003337
003338
003339
003340
003341
003342
003343
003344
003345
003346
003347
003348
003349
003350
003351
003352
003353
003354
003355

{$H+}
END
ELSE
BEGIN
pasteRange.lastPara := textRange.firstPara;
pasteRange.lastIndex := textRange.firstIndex;
pasteRange.lastLP := textRange.firstLP;
END;
SELF.text.ChangeSelInOtherPanels(insertionPt);
END
ELSE
BEGIN
panel.selection.CantDoIt;
SELF.undoable := FALSE;
END;
END;
undoPhase:
BEGIN
WITH SELF.pasteRange DO
{$H-}
textSel := TTextImage(SELF.image).NewTextSelection(firstPara, firstIndex, firstLP,
lastPara, lastIndex, lastLP);
{$H+}
textSel.isParaSelection := SELF.clipIsPara;
{user feedback: highlight pasted text}
SELF.text.HiliteRange(hOffToOn, SELF.pasteRange, textSel.isParaSelection);
{get rid of pasted text; can get it from clipboard for redo}
textSel.DeleteAndFree;
insertionPt := textSel.BecomeInsertionPoint;
firstPara := insertionPt.textRange.firstPara;
firstLP := insertionPt.textRange.firstLP;
firstIndex := insertionPt.textRange.firstIndex;
{put back any text that was pasted over}
insertionPt.InsertText(SELF.savedText, SELF.origIsPara, SELF.origIsWord, FALSE);
WITH insertionPt DO
IF SELF.origIsPara THEN
BEGIN
{$H-}
textRange.firstIndex := Max(1, textRange.firstIndex - 1);
textRange.firstPara := TEditPara(SELF.text.paragraphs.At(textRange.firstIndex));
textRange.firstLP := textRange.firstPara.size;

Apple Lisa ToolKit 3.0 Source Code Listing -- 926 of 1012

Apple Lisa Computer Technical Information


003356
003357
003358
003359
003360
003361
003362
003363
003364
003365
003366
003367
003368
003369
003370
003371
003372
003373
003374
003375
003376
003377
003378
003379
003380
003381
003382
003383
003384
003385
003386
003387
003388
003389
003390
003391
003392
003393
003394
003395
003396
003397
003398
003399
003400
003401
003402
003403

{$H+}
END;
Free(SELF.savedText);
SELF.savedText := NIL;
selection := panel.selection;
WHILE selection.coSelection <> NIL DO
selection := selection.coSelection;
{build original selection (ie before the paste)}
textSel := TTextSelection(selection.FreedAndReplacedBy(
insertionPt.textImage.NewTextSelection(
firstPara, firstIndex, firstLP, insertionPt.textRange.firstPara,
insertionPt.textRange.firstIndex, insertionPt.textRange.firstLP)));
textSel.isParaSelection := SELF.origIsPara;
textSel.isWordSelection := SELF.origIsWord;
SELF.text.ChangeSelInOtherPanels(textSel);
insertionPt.Free;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
END; {METHODS OF TTextPaste}
{$S SgTxtHot}
METHODS OF TTypingCmd;
FUNCTION TTypingCmd.CREATE(object: TObject; heap: THeap; itsImage: TImage;
itsText: TText): TTypingCmd;
VAR range: TTextRange;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF object = NIL THEN
object := NewObject(heap, THISCLASS);
SELF := TTypingCmd(TCommand.CREATE(object, heap, uTyping, itsImage, TRUE, revealAll));
range := TTextRange.CREATE(NIL, heap, NIL, 0, 0, NIL, 0, 0); {Perform initializes}
WITH SELF DO
BEGIN
newCharCount := 0;
newParaCount := 0;
text := itsText;
savedText := NIL;
typingRange := range;
otherInsPts := NIL;

Apple Lisa ToolKit 3.0 Source Code Listing -- 927 of 1012

Apple Lisa Computer Technical Information


003404
003405
003406
003407
003408
003409
003410
003411
003412
003413
003414
003415
003416
003417
003418
003419
003420
003421
003422
003423
003424
003425
003426
003427
003428
003429
003430
003431
003432
003433
003434
003435
003436
003437
003438
003439
003440
003441
003442
003443
003444
003445
003446
003447
003448
003449
003450
003451

hiliteAfter[doPhase] := FALSE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE TTypingCmd.Free;
VAR selection: TSelection;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
Free(SELF.savedText);
selection := SELF.image.view.panel.selection;
WHILE selection.coSelection <> NIL DO
selection := selection.coSelection;
IF InClass(selection, TInsertionPoint) THEN
BEGIN
TInsertionPoint(selection).typingCmd := NIL;
TInsertionPoint(selection).amTyping := FALSE;
END;
SELF.typingRange.Free;
IF SELF.otherInsPts <> NIL THEN
SELF.otherInsPts.FreeObject;
SUPERSELF.Free;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtCld}
{$IFC fTextTrace}
PROCEDURE TTypingCmd.Fields(PROCEDURE Field(nameAndType: S255));
BEGIN
SUPERSELF.Fields(Field);
Field('');
Field('savedText: TText');
Field('text: TText');
Field('newCharCount: INTEGER');
Field('newParaCount: INTEGER');
Field('typingRange: TTextRange');
Field('otherInsPts: TList');
Field('');
END;
{$ENDC}
{$S SgTxtHot}
PROCEDURE TTypingCmd.Perform(cmdPhase: TCmdPhase);
VAR text:
TText;
insertionPt:
TInsertionPoint;

Apple Lisa ToolKit 3.0 Source Code Listing -- 928 of 1012

Apple Lisa Computer Technical Information


003452
003453
003454
003455
003456
003457
003458
003459
003460
003461
003462
003463
003464
003465
003466
003467
003468
003469
003470
003471
003472
003473
003474
003475
003476
003477
003478
003479
003480
003481
003482
003483
003484
003485
003486
003487
003488
003489
003490
003491
003492
003493
003494
003495
003496
003497
003498
003499

selection:
heap:
firstPara:
firstLP:
textSel:
panel:
firstIndex:
aList:
typeStyle:

TSelection;
THeap;
TEditPara;
INTEGER;
TTextSelection;
TPanel;
LONGINT;
TList;
TTypeStyle;

PROCEDURE InstallInsPts(obj: TObject);


VAR selection: TSelection;
BEGIN
selection := TTextImage(obj).view.panel.selection;
WHILE selection.coSelection <> NIL DO
selection := selection.coSelection;
IF selection <> insertionPt THEN
aList.InsLast(selection);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
heap := SELF.Heap;
panel := SELF.image.view.panel;
CASE cmdPhase OF
doPhase, redoPhase:
BEGIN
selection := panel.selection;
WHILE selection.coSelection <> NIL DO
selection := selection.coSelection;
textSel := TTextSelection(selection);
typeStyle := textSel.currTypeStyle;
{We don't want to delete the entire paragraph if we're typing over it,
so set isParaSelection to FALSE}
textSel.isParaSelection := FALSE;
(***** Changed following line 4/27/84 13:07 LSR
BUG: redo of backspace (?) leaves garbage
deferUpdate := TRUE;
*****)
deferUpdate := (cmdPhase = doPhase) OR (SELF.savedText <> NIL);
text := textSel.DeleteButSave;
insertionPt := textSel.BecomeInsertionPoint;
WITH SELF.typingRange DO
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 929 of 1012

Apple Lisa Computer Technical Information


003500
003501
003502
003503
003504
003505
003506
003507
003508
003509
003510
003511
003512
003513
003514
003515
003516
003517
003518
003519
003520
003521
003522
003523
003524
003525
003526
003527
003528
003529
003530
003531
003532
003533
003534
003535
003536
003537
003538
003539
003540
003541
003542
003543
003544
003545
003546
003547

firstPara := insertionPt.textRange.firstPara;
firstIndex := insertionPt.textRange.firstIndex;
firstLP := insertionPt.textRange.firstLP;
lastPara := firstPara;
lastIndex := firstIndex;
lastLP := firstLP;
END;
IF cmdPhase = doPhase THEN
BEGIN
WITH insertionPoint DO
BEGIN
amTyping := TRUE;
typingCmd := SELF;
IF TFakeTStyle(currTypeStyle) <> TFakeTStyle(typeStyle) THEN
BEGIN
styleCmdNumber := -1; {so correct typeStyle will be used}
currTypeStyle := typeStyle;
END;
END;
{If there is more than one panel displaying this text, then store the insertion points
of the other panels in a list for quick access while typing}
IF SELF.text.txtImgList.size > 1 THEN
BEGIN
aList := TList.CREATE(NIL, heap, 0);
SELF.text.txtImgList.Each(InstallInsPt);
SELF.otherInsPts := aList;
END;
insertionPt.textRange.firstPara.StartEdit(insertionPt.textRange.firstPara.GrowSize);
END
ELSE
BEGIN
firstPara := insertionPt.textRange.firstPara;
firstLP := insertionPt.textRange.firstLP;
firstIndex := insertionPt.textRange.firstIndex;
{put back the typed text}
deferUpdate := FALSE;
insertionPt.InsertText(SELF.savedText, FALSE, FALSE, FALSE);
Free(SELF.savedText);
WITH SELF.typingRange DO
BEGIN
lastPara := insertionPt.textRange.firstPara;
lastIndex := insertionPt.textRange.firstIndex;
lastLP := insertionPt.textRange.firstLP;
END;
{build typed selection}

Apple Lisa ToolKit 3.0 Source Code Listing -- 930 of 1012

Apple Lisa Computer Technical Information


003548
003549
003550
003551
003552
003553
003554
003555
003556
003557
003558
003559
003560
003561
003562
003563
003564
003565
003566
003567
003568
003569
003570
003571
003572
003573
003574
003575
003576
003577
003578
003579
003580
003581
003582
003583
003584
003585
003586
003587
003588
003589
003590
003591
003592
003593
003594
003595

textSel := TTextSelection(insertionPt.FreedAndReplacedBy(
insertionPt.textImage.NewTextSelection(
firstPara, firstIndex, firstLP, insertionPt.textRange.firstPara,
insertionPt.textRange.firstIndex, insertionPt.textRange.firstLP)));
SELF.text.ChangeSelInOtherPanels(textSel);
END;
{We always need a valid savedText object, even if no characters were initially typed
over, in case previous characters get backspaced over. See code in KeyBack }
IF text = NIL THEN
BEGIN
text := TText.CREATE(NIL, heap, NIL);
text.paragraphs.InsLast(
TTextImage(SELF.image).NewEditPara(0, SELF.typingRange.firstPara.format));
END;
SELF.savedText := text;
END;
undoPhase:
BEGIN
WITH SELF.typingRange DO
{$H-}
textSel := TTextImage(SELF.image).NewTextSelection(firstPara, firstIndex, firstLP,
lastPara, lastIndex, lastLP);
{$H+}
{user feedback: highlight typed text}
SELF.text.HiliteRange(hOffToOn, SELF.typingRange, textSel.isParaSelection);
{delete but save typed text}
text := textSel.DeleteButSave;
insertionPt := textSel.BecomeInsertionPoint;
firstPara := insertionPt.textRange.firstPara;
firstLP := insertionPt.textRange.firstLP;
firstIndex := insertionPt.textRange.firstIndex;
{put back any text that was typed over}
insertionPt.InsertText(SELF.savedText, FALSE, FALSE, FALSE);
Free(SELF.savedText);
SELF.savedText := text;
selection := panel.selection;
WHILE selection.coSelection <> NIL DO
selection := selection.coSelection;

Apple Lisa ToolKit 3.0 Source Code Listing -- 931 of 1012

Apple Lisa Computer Technical Information


003596
003597
003598
003599
003600
003601
003602
003603
003604
003605
003606
003607
003608
003609
003610
003611
003612
003613

{build original selection (before typing)}


textSel := TTextSelection(selection.FreedAndReplacedBy(
insertionPt.textImage.NewTextSelection(
firstPara, firstIndex, firstLP, insertionPt.textRange.firstPara,
insertionPt.textRange.firstIndex, insertionPt.textRange.firstLP)));
SELF.text.ChangeSelInOtherPanels(textSel);
insertionPt.Free;
END;
END;
{$IFC fTrace}EP;{$ENDC}
END;
{$S SgTxtIni}
END; {METHODS OF TTypingCmd}
{$S SgTxtCld}

End of File -- Lines: 3613 Characters: 131485

Apple Lisa ToolKit 3.0 Source Code Listing -- 932 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/UUNIVTEXT.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{$E+}
{$E ERR1.TEXT}
{------------------------------------------------------------------------------------------------------------}
{
UUniversalText V0.3
}
{------------------------------------------------------------------------------------------------------------}
{$SETC ForOS := TRUE }
{$DECL WithUObject}
{$SETC WithUObject := TRUE}
{Note: TRUE/FALSE status MUST agree with below}

UNIT {$IFC WithUObject}


UTKUniversalText
{$ELSEC}
UUniversalText
{$ENDC};
{$DECL IsIntrinsic}
{$SETC IsIntrinsic := TRUE}
{$SETC WithUObject := TRUE}

{Note: TRUE/FALSE status MUST agree with above}

{$IFC IsIntrinsic}
INTRINSIC;
{$ENDC}
{$IFC NOT WithUObject}
{$SETC LibraryVersion := 30 } { 10 = 1.0 libraries; 13 = 1.3 libraries; 20 = Pepsi, 30 = Spring, etc. }
{$ENDC}
INTERFACE
USES
{$IFC WithUObject}
{$U libtk/UObject}
{$SETC fTrce := fTrace}
{$ENDC}
{$U libsm/UnitStd.obj }
{$U libsm/UnitHz.obj }
{$IFC NOT WithUObject}
{$U libpl/UClascal}
{$U libqd/Storage.obj }
{$ENDC}

UObject,
UnitStd,
UnitHz,
UClascal,
Storage,

{Will be in PASLIB in Spring}

Apple Lisa ToolKit 3.0 Source Code Listing -- 933 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

{$IFC LibraryVersion <= 20}


{$U libfm/FontMgr.obj }
FontMgr,
{$U libqd/QuickDraw.obj }
QuickDraw,
{$ELSEC}
{$U libqd/QuickDraw.obj }
QuickDraw,
{$U libfm/FontMgr.obj }
FontMgr,
{$ENDC}
{$U -#BOOT-SysCall }
Syscall,
{$U libpm/PMDecl.obj }
PMDecl,
{$U libpr/PrStdInfo.obj }
PrStdInfo,
{$U libsu/UnitFmt.obj }
UnitFmt,
{$U libsu/UnitCS.obj }
UnitCS,
{$U libwm/Events.obj }
Events,
{$U libsu/Scrap.obj }
Scrap;
{$DECL fUniversalTextTrace}
{$IFC NOT WithUObject}
{$DECL fDebugMethods}
{$SETC fDebugMethods := FALSE}

{Must be FALSE}

{$DECL fDbgObject}
{$DECL fTrce}
{$SETC fTrce := FALSE}

{Must be FALSE}

{$SETC fDbgObject := FALSE}


{$ENDC}

{Set to FALSE for final libraries}

{$SETC fUniversalTextTrace := fTrce}

{Normal}

{$DECL PasteTrace}
{$SETC PasteTrace := FALSE}

{Generates READLN asking for tracing during Write UT}

TYPE
{$IFC NOT WithUObject}
S255 = STRING[255];
THeap = Ptr;
{alias for THz}
TClass = Ptr;
{alias for TPSliceTable in UClascal}
TCollecHeader =
classPtr:
size:
dynStart:

RECORD
TClass;
LONGINT;
INTEGER;

{number of real elements, not counting the hole}


{bytes from the class ptr to the dynamic data; MAXINT if none allowed}

Apple Lisa ToolKit 3.0 Source Code Listing -- 934 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

holeStart:
holeSize:
holeStd:
END;

INTEGER;
INTEGER;
INTEGER;

{0 = at the beginning, size = at the end; MAXINT = none allowed}


{measured in MemberBytes units}
{if the holeSize goes to 0, how much to grow the collection by}

TFastString = RECORD
{only access ch[i] when hole is at end & TString is not subclassed}
header:
TCollecHeader;
ch:
PACKED ARRAY[1..32740] OF CHAR;
END;
TPFastString = ^TFastString;
THFastString = ^TPFastString;
TUTObject = SUBCLASS OF NIL
FUNCTION
FUNCTION
PROCEDURE
PROCEDURE
FUNCTION
END;

{TUTObject.}CREATE(heap: THeap): TUTObject; ABSTRACT;


{TUTObject.}Heap: THeap;
{which heap it is in}
{TUTObject.}FreeObject; DEFAULT;
{frees just the object, not its contents}
{TUTObject.}Free; DEFAULT;
{frees the object and its contents}
{TUTObject.}Class: TClass;

TUTCollection = SUBCLASS OF TUTObject


{Variables}
size:
dynStart:
holeStart:
holeSize:
holeStd:
FUNCTION
FUNCTION
FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
END;

LONGINT;
INTEGER;
INTEGER;
INTEGER;
INTEGER;

{number of real elements, not counting the hole}


{bytes from the class ptr to the dynamic data}
{0 means hole at the beginning, size means hole at the end}
{measured in MemberBytes units}
{if the holeSize goes to 0, how much to grow the collection by}

{TCollection.}CREATE(object: TUTObject; heap: THeap; initialSlack: INTEGER): TUTCollection;


{TCollection.}AddrMember(i: LONGINT): LONGINT;
{TCollection.}MemberBytes: INTEGER; ABSTRACT;
{TCollection.}EditAt(atIndex: LONGINT; deltaMembers: INTEGER);
{TCollection.}InsManyAt(i: LONGINT; otherCollection: TUTCollection; index, howMany: LONGINT);
{TCollection.}ResizeColl(membersPlusHole: INTEGER);
{TCollection.}ShiftColl(afterSrcIndex, afterDstIndex, howMany: INTEGER);
{TCollection.}StartEdit(withSlack: INTEGER);
{TCollection.}StopEdit;

TUTArray = SUBCLASS OF TUTCollection


recordBytes: INTEGER;
FUNCTION

{TArray.}CREATE(object: TUTObject; heap: THeap; initialSlack, bytesPerRecord: INTEGER)


: TUTArray;

Apple Lisa ToolKit 3.0 Source Code Listing -- 935 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

FUNCTION
FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
END;

{TArray.}MemberBytes: INTEGER; OVERRIDE;


{TArray.}At(i: LONGINT): Ptr; DEFAULT;
{TArray.}InsAt(i: LONGINT; pRecord: Ptr); DEFAULT;
{TArray.}InsLast(pRecord: Ptr);
{TArray.}DelAll;
{TArray.}DelAt(i: LONGINT); DEFAULT;
{TArray.}DelManyAt(i, howMany: LONGINT); DEFAULT;
{TArray.}PutAt(i: LONGINT; pRecord: Ptr);

TUTString = SUBCLASS OF TUTCollection


FUNCTION
FUNCTION
FUNCTION
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
PROCEDURE
END;

{TString.}CREATE(object: TUTObject; heap: THeap; initialSlack: INTEGER): TUTString;


{TString.}At(i: LONGINT): CHAR;
{TString.}MemberBytes: INTEGER; OVERRIDE;
{TString.}ToPAOCAt(i, howMany: LONGINT; pPackedArrayOfCharacter: Ptr);
{TString.}InsAt(i: LONGINT; character: CHAR);
{TString.}InsPAOCAt(i: LONGINT; pPackedArrayOfCharacter: Ptr; howMany: LONGINT);
{TString.}DelAt(i: LONGINT);
{TString.}DelManyAt(i, howMany: LONGINT);
{TString.}DelAll;

{$ENDC}
TEnumLevelOfGranularity = (UTCharacters, UTParagraphs);
TLevelOfGranularity = SET OF TEnumLevelOfGranularity;
TCharDescriptor = RECORD
{ character descroptor record }
font:
INTEGER;
{ font number }
face:
{$IFC LibraryVersion <= 20}TSeteface{$ELSEC}style{$ENDC};
superscript:
-128..127;
{ number of bits to superscript }
keepOnSamePage: BOOLEAN;
END;
TTabTypes
TTabFill
TParaTypes

= (qLeftTab,
= (tNoFill,
= (qLeftPara,

TTabDescriptor = RECORD
position:
fillBetweenTabs:
tabType:
END;
TParaDescriptor = RECORD
paragraphStart:

qCenterTab,
tDotFill,
qCenterPara,
INTEGER;
TTabFill;
TTabTypes;

BOOLEAN;

qRightTab,
tHyphenFill,
qRightPara,

{ formating }

qPeriodTab,
qCommaTab);
tUnderLineFill);
qJustPara);

{Location of the tab}


{Fill character for the tab}
{Type of tab}

{ TRUE if the beginning of the run is also the beginning of a paragraph}

Apple Lisa ToolKit 3.0 Source Code Listing -- 936 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

{$IFC WithUObject}
additionalChrInParagraph:
INTEGER;
{$ENDC}
firstLineMargin:
INTEGER;
{Left margin of first line}
bodyMargin:
INTEGER;
{Left margin of subsequent lines}
rightMargin:
INTEGER;
{Right margin}
paraLeading:
INTEGER;
{Paragraph leading}
lineSpacing:
0..63;
{Inter-line spacing }
{$IFC WithUObject}
tabTable:
TArray {OF TTabDescriptor}; { table of tabs }
{$ELSEC}
tabTable:
TUTArray {OF TTabDescriptor}; { table of tabs }
{$ENDC}
paraType:
TParaTypes;
{Paragraph adjustment }
hasPicture:
BOOLEAN;
{Is there a picture avaible for this paragraph?}
END;
{$IFC WithUObject}
TTKUnivText = SUBCLASS OF TOBJECT
{$ELSEC}
TUnivText
= SUBCLASS OF TUTObject
{$ENDC}
paragraphDescriptor:
TParaDescriptor;
characterDescriptor:
TCharDescriptor;
maxDataSize:
INTEGER;
{$IFC WithUObject}
data:
TString;
{$ELSEC}
data:
TUTString;
{$ENDC}
itsOurTString:
BOOLEAN;
{$IFC WithUObject}
FUNCTION {TTKUnivText.}CREATE(object: TObject;
itsHeap: THeap;
itsTString: TString;
itsDataSize: INTEGER) : TTKUnivText;
{$ELSEC}
FUNCTION {TUnivText.}CREATE(object: TUTObject;
itsHeap: THeap;
itsTString: TUTString;
itsDataSize: INTEGER) : TUnivText;
{$ENDC}
PROCEDURE {TUnivText.}Free; OVERRIDE;
PROCEDURE {TUnivText.}RunToStream;
PROCEDURE {TUnivText.}StreamToTRun;
PROCEDURE {TUnivText.}TabTableToArgTbd;

Apple Lisa ToolKit 3.0 Source Code Listing -- 937 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

PROCEDURE {TUnivText.}ArgTbdToTabTable;
END;
{$IFC WithUObject}
TTKReadUnivText = SUBCLASS OF TTKUnivText
{$ELSEC}
TReadUnivText
= SUBCLASS OF TUnivText
{$ENDC}
{$IFC WithUObject}
buffer:
{$ELSEC}
buffer:
{$ENDC}
columnCount:
dataBeforeTab:

TString;
TUTString;
INTEGER;
BOOLEAN;

{$IFC WithUObject}
FUNCTION {TReadUnivText.}CREATE(object: TObject;
itsHeap: THeap;
itsTString: TString;
itsDataSize: INTEGER;
LevelOfGranularity: TLevelOfGranularity)
: TTKReadUnivText;
{$ELSEC}
FUNCTION {TReadUnivText.}CREATE(object: TUTObject;
itsHeap: THeap;
itsTString: TUTString;
itsDataSize: INTEGER;
LevelOfGranularity: TLevelOfGranularity)
: TReadUnivText;
{$ENDC}
PROCEDURE {TReadUnivText.}Free; OVERRIDE;
PROCEDURE {TReadUnivText.}ReadRun;
{ Returns one run of text each time called }
PROCEDURE {TReadUnivText.}Restart;
{ Resets the object to read from the begining }
PROCEDURE {TReadUnivText.}ScanTable(VAR rows,
tabColumns,
tabStopColumns: INTEGER);
{ Returns number of rows and colums of scrap if a valid table }
FUNCTION

{TReadUnivText.}ReadField(
VAR
VAR
VAR

maxFieldSize: INTEGER;
fieldOverflow: BOOLEAN;
fieldTerminator: CHAR;
tabType: TTabTypes)
: BOOLEAN;

Apple Lisa ToolKit 3.0 Source Code Listing -- 938 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

{ Returns one field of text each time called }


FUNCTION

FUNCTION
END;

{TReadUnivText.}ReadLine(
maxLineSize: INTEGER;
VAR lineOverflow: BOOLEAN;
VAR lineTerminator: CHAR)
: BOOLEAN;
{ Returns one line of text each time called }
{TReadUnivText.}GetParaPicture(heap: THeap)
: PicHandle;
{ Copies the picture for the current paragraph into heap }

{$IFC WithUObject}
TTKWriteUnivText = SUBCLASS OF TTKUnivText
{$ELSEC}
TWriteUnivText
= SUBCLASS OF TUnivText
{$ENDC}
{$IFC WithUObject}
FUNCTION {TWriteUnivText.}CREATE(object: TObject;
itsHeap: THeap;
itsTString: TString;
itsDataSize: INTEGER)
: TTKWriteUnivText;
{$ELSEC}
FUNCTION {TWriteUnivText.}CREATE(object: TUTObject;
itsHeap: THeap;
itsTString: TUTString;
itsDataSize: INTEGER)
: TWriteUnivText;
{$ENDC}
PROCEDURE {TWriteUnivText.}FillParagraph;
{Writes one run of text each time called}
END;
{$IFC NOT WithUObject}
FUNCTION NewUTObject(heap: THeap; itsClass: TClass): TUTObject;
{$ENDC}
{$IFC fUniversalTextTrace}
VAR
fPrintSecrets: BOOLEAN;
{$ENDC}
IMPLEMENTATION
{$IFC fDbgOk}
{$R+}

Apple Lisa ToolKit 3.0 Source Code Listing -- 939 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359

{$ELSEC}
{$R-}
{$ENDC}
{$IFC fSymOk}
{$D+}
{$ELSEC}
{$D-}
{$ENDC}
{$SETC doTraceUT := FALSE}
{$SetC fTraceUT := doTraceUT AND fUniversalTextTrace}
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{$I libut/UUnivText2.text}
{$IFC WithUObject}
{$S TKUTInit}
{$ELSEC}
{$S UTInit}
{$ENDC}
END.

End of File -- Lines: 359 Characters: 13021

Apple Lisa ToolKit 3.0 Source Code Listing -- 940 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBTK/XFER.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

; UNIT XFER; {Copyright 1983, 1984 Apple Computer, Inc.}


;
;
;
;
;
;
;
;
;
;
;
;
;

{changed 01/20/83 2026


{changed 01/05/83 2149

{changed 01/01/83 2000

{changed 09/13/83 1115


{changed 08/30/83 2000

Added EqualBytes
Moved several routines to CLASLIB so they can go into PASLIB;
Here we still have (in SgCLAres):
LIntDivLint, LIntDivInt, LIntMulInt, LIntAndLInt, LIntOrLInt,
XferLeft, XferRight, RotatePattern, EnterLisabug}
Added %_JmpTo, %_ExitCaller, %_ExitFunny, %_CallMethod, %_Super;
Replaced IsJsr by %_NextMethod;
Deleted XPNewMethod;
Changed Segment from SgABCres to SgCLAres & added some SgCLAini procedures;
Added $D information conditioned on DEBUGF flag;
(Note: SP=A7)}
RELEASE TK7D TO TOOLKIT TEAM}
RELEASE TK7C TO TOOLKIT TEAM}

;=============================================================================================
DEBUGF .EQU 1
; 1 to include $D+ info, 0 to exclude it
;=============================================================================================
.MACRO HEAD
.IF DEBUGF
LINK
A6,#0
MOVE.L (SP)+,A6
.ENDC
.ENDM

; These two instructions form a slow no-op

.MACRO TAIL
.IF DEBUGF
UNLK
A6
RTS
.ASCII %1
.ENDC
.ENDM
;=============================================================================================
.SEG
'SgXFER'
;=============================================================================================
.PROC XFERLEFT

Apple Lisa ToolKit 3.0 Source Code Listing -- 941 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

HEAD
; PROCEDURE XferLeft(source, dest: TP; nBytes: INTEGER);
;
; uses A0,A1,D0,D1
;

XFER

MOVE.L
MOVE.W
MOVE.L
MOVE.L
MOVE.L

(SP)+,D1
(SP)+,D0
(SP)+,A1
(SP)+,A0
D1,-(SP)

;
;
;
;
;

POP RETURN ADDRESS


D0 := NBYTES
A1 := DEST
A0 := SOURCE
PUSH RETURN ADDRESS FOR RTS

SUB.W

#1,D0

; DECREMENT NBYTES

BLT.S

RTSLEFT

; NBYTES <= 0, SO EXIT

MOVE.B
DBF

(A0)+,(A1)+
D0,XFER

RTSLEFT RTS
TAIL

'XFERLEFT'

;=============================================================================================
.PROC XFERRIGH
HEAD
; PROCEDURE XferRight(source, dest: TP; nBytes: INTEGER);
;
; uses A0,A1,D0,D1
;
MOVE.L
MOVE.W
MOVE.L
MOVE.L
MOVE.L

(SP)+,D1
(SP)+,D0
(SP)+,A1
(SP)+,A0
D1,-(SP)

;
;
;
;
;

POP RETURN ADDRESS


D0 := NBYTES
A1 := DEST
A0 := SOURCE
PUSH RETURN ADDRESS FOR RTS

TST.W
BLE.S

D0
RTSRIGH

; TEST NBYTES
; NBYTES <= 0, SO EXIT

ADDA.W
ADDA.W

D0,A0
D0,A1

; START AT RIGHT END

SUB.W

#1,D0

; DECREMENT NBYTES

Apple Lisa ToolKit 3.0 Source Code Listing -- 942 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

XFER

MOVE.B
DBF

-(A0),-(A1)
D0,XFER

RTSRIGH RTS
TAIL

'XFERRIGH'

;=============================================================================================
.PROC EqualBytes
HEAD
; PROCEDURE EqualBytes(source, dest: TP; nBytes: INTEGER);
;
; uses A0,A1,D0,D1
;

XFER

MOVE.L
MOVE.W
MOVE.L
MOVE.L
MOVE.L

(SP)+,D1
(SP)+,D0
(SP)+,A1
(SP)+,A0
D1,-(SP)

;
;
;
;
;

POP RETURN ADDRESS


D0 := NBYTES
A1 := DEST
A0 := SOURCE
PUSH RETURN ADDRESS FOR RTS

MOVE.B

#1,4(SP)

; RETURN TRUE UNLESS PROVEN UNEQUAL

SUB.W

#1,D0

; DECREMENT NBYTES

BLT.S

RTSEQUL

; NBYTES <= 0, SO EXIT

MOVE.B
CMP.B
BNE
DBF

(A0)+,D1
(A1)+,D1
UNEQUL
D0,XFER

RTSEQUL RTS
UNEQUL

CLR.B
RTS

4(SP)

TAIL

'EQUALBYT'

; RETURN FALSE

;=============================================================================================
.PROC ROTATEPA
HEAD
; PROCEDURE RotatePattern(pInPat, pOutPat: ^Pattern; dh, dv: LONGINT);

Apple Lisa ToolKit 3.0 Source Code Listing -- 943 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

;
; uses A0-A2,D0-D4
;
MOVEM.L (SP)+,D0-D2/A0-A1
MOVE.L D0,-(SP)
MOVEM.L A2/D3-D4,-(SP)

; D0 := RETURN ADDRESS, D1 := dv; D2 := dh, A0 := pOutPat, A1 := pInPat


; PUSH RETURN ADDRESS FOR RTS
; Save A2,D3,D4

AND.L

; dh := dh MOD 8

#7,D2

; ***** FOR D3 := 7 DOWNTO 0 DO *****


MOVE.W
; *****
RLOOP

; *****

#7,D3

; Loop count

BEGIN *****
MOVE.B

$00(A1,D3.W),D0 ; D0 := next byte in inPat

ROL.B

D2,D0

; Rotate byte in D0 left by D2 (dh)

MOVE.W
SUB.W
AND.W

D3,D4
D1,D4
#7,D4

; D4 := (D3 - dv) MOD 8

MOVE.B

D0,$00(A0,D4.W) ; next byte in outPat := D0

DBF

D3,RLOOP

END; *****
MOVEM.L (SP)+,A2/D3-D4

; Restore A2,D3,D4

RTS
TAIL

'ROTATEPA'

;=============================================================================================
.FUNC LINTDIVL
HEAD
; FUNCTION LIntDivLint(i, j: LONGINT): LONGINT;
;
; uses A0,D0,D1
;
.REF

LD

Apple Lisa ToolKit 3.0 Source Code Listing -- 944 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

CHEK

MOVE.L

(SP)+,A0

; Return address

MOVE.L
MOVE.L

(SP)+,D0
(SP)+,D1

; D0 := j
; D1 := i

CMP.L
BGT
CMP.L
BLT
JMP

#32767,D0
TOOLONG
#-32768,D0
TOOLONG
LD

; Is j too long to use LIntDivInt?


; Too big

TOOLONG ASR.L
ASR.L
JMP
TAIL

; Too small
; Can't BGT LD in this assembler

#1,D0
#1,D1
CHEK
'LINTDIVL'

;=============================================================================================
.FUNC LINTDIVI
HEAD
; FUNCTION LIntDivInt(i: LONGINT; j: INTEGER): LONGINT;
;
; uses A0,D0,D1,D2
;

LD

JPOS

.DEF

LD

MOVE.L

(SP)+,A0

; Return address

MOVE.W
MOVE.L

(SP)+,D0
(SP)+,D1

; D0 := j
; D1 := i

CMP.W
BEQ

#1,D0
DV1

; IF j = 1, return i

MOVE.L
MOVE.W

D1,-(SP)
D0,-(SP)

; Push i as LONGINT
; Push j as INTEGER

CLR.L

D1

TST.W
BGE
NEG.W
NEG.L

(SP)
JPOS
(SP)
2(SP)

; If j is negative, negate both

TST.L

2(SP)

; If i is negative, negate it but remember it was

; negate j
; negate i

Apple Lisa ToolKit 3.0 Source Code Listing -- 945 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

SMI
BGE
NEG.L

D2
IPOS
2(SP)

; D2 := (i < 0)

MOVE.W
DIVU

2(SP),D1
(SP),D1

; Divide MSW of i by j

MOVE.L
MOVE.W
DIVU

D1,D0
4(SP),D0
(SP)+,D0

; Remainder becomes MSW of next Divide


; Divide ((preceding remainder) concat (LSW of i)) by j
; Pop j at the same time

SWAP
MOVE.W

D1
D0,D1

; Quotient of first divide is MSW of result


; Quotient of second divide is LSW of result

TST.B
BEQ
NEG.L

D2
DUN
D1

; Was i negative?

DUN

ADD.L

#4,SP

; Popeye

DV1

MOVE.L

D1,(SP)

; Store function result

JMP

(A0)

; Return

TAIL

'LINTDIVI'

IPOS

; negate i

;=============================================================================================
.FUNC LINTMULI
HEAD
; FUNCTION LIntMulInt(i: LONGINT; j: INTEGER): LONGINT;
;
; uses A0,D0,D1,D2
;
MOVE.L

(SP)+,A0

; Return address

MOVE.W
MOVE.L

(SP)+,D1
(SP)+,D0

; D1 := j
; D0 := i

CMP.W
BEQ

#1,D1
MU1

; IF j = 1, return i

MOVE.L

D2,-(SP)

; Save D2

MOVE.W
SWAP

D0,D2
D0

; D2 := LSW of I
; D0 := MSW of I

Apple Lisa ToolKit 3.0 Source Code Listing -- 946 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

MU1

MULU
LSL.L
LSL.L
MULU
ADD.L

D1,D0
#8,D0
#8,D0
D1,D2
D2,D0

; D0 := D0 * j

MOVE.L

(SP)+,D2

; restore D2

MOVE.L

D0,(SP)

; Store function result

JMP

(A0)

; Return

TAIL

'LINTMULI'

; D0 := product

;=============================================================================================
.FUNC LINTANDL
HEAD
; FUNCTION LIntAndLInt(i, j: LONGINT): LONGINT;
;
; uses A0,D0
;
MOVE.L

(SP)+,A0

; Return address

MOVE.L
AND.L

(SP)+,D0
(SP)+,D0

; D0 := j
; D0 := i AND j

MOVE.L

D0,(SP)

; Store function result

JMP

(A0)

; Return

TAIL

'LINTANDL'

;=============================================================================================
.FUNC LINTORLI
HEAD
; FUNCTION LIntOrLInt(i, j: LONGINT): LONGINT;
;
; uses A0,D0
;
MOVE.L

(SP)+,A0

; Return address

Apple Lisa ToolKit 3.0 Source Code Listing -- 947 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

MOVE.L
OR.L

(SP)+,D0
(SP)+,D0

; D0 := j
; D0 := i OR j

MOVE.L

D0,(SP)

; Store function result

JMP

(A0)

; Return

TAIL

'LINTORLI'

;=============================================================================================
.FUNC LINTXORL
HEAD
; FUNCTION LIntXorLInt(i, j: LONGINT): LONGINT;
;
; uses A0,D0, D1
;
MOVE.L

(SP)+,A0

; Return address

MOVE.L
MOVE.L
EOR.L

(SP)+,D0
(SP)+,D1
D1,D0

; D0 := j
; D1 := i
; D0 := i XOR j

MOVE.L

D0,(SP)

; Store function result

JMP

(A0)

; Return

TAIL

'LINTXORL'

;=============================================================================================
.PROC ENTERLIS
HEAD
; PROCEDURE EnterLisabug;
TRAP
RTS

#0

TAIL

'ENTERLIS'

;=============================================================================================
.END

Apple Lisa ToolKit 3.0 Source Code Listing -- 948 of 1012

Apple Lisa Computer Technical Information


000380
000381
End of File -- Lines: 381 Characters: 9390

Apple Lisa ToolKit 3.0 Source Code Listing -- 949 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "LIBUT/UUNIVTEXT2.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

{$SETC PasteTrace := PasteTrace AND fUniversalTextTrace}


CONST
magicTabMax= itbdLst;
maxBacking = 12;

{The maximum number of tabstops on a ruler allowed by LisaWrite and its ilk}
{Maximum number of chars saved for backing up the lpLim during Write UT}

TYPE
TPtrToolKitUT = ^ToolKitUT;
ToolKitUT =
Tcs;
TSavedPara =
RECORD
firstLp:
TLp;
theArce:
TArce;
theArpe:
TArpe;
{$IFC WithUObject}
theText:
TString;
{$ELSEC}
theText:
TUTString;
{$ENDC}
END;
PSavedPara =
^TSavedPara;
HSavedPara =
^PSavedPara;
{$IFC NOT WithUObject}
Byte =
-128..127;
TpLONGINT =
^LONGINT;
TPByte =
^Byte;
{$ENDC}
{private types not used in the Toolkit; used in place of the Toolkit's type coercion to a
Handle, since a Handle outside of the Toolkit is a double-indeirect pointer to a byte}
UTpLongint = ^LONGINT;
UTppLongint = ^UTpLongint;
{ Carefull, carefull, carefull here kids. Since I can't have private fields and/or methods in my classes
inorder to resolve a few types I am forced to do this thing to keep you innocents from having to
include an ugly list of units. Only one instance of these variabes exists ever! Therefore I can only
do things one at a time.}
TSecretThings = RECORD
streamArrayIndex:
lpd:
achad:
END;

Byte;
TALpd;
TAchad;

Apple Lisa ToolKit 3.0 Source Code Listing -- 950 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

VAR
{$IFC WithUObject}
activeStream:
{$ELSEC}
activeStream:
{$ENDC}
secrets:
currentLpd:
dataIndex:
dataLp:
savedPara:
nOfSavedPara:
{$IFC WithUObject}
theData:
{$ELSEC}
theData:
{$ENDC}

TTKWriteUnivText;
TWriteUnivText;
TSecretThings;
TLpd;
INTEGER;
TLp;
ARRAY [1..maxBacking] OF HSavedPara;
0..maxBacking;
TString;
TUTString;

{$IFC NOT WithUObject}


{The following is a ToolKit to avoid including lots of code that is not used by non-ToolKit applications.}
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
PROCEDURE UTXferRight(source, dest: Ptr; nBytes: INTEGER); EXTERNAL;
PROCEDURE UTXferLeft(source, dest: Ptr; nBytes: INTEGER); EXTERNAL;
{--------------------------------------------------------------------------------------------------------}
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
FUNCTION Min(i, j: LONGINT): LONGINT;
{--------------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
IF i < j THEN
Min := i
ELSE
Min := j;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 951 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
FUNCTION Max(i, j: LONGINT): LONGINT;
{--------------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
IF i > j THEN
Max := i
ELSE
Max := j;
END;
{$IFC WithUObject}
{$S TKUTInit}
{$ELSEC}
{$S UTInit}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
PROCEDURE ABCBreak(s: S255; errCode: LONGINT);
{--------------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fDbgObject}
WriteLn;
Write(CHR(7), s);
{Beep}
IF errCode <> 0 THEN
Write(': ', errCode:1);
WriteLn;
{$ENDC}
HALT;
END;
{$IFC WithUObject}
{$S TKUTInit}
{$ELSEC}
{$S UTInit}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
PROCEDURE SetCp(object: TUTObject; itsClass: TClass);
{--------------------------------------------------------------------------------------------------------}

Apple Lisa ToolKit 3.0 Source Code Listing -- 952 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

VAR index: INTEGER;


BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
UTppLongint(object)^^ := ORD(itsClass);
index := CiOfCp(TPSliceTable(itsClass));
IF index < 256 THEN
TPByte(UTppLongint(object)^)^ := index;
END;

{Install slice table


{Determine its class
{If it will fit in a
{...to speed version

pointer}
index}
byte, store it...}
conversion (cf ConvertHeap: FindClasses)}

{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
FUNCTION NewDynObject(heap: THeap; itsClass: TClass; dynBytes: INTEGER): TUTObject;
{--------------------------------------------------------------------------------------------------------}
VAR nBytes: INTEGER;
object: TUTObject;
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
nBytes := SizeOfCp(TPSliceTable(itsClass)) + dynBytes;
object := POINTER(ORD(HAllocate(THz(heap), nBytes)));
{TUTObject() won't work until after SetCp}
IF ORD(object) = ORD(hNIL) THEN
ABCBreak('NewObject: Heap full, can''t make an object of size', nBytes);
SetCp(object, itsClass);
NewDynObject := object;
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
FUNCTION NewUTObject(heap: THeap; itsClass: TClass): TUTObject;
{--------------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
NewUTObject := NewDynObject(heap, itsClass, 0);
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 953 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

{$S UTMain}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
PROCEDURE ResizeDynObject(object: TUTObject; newTotalBytes: INTEGER);
{--------------------------------------------------------------------------------------------------------}
VAR i: INTEGER;
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
IF (newTotalBytes < 0) OR (newTotalBytes > (MAXINT-20)) THEN
ABCBreak('New size must lie between 0 and 32K-20, not', newTotalBytes);
ChangeSizeH(THz(object.Heap), TH(object), newTotalBytes);
IF CbDataOfH(THz(object.Heap), TH(object)) < newTotalBytes THEN
ABCBreak('ResizeDynObject: Heap full, size can''t change to', newTotalBytes);
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
FUNCTION ClassPtr(hndl: UTppLongint): TClass;
{--------------------------------------------------------------------------------------------------------}
VAR stp: RECORD
CASE INTEGER OF
1: (asLong: LONGINT);
2: (asBytes: PACKED ARRAY [0..3] OF TByte);
3: (asClass: TClass);
END;
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
stp.asLong := hndl^^;
stp.asBytes[0] := 0;
ClassPtr := stp.asClass;
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
FUNCTION SizeOfClass(class: TClass): INTEGER;
{--------------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 954 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

SizeOfClass := SizeOfCp(TPSliceTable(class));
END;
{$IFC WithUObject}
{$S TKUTInit}
{$ELSEC}
{$S UTInit}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
PROCEDURE InitObject;
{--------------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{Do very little for the time beeing}
END;
{$IFC WithUObject}
{$S TKUTInit}
{$ELSEC}
{$S UTInit}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
PROCEDURE ClascalError(error: INTEGER); {called with error = 0 after successful Clascal initialization}
{--------------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
IF error > 0 THEN
ABCBreak('Some kind of Clascal error', error);
END;
METHODS OF TUTObject;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TObject.}Free;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
SELF.FreeObject;
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 955 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TObject.}FreeObject;
{----------------------------------------------------------------------------------------------------}
VAR heap:
THeap;
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
heap := SELF.Heap;
FreeH(THz(heap), TH(SELF));
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
FUNCTION {TObject.}Heap: THeap;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
Heap := THeap(HzFromH(TH(SELF)));
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
FUNCTION {TObject.}Class: TClass;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
Class := ClassPtr(UTppLongint(SELF));
END;
{$IFC WithUObject}
{$S TKUTInit}
{$ELSEC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 956 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

{$S UTInit}
{$ENDC}
BEGIN {Class Initialization}
{$IFC fTraceUT}
LogCall;
InitClascal(ClascalError);
InitObject;
END;

{$ENDC}
{Provide an error routine in case of errors in Clascal run-time support}
{Do remaining initialization}

METHODS OF TUTCollection;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
FUNCTION {TCollection.}CREATE(object: TUTObject; heap: THeap; initialSlack: INTEGER): TUTCollection;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
IF object = NIL THEN
ABCBreak('TUTCollection.CREATE must be passed an already-allocated object by a subclass CREATE', 0);
SELF := TUTCollection(object);
WITH SELF DO
BEGIN
size := 0;
{$H-} dynStart := SizeOfClass(SELF.Class); {$H+}
holeStart := 0;
holeSize := initialSlack;
holeStd := 0;
END;
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
FUNCTION {TCollection.}AddrMember(i: LONGINT): LONGINT;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
IF i > SELF.holeStart THEN
i := i + SELF.holeSize;

Apple Lisa ToolKit 3.0 Source Code Listing -- 957 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421
000422
000423
000424
000425
000426
000427

AddrMember := TpLONGINT(SELF)^ + SELF.dynStart + (SELF.MemberBytes * (i - 1));


END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TCollection.}EditAt(atIndex: LONGINT; deltaMembers: INTEGER);
{----------------------------------------------------------------------------------------------------}
VAR oldHoSize:
INTEGER;
newHoSize:
INTEGER;
oldHoStart:
INTEGER;
newHoStart:
INTEGER;
maxHoStart:
INTEGER;
minHoStart:
INTEGER;
size:
INTEGER;
b:
0..1;
BEGIN
{Removes any hole it creates unless holdStd <> 0}
{$IFC fTraceUT}
LogCall;
{$ENDC}
oldHoSize := SELF.holeSize;
oldHoStart := SELF.holeStart;
IF (deltaMembers < 0) AND ((oldHoStart + 1) = atIndex) THEN {the hole is right before the deletion}
SELF.holeStart := oldHoStart - deltaMembers
ELSE
BEGIN
newHoStart := atIndex - 1 - Min(deltaMembers, 0);
IF (deltaMembers > oldHoSize) OR (newHoStart <> oldHoStart) THEN
BEGIN
maxHoStart := Max(oldHoStart, newHoStart);
newHoSize := Max(oldHoSize, deltaMembers);
IF newHoSize > oldHoSize THEN
BEGIN
size := SELF.size;
newHoSize := Max(newHoSize, SELF.holeStd);
SELF.ResizeColl(size + newHoSize);
SELF.ShiftColl(maxHoStart + oldHoSize, maxHoStart + newHoSize, size - maxHoStart);
END;
IF newHoStart <> oldHoStart THEN
BEGIN
b := ORD(newHoStart > oldHoStart);
{1 if hole is moving right and data is moving left}
minHoStart := Min(oldHoStart, newHoStart);
SELF.ShiftColl(minHoStart + oldHoSize*b, minHoStart + newHoSize*(1-b), maxHoStart - minHoStart);

Apple Lisa ToolKit 3.0 Source Code Listing -- 958 of 1012

Apple Lisa Computer Technical Information


000428
000429
000430
000431
000432
000433
000434
000435
000436
000437
000438
000439
000440
000441
000442
000443
000444
000445
000446
000447
000448
000449
000450
000451
000452
000453
000454
000455
000456
000457
000458
000459
000460
000461
000462
000463
000464
000465
000466
000467
000468
000469
000470
000471
000472
000473
000474
000475

END;
SELF.holeStart := newHoStart;
SELF.holeSize := newHoSize;
END;
END;
WITH SELF DO
BEGIN
size := size + deltaMembers;
holeSize := holeSize - deltaMembers;
holeStart := holeStart + deltaMembers;
IF oldHoSize = 0 THEN
IF holeStd = 0 THEN
IF holeSize > 0 THEN
{$H-}
SELF.StopEdit; {$H+}
END;
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TCollection.}InsManyAt(i: LONGINT; otherCollection: TUTCollection; index, howMany: LONGINT);
{----------------------------------------------------------------------------------------------------}
VAR memberBytes:
INTEGER;
beforeHole:
INTEGER;
srcAddr:
LONGINT;
dstAddr:
LONGINT;
j:
INTEGER;
offset:
INTEGER;
BEGIN
{Stops edit if it wasn't explicitly started}
{$IFC fTraceUT}
LogCall;
{$ENDC}
memberBytes := SELF.memberBytes;
SELF.EditAt(i, howMany);
IF howMany > 0 THEN
IF otherCollection.Class = SELF.Class THEN
{Can do it with at most two Xfers}
BEGIN
beforeHole := Min(howMany, otherCollection.holeStart + 1 - index);
srcAddr := otherCollection.AddrMember(index);
dstAddr := SELF.AddrMember(i);
IF beforeHole > 0 THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 959 of 1012

Apple Lisa Computer Technical Information


000476
000477
000478
000479
000480
000481
000482
000483
000484
000485
000486
000487
000488
000489
000490
000491
000492
000493
000494
000495
000496
000497
000498
000499
000500
000501
000502
000503
000504
000505
000506
000507
000508
000509
000510
000511
000512
000513
000514
000515
000516
000517
000518
000519
000520
000521
000522
000523

BEGIN
UTXferLeft(Ptr(srcAddr), Ptr(dstAddr), beforeHole * memberBytes);

END;

IF beforeHole < howMany THEN


BEGIN
srcAddr := srcAddr + (beforeHole + otherCollection.holeSize) * memberBytes;
dstAddr := dstAddr + beforeHole * memberBytes;
UTXferLeft(Ptr(srcAddr), Ptr(dstAddr), (howMany - beforeHole) * memberBytes);
END;
END
ELSE
UTXferLeft(Ptr(srcAddr), Ptr(dstAddr), howMany * memberBytes);
END
ELSE
{Must Xfer each member separately}
BEGIN
offset := SELF.dynStart + (i - 1) * memberBytes; {AddrMember may even compact for all we know}
FOR j := 1 TO howMany DO
BEGIN
UTXferLeft(Ptr(otherCollection.AddrMember(j)), Ptr(TpLONGINT(SELF)^ + offset), memberBytes);
offset := offset + memberBytes;
END;
END;

{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TCollection.}ResizeColl(membersPlusHole: INTEGER);
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
IF membersPlusHole <> (SELF.size + SELF.holeSize) THEN
ResizeDynObject(SELF, SELF.dynStart + (membersPlusHole * SELF.MemberBytes));
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TCollection.}ShiftColl(afterSrcIndex, afterDstIndex, howMany: INTEGER);
{----------------------------------------------------------------------------------------------------}

Apple Lisa ToolKit 3.0 Source Code Listing -- 960 of 1012

Apple Lisa Computer Technical Information


000524
000525
000526
000527
000528
000529
000530
000531
000532
000533
000534
000535
000536
000537
000538
000539
000540
000541
000542
000543
000544
000545
000546
000547
000548
000549
000550
000551
000552
000553
000554
000555
000556
000557
000558
000559
000560
000561
000562
000563
000564
000565
000566
000567
000568
000569
000570
000571

VAR memberBytes:
INTEGER;
numBytes:
INTEGER;
startAddr:
LONGINT;
srcAddr:
LONGINT;
dstAddr:
LONGINT;
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
IF (howMany > 0) AND (afterSrcIndex <> afterDstIndex) THEN
BEGIN
memberBytes := SELF.MemberBytes;
numBytes := howMany * memberBytes;
startAddr := TpLONGINT(SELF)^ + SELF.dynStart;
srcAddr := startAddr + afterSrcIndex * memberBytes;
dstAddr := startAddr + afterDstIndex * memberBytes;

END;

IF afterSrcIndex < afterDstIndex THEN


UTXferRight(Ptr(srcAddr), Ptr(dstAddr), numBytes)
ELSE
UTXferLeft(Ptr(srcAddr), Ptr(dstAddr), numBytes);
END;

{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TCollection.}StartEdit(withSlack: INTEGER);
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
SELF.holeStd := withSlack;
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TCollection.}StopEdit;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 961 of 1012

Apple Lisa Computer Technical Information


000572
000573
000574
000575
000576
000577
000578
000579
000580
000581
000582
000583
000584
000585
000586
000587
000588
000589
000590
000591
000592
000593
000594
000595
000596
000597
000598
000599
000600
000601
000602
000603
000604
000605
000606
000607
000608
000609
000610
000611
000612
000613
000614
000615
000616
000617
000618
000619

IF SELF.holeStart < SELF.size THEN


SELF.EditAt(SELF.size + 1, 0);
SELF.ResizeColl(SELF.size);
SELF.holeStd := 0;
SELF.holeSize := 0;
END;
{$IFC WithUObject}
{$S TKUTInit}
{$ELSEC}
{$S UTInit}
{$ENDC}
END;
METHODS OF TUTArray;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
FUNCTION {TArray.}CREATE(object: TUTObject; heap: THeap; initialSlack, bytesPerRecord: INTEGER): TUTArray;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
IF ODD(bytesPerRecord) THEN
bytesPerRecord := bytesPerRecord + 1;
IF object = NIL THEN
object := NewDynObject(heap, THISCLASS, initialSlack * bytesPerRecord);
SELF := TUTArray(TUTCollection.CREATE(object, heap, initialSlack));
SELF.recordBytes := bytesPerRecord;
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
FUNCTION {TArray.}MemberBytes: INTEGER;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
MemberBytes := SELF.recordBytes;

Apple Lisa ToolKit 3.0 Source Code Listing -- 962 of 1012

Apple Lisa Computer Technical Information


000620
000621
000622
000623
000624
000625
000626
000627
000628
000629
000630
000631
000632
000633
000634
000635
000636
000637
000638
000639
000640
000641
000642
000643
000644
000645
000646
000647
000648
000649
000650
000651
000652
000653
000654
000655
000656
000657
000658
000659
000660
000661
000662
000663
000664
000665
000666
000667

END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
FUNCTION {TArray.}At(i: LONGINT): Ptr;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{ At := Ptr(SELF.AddrMember(i));
but for speed...}
IF i > SELF.holeStart THEN
i := i + SELF.holeSize;
At := Ptr(TpLONGINT(SELF)^ + SELF.dynStart + (SELF.recordBytes * (i - 1)));
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TArray.}DelAll;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
SELF.EditAt(1, -SELF.size);
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TArray.}DelAt(i: LONGINT);
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
SELF.EditAt(i, -1);
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 963 of 1012

Apple Lisa Computer Technical Information


000668
000669
000670
000671
000672
000673
000674
000675
000676
000677
000678
000679
000680
000681
000682
000683
000684
000685
000686
000687
000688
000689
000690
000691
000692
000693
000694
000695
000696
000697
000698
000699
000700
000701
000702
000703
000704
000705
000706
000707
000708
000709
000710
000711
000712
000713
000714
000715

{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TArray.}DelManyAt(i, howMany: LONGINT);
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
SELF.EditAt(i, -howMany);
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TArray.}PutAt(i: LONGINT; pRecord: Ptr);
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
UTXferLeft(pRecord, Ptr(SELF.AddrMember(i)), SELF.recordBytes);
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TArray.}InsAt(i: LONGINT; pRecord: Ptr);
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
SELF.EditAt(i, 1);
SELF.PutAt(i, pRecord);
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 964 of 1012

Apple Lisa Computer Technical Information


000716
000717
000718
000719
000720
000721
000722
000723
000724
000725
000726
000727
000728
000729
000730
000731
000732
000733
000734
000735
000736
000737
000738
000739
000740
000741
000742
000743
000744
000745
000746
000747
000748
000749
000750
000751
000752
000753
000754
000755
000756
000757
000758
000759
000760
000761
000762
000763

{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TArray.}InsLast(pRecord: Ptr);
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(3);{$ENDC}
SELF.InsAt(SELF.size + 1, pRecord);
{$IFC fTrce}EP;{$ENDC}
END;
{$IFC WithUObject}
{$S TKUTInit}
{$ELSEC}
{$S UTInit}
{$ENDC}
END;
METHODS OF TUTString;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
FUNCTION {TString.}CREATE(object: TUTObject; heap: THeap; initialSlack: INTEGER): TUTString;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
IF ODD(initialSlack) THEN
initialSlack := initialSlack + 1;
IF object = NIL THEN
object := NewDynObject(heap, THISCLASS, initialSlack);
SELF := TUTString(TUTCollection.CREATE(object, heap, initialSlack));
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
FUNCTION {TString.}At(i: LONGINT): CHAR;

Apple Lisa ToolKit 3.0 Source Code Listing -- 965 of 1012

Apple Lisa Computer Technical Information


000764
000765
000766
000767
000768
000769
000770
000771
000772
000773
000774
000775
000776
000777
000778
000779
000780
000781
000782
000783
000784
000785
000786
000787
000788
000789
000790
000791
000792
000793
000794
000795
000796
000797
000798
000799
000800
000801
000802
000803
000804
000805
000806
000807
000808
000809
000810
000811

{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{At := CHAR(TPByte(SELF.AddrMember(i))^); but for speed...}
IF i > SELF.holeStart THEN
i := i + SELF.holeSize;
At := CHAR(TPByte(TpLONGINT(SELF)^ + SELF.dynStart + (i - 1))^);
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TString.}DelAt(i: LONGINT);
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
SELF.EditAt(i, -1);
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TString.}DelAll;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
SELF.EditAt(1, -SELF.size);
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TString.}DelManyAt(i, howMany: LONGINT);
{----------------------------------------------------------------------------------------------------}
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 966 of 1012

Apple Lisa Computer Technical Information


000812
000813
000814
000815
000816
000817
000818
000819
000820
000821
000822
000823
000824
000825
000826
000827
000828
000829
000830
000831
000832
000833
000834
000835
000836
000837
000838
000839
000840
000841
000842
000843
000844
000845
000846
000847
000848
000849
000850
000851
000852
000853
000854
000855
000856
000857
000858
000859

{$IFC fTraceUT}
LogCall;
{$ENDC}
SELF.EditAt(i, -howMany);
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TString.}InsAt(i: LONGINT; character: CHAR);
{----------------------------------------------------------------------------------------------------}
VAR pByte:
TPByte;
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
SELF.EditAt(i, 1);
{TPByte(SELF.AddrMember(i))^ := PByte(character);

but for speed...}

pByte := TPByte(TpLONGINT(SELF)^ + SELF.dynStart + (i - 1));


pByte^ := TByte(character);
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TString.}InsPAOCAt(i: LONGINT; pPackedArrayOfCharacter: Ptr; howMany: LONGINT);
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
SELF.EditAt(i, howMany);
UTXferLeft(pPackedArrayOfCharacter, Ptr(SELF.AddrMember(i)), howMany);
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TString.}ToPAOCAt(i, howMany: LONGINT; pPackedArrayOfCharacter: Ptr);
{----------------------------------------------------------------------------------------------------}

Apple Lisa ToolKit 3.0 Source Code Listing -- 967 of 1012

Apple Lisa Computer Technical Information


000860
000861
000862
000863
000864
000865
000866
000867
000868
000869
000870
000871
000872
000873
000874
000875
000876
000877
000878
000879
000880
000881
000882
000883
000884
000885
000886
000887
000888
000889
000890
000891
000892
000893
000894
000895
000896
000897
000898
000899
000900
000901
000902
000903
000904
000905
000906
000907

BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
SELF.EditAt(i + howMany, 0);
UTXferLeft(Ptr(SELF.AddrMember(i)), pPackedArrayOfCharacter, howMany);
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
FUNCTION {TString.}MemberBytes: INTEGER;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
MemberBytes := 1;
END;
{$IFC WithUObject}
{$S TKUTInit}
{$ELSEC}
{$S UTInit}
{$ENDC}
END;
{$ENDC}
{$IFC fUniversalTextTrace}
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
PROCEDURE PrintRun;
{--------------------------------------------------------------------------------------------------------}
VAR i:
INTEGER;
tab:
TTabDescritor;
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
{lpd, achad}
WRITELN('the character Descriptor is ');

Apple Lisa ToolKit 3.0 Source Code Listing -- 968 of 1012

Apple Lisa Computer Technical Information


000908
000909
000910
000911
000912
000913
000914
000915
000916
000917
000918
000919
000920
000921
000922
000923
000924
000925
000926
000927
000928
000929
000930
000931
000932
000933
000934
000935
000936
000937
000938
000939
000940
000941
000942
000943
000944
000945
000946
000947
000948
000949
000950
000951
000952
000953
000954
000955

FOR i := 1 TO activeStream.data.size DO
WRITE(activeStream.data.At(i));
WRITELN;
WRITELN('
maxDataSize ', activeStream.maxDataSize);
{$H-}
WITH activeStream.characterDescriptor DO
BEGIN
WRITELN('
font ', font);
WRITELN('
face ');
WRITELN('
Superscript ', Superscript);
WRITELN('
keepOnSamePage ', keepOnSamePage);
END;
WRITELN('the paragraph Descriptor is ');
WITH activeStream.paragraphDescriptor DO
BEGIN
WRITELN('
paraGraphStart ', paraGraphStart);
WRITELN('
firstLineMargin ', firstLineMargin);
WRITELN('
bodyMargin ', bodyMargin);
WRITELN('
rightMargin ', rightMargin);
WRITELN('
paraLeading ', paraLeading);
WRITELN('
lineSpacing ', lineSpacing);
WRITELN('
', tabTable.size:2,' Tabs ');
FOR i := 1 TO tabTable.size DO
BEGIN
tab := TTabDescritor(tabTable.At(i));
WITH tab DO
BEGIN
WRITELN('
position ', position);
WRITE ('
fillBetweenTabs ');
CASE fillBetweenTabs OF
tNoFill:
WRITELN('No fill');
tDotFill:
WRITELN('Dot fill');
tHyphenFill:
WRITELN('Hyphen fill');
tUnderLineFill: WRITELN('Underline fill');
END;{CASE}
WRITE ('
tabType ');
CASE tabType OF
qLeftTab:
WRITELN('Left tab');
qCenterTab:
WRITELN('Center tab');
qRightTab:
WRITELN('Right tab');
qPeriodTab:
WRITELN('Decimal period tab');
qCommaTab:
WRITELN('Decimal comma tab');
END;{CASE}
END;
END;
WRITE ('
paraType ');
CASE paraType OF

Apple Lisa ToolKit 3.0 Source Code Listing -- 969 of 1012

Apple Lisa Computer Technical Information


000956
000957
000958
000959
000960
000961
000962
000963
000964
000965
000966
000967
000968
000969
000970
000971
000972
000973
000974
000975
000976
000977
000978
000979
000980
000981
000982
000983
000984
000985
000986
000987
000988
000989
000990
000991
000992
000993
000994
000995
000996
000997
000998
000999
001000
001001
001002
001003

qLeftPara:
WRITELN('Left aligned');
qCenterPara:
WRITELN('Centered');
qRightPara:
WRITELN('Right aligned');
qJustPara:
WRITELN('Justified');
END;{CASE}
WRITELN('
hasPicture ', hasPicture);
END;

{$H+}
{$IFC fTrce}EP;{$ENDC}
END;
{$ENDC}

{$IFC fUniversalTextTrace}
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
PROCEDURE PrintLpd(theLpd: TALpd);
{--------------------------------------------------------------------------------------------------------}
PROCEDURE WriteQuad(quad: TQuad);
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
CASE quad OF
quadL: WRITELN('quadL');
quadC: WRITELN('quadC');
quadR: WRITELN('quadR');
quadJ: WRITELN('quadJ');
END;
END;
PROCEDURE WriteTArpe(arpe: TArpe);
VAR i: INTEGER;
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
WITH arpe DO
BEGIN
WRITELN('
cb:
WRITELN('
sy:
WRITELN('
xLftFst:
WRITELN('
xLftBody:
WRITELN('
xRt:
WRITELN('
yLd:
WRITELN('
fill1:
WRITELN('
yLine:

',
',
',
',
',
',
',
',

cb:1);
sy:1);
xLftFst:1);
xLftBody:1);
xRt:1);
yLd:1);
fill1:1);
yLine:1);

Apple Lisa ToolKit 3.0 Source Code Listing -- 970 of 1012

Apple Lisa Computer Technical Information


001004
001005
001006
001007
001008
001009
001010
001011
001012
001013
001014
001015
001016
001017
001018
001019
001020
001021
001022
001023
001024
001025
001026
001027
001028
001029
001030
001031
001032
001033
001034
001035
001036
001037
001038
001039
001040
001041
001042
001043
001044
001045
001046
001047
001048
001049
001050
001051

WRITE ('
quad:
');
WriteQuad(quad);
WRITELN('
itbLim:
', itbLim:1);
WRITELN('
argtbd:');
FOR i := 0 TO itbLim - 1 DO
{$R-}
WITH argtbd[i] DO
BEGIN
WRITELN('
[',i:0,']:');
WRITELN('
x:
', x:1);
(* WRITELN('
fill4:
', fill4:1); *)
WRITE ('
quad:
');
WriteQuad(argtbd[i].quad);
WRITE ('
tyfill:
');
CASE tyfill OF
tyfillNil: WRITELN('tyfillNil');
tyfillDots: WRITELN('tyfillDots');
tyfillHyph: WRITELN('tyfillHyph');
tyfillUL:
WRITELN('tyfillUL');
END;

END;

WRITELN('
END;
{$R+}
END;

BEGIN
{$IFC fTraceUT}
LogCall;
{$IFC fTrce}BP(11);{$ENDC}

chLdr:

', chLdr:1);

{$ENDC}

WRITELN(' Lpd ');


WITH theLpd DO
BEGIN
WRITELN('ics:
',
WRITELN('ilpd:
',
WRITELN('fParSt:
',
WRITELN('lp:
',
WRITELN('lplim
',
WRITELN('lpson:
',
WRITELN('icsson:
',
WRITELN('tyset:');
WITH tyset DO
BEGIN
WRITELN('
fRce:
WRITELN('
fParBnds:

ics:1);
ilpd:1);
fParSt);
lp:1);
lplim:1);
lpson:1);
icsson:1);

', tyset.fRce);
', tyset.fParBnds);

Apple Lisa ToolKit 3.0 Source Code Listing -- 971 of 1012

Apple Lisa Computer Technical Information


001052
001053
001054
001055
001056
001057
001058
001059
001060
001061
001062
001063
001064
001065
001066
001067
001068
001069
001070
001071
001072
001073
001074
001075
001076
001077
001078
001079
001080
001081
001082
001083
001084
001085
001086
001087
001088
001089
001090
001091
001092
001093
001094
001095
001096
001097
001098
001099

WRITELN('
fRpe:
END;
WRITELN('lpFstPar:
WRITELN('lpLimPar:

', tyset.fRpe);
', lpFstPar:1);
', lpLimPar:1);

IF tyset.fRpe THEN
IF rpe = NIL THEN
WRITELN('rpe:
ELSE
WITH rpe^ DO
BEGIN
WRITELN('rpe:');
WriteTArpe(rpe^);
END;

NIL')

IF tyset.fRce THEN
WITH arce DO
BEGIN
WRITELN('arce:');
WRITELN('
cb:
WRITELN('
fVan:
WRITELN('
fBold:
WRITELN('
fItalic:
WRITELN('
fUnderline:
WRITELN('
fill4:
WRITELN('
cbSuperscript:
WRITELN('
ifnt:
WRITELN('
fKeep:
WRITELN('
fOutLine:
WRITELN('
fShadow:
WRITELN('
fFillB:
WRITELN('
fFillC:
WRITELN('
fFillD:
WRITELN('
fFillE:
WRITELN('
fFillF:
END;

',
',
',
',
',
',
',
',
',
',
',
',
',
',
',
',

cb:1);
fVan:1);
fBold:1);
fItalic:1);
fUnderline:1);
fill4:1);
cbSuperscript:1);
ifnt:1);
fKeep:1);
fOutLine:1);
fShadow:1);
fFillB:1);
fFillC:1);
fFillD:1);
fFillE:1);
fFillF:1);

IF tyset.fRpe THEN
BEGIN
WRITELN('arpe:');
WriteTArpe(arpe);
END;
END;
WRITELN('');
WRITELN;
{$IFC fTrce}EP;{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 972 of 1012

Apple Lisa Computer Technical Information


001100
001101
001102
001103
001104
001105
001106
001107
001108
001109
001110
001111
001112
001113
001114
001115
001116
001117
001118
001119
001120
001121
001122
001123
001124
001125
001126
001127
001128
001129
001130
001131
001132
001133
001134
001135
001136
001137
001138
001139
001140
001141
001142
001143
001144
001145
001146
001147

END;
{$ENDC}

{$IFC fUniversalTextTrace}
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
PROCEDURE PrintAchad(achad: TAchad);
{--------------------------------------------------------------------------------------------------------}
VAR i:
INTEGER;
size:
INTEGER;
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
WITH achad DO
BEGIN
WRITELN(' Achad ');
WRITELN('ichFst:
', ichFst:1);
WRITELN('ichLim:
', ichLim:1);
IF rgch <> NIL THEN
BEGIN
size := ichlim - ichFst - 1;
IF size >= 80 THEN
size := 79;
FOR i := ichFst TO ichFst + size DO
{$R-}
IF rgch^[i] >= 32 THEN
WRITE(CHR(rgch^[i]))
ELSE
WRITE('<', rgch^[i]:0, '>');
{$R+}
WRITELN;
IF ichlim - ichFst >= 79 THEN
WRITELN('etc, etc...');
END;
WRITELN('');
WRITELN;
END;
{$IFC fTrce}EP;{$ENDC}
END;
{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 973 of 1012

Apple Lisa Computer Technical Information


001148
001149
001150
001151
001152
001153
001154
001155
001156
001157
001158
001159
001160
001161
001162
001163
001164
001165
001166
001167
001168
001169
001170
001171
001172
001173
001174
001175
001176
001177
001178
001179
001180
001181
001182
001183
001184
001185
001186
001187
001188
001189
001190
001191
001192
001193
001194
001195

{$IFC fUniversalTextTrace}
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
PROCEDURE PrintSecrets(achad: TAchad; theLpd: TALpd);
{--------------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
WRITELN('streamArrayIndex is ', secrets.streamArrayIndex);
PrintLpd(theLpd);
PrintAchad(achad);
{$IFC fTrce}EP;{$ENDC}
END;
{$ENDC}
{$IFC WithUObject}
{$S TKUTWrite}
{$ELSEC}
{$S UTWrite}
{$ENDC}
{--------------------------------------------------------------------------------------------------------}
PROCEDURE SeqLpdUTBB(Lpd: TLpd; var achad: Tachad);
{--------------------------------------------------------------------------------------------------------}
VAR howMany:
INTEGER;
done:
BOOLEAN;
index:
INTEGER;
backUp:
INTEGER;
newPara:
BOOLEAN;
{$IFC WithUObject}
newData:
TString;
{$ELSEC}
newData:
TUTString;
{$ENDC}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
{LSR: put the next assignment and the WITH before the debugging code because
PrintSecrets depends on it.}

Apple Lisa ToolKit 3.0 Source Code Listing -- 974 of 1012

Apple Lisa Computer Technical Information


001196
001197
001198
001199
001200
001201
001202
001203
001204
001205
001206
001207
001208
001209
001210
001211
001212
001213
001214
001215
001216
001217
001218
001219
001220
001221
001222
001223
001224
001225
001226
001227
001228
001229
001230
001231
001232
001233
001234
001235
001236
001237
001238
001239
001240
001241
001242
001243

currentLpd := lpd;

{ Remember the lpd for RunToStream }

WITH lpd^ DO
BEGIN
rpe := @arpe;
rce := @arce;
END;

{ Make shure the lpd is set up OK }

{$IFC fUniversalTextTrace}
IF fPrintSecrets THEN
BEGIN
WRITELN(' SeqLpdUTBB ');
PrintSecrets(achad, currentLpd^);
WRITELN('dataLp =
', dataLp:0);
WRITELN('dataIndex =
', dataIndex:0);
WRITELN('nOfSavedPara = ', nOfSavedPara:0);
END;
{$ENDC}
newPara := FALSE;

{Assume no new para}


{ Compute if we have to back up }
backUp := MIN(maxBacking, MAX(dataLp - lpd^.lpLim, 0));
{$IFC fUniversalTextTrace}
IF fPrintSecrets THEN
WRITELN('backUp =
{$ENDC}

', backUp:0);

IF backUp > 0 THEN


BEGIN
index := 1;
done := FALSE;
WHILE (NOT done) AND (index <= nOfSavedPara) DO
WITH savedPara[index]^^, lpd^ DO
IF firstLp <= lpLim THEN
BEGIN
{$IFC fUniversalTextTrace}
IF fPrintSecrets THEN
WRITELN('Backing up... to saved paragraph #', index:0);
{$ENDC}
lpLim := MAX(firstLp, lpLim);
theData := theText;
dataIndex := lpLim - firstLp;
arpe := theArpe;
IF dataIndex <> 0 THEN
fParSt := FALSE;
arce := theArce;

Apple Lisa ToolKit 3.0 Source Code Listing -- 975 of 1012

Apple Lisa Computer Technical Information


001244
001245
001246
001247
001248
001249
001250
001251
001252
001253
001254
001255
001256
001257
001258
001259
001260
001261
001262
001263
001264
001265
001266
001267
001268
001269
001270
001271
001272
001273
001274
001275
001276
001277
001278
001279
001280
001281
001282
001283
001284
001285
001286
001287
001288
001289
001290
001291

done := TRUE;
END
ELSE
index := index + 1;
IF NOT done THEN
{ This is FATAL !!!}
BEGIN
{$IFC fUniversalTextTrace}
WRITELN('Fatal back up attempt in SeqLpdUTBB');
PrintSecrets(achad, lpd^);
{$ENDC}
HALT;
END;

{Die rather than fuck up}

END
ELSE
BEGIN
IF activeStream.data.Size = 0 THEN
{ Test if there is anything left in the buffer, }
BEGIN
newPara := TRUE;
activeStream.ParagraphDescriptor.paraGraphStart := TRUE;
{$IFC WithUObject}
activeStream.ParagraphDescriptor.additionalChrInParagraph := 0;
{$ENDC}
activeStream.FillParagraph;
{ if not then try to get one more paragraph }
activeStream.data.StopEdit;
{ Remove any holes from data }
{$IFC fUniversalTextTrace}
IF fPrintSecrets THEN
BEGIN
WRITELN('FillRun returns:');
PrintRun;
END;
{$ENDC}
dataIndex := 0;

{ Reset the index to the begining of the text}

WITH lpd^ DO
{ Pre-fill the lpd with standard data }
BEGIN
{$H-} MoveRgch(@arpe, @arpeStd, arpeStd.cb); {$H+}
{$H-} MoveRgch(@arce, @arceStd, arceStd.cb); {$H+}
dataLp := lpLim;
END;
activeStream.RunToStream;
END
ELSE
BEGIN

{ Convert into stream format }

Apple Lisa ToolKit 3.0 Source Code Listing -- 976 of 1012

Apple Lisa Computer Technical Information


001292
001293
001294
001295
001296
001297
001298
001299
001300
001301
001302
001303
001304
001305
001306
001307
001308
001309
001310
001311
001312
001313
001314
001315
001316
001317
001318
001319
001320
001321
001322
001323
001324
001325
001326
001327
001328
001329
001330
001331
001332
001333
001334
001335
001336
001337
001338
001339

{$IFC fUniversalTextTrace}
IF fPrintSecrets THEN
WRITELN('Procede with the rest of the old run:');
{$ENDC}
dataIndex := Lpd^.lpLim - dataLp;
IF dataIndex <> 0 THEN
lpd^.fParSt := FALSE;
END;
theData := activeStream.data;
END;
{ Compute how many bytes to transfer this time }
howMany := MIN(achad.ichLim - achad.ichFst, theData.size - dataIndex);
{$IFC fUniversalTextTrace}
IF fPrintSecrets THEN
BEGIN
WRITELN('theData.size =
WRITELN('dataLp =
WRITELN('dataIndex =
WRITELN('howMany =
WRITELN('newPara =
END;
{$ENDC}

',
',
',
',
',

theData.size:0);
dataLp:0);
dataIndex:0);
howMany:0);
newPara:0);

WITH lpd^ DO
BEGIN
lp := lpLim;
lplim := lp + howMany;
END;
WITH secrets.achad DO
{ Build our own achad just in case... }
BEGIN
rgch := POINTER(ORD4(theData.AddrMember(1)) + dataIndex);
ichfst := 0;
ichLim := howMany;
END;
{ Copy the achad }
{ Check for NIL rgch.}
{ If NIL then pass data else copy the data }
IF achad.rgch = NIL THEN
achad := secrets.achad
ELSE
BEGIN
achad.ichlim := achad.ichFst + howMany;
MoveAchad(achad, secrets.achad);

Apple Lisa ToolKit 3.0 Source Code Listing -- 977 of 1012

Apple Lisa Computer Technical Information


001340
001341
001342
001343
001344
001345
001346
001347
001348
001349
001350
001351
001352
001353
001354
001355
001356
001357
001358
001359
001360
001361
001362
001363
001364
001365
001366
001367
001368
001369
001370
001371
001372
001373
001374
001375
001376
001377
001378
001379
001380
001381
001382
001383
001384
001385
001386
001387

END;
IF howMany = 0 THEN
{ We are done, kill all saved stuff }
FOR index := 1 TO nOfSavedPara DO
BEGIN
savedPara[index]^^.theText.Free;
FreeH(HzFromH(TH(savedPara[index])), TH(savedPara[index]));
END
ELSE
BEGIN
IF newPara THEN
{ New text in activeStream.data... }
BEGIN
done := FALSE;
index := nOfSavedPara;
WHILE (NOT done) AND (index > 0) DO
{ Get ridd of old stuff }
WITH savedPara[index]^^ DO
IF (lpd^.lpLim - (firstLp + theText.size) ) >= maxBacking THEN {LSR}
BEGIN
theText.Free;
FreeH(HzFromH(TH(savedPara[index])), TH(savedPara[index]));
index := index - 1;
nOfSavedPara := nOfSavedPara - 1;
END
ELSE
done := true;
{LSR: changed direction of following loop}
FOR index := nOfSavedPara DOWNTO 1 DO
{ Shift everything to free the first one }
savedPara[index + 1] := savedPara[index];
nOfSavedPara := nOfSavedPara + 1;
{ Make a new place to save old paragraphs }
savedPara[1] := POINTER(HAllocate(THz(activeStream.Heap), SIZEOF(TSavedPara)));
WITH savedPara[1]^^, lpd^ DO
BEGIN
firstLp := lp;
theArpe := arpe;
theArce := arce;
theText := activeStream.data;
END;
END;
IF (dataIndex + howMany) >= activeStream.data.Size THEN
BEGIN
{ Make a fresh string, the old one is in savedPara[1] }
{$IFC WithUObject}

{LSR: break up the assignment to activeStream.data to prevent dereferenced handles}

Apple Lisa ToolKit 3.0 Source Code Listing -- 978 of 1012

Apple Lisa Computer Technical Information


001388
001389
001390
001391
001392
001393
001394
001395
001396
001397
001398
001399
001400
001401
001402
001403
001404
001405
001406
001407
001408
001409
001410
001411
001412
001413
001414
001415
001416
001417
001418
001419
001420
001421
001422
001423
001424
001425
001426
001427
001428
001429
001430
001431
001432
001433
001434
001435

{$ELSEC}
{$ENDC}

newData := TString.CREATE(NIL, activeStream.heap, activeStream.maxDataSize);


newData := TUTString.CREATE(NIL, activeStream.heap, activeStream.maxDataSize);

activeStream.data := newData;
activeStream.data.StartEdit(50);
dataLp := lpd^.lpLim;
END;
END;

{Allow holes}
{Make shure backUp will compute to zero}

{$IFC fUniversalTextTrace}
IF fPrintSecrets THEN
BEGIN
PrintSecrets(achad, currentLpd^);
WRITELN('dataLp =
', dataLp:0);
WRITELN('dataIndex =
', dataIndex:0);
WRITELN('nOfSavedPara = ', nOfSavedPara:0);
WRITELN('');
WRITELN;
WRITELN;
END;
{$ENDC}
{$IFC fTrce}EP;{$ENDC}
END;
{$IFC WithUObject}
METHODS OF TTKUnivText
{$ELSEC}
METHODS OF TUnivText
{$ENDC}
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
{$IFC WithUObject}
FUNCTION {TUnivText.}CREATE(object: TObject;
itsHeap: THeap;
itsTString: TString;
itsDataSize: INTEGER)
: TTKUnivText;
{$ELSEC}
FUNCTION {TUnivText.}CREATE(object: TUTObject;
itsHeap: THeap;

Apple Lisa ToolKit 3.0 Source Code Listing -- 979 of 1012

Apple Lisa Computer Technical Information


001436
001437
001438
001439
001440
001441
001442
001443
001444
001445
001446
001447
001448
001449
001450
001451
001452
001453
001454
001455
001456
001457
001458
001459
001460
001461
001462
001463
001464
001465
001466
001467
001468
001469
001470
001471
001472
001473
001474
001475
001476
001477
001478
001479
001480
001481
001482
001483

itsTString: TUTString;
itsDataSize: INTEGER)
: TUnivText;

{$ENDC}
{----------------------------------------------------------------------------------------------------}
{$IFC WithUObject}
VAR thisTabTable:
{$ELSEC}
VAR thisTabTable:
{$ENDC}
thisString:

TArray;
TUTArray;
^Tsp;

BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
IF object = NIL THEN
{$IFC WithUObject}
object := NewObject(itsHeap, THISCLASS);
{$ELSEC}
object := NewUTObject(itsHeap, THISCLASS);
{$ENDC}
{$IFC WithUObject}
SELF := TTKUnivText(object);
{$ELSEC}
SELF := TUnivText(object);
{$ENDC}
{ Get the stream }
SELF.itsOurTString := itsTString = NIL;
IF SELF.itsOurTString THEN
{$IFC WithUObject}
itsTString := TString.CREATE(NIL, itsHeap, itsDataSize);
{$ELSEC}
itsTString := TUTString.CREATE(NIL, itsHeap, itsDataSize);
{$ENDC}
itsTString.StartEdit(50);
SELF.data := itsTString;
SELF.maxDataSize := itsDataSize;

{Allow holes}

{$IFC WithUObject}
thisTabTable := TArray.CREATE(NIL, itsHeap, 0, SIZEOF(TTabDescriptor));
{$ELSEC}
thisTabTable := TUTArray.CREATE(NIL, itsHeap, 0, SIZEOF(TTabDescriptor));
{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 980 of 1012

Apple Lisa Computer Technical Information


001484
001485
001486
001487
001488
001489
001490
001491
001492
001493
001494
001495
001496
001497
001498
001499
001500
001501
001502
001503
001504
001505
001506
001507
001508
001509
001510
001511
001512
001513
001514
001515
001516
001517
001518
001519
001520
001521
001522
001523
001524
001525
001526
001527
001528
001529
001530
001531

thisTabTable.StartEdit(5);
SELF.paragraphDescriptor.tabTable := thisTabTable;
{$IFC fTrce}EP;{$ENDC}
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TUnivText.}Free;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
{If the dynamic array was not passed in then free it}
IF SELF.itsOurTString THEN
SELF.data.Free;
SELF.paragraphDescriptor.tabTable.Free;
SUPERSELF.Free;
{$IFC fTrce}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TUnivText.}Fields(PROCEDURE Field(nameAndType: S255));
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
SUPERSELF.Fields(Field);
Field('paraGraphStart: BOOLEAN');
{$IFC WithUObject}
Field('additionalChrInParagraph: INTEGER');
{$ENDC}
Field('firstLineMargin: INTEGER');
Field('bodyMargin: INTEGER');
Field('rightMargin: INTEGER');
Field('paraLeading: INTEGER');
Field('lineSpacing: BYTE');
{$IFC WithUObject}

Apple Lisa ToolKit 3.0 Source Code Listing -- 981 of 1012

Apple Lisa Computer Technical Information


001532
001533
001534
001535
001536
001537
001538
001539
001540
001541
001542
001543
001544
001545
001546
001547
001548
001549
001550
001551
001552
001553
001554
001555
001556
001557
001558
001559
001560
001561
001562
001563
001564
001565
001566
001567
001568
001569
001570
001571
001572
001573
001574
001575
001576
001577
001578
001579

Field('tabTable: TArray');
{$ELSEC}
Field('tabTable: TUTArray');
{$ENDC}
Field('paraType: BYTE');
Field('hasPicture: BOOLEAN');
Field('font: INTEGER');
Field('face: BYTE');
Field('superscript: BYTE');
Field('keepOnSamePage: BOOLEAN');
Field('maxDataSize: INTEGER');
{$IFC WithUObject}
Field('data: TString');
{$ELSEC}
Field('data: TUTString');
{$ENDC}
Field('itsOurTString: BOOLEAN');
Field('');
END;
{$ENDC}
{$IFC WithUObject}
{$S TKUTWrite}
{$ELSEC}
{$S UTWrite}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TUnivText.}RunToStream;
{----------------------------------------------------------------------------------------------------}
VAR i:
INTEGER;
found:
BOOLEAN;
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
IF currentLpd^.tyset.fRce THEN
{ Convert the character descriptor }
WITH SELF.characterDescriptor, currentLpd^.rce^ DO
BEGIN
{ Set the face fields }
fbold
:= bold IN face;
fitalic
:= italic IN face;
funderline := underline IN face;
foutline
:= outline IN face;
fshadow
:= shadow IN face;

Apple Lisa ToolKit 3.0 Source Code Listing -- 982 of 1012

Apple Lisa Computer Technical Information


001580
001581
001582
001583
001584
001585
001586
001587
001588
001589
001590
001591
001592
001593
001594
001595
001596
001597
001598
001599
001600
001601
001602
001603
001604
001605
001606
001607
001608
001609
001610
001611
001612
001613
001614
001615
001616
001617
001618
001619
001620
001621
001622
001623
001624
001625
001626
001627

fvan := FALSE;

{No vanished runs}

{ Because of the way lotus does fonts we have to convert the a real font to a lotus font }
found := FALSE;
i := 0;
WHILE (i <= ifntlst) AND NOT(found) DO
BEGIN
IF argfam[i] = font THEN
BEGIN
ifnt := i;
found := TRUE;
END;
i := i + 1;
END;
IF NOT found THEN ifnt := 0;
cbSuperscript := superscript;
fKeep := keepOnSamePage;
END; { with }
{ Convert the paragraph descriptor }
WITH SELF.ParagraphDescriptor, currentLpd^, rpe^ DO
BEGIN
fParSt := paraGraphStart;
IF paraGraphStart THEN
BEGIN
{LSR: added lpLim to the right side of each of the following assignments}
lpFstPar := lpLim;
{$IFC WithUObject}
lpLimPar := lpLim + SELF.data.Size + additionalChrInParagraph;
{$ELSEC}
lpLimPar := lpLim + SELF.data.Size;
{$ENDC}
END;
IF tyset.fRpe THEN
BEGIN
xLftFst := firstLineMargin;
xLftBody := bodyMargin;
xRt := rightMargin;
yLd := paraLeading;
yLine := lineSpacing;
CASE paraType OF
qLeftPara:
qCenterPara:
qRightPara:

quad := quadL;
quad := quadC;
quad := quadR;

Apple Lisa ToolKit 3.0 Source Code Listing -- 983 of 1012

Apple Lisa Computer Technical Information


001628
001629
001630
001631
001632
001633
001634
001635
001636
001637
001638
001639
001640
001641
001642
001643
001644
001645
001646
001647
001648
001649
001650
001651
001652
001653
001654
001655
001656
001657
001658
001659
001660
001661
001662
001663
001664
001665
001666
001667
001668
001669
001670
001671
001672
001673
001674
001675

qJustPara:
OTHERWISE
END;{CASE}

quad := quadJ;
quad := quadL;

itbLim := tabTable.Size - 1;
{$H-} SELF.TabTableToArgTbd; {$H+}
END;
END;

{ This invalidates WITH statement!! }

{$IFC fTrce}EP;{$ENDC}
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TUnivText.}StreamToRun;
{----------------------------------------------------------------------------------------------------}
VAR ifnt:
INTEGER;
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
{ do the format stuff }
IF secrets.lpd.tyset.frce THEN
WITH SELF.characterDescriptor, secrets.lpd.rce^ DO
BEGIN
font := argfam[ifnt];
face := [];
IF fbold THEN
face := face + [bold];
IF fitalic THEN
face := face + [italic];
IF funderline THEN
face := face + [underline];
IF foutline THEN
face := face + [outline];
IF fshadow THEN
face := face + [shadow];
superscript := cbSuperscript;
keepOnSamePage := fKeep;
END;
IF secrets.lpd.tyset.frpe THEN
BEGIN
WITH SELF.paragraphDescriptor, secrets.lpd.rpe^ DO

Apple Lisa ToolKit 3.0 Source Code Listing -- 984 of 1012

Apple Lisa Computer Technical Information


001676
001677
001678
001679
001680
001681
001682
001683
001684
001685
001686
001687
001688
001689
001690
001691
001692
001693
001694
001695
001696
001697
001698
001699
001700
001701
001702
001703
001704
001705
001706
001707
001708
001709
001710
001711
001712
001713
001714
001715
001716
001717
001718
001719
001720
001721
001722
001723

BEGIN
paraGraphStart := secrets.lpd.fParSt;
firstLineMargin := xLftFst;
bodyMargin := xLftBody;
rightMargin := xRt;
paraLeading := yLd;
lineSpacing := yLine;
hasPicture := FALSE; {not yet implemented}
CASE quad OF
quadL:
quadC:
quadR:
quadJ:
OTHERWISE
END;{CASE}

paraType
paraType
paraType
paraType
paraType

IF itbLim < 0 THEN


itbLim := -1;
END;

:=
:=
:=
:=
:=

qLeftPara;
qCenterPara;
qRightPara;
qJustPara;
qLeftPara;
{ Resize the tab table and move the data }

SELF.ArgTbdToTabTable;
END;
{$IFC fTrce}EP;{$ENDC}
END;
{$IFC WithUObject}
{$S TKUTWrite}
{$ELSEC}
{$S UTWrite}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TUnivText.}TabTableToArgTbd;
{----------------------------------------------------------------------------------------------------}
VAR i:
INTEGER;
temp:
INTEGER;
ptrToTab:
Ptr;
tab:
TTabDescriptor;
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
temp := MIN(SELF.paragraphDescriptor.tabTable.size, magicTabMax);
FOR i:= 1 to temp DO
BEGIN
tab := TTabDescriptor(SELF.paragraphDescriptor.tabTable.At(i));
{R$-}

Apple Lisa ToolKit 3.0 Source Code Listing -- 985 of 1012

Apple Lisa Computer Technical Information


001724
001725
001726
001727
001728
001729
001730
001731
001732
001733
001734
001735
001736
001737
001738
001739
001740
001741
001742
001743
001744
001745
001746
001747
001748
001749
001750
001751
001752
001753
001754
001755
001756
001757
001758
001759
001760
001761
001762
001763
001764
001765
001766
001767
001768
001769
001770
001771

WITH tab, currentLpd^.rpe^.argTbd[i-1] DO


BEGIN
x := position;
CASE tabType OF
qLeftTab:
quad := quadL;
qCenterTab:
quad := quadC;
qRightTab:
quad := quadR;
qPeriodTab:
BEGIN
quad := quadJ;
fDecimalComma := FALSE;
END;
qCommaTab:
BEGIN
quad := quadJ;
fDecimalComma := TRUE;
END;
OTHERWISE
quad := quadL;
END;{CASE}
CASE fillBetweenTabs OF
tNoFill:
BEGIN
tyFill := tyFillNil;
chLdr := ORD(' ');
END;
tDotFill:
BEGIN
tyFill := tyFillDots;
chLdr := ORD('.');
END;
tHyphenFill:
BEGIN
tyFill := tyFillHyph;
chLdr := ORD('-');
END;
tUnderLineFill:
BEGIN
tyFill := tyFillUL;
chLdr := ORD('_');
END;
OTHERWISE
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 986 of 1012

Apple Lisa Computer Technical Information


001772
001773
001774
001775
001776
001777
001778
001779
001780
001781
001782
001783
001784
001785
001786
001787
001788
001789
001790
001791
001792
001793
001794
001795
001796
001797
001798
001799
001800
001801
001802
001803
001804
001805
001806
001807
001808
001809
001810
001811
001812
001813
001814
001815
001816
001817
001818
001819

tyFill := tyFillNil;
chLdr := ORD(' ');
END;
END;{CASE}
END;
{$R+}
END;
currentLpd^.rpe^.itbLim := temp - 1;
{$IFC fTrce}EP;{$ENDC}
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TUnivText.}ArgTbdToTabTable;
{----------------------------------------------------------------------------------------------------}
VAR i:
INTEGER;
tab:
TTabDescriptor;
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
{ Size down the tab array for writing }
SELF.paragraphDescriptor.tabTable.DelAll;
FOR i := 0 to secrets.lpd.rpe^.itbLim - 1 DO
BEGIN
{$R-}
WITH tab, secrets.lpd.rpe^.argTbd[i] DO
BEGIN
position := x;
CASE quad OF
quadL:
quadC:
quadR:
quadJ:

OTHERWISE
END;{CASE}

tabType := qLeftTab;
tabType := qCenterTab;
tabType := qRightTab;
IF fDecimalComma THEN
tabType := qCommaTab
ELSE
tabType := qPeriodTab;
tabType := qLeftTab;

CASE tyFill OF

Apple Lisa ToolKit 3.0 Source Code Listing -- 987 of 1012

Apple Lisa Computer Technical Information


001820
001821
001822
001823
001824
001825
001826
001827
001828
001829
001830
001831
001832
001833
001834
001835
001836
001837
001838
001839
001840
001841
001842
001843
001844
001845
001846
001847
001848
001849
001850
001851
001852
001853
001854
001855
001856
001857
001858
001859
001860
001861
001862
001863
001864
001865
001866
001867

tyFillNil:
tyFillDots:
tyFillHyph:
tyFillUL:
OTHERWISE
END;{CASE}

fillBetweentabs
fillBetweentabs
fillBetweentabs
fillBetweentabs
fillBetweentabs

:=
:=
:=
:=
:=

tNoFill;
tDotFill;
tHyphenFill;
tUnderLineFill;
tNoFill;

{$IFC fUniversalTextTrace}
IF fPrintSecrets THEN
BEGIN
WRITELN('Tab #', i + 1:0, ', tabType =', ORD(tabType):0, ', quad =', ORD(quad):0);
END;
{$ENDC}
END;
{$R+}
SELF.paragraphDescriptor.tabTable.InsLast(@tab);
END;
{$IFC fTrce}EP;{$ENDC}
END;
{$IFC WithUObject}
{$S TKUTInit}
{$ELSEC}
{$S UTInit}
{$ENDC}
BEGIN
{$IFC fTraceUT}
LogCall;
{$IFC fUniversalTextTrace}
fPrintSecrets := FALSE;
{$ENDC}
END;

{$ENDC}

{$IFC WithUObject}
METHODS OF TTKReadUnivText
{$ELSEC}
METHODS OF TReadUnivText
{$ENDC}
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
{$IFC WithUObject}
FUNCTION {TReadUnivText.}CREATE(object: TObject;
itsHeap: THeap;

Apple Lisa ToolKit 3.0 Source Code Listing -- 988 of 1012

Apple Lisa Computer Technical Information


001868
001869
001870
001871
001872
001873
001874
001875
001876
001877
001878
001879
001880
001881
001882
001883
001884
001885
001886
001887
001888
001889
001890
001891
001892
001893
001894
001895
001896
001897
001898
001899
001900
001901
001902
001903
001904
001905
001906
001907
001908
001909
001910
001911
001912
001913
001914
001915

{$ELSEC}
FUNCTION

itsTString: TString;
itsDataSize: INTEGER;
LevelOfGranularity: TLevelOfGranularity)
: TTKReadUnivText;
{TReadUnivText.}CREATE(object: TUTObject;
itsHeap: THeap;
itsTString: TUTString;
itsDataSize: INTEGER;
LevelOfGranularity: TLevelOfGranularity)
: TReadUnivText;

{$ENDC}
{----------------------------------------------------------------------------------------------------}
VAR index:
TB;
{$IFC WithUObject}
thisList:
TString;
{$ELSEC}
thisList:
TUTString;
{$ENDC}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
{ Establish the level of granularity for reading }
WITH secrets.lpd.tyset DO
BEGIN
frce := UTCharacters IN LevelOfGranularity;
frpe := UTparagraphs IN LevelOfGranularity;
fParBnds := FALSE;
END;
GetCSScrap(index);
IF index = 0 THEN
SELF := NIL
ELSE
BEGIN
secrets.streamArrayIndex := index;
IF object = NIL THEN
{$IFC WithUObject}
object := NewObject(itsHeap, THISCLASS);
{$ELSEC}
object := NewUTObject(itsHeap, THISCLASS);
{$ENDC}
{$IFC WithUObject}
SELF := TTKReadUnivText(TTKUnivText.CREATE(object, itsHeap, itsTString, itsDataSize));
{$ELSEC}
SELF := TReadUnivText(TUnivText.CREATE(object, itsHeap, itsTString, itsDataSize));

Apple Lisa ToolKit 3.0 Source Code Listing -- 989 of 1012

Apple Lisa Computer Technical Information


001916
001917
001918
001919
001920
001921
001922
001923
001924
001925
001926
001927
001928
001929
001930
001931
001932
001933
001934
001935
001936
001937
001938
001939
001940
001941
001942
001943
001944
001945
001946
001947
001948
001949
001950
001951
001952
001953
001954
001955
001956
001957
001958
001959
001960
001961
001962
001963

{$ENDC}
{$IFC WithUObject}
thisList := TString.CREATE(NIL, itsHeap, itsDataSize);
{$ELSEC}
thisList := TUTString.CREATE(NIL, itsHeap, itsDataSize);
{$ENDC}
thisList.StartEdit(50);
{Allow holes}
SELF.buffer := thisList;
SELF.dataBeforeTab := TRUE;
SELF.Restart;
{ Set up for reading from the beginning}
END;
{$IFC fTrce}EP;{$ENDC}
END;
{$IFC fDebugMethods}
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TReadUnivText.}Fields(PROCEDURE Field(nameAndType: S255));
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
SUPERSELF.Fields(Field);
{$IFC WithUObject}
Field('buffer: TString');
{$ELSEC}
Field('buffer: TUTString');
{$ENDC}
Field('');
END;
{$ENDC}
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TReadUnivText.}Free;
{----------------------------------------------------------------------------------------------------}
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 990 of 1012

Apple Lisa Computer Technical Information


001964
001965
001966
001967
001968
001969
001970
001971
001972
001973
001974
001975
001976
001977
001978
001979
001980
001981
001982
001983
001984
001985
001986
001987
001988
001989
001990
001991
001992
001993
001994
001995
001996
001997
001998
001999
002000
002001
002002
002003
002004
002005
002006
002007
002008
002009
002010
002011

{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
SELF.buffer.Free;
SUPERSELF.Free;
{$IFC fTrce}EP;{$ENDC}
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TReadUnivText.}Restart;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
{ Set up the Achad for reading from the beginning}
WITH secrets.achad DO
BEGIN
ichFst := 0;
ichLim := SELF.data.size;
END;
secrets.lpd.lpLim := 0;
SELF.columnCount := 0;
{$IFC fTrce}EP;{$ENDC}
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TReadUnivText.}ScanTable(VAR rows, tabColumns, tabStopColumns: INTEGER);
{----------------------------------------------------------------------------------------------------}
VAR
fieldOverflow:
BOOLEAN;
fieldTerminator:
CHAR;
lastTerminator:
CHAR;
tabType:
TTabTypes;
columnsInThisRow:
INTEGER;
dataBeforeTab:
BOOLEAN;

Apple Lisa ToolKit 3.0 Source Code Listing -- 991 of 1012

Apple Lisa Computer Technical Information


002012
002013
002014
002015
002016
002017
002018
002019
002020
002021
002022
002023
002024
002025
002026
002027
002028
002029
002030
002031
002032
002033
002034
002035
002036
002037
002038
002039
002040
002041
002042
002043
002044
002045
002046
002047
002048
002049
002050
002051
002052
002053
002054
002055
002056
002057
002058
002059

BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
rows := 0;
tabColumns := 1;
tabStopColumns := 0;
columnsInThisRow := 1;
{There is at least one column}
SELF.dataBeforeTab := TRUE;
{Make shure ReadField doesn't skip any fields}
dataBeforeTab := FALSE;
SELF.Restart;
WHILE SELF.ReadField(1, fieldOverflow, fieldTerminator, tabType) DO
BEGIN
IF columnsInThisRow = 1 THEN
BEGIN
IF SELF.data.size > 0 THEN
dataBeforeTab := TRUE;
IF tabStopColumns < SELF.paragraphDescriptor.tabTable.size THEN
tabStopColumns := SELF.paragraphDescriptor.tabTable.size;
END;
lastTerminatior := fieldTerminator;
IF fieldTerminator = CHR(chCr) THEN
BEGIN
rows := rows + 1;
columnsInThisRow := 1;
{Check the tab table here}
END
ELSE
IF fieldTerminator = CHR(chTab) THEN
BEGIN
columnsInThisRow := columnsInThisRow + 1;
IF columnsInThisRow > tabColumns THEN
tabColumns := columnsInThisRow;
END;
END;
SELF.Restart;
IF (NOT dataBeforeTab) AND (tabColumn > 0) THEN
tabColumns := tabColumns - 1;
SELF.dataBeforeTab := dataBeforeTab;
IF lastTerminatior <> CHR(chCr) THEN
rows := rows + 1;
{$IFC fUniversalTextTrace}
IF fPrintSecrets THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 992 of 1012

Apple Lisa Computer Technical Information


002060
002061
002062
002063
002064
002065
002066
002067
002068
002069
002070
002071
002072
002073
002074
002075
002076
002077
002078
002079
002080
002081
002082
002083
002084
002085
002086
002087
002088
002089
002090
002091
002092
002093
002094
002095
002096
002097
002098
002099
002100
002101
002102
002103
002104
002105
002106
002107

WRITELN('ScanTable:');
WRITELN('
dataBeforeTab:
WRITELN('
tabColumns:
WRITELN('
tabStopColumns:
WRITELN('
rows:
END;
{$ENDC}

',
',
',
',

dataBeforeTab);
tabColumns);
tabStopColumns);
rows);

END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
FUNCTION {TReadUnivText.}ReadField(
maxFieldSize: INTEGER;
VAR fieldOverflow: BOOLEAN;
VAR fieldTerminator: CHAR;
VAR tabType: TTabTypes)
: BOOLEAN;
{----------------------------------------------------------------------------------------------------}
{$IFC WithUObject}
VAR data:
TString;
buffer:
TString;
{$ELSEC}
VAR data:
TUTString;
buffer:
TUTString;
{$ENDC}
i:
INTEGER;
terminatorFound:
BOOLEAN;
result:
BOOLEAN;
oldSize:
INTEGER;
newSize:
INTEGER;
columnNr:
INTEGER;
tab:
TTabDescriptor;
ch:
CHAR;
PROCEDURE ReadBuffer;
BEGIN
SELF.data := buffer;
SELF.ReadRun;
SELF.data := data;
END;
BEGIN
{$IFC fTraceUT}

LogCall;

{$ENDC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 993 of 1012

Apple Lisa Computer Technical Information


002108
002109
002110
002111
002112
002113
002114
002115
002116
002117
002118
002119
002120
002121
002122
002123
002124
002125
002126
002127
002128
002129
002130
002131
002132
002133
002134
002135
002136
002137
002138
002139
002140
002141
002142
002143
002144
002145
002146
002147
002148
002149
002150
002151
002152
002153
002154
002155

{$IFC fTrce}BP(11);{$ENDC}
REPEAT
buffer := SELF.buffer;
data := SELF.data;
IF buffer.Size = 0 THEN
ReadBuffer;

{ If there is no data then get some }

fieldTerminator := CHR(0);
fieldOverflow := FALSE;
data.DelAll;
terminatorFound := FALSE;
IF buffer.Size > 0 THEN
BEGIN

{ If there is still text to paste }

tabType := qLeftTab;
{ Default tab type }
IF SELF.columnCount > 0 THEN
IF SELF.paragraphDescriptor.tabTable.size >= SELF.columnCount THEN
tabType := TTabDescriptor(
SELF.paragraphDescriptor.tabTable.At(SELF.columnCount)
).tabType;
SELF.columnCount := SELF.columnCount + 1;
columnNr := SELF.columnCount;
result := TRUE;
REPEAT
i := 0;
WHILE (i < buffer.Size) AND (NOT terminatorFound) DO
BEGIN
i := i + 1;
ch := buffer.At(i);
IF (ch = CHR(chTab)) OR (ch = CHR(chCr)) THEN
BEGIN
terminatorFound := TRUE;
fieldTerminator := ch;
IF fieldTerminator = CHR(chCr) THEN
SELF.columnCount := 0;
END;
END;
oldSize := data.Size;
newSize := oldSize + i;
IF terminatorFound THEN
newSize := newSize - 1;

{ Hide the terminating character, if any }

IF newSize > maxFieldSize THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 994 of 1012

Apple Lisa Computer Technical Information


002156
002157
002158
002159
002160
002161
002162
002163
002164
002165
002166
002167
002168
002169
002170
002171
002172
002173
002174
002175
002176
002177
002178
002179
002180
002181
002182
002183
002184
002185
002186
002187
002188
002189
002190
002191
002192
002193
002194
002195
002196
002197
002198
002199
002200
002201
002202
002203

BEGIN
newSize := maxFieldSize;
fieldOverflow := TRUE;
END;
IF newSize > oldSize THEN
data.InsManyAt(1 + data.size, buffer, 1, newSize - oldSize);
buffer.DelManyAt(1, i);
IF (NOT terminatorFound) AND (buffer.Size = 0) THEN
ReadBuffer;
UNTIL terminatorFound OR (buffer.Size = 0);
{$IFC fUniversalTextTrace}
IF fPrintSecrets THEN
BEGIN
WRITELN('Buffer size is ',buffer.Size:1, ' data size is ',data.size:1);
FOR i := 1 to data.size DO
WRITE(data.At(i));
IF fieldTerminator = CHR(chTab) THEN
WRITE('<Tab>')
ELSE
IF fieldTerminator = CHR(chCr) THEN
WRITE('<Cr>')
ELSE
WRITE('<End of paste>');
WRITELN;
WRITELN('FieldOverflow is ', fieldOverflow);
END;
{$ENDC}
END
ELSE
result := FALSE;
UNTIL (NOT result) OR (columnNr > 1) OR SELF.dataBeforeTab;
ReadField := result;
{$IFC fTrce}EP;{$ENDC}
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
FUNCTION {TReadUnivText.}ReadLine(
maxLineSize: INTEGER;

Apple Lisa ToolKit 3.0 Source Code Listing -- 995 of 1012

Apple Lisa Computer Technical Information


002204
002205
002206
002207
002208
002209
002210
002211
002212
002213
002214
002215
002216
002217
002218
002219
002220
002221
002222
002223
002224
002225
002226
002227
002228
002229
002230
002231
002232
002233
002234
002235
002236
002237
002238
002239
002240
002241
002242
002243
002244
002245
002246
002247
002248
002249
002250
002251

VAR lineOverflow: BOOLEAN;


VAR lineTerminator: CHAR)
: BOOLEAN;
{----------------------------------------------------------------------------------------------------}
{$IFC WithUObject}
VAR data:
TString;
buffer:
TString;
{$ELSEC}
VAR data:
TUTString;
buffer:
TUTString;
{$ENDC}
i:
INTEGER;
terminatorFound:
BOOLEAN;
oldSize:
INTEGER;
newSize:
INTEGER;
ch:
CHAR;
PROCEDURE ReadBuffer;
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
SELF.data := buffer;
SELF.ReadRun;
SELF.data := data;
END;
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
buffer := SELF.buffer;
data := SELF.data;
IF buffer.Size = 0 THEN
ReadBuffer;

{ If there is no data then get some }

lineTerminator := CHR(0);
lineOverflow := FALSE;
data.DelAll;
terminatorFound := FALSE;
IF buffer.Size > 0 THEN
{ If there is still text to paste }
BEGIN
ReadLine := TRUE;
REPEAT
i := 0;
WHILE (i < buffer.size) AND (NOT terminatorFound) DO
BEGIN
i := i + 1;
ch := buffer.At(i);

Apple Lisa ToolKit 3.0 Source Code Listing -- 996 of 1012

Apple Lisa Computer Technical Information


002252
002253
002254
002255
002256
002257
002258
002259
002260
002261
002262
002263
002264
002265
002266
002267
002268
002269
002270
002271
002272
002273
002274
002275
002276
002277
002278
002279
002280
002281
002282
002283
002284
002285
002286
002287
002288
002289
002290
002291
002292
002293
002294
002295
002296
002297
002298
002299

IF ch = CHR(chCr) THEN
BEGIN
terminatorFound := TRUE;
lineTerminator := ch;
END;
END;
oldSize := data.Size;
newSize := oldSize + i;
IF terminatorFound THEN
newSize := newSize - 1;

{ Hide the terminating character, if any }

IF newSize > maxLineSize THEN


BEGIN
newSize := maxLineSize;
lineOverflow := TRUE;
END;
IF newSize > oldSize THEN
data.InsManyAt(1 + data.size, buffer, 1, newSize - oldSize);
buffer.DelManyAt(1, i);
IF (NOT terminatorFound) AND (buffer.Size = 0) THEN
ReadBuffer;
UNTIL terminatorFound OR (buffer.Size = 0);
{$IFC fUniversalTextTrace}
IF fPrintSecrets THEN
BEGIN
WRITELN('Buffer size is ',buffer.Size:1, ' data size is ',data.size:1);
FOR i := 1 to data.size DO
WRITE(data.At(i));
IF lineTerminator = CHR(chCr) THEN
WRITE('<Cr>')
ELSE
WRITE('<End of paste>');
WRITELN;
WRITELN('LineOverflow is ', lineOverflow);
END;
{$ENDC}
END
ELSE
ReadLine := FALSE;
{$IFC fTrce}EP;{$ENDC}
END;

Apple Lisa ToolKit 3.0 Source Code Listing -- 997 of 1012

Apple Lisa Computer Technical Information


002300
002301
002302
002303
002304
002305
002306
002307
002308
002309
002310
002311
002312
002313
002314
002315
002316
002317
002318
002319
002320
002321
002322
002323
002324
002325
002326
002327
002328
002329
002330
002331
002332
002333
002334
002335
002336
002337
002338
002339
002340
002341
002342
002343
002344
002345
002346
002347

{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TReadUnivText.}ReadRun;
{----------------------------------------------------------------------------------------------------}
VAR error: INTEGER;
size:
LONGINT;
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
BindUTDSeg(error);
{ Size up the tab and data arrays to take the next run }
SELF.data.DelAll;
SELF.data.EditAt(1, SELF.maxDataSize);
{ Set the achad to receive the next run }
WITH secrets.achad DO
BEGIN
rgch := POINTER(SELF.data.AddrMember(1));
ichFst := 0;
ichLim := SELF.maxDataSize;
END;
WITH secrets DO
REPEAT
{ Get the next run }
IF lpd.lplim = 0 THEN
SetLpd(@Lpd, streamArrayIndex, 0, lpd.Tyset, achad)
ELSE
Seqlpd(@lpd, achad);
UNTIL (NOT lpd.rce^.fvan) OR (achad.ichFst = achad.ichLim);
{$IFC fUniversalTextTrace}
IF fPrintSecrets THEN
PrintSecrets(secrets.achad, secrets.lpd);
{$ENDC}
{ Convert to Run }
SELF.StreamToRun;
WITH secrets.lpd DO
BEGIN
IF tyset.fRpe THEN

Apple Lisa ToolKit 3.0 Source Code Listing -- 998 of 1012

Apple Lisa Computer Technical Information


002348
002349
002350
002351
002352
002353
002354
002355
002356
002357
002358
002359
002360
002361
002362
002363
002364
002365
002366
002367
002368
002369
002370
002371
002372
002373
002374
002375
002376
002377
002378
002379
002380
002381
002382
002383
002384
002385
002386
002387
002388
002389
002390
002391
002392
002393
002394
002395

size := lpLimPar - lp {LSR: changed lpFstPar to lp}


ELSE
size := lpLim - lp;
IF size > (lpLim-lp) THEN
size := lpLim - lp;
lpLim := lp + size;
END;
IF size < SELF.data.size THEN
SELF.data.DelManyAt(size + 1, SELF.data.size - size);
UnBindUTDSeg(error);
{$IFC fTrce}EP;{$ENDC}
END;
{$IFC WithUObject}
{$S TKUTMain}
{$ELSEC}
{$S UTMain}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
FUNCTION {TReadUnivText.}GetParaPicture(heap: THeap) : PicHandle;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
GetParaPicture := NIL;
{$IFC fTrce}EP;{$ENDC}
END;
{$IFC WithUObject}
{$S TKUTInit}
{$ELSEC}
{$S UTInit}
{$ENDC}
END;
{$IFC WithUObject}
METHODS OF TTKWriteUnivText
{$ELSEC}
METHODS OF TWriteUnivText
{$ENDC}
{$IFC WithUObject}
{$S TKUTWrite}

Apple Lisa ToolKit 3.0 Source Code Listing -- 999 of 1012

Apple Lisa Computer Technical Information


002396
002397
002398
002399
002400
002401
002402
002403
002404
002405
002406
002407
002408
002409
002410
002411
002412
002413
002414
002415
002416
002417
002418
002419
002420
002421
002422
002423
002424
002425
002426
002427
002428
002429
002430
002431
002432
002433
002434
002435
002436
002437
002438
002439
002440
002441
002442
002443

{$ELSEC}
{$S UTWrite}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
{$IFC WithUObject}
FUNCTION {TWriteUnivText.}CREATE(object: TObject;
itsHeap: THeap;
itsTString: TString;
itsDataSize: INTEGER)
: TTKWriteUnivText;
{$ELSEC}
FUNCTION {TWriteUnivText.}CREATE(object: TUTObject;
itsHeap: THeap;
itsTString: TUTString;
itsDataSize: INTEGER)
: TWriteUnivText;
{$ENDC}
{----------------------------------------------------------------------------------------------------}
VAR
ptrToolKitUT:
TPtrToolKitUT;
error:
INTEGER;
index:
TB;
{$IFC PasteTrace}
dbgCh:
CHAR;
{$ENDC}
BEGIN
{$IFC PasteTrace}
WRITE('Do you want to debug (Y/N): ');
READ(dbgCh);
fPrintSecrets := dbgCh IN ['Y', 'y'];
{$ENDC}
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
BindUTDseg(error);
IF error <> 0 THEN
ABCBreak('BindUTDseg Error',error);
index := IcsCreate(tycsFld, SIZEOF(ToolKitUT), POINTER(ORD(itsHeap)));
{$R-}
ptrToolKitUT := POINTER( rghcs^[index]^ );
{$R+}
WITH secrets DO
BEGIN
streamArrayIndex := index;
lpd.tyset.fRpe := TRUE;

Apple Lisa ToolKit 3.0 Source Code Listing -- 1000 of 1012

Apple Lisa Computer Technical Information


002444
002445
002446
002447
002448
002449
002450
002451
002452
002453
002454
002455
002456
002457
002458
002459
002460
002461
002462
002463
002464
002465
002466
002467
002468
002469
002470
002471
002472
002473
002474
002475
002476
002477
002478
002479
002480
002481
002482
002483
002484
002485
002486
002487
002488
002489
002490
002491

lpd.tyset.fRce := TRUE;
END;
WITH ptrToolKitUT^ DO
BEGIN
cspd.argproc[IProcSeqLpd] := @SeqLpdUTBB;
cspd.argproc[IProcFreeIcs] := Pointer(procnil);
cspd.argproc[IProcPxHcs] := Pointer(procnil);
cspd.argproc[IProcFindLpFixed] := @FindLpFstPar;
cspd.argproc[IProcFSelLpBounds] := @TrueStdSelLpBounds;
END;
secrets.streamArrayIndex := index;
nOfSavedPara := 0;
dataLp := 0;

{Nothing in the backLogBuffer}


{Starting lpd}

IF object = NIL THEN


{$IFC WithUObject}
object := NewObject(itsHeap, THISCLASS);
{$ELSEC}
object := NewUTObject(itsHeap, THISCLASS);
{$ENDC}
{$IFC WithUObject}
SELF := TTKWriteUnivText(TTKUnivText.CREATE(object, itsHeap, itsTString, itsDataSize));
{$ELSEC}
SELF := TWriteUnivText(TUnivText.CREATE(object, itsHeap, itsTString, itsDataSize));
{$ENDC}
{ Get a default UT character and paragraph descriptors }
WITH secrets DO
BEGIN
lpd.rpe := @lpd.arpe;
{$H-} moveRgch(@lpd.arpe, @arpeStd, arpeStd.cb); {$H+}
Lpd.rce := @lpd.arce;
{$H-} moveRgch(pointer(ord(lpd.rce)), @arceStd, arceStd.cb); {$H+}
END;
SELF.StreamToRun;
activeStream := SELF;
SELF.data.DelAll;
StartGetScrap(error);
IF error <> 0 THEN
ABCBreak('StartGetScrap Error',error);

Apple Lisa ToolKit 3.0 Source Code Listing -- 1001 of 1012

Apple Lisa Computer Technical Information


002492
002493
002494
002495
002496
002497
002498
002499
002500
002501
002502
002503
002504
002505
002506
002507
002508
002509
002510
002511
002512
002513
002514
002515
002516
002517
002518
002519
002520
002521
002522
002523
002524
002525
002526
002527
002528
002529
002530
002531
002532
002533
002534

PutCsScrap(index, error);
IF error <> 0 THEN
ABCBreak('PutCsScrap Error',error);
freeics(index);
EndGetScrap(error);
IF error <> 0 THEN
ABCBreak('EndGetScrap Error',error);
UnbindUTDseg(error);
IF error <> 0 THEN
ABCBreak('UnbindUTDseg Error',error);
{$IFC fTrce}EP;{$ENDC}
END;
{$IFC WithUObject}
{$S TKUTWrite}
{$ELSEC}
{$S UTWrite}
{$ENDC}
{----------------------------------------------------------------------------------------------------}
PROCEDURE {TWriteUnivText.}FillParagraph;
{----------------------------------------------------------------------------------------------------}
BEGIN
{$IFC fTraceUT}
LogCall;
{$ENDC}
{$IFC fTrce}BP(11);{$ENDC}
{$IFC WithUObject}
ABCBreak('Failed to reimplement TTKWriteUnivText.FillParagraph',0);
{$ELSEC}
ABCBreak('Failed to reimplement TWriteUnivText.FillParagraph',0);
{$ENDC}
{$IFC fTrce}EP;{$ENDC}
END;
{$IFC WithUObject}
{$S TKUTInit}
{$ELSEC}
{$S UTInit}
{$ENDC}
END;

End of File -- Lines: 2534 Characters: 79766

Apple Lisa ToolKit 3.0 Source Code Listing -- 1002 of 1012

Apple Lisa Computer Technical Information


================================================================================================
FILE: "UFIXUTEXT.TEXT"
================================================================================================
000001
000002
000003
000004
000005
000006
000007
000008
000009
000010
000011
000012
000013
000014
000015
000016
000017
000018
000019
000020
000021
000022
000023
000024
000025
000026
000027
000028
000029
000030
000031
000032
000033
000034
000035
000036
000037
000038
000039
000040
000041
000042
000043

UNIT UFixUText;
{This unit fixes a bug with UText, where pasting universal text containing a 14 Point or
20 Pitch font would crash with a check range error, accessing the uvFont array. The
only access was made in TInsertionPoint.InsertText. To fix the problem we subclass
TInsertionPoint.InsertText, but install a pointer to the revised method in TInsertionPoint's
method table.}
{$SETC CalcNumbers := FALSE}
{$SETC Debug := FALSE}

{IF TRUE, calculate level/method numbers, else use CONSTs}

INTERFACE
{$E ERRORS}
{$E+}
USES
{$U
{$U
{$U
{$U
{$U
{$U
{$U

LIBPL/UCLASCAL}
UObject}
QuickDraw}
UDraw}
UABC}
UUnivText}
UText}

UClascal,
UObject,
QuickDraw,
UDraw,
UABC,
UTKUniversalText,
UText;

TYPE
TFixInsertionPoint = SUBCLASS OF TInsertionPoint
FUNCTION

TFixInsertionPoint.CREATE: TFixInsertionPoint; ABSTRACT;

PROCEDURE TFixInsertionPoint.InsertText(text: TText; isParaSelection: BOOLEAN;


isWordSelection: BOOLEAN;
universalText: BOOLEAN); OVERRIDE;
END;
IMPLEMENTATION
{$IFC fSymOK AND Debug}
{$D+}
{$ELSEC}

Apple Lisa ToolKit 3.0 Source Code Listing -- 1003 of 1012

Apple Lisa Computer Technical Information


000044
000045
000046
000047
000048
000049
000050
000051
000052
000053
000054
000055
000056
000057
000058
000059
000060
000061
000062
000063
000064
000065
000066
000067
000068
000069
000070
000071
000072
000073
000074
000075
000076
000077
000078
000079
000080
000081
000082
000083
000084
000085
000086
000087
000088
000089
000090
000091

{$D-}
{$ENDC}
{$IFC fDbgOK AND Debug}
{$R+}
{$ELSEC}
{$R-}
{$ENDC}
VAR uvFont:
cFixInsertionPoint:

ARRAY[1..19] OF TFontRecord;
TClass;

{$S FixText1}
{Caller and HackMethodTable must be in the same segment}
{$IFC CalcNumbers}
PROCEDURE Caller;
VAR ip:
TInsertionPoint;
t:
TText;
BEGIN
ip.InsertText(t, TRUE, TRUE, TRUE);
END;
{$ENDC}
PROCEDURE HackMethodTables;
{$IFC CalcNumbers AND DEBUG}
LABEL
1,100;
{$ELSEC}
{$IFC CalcNumbers}
LABEL
100;
{$ENDC}
{$IFC Debug}
LABEL
1;
{$ENDC}
{$ENDC}
{$IFC NOT CalcNumbers}
CONST
levNum
=
methNum
=
{$ENDC}

6;
2;

TYPE
TMethodArray = ARRAY [1..256] OF LONGINT;
TPMethodArray = ^TMethodArray;
TSliceTable = ARRAY [0..255] OF TPMethodArray;
TPSliceTable = ^TSliceTable;

Apple Lisa ToolKit 3.0 Source Code Listing -- 1004 of 1012

Apple Lisa Computer Technical Information


000092
000093
000094
000095
000096
000097
000098
000099
000100
000101
000102
000103
000104
000105
000106
000107
000108
000109
000110
000111
000112
000113
000114
000115
000116
000117
000118
000119
000120
000121
000122
000123
000124
000125
000126
000127
000128
000129
000130
000131
000132
000133
000134
000135
000136
000137
000138
000139

VAR myProc:
LONGINT;
{$IFC CalcNumbers}
pc:
TpInteger;
wd:
INTEGER;
levNum:
INTEGER;
methNum:
INTEGER;
{$ENDC}
pSliceTable:
TpSliceTable;
BEGIN
{$IFC Debug}
1: GOTO 1;
{$ENDC}
{$IFC CalcNumbers}
{Find out the method # & level # for TInsertionPoint.InsertText}
pc := TpInteger(@Caller);
WHILE ORD(pc) <= ORD(@HackMethodTables) DO
BEGIN
wd := pc^;
pc := TpInteger(ORD(pc)+2);
IF wd = $4E95 THEN {JSR (A5)}
BEGIN
wd := pc^;
{get level/method # as an integer}
levNum := wd DIV 256;
{these 2 statements only work for <128 levels}
methNum := wd MOD 256;
{$IFC Debug}
WriteLn(levNum, methNum); {***}
{$ENDC}
GOTO 100;
END;
END;
HALT;
{did not find the method call}
100:
{$ENDC}
pSliceTable := TpSliceTable(cFixInsertionPoint);
myProc := pSliceTable^[levNum]^[methNum];
{The superclass pointers have not been installed yet, so need to use the arrays in UClascal.}
pSliceTable := TpSliceTable(pSTables^[pClasses^[numClasses].superIndex]);
pSliceTable^[levNum]^[methNum] := myProc;
END;
METHODS OF TFixInsertionPoint;
{$S FixText2}

Apple Lisa ToolKit 3.0 Source Code Listing -- 1005 of 1012

Apple Lisa Computer Technical Information


000140
000141
000142
000143
000144
000145
000146
000147
000148
000149
000150
000151
000152
000153
000154
000155
000156
000157
000158
000159
000160
000161
000162
000163
000164
000165
000166
000167
000168
000169
000170
000171
000172
000173
000174
000175
000176
000177
000178
000179
000180
000181
000182
000183
000184
000185
000186
000187

PROCEDURE TFixInsertionPoint.InsertText(text: TText; isParaSelection: BOOLEAN; isWordSelection: BOOLEAN;


universalText: BOOLEAN);
VAR s:
TListScanner;
prevPara:
TEditPara;
newPara:
TEditPara;
aParagraph:
TEditPara;
newLP:
INTEGER;
textImage:
TTextImage;
insertIt:
BOOLEAN;
done:
BOOLEAN;
newParaImage:
TParaImage;
paraIndex:
LONGINT;
delta:
INTEGER;
numParas:
INTEGER;
needSpRight:
BOOLEAN;
{$IFC fUseUnivText}
readUnivText:
TTKReadUnivText;
univPara:
TEditPara;
univFormat:
TParaFormat;
{$ENDC}
PROCEDURE StartPaste;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF universalText THEN
BEGIN
{$IFC fUseUnivText}
univFormat := TParaFormat.CREATE(NIL, SELF.Heap, SELF.textImage.text.styleSheet);
univPara := textImage.NewEditPara(0, prevPara.format);
readUnivText := TTKReadUnivText.CREATE(NIL, SELF.Heap, NIL, 512,
[UTCharacters, UTParagraphs]);
numParas := 0;
{$ENDC}
END
ELSE
BEGIN
numParas := text.paragraphs.size;
s := text.paragraphs.Scanner;
END;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE EndPaste;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
IF universalText THEN
BEGIN
{$IFC fUseUnivText}

Apple Lisa ToolKit 3.0 Source Code Listing -- 1006 of 1012

Apple Lisa Computer Technical Information


000188
000189
000190
000191
000192
000193
000194
000195
000196
000197
000198
000199
000200
000201
000202
000203
000204
000205
000206
000207
000208
000209
000210
000211
000212
000213
000214
000215
000216
000217
000218
000219
000220
000221
000222
000223
000224
000225
000226
000227
000228
000229
000230
000231
000232
000233
000234
000235

univPara.Free;
readUnivText.Free;
{$ENDC}
END;
{$IFC fTrace}EP;{$ENDC}
END;
FUNCTION GetParagraph(VAR paragraph: TEditPara): BOOLEAN;
VAR currPos:
INTEGER;
done:
BOOLEAN;
runSize:
INTEGER;
wasSomeText:
BOOLEAN;
ch:
CHAR;
typeStyle:
TTypeStyle;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
If universalText THEN
BEGIN
{$IFC fUseUnivText}
univPara.ReplPString(0, univPara.Size, NIL);
currPos := 0;
wasSomeText := FALSE;
done := FALSE;
REPEAT
readUnivText.ReadRun;
runSize := readUnivText.data.size;
IF runSize > 0 THEN
BEGIN
IF NOT wasSomeText THEN
BEGIN
WITH univFormat, readUnivText.paragraphDescriptor DO
BEGIN
firstIndent := firstLineMargin;
leftIndent := bodyMargin;
(* Can't use this because it's given as distance from left rather than
indent from right and I don't know what value of right edge of paper is.
rightIndent := rightMargin;
*)
spaceBelowPara := paraLeading;
END;
univPara.format := univFormat;
END;
wasSomeText := TRUE;
ch := readUnivText.data.At(runSize);
IF ORD(ch) = ascReturn THEN
BEGIN
readUnivText.data.DelAt(runSize);
runSize := runSize - 1;

Apple Lisa ToolKit 3.0 Source Code Listing -- 1007 of 1012

Apple Lisa Computer Technical Information


000236
000237
000238
000239
000240
000241
000242
000243
000244
000245
000246
000247
000248
000249
000250
000251
000252
000253
000254
000255
000256
000257
000258
000259
000260
000261
000262
000263
000264
000265
000266
000267
000268
000269
000270
000271
000272
000273
000274
000275
000276
000277
000278
000279
000280
000281
000282
000283

numParas := numParas + 1;
done := TRUE;
END;
univPara.ReplTString(currPos, 0, readUnivText.data, 0, runSize);
typeStyle.onFaces := readUnivText.characterDescriptor.face;
typeStyle.font.fontFamily := uvFont[readUnivText.characterDescriptor.font].fontFamily;
typeStyle.font.fontSize := uvFont[readUnivText.characterDescriptor.font].fontSize;
univPara.NewStyle(currPos, currPos+runSize, typeStyle);
currPos := currPos + runSize;
END
ELSE
BEGIN
IF wasSomeText THEN
numParas := numParas + 1;
done := TRUE;
END;
UNTIL done;
IF wasSomeText THEN
paragraph := univPara
ELSE
paragraph := NIL;
GetParagraph := wasSomeText;
{$ELSEC}
paragraph := NIL;
GetParagraph := FALSE;
{$ENDC}
END
ELSE
GetParagraph := s.Scan(paragraph);
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE InsText;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
delta := 0;
textImage := SELF.textImage;
newLP := SELF.textRange.firstLP;
newPara := SELF.textRange.firstPara;
prevPara := newPara;
insertIt := FALSE;
IF isWordSelection THEN
BEGIN
needSpRight := newPara.Qualifies(newLP);
IF newPara.Qualifies(newLP-1) THEN
BEGIN
newPara.InsertOneChar(' ', newLP);

Apple Lisa ToolKit 3.0 Source Code Listing -- 1008 of 1012

Apple Lisa Computer Technical Information


000284
000285
000286
000287
000288
000289
000290
000291
000292
000293
000294
000295
000296
000297
000298
000299
000300
000301
000302
000303
000304
000305
000306
000307
000308
000309
000310
000311
000312
000313
000314
000315
000316
000317
000318
000319
000320
000321
000322
000323
000324
000325
000326
000327
000328
000329
000330
000331

newLP := newLP + 1;
delta := 1;
END;
END;
(*

*)

{special case: if first paragraph in text is designated a whole paragraph (by isParaSelection) AND
if the insertion point (SELF) is at the end of the paragraph then we want to make a new
paragraph rather than append it to the current paragraph and consequently set the flag that
was supposed to prevent the first paragraph from being inserted}
IF isParaSelection AND (prevPara.size = newLP) THEN
BEGIN
newPara := textImage.NewEditPara(0, prevPara.format);
newLP := 0;
insertIt := TRUE;
END;
done := FALSE;
StartPaste;
IF GetParagraph(aParagraph) THEN
BEGIN
delta := delta + aParagraph.size;
REPEAT
newPara.ReplPara(newLP, 0, aParagraph, 0, aParagraph.size);
newLP := newLP + aParagraph.size;
IF insertIt THEN
textImage.text.InsParaAfter(prevPara, newPara);
insertIt := TRUE;
prevPara := newPara;
IF GetParagraph(aParagraph) THEN
BEGIN
newPara := textImage.NewEditPara(prevPara.size-newLP,
TParaFormat(aParagraph.format.Clone(SELF.Heap)));
{For now, so we don't get garbage (if aParagraph later deleted), put cloned
format on to styleSheet list}
SELF.textImage.text.styleSheet.formats.InsLast(newPara.format);
newPara.StartEdit(newPara.GrowSize);
newPara.ReplPara(0, 0, prevPara, newLp, prevPara.size - newLp);
prevPara.ReplPString(newLp, prevPara.size-newLP, NIL);
prevPara.StopEdit;
newLP := 0;
END
ELSE
done := TRUE;
UNTIL done;
END;
IF isParaSelection THEN
BEGIN

Apple Lisa ToolKit 3.0 Source Code Listing -- 1009 of 1012

Apple Lisa Computer Technical Information


000332
000333
000334
000335
000336
000337
000338
000339
000340
000341
000342
000343
000344
000345
000346
000347
000348
000349
000350
000351
000352
000353
000354
000355
000356
000357
000358
000359
000360
000361
000362
000363
000364
000365
000366
000367
000368
000369
000370
000371
000372
000373
000374
000375
000376
000377
000378
000379

newPara := textImage.NewEditPara(prevPara.size - newLP, prevPara.format);


newPara.StartEdit(newPara.GrowSize);
newPara.ReplPara(0, 0, prevPara, newLp, prevPara.size - newLp);
prevPara.ReplPString(newLp, prevPara.size - newLP, NIL);
prevPara.StopEdit;
textImage.text.InsParaAfter(prevPara, newPara);
newPara := TEditPara(textImage.text.paragraphs.At(SELF.textRange.firstIndex + numParas));
numParas := numParas+1;
newLP := 0;
END
ELSE IF isWordSelection THEN
IF needSpRight THEN
BEGIN
newPara.InsertOneChar(' ', newLP);
newLP := newLP + 1;
delta := delta + 1;
END;
EndPaste;
{$IFC fTrace}EP;{$ENDC}
END;
PROCEDURE Adjust;
PROCEDURE AddDelta(paraImage: TParaImage);
BEGIN
paraImage.AdjustLineLPs(SELF.textRange.firstLP, delta);
END;
BEGIN
{$IFC fTrace}BP(10);{$ENDC}
SELF.textRange.firstPara.EachImage(AddDelta);
WITH SELF, textRange DO
BEGIN
firstPara := newPara;
lastPara := newPara;
firstLP := newLP;
lastLP := newLP;
firstIndex := firstIndex + numParas - 1;
lastIndex := firstIndex;
newestLP := newLP;
amTyping := FALSE;
END;
{$IFC fTrace}EP;{$ENDC}
END;
BEGIN
{$IFC fTrace}BP(11);{$ENDC}
IF (text <> NIL) OR universalText THEN
SELF.ChangeText(InsText, Adjust);

Apple Lisa ToolKit 3.0 Source Code Listing -- 1010 of 1012

Apple Lisa Computer Technical Information


000380
000381
000382
000383
000384
000385
000386
000387
000388
000389
000390
000391
000392
000393
000394
000395
000396
000397
000398
000399
000400
000401
000402
000403
000404
000405
000406
000407
000408
000409
000410
000411
000412
000413
000414
000415
000416
000417
000418
000419
000420
000421

{$IFC fTrace}EP;{$ENDC}
END;
{$S FixText1}
BEGIN
cFixInsertionPoint := THISCLASS;
HackMethodTables;
uvFont[4].fontFamily := famModern;
uvFont[5].fontFamily := famModern;
uvFont[6].fontFamily := famModern;
uvFont[7].fontFamily := famModern;
uvFont[8].fontFamily := famModern;
uvFont[9].fontFamily := famModern;
uvFont[10].fontFamily := famClassic;
uvFont[11].fontFamily := famClassic;
uvFont[12].fontFamily := famClassic;
uvFont[13].fontFamily := famClassic;
uvFont[14].fontFamily := famClassic;
uvFont[15].fontFamily := famModern;
uvFont[16].fontFamily := famClassic;
uvFont[19].fontFamily := famModern;
uvFont[4].fontSize := 5;
uvFont[5].fontSize := 7;
uvFont[6].fontSize := 8;
uvFont[7].fontSize := 2;
uvFont[8].fontSize := 3;
uvFont[9].fontSize := 4;
uvFont[10].fontSize := 5;
uvFont[11].fontSize := 7;
uvFont[12].fontSize := 8;
uvFont[13].fontSize := 3;
uvFont[14].fontSize := 6;
uvFont[15].fontSize := 6;
uvFont[16].fontSize := 6;
uvFont[19].fontSize := 1;
END;

{added}
{added}
{added}

{added}
{added}
{added}

END.

End of File -- Lines: 421 Characters: 13961


SUMMARY:
Total number of files : 38

Apple Lisa ToolKit 3.0 Source Code Listing -- 1011 of 1012

Apple Lisa Computer Technical Information


Total file lines
: 47256
Total file characters : 1553575

Apple Lisa ToolKit 3.0 Source Code Listing -- 1012 of 1012

You might also like