Text preview for : Windows.mesa_Oct77.pdf part of xerox Windows.mesa Oct77 xerox mesa 3.0_1977 listing Windows.mesa_Oct77.pdf



Back to : Windows.mesa_Oct77.pdf | Home

wi ndows. mESA 24-0CT-77 18: 55: 07 Page 1


-- Windows.Mesa Edited by Sandman on September 27, 1977 11:28 AM
DIRECTORY
ControlDefs: FROM "controldefs",
ImageDefs: FROM "imagedefs",
InlineDefs: FROM "inlinedefs",
MenuDefs: FROM "menudefs",
NovaOps: FROM "novaops",
RectangleDefs: FROM "rectangledefs",
SegmentDefs: FROM "segmentdefs",
StreamDefs: FROM "streamdefs",
StringDefs: FROM "stringdefs",
SystemDefs: FROM "systemdefs",
WindowDefs: FROM "windowdefs";
DEFINITIONS FROM MenuDefs.SystemDefs, SegmentDefs, StreamDefs. RectangleDefs, WindowDefs:
Windows: PROGRAM [dfn: STRING]
IMPORTS ImageDefs, RectangleDefs, SegmentDefs, StreamDefs, StringDefs, SystemDefs.
WindowDefs
EXPORTS WindowDefs SHARES WindowDefs, StreamDefs =
BEGIN

