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
|
############################################################################
#
# File: attribs.icn
#
# Subject: Procedure to set attributes via dialog
#
# Author: Ralph E. Griswold
#
# Date: February 17, 1997
#
############################################################################
#
# This file is in the public domain.
#
############################################################################
#
# This procedure produces a dialog in which the user can change
# the most commonly used graphics attributes.
#
# Problems: If a text-entry field is not long enough to hold the current
# value for an attribute, the attribute has to be edited. Also, a
# slider is not the best way of changing the gamma attribute -- it's
# not possible to set a precise value. A slider was used mostly for
# demonstration purposes.
#
############################################################################
#
# Requires: Version 9 graphics
#
############################################################################
#
# Links: dsetup
#
############################################################################
link dsetup # dialog setup
procedure attribs(win) #: set graphics attributes via dialog
static atts
initial atts := table() # table of vidget IDs
/win := &window
# Assign values from current attributes.
atts["1_fg"] := Fg(win)
atts["2_bg"] := Bg(win)
atts["3_font"] := Font(win)
atts["4_linewidth"] := WAttrib(win, "linewidth")
atts["5_pattern"] := WAttrib(win, "pattern")
atts["linestyle"] := WAttrib(win, "linestyle")
atts["fillstyle"] := WAttrib(win, "fillstyle")
atts["gamma"] := WAttrib(win, "gamma")
# Call up the dialog.
repeat {
attributes(win, atts) == "Okay" | fail
# Set attributes from table.
Fg(win, atts["1_fg"]) | {
Notice("Invalid foreground color.")
next
}
Bg(win, atts["2_bg"]) | {
Notice("Invalid background color.")
next
}
Font(win, atts["3_font"]) | {
Notice("Invalid font.")
next
}
WAttrib(win, "linewidth=" || integer(atts["4_linewidth"])) | {
Notice("Invalid linewidth.")
next
}
WAttrib(win, "pattern=" || atts["5_pattern"]) | {
Notice("Invalid pattern.")
next
}
WAttrib(win, "linestyle=" || atts["linestyle"])
WAttrib(win, "fillstyle=" || atts["fillstyle"])
WAttrib(win, "gamma=" || atts["gamma"])
return
}
end
#===<<vib:begin>>=== modify using vib; do not remove this marker line
procedure attributes(win, deftbl)
static dstate
initial dstate := dsetup(win,
["attributes:Sizer::1:0,0,370,400:attributes",],
["0.5:Label:::105,204,21,13:0.5",],
["1.0:Label:::135,203,21,13:1.0",],
["1_fg:Text::35:10,20,339,19: fg: \\=",],
["2.0:Label:::199,203,21,13:2.0",],
["2_bg:Text::35:10,52,339,19: bg: \\=",],
["3.0:Label:::261,204,21,13:3.0",],
["3_font:Text::35:11,80,339,19: font: \\=",],
["4.0:Label:::324,204,21,13:4.0",],
["4_linewidth:Text::3:11,110,115,19:line width: \\=",],
["5_pattern:Text::35:11,140,339,19: pattern: \\=",],
["button1:Button:regular::206,350,60,30:Cancel",],
["fill label:Label:::202,241,70,13:fill style",],
["fillstyle:Choice::3:195,262,85,63:",,
["solid","textured","masked"]],
["gamma:Slider:h:1:97,174,253,20:0.5,4.0,1.0",],
["glabel:Label:::11,176,84,13: gamma: ",],
["line label:Label:::100,241,70,13:line style",],
["linestyle:Choice::3:96,262,78,63:",,
["solid","striped","dashed"]],
["okay:Button:regular:-1:106,350,60,30:Okay",],
["tick1:Line:::117,196,117,201:",],
["tick2:Line:::146,195,146,200:",],
["tick3:Line:::209,195,209,200:",],
["tick4:Line:::272,195,272,200:",],
["tick5:Line:::335,195,335,200:",],
)
return dpopup(win, deftbl, dstate)
end
#===<<vib:end>>=== end of section maintained by vib
|