Slate.mesa
Copyright Ó 1992, 1993 by Xerox Corporation. All rights reserved.
Created by Christian Jacobi, December 7, 1992 2:03 pm PST
Christian Jacobi, July 3, 1993 9:56 am PDT
Theimer, December 17, 1992 2:09 pm PST
Generic types and properties
All fields except property values on a property list are considered readonly to external clients.
globalProperties:
READONLY PropList.List;
A global property list.
Using a private scheme for global properties is better then using global Atom properties because it establishes a naming scope of its own.
Session:
TYPE =
REF SessionRec;
A session represents the union of instances sharing the same data
SessionRec:
TYPE =
RECORD [
activePage: Page,
debugLog: IO.STREAM, --Capable for being used as master for stream widgets
nameCell: SharedCell.Cell,
properties: PropList.List,
private: REF SessionPrivateRec
];
SessionPrivateRec: TYPE;
Instance:
TYPE =
REF InstanceRec;
A particular instance has its user interface widget fooling around with the data of its session
InstanceRec:
TYPE =
RECORD [
session: Session,
log: IO.STREAM, --Capable for being used as master for stream widgets
uiPrivate: REF ANY ¬ NIL, --private for the implementor of the user interface
shell, surface: XTk.Widget ¬ NIL,
properties: PropList.List,
private: REF InstancePrivateRec
];
InstancePrivateRec: TYPE;
SetSessionName:
PROC [session: Session, name: Rope.
ROPE];
Changes name of session
SessionName:
PROC [session: Session]
RETURNS [Rope.
ROPE];
Returns name of session; might change later
Generic event handling
EventProc:
TYPE =
PROC [instance: Instance, session: Session, callData:
REF, registerData:
REF, event:
REF];
Type for procedure to be called on certain events
Calling procedures registered on events is not for whimps.
You do not get feedback on how many procedures are called.
Registered procedures are called in arbitrary order.
CallGlobalEvent:
PROC [instance: Instance ¬
NIL, session: Session ¬
NIL, event:
REF, callData:
REF ¬
NIL];
Calls the procedures which have been registered with RegisterGlobalEventProc.
CallSessionEvent:
PROC [instance: Instance ¬
NIL, session: Session ¬
NIL, event:
REF, callData:
REF ¬
NIL];
Calls the procedures which have been registered with RegisterSessionEventProc on this session.
session may be NIL if it can be taken from the instance
CallInstanceEvent:
PROC [instance: Instance, session: Session ¬
NIL, event:
REF, callData:
REF ¬
NIL];
Calls those procedures which have been registered with RegisterInstanceEventProc on this instance.
A NIL session will be filled in from the instance before calling the EventProc's.
Registration for procedures to be called on certain events is not for whimps.
Registrations can not be un-done.
RegisterGlobalEventProc: PROC [event: REF, proc: EventProc, registerData: REF ¬ NIL];
RegisterSessionEventProc: PROC [session: Session, event: REF, proc: EventProc, registerData: REF ¬ NIL];
RegisterInstanceEventProc: PROC [instance: Instance, event: REF, proc: EventProc, registerData: REF ¬ NIL];
Finding and creating Instances
NewSession:
PROC []
RETURNS [session: Session];
In the glorious future we might add a naming concept to sessions, but now a session doesn't have a name.
Restriction: Most user interface implementors want to see a page included before they can accept a session.
NewInstance:
PROC [session: Session]
RETURNS [instance: Instance];
Creates a new instance for this session. The caller must attach a user interface to the the instance.
Instances must be destroyed before they are subject to the garbage collector.
DestroyInstance:
PROC [instance: Instance];
Destroys instance. Idempotent.
Typically called by the user interface implementor only.
NewInstanceTool:
PROC [session: Session, server:
REF]
RETURNS [instance: Instance];
Creates a new instance for this session with an attached UI window.
Instances must be destroyed before they are subject to the garbage collector.
CountInstances:
PROC [session: Session]
RETURNS [
INT];
Returns the number of currently existing instances
InstanceProc: TYPE = PROC [instance: Instance, clientData: REF] RETURNS [quit: BOOL ¬ FALSE];
EnumerateInstances:
PROC [session: Session, eachInstance: InstanceProc, clientData:
REF ¬
NIL]
RETURNS [quit:
BOOL ¬
FALSE];
Calls eachInstance for each instance of session or until it returns quit=TRUE
Additions or deletions of instances while an enumeration is in progress might or might not be seen
CallSessionForAllInstancesOfSession:
PROC [session: Session ¬
NIL, event:
REF, callData:
REF ¬
NIL];
Calls the procedures which have been registered with RegisterSessionEventProc on this session once for each instance.
CallGlobalForAllInstancesOfSession:
PROC [session: Session ¬
NIL, event:
REF, callData:
REF ¬
NIL];
Calls the procedures which have been registered with RegisterGlobalEventProc for all instances of this session.
Currently there is no way to enumerate all sessions. Sessions are subject to the garbage collector.
Pages
A session has multiple pages, one of which may be active.
A page must not be included into more then 1 session, so the session might use the properties safely.
Page numbering is NOT a generic feature. A session might be composed from multiple files: the page number is a property of the session, not the stored page.
Page: TYPE = REF PageRec;
PageRec:
TYPE =
RECORD [
session: Session,
activeArea: XlBitmap.Bitmap,
properties: PropList.List
];
NewPage:
PROC [session: Session, sz:
SF.Vec ¬ [0, 0], initial: ImagerSample.RasterSampleMap ¬
NIL, properties: PropList.List ¬
NIL, bpp:
INT ¬ 0]
RETURNS [page: Page];
Creates a new page and includes it into the session. It is not (yet) active.
sz size of page in pixels, f horizontal (scanline), s vertical.
RemovePage:
PROC [page: Page];
The page is removed from the session, but the data stays around.
Restriction: Most user interface implementors want to see at least one page attached to a session.
PageProc: TYPE = PROC [page: Page, clientData: REF] RETURNS [quit: BOOL ¬ FALSE];
EnumeratePages:
PROC [session: Session, eachPage: PageProc, clientData:
REF ¬
NIL]
RETURNS [quit:
BOOL ¬
FALSE];
Calls eachPage for each page of session or until it returns quit=TRUE
Additions or deletions of pages while an enumeration is in progress might or might not be seen
CurrentListOfPages:
PROC [session: Session]
RETURNS [
LIST
OF Page];
Creates a new list of pages with the current contents
ActivatePage:
PROC [page: Page];
Copies the contents of this page to the active and shared area of the session
ActivePage:
PROC [session: Session]
RETURNS [page: Page];
Returns currently active page of session