home *** CD-ROM | disk | FTP | other *** search
- '***********************************************************************
- ' FormDev: Fonts.RLZ
- '
- ' Copyright ⌐ 1991-1992 Computer Associates International, Inc.
- ' All rights reserved.
- '
- '***********************************************************************
-
- 'FONTS table
- 'fonts.name[] ("" = empty entry)
- 'fonts.size[]
- 'fonts.style[] (_Bold=1, _Italic=2, _Underline=4, _StrikeOut=8)
- 'fonts.refs[] number of references to the font
-
- 'Add to ITEM structure
- 'item.font[] refers to the table entry
-
- PROC InitFonts
- CLEAR fonts
-
- fonts.name[1] = "dummy"
- fonts.size[1] = "0"
- fonts.style[1] = "0"
- fonts.refs[1] = 0
- END PROC
-
- PROC FdFontLoadAll
- LOCAL i, fontdata
-
- FOR i = 2 to EndValid(fonts.name)
- IF fonts.name[i] <> "" THEN
- fontdata[1] = fonts.name[i]
- fontdata[2] = fonts.size[i]
- fontdata[3] = fonts.style[i]
- FontNew(i; fontdata)
- END IF
- NEXT i
- END PROC
-
- FUNC FdFontLookup(name, size, style)
- LOCAL i, n
-
- IF name = "" THEN
- RETURN 0
- END IF
- FOR i = 2 to EndValid(fonts.name)
- IF name = fonts.name[i] THEN
- IF size = fonts.size[i] AND style = fonts.style[i] THEN
- RETURN i
- END IF
- END IF
- NEXT i
- n = -1
- FOR i = 2 to EndValid(fonts.name)
- IF fonts.name[i] = "" THEN
- n = i
- EXIT FOR
- END IF
- NEXT i
- IF n = -1 THEN
- n = EndValid(fonts.name) + 1
- END IF
- fonts.name[n] = name
- fonts.size[n] = size
- fonts.style[n] = style
- fonts.refs[n] = 0
- FontNew(n; {name, size, style})
- RETURN n
- END FUNC
-
- PROC FdFontDelete(fontnum)
- IF fontnum <> 0 THEN
- fonts.name[fontnum] = ""
- FontSelect(fontnum)
- FontControl(_Close)
- END IF
- END PROC
-
- PROC FdFontRefDec(fontnum)
- IF fontnum <> 0 THEN
- fonts.refs[fontnum] = fonts.refs[fontnum] - 1
- IF fonts.refs[fontnum] = 0 THEN
- FdFontDelete(fontnum)
- END IF
- END IF
- END PROC
-
- PROC FdFontRefInc(fontnum)
- IF fontnum <> 0 THEN
- fonts.refs[fontnum] = fonts.refs[fontnum] + 1
- END IF
- END PROC
-
- FUNC FdFontModal (fontnum)
- LOCAL orig, newfont, tempfont
-
- IF fontnum THEN
- orig = {fonts.name[fontnum], fonts.size[fontnum], fonts.style[fontnum]}
- ELSE
- orig = {"", "", ""}
- END IF
- FormNew(FormQUnique)
- FormControl(_Size; _Center, _Center, 40 pct, 35 pct)
- FormSetObject(10, _CaptionCenter, "Current font: ", _Center, 5 pct, 100 pct, _Default)
- FormSetObject(15, _CaptionCenter, FdFontStr(orig), _Center, 25 pct, 100 pct, _Default)
- FormSetObject(20, _Button, "Select Font", _Center, 50 pct, 50 pct, _Default)
- FormSetObject(1, _Button, "OK", _Left, _Bottom)
- FormSetObject(2, _Button, "Cancel", _Right, _Bottom)
- newfont = orig
- result = fontnum
- LOOP
- SELECT CASE FormWait
- CASE 1 'OK
- IF Sum(newfont <> orig) THEN
- result = FDFontLookup(newfont[1], newfont[2], newfont[3])
- IF result <> fontnum THEN
- FDFontRefDec(fontnum)
- FDFontRefInc(result)
- END IF
- END IF
- EXIT LOOP
-
- CASE 2 'Cancel
- EXIT LOOP
-
- CASE 20 'Select Font
- tempfont = StdFont()
- IF tempfont[1] <> "" THEN
- newfont = tempfont
- FormModifyObject(15, _Normal, FdFontStr(newfont))
- END IF
- END SELECT
- END LOOP
- FormControl(_Close)
- RETURN result
- END FUNC
-
-
- FUNC FdFontStr (fontvect)
- LOCAL flags, s
-
- IF fontvect[1] = "" THEN
- RETURN "<default font>"
- END IF
- s = fontvect[1] + "-" + fontvect[2]
- flags = StrToNum(fontvect[3])
- IF flags THEN
- s = s + "/"
- IF flags mod 2 THEN
- s = s + "b"
- END IF
- flags = flags \ 2
- IF flags mod 2 THEN
- s = s + "i"
- END IF
- flags = flags \ 2
- IF flags mod 2 THEN
- s = s + "u"
- END IF
- flags = flags \ 2
- IF flags mod 2 THEN
- s = s + "s"
- END IF
- END IF
- RETURN s
- END FUNC
-