Sie sind auf Seite 1von 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);
F