-- GLOBAL Data
--dfn: STRING ~ "foo.script";
currentwindow: WindowHandle ~ NIL;
defaultwindow: WindowHandle ~ NIL;
maxwindows: CARDINAL = 15:
max1ines: CARDINAL = 50:
linestarts: ARRAY [l .. maxlines] OF StreamIndex;
originindex: StreamIndex = StreamIndex[O. 0]:
nullindex: StreamIndex = StreamIndex[O. -1]:
Contro1A: CHARACTER = 1C;
85: CHARACTER = 10C:
CR: CHARACTER = 15C:
-- mouse locations
xmloc: POINTER LOOPHOLE[4248]:
ymloc: POINTER LOOPHOLE[425B];
xcloc: POINTER LOOPHOLE [4268]:
ycloc: POINTER LOOPHOLE [4278]:
-- Mesa Display Window Routines
CreateDisp1ayWindow: PUBLIC PROCEDURE
[type: WindowType. rectangle: Rptr. ds: DisplayHandle. ks: StreamHandle. name: STRING]
RETURNS[WindowHandle]
BEGIN
-- declare locals
w: Windowllandle:
-- create window structure and init it
w ~ Sys temDe fs . A ocatelieapNode[S TZErO i sp 1ayWi ndow]] ;
11
w~ ~ OisplayWindow[NIL. type. NIL. NIL. NILProc. rectangle. ds. ks. NIL .... ];
-- initialize data refresh mechanism based upon window type
AlterWindowType[w. lype. name];
SetCurrenlDisplayWindow[w];
RETURN[w] ;
END;
AlterWindowType: PUBLIC PROCEDURE [w: WindowHandle. type: WindowType. name: STRING]
RfGTN
-- firsl undo all stuff for current type
Sfl[(T w.lype fROM
clear => NULL; -- window is simply cleared on aclivation
random =) NUll; USfRS res pons ib iIi ty to repa i n l screen
scratch.
scriptfile.
file => -- data is a window on file
RrGIN
If w. file # NIL TflEN
RfG IN
w.file.destroy[w.file];
windows.mESA 24-0CT-77 18:55:07 Page 2


w.file .. NIL;
END;
END;
ENDCASE;
now fixup all stuff for new type
w.type .. type;
SELECT type FROM
clear => NULL; -- window is simply cleared on activation
random =) NULL; USERS responsibility to repaint screen
scratch,
scriptfile,
file => -- data is a window on file
IF name # NIL THEN
SetFi1eForWindow[w, name];
E~JOCASE ;
and set name (if not done already)
IF (w.name = NIL AND name # NIL) OR w.name # name THEN
BEGIN
If w.name # NIL THEN freeHeapString[w.name];
w.name .. SystemDefs.A110cateHeapString[name.length];
~tringDefs.AppendString[w.name, name];
END;
set current selection null
w.selection .. Selection[leftmargin,leftmargin,l,l,nullindex, nullindex];
-- setup Stream options based upon stream existance
If w.ds # NIL THEN
BEGIN
w.ds.options.NoteLineBreak .. TRUE;
w.ds.options.NoteScro11ing .. TRUE;
w.ds.put .. WriteWindowChar;
SELECT type fROM
clear =) NULL;
random =) NULL;
scratch,
scriptfi1e =) w.ds.options.StopBottom .. fALSE:
file =) w.ds.options.StopBottom .. TRUE;
ENDCASE:
END;
END;
DestroyDisplayWindow: PUBLIC PROCEDURE [w: WindowHand1e] =
BEGIN -- clear it, unlink it deallocate record space and return
-- define locals
rectangle: Rptr = w.rectangle:
clearwords: GrayArray .. [0, 0, 0, 0];
clear: GrayPtr .. @clearwords;
-- clear it and free any storage
ClearBoxInRectangle[rectangle, 0, rectangle.cw, 0, rectangle.ch, clear];
IF w = currentwindow THEN
BEGIN
IF w = w.link THEN
BEGIN
currentwindow .. NIL;
UndoDataSetup[w);
END
ELSE
BEGIN
SetCurrentDisplayWindow[w. link]:
END;
END:
UnlinkDisplayWindow[w];
IF w.file # NIL THEN w.file.destroy[w.file];
Sys temDe fs. F l'eeHeapNode[w];
-- later!! must undo anything done to StreamObject
END;
Unl ink!) isplayWindow: PUBI IC PROCroUR[ [w: Windowllandle]
BEGIN
-- define locals
next: WindowHandle;
-- check if only window
rr w.link = w TIIrN
currentwindow .. NIL
rL SE
BrGIN
IF w = curl'entwindow TlI[N cUl'renlwindow .. w.l ink;
windows.mESA 24-0CT-77 18:55:07 Page 3


next .. w;
WHILE next.link # w DO
next .. next.link;
ENDLOOP;
next.link .. w.link;
END;
w.link" NIL;
END;
RepaintDisplayWindows: PUBLIC PROCEDURE [mapdata: BMHandle]=
BEGIN
-- declare locals
i. j: INTEGER;
w: WindowHandle;
wa: ARRAY[O .. maxwindows} OF WindowHandle;
-- Build array of window handles
i .. 0;
w .. currentwindow;
DO
wa[i] .. w;
w .. w.link;
i .. i + 1;
IF w = currentwindow THEN EXIT
ENDlOOP;
now paint them in reverse order
FOR j DECREASING IN [O .. i} DO
SetCurrentDisplayWindow[wa[j]];
ENOLOOP;
END;
PaintDisplayWindow: PUBLIC PROCEDURE [1'1: WindowHandle] =
BEGIN
-- declare locals
rectangle: Rptr = w.rectangle;
clearwords: GrayArray .. [a, 0, 0, 0];
clear: GrayPtr = @clearwords;
-- first see if it's visible
IF w.rectangle.visible = FALSE THEN RETURN;
-- clear it and draw a box around it
ClearBoxInRectangle[rectangle, 0, rectangle.cw, 0, rectangle.ch, clear]:
DrawDisplayWindow[w]:
-- do type dependent stuff
IF w.ds # NIL THEN
BEGIN
SetDisplayL ine[w. ds, 1, leftmargin];
w.ds.chary .. w.ds.chary + 1;
END;
SELECT w.type FROM
clear, -- window is simply cleared on activation
random => -- USERS responsibility to repaint screen
w.displayproc[w): -- dispatch to procedure
scratch, -- data is maintained in scratch file
scriptfile, -- data is maintained in typescript file
file => -- window on a file
IF w.file # NIL THEN
w.displayproc[w]: -- dispatch to procedure
ENDCASE:
UpdateSelection[w]:
END:
DrawDisplayWindow: PUBLIC PROCEDURE [w: WindowHandle]
BEGIN
-- declare locals
pront: FAptr:
rectangle: Rptr = w.rectangle;
x,y,lineheight: INTEGER;
-- write box name
[pfont, 1 ineheight] .. GetDeraultFont[];
rr w.name H NIL THfN
BEGIN
[x,y] .. WriteRectangleString[rectangle, 2, I, w.name, pfont
I Rectanglerrror =)
SflfCT error fROM
NoLVisible,
RlghtOverflow,
BoLLomOverflow =) CONTINUE;
windows.mESA 24-0CT-77 18:55:07 Page 4


ENDCASE
]:
END:
invert the top stripe:
InvertBoxInRectangle[rectangle, 0, rectangle.cw, 0, lineheight + 1]:
-- draw box arround the edge:
DrawBoxlnRectangle[rectangle, 0, rectangle.cw, 0, rectangle.ch]:
END:
FindDisplayWindow: PUBLIC PROCEDURE [x, y: INTEGER]
RETURNS[WindowHandle, xCoord, yCoord]