7Syntax10.Scn.Fnt`=IStampElemsAlloc11 Mar 98rSyntax10i.Scn.Fnt4DSyntax10b.Scn.Fnt     +)$MarkElemsAlloc8FoldElemsNew#Syntax10.Scn.FntUU VAR swap: INTEGER; BEGIN IF a > b THEN swap := a; a := b; b := swap END END Order; 8 $8#Syntax10.Scn.FntVV BEGIN Order (x1, x2); Order (y1, y2); Display.ReplConst (Display.white, x1, y1, x2 - x1, 1, Display.invert); Display.ReplConst (Display.white, x1, y1, 1, y2 - y1, Display.invert); Display.ReplConst (Display.white, x1, y2, x2 - x1, 1, Display.invert); Display.ReplConst (Display.white, x2, y1, 1, y2 - y1, Display.invert) END DrawFrame; 8 @%8#Syntax10.Scn.Fnt22 BEGIN RETURN val * DUnit DIV Unit300 END Scale; +8@"`s%j8_Syntax10.Scn.Fnt7Syntax10i.Scn.Fnt5#d8 BEGIN SetMapMode(hdc, mf.mm); Win32.SetTextAlign(hdc, mf.textAlign); IF mf.mm = MMTEXT THEN SetWindowOrg(hdc, -x -(frameW DIV 2), -(Win32.DispH - y + (frameW DIV 2)), NULL) ELSIF (mf.mm = ISOTROPIC) OR (mf.mm = ANISOTROPIC) THEN SetWindowExt(hdc, Win32.DispW, Win32.DispH, NULL); IF mf.w = 0 THEN (* no dimensions provided *) SetViewportExt(hdc, CLIENTAREA, CLIENTAREA, NULL); SetViewportOrg(hdc, x +(frameW DIV 2), Win32.DispH - y + (frameW DIV 2), NULL); ELSIF mf.w > 0 THEN SetViewportExt(hdc, mf.w, mf.h, NULL); SetViewportOrg(hdc, x +(frameW DIV 2), Win32.DispH - y + (frameW DIV 2), NULL); ELSIF mf.w < 0 THEN (* not implemented yet *) END ELSE (* all metric coordinate systems *) SetViewportOrg(hdc, x + frameW DIV 2, Win32.DispH - y + frameW DIV 2, NULL) END END PrepareDisp;8@s%8{Syntax10.Scn.FntSyntax10i.Scn.Fnt$Oc=4 VAR dpi: INTEGER; (* factor for adaption to 600 dpi *) W, H: LONGINT; BEGIN IF Win32.Unit # Unit300 THEN dpi:=2 ELSE dpi :=1 END; (* 300 dpi or 600 dpi ? *) SetMapMode(hdc, mf.mm); Win32.SetTextAlign(hdc, mf.textAlign); IF mf.mm = MMTEXT THEN (* rescale in mode isotropic *) SetMapMode(hdc, ISOTROPIC); SetWindowExt(hdc, mf.w, mf.h, NULL); SetViewportExt(hdc, Scale(mf.w * dpi), Scale(mf.h * dpi), NULL) ELSIF (mf.mm = ISOTROPIC) OR (mf.mm = ANISOTROPIC) THEN SetWindowExt(hdc, Printer.PageWidth*dpi, Printer.PageHeight*dpi, NULL); IF mf.w = 0 THEN W := Scale(CLIENTAREA); H := Scale(CLIENTAREA) ELSIF mf.w > 0 THEN W := Scale(mf.w); H := Scale(mf.h) ELSE (* not implemented yet *) END; SetViewportExt(hdc, W * dpi, H * dpi, NULL) END; (* metric coordinate systems need no special code *) W := x + Scale(frameW DIV 2); H := Printer.PageHeight - y - Scale(frameW DIV 2) - Scale(mf.h); SetViewportOrg(hdc, W * dpi, H * dpi, NULL) END PreparePrint; 8r8#Syntax10.Scn.Fnt VAR dc: HDC; BEGIN IF mf.handle # NULL THEN dc := SaveDC(Win32.hdcDisp); IF dc # NULL THEN mf.PrepareDisp(Win32.hdcDisp, x, y); PlayMetaFile(Win32.hdcDisp, mf.handle); Done := RestoreDC(Win32.hdcDisp, -1); IF ~Done THEN HALT(255) END END END END Draw;8#r8#Syntax10.Scn.Fnt VAR dc: HDC; BEGIN IF mf.handle # NULL THEN dc := SaveDC(Win32.PD.hdc); IF dc # NULL THEN mf.PreparePrint(Win32.PD.hdc, x, y); PlayMetaFile(Win32.PD.hdc, mf.handle); Done := RestoreDC(Win32.PD.hdc, -1); IF ~Done THEN HALT(255) END END END END Print; 8A0rN8#Syntax10.Scn.Fnt VAR hdcMeta : HDC; BEGIN hdcMeta := CreateMetaFile(NULL); PlayMetaFile(hdcMeta, mfh); mf.handle := CloseMetaFile(hdcMeta) END CopyMetaFile;8r+8QSyntax10.Scn.FntSyntax10i.Scn.Fntk CONST inch = 254; (* 254 * 0,1 mm *) BEGIN mf.w := mfh.xExt; mf.h := mfh.yExt; mf.mm := mfh.mm; IF (mf.mm = ISOTROPIC) OR (mf.mm = ANISOTROPIC) THEN IF mf.w = 0 THEN mf.w := CLIENTAREA*10 END; IF mf.h = 0 THEN mf.h := CLIENTAREA*10 END; mf.w := mf.w * Win32.GetDeviceCaps(hdc, HORZRES); mf.w := mf.w DIV Win32.GetDeviceCaps(hdc, HORZSIZE) DIV 100; mf.h := mf.h * Win32.GetDeviceCaps(hdc, VERTRES); mf.h := mf.h DIV Win32.GetDeviceCaps(hdc, VERTSIZE) DIV 100; ELSIF mf.mm = LOMETRIC THEN IF mf.w = 0 THEN mf.w := CLIENTAREA*10 END; IF mf.h = 0 THEN mf.h := CLIENTAREA*10 END; mf.w := mf.w * mm DIV 10 DIV DUnit; mf.h := mf.h * mm DIV 10 DIV DUnit ELSIF mf.mm = HIMETRIC THEN IF mf.w = 0 THEN mf.w := CLIENTAREA*100 END; IF mf.h = 0 THEN mf.h := CLIENTAREA*100 END; mf.w := mf.w * mm DIV 100 DIV DUnit; mf.h := mf.h * mm DIV 100 DIV DUnit ELSIF mf.mm = LOENGLISH THEN IF mf.w = 0 THEN mf.w := CLIENTAREA*inch END; IF mf.h = 0 THEN mf.h := CLIENTAREA*inch END; mf.w := mf.w * inch DIV 1000 * mm DIV DUnit; mf.h := mf.h * inch DIV 1000 * mm DIV DUnit ELSIF mf.mm = HIENGLISH THEN IF mf.w = 0 THEN mf.w := CLIENTAREA*inch*10 END; IF mf.h = 0 THEN mf.h := CLIENTAREA*inch*10 END; mf.w := mf.w * inch DIV 1000 * mm DIV 10 DIV DUnit; mf.h := mf.h * inch DIV 1000 * mm DIV 10 DIV DUnit ELSE (* MMTEXT assumed *) IF mf.w = 0 THEN mf.w := CLIENTAREA END; IF mf.h = 0 THEN mf.h := CLIENTAREA END END END GetDimensions;8 $q8#Syntax10.Scn.Fnt__ VAR mf: MetaFile; BEGIN mf := S.VAL(MetaFile, ptr); DeleteMetaFile(mf.handle) END Finalize;-8 r-88 |vrj8CSyntax10.Scn.FntSyntax10i.Scn.Fnt0XT VAR adr, hMEM: LONGINT; mf: MetaFile; mfHeader: MetaFilePict; BEGIN Done := Win32.OpenClipboard(Win32.Display); IF Done THEN hMEM := Win32.GetClipboardData(CFMETAFILEPICT); IF hMEM # NULL THEN (* metafile found in clipboard, now get handle *) adr := Win32.GlobalLock(hMEM); IF adr # NULL THEN mfHeader := S.VAL(MetaFilePict, adr); NEW(mf); mf.CopyMetaFile(mfHeader.handle); mf.GetDimensions(Win32.hdcDisp, mfHeader); Kernel.RegisterObject(mf, Finalize); Win32.GlobalUnlock(hMEM) END END; Win32.CloseClipboard END; RETURN mf END GetFromClipboard;-8 |vr18$Syntax10i.Scn.Fnt))load a MetaFile from a given file on disk0?168 cr 8#Syntax10.Scn.Fnt<< BEGIN Texts.CopyElem(se, de); de.mf := se.mf END CopyElem;8 q8Y8 Fr8.(8 iQq8#Syntax10.Scn.FntZZ BEGIN e.W := (e.mf.w + frameW)* DUnit; e.H := (e.mf.h + frameW)* DUnit; END MeasureItem;98 !f8#Syntax10.Scn.Fntxx VAR w, x, i, j: INTEGER; BEGIN w := 3 * mm DIV DUnit; x := F.X + F.W - w; Display.ReplConst(Display.white, x, F.Y , w, w, Display.invert); Display.ReplConst(Display.white, x + 1, F.Y + 1, w - 2, w - 2, Display.invert); FOR i := x +1 TO (x + w -2) DO FOR j := 1 TO (i - x ) DO Display.Dot(Display.white, i, F.Y + j, Display.invert); END END END DrawResizeArea; 8 K9N8#Syntax10.Scn.Fnt VAR w: INTEGER; BEGIN w := 3 * mm DIV DUnit; RETURN ((x < F.X + F.W) & (x > F.X + F.W - w) & (y > F.Y) & (y < F.Y + w)) END IsInResizeArea; 8 7k88CSyntax10.Scn.FntSyntax10i.Scn.FntG VAR keysum: SET; oldX, oldY, w, h: INTEGER; BEGIN REPEAT Input.Mouse (keys, x, y) UNTIL (keys # {}) OR (Input.Available () # 0); oldX := x; oldY := y; keysum := {}; DrawFrame (F.X, F.Y + F.H, oldX, oldY); WHILE (keys = {ML}) & (Input.Available() = 0) DO keysum := keysum + keys; Input.Mouse (keys, x, y); IF (x # oldX) OR (y # oldY) THEN DrawFrame (F.X, F.Y + F.H, oldX, oldY); DrawFrame (F.X, F.Y + F.H, x, y); oldX := x; oldY := y END END; DrawFrame (F.X, F.Y + F.H, oldX, oldY); IF keysum = {ML} THEN (* only left click allowed - operation is canceled by any interclick *) w := oldX - F.X - (frameW DIV 2); h := F.Y + F.H - oldY - (frameW DIV 2); IF (w > 0) & (h > 0) THEN IF F IS Frame THEN WITH F: Frame DO (* resize element and redraw text *) F.e.mf.w := w; F.e.mf.h := h; TextFrames.NotifyDisplay (Texts.ElemBase(F.e), TextFrames.replace, Texts.ElemPos(F.e), Texts.ElemPos(F.e)+1); END END END END END TrackResize; 8  i98#Syntax10.Scn.Fnt BEGIN IF msg IS Oberon.InputMsg THEN WITH msg: Oberon.InputMsg DO IF msg.id = Oberon.track THEN IF msg.keys = {ML} THEN IF IsInResizeArea(F, msg.X, msg.Y) THEN TrackResize(F, msg.X, msg.Y, msg.keys) END END END END END END HandleFrame; 8$ yq.8CSyntax10.Scn.FntSyntax10i.Scn.Fnt3 VAR copy: Elem; F: Frame; BEGIN WITH e: Elem DO IF msg IS Texts.CopyMsg THEN NEW(copy); CopyElem(e, copy); msg(Texts.CopyMsg).e := copy ELSIF msg IS TextFrames.FocusMsg THEN WITH msg: TextFrames.FocusMsg DO DrawResizeArea(msg.elemFrame) END ELSIF msg IS Texts.IdentifyMsg THEN WITH msg: Texts.IdentifyMsg DO msg.mod := "MetaFileElems"; msg.proc := "Alloc" END; ELSIF msg IS Texts.FileMsg THEN WITH msg: Texts.FileMsg DO IF msg.id = Texts.load THEN Load(e, msg.r) ELSIF msg.id = Texts.store THEN Store(e, msg.r) END END ELSIF msg IS TextFrames.DisplayMsg THEN WITH msg: TextFrames.DisplayMsg DO IF msg.prepare THEN MeasureItem(e) ELSE e.mf.Draw(msg.X0, msg.Y0 + (e.H DIV DUnit)); (* if metafile is scalable then install subframe *) IF (e.mf.mm = ISOTROPIC) OR (e.mf.mm = ANISOTROPIC) THEN NEW(F); F.X := msg.X0; F.Y := msg.Y0; F.W := SHORT(e.W DIV DUnit); F.H := SHORT(e.H DIV DUnit); F.handle := HandleFrame; F.e := e; msg.elemFrame := F END END END ELSIF msg IS TextPrinter.PrintMsg THEN WITH msg: TextPrinter.PrintMsg DO IF ~msg.prepare THEN e.mf.Print(msg.X0, msg.Y0) END END END END END Handle;8/8#Syntax10.Scn.Fnt VAR txt: Texts.Text; r: Texts.Reader; beg, end, time: LONGINT; BEGIN Oberon.GetSelection(txt, beg, end, time); IF time >= 0 THEN Texts.OpenReader(r, txt, beg); Texts.ReadElem(r); END; RETURN r.elem END GetElemFromSelection; 8 8#Syntax10.Scn.Fnt VAR M: TextFrames.InsertElemMsg; BEGIN IF e.mf # NIL THEN e.handle := Handle; M.e := e; Oberon.FocusViewer.handle(Oberon.FocusViewer, M); Done := TRUE ELSE Done := FALSE END END InstallElem; >8 q8#Syntax10.Scn.Fnt VAR e:Elem; BEGIN NEW(e);e.handle := Handle; NEW(e.mf); e.mf.handle := NULL; e.mf.textAlign := AlignLeft + AlignTop; e.mf.w := 0; e.mf.h := 0; e.mf.mm := MMTEXT; Texts.new := e END Alloc;8 ْq8#Syntax10.Scn.FntTT VAR e: Elem; BEGIN NEW(e); e.mf := GetFromClipboard(); InstallElem(e) END Paste;08 d(X8_Syntax10.Scn.FntSyntax10i.Scn.Fnt!}J CONST SizeMFH = 16; GHND = 42H; VAR hdcMeta: HDC; data, hMEM: LONGINT; mfp: MetaFilePict; e: Texts.Elem; done: BOOLEAN; BEGIN e := GetElemFromSelection(); IF e # NIL THEN WITH e: Elem DO (* copy metafile to clipboard *) hMEM := Win32.GlobalAlloc(GHND, SizeMFH); mfp := S.VAL(MetaFilePict, Win32.GlobalLock(hMEM)); mfp.mm := e.mf.mm; (* units of 0.1 mm used *) mfp.xExt := e.mf.w * mm * 10 DIV DUnit; mfp.yExt := e.mf.h * mm * 10 DIV DUnit; hdcMeta := CreateMetaFile(NULL); PlayMetaFile(hdcMeta, e.mf.handle); mfp.handle := CloseMetaFile(hdcMeta); Win32.GlobalUnlock(hMEM); done := Win32.OpenClipboard(Win32.Display); IF done THEN Win32.EmptyClipboard; data := Win32.SetClipboardData(CFMETAFILEPICT, hMEM); Win32.CloseClipboard END ELSE (* do nothing *) END END END Copy; +8 Sv8#Syntax10.Scn.Fnthh VAR s: Texts.Scanner; name: ARRAY 256 OF CHAR; text: Texts.Text; beg, end, time: LONGINT; e: Elem; found: BOOLEAN; BEGIN Texts.OpenScanner(s, Oberon.Par.text, Oberon.Par.pos); Texts.Scan(s); found := FALSE; IF s.class = Texts.Name THEN COPY(s.s, name); found := TRUE ELSIF (s.class = Texts.Char) & (s.c = '^') THEN Oberon.GetSelection(text, beg, end, time); IF time > 0 THEN Texts.OpenScanner(s, text, beg); Texts.Scan(s); IF s.class = Texts.Name THEN COPY(s.s, name); found := TRUE; END END END; IF found THEN NEW(e); e.mf := GetFromFile(name); InstallElem(e) END END Insert; 8 8$Syntax10i.Scn.Fntloading Windows API functionsG8o %MODULE MetaFileElems; (* StCh,  *) (* Class for Windows Meta Files and MetaFile - TextElements *) IMPORT Win32, Kernel, S := SYSTEM, Printer, TextPrinter, Display, Oberon, Out, Files, Texts, TextFrames, Input, Directories; CONST MMTEXT = 1; LOMETRIC = 2; HIMETRIC = 3; LOENGLISH = 4; HIENGLISH = 5; ISOTROPIC = 7; ANISOTROPIC = 8; CFMETAFILEPICT = 3; NULL = 0; CLIENTAREA = 100; (* default : 100 Units if no dimensions available *) HORZRES = 8; HORZSIZE = 4; VERTRES = 10; VERTSIZE = 6; AlignLeft = 0; AlignTop = 0; (*AlignRight = 2; AlignBottom = 8; AlignCenter = 6; AlignBaseline = 24;*) DUnit = LONG(TextFrames.Unit); Unit300 = TextPrinter.Unit; mm = TextFrames.mm; frameW = 4; ML =2; TYPE ADDRESS = LONGINT; HANDLE = LONGINT; HMETAFILE = HANDLE; HDC = HANDLE; LPSZ = LONGINT; (* constant header in clipboard, holds the handle of the metafile *) MetaFilePict = POINTER TO MetaFilePictDesc; MetaFilePictDesc = RECORD mm, xExt, yExt: LONGINT; handle: HMETAFILE; END; (* metafile class *) MetaFile* = POINTER TO MetaFileDesc; MetaFileDesc* = RECORD handle*: HMETAFILE; w*, h* : LONGINT; mm*: LONGINT; textAlign*: LONGINT; END; (* metafile text element *) Elem = POINTER TO ElemDesc; ElemDesc = RECORD (Texts.ElemDesc) mf: MetaFile; END; Rect = RECORD left, top, right, bottom: INTEGER END; APMHeader= RECORD (* key: LONGINT;*) (* not necessary, key is read seperately *) hmf: INTEGER; bbox: Rect; inch: INTEGER; reserved: LONGINT; checksum: INTEGER END; Frame = POINTER TO RECORD(Display.FrameDesc) e: Elem END; (* global variables *) VAR mod: LONGINT; Done: BOOLEAN; (* Windows specific API functions *) SaveDC: PROCEDURE (hdc: HDC): LONGINT; RestoreDC: PROCEDURE (hdc: HDC; nSavedDC: LONGINT): BOOLEAN; CreateMetaFile: PROCEDURE (filename: ADDRESS): HDC; CloseMetaFile: PROCEDURE (hdc: HDC): HMETAFILE; SetMetaFileBits: PROCEDURE (size: LONGINT; lpData: LONGINT): HMETAFILE; DeleteMetaFile: PROCEDURE (hmf: HMETAFILE); PlayMetaFile: PROCEDURE (hdc: HDC; hmf: HMETAFILE); GetMetaFile: PROCEDURE (szFileName: LONGINT): HMETAFILE; SetWindowOrg: PROCEDURE (hdc: HDC; x, y, lpPoint: LONGINT); SetWindowExt: PROCEDURE(hdc: HDC; nXExt, nYExt, lpPoint: LONGINT); SetMapMode: PROCEDURE (hdc: HDC; mapMode: LONGINT); SetViewportExt: PROCEDURE( hdc: HDC; nXExt, nYExt, lpSize : LONGINT); SetViewportOrg: PROCEDURE(hdc: HDC; x, y, lpPoint : LONGINT); GetTempPath: PROCEDURE(len: LONGINT; path: LPSZ); GetWinTempFileName: PROCEDURE (path: LPSZ; prefix: LPSZ; unique: LONGINT; name: LPSZ); PROCEDURE Order (VAR a, b: INTEGER); PROCEDURE DrawFrame (x1, y1, x2, y2: INTEGER); PROCEDURE Scale(val: LONGINT): LONGINT;scale value to 300 dpi units on the printer (* prepare the device context for the display of the metafile *) PROCEDURE (mf: MetaFile) PrepareDisp(hdc: HDC; x, y: LONGINT); (* prepare the printer device context for the printing of the metafile the parameters (x,y) are 300dpi pixels, mf.w and mf.h are device dependant units *) PROCEDURE (mf: MetaFile) PreparePrint(hdc: HDC; x,y: LONGINT); PROCEDURE (mf: MetaFile) Draw*(x, y: LONGINT); PROCEDURE (mf: MetaFile) Print*(x, y: LONGINT); (* copy a metafile denoted by the handle 'mfh' into the object *) PROCEDURE (mf: MetaFile) CopyMetaFile(mfh: HMETAFILE); PROCEDURE (mf: MetaFile) GetDimensions(hdc: HDC; mfh: MetaFilePict); PROCEDURE Finalize(ptr: S.PTR);finalizer : delete the metafile of the object PROCEDURE GetTempFileName(VAR nameTemp: ARRAY OF CHAR); VAR path: ARRAY 40 OF CHAR; BEGIN GetTempPath(40, S.ADR(path)); GetWinTempFileName(S.ADR(path), S.ADR("MF"), 0, S.ADR(nameTemp)) END GetTempFileName; PROCEDURE GetFromClipboard(): MetaFile;look up the clipboard for a windows metafile  PROCEDURE GetFromFile(VAR fName: ARRAY OF CHAR): MetaFile; CONST inch = 254; (* 254 * 0,1 mm *) VAR mf: MetaFile; handle: HMETAFILE; mfHeader: MetaFilePict; f: Files.File; key: ARRAY 4 OF S.BYTE; r: Files.Rider; len: LONGINT; apm: APMHeader; data: POINTER TO ARRAY OF S.BYTE; BEGIN (* first check if it's a placeable metafile *) NEW(mfHeader); mfHeader.mm := ANISOTROPIC; f := Files.Old(fName); IF f = NIL THEN Out.String("no such file or directory : "); Out.String(fName); Out.Ln; RETURN NIL END; Files.Set(r, f, 0); Files.ReadBytes(r, key, 4); IF (ORD(key[0]) = -41) & (ORD(key[1]) = -51) & (ORD(key[2]) = -58) & (ORD(key[3]) = -102) THEN (* placeable metafile, skip 22 bytes header *) Files.ReadInt(r, apm.hmf); Files.ReadInt(r, apm.bbox.left); Files.ReadInt(r, apm.bbox.top); Files.ReadInt(r, apm.bbox.right); Files.ReadInt(r, apm.bbox.bottom); Files.ReadInt(r, apm.inch); Files.ReadLInt(r, apm.reserved); Files.ReadInt(r, apm.checksum); len := Files.Length(f) - 22; NEW(data, len); Files.ReadBytes(r, data^, len); mfHeader.xExt := (apm.bbox.right - apm.bbox.left) DIV apm.inch; (* dimensions in inches *) mfHeader.xExt := mfHeader.xExt * inch * mm DIV DUnit; mfHeader.yExt := (apm.bbox.bottom - apm.bbox.top) DIV apm.inch; mfHeader.yExt := mfHeader.yExt * inch * mm DIV DUnit; handle := SetMetaFileBits(len, S.ADR(data[0])) ELSE mfHeader.xExt := 0; mfHeader.yExt := 0; handle := GetMetaFile(S.ADR(fName)) END; Files.Close(f); IF handle # NULL THEN NEW(mf); mf.CopyMetaFile(handle); DeleteMetaFile(handle); mf.GetDimensions(Win32.hdcDisp, mfHeader); Kernel.RegisterObject(mf, Finalize) END; RETURN mf END GetFromFile; PROCEDURE CopyElem* (se, de: Elem); PROCEDURE Load*(e: Elem; VAR r: Files.Rider); VAR tFile, oberonName: ARRAY 80 OF CHAR; hmf: HMETAFILE; tr: Files.Rider; temp: Files.File; len: LONGINT; res: INTEGER; data: POINTER TO ARRAY OF S.BYTE; BEGIN (* get stored data *) Files.ReadLInt(r, len); Files.ReadLInt(r, e.mf.w); Files.ReadLInt(r, e.mf.h); Files.ReadLInt(r, e.mf.mm); Files.ReadLInt(r, e.mf.textAlign); NEW(data, len); Files.ReadBytes(r, data^, len); GetTempFileName(tFile); COPY(tFile, oberonName); Directories.LocalToURL(oberonName); temp := Files.New(oberonName); IF temp # NIL THEN Files.Set(tr, temp, 0); Files.WriteBytes(tr, data^, len); Files.Register(temp); hmf := GetMetaFile(S.ADR(tFile)); IF hmf # NULL THEN e.mf.CopyMetaFile(hmf); DeleteMetaFile(hmf) END; Files.Delete(oberonName, res); Files.Purge(temp) END END Load;  PROCEDURE Store*(e: Elem; VAR r: Files.Rider); VAR tFile: ARRAY 80 OF CHAR; hdcMeta: HDC; hmf: HMETAFILE; tr: Files.Rider; temp: Files.File; len: LONGINT; res: INTEGER; data: POINTER TO ARRAY OF S.BYTE; BEGIN (* open temp. file for storing the metafile *) GetTempFileName(tFile); hdcMeta := CreateMetaFile(S.ADR(tFile)); PlayMetaFile(hdcMeta, e.mf.handle); hmf := CloseMetaFile(hdcMeta); DeleteMetaFile(hmf); (* copy temp. file into original file *) Directories.LocalToURL(tFile); temp := Files.Old(tFile); IF temp # NIL THEN len := Files.Length(temp); NEW(data, len); Files.WriteLInt(r, len); (* save length of temp. file *) Files.WriteLInt(r, e.mf.w); Files.WriteLInt(r, e.mf.h); Files.WriteLInt(r, e.mf.mm); Files.WriteLInt(r, e.mf.textAlign); Files.Set(tr, temp, 0); Files.ReadBytes(tr, data^, len); Files.WriteBytes(r, data^, len); Files.Delete(tFile, res); Files.Purge(temp) END END Store; PROCEDURE MeasureItem(e: Elem);compute correct dimensions before displaying the element  PROCEDURE DrawResizeArea(F: Display.Frame);dynamic resizing  PROCEDURE IsInResizeArea(F: Display.Frame; x, y: INTEGER): BOOLEAN; PROCEDURE TrackResize(F: Display.Frame; x, y: INTEGER; keys: SET); (* handle input into subframe *) PROCEDURE HandleFrame(F: Display.Frame; VAR msg: Display.FrameMsg); (* message handler of the element *) PROCEDURE Handle(e: Texts.Elem; VAR msg: Texts.ElemMsg); PROCEDURE GetElemFromSelection(): Texts.Elem; PROCEDURE InstallElem(e: Elem); if the elem is filled correctly, it is installed into the text PROCEDURE Alloc*;allocate a new (empty) element  PROCEDURE Paste*;insert an element from the clipboard into a text PROCEDURE Copy*;copy the selected metafile to the clipboard PROCEDURE Insert*;insert an element from file BEGIN  mod := Kernel.LoadLibrary("GDI32"); Kernel.GetAdr(mod,"SaveDC", S.VAL(LONGINT, SaveDC)); Kernel.GetAdr(mod,"RestoreDC", S.VAL(LONGINT, RestoreDC)); Kernel.GetAdr(mod,"CreateMetaFileA",S.VAL(LONGINT, CreateMetaFile)); Kernel.GetAdr(mod,"DeleteMetaFile", S.VAL(LONGINT, DeleteMetaFile)); Kernel.GetAdr(mod,"CloseMetaFile", S.VAL(LONGINT, CloseMetaFile)); Kernel.GetAdr(mod,"PlayMetaFile", S.VAL(LONGINT, PlayMetaFile)); Kernel.GetAdr(mod,"GetMetaFileA", S.VAL(LONGINT, GetMetaFile)); Kernel.GetAdr(mod,"SetMetaFileBitsEx", S.VAL(LONGINT, SetMetaFileBits)); Kernel.GetAdr(mod,"SetWindowOrgEx", S.VAL(LONGINT, SetWindowOrg)); Kernel.GetAdr(mod,"SetWindowExtEx", S.VAL(LONGINT, SetWindowExt)); Kernel.GetAdr(mod,"SetMapMode", S.VAL(LONGINT, SetMapMode)); Kernel.GetAdr(mod,"SetViewportExtEx", S.VAL(LONGINT, SetViewportExt)); Kernel.GetAdr(mod,"SetViewportOrgEx", S.VAL(LONGINT, SetViewportOrg)); mod := Kernel.LoadLibrary("Kernel32"); Kernel.GetAdr(mod,"GetTempFileNameA", S.VAL(LONGINT, GetWinTempFileName)); Kernel.GetAdr(mod,"GetTempPathA", S.VAL(LONGINT, GetTempPath));  END MetaFileElems. System.Free MetaFileElems~ MetaFileElems.Insert ^ MetaFileElems.Paste MetaFileElems.Copy