
class xuiBoolean {
    inherit xuiObject

    variable value {}
    variable default {}
    constructor {} {
    setXuiClass boolean
    }   
    method getValue {}
    method setValue {}
    method getDefault {}
    method setDefault { bool }
    method clearValue {}
    method getText {}
    method clone 
    method copyClone { clone }
    method reset {}
}

body xuiBoolean::reset {} {
       set value $default
}

body xuiBoolean::getDefault {} {
return $default
}

body xuiBoolean::setDefault { bool } {
set default $bool
}

body xuiBoolean::setValue {} {
    set value 1
}

body xuiBoolean::clearValue {} {
    set value 0
}

body xuiBoolean::getValue {} {
    return $value
}

body xuiBoolean::getText {} {
  if [llength $value] {
    if $value {
    return yes
    } else {
    return no
    }
  } else {
     return "unset"
  }
}

body xuiBoolean::clone {{parentName {::#auto}}} {
   set clone [xuiBoolean $parentName.$name]
   copyClone $clone
   return $clone
}
      
body xuiBoolean::copyClone { clone } {
   xuiObject::copyClone $clone
   if [llength $value] {
    if $value {
    $clone setValue
    } else {
    $clone clearValue
    }
  } else {
     return
  }
   $clone setDefault $default
   $clone setXuiClass $xuiClass
}

