This file is indexed.

/usr/share/pyshared/fltk/test/table.py is in python-fltk 1.3.0-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
#
# "$Id: table.py 471 2011-01-24 20:31:16Z andreasheld $"
#
# Fl_Table test program for pyFLTK the Python bindings
# for the Fast Light Tool Kit (FLTK).
#
# FLTK copyright 1998-1999 by Bill Spitzak and others.
# Fl_Table copyright 2003 by G. Ercolano
# pyFLTK copyright 2003 by Andreas Held and others.
#
# This library is free software you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# Library General Public License for more details.
#
# You should have received a copy of the GNU Library General Public
# License along with this library if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
#
# Please report all bugs and problems to "pyfltk-user@lists.sourceforge.net".
#

from fltk import *
import sys


def button_cb(w, data):
    print "BUTTON: %s"%w.label()

class WidgetTable(Fl_Table_Row):
    def __init__(self, x, y, w, h, l=""):
        Fl_Table_Row.__init__(self, x, y, w, h, l)
        self.col_header(1)
        self.col_resize(1)
        self.col_header_height(25)
        self.row_header(1)
        self.row_resize(1)
        self.row_header_width(80)
        self.end()

    def draw_cell(self, context, R, C, X, Y, W, H):
        s="%d/%d"%(R,C) # text for each cell

        if context==self.CONTEXT_STARTPAGE:
            fl_font(FL_HELVETICA, 12) # font used by all headers
            return None
        elif context==self.CONTEXT_RC_RESIZE:
            index = 0
            for r in range(self.rows()):
                for c in range(self.cols()):
                    if index >= self.children():
                        break
                    #(status, X, Y, W, H) = self.find_cell(self.CONTEXT_TABLE, r, c, X, Y, W, H)
                    #(status, X, Y, W, H) = self.find_cell(self.CONTEXT_TABLE, r, c)
                    self.child(index).resize(X,Y,W,H)
                    index += 1
            self.init_sizes()
            return None
        elif context==self.CONTEXT_ROW_HEADER:
            s1="Row %d"%R
            fl_push_clip(X,Y,W,H)
            fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, self.row_header_color())
            fl_color(FL_BLACK)
            fl_draw(s1, X, Y, W, H, FL_ALIGN_CENTER)
            fl_pop_clip()
            return None
        elif context==self.CONTEXT_COL_HEADER:
            s1="Column %d"%C
	    fl_push_clip(X, Y, W, H)
            fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, self.col_header_color())
            fl_color(FL_BLACK)
            fl_draw(s1, X, Y, W, H, FL_ALIGN_CENTER)
	    fl_pop_clip()
	    return None
        elif context==self.CONTEXT_CELL:
            return None
        else:
            return None

    def SetSize(self, newrows, newcols):
        self.rows(newrows)
        self.cols(newcols)
        self.begin()
        self.s_list = []
        for r in range(newrows):
            for c in range(newcols):
                X=0
                Y=0
                W=self.col_width(c)
                H=self.row_height(r)
                #c=0
                #(status, X, Y, W, H)=self.find_cell(self.CONTEXT_TABLE, r, c, X, Y, W, H)
                
                if c&1:
                    s="%d.%d"%(r,c)
                    inp = Fl_Input(X,Y,W,H)
                    inp.value(s)
                else:
                    s1="%d/%d"%(r,c)
                    butt = Fl_Light_Button(X,Y,W,H,s1)
                    self.s_list.append(s1)
                    butt.align(FL_ALIGN_CENTER|FL_ALIGN_INSIDE)
                    butt.callback(button_cb, 0)
                    if (r+2*c)&4:
                        butt.value(1)
                    else:
                        butt.value(0)
        self.end()
                    


class DemoTable(Fl_Table_Row):
    def __init__(self, x, y, w, h, l=""):
        Fl_Table_Row.__init__(self, x, y, w, h, l)

    def draw_cell(self, context, R, C, X, Y, W, H):
        s="%d/%d"%(R,C) # text for each cell

        if context==self.CONTEXT_STARTPAGE:
            fl_font(FL_HELVETICA, 16)
            return None
        elif context==self.CONTEXT_ROW_HEADER or context==self.CONTEXT_COL_HEADER:
            fl_push_clip(X,Y,W,H)
            fl_draw_box(FL_THIN_UP_BOX, X, Y, W, H, self.color())
            fl_color(FL_BLACK)
            fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER)
            fl_pop_clip()
            return None
        elif context==self.CONTEXT_CELL:
            fl_push_clip(X,Y,W,H)
            # BG color
            if self.row_selected(R):
                fl_color(self.selection_color())
            else:
                fl_color(FL_WHITE)
            fl_rectf(X, Y, W, H)
            
            # TEXT
            fl_color(FL_BLACK)
            fl_draw(s, X, Y, W, H, FL_ALIGN_CENTER)

            # BORDER
            fl_color(FL_LIGHT2); 
            fl_rect(X, Y, W, H);
            fl_pop_clip()
            return None
        else:
            return None
                                   


def table_cb(o, data):
    table = data
    print "%s callback: row=%d col=%d, context=%d, event=%d, clicks=%d"%(table.label(),table.callback_row(),table.callback_col(),table.callback_context(),Fl.event(), Fl.event_clicks())
    
if __name__=='__main__':
    #win1 = Fl_Window(940, 500, "widgettable")
    #table = WidgetTable(20, 20, win1.w()-40, win1.h()-40, "widgettable")
    #table.SetSize(20, 20)
    #win1.end()
    #win1.resizable(table)
    #win1.show()

    w = 900
    h = 700
    t1x = 20
    t1y = 20
    t1w = w - 40
    t1h = ( (h-60) / 2 )
    t2x = 20
    t2y = t1y+t1h+20
    t2w = w - 40
    t2h = t1h

    win2 = Fl_Window(w, h, "testtablerow")
    table1 = DemoTable(t1x, t1y, t1w, t1h, "Table 1")
    table1.selection_color(FL_YELLOW)
    table1.when(FL_WHEN_RELEASE)	# handle table events on release
    #table1.rows(1001)
    table1.rows(51)
    table1.cols(31)
    table1.col_header(1)		# enable col header
    table1.col_resize(4)		# enable col resizing
    table1.row_header(1)		# enable row header
    table1.row_resize(4)		# enable row resizing
    table1.callback(table_cb, table1)
    table1.when(FL_WHEN_CHANGED|FL_WHEN_RELEASE)
    table1.end()

    table2 = DemoTable(t2x, t2y, t2w, t2h, "Table 2")
    table2.selection_color(FL_YELLOW)
    table2.when(FL_WHEN_RELEASE)	# handle table events on release
    #table2.rows(1001)
    table2.rows(51)
    table2.cols(31)
    table2.col_header(1)		# enable col header
    table2.col_resize(4)		# enable col resizing
    table2.row_header(1)		# enable row header
    table2.row_resize(4)		# enable row resizing
    table2.end()
    win2.end()
    win2.show()

    Fl.run()