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

  1. %%% This is the file demo.lf.in which generates demo.lf through the
  2. %%% configure command.
  3.  
  4. module("life_demo")?
  5. public(demo, using_demo_fonts) ?
  6.  
  7. %%% Make sure the Demo fonts are known by the Xserver
  8.  
  9. persistent(using_demo_fonts) ?
  10.  
  11. check_font_path :-
  12.     X = system("+SETUPDIR+/Demo/check_fp"),
  13.     X =:= 0, !,
  14.     write("\nDemo fonts not found. Using standard fonts.\nSee the file +SETUPDIR+/Demo/INSTALL on a possible fix to this problem.\n"),
  15.     write("\nShould I try to use the demo fonts anyway? (yes/no) "),
  16.     read_token(Answer),
  17.     using_demo_fonts <<- (Answer :== y or Answer :== yes)
  18.     ;
  19.     using_demo_fonts <<- true.
  20.  
  21. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  22. %
  23. % This is a control panel to drive the Wild_LIFE demos using the X toolkit.
  24. %
  25. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  26.  
  27. %%% load the toolkit, open the xtools module
  28.  
  29. import("xtools") ?
  30. import("xtools_utils") ?
  31.  
  32. %%% Checking font availability
  33.  
  34. check_font_path?
  35.  
  36. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  37. %%% the demo_panel design
  38.  
  39. persistent(demo_panel)?
  40. global(begin_demo) ?
  41.  
  42. demo_button <| push_button.
  43. :: demo_button(font_id => button_font,
  44.            true_text_color_id => d_led_on).
  45.  
  46. def_font(button_font,
  47.      new_font(cond(using_demo_fonts,
  48.                "terminal_bold_narrow18",
  49.                "-adobe-helvetica-bold-r-narrow--17-120-100-100-p-72-*")))?
  50.  
  51. led_button(B:@(light=>L)) -> hc_list [L, h_box(55), B].
  52.  
  53. d_button(label => S:string,
  54.      file => F:string,
  55.      demo => D) ->  demo_button(text => S,
  56.                     light => L:led,
  57.                     action => (import(F),
  58.                            L.led_state <<- true,
  59.                            refresh_look(L),
  60.                            D)).
  61.  
  62. control_panel :-
  63.     
  64.     B0 = d_button(label => "Color Editor",
  65.               file => "color_edit",
  66.               demo => demo_color),
  67.     
  68.     B1 = d_button(label => "Queens",
  69.               file => "queens",
  70.               demo => demo_queens),
  71.     
  72.     B2 = d_button(label => "Boxes",
  73.               file => "boxes",
  74.               demo => demo_boxes),
  75.     
  76.     B3 = d_button(label => "Flowers",
  77.               file => "flowers",
  78.               demo => demo_flowers),
  79.     
  80.     B41 = d_button(label => "Schedule (small)",
  81.                file => "x_schedule",
  82.                demo => demo_schedule_s),
  83.  
  84.     B42 = d_button(label => "Schedule (large)",
  85.                file => "x_schedule",
  86.                demo => demo_schedule_l),
  87.     
  88.     B5 = d_button(label => "Zebra",
  89.               file => "x_zebra",
  90.               demo => demo_zebra),
  91.     
  92.     B6 = d_button(label => "Cryptarithmetic",
  93.               file => "crypt",
  94.               demo => demo_crypt),
  95.     
  96.     B7 = d_button(label => "Math Wiz",
  97.               file => "x_mathwiz",
  98.               demo => demo_mathwiz),
  99.     
  100.     B8 = d_button(label => "Tutorial",
  101.               file => "tutorial",
  102.               demo => demo_tutorial),
  103.     
  104.     same_size([B0, B1, B2, B3, B41, B42, B5, B6, B7, B8]),
  105.  
  106.     QT = push_button(text => "Quit",
  107.              font_id => button_font,
  108.              action => get_out),
  109.  
  110.     demo_panel <<- panel(title => "LIFE DEMO") 
  111.       containing
  112.       vc_list
  113.       [ v_box(35),
  114.         ht_list [h_box(35),
  115.              vl_list
  116.                [ led_button(B0)
  117.                , led_button(B1)
  118.                , led_button(B2)
  119.                , led_button(B3)
  120.                , led_button(B41)
  121.                , led_button(B42)
  122.                , led_button(B5)
  123.                , led_button(B6)
  124.                , led_button(B7)
  125.                , led_button(B8)
  126.                ],
  127.              h_box(35)],
  128.         v_box(40),
  129.         QT,
  130.         v_box(35)].
  131.  
  132.  
  133. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  134. %%% Actions
  135.  
  136. demo_color :- str2psi("color_edit", "color_edit").
  137. demo_queens :- str2psi("queens", "queens").
  138. demo_boxes :- str2psi("boxes", "boxes").
  139. demo_flowers :- str2psi("flowers", "flowers").
  140. demo_schedule_s :- str2psi("sch_1", "x_schedule").
  141. demo_schedule_l :- str2psi("sch_2", "x_schedule").
  142. demo_zebra :- str2psi("x_zebra", "x_zebra").
  143. demo_crypt :- str2psi("crypt", "crypt").
  144. demo_mathwiz :- str2psi("mathwiz", "x_mathwiz").
  145. demo_tutorial :- str2psi("start", "tutorial").
  146. get_out :-
  147.     writeln("Bye, bye!..."),
  148.     set_choice(begin_demo),
  149.     fail.
  150.  
  151. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  152. %%% utilities 
  153.  
  154. C:writeln :- write&strip(C), nl.
  155.  
  156. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  157. %%% compose the interface at load time
  158.  
  159. demo :-
  160.     control_panel, !,
  161.        (
  162.            begin_demo = get_choice,
  163.            create_box(copy_term(demo_panel))
  164.            ;
  165.            succeed
  166.        ).
  167.  
  168. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  169.  
  170.