home *** CD-ROM | disk | FTP | other *** search
/ TestDrive Super Store 2.3 / TESTDRIVE_2.ISO / realizer / utility / fontview.rlz < prev    next >
Encoding:
Text File  |  1992-09-30  |  6.4 KB  |  235 lines

  1. '***********************************************************************
  2. '    FontView.rlz                          
  3. '
  4. '    Font Viewer
  5. '
  6. '    Copyright ⌐ 1991-1992 Computer Associates International, Inc.
  7. '    All rights reserved.
  8. '
  9. '***********************************************************************
  10.  
  11. FUNC FormQCurStr (itemNum)
  12.     ' Return the currently selected string, which may be different than
  13.     ' FormQStr(itemNum) since the top part of the _ComboBox might not
  14.     ' be updated yet.
  15.     LOCAL    J
  16.  
  17.     J = FormQNum(itemNum)
  18.     IF J <> 0 THEN
  19.         RETURN FormQStr(itemNum, J, 1)[J]
  20.     ELSE
  21.         RETURN FormQStr(itemNum)
  22.     END IF
  23. END FUNC
  24.  
  25. FUNC FormQRight (itemNum)
  26.     LOCAL    v
  27.     v = FormQObject(itemNum)
  28.     RETURN v[_FQO_Left] + v[_FQO_Width] + 5
  29. END FUNC
  30.  
  31.  
  32. FUNC FormQBottom (itemNum)
  33.     LOCAL    v
  34.     v = FormQObject(itemNum)
  35.     RETURN v[_FQO_Top] + v[_FQO_Height] + 5
  36. END FUNC
  37.  
  38.  
  39. PROC ResizeFormToObjects (lf, tp, rtID, botID)
  40.     LOCAL    v, newRight, newBot, freeID, actright, actbot, wd, ht
  41.  
  42.     v = FormQObject(rtID)
  43.     newRight = v[_FQO_Left] + v[_FQO_Width]
  44.     v = FormQObject(botID)
  45.     newBot = v[_FQO_Top] + v[_FQO_Height]
  46.  
  47.     freeID = 29297
  48.     WHILE FormQObject(freeID)[_FQO_ItemNum] = freeID
  49.         freeID = freeID + 1
  50.     END WHILE
  51.     FormSetObject(freeID, _CaptionLeft, "", _Right, _Bottom)
  52.     v = FormQObject(freeID)
  53.     FormModifyObject(freeID, _Close)
  54.     actbot = v[_FQO_Top] + v[_FQO_Height]
  55.     actright = v[_FQO_Left] + v[_FQO_Width]
  56.  
  57.     v = FormQ(_Size)
  58.     IF newRight > 0 THEN
  59.         wd = v[3] + (newRight - actright)
  60.     ELSE
  61.         wd = _Default
  62.     END IF
  63.     IF newBot > 0 THEN
  64.         ht = v[4] + (newbot - actbot)
  65.     ELSE
  66.         ht = _Default
  67.     END IF
  68.     FormControl(_Size; lf, tp, wd, ht)
  69. END PROC
  70.  
  71. PROC ScreenSample ()
  72.     LOCAL    fnt, s, curSizeStr, curNameStr
  73.  
  74.     curNameStr = FormQCurStr(11)
  75.     curSizeStr = FormQCurStr(12)
  76.     curSize = StrToNum(curSizeStr)
  77.     fnt = FontQUnique()
  78.     FontNew(fnt; curNameStr, curSize)
  79.     s = curNameStr + "-" + curSizeStr + CHR$(13) + CHR$(10)
  80.     s = s + "The quick brown fox jumped over the lazy dog."
  81.     FormSetObject(202, _EditText, s, fnt, sampBox[1], sampBox[2], sampBox[3], sampBox[4]; _Multiline + _NoBorder)
  82.     FontControl(_Close)
  83. END PROC
  84.  
  85. PROC PrintSample (bAllFonts)
  86.     LOCAL    fnt, styles, stStrs, fontNames, nm, sz
  87.  
  88.     fnt = FontQUnique()
  89.     styles = {0, _Bold, _Italics}
  90.     stStrs = {"Plain", "Bold", "Ital"}
  91.  
  92.     ' Do title.
  93.     LogNew(LogQUnique(); SPrint("Realizer Fonts  D(D1-M3-Y1 h1:m1) &", QDate(), IF QSys(_PrintBest) THEN "Best" ELSE "Fast"))
  94.     LogControl(_Print; 0, 0, 1, 1)
  95.     LogControl(_Close)
  96.  
  97.     LogSelect(_PrintLog)
  98.  
  99.     IF bAllFonts THEN
  100.         fontNames = FormQStr(11, 1, 1000)
  101.     ELSE
  102.         fontNames = {FormQCurStr(11)}
  103.     END IF
  104.     FormSetObject(9909, _ListBox, "", 100pct, 100pct)
  105.     FOR J = 1 TO EndValid(fontNames)
  106.         nm = fontNames[J]
  107.         FormModifyObject(9909, _Clear; _ListPrFontSizes, nm)
  108.         fontSizes = FormQStr(9909, 1, 1000)
  109.         IF EndValid(fontSizes) > 10 THEN
  110.             fontSizes = {"3", "6", "12"}
  111.         END IF
  112.         FOR K = 1 TO EndValid(fontSizes)
  113.             sz = fontSizes[K]
  114.             FOR L = 1 TO EndValid(styles)
  115.                 FontNew(fnt; nm, StrToNum(sz), styles[L])
  116.                 LogControl(_SetFont; fnt)
  117.                 s = nm + "-" + sz + "/" + stStrs[L]
  118.                 FormSetObject(202, _CaptionLeft, "Printing " + s, fnt, sampBox[1], sampBox[2], sampBox[3], sampBox[4])
  119.                 LPRINT s, "The quick brown fox jumped over the lazy dog."
  120.             NEXT L
  121.         NEXT K
  122.     NEXT J
  123.     FormModifyObject(9909, _Close)
  124.     FontControl(_Close)
  125.     LFLUSH
  126.     ScreenSample()
  127. END PROC
  128.  
  129.  
  130. PROC EnabButs (rsAttrib)
  131.     LOCAL    J
  132.     FOR J = 103 TO 105
  133.         FormModifyObject(J, rsAttrib)
  134.     NEXT
  135. END PROC
  136.  
  137.  
  138. PROC RelistFontSizes (itemNum)
  139.     LOCAL    modf, av, idx, thisSize
  140.  
  141.     modf = IF FormQNum(101) THEN _ListFontSizes ELSE _ListPrFontSizes
  142.     FormModifyObject(itemNum, _Clear)
  143.     FormModifyObject(itemNum; modf, FormQCurStr(itemNum - 1))
  144.     idx = 1
  145.     IF QVar(curSize) THEN
  146.         av = FormQStr(itemNum, 1, 1000)
  147.         WHILE idx < ENDVALID(av)
  148.             thisSize = StrToNum(av[idx])
  149.             IF thisSize >= curSize THEN
  150.                 IF idx > 1 THEN        'Check if previous was closer.
  151.                     IF curSize - StrToNum(av[idx - 1]) < thisSize - curSize THEN
  152.                         idx = idx - 1
  153.                     END IF
  154.                 END IF
  155.                 EXIT WHILE
  156.             END IF
  157.             idx = idx + 1
  158.         END WHILE
  159.     END IF
  160.     FormModifyObject(itemNum; _ListSelect, idx)
  161.     ScreenSample()
  162. END PROC
  163.  
  164.  
  165. PROC RelistFonts ()
  166.     FormModifyObject(11, _Clear)
  167.     FormModifyObject(12, _Clear)
  168.     FormModifyObject(11; IF FormQNum(101) THEN _ListFonts ELSE _ListPrFonts)
  169.     FormModifyObject(11; _ListSelect, 1)
  170.     RelistFontSizes(12)
  171. END PROC
  172.  
  173.  
  174. PROC FontTestProc (v)
  175.     IF v[_Invoke] <> _Click THEN
  176.         IF v[_Invoke] = _Close THEN
  177.             CLEAR sampBox, curSize
  178.         END IF
  179.     END IF
  180.     FormSelect(v[_FormNum])
  181.     SELECT CASE v[_ItemNum]
  182.     CASE 101            'Screen
  183.         RelistFonts()
  184.         EnabButs(_Gray)
  185.     CASE 102            'Printer
  186.         RelistFonts()
  187.         EnabButs(_Normal)
  188.     CASE 103            'Quality
  189.         SetSys(_PrintBest, FormQNum(103))
  190.         RelistFonts()
  191.     CASE 11
  192.         RelistFontSizes(12)
  193.     CASE 12
  194.         ScreenSample()
  195.     CASE 104            'Print - selected font only
  196.         PrintSample(0)
  197.     CASE 105            'Print All - all fonts
  198.         PrintSample(1)
  199.     CASE 1, 106        'Required if you type in a font size (no _Notify on item 12 then)
  200.         ScreenSample()
  201.     END SELECT
  202. END PROC
  203.  
  204.  
  205. LOCAL    lf, wd, lineHt, box
  206. ' NOTE: curSize and sampBox are global.
  207.  
  208. FontNew(1; "Helv", 8, _Bold)
  209. FormNew(1; "Font Viewer", _Title + _Close + _Minimize)
  210. FormControl(_Size; 0, 0, 300pxl, 100pct)
  211. FormSetObject(11, _CaptionLeft, "Hello", 1, 0, 0)
  212. lineHt = FormQObject(11)[_FQO_Height]
  213. lf = _Left
  214. wd = 140pxl
  215. FormSetObject(11, _ComboBox, "", 1, lf, _Top, wd, 15 * lineHt; _Sorted + _Notify)
  216. lf = FormQRight(11)
  217. wd = 50pxl
  218. FormSetObject(12, _ComboBox, "", 1, lf, _Top, wd, 15 * lineHt; _Notify)
  219. lf = FormQRight(12)
  220. wd = _Default
  221. FormSetObject(101, _OptionButton, "Screen", 1, lf, _Top, wd, _Default; _Notify, 1)
  222. FormSetObject(102, _OptionButton, "Printer", 1, lf, FormQBottom(101), wd, _Default; _Notify, 0)
  223. FormSetObject(103, _CheckBox, "Best Quality", 1, lf, FormQBottom(102), wd, _Default; _Notify, QSys(_PrintBest))
  224. FormSetObject(104, _Button, "Print", 1, _Right, FormQBottom(103))
  225. FormSetObject(105, _Button, "Print All", 1, _Right, FormQBottom(104))
  226. 'FormSetObject(106, _Button, "Sample", 1, _Right, FormQBottom(105))
  227. FormSetObject(201, _GroupBox, "Sample", 1, _Left, FormQBottom(11), 100pct, 7 * lineHt)
  228. sampBox[1 : 4] = FormQObject(201)[_FQO_Left : _FQO_Height]
  229. sampBox = sampBox + {5, lineHt + 5, -10, -2 * lineHt}
  230. ResizeFormToObjects(_Center, _Center, 201, 201)
  231. EnabButs(IF FormQNum(102) THEN _Normal ELSE _Gray)
  232. RelistFonts()
  233. FormControl(_Show)
  234. FormSetProc(FontTestProc)
  235.