NB. table grid class
NB. built from project: ~Source\classes\grid\table\table
NB. jtable grid class


coclass 'jtgrid'
require 'jzgrid'
coextend 'jzgrid'

NB. =========================================================
create=: 3 : 0
create_jzgrid_ f. y.
fixeddata=: 0
xprecision=: 0
sizeenable=: 1
)

NB. =========================================================
destroy=: 3 : 0
destroy_jzgrid_ f. y.
)

NB. =========================================================
setdata=: 3 : 0
'r c'=. getreqrc'' NB. rows/cols required by grid
rx=. (<.skipr) + i.r
cx=. (<.skipc) + i.c
if. xprecision do. cx=. x: cx end.
d=. ".'rx ',dataname,' / cx'
NB. d=. ".'(skipr+i.r)',dataname,'/skipc+i.',>xprecision{'c';'x:c'
d=. ":each d
shape=:$d
rows=.0{shape
cols=.1{shape
setgrid 1+shape
setwidths 50,cols$defwidth
setheights 20,rows$defheight
(0, (1+skipc), 1,cols) settext skipc+i.cols
((1+skipr), 0,rows, 1) settext skipr+i.rows
((1+skipr),  (1+skipc),shape) settext d
settype shape$1
)

NB. =========================================================
fixcopy=: 3 : 0
t=. toJ y.
t=. t rplc '"';'""'
t=. '"',t,'"'
)

NB. =========================================================
copy=: 3 : 0
t=. ''
m=. mark-fixr,fixc
ex=. extent
r=. 0{ex
c=. 1{ex
index=. (0{m)+i.0{ex
index=. index ; (1{m)+i.1{ex
t=.'(,>{.index) ',dataname,' /',(xprecision#'x:'),',>}.index'
t=.":each ".t
t=. fixcopy each t
t=. t,each ((r,c-1)$<TAB),.r$<CRLF
t=. ;t
wd'clipcopy *',t
)

