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

  1. /* Very cute: show the content of the clipboard
  2. ** both text and image
  3. **/
  4.  
  5. signal on halt
  6. signal on break_c
  7.  
  8. call Init()
  9. call CreateApp(f)
  10. call HandleApp
  11. /* never reached */
  12.  
  13. /***********************************************************************/
  14. Init: procedure expose global.
  15.     l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
  16.     if AddLibrary("rexxsupport.library","rxmui.library")~=0 then exit
  17.     call MacroEnv("global","ProgDir CD")
  18.     call SetRxMUIStack(16384)
  19.     global.noti=StartNotify("CLIP",0)
  20.     if global.noti<0 then do
  21.         call PrintFault(IoErr(),ProgramName("NOEXT"))
  22.         exit
  23.     end
  24.     global.ns=NotifySignal(global.noti)
  25.     global.bm=0
  26.     if NewObj("rectangle","bm")>0 then exit
  27.     return
  28. /***********************************************************************/
  29. CreateApp: procedure expose global.
  30.  
  31.     call RxMUIOpt("debugmode showerr")
  32.  
  33.     app.Title="Clipview"
  34.     app.Version="$VER: Clipview 1.1 (25.1.2002)"
  35.     app.Copyright="Copyright 2002 by alfie"
  36.     app.Author="alfie"
  37.     app.Description="Clipview example"
  38.     app.Base="CLIPVIEW"
  39.     app.SubWindow="win"
  40.  
  41.      win.ID="main"
  42.      win.Title="Clipview"
  43.      win.UseBottomBorderScroller=1
  44.      win.UseRightBorderScroller=1
  45.      win.Contents="mgroup"
  46.  
  47.       mgroup.0="sg"
  48.        sg.class="scrollgroup"
  49.        sg.UseWinBorder=1
  50.        sg.frame="virtual"
  51.        sg.virtgroupcontents="vg"
  52.         vg.class="virtgroup"
  53.  
  54.     if NewObj("APPLICATION","APP")>0 then exit
  55.  
  56.     call RxMUIOpt("")
  57.  
  58.     call CreateClipObject()
  59.  
  60.     call set("win","open",1)
  61.  
  62.     call Notify("win","CloseRequest",1,"app","ReturnID","quit")
  63.  
  64.     return
  65. /***********************************************************************/
  66. HandleApp: procedure expose global.
  67.  
  68.     ctrl_c=2**12
  69.     mask=or(ctrl_c,global.ns)
  70.     do forever
  71.  
  72.         call NewHandle("app","h",mask)
  73.  
  74.         if and(h.signals,ctrl_c)>0 then exit
  75.         if and(h.signals,global.ns)>0 then call CreateClipObject()
  76.         if h.EventFlag then
  77.             select
  78.                 when h.event="QUIT" then exit
  79.                 otherwise interpret h.event
  80.             end
  81.  
  82.     end
  83.     /* never reached */
  84. /***********************************************************************/
  85. CreateClipObject: procedure expose global.
  86.  
  87.     call set("app","sleep",1)
  88.  
  89.     call DoMethod("vg","InitChanges")
  90.     if global.bm then call Dispose("chg")
  91.  
  92.     bm.sourcetype="Clipboard"
  93.     bm.source=0
  94.     if NewObj("picture","bm")>0 then do
  95.         if ReadTextClip("t")>0 then do
  96.             drop bm.
  97.             bm.contents=t
  98.             if NewObj("text","bm")>0 then exit
  99.             t="text"
  100.         end
  101.         else t="none"
  102.     end
  103.     else t="picture"
  104.  
  105.     chg.horiz=1
  106.     chg.spacing=0
  107.      chg.0="cvg"
  108.       cvg.class="group"
  109.       cvg.spacing=0
  110.        cvg.0="bm"
  111.        cvg.1=vspace()
  112.      chg.1=hspace()
  113.     if NewObj("group","chg")>0 then exit
  114.  
  115.     global.bm=1
  116.  
  117.     call Add("vg","chg")
  118.     call DoMethod("vg","ExitChanges")
  119.     call set("win","Title","Clipview ["t"]")
  120.     call set("app","sleep",0)
  121.     return
  122. /***********************************************************************/
  123. halt:
  124. break_c:
  125.     exit
  126. /**************************************************************************/
  127.  
  128.