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