~ubuntu-branches/ubuntu/vivid/grass/vivid-proposed

« back to all changes in this revision

Viewing changes to gui/tcltk/d.m/dtext.tcl

  • Committer: Package Import Robot
  • Author(s): Bas Couwenberg
  • Date: 2015-02-20 23:12:08 UTC
  • mfrom: (8.2.6 experimental)
  • Revision ID: package-import@ubuntu.com-20150220231208-1u6qvqm84v430b10
Tags: 7.0.0-1~exp1
* New upstream release.
* Update python-ctypes-ternary.patch to use if/else instead of and/or.
* Drop check4dev patch, rely on upstream check.
* Add build dependency on libpq-dev to grass-dev for libpq-fe.h.
* Drop patches applied upstream, refresh remaining patches.
* Update symlinks for images switched from jpg to png.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
          # 1 Sept 2005
2
 
# panel for d.text
3
 
# Michael Barton, Arizona State University
4
 
 
5
 
namespace eval DmDtext {
6
 
    variable array opt # dtext options
7
 
    variable count 1
8
 
}
9
 
 
10
 
 
11
 
proc DmDtext::create { tree parent } {
12
 
    variable opt
13
 
    variable count
14
 
    global dmpath
15
 
 
16
 
    set node "dtext:$count"
17
 
 
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]
23
 
 
24
 
    image create photo dtxtico -file "$dmpath/dtext.gif"
25
 
    set ico [label $frm.ico -image dtxtico -bd 1 -relief raised]
26
 
    
27
 
    pack $check $ico -side left
28
 
    
29
 
    $tree insert end $parent $node \
30
 
        -text  "text $count"\
31
 
        -window    $frm \
32
 
        -drawcross auto  
33
 
        
34
 
    set opt($count,_check) 1 
35
 
 
36
 
    set opt($count,text) "" 
37
 
    set opt($count,at) "" 
38
 
    set opt($count,line) "" 
39
 
    set opt($count,color) \#000000 
40
 
    set opt($count,size) 5 
41
 
    set opt($count,bold) 0 
42
 
    
43
 
    incr count
44
 
    return $node
45
 
}
46
 
 
47
 
proc DmDtext::set_option { node key value } {
48
 
    variable opt
49
 
 
50
 
    set id [Dm::node_id $node]
51
 
    set opt($id,$key) $value
52
 
}
53
 
 
54
 
proc DmDtext::select_file { id } {
55
 
    variable tree
56
 
    variable node
57
 
    set m [GSelect file]
58
 
    if { $m != "" } { 
59
 
        set DmDtext::opt($id,path) $m
60
 
    }
61
 
}
62
 
 
63
 
 
64
 
# dtext options
65
 
proc DmDtext::options { id frm } {
66
 
    variable opt
67
 
    global dmpath
68
 
    global bgcolor
69
 
 
70
 
    # text
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 \
74
 
            -entrybg white
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
82
 
    
83
 
    # placement1
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 \
87
 
            -entrybg white
88
 
    pack $row.a $row.b -side left
89
 
    pack $row -side top -fill both -expand yes
90
 
        
91
 
    # placement2
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 \
95
 
            -entrybg white
96
 
    pack $row.a $row.b -side left
97
 
    pack $row -side top -fill both -expand yes
98
 
    
99
 
    # font options
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
110
 
 
111
 
}
112
 
 
113
 
proc DmDtext::save { tree depth node } {
114
 
    variable opt
115
 
    
116
 
    set id [Dm::node_id $node]
117
 
 
118
 
    foreach key { _check text at line color size bold } {
119
 
        Dm::rc_write $depth "$key $opt($id,$key)"
120
 
    } 
121
 
}
122
 
 
123
 
 
124
 
 
125
 
 
126
 
proc DmDtext::display { node } {
127
 
    variable opt
128
 
    set line ""
129
 
    set input ""
130
 
    global dmpath
131
 
    set cmd ""
132
 
 
133
 
    set tree $Dm::tree
134
 
    set id [Dm::node_id $node]
135
 
    
136
 
    # set hex colors to rgb         
137
 
    set color [Dm::color $opt($id,color)]
138
 
    
139
 
 
140
 
    if { ! ( $opt($id,_check) ) } { return } 
141
 
 
142
 
    if { $opt($id,text) == "" } { return } 
143
 
    
144
 
    set cmd "echo $opt($id,text) | d.text color=$color size=$opt($id,size) "
145
 
 
146
 
    # at
147
 
    if { $opt($id,at) != "" } { 
148
 
        append cmd " {at=$opt($id,at)}"
149
 
    }
150
 
 
151
 
    # line
152
 
    if { $opt($id,line) != "" } { 
153
 
        append cmd " line=$opt($id,line)"
154
 
    }
155
 
 
156
 
 
157
 
    # bold text
158
 
    if { $opt($id,bold) != 0 } { 
159
 
        append cmd " -b"
160
 
    }
161
 
    
162
 
#    eval "exec echo $opt($id,text) | $cmd"
163
 
 
164
 
        run_panel $cmd
165
 
    
166
 
}
167
 
 
168
 
proc DmDtext::print { file node } {
169
 
    variable opt
170
 
    
171
 
    set tree $Dm::tree
172
 
    set id [Dm::node_id $node]
173
 
 
174
 
    if { ! ( $opt($id,_check) ) } { return } 
175
 
 
176
 
    if { $opt($id,text) == "" } { return } 
177
 
 
178
 
    puts $file "dtext $opt($id,dtext)"
179
 
}
180
 
 
181
 
 
182
 
proc DmDtext::duplicate { tree parent node id } {
183
 
    variable opt
184
 
    variable count 
185
 
    global dmpath
186
 
 
187
 
    set node "dtext:$count"
188
 
 
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]
194
 
 
195
 
    image create photo dtxtico -file "$dmpath/dtext.gif"
196
 
    set ico [label $frm.ico -image dtxtico -bd 1 -relief raised]
197
 
    
198
 
    pack $check $ico -side left
199
 
 
200
 
        if { $opt($id,text) == ""} {
201
 
        $tree insert end $parent $node \
202
 
                -text      "text $count" \
203
 
                -window    $frm \
204
 
                -drawcross auto
205
 
        }
206
 
 
207
 
    set opt($count,_check) $opt($id,_check)
208
 
 
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)
215
 
 
216
 
    incr count
217
 
    return $node
218
 
}