NB. edit graph definition

coclass 'jdplot'

getfontsz=: 13 : '{.1{._1 -.~ _1 ". y.'
setfontsize=: 4 : 0
b=. ~: /\ y.='"'
nam=. b#y.
txt=. ;:(-.b)#y.	
ndx=. 1 i.~ ([: *./ e.&'0123456789.') &> txt
nam, ; ,&' ' &.> (<fmt x.) ndx } txt
)

NB. =========================================================
GEDIT=: 0 : 0
pc gedit;
xywh 82 1 42 12;cc redisplay button leftmove rightmove;cn "&Redisplay";
xywh 124 1 42 12;cc help button leftmove rightmove;cn "&Help";
xywh 166 1 42 12;cc close button leftmove rightmove;cn "&Close";
xywh 0 13 208 100;cc graf editm ws_vscroll rightmove bottommove;
pas 0 0;ptop;
rem form end;
)

NB. =========================================================
NB. argument is name of definition
gedit_run=: 3 : 0
GNAME=: 'D',y.,(0=#y.)#'JGRAPHICS'
if. wdisparent 'gedit' do.
  wd 'psel gedit'
else.
  wd GEDIT
  wd 'setfont graf ',FIXFONT
end.
wd 'set graf *',".GNAME
wd 'setfocus graf'
wd 'pshow;'
)

NB. =========================================================
gedit_close_button=: 3 : 0
GRAF=: graf
GNAME assign graf
wd 'pclose'
)

NB. =========================================================
gedit_close=: gedit_close_button

NB. =========================================================
GEDITHELP=: 0 : 0
To experiment, modify the commands, then Redisplay.

To run a demo by itself, wrap the commands in reset and show. 
In some cases, you need to reference data in locale jdplot.

For example, to run the 2D|Bar demo:

pd 'reset'
)

gedit_help_button=: 3 : 0
wdinfo 'Plot Demo';GEDITHELP,DBAR,'pd ''show'''
)

NB. =========================================================
gedit_redisplay_button=: 3 : 0
GRAF=: graf
try.
  wd 'psel ',PForm
  pd 'reset ',PForm
  plotrun graf
  wd 'psel gedit'
catch.
  wdinfo 'error in graph definition'
  0 return.
end.
1
)

NB. =========================================================
NB. gedit_sctrlshift_fkey
NB. !!! development only
gedit_sctrlshift_fkey=: 3 : 0
grf=. toJ graf
grf=. (+./\. grf ~: LF) # grf
grf=. grf,LF
f=. jpath '~Plotdev\demo\plexam.ijs'
dat=. freads f
sel=. GNAME,'=: 0 : 0',LF
ndx=. (#sel) + 1 i.~ sel E. dat
hdr=. ndx {. dat
dat=. ndx }. dat
ndx=. 1 + 1 i.~ (LF,')',LF) E. dat
mid=. ndx {. dat
ftr=. ndx }. dat
ftr=. ftr, LF -. {:ftr
new=. hdr,grf,ftr
new fwrites f
wdinfo 'Plot';'Saved: ',GNAME
)
