\ gadgetutil

needs rectangletype

variable objx
variable objy

: objindex>yx  ( objindex -- y x )
    >r  
    objy >abs objx >abs  r>
    FrmGetActiveForm
    FrmGetObjectPosition
    objy @  objx @ ;

: draw-gadget  
    ( bitmpID gadgetindex -- )
    objindex>yx        ( bitmpID y x )
    rot                    ( y x bitmpID )
    [id] Tbmp
    DrawBitmapResource ;

RectangleType: gadget-bounds

: in-gadget?  
    ( gadget-index -- flag )
    >r    gadget-bounds >abs   r>
    ( &rect. gadget-index )
    FrmGetActiveForm
    FrmGetObjectBounds   ( )

    \ now see if the point was in bounds
    gadget-bounds >abs
    coords@          ( &rect. y x )
    RctPtInRectangle 

    \ need to clean flag - garbage in
    \ high byte
    (hex) 00FF and ;    

