Bwidget Source Code
Check-in [b8bf09501c]
Not logged in
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:theme related mod's done
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: b8bf09501cf3e30325a512948a07439630bd6711
User & Date: oberdorfer 2009-09-06 21:36:41
Context
2009-09-06
21:49
theme related mod's done check-in: 8ca4af4990 user: oberdorfer tags: trunk
21:36
theme related mod's done check-in: b8bf09501c user: oberdorfer tags: trunk
21:28
theme related mod's done check-in: 85325e23c6 user: oberdorfer tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to panelframe.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
# ----------------------------------------------------------------------------

#  panelframe.tcl

#	Create PanelFrame widgets.

#	A PanelFrame is a boxed frame that allows you to place items

#	in the label area (liked combined frame+toolbar).  It uses the

#	highlight colors the default frame color.

#  $Id: panelframe.tcl,v 1.11 2009/09/06 21:31:16 oberdorfer Exp $

# ----------------------------------------------------------------------------

#  Index of commands:

#     - PanelFrame::create

#     - PanelFrame::configure

#     - PanelFrame::cget

#     - PanelFrame::getframe

#     - PanelFrame::add

#     - PanelFrame::remove

#     - PanelFrame::items

# ----------------------------------------------------------------------------



namespace eval PanelFrame {

    Widget::define PanelFrame panelframe



    Widget::declare PanelFrame {

	{-background	   Color "SystemWindowFrame" 0}

	{-borderwidth	   TkResource 1	 0 frame}

	{-relief	   TkResource flat 0 frame}

	{-panelbackground  Color "SystemHighlight" 0}

	{-panelforeground  Color "SystemHighlightText" 0}

	{-width		   Int	      0	 0}

	{-height	   Int	      0	 0}

	{-font		   String     "TkTextFont" 0}

	{-text		   String     "" 0}

	{-textvariable	   String     "" 0}

	{-ipad		   String      1 0}

	{-bg		   Synonym    -background}

	{-bd		   Synonym    -borderwidth}

    }

    # Should we have automatic state handling?

    #{-state            TkResource "" 0 label}



    Widget::addmap PanelFrame "" :cmd {

	-panelbackground -background

	-width {} -height {} -borderwidth {} -relief {}

    }

    Widget::addmap PanelFrame "" .title	  {

	-panelbackground -background

    }

    Widget::addmap PanelFrame "" .title.text   {

	-panelbackground -background

	-panelforeground -foreground

	-text {} -textvariable {} -font {}

    }

    Widget::addmap PanelFrame "" .frame {

	-background {}

    }



    if {0} {

	# This would be code to have an automated close button

	#{-closebutton	   Boolean    0	 0}

	Widget::addmap PanelFrame "" .title.close   {

	    -panelbackground -background

	    -panelforeground -foreground

	}

	variable HaveMarlett \

	    [expr {[lsearch -exact [font families] "Marlett"] != -1}]



	variable imgdata {

	    #define close_width 16

	    #define close_height 16

	    static char close_bits[] = {

		0x00, 0x00, 0x00, 0x00,

		0x00, 0x00, 0x10, 0x08,

		0x38, 0x1c, 0x70, 0x0e,

		0xe0, 0x07, 0xc0, 0x03,

		0xc0, 0x03, 0xe0, 0x07,

		0x70, 0x0e, 0x38, 0x1c,

		0x10, 0x08, 0x00, 0x00,

		0x00, 0x00, 0x00, 0x00};

	}

	# We use the same -foreground as the default -panelbackground

	image create bitmap ::PanelFrame::X -data $imgdata \

	    -foreground [lindex $Widget::PanelFrame::opt(-panelbackground) 1]

    }



    bind PanelFrame <Destroy> [list Widget::destroy %W]

}





# ----------------------------------------------------------------------------

#  Command PanelFrame::create

# ----------------------------------------------------------------------------

proc PanelFrame::create { path args } {

    variable HaveMarlett



    Widget::init PanelFrame $path $args



    set lblopts [list -bd 0 -highlightthickness 0]

    set outer [eval [list frame $path -class PanelFrame] \

		   [Widget::subcget $path :cmd]]

    set title [eval [list frame $path.title] \

		   [Widget::subcget $path .title]]

    set tlbl  [eval [list label $path.title.text] $lblopts -anchor w \

		   [Widget::subcget $path .title.text]]

    set inner [eval [list frame $path.frame] \

		   [Widget::subcget $path .frame]]



    foreach {ipadx ipady} [_padval [Widget::cget $path -ipad]] { break }



    if {0} {

	set btnopts [list -padx 0 -pady 0 -relief flat -overrelief raised \

			 -bd 1 -highlightthickness 0]

	set clbl  [eval [list button $path.title.close] $btnopts \

		       [Widget::subcget $path .title.close]]

	set close [Widget::cget $path -closebutton]

	if {$HaveMarlett} {

	    $clbl configure -font "Marlett -14" -text \u0072

	} else {

	    $clbl configure -image ::PanelFrame::X

	}

	if {$close} {

	    pack $path.title.close -side right -padx $ipadx -pady $ipady

	}

    }



    grid $path.title -row 0 -column 0 -sticky ew

    grid $path.frame -row 1 -column 0 -sticky news

    grid columnconfigure $path 0 -weight 1

    grid rowconfigure $path 1 -weight 1



    pack $path.title.text -side left -fill x -anchor w \

	-padx $ipadx -pady $ipady



    return [Widget::create PanelFrame $path]

}





# ----------------------------------------------------------------------------

#  Command PanelFrame::configure

# ----------------------------------------------------------------------------

proc PanelFrame::configure { path args } {

    set res [Widget::configure $path $args]



    if {[Widget::hasChanged $path -ipad ipad]} {

    }



    return $res

}





# ----------------------------------------------------------------------------

#  Command PanelFrame::cget

# ----------------------------------------------------------------------------

proc PanelFrame::cget { path option } {

    return [Widget::cget $path $option]

}



# ----------------------------------------------------------------------------

#  Command PanelFrame::getframe

# ----------------------------------------------------------------------------

proc PanelFrame::getframe { path } {

    return $path.frame

}



# ------------------------------------------------------------------------

#  Command PanelFrame::add

# ------------------------------------------------------------------------

proc PanelFrame::add {path w args} {

    variable _widget



    array set opts [list \

			-side   right \

			-fill   none \

			-expand 0 \

			-pad    [Widget::cget $path -ipad] \

		       ]

    foreach {key val} $args {

	if {[info exists opts($key)]} {

	    set opts($key) $val

	} else {

	    set msg "unknown option \"$key\", must be one of: "

	    append msg [join [lsort [array names opts]] {, }]

	    return -code error $msg

	}

    }

    foreach {ipadx ipady} [_padval $opts(-pad)] { break }



    set f $path.title



    lappend _widget($path,items) $w

    pack $w -in $f -padx $ipadx -pady $ipady -side $opts(-side) \

	-fill $opts(-fill) -expand $opts(-expand)



    return $w

}



# ------------------------------------------------------------------------

#  Command PanelFrame::remove

# ------------------------------------------------------------------------

proc PanelFrame::remove {path args} {

    variable _widget



    set destroy [string equal [lindex $args 0] "-destroy"]

    if {$destroy} {

	set args [lrange $args 1 end]

    }

    foreach w $args {

	set idx [lsearch -exact $_widget($path,items) $w]

	if {$idx == -1} {

	    # ignore unknown

	    continue

	}

	if {$destroy} {

	    destroy $w

	} elseif {[winfo exists $w]} {

	    pack forget $w

	}

	set _widget($path,items) [lreplace $_widget($path,items) $idx $idx]

    }

}



# ------------------------------------------------------------------------

#  Command PanelFrame::delete

# ------------------------------------------------------------------------

proc PanelFrame::delete {path args} {

    return [PanelFrame::remove $path -destroy $args]

}



# ------------------------------------------------------------------------

#  Command PanelFrame::items

# ------------------------------------------------------------------------

proc PanelFrame::items {path} {

    variable _widget

    return $_widget($path,items)

}



proc PanelFrame::_padval {padval} {

    set len [llength $padval]

    foreach {a b} $padval { break }

    if {$len == 0 || $len > 2} {

	return -code error \

	    "invalid pad value \"$padval\", must be 1 or 2 pixel values"

    } elseif {$len == 1} {

	return [list $a $a]

    } elseif {$len == 2} {

	return $padval

    }

}

<

<

<

<

<

<
|
<

<

<

<

<

<

<

<

<

<

<
<





<
<

<

<

<

<

<

<

<

<

<

<

<

<

<

<



<


<
<

<

<

<



<

<



<

<

<

<



<

|
|
<
<
<

<

<

<

<

<

<



<


<
<

<

<

<

<

<

<

<

<

<

<

<

<



<

<

|
|
<
<
<

<



<
<
<

<

<

<

<

<
<



<
<

<

<

<

<

<

<

<

<

<
<



<
<

<

<

<

<

<

<

<

<

<

|
<
<

<

|
|

<
<
<
<

<

<

<


