NB. edit graph definition

cocurrent 'jgldemo'

GLEDFONTSZ=: ''
GLEDTEXT=: ''

GLEDIT=: 0 : 0
pc gledit;
xywh 0 0 17 10;cc minus button;cn "&<<";
xywh 16 0 17 10;cc plus button;cn "&>>";
xywh 131 0 34 10;cc redisplay button leftmove rightmove;cn "&Redisplay";
xywh 165 0 34 10;cc cancel button leftmove rightmove;cn "&Cancel";
xywh 0 10 200 100;cc graf editm ws_vscroll rightmove bottommove;
pas 0 0;
rem form end;
)

NB. argument is definition
gledit_run=: 3 : 0
GLFONTDEF=: PROFONT
if. 0=#GLEDFONTSZ do.
  GLEDFONT=: FIXFONT
  GLEDFONTSZ=: getfontsize GLEDFONT
end.
if. wdisparent 'gledit' do.
  wd 'psel gledit'
else.
  wd GLEDIT
  wd 'setfont minus ',GLFONTDEF
  wd 'setfont plus ',GLFONTDEF
  wd 'setfont redisplay ',GLFONTDEF
  wd 'setfont cancel ',GLFONTDEF
  wd 'setfont graf ',GLEDFONT
end.
wd 'set graf *',y.
wd 'setfocus graf'
wd 'pshow;'
)

gledit_cancel_button=: 3 : 0
GLEDTEXT=: graf
wd 'pclose'
wd :: ] 'psel opengl'
)

gledit_close=: gledit_cancel_button

gledit_redisplay_button=: 3 : 0
GLEDTEXT=: graf
if. 0=wdisparent 'opengl' do.
  wdinfo 'Cannot redisplay - OpenGL graphics window has been closed'
  return.
end.
try.
  wd 'psel opengl'
  opengl_run1 graf
  GLDEMODAT=: graf
  wd 'psel gledit'
catch.
  err=. LF,,LF,.}.;._2 [ 13!:12''
  wdinfo 'error in OpenGL definition:',err
  0 return.
end.
1
)

gledit_minus_button=: 3 : 0
1 >. GLEDFONTSZ=: <:GLEDFONTSZ
GLEDFONT=: GLEDFONTSZ setfontsize GLEDFONT
wd 'setfont graf ',":GLEDFONT
)

gledit_plus_button=: 3 : 0
GLEDFONTSZ=: >:GLEDFONTSZ
GLEDFONT=: GLEDFONTSZ setfontsize GLEDFONT
wd 'setfont graf ',":GLEDFONT
)

gledit_rctrl_fkey=: 3 : 0
if. 0=2 wdquery 'gledit';'OK to recover definition?' do.
  wd 'set graf *',freads tolower GLDEMOPATH,GLDEMOSEL,'.ijs'
end.
)

gledit_sctrl_fkey=: 3 : 0
if. 0=2 wdquery 'gledit';'OK to save definition?' do.
  graf fwrites tolower GLDEMOPATH,GLDEMOSEL,'.ijs'
end.
)
