home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / windows / kpwdemo.zip / FONTDEM.SRC < prev    next >
Text File  |  1990-06-28  |  6KB  |  208 lines

  1. (* ============================= FONT.KB ===================================
  2.    FONT lets you see how different fonts appear on the screen and on your printer.  Once
  3.    you find a font which you want to use you can select COPY to copy the code to create
  4.    it to the clipboard. 
  5. ========================================================================== *)
  6.  
  7. w1 is window (,27,1,53,28,'', [PopUp,TitleBar,ThickFrame,ShowChildren]).
  8.  
  9. (* The #x is used to position the text in the correct column. This is done for compatibility
  10.     between Windows 2.0 which uses fixed fonts and 3.0 which uses proportional fonts.
  11.     Whenever possible it is faster to format text directly within the TEXT command instead
  12.     of using # display commands. *)
  13.  
  14. text ('
  15.    
  16.  
  17.                                         
  18.  
  19. #x3Width: #x20Height: #x36Family:
  20.  
  21. #x3Special: #x20Pitch:
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28. #x20Quality: #x36Font:
  29.                    
  30. #x3Set:').
  31.  
  32. CopiedtoClip is f.
  33.  
  34. fontList is ([12,8,400,'f','f','f',0,1,2,'System']).  
  35. fontHandle is create_font (?fontList).
  36. pitch is 2.
  37. family is 0.
  38.  
  39. w2 is window (,2.5,2,48,3,,[child,visible,thinframe],?w1).
  40. use_font (?fontHandle).
  41. text ('This is the sample font text.').
  42.  
  43. set_display_window (?w1).
  44.  
  45. ed1 is edit_line (12,makeWidth,11,5.8,5).
  46. ed2 is edit_line (8,makeHeight,28,5.8,5).
  47.  
  48. cb1 is check_box (Bold,bold,4,9.8).
  49. cb2 is check_box (Underline,underline,4,11.3).
  50. cb3 is check_box (Italic,italic,4,12.8).
  51. cb4 is check_box (Strikeout,strikeout,4,14.3).
  52.  
  53. rb1 is radio_button ([['ANSI', 4, 19, T],['OEM', 4, 20.5, ]],set).
  54. rb2 is radio_button ([['Default', 21, 10],['Fixed', 21, 11.5, ],['Variable', 21, 13, t]],pitch).
  55. rb3 is radio_button ([['Default', 21, 17],['Draft', 21, 18.5],['Proof', 21, 20,t ]], quality).
  56.  
  57. familyList is ['Don''t Care','Roman','Swiss','Modern','Script','Decorative'].
  58. lb1 is list_box (?familyList,family,36,7.2,13,6,,,[list_select_event,double_click_event]).
  59. lb2 is list_box (['System','Terminal','Roman','Script','Modern','Helv','Courier','Tms Rmn'],face,36,16.2,13,8,,,[list_select_event,double_click_event]).
  60.  
  61. button (Print,printIt,4,23).
  62. button (Copy, copy_font,13.5 , 23).
  63. button (Quit, quit_font, 22, 23).
  64.  
  65. pitchList is [Default, Fixed, Variable].
  66. qualityList is [Default, Draft, Proof].
  67.  
  68. (* Complicated window are drawn much quicker if they are created without a visible style
  69.    and then displayed using SHOW_WINDOW after all screen objects are created. *)
  70.  
  71. show_window (?w1).
  72.  
  73. topic makeWidth.
  74.   width is get_text (?ed1).
  75.   fontList is replace_elements (?fontList,2,?width).
  76.   showFont ().
  77. end.
  78.  
  79. topic makeHeight.
  80.   height is get_text (?ed2).
  81.   fontList is replace_elements (?fontList,1,?height).
  82.   showFont ().
  83. end.
  84.  
  85. topic bold.
  86.   if get_check_box (?cb1)
  87.      then bold is 400
  88.      else bold is 700.
  89.   fontList is replace_elements (?fontList,3,?bold).
  90.   showFont ().    
  91. end.
  92.  
  93. topic underline.
  94.   if get_check_box (?cb2)
  95.      then underline is f
  96.      else underline is t.
  97.   fontList is replace_elements (?fontList,5,?underline).
  98.   showFont ().    
  99. end.
  100.  
  101. topic italic.
  102.   if get_check_box (?cb3)
  103.      then italic is f
  104.      else italic is t.
  105.   fontList is replace_elements (?fontList,4,?italic).
  106.   showFont ().    
  107. end.
  108.  
  109. topic strikeout.
  110.   if get_check_box (?cb4)
  111.      then strikeout is f
  112.      else strikeout is t.
  113.   fontList is replace_elements (?fontList,6,?strikeout).
  114.   showFont ().    
  115. end.
  116.  
  117. topic set (item).
  118.   if ?item is 'ANSI' 
  119.      then set is 0
  120.      else set is 255.
  121.   fontList is replace_elements (?fontList,7,?set).
  122.   showFont ().
  123. end.
  124.  
  125. topic quality (item).
  126.   quality is (where (?qualityList,?item) - 1).
  127.   fontList is replace_elements (?fontList,8,?quality).
  128.   showFont ().
  129. end.
  130.  
  131. topic pitch (item).
  132.   pitch is (where (?pitchList,?item) - 1).
  133.   item is ?family + ?pitch.
  134.   fontList is replace_elements (?fontList,9,?item).
  135.   showFont ().
  136. end.
  137.  
  138. topic family (item).
  139.   family is (where (?familyList,?item) - 1)*16.
  140.   item is ?family + ?pitch.
  141.   fontList is replace_elements (?fontList,9,?item).
  142.   showFont ().
  143. end.
  144.  
  145. topic face (item).
  146.   fontList is replace_elements (?fontList,10,?item).
  147.   showFont ().
  148. end.
  149.  
  150. topic showFont.
  151.   CopiedtoClip is f.
  152.   delete_font (?fontHandle).
  153.   fontHandle is create_font (?fontList).
  154.   use_font (?fontHandle).
  155.   set_text (?w2,'This is the sample font text.').
  156. end.
  157.  
  158. topic copy_font.
  159.   CopiedtoClip is t.
  160.   fontText is concat ('create_font ([', list_to_string (?fontList, ',',,,''''), ']).').
  161.   text_to_clipboard (?fontText).
  162.   temp is window (,15.71,4.75,60.14,11.62,,[popup,showChildren,siblings,DialogFrame]).
  163.   make_modal (?temp).
  164.   use_font (system_font).
  165.   text ('
  166.   The code shown below has been copied to the clipboard:
  167.  ',?fontText).
  168.   use_font (?fontHandle).
  169.   button ('Continue',done,26.42,7.875,).
  170.   show_window ().
  171.  
  172.   topic done.
  173.     close_window (?temp).
  174.   end.
  175.  
  176. end.
  177.  
  178. topic quit_font.
  179.    if not (?CopiedtoClip)
  180.       then ask_quit ()
  181.       else finish ().
  182.  
  183.   topic ask_quit.
  184.     wSave is window (,25.42,12,29.71,9,,[popup,showChildren,siblings,DialogFrame]).
  185.     use_font (SYSTEM_FONT).
  186.     text ('
  187.   Copy the most recent
  188.   change  to the clipboard ?
  189.  ').
  190.      b1 is button ('Yes',[copy_font,finish],6,6,6).
  191.      button ('No', finish ,17,6,6).
  192.      show_window (?wSave).
  193.      set_focus (?b1).
  194.      make_modal (?wSave).
  195.   end.
  196.  
  197.   topic finish.
  198.     hide_window (?w1).
  199.     new_kb ('demo.ckb').
  200.   end.
  201.  
  202. end.
  203.  
  204. topic Printit.
  205.   fontText is concat ('create_font ([', list_to_string (?fontList, ',',,,''''), ']).').
  206.   use_font (?fontHandle, prn).
  207.   print (?fontText).
  208. end.