3Syntax10.Scn.FntSyntax10i.Scn.Fnt@IStampElemsAlloc8 Dec 98qInfoElemsAllocUSyntax10.Scn.Fnt`=IStampElemsAlloc8 Dec 98U("Title": WebCellElems "Author": Andreas Helm "Abstract": WebCellElems is part of the Oberon-Web-Browser "Keywords": Cells, Tablecells, Web, Webbrowser, Tables "Version": no version "From": 1 March 98 "Until":  "Changes": no changes so far "Hints": based on TextAreaElems from the elems package OqBalloonElemsAlloczSyntax10.Scn.FntSyntax10i.Scn.Fnt Syntax10m.Scn.Fnt 5h 3Syntax10b.Scn.Fnt 'qH^ 3 H  6&  A  g )1( &8  <    8!  .H (  5&   !?   8! 7&B 7 "WebCellElems" WebCellElems is an auxiliaray module for the Oberon-Web-Browser. It implements the cell fragments for the tables and is based on the Elems package. "Notifier" Notifier* = PROCEDURE (e: WebCellElems.Elem; update: BOOLEAN); The Notifier is called, when the element (is supposed) to have changed size. It is also called, when a TextFrames.DisplayMsg is received with msg.prepare = TRUE. If update = TRUE, Elems.UpdateElem should be called for e. "Elem" Elem* = POINTER TO ElemDesc; ElemDesc* = RECORD(TextAreaElems.ElemDesc) border*: INTEGER; (* border is the width of the border in pixels of the HTML file. The border width is always 1 for WebCellElems *) colSpan*, rowSpan*: INTEGER; (* colSpan and rowSpan represent the spanning information of the cell *) header*: BOOLEAN; (* header is TRUE, if the cell is an header cell (), FALSE for a table data cell () *) wantedWidth*: INTEGER; (* this is the optimal width of a cell in pixels *) next*: Elem; (* list of elems, which belong to the same cell, used only temporary! *) END; "ElemDesc" Elem* = POINTER TO ElemDesc; See Elem for more details. "Text" Text* = POINTER TO TextDesc; TextDesc* = RECORD(Web.TextDesc) elem*: Elem (* elem points to the elem, which contains the text *) END; "TextDesc" Text* = POINTER TO TextDesc; See Text for more details. "notify" VAR notify*: WebCellElems.Notifier; The Notifier is called, when the element (is supposed) to have changed size. It is also called, when a TextFrames.DisplayMsg is received with msg.prepare = TRUE. "normalFont" VAR normalFont-: Fonts.Font; normalFont is the default font for the web browser as loadad from the file Web.Profile. "text" VAR text*: Web.Text; text is set by the module HTML and contains the last text, in which a table should be inserted. "NewText" PROCEDURE NewText*(name: ARRAY OF CHAR): WebCellElems.Text; NewText creates an new text and returns it. "CopyText" PROCEDURE CopyText(T: Texts.Text): Text; CopyText returns a copy of the text T. "FindOutmostText" PROCEDURE FindOutmostText*(text: WebCellElems.Text): Texts.Text; FindOutmostText returns the text, in which text is nested (in various WebPanelElems.Elems). "InsertParc" PROCEDURE InsertParc*(text: Texts.Text; parc: StyleElems.Parc; font: Fonts.Font); InsertParc inserts parc at the first position in text with the given font. "Draw" PROCEDURE Draw*(e: WebCellElems.Elem; x, y: INTEGER; f: Display.Frame); Draw draws the frame around the elem e. "FrameHandle" PROCEDURE FrameHandle*(f: Display.Frame; VAR msg: Display.FrameMsg); FrameHandle is the handler for the frame opened by the elem. "Handle" PROCEDURE Handle*(E: Texts.Elem; VAR msg: Texts.ElemMsg); Handle is the handler for a WebCellElems.Elem. "Init" PROCEDURE Init*(e: WebCellElems.Elem; text: WebCellElems.Text); Init sets the default values for the elem e and uses text and notify. "New" PROCEDURE New*; New creates a new element and calls Init for it with an empty text. The resulting element is stored in Texts.New. "Create" PROCEDURE Create*(border: INTEGER; text: Text): WebCellElems.Elem; Create creates a new element and calls Init for it with text. The resulting element is returned. "GetNormalFont" PROCEDURE GetNormalFont; GetNormalFont loads the normal font from the file Web.Profile and stores it in normalFont. 1Syntax10b.Scn.Fnt * "8FoldElemsNewSyntax10.Scn.FntSyntax10b.Scn.Fnt     Syntax10i.Scn.FntH border*: INTEGER; colSpan*, rowSpan*: INTEGER; header*: BOOLEAN; wantedWidth*: INTEGER; next*: Elem; (* list of elems, which belong to the same cell, used only temporary! *) END;8#8qSyntax10.Scn.FntSyntax10b.Scn.Fnt Syntax10i.Scn.Fnt6m TextDesc* = RECORD(Web.TextDesc) elem*: Elem (* elem points to the elem, which contains the text *) END;8     8#Syntax10.Scn.Fnt VAR t: Text; BEGIN NEW(t); Texts.Open(t, name); t.notify := TextFrames.NotifyDisplay; t.act := NIL; t.base := NIL; t.cancelled := FALSE; t.display := TRUE; t.elem := NIL; RETURN t END NewText;8*8#Syntax10.Scn.Fnt VAR t: Text; buf: Texts.Buffer; BEGIN NEW(buf); Texts.OpenBuf(buf); Texts.Save(T, 0, T.len, buf); t := NewText(""); t.notify := T.notify; Texts.Append(t, buf); RETURN t END CopyText;8&8#Syntax10.Scn.Fnt VAR t: Texts.Text; BEGIN t:= Texts.ElemBase(txt.elem); WHILE (t # NIL) & (t IS PanelElems.Text) DO t := Texts.ElemBase(t(PanelElems.Text).base) END; IF t # NIL THEN RETURN t ELSE RETURN text END END FindOutmostText;8'8#Syntax10.Scn.Fnt VAR t: Texts.Text; BEGIN t:= Texts.ElemBase(txt.elem); WHILE (t # NIL) & (t IS PanelElems.Text) DO t := Texts.ElemBase(t(PanelElems.Text).base) END; RETURN t END FindOutmostText;84  =U8#Syntax10.Scn.Fnt VAR r: Texts.Reader; w: Texts.Writer; p: StyleElems.Parc; BEGIN Texts.OpenReader(r, text, 0); Texts.ReadElem(r); IF (r.elem = NIL) OR ~ (r.elem IS TextFrames.Parc) THEN NEW(p); StyleElems.Copy(parc, p); p.left := 0; p.first := 0; Texts.OpenWriter(w); Texts.SetFont(w, font); Texts.SetColor(w, 15); Texts.WriteElem(w, p); Texts.Insert(text, 0, w.buf) END END InsertParc;8# -R8#Syntax10.Scn.Fnt VAR w, h: INTEGER; BEGIN w := GU.Unit(e.W, TRUE); h := GU.Unit(e.H, TRUE); GU.Frame(f, GU.black, x, y, w, h, 1, Display.paint) END Draw;8  /8CSyntax10.Scn.FntPSyntax10i.Scn.Fnt4^ BEGIN TextAreaElems.FrameHandle(f, msg); IF msg IS Pictures.UpdateMsg THEN (* force a new calculation of the elems dimension *) IF notify # NIL THEN notify(f(TextAreaElems.Frame).e(Elem), TRUE) END END END FrameHandle;8 * 8 Syntax10.Scn.FntaSyntax10i.Scn.Fnt4&,8FoldElemsNew#Syntax10.Scn.Fnt IF msg.prepare THEN IF notify # NIL THEN notify(E, FALSE) END ELSE insert := E.txt.len = 0; IF normStyle # NIL THEN InsertParc(E.txt, normStyle, normalFont) END; GU.SetDevice(GU.display); msg.elemFrame := TextAreaElems.OpenFrame(E, msg.frame, TextAreaElems.TextHandle, FrameHandle, msg.X0, msg.Y0, SHORT(E.W DIV DUnit), SHORT(E.H DIV DUnit)); IF insert THEN Texts.OpenReader(r, E.txt, 0); Texts.ReadElem(r); IF (r.elem # NIL) & (Texts.Pos(r) = 1) & (r.elem IS TextFrames.Parc) THEN Texts.ChangeLooks(E.txt, 0, E.txt.len, {0}, normalFont, 0, 0) END END; IF E.border > 0 THEN Draw(E, msg.X0, msg.Y0, msg.elemFrame) END; END 8#x8#Syntax10.Scn.Fntff IF msg.prepare THEN IF notify # NIL THEN notify(E, TRUE) END END; TextAreaElems.Handle(E, msg) 88#Syntax10.Scn.FntRR IF msg.e = NIL THEN NEW(copy); msg.e := copy ELSE copy := msg.e(Elem) END; TextAreaElems.Handle(E, msg); copy.txt := CopyText(E.txt); copy.txt(Text).elem := copy; IF E.txt IS Text THEN copy.txt(Text).act := E.txt(Text).act; copy.txt(Text).base := E.txt(Text).base; copy.txt(Text).cancelled := E.txt(Text).cancelled; copy.txt(Text).display := E.txt(Text).display END; copy.border := E.border; copy.colSpan := E.colSpan; copy.rowSpan := E.rowSpan; copy.header := E.header; copy.wantedWidth := E.wantedWidth; copy.next := NIL; msg.e := copy 8 8CSyntax10.Scn.FntSyntax10i.Scn.Fnt-1 msg.mod := "WebCellElems"; msg.proc := "New" 84T8Syntax10.Scn.Fnt"Syntax10i.Scn.Fnt:+ $ TextAreaElems.Handle(E, msg); IF msg.id = Texts.load THEN E.txt := CopyText(E.txt); (* to convert a Texts.Text to a Web.Text *) E.txt(Text).elem := E; Files.ReadInt(msg.r, E.border); Files.ReadInt(msg.r, E.colSpan); Files.ReadInt(msg.r, E.rowSpan); Files.ReadBool(msg.r, E.header); E.wantedWidth := 0; E.next := NIL; ELSIF msg.id = Texts.store THEN Files.WriteInt(msg.r, E.border); Files.WriteInt(msg.r, E.colSpan); Files.WriteInt(msg.r, E.rowSpan); Files.WriteBool(msg.r, E.header) END 8!8#Syntax10.Scn.Fnt!! TextAreaElems.Handle(E, msg) 8!8#Syntax10.Scn.Fnt!! TextAreaElems.Handle(E, msg) 828#Syntax10.Scn.Fnt TextAreaElems.Handle(E, msg); Texts.OpenReader(r, E.txt, 0); REPEAT Texts.ReadElem(r); IF r.elem # NIL THEN r.elem.handle(r.elem, msg) END; UNTIL r.eot48 VAR copy: Elem; r: Texts.Reader; insert: BOOLEAN; BEGIN WITH E: Elem DO E.locked := TRUE; (* to prevent unlocking by Inspector or a program *) WITH msg: TextFrames.DisplayMsg DO  | msg : TextPrinter.PrintMsg DO  | msg : Texts.CopyMsg DO  | msg : Texts.IdentifyMsg DO  | msg : Elems.AttrMsg DO | msg : Texts.FileMsg DO  | msg: TextFrames.TrackMsg DO  | msg: TextFrames.FocusMsg DO  ELSE  (* Broadcast to all elems, which are in the text *)  END END END Handle;80 8<Syntax10i.Scn.FntSyntax10.Scn.Fnt BEGIN TextAreaElems.Init(e); e.handle := Handle; text.elem := e; e.txt := text; e.scrBar := FALSE; e.border := 1; e.colSpan := 1; e.rowSpan := 1; e.header := FALSE; e.wantedWidth := 0; e.next := NIL END Init;83 z8<Syntax10i.Scn.FntSyntax10.Scn.FntJK VAR e: Elem; BEGIN NEW(e); Init(e, NewText("")); Texts.new := e END New;8F %8#Syntax10.Scn.FntUU VAR e: Elem; BEGIN NEW(e); Init(e, text); e.border := border; RETURN e END Create;8O8#Syntax10.Scn.FntQQ VAR prof: Web.ProfileEntry; family, str: ARRAY 64 OF CHAR; size: INTEGER; BEGIN normalFont := Fonts.Default; Web.GetProfile("HTML", "normalFont", prof); family := ""; size := -1; IF (prof # NIL) & (prof.class IN {Texts.Name, Texts.String}) THEN COPY(prof.str, family) END; Web.GetProfile("HTML", "fontSize", prof); IF (prof # NIL) & (prof.class = Texts.Int) THEN size := SHORT(prof.int) END; IF (family # "") & (size # -1) THEN Web.Int2Str(size, str); Strings.Append(str, family); Strings.Append(".Scn.Fnt", family); normalFont := Fonts.This(family) END END GetNormalFont;8VMODULE WebCellElems; (* Andreas Helm,  *)   (* Based on TextAreaElems of the elems package *) IMPORT Display, Elems, Files, Fonts, GU := GUtils, PanelElems, Pictures, Strings, StyleElems, TextAreaElems, TextFrames, TextPrinter, Texts, Web; CONST DUnit = TextFrames.Unit; TYPE Elem* = POINTER TO ElemDesc; Notifier* = PROCEDURE (e: Elem; update: BOOLEAN); ElemDesc* = RECORD(TextAreaElems.ElemDesc)  Text* = POINTER TO TextDesc;  VAR notify*: Notifier; normalFont-: Fonts.Font; normStyle*: StyleElems.Parc; text*: Web.Text; (* creates a new, empty text *) PROCEDURE NewText*(name: ARRAY OF CHAR): Text;  (* returns a copy of T *) PROCEDURE CopyText(T: Texts.Text): Text;  (* returns the outmost text of text *) (* PROCEDURE FindOutmostText*(txt: Text): Texts.Text;  *) PROCEDURE FindOutmostText*(txt: Text): Texts.Text;  (* Inserts a parc at the first position of a text *) PROCEDURE InsertParc*(text: Texts.Text; parc: StyleElems.Parc; font: Fonts.Font);  (* Draws a frame around the elem *) PROCEDURE Draw*(e: Elem; x, y: INTEGER; f: Display.Frame);  (* Frame handler *) PROCEDURE FrameHandle*(f: Display.Frame; VAR msg: Display.FrameMsg);  (* Message handler *) PROCEDURE Handle*(E: Texts.Elem; VAR msg: Texts.ElemMsg);  (* Sets the default properties of the element *) PROCEDURE Init*(e: Elem; text: Text);  (* Creates a new element and calls Init for it *) PROCEDURE New*;  (* Creates a new element, initializes it and returns it as result *) PROCEDURE Create*(border: INTEGER; text: Text): Elem;  (* Load the normal font from the file Web.Profile and store it in normalFont *) PROCEDURE GetNormalFont;  BEGIN notify := NIL; normStyle := NIL; text := NIL; GetNormalFont END WebCellElems.