home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / PRESPM.ZIP / FNTDEMO.EAL < prev    next >
Text File  |  1990-10-05  |  13KB  |  432 lines

  1. ##############################################################################
  2. #
  3. # FntDemo.eal
  4. #            
  5. # This is a demonstration application that simply shows the use of the
  6. # FntDemo.dll subroutines "ChangeHANDLE_FontToPOINTS_FACE_"
  7. # and "ErrMsgFromChangeHANDLEFont."
  8. #            
  9.  
  10. screen size 640 480     
  11.  
  12. include "accel.inc"
  13. include "fileio.inc"
  14. include "message.inc"    
  15.  
  16. ##############################################################################
  17. #
  18. # subroutine/function declarations
  19. #            
  20.  
  21. include "fntdemo.inc"  
  22.   
  23. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
  24. subroutine Initialize
  25.     (
  26.     )
  27. subroutine ChangeObjectAttrs
  28.     ( string  : ObjectName
  29.     , string  : FontName
  30.     , string  : ColorName
  31.     , string  : WhatPP  
  32.     )   
  33. subroutine ChangeFont 
  34.     ( string  : ObjectName
  35.     , string  : FontName
  36.     )   
  37. subroutine ChangeColor
  38.     ( string  : ObjectName
  39.     , string  : ColorName
  40.     , string  : WhatPP
  41.     )   
  42. ##############################################################################
  43. #
  44. # Primary Window Region Definition
  45. #
  46.  
  47. enabled invisible primary dialog region PrimaryWindow
  48.     size 330 202 
  49.     at position 10 10
  50.     size border
  51.     title bar "FntDemo"
  52.     vertical   scroll bar scroll by 8
  53.     horizontal scroll bar scroll by 8
  54.     system menu
  55. #   maximize button
  56.  
  57. enabled visible checked radio button RB1
  58.     size 180 16 
  59.     at position  0 165
  60.     in PrimaryWindow 
  61.     group is G_RB
  62.     text "Sample radio RB1"
  63.  
  64. disabled visible         radio button RB2
  65.     size 180 16 
  66.     at position  0 149
  67.     in PrimaryWindow 
  68.     group is G_RB
  69.     text "Disabled radio RB2"
  70.  
  71. enabled visible check box   CB
  72.     size 180 16 
  73.     at position  0 133
  74.     in PrimaryWindow 
  75.     text "Sample checkbox CB"
  76.  
  77. enabled visible static text ST
  78.     size 180 20 
  79.     at position  0 113
  80.     in PrimaryWindow 
  81.     left align top align
  82.     text "Sample static text ST"
  83.  
  84. enabled visible entry field EF
  85.     size 180 28               
  86.     at position  0 85 
  87.     in PrimaryWindow
  88.     text "Sample entry field EF"
  89.  
  90. enabled visible list box LB
  91.     size 180 60
  92.     at position 0  25
  93.     in PrimaryWindow   
  94.     horizontal scroll bar
  95.     insert "This is listbox LB"
  96.     insert "abcdefghijklmnopqrstuvwxyz"
  97.     insert "nopqrstuvwxyzabcdefghijklm"
  98.     insert "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  99.     insert "NOPQRSTUVWXYZABCDEFGHIJKLM"
  100.     insert "`~!@#$%^&*()-_=+[]{}\\|;:'\",.<>/?"
  101.     insert "0123456789"
  102.  
  103. disabled visible         push button PB1
  104.     size  83 24
  105.     at position 5    0 
  106.     in PrimaryWindow
  107.     text "~Disabled"
  108.  
  109. enabled visible         push button PB2
  110.     size  83 24
  111.     at position 94   0 
  112.     in PrimaryWindow
  113.     text "~Enabled"
  114.  
  115. enabled visible static text ST_What
  116.     size 140 12 
  117.     at position  190 165
  118.     in PrimaryWindow 
  119.     left align top align
  120.     text "Select a window part:"
  121.            
  122. enabled visible dropdown list DL_What
  123.     size 140 80
  124.     at   190  85
  125.     in PrimaryWindow
  126.     text size 17 columns
  127.     text "foreground"
  128.     insert "foreground"
  129.     insert "background"
  130.     insert "border"
  131.     insert "hilite foreground"
  132.     insert "hilite background"
  133.     insert "disabled foreground"
  134.     insert "disabled background"
  135.  
  136. enabled visible static text ST_Color
  137.     size 140 12 
  138.     at position  190 129
  139.     in PrimaryWindow 
  140.     left align top align
  141.     text "...and its color:"
  142.  
  143. enabled visible dropdown list DL_Color
  144.     size 140 80
  145.     at   190 49
  146.     in PrimaryWindow
  147.     text size 17 columns
  148.     text "default"
  149.     insert "default"
  150.     insert "red"
  151.     insert "green"
  152.     insert "yellow"
  153.     insert "blue"
  154.     insert "magenta"
  155.     insert "cyan"
  156.     insert "white"
  157.     insert "black"
  158.     insert "dark gray"
  159.     insert "dark blue"
  160.     insert "dark red"
  161.     insert "dark magenta"
  162.     insert "dark green"
  163.     insert "dark cyan"
  164.     insert "dark yellow"
  165.     insert "pale gray"
  166.     insert "window background"
  167.     insert "window text"
  168.  
  169. enabled visible static text ST_font
  170.     size 140 12 
  171.     at position  190  93
  172.     in PrimaryWindow 
  173.     left align top align
  174.     text "...and the font, e.g. \"12.Helv\":"
  175.  
  176. enabled visible entry field EF_font
  177.     size 140 12               
  178.     at position  190  81
  179.     in PrimaryWindow
  180.  
  181. enabled visible static text ST_results
  182.     size 140 12 
  183.     at position  190  69
  184.     in PrimaryWindow 
  185.     left align top align
  186.     text "Results:"
  187.  
  188. enabled visible list box LB_results
  189.     size 140 44
  190.     at position 190 25
  191.     in PrimaryWindow   
  192.     horizontal scroll bar
  193.  
  194. enabled visible default push button PB_Apply
  195.     size 60 24
  196.     at position 190  0 
  197.     in PrimaryWindow
  198.     text "~Apply"
  199.            
  200. enabled visible group box GB_sepV
  201.     size 1 187              
  202.     at position  187 0 
  203.     in PrimaryWindow
  204.  
  205. enabled visible group box GB_sepH
  206.     size 330 5            
  207.     at position  0 183 
  208.     in PrimaryWindow
  209.  
  210. enabled visible static text ST_topinstr
  211.     size 330 18 
  212.     at position  0  184
  213.     in PrimaryWindow 
  214.     left align top align word wrap
  215.     text "Select your choices for presentation parameters from the section below right.  The section below left will show the changed appearance."
  216.  
  217. ##############################################################################
  218. #
  219. # common variable definitions  
  220. #            
  221. integer
  222.     Handle        
  223.  
  224. string 
  225.     FontName                              
  226.     ColorName                              
  227.     ObjectName                            
  228.     WhatPP        
  229.  
  230. ##############################################################################
  231. #
  232. # responses
  233. #              
  234. response to start 
  235.     call Initialize ()
  236.     make PrimaryWindow visible
  237.  
  238. response to PB_Apply
  239.  
  240.     copy text of EF_font to FontName
  241.     copy text of DL_Color to ColorName
  242.     copy text of DL_What  to WhatPP
  243.     clear LB_results
  244.  
  245.     copy "LB"  to ObjectName 
  246.     call ChangeObjectAttrs ( ObjectName, FontName, ColorName, WhatPP )
  247.  
  248.     copy "EF"  to ObjectName
  249.     call ChangeObjectAttrs ( ObjectName, FontName, ColorName, WhatPP )
  250.  
  251.     copy "PB1"  to ObjectName
  252.     call ChangeObjectAttrs ( ObjectName, FontName, ColorName, WhatPP )
  253.  
  254.     copy "PB2"  to ObjectName
  255.     call ChangeObjectAttrs ( ObjectName, FontName, ColorName, WhatPP )
  256.  
  257.     copy "ST"  to ObjectName
  258.     call ChangeObjectAttrs ( ObjectName, FontName, ColorName, WhatPP )
  259.  
  260.     copy "CB"  to ObjectName
  261.     call ChangeObjectAttrs ( ObjectName, FontName, ColorName, WhatPP )
  262.  
  263.     copy "RB1" to ObjectName
  264.     call ChangeObjectAttrs ( ObjectName, FontName, ColorName, WhatPP )
  265.  
  266.     copy "RB2" to ObjectName
  267.     call ChangeObjectAttrs ( ObjectName, FontName, ColorName, WhatPP )     
  268.  
  269.  
  270. ##############################################################################
  271. #
  272. # subroutine definitions
  273. #     
  274.  
  275. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
  276. subroutine Initialize () is
  277.     string  FontName
  278.     integer ColorNumber
  279.     integer Handle
  280.     copy "8.Courier" to FontName
  281.     copy handle of LB_results to Handle
  282.     call ChangeHANDLE_FontToPOINTSFACE_ ( Handle, FontName ) 
  283.     copy "10.Helv" to FontName
  284.     copy handle of ST_topinstr to Handle
  285.     call ChangeHANDLE_FontToPOINTSFACE_ ( Handle, FontName ) 
  286.     copy 3 to ColorNumber # 3=yellow
  287.     call MakeHANDLE_BackCOLOR_ ( Handle, ColorNumber )
  288. #   end subroutine
  289. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
  290. subroutine ChangeObjectAttrs
  291.     ( string  : ObjectName
  292.     , string  : FontName
  293.     , string  : ColorName
  294.     , string  : WhatPP
  295.     ) is            
  296.  
  297.     integer Handle
  298.     string  Error  
  299.     string  ErrorLogMsg
  300.  
  301.     call ChangeFont ( ObjectName, FontName )
  302.     call ChangeColor ( ObjectName, ColorName, WhatPP )
  303. #   end subroutine
  304. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
  305. subroutine ChangeFont 
  306.     ( string  : ObjectName
  307.     , string  : FontName
  308.     ) is            
  309.  
  310.     integer Handle
  311.     string  Error  
  312.     string  ErrorLogMsg
  313.  
  314.     copy handle of (ObjectName) to Handle  
  315.     if ( FontName != "" ) then
  316.         call ChangeHANDLE_FontToPOINTSFACE_ ( Handle, FontName ) 
  317.     else
  318.         call ChangeHANDLE_FontToDefault ( Handle ) 
  319.         end if
  320.     copy ObjectName 
  321.         " " errorlevel 
  322.         " Error=<" ErrMsgFromChangeHANDLEFont ( errorlevel ) ">" 
  323.         " font=<" FontName ">" 
  324.         to ErrorLogMsg
  325.     add to LB_results insert ErrorLogMsg
  326. ####send ErrorLogMsg to errorlog
  327. #   end subroutine
  328. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
  329. subroutine ChangeColor
  330.     ( string  : ObjectName
  331.     , string  : ColorName
  332.     , string  : WhatPP
  333.     ) is            
  334.  
  335.     integer Handle
  336.     string  Error  
  337.     string  ErrorLogMsg
  338.     integer ColorNumber
  339.  
  340.     copy handle of (ObjectName) to Handle 
  341.     switch ColorName is
  342.         case char col 1 "default" is
  343.             copy  0 to ColorNumber
  344.         case char col 1 "red" is
  345.             copy  1 to ColorNumber
  346.         case char col 1 "green" is
  347.             copy  2 to ColorNumber
  348.         case char col 1 "yellow" is
  349.             copy  3 to ColorNumber
  350.         case char col 1 "blue" is
  351.             copy  4 to ColorNumber
  352.         case char col 1 "magenta" is
  353.             copy  5 to ColorNumber
  354.         case char col 1 "cyan" is
  355.             copy  6 to ColorNumber
  356.         case char col 1 "white" is
  357.             copy  7 to ColorNumber
  358.         case char col 1 "black" is
  359.             copy  8 to ColorNumber
  360.         case char col 1 "dark gray" is
  361.             copy 18 to ColorNumber
  362.         case char col 1 "dark blue" is
  363.             copy 19 to ColorNumber
  364.         case char col 1 "dark red" is
  365.             copy 20 to ColorNumber
  366.         case char col 1 "dark magenta" is
  367.             copy 21 to ColorNumber
  368.         case char col 1 "dark green" is
  369.             copy 22 to ColorNumber
  370.         case char col 1 "dark cyan" is
  371.             copy 23 to ColorNumber
  372.         case char col 1 "dark yellow" is
  373.             copy 24 to ColorNumber
  374.         case char col 1 "pale gray" is
  375.             copy 25 to ColorNumber
  376.         case char col 1 "window background" is
  377.             copy 26 to ColorNumber
  378.         case char col 1 "window text" is
  379.             copy 27 to ColorNumber     
  380.         default is
  381.         end switch 
  382.          
  383.     switch WhatPP is
  384.         case char col 1 "foreground" is
  385.             if  ( ColorNumber = 0 ) then 
  386.                 copy 27 to ColorNumber
  387.                 end if
  388.             call MakeHANDLE_ForeCOLOR_ ( Handle, ColorNumber )
  389.         case char col 1 "background" is
  390.             if  ( ColorNumber = 0 ) then 
  391.                 copy 26 to ColorNumber
  392.                 end if
  393.             call MakeHANDLE_BackCOLOR_ ( Handle, ColorNumber )
  394.         case char col 1 "hilite foreground" is
  395.             if  ( ColorNumber = 0 ) then 
  396.                 copy 26 to ColorNumber
  397.                 end if
  398.             call MakeHANDLE_HiliteForeCOLOR_ ( Handle, ColorNumber )
  399.         case char col 1 "hilite background" is
  400.             if  ( ColorNumber = 0 ) then 
  401.                 copy 27 to ColorNumber
  402.                 end if
  403.             call MakeHANDLE_HiliteBackCOLOR_ ( Handle, ColorNumber )
  404.         case char col 1 "disabled foreground" is
  405.             if  ( ColorNumber = 0 ) then 
  406.                 copy 25 to ColorNumber
  407.                 end if
  408.             call MakeHANDLE_DisabledForeCOLOR_ ( Handle, ColorNumber )
  409.         case char col 1 "disabled background" is
  410.             if  ( ColorNumber = 0 ) then 
  411.                 copy 26 to ColorNumber
  412.                 end if
  413.             call MakeHANDLE_DisabledBackCOLOR_ ( Handle, ColorNumber )
  414.         case char col 1 "border" is
  415.             if  ( ColorNumber = 0 ) then 
  416.                 copy 27 to ColorNumber
  417.                 end if
  418.             call MakeHANDLE_BorderCOLOR_ ( Handle, ColorNumber )
  419.         default is
  420.         end switch 
  421.  
  422.     copy ObjectName 
  423.         " " errorlevel 
  424.         " Error=<" ErrMsgFromMakeHANDLECOLOR ( errorlevel ) ">" 
  425.         " attr=<" WhatPP ">" 
  426.         " color=<" ColorName ">" 
  427.         to ErrorLogMsg
  428.     add to LB_results insert ErrorLogMsg
  429. ####send ErrorLogMsg to errorlog
  430. #   end subroutine
  431. # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 
  432.