home *** CD-ROM | disk | FTP | other *** search
/ Millennium Time Capsule / AC2000.BIN / disks / hbasic_1 / prgflags / prgflags.bas < prev   
BASIC Source File  |  1997-09-22  |  16KB  |  599 lines

  1. WINDOW OFF
  2. REM $option y+,q300
  3. LIBRARY "GEMAES","GEMVDI","GEMDOS","BIOS","XBIOS","MINT"
  4. DEFINT a-z
  5. REM check if OS understands iconify and tell it I understand ap_term
  6. IF &H400<=PEEKW(PEEKL(GB+4)) THEN j=appl_getinfo(11,windflag,0,0,0) : j=shel_write(9,1,0,0,0)
  7.  
  8.  
  9. REM check if run from an auto folder...
  10. IF PEEKW(PEEKL(GB+4))=0 THEN CCONWS "PRGFLAGS needs GEM to run Properly!" : SYSTEM
  11.  
  12.  
  13. REM $include prgflag3.bh
  14. REM $include gemaes.bh
  15. DIM mess(7) : REM message space
  16.  
  17.  
  18. REM this section is for 65535 windows
  19.  
  20. REM $dynamic
  21. REM handle_handlers
  22.  
  23. REM current GEM allows 15 windows
  24.  
  25. DIM windnum(15),wtype(15),w_ob(15),wedit(15)
  26.  
  27. REM if type=1 then wedit=current field edit index w_ob=current edit field
  28.  
  29. REM if type=0 then windnum=2 for open,1=created/closed, 0=deleted/notmine
  30. REM window type, 0=ordinary, 1=form
  31. REM if type=1 then windnum=tree number for form window
  32. REM if type=2 alliconified form : windnum=tree number
  33.  
  34. REM $static
  35.  
  36.  
  37. REM declare functions
  38. DECLARE SUB do_message(BYVAL mes_type)
  39. DECLARE FUNCTION dialog(BYVAL tree,BYVAL num)
  40. DECLARE FUNCTION newform_alert(BYVAL button,BYVAL num)
  41. DECLARE FUNCTION form_window(BYVAL tree,BYVAL title,BYVAL myco)
  42.  
  43. REM window buttons are...
  44. myco=win_name+win_close+win_move+&H4000
  45.  
  46.  
  47.  
  48. REM load RSC file based on cookie
  49. IF GETCOOKIE("_AKP",j&)=0 THEN j&=3: ELSE j&=j& AND &HFFFF
  50. retry:
  51. g$="PRGFLAGS"
  52. rn$=STR$(j&) : rn$=RIGHT$(rn$,LEN(rn$)-1) : IF LEN(rn$)<8 THEN rn$=LEFT$(g$,8-LEN(rn$))+rn$ 
  53. rn$=rn$+".RSC"
  54. r=rsrc_load(rn$)
  55. IF r=0 AND j&=3 THEN j=form_alert(1,"[3]["+rn$+"][OK]") : SYSTEM
  56. IF r=0 AND j&<>3 THEN j&=3 : GOTO retry:
  57. rn$="" : g$=""
  58.  
  59.  
  60.  
  61. j=rsrc_gaddr(0,MENU,menu&)
  62. mnu=1 : menu_bar menu&,1 : REM put menu bar
  63.  
  64. REM ### If Multitasking present, register menu bar ######################11111222223333344444####
  65. IF PEEKW(PEEKL(GB+4)+2)=-1 THEN mpos=menu_register(PEEKW(PEEKL(GB+4)+4),"  Prgflags setter   ")
  66.  
  67.  
  68.  
  69. REM main message loop
  70. main:
  71. e=evnt_multi(mu_mesag+mu_button+mu_keybd,258,3,0,0,0,0,0,0,0,0,0,0,0,VARPTR(mess(0)),time&,xa,ya,buttona,kstate,k,br)
  72. IF e AND mu_mesag THEN do_message mess(0) : ' deal with a message
  73. IF e AND mu_button AND buttona>0 THEN do_mouse xa,ya,buttona : ' deal with a click
  74. IF e AND mu_keybd THEN do_keybd k
  75. GOTO main:
  76.  
  77.  
  78. endprog:
  79. REM close windows
  80. FOR CW=1 TO UBOUND(windnum)
  81. IF wtype(CW)=0 THEN
  82.     IF windnum(CW)=2 THEN j=wind_close(CW) : windnum(CW)=1
  83.     IF windnum(CW)=1 THEN j=wind_delete(CW) : windnum(CW)=0
  84. END IF
  85.  
  86. IF wtype(CW)=1 THEN
  87.     j=wind_close(CW) : j=wind_delete(CW)
  88.     wtype(CW)=0 : wind_num(CW)=0
  89. END IF
  90.  
  91. IF wtype(CW)=2 THEN
  92.     j=wind_delete(CW)
  93.     wtype(CW)=0 : windnum(CW)=0
  94. END IF
  95. NEXT CW
  96.  
  97. IF PEEKW(PEEKL(GB+4)+2)=-1 THEN j=menu_unregister(mpos)
  98. IF mnu=1 THEN menu_bar menu&,0
  99. r=rsrc_free
  100. SYSTEM
  101.  
  102.  
  103.  
  104. SUB do_message(BYVAL mes_type) STATIC
  105.  
  106. LOCAL pip,f,cc$,m&,j,title,item,tree&,tt,ii,m
  107. LOCAL xre,yre,wre,hre
  108. LOCAL x_in,y_in,w_in,h_in
  109. LOCAL x,y,w,h,x2,y2,w2,h2
  110.  
  111. SHARED mess(0),menu&,windnum(0),wtype(0),myco,windflag,allicons
  112.  
  113.  
  114.  
  115.  
  116.  
  117. SELECT CASE mes_type
  118.  
  119.     CASE ap_dragdrop
  120.     REM IS NOT currently used by this program, still
  121.     REM is good programming practise to reject rather
  122.     REM than ignore requests
  123.     pip=fopen("U:\PIPE\DRAGDROP."+CHR$(PEEKB(VARPTR(mess(7))))+CHR$(PEEKB(VARPTR(mess(7))+1)),2)
  124.     IF pip<0 THEN f=form_error(ABS(pip)-31) : GOTO mm:
  125.     cc$=CHR$(1)
  126.     m&=fwrite&(pip,1&,VARPTR(cc$))
  127.     mm:
  128.     IF pip>-1 THEN j=fclose(pip)
  129.     CASE 50 : REM ap_term
  130.  
  131.     IF mess(4)=50 THEN GOTO endprog:
  132.  
  133.  
  134.  
  135.     CASE mn_selected 
  136.     title=mess(3)
  137.     item=mess(4)
  138.     menu_tnormal menu&,title,1
  139.     IF title=desk AND item=prgflags THEN
  140.         REM check if ABOUT window is already open
  141.  
  142.         FOR j=0 TO UBOUND(windnum)
  143.         IF windnum(j)=ABOUT AND wtype(j)=1 THEN EXIT IF : REM can't have more than one about open!
  144.         NEXT j
  145.  
  146.         REM try to open about's window
  147.         j=form_window(ABOUT,ABOUT_T,MYCO)
  148.         REM could not open
  149.         IF j<0 THEN j=rsrc_gaddr(5,WINDOWERROR,tree&) : j=newform_alert(1,tree&) : EXIT IF
  150.  
  151.         REM increase array size if needed
  152.         IF j>UBOUND(windnum) THEN REDIM PRESERVE windnum(j)
  153.         IF j>UBOUND(wtype) THEN REDIM PRESERVE wtype(j)
  154.         REM ...and insert this window entry
  155.         wtype(j)=1 : REM its a formwindow!!
  156.         windnum(j)=ABOUT : REM rsrc_gaddr!
  157.  
  158.     END IF
  159.  
  160.     REM if quit pressed then exit...
  161.     IF title=file AND item=quit THEN GOTO endprog:
  162.  
  163.     CASE wm_redraw
  164.  
  165.     IF wtype(mess(3))<>0 THEN GOTO skipreal:
  166.     j=wind_get(mess(3),wf_firstxywh,xre,yre,wre,hre)
  167.     DO
  168.     IF wre=0 AND hre=0 THEN EXIT LOOP
  169.     j=objc_draw(tree&,0,4,xre,yre,wre,hre)
  170.     j=wind_get(mess(3),wf_nextxywh,xre,yre,wre,hre)
  171.     LOOP
  172.  
  173.     graf_mouse 256,0
  174.     'vs_clip 1,mess(4),mess(5),mess(6),mess(7)
  175.     j=wind_get(mess(3),wf_firstxywh,xre,yre,wre,hre)
  176.     DO
  177.     IF wre=0 AND hre=0 THEN EXIT LOOP
  178.     j=wind_update(1)
  179.     REM update
  180.     j=wind_update(0)
  181.     j=wind_get(mess(3),wf_nextxywh,xre,yre,wre,hre)
  182.     LOOP
  183.     graf_mouse 257,0
  184.  
  185.     skipreal:
  186.  
  187.  
  188.     REM redraw formdialog
  189.     IF wtype(mess(3))<>1 THEN skipform:
  190.     REM is it iconified?
  191.     ii=0
  192.     IF &H410<=PEEKW(PEEKL(GB+4)) AND (windflag AND &B10000000) THEN j=wind_get(mess(3),26,ii,w,h,0)
  193.  
  194.  
  195.  
  196.     IF ii=0 THEN j=rsrc_gaddr(0,windnum(mess(3)),tree&)
  197.     IF ii<>0 THEN j=rsrc_gaddr(0,ICONIFIED,tree&)
  198.  
  199.     j=wind_get(mess(3),wf_firstxywh,xre,yre,wre,hre)
  200.     DO
  201.     IF wre=0 AND hre=0 THEN EXIT LOOP
  202.     j=objc_draw(tree&,0,4,xre,yre,wre,hre)
  203.     j=wind_get(mess(3),wf_nextxywh,xre,yre,wre,hre)
  204.     LOOP
  205.  
  206.     skipform:
  207.  
  208.      CASE 34 : REM wm_iconify
  209.     IF &H410<=PEEKW(PEEKL(GB+4)) AND (windflag AND &B10000000) THEN
  210.  
  211.         j=rsrc_gaddr(0,ICONIFIED,tree&)
  212.         j=wind_get(mess(3),wf_currxywh,x,y,w,h)
  213.         j=wind_calc(1,win_name,mess(4),mess(5),mess(6),mess(7),x_in,y_in,w_in,h_in)
  214.  
  215.         graf_shrinkbox mess(4),mess(5),mess(6),mess(7),x,y,w,h
  216.  
  217.         POKEW tree&+ob_sizeof*0+ob_x,x_in : REM set form to new value
  218.         POKEW tree&+ob_sizeof*0+ob_y,y_in : REM set form to new value
  219.         POKEW tree&+ob_sizeof*0+ob_width,w_in
  220.         POKEW tree&+ob_sizeof*0+ob_height,h_in
  221.         j=wind_set(mess(3),26,mess(4),mess(5),mess(6),mess(7))
  222.     END IF
  223.  
  224.     CASE 35 : REM wm_uniconify
  225.  
  226.  
  227.     IF &H410<=PEEKW(PEEKL(GB+4)) AND (windflag AND &B100000000) THEN
  228.         j=wind_get(mess(3),wf_currxywh,x,y,w,h)
  229.         graf_growbox x,y,w,h,mess(4),mess(5),mess(6),mess(7)
  230.         j=wind_set(mess(3),27,mess(4),mess(5),mess(6),mess(7))
  231.     END IF 
  232.  
  233.     CASE 36 : REM wm_alliconify
  234.  
  235.  
  236.     REM if alliconify icon not already on screen/ create it
  237.  
  238.     IF allicons>0 THEN GOTO removewindowsonly: 
  239.     j=wind_get(0,wf_workxywh,x,y,w,h)
  240.     m=wind_create(win_name+win_move,x,y,w,h) 
  241.     IF m<0 THEN j=rsrc_gaddr(5,WINDOWERROR,tree&) : j=newform_alert(1,tree&) : GOTO cantalliconify:
  242.         
  243.     IF NOT((&H410<=PEEKW(PEEKL(GB+4))) AND (windflag AND &B10000000)) THEN
  244.         j=wind_delete(m): BEEP
  245.         GOTO cantalliconify:
  246.     END IF
  247.             
  248.     j=wind_set(m,26,mess(4),mess(5),mess(6),mess(7))
  249.     j=rsrc_gaddr(5,ALLICON_T,tree&)
  250.     j=wind_set(m,wf_name,PEEKW(VARPTR(tree&)),PEEKW(VARPTR(tree&)),0,0)
  251.     j=wind_open(m,mess(4),mess(5),mess(6),mess(7)) 
  252.  
  253.     allicons=m
  254.  
  255.     removewindowsonly:
  256.     REM close all other windows
  257.  
  258.     FOR tt=1 TO UBOUND(windnum)
  259.     REM if it's real and open then
  260.     IF wtype(tt)=0 AND windnum(tt)=2 THEN
  261.         j=wind_close(tt)
  262.         windnum(tt)=1
  263.         REM close it
  264.     END IF
  265.  
  266.     REM if it's a formwindow/ close it.
  267.     IF wtype(tt)=1 THEN wtype(tt)=2 : j=wind_close(tt)
  268.     NEXT tt
  269.  
  270.     cantalliconify:
  271.     CASE wm_sized,wm_moved
  272.     REM formwindows need this, real ones don't
  273.     IF wtype(mess(3))<>1 THEN GOTO skipformmoved:
  274.  
  275.     ii=0
  276.     IF &H410<=PEEKW(PEEKL(GB+4)) AND (windflag AND &B10000000) THEN j=wind_get(mess(3),26,ii,0,0,0)
  277.  
  278.     IF ii=0 THEN j=rsrc_gaddr(0,windnum(mess(3)),tree&)
  279.     IF ii<>0 THEN j=rsrc_gaddr(0,ICONIFIED,tree&)
  280.  
  281.     IF ii=0 THEN j=wind_calc(1,myco,mess(4),mess(5),mess(6),mess(7),x_in,y_in,w_in,h_in)
  282.     IF ii<>0 THEN j=wind_calc(1,win_name,mess(4),mess(5),mess(6),mess(7),x_in,y_in,w_in,h_in)
  283.  
  284.     POKEW tree&+ob_sizeof*0+ob_x,x_in : REM set form to new value
  285.     POKEW tree&+ob_sizeof*0+ob_y,y_in : REM set form to new value
  286.     POKEW tree&+ob_sizeof*0+ob_width,w_in
  287.     POKEW tree&+ob_sizeof*0+ob_height,h_in
  288.  
  289.  
  290.     skipformmoved:
  291.     j=wind_set(mess(3),wf_currxywh,mess(4),mess(5),mess(6),mess(7))
  292.  
  293.  
  294.  
  295.  
  296.     CASE wm_fulled
  297.     j=wind_get(mess(3),wf_currxywh,x,y,w,h)
  298.     j=wind_get(mess(3),wf_fullxywh,x2,y2,w2,h2)
  299.     IF x=x2 AND y=y2 AND w=w2 AND h=h2 THEN
  300.         j=wind_get(mess(3),wf_prevxywh,x2,y2,w2,h2)
  301.     END IF
  302.     j=wind_set(mess(3),wf_currxywh,x2,y2,w2,h2)
  303.  
  304.     CASE wm_closed
  305.     j=wind_close(mess(3)) 
  306.     j=wind_delete(mess(3))
  307.     windnum(mess(3))=0
  308.     wtype(mess(3))=0
  309.  
  310.     CASE wm_topped
  311.     j=wind_set(mess(3),wf_top,tt,0,0,0)
  312.  
  313. END SELECT
  314. END SUB
  315.  
  316.  
  317. SUB do_keybd(BYVAL k)
  318. LOCAL j,ky,tw,state,x,y,w,h,n,kx,tree&,flags,index,stay
  319. SHARED mess(0),wtype(0),windnum(0),w_ob(0),wedit(0)
  320.  
  321.  
  322. REM split key into ASCII and scancode
  323. KY=k AND 255
  324. kx=(k AND &HFF00)/&H100
  325.  
  326. REM find the topped window
  327. j=wind_get(0,wf_top,tw,0,0,0)
  328.  
  329. REM is it my window?
  330. IF tw>UBOUND(wtype) THEN EXIT SUB
  331.  
  332. REM is it a formwindow?
  333. IF wtype(tw)<>1 THEN GOTO skipedit:
  334.  
  335. REM any f(box)text's? : w_ob contains the objectnumber of the object being edited
  336. IF w_ob(tw)=-1 THEN GOTO skipedit:
  337.  
  338. REM Get formwindow tree address
  339. j=rsrc_gaddr(0,windnum(tw),tree&)
  340.  
  341. REM and get the position of the cursor in the f(box)text
  342.  
  343. index=wedit(tw) : REM wedit contains the position of the cursor in the object currently being edited
  344.  
  345. REM process f(box)text with new character
  346. j=objc_edit(tree&,w_ob(tw),k,index,2)
  347.  
  348. stay=index-wedit(tw)
  349. wedit(tw)=index
  350.  
  351. skipedit:
  352.  
  353.  
  354. REM process default buttons in formdialogs
  355.  
  356. IF (ky<>13) OR (wtype(tw)<>1) OR stay<>0 THEN GOTO skipdefault:
  357.  
  358. REM get form address
  359. j=rsrc_gaddr(0,windnum(tw),tree&)
  360.  
  361. REM search for a default object
  362.  
  363. n=0
  364. again:
  365. flags=PEEKW(tree&+ob_sizeof*n+ob_flags)
  366. REM found one
  367. IF flags AND mask_default THEN GOTO do_it:
  368. REM none found
  369. IF flags AND mask_lastob THEN GOTO skipdefault:
  370. INCR n : GOTO again:
  371.  
  372.  
  373. REM Animate and activate default button
  374. do_it:
  375. state=PEEKW(tree&+ob_sizeof*n+ob_state) AND &HFFFE
  376. x=PEEKW(tree&+ob_sizeof*0+ob_x)
  377. y=PEEKW(tree&+ob_sizeof*0+ob_y)
  378. w=PEEKW(tree&+ob_sizeof*0+ob_width)
  379. h=PEEKW(tree&+ob_sizeof*0+ob_height)
  380.     
  381.  
  382. j=objc_change(tree&,n,x,y,w,h,state+mask_selected,1)
  383. mess(3)=tw : mess(0)=wm_closed : appl_write PEEKW(PEEKL(GB+4)+4),16,VARPTR(mess(0))
  384. j=objc_change(tree&,n,x,y,w,h,state+mask_normal,0)
  385. skipdefault:
  386.  
  387. END SUB
  388.  
  389.  
  390.  
  391. REM standard dialog box routine
  392.  
  393. FUNCTION dialog(BYVAL tree,BYVAL num)
  394. LOCAL tree&,j,x1,y1,w1,h1,x,y,w,h
  395. w1=10 : h1=10
  396.  
  397. graf_mkstate x1,y1,0,0
  398. j=rsrc_gaddr(0,tree,tree&) 
  399. form_center tree&,x,y,w,h
  400. form_dial 1,x1,y1,w1,h1,x,y,w,h
  401. form_dial 0,x1,y1,w1,h1,x,y,w,h
  402. j=objc_draw(tree&,0,10,x,y,w,h)
  403. dialog=form_do(tree&,num)
  404. form_dial 3,x1,y1,w1,h1,x,y,w,h
  405. form_dial 2,x1,y1,w1,h1,x,y,w,h
  406. END FUNCTION
  407.  
  408.  
  409. SUB do_mouse(x,y,b)
  410. LOCAL x,y,w,h,b,ob,h,j,tree&,flags,obfind,nxt,prv,parent,obj,state,jj,oldstate,ii
  411. SHARED wtype(0),windnum(0),mess(0),windflag
  412.  
  413. REM Find the window the user clicked upon
  414.  
  415. h=wind_find(x,y)
  416. REM h=window id or 0 if the desktop was clicked
  417.  
  418. IF h>UBOUND(wtype) THEN EXIT SUB : REM It's not my window
  419.  
  420. REM this routine is currently only for formwindow buttons
  421. IF wtype(h)<>1 THEN EXIT SUB: REM currently only formwindows!
  422.  
  423. REM is it iconified?
  424.  
  425. ii=0
  426. IF &H410<=PEEKW(PEEKL(GB+4)) AND (windflag AND &B10000000) THEN j=wind_get(mess(3),26,ii,0,0,0)
  427.  
  428.  
  429.  
  430.  
  431. REM get address of form
  432. IF ii=0 THEN j=rsrc_gaddr(0,windnum(h),tree&)
  433. IF ii<>0 THEN j=rsrc_gaddr(0,ICONIFIED,tree&)
  434.  
  435. REM and find the object in the formwindow that is being clicked
  436.  
  437. ob=objc_find(tree&,0,10,x,y)
  438. REM oops, that was not an object
  439. IF ob<0 THEN EXIT SUB
  440.  
  441. REM get the flags of the clicked object, so we know what to do.
  442.  
  443. flags=PEEKW(tree&+ob*ob_sizeof+ob_flags)
  444. oldstate=PEEKW(tree&+ob*ob_sizeof+ob_state)
  445.  
  446.  
  447. REM if it's a touchexit the form closes immediately
  448.  
  449. IF flags AND mask_touchexit THEN mess(3)=h : mess(0)=wm_closed : appl_write PEEKW(PEEKL(GB+4)+4),16,VARPTR(mess(0))
  450. IF (flags AND mask_selectable)=0 THEN EXIT SUB
  451.  
  452. REM Process radiobuttons
  453. IF (flags AND mask_rbutton)=0 THEN GOTO skipradio:
  454. REM Find parent of this object
  455.  
  456.  
  457. obfind=ob
  458.     
  459. findparentagain:
  460. nxt=PEEKW(tree&+ob_sizeof*obfind+ob_next)
  461. prv=PEEKW(tree&+ob_sizeof*nxt+ob_tail)
  462.  
  463. IF nxt=-1 THEN EXIT SUB
  464. IF obfind<>prv THEN obfind=nxt : GOTO findparentagain:
  465. REM found the parent, now select the object and deselect other radios.
  466.  
  467. parent=nxt
  468.  
  469. obj=PEEKW(tree&+ob_sizeof*parent+ob_head)
  470.  
  471. nxtunsel:
  472.  
  473. IF (PEEKW(tree&+obj*ob_sizeof+ob_flags) AND mask_rbutton) AND obj<>ob THEN
  474.     x=PEEKW(tree&+ob_sizeof*0+ob_x)
  475.     y=PEEKW(tree&+ob_sizeof*0+ob_y)
  476.     w=PEEKW(tree&+ob_sizeof*0+ob_width)
  477.     h=PEEKW(tree&+ob_sizeof*0+ob_height)
  478.     j=objc_change(tree&,obj,x,y,w,h,PEEKW(tree&+obj*ob_sizeof+ob_state) AND &HFFFE,1) : REM unselect objects
  479. END IF
  480.  
  481. IF obj<>PEEKW(tree&+ob_sizeof*parent+ob_tail) THEN : obj=PEEKW(tree&+ob_sizeof*obj+ob_next) : GOTO nxtunsel:
  482.  
  483.  
  484. x=PEEKW(tree&+ob_sizeof*0+ob_x)
  485. y=PEEKW(tree&+ob_sizeof*0+ob_y)
  486. w=PEEKW(tree&+ob_sizeof*0+ob_width)
  487. h=PEEKW(tree&+ob_sizeof*0+ob_height)
  488. j=objc_change(tree&,ob,x,y,w,h,(PEEKW(tree&+obj*ob_sizeof+ob_state) AND &HFFFE)+mask_selected,1) : REM select pressed radio object
  489.  
  490. EXIT SUB
  491. skipradio:
  492.  
  493.  
  494. state=PEEKW(tree&+ob_sizeof*ob+ob_state) AND &HFFFE
  495.  
  496.  
  497. IF oldstate AND mask_selected THEN
  498. jj=graf_watchbox(tree&,ob,state+mask_normal,state+mask_selected)
  499. ELSE
  500. jj=graf_watchbox(tree&,ob,state+mask_selected,state+mask_normal)
  501. END IF
  502.  
  503.  
  504.  
  505. IF (jj=1) AND ((flags AND mask_exit)<>0) THEN
  506.     mess(3)=h : mess(0)=wm_closed : appl_write PEEKW(PEEKL(GB+4)+4),16,VARPTR(mess(0))
  507.     j=objc_change(tree&,ob,x,y,w,h,state+mask_normal,0)
  508. END IF
  509.  
  510.  
  511.  
  512.  
  513. END SUB
  514.  
  515.  
  516.  
  517.  
  518.  
  519. REM a function to open a formwindow
  520.  
  521. FUNCTION form_window(BYVAL tree,BYVAL title,BYVAL myco)
  522. STATIC mm,j,tree,tree&,x_in,y_in,w_in,h_in,myco,handle
  523. STATIC XSM,YSM,WSM,HSM,xab,yab,wab,hab,title,attl&,MX,MY,MW,MH
  524. LOCAL alert&,edit,n,flags,k
  525. SHARED index,newindex,w_ob(0),wedit(0)
  526.  
  527.  
  528. j=wind_get(0,wf_workxywh,MX,MY,MW,MH) : REM get screen work area (excludes menu bar)
  529.  
  530. WSM=10 : HSM=10
  531. graf_mkstate xsm,ysm,0,0
  532.  
  533. mm=rsrc_gaddr(0,tree,tree&)
  534.  
  535. x_in=PEEKW(tree&+ob_sizeof*0+ob_x)
  536. y_in=PEEKW(tree&+ob_sizeof*0+ob_y)
  537. w_in=PEEKW(tree&+ob_sizeof*0+ob_width)
  538. h_in=PEEKW(tree&+ob_sizeof*0+ob_height)
  539.  
  540.  
  541. form_center tree&,x_in,y_in,w_in,h_in
  542. x_in=(x_in+4) AND &hFFF8 : REM align form window
  543. POKEW tree&+ob_sizeof*0+ob_x,x_in : REM set form to new value
  544. j=wind_calc(0,myco,x_in,y_in,w_in,h_in,xab,yab,wab,hab) : REM what is the size of my form window?
  545.  
  546. handle=wind_create(myco,MX,MY,MW,MH) : REM create window
  547. IF handle<0 THEN form_window=handle : EXIT FUNCTION
  548.  
  549. form_dial 0,xsm,ysm,wsm,hsm,x_in,y_in,w_in,h_in
  550. form_dial 1,xsm,ysm,wsm,hsm,x_in,y_in,w_in,h_in
  551.  
  552. REM give my form window a title
  553. IF title>-1 THEN
  554.     j=rsrc_gaddr(5,title,attl&) : REM GET title string
  555.     j=wind_set(handle,wf_name,PEEKW(VARPTR(attl&)),PEEKW(VARPTR(attl&)+2),0,0)
  556.     REM give it to my form_window
  557. END IF
  558.  
  559. j=wind_open(handle,xab,yab,wab,hab)
  560. 'j=objc_draw(tree&,0,10,x_in,y_in,w_in,h_in)
  561.  
  562.  
  563. REM if the formwindow contains an edit field!
  564.  
  565. edit=-1
  566. n=0
  567. agai_n:
  568. flags=PEEKW(tree&+ob_sizeof*n+ob_flags)
  569. IF flags AND mask_editable THEN edit=n : GOTO ed_it:
  570. IF flags AND mask_lastob THEN GOTO end_it:
  571. INCR n : GOTO agai_n:
  572. ed_it:
  573.  
  574. REM create space for the extra values
  575. IF UBOUND(w_ob)<handle THEN REDIM PRESERVE w_ob(handle)
  576. IF UBOUND(wedit)<handle THEN REDIM PRESERVE wedit(handle)
  577.  
  578. w_ob(handle)=edit
  579. wedit(handle)=0
  580. index=wedit(handle)
  581. j=objc_edit(tree&,edit,k,index,0)
  582. wedit(handle)=index
  583.  
  584. end_it:
  585. form_window=handle
  586. END FUNCTION
  587.  
  588.  
  589. FUNCTION newform_alert(BYVAL button,BYVAL addr&)
  590. LOCAL j
  591. POKEW PEEKL(GB+8),button    'int_in
  592. POKEL PEEKL(GB+16),addr&    'addr_in
  593. GEMSYS(52)                    
  594. newform_alert=PEEKW(PEEKL(GB+20))
  595. END FUNCTION
  596.  
  597.  
  598.  
  599.