NB. demosel.ijs      - main selection dialog

require 'files gl2 gl3 numeric stats'
require jpath '~system\packages\misc\font.ijs'
coclass 'jdemos'
coextend 'jgl2'
coextend 'jgl3'
COCLASSPATH copath coname''

subs=: I. @(e.&'_')@]}
maketitle=: ' '&subs each @ cutopen ;._2
fexist=: 1:@(1!:4)@boxopen ::0:

TITLES95WIN=: maketitle 0 : 0
cities dcities
controls dcontrols
eigenpictures deigenpic
events devents
isigraph... disigraph
opengl dopengl
opengl_lab_demos... dopengllab
plot dplot
allout dallout
pousse dpousse
regular_expressions dregex
solitaire dsolitaire
socket_server dsockserver
socket_client dsockclient
)

TITLES95JAVA=: maketitle 0 : 0
cities dcities
controls dcontrols
eigenpictures deigenpic
events devents
opengl dopengl
opengl_lab_demos... dopengllab
plot dplot
regular_expressions dregex
solitaire dsolitaire
)

TITLESCE=: maketitle 0 : 0
cities dcities
eigenpictures deigenpic
events devents
paint dpaint
plot dplot
pousse dpousse
)

TITLES=: 3 : 0''
if. IFJAVA do.
  TITLES95JAVA
elseif. IFWINCE do.
   TITLESCE
elseif. do.
  TITLES95WIN
end.
)
   
NB. TITLES=: > (5 6 7 i. 9!:12'') { TITLES95;TITLES95;<TITLESCE

NB. =========================================================
DEMOS=: 0 : 0
pc demos closeok;pn "Demos Select";
xywh 99 24 42 12;cc ok button leftmove rightmove;cn "OK";
xywh 99 41 42 12;cc cancel button leftmove rightmove;cn "Cancel";
xywh 6 22 86 116;cc listbox listbox ws_border ws_vscroll rightmove bottommove;
xywh 7 9 137 11;cc static1 static;cn "static1";
pas 4 2;pcenter;
rem form end;
)

NB. =========================================================
demos_run=: 3 : 0
if. wdisparent 'demos' do.
  wd 'psel demos;pshow;pactive' return.
end.
wd DEMOS
wd 'set static1 *Select a demo from the list below:'
wd 'set listbox ',;EAV,each ({."1 TITLES),each EAV
wd 'setselect listbox 0'
wd 'setfocus listbox'
wd 'pshow;'
)

NB. =========================================================
demos_close=: 3 : 0
wd 'pclose'
)

NB. =========================================================
demos_listbox_button=: 3 : 0
fn=. > {: (".listbox_select) { TITLES
fn~0
)

NB. =========================================================
demos_enter=: demos_ok_button=: demos_listbox_button
demos_cancel_button=: demos_close

NB. =========================================================
dallout=: load bind (jpath '~system\examples\demo\allout.ijs')
dcities=: load bind (jpath '~system\examples\demo\citydemo.ijs')
dcontrols=: load bind (jpath '~system\examples\demo\controls.ijs')
ddialogs=: load bind (jpath '~system\examples\demo\demoall.ijs')
deigenpic=: load bind (jpath '~system\examples\graphics\isigraph\eigenpic.ijs')
devents=: load bind (jpath '~system\examples\demo\events.ijs')
disigraph=: load bind (jpath '~system\examples\graphics\isigraph\isdemo.ijs')
dopengl=: load bind (jpath '~system\examples\graphics\opengl\demo\gldemo.ijs')
dopengllab=: load bind (jpath '~system\examples\graphics\opengl\simple\gldemos.ijs')
dpaint=: load bind (jpath '~system\examples\graphics\isigraph\paint.ijs')
dplot=: load bind (jpath '~system\examples\graphics\plot\plotdemo.ijs')
dpousse=: load bind (jpath '~system\examples\graphics\isigraph\pousse.ijs')
dregex=: load bind (jpath '~system\packages\regex\regdemo.ijs')
dsolitaire=: load bind (jpath '~system\examples\games\solitaire\main.ijs')

NB. =========================================================
deigenpic=: 3 : 0
if. fexist jpath '~addons\lapack\lapack.ijs' do.
  load jpath '~system\examples\graphics\isigraph\eigenpic.ijs'
else.
  wdinfo 'Eigenpicture';'This demo requires the LAPACK AddOn'
end.
)

NB. =========================================================
DDESERVERMSG=: 0 : 0
The server demo creates the DDE server window.

Once it is shown, minimize the J session, load
another copy of J and run the DDE client demo.

Closing the DDE server window also closes J.

Do you wish to continue?
)

dddeserver=: 3 : 0
if. 0=2 wdquery 'Demos';DDESERVERMSG do.
  load jpath '~system\packages\dde\server1.ijs'
end.
)

NB. =========================================================
DDECLIENTMSG=: 0 : 0
The DDE client demo assumes that the DDE
server demo has been loaded.

Use cmd to send commands.

For example, try:
  cmd 'abc=: i.2 3 4'
  cmd 'abc'
  cmd 'i.2 3 4'
  cmd '+/\i.10'

Do you wish to continue?
)

dddeclient=: 3 : 0
if. 0=2 wdquery 'Demos';DDECLIENTMSG do.
  load jpath '~system\examples\dde\client1.ijs'
end.
)

NB. =========================================================
SOCKSERVERMSG=: 0 : 0
The socket demos assume you have access to
sockets on your machine.

The server demo creates the socket server window.

Once it is shown, minimize the J session, load
another copy of J and run the socket client demo.

Closing the socket server window also closes J.

Do you wish to continue?
)

dsockserver=: 3 : 0
if. 0=2 wdquery 'Demos';SOCKSERVERMSG do.
  wd 'psel demos;pclose'
  load jpath '~system\examples\socket\servfnsw.ijs'
end.
)

NB. =========================================================
SOCKCLIENTMSG=: 0 : 0
The socket demos assume you have access to
sockets on your machine; and that the socket
server demo has been loaded.

This client demo creates the following verbs:

  sockcmd   send J sentence, return result
  sockdo    send J sentence to be executed
  sockget   get value of J name
  sockset   set value to J name

For example, try:
  sockcmd 'abc=: i.2 3 4'
  sockget 'abc'

Do you wish to continue?
)

dsockclient=: 3 : 0
if. 0=2 wdquery 'Demos';SOCKCLIENTMSG do.
  wd 'psel demos;pclose'
  load jpath '~system\examples\socket\clifns.ijs'
end.
)

demos_run''
