\ fourtap-buttons 2001/12/22 KDJ

\ Copyright 2001
\ Kristopher D. Johnson
\ 
\ THIS CODE IS PROVIDED "AS IS"
\ WITHOUT WARRANTY OF ANY KIND.
\ THE AUTHOR SHALL NOT BE LIABLE
\ FOR ANY CLAIM IN CONNECTION
\ WITH THIS CODE.
\ 
\ This code may be used, copied,
\ modified, or distributed for any
\ purpose, provided that the above
\ copyright notice and disclaimer of
\ warranty is retained on all copies.

needs Forms

needs fourtap-util
needs fourtap-resources
needs fourtap-sounds

.( fourtap-buttons... )

decimal

3 constant BtnRectDiam

: ctlptr>bounds ( &ControlType. -- &Rect. )
  cell m+ ;
  
: btn>rect ( n -- diam &rect. )
  BtnRectDiam swap
  GetObjectPtr ctlptr>bounds ;

: invert-rect ( diam &rect. -- )
  WinInvertRectangle ;

: invert-btn ( n -- )
  btn>rect invert-rect ;

variable flash-time
200 flash-time !

: flash-delay ( -- )
  flash-time @ ms ;

: invert&delay ( diam &rect.-- diam &rect.)
  3dup invert-rect flash-delay ;

: on&off ( diam &rect.-- diam &rect. )
  invert&delay invert&delay ;

: flash-btn ( n -- )
  btn>rect
  on&off on&off on&off
  2drop drop ;

: play-btn ( n -- )
  dup invert-btn
  dup btn-sound
  invert-btn ;

: btn-id? ( n -- f )
  btn1 btnMax inrange? ;

