home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lifeos2.zip / LIFE-1.02 / LIB / XTOOLS.LF < prev   
Text File  |  1996-06-04  |  5KB  |  215 lines

  1. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2. %    $Id: xtools.lf,v 1.2 1994/12/09 00:28:30 duchier Exp vorbeck $    
  3. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  4. %
  5. % XTOOLS: MAIN FILE - OBJECT TYPES
  6. %
  7. %
  8. % Author: Bruno Dumant                                                      
  9. % (c) Copyright 1993 -  Digital Equipment Corporation 
  10. % All Rights Reserved 
  11. %                                                        
  12. % xtools is a simple toolkit to build X applications in Life. It provides the
  13. % user with some basic functionalities of bigger toolkits, in short the ability
  14. % to build interactive window-based applications with buttons, editable text
  15. % fields, menus, and sliders.
  16. %
  17. % See the Wild_LIFE User Manual for a description of the X toolkit.
  18. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  19. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  20.  
  21. %%% interface
  22.  
  23. module("xtools") ?
  24.  
  25.  
  26. public(on_off_button,push_button,menu_button,text_field_button,
  27.     panel,menu_panel,menu_item,
  28.     slide_bar,v_slide_bar,h_slide_bar,
  29.     h_slider,v_slider,
  30.  
  31.     change_on_off,change_push,change_menu_item,
  32.     change_menu_button,change_text_field
  33.        )?
  34.  
  35. load("xtools_init","xtools_b","xtools_c","xtools_l","xtools_constants") ?
  36.  
  37.  
  38. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  39. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  40. %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  41.  
  42.  
  43. %%%  Standard object types
  44.  
  45. %%% panel
  46.  
  47. panel <| panel_c.
  48. panel <| frame.
  49.  
  50. %%% Added the following; otherwise only panels with border 5 were
  51. %%% allowed.
  52. %%% Old code:
  53. %%% :: panel(border => 5).
  54. %%% MJV 01-02-96
  55.  
  56. :: panel(border => Border) | Border = {5;real}, !.
  57.  
  58.  
  59. %%% on_off_button
  60.  
  61. on_off_button <| frame.
  62. on_off_button <| text_box.
  63. on_off_button <| led.
  64. on_off_button <| on_off_c.
  65. :: B:on_off_button( offset => Offset,
  66.                 h_space => d_led_offset + d_h_space/2,
  67.             depth => 2,
  68.             active => A,on => On,
  69.             change_state => change_on_off(A,On,B))
  70.     | Offset = {d_led_offset; real}, !.
  71.  
  72. change_on_off(Active,On,B) :-
  73.     cond( On,
  74.         State = not(Active and enabled),
  75.         State = Active and enabled
  76.     ),
  77.     B.led_state <<- root_sort(State),
  78.     B.frame_state <<- root_sort(State),
  79.     B.text_state <<- root_sort(State).
  80.  
  81.  
  82. %%% push_button
  83.  
  84. push_button <| push_c.
  85. push_button <| text_box.
  86. push_button <| frame.
  87. :: B:push_button(active => A,
  88.              depth => 2,
  89.              change_state => change_push(A,B)).
  90.  
  91. change_push(Active,B) :-
  92.     State = Active and enabled,
  93.     B.frame_state <<- root_sort(State),
  94.     B.text_state <<- root_sort(State).
  95.  
  96.  
  97. %%% menu_button
  98.  
  99. menu_button <| menu_button_c.
  100. menu_button <| frame.
  101. menu_button <| text_box.
  102. :: B:menu_button(on => On,
  103.              depth => 2,
  104.          change_state => change_menu_button(On,B)).
  105.  
  106. change_menu_button(On,B) :-
  107.     cond( On,
  108.         (
  109.         B.frame_state <<- true,
  110.         B.text_state <<- true
  111.         ),
  112.         (
  113.         B.frame_state <<- false,
  114.         B.text_state <<- false
  115.         )
  116.     ). 
  117.  
  118.  
  119. %%% text_field_button
  120.  
  121. text_field_button <| frame.
  122. text_field_button <| text_box.
  123. text_field_button <| field.
  124. text_field_button <| text_field_c.
  125. :: B:text_field_button(on => On,
  126.                    change_state => change_text_field(On,B),
  127.                offset => Offset,
  128.                frame_state => State) |
  129.     Offset = {d_text_field_offset;@},!,
  130.     State <<- true.
  131.  
  132. change_text_field(On,B) :-
  133.     cond( On,
  134.         (
  135.         B.text_state <<- true,
  136.             B.field_state <<- true
  137.         ),
  138.         (
  139.         B.field_state <<- false,
  140.         B.text_state <<- false
  141.         )
  142.     ). 
  143.  
  144.  
  145. %%% menu_panel
  146.  
  147. menu_panel <| menu_panel_c.
  148. menu_panel <| frame.
  149. :: menu_panel(border => 1).
  150.  
  151.  
  152. %%% menu_item
  153.  
  154. menu_item <| frame.
  155. menu_item <| text_box.
  156. menu_item <| item_c.
  157. :: B:menu_item(on => On,
  158.            change_state => change_menu_item(On,B),
  159.            offset => Offset,v_space => Space,
  160.            flat => true) |
  161.        Offset = {d_item_offset;@},
  162.        Space = {d_item_v_space;@},
  163.        !.
  164.  
  165. change_menu_item(On,B) :-
  166.     cond( On,
  167.         (
  168.         B.frame_state <<- true,
  169.         B.text_state <<- true
  170.         ),
  171.         (
  172.         B.frame_state <<- false,
  173.         B.text_state <<- false
  174.         )
  175.     ). 
  176.  
  177.  
  178. %%% sliders
  179.  
  180. v_slider <| frame.
  181. v_slider <| v_slider_c.
  182. :: v_slider(width => W,
  183.         height => H,
  184.         depth => 2) |
  185.     W = {d_v_slider_width;@},
  186.     H = {d_v_slider_height;@},!.
  187.  
  188. h_slider <| frame.
  189. h_slider <| h_slider_c.
  190. :: h_slider(width => W,
  191.         height => H,
  192.         depth => 2) |
  193.     W = {num(d_h_slider_width);@},
  194.     H = {num(d_h_slider_height);@},!.
  195.  
  196.  
  197. %%% slide bars
  198.  
  199. slide_bar1 <| sub_panel_c.
  200. :: slide_bar1(border => Border) |
  201.         Border = {num(d_slide_bar_border);@},!.
  202.  
  203. slide_bar <| slide_bar1.
  204. slide_bar <| frame.
  205. :: slide_bar(frame_state => true).
  206.  
  207. v_slide_bar <| slide_bar1.
  208. v_slide_bar <| v_slide_bar_l.
  209.  
  210. h_slide_bar <| slide_bar1.
  211. h_slide_bar <| h_slide_bar_l.
  212.  
  213.       
  214.