1
# ------------------------------------------------------------------------------
3
# This file is part of Unifix BWidget Toolkit
4
# $Id: labelframe.tcl,v 1.1 2004/03/04 00:47:28 airadier Exp $
5
# ------------------------------------------------------------------------------
8
# - LabelFrame::getframe
9
# - LabelFrame::configure
12
# ------------------------------------------------------------------------------
14
namespace eval LabelFrame {
15
Widget::define LabelFrame labelframe Label
17
Widget::bwinclude LabelFrame Label .l \
19
-highlightthickness -highlightcolor -highlightbackground
20
-takefocus -relief -borderwidth
22
-dragenabled -draginitcmd -dragendcmd -dragevent -dragtype
23
-dropenabled -droptypes -dropovercmd -dropcmd} \
24
initialize {-anchor w}
26
Widget::declare LabelFrame {
27
{-relief TkResource flat 0 frame}
28
{-borderwidth TkResource 0 0 frame}
29
{-side Enum left 1 {left right top bottom}}
30
{-bd Synonym -borderwidth}
33
Widget::addmap LabelFrame "" :cmd {-background {}}
34
Widget::addmap LabelFrame "" .f {-background {} -relief {} -borderwidth {}}
36
Widget::syncoptions LabelFrame Label .l {-text {} -underline {}}
38
bind BwLabelFrame <FocusIn> [list Label::setfocus %W.l]
39
bind BwLabelFrame <Destroy> [list LabelFrame::_destroy %W]
43
# ----------------------------------------------------------------------------
44
# Command LabelFrame::create
45
# ----------------------------------------------------------------------------
46
proc LabelFrame::create { path args } {
47
Widget::init LabelFrame $path $args
49
set path [eval [list frame $path] [Widget::subcget $path :cmd] \
50
-relief flat -bd 0 -takefocus 0 -highlightthickness 0 \
53
set label [eval [list Label::create $path.l] [Widget::subcget $path .l] \
54
-takefocus 0 -highlightthickness 0 -relief flat \
55
-borderwidth 0 -dropenabled 0 -dragenabled 0]
56
set frame [eval [list frame $path.f] [Widget::subcget $path .f] \
57
-highlightthickness 0 -takefocus 0]
59
switch [Widget::getoption $path -side] {
60
left {set packopt "-side left"}
61
right {set packopt "-side right"}
62
top {set packopt "-side top -fill x"}
63
bottom {set packopt "-side bottom -fill x"}
66
eval [list pack $label] $packopt
67
pack $frame -fill both -expand yes
69
bindtags $path [list $path BwLabelFrame [winfo toplevel $path] all]
71
return [Widget::create LabelFrame $path]
75
# ----------------------------------------------------------------------------
76
# Command LabelFrame::getframe
77
# ----------------------------------------------------------------------------
78
proc LabelFrame::getframe { path } {
83
# ----------------------------------------------------------------------------
84
# Command LabelFrame::configure
85
# ----------------------------------------------------------------------------
86
proc LabelFrame::configure { path args } {
87
return [Widget::configure $path $args]
91
# ----------------------------------------------------------------------------
92
# Command LabelFrame::cget
93
# ----------------------------------------------------------------------------
94
proc LabelFrame::cget { path option } {
95
return [Widget::cget $path $option]
99
# ----------------------------------------------------------------------------
100
# Command LabelFrame::align
101
# This command align label of all widget given by args of class LabelFrame
102
# (or "derived") by setting their width to the max one +1
103
# ----------------------------------------------------------------------------
104
proc LabelFrame::align { args } {
109
if { ![info exists Widget::_class($w)] } {
112
set class $Widget::_class($w)
113
if { [string equal $class "LabelFrame"] } {
117
upvar 0 Widget::${class}::map classmap
121
foreach {option lmap} [array get classmap] {
122
foreach {subpath subclass realopt} $lmap {
123
if { [string equal $subclass "LabelFrame"] } {
124
if { [string equal $realopt "-text"] } {
129
if { [string equal $realopt "-width"] } {
144
set len [string length [$w cget $textopt]]
145
if { $len > $maxlen } {
148
lappend wlist $w $widthopt
152
foreach {w widthopt} $wlist {
153
$w configure $widthopt $maxlen
158
proc LabelFrame::_destroy { path } {
159
Widget::destroy $path