table.tcl a) Layout canvas items in rows and columns b) Optionally draw grid lines in table Current Version 1.1 (Fri Jan 6 09:27:36 1995) Author: Bryan M. Kramer (kramer@ai.toronto.edu) # USAGE example: # # set table [new_table] # pack $table # set canvas [table_canvas $table] # # table_col_defaults $table 5 1 5 grey # table_row_defaults $table 5 1 5 grey # table_col_info $table 1 5 3 5 black right # table_row_info $table 1 5 3 5 black # # set i [$canvas create text 10 10 -text "item 1 1"] # table_add $table $i 1 1 # set i [$canvas create text 10 10 -text "item 2 1"] # table_add $table $i 2 1 # set i [$canvas create text 10 10 -text "item 2 2"] # table_add $table $i 2 2 # # table_layout $table # # NOTE: # since canvases can take window items, this can be used to create # scrolling tables of buttons, entries etc.! # # # # # new_table [parent [-noscroll]] # - returns a frame containing a canvas and # vertical and horizontal scrollbars # - the returned name is the 'table' identifier # for the other table functions # - -noscroll skips making scrollbars and makes the # canvas big enough to show everything in it and make # table_fix_scroll will recalculate the canvas size # instead of recalculating the scrollregion. # # table_canvas table - return the canvas on which the table is to be drawn # USE this canvas for creating objects # # USER CAN REDEFINE the ABOVE two functions if other window arrangements are # desired # THE ONLY CONSTRAINT IS THAT [table_canvas table_id] return a canvas # containing # all the items that are to be layed out # # table_add table item row col - add an item to the table in position row,col # - ROW AND COL MUST BE >= 1 # - item is an integer identifying an object in # the canvas # # table_col_defaults table # [margin1 [rule_width [margin2 [rule_colour [alignment]]]]] # table_row_defaults table # [margin1 [rule_width [margin2 [rule_colour [alignment]]]]] # # - set up default row and column information # - between columns we have # where space1 is margin1 pixels, the line has width # rule_width and space2 is margin2 pixels # - the line is drawn in rule_colour # - alignment specifies how objects are placed into cells # that are bigger than the space they need # - column alignments are one of left, right, or center # - row alignments are one of top, bottom, or center # # table_col_info table col # [margin1 [rule_width [margin2 [rule_colour [alignment]]]]] # table_row_info table row # [margin1 [rule_width [margin2 [rule_colour [alignment]]]]] # # - same as defaults except specifies a specific row or # column # - the rule information is for the line AFTER then nth # row or column # - use 0 to specify the rule_width and margin2 for the # leftmost or topmost line # # table_layout table - move the objects in the canvas so that rows and # columns accomodate the largest elements, aligning # the rest according to the alignment information # given for the table # - NOTE: can call this at any time, i.e. add new # items and redo layout is no problem # # table_fix_scroll table - change the scroll region of the canvas to # accomodate all objects on the canvas # #