indexing description: "[ Table boxes for layouting other boxes. ]" author: "" date: "$Date$" revision: "$Revision$" class EXHIBIT_TABLE_BOX inherit EXHIBIT_BOX create make feature -- Access title: STRING is -- Title "Table Boxes" description: STRING is -- Description "The table boxes in the Viz library have numerous uses. % %But the main use is probably to layout boxes in a more strucured % %manner, especially if boxes need to be aligned with each % %other in the horizontal as well as in the vertical direction. % %Additionally, each table can have an (initially hidden) border % %which can be arbitrarily wide. Care should be taken, though, as % %borders, which are too wide, can hide the cells of the table.%N% %" align_table: EM_VIZ_TABLE_BOX [EM_VIZ_BOX] -- Table to exhibit cell alignment grid_table: EM_VIZ_TABLE_BOX [EM_VIZ_BOX] -- Table to exhibit cell (auto-) sizing feature -- Manufacturing put_color_box (table: EM_VIZ_TABLE_BOX [EM_VIZ_BOX]; c: EM_COLOR; i: EM_VECTOR2I) is -- Add a colored box to a table local cbox: EM_VIZ_COLOR_BOX do create cbox.make ([30, 30, 30], c) table.put (cbox, i) end create_exhibit is -- Create two tables local tbox: EM_VIZ_TEXT_BOX do -- Two columns create_column_layout (2) -- Make table with minimal size (0,0,0) and tree rows and tree columns create align_table.make ( [0.0, 0.0, 0.0], [3,3] ) align_table.set_border_hidden (False) -- Put colored boxes into table put_color_box (align_table, [255, 0, 0], [1,1]) put_color_box (align_table, [255, 0,127], [2,1]) put_color_box (align_table, [255, 0,255], [3,1]) put_color_box (align_table, [127, 0, 0], [1,2]) put_color_box (align_table, [127, 0,127], [2,2]) put_color_box (align_table, [127, 0,255], [3,2]) put_color_box (align_table, [ 0, 0, 0], [1,3]) put_color_box (align_table, [ 0, 0,127], [2,3]) put_color_box (align_table, [ 0, 0,255], [3,3]) -- Set minimal column- and row-sizes -- Also set alignment for each column / row align_table.set_column_alignment (1, Align_left) align_table.set_column_alignment (2, Align_center) align_table.set_column_alignment (3, Align_right) align_table.set_row_alignment (1, Align_top) align_table.set_row_alignment (2, Align_center) align_table.set_row_alignment (3, Align_bottom) animate_align_table (0) -- Put contents into first column put_column_title ("Each row/column can have separate alignment and minimal size.", 1) put_column_content (align_table, 1) -- Make second create grid_table.make ( [100.0, 100.0, 0.0], [8,4] ) -- 4 point, green border grid_table.set_border_width (4) grid_table.set_border_color ([0,255,0]) -- Put text box larger than cell size into grid and see what happens (The cell will be -- resized!) create tbox.make_auto_sized ("Cell%Nfits%Ncontents", Viz_options.text_font_format) grid_table.put (tbox, [6,2]) put_color_box (grid_table, [0,0,63,63], [2,2]) put_color_box (grid_table, [0,0,63,63], [8,4]) animate_grid_table (0) -- Put contents into second column put_column_title ( "Grid table consisting of 8 columns and 4 rows, initial size is evenly distributed. % %Rows and columns are resized as neccessary when content is added.", 2 ) put_column_content (grid_table, 2) exhibit := column_layout end feature -- Animation animate_align_table (a_time: INTEGER) is -- Dynamically resize the columns and rows of the first table local c: DOUBLE do c := 30 * cosine (a_time / 1000.0) align_table.set_column_width (1, 40.0 + c) align_table.set_column_width (2, 40.0 - c) align_table.set_column_width (3, 40.0 + c) align_table.set_row_height (1, 40.0 + c) align_table.set_row_height (2, 40.0 - c) align_table.set_row_height (3, 40.0 + c) end animate_grid_table (a_time: INTEGER) is -- Dynamically resize the whole second table local c: DOUBLE do c := 50 * cosine (a_time / 1000.0) grid_table.set_size ([100.0 + c, 100.0 + c, 0.0]) end go_to_time (a_time: INTEGER) is -- Animate exhibit do animate_align_table (a_time) animate_grid_table (a_time) end end