3
# Michael Barton, Arizona State University
5
namespace eval DmDtext {
6
variable array opt # dtext options
11
proc DmDtext::create { tree parent } {
16
set node "dtext:$count"
18
set frm [ frame .dtexticon$count]
19
set fon [font create -size 10]
20
set check [checkbutton $frm.check -font $fon \
21
-variable DmDtext::opt($count,_check) \
22
-height 1 -padx 0 -width 0]
24
image create photo dtxtico -file "$dmpath/dtext.gif"
25
set ico [label $frm.ico -image dtxtico -bd 1 -relief raised]
27
pack $check $ico -side left
29
$tree insert end $parent $node \
34
set opt($count,_check) 1
36
set opt($count,text) ""
38
set opt($count,line) ""
39
set opt($count,color) \#000000
40
set opt($count,size) 5
41
set opt($count,bold) 0
47
proc DmDtext::set_option { node key value } {
50
set id [Dm::node_id $node]
51
set opt($id,$key) $value
54
proc DmDtext::select_file { id } {
59
set DmDtext::opt($id,path) $m
65
proc DmDtext::options { id frm } {
71
set row [ frame $frm.text ]
72
Label $row.a -text "Text to display:"
73
LabelEntry $row.b -textvariable DmDtext::opt($id,text) -width 51 \
75
Button $row.c -text [G_msg "Help"] \
76
-image [image create photo -file "$dmpath/grass.gif"] \
77
-command "run g.manual d.text" \
78
-background $bgcolor \
79
-helptext [G_msg "Help"]
80
pack $row.a $row.b $row.c -side left
81
pack $row -side top -fill both -expand yes
84
set row [ frame $frm.at ]
85
Label $row.a -text "Text placement: as % of display from lower left (x,y)"
86
LabelEntry $row.b -textvariable DmDtext::opt($id,at) -width 10 \
88
pack $row.a $row.b -side left
89
pack $row -side top -fill both -expand yes
92
set row [ frame $frm.line ]
93
Label $row.a -text " by line number from top (1-1000)"
94
LabelEntry $row.b -textvariable DmDtext::opt($id,line) -width 10 \
96
pack $row.a $row.b -side left
97
pack $row -side top -fill both -expand yes
100
set row [ frame $frm.fontopt ]
101
Label $row.a -text [G_msg "Text options: color"]
102
SelectColor $row.b -type menubutton -variable DmDtext::opt($id,color)
103
Label $row.c -text " text height (% of display)"
104
SpinBox $row.d -range {1 100 1} -textvariable DmDtext::opt($id,size) \
105
-entrybg white -width 3
106
checkbutton $row.e -padx 10 -text [G_msg "bold text"] -variable \
107
DmDtext::opt($id,bold)
108
pack $row.a $row.b $row.c $row.d $row.e -side left
109
pack $row -side top -fill both -expand yes
113
proc DmDtext::save { tree depth node } {
116
set id [Dm::node_id $node]
118
foreach key { _check text at line color size bold } {
119
Dm::rc_write $depth "$key $opt($id,$key)"
126
proc DmDtext::display { node } {
134
set id [Dm::node_id $node]
136
# set hex colors to rgb
137
set color [Dm::color $opt($id,color)]
140
if { ! ( $opt($id,_check) ) } { return }
142
if { $opt($id,text) == "" } { return }
144
set cmd "echo $opt($id,text) | d.text color=$color size=$opt($id,size) "
147
if { $opt($id,at) != "" } {
148
append cmd " {at=$opt($id,at)}"
152
if { $opt($id,line) != "" } {
153
append cmd " line=$opt($id,line)"
158
if { $opt($id,bold) != 0 } {
162
# eval "exec echo $opt($id,text) | $cmd"
168
proc DmDtext::print { file node } {
172
set id [Dm::node_id $node]
174
if { ! ( $opt($id,_check) ) } { return }
176
if { $opt($id,text) == "" } { return }
178
puts $file "dtext $opt($id,dtext)"
182
proc DmDtext::duplicate { tree parent node id } {
187
set node "dtext:$count"
189
set frm [ frame .dtexticon$count]
190
set fon [font create -size 10]
191
set check [checkbutton $frm.check -font $fon \
192
-variable DmDtext::opt($count,_check) \
193
-height 1 -padx 0 -width 0]
195
image create photo dtxtico -file "$dmpath/dtext.gif"
196
set ico [label $frm.ico -image dtxtico -bd 1 -relief raised]
198
pack $check $ico -side left
200
if { $opt($id,text) == ""} {
201
$tree insert end $parent $node \
202
-text "text $count" \
207
set opt($count,_check) $opt($id,_check)
209
set opt($count,text) $opt($id,text)
210
set opt($count,at) $opt($id,at)
211
set opt($count,line) $opt($id,line)
212
set opt($count,color) $opt($id,color)
213
set opt($count,size) $opt($id,size)
214
set opt($count,bold) $opt($id,bold)