[REBOL] Re: [glayout]
From: greggirwin:mindspring at: 6-Jul-2004 23:12
Hi Ashley,
AT> I'm currently using VID to scroll a 1,000,000 row query result table ...
AT> it takes about 90 seconds to format and display the data [in a text-list]
AT> ... I'm curious to see how glayout performs. ;)
How much memory does it use (morbid curiosity :)?
I did a proof-of-concept thing a while back that used dynamically
generated draw commands to display virtual grid/tree data. The grid
version is below; watch for wrap.
-- Gregg
REBOL [
Title: "Draw Data Grid"
File: %draw-data-grid.r
Author: "Gregg Irwin"
Purpose: {Shows how you can dynamically create DRAW commands in response
to slider events to display data in a virtual grid.}
]
cell-size: 120x21
map-slider-to-value: func [
"Converts a slider value between 0 and 1 to a value within a range."
value [number!] "A value between 0 and 1."
min-val [number!] "The minimum range value (if value = 0)."
max-val [number!] "The maximum range value (if value = 1)."
][
max-val - min-val * value + min-val
]
display-data: does [
v-base-val: map-slider-to-value v-sld/data 1 10000
h-base-val: map-slider-to-value h-sld/data 1 3000
clear head draw-cmds
append draw-cmds [pen black]
repeat row to-integer divide grd/size/y cell-size/y [
;append draw-cmds compose [pen (random 255.255.255)] ; random row coloring
;append draw-cmds compose [pen (pick [64.64.64 64.128.32] odd? row)]
repeat col to-integer divide grd/size/x cell-size/x [
append draw-cmds compose [
pen (random 200.200.200) ; random data coloring
text
(to-pair reduce [
col - 1 * cell-size/x + 2
row - 1 * cell-size/y + 2
])
(rejoin [
"R"
to-integer (row - 1 + v-base-val)
":C"
to-integer (col - 1 + h-base-val)
])
]
]
]
show grd
]
lay: layout [
across
space 1x1
grd: box 361x358 effect compose [grid (cell-size) 0x0 1x1 draw []]
;grd: box 722x716 effect compose [grid (cell-size) 0x0 1x1 draw []]
v-sld: slider 15x358 [display-data]
return
h-sld: slider 361x15 [display-data]
]
draw-cmds: grd/effect/draw
display-data
view lay