home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / mprocs / typebind.icn < prev    next >
Text File  |  2000-07-29  |  2KB  |  57 lines

  1. ############################################################################
  2. #
  3. #    File:     typebind.icn
  4. #
  5. #    Subject:  Procedures to produce table of graphic contexts for type
  6. #
  7. #    Author:   Ralph E. Griswold and Clinton L. Jeffery
  8. #
  9. #    Date:     March 4, 1997
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  typebind(window, codes, opts) returns a table of graphic contexts bound to 
  18. #  window with foreground colors keyed by type in the string of event codes.
  19. #
  20. #  Codes for which there is no corresponding color are ignored.
  21. #
  22. #  Note:  Event monitoring global identifiers must be linked by the program
  23. #  that uses this procedure.
  24. #
  25. ############################################################################
  26. #
  27. #  Links: colormap
  28. #
  29. ############################################################################
  30. #
  31. #  Requires: Version 9 graphics
  32. #
  33. ############################################################################
  34.  
  35. link colormap
  36.  
  37. procedure typebind(window, codes, opts)
  38.    local code, context
  39.    static contexts, color
  40.  
  41.    initial {
  42.       contexts := table()
  43.       if /opts then color := colormap("standard")
  44.       else color := colormap(opts["p"])
  45.       }
  46.  
  47.    if /contexts[window] := table() then {
  48.       context := contexts[window]
  49.       every code := !codes do
  50.          context[code] := Clone(window, , "fg=" || \color[code])
  51.       }
  52.    contexts[window]["bg"] := Clone(window, "fg=" || WAttrib(window,"bg"))
  53.    return contexts[window]
  54.  
  55. end
  56.  
  57.