home *** CD-ROM | disk | FTP | other *** search
/ CyberMycha 2006 April / SGP.iso / dema / Keepsake-Demo-en-li-v1.0.exe / res / bin / prime / oz'event.tcl < prev    next >
Text File  |  2005-10-29  |  2KB  |  78 lines

  1. proc oz'event {flag {code ""}} {
  2.     if {$code == ""} {set code $flag}
  3.     if {$flag == "-all"} {
  4.         chainEvent [uplevel 1 subst \{$code\}]
  5.         return
  6.     }
  7.     
  8.     chainEvent [uplevel 1 subst -nocommands \{$code\}]
  9. }
  10.  
  11. proc oz'thread {id code} {
  12.     setThreadID $id
  13.     $code
  14.     setThreadID 0
  15. }
  16.  
  17. proc oz'delay {time} {
  18.     delay [expr floor($time * 1000)]
  19. }
  20.     
  21. namespace eval wq'widget {
  22.     proc new {name args} {
  23.         set optstring {{depth "0"} foreground background interface}
  24.         array set v [cmdline::getopt $args $optstring]
  25.  
  26.         set sprite [::new oz'sprite $name]
  27.         eval "oz'widget::property $sprite $args"
  28.  
  29.         oz'event {
  30.             if [oz'widget::valid? $sprite] {
  31.                 if $v(background?) {
  32.                     oz'widget::child [BACKGROUNDWIDGET] $sprite $v(depth)
  33.                 } elseif $v(interface?) {
  34.                     oz'widget::child [INTERFACEWIDGET] $sprite $v(depth)
  35.                 } else {
  36.                     oz'widget::child [FOREGROUNDWIDGET] $sprite $v(depth)
  37.                 }
  38.             }
  39.         }
  40.         return $sprite
  41.     }
  42.  
  43.     proc fadeto {this alpha args} {
  44.         if !$this return
  45.         
  46.         set optstring {wait {time 0.5}}
  47.         array set v [cmdline::getopt $args $optstring]
  48.        
  49.         oz'event {oz'widget::fadeto $this $alpha $v(time)}
  50.         if $v(wait?) {waitfor $this -transit}
  51.     }
  52.  
  53.     proc waitfor {this args} {
  54.         if !$this return
  55.         
  56.         set optstring {transit animate}
  57.         array set v [cmdline::getopt $args $optstring]
  58.         
  59.         if $v(transit?) {oz'event {if [oz'widget::transit? $this] {oz'return wait}}}
  60.         if $v(animate?) {oz'event {if [oz'widget::animate? $this] {oz'return wait}}}
  61.     }
  62.  
  63.     proc delete {this} {
  64.         if !$this return
  65.         
  66.         oz'event {::delete $this}
  67.     }
  68.  
  69.     proc delete& {var} {
  70.         upvar 1 $var this
  71.         if !$this return
  72.         
  73.         oz'event {::delete $this}
  74.         set this 0
  75.     }
  76. }
  77.  
  78.