home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / EXAMPLES / FLO_XTOO.LF < prev    next >
Text File  |  1996-06-04  |  18KB  |  667 lines

  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  3. %
  4. %                XTOOLS: BASIC BUTTONS AND ACTIONS
  5. %
  6. % This file contains all the basic predicates related to the X part of the
  7. % demo: definition of panels and button classes, events handler, utilities, and
  8. % definition of colors.
  9. %
  10. % This file is loaded automatically by the main file of the demo.
  11. %
  12. % Author: Bruno Dumant                                                      
  13. %
  14. % Copyright 1992 Digital Equipment Corporation                                
  15. % All Rights Reserved 
  16. %                                                        
  17. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  18. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  19.  
  20. module("xtools_flo") ?
  21. public( open_panel,close_panel,create_new_panel,update_panel,
  22.     add_button,refresh_button,find_chosen_button,choose_button,
  23.  
  24.     on_off_button,toggle_button,textfield,rectangle_button,
  25.     rectangle_look,ledandtext,textfield_look,
  26.  
  27.     action,color_block,choice,name,title,panel,shade,highlight,depth,text,
  28.         selected_text,on,buttons,
  29.  
  30.     draw_static,draw_dynamic,draw_buttons,draw_basic_button,switch_off,
  31.  
  32.         button_font,textfield_font,color_name_font,
  33.  
  34.         shade_color,highlight_color,
  35.     button_color,text_color,on_off_color,toggle_color,
  36.     textfield_color,selected_textfield_color,color_name_textfield_color,
  37.     text_in_field_color,text_in_selected_field_color,
  38.         led_color,led_shade_color,led_highlight_color,
  39.     def_led_color,def_led_shade,def_led_highlight,
  40.     panel_color,panel_highlight,panel_shade,
  41.     
  42.         catch_panel_events,
  43.  
  44.         default_display,default_window,
  45.  
  46.     color,
  47.     aquamarine,black,blue,'blue violet',brown,'cadet blue',coral,
  48.         'cornflower blue',cyan,'dark green','dark olive green','dark orchid',
  49.         'dark slate blue', 'dark slate grey','dark turquoise','dim grey',
  50.         firebrick,'forest green',gold,goldenrod,green,'green yellow',grey,
  51.         'indian red',khaki,'light blue','light grey','light steel blue',
  52.         'lime green',magenta,maroon,'medium aquamarine','medium blue',
  53.         'medium orchid','medium sea green','medium slate blue',
  54.         'medium spring green','medium turquoise','medium violet red',
  55.         'midnight blue','navy blue',orange,'orange red','orchid','pale green',
  56.         pink,plum,red,salmon,'sea green',sienna,'sky blue','slate blue',
  57.         'spring green','steel blue','light brown',thistle,turquoise,
  58.         violet,'violet red',wheat,white,yellow,'yellow green') ?
  59.  
  60. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  61. %
  62. % panel: window containing buttons
  63. %
  64. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  65.  
  66. global(event_mask <- xExposureMask \/ xKeyPressMask \/ xButtonPressMask) ?
  67.  
  68. create_new_panel( X0 ,Y0, DX, DY, choice => F, title => T, name => P) :- 
  69.     xCreateWindow (default_display, 
  70.                    X0, Y0, DX, DY,
  71.                Window,
  72.                windowtitle => T,
  73.                eventmask => event_mask,
  74.                color     => panel_color,
  75.                show => false),
  76.     xSetWindowBorderWidth(Window,2),
  77.     Panel = panel( window  => Window,
  78.                    buttons => [],
  79.                choice  => F ),
  80.     set_panel(P,Panel),
  81.     catch_panel_events(P).
  82.  
  83.  
  84. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  85. %
  86. % buttons
  87. %
  88. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  89.  
  90. %
  91. % generic button: ::button:@( on => bool).
  92. %
  93. % buttons are classified using:
  94. %         - their behaviour: toggle, on_off, text_field
  95. %         - their shape (choice predicate): rectangle
  96. %         - their look : with text and a led, ...
  97. %
  98. % In the present file, buttons belong to the followong hierarchy:
  99. %
  100. %                                button
  101. %                _________________________________
  102. %               /                   |             \
  103. %      (behaviour types)      (shape types)  (look types)
  104. %      /       |       \            |             |
  105. %   on_off  toggle text_field   rectangle        /
  106. %                      |            |           /
  107. %                      |            |          /
  108. %                      |          rectangle_look
  109. %                      \           /      \
  110. %                       \         /        \
  111. %                     textfield_look     ledandtext
  112. %
  113.  
  114. % add a button to a panel
  115.  
  116. add_button( B, panel => P) :-
  117.     Panel:@(window => PW, buttons => PB)&root_sort(P),
  118.     B = @( on => false, window  => PW),
  119.         PB <-[B|copy_pointer(PB)],
  120.     update_panel(Panel), !.
  121.  
  122. %%%
  123. %%% Button types associated with an action
  124. %%%
  125.  
  126.  
  127. %
  128. % Note: draw_button(B) draws entirely the button B, while refresh_button(B)
  129. % only redraws the dynamic part of B, according to its state.
  130. %
  131.  
  132.  
  133. %%% on_off button
  134.  
  135. :: A:on_off_button( associated_action => on_off_action(A), 
  136.                 color => on_off_color ).
  137.  
  138. on_off_action(A:@(on => ON, action => RAct), panel => P) :-
  139.     (
  140.         ON <- not(ON), 
  141.         refresh_button(A),
  142.         copy_pointer(RAct)&@(panel => P), ! 
  143.     ; 
  144.         write("error"),
  145.         nl, 
  146.         refresh_button(A)
  147.     ).
  148.  
  149.  
  150. %%% toggle button
  151.  
  152. :: A:toggle_button( associated_action => toggle_action(A),
  153.                 color => toggle_color ).
  154.  
  155. toggle_action(A:@(on => ON, action => RAct), panel => P) :-
  156.     ON <- true, 
  157.     refresh_button(A),
  158.     copy_pointer(RAct)&@(panel => P),
  159.     ON <- false,
  160.     refresh_button(A).
  161.  
  162.  
  163. %%% text field
  164.  
  165. :: A:textfield(  text => {"";@},
  166.              associated_action => text_action(A))
  167.          | !.
  168.  
  169. text_action( A, panel => P:@(selected_text => Q)) :-
  170.     (
  171.         Q :== true, !,
  172.         PrevButton = Q.1,
  173.         cond( B:(not( PrevButton ===  A)),
  174.               ( 
  175.               PrevButton.action,
  176.               PrevButton.on <- false,
  177.               refresh_button(PrevButton) 
  178.           )
  179.         )
  180.     ;
  181.         succeed
  182.     ),
  183.     cond( B, 
  184.           (
  185.           A.on <- true,
  186.           P.clearable <- true,
  187.           refresh_button(A),
  188.           Q <- true(A)
  189.           )).
  190.  
  191.  
  192. %%% very basic editor for a text-field
  193.  
  194.  
  195. handle_char( B, P, char  => C) :-
  196.     cond(   C =:= 13, %%% return
  197.             (
  198.             P.selected_text <- false,
  199.             B.on <- false,
  200.             refresh_button(B),
  201.             AA = copy_pointer(B.action)&@(panel => P),
  202.             AA
  203.         ),
  204.         (
  205.             cond( Q:(P.clearable),
  206.                   (   B.text <- "",
  207.                   refresh_button(B),
  208.                   Q <- false
  209.               )),
  210.             cond(   C >= 32 and C =< 126,
  211.                     add_new_char(B,C),
  212.                         cond(   C =:= 8,
  213.                             remove_last_char(B)
  214.                 )
  215.             )
  216.         )
  217.         ).
  218.  
  219. add_new_char(B:@(text => T),K) :-
  220.     T <- strcon(T,chr(K)),
  221.     refresh_button(B).
  222.  
  223. remove_last_char(B:@(text => T)) :-
  224.     cond( L:strlen(T) > 0,
  225.           (   T <- substr(T,1,L-1),
  226.               refresh_button(B))).
  227.  
  228.  
  229. %%% 
  230. %%% button types associated with a shape
  231. %%%
  232.  
  233.  
  234. %%% rectangle button                        
  235.  
  236. :: X:rectangle_button ( X0, Y0, DX, DY, choice  => chosen(_,_,X0,Y0,DX,DY)).
  237.  
  238.  
  239. chosen(X,Y,X0,Y0,DX,DY) :- (X-X0)*(X-X0-DX) < 0 and
  240.                    (Y-Y0)*(Y-Y0-DY) <0 .
  241. %%%
  242. %%% button types associated with a look
  243. %%%
  244. %%% for each look type, two predicates are defined:
  245. %%%   - draw_static draws the static part of the button
  246. %%%   - draw_dynamic draws the dynamic part of the button,
  247. %%%     and therefore depends on the state of the button
  248. %%%
  249.  
  250. dynamic(draw_static) ?
  251. dynamic(draw_dynamic) ?
  252.  
  253.  
  254. %%% rectangle_look
  255.  
  256. rectangle_look <| rectangle_button.     % this means that rectangle_look will
  257.                     % inherit the choice predicate of
  258.                     % rectangle_button.
  259.  
  260. draw_static( rectangle_look ( X0, Y0, DX, DY, color => C, window => W)) :-
  261.     xFillRectangle(W,X0+2,Y0+2,DX-4,DY-4,color => button_color(C)),
  262.     fail.
  263.  
  264.  
  265. draw_dynamic( rectangle_look ( X0, Y0, DX, DY, 
  266.                            on => false, color => C, window => W)) :-
  267.     draw_shade(X0,Y0,DX,DY,depth => 2,
  268.                shade => shade_color(C), 
  269.                highlight => highlight_color(C),
  270.                window => W),
  271.     fail.
  272.  
  273. draw_dynamic( rectangle_button ( X0, Y0, DX, DY, 
  274.                              on => true, color => C, window => W)) :-
  275.     draw_shade(X0,Y0,DX,DY,depth => 2,
  276.                shade => highlight_color(C), 
  277.                highlight => shade_color(C),
  278.                window => W),
  279.     fail.
  280.  
  281. %%% ledandtext
  282.                     
  283. ledandtext <| rectangle_look.           % this means that ledandtext will
  284.                     % inherit the choice predicate of
  285.                     % rectangle_button, and the basic
  286.                     % rectangle look .
  287.  
  288. draw_static( ledandtext( X0, Y0, DX, DY, text => T,
  289.                      color => C, window => W )) :-
  290.     draw_shade_rectangle( X0 + 9, Y0 + DY/2 - 5, 16, 9,
  291.                              shade => highlight_color(C), 
  292.                   highlight => shade_color(C),
  293.                   window => W),
  294.     xDrawString( W, X0 + 35, Y0 + DY/2 + 4, T, font => button_font,
  295.                  color => text_color(C) ),
  296.     fail.
  297.  
  298. draw_dynamic( ledandtext( X0, Y0, DX, DY, 
  299.                       color => C, on => true, window => W )) :-
  300.     draw_basic_led( X0+10, Y0 + DY/2 - 4, 14, 7,
  301.                 color => led_color(C),
  302.             shade => led_shade_color(C), 
  303.             highlight => led_highlight_color(C),
  304.             window => W),
  305.     fail.
  306.  
  307. draw_dynamic( ledandtext( X0, Y0, DX, DY, on => false, window => W)) :-
  308.     draw_basic_led( X0+10, Y0 + DY/2 - 4, 14,7,
  309.                     color => def_led_color,
  310.             shade => def_led_shade, 
  311.             highlight => def_led_highlight,
  312.             window => W),
  313.     fail.
  314.         
  315.  
  316. %%% textfield_look
  317.  
  318. textfield_look <| textfield.
  319. textfield_look <| rectangle_button.
  320.  
  321. draw_static( textfield_look( X0, Y0, DX, DY, window => W)) :-
  322.     draw_shade_rectangle( X0, Y0, DX, DY,
  323.                           shade => panel_highlight, 
  324.                   highlight => panel_shade,
  325.                   window => W),
  326.     fail.
  327.  
  328. draw_dynamic( textfield_look( X0, Y0, DX, DY,
  329.                           on => true, text => T , window => W)) :-
  330.     xFillRectangle( W, X0+1, Y0+1, DX -1, DY-1, 
  331.                     color => selected_textfield_color),
  332.     xDrawString( W, X0 + 5, Y0 + DY/2 + 4, T, font => textfield_font,
  333.                  color => text_in_selected_field_color),
  334.     fail.
  335.  
  336. draw_dynamic( textfield_look( X0, Y0, DX, DY,
  337.                           on => false, text => T , window => W)) :-
  338.     xFillRectangle( W, X0+1, Y0+1, DX -1, DY-1, 
  339.                     color => textfield_color),
  340.     xDrawString( W, X0 + 5, Y0 + DY/2 + 4, T, font => textfield_font,
  341.                  color => text_in_field_color ),
  342.     fail.
  343.  
  344. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  345. %
  346. % events
  347. %
  348. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  349.  
  350. %%% keyboard and mouse events: 5 is xKeyPressMask \/ xButtonPress
  351.  
  352.  
  353. catch_panel_events(P) :-
  354.     Panel:@(window => PW)&root_sort(P),
  355.     handle_panel_event (xGetEvent ( PW, eventmask => 5),
  356.                 PW, P).
  357.  
  358.  
  359. handle_panel_event ( button_event (x => X, y => Y), PW, P) ->      
  360.     true 
  361.     | 
  362.         handle_panel_mouse_event(X,Y,PW,P).
  363.  
  364. handle_panel_event(keyboard_event (char => C), PW, P) ->
  365.     true
  366.     |
  367.         handle_panel_keyboard_event(C,PW,P).
  368.  
  369.  
  370. handle_panel_mouse_event( X, Y, PW, P) :-
  371.     (
  372.         Panel:@( choice => C, busy => B)&root_sort(P),
  373.         ( 
  374.         B :== true,!,
  375.                 handle_panel_event (xGetEvent ( PW, eventmask => 5),
  376.                                PW, P)
  377.         ;
  378.                 B <- true,
  379.         update_panel(Panel),
  380.         handle_panel_event (xGetEvent ( PW, eventmask => 5),
  381.                                     PW, P),
  382.         copy_pointer(C)&@(X,Y,Panel),!,
  383.         B <- false,
  384.         update_panel(Panel)
  385.         )
  386.     ;
  387.         succeed
  388.     ).
  389.  
  390. handle_panel_keyboard_event(C,PW,P) :-
  391.     Panel:@(selected_text => S, busy => B)&root_sort(P),
  392.     (
  393.         B :== true,!,
  394.         handle_panel_event (xGetEvent ( PW, eventmask => 5),
  395.                             PW, P)
  396.     ;
  397.         B <- true,
  398.         update_panel(Panel),
  399.         handle_panel_event (xGetEvent ( PW, eventmask => 5),
  400.                 PW, P),
  401.         (
  402.         cond(   S,
  403.                 handle_char(project(1,S), Panel, char => C)
  404.             ),
  405.         B <- false,
  406.         update_panel(Panel),
  407.         fail
  408.         ;
  409.             succeed
  410.         )
  411.     ). 
  412.  
  413. %%% refresh event: 32768 is xExposureMask
  414.  
  415. catch_refresh_event(P) :-
  416.     root_sort(P)&@(window => PW),
  417.     handle_refresh_event (xGetEvent ( PW, eventmask =>  32768),
  418.                   PW).
  419.  
  420. handle_refresh_event ( expose_event, PW) ->
  421.     true 
  422.     |
  423.         xRefreshWindow(PW),
  424.     handle_refresh_event (xGetEvent ( PW, eventmask =>  32768),
  425.                   PW).
  426.  
  427. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  428. %
  429. %  Toolkit Utilities
  430. %
  431. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  432.  
  433. %%%
  434. %%% define a panel
  435. %%%
  436.  
  437. set_panel(P,Panel) :-
  438.     RS1 = root_sort(P),
  439.     RS2 = root_sort(P),
  440.     retract(( RS1 :- @)),!,
  441.     Q = RS2&strip(Panel),
  442.     assert(Q).
  443. set_panel(P,Panel) :-
  444.     dynamic(P),
  445.     RS = root_sort(P),
  446.     Q = RS&strip(Panel),
  447.     assert(Q).
  448. update_panel(Panel) :-
  449.     P = root_sort(Panel),
  450.     retract(( P :- @)),
  451.     assert(Panel).
  452.  
  453. %%%
  454. %%% open and close a panel. 32768 is xExposureMask
  455. %%%
  456.  
  457. open_panel(P) :-
  458.     root_sort(P)&@(window => PW),
  459.     handle_refresh_event (xGetEvent ( PW, eventmask =>  32768),
  460.                   PW),
  461.     xShowWindow(PW).
  462.  
  463. close_panel(P) :-
  464.     root_sort(P)&@(window => PW),
  465.     xFlushEvents( PW, eventmask => 32768),
  466.     xHideWindow(PW).
  467.  
  468. %%%
  469. %%% drawing utilities
  470. %%%
  471.  
  472. %%% refresh a button (redraw its dynamic part)
  473.  
  474. refresh_button(A) :- 
  475.     implies(draw_dynamic(A))
  476.     ;
  477.     succeed.
  478.  
  479.  
  480. %%% switching off a button
  481.  
  482. switch_off(B:@(on => ON)) :-
  483.     ON <- false,
  484.     (
  485.         refresh_button(B),
  486.         fail
  487.     ;
  488.         succeed
  489.     ).
  490.  
  491. %%% draw a list of buttons
  492.  
  493. draw_buttons(L) :- maprel(draw_button,L) .
  494.  
  495.  
  496. %%% draw one button
  497.  
  498. draw_button(A) :-
  499.         implies(draw_static(A))
  500.     ;
  501.     implies(draw_dynamic(A))
  502.     ;
  503.     succeed.
  504.  
  505.  
  506. %%% draw something that looks like a simple button
  507.  
  508. draw_basic_button( X0,Y0,DX,DY,
  509.                depth => D,
  510.            color => BC,
  511.            shade => SC, 
  512.            highlight => HC,
  513.            window => W) :-
  514.     draw_shade(X0,Y0,DX,DY,depth => D,
  515.                shade => SC, 
  516.                highlight => HC,
  517.                window => W),
  518.     xFillRectangle(W,X0+D,Y0+D,DX-2*D,DY-2*D,color => BC),!.
  519.  
  520. draw_shade(X0,Y0,DX,DY,depth => D,
  521.         shade => SC, 
  522.         highlight => HC,
  523.         window => W) :-
  524.     xFillPolygon(W,[(X0,Y0),(XB1:(X0+DX),Y0),(XB2:(X0+DX-D),YB2:(Y0+D)),
  525.                     (XB3:(X0+D),YB2),(XB3,YB3:(Y0+DY-D)),(X0,YB4:(Y0+DY))],
  526.                  color => HC),
  527.     xFillPolygon(W,[(XB1,Y0),(XB2,YB2),(XB2,YB3),(XB3,YB3),(X0,YB4),
  528.                     (XB1,YB4)],color => SC),!.
  529.  
  530. %%% draw something that looks like a led.
  531.  
  532. draw_basic_led( X0, Y0, DX, DY, 
  533.             color => BC, shade => SC, highlight => HC,
  534.         window => W) :-
  535.     draw_shade_rectangle( X0, Y0, DX, DY,
  536.                           shade => SC, highlight => HC,
  537.                   window => W),
  538.     xFillRectangle(W,X0+1,Y0+1,DX-1,DY-1,color => BC),!.
  539.  
  540. draw_shade_rectangle( X1, Y1, DX, DY,
  541.                   shade => SC, highlight => HC,
  542.                   window => W ) :-
  543.     xDrawLine( W, X1,Y1,X2:(X1+DX),Y1,
  544.                color => HC),
  545.     xDrawLine( W, X1,Y1,X1,Y2:(Y1+DY),
  546.                color => HC),
  547.     xDrawLine( W, X2,Y2,X1,Y2,
  548.                color => SC),
  549.     xDrawLine( W, X2,Y2,X2,Y1,
  550.                color => SC),!.
  551.  
  552. %%%
  553. %%% Basic choice predicate for a button 
  554. %%%
  555.  
  556. find_chosen_button([A:@(associated_action => Act, choice => C)|B],X,Y,Panel) :-
  557.     !,
  558.     cond( copy_term(C)&@(X,Y),
  559.           copy_pointer(Act)&@(panel => Panel),
  560.           find_chosen_button(B,X,Y,Panel)).
  561. find_chosen_button([]).
  562.  
  563.  
  564. %%% Find a button in a panel
  565.  
  566. choose_button(X,Y,Panel) :- find_chosen_button(Panel.buttons,X,Y,Panel).
  567.  
  568.  
  569. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  570. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  571. %
  572. % X Functions initialization
  573. %
  574. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  575. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  576.  
  577. dynamic(default_display,default_window)?
  578.  
  579. xOpenConnection(D), setq(default_display, D)?
  580.  
  581. xDefaultRootWindow(D:default_display,Root), 
  582. Root = @(display => D), 
  583. setq(default_window, Root)?
  584.  
  585. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  586. %
  587. % COLORS
  588. %
  589. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  590.  
  591. non_strict(named_color)?
  592. dynamic(number_of_colors)?
  593.  
  594. number_of_colors -> 0.
  595.  
  596. named_color( Reference, String) :- 
  597.     String = { psi2str(Reference); string },!,
  598.     setq( number_of_colors, N:(number_of_colors+1)),
  599.     asserta(color(Reference,N)),
  600.     xRequestNamedColor( default_window, String, C),
  601.     assert((Reference -> C:int(name => String))).
  602.  
  603. named_color(aquamarine),
  604. named_color(black),
  605. named_color(blue),
  606. named_color('blue violet'),
  607. named_color(brown),
  608. named_color('cadet blue'),
  609. named_color(coral),
  610. named_color('cornflower blue'),
  611. named_color(cyan),
  612. named_color('dark green'),
  613. named_color('dark olive green'),
  614. named_color('dark orchid'),
  615. named_color('dark slate blue'),
  616. named_color('dark slate grey'),
  617. named_color('dark turquoise'),
  618. named_color('dim grey'),
  619. named_color(firebrick),
  620. named_color('forest green'),
  621. named_color(gold),
  622. named_color(goldenrod),
  623. named_color(green),
  624. named_color('green yellow'),
  625. named_color(grey),
  626. named_color('indian red'),
  627. named_color(khaki),
  628. named_color('light blue'),
  629. named_color('light grey'),
  630. named_color('light steel blue'),
  631. named_color('lime green'),
  632. named_color(magenta),
  633. named_color(maroon),
  634. named_color('medium aquamarine'),
  635. named_color('medium blue'),
  636. named_color('medium orchid'),
  637. named_color('medium sea green'),
  638. named_color('medium slate blue'),
  639. named_color('medium spring green'),
  640. named_color('medium turquoise'),
  641. named_color('medium violet red'),
  642. named_color('midnight blue'),
  643. named_color('navy blue'),
  644. named_color(orange),
  645. named_color('orange red'),
  646. named_color('orchid'),
  647. named_color('pale green'),
  648. named_color(pink),
  649. named_color(plum),
  650. named_color(red),
  651. named_color(salmon),
  652. named_color('sea green'),
  653. named_color(sienna),
  654. named_color('sky blue'),
  655. named_color('slate blue'),
  656. named_color('spring green'),
  657. named_color('steel blue'),
  658. named_color('light brown',"tan"),
  659. named_color(thistle),
  660. named_color(turquoise),
  661. named_color(violet),
  662. named_color('violet red'),
  663. named_color(wheat),
  664. named_color(white),
  665. named_color(yellow),
  666. named_color('yellow green') ?
  667.