home *** CD-ROM | disk | FTP | other *** search
- '***********************************************************************
- ' FontView.rlz
- '
- ' Font Viewer
- '
- ' Copyright ⌐ 1991-1992 Computer Associates International, Inc.
- ' All rights reserved.
- '
- '***********************************************************************
-
- FUNC FormQCurStr (itemNum)
- ' Return the currently selected string, which may be different than
- ' FormQStr(itemNum) since the top part of the _ComboBox might not
- ' be updated yet.
- LOCAL J
-
- J = FormQNum(itemNum)
- IF J <> 0 THEN
- RETURN FormQStr(itemNum, J, 1)[J]
- ELSE
- RETURN FormQStr(itemNum)
- END IF
- END FUNC
-
- FUNC FormQRight (itemNum)
- LOCAL v
- v = FormQObject(itemNum)
- RETURN v[_FQO_Left] + v[_FQO_Width] + 5
- END FUNC
-
-
- FUNC FormQBottom (itemNum)
- LOCAL v
- v = FormQObject(itemNum)
- RETURN v[_FQO_Top] + v[_FQO_Height] + 5
- END FUNC
-
-
- PROC ResizeFormToObjects (lf, tp, rtID, botID)
- LOCAL v, newRight, newBot, freeID, actright, actbot, wd, ht
-
- v = FormQObject(rtID)
- newRight = v[_FQO_Left] + v[_FQO_Width]
- v = FormQObject(botID)
- newBot = v[_FQO_Top] + v[_FQO_Height]
-
- freeID = 29297
- WHILE FormQObject(freeID)[_FQO_ItemNum] = freeID
- freeID = freeID + 1
- END WHILE
- FormSetObject(freeID, _CaptionLeft, "", _Right, _Bottom)
- v = FormQObject(freeID)
- FormModifyObject(freeID, _Close)
- actbot = v[_FQO_Top] + v[_FQO_Height]
- actright = v[_FQO_Left] + v[_FQO_Width]
-
- v = FormQ(_Size)
- IF newRight > 0 THEN
- wd = v[3] + (newRight - actright)
- ELSE
- wd = _Default
- END IF
- IF newBot > 0 THEN
- ht = v[4] + (newbot - actbot)
- ELSE
- ht = _Default
- END IF
- FormControl(_Size; lf, tp, wd, ht)
- END PROC
-
- PROC ScreenSample ()
- LOCAL fnt, s, curSizeStr, curNameStr
-
- curNameStr = FormQCurStr(11)
- curSizeStr = FormQCurStr(12)
- curSize = StrToNum(curSizeStr)
- fnt = FontQUnique()
- FontNew(fnt; curNameStr, curSize)
- s = curNameStr + "-" + curSizeStr + CHR$(13) + CHR$(10)
- s = s + "The quick brown fox jumped over the lazy dog."
- FormSetObject(202, _EditText, s, fnt, sampBox[1], sampBox[2], sampBox[3], sampBox[4]; _Multiline + _NoBorder)
- FontControl(_Close)
- END PROC
-
- PROC PrintSample (bAllFonts)
- LOCAL fnt, styles, stStrs, fontNames, nm, sz
-
- fnt = FontQUnique()
- styles = {0, _Bold, _Italics}
- stStrs = {"Plain", "Bold", "Ital"}
-
- ' Do title.
- LogNew(LogQUnique(); SPrint("Realizer Fonts D(D1-M3-Y1 h1:m1) &", QDate(), IF QSys(_PrintBest) THEN "Best" ELSE "Fast"))
- LogControl(_Print; 0, 0, 1, 1)
- LogControl(_Close)
-
- LogSelect(_PrintLog)
-
- IF bAllFonts THEN
- fontNames = FormQStr(11, 1, 1000)
- ELSE
- fontNames = {FormQCurStr(11)}
- END IF
- FormSetObject(9909, _ListBox, "", 100pct, 100pct)
- FOR J = 1 TO EndValid(fontNames)
- nm = fontNames[J]
- FormModifyObject(9909, _Clear; _ListPrFontSizes, nm)
- fontSizes = FormQStr(9909, 1, 1000)
- IF EndValid(fontSizes) > 10 THEN
- fontSizes = {"3", "6", "12"}
- END IF
- FOR K = 1 TO EndValid(fontSizes)
- sz = fontSizes[K]
- FOR L = 1 TO EndValid(styles)
- FontNew(fnt; nm, StrToNum(sz), styles[L])
- LogControl(_SetFont; fnt)
- s = nm + "-" + sz + "/" + stStrs[L]
- FormSetObject(202, _CaptionLeft, "Printing " + s, fnt, sampBox[1], sampBox[2], sampBox[3], sampBox[4])
- LPRINT s, "The quick brown fox jumped over the lazy dog."
- NEXT L
- NEXT K
- NEXT J
- FormModifyObject(9909, _Close)
- FontControl(_Close)
- LFLUSH
- ScreenSample()
- END PROC
-
-
- PROC EnabButs (rsAttrib)
- LOCAL J
- FOR J = 103 TO 105
- FormModifyObject(J, rsAttrib)
- NEXT
- END PROC
-
-
- PROC RelistFontSizes (itemNum)
- LOCAL modf, av, idx, thisSize
-
- modf = IF FormQNum(101) THEN _ListFontSizes ELSE _ListPrFontSizes
- FormModifyObject(itemNum, _Clear)
- FormModifyObject(itemNum; modf, FormQCurStr(itemNum - 1))
- idx = 1
- IF QVar(curSize) THEN
- av = FormQStr(itemNum, 1, 1000)
- WHILE idx < ENDVALID(av)
- thisSize = StrToNum(av[idx])
- IF thisSize >= curSize THEN
- IF idx > 1 THEN 'Check if previous was closer.
- IF curSize - StrToNum(av[idx - 1]) < thisSize - curSize THEN
- idx = idx - 1
- END IF
- END IF
- EXIT WHILE
- END IF
- idx = idx + 1
- END WHILE
- END IF
- FormModifyObject(itemNum; _ListSelect, idx)
- ScreenSample()
- END PROC
-
-
- PROC RelistFonts ()
- FormModifyObject(11, _Clear)
- FormModifyObject(12, _Clear)
- FormModifyObject(11; IF FormQNum(101) THEN _ListFonts ELSE _ListPrFonts)
- FormModifyObject(11; _ListSelect, 1)
- RelistFontSizes(12)
- END PROC
-
-
- PROC FontTestProc (v)
- IF v[_Invoke] <> _Click THEN
- IF v[_Invoke] = _Close THEN
- CLEAR sampBox, curSize
- END IF
- END IF
- FormSelect(v[_FormNum])
- SELECT CASE v[_ItemNum]
- CASE 101 'Screen
- RelistFonts()
- EnabButs(_Gray)
- CASE 102 'Printer
- RelistFonts()
- EnabButs(_Normal)
- CASE 103 'Quality
- SetSys(_PrintBest, FormQNum(103))
- RelistFonts()
- CASE 11
- RelistFontSizes(12)
- CASE 12
- ScreenSample()
- CASE 104 'Print - selected font only
- PrintSample(0)
- CASE 105 'Print All - all fonts
- PrintSample(1)
- CASE 1, 106 'Required if you type in a font size (no _Notify on item 12 then)
- ScreenSample()
- END SELECT
- END PROC
-
-
- LOCAL lf, wd, lineHt, box
- ' NOTE: curSize and sampBox are global.
-
- FontNew(1; "Helv", 8, _Bold)
- FormNew(1; "Font Viewer", _Title + _Close + _Minimize)
- FormControl(_Size; 0, 0, 300pxl, 100pct)
- FormSetObject(11, _CaptionLeft, "Hello", 1, 0, 0)
- lineHt = FormQObject(11)[_FQO_Height]
- lf = _Left
- wd = 140pxl
- FormSetObject(11, _ComboBox, "", 1, lf, _Top, wd, 15 * lineHt; _Sorted + _Notify)
- lf = FormQRight(11)
- wd = 50pxl
- FormSetObject(12, _ComboBox, "", 1, lf, _Top, wd, 15 * lineHt; _Notify)
- lf = FormQRight(12)
- wd = _Default
- FormSetObject(101, _OptionButton, "Screen", 1, lf, _Top, wd, _Default; _Notify, 1)
- FormSetObject(102, _OptionButton, "Printer", 1, lf, FormQBottom(101), wd, _Default; _Notify, 0)
- FormSetObject(103, _CheckBox, "Best Quality", 1, lf, FormQBottom(102), wd, _Default; _Notify, QSys(_PrintBest))
- FormSetObject(104, _Button, "Print", 1, _Right, FormQBottom(103))
- FormSetObject(105, _Button, "Print All", 1, _Right, FormQBottom(104))
- 'FormSetObject(106, _Button, "Sample", 1, _Right, FormQBottom(105))
- FormSetObject(201, _GroupBox, "Sample", 1, _Left, FormQBottom(11), 100pct, 7 * lineHt)
- sampBox[1 : 4] = FormQObject(201)[_FQO_Left : _FQO_Height]
- sampBox = sampBox + {5, lineHt + 5, -10, -2 * lineHt}
- ResizeFormToObjects(_Center, _Center, 201, 201)
- EnabButs(IF FormQNum(102) THEN _Normal ELSE _Gray)
- RelistFonts()
- FormControl(_Show)
- FormSetProc(FontTestProc)
-