home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmigaPlus / Tools / Development / RxMUI / Examples / Select.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  2004-01-31  |  6.1 KB  |  185 lines

  1. /* NList example */
  2.  
  3. signal on halt
  4. signal on break_c
  5.  
  6. call Init
  7. call CreateApp
  8. call set("mwin","open",1)
  9. call HandleApp
  10.  
  11. /***********************************************************************/
  12. init: procedure
  13.     l="rmh.library";if ~show("L",l) then;if ~AddLib(l,0,-30) then exit
  14.     if AddLibrary("rxmui.library")~=0 then exit
  15.     call RxMUIOpt("DebugMode ShowErr")
  16.     call SetRxMUIStack(64000)
  17.     return
  18. /***********************************************************************/
  19. CreateApp: procedure
  20.  
  21.     app.Title="Listview example"
  22.     app.Version="$VER: Listview examples 2.0 (10.3.2003)"
  23.     app.Copyright="©2000-2003, alfie"
  24.     app.Author="alfie"
  25.     app.Description="Listview example"
  26.     app.Base="RXMUIEXAMPLE"
  27.     app.SubWindow="mwin"
  28.  
  29.      mwin.Title="Listview example"
  30.      mwin.ScreenTitle="Listview example"
  31.      mwin.ID="MWIN"
  32.      mwin.Contents="mgroup"
  33.  
  34.       mgroup.0=text("info",,"none","none","1B"x"l")
  35.  
  36.       mgroup.1="lg"
  37.        lg.class="group"
  38.         lg.0="lview"
  39.          lview.Class="nlistview"
  40.          lview.List="list"
  41.          list.Title="First|Second|Third"
  42.           list.Format="BAR,BAR,BAR"
  43.           list.MultiSelect="default"
  44.           list.DragSortable=1
  45.           list.MincolSortable=0
  46.  
  47.       mgroup.2="bg"
  48.        bg.class="group"
  49.        bg.Columns=3
  50.  
  51.         bg.0  = Button("selall","_Select all")
  52.         bg.1  = Button("selnone","S_elect none")
  53.         bg.2  = Button("seltoggle","Se_lect toggle")
  54.  
  55.         bg.3  = Button("remact","_Remove active")
  56.         bg.4  = Button("remall","Re_move all")
  57.         bg.5  = Button("remsel","Rem_ove selected")
  58.  
  59.         bg.6  = Button("getactive","_Get active")
  60.         bg.7  = Button("getall","Get _all")
  61.         bg.8  = Button("getsel","Get sele_cted")
  62.  
  63.         bg.9  = Button("defsort","_Def sort")
  64.         bg.10 = Button("nosort","_No Sort")
  65.         bg.11 = Button("readd","Add Entr_ies")
  66.  
  67.         bg.12 = ToggleButton("showsecret","S_how Secret")
  68.         bg.13 = hspace()
  69.         bg.14 = hspace()
  70.  
  71.     if NewObj("application","app")>0 then exit
  72.  
  73.     call notify("selall","pressed",0,"list","select","all","on")
  74.     call notify("selnone","pressed",0,"list","select","all","off")
  75.     call notify("seltoggle","pressed",0,"list","select","all","toggle")
  76.  
  77.     call notify("remall","pressed",0,"list","clear")
  78.     call notify("remact","pressed",0,"list","remove","active")
  79.     call notify("remsel","pressed",0,"list","remove","selected")
  80.  
  81.     call notify("getactive","pressed",0,"app","return","call GetActive")
  82.     call notify("getall","pressed",0,"app","return","call GetAll")
  83.     call notify("getsel","pressed",0,"app","return","call GetSel")
  84.  
  85.     call notify("readd","pressed",0,"app","return","call AddEntries")
  86.     call Notify("defsort","pressed",0,"list","set","SortType","COL 1")
  87.     call Notify("defsort","pressed",0,"list","set","SortType2","COL 0 REV")
  88.     call Notify("defsort","pressed",0,"list","Sort")
  89.     call Notify("showsecret","Selected",0,"app","return","call setformat('BAR,BAR')")
  90.     call Notify("showsecret","Selected",1,"app","return","call setformat('BAR,BAR,BAR')")
  91.  
  92.     call Notify("nosort","pressed",0,"list","set","SortType","off")
  93.     call Notify("nosort","pressed",0,"list","set","SortType2","off")
  94.  
  95.     call Notify("list","TitleClick","EveryTime","list","Sort3","TriggerValue","Add2Values","Both");
  96.     call Notify("list","TitleClick2","EveryTime","list","Sort3","TriggerValue","Add2Values","Type2");
  97.     call Notify("list","SortType","EveryTime","list","Set","TitleMark","TriggerValue");
  98.     call Notify("list","SortType2","EveryTime","list","Set","TitleMark2","TriggerValue");
  99.  
  100.     call Notify("list","Entries","EveryTime","app","return","call info")
  101.     call Notify("list","SelectChange","EveryTime","app","return","call info")
  102.  
  103.     call Notify("mwin","closerequest",1,"app","returnid","quit")
  104.  
  105.     call set("list","SortType","COL 1 ")
  106.     call set("list","SortType2","COL 0 REV")
  107.  
  108.     call AddEntries
  109.  
  110.     call set("list","Format","BAR,BAR")
  111.  
  112.     return
  113. /***********************************************************************/
  114. HandleApp: procedure
  115.     ctrl_c=2**12
  116.     do forever
  117.         call NewHandle("app","h",ctrl_c)
  118.         if and(h.Signals,2**12)~=0 then call halt
  119.         select
  120.             when h.Event="QUIT" then call halt
  121.             otherwise interpret h.Event
  122.         end
  123.     end
  124. end
  125. /***********************************************************************/
  126. AddEntries: procedure
  127.  
  128.     call DoMethod("list","insert","Emi|Ranieri|Secret 2","sorted")
  129.     call DoMethod("list","insert","Alfonso|Ranieri|Secret 1","sorted")
  130.     call DoMethod("list","insert","Paolo|Ranieri|Secret 3","sorted")
  131.     call DoMethod("list","insert","Tiziana|Spognardi|Secret 4","sorted")
  132.     return
  133. /***********************************************************************/
  134. GetActive: procedure
  135.  
  136.     a=xget("list","active")
  137.     if a>-1 then do
  138.         call DoMethod("list","GetEntry",a,"e")
  139.         say "Active ["a"]:" e
  140.     end
  141.     else say "No entry active"
  142.     say
  143.     return
  144. /***********************************************************************/
  145. GetAll: procedure
  146.  
  147.     call DoMethod("list","GetEntries","A")
  148.     if a.num>0 then
  149.         do i=0 to a.num-1
  150.             say i":" a.i
  151.         end
  152.     else say "No entries"
  153.     say
  154.     return
  155. /***********************************************************************/
  156. GetSel: procedure
  157.  
  158.     call DoMethod("list","GetSelected","a")
  159.     if a.num>0 then
  160.         do i=0 to a.num-1
  161.             call DoMethod("list","GetEntry",i,"e")
  162.             say i":" e
  163.         end
  164.     else say "No entries"
  165.     say
  166.     return
  167. /***********************************************************************/
  168. info: procedure
  169.     call set("info","Contents","Entyries:"xget("list","Entries")" Selected:"xget("list","NumSelected"))
  170.     return
  171. /***********************************************************************/
  172. setformat: procedure
  173. parse arg f
  174.     call set("list","format",f)
  175.     return
  176. /***********************************************************************/
  177. halt:
  178. break_c:
  179.     call DoMethod("list","GetSortType","st")
  180.     say " SortType:" st
  181.     call DoMethod("list","GetSortType2","st2")
  182.     say "SortType2:" st2
  183.     exit
  184. /***********************************************************************/
  185.