1*46439007SCharles.ForsythPrefab: module 2*46439007SCharles.Forsyth{ 3*46439007SCharles.Forsyth PATH: con "$Prefab"; 4*46439007SCharles.Forsyth 5*46439007SCharles.Forsyth # types of Elements 6*46439007SCharles.Forsyth EIcon: con 0; 7*46439007SCharles.Forsyth EText: con 1; 8*46439007SCharles.Forsyth ETitle: con 2; 9*46439007SCharles.Forsyth EHorizontal: con 3; 10*46439007SCharles.Forsyth EVertical: con 4; 11*46439007SCharles.Forsyth ESeparator: con 5; 12*46439007SCharles.Forsyth 13*46439007SCharles.Forsyth # first arg to Element.adjust: size of elements 14*46439007SCharles.Forsyth Adjpack: con 10; # leave alone, pack tightly 15*46439007SCharles.Forsyth Adjequal: con 11; # make equal 16*46439007SCharles.Forsyth Adjfill: con 12; # make equal, filling available space 17*46439007SCharles.Forsyth 18*46439007SCharles.Forsyth # second arg: position of element within space 19*46439007SCharles.Forsyth Adjleft: con 20; 20*46439007SCharles.Forsyth Adjup: con 20; 21*46439007SCharles.Forsyth Adjcenter: con 21; 22*46439007SCharles.Forsyth Adjright: con 22; 23*46439007SCharles.Forsyth Adjdown: con 22; 24*46439007SCharles.Forsyth 25*46439007SCharles.Forsyth # default fonts and colors for objects 26*46439007SCharles.Forsyth Style: adt 27*46439007SCharles.Forsyth { 28*46439007SCharles.Forsyth titlefont: ref Draw->Font; 29*46439007SCharles.Forsyth textfont: ref Draw->Font; 30*46439007SCharles.Forsyth elemcolor: ref Draw->Image; 31*46439007SCharles.Forsyth edgecolor: ref Draw->Image; 32*46439007SCharles.Forsyth titlecolor: ref Draw->Image; 33*46439007SCharles.Forsyth textcolor: ref Draw->Image; 34*46439007SCharles.Forsyth highlightcolor: ref Draw->Image; 35*46439007SCharles.Forsyth }; 36*46439007SCharles.Forsyth 37*46439007SCharles.Forsyth # drawing environment for objects 38*46439007SCharles.Forsyth Environ: adt 39*46439007SCharles.Forsyth { 40*46439007SCharles.Forsyth screen: ref Draw->Screen; 41*46439007SCharles.Forsyth style: ref Style; 42*46439007SCharles.Forsyth }; 43*46439007SCharles.Forsyth 44*46439007SCharles.Forsyth # operand for layout operators; set either (font, color, text) or (icon, mask) 45*46439007SCharles.Forsyth Layout: adt 46*46439007SCharles.Forsyth { 47*46439007SCharles.Forsyth font: ref Draw->Font; 48*46439007SCharles.Forsyth color: ref Draw->Image; 49*46439007SCharles.Forsyth text: string; 50*46439007SCharles.Forsyth icon: ref Draw->Image; 51*46439007SCharles.Forsyth mask: ref Draw->Image; 52*46439007SCharles.Forsyth tag: string; 53*46439007SCharles.Forsyth }; 54*46439007SCharles.Forsyth 55*46439007SCharles.Forsyth # graphical objects in the interface, recursively defined for making lists 56*46439007SCharles.Forsyth Element: adt 57*46439007SCharles.Forsyth { 58*46439007SCharles.Forsyth # part of Ell elements 59*46439007SCharles.Forsyth kind: int; # type: EIcon, EText, etc. 60*46439007SCharles.Forsyth r: Draw->Rect; # rectangle on screen 61*46439007SCharles.Forsyth environ: ref Environ; # graphics screen, style 62*46439007SCharles.Forsyth tag: string; # identifier for selection 63*46439007SCharles.Forsyth 64*46439007SCharles.Forsyth # different fields defined for different kinds of Elements 65*46439007SCharles.Forsyth kids: list of ref Element; # children of EHorizontal, EVertical 66*46439007SCharles.Forsyth str: string; # text in an EText element 67*46439007SCharles.Forsyth mask: ref Draw->Image; # part of Eicon, ESeparator 68*46439007SCharles.Forsyth image: ref Draw->Image; # part of Eicon, ESeparator, EText, Etitle 69*46439007SCharles.Forsyth font: ref Draw->Font; # part of EText, Etitle 70*46439007SCharles.Forsyth 71*46439007SCharles.Forsyth # constructors 72*46439007SCharles.Forsyth icon: fn(env: ref Environ, r: Draw->Rect, icon, mask: ref Draw->Image): ref Element; 73*46439007SCharles.Forsyth text: fn(env: ref Environ, text: string, r: Draw->Rect, kind: int): ref Element; 74*46439007SCharles.Forsyth layout: fn(env: ref Environ, lay: list of Layout, r: Draw->Rect, kind: int): ref Element; 75*46439007SCharles.Forsyth elist: fn(env: ref Environ, elem: ref Element, kind: int): ref Element; 76*46439007SCharles.Forsyth separator: fn(env: ref Environ, r: Draw->Rect, icon, mask: ref Draw->Image): ref Element; 77*46439007SCharles.Forsyth 78*46439007SCharles.Forsyth # editing and geometry 79*46439007SCharles.Forsyth append: fn(elist: self ref Element, elem: ref Element): int; 80*46439007SCharles.Forsyth adjust: fn(elem: self ref Element, equal: int, dir: int); 81*46439007SCharles.Forsyth clip: fn(elem: self ref Element, r: Draw->Rect); 82*46439007SCharles.Forsyth scroll: fn(elem: self ref Element, d: Draw->Point); 83*46439007SCharles.Forsyth translate: fn(elem: self ref Element, d: Draw->Point); 84*46439007SCharles.Forsyth show: fn(elist: self ref Element, elem: ref Element): int; 85*46439007SCharles.Forsyth }; 86*46439007SCharles.Forsyth 87*46439007SCharles.Forsyth # connects an element to a window for display 88*46439007SCharles.Forsyth Compound: adt 89*46439007SCharles.Forsyth { 90*46439007SCharles.Forsyth image: ref Draw->Image; # window on which contents are drawn 91*46439007SCharles.Forsyth environ: ref Environ; # graphics screen, style 92*46439007SCharles.Forsyth r: Draw->Rect; # rectangle on screen 93*46439007SCharles.Forsyth title: ref Element; # above the line (may be nil) 94*46439007SCharles.Forsyth contents: ref Element; # below the line 95*46439007SCharles.Forsyth 96*46439007SCharles.Forsyth # constructors 97*46439007SCharles.Forsyth iconbox: fn(env: ref Environ, p: Draw->Point, title: string, icon, mask: ref Draw->Image): ref Compound; 98*46439007SCharles.Forsyth textbox: fn(env: ref Environ, r: Draw->Rect, title, text: string): ref Compound; 99*46439007SCharles.Forsyth layoutbox:fn(env: ref Environ, r: Draw->Rect, title: string, lay: list of Layout): ref Compound; 100*46439007SCharles.Forsyth box: fn(env: ref Environ, p: Draw->Point, title, elist: ref Element): ref Compound; 101*46439007SCharles.Forsyth 102*46439007SCharles.Forsyth # display 103*46439007SCharles.Forsyth draw: fn(comp: self ref Compound); 104*46439007SCharles.Forsyth redraw: fn(comp: self ref Compound, r: Draw->Rect); 105*46439007SCharles.Forsyth scroll: fn(comp: self ref Compound, elem: ref Element, d: Draw->Point); 106*46439007SCharles.Forsyth show: fn(comp: self ref Compound, elem: ref Element): int; 107*46439007SCharles.Forsyth 108*46439007SCharles.Forsyth # support for using EHorizontal and EVertical as menus 109*46439007SCharles.Forsyth select: fn(comp: self ref Compound, elem: ref Element, i: int, c: chan of int): (int, int, ref Element); 110*46439007SCharles.Forsyth tagselect: fn(comp: self ref Compound, elem: ref Element, i: int, c: chan of int): (int, int, ref Element); 111*46439007SCharles.Forsyth highlight: fn(comp: self ref Compound, elem: ref Element, on: int); 112*46439007SCharles.Forsyth }; 113*46439007SCharles.Forsyth}; 114