NB. built from project: ~Source\classes\browse\browse
NB. browse


require '~system\packages\misc\guid.ijs'

coclass 'jbrowse'

NB. Browser class
NB.
NB. Simple J form including a single IE browser control.
NB.
NB.
NB. Methods:
NB.
NB.   create contents[;title[;move[;center]]]
NB.     Create browse object and form.
NB.       contents - 'url'  or  <'contents'
NB.       title - 'form title'; '' is default ("Browser')
NB.       move - argument to pmove
NB.       center - 0/1 whether to center the form; '' is default (0)
NB.       top - 0/1 whether to keep form on top; '' is default (0)
NB.
NB.   destroy ask
NB.     Destroy browse object and form.
NB.       ask - 0/1 whether to call CLOSE verb; '' is default (0)
NB.
NB.   navigate contents[;title[;move[;center]]]
NB.     Navigate IE control to new contents.
NB.       Arguments the same as create, except the defaults for
NB.       the arguments are the same as the existing form.
NB.



BROWSERTEMPLATE=: 0 : 0
pc browse;pn "Browse";
xywh 0 0 286 190;cc browse ocx:Shell.Explorer.2 rightmove bottommove;
pas 0 0;
rem form end;
)


NB.
create=: 3 : 0
wd BROWSERTEMPLATE
formhwnd=: wd'qhwndp'
NB. initialize form here
CLOSE=: 1:
TMPFILE=: ''
navigate y.
wd'pshow'
)


destroy=: 3 : 0
close=. 1
if. {.y.,0 do. close=. CLOSE '' end.
if. close do.
	wd 'pclose'
	clear_temp ''
	codestroy ''
end.
)


navigate=: verb define
'contents title move center top'=. 5{. <^:((0: = L.)+.0: = #@$) y.

clear_temp ''
if. 1=L. contents do.
	(>contents) 1!:2 tmp=. <TMPFILE=: jpath '~temp\BRtmp-',(guidsn $0),'.html'
	contents=. TMPFILE
end.

if. *#contents do. wd 'olemethod browse base navigate2 *',contents end.
if. *#title do. wd 'pn *',title end.
if. *#move do. wd 'pmove ',":move end.
if. {.center,0 do. wd 'pcenter' end.
if. #top do. wd 'ptop ',":{.top,0 end.
)


clear_temp=: verb define
if. *#TMPFILE do. TMPFILE=: '' [ 1!:55<TMPFILE end.
)


browse_close=: destroy bind 1

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