<
<

<


<
<

|
|

<
<
<
<

<

<

<

<


<
<

|
|
<
<
<

|
|

<
<
<
<

<

<

<

<

|
|
<
<
<

<

<

<

<

|
|
<
<
<

<

<

<

<


<
<

<

<

<

<

|
<
<

<

<

<

<

<

<

|
|
<
<
<

<
<



<
<

<

<


<
<

|
|
<
<
<

<

<

<

<


<
<

<

<

|
<
<

<

<

<

<

|
<
<

<

<

<

|
<
<

|
|

<
<
<
<

<

<

<

<

|
|
<
<
<

<

<

<

<

<

|
|
<
<
<

<

<

<

<

<

<

<

<

<

|
|
<
<
<
1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17


18
19
20
21
22


23

24

25

26

27

28

29

30

31

32

33

34

35

36

37
38
39

40
41


42

43

44

45
46
47

48

49
50
51

52

53

54

55
56
57

58
59
60



61

62

63

64

65

66

67
68
69

70
71


72

73

74

75

76

77

78

79

80

81

82

83

84
85
86

87

88
89
90



91

92
93
94



95

96

97

98

99


100
101
102


103

104

105

106

107

108

109

110

111


112
113
114


115

116

117

118

119

120

121

122

123

124
125


126

127
128
129
130




131

132

133

134
135


136

137
138


139
140
141
142




143

144

145

146

147
148


149
150
151



152
153
154
155




156

157

158

159

160
161
162



163

164

165

166

167
168
169



170

171

172

173

174
175


176

177

178

179

180
181


182

183

184

185

186

187

188
189
190



191


192
193
194


195

196

197
198


199
200
201



202

203

204

205

206
207


208

209

210
211


212

213

214

215

216
217


218

219

220

221
222


223
224
225
226




227

228

229

230

231
232
233



234

235

236

237

238

239
240
241



242

243

244

245

246

247

248

249

250

251
252
253



# ----------------------------------------------------------------------------

#  panelframe.tcl

#	Create PanelFrame widgets.

#	A PanelFrame is a boxed frame that allows you to place items

#	in the label area (liked combined frame+toolbar).  It uses the

#	highlight colors the default frame color.

#  $Id: panelframe.tcl,v 1.12 2009/09/06 21:36:41 oberdorfer Exp $

# ----------------------------------------------------------------------------

#  Index of commands:

#     - PanelFrame::create

#     - PanelFrame::configure

#     - PanelFrame::cget

#     - PanelFrame::getframe

#     - PanelFrame::add

#     - PanelFrame::remove

#     - PanelFrame::items

# ----------------------------------------------------------------------------



namespace eval PanelFrame {

    Widget::define PanelFrame panelframe



    Widget::declare PanelFrame {

	{-background	   Color "SystemWindowFrame" 0}

	{-borderwidth	   TkResource 1	 0 frame}

	{-relief	   TkResource flat 0 frame}

	{-panelbackground  Color "SystemHighlight" 0}

	{-panelforeground  Color "SystemHighlightText" 0}

	{-width		   Int	      0	 0}

	{-height	   Int	      0	 0}

	{-font		   String     "TkTextFont" 0}

	{-text		   String     "" 0}

	{-textvariable	   String     "" 0}

	{-ipad		   String      1 0}

	{-bg		   Synonym    -background}

	{-bd		   Synonym    -borderwidth}

    }

    # Should we have automatic state handling?

    #{-state            TkResource "" 0 label}



    Widget::addmap PanelFrame "" :cmd {

	-panelbackground -background

	-width {} -height {} -borderwidth {} -relief {}

    }

    Widget::addmap PanelFrame "" .title	  {

	-panelbackground -background

    }

    Widget::addmap PanelFrame "" .title.text   {

	-panelbackground -background

	-panelforeground -foreground

	-text {} -textvariable {} -font {}

    }

    Widget::addmap PanelFrame "" .frame {

	-background {}
    }




    if {0} {

	# This would be code to have an automated close button

	#{-closebutton	   Boolean    0	 0}

	Widget::addmap PanelFrame "" .title.close   {

	    -panelbackground -background

	    -panelforeground -foreground

	}

	variable HaveMarlett \

	    [expr {[lsearch -exact [font families] "Marlett"] != -1}]



	variable imgdata {

	    #define close_width 16

	    #define close_height 16

	    static char close_bits[] = {

		0x00, 0x00, 0x00, 0x00,

		0x00, 0x00, 0x10, 0x08,

		0x38, 0x1c, 0x70, 0x0e,

		0xe0, 0x07, 0xc0, 0x03,

		0xc0, 0x03, 0xe0, 0x07,

		0x70, 0x0e, 0x38, 0x1c,

		0x10, 0x08, 0x00, 0x00,

		0x00, 0x00, 0x00, 0x00};

	}

	# We use the same -foreground as the default -panelbackground

	image create bitmap ::PanelFrame::X -data $imgdata \

	    -foreground [lindex $Widget::PanelFrame::opt(-panelbackground) 1]
    }




    bind PanelFrame <Destroy> [list Widget::destroy %W]

}





# ----------------------------------------------------------------------------

#  Command PanelFrame::create

# ----------------------------------------------------------------------------

proc PanelFrame::create { path args } {

    variable HaveMarlett



    Widget::init PanelFrame $path $args



    set lblopts [list -bd 0 -highlightthickness 0]

    set outer [eval [list frame $path -class PanelFrame] \

		   [Widget::subcget $path :cmd]]

    set title [eval [list frame $path.title] \

		   [Widget::subcget $path .title]]

    set tlbl  [eval [list label $path.title.text] $lblopts -anchor w \

		   [Widget::subcget $path .title.text]]

    set inner [eval [list frame $path.frame] \

		   [Widget::subcget $path .frame]]



    foreach {ipadx ipady} [_padval [Widget::cget $path -ipad]] { break }



    if {0} {

	set btnopts [list -padx 0 -pady 0 -relief flat -overrelief raised \

			 -bd 1 -highlightthickness 0]

	set clbl  [eval [list button $path.title.close] $btnopts \

		       [Widget::subcget $path .title.close]]

	set close [Widget::cget $path -closebutton]

	if {$HaveMarlett} {

	    $clbl configure -font "Marlett -14" -text \u0072

	} else {

	    $clbl configure -image ::PanelFrame::X
	}


	if {$close} {

	    pack $path.title.close -side right -padx $ipadx -pady $ipady
	}
    }





    grid $path.title -row 0 -column 0 -sticky ew

    grid $path.frame -row 1 -column 0 -sticky news

    grid columnconfigure $path 0 -weight 1

    grid rowconfigure $path 1 -weight 1



    pack $path.title.text -side left -fill x -anchor w \

	-padx $ipadx -pady $ipady



    return [Widget::create PanelFrame $path]
}






# ----------------------------------------------------------------------------

#  Command PanelFrame::configure

# ----------------------------------------------------------------------------

proc PanelFrame::configure { path args } {

    set res [Widget::configure $path $args]



    if {[Widget::hasChanged $path -ipad ipad]} {
    }




    return $res
}






# ----------------------------------------------------------------------------

#  Command PanelFrame::cget

# ----------------------------------------------------------------------------

proc PanelFrame::cget { path option } {

    return [Widget::cget $path $option]
}




# ----------------------------------------------------------------------------

#  Command PanelFrame::getframe

# ----------------------------------------------------------------------------

proc PanelFrame::getframe { path } {

    return $path.frame
}




# ------------------------------------------------------------------------

#  Command PanelFrame::add

# ------------------------------------------------------------------------

proc PanelFrame::add {path w args} {

    variable _widget



    array set opts [list \

			-side   right \

			-fill   none \

			-expand 0 \

			-pad    [Widget::cget $path -ipad] \
		       ]


    foreach {key val} $args {

	if {[info exists opts($key)]} {

	    set opts($key) $val

	} else {

	    set msg "unknown option \"$key\", must be one of: "

	    append msg [join [lsort [array names opts]] {, }]

	    return -code error $msg
	}
    }



    foreach {ipadx ipady} [_padval $opts(-pad)] { break }



    set f $path.title



    lappend _widget($path,items) $w

    pack $w -in $f -padx $ipadx -pady $ipady -side $opts(-side) \

	-fill $opts(-fill) -expand $opts(-expand)



    return $w
}




# ------------------------------------------------------------------------

#  Command PanelFrame::remove

# ------------------------------------------------------------------------

proc PanelFrame::remove {path args} {

    variable _widget



    set destroy [string equal [lindex $args 0] "-destroy"]

    if {$destroy} {

	set args [lrange $args 1 end]
    }


    foreach w $args {

	set idx [lsearch -exact $_widget($path,items) $w]

	if {$idx == -1} {

	    # ignore unknown

	    continue
	}


	if {$destroy} {

	    destroy $w

	} elseif {[winfo exists $w]} {

	    pack forget $w
	}


	set _widget($path,items) [lreplace $_widget($path,items) $idx $idx]
    }
}





# ------------------------------------------------------------------------

