blob: edb8e7a9b9530c64eea079b6453fc0eb4ec21447 (
plain)
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
|
# MkChoose.tcl --
#
# This file implements the "Choosers" page in the widget demo
#
# This file has not been properly documented. It is NOT intended
# to be used as an introductory demo program about Tix
# programming. For such demos, please see the files in the
# demos/samples directory or go to the "Samples" page in the
# "widget demo"
#
#
# Copyright (c) 1996, Expert Interface Technologies
#
# See the file "license.terms" for information on usage and redistribution
# of this file, and for a DISCLAIMER OF ALL WARRANTIES.
#
proc MkChoosers {nb page} {
set w [$nb subwidget $page]
set name [tixOptionName $w]
option add *$name*TixLabelFrame*label.padX 4
tixLabelFrame $w.til -label "Chooser Widgets"
tixLabelFrame $w.cbx -label "tixComboBox"
tixLabelFrame $w.ctl -label "tixControl"
tixLabelFrame $w.sel -label "tixSelect"
tixLabelFrame $w.opt -label "tixOptionMenu"
tixLabelFrame $w.fil -label "tixFileEntry"
tixLabelFrame $w.fbx -label "tixFileSelectBox"
tixLabelFrame $w.tbr -label "Tool Bar"
MkTitle [$w.til subwidget frame]
MkCombo [$w.cbx subwidget frame]
MkControl [$w.ctl subwidget frame]
MkSelect [$w.sel subwidget frame]
MkOptMenu [$w.opt subwidget frame]
MkFileBox [$w.fbx subwidget frame]
MkFileEnt [$w.fil subwidget frame]
MkToolBar [$w.tbr subwidget frame]
#
# First column: comBox and selector
tixForm $w.cbx -top 0 -left 0 -right %33
tixForm $w.sel -left 0 -right &$w.cbx -top $w.cbx
tixForm $w.opt -left 0 -right &$w.cbx -top $w.sel -bottom -1
#
# Second column: title .. etc
tixForm $w.til -left $w.cbx -right %66 -top 0
tixForm $w.ctl -left $w.cbx -right &$w.til -top $w.til
tixForm $w.fil -left $w.cbx -right &$w.til -top $w.ctl
tixForm $w.tbr -left $w.cbx -right &$w.til -top $w.fil -bottom -1
#
# Third column: file selection
tixForm $w.fbx -left %66 -right -1 -top 0
}
#----------------------------------------------------------------------
# ComboBox
#----------------------------------------------------------------------
proc MkCombo {w} {
set name [tixOptionName $w]
option add *$name*TixComboBox*label.width 10
option add *$name*TixComboBox*label.anchor e
option add *$name*TixComboBox*entry.width 14
tixComboBox $w.static -label "Static" \
-editable false
tixComboBox $w.editable -label "Editable" \
-editable true
tixComboBox $w.history -label "History" \
-editable true -history true -anchor e
$w.static insert end January
$w.static insert end February
$w.static insert end March
$w.static insert end April
$w.static insert end May
$w.static insert end June
$w.static insert end July
$w.static insert end August
$w.static insert end September
$w.static insert end October
$w.static insert end November
$w.static insert end December
$w.editable insert end "America"
$w.editable insert end "Britain"
$w.editable insert end "China"
$w.editable insert end "Denmark"
$w.editable insert end "Egypt"
$w.history insert end "/usr/bin/mail"
$w.history insert end "/etc/profile"
$w.history insert end "/home/d/doe/Mail/letter"
pack $w.static $w.editable $w.history -side top -padx 5 -pady 3
}
#----------------------------------------------------------------------
# The Control widgets
#----------------------------------------------------------------------
set states {Alabama "New York" Pennsylvania Washington}
proc stCmd {w by value} {
global states
set index [lsearch $states $value]
set len [llength $states]
set index [expr $index + $by]
if {$index < 0} {
set index [expr $len -1]
}
if {$index >= $len} {
set index 0
}
return [lindex $states $index]
}
proc stValidate {w value} {
global states
if {[lsearch $states $value] == -1} {
return [lindex $states 0]
} else {
return $value
}
}
proc MkControl {w} {
set name [tixOptionName $w]
option add *$name*TixControl*label.width 10
option add *$name*TixControl*label.anchor e
option add *$name*TixControl*entry.width 13
tixControl $w.simple -label Numbers
tixControl $w.spintext -label States \
-incrcmd "stCmd $w.spintext 1" \
-decrcmd "stCmd $w.spintext -1" \
-validatecmd "stValidate .d" \
-value "Alabama"
pack $w.simple $w.spintext -side top -padx 5 -pady 3
}
#----------------------------------------------------------------------
# The Select Widgets
#----------------------------------------------------------------------
proc MkSelect {w} {
set name [tixOptionName $w]
option add *$name*TixSelect*label.anchor c
option add *$name*TixSelect*orientation vertical
option add *$name*TixSelect*labelSide top
tixSelect $w.sel1 -label "Mere Mortals" -allowzero true -radio true
tixSelect $w.sel2 -label "Geeks" -allowzero true -radio false
$w.sel1 add eat -text Eat
$w.sel1 add work -text Work
$w.sel1 add play -text Play
$w.sel1 add party -text Party
$w.sel1 add sleep -text Sleep
$w.sel2 add eat -text Eat
$w.sel2 add prog1 -text Program
$w.sel2 add prog2 -text Program
$w.sel2 add prog3 -text Program
$w.sel2 add sleep -text Sleep
pack $w.sel1 $w.sel2 -side left -padx 5 -pady 3 -fill x
}
#----------------------------------------------------------------------
# The OptMenu Widget
#----------------------------------------------------------------------
proc MkOptMenu {w} {
set name [tixOptionName $w]
option add *$name*TixOptionMenu*label.anchor e
tixOptionMenu $w.menu -label "File Format : " \
-options {
menubutton.width 15
}
$w.menu add command text -label "Plain Text"
$w.menu add command post -label "PostScript"
$w.menu add command format -label "Formatted Text"
$w.menu add command html -label "HTML"
$w.menu add separator sep
$w.menu add command tex -label "LaTeX"
$w.menu add command rtf -label "Rich Text Format"
pack $w.menu -padx 5 -pady 3 -fill x
}
#----------------------------------------------------------------------
# FileEntry
#----------------------------------------------------------------------
proc MkFileEnt {w} {
set name [tixOptionName $w]
message $w.msg -font -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*\
-relief flat -width 240 -anchor n\
-text {Press the "open file" icon button and a\
TixFileSelectDialog will popup.}
tixFileEntry $w.ent -label "Select a file : "
pack $w.msg -side top -expand yes -fill both -padx 3 -pady 3
pack $w.ent -side top -fill x -padx 3 -pady 3
}
proc MkFileBox {w} {
set name [tixOptionName $w]
message $w.msg -font -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*\
-relief flat -width 240 -anchor n\
-text {The TixFileSelectBox is Motif-style file selection\
box with various enhancements. For example, you can adjust the\
size of the two listboxes and your past selections are recorded.}
tixFileSelectBox $w.box
pack $w.msg -side top -expand yes -fill both -padx 3 -pady 3
pack $w.box -side top -fill x -padx 3 -pady 3
}
#----------------------------------------------------------------------
# Tool Bar
#----------------------------------------------------------------------
proc MkToolBar {w} {
set name [tixOptionName $w]
option add $name*TixSelect*frame.borderWidth 1
message $w.msg -font -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*\
-relief flat -width 240 -anchor n\
-text {The Select widget is also good for arranging buttons\
in a tool bar.}
frame $w.bar -bd 2 -relief raised
tixSelect $w.font -allowzero true -radio false -label {}
tixSelect $w.para -allowzero false -radio true -label {}
$w.font add bold -bitmap [tix getbitmap bold]
$w.font add italic -bitmap [tix getbitmap italic]
$w.font add underline -bitmap [tix getbitmap underlin]
$w.font add capital -bitmap [tix getbitmap capital]
$w.para add left -bitmap [tix getbitmap leftj]
$w.para add right -bitmap [tix getbitmap rightj]
$w.para add center -bitmap [tix getbitmap centerj]
$w.para add justify -bitmap [tix getbitmap justify]
pack $w.msg -side top -expand yes -fill both -padx 3 -pady 3
pack $w.bar -side top -fill x -padx 3 -pady 3
pack $w.para $w.font -in $w.bar -side left -padx 4 -pady 3
}
#----------------------------------------------------------------------
# Title
#----------------------------------------------------------------------
proc MkTitle {w} {
set name [tixOptionName $w]
option add $name*TixSelect*frame.borderWidth 1
message $w.msg -font -*-helvetica-bold-r-normal-*-14-*-*-*-*-*-*-*\
-relief flat -width 240 -anchor n\
-text {There are many types of "choose" widgets that allow\
the user to input different type of information.}
pack $w.msg -side top -expand yes -fill both -padx 3 -pady 3
}
|