# Program: xf
# Description: handle checkbutton widgets
#
# $Header: CheckButton[2.3] Wed Mar 10 11:58:40 1993 garfield@garfield frozen $

global xfDefaultConf
set xfDefaultConf(checkbutton) 4

##########
# Procedure: XFAdd.CheckButton
# Description: add a checkbutton
# Arguments: xfW - the widget
#            xfName - a optional name
#            xfType - add or config
# Returns: none
# Sideeffects: none
##########
proc XFAdd.CheckButton {xfW xfName xfType} {
  global xfStatus

  XFEditSetStatus "Inserting CheckButton..."
  set xfName [XFMiscGetUniqueName $xfName checkbutton]
  if {"$xfStatus(path)" == "."} {
    if {"$xfType" == "add"} {
      checkbutton .$xfName \
        -text "$xfName" \
        -relief raised
    } {
      checkbutton .$xfName
    }

    XFMiscPositionWidget .$xfName
    XFMiscBindWidgetTree .$xfName
  } {
    if {"$xfType" == "add"} {
      checkbutton $xfStatus(path).$xfName \
        -text "$xfName" \
        -relief raised
    } {
      checkbutton $xfStatus(path).$xfName
    }

    XFMiscPositionWidget $xfStatus(path).$xfName
    XFMiscBindWidgetTree $xfStatus(path).$xfName
  }

  incr xfStatus(elementCounter)
  XFEditSetPath $xfStatus(path)
  XFEditSetStatus "Inserting CheckButton...done"
}

##########
# Procedure: XFConfig.CheckButton4
# Description: configure a checkbutton
# Arguments: xfW - the widget
#            xfType - config type (add config)
#            xfClass - the class we configure
#            xfLeader - the leading window
# Returns: none
# Sideeffects: none
##########
proc XFConfig.CheckButton4 {xfW xfType xfClass {xfLeader ""}} {
  global xfStatus

  if {"$xfType" == "add"} {
    set xfName checkbutton$xfStatus(elementCounter)
  } {
    set xfName [XFMiscPathName $xfW]
  }
  XFEditSetStatus "Calling parameter setting for Checkbutton..."

  # build widget structure
  XFTmpltToplevel .xf${xfClass}Config4 400x520 \
    "Checkbutton parameters:[XFMiscPathTail $xfW]" $xfLeader

  XFElementInit $xfW .xf${xfClass}Config4 $xfType $xfClass \
    XFCheckButtonSetCheckButton4 parameters $xfName 4
  XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass bg \
    background Background "Background" XFCheckButtonSetCheckButton4
  XFElementBitmap $xfW .xf${xfClass}Config4 $xfType $xfClass \
    XFCheckButtonSetCheckButton4
  XFElementFont $xfW .xf${xfClass}Config4 $xfType $xfClass \
    XFCheckButtonSetCheckButton4
  XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass fg \
    foreground Foreground "Foreground" XFCheckButtonSetCheckButton4
  XFElementText $xfW .xf${xfClass}Config4 $xfType $xfClass text text Text \
    "Label" XFCheckButtonSetCheckButton4 $xfName
  XFElementText $xfW .xf${xfClass}Config4 $xfType $xfClass offvalue \
    offValue Value "Off value" XFCheckButtonSetCheckButton4 0
  XFElementText $xfW .xf${xfClass}Config4 $xfType $xfClass onvalue \
    onValue Value "On value" XFCheckButtonSetCheckButton4 1
  XFElementSize $xfW .xf${xfClass}Config4 $xfType $xfClass \
    XFCheckButtonSetCheckButton4
  XFElementTextVariable $xfW .xf${xfClass}Config4 $xfType $xfClass \
    XFCheckButtonSetCheckButton4
  XFElementVariable $xfW .xf${xfClass}Config4 $xfType $xfClass \
    XFCheckButtonSetCheckButton4 
  XFElementCommand $xfW .xf${xfClass}Config4 $xfType

  if {"$xfType" == "add"} {
    .xf${xfClass}Config4.params1.params2.variable.variable delete 0 end
    .xf${xfClass}Config4.params1.params2.variable.variable insert 0 $xfName
  }

  # save current parameter
  XFElementSave $xfW $xfClass {background bitmap command font foreground height offvalue onvalue text textvariable variable width}

  # packing
  pack append .xf${xfClass}Config4.params1 \
              .xf${xfClass}Config4.params1.params2 {left fill expand}
  pack append .xf${xfClass}Config4 \
              .xf${xfClass}Config4.pathname {top fill frame center} \
              .xf${xfClass}Config4.leave {bottom fill} \
              .xf${xfClass}Config4.additional {bottom fill} \
              .xf${xfClass}Config4.params1 {top fill expand}

  XFBindFormConnect .xf${xfClass}Config4.params1.params2 \
    "XFCheckButtonSetCheckButton4 $xfW 0 $xfClass"

  XFEditSetStatus "Calling parameter setting for CheckButton...done"
}

##########
# Procedure: XFCheckButtonSetCheckButton4
# Description: set checkbutton parameters
# Arguments: xfW - the widget
#            xfType - the type of setting (1 = set always, 0 = set
#                     only if permanent apply is on)
#            xfClass - the class we configure
#            xfParam1 - ignored parameter
# Returns: none
# Sideeffects: none
##########
proc XFCheckButtonSetCheckButton4 {xfW xfType xfClass {xfParam1 ""}} {
  global xfConf
  global xfMisc

  if {$xfType == 0 && !$xfConf(applyParameters)} {
    return
  }
  if {"[info commands $xfW]" == ""} {
    return
  }
  XFMiscSetSymbolicName $xfW \
    [.xf${xfClass}Config4.params1.params2.symname.symname get]

  XFMiscSetResource $xfW background \
    [.xf${xfClass}Config4.params1.params2.bg.bg get]
  XFMiscSetResource $xfW bitmap \
    [.xf${xfClass}Config4.params1.params2.bitmap.bitmap get]
  XFMiscSetResource $xfW command \
    [XFMiscGetText .xf${xfClass}Config4.params1.params2.command.command.command]
  XFMiscSetResource $xfW font \
    [.xf${xfClass}Config4.params1.params2.font.font get]
  XFMiscSetResource $xfW foreground \
    [.xf${xfClass}Config4.params1.params2.fg.fg get]
  XFMiscSetResource $xfW height \
    [.xf${xfClass}Config4.params1.params2.size.size2.size2 get]
  XFMiscSetResource $xfW offvalue \
    [.xf${xfClass}Config4.params1.params2.offvalue.offvalue get]
  XFMiscSetResource $xfW onvalue \
    [.xf${xfClass}Config4.params1.params2.onvalue.onvalue get]
  XFMiscSetResource $xfW text \
    [.xf${xfClass}Config4.params1.params2.text.text get]
  XFMiscSetResource $xfW textvariable \
    [.xf${xfClass}Config4.params1.params2.textvar.textvar get]
  XFMiscSetResource $xfW variable \
    [.xf${xfClass}Config4.params1.params2.variable.variable get]
  XFMiscSetResource $xfW width \
    [.xf${xfClass}Config4.params1.params2.size.size1.size1 get]
}

# eof