#  Command PanelFrame::delete

# ------------------------------------------------------------------------

proc PanelFrame::delete {path args} {

    return [PanelFrame::remove $path -destroy $args]
}




# ------------------------------------------------------------------------

#  Command PanelFrame::items

# ------------------------------------------------------------------------

proc PanelFrame::items {path} {

    variable _widget

    return $_widget($path,items)
}




proc PanelFrame::_padval {padval} {

    set len [llength $padval]

    foreach {a b} $padval { break }

    if {$len == 0 || $len > 2} {

	return -code error \

	    "invalid pad value \"$padval\", must be 1 or 2 pixel values"

    } elseif {$len == 1} {

	return [list $a $a]

    } elseif {$len == 2} {

	return $padval
    }
}



Changes to progressbar.tcl.

1
2
3

4
5
6
7
8
9
10

11

12
13
14
15
16
17
18
19
20
21

22
23
24
25
26
27
28
29
30
..
32
33
34
35
36
37
38




39
40
41
42
43
44
45
46
47
48
49
50
51

52
53
54
55
56
57
58
..
69
70
71
72
73
74
75



76
77
78
79
80
81
82
...
114
115
116
117
118
119
120





121
122
123
124
125
126
127
...
202
203
204
205
206
207
208















# ----------------------------------------------------------------------------
#  progressbar.tcl
#  This file is part of Unifix BWidget Toolkit

# ----------------------------------------------------------------------------
#  Index of commands:
#     - ProgressBar::create
#     - ProgressBar::configure
#     - ProgressBar::cget
#     - ProgressBar::_destroy
#     - ProgressBar::_modify

# ----------------------------------------------------------------------------


namespace eval ProgressBar {
    Widget::define ProgressBar progressbar

    Widget::declare ProgressBar {
        {-type        Enum       normal     0
                      {normal incremental infinite nonincremental_infinite}}
        {-maximum     Int        100        0 "%d > 0"}
        {-background  TkResource ""         0 frame}
        {-foreground  TkResource "blue"     0 label}

        {-borderwidth TkResource 2          0 frame}
        {-troughcolor TkResource ""         0 scrollbar}
        {-relief      TkResource sunken     0 label}
        {-orient      Enum       horizontal 1 {horizontal vertical}}
        {-variable    String     ""         0}
        {-idle        Boolean    0          0}
        {-width       TkResource 100        0 frame}
        {-height      TkResource 4m         0 frame}
        {-bg          Synonym    -background}
................................................................................
        {-bd          Synonym    -borderwidth}
    }

    Widget::addmap ProgressBar "" :cmd {-background {} -width {} -height {}}
    Widget::addmap ProgressBar "" .bar {
	-troughcolor -background -borderwidth {} -relief {}
    }





    variable _widget
}


# ----------------------------------------------------------------------------
#  Command ProgressBar::create
# ----------------------------------------------------------------------------
proc ProgressBar::create { path args } {
    variable _widget

    array set maps [list ProgressBar {} :cmd {} .bar {}]
    array set maps [Widget::parseArgs ProgressBar $args]

    eval frame $path $maps(:cmd) -class ProgressBar -bd 0 \
	    -highlightthickness 0 -relief flat
    Widget::initFromODB ProgressBar $path $maps(ProgressBar)

    set c  [eval [list canvas $path.bar] $maps(.bar) -highlightthickness 0]
    set fg [Widget::cget $path -foreground]
    if { [string equal [Widget::cget $path -orient] "horizontal"] } {
................................................................................
		[list ProgressBar::_modify $path]
        set _widget($path,afterid) \
	    [after idle [list ProgressBar::_modify $path]]
    }

    bind $path.bar <Destroy>   [list ProgressBar::_destroy $path]
    bind $path.bar <Configure> [list ProgressBar::_modify $path]




    return [Widget::create ProgressBar $path]
}


# ----------------------------------------------------------------------------
#  Command ProgressBar::configure
................................................................................
		[after idle [list ProgressBar::_modify $path]]
	}
    }
    if { [Widget::hasChangedX $path -foreground] } {
	set fg [Widget::cget $path -foreground]
        $path.bar itemconfigure rect -fill $fg -outline $fg
    }





    return $res
}


# ----------------------------------------------------------------------------
#  Command ProgressBar::cget
# ----------------------------------------------------------------------------
................................................................................
		[list ProgressBar::_modify $path]
	}
	unset _widget($path,var)
    }
    unset _widget($path,dir)
    Widget::destroy $path
}

















>







>

>








|
|
>

<







 







>
>
>
>













>







 







>
>
>







 







>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26

27
28
29
30
31
32
33
..
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
..
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
...
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
...
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
# ----------------------------------------------------------------------------
#  progressbar.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: progressbar.tcl,v 1.14 2009/09/06 21:37:18 oberdorfer Exp $
# ----------------------------------------------------------------------------
#  Index of commands:
#     - ProgressBar::create
#     - ProgressBar::configure
#     - ProgressBar::cget
#     - ProgressBar::_destroy
#     - ProgressBar::_modify
#     - ProgressBar::_themechanged
# ----------------------------------------------------------------------------
# to-do: johann: -troughcolor has no effect ?!

namespace eval ProgressBar {
    Widget::define ProgressBar progressbar

    Widget::declare ProgressBar {
        {-type        Enum       normal     0
                      {normal incremental infinite nonincremental_infinite}}
        {-maximum     Int        100        0 "%d > 0"}
        {-background  Color      "SystemWindowFrame" 0}
        {-foreground  Color      "SystemHighlight"   0}
        {-troughcolor Color      "SystemScrollbar"  0}
        {-borderwidth TkResource 2          0 frame}

        {-relief      TkResource sunken     0 label}
        {-orient      Enum       horizontal 1 {horizontal vertical}}
        {-variable    String     ""         0}
        {-idle        Boolean    0          0}
        {-width       TkResource 100        0 frame}
        {-height      TkResource 4m         0 frame}
        {-bg          Synonym    -background}
................................................................................
        {-bd          Synonym    -borderwidth}
    }

    Widget::addmap ProgressBar "" :cmd {-background {} -width {} -height {}}
    Widget::addmap ProgressBar "" .bar {
	-troughcolor -background -borderwidth {} -relief {}
    }

    if {[lsearch [bindtags .] ProgressBarThemeChanged] < 0} {
        bindtags . [linsert [bindtags .] 1 ProgressBarThemeChanged]
    }

    variable _widget
}


# ----------------------------------------------------------------------------
#  Command ProgressBar::create
# ----------------------------------------------------------------------------
proc ProgressBar::create { path args } {
    variable _widget

    array set maps [list ProgressBar {} :cmd {} .bar {}]
    array set maps [Widget::parseArgs ProgressBar $args]

    eval frame $path $maps(:cmd) -class ProgressBar -bd 0 \
	    -highlightthickness 0 -relief flat
    Widget::initFromODB ProgressBar $path $maps(ProgressBar)

    set c  [eval [list canvas $path.bar] $maps(.bar) -highlightthickness 0]
    set fg [Widget::cget $path -foreground]
    if { [string equal [Widget::cget $path -orient] "horizontal"] } {
................................................................................
		[list ProgressBar::_modify $path]
        set _widget($path,afterid) \
	    [after idle [list ProgressBar::_modify $path]]
    }

    bind $path.bar <Destroy>   [list ProgressBar::_destroy $path]
    bind $path.bar <Configure> [list ProgressBar::_modify $path]

    bind ProgressBarThemeChanged <<ThemeChanged>> \
	     "+ [namespace current]::_themechanged $path"

    return [Widget::create ProgressBar $path]
}


# ----------------------------------------------------------------------------
#  Command ProgressBar::configure
................................................................................
		[after idle [list ProgressBar::_modify $path]]
	}
    }
    if { [Widget::hasChangedX $path -foreground] } {
	set fg [Widget::cget $path -foreground]
        $path.bar itemconfigure rect -fill $fg -outline $fg
    }
    if { [Widget::hasChangedX $path -background] } {
	set bg [Widget::cget $path -background]
        $path.bar configure -background $bg
    }

    return $res
}


# ----------------------------------------------------------------------------
#  Command ProgressBar::cget
# ----------------------------------------------------------------------------
................................................................................
		[list ProgressBar::_modify $path]
	}
	unset _widget($path,var)
    }
    unset _widget($path,dir)
    Widget::destroy $path
}


# ----------------------------------------------------------------------------
#  Command ProgressBar::_themechanged
# ----------------------------------------------------------------------------
proc ProgressBar::_themechanged { path } {

    if { ![winfo exists $path] } { return }
    BWidget::set_themedefaults
    
    $path configure \
           -background $BWidget::colors(SystemWindowFrame) \
           -foreground $BWidget::colors(SystemHighlight)
}

Changes to scrollframe.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14

15
16
17
18
19
20
21
22

23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63




64
65
66
67
68
69
70
71
72


73
74

75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
..
97
98
99
100
101
102
103



104
105
106
107
108
109
110
111
112
113
114





115
116
117
118
119
120
121
...
256
257
258
259
260
261
262










