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

  1. /* How to handle manual drag and drop between 2 NList */
  2.  
  3.  
  4. signal on halt
  5. signal on break_c
  6.  
  7. l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  8. if AddLibrary("rexxsupport.library","rxmui.library")~=0 then exit
  9. call setrxmuistack(86000) /* Big stack for NList */
  10.  
  11. call CreateApp
  12.  
  13. call set("win","open",1)
  14.  
  15. call HandleApp
  16. exit
  17. /***********************************************************************/
  18. handleApp: procedure
  19.     ctrl_c=2**12
  20.     s=0
  21.     do forever
  22.         ws=1
  23.         call handle("APP","H",s)
  24.         do i=0 to h.num-1
  25.             select
  26.                 when h.i="QUIT" then exit
  27.                 when h.i="DROPEVENT" then do
  28.                     call dropFun(h.i.from,h.i.to,1)
  29.                     ws=0
  30.                 end
  31.                 otherwise say i"/"h.num-1 h.i
  32.             end
  33.         end
  34.         if ~ws then iterate
  35.         s=wait(or(h.signals,ctrl_c))
  36.         if and(s,ctrl_c)~=0 then exit
  37.     end
  38.     /* never reached */
  39. /***********************************************************************/
  40. err: procedure expose sigl rxmuierror
  41. parse arg res
  42. say signl "["res"]"
  43.     say getrxmuistring(res) "in line" sigl-1 rxmuierror
  44.     exit
  45. /***********************************************************************/
  46. CreateApp: procedure
  47.     app.Title="ManualD&D"
  48.     app.Version="$VER: ManualD&D 1.0 (22.11.99)"
  49.     app.Copyright="©1999, alfie"
  50.     app.Author="alfie"
  51.     app.Description="ManualD&D example"
  52.     app.Base="SHOW"
  53.     app.SubWindow="WIN"
  54.  
  55.      win.Title="ManualD&D"
  56.      win.ScreenTitle="ManualD&D"
  57.      win.ID="SHOW"
  58.      win.Contents="mgroup"
  59.  
  60.       mgroup.0="bg"
  61.        bg.class="group"
  62.        bg.horiz=1
  63.        bg.0 = Button("remove","_Remove")
  64.        bg.1 = Button("sort","_Sort")
  65.       mgroup.1="g"
  66.        g.class="group"
  67.        g.horiz=1
  68.        g.0="listview1"
  69.         listview1.class="nlistview"
  70.         listview1.list="list1"
  71.          list1.title="Uno|Due"
  72.          list1.titleclick=2
  73.          list1.multiselect="shifted"
  74.          list1.dragsortable=1
  75.          list1.dragtype="immediate"
  76.          list1.Format="BAR W=-1,BAR W=-1"
  77.          list1.mincolsortable=0
  78.          list1.titlemark=0
  79.           list1.0="Uno|1"
  80.           list1.1="Due|2"
  81.           list1.2="Tre|3"
  82.        g.1="listview2"
  83.         listview2.class="nlistview"
  84.         listview2.list="list2"
  85.          list2.dragsortable=1
  86.          list2.dragtype="immediate"
  87.          list2.Format="COL=1 BAR,COL=0 BAR"
  88.          list2.multiselect="DEFAULT"
  89.          list2.dragsortinsert=1
  90.           list2.0="Alfonso|Ranieri"
  91.           list2.1="Franco|Fiocca"
  92.           list2.2="Tiziana|Spognardi"
  93.           list2.3="Angelo|Barone"
  94.  
  95.     res=NewObj("application","app")
  96.     if res~=0 then call err(res)
  97.  
  98.     res=DandD("list2","list1")
  99.     if res~=0 then call err(res)
  100.  
  101.     res=DandD("list1","list2")
  102.     if res~=0 then call err(res)
  103.  
  104.     res=Notify("sort","pressed",0,"list2","sort")
  105.     if res~=0 then call err(res)
  106.  
  107.     res=Notify("remove","pressed",0,"list1","remove","active")
  108.     if res~=0 then call err(res)
  109.  
  110.     res=Notify("list1","titleclick","everytime","list1","sort2","triggervalue","add2values")
  111.     if res~=0 then call err(res)
  112.  
  113.     res=Notify("list1","sorttype","everytime","list1","set","titlemark","triggervalue")
  114.     if res~=0 then call err(res)
  115.  
  116.     res=Notify("list1","active","everytime","app","returnid")
  117.     if res~=0 then call err(res)
  118.  
  119.     res=Notify("win","closerequest",1,"app","returnid","quit")
  120.     if res~=0 then call err(res)
  121.  
  122.     return
  123. /***********************************************************************/
  124. halt:
  125. break_c:
  126.     exit
  127. /**************************************************************************/
  128. /* this is a drag and drop between 2 NList view */
  129. dropFun: procedure
  130. parse arg from,to,remove
  131.  
  132.     call set(to,"Quiet",1)
  133.  
  134.     call getattr(to,"DragSortable","ds")
  135.     if ds then dm="sorted"
  136.     else call getattr(to,"DropMark","dm")
  137.  
  138.     call DoMethod(from,"GetSelected","SEL")
  139.     do i=0 to sel.num-1
  140.         call DoMethod(from,"GetEntry",sel.i,"E")
  141.         call DoMethod(to,"Insert",e,dm)
  142.         if ~ds then dm=dm+1
  143.     end
  144.  
  145.     call set(to,"Active",xget(to,"InsertPosition"))
  146.  
  147.     call set(to,"Quiet",0)
  148.  
  149.     if remove then call DoMethod(from,"remove","selected")
  150.     call set(from,"Active","off")
  151.  
  152.     return
  153. /**************************************************************************/
  154.