-- File: Palm.mesa
-- Contents: Interface to Palm browser. 
-- Created by: Rick Cattell on 11-Dec-81 12:29:29
-- Last edited by:
--   Rick on: March 18, 1982 1:46 pm
--  Willie-Sue on: October 22, 1982 12:04 pm

DIRECTORY
  DBView,
  MBQueue USING [Queue],
  Nut USING[CreateProc, DisplayProc, EditProc, QueryProc],
  Buttons, Menus, Rope, TypeScript, ViewerClasses, VFonts;

Palm: DEFINITIONS 
  IMPORTS VFonts  =

BEGIN OPEN DBView;

Viewer: TYPE = ViewerClasses.Viewer;
ROPE: TYPE = Rope.ROPE;
Queue: TYPE = MBQueue.Queue;

-- ********************************************************
-- Handy Procedures for dealing with viewers (NutViewerImpl.mesa)
-- ********************************************************

NextTextViewer: PROC[sib: Viewer]  RETURNS [nV: Viewer];
  -- creates text viewer on line following sib, full width of sib.parent

NextRightTextViewer: PROC[sib: Viewer, w: INTEGER] RETURNS [nV: Viewer];
  --  creates a text viewer, next right on the same line as v

FirstLabel: PROC[name: ROPE, parent: Viewer] RETURNS [nV: Viewer];
  --  makes a label which is the first one in a viewer, at standard Y value

AnotherLabel: PROC[name: ROPE, sib: Viewer, newLine: BOOL← FALSE] RETURNS [nV: Viewer];
  --  sib is a viewer to the left or above the label to be made

--  ALL menus/buttons are serialized now
--  IF q=NIL THEN uses defaultDBQueue to serialize clicks

FirstButton: PROC[q: Queue, name: ROPE, proc: Buttons.ButtonProc, parent: Viewer,
                  data: REF ANY← NIL, border: BOOL← FALSE, guarded: BOOL← FALSE,
                  font: VFonts.Font ← VFonts.defaultFont]
      RETURNS [nV: Viewer];
  --  makes a button which is the first one in a viewer

AnotherButton: PROC[q: Queue, name: ROPE, proc: Buttons.ButtonProc, sib: Viewer,
		    data: REF ANY← NIL, border: BOOL← FALSE, width: INTEGER← 0,
		    guarded: BOOL← FALSE, font: VFonts.Font ← VFonts.defaultFont,
		    newLine: BOOL← FALSE]
		RETURNS [nV: Viewer];
  --  sib is a viewer to the left or above the button to be made

CreateMenuEntry: PROC[q: Queue, name: ROPE, proc: Menus.MenuProc,
			clientData: REF ANY← NIL, documentation: REF ANY← NIL, fork: BOOL← TRUE,
			guarded: BOOL← FALSE]
	RETURNS[Menus.MenuEntry];

GetDefaultDBQueue: PROC RETURNS[Queue];
  -- returns Squirrel's default Queue

--  The following three PROCs assume that sib.parent#NIL
MakeTypescript: PROC[sib: Viewer] RETURNS [ts: TypeScript.TS];
  --  sib is sibling to create TS after, this must be last child of sib.parent.

MakeRuler: PROC[sib: Viewer, h: INTEGER← 1] RETURNS [r: Viewer];
  --  Put a h-bit wide line after sib

MakeBigTextBox: PUBLIC PROC[sib: Viewer, contents: ROPE] RETURNS [nV: Viewer];
  -- Makes editable text viewer taking rest of sib.parent's viewer, suitable for msg body or whatever.
  -- sib is sibling to create text box after, this must be last child of sib.parent.

FieldHandle: TYPE = REF FieldObject;
FieldObject: TYPE = RECORD[
  tuple: Relship,
  attribute: Attribute ];

ProcessSelection: Buttons.ButtonProc;
  -- A standard ButtonProc that assumes the button's REF ANY data is the FieldHandle above.
  -- Insures attribute of tuple is entity-valued and non-NIL, then calls Nut.Display on it.

DefaultFreezeProc: Menus.MenuProc;
  -- A standard proc for freezing a Nut (make it not reuseable)

-- ********************************************************
--  TYPEs used in editor windows
-- ********************************************************

CommitEditableTuple: PROC[eti: EditableTupleInfo, eei: EditableEntityInfo]
  RETURNS[BOOLEAN];

EditableTupleInfoObject: TYPE = RECORD[
  a: Attribute,  -- Attribute that references entity we're editing
  r: Relation, -- relation this tuple comes from
  al: LIST OF Attribute, -- attributes of this relation
  existing: Relship, -- NIL if this doesn't represent existing tuple
  uniqueNess: Uniqueness, -- {None, Key, KeyPart, OptionalKey}
  lastAttributeViewerInfo: AttributeFieldInfo, -- last viewer horizontally
  nextETIO: EditableTupleInfo];  -- next line of viewers

EditableTupleInfo: TYPE = REF EditableTupleInfoObject;

AttributeFieldInfoObject: TYPE = RECORD[
  a: Attribute,		-- this Attribute
  v: ViewerClasses.Viewer,		-- this viewer
  prev: AttributeFieldInfo];	-- previous viewer horizontally

AttributeFieldInfo: TYPE = REF AttributeFieldInfoObject;

EditableEntityInfoObject: TYPE = RECORD[
  d: Domain,		-- domain of this viewer
  eName: ROPE,		-- name of new/existing entity
  e: Entity,		-- new/existing entity of this viewer
  neV: ViewerClasses.Viewer,	-- text viewer for nextEntity to edit 
  etiChain: EditableTupleInfo];

EditableEntityInfo: TYPE = REF EditableEntityInfoObject;

-- ********************************************************
-- TYPEs used in Displayer viewers
-- ********************************************************

AttributeFieldObject: TYPE = RECORD[
  attribute: Attribute,
  property: Property ];

AttributeFieldHandle: TYPE = REF AttributeFieldObject;

EntityFieldObject: TYPE = RECORD[
  entity: Entity];

EntityFieldHandle: TYPE = REF EntityFieldObject;


-- ********************************************************
-- default nut procs
-- ********************************************************

Display: Nut.DisplayProc;
  -- Creates a browser viewer display the given entity.
  
Edit: Nut.EditProc;
  -- Creates a browser viewer display the given entity, and prompts for
  -- all the relationships an entity of this type can participate in.

Query: Nut.QueryProc;
  -- Not yet implemented.  Creates default queryer.

Create: Nut.CreateProc;
  -- Creates a default viewer for a nut, a Container with default menu and title


END.