# ----------------------------------------------------------------------------
#  scrollframe.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: scrollframe.tcl,v 1.11 2009/07/17 15:29:51 oehhar Exp $
# ----------------------------------------------------------------------------
#  Index of commands:
#     - ScrollableFrame::create
#     - ScrollableFrame::configure
#     - ScrollableFrame::cget
#     - ScrollableFrame::getframe
#     - ScrollableFrame::see
#     - ScrollableFrame::xview
#     - ScrollableFrame::yview
#     - ScrollableFrame::_resize

# ----------------------------------------------------------------------------

namespace eval ScrollableFrame {
    Widget::define ScrollableFrame scrollframe

    # If themed, there is no background and -bg option
    if {[Widget::theme]} {
        Widget::declare ScrollableFrame {

            {-width             Int        0  0 {}}
            {-height            Int        0  0 {}}
            {-areawidth         Int        0  0 {}}
            {-areaheight        Int        0  0 {}}
            {-constrainedwidth  Boolean    0 0}
            {-constrainedheight Boolean    0 0}
            {-xscrollcommand    TkResource "" 0 canvas}
            {-yscrollcommand    TkResource "" 0 canvas}
            {-xscrollincrement  TkResource "" 0 canvas}
            {-yscrollincrement  TkResource "" 0 canvas}
        }
    } else {
        Widget::declare ScrollableFrame {
            {-background        TkResource "" 0 frame}
            {-width             Int        0  0 {}}
            {-height            Int        0  0 {}}
            {-areawidth         Int        0  0 {}}
            {-areaheight        Int        0  0 {}}
            {-constrainedwidth  Boolean    0 0}
            {-constrainedheight Boolean    0 0}
            {-xscrollcommand    TkResource "" 0 canvas}
            {-yscrollcommand    TkResource "" 0 canvas}
            {-xscrollincrement  TkResource "" 0 canvas}
            {-yscrollincrement  TkResource "" 0 canvas}
            {-bg                Synonym    -background}
        }
    }

    Widget::addmap ScrollableFrame "" :cmd {
        -width {} -height {} 
        -xscrollcommand {} -yscrollcommand {}
        -xscrollincrement {} -yscrollincrement {}
    }
    if { ! [Widget::theme]} {
        Widget::addmap ScrollableFrame "" .frame {-background {}}
    }

    variable _widget

    bind BwScrollableFrame <Configure> [list ScrollableFrame::_resize %W]
    bind BwScrollableFrame <Destroy>   [list Widget::destroy %W]




}


# ----------------------------------------------------------------------------
#  Command ScrollableFrame::create
# ----------------------------------------------------------------------------
proc ScrollableFrame::create { path args } {
    Widget::init ScrollableFrame $path $args



    set canvas [eval [list canvas $path] [Widget::subcget $path :cmd] \
                    -highlightthickness 0 -borderwidth 0 -relief flat]


    if {[Widget::theme]} {
	set frame [eval [list ttk::frame $path.frame] \
		       [Widget::subcget $path .frame]]
	set bg [ttk::style lookup TFrame -background]
    } else {
	set frame [eval [list frame $path.frame] \
		       [Widget::subcget $path .frame] \
		       -highlightthickness 0 -borderwidth 0 -relief flat]
	set bg [$frame cget -background]
    }
    # Give canvas frame (or theme) background
    $canvas configure -background $bg

    $canvas create window 0 0 -anchor nw -window $frame -tags win \
        -width  [Widget::cget $path -areawidth] \
        -height [Widget::cget $path -areaheight]

    bind $frame <Configure> \
        [list ScrollableFrame::_frameConfigure $canvas]
................................................................................
    # but now we need to add a <map> binding too
    bind $frame <Map> \
        [list ScrollableFrame::_frameConfigure $canvas]
    bind $frame <Unmap> \
        [list ScrollableFrame::_frameConfigure $canvas 1]

    bindtags $path [list $path BwScrollableFrame [winfo toplevel $path] all]




    return [Widget::create ScrollableFrame $path]
}


