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

  1. (* ========================= COLOR.KB =================================
  2.    This KB shows the colors associated with different RBG values. Standard color
  3.    names can be used to name colors for text and window backgrounds. These are
  4.    shown in PALETTE.KB.  If you want to use window background colors other than the
  5.    ones defined you can use the RBG values shown in this KB. 
  6. =====================================================================*)
  7.  
  8. collect_not_ok ().
  9. from_edit is no.  (* When the value of the color is changed using the scroll bars
  10.                                the number is written into the edit line. Before the value is
  11.                                written into the edit line, this topic is checked to make sure that
  12.                                the value was not typed into the editor in the first place. *)
  13.  
  14. w2 is window (,21,2,38,20,,[popup,thickframe,titlebar,showchildren]).  
  15. [color,green,red,blue] is 0.  
  16.  
  17. (* The #x is used to position the text in the correct column. This is done for compatibility
  18.     between Windows 2.0 which uses fixed fonts and 3.0 which uses proportional fonts.
  19.     Whenever possible it is faster to format text directly within the TEXT command instead
  20.     of using # display commands. *)
  21.  
  22. text ('  
  23. #x24RBG VALUE:  
  24.   
  25.                        
  26.  
  27.   
  28.   
  29.        
  30. #x9GREEN  
  31.   
  32.   
  33.   
  34. #x9RED  
  35.   
  36.   
  37.   
  38. #x9BLUE').  
  39.   
  40. g is horz_scroll_bar (green,4,7,15,1.5,0,85).  
  41. r is horz_scroll_bar (red,4,11,15,1.5,0,85).  
  42. b is horz_scroll_bar (blue,4,15,15,1.5,0,85).
  43. ed1 is edit_line (0,define,24,4,12,[char_event]).  
  44. button (Copy,copy,25,9).  
  45. button (Quit,quit,25,14). 
  46. w1 is window (,4,2,15,3,,[child,visible,thinframe,siblings],?w2,,?color).  
  47.  
  48. (* Complicated window are drawn much quicker if they are created without a visible style
  49.    and then displayed using SHOW_WINDOW after all screen objects are created. *)
  50.  
  51. show_window (?w2). 
  52. set_focus (?ed1). 
  53.  
  54. topic define (item).
  55.   if ?item is 13
  56.      then color_value is get_text (?ed1) and
  57.           blue is ?color_value DIV 65536 and
  58.           remain is ?color_value - (?blue * 65536) and
  59.           green is ?remain DIV 256 and
  60.           red is ?remain - (?green * 256) and
  61.           from_edit is yes and
  62.           displayWindow () and
  63.           set_scroll_bar (?b,?blue/3) and
  64.           set_scroll_bar (?g,?green/3) and
  65.           set_scroll_bar (?r,?red/3) and
  66.           from_edit is no and
  67.           define is true.
  68. end.
  69.  
  70. topic copy.  
  71.   text_to_clipboard (?color).  
  72.   :temp is window ((* eventTopic*),21,2,50,20.43,,[popup,thickFrame,titleBar,showChildren,siblings]).
  73.   make_modal (?temp).
  74.   text ('
  75.   The RGB value for the color you selected is:
  76.  
  77.         #s',?color,'#l
  78.  
  79.  
  80.   This number has been copied to the clipboard.
  81.   It can be used to change the color of window
  82.   backgrounds or text. For example:
  83.  
  84.   window (,2,4,30,50,hello, , , , #s',?color,'#l).
  85.  
  86.   Creates a window with the background of the
  87.   selected color.  Standard color names can also
  88.   be used. To see examples of the standard
  89.   colors, run the program PALETTE.
  90.  ').
  91.   button (Continue,done,21,16.5,).
  92.   show_window ().
  93.   set_focus (?ed1).
  94.  
  95.   topic done.
  96.     close_window (?temp).
  97.   end.
  98.  
  99. end.  
  100.   
  101. topic quit.
  102.   new_kb ('demo.ckb').  
  103. end.  
  104.   
  105. topic green (value).  
  106.   green is ?value * 3.  
  107.   if ?from_edit is no then displayWindow ().  
  108. end.  
  109.   
  110. topic red (value).  
  111.   red is ?value * 3.  
  112.   if ?from_edit is no then displayWindow ().  
  113. end.  
  114.   
  115. topic blue (value).  
  116.   blue is ?value * 3.  
  117.   if ?from_edit is no then displayWindow ().  
  118.   collect ().
  119. end.  
  120.   
  121. topic displayWindow .  
  122.   color is (65536 * ?blue) + (256 * ?green) + ?red.  
  123.   temp is ?w1.
  124.   w1 is window (,4,2,15,3,,[child,thinframe,siblings],?w2,,?color).  
  125.   show_window (?w1,4).
  126.   close_window (?temp).
  127.   if ?from_edit is no then set_text (?ed1,?color).
  128. end.