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

  1. @desobj.src
  2. collect_not_ok ().
  3. introWin is window (,26,8,34,15,,[popup,visible,DialogFrame]).
  4. set_text (,'
  5.  
  6.  
  7. #x5KnowledgePro (Windows)
  8.  
  9. #x9Design Program
  10.  
  11.  
  12. #x2⌐ Knowledge Garden Inc. 1990').
  13. if element (system_info (), 3) < 8
  14.    then logo is load_icon ('kpwin.ico') and
  15.            icon (?logo, 14,12)
  16.    else logo is [].
  17.  
  18. (* ======== Create the menu window ================ *)
  19.  
  20. MenuTopic:saveCode is [].
  21. MenuTopic:saveSetup is [].   
  22. wMenu is window (menuTopic:E&xit,30,23,55,4,Design,[OverlappedWindow], , , ,close_event).
  23. m1 is menu ([[&File,&New,'&Load...','&Save','Save &As...',,E&xit],
  24.                         [&Window,&Style,'&Position and Size'],
  25.                         [&Objects,&Button,'&Check Box','&Radio Button','&Edit Line','Edit Bo&x',
  26.                                  '&List Box','&Horizontal Scroll Bar','&Vertical Scroll Bar'],
  27.                         [&Text,'&Type in Text','from &Clipboard','from &File'],
  28.                         [&Edit,&Position,&Size,&Name,&Delete],
  29.                         [Co&de,'to &Clipboard','to &File'],&Help],menuTopic).
  30.  
  31. close_window (?introWin).
  32. if ?logo <> [] then delete_icon (?logo).
  33. CreateWindow ().
  34. show_window (?wMenu).
  35.  
  36. topic CreateWindow.
  37.   [Number,objectList,winColumn,winRow,winWidth,winHeight,
  38.       winText,winMenu,menuCreate,handleList] is_c [1,,15,2,50,15,,no,no].
  39.   winStyle is [popup,thickFrame,visible,titleBar,showChildren,siblings].
  40.   windowHandle is window (WindowEventTopic,15,2,50,15,,
  41.        [popup,thickFrame,titleBar,showChildren,siblings,visible],,,,
  42.        [move_event,resize_event,close_event]). 
  43.   current is ?windowHandle.
  44.   hyper_region ( ClickMove,1,1,200,100).
  45. end.
  46.  
  47. (* <<-<<-<<-<<-<<-<<-<<-<<-<<-<<- MENU OPTIONS -<<-<<-<<-<<-<<-<<-<<<< *)
  48.  
  49. topic menuTopic (item).
  50.   if one_of ([&Button,'&Check Box','&Radio Button','&Edit Line',
  51.      'Edit Bo&x','&List Box','&Horizontal Scroll Bar','&Vertical Scroll Bar'],?item)
  52.      then new (concat (!main:Object,?Number),?item)
  53.      else do (?item).
  54.   collect ().
  55.  
  56.   topic &New.
  57.     close_window (?windowHandle).
  58.     if ?objectList <> [] 
  59.        then remove_topic ( ?objectList ).
  60.     handleList is [].
  61.     createWindow ().
  62.   end.
  63.  
  64.   topic '&Load...' (file,temp,item).
  65.     file is file_menu ('*.set').
  66.     if ?file is [] then exit ().
  67.     close_window (?windowHandle).
  68.     if ?objectList <> []
  69.        then remove_topic (?objectList).
  70.     remove_topic ([winColumn,winRow,winWidth,winHeight,winText,winStyle,winMenu,objectList]).
  71.     load  (?file,'!main').
  72.     saveSetup is ?file.
  73.     windowHandle is window (WindowEventTopic,?winColumn,?winRow,?winWidth,?winHeight,,?winStyle,,,,[move_event,resize_event,close_event]). 
  74.     if ?WinMenu is yes 
  75.          then menuCreate is yes and
  76.                  menu ([Sample,Menu],Number).
  77.     menuCreate is no.
  78.     text (?winText).
  79.     number is 1.   
  80.     handleList is [].
  81.     if ?objectList <> [] then createObjects (?objectList).
  82.     if ?handleList is [] then current is ?windowHandle.
  83.     hyper_region ( ClickMove,1,1,200,100).
  84.   end.
  85.  
  86.   topic '&Save'.
  87.     if ?saveSetup is []
  88.        then 'Save &As...'()
  89.        else (if exists (objectList)
  90.                    then save_topic (?saveSetup, combine (?objectList,objectList,winColumn,
  91.                                 winRow,winWidth,winHeight,winText,WinMenu,winStyle)) 
  92.                    else save_topic (?SaveSetup,[winColumn,winRow,winWidth,winHeight,winText,WinMenu,winStyle])).
  93.   end.
  94.  
  95.   topic 'Save &As...'.
  96.     SaveSetup is save_as (?saveSetup,'Save design to file name:').
  97.     if ?saveSetup <> []
  98.        then (if string_where (?saveSetup,'.') = 0
  99.                    then saveSetup is concat (?saveSetup,'.SET')) and
  100.                (if exists (objectList)
  101.                    then save_topic (?saveSetup, combine (?objectList,objectList,winColumn,
  102.                                 winRow,winWidth,winHeight,winText,WinMenu,winStyle)) 
  103.                    else save_topic (?SaveSetup,[winColumn,winRow,winWidth,winHeight,winText,WinMenu,winStyle])).
  104.   end.
  105.  
  106.   topic E&xit.
  107.     new_kb ('demo.ckb').
  108.   end.
  109.  
  110.   topic '&Position and Size' (ed1,ed2,ed3,ed4).
  111.     window (,50,16,20,15,,[popupWindow,TitleBar]).
  112.     text ( '
  113.   Column:
  114.  
  115.   Row:
  116.  
  117.   Width:
  118.  
  119.   Height: ').
  120.     ed1 is edit_line (?winColumn,,11,1.8,6).
  121.     ed2 is edit_line (?winRow,,11,3.8,6).
  122.     ed3 is edit_line (?winWidth,,11,5.8,6).
  123.     ed4 is edit_line (?winHeight,,11,7.8,6).
  124.     button ('Continue',continue,5,10.5,11).
  125.     show_window ().
  126.     set_focus (?ed1).
  127.     wait ().
  128.     [winColumn,winRow,winWidth,winHeight] is_c get_text ([?ed1,?ed2,?ed3,?ed4]).
  129.     close_window ().
  130.     move_window (,?winColumn,?winRow).
  131.     resize_window (,?winWidth,?winHeight).
  132.   end.
  133.  
  134.   topic &Style.
  135.     hide_window (?wMenu).
  136.     frame is thickFrame.
  137.     winStyle is [popup,visible,showChildren,siblings].
  138.     window (,26,8,34,15,'Create Window',[popupWindow,ControlMenu,TitleBar]).
  139.     text('
  140.   Add Elements:    Frame:').
  141.     :c1 is check_box ('TitleBar',correct,4,3.5,t).
  142.     :c2 is check_box ('HorzScroll',correct,4,5).
  143.     :c3 is check_box ('VertScroll',correct,4,6.5).
  144.     :c4 is check_box ('Menu Bar',correct,4,8).
  145.     :rb1 is radio_button ( [[Thin,21,3.5],[Thick,21,5,t],[Dialog,21,6.5]],Frame).
  146.     :b1 is button (Continue,newStyle,4,10.5).
  147.     button (Cancel,cancel,19,10.5,12).
  148.     show_window ().
  149.     set_focus (?b1).
  150.  
  151.     topic cancel.
  152.       close_window ().
  153.       show_window (?wmenu).
  154.     end.
  155.  
  156.     topic NewStyle.
  157.       if get_check_box (?c1) then winStyle gets TitleBar.
  158.       if get_check_box (?c2) then winStyle gets HorzScroll.
  159.       if get_check_box (?c3) then winStyle gets VertScroll.
  160.       if get_check_box (?c4) 
  161.          then winMenu is yes 
  162.          else winMenu is no.
  163.       winStyle gets ?frame.
  164.       close_window ().
  165.       close_window (?windowHandle).
  166.       windowHandle is window (WindowEventTopic,?winColumn,?winRow,?winWidth,
  167.              ?winHeight,,?winStyle,,,,[move_event,resize_event,close_event]). 
  168.       current is ?windowHandle.
  169.       if ?WinMenu is yes 
  170.            then menuCreate is yes and
  171.                    menu ([Sample,Menu],Number).
  172.       menuCreate is no.
  173.       text (?winText).
  174.       if ?objectList <> [] then createObjects (?objectList).
  175.       hyper_region ( ClickMove,1,1,200,100).
  176.       show_window (?wMenu).
  177.     end. (* newStyle *)
  178.  
  179.     topic correct (item,e,h).
  180.       if not (get_check_box (?h))
  181.       and get_radio_button ( last (?rb1) )
  182.           then set_radio_button ( element (?rb1,2),t) and
  183.                set_radio_button (last (?rb1),f) and
  184.                frame is ThickFrame.         
  185.     end.
  186.  
  187.     topic Frame (i).
  188.       Frame is concat (?i,Frame).
  189.       if ?i is Dialog then set_check_box ([?c1,?c2,?c3,?c4],f).
  190.     end.
  191.  
  192.   end. (* &Style *)
  193.  
  194.   topic 'from &Clipboard'.
  195.     WinText gets first (read_clipboard ()).
  196.     set_text (?WindowHandle,?WinText).
  197.   end.
  198.  
  199.   topic 'from &File' (file).
  200.     file is file_menu ('*.txt').
  201.     if ?file is [] then exit ().
  202.     winText gets read (?file).
  203.     set_text (?WindowHandle,?WinText).
  204.   end.
  205.  
  206.   topic '&Type in Text' (w, edwin).
  207.     hide_window (?wMenu).
  208.     w is window (,58,26,22,3,,[popup,visible,ShowChildren],,,blue).
  209.     button ('Done Entering Text',Continue,2,1.5).
  210.     edWin is edit_window (?winText,,1,1,100,100,,
  211.          [childwindow,visible,siblings,showChildren],?WindowHandle).
  212.     wait ().
  213.     winText is get_text (?edWin).
  214.     set_text (?WindowHandle,?winText).
  215.     close_window ([?edWin,?w]).
  216.     show_window (?wMenu).
  217.     hyper_region ( ClickMove,1,1,200,100).
  218.     set_focus (?current).
  219.   end. (* type text *)
  220.  
  221.   topic &Position.
  222.     if ?current <> ?windowHandle then do (concat (CurrentObject (),':newPosition')).
  223.   end.
  224.  
  225.   topic &Size.
  226.         if ?current <> ?windowHandle then do (concat (currentObject(),':newSize')).
  227.   end.
  228.  
  229.   topic &Name.
  230.         if ?current <> ?windowHandle then do (concat (currentObject (),':newName')).
  231.   end.
  232.  
  233.   topic &Delete.
  234.     close_window (?current).
  235.     ObjectList is remove (?ObjectList, CurrentObject ()).
  236.     handleList is remove (?handleList,?current).
  237.     current is last (?handleList).  
  238.     if ?current is []
  239.        then current is ?WindowHandle.
  240.   end. (* delete *)
  241.  
  242.   topic 'to &File'.
  243.     SaveCode is save_as (?SaveCode).
  244.     if ?saveCode is [] then exit ().
  245.     new_file (?saveCode).
  246.     CreateCode ().
  247.     write (?SaveCode,?code).
  248.     code is [].
  249.   end.
  250.  
  251.   topic 'to &Clipboard'.
  252.     Createcode ().
  253.     text_to_clipboard (?code).
  254.     showCode ().
  255.     code is [].    
  256.  
  257.     topic showCode .
  258.       :temp is window (,9.142,2,74,15,,[popup,titlebar,showChildren,siblings,thickframe,vertscroll,horzscroll]).
  259.       menu ( [Done],done).
  260.       text ('
  261.   The code shown below has been copied to your clipboard: 
  262.  ',?code).
  263.       make_modal ().
  264.       show_window ().
  265.       
  266.       topic done.
  267.         close_window (?temp).
  268.       end.
  269.  
  270.     end. (* showCode *)
  271.   end.
  272.  
  273.   topic CreateCode (temp,item,text1,text2,tempStyle).
  274.     window ((* eventTopic*),33.85,8.25,29.57,10.37,,[popup,visible,showChildren,siblings,DialogFrame]).
  275.     set_text (,'
  276.  
  277.    One moment while the
  278.  
  279.    code is created .... ').
  280.     code is [].
  281.     tempStyle is remove (?winStyle,visible).
  282.     code gets concat ('window ((* eventTopic*),',?winColumn,',',?winRow,',',?winWidth,',',?winHeight,',,',list_to_string (?tempStyle,',','[',']'),').').
  283.     if ?WinMenu is yes then code gets 'menu ([Sample,Menu]).'. 
  284.     if ?WinText <> []
  285.        then :text1 is concat ('text (''',first (?WinText) ) and
  286.                :text2 is rest (?WinText) and
  287.                code gets ?text1 and
  288.                code gets ?text2 and 
  289.                code gets ' '').'.
  290.     temp  is ?ObjectList.
  291.     while ?temp <> []
  292.        then item is first (?temp) and
  293.             do (concat (?item,':MakeCode')) and
  294.             temp is rest (?temp).
  295.     code gets ('show_window ().').
  296.     close_window ().
  297.   end.
  298.  
  299.   topic &Help.
  300.     load ('apphelp.hkb',temp).
  301.     temp:file is 'design.hyp'.
  302.     temp ().
  303.     wait ().
  304.     remove_topic (temp).
  305.     collect ().
  306.   end. 
  307.  
  308. end. (* menuTopic *)
  309.  
  310. (* <<-<<-<<-<<-<<-<<-<<-<<- END OF MENU OPTIONS <<-<<-<<-<<-<<-<<-<<-<<- *)
  311.  
  312.  
  313. (* ########## TOPIC CALLED BY HYPER-REGIONS AND WINDOW EVENTS ###### *)
  314.  
  315. topic ClickMove (n,h,c,r).
  316.   (* This topic is called when the mouse is clicked in the window.
  317.      It moves the current object to the location of the click. *)
  318.   if ?current is ?windowHandle then exit ().
  319.   c is string_copy (?c,1,5).
  320.   r is string_copy (?r,1,5).
  321.   do (concat (CurrentObject () ,':setPosition'),?c,?r).
  322. end.
  323.  
  324. topic WindowEventTopic (i,e).
  325.     if ?menuCreate is no 
  326.           then do (?e).
  327.  
  328.     topic move_event (c,r).
  329.       winColumn is string_copy (first (?i),1,5).
  330.       winRow is string_copy (element (?i,2),1,5).
  331.     end.
  332.  
  333.     topic resize_event (w,h).
  334.       winWidth is string_copy (element ( window_info (),3),1,5).
  335.       winHeight is string_copy (element ( window_info (),4),1,5).
  336.     end.
  337.  
  338.     topic close_event.
  339.       windowHandle is [].
  340.     end.
  341.  
  342.   end. (* WindoweventTopic *)
  343.  
  344.  
  345. (* ################ END OF EVENT AND HYPER-REGION TOPICS ############### *)
  346.  
  347.  
  348. (* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ TOPICS USED TO READ IN VALUES ^^^^^^^^^^^^^^^^^^^^^^^^^^ *)
  349.  
  350. topic message (m).
  351.   window (,53,18,28,10,,[popupWindow,Visible,TitleBar,thickFrame]).
  352.   text (?m).
  353.   button ('Continue',continue,9,5.5,11).
  354.   wait ().
  355.   close_window ().
  356. end.
  357.  
  358. topic oneEdLn (txt,d1,ed).
  359.     window (,53,18,22,10,,[popupWindow,TitleBar]).
  360.     text (?txt).
  361.     ed is edit_line (?d1,,11,1.8,8).
  362.     button ('Continue',continue,6,6.5,11).
  363.     show_window ().
  364.     set_focus (?ed).
  365.     wait ().
  366.     oneEdLn is get_text (?ed).
  367.     close_window ().
  368. end.
  369.   
  370.   topic oneEdBx (txt,d1,ed).
  371.     window (,53,16,24,14.5,,[popupWindow,TitleBar]).
  372.     text (?txt).
  373.     ed is edit_box (?d1,,4,4,18,5).
  374.     button ('Continue',continue,7,10.5,11).
  375.     show_window ().
  376.     set_focus (?ed).
  377.     wait ().
  378.     oneEdBx is get_text (?ed).
  379.     close_window ().
  380.   end.    
  381.   
  382.   topic twoEdLn (txt,d1,d2,ed1,ed2).
  383.     window (,53,18,22,10,,[popupWindow,TitleBar]).
  384.     text (?txt).
  385.     ed1 is edit_line (?d1,,11,1.8,8).
  386.     ed2 is edit_line (?d2,,11,3.8,8).
  387.     button ('Continue',continue,6,6.5,11).
  388.     show_window ().
  389.     set_focus (?ed1).
  390.     wait ().
  391.     twoEdLn is  [get_text (?ed1), get_text (?ed2) ] .
  392.     close_window ().
  393.   end.
  394.  
  395. (* ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ *)
  396.  
  397. topic CurrentObject .
  398. (* This topic finds the topic name of the topic that is associated 
  399.    with the current object *)
  400.  
  401.   CurrentObject is element (?ObjectList, where (?HandleList,?current)).
  402.   if ?CurrentObject is [] 
  403.      then current is parent_window (?current).
  404. end.
  405.  
  406.  
  407. topic CreateObjects (temp).
  408.   number is 1.
  409.   handleList is [].
  410.   while ?temp <> []
  411.      then item is first (?temp) and
  412.           do (concat (?item,':CreateNew'),?number ) and
  413.           handleList gets ? (concat (?item,':handle') ) and
  414.           number is ?number + 1 and
  415.           temp is rest (?temp).
  416.   if ?handleList <> []
  417.      then current is last (?handleList).
  418. end.