/**/

signal on halt
signal on break_c

call CreateApp
call HandleApp
/* never reached */
/***********************************************************************/
init: procedure expose global.
    l="rmh.library";if ~show("L",l) then;if ~addlib(l,0,-30) then exit
    if AddLibrary("rxmui.library")~=0 then exit
    call RxMUIOpt("debugmode showerr")
    return
/***********************************************************************/
CreateApp: procedure

    app.Title="DockDemo"
    app.Version="$VER: DockDemo 1.0 (4.2.2001)"
    app.Copyright="©2001, alfie"
    app.Author="alfie"
    app.Description="DockDemo"
    app.Base="DOCKDEMO"
    app.SubWindow="win"
     win.ID="MAIN"
     win.AppWindow=1
     win.Title="DockDemo"
     win.Contents="mgroup"

      mgroup.0="g"
       g.class="group"
       g.spacing=0
       g.horiz=1
        g.0=CreateDock(1,1)

      mgroup.1=MakeObj(,"HBar")

       ni.Format="1b63"x || "  Icons: %ld  "
      mgroup.2=MakeObj("ni","numericbutton",,1,10)

    res=NewObj("APPLICATION","APP")
    if res~=0 then call err(res)

    call Notify("win","CloseRequest",1,"app","ReturnID","quit")
    call Notify("ni","value","everytime","app","Return","call CreateDock(h.value,0)","triggerattr")
    call IconNotify(1)
    call set("win","open",1)
    call getattr("win","open","o")
    if o=0 then do
        say "can't open window"
        exit
    end

    return
/**************************************************************************/
CreateDock: procedure expose global.
parse arg ni,init
    if ~init then do
        call DoMethod("g","InitChanges")
        call Dispose("dock")
    end
    dock.horiz=1
    if NewObj("group","dock")<0 then exit
    do i=1 to ni
        ic.class="icon"
        ic.name="sys:disk"
        ic.inputmode="relverify"
        ic.frame="button"
        name="icon"i
        if NewObj("icon",name,"ic")<0 then exit
        call Add("dock",name)
    end
    call Add("dock",hspace())
    if ~init then do
        call Add("g","dock")
        call DoMethod("g","ExitChanges")
        call IconNotify(ni)
    end
    return "dock"
/**************************************************************************/
IconNotify: procedure expose global.
parse arg ni
    do i=1 to ni
        call Notify("icon"i,"pressed",0,"app","return","say icon" i "pressed")
        call AppMessage("icon"i)
    end
    return
/**************************************************************************/
HandleApp: procedure
    ctrl_c=2**12
    do forever
        call NewHandle("app","h",ctrl_c)
        if and(h.signals,ctrl_c)>0 then exit
        select
            when h.event="QUIT" then exit
            when h.event="APPEVENT" then call AppFun(h.to,h.name)
            otherwise interpret h.event
        end
    end
    /* never reached */
/***********************************************************************/
AppFun: procedure
    parse arg to,name
    say "Dropped" name "to" to
    return
/**************************************************************************/
halt:
break_c:
    exit
/**************************************************************************/
