home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / f / formed2 / !FormEd2 / !RunImage (.txt) < prev    next >
RISC OS BBC BASIC V Source  |  1993-04-12  |  101KB  |  4,272 lines

  1.  > <FormEd2$Dir>.!RunImage
  2.  /// Forms Editor program (for designing Wimp Templates) ///
  3.   Buggered about with with by The RISC Squad
  4.   Now on version 2.84b
  5.  Directory Structure: . . . Snore !
  6.  !Formed.!Boot
  7.  !Formed.!Help
  8.  !Formed.!Run
  9.  !Formed.!RunImage            (this file) - run when !Run is executed
  10.  !Formed.!Sprites
  11.  !Formed.Default
  12.  !Formed.Sprites
  13.  !Formed.Templates
  14.  "XHourglass_On"
  15.  "OS_GetEnv" 
  16.  commandstring$
  17. :hwic%=-2
  18.  fontcounts% 255
  19.  I%=0 
  20.  255:fontcounts%?I%=0:
  21.  -- Start Wimp going
  22.  "Wimp_Initialise",200,&4B534154,"FormEd2" 
  23.  version%,task_handle%
  24. errordisplay(
  25.  after calling Wimp_Initialise!
  26. )`wbcol=&0:`tbcol=&D:`sco=&3:`mbcol=&B
  27. *`wfcol=&7:`tfcol=&7:`sci=&D:`tbcol2=&C
  28. DragASprite%=
  29.  inv% 27,outv% 23
  30.  px2% 1,px4% 3,px256% 255
  31. getmodeinfo
  32. switched%=
  33.  factors% 15,pixtrans% 15
  34.  -- dimension arrays
  35.  pal%(2),bright%(15),uncolour%(15)
  36.  q% &2000,erroraddr%(4),oldq% &100,_Q% 256
  37.  indexdata% 32*24+20,fontbinding% 255
  38. maxbuf%=&3000
  39.  buffer% maxbuf%:curbuff%=buffer%
  40. nh%=32
  41.  handle%(nh%+1),wident$(nh%),wptr%(nh%),tempind% nh%*16,temppatch%(nh%)
  42.  I%=0
  43. nh%:handle%(I%)=I%-1:wident$(I%)="":
  44. :handleSP%=nh%
  45.  spritename% 12
  46.  menufree% &2500:menuend%=menufree%+&2500
  47.  menulist% &100
  48. brx%=400:bry%=740
  49. />currentwindow%=-1:currenticon%=-1:dialogue%=-1:def_menu%=1
  50. spritef$="":clear%=
  51.  ib_text% 256,ib_sprite% 12,ib_buffersize% 6,ib_validation% 256
  52.  tb_text% 40,tb_sprite% 12,tb_buffersize% 6
  53.  mb_fsize% 6:$mb_fsize%="30"
  54.  mb_wident% 12
  55.  mb_renumber% 5:$mb_renumber%="0"
  56.  mb_delete% 5:$mb_delete%=""
  57.  mb_Hspacing% 6:$mb_Hspacing%="8"
  58.  mb_Vspacing% 6:$mb_Vspacing%="8"
  59.  mb_crsprite% 12,mb_rnsprite% 12
  60. nsp=80:ns%=10
  61.  spw%(nsp),sph%(nsp),spwx%(nsp),minx%(nsp),miny%(nsp),spname$(nsp)
  62.  spritew%(ns%+1),nsprite%(ns%)
  63.  spritei%(ns%),sprxscale%(ns%),spryscale%(ns%),spriten$(ns%)
  64.  I%=0
  65. ns%:spritew%(I%)=I%-1:spriten$(I%)="":
  66. :sprSP%=ns%:sprSP2%=-1
  67.  "OS_File",5,"<FormEd2$Dir>.Sprites" 
  68.  type%,,,,systemareasize%
  69.  type%<>1 
  70.  1,"Can't find 'Sprites' file"
  71. systemareasize%+=4
  72.  systemsprites% systemareasize%
  73. C$systemsprites%!0=systemareasize%
  74.  "OS_SpriteOp",&10A,systemsprites%,"<FormEd2$Dir>.Sprites"
  75.  SYS "OS_SpriteOp",&10F,systemsprites%,"editbuffer",0,1280/dx%,1024/dy%,MODE
  76.  editbuffer%=FNspriteaddr(systemsprites%,"editbuffer")
  77.  editbufferwidth%=(sptr%!16+1)*4
  78. spriteareasize%=
  79. -16*1024
  80.  spritearea% spriteareasize%
  81. J1!spritearea%=spriteareasize%:spritearea%!8=16
  82.  "OS_SpriteOp",&109,spritearea%
  83. loadsprites("<FormEd2$Dir>.Default"):spritef$="Default"
  84. loadchoices
  85. N.undoname$="":undoscreen%=-1:editbuffer%=-2
  86.  -- Create windows
  87. defaultwindows
  88.  paltable% 79:
  89.  "Wimp_ReadPalette",,paltable%
  90. palcolour%=7:sprcolour%=7
  91. S.paintmode%=16:
  92. select(palette%,paintmode%)
  93. T*grid%=
  94.  grid% 
  95. select(palette%,31)
  96.  -- Create Menus
  97. m_palette%=
  98. crmenu
  99.  "#Colours,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15"
  100. i_esg%=
  101. crmenu
  102.  "#ESG,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15"
  103. i_button%=
  104. crmenu
  105.  "#Button type,Never,Always,Auto-repeat,Click,Release,Double click,++"
  106.  "Click/Drag,Release/Drag,Double/Drag,Menu icon,Double/Click/Drag,++"
  107.  "Radio,Reserved,Reserved,Write/Click/Drag,Writeable"
  108. m_fsize%=
  109. crmenu
  110.  "#Point size,10 point,12 point,14 point,20 point,$mb_fsize%(6)"
  111. i_font%=
  112. crmenu
  113.  "#Text style,&"
  114. i_txt%=
  115. crmenu
  116.  "#Icon text,$ib_text%(256)"
  117. i_sprite%=
  118. crmenu
  119.  "#Sprite name,$ib_sprite%(12)"
  120. i_validation=
  121. crmenu
  122.  "#Validation,$ib_validation%(256)"
  123. i_buffersize%=
  124. crmenu
  125.  "#Max size,$ib_buffersize%(6),Valid>i_validation"
  126. i_flags%=
  127. crmenu
  128.  "#Icon flags,Text>i_txt%,Sprite>i_sprite%,Border,H centred,++"
  129.  "V centred,Filled,Anti-aliased>i_font%,Needs help,++"
  130.  "Indirected>i_buffersize%,R justified,Allow adjust,Half size,++"
  131.  "Button type>i_button%,ESG>i_esg%,++"
  132.  "Fg colour?m_palette%,Bg colour?m_palette%"
  133. t_text%=
  134. crmenu
  135.  "#Title text,$tb_text%(40)"
  136. t_sprite%=
  137. crmenu
  138.  "#Sprite name,$tb_sprite%(12)"
  139. t_buffersize%=
  140. crmenu
  141.  "#Max size,$tb_buffersize%(6)"
  142. t_flags%=
  143. crmenu
  144.  "#Title flags,Text>t_text%,Sprite>t_sprite%,Border,H centred,++"
  145.  "V centred,Filled,Anti-aliased>i_font%,Indirected>t_buffersize%,++"
  146.  "R justified"
  147. w_scroll%=
  148. crmenu
  149.  "Auto-repeat,Debounced"
  150. w_flags%=
  151. crmenu
  152.  "#Flags,Title>t_flags%,Moveable,V scroll,H scroll,Auto-redraw,Pane,++"
  153.  "No bounds,No quit box,User scroll>w_scroll%,Real colours,++"
  154.  "Back,Keys,Work area#>i_button%,New format,Back icon,++"
  155.  "Quit icon,Title icon>t_flags%,Toggle icon,V scroll,Size icon,H scroll"
  156. w_colours%=
  157. crmenu
  158.  "Title fg?m_palette%,Title bg?m_palette%,Work fg?m_palette%,Work bg?m_palette%,Scroll outer?m_palette%,Scroll inner?m_palette%,Input focus?m_palette%"
  159. w_ident%=
  160. crmenu
  161.  "#Window name:,$mb_wident%(12)"
  162. i_renumber%=
  163. crmenu
  164.  "#Icon #,$mb_renumber%(5)"
  165. i_delete%=
  166. crmenu
  167.  "#Icon #,$mb_delete%(5)"
  168. i_copy%=
  169. crmenu
  170.  "#Copy,left,right,up,down"
  171. i_move%=
  172. crmenu
  173.  "#Move,left,right,up,down"
  174. i_arrows%=
  175. crmenu
  176.  "#Arrow,left,right,down,up"
  177. i_3darrows%=
  178. crmenu
  179.  "#3D Arrow,left,right,down,up"
  180. i_align%=
  181. crmenu
  182.  "#Align,Left,Right,Top,Bottom,V Centre,H Centre"
  183. i_Hspacing%=
  184. crmenu
  185.  "#Spacing,$mb_Hspacing%(6)"
  186. i_Vspacing%=
  187. crmenu
  188.  "#Spacing,$mb_Vspacing%(6)"
  189. i_arrange%=
  190. crmenu
  191.  "#Arrange,Horizontal>i_Hspacing%,Vertical>i_Vspacing%,Both"
  192. i_new%=
  193. crmenu
  194.  "#New icon,Text>i_txt%,Sprite>i_sprite%,Arrow>i_arrows%,++"
  195.  "Option>i_txt%,Radio>i_txt%,Writeable>i_txt%,Menu>i_txt%,++"
  196.  "Comment#>i_txt%,Group,Raised>i_txt%,Sunken>i_txt%,Writeable>i_txt%,Default>i_txt%,++"
  197.  "Groove,Double,Option>i_txt%,Radio>i_txt%,Arrows>i_3darrows%"
  198. i_sel%=
  199. crmenu
  200.  "#Selection,Edit>i_flags%,Copy>i_copy%,Move>i_move%,Resize?m_resize%,Same size,Align>i_align%,Arrange>i_arrange%,Wipe>i_delete%,++"
  201.  "Renumber nnnn>i_renumber%"
  202. i_general%=
  203. crmenu
  204.  "#Icons,Edit window,Create icon?i_new%,Selected xxxxx?i_sel%,++"
  205.  "Select all,Deselect all,Tidy icons,Delete window"
  206. w_general%=
  207. crmenu
  208.  "#Window,Edit icons,Window flags?w_flags%,Colours>w_colours%,++"
  209.  "Work area?m_workarea%,Identifier>w_ident%,Delete window,++"
  210.  "Save?m_savetemp%"
  211. m_templates%=
  212. crmenu
  213.  "#Filename:,$mb_templates%(256)"
  214. m_show%=
  215. crmenu
  216.  "#Show,Handles,Templates"
  217. main_w%=
  218. crmenu
  219.  "#Templates,Create>w_ident%,Clear,Load>m_templates%,Save?m_savetemp%"
  220. main_s%=
  221. crmenu
  222.  "#Sprites,Show sprites,Show tools"
  223. mainmenu%=
  224. crmenu
  225.  "#FormEd2,Info>proginfo%,Sprites,Show>m_show%,Options,Finish,Quit"
  226. m_rowcol%=
  227. crmenu
  228.  "Row,Column"
  229. m_sprite%=
  230. crmenu
  231.  "#Sprite,Undo,Colour>m_palette%,Transparent,Create mask,Delete mask,++"
  232.  "Extend>m_rowcol%,Reduce>m_rowcol%,Insert>m_rowcol%,Delete>m_rowcol%,++"
  233.  "Flip X,Flip Y,Blob size>m_scale%"
  234. m_crsprite%=
  235. crmenu
  236.  "#New name,$mb_crsprite%(12)"
  237. m_rnsprite%=
  238. crmenu
  239.  "#New name,$mb_rnsprite%(12)"
  240. m_spritef%=
  241. crmenu
  242.  "#Filename,$mb_spritef%(256)"
  243. m_append%=
  244. crmenu
  245.  "Horizontally,Vertically"
  246. m_spritelist%=
  247. crmenu
  248.  "#Sprites,Delete,Copy>m_rnsprite%,Rename#>m_rnsprite%,Load>m_spritef%,Save>m_savespr%,Merge>m_spritef%"
  249. t_sel%=
  250. crmenu
  251.  "#Selection,Open,Close#,Copy?w_ident%,Rename?w_ident%#,Wipe"
  252. t_file%=
  253. crmenu
  254.  "#Templates,'12345678901'>t_sel%,Select all,Clear selection,Create?w_ident%,Clear,Load>m_templates%,Save?m_savetemp%"
  255. loaded%=
  256. setloaded(
  257.  -- if command was '*FormEd2 <filename>', load a template file
  258. ic_window%=
  259. iconbar
  260. commandstring$," -quit ")
  261.   I%+=
  262. " -quit "
  263. commandstring$,I%,1)=" ":I%+=1:
  264. (    I%=
  265. commandstring$+" "," ",I%+1)
  266. *    
  267. I%+=1:
  268. commandstring$,I%,1)<>" "
  269.     f$=
  270. commandstring$,I%)
  271.     f$=
  272. f$+" "," ")-1)
  273.  f$<>"" 
  274.       
  275. filetype(f$) 
  276. #      
  277.  &FEC:
  278. loadtemplates(f$)
  279. -      
  280.  &FF9:
  281. loadsprites(f$):
  282. spriteinfo
  283. -      
  284.  -2: 
  285.  1,"File '"+f$+"' not found"
  286. E      
  287.  1,"File '"+f$+"' is not a sprite file or template file"
  288.       
  289.         
  290.  f$=""
  291. encodepal(0,15)
  292. initbuf%=curbuff%
  293. front(handlew%)
  294. movehandles(
  295. updatefile(1)
  296.  -- Error handler - drops through to Wimp_Poll
  297. saveref%=-1:scrapref%=-1
  298. dragtype%=0:pdrag%=-1
  299. paint_drag%=-1
  300. inerror%=
  301. :oldhelp%=1
  302.  "XHourglass_Off":*Pointer 1
  303.  "Wimp_DragBox",,-1:menuhandle%=-1:
  304. errorbox(
  305.  -- Main Polling loop
  306.  hw% 
  307.  ?hndident%<>13 
  308. handledoicon
  309.  "Wimp_Poll",0,q% 
  310.  action%
  311.  interface% 
  312.  "XWimp_PollPointer",action%,,task_handle%
  313.  action% 
  314. redraw(!q%)
  315. open(!q%,q%!4,q%!8,q%!12,q%!16,q%!20,q%!24,q%!28)
  316. close(!q%)
  317. leave(!q%)
  318. enter(!q%)
  319. mouse(!q%,q%!4,q%!8,q%!12,q%!16,q%!20)
  320. decodedrag(!q%,q%!4,q%!8,q%!12)
  321.  8: key%=q%!24:
  322. processkey(q%!0,q%!4,key%)
  323.  9: I%=0:
  324. :menulist%!I%=q%!I%:I%=I%+4:
  325. q%!(I%-4)=-1
  326. .        
  327. decodemenu(menuhandle%,menulist%)
  328. .        
  329. getpointer:
  330.  buttons%
  331. remenu
  332. open(!q%,q%!4,q%!8,q%!12,q%!16,q%!20+q%!32*32,q%!24+q%!36*32,q%!28)
  333.  17,18:
  334. receive(q%)
  335. receive(q%)
  336.  I%=0 
  337.  !q%-1 
  338. 4:oldq%!I%=q%!I%:
  339.  q%!16 
  340. finish:
  341.  q%!40 
  342. 5       
  343.  &FF9,&FEC:  
  344.  do the scrap file business
  345. D            
  346.  "XOS_ReadVarVal","Wimp$Scrap",,-1,0,3 
  347.  ,,exists%
  348. <            
  349.  exists%=0 
  350.  1,"<Wimp$Scrap> not defined"
  351. 7            q%!36=-1:
  352. string0(q%+44,"<Wimp$Scrap>")
  353. +            !q%=(48+
  354. "<Wimp$Scrap>")
  355.     C            q%!12=q%!8:q%!16=2:
  356.  "Wimp_SendMessage",17,q%,q%!4
  357.             scrapref%=q%!8
  358.        
  359.  q%!12<>saveref% 
  360.  1,"Unexpected DataSave packet received"
  361.        
  362.  q%!40 
  363. ;       
  364.  &FEC:
  365. savetemplates(
  366. string0(q%+44),q%!36<>-1)
  367. 1                 
  368.  clear% 
  369. wipealltemplates
  370. 9       
  371.  &FF9:
  372. savesprites(
  373. string0(q%+44),q%!36<>-1)
  374. 8       
  375.  1,"Unexpected DataSave filetype received"
  376.        
  377. M       oldq%!12=oldq%!8:oldq%!16=3:
  378.  "Wimp_SendMessage",17,oldq%,oldq%!4
  379.  3:typ%=q%!40:file$=
  380. string0(q%+44)
  381.        
  382.  typ%=&2000 
  383. G        
  384.  "OS_File",5,file$+"."+auto$ 
  385.  T%,,R%:typ%=(R%>>8) 
  386.  &FFF
  387.         
  388.  typ%=&FEC 
  389. ;         file$+="."+auto$:
  390.  loaded% 
  391. wipealltemplates
  392.         
  393. L         void%=
  394. warning(q%,1,"This application has no '"+auto$+"' file")
  395.           typ%=&1000:name$=""
  396.         
  397.        
  398.        
  399.  typ% 
  400. '       
  401.  &FEC:
  402. loadtemplates(file$)
  403.        
  404.  &FF9:
  405.  q%!20=-2 
  406. !9                      
  407. loadsprites(file$):
  408. spriteinfo
  409. "7                 
  410. mergesprites(file$):
  411. spriteinfo
  412.                  
  413.        
  414.        
  415. &6       
  416.  oldq%!12=scrapref% 
  417.  *Delete <Wimp$Scrap>
  418. 'M       oldq%!12=oldq%!8:oldq%!16=4:
  419.  "Wimp_SendMessage",17,oldq%,oldq%!4
  420.  q%!40=&FEC 
  421.         A%=
  422.         
  423. +%         
  424.  wident$(I%)<>"" 
  425.         
  426.         
  427. .,         
  428. loadtemplates(
  429. string0(q%+44))
  430. /O         oldq%!12=oldq%!8:oldq%!16=4:
  431.  "Wimp_SendMessage",17,oldq%,oldq%!4
  432.         
  433.        
  434. encodepal(0,15)
  435. bootmessage(q%)
  436.  &400C0:
  437. 59  submenu%=q%!20:subx%=q%!24:suby%=q%!28:menus%=q%+32
  438.  submenu%>&8000 
  439. encodemenu(submenu%)
  440. 9(   
  441.  submenu%=m_savetemp% 
  442.  clear%=
  443.  "Wimp_CreateSubMenu",,submenu%,subx%,suby%
  444.  &400C1:
  445. getmodeinfo:
  446. movehandles(
  447. sendsave(ft%,fn%)
  448.  filename%
  449.  "Wimp_CreateMenu",,-1
  450. filename%=fn%:fn%+=
  451. $fn%,"."):
  452.  fn%=filename%
  453. getpointer : 
  454.  sets up handle%,icon%,mousex%,mousey%
  455. !q%=(48+
  456. $filename%)
  457. q%!12=0:q%!16=1
  458. F9q%!20=handle%:q%!24=icon%:q%!28=mousex%:q%!32=mousey%
  459. G(q%!36=0   : 
  460.  file size (inaccurate)
  461. q%!40=ft% : 
  462.  file type
  463. string0(q%+44,$filename%)
  464.  "Wimp_SendMessage",17,q%,handle%,icon%
  465. saveref%=q%!8
  466. string0(a%) 
  467. a$:a$="":
  468.  ?a%:a$+=
  469. ?a%:a%+=1:
  470. string0(a%,a$) $a%=a$:a%?
  471. a$=0:
  472. getmodeinfo
  473. inv%!0 = 4
  474. inv%!4 = 5
  475. inv%!8 = 6
  476. inv%!12= 7
  477. inv%!16= 11
  478. inv%!20= 12
  479. inv%!24= -1
  480.  "OS_ReadVduVariables",inv%,outv%
  481. dx%=1<<(outv%!0)
  482. dy%=1<<(outv%!4)
  483. linelen%=outv%!8
  484. screensize%=outv%!12
  485. scrx1%=(outv%!16+1)*dx%
  486. scry1%=(outv%!20+1)*dy%
  487. redraw(handle%):!q%=handle%:
  488.  "Wimp_RedrawWindow",,q% 
  489.  more%
  490. info(q%+4):
  491.  dx%:dx%=48
  492.  more%
  493.  hatch% 
  494. whichwindow(handle%)>0) 
  495. d-  x0%=q%!28:y0%=q%!32:x1%=q%!36:y1%=q%!40
  496. e/  minx0%=x0%-(by%-y0%):maxx0%=x1%-(by%-y1%)
  497. f/  minx1%=x0%+(by%-y1%):maxx1%=x1%+(by%-y0%)
  498. g1  minx0%=(minx0%-bx%+10000)
  499. dx%*dx%+bx%-10000
  500. h1  minx1%=(minx1%-bx%+10000)
  501. dx%*dx%+bx%-10000
  502. x%=minx0%
  503. maxx0%
  504. x%,by%:
  505. 1,3E4,-3E4:
  506. x%=minx1%
  507. maxx1%
  508. x%,by%:
  509. 1,-3E4,-3E4:
  510.  interface% 
  511.  "XWimp_BorderWindow",,q%
  512.  "Wimp_GetRectangle",,q% 
  513.  more%
  514. front(handle%)
  515. r,!q%=handle%:
  516.  "Wimp_GetWindowState",,q%
  517. s%q%!28=-1:
  518.  "Wimp_OpenWindow",,q%
  519. reopen(handle%)
  520. vE!q%=handle%:
  521.  "Wimp_GetWindowState",,q%:
  522.  "Wimp_OpenWindow",,q%
  523. getw(handle%)
  524. y8!q%=handle%:
  525.  "Wimp_GetWindowState",,q%:
  526. info(q%+4)
  527. geti(h%,i%)
  528. |-!q%=h%:q%!4=i%:
  529.  "Wimp_GetIconState",,q%
  530. }.ix0%=q%!8:iy0%=q%!12:ix1%=q%!16:iy1%=q%!20
  531. iflags%=q%!24:idata%=q%+28
  532. info(p%)
  533. 'x0%=!p%:y0%=p%!4:x1%=p%!8:y1%=p%!12
  534. 5scx%=p%!16:scy%=p%!20:bhandle%=p%!24:flags%=p%!28
  535. Kbx%=x0%-scx%:by%=y1%-scy% : 
  536.  all drawing should be relative to bx%,by%
  537. update(handle%,x0%,y0%,x1%,y1%)
  538. 5!q%=handle%:q%!4=x0%:q%!8=y0%:q%!12=x1%:q%!16=y1%
  539.  "Wimp_UpdateWindow",,q% 
  540.  more%
  541. upicon(handle%,icon%)
  542. D!q%=handle%:q%!4=icon%:q%!8=0:q%!12=0:
  543.  "Wimp_SetIconState",,q%
  544. lc(a$):
  545.  b$,A%:
  546.  a$>"":A%=
  547. a$:a$=
  548. a$,2):
  549.  A%>64 
  550.  A%<91 A%+=32
  551.  b$+=
  552. newdef(a$)
  553.  a$="" 
  554. warning(q%,2,"Templates must be named"):
  555. matchident(a$)<>-1 
  556. warning(q%,2,"Template already exists"):
  557. createwindow(brx%,bry%,a$):brx%+=60:bry%-=40
  558. setloaded(
  559. updatefile(0)
  560. bry%<340 bry%=1000
  561. brx%>1040 brx%=40
  562. setloaded(T%):
  563.  loaded%=T% 
  564.  T% loaded%=
  565.  loaded%=
  566. :templatef$=deffile$:
  567.  I%=0
  568. nh%:handle%(I%)=I%-1:wident$(I%)="":
  569. :handleSP%=nh%
  570. open(handle%,x0%,y0%,x1%,y1%,scx%,scy%,bhandle%)
  571. !q%=handle%
  572. )q%!4=x0%:q%!8=y0%:q%!12=x1%:q%!16=y1%
  573. q%!20=scx%:q%!24=scy%
  574. q%!28=bhandle%
  575.  "Wimp_OpenWindow",,q%
  576. close(handle%)
  577. whichwindow(handle%):
  578. I%<>-1 
  579. setfileopen(I%,
  580.  handle%=spritelist% 
  581.  spop%=
  582.  handle%=options% 
  583.  interface% 
  584.  "XWimp_ReleaseInterface",task_handle%
  585. geti(options%,2):
  586.  iflags%
  587. (1<<21) finac%=0
  588. geti(options%,3):
  589.  iflags%
  590. (1<<21) finac%=1
  591. geti(options%,4):
  592.  iflags%
  593. (1<<21) finac%=2
  594. geti(options%,8):interface%=(iflags%
  595. (1<<21))>0
  596. geti(options%,9):    hatch%=(iflags%
  597. (1<<21))>0
  598.  handle%=handlew% 
  599.  hw%=
  600. )!q%=handle%:
  601.  "Wimp_CloseWindow",,q%
  602. mouse(mousex%,mousey%,buttons%,handle%,icon%,oldbuttons%)
  603.  void%
  604.  buttons% 
  605.  &02     : 
  606.  -- MENU button
  607.   I%=
  608. whichwindow(handle%)
  609.   menuwindow%=handle%
  610. I%<>-1
  611. (-1) 
  612. K   !q%=handle%:q%!4=icon%:q%!8=1<<21:q%!12=0:
  613.  "Wimp_SetIconState",,q%
  614. (-2) 
  615.  icon%>-1 
  616. !     renumber%=
  617. $mb_renumber%
  618. &     
  619. renumber(I%,icon%,renumber%)
  620. 6     
  621.  renumber%<9999 $mb_renumber%=
  622. (renumber%+1)
  623.         
  624. N    oldhandle%=handle%:oldicon%=icon%:mmousex%=mousex%:mmousey%=mousey%+44
  625. "    mmousey%-=44*(def_menu%=1)
  626. windowmenu(I%)
  627. 8  I%=
  628. whichsprite(handle%):
  629. I%<>-1 
  630. spritemenu(I%):
  631.  handle% 
  632. menu(mainmenu%)
  633.  spritelist%:
  634. menu(m_spritelist%)
  635.  tempfile%:I%=q%+40:
  636.  "Wimp_WhichIcon",tempfile%,I%,5<<21,1<<21
  637.  !I%=-1 
  638.  I%!4=-1 
  639. -      
  640.  !I%>-1 
  641. deselect(tempfile%,!I%)
  642. /      
  643.  icon%>-1 
  644. select(tempfile%,icon%)
  645.         
  646. menu(t_file%)
  647.  &01,&04 : 
  648.  -- SELECT/ADJUST buttons
  649. 9  I%=
  650. whichsprite(handle%):
  651. I%<>-1 
  652. spritepixel(I%):
  653.  handle% 
  654.        
  655.  icon% 
  656.        
  657.  ic_window%
  658.          $mb_name%=deftem$
  659. <         
  660.  "Wimp_CreateMenu",,new_temp%,mousex%-192,160
  661.        
  662.  palette%:
  663. palette
  664.  spritelist%
  665.        
  666. icon%=-1
  667.          
  668.  buttons%=&04 
  669.            
  670. deselectsprites
  671.          
  672. )           
  673. geti(spritelist%,icon%
  674.          
  675.  m_scale%
  676. *       
  677. setxy(xsc%,ysc%,$sprbuff%,"x")
  678.        xs%=xsc%
  679.        
  680.  icon% 
  681.         
  682.  xs%<48 xs%+=dx%
  683. !       
  684.  xs%>dx% xs%-=dx%
  685.        
  686.        
  687.  xs%<>xsc% 
  688.          ys%=xs%*ysc%/xsc%
  689. $         $sprbuff%=
  690. xs%+"x"+
  691. 4         
  692. upicon(m_scale%,2):
  693. upicon(m_scale%,3)
  694. 0         
  695. changesize(currentsprite%,xs%,ys%)
  696.        
  697.  m_workarea%
  698. %       
  699. setwork(q%,mb_workarea0%)
  700. '       
  701. setwork(q%+8,mb_workarea1%)
  702. .       x0%=!q%:y0%=q%!4:x1%=q%!8:y1%=q%!12
  703.        
  704.  icon% 
  705.        
  706.  0:y1%+=4
  707.        
  708.  1:x1%+=2
  709.        
  710.  2:x0%-=2
  711.        
  712.  3:y0%-=4
  713. +       
  714.  5:x0%+=2:
  715.  x0%>mwx0% x0%=mwx0%
  716. +       
  717.  6:x1%-=2:
  718.  x1%<mwx1% x1%=mwx1%
  719. +       
  720.  7:y1%-=4:
  721.  y1%<mwy1% y1%=mwy1%
  722. +       
  723.  8:y0%+=4:
  724.  y0%>mwy0% y0%=mwy0%
  725. &       
  726. xor(m_workarea%,11,6)
  727. /               
  728. setworkarea(currentwindow%)
  729. <               
  730.  (buttons%
  731. 1)=0 
  732.  "Wimp_CreateMenu",,-1
  733.        
  734.        w0$=
  735. x0%+","+
  736.        w1$=
  737. x1%+","+
  738. I       
  739. w0$<>$mb_workarea0% $mb_workarea0%=w0$:
  740. upicon(m_workarea%,9)
  741. J       
  742. w1$<>$mb_workarea1% $mb_workarea1%=w1$:
  743. upicon(m_workarea%,10)
  744.  dial_delete%
  745.        
  746.  icon% 
  747. %       
  748. xor(dial_delete%,2,6)
  749. "              
  750. godeletesprites
  751. &              
  752. close(dial_delete%)
  753. #       
  754. close(dial_delete%)
  755.        
  756.  m_savetemp%
  757.        
  758.  icon%=2 
  759. &        
  760. checkfull($mb_templates%)
  761. ,        
  762. savetemplates($mb_templates%,
  763. 7        
  764.  buttons% 
  765.  &01 
  766.  "Wimp_CreateMenu",,-1
  767. &        
  768.  clear% 
  769. wipealltemplates
  770.        
  771.  m_savespr%
  772.        
  773.  icon%=2 
  774. %         
  775. checkfull($mb_spritef%)
  776. )         
  777. savesprites($mb_spritef%,
  778.  8         
  779.  buttons% 
  780.  &01 
  781.  "Wimp_CreateMenu",,-1
  782.        
  783.  new_temp%
  784.        
  785.  icon%=1 
  786.          
  787. newdef($mb_name%)
  788.          
  789. close(new_temp%)
  790.        
  791.  options%
  792. (%       
  793.  icon%<2 
  794. close(options%)
  795.        
  796.  icon%=1 
  797. **         X%=
  798. ("<FormEd2$Dir>.Choices")
  799. +9         
  800. #X%,deftem$,deffile$:
  801. #X%,finac%:
  802. #X%,auto$
  803. ,6         
  804. #X%,interface%:
  805. #X%,hatch%:
  806. #X%,country$
  807. -?         
  808. #X%:*SetType <FormEd2$Dir>.Choices Text
  809. .)         *Stamp <FormEd2$Dir>.Choices
  810.        
  811.  m_resize%
  812.  Hilke
  813. 2L    C%=q%+&80:
  814.  "Wimp_WhichIcon",handle%(currentwindow%),C%,5<<21,1<<21
  815. 3;    
  816.  currenticon%>-1 
  817. geti(menuwindow%,currenticon%)
  818.  icon% 
  819.       
  820.  increase max x
  821. 6'        
  822. handle_resize(6,4,0,0,4,0)
  823.       
  824.  decrease max x
  825. 8)        
  826. handle_resize(6,-4,0,0,-4,0)
  827.       
  828.  decrease max y
  829. :)        
  830. handle_resize(5,-4,0,0,0,-4)
  831.       
  832.  increase max y
  833. <'        
  834. handle_resize(5,4,0,0,0,4)
  835.       
  836.  increase min x
  837. >(        
  838. handle_resize(6,-4,4,0,0,0)
  839.       
  840.  decrease min x
  841. @(        
  842. handle_resize(6,4,-4,0,0,0)
  843.       
  844.  increase min y
  845. B(        
  846. handle_resize(5,4,0,-4,0,0)
  847.       
  848.  decrease min y
  849. D(        
  850. handle_resize(5,-4,0,4,0,0)
  851.       
  852.         
  853. handle_resizeOK
  854. G3        
  855.  buttons%=4 
  856.  "Wimp_CreateMenu",,-1
  857. H<        
  858.  "Wimp_ForceRedraw",menuwindow%,0,-5000,5000,0
  859. I        
  860.  tempfile%
  861.  icon%>-1 
  862. LQ     I%=
  863. backreffile(icon%):q%!40=handle%(I%):
  864.  "Wimp_GetWindowState",,q%+40
  865. M%     
  866.  q%!72 
  867.  (1<<16) 
  868. (-1) 
  869.        
  870. close(q%!40)
  871.      
  872. P+       
  873. front(q%!40):
  874. setfileopen(I%,
  875.      
  876. S>     I%=q%+40:
  877.  "Wimp_WhichIcon",tempfile%,I%,5<<21,1<<21
  878. T3     
  879.  !I%>-1:
  880. deselect(tempfile%,!I%):I%+=4:
  881.  &10,&40 : 
  882.  -- SELECT/ADJUST dragging
  883.  handle% 
  884.  m_savetemp%,m_savespr%:
  885. dragicon(mousex%,mousey%,handle%,icon%)
  886. icon%<>-1 
  887. drag(buttons%,handle%,icon%)
  888.  &100,&400:
  889.  -- selection if button type = 10
  890.  handle% 
  891.  spritelist%
  892. _+       
  893.  buttons%=&400 
  894. deselectsprites
  895. `!       
  896. geti(handle%,icon%
  897. a"       
  898.  (iflags%
  899. &400000)=0 
  900. b3          
  901. seti(spritelist%,icon%
  902. 1,&200000,0)
  903. c2          
  904. seti(spritelist%,icon%
  905. 1,&200000,0)
  906.        
  907. processkey(handle%,icon%,key%)
  908.  handle% 
  909.  m_workarea%
  910.      
  911.  key%=13 
  912. l!       
  913. xor(m_workarea%,11,6)
  914. m'       
  915. setworkarea(currentwindow%)
  916. n#       
  917.  "Wimp_CreateMenu",,-1
  918.        
  919.      
  920.  m_savetemp%
  921.      
  922.  key%=13 
  923. s%       
  924. checkfull($mb_templates%)
  925. t+       
  926. savetemplates($mb_templates%,
  927. u%       
  928.  clear% 
  929. wipealltemplates
  930. v#       
  931.  "Wimp_CreateMenu",,-1
  932.        
  933.      
  934.  m_savespr%
  935.      
  936.  key%=13 
  937. {#       
  938. checkfull($mb_spritef%)
  939. |'       
  940. savesprites($mb_spritef%,
  941. }#       
  942.  "Wimp_CreateMenu",,-1
  943.        
  944.      
  945.  new_temp%
  946.      
  947.  key%=13 
  948.        
  949. newdef($mb_name%)
  950.        
  951. close(new_temp%)
  952.      
  953.  options%
  954.      
  955.  icon% 
  956.   5:N%= 6: deftem$=$mb_deft%
  957.   6:N%= 7:deffile$=$mb_deff%:
  958.  loaded% templatef$=deffile$
  959.   7:N%=10:   auto$=$mb_auto%
  960.  10:N%= 5
  961.  "Wimp_SetCaretPosition",handle%,N%,0,0,-1,
  962. iconaddr(handle%,N%)
  963.  m_resize%
  964.      
  965.  key% =13 
  966.        
  967.  icon% 
  968.          
  969. Q           
  970.  "Wimp_SetCaretPosition",handle%,6,0,0,-1,
  971. iconaddr(handle%,6)
  972.          
  973.            
  974. handle_resizeOK
  975.             
  976. close(new_temp%)
  977. '           
  978.  "Wimp_CreateMenu",,-1
  979. ?           
  980.  "Wimp_ForceRedraw",menuwindow%,0,-5000,5000,0
  981.        
  982.      
  983.  "Wimp_ProcessKey",key%
  984. R------------------------------------------------------------------------------
  985. drag(b%,handle%,icon%)
  986. whichwindow(handle%):
  987. I%=-1 
  988. (currentwindow%=I%:currenticon%=icon%
  989. 4dragtype%=b%:draghandle%=handle%:dragicon%=icon%
  990. getcurw
  991. getcuri(currenticon%)
  992. +cx0%+=bx%:cy0%+=by%:cx1%+=bx%:cy1%+=by%
  993. %x0%=0:y0%=0:x1%=scrx1%:y1%=scry1%
  994. home_x%=cx0%:home_y%=cy0%
  995. b%=&10
  996. getminxy(flags%,text$,sprite$)
  997. )  mx0%=mousex%-cx0%:mx1%=cx1%-mousex%
  998. )  my0%=mousey%-cy0%:my1%=cy1%-mousey%
  999. 4  x0%=cx0%+minx%:y0%=0:x1%=scrx1%:y1%=cy1%-miny%
  1000. mx0%<mx1% 
  1001. swapx:x0%=0:x1%=cx0%-minx%:x0%+=1:x1%-=1
  1002. my0%>my1% 
  1003. swapy:y0%=cy1%+miny%:y1%=scry1%:y0%+=1:y1%-=1
  1004. .  x0%+=cx0%-cx1%:y1%+=cy1%-cy0%  : 
  1005.  bodge
  1006.   many_icon%=
  1007.   many_icon%=
  1008. (!q%=handle%:
  1009.  b%=&40 q%!4=5 
  1010.  q%!4=6
  1011. .q%!8=cx0%:q%!12=cy0%:q%!16=cx1%:q%!20=cy1%
  1012. +q%!24=x0%:q%!28=y0%:q%!32=x1%:q%!36=y1%
  1013.  "Wimp_DragBox",,q%
  1014. R------------------------------------------------------------------------------
  1015. dragicon(mousex%,mousey%,handle%,icon%)
  1016.  f%,area%,name%,spr_name$,flags%
  1017. %dragtype%=&FF:draghandle%=handle%
  1018.  handle%=m_savetemp% 
  1019.  spr_name$="file_FEC"
  1020.  handle%=m_savespr%  
  1021.  spr_name$="file_FF9"
  1022. getw(handle%)
  1023. geti(handle%,icon%)
  1024. flags%=q%!24
  1025. !q%=handle%:q%!4=5
  1026. >q%!8=bx%+ix0%:q%!12=by%+iy0%:q%!16=bx%+ix1%:q%!20=by%+iy1%
  1027. *q%!24=q%!8-mousex%:q%!28=q%!12-mousey%
  1028. 9q%!32=scrx1%+q%!16-mousex%:q%!36=scry1%+q%!20-mousey%
  1029.  "OS_Byte",161,28 
  1030.  ,,f%
  1031. DragASprite%=((f% 
  1032.  2)=2)
  1033.  DragASprite% 
  1034.   f%=flags%
  1035.  (f% 
  1036.  2)=0 
  1037.  99,"Not a sprite icon to drag"
  1038.  "DragASprite_Start",%10000101,1,spr_name$,q%+8
  1039.  "Wimp_DragBox",,q%
  1040. R------------------------------------------------------------------------------
  1041. swapx
  1042. @cx0%=cx0%
  1043. cx1%:cx1%=cx1%
  1044. cx0%:cx0%=cx0%
  1045. cx1%:cx0%-=1:cx1%+=1
  1046. R------------------------------------------------------------------------------
  1047. swapy
  1048. @cy0%=cy0%
  1049. cy1%:cy1%=cy1%
  1050. cy0%:cy0%=cy0%
  1051. cy1%:cy0%-=1:cy1%+=1
  1052. R------------------------------------------------------------------------------
  1053. getminxy(flags%,text$,sprite$)
  1054.  x0%,y0%,x1%,y1%,mx%,my%
  1055. minx%=0:miny%=0
  1056.  flags%
  1057.  text$<>"" 
  1058.  flags%
  1059. 5       
  1060.  "Font_ReadInfo",flags%>>24 
  1061.  ,,y0%,,y1%
  1062. D       
  1063.  "Font_StringBBox",,
  1064. (flags%>>24)+text$ 
  1065.  ,x0%,,x1%
  1066. ,       
  1067.  "Font_ConverttoOS",,x0% 
  1068.  ,x0%
  1069. ,       
  1070.  "Font_ConverttoOS",,x1% 
  1071.  ,x1%
  1072. &       minx%=x1%-x0%:miny%=y1%-y0%
  1073.  minx%=6*dx%+16*
  1074. text$:miny%=32
  1075.  flags%
  1076. &04 miny%+=2*dy%
  1077.  flags%
  1078.  sprite$<>"" 
  1079.  "XOS_SpriteOp",&128,spritearea%,sprite$ 
  1080.  ,,,mx%,my%,,spm% ; P%
  1081. 1)=0 
  1082. A      
  1083.  "XOS_ReadModeVariable",spm%,4 
  1084.  ,,spx%:mx%=mx%<<spx%
  1085. A      
  1086.  "XOS_ReadModeVariable",spm%,5 
  1087.  ,,spy%:my%=my%<<spy%
  1088. +      
  1089.  flags%
  1090. &800 mx%=mx%/2:my%=my%/2
  1091. B      
  1092.  (flags%
  1093. &21B)=&13 mx%=minx%+mx% :
  1094.  sprite+text (V~H~R)
  1095.       
  1096.  mx%>minx% minx%=mx%
  1097.       
  1098.  my%>miny% miny%=my%
  1099. R------------------------------------------------------------------------------
  1100. decodedrag(cx0%,cy0%,cx1%,cy1%)
  1101. dragtype%=0
  1102.  DragASprite% 
  1103.   DragASprite%=
  1104.  "DragASprite_Stop"
  1105.  draghandle%=m_savetemp% 
  1106. sendsave(&FEC,mb_templates%):
  1107.  draghandle%=m_savespr% 
  1108. sendsave(&FF9,mb_spritef%):
  1109. getw(draghandle%)
  1110. 'd_x%=cx0%-home_x%:d_y%=cy0%-home_y%
  1111. +cx0%-=bx%:cx1%-=bx%:cy0%-=by%:cy1%-=by%
  1112.  cx0%>cx1% 
  1113. swapx
  1114.  cy0%>cy1% 
  1115. swapy
  1116.  many_icon% 
  1117. moveicon(draghandle%,dragicon%,d_x%,d_y%)
  1118. <I%=q%+&80:
  1119.  "Wimp_WhichIcon",draghandle%,I%,5<<21,1<<21
  1120.  !I%>-1:
  1121.  !I%<>dragicon% 
  1122. moveicon(draghandle%,!I%,d_x%,d_y%)
  1123. I%+=4:
  1124. geti(draghandle%,dragicon%)
  1125.     -od0%=idata%!0:od1%=idata%!4:od2%=idata%!8
  1126. deleteicon(draghandle%,dragicon%)
  1127. Pcurrenticon%=
  1128. cricon(draghandle%,cx0%,cy0%,cx1%,cy1%,iflags%,od0%,od1%,od2%)
  1129. R------------------------------------------------------------------------------
  1130. cricon(handle%,x0%,y0%,x1%,y1%,flags%,dt0%,dt1%,dt2%)
  1131. !q%=handle%
  1132. 1q%!20=flags%:q%!24=dt0%:q%!28=dt1%:q%!32=dt2%
  1133. text$="":sprite$=""
  1134.  flags% 
  1135.  flags% 
  1136.  &100 text$=$(q%!24) 
  1137.  text$=$(q%+24)
  1138.  flags% 
  1139.  flags% 
  1140.  &100 
  1141. $  sprite$=
  1142. getcommand(q%!28,"S")
  1143.   sprite$=$(q%+24)
  1144. getminxy(flags%,text$,sprite$)   : 
  1145.  bodge
  1146. x1%-x0%<minx% x1%=x0%+minx%
  1147. y1%-y0%<miny% y1%=y0%+miny%
  1148. !)q%!4=x0%:q%!8=y0%:q%!12=x1%:q%!16=y1%
  1149.  "Wimp_CreateIcon",,q% 
  1150.  due to interface icon borders redraw a larger area than before!
  1151.  "Wimp_ForceRedraw",!q%,q%!4-50,q%!8-50,q%!12+50,q%!16+50
  1152.  "Wimp_GetCaretPosition",,q%
  1153. !q%=handle%
  1154. q%!4=ic%:
  1155.  "Wimp_SetCaretPosition",handle%,ic%,0,0,-1,0
  1156. (R------------------------------------------------------------------------------
  1157. moveicon(handle%,icon%,d_x%,d_y%)
  1158.  new_handle%
  1159. geti(handle%,icon%)
  1160. ,Boldflags%=iflags%:odt0%=idata%!0:odt1%=idata%!4:odt2%=idata%!8
  1161. ix0%+=d_x%:ix1%+=d_x%
  1162. iy0%+=d_y%:iy1%+=d_y%
  1163. deleteicon(handle%,icon%)
  1164.  ix0%>ix1% 
  1165.  ix0%,ix1%:ix0%-=1:ix1%+=1
  1166.  iy0%>iy1% 
  1167.  iy0%,iy1%:iy0%-=1:iy1%+=1
  1168. 2Pnew_handle%=
  1169. cricon(handle%,ix0%,iy0%,ix1%,iy1%,oldflags%,odt0%,odt1%,odt2%)
  1170.  currenticon%<>-1 
  1171.  currenticon%=new_handle%
  1172. 5R------------------------------------------------------------------------------
  1173. deleteicon(handle%,icon%)
  1174.  bd%:bd%=20
  1175. 85!q%=handle%:q%!4=icon%:
  1176.  "Wimp_GetIconState",,q%
  1177.  "Wimp_DeleteIcon",,q%
  1178.  ##PH increased redrawn area to erase interface type icons when dragging
  1179.  "Wimp_ForceRedraw",!q%,q%!8-bd%,q%!12-bd%,q%!16+bd%,q%!20+bd%
  1180. =R------------------------------------------------------------------------------
  1181. menu(m%)
  1182. menuhandle%=m%
  1183. getpointer:mmousex%=mousex%:mmousey%=mousey%
  1184. encodemenu(m%) 
  1185.  handle%=-2 
  1186. C+    I%=m%!20+m%!24:J%=m%+28:K%=96-m%!24
  1187. D#    
  1188.  K%+=I%:J%+=24:
  1189. J%!-24
  1190.     K%=mousey%+12+44
  1191.  "Wimp_CreateMenu",,-1
  1192.  "Wimp_CreateMenu",,menuhandle%,mousex%-102,K%
  1193. J'  oldhandle%=handle%:oldicon%=icon%
  1194. remenu:
  1195.  menuhandle%=-1 
  1196. N%handle%=oldhandle%:icon%=oldicon%
  1197. encodemenu(menuhandle%) 
  1198.  "Wimp_CreateMenu",,menuhandle%,mmousex%-102,mmousey%+12 :
  1199.  default coords
  1200. crmenu
  1201.  menufree%+28 > menuend% 
  1202.  1,"Menu area full"
  1203.  m%,menu$,m$:
  1204.  menu$
  1205. menu$,2)="++":
  1206.  m$:menu$=
  1207. menu$,
  1208. menu$-2)+m$:
  1209. menu$,1)="=" menu$=
  1210. menu$,2)
  1211. menuptr%=menufree%
  1212. i%=0:ctr%=0
  1213. menu$,1)="#" i%=1:menutitle$=
  1214. par(",") 
  1215.  menutitle$=""
  1216. menutitle$,">")
  1217.  I%>0 
  1218. ])     menuptr%!20=
  1219. menutitle$,I%+1))
  1220. ^%     menutitle$=
  1221. menutitle$,I%-1)
  1222.  menuptr%!20=40
  1223. $menuptr%=menutitle$
  1224. bJmenuptr%?12=`tfcol:menuptr%?13=2:menuptr%?14=`wfcol:menuptr%?15=`wbcol
  1225. c$menuptr%!16=196-24:menuptr%!24=0
  1226. d$menuptr%+=28:maxx%=
  1227. menutitle$-3
  1228. menu$,1)="~"
  1229.   menu$=
  1230. menu$,
  1231. menu$-1)
  1232.  item$=
  1233. par(","):
  1234. menuitem(item$):
  1235.  item$=""
  1236.  menu$
  1237.  item$=
  1238. par(","):
  1239. menuitem(item$):
  1240.  item$=""
  1241.  menuptr%-menufree% <= 28 
  1242.  = -1 : 
  1243.  null menu
  1244. l#menuptr%!-24=(menuptr%!-24)
  1245. m"m%=menufree%:m%!16=maxx%*16+12
  1246. menufree%=menuptr%
  1247. menuitem(text$)
  1248.  text$="" 
  1249.  menuptr%+24 > menuend% 
  1250.  1,"Menu area full"
  1251.  text$="&" 
  1252.  "Font_ListFonts",,q%,ctr% 
  1253.  ,,ctr%
  1254.  ctr%>=0 text$=$q%+">m_fsize%":i%-=2 
  1255. i%,flg%
  1256. flg%=&00
  1257. text$,"?")
  1258.  i%<2 i%=
  1259. text$,">") 
  1260.  flg%+=&08
  1261.  i%>0 subptr%=
  1262. text$,i%+1):text$=
  1263. text$,i%-1) 
  1264.  subptr%=-1
  1265. text$,1)="#" text$=
  1266. text$,
  1267. text$-1):flg%+=&02
  1268. menuptr%!0=flg%
  1269. menuptr%!4=subptr%
  1270. menuptr%!8=&07000021
  1271. text$,1)="?" 
  1272.   menuptr%!8=&0700011A
  1273. )  I%=
  1274. workspace(
  1275. text$):$I%=
  1276. text$,2)
  1277. B  menuptr%!12=I%:menuptr%!16=systemsprites%:menuptr%!20=
  1278. text$
  1279. text$,1)="$" 
  1280.     !menuptr%+=&04
  1281.     menuptr%!8+=&100
  1282.     i%=
  1283. text$,"(")
  1284. 7    
  1285. i%>0 L%=
  1286. text$,i%+1):text$=
  1287. text$,i%-1)
  1288. L%=12
  1289. <    menuptr%!12=
  1290. text$,2):menuptr%!16=-1:menuptr%!20=L%
  1291. *    
  1292.  L%>15 L%=15 : 
  1293.  icons can scroll
  1294. 3    text$=
  1295. L%-1," ")  : 
  1296.  1 char was terminator
  1297. text$<=12
  1298. !         $(menuptr%+12)=text$
  1299. )    
  1300. workspace(
  1301. text$):$I%=text$
  1302. ?         menuptr%!12=I%:menuptr%!16=-1:menuptr%!20=
  1303. text$+1
  1304. )         menuptr%!8=menuptr%!8 
  1305.  &100
  1306.         
  1307. text$>maxx% maxx%=
  1308. text$
  1309. menuptr%+=24
  1310. par(sep$)
  1311. %i1%=i%+1:i%=
  1312. menu$+sep$,sep$,i1%)
  1313. menu$,i1%,i%-i1%)
  1314. R------------------------------------------------------------------------------
  1315. windowmenu(I%)
  1316. currentwindow%=I%
  1317.  def_menu% 
  1318.  0:menuhandle%=w_general%
  1319.  1:currenticon%=oldicon%:menuhandle%=i_general%
  1320. remenu
  1321. spritemenu(I%)
  1322. 7currentsprite%=I%:mmousex%=mousex%:mmousey%=mousey%
  1323. menu(m_sprite%)
  1324. R------------------------------------------------------------------------------
  1325. encodemenu(menuhandle%)
  1326. encodemenu(menuhandle%) 
  1327.  1,"Menu shouldn't be allowed"
  1328. encodemenu(menuhandle%)
  1329. menuhandle%<&8000 
  1330. I%=menuhandle%+28
  1331. !I%=!I%
  1332. &01:I%!8=I%!8
  1333. &400000:I%+=24:
  1334. I%!-24
  1335.  menuhandle% 
  1336.  mainmenu%
  1337.      
  1338. encodemenu(m_show%)
  1339.  m_show%
  1340.      
  1341.  hw% 
  1342. tick(m_show%,0)
  1343. 8     q%!40=tempfile%:
  1344.  "Wimp_GetWindowState",,q%+40
  1345. +     
  1346.  q%!72 
  1347.  (1<<16) 
  1348. tick(m_show%,1)
  1349. %     
  1350. shade(mainmenu%,4,
  1351. loaded%)
  1352.  i_flags%
  1353.      
  1354.  currenticon%=-1 
  1355. N      C%=q%+&80:
  1356.  "Wimp_WhichIcon",handle%(currentwindow%),C%,5<<21,1<<21
  1357.       C%=!C%
  1358.       
  1359. shade(i_flags%,0,1)
  1360.       
  1361. shade(i_flags%,1,1)
  1362.       
  1363. shade(i_flags%,6,1)
  1364.       
  1365. shade(i_flags%,8,1)
  1366.      
  1367.       C%=currenticon%
  1368.      
  1369.      
  1370.  C%>-1 
  1371.       
  1372. getcuri(C%)
  1373. C      
  1374. encodeicon(i_flags%,11,flags%,q%+28,ib_text%,ib_sprite%)
  1375.       $ib_buffersize%=
  1376.       $ib_validation%=""
  1377. $      
  1378. encodemenu(i_buffersize%)
  1379.       
  1380.  (flags%
  1381. &01)=0 
  1382. $       
  1383. shade(i_buffersize%,1,1)
  1384.       
  1385.        
  1386.  flags%
  1387. &100 
  1388. E        
  1389.  q%!32>0 $ib_validation%=$(q%!32):
  1390. tick(i_buffersize%,1)
  1391.        
  1392.       
  1393. -      $(i_flags%+28+12+24*14)="Fg colour"
  1394. -      $(i_flags%+28+12+24*15)="Bg colour"
  1395. ?      
  1396.  flags% 
  1397.  &02 
  1398.  $(i_flags%+28+12+24*14)="EOR colour"
  1399. ?      
  1400.  flags% 
  1401.  &20 
  1402.  $(i_flags%+28+12+24*15)="EOR colour"
  1403.       
  1404.  flags% 
  1405.  &40 
  1406. #       i_flags%?(28+11+24*14)=7
  1407. #       i_flags%?(28+11+24*15)=7
  1408. 6       
  1409. shade(i_flags%,14,1):
  1410. shade(i_flags%,15,1)
  1411.       
  1412. <       i_flags%?(28+11+24*14)=
  1413. foreback((flags%>>24)
  1414. <       i_flags%?(28+11+24*15)=
  1415. foreback((flags%>>28)
  1416.       
  1417.        
  1418. encodemenu(i_button%)
  1419.       
  1420. encodemenu(i_esg%)
  1421.      
  1422.  i_esg%
  1423. '     
  1424. tick(i_esg%,(flags%>>16)
  1425.  i_button%
  1426. *     
  1427. tick(i_button%,(flags%>>12)
  1428.      
  1429. shade(i_button%,12,1)
  1430.      
  1431. shade(i_button%,13,1)
  1432.  w_general%
  1433. .     
  1434.  currentwindow%=-1 
  1435.  deleted!
  1436.      
  1437. encodemenu(w_flags%)
  1438. -     $mb_workarea0%=
  1439. (q%!44)+","+
  1440. (q%!48)
  1441. -     $mb_workarea1%=
  1442. (q%!52)+","+
  1443. (q%!56)
  1444. #     $mb_minx%=
  1445. (q%!72 
  1446.  &FFFF)
  1447. !     $mb_miny%=
  1448. (q%!72 >> 16)
  1449. -     mwx0%=q%!20:mwy0%=q%!24+(q%!8-q%!16)
  1450. -     mwx1%=q%!20+(q%!12-q%!4):mwy1%=q%!24
  1451.      I%=w_colours%+28
  1452. B     
  1453.  J%=q%+36 
  1454.  q%+42:I%?11=(?J%<<4)
  1455. uncolour%(?J%):I%+=24:
  1456. /     $mb_wident%   =wident$(currentwindow%)
  1457. 4     $mb_templates%=
  1458. wident$(currentwindow%),10)
  1459.  i_general%
  1460.      
  1461. getcuri(currenticon%)
  1462. ?     
  1463.  flags%
  1464. &800000 currenticon%=-1 : 
  1465.  has been deleted!
  1466. I     C%=q%+&80:
  1467.  "Wimp_WhichIcon",handle%(currentwindow%),C%,4<<21,0
  1468.      
  1469.  !C%=-1 
  1470. /      $(i_general%!(28+24*2+12))="No icons"
  1471. .      
  1472.  A%=2 
  1473. shade(i_general%,A%,1):
  1474.      
  1475. N      C%=q%+&80:
  1476.  "Wimp_WhichIcon",handle%(currentwindow%),C%,5<<21,1<<21
  1477. )      
  1478.  !C%=-1 
  1479. shade(i_general%,4,1)
  1480.       
  1481.  currenticon%>-1 
  1482. <       $(i_general%!(28+24*2+12))="Icon #"+
  1483. currenticon%
  1484.       
  1485.        
  1486.  !C%=-1 
  1487. 1        $(i_general%!(28+24*2+12))="No icons"
  1488. "        
  1489. shade(i_general%,2,1)
  1490.        
  1491. 7        $(i_general%!(28+24*2+12))="Selected icons"
  1492.        
  1493.       
  1494.      
  1495.  i_sel%
  1496. M     C%=q%+&80:
  1497.  "Wimp_WhichIcon",handle%(currentwindow%),C%,5<<21,1<<21
  1498.      
  1499.  !C%=-1 
  1500.  C%!4=-1 
  1501. @       
  1502. shade(i_sel%,4,1):
  1503.  shade 'Same size' if <2 selected
  1504.      
  1505.      i_sel%!16=152
  1506.      
  1507.  currenticon%>-1 
  1508. +      $i_sel%="Icon":i_renumber%!16=160
  1509. =      $(i_sel%!(28+24*8+12))="Renumber #"+
  1510. $mb_renumber%
  1511.      
  1512.       $i_sel%="Selected"
  1513. >      $(i_sel%!(28+24*8+12))="Renumber":i_renumber%!16=128
  1514.       
  1515. shade(i_sel%,8,1)
  1516.      
  1517.      
  1518. encodemenu(i_flags%)
  1519.      
  1520. encodemenu(i_align%)
  1521.       
  1522. encodemenu(i_arrange%)
  1523.      
  1524. encodemenu(i_delete%)
  1525.  i_delete%
  1526.      
  1527.  currenticon%>-1 
  1528. $       $mb_delete%=
  1529. currenticon%
  1530.      
  1531.        $mb_delete%=""
  1532.      
  1533.  i_align%
  1534. #0     
  1535.  if <2 icons are selected then shade..
  1536. $M     I%=q%+&80:
  1537.  "Wimp_WhichIcon",handle%(currentwindow%),I%,5<<21,1<<21
  1538.      
  1539.  !I%=-1 
  1540.  I%!4=-1 
  1541.        
  1542. shade(i_align%,0,1)
  1543.        
  1544. shade(i_align%,1,1)
  1545.        
  1546. shade(i_align%,2,1)
  1547.        
  1548. shade(i_align%,3,1)
  1549.        
  1550. shade(i_align%,4,1)
  1551.        
  1552. shade(i_align%,5,1)
  1553.      
  1554.  i_arrange%
  1555. .0     
  1556.  if <2 icons are selected then shade..
  1557. /M     I%=q%+&80:
  1558.  "Wimp_WhichIcon",handle%(currentwindow%),I%,5<<21,1<<21
  1559.      
  1560.  !I%=-1 
  1561.  I%!4=-1 
  1562. 1!       
  1563. shade(i_arrange%,0,1)
  1564. 2!       
  1565. shade(i_arrange%,1,1)
  1566. 3!       
  1567. shade(i_arrange%,2,1)
  1568.      
  1569. 58     
  1570. shade(i_arrange%,2,1):
  1571.  shade 'Both' for now..
  1572.  w_flags%
  1573. 7$     !q%=handle%(currentwindow%)
  1574. 8$     
  1575.  "Wimp_GetWindowInfo",,q%
  1576.      
  1577.  I%=0 
  1578. :.      
  1579.  q%!32 
  1580.  (1<<I%) 
  1581. tick(w_flags%,I%)
  1582.      
  1583. <,     
  1584.  q%!32 
  1585.  (3<<8)  
  1586. tick(w_flags%,8)
  1587. =>     
  1588.  q%!32 
  1589.  (1<<10) 
  1590. tick(w_flags%,9)   :
  1591.  real colours
  1592. >=     
  1593.  q%!32 
  1594.  (1<<11) 
  1595. tick(w_flags%,10)  :
  1596.  back window
  1597. ?;     
  1598.  q%!32 
  1599.  (1<<12) 
  1600. tick(w_flags%,11)  :
  1601.  grab keys
  1602.      
  1603. encodemenu(t_flags%)
  1604.      
  1605.  currenticon%=-1 
  1606. BD      flags%=q%!64:
  1607. encodemenu(i_button%):
  1608. shade(i_button%,14,1)
  1609.      
  1610.       
  1611. shade(w_flags%,12,1)
  1612.      
  1613.      
  1614.  I%=14 
  1615. G6      
  1616.  q%!32 
  1617.  (1<<(I%+24-14)) 
  1618. tick(w_flags%,I%)
  1619.      
  1620.      
  1621.  q%!32 
  1622.  &80000000 
  1623.        
  1624. tick(w_flags%,13)
  1625.        
  1626. shade(w_flags%,0,1)
  1627.        
  1628. shade(w_flags%,2,1)
  1629.        
  1630. shade(w_flags%,3,1)
  1631.        
  1632. shade(w_flags%,7,1)
  1633.      
  1634. P/       
  1635.  I%=14 
  1636. shade(w_flags%,I%,1):
  1637.      
  1638.  t_flags%
  1639. SM     q%!60=q%!60 
  1640.  &24                     : 
  1641.  must be filled with border
  1642. T@     
  1643. encodeicon(t_flags%,6,q%!60,q%+76,tb_text%,tb_sprite%)
  1644.      $tb_buffersize%=
  1645. V&     
  1646. q%!60
  1647. &100 
  1648. tick(t_flags%,7)
  1649. W&     
  1650. q%!60
  1651. &200 
  1652. tick(t_flags%,8)
  1653.  w_scroll%
  1654.      
  1655. getcurw
  1656. Z(     
  1657. flags%
  1658. &100 
  1659. tick(w_scroll%,0)
  1660. [(     
  1661. flags%
  1662. &200 
  1663. tick(w_scroll%,1)
  1664.  m_spritelist%
  1665. ].     $mb_spritef%=spritef$:iflags%=&400000
  1666. ^(     
  1667. icon%<>-1 
  1668. geti(handle%,icon%)
  1669.      
  1670. iflags%
  1671. &400000
  1672. `$       
  1673. shade(m_spritelist%,1,1)
  1674. a$       
  1675. shade(m_spritelist%,2,1)
  1676.      
  1677. c4       renamesprite$=
  1678. iconstring(iflags%,idata%)
  1679. d&       $mb_rnsprite%=renamesprite$
  1680.      
  1681. f;     
  1682.  "Wimp_WhichIcon",spritelist%,q%,&200001,&200001
  1683. g+     
  1684.  !q%=-1 
  1685. shade(m_spritelist%,0,1)
  1686.  i_new%
  1687.      $ib_text%=""
  1688.      $ib_sprite%=""
  1689.  m_palette%
  1690.      
  1691.  def_menu% 
  1692. m7      
  1693.  0:C%=((w_colours%!(36+24*menus%!4)>>28)
  1694. n7      
  1695.  1:C%=  ((i_flags%!(36+24*menus%!8)>>28)
  1696.       
  1697. :C%=13
  1698.      
  1699.      
  1700. encodepalmenu(C%)
  1701.  t_file%
  1702. s;     I%=q%:
  1703.  "Wimp_WhichIcon",tempfile%,I%,5<<21,1<<21
  1704. t"     $mb_templates%=templatef$
  1705.      
  1706.  !I%=-1 
  1707. v3      
  1708. shade(t_file%,0,1):m$="Nothing":curw%=-1
  1709.      
  1710. xW      
  1711.  I%!4>-1 m$="Selection":curw%=-1 
  1712.  curw%=
  1713. backreffile(!I%):m$=wident$(curw%)
  1714. y?      
  1715. shade(t_sel%,2,(I%!4>-1)):
  1716. shade(t_sel%,3,(I%!4>-1))
  1717.      
  1718. {#     $(t_file%!(28+24*0+12))=m$
  1719.      
  1720. loaded% 
  1721. ~1      
  1722. shade(t_file%,:,1):
  1723. shade(t_file%,2,1)
  1724. 1      
  1725. shade(t_file%,4,1):
  1726. shade(t_file%,6,1)
  1727.      
  1728.  m_resize%
  1729.      
  1730.  currenticon%<>-1 
  1731. *       
  1732. geti(menuwindow%,currenticon%)
  1733. 9       
  1734. shell_IconPutData(m_resize%,5,
  1735. (iy1%-iy0%),0)
  1736. 9       
  1737. shell_IconPutData(m_resize%,6,
  1738. (ix1%-ix0%),0)
  1739.      
  1740. B       
  1741.  if no icons are selected and currenticon%=-1 then the
  1742. E       
  1743.  resize menu entry is greyed already, so a selection must
  1744. "       
  1745.  exist to reach here..
  1746. O       C%=q%+&80:
  1747.  "Wimp_WhichIcon",handle%(currentwindow%),C%,5<<21,1<<21
  1748.        
  1749.  C%>-1 
  1750. B         
  1751. geti(menuwindow%,C%!0):
  1752.  take coords of first icon..
  1753. ;         
  1754. shell_IconPutData(m_resize%,5,
  1755. (iy1%-iy0%),0)
  1756. ;         
  1757. shell_IconPutData(m_resize%,6,
  1758. (ix1%-ix0%),0)
  1759.        
  1760.      
  1761. shade(mh%,I%,T%):mh%+=28+8+24*I%:T%=(T%<>0)
  1762. ,!mh%=!mh% 
  1763. &400000) 
  1764.  (T% 
  1765.  (1<<22)):
  1766. tick(mh%,I%):mh%!(28+24*I%)=mh%!(28+24*I%)
  1767. select(h%,i%):!q%=h%:q%!4=i%:q%!8=&200000
  1768. 0  q%!12=&200000:
  1769.  "Wimp_SetIconState",,q%:
  1770. deselect(h%,i%)
  1771. B!q%=h%:q%!4=i%:q%!8=0:q%!12=&200000:
  1772.  "Wimp_SetIconState",,q%
  1773. encodeicon(iconmenu%,nmenu%,flags%,q%,itext%,isprite%)
  1774.  i_font%<0 
  1775. shade(iconmenu%,6,1)
  1776. $itext%="":$isprite%=""
  1777.  flags% 
  1778.  &01 $itext%=
  1779. iconstring(flags%,q%)
  1780.  (flags%
  1781.  &03)=&02 $isprite%=
  1782. iconstring(flags%,q%)
  1783.  flags% 
  1784.  &100 L%=q%!8 
  1785.  L%=12 : 
  1786.  returned to caller
  1787. I%=iconmenu%+28:J%=1
  1788. item%=0
  1789. nmenu%:
  1790. flags%
  1791. J% !I%=!I%
  1792. I%+=24:J%+=J%:
  1793. decodemenu(MenuHandle%,menus%)
  1794.  temp%,minix%,miniy%,maxix%,maxiy%,ref_cl%,nr_left_side%
  1795.  nr_right_side%,x_centre%,y_centre%
  1796.  MenuHandle% 
  1797.  mainmenu%
  1798.      
  1799.  !menus% 
  1800. D     
  1801. getpointer:
  1802.  &400D4,,proginfo%,mousex%-160,mousey%+64
  1803.      
  1804. spriteinfo
  1805.      
  1806.  menus%!4 
  1807. $             
  1808. movehandles(
  1809. #             
  1810. updatefile(1)
  1811.             
  1812. A     
  1813.  3:$mb_deft%=deftem$:$mb_deff%=deffile$:$mb_auto%=auto$
  1814. %            
  1815. deselect(options%,2)
  1816. %            
  1817. deselect(options%,3)
  1818. %            
  1819. deselect(options%,4)
  1820. %            
  1821. deselect(options%,8)
  1822. %            
  1823. deselect(options%,9)
  1824. *            
  1825. select(options%,finac%+2)
  1826. 0            
  1827.  interface% 
  1828. select(options%,8)
  1829. 0            
  1830.      hatch% 
  1831. select(options%,9)
  1832. 9            !q%=options%:
  1833.  "Wimp_GetWindowState",,q%
  1834. 4            
  1835.  "Wimp_CreateMenu",,!q%,q%!4,q%!16
  1836. G            
  1837.  "Wimp_SetCaretPosition",options%,5,0,0,-1,
  1838. $mb_deft%
  1839.      
  1840.  finac% 
  1841. /             
  1842. checkfull($mb_templates%)
  1843. 8                    
  1844. savetemplates($mb_templates%,
  1845. )                    
  1846. wipealltemplates
  1847. C             
  1848.  1:clear%=
  1849. getpointer:$mb_templates%=templatef$
  1850. P                    
  1851.  "Wimp_CreateMenu",,m_savetemp%,mousex%-112,mousey%+64
  1852. &             
  1853. wipealltemplates
  1854.             
  1855.      
  1856. finish:
  1857.      
  1858.  i_general%
  1859.      
  1860.  !menus% 
  1861. A     
  1862.  0:def_menu%=0:
  1863. getmenuposn:
  1864. windowmenu(currentwindow%)
  1865.      
  1866. getcurw
  1867. =            mx%=mmousex%-bx%:my%=mmousey%-by%:t$="":s$=""
  1868.             
  1869.  menus%!4 
  1870. /             
  1871.  0:t$=$ib_text%:fl%=&C700603D
  1872. 0                    ix%=16*(
  1873. (t$)+2):iy%=&30
  1874. 1             
  1875.  1:s$=$ib_sprite%:fl%=&0700601A
  1876. ,                    
  1877. getminxy(fl%,"",s$)
  1878. +                    ix%=minx%:iy%=miny%
  1879. @             
  1880.  menus%!8>-1 t$=
  1881. ((menus%!8)+136) 
  1882.  t$="?"
  1883. 5                    fl%=&C700603D:ix%=&28:iy%=&30
  1884. B             
  1885.  3:t$=$ib_text%:s$="Soptoff,opton":fl%=&1700B113
  1886. 0                    ix%=16*(
  1887. (t$)+4):iy%=&30
  1888. J             
  1889.  4:t$=" "+$ib_text%:s$="Sradiooff,radioon":fl%=&1700B113
  1890. 0                    ix%=16*(
  1891. (t$)+4):iy%=&30
  1892. /             
  1893.  5:t$=$ib_text%:fl%=&0700E13D
  1894. 0                    ix%=16*(
  1895. (t$)+2):iy%=&30
  1896. /             
  1897.  6:t$=$ib_text%:fl%=&C71F903D
  1898. 0                    ix%=16*(
  1899. (t$)+2):iy%=&30
  1900. /             
  1901.  7:t$=$ib_text%:fl%=&17006019
  1902. 0                    ix%=16*(
  1903. (t$)+2):iy%=&30
  1904.  --------------------##PH Interface mods ---------------------------------------------
  1905. 4             
  1906.  8:t$="    ":fl%=&17006139:s$="b1"
  1907. 0                    ix%=16*(
  1908. (t$)+2):iy%=&30
  1909. !             
  1910.  9:t$=$ib_text%
  1911. 0                    ix%=16*(
  1912. (t$)+2):iy%=&30
  1913. -                    s$="b0":fl%=&17006139
  1914. "             
  1915.  10:t$=$ib_text%
  1916. 1                     ix%=16*(
  1917. (t$)+2):iy%=&30
  1918. .                     s$="b3":fl%=&17006139
  1919. "             
  1920.  11:t$=$ib_text%
  1921. 1                     ix%=16*(
  1922. (t$)+2):iy%=&30
  1923. -                     s$="b3":fl%=&700E13D
  1924. "             
  1925.  12:t$=$ib_text%
  1926. 1                     ix%=16*(
  1927. (t$)+2):iy%=&30
  1928. .                     s$="b2":fl%=&17006139
  1929.               
  1930.  13:t$="     "
  1931. 1                     ix%=16*(
  1932. (t$)+2):iy%=&30
  1933. .                     s$="b6":fl%=&17006139
  1934.               
  1935.  14:t$="     "
  1936. 1                     ix%=16*(
  1937. (t$)+2):iy%=&30
  1938. .                     s$="b5":fl%=&17006139
  1939. G             
  1940.  15:t$=$ib_text%:s$="S3doptoff,3dopton":fl%=&1700B113
  1941. 1                     ix%=16*(
  1942. (t$)+4):iy%=&30
  1943. O             
  1944.  16:t$=" "+$ib_text%:s$="S3dradiooff,3dradioon":fl%=&1700B113
  1945. 1                     ix%=16*(
  1946. (t$)+4):iy%=&30
  1947. #             
  1948.  menus%!8 
  1949. L                     
  1950.  0:t$="":s$="3dleft" :fl%=&700601A:ix%=&28:iy%=&30
  1951. L                     
  1952.  1:t$="":s$="3dright":fl%=&700601A:ix%=&28:iy%=&30
  1953. L                     
  1954.  2:t$="":s$="3ddown" :fl%=&700601A:ix%=&28:iy%=&30
  1955. L                     
  1956.  3:t$="":s$="3dup"   :fl%=&700601A:ix%=&28:iy%=&30
  1957.                      
  1958.  --------------------##PH Interface mods ---------------------------------------------
  1959. .             
  1960. :t$="Untitled":fl%=&C700603D
  1961. '                    ix%=192:iy%=&30
  1962.             
  1963. M            q%!4=mx%-ix%/2:q%!8=my%-iy%*3/2:q%!12=q%!4+ix%:q%!16=q%!8+iy%
  1964. /            
  1965. t$>11 
  1966. s$>11 fl%=fl% 
  1967.             q%!20=fl%
  1968.             
  1969.  fl% 
  1970.  256 
  1971. 2             
  1972.  (((fl% 
  1973.  3)=3) 
  1974.  (fl% 
  1975.  257)) 
  1976. 3              q%!24=
  1977. workspace(
  1978. t$):$(q%!24)=t$
  1979. 3              q%!28=
  1980. workspace(
  1981. s$):$(q%!28)=s$
  1982.               q%!32=
  1983.              
  1984.               
  1985.  s$="" 
  1986. 4               q%!24=
  1987. workspace(
  1988. t$):$(q%!24)=t$
  1989.                q%!28=-1
  1990.                q%!32=
  1991.               
  1992. 4               q%!24=
  1993. workspace(
  1994. s$):$(q%!24)=s$
  1995. $               q%!28=spritearea%
  1996.                q%!32=
  1997.               
  1998.              
  1999.             
  2000. 4             
  2001.  fl% 
  2002.  1 $(q%+24)=t$ 
  2003.  $(q%+24)=s$
  2004.             
  2005. 7            
  2006.  "Wimp_CreateIcon",,q% 
  2007.  currenticon%
  2008. S            
  2009.  "Wimp_ForceRedraw",!q%,(q%!4)-50,(q%!8)-50,(q%!12)+50,(q%!16)+50
  2010.      
  2011.  menus%!4 
  2012.            
  2013. #            
  2014.  currenticon%>-1 
  2015. '             
  2016. getcuri(currenticon%)
  2017. &             
  2018. deleteicon(!q%,q%!4)
  2019. e             
  2020. decodeicon(menus%+8,q%+24,q%+28,ib_text%,ib_sprite%,ib_buffersize%,$ib_validation%)
  2021.  Y             currenticon%=
  2022. cricon(!q%,q%!8,q%!12,q%!16,q%!20,q%!24,q%!28,q%!32,q%!36)
  2023. !$             
  2024. encodemenu(i_sel%)
  2025.             
  2026.              I%=q%+&80
  2027. $K             
  2028.  "Wimp_WhichIcon",handle%(currentwindow%),I%,5<<21,1<<21
  2029.              
  2030.  !I%>-1 
  2031.               
  2032. getcuri(!I%)
  2033. ''              
  2034. deleteicon(!q%,q%!4)
  2035.               
  2036.  menus%!8 
  2037. )I               
  2038.  2,3,4,5,7,8,9,10,11:B%=1<<(menus%!8):A%=(q%!24) 
  2039. *4               
  2040.  12:B%=15<<12:A%=(menus%!12)<<12
  2041. +4               
  2042.  13:B%=31<<16:A%=(menus%!12)<<16
  2043. ,4               
  2044.  14:B%=15<<24:A%=(menus%!12)<<24
  2045. -4               
  2046.  15:B%=15<<28:A%=(menus%!12)<<28
  2047.               
  2048. /6              A%=A% 
  2049.  B%:q%!24=(q%!24 
  2050. B%)) 
  2051. 0O              
  2052. cricon(!q%,q%!8,q%!12,q%!16,q%!20,q%!24,q%!28,q%!32,q%!36)
  2053.               I%+=4
  2054.               
  2055.  !I%>-1
  2056. 3                
  2057. getcuri(!I%)
  2058. 4(               
  2059. deleteicon(!q%,q%!4)
  2060. 5,               q%!24=(q%!24 
  2061. B%)) 
  2062. 6P               
  2063. cricon(!q%,q%!8,q%!12,q%!16,q%!20,q%!24,q%!28,q%!32,q%!36)
  2064.                I%+=4
  2065.               
  2066. 9;              
  2067.  (menus%!8)>13 
  2068. encodepalmenu(menus%!12)
  2069. :%              
  2070. encodemenu(i_sel%)
  2071.              
  2072.             
  2073.            
  2074. >#            
  2075.  currenticon%>-1 
  2076. ?&            
  2077. getcuri(currenticon%)
  2078.             
  2079. flags%
  2080. A9              B%=
  2081. workspace(q%!36):$B%=text$:q%!28=B%
  2082. BK              
  2083. q%!32>0 B%=
  2084. workspace(
  2085. $(q%!32)+1):$B%=$(q%!32):q%!32=B%
  2086.             
  2087. D6            x0%=q%!8:y0%=q%!12:x1%=q%!16:y1%=q%!20
  2088.             
  2089.  menus%!8 
  2090. F)            
  2091.  -1:copyx%=16:copyy%=-16
  2092. G-            
  2093.  0:copyx%=x0%-x1%-8:copyy%=0
  2094. H-            
  2095.  1:copyx%=x1%-x0%+8:copyy%=0
  2096. I-            
  2097.  2:copyx%=0:copyy%=y1%-y0%+4
  2098. J-            
  2099.  3:copyx%=0:copyy%=y0%-y1%-4
  2100.             
  2101. L?            x0%+=copyx%:y0%+=copyy%:x1%+=copyx%:y1%+=copyy%
  2102. MQ            currenticon%=
  2103. cricon(!q%,x0%,y0%,x1%,y1%,q%!24,q%!28,q%!32,q%!36)
  2104.             
  2105. OR          I%=q%+&80:
  2106.  "Wimp_WhichIcon",handle%(currentwindow%),I%,5<<21,1<<21
  2107. P=            min_x%=1E8:max_x%=-1E8:min_y%=1E8:max_y%=-1E8
  2108.             
  2109.  !I%>-1
  2110. R#            
  2111. getcuri(!I%):I%+=4
  2112. S)            
  2113.  cx0%<min_x% min_x%=cx0%
  2114. T)            
  2115.  cx1%>max_x% max_x%=cx1%
  2116. U)            
  2117.  cy0%<min_y% min_y%=cy0%
  2118. V)            
  2119.  cy1%>max_y% max_y%=cy1%
  2120.             
  2121.             
  2122.  menus%!8 
  2123. Y)            
  2124.  -1:copyx%=16:copyy%=-16
  2125. Z3            
  2126.  0:copyx%=min_x%-max_x%-8:copyy%=0
  2127. [3            
  2128.  1:copyx%=max_x%-min_x%+8:copyy%=0
  2129. \3            
  2130.  2:copyx%=0:copyy%=max_y%-min_y%+4
  2131. ]3            
  2132.  3:copyx%=0:copyy%=min_y%-max_y%-4
  2133.             
  2134.             I%=q%+&80
  2135.             
  2136.  !I%>-1
  2137.             
  2138. getcuri(!I%)
  2139.             
  2140. flags%
  2141. c9              B%=
  2142. workspace(q%!36):$B%=text$:q%!28=B%
  2143. dK              
  2144. q%!32>0 B%=
  2145. workspace(
  2146. $(q%!32)+1):$B%=$(q%!32):q%!32=B%
  2147.             
  2148. f6            x0%=q%!8:y0%=q%!12:x1%=q%!16:y1%=q%!20
  2149. g?            x0%+=copyx%:y0%+=copyy%:x1%+=copyx%:y1%+=copyy%
  2150. hF            
  2151. cricon(!q%,x0%,y0%,x1%,y1%,q%!24,q%!28,q%!32,q%!36)
  2152. i<            
  2153. deselect(handle%(currentwindow%),!I%):I%+=4
  2154.             
  2155.             
  2156.            
  2157. m*            h%=handle%(currentwindow%)
  2158.             
  2159.  menus%!8 
  2160. o#             
  2161.  0:ix%=-dx%:iy%=0
  2162. p#             
  2163.  1:ix%=+dx%:iy%=0
  2164. q#             
  2165.  2:iy%=+dy%:ix%=0
  2166. r#             
  2167.  3:iy%=-dy%:ix%=0
  2168.             
  2169. t#            
  2170.  currenticon%=-1 
  2171.              I%=q%+&80
  2172. vK             
  2173.  "Wimp_WhichIcon",handle%(currentwindow%),I%,5<<21,1<<21
  2174.              
  2175.  !I%>-1
  2176. x1              
  2177. moveicon(h%,!I%,ix%,iy%):I%+=4
  2178.              
  2179.             
  2180. {3             
  2181. moveicon(h%,currenticon%,ix%,iy%)
  2182.             
  2183.            
  2184. ~7             
  2185.  PH mod - add resize dialog for icons
  2186.            
  2187. "             
  2188. Handle_Same_size
  2189.            
  2190.              I%=q%+&80
  2191. K             
  2192.  "Wimp_WhichIcon",handle%(currentwindow%),I%,5<<21,1<<21
  2193. 8             J%=q%+&400:J%!0=handle%(currentwindow%)
  2194. $             
  2195.  currenticon%=-1 
  2196. 4               J%!4=
  2197. pick_referenceicon(J%!0,I%)
  2198.              
  2199. $               J%!4=currenticon%
  2200.              
  2201. K             
  2202.  "Wimp_GetIconState",,J% :
  2203.  get position of first icon..
  2204.              
  2205.  menus%!8 
  2206. !             
  2207.  left align
  2208.                minix%=J%!8
  2209.                
  2210.  !I%>-1
  2211.                  J%!4=!I%
  2212. /                 
  2213.  "Wimp_GetIconState",,J%
  2214. ;                 
  2215. moveicon(!J%,!I%,minix%-J%!8,0):I%+=4
  2216.                
  2217. "             
  2218.  right align
  2219.                maxix%=J%!16
  2220.                
  2221.  !I%>-1
  2222.                  J%!4=!I%
  2223. /                 
  2224.  "Wimp_GetIconState",,J%
  2225. <                 
  2226. moveicon(!J%,!I%,maxix%-J%!16,0):I%+=4
  2227.                
  2228.               
  2229.  top align
  2230.                miniy%=J%!20
  2231.                
  2232.  !I%>-1
  2233.                  J%!4=!I%
  2234. /                 
  2235.  "Wimp_GetIconState",,J%
  2236. <                 
  2237. moveicon(!J%,!I%,0,miniy%-J%!20):I%+=4
  2238.                
  2239. #             
  2240.  bottom align
  2241.                maxiy%=J%!12
  2242.                
  2243.  !I%>-1
  2244.                  J%!4=!I%
  2245. /                 
  2246.  "Wimp_GetIconState",,J%
  2247. <                 
  2248. moveicon(!J%,!I%,0,maxiy%-J%!12):I%+=4
  2249.                
  2250.              
  2251.  V Centre
  2252. 2               x_centre%=((J%!16-J%!8)/2)+J%!8
  2253.                
  2254.  !I%>-1
  2255.                  J%!4=!I%
  2256. /                 
  2257.  "Wimp_GetIconState",,J%
  2258. O                 
  2259. moveicon(!J%,!I%,x_centre%-((J%!16-J%!8)/2+J%!8),0):I%+=4
  2260.                
  2261.              
  2262.  H Centre
  2263. .               y_centre%=((J%!12+J%!20)/2)
  2264.                
  2265.  !I%>-1
  2266.                  J%!4=!I%
  2267. /                 
  2268.  "Wimp_GetIconState",,J%
  2269. N                 
  2270. moveicon(!J%,!I%,0,y_centre%+
  2271. (((J%!12+J%!20)/2))):I%+=4
  2272.                
  2273.              
  2274.            
  2275.              I%=q%+&80
  2276. K             
  2277.  "Wimp_WhichIcon",handle%(currentwindow%),I%,5<<21,1<<21
  2278. 8             J%=q%+&400:J%!0=handle%(currentwindow%)
  2279. $             
  2280.  currenticon%=-1 
  2281. 4               J%!4=
  2282. pick_referenceicon(J%!0,I%)
  2283.              
  2284. $               J%!4=currenticon%
  2285.              
  2286. %             reference_icon%=J%!4
  2287.              
  2288.  menus%!8 
  2289. >             
  2290. arrange_horizontal(J%!0,reference_icon%)
  2291. <             
  2292. arrange_vertical(J%!0,reference_icon%)
  2293.              
  2294.            
  2295.             
  2296.  menus%!8=-1 
  2297. $             
  2298.  currenticon%=-1 
  2299.               I%=q%+&80
  2300. L              
  2301.  "Wimp_WhichIcon",handle%(currentwindow%),I%,5<<21,1<<21
  2302.               
  2303.  !I%>-1
  2304. A               
  2305. deleteicon(handle%(currentwindow%),!I%):I%+=4
  2306.               
  2307.              
  2308. C              
  2309. deleteicon(handle%(currentwindow%),currenticon%)
  2310.              
  2311.             
  2312. #             
  2313.  $mb_delete%="" 
  2314.              
  2315. I              !q%=handle%(currentwindow%):
  2316.  "Wimp_GetWindowInfo",,q%
  2317. (              
  2318.  q%!88>
  2319. $mb_delete% 
  2320. D               
  2321. deleteicon(handle%(currentwindow%),
  2322. $mb_delete%)
  2323.               
  2324. >               
  2325. warning(q%,2,"Icon number out of range")
  2326.               
  2327.              
  2328.             
  2329.            
  2330. (            renumber%=
  2331. $mb_renumber%
  2332. @            
  2333. renumber(currentwindow%,currenticon%,renumber%)
  2334. =            
  2335.  renumber%<9999 $mb_renumber%=
  2336. (renumber%+1)
  2337.            
  2338. I     
  2339.  3:I%=q%+&40:!q%=handle%(currentwindow%):q%!8=1<<21:q%!12=1<<21
  2340. 6            
  2341.  "Wimp_WhichIcon",!q%,I%,5<<21,0<<21
  2342. E            
  2343.  !I%>-1:q%!4=!I%:
  2344.  "Wimp_SetIconState",,q%:I%+=4:
  2345. E     
  2346.  4:I%=q%+&40:!q%=handle%(currentwindow%):q%!8=0:q%!12=1<<21
  2347. 6            
  2348.  "Wimp_WhichIcon",!q%,I%,5<<21,1<<21
  2349. E            
  2350.  !I%>-1:q%!4=!I%:
  2351.  "Wimp_SetIconState",,q%:I%+=4:
  2352. 1     
  2353.  5:I%=q%+48:!q%=handle%(currentwindow%)
  2354. +            
  2355.  "Wimp_GetWindowInfo",,q%
  2356. 3            A%=q%!44:B%=q%!48:C%=q%!52:D%=q%!56
  2357. 2            
  2358.  "Wimp_WhichIcon",!q%,I%,1<<23,0
  2359.             
  2360.  !I%<>-1
  2361.              
  2362. getcuri(!I%)
  2363.              
  2364.  ((cx0%<A% 
  2365.  cx1%<A%) 
  2366.  (cx0%>C% 
  2367.  cx1%>C%)) 
  2368.  ((cy0%<B% 
  2369.  cy1%<B%) 
  2370.  (cy0%>D% 
  2371.  cy1%>D%)) 
  2372. deleteicon(!q%,!I%)
  2373.              I%+=4
  2374.             
  2375. <     
  2376. deletewindow(currentwindow%):currentwindow%=-1
  2377.      
  2378.  w_general%
  2379.      
  2380.  !menus% 
  2381. A     
  2382.  0:def_menu%=1:
  2383. getmenuposn:
  2384. windowmenu(currentwindow%)
  2385. +     
  2386. decodemenu(w_flags%,menus%+4)
  2387. ,     
  2388.  menus%!4<>-1 
  2389.  menus%!8<>-1 
  2390. -              !q%=handle%(currentwindow%)
  2391. -              
  2392.  "Wimp_GetWindowInfo",,q%
  2393. D              q%?(36+menus%!4)=menus%!8:
  2394. encodepalmenu(menus%!8)
  2395. &              curw%=currentwindow%
  2396. 0              
  2397. crwindow(q%+4,wident$(curw%))
  2398. &              
  2399. deletewindow(curw%)
  2400.             
  2401. )     
  2402. setworkarea(currentwindow%)
  2403.      
  2404.  $mb_wident%="" 
  2405. ;             
  2406. warning(q%,2,"Templates must be named")
  2407.             
  2408. A             
  2409. checkident($mb_wident%,wident$(currentwindow%))
  2410. 4             wident$(currentwindow%)=$mb_wident%
  2411.             
  2412. <     
  2413. deletewindow(currentwindow%):currentwindow%=-1
  2414.      
  2415.  w_flags%
  2416.      
  2417.  !menus%=-1 
  2418. $     !q%=handle%(currentwindow%)
  2419.     $     
  2420.  "Wimp_GetWindowInfo",,q%
  2421.      
  2422.  !menus% 
  2423.      
  2424. decodetitle(1)
  2425.      
  2426.  1:q%!32=q%!32
  2427.      
  2428.  2:q%!32=q%!32
  2429.      
  2430.  3:q%!32=q%!32
  2431.      
  2432.  4:q%!32=q%!32
  2433.      
  2434.  5:q%!32=q%!32
  2435.      
  2436.  6:q%!32=q%!32
  2437.      
  2438.  7:q%!32=q%!32
  2439.      
  2440.  8:q%!32=q%!32
  2441.             
  2442.  menus%!4 
  2443. $            
  2444.  0:q%!32=q%!32
  2445. $            
  2446.  1:q%!32=q%!32
  2447.             
  2448.             
  2449.      
  2450.  9:q%!32=q%!32
  2451.      
  2452.  10:q%!32=q%!32
  2453.      
  2454.  11:q%!32=q%!32
  2455. &1000
  2456. 1     
  2457.  menus%!4<>-1 q%!64=(menus%!4)<<12
  2458. #     
  2459.  13:q%!32=q%!32
  2460. &80000000
  2461. <     
  2462.  14,15,17,18,19,20:q%!32=q%!32 
  2463.  (1<<(10+!menus%))
  2464. !     
  2465. decodetitle(1<<26)
  2466.      
  2467.      curw%=currentwindow%
  2468. ""     
  2469. changewindow(q%+4,curw%)
  2470.  m_spritelist%
  2471.      
  2472.  !menus% 
  2473. %W     
  2474.  0:A%=
  2475. warning(q%,3,"Are you sure you want to delete the selected sprites ?")
  2476. &'            
  2477.  A%=1 
  2478. godeletesprites
  2479. '+     
  2480. $mb_rnsprite%<>renamesprite$
  2481. (L            
  2482.  "OS_SpriteOp",&11B,spritearea%,renamesprite$,mb_rnsprite%
  2483.             
  2484. spriteinfo
  2485.           
  2486. ++     
  2487. $mb_rnsprite%<>renamesprite$
  2488. ,L            
  2489.  "OS_SpriteOp",&11A,spritearea%,renamesprite$,mb_rnsprite%
  2490.             
  2491. spriteinfo
  2492.           
  2493. /3     
  2494. loadsprites($mb_spritef%):
  2495. spriteinfo
  2496. 0%     
  2497. checkfull($mb_spritef%)
  2498. 1,            
  2499. savesprites($mb_spritef%,
  2500. 24     
  2501. mergesprites($mb_spritef%):
  2502. spriteinfo
  2503.      
  2504.  t_file%
  2505.      
  2506.  !menus% 
  2507. 6B     
  2508.  0:J%=q%+40:
  2509.  "Wimp_WhichIcon",tempfile%,J%,5<<21,1<<21
  2510.             
  2511.  menus%!4 
  2512. 8a            
  2513.  !J%>-1:B%=
  2514. backreffile(!J%):
  2515. front(handle%(B%)):
  2516. setfileopen(B%,1):J%+=4:
  2517. 9a            
  2518.  !J%>-1:B%=
  2519. backreffile(!J%):q%!36=handle%(B%):
  2520.  "Wimp_CloseWindow",,q%+36
  2521. :1                   
  2522. setfileopen(B%,0):J%+=4:
  2523. ;5            
  2524.  2:a$=$mb_wident%:W%=
  2525. matchident(a$)
  2526. <R                   
  2527.  a$="" 
  2528. warning(q%,2,"Templates must be named")
  2529.  1,""
  2530. =S                   
  2531.  W%<>-1 
  2532. warning(q%,2,"Template already exists")
  2533.  1,""
  2534. >E                   !q%=handle%(curw%):
  2535.  "Wimp_GetWindowInfo",,q%
  2536. ?:                   
  2537. crwindow(q%+4,a$,0):
  2538. updatefile(0)
  2539. @5            
  2540.  3:a$=$mb_wident%:W%=
  2541. matchident(a$)
  2542. AR                   
  2543.  a$="" 
  2544. warning(q%,2,"Templates must be named")
  2545.  1,""
  2546. B_                   
  2547.  W%<>-1 
  2548.  W%<>curw% 
  2549. warning(q%,2,"Template already exists")
  2550.  1,""
  2551. C?                   wident$(curw%)=a$:
  2552. updatefilename(curw%)
  2553. DU            
  2554.  !J%>-1:
  2555. deletewindow(
  2556. backreffile(!J%)):J%+=4:
  2557. updatefile(0)
  2558.             
  2559. F>     
  2560.  1:I%=q%+40:
  2561.  "Wimp_WhichIcon",tempfile%,I%,5<<21,0
  2562. G8            
  2563.  !I%>-1:
  2564. select(tempfile%,!I%):I%+=4:
  2565. HB     
  2566.  2:I%=q%+40:
  2567.  "Wimp_WhichIcon",tempfile%,I%,5<<21,1<<21
  2568. I:            
  2569.  !I%>-1:
  2570. deselect(tempfile%,!I%):I%+=4:
  2571. J-     
  2572. getpointer:
  2573. newdef($mb_wident%)
  2574. Ko     
  2575.  4:A%=
  2576. warning(q%,3,"Are you sure you want to clear all of the templates ?"):
  2577.  A%=1 
  2578. wipealltemplates
  2579. L7     
  2580.  "XOS_File",5,$mb_templates% 
  2581.  T%,,R%;F%
  2582. M#            typ%=(R%>>8) 
  2583.  &FFF
  2584.             
  2585.              
  2586. P1              
  2587. warning(q%,1,
  2588. string0(T%+4))
  2589.              
  2590.  T%=1
  2591. Rs              
  2592.  typ%<>&FEC A%=
  2593. warning(q%,3,"This is not a template file - Are you sure you want to load it ?")
  2594. SC              
  2595.  typ%=&FEC 
  2596.  A%=1 
  2597. loadtemplates($mb_templates%)
  2598.              
  2599. UF              
  2600. warning(q%,1,"File "+$mb_templates%+" not found")
  2601.              
  2602. W'     
  2603. checkfull($mb_templates%)
  2604. X0            
  2605. savetemplates($mb_templates%,
  2606.      
  2607. loadsprites(f$):
  2608.  "OS_SpriteOp",&10A,spritearea%,f$
  2609.  f$<>"<Wimp$Scrap>" spritef$=f$
  2610.  following added by Paul Hobbs to redraw all windows after loading
  2611.  a sprite file so that sprites appear immediately
  2612. "Wimp_ForceRedraw",-1,0,0,10000,10000
  2613. savesprites(f$,safe%):
  2614.  "OS_SpriteOp",&10C,spritearea%,f$
  2615.  safe% 
  2616. spritef$=f$
  2617.  $spritef%<>
  2618. spfname(spritef$) 
  2619. h"  $spritef%=
  2620. spfname(spritef$)
  2621. i.  !q%=spritelist%:
  2622. "Wimp_CloseWindow",,q%
  2623. front(spritelist%)
  2624. mergesprites(f$)
  2625.  "OS_SpriteOp",&10B,spritearea%,f$
  2626.  following added by Paul Hobbs to redraw all windows after loading
  2627.  a sprite file so that sprites appear immediately
  2628. "Wimp_ForceRedraw",-1,0,0,10000,10000
  2629. filetype(f$)
  2630.  f%,type%
  2631.  "OS_File",17,f$ 
  2632.  type%,,f%
  2633.  type%<>1 
  2634.  = -2
  2635.  (f%>>>20)=&FFF 
  2636.  = (f%>>>8)
  2637. &FFF 
  2638.  = -1
  2639. decodetitle(bit%)
  2640.  menus%!4 
  2641.  -1:q%!32=q%!32
  2642. :q%!32=q%!32
  2643. menus%!4=8 menus%!4=9 : 
  2644.  bodge for 'right-justified' bit
  2645. menus%!4=7 menus%!4=8 : 
  2646.  bodge for 'indirected' bit
  2647. decodeicon(menus%+4,q%+60,q%+76,tb_text%,tb_sprite%,tb_buffersize%,"")
  2648. setxy(
  2649.  y%,a$,sep$)
  2650. a$:y%=
  2651. a$,sep$)+1)
  2652. setwork(q%,v%)
  2653. "!q%=
  2654. $v%:q%!4=
  2655. $(v%+
  2656. $v%,","))
  2657. setworkarea(curw%)
  2658. h%=handle%(curw%)
  2659. setwork(q%,mb_workarea0%)
  2660. setwork(q%+8,mb_workarea1%)
  2661.  "Wimp_SetExtent",h%,q%
  2662. 4min% = (
  2663. $mb_minx% 
  2664.  &FFFF) 
  2665. $mb_miny% << 16)
  2666. &!q%=h%:
  2667.  "Wimp_GetWindowInfo",,q%
  2668.  q%!72<>min% 
  2669. >  q%!72=min%:
  2670.  "Wimp_CreateWindow",,q%+4 
  2671.  handle%(curw%)
  2672. 1  !q%=handle%(curw%):
  2673.  "Wimp_OpenWindow",,q%
  2674. '  !q%=h%:
  2675.  "Wimp_DeleteWindow",,q%
  2676. godeletesprites
  2677. @I%=q%+&40:
  2678.  "Wimp_WhichIcon",spritelist%,I%,&200001,&200001
  2679. !q%=spritelist%
  2680.  !I%<>-1
  2681. 'q%!4=!I%:
  2682.  "Wimp_GetIconState",,q%
  2683.  "OS_SpriteOp",&119,spritearea%,q%+28
  2684. I%+=4:
  2685. spriteinfo
  2686. decodeicon(menus%,fptr%,qptr%,mb_text%,mb_sprite%,mb_buffersize%,v$)
  2687.  !menus% 
  2688.  0:oldf%=!fptr%
  2689.        
  2690.  menus%!4 
  2691. #       
  2692.  -1:!fptr%=!fptr% 
  2693.        
  2694. :!fptr%=!fptr%
  2695. 7                 
  2696.  (oldf%
  2697. &01)=0 !fptr%=!fptr%
  2698.        
  2699. 6       
  2700. puticonstring(oldf%,fptr%,qptr%,$mb_text%)
  2701.  1:oldf%=!fptr%
  2702.        
  2703.  menus%!4 
  2704. #       
  2705.  -1:!fptr%=!fptr% 
  2706. %       
  2707. :!fptr%=(!fptr%
  2708.        
  2709. 7       
  2710.  !fptr% 
  2711.  &01 A$=$mb_text% 
  2712.  A$=$mb_sprite%
  2713. /       
  2714. puticonstring(oldf%,fptr%,qptr%,A$)
  2715.  2:!fptr%=!fptr%
  2716.  3:!fptr%=!fptr%
  2717.  4:!fptr%=!fptr%
  2718.  5:!fptr%=!fptr%
  2719.  "Wimp_DecodeMenu",,i_font%,menus%+4,
  2720. 100," ")
  2721. ,,,fontname$
  2722. :       
  2723.  menus%!4<>-1 
  2724.  menus%!8=4 fontname$+=" point"
  2725.        
  2726.  fontname$="" 
  2727. "            !fptr%=!fptr%
  2728.             fptr%?3=&D7
  2729.        
  2730.  !fptr%=!fptr%
  2731. )            
  2732. fontname$,5)="point" 
  2733. "                 I%=
  2734. fontname$
  2735. 3                 
  2736. I%=I%-1:
  2737. fontname$,I%,1)="."
  2738. ,                 psiz%=
  2739. fontname$,I%+1)
  2740. /                 fontname$=
  2741. fontname$,I%-1)
  2742.             
  2743.  psiz%=12
  2744.             
  2745. 2            fptr%?3=
  2746. findfont(fontname$,psiz%)
  2747.        
  2748.  7:!fptr%=!fptr%
  2749. !fptr%
  2750. &100 B$=$!qptr%
  2751. B$=$qptr%
  2752. ?       
  2753. menus%!4=-1 !fptr%=!fptr%
  2754. &100 
  2755.  !fptr%=!fptr%
  2756.        
  2757. !fptr%
  2758. %         qptr%!8=
  2759. $mb_buffersize%
  2760. >         !qptr%=
  2761. workspace(qptr%!8):$!qptr%=
  2762. B$,qptr%!8-1)
  2763.          
  2764.  v$="" 
  2765.               qptr%!4=-1
  2766. #         
  2767.  (!fptr%
  2768. &03)=&02 
  2769. *                   qptr%!4=spritearea%
  2770. ;              
  2771.  qptr%!4=
  2772. workspace(
  2773. v$+1):$(qptr%!4)=v$
  2774.               
  2775.          
  2776.        
  2777.  $qptr%=
  2778. B$,11)
  2779.        
  2780. %       
  2781.  (!fptr% 
  2782.  &103) = &102 
  2783. 0         
  2784.  qptr%!4 > 1 !fptr%=!fptr% 
  2785.        
  2786.  9:!fptr%=!fptr%
  2787.  10:!fptr%=!fptr%
  2788.  11:!fptr%=!fptr%
  2789.  12:!fptr%=
  2790. field(!fptr%,12,4,menus%!4)
  2791.  13:!fptr%=
  2792. field(!fptr%,16,5,menus%!4)
  2793.  14:!fptr%=
  2794. field(!fptr%,24,4,menus%!4):
  2795. encodepalmenu(menus%!4)
  2796.  15:!fptr%=
  2797. field(!fptr%,28,4,menus%!4):
  2798. encodepalmenu(menus%!4)
  2799. field(flg%,b0%,nb%,i%)
  2800. i%<>-1 
  2801.  =flg%
  2802. (((1<<nb%)-1)<<b0%)
  2803. (i%<<b0%)
  2804. =flg%
  2805. puticonstring(oldf%,fptr%,qptr%,A$)
  2806.  oldf%
  2807. &100 
  2808. ;     
  2809.  (!fptr% 
  2810.  &03)=&02 qptr%!4=-1 : 
  2811.  no sprite area
  2812.      
  2813. A$<qptr%!8 
  2814. +        $!qptr%=A$:!fptr%=!fptr%
  2815. &100:
  2816.      
  2817. A$<12 
  2818. +        $qptr%=A$:!fptr%=!fptr%
  2819. &100:
  2820.      
  2821. !fptr%=!fptr% 
  2822.  &100
  2823. *!qptr%=
  2824. workspace(
  2825. A$+1):qptr%!8=
  2826. $!qptr%=A$
  2827.  (oldf%
  2828. &100)=0 qptr%!4=-1 : 
  2829.  keep old validation string, if any
  2830. R------------------------------------------------------------------------------
  2831. renumber(curw%,curi%,newi%):
  2832.  curi%<0 
  2833.  newi%<0 
  2834.  M%,N%:!q%=handle%(curw%):
  2835.  "Wimp_GetWindowInfo",,q%
  2836.  q%!88 <= newi% 
  2837. warning(q%,2,"Icon number out of range"):
  2838. +M%=q%+4+88+32*curi%:N%=q%+4+88+32*newi%
  2839.  I%=0 
  2840.  M%!I%,N%!I%:
  2841. crwindow(q%+4,wident$(curw%)):
  2842. deletewindow(curw%)
  2843. R------------------------------------------------------------------------------
  2844. dialogue(handle%,mx%,my%)
  2845. getw(handle%):
  2846. open(handle%,mx%,my%+y0%-y1%,mx%+x1%-x0%,my%,0,0,-1)
  2847.  "Wimp_SetCaretPosition",handle%,-1,0,0,&3000000,0:
  2848. getw(handle%)
  2849.  x0%,y0%,x1%-x0%,y1%-y0%+40:dialogue%=handle%
  2850. R------------------------------------------------------------------------------
  2851. standardwindow(brx%,bry%,n$)
  2852.  I%=0 
  2853. 4:q%!I%=default%!I%:
  2854. :q%!84=0:q%!64=spritearea%
  2855. NI%=q%!8-q%!0:q%!0=brx%:q%!8=q%!0+I%:I%=q%!4-q%!12:q%!12=bry%:q%!4=q%!12+I%
  2856. $(q%+72)=n$:
  2857. createwindow(brx%,bry%,wident$)
  2858. standardwindow(brx%,bry%,wident$)
  2859. crwindow(q%,wident$,1)
  2860. crwindow(q%,wident$,F%)
  2861.  IF handle%(handleSP%)=-1 IF FNwarning(q%,1,FNmsg0("TEMPFL"))OR1 ERROR 1,""
  2862.  "Wimp_CreateWindow",,q% 
  2863.  handle%
  2864. Am%=handleSP%:handleSP%=handle%(handleSP%):handle%(m%)=handle%
  2865.  !q%=handle%:
  2866.  "Wimp_GetWindowState",,q%:
  2867.  "Wimp_OpenWindow",,q%
  2868. )currentwindow%=m%:wident$(m%)=wident$
  2869. currenticon%=-1
  2870. whichwindow(handle%)
  2871.  handle%=-1 
  2872. handle%(nh%+1)=handle%
  2873. &I%=-1:
  2874. I%+=1:
  2875.  handle%(I%)=handle%
  2876. I%>nh%
  2877. whichsprite(handle%)
  2878.  handle%=-1 
  2879. spritew%(ns%+1)=handle%
  2880. 'I%=-1:
  2881. I%+=1:
  2882.  spritew%(I%)=handle%
  2883. I%>ns%
  2884. deletewindow(I%):!q%=handle%(I%):handle%(I%)=handleSP%:handleSP%=I%
  2885.  "Wimp_DeleteWindow",,q%:wident$(I%)=""
  2886. 9I%=0:C%=
  2887.  I%<=nh% 
  2888.  C%:C%=(wident$(I%)=""):I%+=1:
  2889.  C% curbuff%=initbuf%:
  2890. setloaded(
  2891. deletesprite(I%)
  2892.  ((paint_drag%>>16)
  2893. &7FFF)=I% paint_drag%=-1
  2894.  sprSP2%=I% 
  2895.      sprSP2%=nsprite%(I%)
  2896.  i%=sprSP2%:
  2897. i1%=i%:i%=nsprite%(i%):
  2898. i%=I%
  2899. &#     nsprite%(i1%)=nsprite%(i%)
  2900. seti(spritelist%,spritei%(I%)
  2901. 1,0,&600000)
  2902. !q%=spritew%(I%)
  2903. *!spritew%(I%)=sprSP%:sprSP%=I%
  2904.  "Wimp_DeleteWindow",,q%
  2905. getcurw:!q%=handle%(currentwindow%):
  2906.  "Wimp_GetWindowState",,q%
  2907. info(q%+4):
  2908. getcuri(currenticon%):!q%=handle%(currentwindow%)
  2909. 00q%!4=currenticon%:
  2910.  "Wimp_GetIconState",,q%
  2911. 1;cx0%=q%!8:cy0%=q%!12:cx1%=q%!16:cy1%=q%!20:flags%=q%!24
  2912.   flags% 
  2913.  &100 text$=$(q%!28) 
  2914.  text$=$(q%+28)
  2915.  (flags% 
  2916.  &103)=&103 sprite$=
  2917. getcommand(q%!32,"S") 
  2918.  sprite$=text$
  2919. getcommand(v%,c$):
  2920.  v%<=0 
  2921.  ="" 
  2922. 6$I%=
  2923. ";"+$v%,";"+c$):
  2924.  I%=0 
  2925. $(v%+I%),
  2926. $(v%+I%)+";",";")-1)
  2927. iconstring(flg%,p%):
  2928.  i%,i$
  2929.  flg% 
  2930.  &100 i$=$!p% 
  2931.  i%=p%?12:p%?12=13:i$=$p%:p%?12=i%
  2932. getpointer:
  2933.  "Wimp_GetPointerInfo",,q%:mousex%=!q%:mousey%=q%!4
  2934. <-buttons%=q%!8:handle%=q%!12:icon%=q%!16:
  2935. =R------------------------------------------------------------------------------
  2936. warning(b%,f%,a$):!b%=1:$(b%+4)=a$+
  2937.  "Wimp_DragBox",,-1
  2938. ?Bmenuhandle%=-1:
  2939.  "Wimp_ReportError",b%,f%,"FormEd2" 
  2940.  ,A%:=A%
  2941. errorbox(err%,err$,erl%)
  2942. editoff("")
  2943. B!Err%=err%:Err$=err$:Erl%=erl%
  2944. inerror% 
  2945. errordisplay(err%,err$,erl%)
  2946. inerror%=
  2947.  "Wimp_DragBox",,-1 : dragtype%=0:pdrag%=-1
  2948.  dialogue%<>-1 
  2949. close(dialogue%)
  2950. G0!q%=err%:$(q%+4)=err$+" [Ref. "+
  2951. erl%+"]"+
  2952.  "Wimp_ReportError",q%,1,"FormEd2"
  2953. inerror%=
  2954. errordisplay(err%,err$,erl%)
  2955. M0!q%=err%:$(q%+4)=err$+" [Ref. "+
  2956. erl%+"]"+
  2957.  "Wimp_ReportError",q%,2,"FormEd2"
  2958. finish
  2959. finish
  2960.  fontcounts%?I%>0:
  2961.  "Font_LoseFont",I%:fontcounts%?I%-=1:
  2962.  "Wimp_CloseDown"
  2963. XR------------------------------------------------------------------------------
  2964. workspace(L%):L%+=1
  2965.  curbuff%+L%>buffer%+maxbuf% 
  2966.  1,"No more buffer space"
  2967.  (buffer%+maxbuf%-curbuff%)<256 
  2968. warning(q%+100,1,"Buffer space running short, Save off quick ! !")
  2969. curbuff%+=L%:=curbuff%-L%
  2970. ]R------------------------------------------------------------------------------
  2971. findfont(f$,p):
  2972.  "Font_FindFont",,f$,p*16,p*16,0,0 
  2973. _Jfontcounts%?f%+=1:
  2974.  fontcounts%?f%>=255 
  2975.  1,"Internal font table full"
  2976. aR------------------------------------------------------------------------------
  2977. spriteinfo
  2978. d8I%=q%+4:
  2979.  "Wimp_WhichIcon",spritelist%,I%,&800000,0
  2980.  !I%<>-1:I%!-4=spritelist%:
  2981.  "Wimp_DeleteIcon",,I%-4:I%+=4:
  2982. f:i%=sprSP2%:
  2983.  i%<>-1:spritei%(i%)=-1:i%=nsprite%(i%):
  2984. g-!q%=spritelist%:
  2985.  "Wimp_CloseWindow",,q%
  2986. h $spritef%=
  2987. spfname(spritef$)
  2988.  "OS_SpriteOp",&108,spritearea% 
  2989.  ,,,nsprites%
  2990. j?maxspwidth%=scrx1%-80:curx%=0:cury%=0:maxw%=0:maxh%=0:ix%=0
  2991.  nsprites%>0 
  2992.  I%=1 
  2993.  nsprites%
  2994. readsprite(I%)
  2995. nG  flags%=&1701A429:text$=$spritename%:
  2996. getminxy(flags%,text$,text$)
  2997.  minx%>spw% spwx%=minx%+32 
  2998.  spwx%=spw%+32
  2999.  curx%+spwx%>maxspwidth% 
  3000. lineofsprites
  3001.   spwx%(ix%)=spwx%
  3002.  -32-sph%-miny%-8<maxh% maxh%=-32-sph%-miny%-8
  3003. sE  spw%(ix%)=spw%:sph%(ix%)=sph%:minx%(ix%)=minx%:miny%(ix%)=miny%
  3004.   spname$(ix%)=$spritename%
  3005.   curx%+=spwx%(ix%):ix%+=1
  3006. lineofsprites
  3007. y'!q%=0:q%!4=cury%:q%!8=maxw%:q%!12=0
  3008.  "Wimp_SetExtent",spritelist%,q%
  3009. front(spritelist%)
  3010. i%=sprSP2%:
  3011.  i%<>-1
  3012. i2%=nsprite%(i%)
  3013. close(spritew%(i%))
  3014.  spritei%(i%)>=0 
  3015. opensprite(spritei%(i%))
  3016. i%=i2%:
  3017.  "Wimp_ForceRedraw",spritelist%,0,-30000,30000,0
  3018. spfname(sp$)
  3019. sp$>spflen%-2 ="..."+
  3020. sp$,spflen%-5) 
  3021.  =sp$
  3022. lineofsprites
  3023.  curx%=0:cury%+=maxh%:maxh%=0
  3024.  ix%>0 
  3025. ix%-1
  3026. O  !q%=spritelist%:q%!4=curx%+(spwx%(J%)-spw%(J%))
  3027. 2:q%!8=cury%+miny%(J%)+16
  3028. M  q%!12=curx%+(spwx%(J%)+spw%(J%))
  3029. 2:q%!16=cury%+miny%(J%)+16+sph%(J%)+16
  3030. "  q%!20=
  3031. sprflags(spname$(J%))
  3032. 9  $(q%+24)=spname$(J%):
  3033.  "Wimp_CreateIcon",,q% 
  3034.   f%=flags%:i%=sprSP2%
  3035. i%<>-1:
  3036.  spriten$(i%)=spname$(J%) f%=f%
  3037. &400000:spritei%(i%)=ic%
  3038.   i%=nsprite%(i%):
  3039. F  !q%=spritelist%:q%!4=curx%+(spwx%(J%)-minx%(J%))
  3040. 2:q%!8=cury%+16
  3041. B  q%!12=curx%+(spwx%(J%)+minx%(J%))
  3042. 2:q%!16=cury%+miny%(J%)+16
  3043. <  q%!20=f%:$(q%+24)=spname$(J%):
  3044.  "Wimp_CreateIcon",,q%
  3045.   curx%+=spwx%(J%)
  3046.  curx%>maxw% maxw%=curx%
  3047. ix%=0:curx%=0
  3048. sprflags(sp$)
  3049.  "OS_SpriteOp",&128,spritearea%,sp$ 
  3050.  ,,,,,hasmask%
  3051.  hasmask% 
  3052.  = &1701A032 
  3053.  = &1701A012
  3054. readsprite(I%)
  3055.  S%:S%=spritearea%
  3056.  "OS_SpriteOp",&10D,S%,spritename%,12,I% 
  3057.  ,,,splen%:spritename%?splen%=13
  3058.  "OS_SpriteOp",&128,S%,spritename% 
  3059.  ,,,spw%,sph%,hasmask%,spm%
  3060.  "OS_ReadModeVariable",spm%,4 
  3061.  ,,spx%:spw%=spw%<<spx%
  3062.  "OS_ReadModeVariable",spm%,5 
  3063.  ,,spy%:sph%=sph%<<spy%
  3064. deselectsprites
  3065. I%=q%+16
  3066.  "Wimp_WhichIcon",spritelist%,I%,&200000,&200000
  3067.  !I%>-1:
  3068. deselect(spritelist%,!I%):I%+=4:
  3069. opensprite(icon%)
  3070.  sprSP%=-1 
  3071.  1,"No more sprite windows!"
  3072. geti(spritelist%,icon%
  3073. 6idata0%=idata%!0:idata4%=idata%!4:idata8%=idata%!8
  3074. %text$=
  3075. iconstring(iflags%,idata%)
  3076. standardwindow(0,0,"Sprites")
  3077. q%!28=&0F
  3078. q%?35=-1
  3079. q%!56=(iflags%
  3080. &100)
  3081. <q%!72=idata0%:q%!76=idata4%:q%!80=idata8% : 
  3082.  share data
  3083. q%!60=&3000
  3084.  "OS_SpriteOp",&128,spritearea%,text$ 
  3085.  ,,,spw%,sph%,,spm%
  3086.  "OS_ReadModeVariable",spm%,4 
  3087.  ,,spx%:xsc%=6<<spx%
  3088.  "OS_ReadModeVariable",spm%,5 
  3089.  ,,spy%:ysc%=6<<spy%
  3090. wx%=spw%*xsc%:wy%=sph%*ysc%
  3091. +q%!4=-wy%:q%!8=wx%:q%!44=-wy%:q%!48=wx%
  3092.  "Wimp_CreateWindow",,q% 
  3093.  handle%
  3094. 6m%=sprSP%:sprSP%=spritew%(m%):spritew%(m%)=handle%
  3095. #nsprite%(m%)=sprSP2%:sprSP2%=m%
  3096. >spriten$(m%)=text$:sprxscale%(m%)=xsc%:spryscale%(m%)=ysc%
  3097. spritei%(m%)=icon%
  3098. deselect(spritelist%,icon%
  3099. seti(spritelist%,icon%
  3100. 1,&400000,&600000) : 
  3101.  shaded and deselected
  3102. (!q%=handle%:q%!20=0:q%!24=0:q%!28=-1
  3103. Iq%!4=mousex%-wx%
  3104. 2:q%!8=mousey%-wy%:q%!12=mousex%+wx%
  3105. 2:q%!16=mousey%
  3106.  "Wimp_OpenWindow",,q%
  3107. getspritexy(I%,mx%,my%)
  3108. )xs%=sprxscale%(I%):ys%=spryscale%(I%)
  3109. x%=(mx%-bx%)/xs%
  3110. y%=(by%-my%-dy%)/ys%
  3111.  "OS_SpriteOp",&128,spritearea%,spriten$(I%) 
  3112.  ,,,spw%,sph%,hasmask%,spm%
  3113.  "OS_ReadModeVariable",spm%,4 
  3114.  ,,spx%
  3115.  "OS_ReadModeVariable",spm%,5 
  3116.  ,,spy%
  3117. wx%=spw%*xs%:wy%=sph%*ys%
  3118. x%<0x%=0
  3119. y%<0y%=0
  3120. x%>=spw%x%=spw%-1
  3121. y%>=sph%y%=sph%-1
  3122. adjustsize(I%,insdel%,rowcol%)
  3123. getw(spritew%(I%))
  3124. getspritexy(I%,mmousex%,mmousey%)
  3125. owx%=wx%:owy%=wy%
  3126.  rowcol% 
  3127.  insdel% 
  3128. *       
  3129.  0:rcode%=31:rc%=sph%:wy%+=ys%
  3130. 5       
  3131.  1:rcode%=32:rc%=sph%-1:wy%-=ys%:
  3132. wy%<1 
  3133. /       
  3134.  2:rcode%=31:rc%=sph%-1-y%:wy%+=ys%
  3135. 8       
  3136.  3:rcode%=32:rc%=sph%-1-y%:wy%-=ys%:
  3137. wy%<1 
  3138.        
  3139.  insdel% 
  3140. *       
  3141.  0:rcode%=45:rc%=spw%:wx%+=xs%
  3142. 5       
  3143.  1:rcode%=46:rc%=spw%-1:wx%-=xs%:
  3144. wx%<1 
  3145. (       
  3146.  2:rcode%=45:rc%=x%:wx%+=xs%
  3147. 1       
  3148.  3:rcode%=46:rc%=x%:wx%-=xs%:
  3149. wx%<1 
  3150.        
  3151.  "OS_SpriteOp",&100+rcode%,spritearea%,spriten$(I%),rc%
  3152. newsize(I%,owx%,owy%,wx%,wy%)
  3153. upicon(spritelist%,spritei%(I%))
  3154. newsize(I%,wx%,wy%,newwx%,newwy%)
  3155. getw(spritew%(I%))
  3156. limitx%=
  3157. :limity%=
  3158.  limitx%=(x1%-bx%>=wx%):limity%=(by%-y0%>=wy%)
  3159. wx%=newwx%:wy%=newwy%
  3160. limitx%
  3161. (wx%<x1%-bx%) newx%=bx%+wx%
  3162. newx%=x1%
  3163. limity%
  3164. (wy%<by%-y0%) newy%=by%-wy%
  3165. newy%=y0%
  3166. newx%<x1%
  3167. newy%>y0% q%!8=newy%:q%!12=newx%:
  3168.  "Wimp_OpenWindow",,q%
  3169. ,q%!&80=0:q%!&84=-wy%:q%!&88=wx%:q%!&8C=0
  3170.  "Wimp_SetExtent",spritew%(I%),q%+&80
  3171. newx%>x1%
  3172. newy%<y0% q%!8=newy%:q%!12=newx%:
  3173.  "Wimp_OpenWindow",,q%
  3174.  "Wimp_ForceRedraw",spritew%(I%),0,-30000,30000,0
  3175. updatesprite(I%)
  3176.  "Wimp_ForceRedraw",spritew%(I%),0,-30000,30000,0
  3177. upicon(spritelist%,spritei%(I%))
  3178. changesize(I%,xsc%,ysc%)
  3179. )xs%=sprxscale%(I%):ys%=spryscale%(I%)
  3180. +sprxscale%(I%)=xsc%:spryscale%(I%)=ysc%
  3181.  "OS_SpriteOp",&128,spritearea%,spriten$(I%) 
  3182.  ,,,spw%,sph%
  3183. newsize(I%,spw%*xs%,sph%*ys%,spw%*xsc%,sph%*ysc%)
  3184. flipx(I%)
  3185.  "OS_SpriteOp",&12F,spritearea%,spriten$(I%)
  3186.  "Wimp_ForceRedraw",spritew%(I%),0,-30000,30000,0
  3187. upicon(spritelist%,spritei%(I%))
  3188. flipy(I%)
  3189.  "OS_SpriteOp",&121,spritearea%,spriten$(I%)
  3190.  "Wimp_ForceRedraw",spritew%(I%),0,-30000,30000,0
  3191. upicon(spritelist%,spritei%(I%))
  3192. bigsprite(I%)
  3193.  xs%,ys%,By%,paint%
  3194. Dpaint%=
  3195.  paint_drag%>=0 paint%=(!q%=spritew%(paint_drag%>>16))
  3196. $spritename%=spriten$(I%)
  3197. )xs%=sprxscale%(I%):ys%=spryscale%(I%)
  3198.  23,12,0,7,0,7,0,7,0,7
  3199.  "OS_SpriteOp",&128,spritearea%,spritename% 
  3200.  ,,,spw%,sph%,hasmask%
  3201. By%=by%-sph%*ys%
  3202.  more%
  3203. hasmask% 
  3204. 16,128:
  3205.  "Wimp_ReadPixTrans",&100,spritearea%,spritename%,,,,factors%,pixtrans%
  3206. !factors%!0=xs%:factors%!4=ys%
  3207.  "OS_SpriteOp",&134,spritearea%,spritename%,bx%,By%,8,factors%,pixtrans%
  3208.  paint% 
  3209. drgoff
  3210.  "Wimp_GetRectangle",,q% 
  3211.  more%
  3212. R------------------------------------------------------------------------------
  3213. spritepixel(I%)
  3214. getw(spritew%(I%))
  3215. )xs%=sprxscale%(I%):ys%=spryscale%(I%)
  3216. getspritexy(I%,mousex%,mousey%)
  3217. y%=sph%-1-y%
  3218.  x%<0 
  3219.  y%<0 
  3220.  x%>=spw% 
  3221.  y%>=sph% 
  3222.  paintmode% 
  3223. paint_pixel(&40)
  3224. paint_spray
  3225. paint_flood(&80)
  3226. paint_line(&00)
  3227. paint_ellipse(&C0)
  3228. paint_ellipse(&C8)
  3229. paint_circle(&90)
  3230. paint_circle(&98)
  3231. paint_arc(&A0)
  3232. paint_segment(&A8)
  3233. paint_sector(&B0)
  3234. paint_triangle(&50)
  3235. paint_blockcopy(&BE)
  3236. paint_blockmove(&BD)
  3237. paint_typetext
  3238.  1,"Unknown paint mode!"
  3239. upicon(spritelist%,spritei%(I%))
  3240. paint_pixel(void%)
  3241. 5(paint_drag%=I%<<16   : 
  3242.  auto-repeat
  3243.  sprcolour%=16 
  3244.  hasmask% 
  3245.  buttons%=&01 c%=1 
  3246.  c%=0
  3247.  "OS_SpriteOp",&12C,spritearea%,spriten$(I%),x%,y%,c%
  3248.  c%=0 
  3249.        c%=16
  3250.  "OS_SpriteOp",&129,spritearea%,spriten$(I%),x%,y% 
  3251.  ,,,,,c%
  3252.  buttons%=&01 c%=0 
  3253.  c%=sprcolour%
  3254.  c%=16 c%=0
  3255.  "OS_SpriteOp",&12A,spritearea%,spriten$(I%),x%,y%,c%
  3256.  hasmask% 
  3257. "OS_SpriteOp",&12C,spritearea%,spriten$(I%),x%,y%,1
  3258. update(spritew%(I%),x%*xs%,-(sph%-y%)*ys%,(x%+1)*xs%,-(sph%-1-y%)*ys%)
  3259.  more%
  3260.  c%=16 
  3261.  23,12,0,7,0,7,0,7,0,7:
  3262. 16,0 
  3263.  bx%+x%*xs%,by%-(sph%-y%)*ys%
  3264.  &65,bx%+(x%+1)*xs%-1,by%-(sph%-1-y%)*ys%-1
  3265.  "Wimp_GetRectangle",,q% 
  3266.  more%:
  3267. paint_flood(code%)
  3268.  buttons% 
  3269.  &01 
  3270. undo(I%):
  3271.  "OS_SpriteOp",&129,spritearea%,spriten$(I%),x%,y% 
  3272.  ,,,,,c%
  3273. edit(spriten$(I%))
  3274.  0,128+c%:
  3275.  0,sprcolour%
  3276.  code%+5,x%<<spx%,y%<<spy%
  3277. editoff(spriten$(I%))
  3278. updatesprite(I%)
  3279. paint_line(code%)
  3280. paint_circle(code%)
  3281. dragclick(1,code%)
  3282. paint_ellipse(code%)
  3283. paint_arc(code%)
  3284. paint_segment(code%)
  3285. paint_sector(code%)
  3286. paint_triangle(code%)
  3287. paint_blockcopy(code%)
  3288. paint_blockmove(code%)
  3289. dragclick(2,code%)
  3290. dragclick(nclicks%,code%)
  3291.  buttons% 
  3292.  &01 
  3293. dragoff:paint_drag%=-1:
  3294.  paint_drag%>=0 
  3295. dragoff
  3296.  ((paint_drag%>>4)
  3297. &F)-(paint_drag%
  3298. f'    dragx1%=dragx0%:dragy1%=dragy0%
  3299. g#    sprx1%=sprx0%:spry1%=spry0%
  3300. h/    dragx0%=mousex%-bx%:dragy0%=mousey%-by%
  3301. i9    dragx%=dragx0%:dragy%=dragy0%:sprx0%=x%:spry0%=y%
  3302.     paint_drag%+=1
  3303. edit(spriten$(I%))
  3304. 0,sprcolour%
  3305. 0,128+sprcolour%
  3306. o;    
  3307.  (paint_drag%
  3308. &F0)=&10 
  3309.  sprx1%<<spx%,spry1%<<spy%
  3310. p#    
  3311.  sprx0%<<spx%,spry0%<<spy%
  3312.  paintmode% 
  3313.  28,29
  3314. s-      
  3315.  sprx1%-sprx0%<0 x%+=sprx1%-sprx0%
  3316. t-      
  3317.  spry1%-spry0%<0 y%+=spry1%-spry0%
  3318. u#      
  3319.  code%,x%<<spx%,y%<<spy%
  3320. v        
  3321. w%      
  3322.  code%+5,x%<<spx%,y%<<spy%
  3323. x        
  3324. editoff(spriten$(I%))
  3325. updatesprite(I%)
  3326.  paintmode% 
  3327. }=    
  3328.  28:dragx%=mousex%-bx%:dragy%=mousey%-by%:
  3329. dragoff:
  3330. ~,    
  3331.  27:dragx1%=dragx0%:dragy1%=dragy0%
  3332. +            sprx1%=sprx0%:spry1%=spry0%
  3333. :paint_drag%=-1
  3334.         
  3335. 5  paint_drag%=(I%<<16)
  3336. (code%<<8)
  3337. (nclicks%-1<<4)
  3338. +dragx0%=mousex%-bx%:dragy0%=mousey%-by%
  3339. 5dragx%=dragx0%:dragy%=dragy0%:sprx0%=x%:spry0%=y%
  3340. dragoff
  3341. paintdrag(mousex%,mousey%,buttons%,handle%,icon%,oldbuttons%)
  3342. getw(spritew%(paint_drag%>>16))
  3343. dragoff
  3344.  handle%<>spritew%(paint_drag%>>16) paint_drag%=-1:
  3345. )dragx%=mousex%-bx%:dragy%=mousey%-by%
  3346.  (paintmode%=20 
  3347.  paintmode%=21)
  3348. (paint_drag%
  3349. &F)=0 dragy%=dragy0%
  3350. dragon(buttons%)
  3351. dragoff
  3352.  paint_drag%=-1 
  3353.  paintmode% 
  3354.  16,18: 
  3355.  do nothing
  3356. K  !q%=spritew%(paint_drag%>>16):q%!4=-1E8:q%!8=-1E8:q%!12=1E8:q%!16=1E8
  3357.  "Wimp_UpdateWindow",,q% 
  3358.  more%
  3359.  more%:
  3360. drgoff:
  3361.  "Wimp_GetRectangle",,q% 
  3362.  more%:
  3363. drgoff
  3364. code%=(paint_drag%>>8)
  3365.  paintmode% 
  3366.  28,29
  3367.  paint_drag%
  3368.  bx%+dragx0%,by%+dragy0%,dragx%-dragx0%,dragy%-dragy0%
  3369.  bx%+dragx%,by%+dragy%,dragx1%-dragx0%,dragy1%-dragy0%
  3370. !    
  3371.  bx%+dragx0%,by%+dragy0%
  3372. A    
  3373.  29,bx%+dragx1%,by%+dragy0%:
  3374.  29,bx%+dragx1%,by%+dragy1%
  3375. A    
  3376.  29,bx%+dragx0%,by%+dragy1%:
  3377.  29,bx%+dragx0%,by%+dragy0%
  3378.  19,20,21,22,23,24,25,26,27
  3379.  paint_drag%
  3380.  paint_drag%
  3381. ?    
  3382.  &10:
  3383.  bx%+dragx0%,by%+dragy0%:
  3384.  bx%+dragx%,by%+dragy%
  3385. G    
  3386.  &00:
  3387.  bx%+dragx0%,by%+dragy0%:
  3388.  code%+5,bx%+dragx%,by%+dragy%
  3389.         
  3390.  1:code%=(paint_drag%>>8)
  3391. !    
  3392.  bx%+dragx1%,by%+dragy1%
  3393.  code% 
  3394. (    
  3395.  &00: 
  3396.  bx%+dragx0%,by%+dragy0%
  3397. )              
  3398.  bx%+dragx%,by%+dragy%
  3399. +              
  3400.  bx%+dragx1%,by%+dragy1%
  3401. #    
  3402.  bx%+dragx0%,by%+dragy0%
  3403. 1              
  3404.  code%+5,bx%+dragx%,by%+dragy%
  3405.         
  3406. dragon(buttons%)
  3407.  paintmode% 
  3408.  buttons%
  3409. (       
  3410. spritepixel(paint_drag%>>16)
  3411.  paint_drag%=-1
  3412.  do nothing
  3413. dragoff
  3414. edit(spname$)
  3415.  "OS_SpriteOp",&13C,spritearea%,spname$,0 
  3416.  oldR0%,oldR1%,oldR2%,oldR3%
  3417. switched%=
  3418.  A%,B%,sptr%
  3419. ); A%=
  3420. spriteaddr(spritearea%,spname$)
  3421.  (sptr%!16+1)*4=linelen% 
  3422. ;      !vduscreen%=A%
  3423. 6;      
  3424.  "OS_ReadModeVariable",sptr%!40,10 
  3425.  ,,B%
  3426. %;      
  3427.  29,(sptr%!24>>B%)*dx%;0;
  3428.  !vduscreen%=editbuffer%:
  3429. F;      
  3430.  "OS_SpriteOp",&122,spritearea%,spname$,0,1024-sph%*dy%,0
  3431.  24,0;1024-sph%*dy%;spw%*dx%;1023;
  3432. editoff(spname$)
  3433.  switched% 
  3434.  "OS_SpriteOp",oldR0%,oldR1%,oldR2%,oldR3%
  3435.   undoname$=spname$
  3436.   switched%=
  3437.  A%,B%,E%,H%,L%,W%,I%,J%,T%
  3438.  !vduscreen%=editbuffer% 
  3439.  IF hasmask% THEN
  3440. +;   A%=
  3441. spriteaddr(spritearea%,spname$)
  3442.  sptr%!24<>0 
  3443. 5;     
  3444.  "OS_ReadModeVariable",sptr%!40,10 
  3445.  ,,B%
  3446. &;     J%=sptr%!24 >> B%:sptr%!24=0
  3447. A;     
  3448.  I%=1 
  3449.  "OS_SpriteOp",&22E,spritearea%,sptr%,0:
  3450.     ;   
  3451. ';   W%=(sptr%!16+1)*4:H%=sptr%!20+1
  3452. *;   E%=editbuffer%:L%=editbufferwidth%
  3453. O;   sgetpars!0=A%:sgetpars!4=E%:sgetpars!8=W%:sgetpars!12=H%:sgetpars!16=L%
  3454.  sget
  3455.  FOR J%=1 TO H%:FOR I%=0 TO W%-1 STEP4:T%=A%!I%:A%!I%=E%!I%:E%!I%=T%:NEXT
  3456.  A%+=W%:E%+=L%:NEXT
  3457.  ELSE
  3458.  SYS"OS_SpriteOp",&110,spritearea%,spname$,0,0,1024-sph%*dy%,spw%*dx%-1,1023
  3459.  ENDIF
  3460. /; undoscreen%=!vduscreen%:undoname$=spname$
  3461. $; !vduscreen%=oldvdu%:
  3462. 29,0;0;26
  3463. undo(sprite%)
  3464.  undoname$<>spriten$(I%) 
  3465.  undoscreen%<>editbuffer% 
  3466. ; !vduscreen%=undoscreen%
  3467. editoff(spriten$(I%))
  3468. updatesprite(I%)
  3469. spriteaddr(A%,name$)
  3470.  N%,N1%,N2%,N3%,I%
  3471. :$spritename%=name$:
  3472. name$ 
  3473.  11:spritename%?I%=0:
  3474. 9N1%=spritename%!0:N2%=spritename%!4:N3%=spritename%!8
  3475. N%=A%+A%!12:A%=A%+A%!8
  3476.  A%<N%:
  3477. A%!4=N1%
  3478. A%!8=N2%
  3479. A%!12=N3% sptr%=A%:=A%+A%!32
  3480. A%+=!A%:
  3481.  1,"Sprite '"+name$+"' not found by FNspriteaddr"
  3482. R------------------------------------------------------------------------------
  3483. palette
  3484.  icon% 
  3485. seti(palette%,icon%,&200000,0)
  3486.      grid%=
  3487. grid%
  3488.      
  3489.  icon%<16 
  3490.        
  3491. unhtpal
  3492.        palcolour%=icon%
  3493.         sprcolour%=palcolour%
  3494.        
  3495. htpal
  3496.      
  3497.         
  3498.  icon%<>paintmode% 
  3499. +         
  3500. deselect(palette%,paintmode%)
  3501. $         
  3502. select(palette%,icon%)
  3503. ,         paintmode%=icon%:paint_drag%=-1
  3504.        
  3505.      
  3506. xor(handle%,icon%,ntimes%)
  3507. ntimes%:
  3508. seti(handle%,icon%,&200000,0)
  3509. tempt%=
  3510. -tempt%>3:
  3511. unhtpal
  3512. palcolour%=-1 
  3513. seti(palette%,palcolour%,&00,&05)
  3514. htpal
  3515. palcolour%=-1 
  3516.     #!c3%=uncolour%(palcolour%)<<24
  3517. seti(palette%,palcolour%,c3%
  3518. &05,&0F000005)
  3519. seti(handle%,icon%,eor%,bic%)
  3520.     'J!q%=handle%:q%!4=icon%:q%!8=eor%:q%!12=bic%:
  3521.  "Wimp_SetIconState",,q%
  3522. setrgbvals(r%,g%,b%)
  3523.     +$pal%(0)=r%:pal%(1)=g%:pal%(2)=b%
  3524. seti(palette%,I%,0,0)
  3525. readpal(c%,c2%)
  3526.  c2%=16 
  3527.     3"     palword%=paltable%!(4*c%)
  3528.  "OS_ReadPalette",c%,c2% 
  3529.  ,,palword%
  3530. r%=(palword%>> 8)
  3531. g%=(palword%>>16)
  3532. b%=(palword%>>24)
  3533.     ;R------------------------------------------------------------------------------
  3534. encodepalmenu(tickcolour%)
  3535.     =JI%=m_palette%+28:
  3536.  c%=0 
  3537.  15:I%!0=(c%=tickcolour% 
  3538.  (c%=15 
  3539.  128)
  3540. I%+=24:
  3541. encodepal(c1%,c2%)
  3542.  c%,d%,e%,br%,maxd%,maxe%
  3543.  "Wimp_ReadPalette",,paltable%
  3544. c%=c1%
  3545. c2%:bright%(c%)=
  3546. brightness(c%):
  3547. c%=c1%
  3548. c2%:br%=bright%(c%):maxe%=-1
  3549. 15:e%=
  3550. (bright%(d%)-br%)
  3551. e%>maxe% maxe%=e%:maxd%=d%
  3552. :uncolour%(c%)=maxd%:
  3553. I%=m_palette%+28
  3554.  c%=0 
  3555.  15:I%!8=(((c%<<4)+uncolour%(c%))<<24) 
  3556.  9:I%+=24:
  3557. brightness(c%)
  3558. r%,g%,b%
  3559. readpal(c%,16)
  3560. =r%+g%+g%+b%
  3561. foreback(c%) = (c%<<4)
  3562. uncolour%(c%)
  3563. colourdiff(rgb1%,rgb2%)
  3564.  r%,g%,b%,R%,G%,B%
  3565.     Q;r%=(rbg1%>>8)
  3566. &FF:g%=(rbg1%>>16)
  3567. &FF:b%=(rbg1%>>24)
  3568.     R;R%=(rbg2%>>8)
  3569. &FF:G%=(rbg2%>>16)
  3570. &FF:B%=(rbg2%>>24)
  3571.     S#= (R%-r%)^2+(G%-g%)^2+(B%-b%)^2
  3572.     TR------------------------------------------------------------------------------
  3573. checkfull(f$)
  3574. f$,".") 
  3575. f$,":") 
  3576.  1,"To save, drag the file icon to a directory viewer"
  3577. checkident(A$,B$)
  3578. lc(A$)=
  3579. lc(B$) 
  3580. matchident(A$)<>-1 
  3581.  1,"Template already exists"
  3582. matchident(A$)
  3583.  A$="" 
  3584. lc(A$)
  3585.     `/I%=nh%+1:
  3586. I%=I%-1:
  3587. lc(wident$(I%))
  3588. lc(wident$(I%))
  3589. wipealltemplates
  3590.     e)  
  3591.  wident$(I%)<>"" 
  3592. deletewindow(I%)
  3593. updatefile(0)
  3594. savetemplates(tfile$,safe%)
  3595. loaded% 
  3596. warning(q%,1,
  3597. msg0("NTMPSV"))
  3598.     l;all%=(menuhandle%=mainmenu% 
  3599.  menuhandle%=t_file%):J%=0
  3600. I%=nh%
  3601.  wident$(I%)<>"" 
  3602.  (all% 
  3603.  I%=currentwindow%) wptr%(J%)=I%:J%+=1
  3604. 255:fontbinding%?I%=0:
  3605. :freef%=1:
  3606.  internal font handle allocator
  3607.     q<tf_hdr%=16:tf_fsize%=48:
  3608.  "XOS_Find",&80,tfile$ 
  3609.  E%;F%
  3610.  E%=&108C2 
  3611.  "XOS_Find",0,0:
  3612.  "XOS_Find",&80,tfile$ 
  3613.  E%;F%:
  3614. warning(q%,1,
  3615. msg0("CLOSED"))
  3616. warning(q%,1,
  3617. string0(E%+4))
  3618.  1,""
  3619.  E%=0 
  3620. warning(q%,1,
  3621. msg1("NOOPEN",tfile$))
  3622. tf_handle%=E%:
  3623. #tf_handle%:
  3624. tf_dataptr%=tf_hdr%+J%*24+4
  3625. tf_hdr%-1:indexdata%?I%=0:
  3626. :tf_index%=indexdata%+tf_hdr%
  3627.  I%=0
  3628.     z7 !q%=handle%(wptr%(I%)):
  3629.  "Wimp_GetWindowInfo",,q%
  3630.     {? q%!68=1:tf_datasize%=88+32*q%!88:
  3631. processicon(q%+60,q%+76)
  3632.  q%!88>0 
  3633. processicons
  3634.  "OS_GBPB",1,tf_handle%,q%+4,tf_datasize%,tf_dataptr%
  3635.     ~C tf_index%!0=tf_dataptr%:tf_index%!4=tf_datasize%:tf_index%!8=1
  3636. O $(tf_index%+12)=wident$(wptr%(I%)):tf_index%+=24:tf_dataptr%+=tf_datasize%
  3637. D!tf_index%=0:
  3638.  freef%=1 !indexdata%=-1 
  3639.  !indexdata%=tf_dataptr%
  3640.  "OS_GBPB",1,tf_handle%,indexdata%,tf_index%+4-indexdata%,0
  3641.  freef%>1 
  3642.  I%=0 
  3643.  tf_fsize%-1:indexdata%?I%=0:
  3644.  I%=1 
  3645.  freef%-1
  3646. %  J%=0:
  3647. J%+=1:
  3648. fontbinding%?J%=I%
  3649.  "Font_ReadDefn",J%,indexdata%+8 
  3650.  ,,indexdata%!0,indexdata%!4
  3651.  "OS_GBPB",1,tf_handle%,indexdata%,tf_fsize%,tf_dataptr%
  3652.   tf_dataptr%+=tf_fsize%
  3653.  #tf_handle%:
  3654. ("Settype "+tfile$+" Template"):
  3655. ("Stamp "+tfile$)
  3656.  safe% 
  3657.  menuhandle%=t_file% templatef$=tfile$
  3658. processicons
  3659.  I%,J%
  3660. J%=q%+92
  3661.  I%=0 
  3662.  q%!88-1:
  3663. processicon(J%+16,J%+20):J%+=32:
  3664. processicon(fptr%,qptr%)
  3665.  !fptr% 
  3666.  &40 
  3667. ,  extf%=fptr%?3:intf%=fontbinding%?extf%
  3668.  intf%=0 intf%=freef%:freef%+=1:fontbinding%?extf%=intf%
  3669.   fptr%?3=intf%
  3670.  !fptr% 
  3671.  &100 
  3672.   B%=q%+4+tf_datasize%
  3673. :  $B%=$!qptr%:!qptr%=tf_datasize%:tf_datasize%+=
  3674. $B%+1
  3675.  qptr%!4>0 
  3676.     B%=q%+4+tf_datasize%
  3677. @    $B%=$(qptr%!4):qptr%!4=tf_datasize%:tf_datasize%+=
  3678. $B%+1
  3679. loadtemplates(tfile$)
  3680.  I%,f$
  3681.  "Hourglass_On"
  3682.  "Wimp_OpenTemplate",,tfile$
  3683.  tfile$<>"<Wimp$Scrap>" 
  3684.  loaded% templatef$=tfile$
  3685.  "Wimp_CloseTemplate":
  3686. updatefile(0):
  3687. tf_index%=0:
  3688. $mb_wident%="*"
  3689.  "Wimp_LoadTemplate",,q%+4,curbuff%,buffer%+maxbuf%,fontcounts%,mb_wident%,tf_index% 
  3690.  ,,curbuff%,,,,tf_index%
  3691.  tf_index%<>0 
  3692. loadtemp($mb_wident%)
  3693.  tf_index%=0
  3694.  "Wimp_CloseTemplate":
  3695. setloaded(
  3696. updatefile(0)
  3697.  "Hourglass_Off"
  3698. loadtemp(wident$)
  3699. matchident(wident$):
  3700.  I%<>-1 
  3701. deletewindow(I%)
  3702. 'q%!68=spritearea%:P%=q%+92:I%=q%!88
  3703. I%>0:
  3704.  ((P%!16)
  3705. &103)=&102 P%!24=spritearea%
  3706. ,P%+=32:I%-=1:
  3707. crwindow(q%+4,wident$,0)
  3708. R------------------------------------------------------------------------------
  3709. defaultwindows
  3710.  "Wimp_OpenTemplate",,"<FormEd2$Dir>.Templates"
  3711.  default% (88+1*32)
  3712. loadcrtemp("default",default%)
  3713. 'spritelist% = 
  3714. crtemp("spritelist")
  3715. $m_scale%    = 
  3716. crtemp("m_scale")
  3717. 'm_workarea% = 
  3718. crtemp("m_workarea")
  3719. %m_resize%   = 
  3720. crtemp("m_resize")
  3721. $palette%    = 
  3722. crtemp("palette")
  3723. &m_savetemp% = 
  3724. crtemp("save_temp")
  3725. (m_savespr%  = 
  3726. crtemp("save_sprite")
  3727. %proginfo%   = 
  3728. crtemp("ProgInfo")
  3729. (dial_delete%= 
  3730. crtemp("dial_delete")
  3731. (new_temp%   = 
  3732. crtemp("NewTemplate")
  3733. $options%    = 
  3734. crtemp("Options")
  3735. $handlew%    = 
  3736. crtemp("Handles")
  3737. &tempfile%   = 
  3738. crtemp("Templates")
  3739.  "Wimp_CloseTemplate"
  3740. "sprbuff%=
  3741. iconaddr(m_scale%,3)
  3742. *mb_templates%=
  3743. iconaddr(m_savetemp%,1)
  3744. 'mb_spritef%=
  3745. iconaddr(m_savespr%,1)
  3746. *mb_workarea0%=
  3747. iconaddr(m_workarea%,9)
  3748. +mb_workarea1%=
  3749. iconaddr(m_workarea%,10)
  3750. &mb_minx%=
  3751. iconaddr(m_workarea%,14)
  3752. &mb_miny%=
  3753. iconaddr(m_workarea%,15)
  3754. #mb_name%=
  3755. iconaddr(new_temp%,0)
  3756. "mb_deft%=
  3757. iconaddr(options%,5)
  3758. "mb_deff%=
  3759. iconaddr(options%,6)
  3760. "mb_auto%=
  3761. iconaddr(options%,7)
  3762. #hndident%=
  3763. iconaddr(handlew%,1)
  3764. "hndicon%=
  3765. iconaddr(handlew%,3)
  3766. geti(m_scale%,2):sprxoff%=(ix0%+ix1%)
  3767. 2:spryoff%=(iy0%+iy1%)
  3768. R------------------------------------------------------------------------------
  3769. crtemp(wident$)
  3770. loadcrtemp(wident$,q%)
  3771.  "Wimp_CreateWindow",,q% 
  3772. R------------------------------------------------------------------------------
  3773. loadcrtemp(wident$,q%)
  3774.  I%,c%,c2%,w$
  3775. #c%=curbuff%:c2%=buffer%+maxbuf%
  3776.  w$=wident$+
  3777. wident$,
  3778.  "Wimp_LoadTemplate",,q%,c%,c2%,fontcounts%,w$,0 
  3779.  ,,curbuff%,,,,c%
  3780.  c%=0 
  3781.  1,"Window definition not found"
  3782.  wident$="iconbar" q%!28=q%!28 
  3783. q%!64=systemsprites%
  3784.  wident$="spritelist" q%!64=spritearea%
  3785.  wident$="save_temp" 
  3786.  wident$="save_sprite" q%!64=1
  3787.  wident$="spritelist" spritef%=q%!72:spflen%=q%!80-1:q%!68=100
  3788.  wident$="Options" q%!64=systemsprites%
  3789. R------------------------------------------------------------------------------
  3790. iconaddr(h%,i%)
  3791. -!q%=h%:q%!4=i%:
  3792.  "Wimp_GetIconState",,q%
  3793.  q%!24
  3794. &100 
  3795.  =q%!28
  3796.  1,"Icon is not indirected"
  3797. iconbar:!q%=-1:q%!4=0:q%!8=0:q%!12=68:q%!16=72:q%!20=&3002
  3798. ;$(q%+24)="!FormEd2":
  3799.  "Wimp_CreateIcon",,q% 
  3800.  ic%:=ic%
  3801.  spname$=$(icon%+20)
  3802.  q%!24=FNworkspace(LENspname$+1):$(q%!24)=spname$
  3803.  q%!28=systemsprites%
  3804.  q%!32=LENspname$+1
  3805. R------------------------------------------------------------------------------
  3806. createmenu
  3807.  1,"Not yet implemented - sorry!" : 
  3808.  Weddun ! - The RISC Squad
  3809. R------------------------------------------------------------------------------
  3810. printscreen
  3811. ensure
  3812. :    
  3813.  "Print_PageSize" 
  3814.  ,xs%,ys%,px0%,py0%,px1%,py1%
  3815. O    q%!&90=0:q%!&94=0:q%!&98=scrx1%:q%!&9C=scry1%    : 
  3816.  input bounding box
  3817. M    
  3818. "Print_AbortJob":
  3819. invalidate(-1,0,0,scrx1%,scry1%):
  3820.  "Print_StartJob"
  3821. '    
  3822.  23,25,&80,1,&F0,&F0,&F0,0,0,0
  3823.  14,0
  3824. matrix(q%+&A0,300,0,0,300,(xs%-scrx1%*300)/2,py1%-scry1%*300-18000):
  3825.  PROCmatrix(q%+&A0,0,-400,400,0,0,ys%):PROCpage
  3826.  PROCmatrix(q%+&A0,0,500,-400,0,xs%,0):PROCpage
  3827.  "Print_EndJob"
  3828. :    
  3829.  "Print_DrawPage",,q%+&80,q%+&90,q%+&A0 
  3830.  pmore%
  3831.  pmore%
  3832. 3    
  3833. invalidate(-1,q%!&80,q%!&84,q%!&88,q%!&8C)
  3834.     PROCinvalidate(-1,0,0,scrx1%,scry1%)
  3835. ensure
  3836. 1    
  3837.  "Print_NextRectangle",,q%+&80 
  3838.  pmore%
  3839.         
  3840. matrix(q%,a,b,c,d,e,f)
  3841. 4    q%!0=a:q%!4=b:q%!8=c:q%!12=d:q%!16=e:q%!20=f
  3842. invalidate(h%,x0%,y0%,x1%,y1%)
  3843. 0    
  3844.  "Wimp_ForceRedraw",h%,x0%,y0%,x1%,y1%
  3845. ensure
  3846. #(    
  3847.  "Wimp_Poll",
  3848. 3,q% 
  3849.  action%
  3850. $     
  3851.  action%=1 
  3852. redraw(!q%)
  3853.  action%=0
  3854. handle_resize(info_ic%,change_info_ic%,x0%,y0%,x1%,y1%)
  3855.  newval%,void%,ctr%
  3856. *Enewval%=
  3857. shell_IconGetData(m_resize%,info_ic%))+change_info_ic%
  3858.  newval%>=1 
  3859. shell_IconPutData(m_resize%,info_ic%,
  3860. newval%,-1)
  3861.  currenticon%>-1 
  3862. .`    void%=
  3863. shell_IconResize(menuwindow%,currenticon%,ix0%+x0%,iy0%+y0%,ix1%+x1%,iy1%+y1%,20)
  3864.     ctr%=0
  3865.  C%!ctr%>-1 
  3866.       
  3867. 3&        
  3868. geti(menuwindow%,C%!ctr%)
  3869. 4_        void%=
  3870. shell_IconResize(menuwindow%,C%!ctr%,ix0%+x0%,iy0%+y0%,ix1%+x1%,iy1%+y1%,20)
  3871.         ctr%+=4
  3872.       
  3873.  C%!ctr%=-1
  3874. 7        
  3875. handle_resizeOK
  3876.  ctr%,void%
  3877.  currenticon%>-1 
  3878.   void%=
  3879. shell_IconResize(menuwindow%,currenticon%,ix0%,iy0%,ix0%+
  3880. shell_IconGetData(m_resize%,6)),iy0%+
  3881. shell_IconGetData(m_resize%,5)),20)
  3882.   ctr%=0
  3883. C"    
  3884. geti(menuwindow%,C%!ctr%)
  3885.     void%=
  3886. shell_IconResize(menuwindow%,C%!ctr%,ix0%,iy0%,ix0%+
  3887. shell_IconGetData(m_resize%,6)),iy0%+
  3888. shell_IconGetData(m_resize%,5)),20)
  3889.     ctr%+=4
  3890.  C%!ctr%=-1
  3891.  ------------------ Added PH Routines --------------------------------
  3892. shell_IconPutData(whandle%,ihandle%,data$,redraw)
  3893. _Q%!0=whandle%
  3894. _Q%!4=ihandle%
  3895.  "Wimp_GetIconState",,_Q%
  3896.  (_Q%!24 
  3897.  (1<<8))<>0 
  3898. data$>_Q%!36 
  3899.  99,"Icon overflow - attempt to place too many characters in a indirected icon"
  3900.   $(_Q%!28)=data$
  3901.   $(_Q%+28)=
  3902. data$,11)
  3903.  redraw<>0 
  3904.   _Q%!8=0:_Q%!12=0
  3905.  "Wimp_SetIconState",,_Q%
  3906. shell_IconGetData(whandle%,ihandle%)
  3907.  result$
  3908. _Q%!0=whandle%
  3909. _Q%!4=ihandle%
  3910.  "Wimp_GetIconState",,_Q%
  3911.  (_Q%!24 
  3912.  (1<<8))<>0 
  3913.  result$=$(_Q%!28) 
  3914.  result$=$(_Q%+28)
  3915. =result$
  3916. shell_IconResize(wh%,ih%,x0%,y0%,x1%,y1%,bdr%)
  3917. e3_Q%!0=wh%:_Q%!4=ih%:
  3918.  "Wimp_GetIconState",,_Q%
  3919.  "Wimp_DeleteIcon",,_Q%
  3920. g._Q%!8=x0%:_Q%!12=y0%:_Q%!16=x1%:_Q%!20=y1%
  3921. h/_Q%!4=wh%:
  3922.  "Wimp_CreateIcon",,_Q%+4 
  3923.  "Wimp_ForceRedraw",wh%,x0%-bdr%,y0%-bdr%,x1%+bdr%,y1%+bdr%
  3924. pick_referenceicon(wh%,selection%)
  3925.  icon%,max_y%,ptr%,Q%
  3926. n.Q%=q%+&500:Q%!0=wh%:ptr%=0:max_y%=-9999999
  3927.  selection%!ptr%<>-1
  3928.   Q%!4=selection%!ptr%
  3929.  "Wimp_GetIconState",,Q%
  3930.  Q%!20>max_y% 
  3931. s!    max_y%=Q%!20:icon%=ptr%/4
  3932.   ptr%+=4
  3933. =icon%
  3934. arrange_horizontal(wh%,reference_icon%)
  3935.  ref_cl%,RIGHT%,LEFT%,ref_minx%,ref_miny%,ref_maxx%,ref_,maxy%
  3936.  nr_left_side%,nr_right_side%,icon_cl%
  3937.  "Hourglass_On"
  3938.  calculate centre line of reference icon..
  3939. J%!0=wh%
  3940.  "Wimp_GetIconState",,J%
  3941.  "Interface_BoundingBox",,J%+8
  3942. ref_cl%=J%!8+(J%!16-J%!8)/2
  3943. Bref_minx%=J%!8:ref_miny%=J%!12:ref_maxx%=J%!16:ref_maxy%=J%!20
  3944. RIGHT%=q%+&1000
  3945. +LEFT% =q%+&1300:
  3946.  space for 192 icons..
  3947. $nr_left_side%=0:nr_right_side%=0
  3948.  !I%<>-1
  3949.  !I%<>reference_icon% 
  3950. &    
  3951.  icon is not reference icon..
  3952.     J%!4=!I%
  3953. "    
  3954.  "Wimp_GetIconState",,J%
  3955. 1    
  3956.  check if centre line is left or right..
  3957. $    icon_cl%=J%!8+(J%!16-J%!8)/2
  3958.  icon_cl%>=ref_cl% 
  3959. (      RIGHT%!(nr_right_side%*4)=J%!4
  3960.       nr_right_side%+=1
  3961.         
  3962. &      LEFT%!(nr_left_side%*4)=J%!4
  3963.       nr_left_side%+=1
  3964.         
  3965.   I%+=4
  3966. LEFT%!(nr_left_side%*4)=-1
  3967.  RIGHT%!(nr_right_side%*4)=-1
  3968. do_icon_sort(wh%,LEFT%,nr_left_side%,-1)
  3969. do_icon_sort(wh%,RIGHT%,nr_right_side%,-1)
  3970. arrange_horizontal_right(RIGHT%,ref_maxx%)
  3971. arrange_horizontal_left(LEFT%,ref_minx%,nr_left_side%)
  3972.  "Hourglass_Off"
  3973. arrange_vertical(wh%,reference_icon%)
  3974.  ref_cl%,ref_minx%,ref_miny%,ref_maxx%,ref_,maxy%
  3975.  ABOVE%,BELOW%,nr_below%,nr_above%,icon_cl%
  3976.  "Hourglass_On"
  3977. J%!0=wh%
  3978.  "Wimp_GetIconState",,J%
  3979.  "Interface_BoundingBox",,J%+8
  3980. !ref_cl%=J%!20+(J%!12-J%!20)/2
  3981. Bref_minx%=J%!8:ref_miny%=J%!12:ref_maxx%=J%!16:ref_maxy%=J%!20
  3982. ABOVE%=q%+&1000
  3983. +BELOW%=q%+&1300:
  3984.  space for 192 icons..
  3985. nr_below%=0:nr_above%=0
  3986.  !I%<>-1
  3987.  !I%<>reference_icon% 
  3988. &    
  3989.  icon is not reference icon..
  3990.     J%!4=!I%
  3991. "    
  3992.  "Wimp_GetIconState",,J%
  3993. 2    
  3994.  check if centre line is above or below..
  3995. &    icon_cl%=J%!20+(J%!12-J%!20)/2
  3996.  icon_cl%>=ref_cl% 
  3997. #      ABOVE%!(nr_above%*4)=J%!4
  3998.       nr_above%+=1
  3999.         
  4000. #      BELOW%!(nr_below%*4)=J%!4
  4001.       nr_below%+=1
  4002.         
  4003.   I%+=4
  4004. ABOVE%!(nr_above%*4)=-1
  4005. BELOW%!(nr_below%*4)=-1
  4006. do_icon_sort(wh%,ABOVE%,nr_above%,0)
  4007. do_icon_sort(wh%,BELOW%,nr_below%,0)
  4008. arrange_vertical_above(ABOVE%,ref_maxy%)
  4009. arrange_vertical_below(BELOW%,ref_miny%,nr_below%)
  4010.  "Hourglass_Off"
  4011. arrange_vertical_above(ABOVE%,ref_maxy%)
  4012.  maxiy%
  4013. maxiy%=ref_maxy%
  4014.  !ABOVE%<>-1
  4015.   J%!4=!ABOVE%
  4016.  "Wimp_GetIconState",,J%
  4017.  "Interface_BoundingBox",,J%+8
  4018.  maxiy%<=0 
  4019. D    
  4020. moveicon(!J%,!ABOVE%,0,
  4021. (J%!12)-
  4022. (maxiy%)+
  4023. ($mb_Vspacing%))
  4024. D    
  4025. moveicon(!J%,!ABOVE%,0,
  4026. (J%!12)+
  4027. (maxiy%)+
  4028. ($mb_Vspacing%))
  4029.  "Wimp_GetIconState",,J%
  4030.  "Interface_BoundingBox",,J%+8
  4031.   maxiy%=J%!20
  4032.   ABOVE%+=4
  4033. arrange_vertical_below(BELOW%,ref_miny%,nr_below%)
  4034.  miniy%,loop%
  4035. miniy%=ref_miny%
  4036.  loop%=(nr_below%-1)*4 
  4037.   J%!4=BELOW%!loop%
  4038.  "Wimp_GetIconState",,J%
  4039.  "Interface_BoundingBox",,J%+8
  4040. moveicon(!J%,BELOW%!loop%,0,
  4041. (J%!20)-
  4042. (miniy%)-
  4043. ($mb_Vspacing%))
  4044.  "Wimp_GetIconState",,J%
  4045.  "Interface_BoundingBox",,J%+8
  4046.   miniy%=J%!12
  4047.  loop%
  4048. arrange_horizontal_right(RIGHT%,ref_maxx%)
  4049.  maxix%
  4050. maxix%=ref_maxx%
  4051.  !RIGHT%<>-1
  4052.   J%!4=!RIGHT%
  4053.  "Wimp_GetIconState",,J%
  4054.  "Interface_BoundingBox",,J%+8
  4055. moveicon(!J%,!RIGHT%,
  4056. (maxix%)-
  4057. (J%!8)+
  4058. ($mb_Hspacing%),0)
  4059.  "Wimp_GetIconState",,J%
  4060.  "Interface_BoundingBox",,J%+8
  4061.   maxix%=J%!16
  4062.   RIGHT%+=4
  4063. arrange_horizontal_left(LEFT%,ref_minx%,nr_left_side%)
  4064.  minix%,loop%
  4065. minix%=ref_minx%
  4066.  loop%=(nr_left_side%-1)*4 
  4067.   J%!4=LEFT%!loop%
  4068.  "Wimp_GetIconState",,J%
  4069.  "Interface_BoundingBox",,J%+8
  4070. moveicon(!J%,LEFT%!loop%,minix%-J%!16-
  4071. ($mb_Hspacing%),0)
  4072.  "Wimp_GetIconState",,J%
  4073.  "Interface_BoundingBox",,J%+8
  4074.   minix%=J%!8
  4075.  loop%
  4076. do_icon_sort(wh%,selection%,nr_icons%,horiz%)
  4077.  flag%,loop%,cl1%,cl2%,I%,temp%
  4078. I%=q%+&1600
  4079.  nr_icons%<2 
  4080. !I%=wh%
  4081.   flag%=
  4082.  loop%=0 
  4083.  ((nr_icons%-2)*4) 
  4084. +    
  4085.  sort icons on centre line coord..
  4086.     I%!4=selection%!loop%
  4087. "    
  4088.  "Wimp_GetIconState",,I%
  4089.  horiz% 
  4090. "      cl1%=I%!8+(I%!16-I%!8)/2
  4091. #      I%!4=selection%!(loop%+4)
  4092. $      
  4093.  "Wimp_GetIconState",,I%
  4094. "      cl2%=I%!8+(I%!16-I%!8)/2
  4095.         
  4096. $      cl1%=I%!20+(I%!12-I%!20)/2
  4097. #      I%!4=selection%!(loop%+4)
  4098. $      
  4099.  "Wimp_GetIconState",,I%
  4100. $      cl2%=I%!20+(I%!12-I%!20)/2
  4101.         
  4102.  cl1%>cl2% 
  4103.       flag%=
  4104. 6      
  4105.  SWAP selection%!loop%,selection%!(loop%+4)
  4106.        temp%=selection%!loop%
  4107. /      selection%!loop%=selection%!(loop%+4)
  4108. $      selection%!(loop%+4)=temp%
  4109.          
  4110.  loop%
  4111.  flag%=
  4112. Handle_Same_size
  4113.  I%,J%,void%,width%,height%
  4114.  Handle 'Same size' item..
  4115. I%=q%+&80
  4116.  "Wimp_WhichIcon",handle%(currentwindow%),I%,5<<21,1<<21
  4117. *+J%=q%+&400:J%!0=handle%(currentwindow%)
  4118.  currenticon%=-1 
  4119. ,'  J%!4=
  4120. pick_referenceicon(J%!0,I%)
  4121.   J%!4=currenticon%
  4122.  "Wimp_GetIconState",,J%:
  4123.  get size of reference icon..
  4124. 1,width%=J%!16-J%!8:height%=
  4125. (J%!20-J%!12)
  4126.  !I%>-1
  4127.   J%!4=!I%
  4128.  "Wimp_GetIconState",,J%
  4129. 5P  void%=
  4130. shell_IconResize(J%!0,J%!4,J%!8,J%!20-height%,J%!8+width%,J%!20,50)
  4131.   I%+=4
  4132.  "Wimp_ForceRedraw",J%!0,0,-10000,10000,0
  4133. bootmessage(Q%)
  4134.  boot$
  4135. =Cboot$="Run "+
  4136. shell_OSVarGetVal(Q%+256,256,"FormEd2$Dir",0)+
  4137.  "OS_GBPB",2,Q%!20,boot$,
  4138. boot$
  4139. shell_OSVarGetVal(buffer%,size%,varname$,expand)
  4140.  value$,nr_bytes,nameptr%,type%
  4141.  "XOS_ReadVarVal",varname$,buffer%,size%,0,-3*(expand=
  4142.  ,,nr_bytes,nameptr%,type%
  4143.  loop%=0 
  4144.  nr_bytes-1
  4145. E$  value$=value$+
  4146. (buffer%?loop%)
  4147.  loop%
  4148. =value$
  4149. updatefile(F%)
  4150. JPq%!40=tempfile%:
  4151.  "Wimp_GetWindowInfo",,q%+40:
  4152.  "Wimp_DeleteWindow",,q%+40
  4153. K1I%=0:A%=tempind%:B%=nh%:C%=q%+132:Y%=-4:D%=40
  4154.  wident$(B%)<>"" 
  4155. N2  !q%=handle%(B%):
  4156.  "Wimp_GetWindowState",,q%
  4157.   $A%="  "+wident$(B%)
  4158.  q%!32 
  4159.  (1<<16) ?A%=128
  4160. QS  P%=C%:[OPT2:DCD8:DCDY%-D%:DCD248:DCDY%:DCD&17018531:DCDA%:DCD-1:DCD16:]:C%=P%
  4161. R+  temppatch%(B%)=I%:A%+=16:I%+=1:Y%-=D%
  4162.   temppatch%(B%)=-1
  4163.  B%-=1
  4164.  B%<0
  4165. q%!128=I%:
  4166.  Y%>-96 Y%=-96
  4167. q%!88=Y%-4
  4168.  Y%<-20*D%-8 q%!48=q%!56-20*D%-8 
  4169.  q%!48=q%!56+Y%-8
  4170.  "Wimp_CreateWindow",,q%+44 
  4171.  tempfile%
  4172.  q%!72 
  4173.  (1<<16) 
  4174.  q%!72 
  4175.  (1<<16) 
  4176.  q%!64=0
  4177. ^/q%!40=tempfile%:
  4178.  "Wimp_OpenWindow",,q%+40
  4179. movehandles(F%)
  4180. b6!q%=handlew%:
  4181.  "Wimp_GetWindowState",,q%:q%!28=-1
  4182.  (q%!32
  4183. (1<<16)) 
  4184. d4q%!40=handlew%:
  4185.  "Wimp_GetWindowOutline",,q%+40
  4186. e%x1%=scrx1%-q%!52:y1%=scry1%-q%!56
  4187. f?q%!4=q%!4+x1%:q%!12=q%!12+x1%:q%!8=q%!8+y1%:q%!16=q%!16+y1%
  4188.  "Wimp_SendMessage",2,q%,task_handle%:hw%=
  4189. :hwic%=-2
  4190. backreffile(A%)
  4191. k.B%=-1:
  4192. :B%+=1:
  4193.  B%=nh% 
  4194.  temppatch%(B%)=A%
  4195.  temppatch%(B%)=A% 
  4196.  =B% 
  4197.  1,"Bad icon reference"
  4198. setfileopen(I%,O%)
  4199. o#A%=tempind%+16*(temppatch%(I%))
  4200.  O% ?A%=128 
  4201.  ?A%=32
  4202. q.!q%=tempfile%:
  4203.  "Wimp_GetWindowState",,q%
  4204.  (q%!32)
  4205. (1<<16) 
  4206. upicon(tempfile%,temppatch%(I%))
  4207. getmenuposn
  4208.  "Wimp_GetPointerInfo",,q%:
  4209.  "Wimp_GetWindowState",,q%+12
  4210. x(mmousex%=q%!16+102:mmousey%=q%!28-12
  4211. changewindow(q%,curw%)
  4212.  "Wimp_CreateWindow",,q% 
  4213.  handle%
  4214. }1!q%=handle%(curw%):
  4215.  "Wimp_DeleteWindow",,q%
  4216. handle%(curw%)=handle%
  4217. E!q%=handle%:
  4218.  "Wimp_GetWindowState",,q%:
  4219.  "Wimp_OpenWindow",,q%
  4220. loadchoices
  4221. Fdeftem$="Template":deffile$="Templates":finac%=1:auto$="Templates"
  4222. 'interface%=
  4223. :hatch%=
  4224. :country$="UK"
  4225. ("<FormEd2$Dir>.Choices")
  4226.  X%=0 
  4227. #X%,deftem$ :
  4228. deftem$ >11 deftem$ ="Template"
  4229. #X%,deffile$:
  4230. deffile$>10 deffile$="Templates"
  4231. .finac%=
  4232. #X%   :
  4233.  finac%     >2  finac%  =1
  4234. #X%,auto$   :
  4235. auto$   >10 auto$   ="Templates"
  4236. interface%=(
  4237. #X%>0)
  4238. hatch%=(
  4239. #X%>0)
  4240. #X%,country$:
  4241. country$>10 country$="UK"
  4242.  "OS_File",5,"<FormEd$Dir>.Messages."+country$ 
  4243.  T%<>1 country$="UK"
  4244. updatehatch
  4245.  I%=0 
  4246.  wident$(I%)<>"" 
  4247. 2  !q%=handle%(I%):
  4248.  "Wimp_GetWindowState",,q%
  4249.  q%!32 
  4250.  (1<<4) 
  4251.  "Wimp_ForceRedraw",!q%,-1E5,-1E5,1E5,1E5
  4252. leave(handle%)
  4253. whichwindow(handle%):
  4254. I%=-1 
  4255. %$hndident%="":
  4256. upicon(handlew%,1)
  4257. $$hndicon%="":
  4258. upicon(handlew%,3)
  4259. enter(handle%)
  4260. whichwindow(handle%):
  4261. I%=-1 
  4262. .$hndident%=wident$(I%):
  4263. upicon(handlew%,1)
  4264. handledoicon
  4265.  "Wimp_GetPointerInfo",,q%:
  4266.  hwic%=q%!16 
  4267. 9hwic%=q%!16:
  4268.  hwic%<0 $hndicon%="" 
  4269.  $hndicon%=
  4270. hwic%
  4271. upicon(handlew%,3)
  4272.