home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CyberMycha 2006 April
/
SGP.iso
/
dema
/
Keepsake-Demo-en-li-v1.0.exe
/
res
/
bin
/
prime
/
oz'button.tcl
< prev
next >
Wrap
Text File
|
2005-10-29
|
4KB
|
122 lines
class oz'button {
proc oz'button {this name} oz'widget {button$name} {
set ($this,name) $name
set filename "$name/[file tail $name]"
set ($this,enable) [new oz'sprite $filename.enable]
set ($this,target) [new oz'sprite $filename.target]
set ($this,disable) [new oz'sprite $filename.disable]
set ($this,select) [new oz'sprite $filename.select]
set ($this,p_click) ""
set ($this,s_click) "sound/interface/switchClic.ogg"
set ($this,s_over) ""
oz'widget::bind $this enter oz'button::enter $this
oz'widget::bind $this leave oz'button::leave $this
oz'widget::bind $this click oz'button::click $this
oz'widget::child $this $($this,disable) 1
oz'widget::child $this $($this,enable) 0.75
oz'widget::child $this $($this,target) 0.50
oz'widget::child $this $($this,select) 0.25
oz'widget::property $($this,disable) -alpha 0
oz'widget::property $($this,enable) -alpha 1
oz'widget::property $($this,target) -alpha 0
oz'widget::property $($this,select) -alpha 0
set ($this,state.enable) 1
set ($this,state.target) 0
set ($this,state.select) 0
oz'widget::property $this -isize [oz'widget::width $($this,enable)] [oz'widget::height $($this,enable)]
}
proc ~oz'button {this} {
delete $($this,enable)
delete $($this,target)
delete $($this,disable)
delete $($this,select)
}
proc property {this args} {
set optstring {
{click "*"}
{disable}
{nodisablecursor}
{sclick "sound/interface/switchClic.ogg"}
{sover ""}
}
array set v [cmdline::getopt $args $optstring]
if $v(click?) {set ($this,p_click) $v(click)}
if $v(disable?) {disable $this}
set ($this,s_click) $v(sclick)
set ($this,s_over) $v(sover)
eval "oz'widget::property $this $args"
}
proc enter {this} {
if $($this,state.enable) {
set ($this,state.target) 1
if {$($this,s_over) != ""} {
ozqSound::NewFX $($this,s_over)
}
oz'widget::fadeto $($this,target) 1
oz'mouse::cursor +1
} else {
oz'mouse::cursor +100
}
}
proc leave {this} {
if $($this,state.enable) {
set ($this,state.target) 0
oz'widget::fadeto $($this,target) 0
oz'mouse::cursor -1
} else {
oz'mouse::cursor -100
}
}
proc click {this} {
if !$($this,state.enable) return
ozqSound::NewFX $($this,s_click)
eval $($this,p_click)
select $this
}
proc select {this} {
if !$($this,state.enable) return
set ($this,state.select) 1
oz'widget::fadeto $($this,select) 1
}
proc unselect {this} {
if !$($this,state.enable) return
set ($this,state.select) 0
oz'widget::fadeto $($this,select) 0
}
proc enable {this} {
set ($this,state.enable) 1
oz'widget::fadeto $($this,disable) 0
oz'widget::fadeto $($this,enable) 1
}
proc disable {this} {
set ($this,state.enable) 0
set ($this,state.target) 0
set ($this,state.select) 0
oz'widget::fadeto $($this,disable) 1
oz'widget::fadeto $($this,enable) 0
oz'widget::fadeto $($this,target) 0
oz'widget::fadeto $($this,select) 0
}
}