This file is indexed.

/usr/share/tcltk/tklib0.6/plotchart/plottable.tcl is in tklib 0.6-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
# plottable.tcl --
#     Routines for drawing a table and its contents
#

# DrawTableFrame --
#     Draw the horizontal and vertical lines for the table
#
# Arguments:
#     w            Widget in which to draw
#
proc ::Plotchart::DrawTableFrame { w } {
    variable scaling
    variable config

    set pxmin [lindex $scaling($w,leftside)    0]
    set pxmax [lindex $scaling($w,rightside) end]
    set pymin $scaling($w,topside)
                                                     #Config      #Config
    $w create line $pxmin $pymin $pxmax $pymin -fill $config($w,frame,color) \
        -width $config($w,frame,outerwidth) -tag frame

    set scaling($w,hseparator) [$w create line $pxmin $pymin $pxmin $pymin \
            -fill $config($w,frame,color) -width $config($w,frame,outerwidth) -tag frame]

    set scaling($w,vseparators) {}

    set linewidth "outerwidth"
    foreach left $scaling($w,leftside) {

        lappend scaling($w,vseparators) [$w create line $left $pymin $left $pymin \
               -fill $config($w,frame,color) -width $config($w,frame,$linewidth) -tag frame]
        set linewidth "innerwidth"
    }

    set right [lindex $scaling($w,rightside) end]

    lappend scaling($w,vseparators) [$w create line $right $pymin $right $pymin \
           -fill $config($w,frame,color) -width $config($w,frame,outerwidth) -tag frame]
}

# SetFormatCommand --
#     Set the format command
#
# Arguments:
#     w            Widget in which to draw
#     command      Command to use
#
proc ::Plotchart::SetFormatCommand { w command } {
    variable scaling

    set fullname [uplevel 2 [list namespace which $command]]

    if { $fullname == "" } {
        return -code error "No such command or procedure: $command"
    } else {
        set scaling($w,formatcommand) $fullname
    }
}

# DefaultFormat --
#     Default routine for formatting the contents of a cell
#
# Arguments:
#     chart        Table chart name
#     w            Widget in which to draw
#     row          Row of the current cell
#     column       Column of the current cell
#     value        Value to draw
#
# Result:
#     String to be drawn
#
# Note:
#     Does not set any cell properties
#
proc ::Plotchart::DefaultFormat { chart w row column value } {

    return $value
}

# TextAnchor --
#     Determine the position of the text in a cell
#
# Arguments:
#     chart        Table chart name
#     type         Type of cell
#     left         Left side of the cell
#     right        Right side of the cell
#
# Result:
#     X and Y-coordinate and anchor
#
proc ::Plotchart::TextAnchor { w type left right } {
    variable scaling
    variable config

    set ypos [expr {$scaling($w,topside) + $config($w,cell,topspace)}]

    switch -- $config($w,$type,anchor) {
        "left" {
            set anchor nw
            set xpos   [expr {$left + $config($w,cell,leftspace)}]
        }
        "right" {
            set anchor ne
            set xpos   [expr {$right - $config($w,cell,rightspace)}]
        }
        "center" -
        default  {
            set anchor n
            set xpos [expr {($left + $right) / 2.0}]
        }
    }

    return [list $xpos $ypos $anchor]
}

