home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilsp / pca / !Spaint / !Runimage (.txt) < prev    next >
Encoding:
RISC OS BBC BASIC V Source  |  1996-08-17  |  53.7 KB  |  1,993 lines

  1.  >!RunImage
  2.  SPaint 0.04
  3.        
  4.  Rob Davison 1996
  5.   Updated sometime...
  6.  Code sections relating to the PCA are commented !!!PCA!!!
  7.  not particularly easy to follow still...Sorry!
  8.  Now use PCA 'tags' and the PCASupport Module
  9. $+" "+
  10. init_variables
  11. initall:
  12. assemble_blit:
  13. init_Wimp
  14. reperr(
  15. $+"at code "+
  16. poll:
  17. terminate
  18.  called on desktop mode change and when new object linked in.
  19.  creates colour translation tables for display of sprites.
  20. initsptrans
  21.  XCtGet%,sblock%,"grad",-1,-1,sgblkg%,0
  22.  !!!PCA!!!
  23.  update display
  24. translation settings on mode changes/new objects
  25.  remotetag%>0 
  26.  "XWimp_ReadPixTrans",&200,!remotetag%,!remotetag%+remotetag%!4,,,,stransW%,sgblk%
  27.  XCtGet%,!remotetag%,!remotetag%+remotetag%!4,-1,-1,sgblk%,1
  28. AstransWx=stransW%!8/!stransW%:stransWy=stransW%!12/stransW%!4
  29.  Spop%,552,!remotetag%,!remotetag%+remotetag%!4 
  30.  ,,,xwhook%,ywhook%
  31. spria%>0 
  32.  reference via the tag is not strictly necessary here as it is a local
  33.  object - but just for forms sake...
  34.  "XWimp_ReadPixTrans",&200,!localtag%,!localtag%+localtag%!4,,,,stransW%,sgblkB%
  35.  XCtGet%,!localtag%,!localtag%+localtag%!4,-1,-1,sgblkB%,1
  36. "OS_ReadModeVariable",-1,3 
  37.  ,,nocol%
  38. &35,-1,11 
  39.  ,,sw%:
  40. &35,-1,12 
  41.  ,,sh%
  42. &35,-1,4 
  43.  ,,xpix%:
  44. &35,-1,5 
  45.  ,,ypix%
  46. xpixf=xpix%:ypixf=ypix%
  47. ,!xpix%=1<<xpix%:ypix%=1<<ypix%
  48. -'sw%=xpix%*(sw%+1):sh%=ypix%*(sh%+1)
  49.  redraw the 'remote' (linked) sprites window.
  50. rdremote(f%)
  51.  Wupdw%,,Wb% 
  52.  more% 
  53. Wrdw%,,Wb% 
  54.  more%
  55. 3&x0%=Wb%!4-Wb%!20:y0%=Wb%!16-Wb%!24
  56.  more%
  57. 53wx0%=Wb%!28:wy0%=Wb%!32:wx1%=Wb%!36:wy1%=Wb%!40
  58. remotetag%>0 
  59.  XSpop%,564,!remotetag%,!remotetag%+remotetag%!4,x0%,y0%,0,stransW%,sgblk%
  60. sc(0,0,0):
  61.  x0%,y0%,xwhook%*2,ywhook%*2
  62.  Wgr%,0,Wb% 
  63.  more%
  64.  redraw the 'local' sprites window.
  65. rdlocal(f%)
  66.  Wupdw%,,Wb% 
  67.  more% 
  68. Wrdw%,,Wb% 
  69.  more%
  70. B&x0%=Wb%!4-Wb%!20:y0%=Wb%!16-Wb%!24
  71.  more%
  72. D3wx0%=Wb%!28:wy0%=Wb%!32:wx1%=Wb%!36:wy1%=Wb%!40
  73. localtag%>0 
  74.  XSpop%,564,!localtag%,!localtag%+localtag%!4,x0%,y0%,0,stransW%,sgblkB%
  75. sc(0,0,0):
  76.  x0%,y0%,xwL%*2,ywL%*2
  77.  Wgr%,0,Wb% 
  78.  more%
  79.  find the width of a text string in the current desktop font.
  80. twid(s$)
  81. "XOS_SWINumberFromString",,"Wimp_TextOp" 
  82. 1)=0 
  83. "XWimp_TextOp",1,s$,0 
  84. (s$)*16
  85.  print some text in the current desktop font.
  86. pp(x%,y%,tt$,bg%)
  87.  "XWimp_TextOp",0,0,bg%
  88. "XWimp_TextOp",2+(1<<30),tt$,-1,-1,x%,y%
  89.  work out the width of a PCA dialogue item.
  90.  uses fixed values for all but the width of the item name which can vary.
  91. uwid(s$,xx%)
  92. twid(s$)
  93.  xx%<>0 
  94. =v%+32+40+64+84
  95.  !!!PCA!!!
  96.  redraw pca dialogue box window.
  97.  chosen%,down% are for when an item is chosen
  98.  in order to simulate the button 'clicking'
  99. rdpca(f%,chosen%,down%)
  100.  Wupdw%,,Wb% 
  101.  more% 
  102.  Wrdw%,,Wb% 
  103.  more%
  104. l]xscrol%=Wb%!20:yscrol%=Wb%!24:x0%=Wb%!4-xscrol%+4:y1%=Wb%!8:x1%=Wb%!12:y0%=Wb%!16-yscrol%
  105.  "Wimp_BaseOfSprites" 
  106.  ,spa%
  107.  more%
  108. o&menu$=
  109. util$,
  110. (util$)-
  111. util$,"\"))
  112. p%=0:yy%=y0%+4
  113.  pca%=0 
  114.  utile%-1
  115. par("\",p%)
  116. chosen%=pca% 
  117.  down% 
  118. sc(&99,&99,&BB) 
  119. sc(&AA,&AA,&CC)
  120.  x0%,yy%+pca%*(uboxh%+8),uboxw%,uboxh%
  121. uAA%=x0%:B%=yy%+pca%*(uboxh%+8):C%=A%+uboxw%:D%=B%+uboxh%:
  122. chosen%=pca% 
  123.  down% A%+=4:B%-=4
  124.  display the sprite for this item.
  125.  utils$(pca%)<>"" 
  126.  XCtGet%,spa%,utils$(pca%),-1,-1,savea%,0
  127.  XSpop%,308,spa%,utils$(pca%),A%+12,B%+(uboxh%-68)/2,8,stransW%,savea%
  128.  display 'sm!info' if info available flag for this item is set.
  129.  "XWimp_ReadPixTrans",&100,sblock%,"sm!info",,,,stransW%,savea%
  130.  (uf%(pca%) 
  131.  %10)<>0 
  132.  XSpop%,308,sblock%,"sm!info",A%+uboxw%-48,B%+(uboxh%-40)/2,8,stransW%,savea%
  133.  display the items name.
  134.  chosen%=pca% 
  135.  down% 
  136. pp(A%+((uboxw%-
  137. twid(s$))/2),B%+uboxh%/2-12,s$,&BB999900) 
  138. pp(A%+((uboxw%-
  139. twid(s$))/2),B%+uboxh%/2-12,s$,&CCAAAA00)
  140.  Wgr%,0,Wb% 
  141.  more%
  142.  main redraw request proc.
  143. redraw(f%)
  144. w%=!Wb%
  145.  m_remote%:
  146. rdremote(f%)
  147.  m_local%:
  148. rdlocal(f%)
  149.  pca_w%:
  150. rdpca(f%,-1,0)
  151.  Wimp Message receipt.
  152. recieve_msg:
  153.  !Wb% 
  154. 4:Wbtsk%!l%=Wb%!l%:
  155. :le%=!Wb%:tsk%=Wb%!4
  156.  msg$=
  157. s(Wb%+44):mess%=Wb%!16
  158.  mess% 
  159. terminate
  160.  2:EX%=
  161.  Wb%!4<>Task_h% 
  162.  savingfile% 
  163.  mox%=Wb%!28:moy%=Wb%!32:
  164. savefile(
  165. s(Wb%+44),Wb%!36=-1):savingfile%=
  166.  EX%=
  167.  Wbtsk%!12=Wbtsk%!8:Wbtsk%!16=3:
  168. "Wimp_SendMessage",17,Wbtsk%,tsk% 
  169.  EX%=
  170.     EX%=0
  171.  Wb%!40<&1000 
  172. read_andload(
  173. s(Wb%+44),Wb%!40,Wb%!20,Wb%!24)
  174.  EX%=
  175.  Wb%!12=scrapref% 
  176.  *REMOVE <Wimp$Scrap>
  177.  EX%=
  178.  Wbtsk%!12=Wbtsk%!8:Wbtsk%!16=4:
  179. "Wimp_SendMessage",17,Wbtsk%,tsk%
  180.  !!!PCA!!! Incoming message handling
  181.  Receipt of Msg_ImHere - record details
  182.  Msg_Im%
  183.  utile%<24 
  184. Gutil$=util$+"\"+
  185. s(Wb%+28):utiltsk%(utile%)=tsk%:uf%(utile%)=Wb%!20
  186.  IFuf%(utile%) AND %10000<>0 THEN uf%(utile%)=uf%(utile%) AND &FFFFFFEF
  187.  Wb%!20 
  188.  1<>0 
  189.  utils$(utile%)=
  190. s(Wb%+60)
  191. utilid%(utile%)=Wb%!24
  192. uwid(
  193. s(Wb%+28),Wb%!20)
  194. uboxw%<v% uboxw%=v%
  195. utile%+=1
  196.  Msg_Info%:
  197. tsk%<>Task_h% 
  198.  Wbtsk%!12=0 
  199.  Receipt of Message_Info - return an info string.
  200. /s$="Spaint - a very simple paint program. "
  201. remotetag%>0 
  202.  s$=s$+"Linked to '"+wn$+"'" 
  203.  s$=s$+"Not linked to anything."
  204. string0(Wbtsk%+20,s$):!Wbtsk%=24+
  205. s(Wbtsk%+20)) 
  206. Wbtsk%!12=Wbtsk%!8
  207.  Wmess%,17,Wbtsk%,tsk%
  208.  return of Message_Info - display info string (if any)
  209.  Wb%!12=myref% 
  210. s(Wb%+20)<>"" 
  211. repmsg(
  212. s(Wb%+20))
  213.  Receipt of Message_WhosAbout - check details of object and respond with ImHere
  214.  Msg_Whos%
  215.  (Wb%!20 
  216.  &FFF)=&FF9 
  217.  tsk%<>Task_h% 
  218.  v%=Wb%!24:v%=(!v%+v%!4)!40)>>27:IFv%=6 THEN:REM only 32bpp sprites need apply?
  219. 1gb%!4=Task_h%:gb%!8=0:gb%!12=0:gb%!16=Msg_Im%
  220.  inplace% 
  221.  gb%!20=%10011 
  222.  gb%!20=%11:
  223.  flags word
  224. ,gb%!24=0:
  225. string0(gb%+28,"Simple Paint")
  226. string0(gb%+60,"!spaint"):!gb%=64+(
  227. s(gb%+60)) 
  228.  Wmess%,17,gb%,tsk%
  229.  ENDIF
  230.  Following not used by this example. This message is
  231.  returned after the owning task has successfully changed the size of the
  232.  object in response to Message_Resize sent. Check myref before acting
  233.  as it may be a resize request by another program.
  234.  Msg_ResizeAck%
  235. Wb%!12=myref% 
  236. dotheresize:myref%=0
  237.  Receipt of Message_DoYourStuff
  238.  open remote window and display the object.
  239.  Msg_Do%
  240. tsk%=Wb%!4
  241.  are we already editing something?
  242.  if so (and its not this tag), send the old local task an unhook...
  243.  remotetag%>0 
  244.  remotetag%<>Wb%!24 
  245.  tskh%=localtask%:ms0%=0:ms1%=remotetag%:
  246. pca(Msg_Unhook%)
  247.  new local task...
  248. localtask%=Wb%!4
  249. uflg%=Wb%!36
  250.  beginning an inplace session so close the remote window (if open).
  251.  (uflg% 
  252.  %10000)<>0 
  253.  inplace% 
  254. CwT(m_remote%)
  255. newmunge
  256.  inplace on so opentoolbar and send Msg_Hook (which will generate msg_ObjPos for us)
  257.  (uflg% 
  258.  %10000)<>0 
  259.  remotetag%>0 
  260.  inplace% 
  261.  tskh%=localtask%:
  262. pca(Msg_Hook%):
  263. Ow(w_remotet%,-1,-1,-1)
  264.  object position message.
  265.  open toolbar at correct position and depth
  266.  Msg_ObjPos%
  267.  Wb%!24=remotetag% 
  268. =remotescale%=Wb%!48:remotexpos%=Wb%!52:remoteypos%=Wb%!56
  269. Dremotescaley%=Wb%!28:
  270. remotescaley%=0 remotescaley%=remotescale%
  271. xown%=Wb%!32:yown%=Wb%!36
  272. !gblk%=w_remotet%:gblk%!4=Wb%!32:gblk%!8=Wb%!36-64:gblk%!12=gblk%!4+192:gblk%!16=gblk%!8+64:gblk%!20=0:gblk%!24=0:gblk%!28=Wb%!44:
  273.  Wow%,,gblk%
  274.  sent an unhook message.
  275.  as Spaint can handle both sides of the protocol it
  276.  must check to see if it is the remote or local task which is asking it
  277.  to unhook.
  278.  Msg_Unhook%
  279.  remote task - therefore we are the local so delete trap icon.
  280. Wb%!24=localtag% 
  281.  tsk%=remotetask% 
  282. deleteRicon(0):aremote%=-1:remotetask%=0
  283.  local task - therefore we are the remote so close window/toolbar
  284.  Wb%!24=remotetag% 
  285.  tsk%=localtask% 
  286.  remotetag%=-1:
  287. Cw(m_remote%):
  288. Cw(w_remotet%):localtask%=0
  289.  sent a hook message by a remote task
  290.  create a trap icon and send Msg_ObjPos
  291.  Msg_Hook%
  292.  Wb%!24=localtag% 
  293. ?remotewin%=Wb%!32:remotetask%=Wb%!4:aremote%=0:rbut%=Wb%!28
  294. 5remoteicon%=
  295. createRicon(0,0,xwL%*2,ywL%*2,rbut%)
  296. gwi(m_local%):y1a%=y1%-yscrol%:yscrola%=yscrol%:xscrola%=xscrol%
  297. xposU%=winx%:yposU%=y1a%
  298. xposL%=xposU%:yposL%=yposU%
  299. xposL%<x0% 
  300.  xposL%=x0%
  301. yposL%<y0% 
  302.  yposL%=y0%
  303. xposL%>x1% 
  304.  xposL%=x1%
  305. yposL%>y1% 
  306.  yposL%=y1%
  307. sfac%=65536:
  308.  100% scale
  309. Jms2%=m_local%:ms3%=w_localt%:v%=s%:tskh%=remotetask%:
  310. pca(Msg_ObjPos%)
  311.  Message_Changed message
  312.  assume nothing is the same!
  313.  Msg_Changed%
  314.  Wb%!24=remotetag% 
  315. newmunge
  316. Wb%!24=localtag% 
  317.  tsk%<>Task_h% 
  318. prime_local(local$):
  319. redrawit(m_local%)
  320.  Message_Deselect - delink from object as it has been deleted.
  321.  Msg_Desel%
  322. Wb%!24=localtag% 
  323.  aremote%>=0 
  324. deleteRicon(0):aremote%=-1
  325. Wb%!24=remotetag% 
  326. remotetag%=0:localtask%=0
  327. #wn$="Nothing":$maint%="Nothing"
  328.  maino% 
  329. redrawit(m_remote%) 
  330. Cw(w_remotet%)
  331.  Message_Done% someone has modified the entire object
  332.  so redraw it. Its size and other parameters are still the same though.
  333.  Msg_Done%
  334. remotetag%=Wb%!24 
  335. redrawit(m_remote%)
  336. Wb%!24=localtag% 
  337. redrawit(m_local%)
  338.  Message_UpdateArea - an area of the object has been modified
  339.  update the correct area of the window quickly.
  340.  Msg_Uparea%
  341. remotetag%=Wb%!24 
  342. +=ms0%=Wb%!28:ms1%=Wb%!32:ms2%=Wb%!36-ms0%:ms3%=Wb%!40-ms1%
  343. spritexm%=4:spriteym%=4
  344. redrawW(m_remote%,ms0%,ms1%,ms2%,ms3%)
  345. localtag%=Wb%!24 
  346. 0=ms0%=Wb%!28:ms1%=Wb%!32:ms2%=Wb%!36-ms0%:ms3%=Wb%!40-ms1%
  347. spritexm%=4:spriteym%=4
  348. redrawW(m_local%,ms0%,ms1%,ms2%,ms3%)
  349.  Example return from Message_MiscOp (Compo_GiveDetails)
  350.  not used by this program.
  351.  Msg_Misc%:
  352. tsk%<>Task_h% 
  353.  Wb%!20 
  354.  Sub_Associated%
  355.  '"Details of object "
  356.  '"Masks:"
  357. xx%=0 
  358.  xx%;" address="~Wb%!(40+xx%*4):
  359.  '"Opacity=";Wb%!68
  360.  "Math=";Wb%!72
  361. &400C1:
  362. initsptrans
  363. &400C0:
  364. "Wimp_CreateSubMenu",,Wb%!20,Wb%!24,Wb%!28
  365. &502:
  366. helptext
  367.  &47700,&47701:vh%=Wb%!20:v2%=Wb%!28:
  368.  mess%=&47700 
  369.  oFCOL1%=v2%
  370.  (Wb%!24 
  371.  1)=1 
  372.  v2%=-1
  373.  mx%,my%,bt%:
  374. (bt%=5 
  375.  mess%=&47700) 
  376.  ColourChanged
  377. pcol%=v2%:oFCOL1%=pcol%
  378. mess%=-1
  379. &47702:vh%=Wb%!20:v2%=Wb%!28
  380.  mx%,my%,b%
  381. pcol%=oFCOL1%
  382.  b%<>1 
  383. &67703,0,Wb%!20:lcpw%=0
  384.  !!!PCA!!!
  385.  new or radically modified remote object so re-read its details (width and height may have changed etc.)
  386. newmunge
  387.  Wb%!20<>&FF9 
  388.  woops, we can't edit that...
  389.  remotetag%>0 
  390.  tskh%=localtask%:ms0%=0:ms1%=remotetag%:
  391. pca(Msg_Unhook%)
  392. Z0remotetag%=-1:wn$="Nothing":
  393. Cw(m_remote%):
  394. remotetag%=Wb%!24
  395. mess%=Msg_Do% 
  396.  wn$=
  397. s(Wb%+40):
  398. wn$="" 
  399.  wn$="<The image with no name>"
  400. mess%=Msg_Changed% 
  401. s(Wb%+32):
  402. w$<>"" 
  403.  wn$=w$
  404. initsptrans
  405.  Spop%,552,!remotetag%,!remotetag%+remotetag%!4 
  406.  ,,,xwhook%,ywhook%
  407.  (uflg% 
  408.  %10000)=0 
  409.  inplace%=0 
  410. prime_remote:
  411. Ow(m_remote%,-1,-1,-1)
  412.  !!!PCA!!!
  413.  new/updated local image
  414.  broadcast Message_Changed
  415.  alternative would be to broadcast Message_Deselect for old object.
  416.  in this case we ask anyone who was linked into the old object
  417.  to accept the new one. This may fail (eg new object is different type/bpp)
  418.  in which case the app receiving Message_Changed should delink quietly
  419. loadsprite(s$)
  420. local$=s$
  421. r_fi(s$):spril%=length%
  422. doclaimg(spril%,spria%,"mem1","SPaint image",m64%)
  423. rGlocal%=
  424. ourarea(spria%):!local%=spril%:
  425. "LOAD "+s$+" "+
  426. ~(local%+4)
  427. s3local2%=local%+local%!8:
  428.  first sprite in area.
  429.  !!!PCA!!!
  430. localtag%=-1 
  431. "PCA_CreateTag",,local%,local%!8,!local%,0 
  432.  localtag%
  433. x+localtag%!0=local%:localtag%!4=local%!8
  434.  hack - we can't resize when the window is open!
  435. {-!Wb%=m_local%:
  436.  "XWimp_CloseWindow",,Wb%
  437. prime_local(s$)
  438. Ow(m_local%,-1,-1,-1)
  439. redrawit(m_local%)
  440. 7ms0%=localtag%:ms0$=
  441. gls(local$):
  442. pca(Msg_Changed%)
  443. mini_poll(8)
  444. aremote%>=0 
  445. resizeRicon(0,0,0,xwL%*xpix%,ywL%*ypix%)
  446.  open the local window to suit the new size of the object.
  447. prime_local(s$)
  448. local2%=local%+local%!8
  449.  Spop%,552,!localtag%,!localtag%+localtag%!4 
  450.  ,,,xwL%,ywL%
  451. local%>0 
  452.  "Wimp_ReadPixTrans",&200,!localtag%,!localtag%+localtag%!4,,,,stransW%,sgblkB%
  453.  XCtGet%,!localtag%,!localtag%+localtag%!4,-1,-1,sgblkB%,1
  454. setsize(m_local%,ywL%*ypix%/ypixf,xwL%*xpix%/xpixf)
  455. $localt%="Local:"+s$
  456. prime_remote
  457. setsize(m_remote%,ywhook%*ypix%/ypixf,xwhook%*xpix%/xpixf)
  458. $maint%="Linked to:"+wn$
  459. maino% 
  460.  !Wb%=m_remote%:
  461. Wgwst%,,Wb%:
  462. CwT(m_remote%):x%=Wb%!4:y%=Wb%!8 
  463.  x%=-1:y%=-1
  464. Ow(m_remote%,x%,y%,-1)
  465.  quit the program.
  466. terminate
  467.  !!!PCA!!! local must remember to broadcast Msg_Desel before removing your object.
  468. localtag%>0 
  469. pca(Msg_Desel%)
  470.  localtag%>0 
  471. "PCA_DeleteTag",localtag%:localtag%=-1
  472.  !!!PCA!!! remote must send Msg_Unhook before quitting.
  473.  remotetag%>0 
  474.  tskh%=remotetask%:ms0%=1:ms1%=remotetag%:
  475. pca(Msg_Unhook%)
  476. spril%=0:
  477. killara(spria%)
  478. ms_end
  479. "Wimp_CloseDown",Task_h%:
  480. "XOS_Exit"
  481.  user clicked in a remote window.
  482. remote_win
  483. Bt%=2 
  484. gpi:ppick%=
  485. picker("Paint colour",pcol%,mox%-128,moy%+128,%1,%100)
  486. remotetag%=0 
  487. Icn%<>-&414350 
  488. G!gb%=m_remote%:
  489.  Wgwst%,,gb%:winx%=gb%!4-gb%!20:y1a%=gb%!16-gb%!24
  490. scalefacX=1:scalefacY=1
  491. "moy%=moy%-y1a%:mox%=mox%-winx%
  492.  scalefacX=remotescale%/65536
  493. !scalefacY=remotescaley%/65536
  494. &winx%=remotexpos%:y1a%=remoteypos%
  495. omox%=mox%:omoy%=moy%
  496. swtos(!remotetag%,!remotetag%+remotetag%!4)
  497. Bt%=4 
  498.  CtSgcol%,pcol%,,,256,0 
  499. Bt%=1 
  500.  CtSgcol%,0,,,256,0
  501.  mox%,moy%,size2%
  502. swbak
  503. Kms0%=mox%-size2%:ms1%=moy%-size2%:ms2%=mox%+size2%+4:ms3%=moy%+size2%+4
  504. ms0%<0 ms0%=0
  505. ms1%<0 ms1%=0
  506. ms2%>xwhook%*2 ms2%=xwhook%*2
  507. ms3%>ywhook%*2 ms3%=ywhook%*2
  508.  maino% 
  509. `!Wb%=m_remote%:Wb%!4=ms0%*mscd:Wb%!8=ms1%*mscd:Wb%!12=Wb%!4+ms2%*mscd:Wb%!16=Wb%!8+ms3%*mscd
  510.  Wupdw%,,Wb% 
  511.  more%
  512. &x0%=Wb%!4-Wb%!20:y0%=Wb%!16-Wb%!24
  513.  more%
  514.  Spop%,564,!remotetag%,!remotetag%+remotetag%!4,x0%,y0%,0,stransW%,sgblk%
  515.  Wgr%,0,Wb% 
  516.  more%
  517.  !!!PCA!!!
  518.  user has painted into remote object so
  519.  broadcast message_updatearea so other apps using
  520.  the object can redraw the appropriate part of their windows
  521. pca(Msg_Uparea%)
  522. mini_poll(1)
  523. gpi:mox%=mox%-winx%:moy%=moy%-y1a%
  524. +mox%=mox%/scalefacX:moy%=moy%/scalefacY
  525.  Bt%=0
  526. Riconpositions
  527.  do resizeRicon for each linked object which has moved
  528.  delete 'remote' trap icon
  529.  this is a _simple_ version as Spaint
  530.  can only handle one object at a time.
  531.  more sophistocated apps will have to do better.
  532. deleteRicon(i%):
  533. i%<0 
  534. 9!gblk%=m_local%:gblk%!4=i%:
  535. "Wimp_DeleteIcon",,gblk%
  536. i%*32+remoteicblk%=ricptr%-32 
  537.  ricptr%-=32
  538.  (ricptr%!20 
  539.  1<<23)<>0 
  540.  ricptr%>remoteicblk%
  541. ricptr%-=32
  542.  resize 'remote' trap icon
  543. resizeRicon(i%,x%,y%,w%,h%)
  544. "XWimp_ResizeIcon",m_local%,i%,x%,y%,(x%+w%),(y%+h%) 
  545.  r0;F
  546.  IF (F AND 1)<>0 THEN PROCreperr(FNs(r0+4)):ENDPROC
  547. gwi(m_local%):y1a%=y1%-yscrol%:yscrola%=yscrol%:xscrola%=xscrol%
  548. xposU%=winx%:yposU%=y1a%
  549. xposL%=xposU%:yposL%=yposU%
  550. xposL%<x0% 
  551.  xposL%=x0%
  552. yposL%<y0% 
  553.  yposL%=y0%
  554. xposL%>x1% 
  555.  xposL%=x1%
  556. yposL%>y1% 
  557.  yposL%=y1%
  558. sfac%=65536:
  559.  100% scale
  560. Dms2%=m_local%:ms3%=w_localt%:tskh%=remotetask%:
  561. pca(Msg_ObjPos%)
  562.  !!!PCA!!! create a 'remote' trap icon to cover the object
  563.  a simple version. For more complex apps (multiple objects)
  564.  something better will have to be done.
  565. createRicon(x%,y%,w%,h%,flgs%)
  566. ricptr%>=remoteicblk%+32*10 
  567.  1,"Remote icon store full!"
  568. #flgs%=flgs%>>28:flgs%=flgs%<<12
  569. !ricptr%=m_local%
  570. Cricptr%!4=x%:ricptr%!8=y%:ricptr%!12=(x%+w%):ricptr%!16=(y%+h%)
  571. 7ricptr%!20=flgs%:
  572.  Rbdr% ricptr%!20=ricptr%!20+%100
  573.  "Wimp_CreateIcon",aremote%,ricptr% 
  574. ricptr%+=32
  575.  !!!PCA!!!
  576.  send message on to remote task.
  577. remotemessage(R%)
  578. sp%=-1:y1a%=y1%-yscrol%
  579.  locate object which matches icon...
  580.  Icn%=remoteicon% 
  581.  remotetask%<>0 
  582. Q!Wb%=!Wb%-winx%:Wb%!4=Wb%!4-y1a%:Wb%!8=tBt%:Wb%!12=remotewin%:Wb%!16=-&414350
  583.  "Wimp_SendMessage",R%,Wb%,remotetask%
  584.  !!!PCA!!!
  585.  Central Message despatch proc.
  586. pca(msg%)
  587.  don't bother with remote update messages if no remote object in use:
  588. remotetag%=0 
  589.  (msg%=Msg_Resize% 
  590.  msg%=Msg_Uparea% 
  591.  msg%=Msg_Misc%) 
  592. 7gb%!4=Task_h%:gb%!8=0:gb%!12=0:gb%!16=msg%:send%=17
  593.  msg% 
  594.  Send Message_WhosAbout
  595.  Msg_Whos%
  596. !util$="#Utilities":pcatask%=0
  597. utiltsk%()=0:utile%=0
  598. utilid%()=0
  599. uf%()=0
  600. #$uboxw%=0:
  601.  max width of dialogue
  602.  sprite, local tag
  603. %)gb%!20=&FF9:gb%!24=localtag%:gb%!28=0
  604. &%!gb%=32:th%=0:
  605.  broadcast message
  606.  Ask task for info about itself.
  607.  Msg_Info%
  608. *!gb%!20=0:!gb%=24:th%=pcatask%
  609.  Tell task to do its stuff (link onto object)
  610.  Msg_Do%
  611. .)gb%!20=&FF9:gb%!24=localtag%:gb%!28=0
  612. /8gb%!32=utilid%(item%):gb%!36=uf%(item%):rflg%=gb%!36
  613. string0(gb%+40,
  614. gls(local$))
  615. !gb%=44+
  616. s(gb%+40))
  617. 2Bth%=utiltsk%(item%):
  618.  send message direct to appropriate task.
  619.  Broadcast message_done (not used by this program as it
  620.  has no 'whole object modified' functions).
  621.  Msg_Done%
  622. gb%!20=&FF9
  623. gb%!24=remotetag%:gb%!28=0
  624. !gb%=32:th%=0
  625.  Broadcast Message_UpdateArea
  626.  so other tasks can redraw appropriate area of their windows.
  627.  Msg_Uparea%
  628. >_gb%!20=&FF9:gb%!24=remotetag%:gb%!28=ms0%:gb%!32=ms1%:gb%!36=ms2%:gb%!40=ms3%:!gb%=44:th%=0
  629.  Send Resize_Request to owning task
  630.  not used by this program.
  631.  ms0% is the new size of the object
  632.  total size - including header.
  633.  owner will reply with ResizeAck if successful
  634.  Msg_Resize%
  635. FMgb%!20=&FF9:gb%!24=remotetag%:gb%!28=0:gb%!32=ms0%:gb%!36=0:!gb%=40:th%=0
  636. send%=18
  637.  Broadcast Message_Changed
  638.  sent when new local image and after ResizeAck and data structure changes.
  639.  Msg_Changed%
  640. L$gb%!20=&FF9:gb%!24=ms0%:gb%!28=0
  641. ms0$<>"" 
  642. string0(gb%+32,ms0$):!gb%=36+
  643. s(gb%+32))
  644.  gb%!32=0:!gb%=36
  645. N    th%=0
  646.  Broadcast Message_MiscOp with Sub_GiveInfoCompo
  647.  not used by this program.
  648.  Msg_Misc%
  649. SIgb%!20=Sub_Give%:gb%!24=&FF9:gb%!28=remotetag%:gb%!32=0:!gb%=36:th%=0
  650.  Broadcast Message_Deselect as object has been deleted.
  651.  Msg_Desel%
  652. gb%!20=&FF9
  653. gb%!24=localtag%:gb%!28=0
  654. YF!gb%=32:th%=0:pcatask%=0:remotetask%=0:
  655. deleteRicon(0):aremote%=-1
  656.  send msg_objPos to remote task
  657.  see Wimp_Poll loop for call details.
  658.  Msg_ObjPos%
  659. gb%!20=0
  660. gb%!24=localtag%:gb%!28=0
  661. `rgb%!32=xposL%:gb%!36=yposL%:gb%!40=ms2%:gb%!44=ms3%:gb%!48=sfac%:gb%!52=xposU%:gb%!56=yposU%:th%=tskh%:!gb%=60
  662.  send msg_Hook to local task
  663.  this asks it to trap messages to the object and
  664.  pass them back to us.
  665.  Msg_Hook%
  666. gb%!20=0
  667. f9gb%!24=remotetag%:gb%!28=%11<<28:
  668.  window button type
  669. g&gb%!32=m_remote%:!gb%=36:th%=tskh%
  670.  send msg_unhook
  671.  Msg_Unhook%
  672. gb%!20=0
  673. gb%!24=ms1%:gb%!28=0
  674. m1gb%!32=m_local%:gb%!36=ms0%:!gb%=40:th%=tskh%
  675.  Hey, thats our local tag (we'd better delete the trap icon...)
  676. ms1%=localtag% 
  677.  remotetask%=0:
  678. deleteRicon(0):aremote%=-1
  679.  send the message and keep ref for checking in Message_Receipt
  680.  Wmess%,send%,gb%,th%:myref%=gb%!8
  681.  !!!PCA!!!
  682.  generate the plug-in dialogue
  683.  start by sending Message_WhosAbout and
  684.  poll until the messages stop flooding in.
  685. pcasprite
  686. pca(Msg_Whos%)
  687. mini_poll(0)
  688.  RR%=0
  689. util$="#Utilities" 
  690. repmsg("No utilities are available for this object at the moment. Please load a utility providing application and try again.")
  691.  simple menu...
  692. popuptype%=1 
  693. Ocurrbuff%=cbstr%:maxbuff%=cbstr%+&80:menufree%=cbbuff%:menuend%=cbbuff%+&80
  694. ;m_pca%=
  695. cmen(util$):
  696. menu(m_pca%,mox%-186,moy%+12)
  697.  ...or something more ambitious
  698. >!Wb%=pca_w%:
  699.  "Wimp_DeleteWindow",,Wb%:c%=(1<<28)+(1<<29)
  700.  If more than five utilities give it a scrollbar (and limit opened size to five)
  701.  utile%>5 
  702.  e%=(1<<28)+(1<<29) 
  703.  e%=0
  704. .pca_wblock%!28=(pca_wblock%!28 
  705. Wcw%,,pca_wblock% 
  706.  pca_w%
  707.  maximum height of dialogue.
  708. ole2h%=((uboxh%+8)*utile%)
  709.  open as a menu positioned such that the first item is centred about the mouse pointer.
  710. setsize3(pca_w%,ole2h%,uboxw%+10,mox%-uboxw%/2,moy%-ole2h%/2):wh%=Wb%!16-Wb%!8
  711. Cw(pca_w%):x%=mox%-uboxw%/2:y%=moy%+(uboxh%/2)
  712.  while coping with pointer near the edge of the screen!
  713. x%<0 x%=0
  714. y%-wh%<0 y%=wh%
  715.  Wcm%,,pca_w%,x%,y%
  716.  general proc. for setting the maximum extent of a window - modified to limit
  717.  the displayed size to a maximum of 5* the height of a pca dialogue item.
  718. setsize3(whn%,h%,w%,x%,y%)
  719. x%<0 x%=0
  720. y%<0 y%=0
  721. U!Wb%=whn%:
  722. Wgwst%,,Wb%:Wb%!4=0:Wb%!8=0:Wb%!16=h%:Wb%!12=w%:
  723. &600D7,whn%,(Wb%+4)
  724. h%>(uboxh%+8)*5 Wb%!16=(uboxh%+8)*5
  725. YWb%!28=-1:Wb%!4=Wb%!4+x%:Wb%!8=Wb%!8+y%:Wb%!12=Wb%!12+x%:Wb%!16=Wb%!16+y%:
  726. Wow%,,Wb%
  727.  !!!PCA!!!
  728.  user has chosen an item in the PCA dialogue
  729.  either send Message_DoYourStuff or Message_Info
  730.  depending on flags and where user clicked.
  731. pca_win
  732.  get window info an work out which button they clicked on.
  733. gwi(pca_w%):oBt%=Bt%:y1a%=y1%-yscrol%
  734. 9item%=(moy%-y1a%)/(uboxh%+8):
  735. item%>utile%-1 item%=-1
  736. xx%=mox%-winx% 
  737. item%>=0 
  738.  make the 'button' click
  739. h!Wb%=pca_w%:Wb%!4=0:Wb%!8=item%*(uboxh%+8):Wb%!12=vissizX%:Wb%!16=Wb%!8+(uboxh%+2):
  740. rdpca(
  741. ,item%,
  742.  Bt%=0
  743. h!Wb%=pca_w%:Wb%!4=0:Wb%!8=item%*(uboxh%+8):Wb%!12=vissizX%:Wb%!16=Wb%!8+(uboxh%+2):
  744. rdpca(
  745. ,item%,0)
  746. pcatask%=utiltsk%(item%)
  747.  clicked on info or elsewhere in button?
  748.  xx%<uboxw%-42 
  749.  ((uf%(item%) 
  750.  %10)=0) 
  751.  Does the utility want sole access to the object?
  752.  (uf%(item%) 
  753.  %1000)<>0 
  754. pca(Msg_Desel%)
  755.  make _sure_ there is a tag for the local object.
  756.  we do it when loading the object so this isn't strictly
  757.  necessary...If you don' want a PCA tag for every object
  758.  you create then this is the time to create it.
  759. localtag%<0 
  760. "PCA_CreateTag",,local%,local%!8,0,0 
  761.  localtag%
  762. *!localtag%=local%:localtag%!4=local%!8
  763.  are we already in an inplace session?
  764.  if so, send an unhook to the previous remote...
  765.  ((uf%(item%) 
  766.  %10000)<>0 
  767.  aremote%<>-1) 
  768.  remotetask%=utiltsk%(item%) 
  769. remotetask%<>0 
  770.  tskh%=remotetask%:ms0%=1:ms1%=localtag%:
  771. pca(Msg_Unhook%)
  772.  tell the utility to do its stuff...
  773. pcatsk%=utiltsk%(item%)
  774. pca(Msg_Do%)
  775. +pcatsk%=utiltsk%(item%):
  776. pca(Msg_Info%)
  777.  Only close dialogue if SELECT clicked.
  778. oBt%=4 
  779. Cw(pca_w%)
  780. select_menu
  781. check_adj=
  782.  adjusting%=
  783.  adjusting%=
  784. mnhnd%=m_ibar% 
  785.  !Wb%=2 
  786. terminate
  787. mnhnd%=m_ibar% 
  788.  !Wb%=1 
  789. oo(w_prefs%,4,inplace%):
  790. Ow(w_prefs%,-1,-1,-1)
  791. mnhnd%=mm_remote% 
  792.  !Wb% 
  793.  !!!PCA!!!
  794.  not used by demo, example 'change object size'
  795.  function.
  796.  double size request
  797. Ucursize%=!remotetag%:cursize%=!cursize%:
  798.  read total size from sprite area header
  799. Nadat%=!remotetag%+remotetag%!4:adat%=adat%+adat%!32:hdr%=adat%-!remotetag%
  800. %ms0%=hdr%+xwhook%*4*2*(ywhook%*2)
  801. pca(Msg_Resize%)
  802. pca(Msg_Misc%)
  803. mnhnd%=m_pca% 
  804. item%=!Wb%
  805.  (uf%(item%) 
  806.  %1000)<>0 
  807.  v%=0:
  808. pca(Msg_Desel%)
  809. pcatask%=utiltsk%(item%)
  810. pca(Msg_Do%)
  811.  adjusting% 
  812. menu(mnhnd%,mousex%,mousey%):
  813. mnhnd%=-1
  814. prefs_win
  815.  Icn% 
  816.  2,3:popuptype%=Icn%-2:
  817. uiG(w_prefs%,2,3,0):
  818. ui(w_prefs%,popuptype%+2,1<<21)
  819.  4:inplace%=
  820.  inplace%:
  821. oo(w_prefs%,4,inplace%)
  822.  !!!PCA!!!
  823.  user has toggled inplace editing option
  824.  Did we begin with inplace on?
  825.  (uflg% 
  826.  %10000)<>0 
  827.  remotetag%>0 
  828. inplace%=0 
  829.  yes, now off so send (temporary) unhook and open remote window.
  830. =tskh%=localtask%:ms0%=0:ms1%=remotetag%:
  831. pca(Msg_Unhook%)
  832. prime_remote
  833. maino% 
  834.  !Wb%=m_remote%:
  835. Wgwst%,,Wb%:
  836. CwT(m_remote%):x%=Wb%!4:y%=Wb%!8 
  837.  x%=-1:y%=-1
  838. Ow(m_remote%,x%,y%,-1)
  839. Ow(m_remote%,-1,-1,-1)
  840. redrawit(m_remote%)
  841.  yes, and now turned on again so close our window and send Msg_Hook
  842. CwT(m_remote%):tskh%=remotetask%:
  843. pca(Msg_Hook%):
  844. Ow(w_remotet%,-1,-1,-1)
  845. remoteT_win
  846.  Icn% 
  847.  !!!PCA!!! User has clicked close icon in remote toolbar - we unhook
  848.  0:tskh%=remotetask%:ms0%=1:ms1%=remotetag%:
  849. pca(Msg_Unhook%):remotetag%=-1:
  850. Cw(m_remote%):
  851. Cw(w_remotet%)
  852.  1:ppick%=
  853. picker("Paint colour",pcol%,mox%-128,moy%+128,%1,%100)
  854. localT_win
  855.  Icn% 
  856.  info
  857.  utils
  858. pcasprite
  859.  close
  860.  !!!PCA!!!
  861. localtag%>0 
  862. pca(Msg_Desel%):
  863. Cw(m_local%)
  864. click:tBt%=Wb%!8:Bt%=tBt%:mox%=Wb%!0:moy%=Wb%!4:Icn%=Wb%!16:Win%=Wb%!12
  865.  Win% 
  866.  m_remote%:
  867. remote_win
  868.  m_local%:
  869. local_win
  870.  pca_w%:
  871. pca_win
  872.  w_prefs%:
  873. prefs_win
  874.  w_report%:
  875.  Icn%=0 
  876. Cw(w_report%)
  877.  w_remotet%:
  878. remoteT_win
  879.  w_localt%:
  880. localT_win
  881.  Icn%=icnbh% 
  882.  Bt%=2 
  883. menu(m_ibar%,mox%-144,204)
  884.  Icn%=icnbh% 
  885.  Bt%=4 
  886. remotetag%>0 
  887.  localtag%>0 
  888.  remotetag%>0 
  889.  inplace% 
  890. 7?EX%=0:
  891. prime_remote:
  892.  EX% 
  893. Ow(m_remote%,-1,-1,-1) 
  894.  EX%=0
  895.  remotetask%<>0 
  896.  inplace% 
  897.  remotetag%>0 
  898. Ow(w_remotet%,-1,-1,-1)
  899. localtag%>0 
  900. prime_local(local$):
  901. Ow(m_local%,-1,-1,-1)
  902. reperr("Spaint has nothing to work on at the moment. Either link an image in or drag an image to the icon.")
  903.  *************************************************************************************************
  904.  bits'n pieces of little interest follow...
  905. getpath(s$):n%=
  906. (s$):
  907. :ch$=
  908. s$,n%,1):n%-=1:
  909. (n%<=0 
  910.  ch$="." 
  911.  ch$=":" 
  912.  ch$=
  913.  n%>0 
  914. s$,n%+1)
  915. varpresent(s$):
  916. "XOS_ReadVarVal",s$,gblk%,(1<<31),0,3 
  917.  ,,exists%:=exists%<>0
  918. gls(s$):n%=
  919. (s$):
  920. :ch$=
  921. s$,n%,1):n%-=1:
  922. (n%<=0 
  923.  ch$="." 
  924.  ch$=":" 
  925.  ch$=
  926.  n%>0 
  927. (s$)-n%-1)
  928. s$,10)
  929. r_fi(nme$)
  930.  "XOS_File",5,nme$ 
  931.  there%,B,ft%,D,length% ;F
  932. ft%=(ft%>>8) 
  933.  1)<>0 
  934. there%=255
  935. ft%=&FCA 
  936.  there%=1 
  937.  ff%=
  938. (nme$):
  939. "OS_GBPB",4,ff%,gblk%,32:
  940. #ff%:ff%=0:orlen%=gblk%!4:type%=!(gblk%+8):type%=(type%>>8) 
  941.  &FFF
  942.  IFft%=pshopty%
  943.  there%=1 
  944.  ff%=
  945. (nme$):
  946. "OS_GBPB",4,ff%,gblk%,32:
  947. #ff%:ff%=0:
  948.  !gblk%=&53504238 
  949.  ft%=&524F42:type%=&524F42
  950. frc_redraw:
  951.  WfrcR%,-1,0,0,&FFFF,&FFFF:
  952. CwT(hand%):
  953.  (Temporary) close window - used to allow window resize.
  954. hand%<=0 
  955. `)!Wb%=hand%:
  956. "XWimp_CloseWindow",,Wb%
  957.  hand%=m_remote% 
  958.  maino%=0:!Wb%=w_remotet%:
  959.  "XWimp_CloseWindow",,Wb%
  960.  hand%=m_local% 
  961.  !Wb%=w_localt%:
  962.  "XWimp_CloseWindow",,Wb%
  963. Cw(hand%)
  964. hand%<=0 
  965. g)!Wb%=hand%:
  966. "XWimp_CloseWindow",,Wb%
  967.  hand%=m_remote% 
  968.  maino%=0:!Wb%=w_remotet%:
  969.  "XWimp_CloseWindow",,Wb%
  970.  hand%=m_local% 
  971.  !Wb%=w_localt%:
  972.  "XWimp_CloseWindow",,Wb%
  973.  !!!PCA!!! closing local window - tell the remote to close its toolbar with an unhook.
  974. hand%=m_local% 
  975.  tskh%=remotetask%:ms0%=1:ms1%=localtag%:
  976. pca(Msg_Unhook%)
  977.  !!!PCA!!! closing remote window - tell the local.
  978. hand%=m_remote% 
  979.  tskh%=localtask%:ms0%=1:ms1%=remotetag%:
  980. pca(Msg_Unhook%):remotetag%=-1
  981. Confirmchange(str1$):!GB%=1:$(GB%+4)=str1$
  982.  "Wimp_ReportError",GB%,19,"SPaint" 
  983.  ,resp%
  984. =(resp%=1)
  985. mini_poll(s5%)
  986. s2%=0 
  987. &400C7,0,Wb% 
  988.  RR% 
  989. redraw(0)
  990. Wow%,,Wb%
  991. Cw(!Wb%)
  992. mini_click
  993. key_pressed
  994. 17,18,19:R%=RR%:
  995. recieve_msg
  996. mini_click
  997. local_win
  998. Icn%>=0 
  999. gwi(m_local%):
  1000. remotemessage(R%):
  1001. Bt%=4 
  1002. pcasprite
  1003. Bt%=2 
  1004. menu(m_ibar%,mox%-128,moy%+48)
  1005. spritep1(v%):=v%+v%!8
  1006. swtosm(v1%,v2%):
  1007.  v1%<&8000 
  1008.  v2%<&8000 
  1009.  &524F42,"Redirection to invalid sprite."
  1010. J!savea%=0:
  1011. Spop%,573,v1%,v2%,savea% 
  1012.  sw0%,sw1%,sw2%,sw3%:switched%=
  1013. swtos(v1%,v2%):
  1014.  v1%<&8000 
  1015.  v2%<&8000 
  1016.  &524F42,"Redirection to invalid sprite."
  1017. J!savea%=0:
  1018. Spop%,572,v1%,v2%,savea% 
  1019.  sw0%,sw1%,sw2%,sw3%:switched%=
  1020. swto(v%)
  1021. M!savea%=0:
  1022. Spop%,572,v%,v%+v%!8,savea% 
  1023.  sw0%,sw1%,sw2%,sw3%:switched%=
  1024. swbak
  1025.  switched% 
  1026. Spop%,sw0%,sw1%,sw2%,sw3%:switched%=0
  1027. picker(s$,col%,x%,y%,f,f2)
  1028. $gb%=s$
  1029. A!Mgb%=f2:
  1030.  col%=-1 
  1031.  (f2 
  1032.  %1)<>0 
  1033.  col%=&FFFFFF00:!Mgb%=%111
  1034. YMgb%!4=gb%:Mgb%!8=x%:Mgb%!12=(1<<31):Mgb%!16=(1<<31)-1:Mgb%!20=y%:Mgb%!24=0:Mgb%!28=0
  1035. Mgb%!32=col%
  1036. Mgb%!36=0
  1037. "ColourPicker_OpenDialogue",f,Mgb% 
  1038.  h%,lcpw%
  1039. wword(
  1040.  b%,v%)
  1041. !b%=v%:b%+=4:
  1042. wstring(
  1043.  b%,s$)
  1044. $b%=s$:b%=b%+4+
  1045. nudge
  1046. -58 moy%+=1:
  1047.  mox%,moy%
  1048. -26 mox%-=1:
  1049.  mox%,moy%
  1050. -122 mox%+=1:
  1051.  mox%,moy%
  1052. -42 moy%-=1:
  1053.  mox%,moy%
  1054.  mox%,moy%,Bt%:
  1055. nudge
  1056. rpanes
  1057. (!gb%=!Wb%:
  1058.  Wgwst%,,gb%:flg%=gb%!32
  1059.  m_local%:!gblk%=w_localt%:tooly%=gb%!8-gb%!16+192:toolyy%=192:toolx%=64:toolxx%=64
  1060.  m_remote%:!gblk%=w_remotet%:tooly%=104:toolyy%=64:toolx%=0:toolxx%=192
  1061. gblk%!28=Wb%!28
  1062.  (flg% 
  1063.  2097152)=0 
  1064.  (flg% 
  1065.  131072)<>0 
  1066.  Wb%!28<>-1 
  1067.  Wb%!28=!gblk%
  1068.  (flg% 
  1069.  2097152)<>0 
  1070.  Wb%!28<>-1 Wb%!28=!gblk%
  1071.  Wow%,,Wb%:gblk%!28=Wb%!28
  1072. bgblk%!8=Wb%!8-tooly%:
  1073. gblk%!8<0 
  1074.  Wb%!8>0 
  1075.  gblk%!8=0 
  1076.  Wb%!8<=0 
  1077.  gblk%!8<0 
  1078.  gblk%!8=Wb%!8
  1079. gblk%!16=gblk%!8+toolyy%
  1080. _gblk%!4=Wb%!4-toolx%:
  1081. gblk%!4<0 
  1082. Wb%!4>0 
  1083.  gblk%!4=0 
  1084. Wb%!4<=0 
  1085.  gblk%!4<0 
  1086.  gblk%!4=Wb%!4
  1087. gblk%!12=gblk%!4+toolxx%-2
  1088. gblk%!20=0:gblk%!24=0
  1089.  !gblk%<>h% 
  1090.  Wow%,,gblk%
  1091.  (flg% 
  1092.  2097152)=0 
  1093.  Wow%,,Wb%
  1094. initsptrans
  1095. &400C7,1,Wb% 
  1096. redraw(0)
  1097. 2:h%=!Wb%
  1098. h%=m_local% 
  1099.  h%=m_remote% 
  1100. rpanes 
  1101. Wow%,,Wb%
  1102. h%=m_local% 
  1103.  aremote%>=0 
  1104. gwi(m_local%):y1a%=y1%-yscrol%:yscrola%=yscrol%:xscrola%=xscrol%
  1105. xposU%=winx%:yposU%=y1a%
  1106. xposL%=xposU%:yposL%=yposU%
  1107. xposL%<x0% 
  1108.  xposL%=x0%
  1109. yposL%<y0% 
  1110.  yposL%=y0%
  1111. xposL%>x1% 
  1112.  xposL%=x1%
  1113. yposL%>y1% 
  1114.  yposL%=y1%
  1115. sfac%=65536:
  1116.  100% scale
  1117. Dms2%=m_local%:ms3%=w_localt%:tskh%=remotetask%:
  1118. pca(Msg_ObjPos%)
  1119. Cw(!Wb%)
  1120. click
  1121. key_pressed
  1122. select_menu
  1123. 17,18:
  1124. recieve_msg
  1125. Ow(h%,x%,y%,bhnd%)
  1126.  h%=m_remote% 
  1127.  maino%=-1
  1128. !Wb%=h%:
  1129.  x%=-1 
  1130.  y%=-1 
  1131. Wgwst%,,Wb%:Wb%!28=bhnd%:
  1132.  Wow%,,Wb%
  1133.  h%=m_local% 
  1134.  h%=m_remote% 
  1135. rpanes
  1136. Wgwst%,,Wb%:xsize%=Wb%!12-Wb%!4:ysize%=Wb%!16-Wb%!8
  1137. E!Wb%=h%:Wb%!4=x%:Wb%!12=Wb%!4+xsize%:Wb%!8=y%:Wb%!16=Wb%!8+ysize%
  1138.  Wb%!8=y%:Wb%!16=Wb%!8+ysize%:Wb%!28=bhnd%:SYS"Wimp_OpenWindow",,Wb%
  1139. "Wimp_OpenWindow",,Wb%
  1140.  h%=m_local% 
  1141.  h%=m_remote% 
  1142. rpanes
  1143. &35,-1,4 
  1144.  ,,xpix%:
  1145. &35,-1,5 
  1146.  ,,ypix%
  1147. &35,-1,11 
  1148.  ,,sw%:
  1149. &35,-1,12 
  1150.  ,,sh%
  1151. Expix%=1<<xpix%:ypix%=1<<ypix%:sw%=xpix%*(sw%+1):sh%=ypix%*(sh%+1)
  1152. xpixf=xpix%/2:ypixf=ypix%/2
  1153. repmsg(str1$)
  1154. "POINTER 1":
  1155. &35,-1,3 
  1156.  ,,nocol%
  1157. wi(w_report%,1,str1$):$msgtit%="Spaint":
  1158.  Wgpi%,,GB%:
  1159. Ow(w_report%,!GB%-356,GB%!4-42,-1)
  1160. reperr(str1$):mnhnd%=0
  1161.  1,"In Error code:"+
  1162. $+" "+
  1163. "POINTER 1":
  1164. "OS_ReadModeVariable",
  1165.  ,,nocol%
  1166. !gb%=1:$(gb%+4)=str1$
  1167.  "Wimp_ReportError",gb%,2,"Spaint"
  1168. key_pressed:win%=!Wb%:key%=Wb%!24:icn%=Wb%!4:mine%=
  1169. win%=lcpw% mine%=
  1170. win%=gensave% 
  1171.  key%=13 
  1172. oksave(
  1173. ri(gensave%,2)):mine%=
  1174.  mine% 
  1175. "Wimp_ProcessKey",key%
  1176. read_andload(s$,ft%,win%,Icn%):EX%=0
  1177.  win% 
  1178.  -2,m_local%
  1179. ft%=&FF9 
  1180. loadsprite(s$)
  1181. xwp%=0
  1182. checkpath(nme$)
  1183. nme$,":")=0 
  1184. nme$,"<")=0 
  1185. nme$,".")=0 
  1186.  nme$<>"<Wimp$Scrap>" 
  1187. onoff(win%,Icn%,state%):
  1188. state% 
  1189. ui(win%,Icn%,0) 
  1190. ui(win%,Icn%,2097152)
  1191. a(A%,B%):
  1192. NiceA%,A%,B%:
  1193. da(A%,B%):
  1194. NiceDa%,A%,B%:
  1195. aG(A%,B%,C%):
  1196. NiceAg%,A%,B%,C%:
  1197. daG(A%,B%,C%):
  1198. NiceDag%,A%,B%,C%
  1199. WcGp%,,gblk%:
  1200. !gblk%=A% 
  1201.  gblk%!4>=B% 
  1202.  gblk%!4<=C% 
  1203. WcSp%,-1
  1204. warning(win%,icn%)
  1205. -E!Wb%=win%:Wb%!4=icn%:Wb%!8=11<<24:Wb%!12=%1111<<24:
  1206.  Wsist%,,Wb%
  1207. ok(win%,icn%)
  1208. 1D!Wb%=win%:Wb%!4=icn%:Wb%!8=7<<24:Wb%!12=%1111<<24:
  1209.  Wsist%,,Wb%
  1210. ui(hand%,no%,state%):!gb%=hand%:gb%!4=no%:gb%!8=state%:gb%!12=2097152:
  1211. Wsist%,,gb%:
  1212. uiG(hand%,start%,end%,state%):
  1213. hand%<=0 
  1214. 7V!gb%=hand%:gb%!8=state%:gb%!12=2097152:
  1215. l%=start% 
  1216. end%:gb%!4=l%:
  1217. Wsist%,,gb%:
  1218. wii(win%,icn%,text$):!gb%=win%:gb%!4=icn%:
  1219. Wgist%,,gb%:
  1220. s(gb%!32)<>text$ $(gb%!32)=text$:gb%!8=0:gb%!12=0:
  1221. Wsist%,,gb%
  1222. wi(win%,icn%,text$):!gb%=win%:gb%!4=icn%:
  1223. Wgist%,,gb%:
  1224. gb%!28<&8000 
  1225.  gb%!28>&800000 
  1226.  &524F42,"Icon not indir. or invalid. Handle "+
  1227. s(gb%!28)<>text$ 
  1228. $(gb%!28)=text$:gb%!8=0:gb%!12=0:
  1229. Wsist%,,gb%
  1230. icnok(win%,icn%):
  1231.  icn%=0 
  1232. A8!gb%=win%:gb%!4=icn%:
  1233. Wgist%,,gb%:v%=gb%!(8+16)>>22
  1234.  (v% 
  1235.  %1)=0 
  1236. setsize(whn%,h%,w%)
  1237. Fc!Wb%=whn%:
  1238. Wgwst%,,Wb%:Wb%!4=0:Wb%!8=0:Wb%!16=h%:Wb%!12=w%:
  1239. &600D7,whn%,(Wb%+4):
  1240. Wgwst%,,Wb%
  1241. loadsquashed(nme$,base%,off%)
  1242. reperr(
  1243. $,"(code "+
  1244. +")"):
  1245. resizeslot(0):EX%=
  1246. &406C0
  1247. r_fi(nme$):rlen%=length%:length%-=off%:
  1248. "Squash_Decompress",%1000,-1 
  1249.  work%
  1250. "Wimp_SlotSize",-1,-1 
  1251.  current,,free:free-=32*1024
  1252. free<work%+4096+1024 
  1253. reperr(
  1254. ms("Sorrlc"),""):EX%=
  1255.  length%
  1256. free>work%+length%+outsize% 
  1257.  free=work%+length%+outsize%
  1258. EX%=0:
  1259. resizeslot(free)
  1260.  EX% 
  1261. reperr(
  1262. ms("Sorrlc"),""):EX%=
  1263. T*freec%=free-work%:worka%=current+&8000
  1264. "Wimp_SlotSize",-1,-1 
  1265.  current
  1266.  freec%-length%>1024 
  1267. WYouta%=worka%+work%+length%:outl%=(current+&8000)-outa%:ina%=worka%+work%:inl%=length%
  1268. YPhlf%=freec%/2:outa%=worka%+work%+hlf%:outl%=hlf%:ina%=worka%+work%:inl%=hlf%
  1269. r5%=outl%:otype%=-1
  1270. \-fileoff%=0:offe%=
  1271. :cont%=0:r3%=0:start%=0
  1272.  inl%>=length% 
  1273.  outl%>=outsize% 
  1274. start%=%100
  1275. "Hourglass_Percentage",0
  1276. `,offc%=inl%:
  1277. getbit(nme$,off%,ina%,offc%)
  1278. a5r1%=worka%:r2%=ina%:r3%=offc%:r4%=outa%:r5%=outl%
  1279.  offe% 
  1280.  cont%=0 
  1281. cont%=1
  1282. "Hourglass_Percentage",(fileoff%/outsize%)*100
  1283. "Squash_Decompress",start% 
  1284.  (cont%<<1),r1%,r2%,r3%,r4%,r5% 
  1285.  status%,r1%,r2%,r3%,r4%,r5%
  1286. start%=1
  1287.  status%=2 
  1288. storeaway(outa%,r4%-outa%,fileoff%,base%,outsize%,otype%,0):r4%=outa%:r5%=outl%
  1289. fileoff%>=outsize% 
  1290. status%=0:off%=rlen%:r4%=outa%
  1291.  status%=1 
  1292.  status%=0
  1293. storeaway(outa%,r4%-outa%,fileoff%,base%,outsize%,otype%,0):r4%=outa%:r5%=outl%
  1294. off%+=(offc%-r3%)
  1295.  off%>=rlen% 
  1296.  status%=0
  1297. &406C1
  1298. resizeslot(0)
  1299. getbit(nme$,off%,addr%,
  1300.  offc%):
  1301.  off%+offc%>rlen% 
  1302.  offc%=rlen%-off%:offe%=
  1303. offc%=0 
  1304. qAF%=
  1305. (nme$):
  1306. #F%=off%:
  1307. "OS_GBPB",4,F%,addr%,offc%:
  1308. #F%:F%=0:
  1309. storeaway(unsquashbuffer,unsquashed,
  1310.  fileoff%,base%,outsize%,otype%,filter%):
  1311.  unsquashed<=0 
  1312. sfA%=unsquashbuffer:B%=base%+fileoff%:C%=unsquashed:
  1313.  B%+C%>base%+outsize% 
  1314. C%=(base%+outsize%)-(B%)
  1315.  D%=0 
  1316.  C%>0 
  1317. moveto,A%,B%,C% 
  1318.  C%=0:fileoff%=outsize%
  1319. fileoff%+=C%
  1320. carpos
  1321. gwi(hand%):!gb%=hand%:
  1322.  Wgwst%,,gb%:x0%=gb%!4:y0%=gb%!8:x1%=gb%!12:y1%=gb%!16:vissizX%=x1%-x0%:vissizY%=y1%-y0%:xscrol%=gb%!20:yscrol%=gb%!24:winx%=x0%:wy%=y0%
  1323. }'wflg%=gb%!32:wo%=(wflg% 
  1324.  1<<16)<>0
  1325. wy%+=yscrol%:winx%-=xscrol%
  1326. ri(win%,icn%):!gb%=win%:gb%!4=icn%:
  1327. Wgist%,,gb%:=
  1328. s(gb%!28)
  1329. r_icid(win%,icn%):!gb%=win%:gb%!4=icn%:
  1330. Wgist%,,gb%:=
  1331. s(gb%!32)
  1332. w_icid(win%,icn%,s$):!gb%=win%:gb%!4=icn%:
  1333. Wgist%,,gb%:$(gb%!32)=s$:gb%!8=0:gb%!12=0:
  1334.  Wsist%,,gb%:
  1335. helptext:Wb%!16=&503:Wb%!12=Wb%!8:icn%=Wb%!36:nme$="":htx%=-1:
  1336.  Wb%!32 
  1337. V$(Wb%+20)=nme$:Wb%!0=(((20+
  1338. (nme$)+1)
  1339. 4)*4)+4:$(Wb%+21+
  1340. (nme$))=
  1341. Wmess%,17,Wb%
  1342. sc(r%,g%,b%):
  1343.  CtSgcol%,(b%<<24)+(g%<<16)+(r%<<8),,,256,0:
  1344. scE(r%,g%,b%):
  1345.  CtSgcol%,(b%<<24)+(g%<<16)+(r%<<8),,,256,3:
  1346. isld(x%,y%,w%):
  1347.  w%>0 
  1348.  w%<256 
  1349.  x%+(255-w%),y%,w%,18
  1350. w%<255 
  1351.  w%>=0 
  1352.  XWscol%,0:
  1353.  x%,y%,(255-w%),18
  1354. w%<0 
  1355.  w%>255 
  1356.  XWscol%,2:
  1357.  x%,y%,256,18
  1358. string0(l%,a$):$l%=a$:l%?
  1359. a$=0:
  1360. ar(v%)
  1361. !v%/(v%!8/xpixf)>v%!4/(v%!12/ypixf) 
  1362. !v%=v%!4:v%!8=v%!12*xpixf
  1363.  xpixf<>1 
  1364.  v%!4=!v%*xpixf 
  1365.  v%!4=!v%
  1366. v%!12=v%!8*ypixf
  1367. redrawW(h%,x00%,y00%,x11%,y11%):!Wb%=h%:Wb%!4=x00%*mscd-spritexm%:Wb%!8=y00%*mscd-spriteym%:Wb%!12=Wb%!4+x11%*mscd+spritexm%*2:Wb%!16=Wb%!8+y11%*mscd+spriteym%*2
  1368. redraw(-1)
  1369. rword(v%)
  1370. $v2%=v% 
  1371.  v2%*4<>v% v%=v2%*4+4
  1372. rword2(v%)
  1373. "v2%=v% 
  1374.  v2%*4<>v% v%=v2%*4
  1375. blobs(x0%,y0%,x1%,y1%,x2%,y2%,x3%,y3%):
  1376.  wx%+x0%,wy%+y0%,6:
  1377.  wx%+x3%,wy%+y3%,6:
  1378.  wx%+x1%,wy%+y1%,6:
  1379.  wx%+x2%,wy%+y2%,6:
  1380. blob(x%,y%):
  1381.  x%,y%,6:
  1382. blob2(x%,y%):
  1383.  x%-4,y%-4,16,16:
  1384. redrawit(hand%):!GB%=hand%:
  1385. "Wimp_GetWindowOutline",,GB%:
  1386.  WfrcR%,-1,GB%!4,GB%!8,GB%!12,GB%!16:
  1387. rdi(hand%,icn%):
  1388. hand%<=0 
  1389.  !gb%=hand%:gb%!4=icn%:
  1390. Wgist%,,gb%:
  1391. WfrcR%,hand%,gb%!8,gb%!12,gb%!16,gb%!20:
  1392.  go%:
  1393. "Wimp_GetRectangle",,GB% 
  1394.  go%:
  1395. getwininfo(hand%):!Wb%=hand%:
  1396. Wgwst%,,Wb%:xbase%=Wb%!4:ybase%=Wb%!8:width%=Wb%!12:height%=Wb%!16:
  1397. GetLeafname(name%):
  1398.  ch$,n%,name$:name$=
  1399. s(name%):
  1400. name$,".")=0) 
  1401. name$,":")=0)) 
  1402.  =name$
  1403. (name$):
  1404. :ch$=
  1405. name$,n%,1):n%-=1:
  1406. (n%<=0 
  1407.  ch$="." 
  1408.  ch$=":")
  1409.  n%>0 
  1410. name$,
  1411. (name$)-n%-1)
  1412. s(s%):
  1413. ?s%<32 =""
  1414. .n$="":
  1415.  ?s%>31 
  1416. n$<255:n$+=
  1417. ?s%:s%+=1:
  1418. resizeslot(cc%)
  1419. Wslt%,-1,-1 
  1420.  ,,free%
  1421.  free%+(slsiz%-basesiz%)<cc% 
  1422.  EX%=
  1423. reperr(
  1424. ms_exp("mem1",
  1425. (((slsiz%-basesiz%+cc%)-free%)/1024),"")):
  1426. Wslt%,(basesiz%+cc%),-1:
  1427. Wslt%,-1,-1 
  1428.  slsiz%
  1429. slsiz%<basesiz%+cc% 
  1430.  EX%=
  1431.  Wslt%,basesiz%,-1:slsiz%=basesiz%:
  1432. reperr(
  1433. ms_exp("mem1",
  1434. ((basesiz%+cc%-slsiz%)/1024),""))
  1435. claims%=slsiz%-basesiz%
  1436. check_adj
  1437. "Wimp_GetPointerInfo",,GB%+300
  1438.  (%111 
  1439.  GB%!308=1) 
  1440.  (%111 
  1441.  GB%!308=2) 
  1442. quitreq(E$,box%):
  1443.  RES%:!GB%=0:$(GB%+4)=
  1444. E$,100)+
  1445.  box%=255 
  1446. "Wimp_ReportError",GB%,19,"SPaint" 
  1447.  ,resp% 
  1448. "Wimp_ReportError",GB%,box%,"SPaint" 
  1449.  ,resp%
  1450. =resp%=1
  1451. decode(hand%,Wb%,gb%):
  1452. "Wimp_DecodeMenu",,hand%,Wb%,gb%:=$gb%
  1453. grey(h%,i%):
  1454. h%>0 !gb%=h%:gb%!4=i%:gb%!8=&2000000:gb%!12=&F000000:
  1455. Wsist%,,gb%
  1456. notselect(h%,i%):
  1457. h%<=0 
  1458. =!gb%=h%:gb%!4=i%:gb%!8=&A000:gb%!12=&F000:
  1459. Wsist%,,gb%:
  1460. black(h%,i%):
  1461. h%>0 !gb%=h%:gb%!4=i%:gb%!8=&7000000:gb%!12=&F000000:
  1462. Wsist%,,gb%
  1463. encodemenu(mnhnd%)
  1464. mnhnd%<&8000 
  1465.  1,"Bad menuhandle"
  1466.  PROCclm(m_remote%)
  1467. tk(hand%,icn%):
  1468. icn%<0 
  1469. 4hand%!(28+(24*icn%))=hand%!(28+(24*icn%))
  1470.  &01:
  1471. clm(hand%):
  1472. hand%<&8000 
  1473.  1,"menu handle &"+
  1474. ~hand%+" called for clearing is invalid."
  1475. [hand%+=28:
  1476. :!hand%=!hand% 
  1477. 1:hand%!8=hand%!8 
  1478. &400000:hand%+=24:
  1479. !(hand%-24) 
  1480.  2<<6:
  1481. shade(mh%,I%):mh%!(28+8+24*I%)=mh%!(28+8+24*I%)
  1482. &40000:
  1483. tick(mh%,I%):
  1484. I%<0 I%=0
  1485. ,mh%!(28+(24*I%))=mh%!(28+(24*I%))
  1486.  &01:
  1487. select(h%,i%):
  1488.  h%>0 !gb%=h%:gb%!4=i%:gb%!8=&7000000:gb%!12=&F000000:
  1489. Wsist%,,gb%:
  1490. deselect(h%,i%):
  1491. h%>0 !gb%=h%:gb%!4=i%:gb%!8=&4000000:gb%!12=&F000000:
  1492. Wsist%,,gb%
  1493. msgrep(str1$):$errb%=str1$
  1494. !gb%=0:$(gb%+4)=str1$
  1495. "Wimp_ReportError",gb%,17,"SPaint Message" 
  1496.  ,resp%
  1497. initall:
  1498.  BL% 16,nameblk% 255:adjusting%=
  1499. :mainW_active%=
  1500. init_Wimp:mnhnd%=0:
  1501. initSys:
  1502. sprites:
  1503. load_templates:
  1504. createmenus:scrapref%=-1:
  1505. triplezero(v):
  1506.  @%:@%=(1<<24)+(2<<16)+(3<<8)+12:=
  1507. doublezero(v):
  1508.  @%:@%=(1<<24)+(2<<16)+(2<<8)+12:=
  1509. singlezero(v):
  1510.  @%:@%=(1<<24)+(2<<16)+(1<<8)+12:=
  1511. azero(v):
  1512.  @%:@%=(1<<24)+(2<<16)+(1<<8)+12:v$=
  1513. v$,2)=".0" 
  1514. (v$)-2)
  1515. alt(v%):
  1516.  =" *"
  1517. initSys
  1518.  "Wimp_Initialise",200,&4B534154,"Simple Paint" 
  1519.  ,Task_h%
  1520.  SpriteName% 14:$SpriteName%="!spaint"
  1521. !Wb%=-1:Wb%!4=0:Wb%!8=0:Wb%!12=76:Wb%!16=76:Wb%!20=&7000311A:Wb%!24=SpriteName%:Wb%!28=1:Wb%!32=12:
  1522. "Wimp_CreateIcon",,Wb% 
  1523.  icnbh%
  1524. sprites
  1525. r_fi("<SPaint$Dir>.Sprites22")
  1526.  there%<>1 
  1527.  (ft%<>&FCA 
  1528.  ft%<>&FF9) 
  1529.  1,"!Spaint.Sprites missing/corrupt. Please install again."
  1530.  ft%=&FCA 
  1531.  sblock% orlen%+16:!sblock%=orlen%+16 
  1532.  sblock% length%+16:!sblock%=length%+16
  1533. *sblock%!4=0:sblock%!8=16:sblock%!12=16
  1534.  ft%=&FCA 
  1535. Vfl%=orlen%+4:outsize%=orlen%:
  1536. loadsquashed("<SPaint$Dir>.Sprites22",sblock%+4,&14)
  1537.  "XOS_Exit"
  1538.  ft%=&FF9 
  1539. Spop%,522,sblock%,"<SPaint$Dir>.Sprites22" 
  1540. reperr("Spaint Sprites are corrupt or missing. Please reinstall the program.",""):
  1541. "XOS_Exit"
  1542. load_templates:st%=styleindir:ste%=styleindir+&1300
  1543. "Wimp_OpenTemplate",,"<SPaint$Dir>.Templates"
  1544. Wlt%,,wad%(1),st%,ste%,-1,"info",0 
  1545.  ,,stx%:wad%(1)!64=sblock%:st%=stx%:
  1546.  Wcw%,,wad%(1) 
  1547.  w_info%
  1548. #split_hand%=-1:restore_hand%=-1
  1549.  Wlt%,,GB%,st%,ste%,-1,"generalsave",0 
  1550.  ,,stx%:GB%!64=1:st%=stx%:
  1551.  Wcw%,,GB% 
  1552.  gensave%
  1553.  Wlt%,,GB%,st%,ste%,-1,"prefs",0 
  1554.  ,,stx%:GB%!64=1:st%=stx%:
  1555.  Wcw%,,GB% 
  1556.  w_prefs%
  1557.  Wlt%,,GB%,st%,ste%,-1,"remote",0 
  1558.  ,,stx%:maint%=st%:GB%!64=sblock%:st%=stx%:
  1559.  Wcw%,,GB% 
  1560.  m_remote%
  1561.  Wlt%,,GB%,st%,ste%,-1,"local",0 
  1562.  ,,stx%:localt%=st%:GB%!64=sblock%:st%=stx%:
  1563.  Wcw%,,GB% 
  1564.  m_local%
  1565. Wlt%,,GB%,st%,ste%,-1,"report",0 
  1566.  ,,stx%:GB%!64=1:msgtit%=st%:st%=stx%:
  1567. Wcw%,,GB% 
  1568.  w_report%
  1569. Wlt%,,GB%,st%,ste%,-1,"localtool",0 
  1570.  ,,stx%:GB%!64=sblock%:st%=stx%:
  1571. Wcw%,,GB% 
  1572.  w_localt%
  1573. Wlt%,,GB%,st%,ste%,-1,"remotetool",0 
  1574.  ,,stx%:GB%!64=sblock%:st%=stx%:
  1575. Wcw%,,GB% 
  1576.  w_remotet%
  1577.  !!!PCA!!!
  1578.  keep the window create block for the PCA dialogue as we
  1579.  need to delete and recreate in order to add the scrollbar.
  1580.  pca_wblock% 256,pca_windir% 100
  1581. Wlt%,,pca_wblock%,pca_windir%,pca_windir%+100,-1,"ole2",0:GB%!64=sblock%:
  1582. Wcw%,,pca_wblock% 
  1583.  pca_w%
  1584. "Wimp_CloseTemplate",,"<SPaint$Dir>.Templates"
  1585.  end% 
  1586. 4,30:
  1587. 6,4,0:
  1588.  6,229,0:
  1589.  st%>=ste% 
  1590.  1,"indirection overlap when loading windows.":
  1591. PROCdefaultstrings
  1592. oo(win%,Icn%,state%):
  1593.  state% 
  1594. ui(win%,Icn%,0) 
  1595. ui(win%,Icn%,1<<21)
  1596. allow(win%,icn%)
  1597. L!gb%=win%:gb%!4=icn%:gb%!8=0<<22:gb%!12=1<<22:
  1598. "Wimp_SetIconState",,gb%
  1599. disallow(win%,icn%)
  1600. !L!gb%=win%:gb%!4=icn%:gb%!8=1<<22:gb%!12=1<<22:
  1601. "Wimp_SetIconState",,gb%
  1602. createmenus
  1603.  menufree% &800:menuend%=menufree%+&800
  1604.  buffer% &400:maxbuff%=buffer%+&400:currbuff%=buffer%
  1605. ("<SPaint$Dir>.menus")
  1606. F%=0 
  1607. ms("nomenus"):
  1608. "OS_Exit"
  1609. submsg%=
  1610. :wid%()=4
  1611. wbptr%=1
  1612. submsg%=
  1613. m_file%=
  1614. cmen(
  1615. ,#m_ibar%=
  1616. cmen(
  1617. #F%):numfonts%=0
  1618. mm_remote%=
  1619. cmen(
  1620. menu(m%,moux%,mouy%)
  1621. mnhnd%=m%
  1622. encodemenu(mnhnd%):
  1623. "Wimp_CreateMenu",,mnhnd%,moux%+100,mouy%+12
  1624.  moux%<>0 
  1625.  mouy%<>0 
  1626.  mousex%=moux%:mousey%=mouy%
  1627. cmen(menu$)
  1628. menufree%>menuend%-28 =-1
  1629. m%,m$
  1630. 9"menuptr%=menufree%:i%=0:ctr%=0
  1631. menu$,1)="#" 
  1632.  i%=1:menutitle$=
  1633. par("\",i%) 
  1634.  menutitle$=""
  1635. menuptr%!20=40:$menuptr%=menutitle$:menuptr%?12=7:menuptr%?13=2:menuptr%?14=7:menuptr%?15=0:menuptr%!16=172:menuptr%!24=0:menuptr%+=28:maxx%=
  1636. menutitle$-3
  1637. :item$=
  1638. par("\",i%):
  1639. menuitem(item$):
  1640.  item$="" 
  1641.  menuptr%>=menuend%-24
  1642. =%!(menuptr%-24)=!(menuptr%-24)
  1643. >"m%=menufree%:m%!16=maxx%*16+12
  1644. menufree%=menuptr%
  1645. menuitem(nme$)
  1646. nme$="" 
  1647. menuptr%+24>menuend% 
  1648.  flg%,i%:
  1649. submsg% flg%=8 
  1650.  flg%=0
  1651. nme$,">")
  1652. i%>0 
  1653. GCsubptr%=
  1654. nme$,i%+1):
  1655. nme$,i%+1)="i_font%" fontsub%=menuptr%+4
  1656. nme$=
  1657. nme$,i%-1)
  1658.  subptr%=-1
  1659. nme$,1)="#" nme$=
  1660. nme$,
  1661. nme$-1):flg%+=&02
  1662. L;menuptr%!0=flg%:menuptr%!4=subptr%:menuptr%!8=&07000021
  1663. nme$,1)="$" 
  1664. N1!menuptr%+=&04:menuptr%!8+=&100:i%=
  1665. nme$,"(")
  1666. i%>0 
  1667. nme$,i%+1):nme$=
  1668. nme$,i%-1)
  1669.  L%=12
  1670. P7menuptr%!12=
  1671. nme$,2):menuptr%!16=-1:menuptr%!20=L%
  1672. L%>15 
  1673.  L%=15
  1674. nme$=
  1675. L%-1," ")
  1676. nme$<=12 
  1677. $(menuptr%+12)=nme$
  1678. workspace(
  1679. nme$+1):$I%=nme$
  1680. WRmenuptr%!12=I%:menuptr%!16=-1:menuptr%!20=
  1681. nme$+1:menuptr%!8=menuptr%!8 
  1682.  &100
  1683. nme$>maxx% maxx%=
  1684. menuptr%+=24
  1685. par(sep$,
  1686.  pos%):i1%=pos%+1:pos%=
  1687. menu$+sep$,sep$,i1%):=
  1688. menu$,i1%,pos%-i1%)
  1689. workspace(L%)
  1690.  currbuff%+L%>maxbuff% 
  1691.  1,"No room to store menu definitions -  too many fonts ?"
  1692. currbuff%+=L%:=currbuff%-L%
  1693. setupstores:offset%=0:
  1694. lopx%=1 
  1695.  required%:wad%(lopx%)=generalstore%+offset%:offset%+=required%:
  1696. offset%>&800 
  1697.  1,"No room for window storage."
  1698.  &500,&100
  1699. str(num):
  1700. "XOS_Release",3,wrchv%,possaddr%:
  1701. reperr(
  1702. $+" code number "+
  1703. ):="0"
  1704. h3!possaddr%=gb%:
  1705. 131103,3,wrchv%,possaddr%:
  1706. 131104,3,wrchv%,possaddr%
  1707. j+s$=$gb%:
  1708. s$,1)=
  1709. 32:s$=
  1710. (s$)-1):
  1711. s$,1)<
  1712. 32:s$=
  1713. assemble_blit
  1714.  space% &1A00
  1715. p+ccr%=0:ccg%=1:ccb%=2:ro%=8:go%=9:bo%=10
  1716. r%=11:g%=12:b%=14
  1717. rd%=4:gd%=5:bd%=7
  1718. opt=0 
  1719. P%=space%
  1720. [OPT opt
  1721. .moveto
  1722. \r0=src%
  1723. \r1=des%
  1724. \r2=len%
  1725. { \r3=0 for words, 1 for bytes
  1726. CMP R2,#0:MOVLE PC,R14
  1727. CMP R0,R1:
  1728. Q PC,R14
  1729. CMP R3,#0:BNE movebytes
  1730. .movewords
  1731. CMP R0,R1:BLE else
  1732. \ src%>des%
  1733. MOV R3,#0:SUB R6,R2,#4
  1734. .for1m
  1735. !LDR R5,[R0,R3]:STR R5,[R1,R3]
  1736. $ADD R3,R3,#4:CMP R3,R6:BLE for1m
  1737. MOV PC,R14
  1738.     .else
  1739. SUB R3,R2,#4
  1740. .for2m
  1741. !LDR R5,[R0,R3]:STR R5,[R1,R3]
  1742. SUBS R3,R3,#4
  1743. BGE for2m
  1744. MOV PC,R14
  1745. .movebytes
  1746. .truemoveb
  1747. CMP R0,R1:BLE elseb
  1748. \ src%>des%
  1749. MOV R3,#0
  1750. .for1mb
  1751. 0LDRB R5,[R0,R3]:STRB R5,[R1,R3]:ADD R3,R3,#1
  1752. CMP R3,R2:BLT for1mb
  1753. MOV PC,R14
  1754. .elseb
  1755. SUB R3,R2,#1
  1756. .for2mb
  1757. #LDRB R5,[R0,R3]:STRB R5,[R1,R3]
  1758. SUBS R3,R3,#1
  1759. BGE for2mb
  1760. MOV PC,R14
  1761. .copydata%
  1762. ; r0 =source ptr
  1763. ; r1 =dest ptr
  1764. ; r2 =length
  1765. Z.copywordsl:TST R2,#31:LDRNE R3,[R0],#4:STRNE R3,[R1],#4:SUBNE R2,R2,#4:BNE copywordsl
  1766. TEQ R2,#0
  1767. NLDMNEIA R0!,{r5-r12}:STMNEIA R1!,{r5-r12}:SUBNES R2,R2,#8*4:BNE copywordsl
  1768. MOV PC,R14
  1769. 4.copyj:MOV R0,R2:MOV R1,R3:MOV R2,R4:B copydata%
  1770. .NiceAg%
  1771. !MOV R4,#0:MOV R7,#1:B groupdo
  1772. .NiceDag%
  1773. %MOV R4,#1<<22:MOV R7,#0:B groupdo
  1774. .groupdo
  1775. ; r0 = window handle
  1776. ; r1 = min_ic
  1777. ; r2 = max_ic
  1778. 3MOV R8,R0:MOV R9,R1:MOV R10,R2:STMFD R13!,{R14}
  1779. MOV R5,#1<<22
  1780. STR R8,window
  1781.     .loop
  1782. STR R9,icon
  1783. ADR R1,block
  1784. SWI "XWimp_GetIconState"
  1785. MLDR R12,flags:MOV R12,R12,LSR#22:
  1786.  R12,R12,#1:CMP R12,R7:; is it shaded ?
  1787. BNE ok
  1788. ; change it
  1789. #STR R4,eorword:STR R5,clearword
  1790. ADR R1,block
  1791. SWI "XWimp_SetIconState"
  1792. $ADD R9,R9,#1:CMP R9,R10:BLE loop
  1793. LDMFD R13!,{PC}
  1794. .block
  1795. .window EQUD 0
  1796. .icon   EQUD 0
  1797. .eorword   EQUD 0
  1798. .clearword EQUD 0
  1799. .data2 EQUD 0
  1800. EQUD 0
  1801. !; bit 22 of flags =shaded bit
  1802. "; bits 12-15      =button type
  1803. .flags EQUD 0
  1804. .data0 EQUD 0
  1805. .data1 EQUD 0
  1806. .data2 EQUD 0
  1807. .data3 EQUD 0
  1808. .NiceDa%
  1809. ; r0 =window
  1810. ; r1 =icon
  1811. MOV R2,R1:B NiceDag%
  1812. .NiceA%
  1813. ; r0 = window
  1814. ; r1 = icon
  1815. MOV R2,R1:B NiceAg%
  1816. ; !!!PCA!!!
  1817. C; used by the dialogue redraw code to simulate 'r1' style icons
  1818.     .bdr%
  1819. &; simulate Acorn style 'r1' border
  1820. .MOV R9,R0:MOV R10,R1:MOV R11,R2:MOV R12,R3
  1821. MOV R0,#0
  1822. SWI &600E6
  1823. ; lh side
  1824. GMOV R0,#4:SUB R1,R9,#2:SUB R2,R10,#2:SWI "OS_Plot":; move x0-2,y0-2
  1825. 5MOV R0,#5:MOV R2,R12:SWI "OS_Plot":; draw x0-2,y1
  1826. 7MOV R0,#4:SUB R1,R1,#2:SWI "OS_Plot":; move x0-4,y1
  1827. :MOV R0,#5:SUB R2,R10,#4:SWI "OS_Plot":; draw x0-4,y0-4
  1828.     ; top
  1829. )MOV R0,#4:ADD R2,R12,#4:SWI "OS_Plot"
  1830. DMOV R0,#5:ADD R1,R11,#2:SWI "OS_Plot":; draw x0-4,y1+4,x1+2,y1+4
  1831. DMOV R0,#4:SUB R1,R1,#2:SUB R2,R2,#2:SWI "OS_Plot":; move x1,y1+2
  1832. @MOV R0,#5:SUB R1,R9,#4:SWI "OS_Plot"; draw x0-4,y1+2,x1,y1+2
  1833. MOV R0,#4
  1834. SWI &600E6
  1835. ;bottom
  1836. GMOV R0,#4:SUB R1,R9,#2:SUB R2,R10,#4:SWI "OS_Plot":; move x0-2,y0-4
  1837. :MOV R0,#5:ADD R1,R11,#4:SWI "OS_Plot":; draw x1+2,y0-4
  1838. EMOV R0,#4:SUB R1,R1,#0:SUB R2,R10,#2:SWI "OS_Plot":; move x1,y0-2
  1839. 3MOV R0,#5:MOV R1,R9:SWI"OS_Plot":; draw x0,y0-2
  1840. ;right
  1841. 4MOV R0,#4:ADD R1,R11,#2:MOV R2,R10:SWI "OS_Plot"
  1842. )MOV R0,#5:ADD R2,R12,#2:SWI "OS_Plot"
  1843. 4MOV R0,#4:ADD R1,R11,#4:MOV R2,R10:SWI "OS_Plot"
  1844. )MOV R0,#5:ADD R2,R12,#4:SWI "OS_Plot"
  1845. MOV PC,R14
  1846.  Dynamic area version...
  1847. createarea(size%,s$,
  1848.  aa%,maxm%)
  1849. 4,30:
  1850. $:mm$=
  1851. ms("vmfail"):EX%=
  1852. :areasize%=0:aa%=0:=-1
  1853. areasize%=0
  1854.  "XOS_DynamicArea",0,-1,size%,-1,%10000000+(1<<31 
  1855.  virtual%),maxm%,0,0,s$ 
  1856.  r0,aa%,,areabase%;F%
  1857. 1)<>0 
  1858. killara(aa%):mm$="Couldn't create "+s$+" area. Probably not enough free memory or disc space.":aa%=0:size%=0:EX%=
  1859.  "OS_ReadDynamicArea",aa% 
  1860.  ,areasize%
  1861.  areasize%<size% 
  1862. killara(aa%):
  1863.  42,"Couldn't create "+s$+" area. Probably not enough free memory."
  1864. =areabase%
  1865. ourarea(v%):
  1866. v%=0 
  1867.  &524F42,"Dynamic area "+
  1868. v%+" called by SPaint is invalid!"
  1869.  "OS_DynamicArea",2,v% 
  1870.  ,,areasize%,addr%
  1871. =addr%
  1872. areasize(v%):
  1873. v%=0 
  1874.  &524F42,"Dynamic area "+
  1875. v%+" called by SPaint is invalid!"
  1876.  "OS_DynamicArea",2,v% 
  1877.  ,,areasize%,addr%
  1878. =areasize%
  1879. killara(v%)
  1880. v%<>0 
  1881. "XOS_DynamicArea",1,v%
  1882. min(v1,v2):
  1883. v1<v2 
  1884. max(v1,v2):
  1885. v1>v2 
  1886.  DA version, general area create/claim
  1887. doclaimg(size%,
  1888.  number%,msg$,arean$,maxm%):EX%=0
  1889.  size%=0 
  1890. killara(number%):number%=0:
  1891. number%=0 
  1892.  areabase%=
  1893. createarea(size%,arean$,number%,maxm%):csize%=areasize%:
  1894.  number%=0 
  1895.  EX%=
  1896. repmsg(
  1897. ms_exp(msg$,
  1898. rounds(size%/1024),"")):number%=0:
  1899. 7)b%=
  1900. ourarea(number%):csize%=areasize%
  1901.  Wslt%,-1,-1 
  1902.  ,,free%:
  1903.  free%<(size%-csize%) 
  1904. virtual% 
  1905. repmsg(
  1906. ms_exp(msg$,
  1907. rounds((size%-csize%-free%)/1024),"")):EX%=
  1908. ourarea(number%)
  1909. : v%=0:change%=size%-areasize%
  1910.  change%<>0 
  1911.  "XOS_ChangeDynamicArea",number%,change% 
  1912.  r0,v%;F%:
  1913. (change%) 
  1914.  change%>0 
  1915. reperr("DynamicArea memory change failed badly. (Passed "+
  1916. (size%/1024))+"k)",""):EX%=
  1917. ourarea(number%)
  1918. ms_load(A$):
  1919.  "MessageTrans_FileInfo",,A$:
  1920.  "OS_Module",6,,,17+
  1921.  ,,ms_desc%:$(ms_desc%+16)=A$:
  1922.  "MessageTrans_OpenFile",ms_desc%,ms_desc%+16:
  1923. ms_end:
  1924.  "XMessageTrans_CloseFile",ms_desc%:
  1925.  "XOS_Module",7,,ms_desc%:
  1926. ms(nme$):=
  1927. ms_exp(nme$,"","")
  1928. ms_exp(A$,B$,C$):
  1929.  398594,ms_desc%,A$,gb%,256,B$,C$ 
  1930.  ,,,zl%;zf%:
  1931.  ="tag '"+A$+"' not present in messages."
  1932. gb%?zl%=13:=$gb%
  1933. init_variables
  1934. J6wh%=-256:rd%=&FF00:cy%=-65536:gr%=&FF0000:myref%=0
  1935. CtHSVtRGB%=&40759:CtRGBtHSV%=&40758:Wscol%=&400E6:CtSgcol%=&40743:CtSOgcol%=&40748:Wrdw%=&400C8:Wgr%=&400CA:XWgr%=&600CA:Wgpi%=&400CF
  1936. Spop%=&2E:XSpop%=&2002E:CtSfc%=&4074F:CtInval%=&40750:CtStb%=&40740:Wlt%=&600DB:Wcw%=&400C1:Wslt%=&600EC:Wgist%=&400CE:Wsist%=&400CD:Wgwst%=&400CB:Ptx%=&40086:XPtx%=&60086:WfrcR%=&400D1:XWfrcR%=&600D1:Wupdw%=&400C9:XCtGet%=&40763
  1937. WcSp%=&400D2:Ffnt%=&40081:Fctp%=&40089:Fctos%=&40088:Lfnt%=&40082:Strw%=&40085:WgR%=&600CA:Fsfnt%=&4008A:Wmess%=&400E7:Fcar%=&40087
  1938. Bbox%=&40097:XWscol%=&600E6:XWgrec%=&600CA:GSTrns%=&20027:WcGp%=&400D3:WcSp%=&400D2:Wcm%=&400D4:Wow%=&400C5:WclW%=&600C6:Wsist%=&400CD:Drwf%=&40702:Drwstr%=&40704:XDwS%=&60704
  1939. maino%=0:overmain%=0
  1940. Spop%=&2E:CtSfc%=&4074F:CtInval%=&40750:CtStb%=&40740:Wlt%=&600DB:Wcw%=&400C1:Wslt%=&600EC:Wgist%=&400CE:Wsist%=&400CD:Wgwst%=&400CB:Ptx%=&40086:WfrcR%=&400D1:XSndC%=&60140
  1941. QmFfnt%=&40081:Fctp%=&40089:Fctos%=&40088:Lfnt%=&40082:Strw%=&40085:WgR%=&600CA:Fsfnt%=&4008A:Wmess%=&400E7
  1942. XOags%=&20009
  1943. S:Bbox%=&40097:XWscol%=&600E6:XWgrec%=&600CA:Wcm%=&600D4
  1944.  !!!PCA!!!
  1945.  PCA message numbers
  1946. XUMsg_Whos%=&83484:Msg_Im%=&83485:Msg_Do%=&83486:Msg_Desel%=&83487:Msg_Done%=&83488
  1947. Msg_Moving%=&83489:Msg_Changed%=&8348A:Msg_Resize%=&8348B:Msg_Uparea%=&8348C:Msg_ResizeAck%=&8348D:Msg_Misc%=&8348E:Msg_Info%=&8348F
  1948. Z+Sub_Give%=&83480:Sub_Associated%=&83481
  1949. \:Msg_ObjPos%=&83490:Msg_Hook%=&83491:Msg_Unhook%=&83492
  1950.  PCA popup dialogue/menu
  1951. _kutil$="#Utilities":pcatask%=0:
  1952.  utiltsk%(24),utilid%(24),uf%(24),utils$(24):utile%=0:uboxw%=0:uboxh%=96
  1953. `3popuptype%=0:m_pca%=0:
  1954.  0 - dialogue   1 - menu
  1955.  pointers to remote objects
  1956. remotetag%=-1:wn$=""
  1957. e;pcol%=&FFFFFF00:size%=64:size2%=64/2+4:ppick%=0:lcpw%=0
  1958.  strans% 32,stransW% 32,sgblk% 256,sgblkB% 256*4,savea% 1024,c0% 1024,Mgb% 256,ascale0p% 32,sgblkg% 256*4
  1959. ms_load("<SPaint$Dir>.messages")
  1960. "Wimp_SlotSize",-1,-1 
  1961.  slsiz%:basesiz%=slsiz%
  1962. kFty01%=104:ty02%=64:tx01%=0:tx02%=258:viewR%=-1:viewG%=-1:viewB%=-1
  1963.  buff% &400,buffo% &400,buffb% &400,gb% &400,gbw% &200,gblk% &400,GWb% &400,gb2% &100
  1964. m!page%=64*1024:g%=0:handle1%=0
  1965. n virtual%=0:m64%=64*1024*1024
  1966. mscd=1
  1967. "XOS_SWINumberFromString",,"DragASprite_Start" 
  1968.  ds%;F
  1969.  ds%=-1
  1970. "XOS_SWINumberFromString",,"DragASprite_Stop" 
  1971.  de%;F
  1972.  de%=-1
  1973. 6,161,28 
  1974. ,,f%:
  1975.  (f% 
  1976. 2)=0 
  1977. ds%=-1:de%=-1
  1978.  !!!PCA!!! local dynamic area and sprite details
  1979. xFlocal%=0:local2%=0:localtag%=-1:spria%=0:spril%=0:local$="Nothing"
  1980.  !!!PCA!!! inplace editing (remote) flags and storage...
  1981. {$inplace%=-1:localtask%=0:uflg%=0
  1982.  !!!PCA!!! inplace editing (local) flags and storage...
  1983. aremote%=-1:remotetask%=0
  1984.  remoteicblk% 32*10:ricptr%=remoteicblk%:Rbdr%=0
  1985.  buffers for simple menu - can be scratch space
  1986.  cbstr% &120,cbbuff% &120
  1987. end%=
  1988. savingfile%=0:DRAGGING%=0
  1989.  wad%(32),Wbtsk% &300,wid%(32),GB% &2400,styleindir &1300,generalstore% &500:wid%()=0:lastopen%=-1:gb%=GB%+&1700:gblk%=GB%+&1A00:Wb%=GB%:
  1990. setupstores
  1991.     EX%=
  1992. F%=0:outform%=0
  1993.