NB. watch grid class
NB. built from project: ~Source\classes\grid\watch\watch
NB. watch form

script_z_ '~system\main\convert.ijs'
script_z_ '~system\main\strings.ijs'


coclass 'jwatch'
require 'jinput'
require 'jwgrid'

WATCH=: 0 : 0
pc watch;pn "Watch";
xywh 0 0 175 150;cc grid isigraph ws_border ws_clipchildren rightmove bottommove;
xywh 0 150 175 9;cc scrollbar scrollbar topmove rightmove bottommove;
xywh 175 0 9 150;cc scrollbarv scrollbarv leftmove rightmove bottommove;
pas 0 0;pcenter;
rem form end;
)

NB. =========================================================
create=: 3 : 0
n=.y.,('_'~:{:y.)#'_base_'
if. 0~:4!:0 <n do. wdinfo 'Invalid name: ',y. return. end.
wd WATCH
wdfit ''
formhwnd=: wd'qhwndp'
wd'pn *Watch - ',y.
grid=: ''conew'jwgrid'
sizeenable__grid=: 1
init__grid n;'grid';'scrollbar';'scrollbarv'
wd'setfocus grid'
wd 'pshow;'
)

NB. =========================================================
destroy=: 3 : 0
wd'pclose'
destroy__grid''
codestroy''
)

NB. =========================================================
watch_close=: destroy

NB. =========================================================
formselect=: 3 : 'wd''psel '',formhwnd'

NB. =========================================================
watch_grid_size=:    3 : 'size__grid 0'
watch_grid_mbldown=: 3 : 'mbldown__grid sysdata'
watch_grid_mmove=:   3 : 'mmove__grid sysdata'
watch_grid_mblup=:   3 : 'mblup__grid sysdata'
watch_grid_mbldbl=:  3 : 'mbldbl__grid sysdata'
watch_grid_char=:    3 : 'char__grid sysdata;sysmodifiers'
watch_grid_copy=:    3 : 'copy__grid 0'
watch_grid_paste=:   3 : 'paste__grid 0'

NB. =========================================================
watch_scrollbar_button=: 3 : 0
scrollbar__grid scrollbar
wd'setfocus grid'
)

NB. =========================================================
watch_scrollbarv_button=: 3 : 0
scrollbarv__grid scrollbarv
wd'setfocus grid'
)

NB. =========================================================
watch_f1_fkey=: 3 : 0
wd 'mb "Watch Help" *',actiondoc__grid,'ctrl+m - highlight expression'
)

NB. =========================================================
watch_fctrl_fkey=: 3 : 0
f=. wd'mbfont ',font0__grid
if.''-:f do. return. end.
gridselect__grid''
setfont0__grid f
setheights__grid ''
paintx__grid''
gridfocus__grid''
)

NB. =========================================================
watch_ectrl_fkey=: 3 : 0
editenable__grid=: -.editenable__grid
)

NB. =========================================================
NB. set borders
watch_bctrl_fkey=: 3 : 0
border_run__grid''
)

NB. =========================================================
watch_mctrl_fkey=: 3 : 0
input=. conew 'jinput'
j=. 'Expression to highlight data (e.g. 0=23|y.):'
create__input j;highlight__grid
)

NB. =========================================================
NB. jinput callback
input_result=: 3 : 0
sethighlight__grid y.
glpaintx__grid''
)