# ----------------------------------------------------------------------------
#  Command ScrollableFrame::configure
# ----------------------------------------------------------------------------
proc ScrollableFrame::configure { path args } {
    set res [Widget::configure $path $args]
    set upd 0






    set modcw [Widget::hasChanged $path -constrainedwidth cw]
    set modw  [Widget::hasChanged $path -areawidth w]
    if { $modcw || (!$cw && $modw) } {
        if { $cw } {
            set w [winfo width $path]
        }
................................................................................
    set framew [expr {$unmap ? 0 : [winfo width  $canvas.frame]}]

    set height [_max $frameh [winfo height $canvas]]
    set width  [_max $framew [winfo width  $canvas]]

    $canvas:cmd configure -scrollregion [list 0 0 $width $height]
}












|










>





<
<
|
>
|
|
|
|
|
|
|
|
|
|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
|
<







<
<
<





>
>
>
>









>
>

|
>

<
<
<
<
<
|
<
|
<
<
<
|







 







>
>
>











>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20


21
22
23
24
25
26
27
28
29
30
31
32














33

34
35
36
37
38
39
40



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64





65

66



67
68
69
70
71
72
73
74
..
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
...
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# ----------------------------------------------------------------------------
#  scrollframe.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: scrollframe.tcl,v 1.12 2009/09/06 21:38:51 oberdorfer Exp $
# ----------------------------------------------------------------------------
#  Index of commands:
#     - ScrollableFrame::create
#     - ScrollableFrame::configure
#     - ScrollableFrame::cget
#     - ScrollableFrame::getframe
#     - ScrollableFrame::see
#     - ScrollableFrame::xview
#     - ScrollableFrame::yview
#     - ScrollableFrame::_resize
#     - ScrollableFrame::_themechanged
# ----------------------------------------------------------------------------

namespace eval ScrollableFrame {
    Widget::define ScrollableFrame scrollframe



    Widget::declare ScrollableFrame {
        {-background	    Color      "SystemWindow"  0}
        {-width             Int        0  0 {}}
        {-height            Int        0  0 {}}
        {-areawidth         Int        0  0 {}}
        {-areaheight        Int        0  0 {}}
        {-constrainedwidth  Boolean    0 0}
        {-constrainedheight Boolean    0 0}
        {-xscrollcommand    TkResource "" 0 canvas}
        {-yscrollcommand    TkResource "" 0 canvas}
        {-xscrollincrement  TkResource "" 0 canvas}
        {-yscrollincrement  TkResource "" 0 canvas}














        {-bg                Synonym    -background}

    }

    Widget::addmap ScrollableFrame "" :cmd {
        -width {} -height {} 
        -xscrollcommand {} -yscrollcommand {}
        -xscrollincrement {} -yscrollincrement {}
    }




    variable _widget

    bind BwScrollableFrame <Configure> [list ScrollableFrame::_resize %W]
    bind BwScrollableFrame <Destroy>   [list Widget::destroy %W]

    if {[lsearch [bindtags .] ScrollableFrameThemeChanged] < 0} {
        bindtags . [linsert [bindtags .] 1 ScrollableFrameThemeChanged]
    }
}


# ----------------------------------------------------------------------------
#  Command ScrollableFrame::create
# ----------------------------------------------------------------------------
proc ScrollableFrame::create { path args } {
    Widget::init ScrollableFrame $path $args

    set bg [Widget::cget $path -background]

    set canvas [eval [list canvas $path] [Widget::subcget $path :cmd] \
                    -highlightthickness 0 -borderwidth 0 -relief flat \
		    -bg $bg]






    set frame [eval [list frame $path.frame] \

		       -highlightthickness 0 -borderwidth 0 -relief flat \



		       -background $bg]

    $canvas create window 0 0 -anchor nw -window $frame -tags win \
        -width  [Widget::cget $path -areawidth] \
        -height [Widget::cget $path -areaheight]

    bind $frame <Configure> \
        [list ScrollableFrame::_frameConfigure $canvas]
................................................................................
    # but now we need to add a <map> binding too
    bind $frame <Map> \
        [list ScrollableFrame::_frameConfigure $canvas]
    bind $frame <Unmap> \
        [list ScrollableFrame::_frameConfigure $canvas 1]

    bindtags $path [list $path BwScrollableFrame [winfo toplevel $path] all]

    bind ScrollableFrameThemeChanged <<ThemeChanged>> \
	   "+ [namespace current]::_themechanged $path"

    return [Widget::create ScrollableFrame $path]
}


# ----------------------------------------------------------------------------
#  Command ScrollableFrame::configure
# ----------------------------------------------------------------------------
proc ScrollableFrame::configure { path args } {
    set res [Widget::configure $path $args]
    set upd 0

    if { [Widget::hasChanged $path -background bg] } {
        $path:cmd configure -background $bg
	$path.frame configure -background $bg
    }

    set modcw [Widget::hasChanged $path -constrainedwidth cw]
    set modw  [Widget::hasChanged $path -areawidth w]
    if { $modcw || (!$cw && $modw) } {
        if { $cw } {
            set w [winfo width $path]
        }
................................................................................
    set framew [expr {$unmap ? 0 : [winfo width  $canvas.frame]}]

    set height [_max $frameh [winfo height $canvas]]
    set width  [_max $framew [winfo width  $canvas]]

    $canvas:cmd configure -scrollregion [list 0 0 $width $height]
}

# ----------------------------------------------------------------------------
#  Command ScrollableFrame::_themechanged
# ----------------------------------------------------------------------------
proc ScrollableFrame::_themechanged { path } {

    if { ![winfo exists $path] } { return }
    BWidget::set_themedefaults
    $path configure -background $BWidget::colors(SystemWindow)
}

Changes to scrollview.tcl.

1
2
3
4
5
6
7
8
9
10
11
..
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
..
45
46
47
48
49
50
51

52
53
54
55
56
57
58
59
# ------------------------------------------------------------------------------
#  scrollview.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: scrollview.tcl,v 1.7 2003/11/05 18:04:29 hobbs Exp $
# ------------------------------------------------------------------------------
#  Index of commands:
#     - ScrolledWindow::create
#     - ScrolledWindow::configure
#     - ScrolledWindow::cget
#     - ScrolledWindow::_set_hscroll
#     - ScrolledWindow::_set_vscroll
................................................................................
	    include {-relief -borderwidth -background -width -height -cursor} \
	    initialize {-relief flat -borderwidth 0 -width 30 -height 30 \
		-cursor crosshair}

    Widget::declare ScrollView {
        {-width       TkResource 30        0 canvas}
        {-height      TkResource 30        0 canvas}
        {-background  TkResource ""        0 canvas}
        {-foreground  String     black     0}
        {-fill        String     ""        0}
        {-relief      TkResource flat      0 canvas}
        {-borderwidth TkResource 0         0 canvas}
        {-cursor      TkResource crosshair 0 canvas}
        {-window      String     ""        0}
        {-fg          Synonym    -foreground}
        {-bg          Synonym    -background}
................................................................................


# ------------------------------------------------------------------------------
#  Command ScrollView::create
# ------------------------------------------------------------------------------
proc ScrollView::create { path args } {
    Widget::init ScrollView $path $args

    eval [list canvas $path] [Widget::subcget $path :cmd] -highlightthickness 0

    Widget::create ScrollView $path

    Widget::getVariable $path _widget

    set w               [Widget::cget $path -window]
    set _widget(bd)     [Widget::cget $path -borderwidth]


|







 







|
|







 







>
|







1
2
3
4
5
6
7
8
9
10
11
..
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
..
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# ------------------------------------------------------------------------------
#  scrollview.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: scrollview.tcl,v 1.71 2009/09/06 21:39:24 oberdorfer Exp $
# ------------------------------------------------------------------------------
#  Index of commands:
#     - ScrolledWindow::create
#     - ScrolledWindow::configure
#     - ScrolledWindow::cget
#     - ScrolledWindow::_set_hscroll
#     - ScrolledWindow::_set_vscroll
................................................................................
	    include {-relief -borderwidth -background -width -height -cursor} \
	    initialize {-relief flat -borderwidth 0 -width 30 -height 30 \
		-cursor crosshair}

    Widget::declare ScrollView {
        {-width       TkResource 30        0 canvas}
        {-height      TkResource 30        0 canvas}
        {-foreground		Color      "SystemWindow"      0}
        {-background		Color      "SystemWindowFrame" 0}
        {-fill        String     ""        0}
        {-relief      TkResource flat      0 canvas}
        {-borderwidth TkResource 0         0 canvas}
        {-cursor      TkResource crosshair 0 canvas}
        {-window      String     ""        0}
        {-fg          Synonym    -foreground}
        {-bg          Synonym    -background}
................................................................................


# ------------------------------------------------------------------------------
#  Command ScrollView::create
# ------------------------------------------------------------------------------
proc ScrollView::create { path args } {
    Widget::init ScrollView $path $args
    eval [list canvas $path] \
         [Widget::subcget $path :cmd] -highlightthickness 0

    Widget::create ScrollView $path

    Widget::getVariable $path _widget

    set w               [Widget::cget $path -window]
    set _widget(bd)     [Widget::cget $path -borderwidth]

Changes to scrollw.tcl.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36




37
38
39
40
41
42
43
..
46
47
48
49
50
51
52
53
54








55
56
57
58
59
60
61
62
63
64

65
66
67
68
69
70
71
..
73
74
75
76
77
78
79


80
81
82
83
84

85
86
87
88
89
90
91
..
95
96
97
98
99
100
101



102
103
104
105
106
107
108
...
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
...
276
277
278
279
280
281
282










# -----------------------------------------------------------------------------
#  scrollw.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: scrollw.tcl,v 1.13 2009/06/29 13:28:24 oehhar Exp $
# -----------------------------------------------------------------------------
#  Index of commands:
#     - ScrolledWindow::create
#     - ScrolledWindow::getframe
#     - ScrolledWindow::setwidget
#     - ScrolledWindow::configure
#     - ScrolledWindow::cget
#     - ScrolledWindow::_set_hframe
#     - ScrolledWindow::_set_vscroll
#     - ScrolledWindow::_setData
#     - ScrolledWindow::_setSBSize
#     - ScrolledWindow::_realize
# -----------------------------------------------------------------------------

namespace eval ScrolledWindow {
    Widget::define ScrolledWindow scrollw

    Widget::declare ScrolledWindow {
	{-background  TkResource ""   0 button}
	{-scrollbar   Enum	 both 0 {none both vertical horizontal}}
	{-auto	      Enum	 both 0 {none both vertical horizontal}}
	{-sides	      Enum	 se   0 {ne en nw wn se es sw ws}}
	{-size	      Int	 0    1 "%d >= 0"}
	{-ipad	      Int	 1    1 "%d >= 0"}
	{-managed     Boolean	 1    1}
	{-relief      TkResource flat 0 frame}
	{-borderwidth TkResource 0    0 frame}
	{-bg	      Synonym	 -background}
	{-bd	      Synonym	 -borderwidth}
    }

    Widget::addmap ScrolledWindow "" :cmd {-relief {} -borderwidth {}}




}


# -----------------------------------------------------------------------------
#  Command ScrolledWindow::create
# -----------------------------------------------------------------------------
proc ScrolledWindow::create { path args } {
................................................................................
    Widget::getVariable $path data

    set bg     [Widget::cget $path -background]
    set sbsize [Widget::cget $path -size]
    set sw     [eval [list frame $path \
			  -relief flat -borderwidth 0 -background $bg \
			  -highlightthickness 0 -takefocus 0] \
		    [Widget::subcget $path :cmd]]









    scrollbar $path.hscroll \
	    -highlightthickness 0 -takefocus 0 \
	    -orient	 horiz	\
	    -relief	 sunken	\
	    -bg	 $bg
    scrollbar $path.vscroll \
	    -highlightthickness 0 -takefocus 0 \
	    -orient	 vert	\
	    -relief	 sunken	\
	    -bg	 $bg


    set data(realized) 0

    _setData $path \
	    [Widget::cget $path -scrollbar] \
	    [Widget::cget $path -auto] \
	    [Widget::cget $path -sides]
................................................................................
    if {[Widget::cget $path -managed]} {
	set data(hsb,packed) $data(hsb,present)
	set data(vsb,packed) $data(vsb,present)
    } else {
	set data(hsb,packed) 0
	set data(vsb,packed) 0
    }


    if {$sbsize} {
	$path.vscroll configure -width $sbsize
	$path.hscroll configure -width $sbsize
    } else {
	set sbsize [$path.vscroll cget -width]

    }
    set data(ipad) [Widget::cget $path -ipad]

    if {$data(hsb,packed)} {
	grid $path.hscroll -column 1 -row $data(hsb,row) \
		-sticky ew -ipady $data(ipad)
    }
................................................................................
    }

    grid columnconfigure $path 1 -weight 1
    grid rowconfigure	 $path 1 -weight 1

    bind $path <Configure> [list ScrolledWindow::_realize $path]
    bind $path <Destroy>   [list ScrolledWindow::_destroy $path]




    return [Widget::create ScrolledWindow $path]
}


# -----------------------------------------------------------------------------
#  Command ScrolledWindow::getframe
................................................................................
#  Command ScrolledWindow::configure
# -----------------------------------------------------------------------------
proc ScrolledWindow::configure { path args } {
    Widget::getVariable $path data

    set res [Widget::configure $path $args]
    if { [Widget::hasChanged $path -background bg] } {
	$path configure -background $bg
	catch {$path.hscroll configure -background $bg}
	catch {$path.vscroll configure -background $bg}
    }

    if {[Widget::hasChanged $path -scrollbar scrollbar] | \
	    [Widget::hasChanged $path -auto	 auto]	| \
	    [Widget::hasChanged $path -sides	 sides]} {
	_setData $path $scrollbar $auto $sides
	foreach {vmin vmax} [$path.hscroll get] { break }
................................................................................

# -----------------------------------------------------------------------------
#  Command ScrolledWindow::_destroy
# -----------------------------------------------------------------------------
proc ScrolledWindow::_destroy { path } {
    Widget::destroy $path
}












|







|


|
|






|













>
>
>
>







 







|

>
>
>
>
>
>
>
>
|




|




>







 







>
>
|
|
|
<
<
>







 







>
>
>







 







|
|
|







 







>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
..
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
..
86
87
88
89
90
91
92
93
94
95
96
97


98
99
100
101
102
103
104
105
...
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
...
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
...
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
# -----------------------------------------------------------------------------
#  scrollw.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: scrollw.tcl,v 1.14 2009/09/06 21:40:13 oberdorfer Exp $
# -----------------------------------------------------------------------------
#  Index of commands:
#     - ScrolledWindow::create
#     - ScrolledWindow::getframe
#     - ScrolledWindow::setwidget
#     - ScrolledWindow::configure
#     - ScrolledWindow::cget
#     - ScrolledWindow::_set_hscroll
#     - ScrolledWindow::_set_vscroll
#     - ScrolledWindow::_setData
#     - ScrolledWindow::_realize
#     - ScrolledWindow::_themechanged
# -----------------------------------------------------------------------------

namespace eval ScrolledWindow {
    Widget::define ScrolledWindow scrollw

    Widget::declare ScrolledWindow {
        {-background  Color      "SystemWindowFrame" 0}
	{-scrollbar   Enum	 both 0 {none both vertical horizontal}}
	{-auto	      Enum	 both 0 {none both vertical horizontal}}
	{-sides	      Enum	 se   0 {ne en nw wn se es sw ws}}
	{-size	      Int	 0    1 "%d >= 0"}
	{-ipad	      Int	 1    1 "%d >= 0"}
	{-managed     Boolean	 1    1}
	{-relief      TkResource flat 0 frame}
	{-borderwidth TkResource 0    0 frame}
	{-bg	      Synonym	 -background}
	{-bd	      Synonym	 -borderwidth}
    }

    Widget::addmap ScrolledWindow "" :cmd {-relief {} -borderwidth {}}

    if {[lsearch [bindtags .] ScrolledWindowThemeChanged] < 0} {
        bindtags . [linsert [bindtags .] 1 ScrolledWindowThemeChanged]
    }
}


# -----------------------------------------------------------------------------
#  Command ScrolledWindow::create
# -----------------------------------------------------------------------------
proc ScrolledWindow::create { path args } {
................................................................................
    Widget::getVariable $path data

    set bg     [Widget::cget $path -background]
    set sbsize [Widget::cget $path -size]
    set sw     [eval [list frame $path \
			  -relief flat -borderwidth 0 -background $bg \
			  -highlightthickness 0 -takefocus 0] \
		     [Widget::subcget $path :cmd]]

    if { [BWidget::using ttk] &&
        ![string equal [tk windowingsystem] "aqua"]} {

        ttk::scrollbar $path.vscroll -orient vertical
        ttk::scrollbar $path.hscroll -orient horizontal

    } else {

        scrollbar $path.hscroll \
	    -highlightthickness 0 -takefocus 0 \
	    -orient	 horiz	\
	    -relief	 sunken	\
	    -bg	 $bg
        scrollbar $path.vscroll \
	    -highlightthickness 0 -takefocus 0 \
	    -orient	 vert	\
	    -relief	 sunken	\
	    -bg	 $bg
    }

    set data(realized) 0

    _setData $path \
	    [Widget::cget $path -scrollbar] \
	    [Widget::cget $path -auto] \
	    [Widget::cget $path -sides]
................................................................................
    if {[Widget::cget $path -managed]} {
	set data(hsb,packed) $data(hsb,present)
	set data(vsb,packed) $data(vsb,present)
    } else {
	set data(hsb,packed) 0
	set data(vsb,packed) 0
    }
    
    if { ![BWidget::using ttk] } {
        if {$sbsize} {
	    $path.vscroll configure -width $sbsize
	    $path.hscroll configure -width $sbsize


        }
    }
    set data(ipad) [Widget::cget $path -ipad]

    if {$data(hsb,packed)} {
	grid $path.hscroll -column 1 -row $data(hsb,row) \
		-sticky ew -ipady $data(ipad)
    }
................................................................................
    }

    grid columnconfigure $path 1 -weight 1
    grid rowconfigure	 $path 1 -weight 1

    bind $path <Configure> [list ScrolledWindow::_realize $path]
    bind $path <Destroy>   [list ScrolledWindow::_destroy $path]

    bind ScrolledWindowThemeChanged <<ThemeChanged>> \
	   "+ [namespace current]::_themechanged $path"

    return [Widget::create ScrolledWindow $path]
}


# -----------------------------------------------------------------------------
#  Command ScrolledWindow::getframe
................................................................................
#  Command ScrolledWindow::configure
# -----------------------------------------------------------------------------
proc ScrolledWindow::configure { path args } {
    Widget::getVariable $path data

    set res [Widget::configure $path $args]
    if { [Widget::hasChanged $path -background bg] } {
	$path:cmd configure -background $bg
	catch { $path.hscroll configure -background $bg }
	catch { $path.vscroll configure -background $bg }
    }

    if {[Widget::hasChanged $path -scrollbar scrollbar] | \
	    [Widget::hasChanged $path -auto	 auto]	| \
	    [Widget::hasChanged $path -sides	 sides]} {
	_setData $path $scrollbar $auto $sides
	foreach {vmin vmax} [$path.hscroll get] { break }
................................................................................

# -----------------------------------------------------------------------------
#  Command ScrolledWindow::_destroy
# -----------------------------------------------------------------------------
proc ScrolledWindow::_destroy { path } {
    Widget::destroy $path
}

# ----------------------------------------------------------------------------
#  Command ScrolledWindow::_themechanged
# ----------------------------------------------------------------------------
proc ScrolledWindow::_themechanged { path } {

    if { ![winfo exists $path] } { return }
    BWidget::set_themedefaults
    $path configure -background $BWidget::colors(SystemWindowFrame)
}

Changes to separator.tcl.

1
2
3

4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# ------------------------------------------------------------------------------
#  separator.tcl
#  This file is part of Unifix BWidget Toolkit

# ------------------------------------------------------------------------------
#  Index of commands:
#     - Separator::create
#     - Separator::configure
#     - Separator::cget
# ------------------------------------------------------------------------------

namespace eval Separator {
    Widget::define Separator separator

    Widget::declare Separator {
        {-background TkResource ""         0 frame}
        {-cursor     TkResource ""         0 frame}
        {-relief     Enum       groove     0 {ridge groove}}
        {-orient     Enum       horizontal 1 {horizontal vertical}}
        {-bg         Synonym    -background}
    }
    Widget::addmap Separator "" :cmd { -background {} -cursor {} }



>











|







1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# ------------------------------------------------------------------------------
#  separator.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: separator.tcl,v 1.41 2009/09/06 21:40:52 oberdorfer Exp $
# ------------------------------------------------------------------------------
#  Index of commands:
#     - Separator::create
#     - Separator::configure
#     - Separator::cget
# ------------------------------------------------------------------------------

namespace eval Separator {
    Widget::define Separator separator

    Widget::declare Separator {
        {-background Color      "SystemWindowFrame"       0}
        {-cursor     TkResource ""         0 frame}
        {-relief     Enum       groove     0 {ridge groove}}
        {-orient     Enum       horizontal 1 {horizontal vertical}}
        {-bg         Synonym    -background}
    }
    Widget::addmap Separator "" :cmd { -background {} -cursor {} }

Changes to spinbox.tcl.

2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
..
64
65
66
67
68
69
70



71


72
73
74
75
76
77
78
#
#	BWidget SpinBox implementation.
#
# Copyright (c) 1999 by Unifix
# Copyright (c) 2000 by Ajuba Solutions
# All rights reserved.
# 
# RCS: @(#) $Id: spinbox.tcl,v 1.12 2003/10/20 21:23:52 damonc Exp $
# -----------------------------------------------------------------------------
#  Index of commands:
#     - SpinBox::create
#     - SpinBox::configure
#     - SpinBox::cget
#     - SpinBox::setvalue
#     - SpinBox::_destroy
................................................................................

    Widget::declare SpinBox {
        {-range          String ""  0}
        {-values         String ""  0}
        {-modifycmd      String ""  0}
        {-repeatdelay    Int    400 0 {%d >= 0}}
        {-repeatinterval Int    100 0 {%d >= 0}}
	{-foreground     TkResource black 0 {button}}
    }

    Widget::addmap SpinBox "" :cmd {-background {}}
    Widget::addmap SpinBox ArrowButton .arrup {
        -foreground {} -background {} -disabledforeground {} -state {} \
		-repeatinterval {} -repeatdelay {}
    }
................................................................................
    eval [list frame $path] $maps(:cmd) \
	[list -highlightthickness 0 -takefocus 0 -class SpinBox]
    Widget::initFromODB SpinBox $path $maps(SpinBox)

    set entry [eval [list Entry::create $path.e] $maps(.e) -relief flat -bd 0]
    bindtags $path.e [linsert [bindtags $path.e] 1 SpinBoxEntry]




    set farr   [frame $path.farr -relief flat -bd 0 -highlightthickness 0]


    set height [expr {[winfo reqheight $path.e]/2-2}]
    set width  11
    set arrup  [eval [list ArrowButton::create $path.arrup -dir top] \
	    $maps(.arrup) \
		    [list -highlightthickness 0 -borderwidth 1 -takefocus 0 \
			 -type button -width $width -height $height \
			 -armcommand    [list SpinBox::_modify_value $path next arm] \






|







 







|







 







>
>
>
|
>
>







2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
..
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
..
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#
#	BWidget SpinBox implementation.
#
# Copyright (c) 1999 by Unifix
# Copyright (c) 2000 by Ajuba Solutions
# All rights reserved.
# 
# RCS: @(#) $Id: spinbox.tcl,v 1.13 2009/09/06 21:41:25 oberdorfer Exp $
# -----------------------------------------------------------------------------
#  Index of commands:
#     - SpinBox::create
#     - SpinBox::configure
#     - SpinBox::cget
#     - SpinBox::setvalue
#     - SpinBox::_destroy
................................................................................

    Widget::declare SpinBox {
        {-range          String ""  0}
        {-values         String ""  0}
        {-modifycmd      String ""  0}
        {-repeatdelay    Int    400 0 {%d >= 0}}
        {-repeatinterval Int    100 0 {%d >= 0}}
        {-foreground     Color  "SystemWindow" 0}
    }

    Widget::addmap SpinBox "" :cmd {-background {}}
    Widget::addmap SpinBox ArrowButton .arrup {
        -foreground {} -background {} -disabledforeground {} -state {} \
		-repeatinterval {} -repeatdelay {}
    }
................................................................................
    eval [list frame $path] $maps(:cmd) \
	[list -highlightthickness 0 -takefocus 0 -class SpinBox]
    Widget::initFromODB SpinBox $path $maps(SpinBox)

    set entry [eval [list Entry::create $path.e] $maps(.e) -relief flat -bd 0]
    bindtags $path.e [linsert [bindtags $path.e] 1 SpinBoxEntry]

    if { [BWidget::using ttk] } {
         set farr [ttk::frame $path.farr -relief flat]
    } else {
         set farr [frame $path.farr -relief flat -bd 0 -highlightthickness 0]
    }

    set height [expr {[winfo reqheight $path.e]/2-2}]
    set width  11
    set arrup  [eval [list ArrowButton::create $path.arrup -dir top] \
	    $maps(.arrup) \
		    [list -highlightthickness 0 -borderwidth 1 -takefocus 0 \
			 -type button -width $width -height $height \
			 -armcommand    [list SpinBox::_modify_value $path next arm] \

Changes to statusbar.tcl.

1
2



3
4
5
6
7
8
9
10
11

12
13
14
15
16
17
18
..
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
...
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
...
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
...
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
...
406
407
408
409
410
411
412




413
414
415
416
417
418
419
420
421
422
# ------------------------------------------------------------------------
#  statusbar.tcl



#	Create a status bar Tk widget
#
#  Provides a status bar to be placed at the bottom of a toplevel.
#  Currently does not support being placed in a toplevel that has
#  gridding applied (via widget -setgrid or wm grid).
#
#  Ensure that the widget is placed at the very bottom of the toplevel,
#  otherwise the resize behavior may behave oddly.
# ------------------------------------------------------------------------


package require Tk 8.3

if {0} {
    proc sample {} {
    # sample usage
    eval destroy [winfo children .]
................................................................................
    }
}

namespace eval StatusBar {
    Widget::define StatusBar statusbar

    Widget::declare StatusBar {
	{-background  TkResource ""	0 frame}
	{-borderwidth TkResource 0	0 frame}
	{-relief      TkResource flat	0 frame}
	{-showseparator Boolean	 1	0}
	{-showresizesep Boolean	 0	0}
	{-showresize  Boolean	 1	0}
	{-width	      TkResource 100	0 frame}
	{-height      TkResource 18	0 frame}
................................................................................
    Widget::init StatusBar $path $args

    eval [list frame $path -class StatusBar] [Widget::subcget $path :cmd]

    foreach {padx pady} [_padval [Widget::cget $path -pad]] \
	{ipadx ipady} [_padval [Widget::cget $path -ipad]] { break }

    if {[Widget::theme]} {
	set sbar   [ttk::frame $path.sbar -padding [list $padx $pady]]
    } else {
	set sbar   [eval [list frame $path.sbar -padx $padx -pady $pady] \
			[Widget::subcget $path .sbar]]
    }
    if {[string equal $::tcl_platform(platform) "windows"]} {
	set cursor size_nw_se
................................................................................
    if {$HaveMarlett} {
	$resize configure -font "Marlett -16" -text \u006f
    } else {
	$resize configure -image ::StatusBar::resizer
    }
    bindtags $resize [list all [winfo toplevel $path] StatusResize $resize]

    if {[Widget::theme]} {
	set fsep [ttk::separator $path.hsep -orient horizontal]
    } else {
	set fsep [eval [list frame $path.hsep -bd 1 -height 2 -relief sunken] \
		      [Widget::subcget $path .hsep]]
    }
    set sep  [_sep $path sepresize {}]

................................................................................
# ------------------------------------------------------------------------
proc StatusBar::items {path} {
    variable _widget
    return $_widget($path,items)
}

proc StatusBar::_sep {path name {sub .sbar}} {
    if {[Widget::theme]} {
	return [ttk::separator $path$sub.$name -orient vertical]
    } else {
	return [frame $path$sub.$name -bd 1 -width 2 -relief sunken]
    }
}

proc StatusBar::_padval {padval} {
................................................................................
    set relx   [expr {$rootx - [winfo rootx $t]}]
    set rely   [expr {$rooty - [winfo rooty $t]}]
    set width  [expr {$relx - $resize($w,x) + $resize($w,w)}]
    set height [expr {$rely - $resize($w,y) + $resize($w,h)}]
    if {$width  < 0} { set width 0 }
    if {$height < 0} { set height 0 }
    wm geometry $t ${width}x${height}




}

# The following proc cleans up when the user releases the mouse button.

proc StatusBar::end_resize {w rootx rooty} {
    variable resize
    #continue_resize $w $rootx $rooty
    #wm grid $t $resize($w,grid)
    array unset resize $w,*
}
|
|
>
>
>









>







 







|







 







|







 







|







 







|







 







>
>
>
>










1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
..
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
...
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
...
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
...
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
...
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
# ----------------------------------------------------------------------------
#  statusbar.tcl ---
#  This file is part of Unifix BWidget Toolkit
#  $Id: statusbar.tcl,v 1.91 2009/09/06 21:42:14 oberdorfer Exp $
# ----------------------------------------------------------------------------
#	Create a status bar Tk widget
#
#  Provides a status bar to be placed at the bottom of a toplevel.
#  Currently does not support being placed in a toplevel that has
#  gridding applied (via widget -setgrid or wm grid).
#
#  Ensure that the widget is placed at the very bottom of the toplevel,
#  otherwise the resize behavior may behave oddly.
# ------------------------------------------------------------------------
# 

package require Tk 8.3

if {0} {
    proc sample {} {
    # sample usage
    eval destroy [winfo children .]
................................................................................
    }
}

namespace eval StatusBar {
    Widget::define StatusBar statusbar

    Widget::declare StatusBar {
	{-background  Color      "SystemWindow"	0}
	{-borderwidth TkResource 0	0 frame}
	{-relief      TkResource flat	0 frame}
	{-showseparator Boolean	 1	0}
	{-showresizesep Boolean	 0	0}
	{-showresize  Boolean	 1	0}
	{-width	      TkResource 100	0 frame}
	{-height      TkResource 18	0 frame}
................................................................................
    Widget::init StatusBar $path $args

    eval [list frame $path -class StatusBar] [Widget::subcget $path :cmd]

    foreach {padx pady} [_padval [Widget::cget $path -pad]] \
	{ipadx ipady} [_padval [Widget::cget $path -ipad]] { break }

    if {[BWidget::using ttk]} {
	set sbar   [ttk::frame $path.sbar -padding [list $padx $pady]]
    } else {
	set sbar   [eval [list frame $path.sbar -padx $padx -pady $pady] \
			[Widget::subcget $path .sbar]]
    }
    if {[string equal $::tcl_platform(platform) "windows"]} {
	set cursor size_nw_se
................................................................................
    if {$HaveMarlett} {
	$resize configure -font "Marlett -16" -text \u006f
    } else {
	$resize configure -image ::StatusBar::resizer
    }
    bindtags $resize [list all [winfo toplevel $path] StatusResize $resize]

    if {[BWidget::using ttk]} {
	set fsep [ttk::separator $path.hsep -orient horizontal]
    } else {
	set fsep [eval [list frame $path.hsep -bd 1 -height 2 -relief sunken] \
		      [Widget::subcget $path .hsep]]
    }
    set sep  [_sep $path sepresize {}]

................................................................................
# ------------------------------------------------------------------------
proc StatusBar::items {path} {
    variable _widget
    return $_widget($path,items)
}

proc StatusBar::_sep {path name {sub .sbar}} {
    if {[BWidget::using ttk]} {
	return [ttk::separator $path$sub.$name -orient vertical]
    } else {
	return [frame $path$sub.$name -bd 1 -width 2 -relief sunken]
    }
}

proc StatusBar::_padval {padval} {
................................................................................
    set relx   [expr {$rootx - [winfo rootx $t]}]
    set rely   [expr {$rooty - [winfo rooty $t]}]
    set width  [expr {$relx - $resize($w,x) + $resize($w,w)}]
    set height [expr {$rely - $resize($w,y) + $resize($w,h)}]
    if {$width  < 0} { set width 0 }
    if {$height < 0} { set height 0 }
    wm geometry $t ${width}x${height}

    if {[string equal $::tcl_platform(platform) "windows"]} {
      update idletasks
    }
}

# The following proc cleans up when the user releases the mouse button.

proc StatusBar::end_resize {w rootx rooty} {
    variable resize
    #continue_resize $w $rootx $rooty
    #wm grid $t $resize($w,grid)
    array unset resize $w,*
}

Changes to titleframe.tcl.

1
2
3

4
5
6
7
8
9
10
..
13
14
15
16
17
18
19
20

21
22
23
24
25
26
27
..
45
46
47
48
49
50
51

















52
53
54
55
56
57
58
59
60
61
62
63
64
65


66
67
68
69
70
71
72
...
151
152
153
154
155
156
157

158





159





160

161
162
163
164
165
166
167
168
169
170
# ------------------------------------------------------------------------------
#  titleframe.tcl
#  This file is part of Unifix BWidget Toolkit

# ------------------------------------------------------------------------------
#  Index of commands:
#     - TitleFrame::create
#     - TitleFrame::configure
#     - TitleFrame::cget
#     - TitleFrame::getframe
#     - TitleFrame::_place
................................................................................
namespace eval TitleFrame {
    Widget::define TitleFrame titleframe

    Widget::declare TitleFrame {
        {-relief      TkResource groove 0 frame}
        {-borderwidth TkResource 2      0 frame}
        {-font        TkResource ""     0 label}
        {-foreground  TkResource ""     0 label}

        {-state       TkResource ""     0 label}
        {-background  TkResource ""     0 frame}
        {-text        String     ""     0}
        {-ipad        Int        4      0 "%d >=0"}
        {-side        Enum       left   0 {left center right}}
        {-baseline    Enum       center 0 {top center bottom}}
        {-fg          Synonym    -foreground}
................................................................................

# ------------------------------------------------------------------------------
#  Command TitleFrame::create
# ------------------------------------------------------------------------------
proc TitleFrame::create { path args } {
    Widget::init TitleFrame $path $args


















    set frame  [eval [list frame $path] [Widget::subcget $path :cmd] \
	    -class TitleFrame -relief flat -bd 0 -highlightthickness 0]

    set padtop [eval [list frame $path.p] [Widget::subcget $path :cmd] \
	    -relief flat -borderwidth 0]
    set border [eval [list frame $path.b] [Widget::subcget $path .b] -highlightthickness 0]
    set label  [eval [list label $path.l] [Widget::subcget $path .l] \
                    -highlightthickness 0 \
                    -relief flat \
                    -bd     0 -padx 2 -pady 0]
    set padbot [eval [list frame $border.p] [Widget::subcget $path .p] \
	    -relief flat -bd 0 -highlightthickness 0]
    set frame  [eval [list frame $path.f] [Widget::subcget $path .f] \
	    -relief flat -bd 0 -highlightthickness 0]


    set height [winfo reqheight $label]

    switch [Widget::getoption $path -side] {
        left   { set relx 0.0; set x 5;  set anchor nw }
        center { set relx 0.5; set x 0;  set anchor n  }
        right  { set relx 1.0; set x -5; set anchor ne }
    }
................................................................................
    switch [Widget::getoption $path -side] {
        left    { set relx 0.0; set x 10;  set anchor nw }
        center  { set relx 0.5; set x 0;   set anchor n  }
        right   { set relx 1.0; set x -10; set anchor ne }
    }
    set bd [Widget::getoption $path -borderwidth]
    switch [Widget::getoption $path -baseline] {

        top    { set htop $height; set hbot 1; set y 0 }





        center { set htop [expr {$height/2}]; set hbot [expr {$height/2+$height%2+1}]; set y 0 }





        bottom { set htop 1; set hbot $height; set y [expr {$bd+1}] }

    }
    $path.p   configure -height $htop
    $path.b.p configure -height $hbot

    place $path.l -relx $relx -x $x -anchor $anchor -y $y
}






>







 







|
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|


|

|
|



|

|

>
>







 







>
|
>
>
>
>
>
|
>
>
>
>
>
|
>






<
<
<
<
1
2
3
4
5
6
7
8
9
10
11
..
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
..
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
...
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199




# ------------------------------------------------------------------------------
#  titleframe.tcl
#  This file is part of Unifix BWidget Toolkit
#  $Id: titleframe.tcl,v 1.51 2009/09/06 21:44:21 oberdorfer Exp $
# ------------------------------------------------------------------------------
#  Index of commands:
#     - TitleFrame::create
#     - TitleFrame::configure
#     - TitleFrame::cget
#     - TitleFrame::getframe
#     - TitleFrame::_place
................................................................................
namespace eval TitleFrame {
    Widget::define TitleFrame titleframe

    Widget::declare TitleFrame {
        {-relief      TkResource groove 0 frame}
        {-borderwidth TkResource 2      0 frame}
        {-font        TkResource ""     0 label}
        {-foreground  Color      "SystemWindow"      0}
        {-background  Color      "SystemWindowFrame" 0}
        {-state       TkResource ""     0 label}
        {-background  TkResource ""     0 frame}
        {-text        String     ""     0}
        {-ipad        Int        4      0 "%d >=0"}
        {-side        Enum       left   0 {left center right}}
        {-baseline    Enum       center 0 {top center bottom}}
        {-fg          Synonym    -foreground}
................................................................................

# ------------------------------------------------------------------------------
#  Command TitleFrame::create
# ------------------------------------------------------------------------------
proc TitleFrame::create { path args } {
    Widget::init TitleFrame $path $args

    if { [BWidget::using ttk] } {

      set frame  [eval [list ttk::frame $path] [Widget::subcget $path :cmd] \
	    -class TitleFrame -relief flat]

      set padtop [eval [list ttk::frame $path.p] [Widget::subcget $path :cmd] \
	    -relief flat]
      set border [eval [list ttk::frame $path.b] [Widget::subcget $path .b]]
      set label  [eval [list ttk::label $path.l] [Widget::subcget $path .l] \
                    -relief flat]
      set padbot [eval [list ttk::frame $border.p] [Widget::subcget $path .p] \
	    -relief flat]
      set frame  [eval [list ttk::frame $path.f] [Widget::subcget $path .f] \
	    -relief flat]

    } else {

      set frame  [eval [list frame $path] [Widget::subcget $path :cmd] \
	    -class TitleFrame -relief flat -bd 0 -highlightthickness 0]

      set padtop [eval [list frame $path.p] [Widget::subcget $path :cmd] \
	    -relief flat -borderwidth 0]
      set border [eval [list frame $path.b] [Widget::subcget $path .b] -highlightthickness 0]
      set label  [eval [list label $path.l] [Widget::subcget $path .l] \
                    -highlightthickness 0 \
                    -relief flat \
                    -bd     0 -padx 2 -pady 0]
      set padbot [eval [list frame $border.p] [Widget::subcget $path .p] \
	    -relief flat -bd 0 -highlightthickness 0]
      set frame  [eval [list frame $path.f] [Widget::subcget $path .f] \
	    -relief flat -bd 0 -highlightthickness 0]
    }

    set height [winfo reqheight $label]

    switch [Widget::getoption $path -side] {
        left   { set relx 0.0; set x 5;  set anchor nw }
        center { set relx 0.5; set x 0;  set anchor n  }
        right  { set relx 1.0; set x -5; set anchor ne }
    }
................................................................................
    switch [Widget::getoption $path -side] {
        left    { set relx 0.0; set x 10;  set anchor nw }
        center  { set relx 0.5; set x 0;   set anchor n  }
        right   { set relx 1.0; set x -10; set anchor ne }
    }
    set bd [Widget::getoption $path -borderwidth]
    switch [Widget::getoption $path -baseline] {
        top {
	  set htop $height
	  set hbot 1
	  set y 0
	}
        center { 
	  set htop [expr {$height/2}]
	  set hbot [expr {$height/2+$height%2+1}]
	  set y 0
	}
        bottom {
	  set htop 1
	  set hbot $height
	  set y [expr {$bd+1}]
	}
    }
    $path.p   configure -height $htop
    $path.b.p configure -height $hbot

    place $path.l -relx $relx -x $x -anchor $anchor -y $y
}