;7Syntax10.Scn.Fnt Syntax10i.Scn.FntStampElemsAlloc3 Mar 99InfoElemsAlloc#Syntax10.Scn.Fnt"Title": Form-Elements (FormElems) "Author": Stefan Aufischer "Abstract": Provides Textelements used in the Web-Browser of Oberon. Most elements are derived from the (Panel)Elems, some from the WebElems. "Keywords": Insert..., New... Form, Hidden, Image, SubmitButton, ResetButton, TextField, TextArea, CheckBox, RadioButton, PassWord, List. "Version": "From": 17.09.97 "Until": 17.03.98 "Changes": 29.04.98 - unlimited length for TextAreas  8FoldElemsNew#Syntax10.Scn.Fnt Files, Fonts, Display, Viewers, Texts, TextFrames, TextPrinter, Oberon, Web, WebElems, Elems, ButtonElems, CheckBoxElems, RadioButtonElems, TextFieldElems, TextAreaElems, ListElems, Strings, HTML, TableTools;8~8Syntax10.Scn.FntSyntax10b.Scn.FntWSyntax10i.Scn.Fnt9     # undef* = -1; left = 2; middle = 1; right = 0; cancel = {left, middle, right}; vLen = 1024; (* max. length of nondynamic string values in InputTag *) formCol* = 1; (* red *) hiddenCol* = 3; (* blue *) clickCol = 8; (* green *) pixel = LONG(TextFrames.Unit); elemH = 11 * pixel; formW = 14 * pixel; hiddenW = 11 * pixel; invisW = 1; (* width of an invisible element *) DUnit = TextFrames.Unit;8r8-Syntax10.Scn.FntSyntax10b.Scn.Fnt  8FoldElemsNewSyntax10.Scn.FntSyntax10b.Scn.Fnt q FormElemDesc* = RECORD (WebElems.LinkElemDesc) method* : ARRAY 5 OF CHAR; encType* : ARRAY 64 OF CHAR END;8  8Syntax10.Scn.FntSyntax10b.Scn.Fntn HiddenElemDesc* = RECORD (WebElems.ElemDesc); name* : ARRAY 64 OF CHAR; value* : Web.DynamicString END;8  8Syntax10.Scn.FntSyntax10b.Scn.FntSyntax10i.Scn.FntE ImageElemDesc* = RECORD (WebElems.ImageElemDesc); x*, y* : INTEGER (* Coordinates of mouseclick, if SubmitForm is called by the elem *) END;8Syntax10i.Scn.Fntm  8?Syntax10.Scn.FntSyntax10b.Scn.Fnt    InputTagDesc* = RECORD type*, value*, name*, align*, myValue* : ARRAY vLen OF CHAR; dynName*, dynValue*, src* : Web.DynamicString; size*, maxLen* : LONGINT; checked*, selected* : BOOLEAN END;8  ]8mSyntax10.Scn.FntSyntax10b.Scn.Fnt      Syntax10i.Scn.Fnt, +7 SelectionDesc* = RECORD name* : ARRAY 64 OF CHAR; defaultSel* : ARRAY 256 OF CHAR; vertSize*, horizSize*, noOfOptions* : LONGINT; multiple*, popup*, done* : BOOLEAN; optionText*, (* Text to be displayed in ListElems.Elem *) valueText* : Texts.Text (* Text to be sent in case of submission *) END;8  8Syntax10.Scn.FntSyntax10b.Scn.Fnt Syntax10i.Scn.Fnt2  OptionDesc* = RECORD text*, (* Text displayed in one line of ListElems.Elem *) value* : Web.DynamicString; selected* : BOOLEAN END;8  8Syntax10.Scn.FntSyntax10b.Scn.Fnt S TextAreaDesc* = RECORD name* : ARRAY 64 OF CHAR; rows*, cols* : LONGINT END;88_Syntax10.Scn.FntSyntax10b.Scn.Fnt " name* : ARRAY 64 OF CHAR END; 8 8Syntax10.Scn.FntSyntax10b.Scn.Fnt\ rider* : Files.Rider; name* : ARRAY 64 OF CHAR; value* : ARRAY 1024 OF CHAR END; 8 8Syntax10.Scn.FntSyntax10b.Scn.Fnt\ rider* : Files.Rider; name* : ARRAY 64 OF CHAR; value* : ARRAY 1024 OF CHAR END; 8 b FormElem* = POINTER TO FormElemDesc;  HiddenElem* = POINTER TO HiddenElemDesc;  ImageElem* = POINTER TO ImageElemDesc;  (* Records containing variables for all attributes the input-, select-, option- and textarea-tags can have *) InputTag* = POINTER TO InputTagDesc;  Selection* = POINTER TO SelectionDesc;  Option* = POINTER TO OptionDesc;  TextArea* = POINTER TO TextAreaDesc;  TagMsg* = RECORD (Texts.ElemMsg)  SubmitMsg* = RECORD (Texts.ElemMsg)  ResetMsg* = RECORD (Texts.ElemMsg)  UpdateMsg* = RECORD (Texts.ElemMsg) END; AttrMsg* = RECORD (Elems.AttrMsg) END;88tSyntax10.Scn.FntSyntax10i.Scn.Fnt!'!*3 fIcon, fClickIcon : ARRAY 2 OF Display.Pattern; (* x = 0, y = 3, w = 13, h = 8 *) hIcon, hClickIcon : Display.Pattern; (* x = 0, y = 3, w = 13, h = 8 *) w : Texts.Writer; cmdElem : ImageElem; (* ImageElem that initialized the latest command *)8 F@ Syntax10b.Scn.Fnt , 8Syntax10.Scn.Fnt"f  #Syntax10i.Scn.Fnth  '  . VAR r: Texts.Reader; e1: FormElem; BEGIN e1 := NIL; IF e.side = WebElems.LeftSide THEN Texts.OpenReader(r, Texts.ElemBase(e), Texts.ElemPos(e)+1); (*Texts.*) TableTools.ReadElem(r); WHILE (r.elem # NIL) & ~ (r.elem IS FormElem) DO (*Texts.*) TableTools.ReadElem(r) END ELSE (* e.side = RightSide *) Texts.OpenReader(r, Texts.ElemBase(e), Texts.ElemPos(e)); (*Texts.*) TableTools.ReadPrevElem(r); WHILE (r.elem # NIL) & ~ (r.elem IS FormElem) DO (*Texts.*) TableTools.ReadPrevElem(r) END END; IF (r.elem # NIL) & (r.elem IS FormElem) & (r.elem(FormElem).side # e.side) THEN e1 := r.elem(FormElem) END; RETURN e1 END Twin;8  ,8Syntax10.Scn.Fnt J  VAR p: TextFrames.Parc; beg: LONGINT; BEGIN IF f = NIL THEN IF fnt = NIL THEN dsr := 0 ELSE dsr := - fnt.minY END ELSE TextFrames.ParcBefore(f(TextFrames.Frame).text, pos, p, beg); dsr := SHORT(p.dsr DIV DUnit) END END GetDsr;8)  8Syntax10.Scn.Fnt    VAR len : INTEGER; BEGIN len := 0; WHILE src[len] # 0X DO INC(len) END; NEW(dest, len + 1); COPY(src, dest^) END CopyDynString; 8 8Syntax10.Scn.Fnt   "  Q VAR pos : LONGINT; len : INTEGER; ch : CHAR; BEGIN pos := Files.Pos(r); len := 0; REPEAT Files.Read(r, ch); INC(len) UNTIL ch = 0X; IF len > 1 THEN NEW(str, len); Files.Set(r, Files.Base(r), pos); Files.ReadBytes(r, str^, len) ELSE str := NIL END END LoadDynString; 8 ,$8wSyntax10.Scn.Fntf BEGIN IF str # NIL THEN Files.WriteString(r, str^) ELSE Files.Write(r, 0X) END END StoreDynString; 8   8Syntax10.Scn.Fnt  (  "Syntax10i.Scn.Fnt $ VAR i, len : INTEGER; ch : CHAR; BEGIN i := 0; len := SHORT(LEN(str)); REPEAT Texts.Read(msg.r, ch); str[i] := ch; INC(i) UNTIL (ch = 0X) OR (ch = 0DX) OR (i > len - 1); str[i-1] := 0X; WHILE (ch # 0X) & (ch # 0DX) DO Texts.Read(msg.r, ch) END (* skip to next line *) END ReadLine; 8 8MSyntax10.Scn.Fnt$  Syntax10i.Scn.Fnt>&   VAR pos : LONGINT; i : INTEGER; ch : CHAR; BEGIN pos := Texts.Pos(msg.r); i := 0; REPEAT Texts.Read(msg.r, ch); INC(i) UNTIL (ch = 0X) OR (ch = 0DX); (* determine length of line *) IF i > 1 THEN NEW(str, i); Texts.OpenReader(msg.r, msg.text, pos); i := 0; REPEAT Texts.Read(msg.r, ch); str[i] := ch; INC(i) UNTIL (ch = 0X) OR (ch = 0DX); str[i-1] := 0X ELSE str := NIL END END ReadDynLine;8  8ISyntax10.Scn.Fnt7 * % VAR i : INTEGER; r: Texts.Reader; ch : CHAR; len : LONGINT; BEGIN i := 0; len := LEN(s); Texts.OpenReader(r, t, pos); Texts.Read(r, ch); IF r.eot THEN s[0]:=0X; pos := Texts.Pos(r); RETURN(FALSE) END; col := r.col; WHILE ~r.eot & (i < len - 1) & (ch # Elems.CR) DO IF ch # Texts.ElemChar THEN s[i] := ch; INC(i) END; Texts.Read(r, ch) END; s[i] := 0X; pos := Texts.Pos(r); RETURN(TRUE) END TextLineToString; 8 ]8Syntax10.Scn.Fnt<' % VAR i : INTEGER; r: Texts.Reader; ch : CHAR; BEGIN i := 0; Texts.OpenReader(r, t, pos); Texts.Read(r, ch); IF r.eot THEN NEW(s, 1); s[0]:=0X; pos := Texts.Pos(r); RETURN(FALSE) END; col := r.col; WHILE ~r.eot & (ch # Elems.CR) DO IF ch # Texts.ElemChar THEN INC(i) END; Texts.Read(r, ch) END; NEW(s, i+1); RETURN(TextLineToString(t, pos, s^, col)); END TextLineToDynString; 8   8sSyntax10.Scn.FntQ     VAR i : INTEGER; r: Texts.Reader; ch : CHAR; BEGIN cols := 0; rows := 0; i := 0; Texts.OpenReader(r, t, 0); Texts.Read(r, ch); WHILE ~r.eot DO IF (ch = Elems.CR) THEN INC(rows); IF i>cols THEN cols := i END; i := 0 ELSIF ch # Texts.ElemChar THEN INC(i) END; Texts.Read(r, ch) END; IF (i>0) THEN INC(rows) END; IF i>cols THEN cols := i END; END TextSizes; 8 " 8)Syntax10.Scn.Fnt   8FoldElemsNew-Syntax10.Scn.Fnt     # VAR pos : INTEGER; BEGIN Web.EncodeStr(str, " "); pos := 0; WHILE str[pos] # 0X DO IF str[pos] = " " THEN str[pos] := "+" ELSIF str[pos] = "+" THEN str[pos] := "%"; Strings.Insert("2B", pos + 1, str); INC(pos, 2) END; INC(pos) END END EncodeStr; 8   y8?Syntax10.Scn.Fnt2 I BEGIN Files.WriteBytes(r, str, Strings.Length(str)) END WriteString;8( -N PROCEDURE EncodeStr(VAR str : ARRAY OF CHAR);  PROCEDURE WriteString(VAR r : Files.Rider; VAR str : ARRAY OF CHAR);  BEGIN EncodeStr(name); EncodeStr(value); IF ~firstTime THEN Files.Write(rid, "&") END; firstTime := FALSE; WriteString(rid, name); Files.Write(rid, "="); WriteString(rid, value) END AppendEncoded; 88$Syntax10i.Scn.FntWW(* Is called by a submit-button, a textfield (when return is pressed), or an image-map between a beginning and an ending form-tag. All formular-elements that also belong to this formular are coded and sent to the URL specified by the action-attribute in the beginning formular-tag (of course according to "encType" and "method" of the form) *)A8  8Syntax10.Scn.Fnt_ Syntax10i.Scn.FntS T  ?&  ;  >  7  #"# $#+e07 4,$ ' t8FoldElemsNew[Syntax10.Scn.Fnt2WebElems.FollowLink(f, "POST", "", NIL, NIL, body))8t8MSyntax10.Scn.Fnt@WebElems.FollowLink(f, "POST", "", NIL, Texts.ElemBase(f), body).8 o8[Syntax10.Scn.Fnt 7WebElems.FollowLink(f, "GET", queryStr^, NIL, NIL, NIL))8o8MSyntax10.Scn.Fnt EWebElems.FollowLink(f, "GET", queryStr^, NIL, Texts.ElemBase(f), NIL).8 t VAR e : Texts.Elem; f : FormElem; r : Texts.Reader; queryStr : Web.DynamicString; nameStr : ARRAY 1024 OF CHAR; error, (* TRUE when the submit-button is not between a beginning and an ending form-tag *) stop : BOOLEAN; body : Web.Body; file : Files.File; rid : Files.Rider; submitMsg : SubmitMsg; BEGIN firstTime := TRUE; error := FALSE; f := NIL; IF cmdElem = NIL THEN e := Elems.CmdElem ELSE e := cmdElem END; Texts.OpenReader(r, Texts.ElemBase(e), Texts.ElemPos(e)); (* Parse back to previous "FormTag" *) WHILE ~r.eot & (f=NIL) & ~error DO (*Texts.*) TableTools.ReadPrevElem(r); e := r.elem; IF e#NIL THEN WITH e : FormElem DO IF e.side = WebElems.LeftSide THEN f:=e END ELSE END ELSE error := TRUE END END; file := Files.New(""); IF f # NIL THEN Strings.Cap(f.method) END; (* Check possible errors that prevent from sending the form *) IF (f=NIL) OR error THEN error := TRUE; Web.LogF("SubmitForm: Beginning Form-Tag expected! (pos #)$",Texts.Pos(r)+1) ELSIF (f.method # "GET") & (f.method # "POST") & (f.method # "") THEN error := TRUE; Web.LogStr("SubmitForm:$ unknown METHOD: '"); Web.LogStr(f.method); Web.LogF("' (pos #)$",Texts.Pos(r)+1) ELSIF (f.encType # "application/x-www-form-urlencoded") & (f.encType # "") THEN error := TRUE; Web.LogStr("SubmitForm:$ unknown ENCTYPE: '"); Web.LogStr(f.encType); Web.LogF("' (pos #)$",Texts.Pos(r)+1) END; IF ~error THEN Files.Set(submitMsg.rider, file, 0); (* Parse forward to ending "FormTag" and encode & append names and values of each formular-element *) (*Texts.*) TableTools.ReadElem(r); stop := FALSE; WHILE ~r.eot & ~stop DO (*Texts.*) TableTools.ReadElem(r); e := r.elem; IF e#NIL THEN WITH e : FormElem DO IF e.side = WebElems.LeftSide THEN error := TRUE; Web.LogF("SubmitForm: Ending Form-Tag expected! (pos #)$",Texts.Pos(r)+1) END; stop := TRUE; e:= NIL ELSE submitMsg.name := ""; r.elem.handle(r.elem, submitMsg) END END END END; IF ~error THEN (* Open Url specfied in form-tag *) IF f.method = "POST" THEN NEW(body); COPY(f.encType, body.type); body.coding := ""; body.file := file; IF newViewer THEN Open result of submission in a new viewer ELSE Open result of submission in the active viewer END ELSE Files.Set(rid, file, 0); NEW(queryStr, Files.Length(file)+1); Files.ReadBytes(rid, queryStr^, Files.Length(file)); IF newViewer THEN Open result of submission in a new viewer ELSE Open result of submission in the active viewer END END END; newViewer := FALSE; Files.Close(file) END SubmitForm;878$Syntax10i.Scn.Fnt(* Is called by a reset-button between a beginning and an ending form-tag. All formular- elements that also belong to this formular are set to their default-values *)@8  8R   a&;  2.S0:    / 8  8 (!8Syntax10.Scn.Fnt   BEGIN Elems.Done := TRUE; IF m.id = Elems.enum THEN Elems.GetString(e, "Type", type); IF type = "SubmitButton" THEN m.enum("Name", Elems.String) END; m.enum("Value", Elems.String) ELSE ButtonElems.Handle(e, m) END END HandleAttrButton;8 8#Syntax10.Scn.Fnt HandleAttrButton(e, m)898Syntax10.Scn.Fnt  %")  Elems.GetString(e, "Type", type); IF (type = "SubmitButton") & (e = Elems.CmdElem) & (cmdElem = NIL) THEN Elems.GetString(e, "Name", m.name); Elems.GetString(e, "Value", m.value); IF m.name#"" THEN AppendEncoded(m.rider, m.name, m.value) END END88MSyntax10.Scn.Fnt  O Elems.GetString(e, "Value", value); Elems.SetString(e, "Caption", value); e.W := DUnit * LONG(Strings.Length(value)) * xDim + DUnit * 10; e.H := DUnit * yDim + DUnit * 58`8Syntax10.Scn.Fnt   Elems.GetString(e, "Type", type); IF type = "SubmitButton" THEN m.name := "" ELSIF type = "ResetButton" THEN m.name := "" ELSE m.name := "No FormElems.Button" END888Syntax10.Scn.Fnt    1 m.mod := "FormElems"; m.proc := "AllocButton"8;8 J8Syntax10.Scn.Fnt  BEGIN Elems.Done := TRUE; IF m.id = Elems.enum THEN m.enum("Name", Elems.String); m.enum("Size", Elems.Int); m.enum("MaxLen", Elems.Int); m.enum("DefaultValue", Elems.String) ELSE TextFieldElems.Handle(e, m) END END HandleAttrTextField; 8 S8Syntax10.Scn.Fnt /8FoldElemsNewwSyntax10.Scn.Fnt% 1 NEW(inp); Elems.GetInteger(e, "Size", inp.size); IF inp.size <= 0 THEN inp.size := 20; Elems.SetInteger(e, "Size", inp.size) END; e.W := DUnit * xDim * inp.size + DUnit * 10 8G8?Syntax10.Scn.Fnt!6{ Elems.GetString(e, "Name", m.name); Elems.GetString(e, "Value", m.value); AppendEncoded(m.rider, m.name, m.value)88MSyntax10.Scn.Fnt$j NEW(inp); Elems.GetString(e, "DefaultValue", inp.value); Elems.SetString(e, "Value", inp.value); Texts.ChangeLooks(e.txt, 0, e.txt.len, {0}, HTML.fixedFont, 0, 0); Elems.UpdateElem(e)88*Syntax10.Scn.Fnt% m.name := ""888Syntax10.Scn.Fnt   4 m.mod := "FormElems"; m.proc := "AllocTextField"8"- VAR inp : InputTag; BEGIN WITH e : TextFieldElems.Elem DO WITH m : AttrMsg DO HandleAttrTextField(e, m) | m: UpdateMsg DO  | m: SubmitMsg DO  | m: ResetMsg DO  | m: TagMsg DO  | m: Texts.IdentifyMsg DO  ELSE TextFieldElems.Handle(e, m) END END END HandleTextField; 8  8 Syntax10.Scn.FntD   8FoldElemsNewISyntax10.Scn.Fnt  I   VAR r : Texts.Reader; ch : CHAR; i, len : INTEGER; BEGIN len := SHORT(LEN(str)); i := 0; Texts.OpenReader(r, t, 0); Texts.Read(r, ch); WHILE ~r.eot & (i < len-1) DO WHILE ~r.eot & (ch = Texts.ElemChar) DO Texts.Read(r, ch) END; IF ~r.eot THEN str[i] := ch; INC(i); IF (ch=Elems.CR) & (i sel.noOfOptions THEN sel.vertSize := sel.noOfOptions END; IF sel.vertSize < 1 THEN sel.vertSize := 1 END; Elems.SetInteger(e, "Size", sel.vertSize); IF sel.vertSize = 1 THEN Elems.SetBoolean(e, "Multi", FALSE); Elems.GetText(e, "ValueT", optT); Texts.ChangeLooks(optT, 0, optT.len, {1}, NIL, 15, 0); Elems.GetText(e, "Keywords", keyT); Texts.ChangeLooks(keyT, 0, keyT.len, {1}, NIL, 15, 0); END; Elems.SetBoolean(e, "Popup", sel.vertSize = 1); Elems.SetBoolean(e, "Combo", FALSE); Elems.SetBoolean(e, "Scrollbar", sel.vertSize < sel.noOfOptions); e.H := DUnit * yDim * sel.vertSize + DUnit * 10; e.W := DUnit * xDim * sel.horizSize + DUnit * 10; IF (sel.vertSize=1) OR (sel.vertSize < sel.noOfOptions) THEN e.W := e.W + DUnit * 18 END END UpdateList; 8 $&8-Syntax10.Scn.Fnt &    BEGIN Elems.Done := TRUE; IF m.id = Elems.enum THEN m.enum("Name", Elems.String); m.enum("Size", Elems.Int); m.enum("Multi", Elems.Bool); m.enum("ValueT", Elems.Text); Elems.GetBoolean(e, "Popup", popup); m.enum("Keywords", Elems.Text); IF popup THEN m.enum("DefaultValue", Elems.String) ELSE m.enum("DefaultValueT", Elems.Text) END ELSE ListElems.Handle(e, m) END END HandleAttrList;8 *#N8Syntax10.Scn.Fnt"Syntax10i.Scn.Fnt)  & $%0x Elems.GetString(e, "Name", m.name); Elems.GetBoolean(e, "Popup", popup); Elems.GetText(e, "ValueT", optT); Elems.GetString(e, "Value", defaultValue); (* selected text in case of popup list *) Elems.GetText(e, "Keywords", keyT); (* textlines to be sent if selected *) keyPos := 0; optPos := 0; eoKeyT := ~TextLineToString(keyT, keyPos, key, col); eot := ~TextLineToString(optT, optPos, m.value, col); WHILE ~eot DO IF (popup & (m.value = defaultValue)) OR (~popup & (col = ListElems.SelCol)) THEN AppendEncoded(m.rider, m.name, key) END; eoKeyT := ~TextLineToString(keyT, keyPos, key, col); eot := ~TextLineToString(optT, optPos, m.value, col); END8Q8Syntax10.Scn.Fnt ( Elems.GetBoolean(e, "Popup", popup); IF popup THEN Elems.GetString(e, "DefaultValue", defaultValue); Elems.SetString(e, "Value", defaultValue) ELSE Elems.GetText(e, "DefaultValueT", optT); Elems.SetText(e, "ValueT", Elems.CopyText(optT)) END;8&(      VAR popup, eot, eoKeyT : BOOLEAN; optT, keyT : Texts.Text; key, defaultValue : ARRAY 1024 OF CHAR; optPos, keyPos : LONGINT; col : SHORTINT; (* Updates List --> Called if Handler gets UpdateMsg *) PROCEDURE UpdateList (e : ListElems.Elem);  PROCEDURE HandleAttrList(e : ListElems.Elem; VAR m : AttrMsg); BEGIN WITH e : ListElems.Elem DO WITH m : AttrMsg DO HandleAttrList(e, m) | m: UpdateMsg DO UpdateList(e) | m: SubmitMsg DO  | m: ResetMsg DO  Elems.UpdateElem(e) | m: TagMsg DO m.name := "" | m: Texts.IdentifyMsg DO m.mod := "FormElems"; m.proc := "AllocList" ELSE ListElems.Handle(e, m) END END END HandleList; 8  >8Syntax10.Scn.Fnt'  8FoldElemsNew1Syntax10.Scn.Fnt' m.name := "
...
";88Syntax10.Scn.Fnt"QSyntax10i.Scn.FntST WebElems.HandleLink(e, m); IF m.id = Texts.load THEN IF e.side = WebElems.LeftSide THEN Files.ReadString(m.r, e.method); Files.ReadString(m.r, e.encType) END ELSE (* Texts.store *) IF e.side = WebElems.LeftSide THEN Files.WriteString(m.r, e.method); Files.WriteString(m.r, e.encType) END END848Syntax10.Scn.Fnt #   IF m.e = NIL THEN NEW(e1); m.e := e1 ELSE e1 := m.e(FormElem) END; WebElems.HandleLink(e, m); IF e1.side = WebElems.LeftSide THEN COPY(e.method, e1.method); COPY(e.encType, e1.encType); ELSE e1.method := ""; e1.encType := "" END888Syntax10.Scn.Fnt    / m.mod := "FormElems"; m.proc := "AllocForm"88Syntax10.Scn.Fnt   } IF m.prepare THEN IF e.visible THEN e.W := formW ELSE e.W := invisW END ELSIF e.visible THEN GetDsr(m.frame, m.pos, m.fnt, dsr); Display.CopyPattern(formCol, fIcon[e.side], m.X0, m.Y0+dsr, Display.replace) END8t8TSyntax10.Scn.Fnt 9 IF m.prepare THEN e.W := invisW ELSE e.W := formW END88Syntax10.Scn.Fnt 4 IF middle IN m.keys THEN IF m.frame # NIL THEN GetDsr(m.frame, m.pos, m.fnt, dsr); Display.CopyPattern(clickCol, fClickIcon[e.side], m.X0, m.Y0+dsr, Display.paint); WebElems.TrackAndPopup(e, m); Display.CopyPattern(formCol, fIcon[e.side], m.X0, m.Y0+dsr, Display.replace) END; IF m.keys # cancel THEN trackedMsg.keys := m.keys; e.handle(e, trackedMsg) END END8"8Syntax10.Scn.Fnt" I //H7 WebElems.HandleLink(e, m); IF e.side = WebElems.LeftSide THEN Texts.WriteString(w, e.method); Texts.WriteLn(w); Texts.WriteString(w, e.encType); Texts.WriteLn(w); Texts.Append(m.text, w.buf); IF m.edInfo # NIL THEN Texts.Delete(m.edInfo, 0, m.edInfo.len); Texts.WriteString(w, "action URL"); Texts.WriteLn(w); Texts.WriteString(w, "send method (POST or GET)"); Texts.WriteLn(w); Texts.WriteString(w, "encryption type"); Texts.WriteLn(w); Texts.Append(m.edInfo, w.buf); m.name := "FormElems.FormElem" END END8q8FSyntax10.Scn.Fnt#J IF m.keys = {middle, right} THEN WebElems.HandleLink(e, m); END8:8FSyntax10.Scn.Fnt": WebElems.HandleLink(e, m); IF e.side = WebElems.LeftSide THEN ReadLine(m, e.method); ReadLine(m, e.encType) END8   VAR e1: FormElem; dsr: INTEGER; trackedMsg : WebElems.TrackedMsg; BEGIN WITH e: FormElem DO WITH m: TagMsg DO  | m: Texts.FileMsg DO  | m: Texts.CopyMsg DO  | m: Texts.IdentifyMsg DO  | m: TextFrames.DisplayMsg DO  | m: TextPrinter.PrintMsg DO  | m: TextFrames.TrackMsg DO  | m: WebElems.ContentMsg DO  | m: WebElems.TrackedMsg DO  | m: WebElems.UpdateMsg DO  ELSE WebElems.HandleLink(e, m) END END END HandleForm; 8 p8 Syntax10.Scn.Fnt 8FoldElemsNew*Syntax10.Scn.Fnt' m.name := ""8]8FSyntax10.Scn.Fnt  =^ IF e.value # NIL THEN COPY(e.value^, m.value); AppendEncoded(m.rider, e.name, m.value) END88mSyntax10.Scn.FntfSyntax10i.Scn.FntI IF m.id = Texts.load THEN e.visible := e.W > invisW; Files.ReadString(m.r, e.name); LoadDynString(m.r, e.value) ELSE (* Texts.store *) Files.WriteString(m.r, e.name); StoreDynString(m.r, e.value) END88iSyntax10.Scn.Fnt 97 IF m.e = NIL THEN NEW(e1); m.e := e1 ELSE e1 := m.e(HiddenElem) END; Texts.CopyElem(e, e1); e1.visible := e.visible; COPY(e.name, e1.name); CopyDynString(e.value^, e1.value)888Syntax10.Scn.Fnt    1 m.mod := "FormElems"; m.proc := "AllocHidden"88Syntax10.Scn.Fnt   w IF m.prepare THEN IF e.visible THEN e.W := hiddenW ELSE e.W := invisW END ELSIF e.visible THEN GetDsr(m.frame, m.pos, m.fnt, dsr); Display.CopyPattern(hiddenCol, hIcon, m.X0, m.Y0+dsr, Display.replace) END8r8TSyntax10.Scn.Fnt ; IF m.prepare THEN e.W := invisW ELSE e.W := hiddenW END88Syntax10.Scn.Fnt  g IF middle IN m.keys THEN IF m.frame # NIL THEN GetDsr(m.frame, m.pos, m.fnt, dsr); Display.CopyPattern(clickCol, hClickIcon, m.X0, m.Y0+dsr, Display.paint); WebElems.TrackAndPopup(e, m); Display.CopyPattern(hiddenCol, hIcon, m.X0, m.Y0+dsr, Display.replace); END; IF ~(left IN m.keys) THEN WebElems.Handle(e, m) END; END88Syntax10.Scn.FntQ  7 .F WebElems.Handle(e, m); Texts.WriteString(w, e.name); Texts.WriteLn(w); IF e.value # NIL THEN Texts.WriteString(w, e.value^) END; Texts.WriteLn(w); Texts.Append(m.text, w.buf); IF m.edInfo # NIL THEN Texts.WriteString(w, "name"); Texts.WriteLn(w); Texts.WriteString(w, "value"); Texts.WriteLn(w); Texts.Append(m.edInfo, w.buf); m.name := "FormElems.HiddenElem" END86 VAR e1: HiddenElem; dsr: INTEGER; BEGIN WITH e: HiddenElem DO WITH m: TagMsg DO  | m: SubmitMsg DO  | m: Texts.FileMsg DO  | m: Texts.CopyMsg DO  | m: Texts.IdentifyMsg DO  | m: TextFrames.DisplayMsg DO  | m: TextPrinter.PrintMsg DO  | m: TextFrames.TrackMsg DO  | m: WebElems.ContentMsg DO  | m: WebElems.UpdateMsg DO ReadLine(m, e.name); ReadDynLine(m, e.value) ELSE END END END HandleHidden; 8 b85Syntax10.Scn.Fnt(  8FoldElemsNew#Syntax10.Scn.Fnt HandleAttrTextField(e, m)88iSyntax10.Scn.Fnt  !, Elems.GetInteger(e, "Size", size); IF size <= 0 THEN size := 20; Elems.SetInteger(e, "Size", size) END; e.W := DUnit * xDim * size + DUnit * 1088TSyntax10.Scn.Fnt91: txt := e.txt(TextFieldElems.PWText); pos := 0; IF TextLineToString(txt.hidden, pos, m.value, col) THEN Elems.GetString(e, "Name", m.name); AppendEncoded(m.rider, m.name, m.value) END88?Syntax10.Scn.Fnt f Elems.GetString(e, "DefaultValue", value); Elems.SetString(e, "Value", value); Texts.ChangeLooks(e.txt, 0, e.txt.len, {0}, HTML.fixedFont, 0, 0); Elems.UpdateElem(e)88*Syntax10.Scn.Fnt) m.name := ""888Syntax10.Scn.Fnt   3 m.mod := "FormElems"; m.proc := "AllocPassWord"8$j VAR txt : TextFieldElems.PWText; col : SHORTINT; value : ARRAY vLen OF CHAR; size, pos : LONGINT; BEGIN WITH e : TextFieldElems.PWElem DO WITH m : AttrMsg DO  | m: UpdateMsg DO  | m: SubmitMsg DO  | m: ResetMsg DO  | m: TagMsg DO  | m : Texts.IdentifyMsg DO  ELSE TextFieldElems.HandlePW(e, m) END END END HandlePassWord; 8  8 Syntax10.Scn.FntR8FoldElemsNew Syntax10.Scn.Fnt   V  t IF e.x # undef THEN COPY(e.alt, m.name); IF m.name="" THEN m.name := "x" ELSE Strings.Append(".x", m.name) END; Web.Int2Str(e.x, m.value); AppendEncoded(m.rider, m.name, m.value); COPY(e.alt, m.name); IF m.name="" THEN m.name := "y" ELSE Strings.Append(".y", m.name) END; Web.Int2Str(e.y, m.value); AppendEncoded(m.rider, m.name, m.value); e.y := undef; e.x := undef END88*Syntax10.Scn.Fnt& m.name := ""88*Syntax10.Scn.FntJO WebElems.HandleImage(e, m); e.x := undef; e.y := undef; e.isMap := FALSE8 8[Syntax10.Scn.Fnt @ IF m.e = NIL THEN NEW(e1); m.e := e1 ELSE e1 := m.e(ImageElem) END; WebElems.HandleImage(e, m); e1.x := undef; e1.y := undef888Syntax10.Scn.Fnt    0 m.mod := "FormElems"; m.proc := "AllocImage"8L8~Syntax10.Scn.Fnt$ G .F7 e.isMap := FALSE; WebElems.HandleImage(e, m); IF m.edInfo # NIL THEN Texts.Delete(m.edInfo, 0, m.edInfo.len); Texts.WriteString(w, "source URL"); Texts.WriteLn(w); Texts.WriteString(w, "name"); Texts.WriteLn(w); Texts.Append(m.edInfo, w.buf); m.name := "FormElems.ImageElem" END8. 8Syntax10.Scn.Fnt /!RA IF (middle IN m.keys) & (m.keys # cancel) THEN newViewer := m.keys = {middle, left}; IF m.keys = {middle, right} THEN WebElems.HandleImage(e, m); ELSIF (m.keys = {middle, left}) OR (m.keys = {middle}) THEN e.x := m.x; e.y := m.y; cmdElem := e; SubmitForm; cmdElem := NIL END END8"  VAR e1: ImageElem; BEGIN WITH e : ImageElem DO WITH m: SubmitMsg DO  | m: TagMsg DO  | m : Texts.FileMsg DO  | m: Texts.CopyMsg DO  | m : Texts.IdentifyMsg DO  | m: WebElems.ContentMsg DO  | m: WebElems.UpdateMsg DO WebElems.HandleImage(e, m); e.isMap := FALSE | m : WebElems.TrackedMsg DO  ELSE WebElems.HandleImage(e, m) END END END HandleImage;8F  p8Syntax10.Scn.Fnt; BEGIN inp.type := "noType"; inp.value := ""; inp.dynValue := NIL; inp.myValue := ""; inp.name := ""; inp.src := NIL; inp.maxLen:= undef; inp.size := undef; inp.checked := FALSE; inp.selected :=FALSE END InitInput; 8 8Syntax10.Scn.FntW%% BEGIN sel.name := ""; sel.vertSize := undef; sel.horizSize := undef; sel.noOfOptions := 0; sel.done := FALSE; sel.defaultSel := ""; sel.optionText := TextFrames.Text(""); sel.valueText := TextFrames.Text("") END InitSelection; 8  e8[Syntax10.Scn.Fnt A BEGIN opt.value := NIL; opt.selected := FALSE END InitOption; 8 8MSyntax10.Scn.Fnt ' BEGIN ta.name := "" END InitTextArea;8  M8[Syntax10.Scn.Fnt, Y VAR e: FormElem; BEGIN NEW(e); e.handle := HandleForm; Texts.new := e END AllocForm; 8  G8[Syntax10.Scn.Fnt._ VAR e: HiddenElem; BEGIN NEW(e); e.handle := HandleHidden; Texts.new := e END AllocHidden; 8  I8[Syntax10.Scn.Fnt. ] VAR e: ImageElem; BEGIN NEW(e); e.handle := HandleImage; Texts.new := e END AllocImage; 8  %8[Syntax10.Scn.Fnt, VAR e : Texts.Elem; BEGIN e := Elems.CreateElem("ButtonElems.New"); e.handle := HandleButton; Texts.new := e END AllocButton; 8 8[Syntax10.Scn.Fnt/ VAR e : Texts.Elem; BEGIN e := Elems.CreateElem ("TextFieldElems.New"); e.handle := HandleTextField; Texts.new := e END AllocTextField; 8 8[Syntax10.Scn.Fnt. VAR e : Texts.Elem; BEGIN e := Elems.CreateElem ("TextAreaElems.New"); e.handle := HandleTextArea; Texts.new := e END AllocTextArea; 8 8[Syntax10.Scn.Fnt. VAR e : Texts.Elem; BEGIN e := Elems.CreateElem ("CheckBoxElems.New"); e.handle := HandleCheckBox; Texts.new := e END AllocCheckBox; 8 8[Syntax10.Scn.Fnt1 VAR e : Texts.Elem; BEGIN e := Elems.CreateElem ("RadioButtonElems.New"); e.handle := HandleRadioButton; Texts.new := e END AllocRadioButton; 8 8[Syntax10.Scn.Fnt. VAR e : Texts.Elem; BEGIN e := Elems.CreateElem ("TextFieldElems.NewPW"); e.handle := HandlePassWord; Texts.new := e END AllocPassWord; 8  +8[Syntax10.Scn.Fnt* { VAR e : Texts.Elem; BEGIN e := Elems.CreateElem ("ListElems.New"); e.handle := HandleList; Texts.new := e END AllocList;8I     f8Syntax10.Scn.FntR  VAR e: FormElem; BEGIN NEW(e); WebElems.InitLink(e, side, visible); e.H := elemH; e.handle := HandleForm; IF visible THEN e.W := formW ELSE e.W := invisW END; e.method := ""; e.encType := ""; RETURN e END NewForm; 8  8Syntax10.Scn.FntD  VAR e: HiddenElem; BEGIN NEW(e); e.H := elemH; e.handle := HandleHidden; e.visible := visible; IF visible THEN e.W := hiddenW ELSE e.W := invisW END; RETURN e END NewNakedHidden; 8  8Syntax10.Scn.Fnt   #/  VAR e : HiddenElem; BEGIN IF inp.name = "" THEN Web.LogStr("Hidden: No NAME specified!$") END; IF inp.dynValue = NIL THEN Web.LogStr("Hidden: No VALUE specified!$") END; e := NewNakedHidden(visible); COPY(inp.name, e.name); e.value := inp.dynValue; RETURN e END NewHidden; 8  8wSyntax10.Scn.Fnt\ VAR e: ImageElem; BEGIN NEW(e); WebElems.InitImage(e); e.x := undef; e.y := undef; e.handle := HandleImage; e.isMap := TRUE; RETURN e END NewImage; 8 &8-Syntax10.Scn.Fnt 3!" "N< VAR e : Texts.Elem; BEGIN IF inp.value = "" THEN inp.value := "Submit Query" END; e := Elems.CreateElem("ButtonElems.New"); e.handle := HandleButton; Elems.SetString(e, "Type", "SubmitButton"); Elems.SetString(e, "Name", inp.name); Elems.SetString(e, "Value", inp.value); Elems.SetString(e, "Caption", inp.value); Elems.SetString(e, "Cmd", "FormElems.SubmitForm"); Elems.SetBoolean(e, "Locked", TRUE); e.W := DUnit * xDim * LONG(Strings.Length(inp.value)) + DUnit * 10; e.H := DUnit * yDim + DUnit * 5; RETURN e(ButtonElems.Elem); END NewSubmitButton; 8 &8Syntax10.Scn.Fnt 3  ""N  VAR e : Texts.Elem; BEGIN IF inp.value = "" THEN inp.value := "Reset" END; e := Elems.CreateElem ("ButtonElems.New"); e.handle := HandleButton; Elems.SetString(e, "Type", "ResetButton"); Elems.SetString(e, "Caption", inp.value); Elems.SetString(e, "Value", inp.value); Elems.SetString(e, "Cmd", "FormElems.ResetForm"); Elems.SetBoolean(e, "Locked", TRUE); e.W := DUnit * xDim * LONG(Strings.Length(inp.value)) + DUnit * 10; e.H := DUnit * yDim + DUnit * 5; RETURN e(ButtonElems.Elem) END NewResetButton; 8 )z8^Syntax10.Scn.Fnt  6 !!!#W) VAR e : Texts.Elem; BEGIN IF inp.name = "" THEN Web.LogStr("TextField: No NAME specified$") END; e := Elems.CreateElem ("TextFieldElems.New"); e.handle := HandleTextField; Elems.SetString(e, "Caption", inp.name); Elems.SetString(e, "Name", inp.name); Elems.SetString(e, "Cmd", "FormElems.SubmitForm"); Elems.SetInteger(e, "MaxLen", inp.maxLen); IF inp.size=undef THEN inp.size := 20 END; Elems.SetInteger(e, "Size", inp.size); Elems.SetString(e, "Value", inp.value); Texts.ChangeLooks(e(TextFieldElems.Elem).txt, 0, e(TextFieldElems.Elem).txt.len, {0}, HTML.fixedFont, 0, 0); Elems.SetString(e, "DefaultValue", inp.value); Elems.SetBoolean(e, "Locked", TRUE); e.W := DUnit * xDim * inp.size + DUnit * 10; e.H := DUnit * yDim + DUnit * 5; RETURN e(TextFieldElems.Elem) END NewTextField; 8  ;M8&Syntax10.Scn.Fnt'  4!!3v VAR txt : Texts.Text; e : Texts.Elem; BEGIN IF ta.name = "" THEN Web.LogStr("TextArea: No NAME specified$") END; e := Elems.CreateElem ("TextAreaElems.New"); e.handle := HandleTextArea; Elems.SetString(e, "Name", ta.name); Elems.SetBoolean(e, "Locked", TRUE); Elems.SetInteger(e, "Rows", ta.rows); Elems.SetInteger(e, "Cols", ta.cols); NEW(txt); txt := TextFrames.Text(""); Texts.Insert(txt, 0, buf); Elems.SetText(e, "ValueT", txt); Elems.SetText(e, "DefaultValueT", Elems.CopyText(txt)); e.H := DUnit * yDim * ta.rows + DUnit * 8; e.W := DUnit * xDim * ta.cols + DUnit * 28; RETURN e(TextAreaElems.Elem) END NewTextArea; 8  (P8Syntax10.Scn.Fnt  5! #% VAR e : Texts.Elem; BEGIN IF inp.name = "" THEN Web.LogStr("CheckBox: No NAME specified$") END; e := Elems.CreateElem ("CheckBoxElems.New"); e.handle := HandleCheckBox; Elems.SetBoolean(e, "Locked", TRUE); Elems.SetString(e, "Name", inp.name); Elems.SetString(e, "ValueStr", inp.value); Elems.SetBoolean(e, "Value", inp.checked); Elems.SetBoolean(e, "DefaultValue", inp.checked); RETURN e(CheckBoxElems.Elem) END NewCheckBox; 8 +8Syntax10.Scn.Fnt  !  "8!  #V VAR e : Texts.Elem; BEGIN IF inp.name = "" THEN Web.LogStr("RadioButton: No NAME specified$") END; IF inp.value = "" THEN Web.LogStr("RadioButton: No VALUE specified$") END; e := Elems.CreateElem ("RadioButtonElems.New"); e.handle := HandleRadioButton; Elems.SetBoolean(e, "Locked", TRUE); Elems.SetString(e, "Name", inp.name); Elems.SetString(e, "MyValue", inp.value); IF inp.checked THEN Elems.SetString(e, "Value", inp.value); Elems.SetString(e, "DefaultValue", inp.value) ELSE Elems.SetString(e, "DefaultValue", ""); END; RETURN e(RadioButtonElems.Elem) END NewRadioButton; 8  +28~Syntax10.Scn.Fnt2  6 !!Syntax10i.Scn.Fnt!"#Q VAR e : Texts.Elem; pwElem : TextFieldElems.PWElem; BEGIN IF inp.name = "" THEN Web.LogStr("PassWord: No NAME specified$") END; e := Elems.CreateElem ("TextFieldElems.NewPW"); e.handle := HandlePassWord; Elems.SetString(e, "Caption", inp.name); Elems.SetString(e, "Name", inp.name); Elems.SetString(e, "Cmd", "FormElems.SubmitForm"); Elems.SetInteger(e, "MaxLen", inp.maxLen); IF inp.size=undef THEN inp.size := 20 END; (* Defaultsize *) Elems.SetInteger(e, "Size", inp.size); Elems.SetString(e, "Value", inp.value); Elems.SetString(e, "DefaultValue", inp.value); Elems.SetBoolean(e, "Locked", TRUE); e.W := DUnit * xDim * inp.size + DUnit * 10; e.H := DUnit * yDim + DUnit * 5; pwElem := e(TextFieldElems.PWElem); Texts.ChangeLooks(pwElem.txt, 0, pwElem.txt.len, {0}, HTML.fixedFont, 0, 0); RETURN pwElem END NewPassWord; 8)  8YSyntax10.Scn.FntSyntax10i.Scn.Fnt)+/?8FoldElemsNew1Syntax10.Scn.Fnt(=(sel.vertSize > 1) OR ((sel.vertSize = undef) & sel.multiple)83<5+*q' '>(F  BEGIN INC(sel.noOfOptions); (* adjust horizontal size of selection *) IF sel.horizSize < Strings.Length(opt.text^) THEN sel.horizSize := Strings.Length(opt.text^) END; (* decide whether to create a popup-list or a selection-list *) IF selection is marked by color THEN IF opt.selected & ~sel.done THEN Texts.SetColor(options, ListElems.SelCol); COPY(opt.text^, sel.defaultSel); sel.done := ~sel.multiple ELSE Texts.SetColor(options, ListElems.DefaultCol) END ELSIF opt.selected & ~sel.done THEN COPY(opt.text^, sel.defaultSel); sel.done := TRUE END; (* Add to optionText = displayed values *) Texts.WriteString(options, opt.text^); Texts.WriteLn(options); Texts.Append(sel.optionText, options.buf); (* Add to valueText = keyword values *) IF opt.value=NIL THEN Texts.WriteString(options, opt.text^) (* no value given -> keyword is the same as displayed value *) ELSE Texts.WriteString(options, opt.value^) END; Texts.WriteLn(options); Texts.Append(sel.valueText, options.buf) END AddOption; 8  $z8Syntax10.Scn.Fnt    &2%5 '& %Syntax10i.Scn.Fnt% $8D'|"  VAR e : Texts.Elem; col : SHORTINT; eot : BOOLEAN; pos : LONGINT; BEGIN IF sel.name = "" THEN Web.LogStr("List (SELECTION): No NAME specified$") END; e := Elems.CreateElem ("ListElems.New"); e.handle := HandleList; Elems.SetString(e, "Name", sel.name); Elems.SetText(e, "ValueT", sel.optionText); Elems.SetText(e, "DefaultValueT", Elems.CopyText(sel.optionText)); Elems.SetText(e, "Keywords", sel.valueText); Elems.SetBoolean(e, "Locked", TRUE); Elems.SetBoolean(e, "Combo", FALSE); Elems.SetBoolean(e, "Multi", sel.multiple); Elems.SetBoolean(e, "Scrollbar", sel.vertSize < sel.noOfOptions); (* Calculate vertical size of list *) IF sel.vertSize = undef THEN IF sel.multiple THEN sel.vertSize := 5 ELSE sel.vertSize := 1 END ELSIF sel.vertSize > sel.noOfOptions THEN sel.vertSize := sel.noOfOptions END; Elems.SetInteger(e, "Size", sel.vertSize); IF sel.vertSize = 1 THEN Elems.SetBoolean(e, "Popup", TRUE) END; (* necessary if selection is or will get a popup-list *) IF sel.defaultSel="" THEN eot := ~TextLineToString(sel.optionText, pos, sel.defaultSel, col) END; Elems.SetString(e, "Value", sel.defaultSel); Elems.SetString(e, "DefaultValue", sel.defaultSel); e.H := DUnit * yDim * sel.vertSize + DUnit * 10; e.W := DUnit * xDim * sel.horizSize + DUnit * 10; IF (sel.vertSize=1) OR (sel.vertSize < sel.noOfOptions) THEN e.W := e.W + DUnit * 18 END; RETURN e(ListElems.Elem) END NewList;8*   8Syntax10.Scn.Fnt4+ $   9  VAR e: FormElem; t: Texts.Text; r: Texts.Reader; ch: CHAR; beg, end, time: LONGINT; BEGIN Oberon.GetSelection(t, beg, end, time); IF (time >= 0) & (t IS Texts.Text) THEN e := NewForm(WebElems.RightSide, TRUE); Texts.OpenReader(r, t, end - 1); Texts.Read(r, ch); Texts.SetFont(w, r.fnt); Texts.WriteElem(w, e); Texts.Insert(t, end, w.buf); e := NewForm(WebElems.LeftSide, TRUE); NEW(e.url, 12); COPY("ACTION(URL)", e.url^); COPY("METHOD", e.method); COPY("ENCTYPE (default = 'application/x-www-form-urlencoded')", e.encType); Texts.OpenReader(r, t, beg); Texts.Read(r, ch); Texts.SetFont(w, r.fnt); Texts.WriteElem(w, e); Texts.Insert(t, beg, w.buf); Texts.SetFont(w, Fonts.Default) END END InsertForm; 8 8Syntax10.Scn.Fnt 1 VAR m: TextFrames.InsertElemMsg; BEGIN m.e := NewNakedHidden(TRUE); COPY("NAME", m.e(HiddenElem).name); NEW(m.e(HiddenElem).value, 6); COPY("VALUE", m.e(HiddenElem).value^); Viewers.Broadcast(m) END InsertHidden; 8  P8MSyntax10.Scn.Fnt *d VAR m: TextFrames.InsertElemMsg; BEGIN m.e := NewImage(); Viewers.Broadcast(m) END InsertImage; 8 8wSyntax10.Scn.Fnt16 VAR m: TextFrames.InsertElemMsg; inp : InputTag; BEGIN NEW(inp); inp.name := "SubmitButton"; inp.value := ""; m.e := NewSubmitButton(inp); Viewers.Broadcast(m) END InsertSubmitButton; 8 8wSyntax10.Scn.Fnt0 5 VAR m: TextFrames.InsertElemMsg; inp : InputTag; BEGIN NEW(inp); inp.name := "ResetButton"; inp.value := ""; m.e := NewResetButton(inp); Viewers.Broadcast(m) END InsertResetButton; 8 8wSyntax10.Scn.Fnt0 F VAR m: TextFrames.InsertElemMsg; inp : InputTag; BEGIN NEW(inp); inp.value := ""; inp.name := "TextField"; inp.size := undef; m.e := NewTextField(inp); Viewers.Broadcast(m) END InsertTextField; 8 8Syntax10.Scn.Fnt3: $ VAR m : TextFrames.InsertElemMsg; txt : Texts.Text; BEGIN m.e := Elems.CreateElem ("TextAreaElems.New"); m.e.handle := HandleTextArea; Elems.SetString(m.e, "Name", "TextArea"); Elems.SetBoolean(m.e, "Locked", TRUE); Elems.SetInteger(m.e, "Rows", 4); Elems.SetInteger(m.e, "Cols", 15); txt := TextFrames.Text(""); Elems.SetText(m.e, "ValueT", txt); Elems.SetText(m.e, "DefaultValueT", Elems.CopyText(txt)); m.e.H := DUnit * yDim * 4 + DUnit * 8; m.e.W := DUnit * xDim * 15 + DUnit * 28; Viewers.Broadcast(m) END InsertTextArea; 8 8Syntax10.Scn.Fnt0 2 VAR m: TextFrames.InsertElemMsg; inp : InputTag; BEGIN NEW(inp); inp.name := "CheckBox"; inp.value := "Value"; inp.checked := FALSE; m.e := NewCheckBox(inp); Viewers.Broadcast(m) END InsertCheckBox; 8 |8Syntax10.Scn.Fnt0  5  VAR m: TextFrames.InsertElemMsg; inp : InputTag; BEGIN NEW(inp); inp.name := "RadioButton"; inp.value := "MyValue"; m.e := NewRadioButton(inp); Elems.SetString(m.e, "Value", "Group value"); Viewers.Broadcast(m) END InsertRadioButton; 8 8wSyntax10.Scn.Fnt0 E VAR m: TextFrames.InsertElemMsg; inp : InputTag; BEGIN NEW(inp); inp.name := "PassWord"; inp.value := ""; inp.size := undef; m.e := NewPassWord(inp); Viewers.Broadcast(m) END InsertPassWord; 8  w8iSyntax10.Scn.Fnt1'  ! VAR m: TextFrames.InsertElemMsg; sel : Selection; BEGIN NEW(sel); InitSelection(sel); sel.name := "Selection"; m.e := NewList(sel); m.e.H := DUnit * yDim * 5 + DUnit * 10; m.e.W := DUnit * xDim * 7 + DUnit * 10; m.e.W := m.e.W + DUnit * 18; Viewers.Broadcast(m) END InsertList;8a8$Syntax10i.Scn.Fnt||(* Sets the global variables xDim and yDim which stand for the width and the height of any character of the font "fnt". *)8 8ISyntax10.Scn.Fnt/8 VAR dx, x, y, w, h: INTEGER; p : Display.Pattern; aboveBase, belowBase: INTEGER; BEGIN xDim := 9; yDim := 17; Display.GetChar(fnt.raster, 'X', dx, x, y, w, h, p); xDim := LONG(dx); yDim := LONG(h); belowBase := - SHORT(TextFrames.defParc.dsr DIV pixel); aboveBase := SHORT(TextFrames.defParc.lsp DIV pixel) + belowBase; IF belowBase > y THEN belowBase := y END; IF aboveBase < h + y THEN aboveBase := h + y END; IF yDim < aboveBase - belowBase THEN yDim := aboveBase - belowBase END END SetDimensions;84  8Syntax10.Scn.Fnt Syntax10i.Scn.Fnt !! ~ VAR line : ARRAY 9 OF SET; BEGIN (* Hidden icon *) line[8] := {2..8}; line[7] := {1, 9}; line[6] := {1, 3, 4, 6, 7, 9}; line[5] := {1, 3..7, 9}; line[4] := {1, 3..7, 9}; line[3] := {1, 3, 4, 6, 7, 9}; line[2] := {1, 9}; line[1] := {2..8}; hIcon:= Display.NewPattern(line, 11, 8); line[8] := {}; line[7] := {}; line[6] := {3, 4, 6, 7}; line[5] := {3..7}; line[4] := {3..7}; line[3] := {3, 4, 6, 7}; line[2] := {}; line[1] := {}; hClickIcon := Display.NewPattern(line, 11, 8); (* FormElem left icon *) line[8] := {4, 5, 7..11}; line[7] := {3, 4, 7..11}; line[6] := {2, 3, 7, 8}; line[5] := {1, 2, 7..10}; line[4] := {1, 2, 7..10}; line[3] := {2, 3, 7, 8}; line[2] := {3, 4, 7, 8}; line[1] := {4, 5, 7, 8}; fIcon[WebElems.LeftSide] := Display.NewPattern(line, 14, 8); (* FormElem clicked left icon *) line[8] := {7..11}; line[7] := {7..11}; line[6] := {7, 8}; line[5] := {7..10}; line[4] := {7..10}; line[3] := {7, 8}; line[2] := {7, 8}; line[1] := {7, 8}; fClickIcon[WebElems.LeftSide] := Display.NewPattern(line, 14, 8); (* FormElem right icon *) line[8] := {3..7, 9, 10}; line[7] := {3..7, 10, 11}; line[6] := {3, 4, 11, 12}; line[5] := {3..6, 12, 13}; line[4] := {3..6, 12, 13}; line[3] := {3, 4, 11, 12}; line[2] := {3, 4, 10, 11}; line[1] := {3, 4, 9, 10}; fIcon[WebElems.RightSide] := Display.NewPattern(line, 14, 8); (* FormElem clicked right icon *) line[8] := {3..7}; line[7] := {3..7}; line[6] := {3, 4}; line[5] := {3..6}; line[4] := {3..6}; line[3] := {3, 4}; line[2] := {3, 4}; line[1] := {3, 4}; fClickIcon[WebElems.RightSide] := Display.NewPattern(line, 14, 8) END InitIcons;8C MODULE FormElems; (** SA  *)  IMPORT  CONST  TYPE  VAR  firstTime, (* TRUE when AppendEncoded is called from SubmitForm the first time *) newViewer : BOOLEAN; (* TRUE when ruibmission-result should appear in a new Viewer *) xDim, yDim : LONGINT; PROCEDURE ^ HandleForm* (e : Texts.Elem; VAR m : Texts.ElemMsg); (* Returns corresponding FormElem for "e" *) PROCEDURE (e: FormElem) Twin* () : WebElems.LinkElem;  PROCEDURE GetDsr (f: Display.Frame; pos: LONGINT; fnt: Fonts.Font; VAR dsr: INTEGER);  (* Help procedures for dynamic strings *) PROCEDURE CopyDynString (src : ARRAY OF CHAR; VAR dest : Web.DynamicString);  PROCEDURE LoadDynString (VAR r : Files.Rider; VAR str : Web.DynamicString);  PROCEDURE StoreDynString (VAR r : Files.Rider; str : Web.DynamicString);  PROCEDURE ReadLine (VAR msg : WebElems.UpdateMsg; VAR str : ARRAY OF CHAR);  PROCEDURE ReadDynLine (VAR msg : WebElems.UpdateMsg; VAR str : Web.DynamicString);  (* Help-procedures for Texts *) PROCEDURE TextLineToString*(t : Texts.Text; VAR pos : LONGINT; VAR s : ARRAY OF CHAR; VAR col : SHORTINT) : BOOLEAN; PROCEDURE TextLineToDynString*(t : Texts.Text; VAR pos : LONGINT; VAR s : Web.DynamicString; VAR col : SHORTINT) : BOOLEAN; PROCEDURE TextSizes*(t : Texts.Text; VAR cols, rows : LONGINT);  (* Encode name and value with Web.EncodeStr ("+" & SPACE are extra-encoded) Then append encoded strings to the Files.Rider "rid" --> ...&name=value *) PROCEDURE AppendEncoded* (VAR rid : Files.Rider; name, value : ARRAY OF CHAR);  Submit all form-elems between a beginning and an ending form-tag. PROCEDURE SubmitForm*;  Reset all form-elems between a beginning and an ending form-tag. PROCEDURE ResetForm*;  VAR e : Texts.Elem; pos : LONGINT; r : Texts.Reader; error, (* TRUE when the reset-button is not between a beginning and an ending form-tag *) stop : BOOLEAN; resetMsg : ResetMsg; BEGIN error := FALSE; stop := FALSE; e := Elems.CmdElem; pos := Texts.ElemPos(e); Texts.OpenReader(r, Texts.ElemBase(e), pos); (* Parse back to previous "FormTag" *) WHILE ~r.eot & ~stop DO (*Texts.*) TableTools.ReadPrevElem(r); e := r.elem; WITH e : FormElem DO IF e.side = WebElems.LeftSide THEN stop := TRUE END ELSE END END; IF ~stop OR error THEN Web.LogF("ResetForm: Beginning Form-Tag expected! (pos #)$", Texts.Pos(r)) ELSE Web.NeutralizeText(Texts.ElemBase(e)); (* Parse forward to ending "FormTag" and set formular-elements to default-values *) (*Texts.*) TableTools.ReadElem(r); stop := FALSE; WHILE ~r.eot & ~stop DO (*Texts.*) TableTools.ReadElem(r); e := r.elem; IF (e#NIL) THEN WITH e : FormElem DO IF e.side = WebElems.LeftSide THEN error := TRUE END; stop := TRUE ELSE e.handle(e, resetMsg) END ELSE END END END; IF error THEN Web.LogF("ResetForm: Ending Form-Tag expected! (pos #)$", Texts.Pos(r)) END END ResetForm; (* Handlers for all FormElems *) PROCEDURE HandleButton* (e: Texts.Elem; VAR m: Texts.ElemMsg);  VAR type, value : ARRAY vLen OF CHAR; PROCEDURE HandleAttrButton(e : ButtonElems.Elem; VAR m : AttrMsg); BEGIN WITH e : ButtonElems.Elem DO WITH m : AttrMsg DO  | m: SubmitMsg DO  | m: UpdateMsg DO  | m: TagMsg DO  | m: Texts.IdentifyMsg DO  | m : Elems.ExecMsg DO newViewer := m.unload; ButtonElems.Handle(e, m) ELSE ButtonElems.Handle(e, m) END END END HandleButton;  PROCEDURE HandleAttrTextField* (e : TextFieldElems.Elem; VAR m : AttrMsg);  PROCEDURE HandleTextField* (e: Texts.Elem; VAR m: Texts.ElemMsg);  PROCEDURE HandleTextArea* (e: Texts.Elem; VAR m: Texts.ElemMsg);  PROCEDURE HandleCheckBox* (e: Texts.Elem; VAR m: Texts.ElemMsg);  PROCEDURE HandleRadioButton* (e: Texts.Elem; VAR m: Texts.ElemMsg);  PROCEDURE HandleList* (e: Texts.Elem; VAR m: Texts.ElemMsg);  PROCEDURE HandleForm* (e: Texts.Elem; VAR m: Texts.ElemMsg);  PROCEDURE HandleHidden* (e: Texts.Elem; VAR m: Texts.ElemMsg);  PROCEDURE HandlePassWord* (e: Texts.Elem; VAR m: Texts.ElemMsg);  PROCEDURE HandleImage* (e: Texts.Elem; VAR m: Texts.ElemMsg);  (* Set default-values for input-, select-, option- or textarea-tags *) PROCEDURE InitInput* (inp : InputTag);  PROCEDURE InitSelection* (sel : Selection);  PROCEDURE InitOption* (opt : Option);  PROCEDURE InitTextArea* (ta : TextArea);  (* Alloc FormElems *) PROCEDURE AllocForm*;  PROCEDURE AllocHidden*;  PROCEDURE AllocImage*;  PROCEDURE AllocButton*;  PROCEDURE AllocTextField*;  PROCEDURE AllocTextArea*;  PROCEDURE AllocCheckBox*;  PROCEDURE AllocRadioButton*;  PROCEDURE AllocPassWord*;  PROCEDURE AllocList*;  (* Return FormElems with the values of InputTag, TextArea or Selection *) PROCEDURE NewForm* (side : INTEGER; visible : BOOLEAN): FormElem;  PROCEDURE NewNakedHidden* (visible : BOOLEAN): HiddenElem;  PROCEDURE NewHidden* (inp : InputTag; visible : BOOLEAN) : HiddenElem;  PROCEDURE NewImage* (): ImageElem;  PROCEDURE NewSubmitButton* (inp : InputTag) : ButtonElems.Elem;  PROCEDURE NewResetButton* (inp : InputTag) : ButtonElems.Elem;  PROCEDURE NewTextField* (inp : InputTag) : TextFieldElems.Elem;  PROCEDURE NewTextArea* (ta : TextArea; buf : Texts.Buffer) : TextAreaElems.Elem;  PROCEDURE NewCheckBox* (inp : InputTag) : CheckBoxElems.Elem;  PROCEDURE NewRadioButton* (inp : InputTag) : RadioButtonElems.Elem;  PROCEDURE NewPassWord* (inp : InputTag) : TextFieldElems.PWElem;  (* Add option "opt" to selection "sel" *) PROCEDURE AddOption* (VAR options : Texts.Writer; VAR sel : Selection; VAR opt : Option);  PROCEDURE NewList* (VAR sel : Selection) : ListElems.Elem;  (* Insert FormElems with default-values *) PROCEDURE InsertForm*;  PROCEDURE InsertHidden*;  PROCEDURE InsertImage*;  PROCEDURE InsertSubmitButton*;  PROCEDURE InsertResetButton*;  PROCEDURE InsertTextField*;  PROCEDURE InsertTextArea*;  PROCEDURE InsertCheckBox*;  PROCEDURE InsertRadioButton*;  PROCEDURE InsertPassWord*;  PROCEDURE InsertList*;  Set xDim and yDim PROCEDURE SetDimensions* (fnt : Fonts.Font);  (* Initializes the Icons for Form- and HiddenElem *) PROCEDURE InitIcons;  BEGIN InitIcons; Texts.OpenWriter(w); SetDimensions(HTML.fixedFont) END FormElems.