#
# DrawRow --
#     Draw a single row
#
# Arguments:
#     w            Widget in which to draw
#     values       Values to fill the row with
#     option       Option for drawing
#
# Note:
#     This does not take care at all of any configuration options!
#
proc ::Plotchart::DrawRow { w values {option {}} } {
    variable scaling
    variable config

    if { [llength $values] < [llength $scaling($w,leftside)] } {
        return -code error "Too few values to fill the row"
    }

    if { $option eq "header" } {
        foreach v $values left $scaling($w,leftside) right $scaling($w,rightside) {

            foreach {xpos ypos anchor} [TextAnchor $w header $left $right] {break}

            $w create rectangle $left $scaling($w,topside) $right [expr {$scaling($w,topside)+$config($w,header,height)}] \
                -tag cellbg -fill $scaling($w,cell,-background) -outline $scaling($w,cell,-background)

            if { [info exists config($w,header,font)] } {  
                $w create text $xpos $ypos -text $v -fill $config($w,header,color) -anchor $anchor \
                    -font $config($w,header,font)
            } else {
                $w create text $xpos $ypos -text $v -fill $config($w,header,color) -anchor $anchor
            }
        }
    } else {

        # TODO
        set type oddrow
        if { $scaling($w,row) % 2 == 0 } {
            set type evenrow
        }

        set column 0
        foreach value $values left $scaling($w,leftside) right $scaling($w,rightside) {

            foreach {xpos ypos anchor} [TextAnchor $w cell $left $right] {break}

            set scaling($w,left)     $left
            set scaling($w,right)    $right
            set scaling($w,hasworld) 0

            set text [$scaling($w,formatcommand) table_$w $w $scaling($w,row) $column $value]

            if { $scaling($w,cell,-background) ne "" } {
                $w create rectangle $left $scaling($w,topside) $right [expr {$scaling($w,topside)+$config($w,$type,height)}] \
                    -tag cellbg -fill $scaling($w,cell,-background) -outline $scaling($w,cell,-background)
            }

            if { [info exists scaling($w,cell,-font)] } {
                $w create text $xpos $ypos -text $text -anchor $anchor -tag celltext \
                    -fill $scaling($w,cell,-color) -font $scaling($w,cell,-font)
            } else {
                $w create text $xpos $ypos -text $text -anchor $anchor -tag celltext \
                -fill $scaling($w,cell,-color)
            }    
            incr column
        }
    }

    set oldtop $scaling($w,toptable)
    set scaling($w,topside) [expr {$scaling($w,topside) + $config($w,evenrow,height)}]

    $w coords $scaling($w,hseparator) [lindex $scaling($w,leftside)    0] $scaling($w,topside) \
                                      [lindex $scaling($w,rightside) end] $scaling($w,topside)

    foreach vseparator $scaling($w,vseparators) hcoord $scaling($w,leftside) {
        if { $hcoord == {} } {
            set hcoord [lindex $scaling($w,rightside) end]
        }
        $w coords $vseparator $hcoord $oldtop $hcoord $scaling($w,topside)
    }

    incr scaling($w,row)

    $w lower cellbg
    $w raise celltext
    $w raise frame
}

#
# DrawSeparator --
#     Draw a horizontal separator
#
# Arguments:
#     w            Widget in which to draw
#
proc ::Plotchart::DrawSeparator { w } {
    variable scaling
    variable config

    set left  [lindex $scaling($w,leftside)    0]
    set right [lindex $scaling($w,rightside) end]

    $w create line $left $scaling($w,topside) $right $scaling($w,topside) -tag frame \
        -fill $config($w,frame,color) -width $config($w,frame,innerwidth)

    $w raise frame
}

# ConfigureTableCell --
#     Set the properties of the "current" table cell
#
# Arguments:
#     w            Widget in which to draw
#     args         List of key-value pairs
#
proc ::Plotchart::ConfigureTableCell { w args } {
    variable scaling
    variable config

    foreach {key value} $args {
        switch -- $key {
            "-background" -
            "-color"      -
            "-font"       -
            "-justify"    {
                set scaling($w,cell,$key) $value
            }
            "-anchor"     {
                #
                # Problem: this takes effect in the _next_ cell!
                #
                set config($w,cell,anchor) $value
            }
            default {
                return -code error "Unknown cell property: $key"
            }
        }
    }
}

# TableCellCoordinates --
#     Get the pixel coordinates of the "current" table cell
#
# Arguments:
#     w            Widget in which to draw
#
proc ::Plotchart::TableCellCoordinates { w } {
    variable scaling
    variable config

    return [list $scaling($w,left) $scaling($w,topside) $scaling($w,right) [expr {$scaling($w,topside)+$config($w,evenrow,height)}]]
}

# TableWorldCoordinates --
#     Set the world coordinates for the "current" table cell
#
# Arguments:
#     w            Widget in which to draw
#     xmin         Minimum x-coordinate
#     ymin         Minimum y-coordinate
#     xmax         Maximum x-coordinate
#     ymax         Maximum y-coordinate
#
proc ::Plotchart::TableWorldCoordinates { w xmin ymin xmax ymax } {
    variable scaling
    variable config

    viewPort         $w $scaling($w,left)  $scaling($w,topside) \
                        $scaling($w,right) [expr {$scaling($w,topside)+$config($w,evenrow,height)}]
    worldCoordinates $w $xmin $ymin $xmax $ymax

    set scaling($w,hasworld) 1
}

# TableWorldToPixels --
#     Convert the world coordinates for the "current" table cell to pixels
#
# Arguments:
#     w            Widget in which to draw
#     args         Either a single argument (list of xy-pairs) or separate
#                  argumentns representing xy-pairs
#
proc ::Plotchart::TableWorldToPixels { w args } {
    variable scaling

    if { [llength $args] == 1 } {
        set coords [lindex $args 0]
    } else {
        set coords $args
    }
    if { $scaling($w,hasworld) } {
        set pixelCoords {}
        foreach {x y} $coords {
            set pixelCoords [concat $pixelCoords [coordsToPixel $w $x $y]]
        }
        set coords $pixelCoords
    }

    return $coords
}