labelentry.tcl 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. # ------------------------------------------------------------------------------
  2. # labelentry.tcl
  3. # This file is part of Unifix BWidget Toolkit
  4. # $Id$
  5. # ------------------------------------------------------------------------------
  6. # Index of commands:
  7. # - LabelEntry::create
  8. # - LabelEntry::configure
  9. # - LabelEntry::cget
  10. # - LabelEntry::bind
  11. # ------------------------------------------------------------------------------
  12. namespace eval LabelEntry {
  13. Entry::use
  14. LabelFrame::use
  15. Widget::bwinclude LabelEntry LabelFrame .labf \
  16. remove {-relief -borderwidth -focus} \
  17. rename {-text -label} \
  18. prefix {label -justify -width -anchor -height -font} \
  19. Widget::bwinclude LabelEntry Entry .e \
  20. remove {-fg -bg} \
  21. rename {-foreground -entryfg -background -entrybg}
  22. Widget::addmap LabelEntry "" :cmd {-background {}}
  23. Widget::syncoptions LabelEntry Entry .e {-text {}}
  24. Widget::syncoptions LabelEntry LabelFrame .labf {-label -text -underline {}}
  25. ::bind BwLabelEntry <FocusIn> {focus %W.labf}
  26. ::bind BwLabelEntry <Destroy> {Widget::destroy %W; rename %W {}}
  27. proc ::LabelEntry { path args } { return [eval LabelEntry::create $path $args] }
  28. proc use { } {}
  29. }
  30. # ------------------------------------------------------------------------------
  31. # Command LabelEntry::create
  32. # ------------------------------------------------------------------------------
  33. proc LabelEntry::create { path args } {
  34. Widget::init LabelEntry $path $args
  35. eval frame $path [Widget::subcget $path :cmd] \
  36. -relief flat -bd 0 -highlightthickness 0 -takefocus 0
  37. set labf [eval LabelFrame::create $path.labf [Widget::subcget $path .labf] \
  38. -relief flat -borderwidth 0 -focus $path.e]
  39. set subf [LabelFrame::getframe $labf]
  40. set entry [eval Entry::create $path.e [Widget::subcget $path .e]]
  41. pack $entry -in $subf -fill both -expand yes
  42. pack $labf -fill both -expand yes
  43. bindtags $path [list $path BwLabelEntry [winfo toplevel $path] all]
  44. rename $path ::$path:cmd
  45. proc ::$path { cmd args } "return \[LabelEntry::_path_command $path \$cmd \$args\]"
  46. return $path
  47. }
  48. # ------------------------------------------------------------------------------
  49. # Command LabelEntry::configure
  50. # ------------------------------------------------------------------------------
  51. proc LabelEntry::configure { path args } {
  52. return [Widget::configure $path $args]
  53. }
  54. # ------------------------------------------------------------------------------
  55. # Command LabelEntry::cget
  56. # ------------------------------------------------------------------------------
  57. proc LabelEntry::cget { path option } {
  58. return [Widget::cget $path $option]
  59. }
  60. # ------------------------------------------------------------------------------
  61. # Command LabelEntry::bind
  62. # ------------------------------------------------------------------------------
  63. proc LabelEntry::bind { path args } {
  64. return [eval ::bind $path.e $args]
  65. }
  66. #------------------------------------------------------------------------------
  67. # Command LabelEntry::_path_command
  68. #------------------------------------------------------------------------------
  69. proc LabelEntry::_path_command { path cmd larg } {
  70. if { ![string compare $cmd "configure"] ||
  71. ![string compare $cmd "cget"] ||
  72. ![string compare $cmd "bind"] } {
  73. return [eval LabelEntry::$cmd $path $larg]
  74. } else {
  75. return [eval $path.e:cmd $cmd $larg]
  76. }
  77. }