home *** CD-ROM | disk | FTP | other *** search
/ Enigma Amiga Life 109 / EnigmaAmiga109CD.iso / software / sviluppo / rxmui / examples / tutorial2.rexx < prev    next >
OS/2 REXX Batch file  |  1999-12-21  |  5KB  |  156 lines

  1. /**/
  2.  
  3. signal on halt
  4. signal on break_c
  5.  
  6. /* first of all add the needed libraries */
  7. l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  8. if AddLibrary("rxmui.library")~=0 then exit
  9.  
  10. /* create the application */
  11. call createApp
  12.  
  13. /* open the window and check if it is */
  14. call set("win","open",1)
  15. call getattr("win","open","o")
  16. if o=0 then do
  17.     say "can't open window"
  18.     exit
  19. end
  20.  
  21. /* handle the application */
  22. call handleApp
  23. exit
  24. /***********************************************************************/
  25. handleApp: procedure
  26. /* this is the standard cycle to handle an application */
  27. ctrl_C=2**12
  28. s=0
  29. do forever
  30.     call handle("APP","H",s)
  31.     do i=0 to h.num-1
  32.         id=h.i
  33.         select
  34.             when id="QUIT" then exit
  35.             otherwise say h.i
  36.         end
  37.     end
  38.     s=wait(or(h.signals,ctrl_C))
  39.     if and(s,ctrl_C)~=0 then exit
  40. end
  41. /* never reached */
  42. /***********************************************************************/
  43. err: procedure expose sigl rxmuierror
  44. parse arg res
  45. say sigl "["res"]"
  46.     say getrxmuistring(res) "in line" sigl-1 rxmuierror
  47.     exit
  48. /***********************************************************************/
  49. createApp: procedure
  50.  
  51.     /* first of all the let's create the menu strip
  52.      * here made only of one item "Project"
  53.      */
  54.     strip.0="mproject"
  55.      mproject.Title="Project"
  56.      mproject.class="menu"
  57.        mproject.0=menuitem("mabout","About...","?")
  58.        mproject.1=menuitem("maboutrxmui","About RxMUI...")
  59.        mproject.2=menuitem("maboutmui","About MUI...")
  60.        mproject.3=menuitem("","BAR")
  61.        mproject.4=menuitem("mhide","Hide","H")
  62.        mproject.5=menuitem("","BAR")
  63.        mproject.6=menuitem("mquit","Quit","Q")
  64.     res=NewObj("menustrip","strip")
  65.     if res~=0 then call err(res)
  66.  
  67.     /* with one NewObj() call we create many objects */
  68.  
  69.     /* first of all the let's define the application object */
  70.     app.Title="Tutorial2"
  71.     app.Version="$VER: Tutorial2 1.0 (10.12.99)"
  72.     app.Copyright="©1999, alfie"
  73.     app.Author="alfie"
  74.     app.Description="Just a little example"
  75.     app.Base="EXAMPLE"
  76.     app.diskobject="rxmui"
  77.     app.ctrlc=1
  78.     app.menustrip="strip"
  79.     app.subwindow="win"
  80.  
  81.      /* let's define the window */
  82.      win.ID="MAIN"
  83.      win.Title="A Tutorial"
  84.      win.Contents="mgroup"
  85.  
  86.       /* let's define the window contents */
  87.       mgroup.0="dg"
  88.        dg.class="group"
  89.        dg.frame="group"
  90.        dg.columns=2
  91.         dg.0=label("_Name");
  92.         dg.1=String("name",'n')
  93.         dg.2=label("Age");
  94.         dg.3="ag"
  95.          ag.class="group"
  96.          ag.horiz=1
  97.          ag.horizspacing=0
  98.           ag.0="age";age.class="numericbutton";age.min=0;age.max=150;age.value=30
  99.           ag.1=hspace()
  100.         dg.4=label("_Sex")
  101.         dg.5="sg"
  102.          sg.class="group"
  103.          sg.horiz=1
  104.           sg.0="sex";sex.controlchar="s";sex.class="radio";sex.entries="Male|Female";sex.horiz=1
  105.           sg.1=hvspace()
  106.         dg.6=label("_Knowledge");dg.7="known";known.class="cycle";known.controlchar="k";known.entries="Novice|Average|Good|Exepert"
  107.         dg.8=label("Language(s)")
  108.         dg.9="lg"
  109.          lg.class="group"
  110.          lg.horiz=1
  111.           lg.0=checkmark("BASIC",,'b');lg.1=label("_Basic");lg.2=hspace(5)
  112.           lg.3=checkmark("ARexx",,'a');lg.4=label("_ARexx");lg.5=hspace(5)
  113.              lg.6=checkmark("C",,'c');lg.7=label("_C");lg.8=hspace(5)
  114.           lg.9=checkmark("ASM",,'m');lg.10=label("AS_M");lg.11=hvspace()
  115.       mgroup.1="bg"
  116.        bg.class="group"
  117.        bg.columns=3
  118.         bg.0=Button("RESET","_Reset Form")
  119.         bg.1=Button("DONE","_Done")
  120.         bg.2=Button("CANCEL","Cance_l")
  121.  
  122.     /* create all */
  123.     call NewObj("APPLICATION","APP")
  124.  
  125.     /* window close gadget means quit */
  126.     call Notify("WIN","CLOSEREQUEST",1,"APP","RETURNID","QUIT")
  127.  
  128.     /* done gadget should do something else, anyway means quit */
  129.     call Notify("done","pressed",0,"APP","RETURNID","QUIT")
  130.  
  131.     /* cancel gadget means quit */
  132.     call Notify("cancel","pressed",0,"APP","RETURNID","QUIT")
  133.  
  134.     /* about menuitem means show the automatic about requester */
  135.     call Notify("mabout","menutrigger","everytime","app","about","win")
  136.  
  137.     /* aboutrxmui menuitem means show the rxmui about requester */
  138.     call Notify("maboutrxmui","menutrigger","everytime","app","aboutrxmui","win")
  139.  
  140.     /* aboutmui menuitem means show the about MUI window */
  141.     call Notify("maboutmui","menutrigger","everytime","app","aboutmui","win")
  142.  
  143.     /* hide menuitem means hide all windows (just one here) */
  144.     call Notify("mhide","menutrigger","everytime","app","set","iconified",1)
  145.  
  146.     /* quit menu item means quit */
  147.     call Notify("mquit","menutrigger","everytime","app","returnid","quit")
  148.  
  149.     call set("win","activeobject","done")
  150.     return
  151. /***********************************************************************/
  152. halt:
  153. break_c:
  154.     exit
  155. /**************************************************************************/
  156.