# Program: xf
# Description: handle radiobutton widgets
#
# $Header: Radiobutton[2.3] Wed Mar 10 11:59:11 1993 garfield@garfield frozen $

global xfDefaultConf
set xfDefaultConf(radiobutton) 4

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

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

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

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

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

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

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

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

  XFElementInit $xfW .xf${xfClass}Config4 $xfType $xfClass \
    XFRadiobuttonSetRadiobutton4 parameters $xfName 4
  XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass bg \
    background Background "Background" XFRadiobuttonSetRadiobutton4
  XFElementBitmap $xfW .xf${xfClass}Config4 $xfType $xfClass \
    XFRadiobuttonSetRadiobutton4
  XFElementFont $xfW .xf${xfClass}Config4 $xfType $xfClass \
    XFRadiobuttonSetRadiobutton4
  XFElementColor $xfW .xf${xfClass}Config4 $xfType $xfClass fg \
    foreground Foreground "Foreground" XFRadiobuttonSetRadiobutton4
  XFElementText $xfW .xf${xfClass}Config4 $xfType $xfClass text text Text \
    "Label" XFRadiobuttonSetRadiobutton4 $xfName
  XFElementSize $xfW .xf${xfClass}Config4 $xfType $xfClass \
    XFRadiobuttonSetRadiobutton4
  XFElementTextVariable $xfW .xf${xfClass}Config4 $xfType $xfClass \
    XFRadiobuttonSetRadiobutton4
  XFElementText $xfW .xf${xfClass}Config4 $xfType $xfClass value value Value \
    "Value" XFRadiobuttonSetRadiobutton4 $xfName
  XFElementVariable $xfW .xf${xfClass}Config4 $xfType $xfClass \
    XFRadiobuttonSetRadiobutton4
  XFElementCommand $xfW .xf${xfClass}Config4 $xfType

  # save current parameter
  XFElementSave $xfW $xfClass {background bitmap command font foreground height text textvariable value 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 \
    "XFRadiobuttonSetRadiobutton4 $xfW 0 $xfClass"

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

##########
# Procedure: XFRadiobuttonSetRadiobutton4
# Description: set radiobutton 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 XFRadiobuttonSetRadiobutton4 {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 text \
    [.xf${xfClass}Config4.params1.params2.text.text get]
  XFMiscSetResource $xfW textvariable \
    [.xf${xfClass}Config4.params1.params2.textvar.textvar get]
  XFMiscSetResource $xfW value \
    [.xf${xfClass}Config4.params1.params2.value.value 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

