home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 4 / DATAFILE_PDCD4.iso / utilities / utilsd / examine / !Examine / Examine (.txt) < prev    next >
Encoding:
RISC OS BBC BASIC V Source  |  1993-04-22  |  33.7 KB  |  1,369 lines

  1.  > Examine
  2.  This is a multitasking magnifier
  3.  Copyright Erik de Kort 1993 (Read the !Help file for conditions)
  4.  Main
  5. 1  : 
  6.  Make sure the WimpSlot is not too small
  7. _Initialise
  8.  + &2000
  9. _ReInitialise
  10. B  : 
  11.  More initialisation, but done here to make you notice it
  12.  "OS_ReadMonotonicTime" 
  13.  NextTime% : TimeStep% = 4
  14.   Mask% = 
  15. (&603FF)
  16. ?    
  17.  "Wimp_PollIdle",Mask%,PollBlock%,NextTime% 
  18.  reason%
  19. )    
  20.  PointerInWindow% 
  21. _SetPointer
  22.  reason% 
  23. ,      
  24.      0 : 
  25. _NullReason(PollBlock%)
  26. .      
  27.      1 : 
  28. _RedrawWindow(PollBlock%)
  29. ,      
  30.      2 : 
  31. _OpenWindow(PollBlock%)
  32. .      
  33.      3 : 
  34. _CloseWindow(!PollBlock%)
  35. /      
  36.      4 : 
  37. _PointerLeave(!PollBlock%)
  38. /      
  39.      5 : 
  40. _PointerEnter(!PollBlock%)
  41. d      
  42.      6 : 
  43. _MouseClick(PollBlock%!0,PollBlock%!4,PollBlock%!8,PollBlock%!12,PollBlock%!16)
  44. !      
  45.      7 : 
  46. _UserDragBox
  47. /      
  48.      8 : 
  49. _KeyPressed(PollBlock%!24)
  50.  /      
  51.      9 : 
  52. _MenuSelection(PollBlock%)
  53. !-      
  54.  17,18 : 
  55. _UserMessage(PollBlock%)
  56. "        
  57. #F    
  58.  "OS_ReadMonotonicTime" 
  59.  NextTime% : NextTime% += TimeStep%
  60.  The program should *NEVER* get here!
  61. _CloseDown:
  62.  ++++++++++ Wimp_Poll routines ++++++++++
  63. _NullReason(block%)
  64.  DisplayOpen% 
  65. /     
  66.  (drag%) 
  67. _DragWindow
  68. 0%    
  69. _UpdateWindow(UpdateWindow%)
  70.  This procedure is called as NullReason
  71.  But it is also called from RedrawWindow for the display
  72. _UpdateWindow(SWI%)
  73.  MinX%,MaxY%
  74.  PWhandle%,Ihandle%
  75.  CWhandle%,Xoff%,Yoff%,Cflags%
  76.  more%
  77.  "WASP_PointerInfo" 
  78.  PWhandle%,Ihandle%,Mx%,My%,buttons%
  79.  "WASP_CaretInfo"   
  80.  CWhandle%,,Xoff%,Yoff%,Cflags%
  81.   FocusX% = Mx%
  82.   FocusY% = My%
  83. C)  : 
  84.  Check if: - we follow caret AND
  85. D0  : 
  86.            - the caret is displayed AND
  87. E/  : 
  88.            - the caret is in a window 
  89.  FollowCaret% 
  90.  (Cflags%<>-1) 
  91.  (CWhandle%<>-1) 
  92. G6    
  93.  "WASP_WindowInfo",CWhandle% 
  94.  MinX%,,,MaxY%
  95. HD    : 
  96.  Is the pointer is inside the window with the caret ? AND
  97. IA    : 
  98.  Is the pointer within the display of the window ? AND
  99. J/    : 
  100.  Has the user released all buttons ?
  101. K.    : 
  102.  OR do we follow caret regardless ?
  103. LZ    
  104.  (((CWhandle% = PWhandle%) 
  105.  (-1 <= Ihandle%)) 
  106.  AlwaysCaret%) 
  107.  (buttons% = 0) 
  108. M!      FocusX% = Xoff% + MinX%
  109. N:      FocusY% = Yoff% + MaxY% + ((Cflags% 
  110.  &FFFF)>>1)
  111. O        
  112. _GrabSprite(FocusX%,FocusY%,Mx%,My%)
  113. _GetWindowInfo
  114. U#  Xoff% = Wminx% + ScaledWidth%
  115. V$  Yoff% = Wminy% + ScaledHeight%
  116. WG  : 
  117.  Updating is sort of ugly now, but it works and isn't too slow
  118. X,  : 
  119.  if the magnification is reasonable
  120. Y!  buffer%!00 = DisplayHandle%
  121.   buffer%!04 =  0
  122.   buffer%!08 = -YLimit%
  123.   buffer%!12 =  XLimit%
  124.   buffer%!16 =  0
  125.  SWI%,,buffer% 
  126.  more%
  127.  more%
  128.  16,0
  129. aD    : 
  130.  Clipping is on, so actual width and height not important
  131. b*    
  132.  Wminx%,Yoff%,XLimit%,YLimit%
  133. c*    
  134.  Xoff%,Wminy%,XLimit%,YLimit%
  135. dM    
  136.  "OS_SpriteOp",256+52,SpriteArea%,SpriteName$,Wminx%,Wminy%,,Scale%
  137. e/    
  138.  "Wimp_GetRectangle",,buffer% 
  139.  more%
  140.  Open the display window
  141. _OpenWindow(block%)
  142.  First open the window
  143.  "Wimp_OpenWindow",,block%
  144.  Next open pane on top
  145.  (!block% = DisplayHandle%) 
  146. _ReOpenPane : DisplayOpen% = 
  147.  This one is called whenever the DisplayWindow is opened
  148.  The variable ShowPane% determines if the pane should be opened
  149. _ReOpenPane : 
  150. (ShowPane%) 
  151.  Dx%,Dy%,behind%
  152. {*  : 
  153.  Get coordinates from main window
  154.  "WASP_WindowInfo",DisplayHandle% 
  155.  Dx%,Dy%,,,,,behind%
  156.   buffer%!00 = PaneHandle%
  157.   buffer%!04 = Dx%
  158. +  buffer%!08 = Dy% - PaneHeight% - Yos%
  159. #  buffer%!12 = Dx% + PaneWidth%
  160.   buffer%!16 = Dy% - Yos%
  161.   buffer%!20 = 0
  162.   buffer%!24 = 0
  163. !  : 
  164.  Open over displaywindow
  165.   buffer%!28 = behind%
  166.  "Wimp_OpenWindow",,buffer%
  167.  Reopen a window (either where it was, or where indicated)
  168. _ReOpenWindow(handle%,where%)
  169. =  buffer%!0 = handle% : 
  170.  "Wimp_GetWindowState",,buffer%
  171.  where% < 0 
  172.  buffer%!28 = where%
  173. _OpenWindow(buffer%)
  174.  Close a window
  175. _CloseWindow(handle%)
  176.  "WASP_CloseWindow",handle%
  177.  handle% = DisplayHandle% 
  178. )    
  179.  "WASP_CloseWindow",PaneHandle%
  180.     DisplayOpen% = 
  181.  Standard window redraw except for the display
  182. _RedrawWindow(block%)
  183.  block%!0 = DisplayHandle% 
  184. _UpdateWindow(RedrawWindow%)
  185. (    
  186.  RedrawWindow%,,block% 
  187.  more%
  188.  more%
  189. 0      
  190.  "Wimp_GetRectangle",,block% 
  191.  more%
  192.         
  193.  Restore the pointer to it's normal state
  194. _PointerLeave(handle%)
  195.  handle%=DisplayHandle%
  196.     PointerInWindow% = 
  197.   Pointer% = 0
  198. _SetPointer
  199.  In the display area, I want to change the pointer
  200. _PointerEnter(handle%)
  201.  handle%=DisplayHandle% 
  202.     PointerInWindow% = 
  203. _SetPointer
  204.  Mouseclicks
  205. _MouseClick(Mx%,My%,Buttons%,Window%,Icon%)
  206.  SelAdj%,Update%
  207.   Update% = 
  208.  Buttons% 
  209.      
  210.  Select% : SelAdj% =  1
  211.      
  212.  Adjust% : SelAdj% = -1
  213.     : SelAdj% =  0
  214.  Window% 
  215.  -2 : 
  216.  Iconbar
  217.       
  218.  Buttons% 
  219. O        
  220.  Select%,Adjust% : 
  221. _ReOpenWindow(DisplayHandle%,Buttons%=Select%)
  222. L        
  223.  Menu%           : 
  224. CreateMenu(MenuHandle%,Mx%-64,96+44*7+24*2)
  225.       
  226.  DisplayHandle%
  227.       
  228.  (Buttons% 
  229.  &F0) 
  230.         drag% = PreDrag%
  231. E        
  232.  "WASP_WindowInfo",DisplayHandle% 
  233.  ,,,,,,BehindWindow%
  234.         :
  235. 7        : 
  236.  Store pointerposition relative to edges
  237. ;        RelMx1% = Wminx% - Mx% : RelMy1% = Wminy% - My%
  238. ;        RelMx2% = Wmaxx% - Mx% : RelMy2% = Wmaxy% - My%
  239.         :
  240. @        
  241. _InitiateDrag(DisplayHandle%,7,0,0,XLimit%,YLimit%)
  242.         :
  243.       
  244. Q        : 
  245.  Next I might receive a dragevent, therefore store info on pointer
  246.         PreDrag% = Pointer%
  247.         
  248.  Buttons% 
  249. ;          
  250.  Select% : 
  251. _ReOpenWindow(DisplayHandle%,-1)
  252. @          
  253.  Menu%   : 
  254. CreateMenu(MenuHandle%,Mx%-64,My%-32)
  255.         
  256.       
  257.  PaneHandle%
  258. 5      
  259. (Buttons% 
  260.  Menu%) 
  261.  No menu in pane
  262.         
  263.  Icon% 
  264. +          
  265.  2    : scalemul% += SelAdj%
  266. +          
  267.  3    : scalediv% += SelAdj%
  268.           
  269.  : Update% = 
  270.         
  271. &        
  272.  Update% 
  273. _ReInitialise
  274.       
  275.  OptionsHandle%
  276.       
  277.  Icon% 
  278. 1        
  279.   1   : ShowPane%     = 
  280. (ShowPane%)
  281. 4        
  282.   2   : ShowPointer%  = 
  283. (ShowPointer%)
  284. 5        
  285.   3   : CrossPointer% = 
  286. (CrossPointer%)
  287. 4        
  288.   4   : FollowCaret%  = 
  289. (FollowCaret%)
  290. 4        
  291.   5   : AlwaysCaret%  = 
  292. (AlwaysCaret%)
  293. 5        
  294.   6   : BlankDisplay% = 
  295. (BlankDisplay%)
  296. )        
  297.  10   : scalemul% += SelAdj%
  298. )        
  299.  11   : scalemul% -= SelAdj%
  300. )        
  301.  12   : scalediv% += SelAdj%
  302. )        
  303.  13   : scalediv% -= SelAdj%
  304.         
  305.  : Update% = 
  306.       
  307. $      
  308.  Update% 
  309. _ReInitialise
  310.  InfoHandle%
  311. ?      
  312.  Icon% = 4 
  313. CreateMenu(MoneyHandle%,Mx%-64,My%-32)
  314.       
  315. CloseMenus
  316. =      
  317.  Icon% = 4 
  318.  "WASP_OpenWindow",MoneyHandle%,
  319.  End the move/resize of the display
  320. _UserDragBox
  321. !  : 
  322.  Last call to DragWindow
  323. _DragWindow
  324.   drag% = 0
  325. ;  Pointer% = 0 : 
  326. _SetPointer : 
  327.  not pretty, fast hack
  328.  The following hot-keys are implemented:
  329.  - shift-TAB : raise window with caret, and move the pointer
  330.                to the caret (as in MENON!)
  331. _KeyPressed(key%)
  332.  handle%,windx%,windy%,scx%,scy%,Xoff%,Yoff%,Cflags%
  333.  key% 
  334.  &19A : 
  335.  = Shift_TAB
  336.       : 
  337.  Get info on caret
  338. <      
  339.  "WASP_CaretInfo" 
  340.  handle%,,Xoff%,Yoff%,Cflags%
  341. /      
  342.  (handle% <> -1) 
  343.  (Cflags% <> -1) 
  344.         :
  345. 1        : 
  346.  Find out about window and pointer
  347. D        
  348.  "WASP_WindowInfo",handle% 
  349.  windx%,,,windy%,scx%,scy%
  350. -        
  351.  "WASP_PointerInfo" 
  352.  ,,Mx%,My%
  353.         :
  354. >        : 
  355.  Send OpenWindow (on top) message to the window
  356.  D        buffer%!00 = handle% : 
  357.  "Wimp_GetWindowState",,buffer%
  358. !J        buffer%!28 = -1      : 
  359.  "Wimp_SendMessage",2,buffer%,handle%
  360.         :
  361. #"        : 
  362.  And move the mouse
  363.         Xoff% += windx%
  364. %6        Yoff% += windy% + ((Cflags% 
  365.  &FFFF) >> 1)
  366. &*        
  367.  (Xoff%<>Mx%) 
  368.  (Yoff%<>My%)
  369. '&          
  370.  Mx% > Xoff% 
  371.  Mx% -= 1
  372. (&          
  373.  Mx% < Xoff% 
  374.  Mx% += 1
  375. )&          
  376.  My% > Yoff% 
  377.  My% -= 1
  378. *&          
  379.  My% < Yoff% 
  380.  My% += 1
  381.           
  382.  Mx%,My%
  383.         
  384.       
  385. .%    
  386.  "Wimp_ProcessKey",key%
  387.  Menus (lots of code from Jan Herman at the end of this file)
  388. _MenuSelection(block%)
  389.  MouseX%,MouseY%,Buttons%,f%
  390.  "WASP_PointerInfo" 
  391.  ,,MouseX%,MouseY%,Buttons%
  392.  !block% 
  393. 9>    
  394.    0 : 
  395. CreateMenu(InfoHandle%,MouseX%-64,MouseY%+32)
  396. :A    
  397.    1 : 
  398. CreateMenu(OptionsHandle%,MouseX%-64,MouseY%-32)
  399. ;H               
  400. CloseMenus : 
  401.  Dirty trick to get the right position
  402. <:               
  403.  "WASP_OpenWindow",OptionsHandle%,
  404.    2 : 
  405.  Save Options
  406. >.               f% = 
  407. (TaskPath$+"Options")
  408. ?I               
  409. #f%,BlankDisplay%,FollowCaret%,ShowPointer%,ShowPane%
  410. @<               
  411. #f%,Wwidth%,Wheight%,scalemul%,scalediv%
  412. A2               
  413. #f%,AlwaysCaret%,CrossPointer%
  414.                
  415. C*    
  416.  3,4 : buffer%!0 = DisplayHandle%
  417. D4               
  418.  "Wimp_GetWindowState",,buffer%
  419. E2               buffer%!28 = -1 - (!block% = 3)
  420. F(               
  421. _OpenWindow(buffer%)
  422. G.    
  423.    5 : 
  424. _CloseWindow(DisplayHandle%) 
  425.    6 : 
  426. _CloseDown
  427. K&  : 
  428.  Reopen menutree after adjust
  429.  (Buttons% 
  430.  Adjust%) 
  431. CreateMenu(LastMenuHdl%,LastMenuX%,LastMenuY%)
  432.  Usermessages
  433. _UserMessage(message%)
  434.  message%!16 
  435.       0 : 
  436. _CloseDown
  437. U*    
  438.      10 : 
  439. _DeskSave(message%!20)
  440. V#    
  441.    &502 : 
  442. _Help(message%)
  443. W!    
  444.  &400C1 : 
  445. _ReInitialise
  446.  ---------- Wimp_Poll routines ----------
  447.  Resizing and moving the display
  448. _DragWindow
  449.  nx0%,nx1%,ny0%,ny1%
  450.  w%,h%
  451.  Mx%,My%,Mz%
  452. f!  : 
  453.  Store window parameters
  454. g"  w% = Wwidth% : h% = Wheight%
  455. h#  nx0% = Wminx% : nx1% = Wmaxx%
  456. i#  ny0% = Wminy% : ny1% = Wmaxy%
  457.  drag% 
  458. l,    
  459.  Move%       : nx0% = RelMx1% + Mx%
  460. m/                       nx1% = RelMx2% + Mx%
  461. n/                       ny0% = RelMy1% + My%
  462. o/                       ny1% = RelMy2% + My%
  463. pC    
  464.  TopLeft%    : nx0% = RelMx1% + Mx% : ny1% = RelMy2% + My%
  465. qR                       
  466.  nx0% + (Border%*4) > nx1% 
  467.  nx0% = nx1% - (Border%*4)
  468. rR                       
  469.  ny0% + (Border%*4) > ny1% 
  470.  ny1% = ny0% + (Border%*4)
  471. sC    
  472.  TopRight%   : nx1% = RelMx2% + Mx% : ny1% = RelMy2% + My%
  473. tR                       
  474.  nx0% + (Border%*4) > nx1% 
  475.  nx1% = nx0% + (Border%*4)
  476. uR                       
  477.  ny0% + (Border%*4) > ny1% 
  478.  ny1% = ny0% + (Border%*4)
  479. vC    
  480.  BottomRight%: nx1% = RelMx2% + Mx% : ny0% = RelMy1% + My%
  481. wR                       
  482.  nx0% + (Border%*4) > nx1% 
  483.  nx1% = nx0% + (Border%*4)
  484. xR                       
  485.  ny0% + (Border%*4) > ny1% 
  486.  ny0% = ny1% - (Border%*4)
  487. yC    
  488.  BottomLeft% : nx0% = RelMx1% + Mx% : ny0% = RelMy1% + My%
  489. zR                       
  490.  nx0% + (Border%*4) > nx1% 
  491.  nx0% = nx1% - (Border%*4)
  492. {R                       
  493.  ny0% + (Border%*4) > ny1% 
  494.  ny0% = ny1% - (Border%*4)
  495.  drag%<>Move% 
  496. #    
  497.  nx0% < 0       
  498.  nx0% = 0
  499. )    
  500.  nx1% > XLimit% 
  501.  nx1% = XLimit%
  502. #    
  503.  ny0% < 0       
  504.  ny0% = 0
  505. )    
  506.  ny1% > YLimit% 
  507.  ny1% = YLimit%
  508. <  Wminx%  = nx0% 
  509. (Xos%-1) : Wmaxx% = nx1% 
  510. (Xos%-1)
  511. <  Wminy%  = ny0% 
  512. (Xos%-1) : Wmaxy% = ny1% 
  513. (Xos%-1)
  514. &  Wwidth% = Wmaxx% - Wminx% + Xos%
  515. &  Wheight%= Wmaxy% - Wminy% + Yos%
  516.  (w%<>Wwidth%) 
  517.  (h%<>Wheight%) 
  518. _InitSprite
  519. !  buffer%!00 = DisplayHandle%
  520.   buffer%!04 = Wminx%
  521.   buffer%!08 = Wminy%
  522.   buffer%!12 = Wmaxx%
  523.   buffer%!16 = Wmaxy%
  524.   buffer%!20 = 0
  525.   buffer%!24 = 0
  526.    buffer%!28 = BehindWindow%
  527. _OpenWindow(buffer%)
  528.  ++++++++++ Sprite routines ++++++++++
  529.  Try to claim the memory needed for the sprite
  530. _InitSprite
  531.  twidth%,theight%
  532. N  : 
  533.  Wimpslot expansion technique from Jan-Herman Buining (clever indeed)
  534. _SetSpriteInfo
  535.  "XWimp_SlotSize",(
  536. -&8000)+SpriteSize%,-1 
  537.  SlotSize%
  538.   SlotSize% -= (
  539. -&8000)
  540.  SlotSize% < &400 
  541. V    
  542. _ShowError(0,"Can't claim memory for internal sprite, must exit immediately")
  543. _CloseDown
  544. 5  : 
  545.  If there is less memory then we require ...
  546.  SlotSize% < SpriteSize% 
  547. 3    : 
  548.  ... we will simply use a smaller sprite
  549. C    : 
  550.  The (crude) method is simply to take the largest square
  551. 9    : 
  552.  area that will fit inside the slot allocated.
  553.         :
  554. :    : 
  555.  First calculate the square root of the maximum
  556.     : 
  557.  number of OSunits
  558. I    theight% = 
  559. ((SlotSize% << (3 + Xeigen% + Yeigen%) ) >> Log2BPP%)
  560. A    : 
  561.  To cater for "spilled" bits, width should be adjusted
  562. 9    twidth%  = theight% - ((64 >> Log2BPP%)<<Xeigen%)
  563. 4    : 
  564.  Finally assign the new width and height,
  565. (    : 
  566.  but only if they are smaller
  567. =    : 
  568.  (Note that some memory may be unused after this!)
  569. =    
  570.   twidth%<Swidth%  
  571.   Swidth% = twidth%  
  572. (Xos%-1)
  573. =    
  574.  theight%<Sheight% 
  575.  Sheight% = theight% 
  576. (Yos%-1)
  577. 9    SpriteSize% = 44 + 
  578. _SpriteSize(Swidth%,Sheight%)
  579. ;  : 
  580.  Initialise the spritearea (use the full slotsize)
  581.   SpriteArea%   = 
  582.   SpriteArea%!0 = SlotSize%
  583.   SpriteArea%!8 = 16
  584.  "OS_SpriteOp",256+9,SpriteArea%
  585. K  ScaledWidth%  = (Xos% +  (Swidth%*scalemul%) 
  586.  scalediv%) 
  587. (Xos%-1)
  588. K  ScaledHeight% = (Yos% + (Sheight%*scalemul%) 
  589.  scalediv%) 
  590. (Yos%-1)
  591.  calculate all there is to know about the sprite:
  592.   - calculate bounding box of sprite ( = windowsize/scaling )
  593.   - calculate size of sprite
  594. _SetSpriteInfo
  595. *  : 
  596.  Calculate width/height of sprite
  597. J  Swidth%  = (Xos% - 1 + (Wwidth% *scalediv%) 
  598.  scalemul%) 
  599. (Xos%-1)
  600. J  Sheight% = (Yos% - 1 + (Wheight%*scalediv%) 
  601.  scalemul%) 
  602. (Yos%-1)
  603. *  : 
  604.  Sprite may not exceed screensize
  605.  Swidth% > XLimit% 
  606.  Swidth% = XLimit%
  607.  Sheight%> YLimit% 
  608.  Sheight%= YLimit%
  609. +  : 
  610.  Calculate areasize for the sprite
  611. 7  SpriteSize% = 44 + 
  612. _SpriteSize(Swidth%,Sheight%)
  613.   SpriteName$ = "display"
  614.  Grab sprite around (x%,y%)
  615. _GrabSprite(x%,y%,MouseX%,MouseY%)
  616.   LOCAL LB%,BB%,RB%,TB%,R1,R2,R3
  617.    : 
  618.  Calculate bounding box
  619. -  LB% = (x% - (Swidth% >> 1)) 
  620. (Xos%-1)
  621. -  TB% = (y% - (Sheight%>> 1)) 
  622. (Yos%-1)
  623.   RB% = LB% + Swidth%
  624.   BB% = TB% + Sheight%
  625. 4  : 
  626.  Move/resize the box inside the screen area
  627.  LB%<0 
  628.  RB%-=LB% : LB%=0
  629.  TB%<0 
  630.  BB%-=TB% : TB%=0
  631.  RB%>XLimit% 
  632.  LB%-=RB%-XLimit% : RB%=XLimit% : 
  633.  LB%<0 
  634.  LB%=0
  635.  BB%>YLimit% 
  636.  TB%-=BB%-YLimit% : BB%=YLimit% : 
  637.  TB%<0 
  638.  TB%=0
  639.  And grab sprite
  640.  "OS_SpriteOp",256+16,SpriteArea%,SpriteName$,,LB%,TB%,RB%,BB%
  641. %  : 
  642.  Redirect output into sprite
  643.  "OS_SpriteOp",&13C,SpriteArea%,SpriteName$,0 
  644.  ,R1,R2,R3
  645.  BlankDisplay% 
  646.  16,0 : 
  647.  Wminx%-LB%,Wminy%-TB%,Wwidth%-Xos%*2,Wheight%-Yos%*2
  648.  ShowPointer%  
  649. )    : 
  650.  Paint a pointer inside sprite
  651.     LB% = MouseX% - LB%
  652.     TB% = MouseY% - TB%
  653.  CrossPointer% 
  654.       
  655.  3,15
  656. !      
  657.  LB%-16,TB%,LB%+16,TB%
  658. !      
  659.  LB%,TB%-16,LB%,TB%+16
  660.         
  661. X      
  662.  "OS_SpriteOp",&122,sparea%,"ptr"+ModeSuffix$,LB%,TB%-((31*Yos%)>>Yeigen%),3
  663.         
  664.  "OS_SpriteOp",&13C,R1,R2,R3
  665.  calculate spritesize (width, height in OS units!)
  666. _SpriteSize(width%,height%)
  667.  bits%
  668. 5  : 
  669.  Worst case: The sprite covers an area using
  670.     9  : 
  671.              the rightmost bit of the first word
  672. <  : 
  673.              upto the leftmost bit of the last word
  674. /  : 
  675.  Therefore:  Add 31 bits to both sides
  676. ?  bits% = ((
  677. _OStoPixel(width%+Xos%,Xeigen%)<<Log2BPP%)+62)
  678. 2= bits%*
  679. _OStoPixel(height%+Yos%,Yeigen%) >> 3
  680.  Convert OSunits to pixels
  681. _OStoPixel(osunits%,eigen%)
  682. 1  : 
  683.  Make sure that the # of pixels at least
  684. $  : 
  685.  covers the area in OSunits
  686. 4  : 
  687.  (the parameter may not be OSunit aligned!)
  688. += (osunits% + (1<<eigen%) -1) >> eigen%
  689.  ---------- Sprite routines ----------
  690.  ++++++++++ Miscelaneous support +++++++++++
  691.  Support routine which starts a dragbox, called from DragWindow
  692. _InitiateDrag(handle%,type%,x0%,y0%,x1%,y1%)
  693.   buffer%!00 = handle%
  694.   buffer%!04 = type%
  695.   buffer%!24 = x0%
  696.   buffer%!28 = y0%
  697.   buffer%!32 = x1%
  698.   buffer%!36 = y1%
  699.  "Wimp_DragBox",,buffer%
  700.  Reinitialise all (eg. after modechange or resize)
  701. _ReInitialise
  702. /(  : 
  703.  Reinit pane and options window
  704. _UpdateOptions
  705. 2)  : 
  706.  Setup scaleblock for spriteplot
  707. 3!  Scale%!00 = scalemul% : 
  708. 4!  Scale%!04 = scalemul% : 
  709. 5!  Scale%!08 = scalediv% : 
  710. 6!  Scale%!12 = scalediv% : 
  711. _GetModeInfo
  712.   Black% = (1<<Log2BPP%)-1
  713. _GetWindowInfo
  714. _InitSprite
  715.   buffer%!00 = 0
  716.   buffer%!04 =-YLimit%
  717.   buffer%!08 = XLimit%
  718.   buffer%!12 = 0
  719.  "Wimp_SetExtent",DisplayHandle%,buffer%
  720. _UpdateWindow(UpdateWindow%)
  721.  Read information about screenmode
  722. _GetModeInfo
  723.  "WASP_ModeInfo" 
  724.  XLimit%,YLimit%,Xeigen%,Yeigen%
  725.  "OS_ReadModeVariable",-1,9  
  726.  ,,Log2BPP%
  727.   Xos% = 1<<Xeigen%
  728.   Yos% = 1<<Yeigen%
  729. N0  XLimit% = (XLimit% + Xos% - 1) 
  730. (Xos%-1)
  731. O0  YLimit% = (YLimit% + Yos% - 1) 
  732. (Yos%-1)
  733.  (Xeigen%<2) 
  734.  (Yeigen%<2) 
  735.  ModeSuffix$ = "22" 
  736.  ModeSuffix$ = ""
  737.  Get info about window
  738. _GetWindowInfo
  739.  "WASP_WindowInfo",DisplayHandle% 
  740.  Wminx%,Wminy%,Wmaxx%,Wmaxy%,,,BehindWindow%
  741. Y'  Wwidth%  = Wmaxx% - Wminx% + Xos%
  742. Z'  Wheight% = Wmaxy% - Wminy% + Yos%
  743.  Determine pointershape relative to display window
  744. _SetPointerInfo
  745.  half%
  746.  Mx%,My%,Mz%
  747. d(  : 
  748.  Move is assumed (largest area)
  749.   Pointer% = Move%
  750. fB  : 
  751.  If it should be resize, set it according to the location
  752.  Wwidth% < Wheight% 
  753.  half% = Wwidth%>>1 
  754.  half% = Wheight%>>1
  755. h$  : 
  756.  check left side of display
  757.  (My% > Wmaxy%-half%+Mx%-Wminx%) 
  758.  Pointer% = TopLeft%
  759.  (My% < Wminy%+half%-Mx%+Wminx%) 
  760.  Pointer% = BottomLeft%
  761. k%  : 
  762.  check right side of display
  763.  (My% > Wmaxy%-half%-Mx%+Wmaxx%) 
  764.  Pointer% = TopRight%
  765.  (My% < Wminy%+half%+Mx%-Wmaxx%) 
  766.  Pointer% = BottomRight%
  767.  Set pointer to shape relating to screenarea
  768. _SetPointer
  769.  PointerInWindow% 
  770. _SetPointerInfo
  771. u.  : 
  772.  In a drag, the pointer never changes
  773.  drag% 
  774.  Pointer% = drag%
  775. w/  : 
  776.  (Re)set the pointer if it has changed
  777.  Pointer%<>OldPointer% 
  778.  Pointer% 
  779.       
  780.  Move%
  781. {J        
  782.  "OS_SpriteOp",256+36,sparea%,"ptr_hand"+ModeSuffix$,&22,8,8
  783. |7      
  784.  TopLeft%,TopRight%,BottomRight%,BottomLeft%
  785. }`        
  786.  "OS_SpriteOp",256+36,sparea%,"ptr_resize"+ModeSuffix$,&22,16>>Xeigen%,16>>Yeigen%
  787.       
  788. /        
  789.  "OS_SpriteOp",256+36,-1,,&31,0,0
  790.         
  791.     OldPointer% = Pointer%
  792. _UpdateOptions
  793. 3  : 
  794.  Check and perhaps justify scaling factors
  795.  scalemul% <  1 
  796.  scalemul% =  1
  797.  scalediv% <  1 
  798.  scalediv% =  1
  799.  scalemul% > 32 
  800.  scalemul% = 32
  801.  scalediv% > 32 
  802.  scalediv% = 32
  803. (  : 
  804.  Update icons in Options window
  805. _UpdateButton(1,ShowPane%)
  806. _UpdateButton(2,ShowPointer%)
  807.  "WASP_Select",OptionsHandle%,3,CrossPointer%
  808. _UpdateButton(4,FollowCaret%)
  809.  "WASP_Select",OptionsHandle%,5,AlwaysCaret%
  810. _UpdateButton(6,BlankDisplay%)
  811.  "WASP_SetIconText",OptionsHandle%,8,
  812. scalemul%
  813.  "WASP_SetIconText",OptionsHandle%,9,
  814. scalediv%
  815. %  : 
  816.  Update icons in Pane window
  817.  "WASP_SetIconText",PaneHandle%,0,
  818. scalemul%
  819.  "WASP_SetIconText",PaneHandle%,1,
  820. scalediv%
  821.  ShowPane% 
  822.  DisplayOpen% 
  823. _ReOpenPane 
  824. _CloseWindow(PaneHandle%)
  825.  (Re)set button in Options window
  826. _UpdateButton(nr%,on%) : 
  827.  Valid%,Colour%,OldValid%
  828.  "WASP_IconValid",OptionsHandle%,nr% 
  829.  OldValid%
  830.  on% 
  831.  Colour% = &E7 : Valid% = 
  832. "2" : 
  833.  Colour% = &17 : Valid% = 
  834.  OldValid%?1 <> Valid% 
  835.     OldValid%?1 = Valid%
  836. G    
  837.  "WASP_SetIconState",OptionsHandle%,nr%,Colour%<<24,&FF000000
  838.  Get position for next CLI argument
  839. _CLINextArg(instr%,len%)
  840.  (instr% <= len%)
  841. +    
  842. CLI$,instr%,1) <> " " 
  843.  = instr%
  844.     instr% += 1
  845. = instr%
  846.  Read integer value following CLI argument
  847. _CLIargs(arg$,
  848.  value%)
  849.  arg%,instr%,I%,len%,ch%
  850.   instr% = 
  851. CLI$,arg$)
  852.  instr% = 0 
  853.   len% = 
  854. (CLI$)
  855. ,  I% = 
  856. _CLINextArg(instr%+
  857. (arg$),len%)
  858.   arg% = 0
  859.  (I% <= len%)
  860. #    ch% = 
  861. CLI$,I%,1)) - 
  862. D    
  863.  (0 <= ch%) 
  864.  (ch% < 10) 
  865.  arg% = 10*arg% + ch% 
  866.  I% = len%
  867.     I% += 1
  868.  arg% <> 0 
  869.  value% = arg%
  870.  Return option value on/off, according to "+' or "-".
  871.  No "+" or "-" will return default%.
  872. _CLIonoff(search$,default%)
  873.  result%
  874.   result% = 
  875. CLI$,search$)
  876.  result%>1 
  877.  result% = (
  878. CLI$,result%-1,1) = "+") 
  879.  result% = default%
  880. = result%
  881.  ---------- Miscelaneous support -----------
  882.  ++++++++++ Startup/Closedown/Error routines +++++++++++
  883. _Initialise
  884. I  TaskName$ = "Examine" : TaskPath$ = 
  885. ExpandString("<Examine$Dir>.")
  886.  "WASP_Initialise",200,TaskName$ 
  887.  WimpVersion%,TaskHandle%
  888. _ShowError(
  889. ,"Line "+
  890. )+" ("+
  891. $+")")
  892. _GetModeInfo
  893.  "OS_SWINumberFromString",,"Wimp_UpdateWindow" 
  894.  UpdateWindow%
  895.  "OS_SWINumberFromString",,"Wimp_RedrawWindow" 
  896.  RedrawWindow%
  897.  PollBlock% 256 , Scale% 16, buffer% 80
  898.   IndirSize% = 900
  899.  IndirPtr% IndirSize%
  900. (  IndirEnd% = IndirPtr% + IndirSize%
  901. ,  : 
  902.  Set up defaults for display window
  903.   Border%   = 32
  904.  Declare mouse buttons
  905.   Adjust% = 1
  906.   Menu%   = 2
  907.   Select% = 4
  908. #  : 
  909.  Information about pointer
  910.   PointerInWindow% = 
  911.   Pointer%    = 0
  912.   OldPointer% = 0
  913.  dragtypes in Display
  914.   drag%       = 0
  915.   Move%       = 1
  916.   TopLeft%    = 2
  917.   TopRight%   = 3
  918.   BottomLeft% = 4
  919.   BottomRight%= 5
  920. _LoadResources
  921.  "Wimp_OpenTemplate",,TaskPath$+"TemplRO"+
  922. (WimpVersion% 
  923.  100)
  924.  "WASP_LoadWindow","Display" ,sparea%,IndirPtr%,IndirEnd%,-1 
  925.  DisplayHandle%,,IndirPtr%
  926.  "WASP_LoadWindow","ProgInfo",sparea%,IndirPtr%,IndirEnd%,-1 
  927.  InfoHandle%,,IndirPtr%
  928.  "WASP_LoadWindow","Options" ,sparea%,IndirPtr%,IndirEnd%,-1 
  929.  OptionsHandle%,,IndirPtr%
  930.  "WASP_LoadWindow","Pane"    ,sparea%,IndirPtr%,IndirEnd%,-1 
  931.  PaneHandle%,,IndirPtr%
  932.  "WASP_LoadWindow","Money"   ,sparea%,IndirPtr%,IndirEnd%,-1 
  933.  MoneyHandle%,,IndirPtr%
  934.  "Wimp_CloseTemplate"
  935. :  IndirPtr% = (IndirPtr%+3) 
  936.  &FFFFFFFC : 
  937.  word align
  938.   MenuHandle% = 
  939. CreateMenu("!Examine,Info>InfoHandle%,Options>OptionsHandle%,Save options,_Back,Front,Close,_Quit",IndirPtr%,IndirEnd%)
  940.  "WASP_Iconbar","!Examine",
  941. #  : 
  942.  read command line options
  943.  "OS_GetEnv" 
  944.  CLI$
  945. .  ShowPane%     = 
  946. _CLIonoff("pane"   ,
  947. .  ShowPointer%  = 
  948. _CLIonoff("pointer",
  949. .  CrossPointer% = 
  950. _CLIonoff("cross"  ,
  951.     -  FollowCaret%  = 
  952. _CLIonoff("caret"  ,
  953. -  AlwaysCaret%  = 
  954. _CLIonoff("always" ,
  955. .  BlankDisplay% = 
  956. _CLIonoff("blank"  ,
  957. _CLIargs("-width", Wwidth%)
  958. _CLIargs("-height",Wheight%)
  959. _CLIargs("-mul",   scalemul%)
  960. _CLIargs("-div",   scalediv%)
  961.   DisplayOpen% = 
  962. '  : 
  963.  Determine size of pane window
  964.  "WASP_WindowInfo",PaneHandle% 
  965.  Wminx%,Wminy%,Wmaxx%,Wmaxy%
  966. #  PaneWidth%  = Wmaxx% - Wminx%
  967. #  PaneHeight% = Wmaxy% - Wminy%
  968. !  buffer%!00 = DisplayHandle%
  969. "  buffer%!04 = XLimit%-Wwidth%
  970. #  buffer%!08 = YLimit%-Wheight%
  971.   buffer%!12 = XLimit%
  972.   buffer%!16 = YLimit%
  973.   buffer%!20 = 0
  974.   buffer%!24 = 0
  975.   buffer%!28 = -1
  976. _OpenWindow(buffer%)
  977.  "WASP_SetIconText",InfoHandle%,3,"0.25
  978.  (21 Apr 1993)"
  979. _LoadResources
  980.  f%,l%
  981.  Load the sprites
  982.  "OS_File",13,"Sprites",,,TaskPath$ 
  983.  f%,,,,l% : l% += &4
  984.  (f% = 1) 
  985.  sparea% l%
  986. *9    
  987.  "WASP_LoadSprites",TaskPath$+"Sprites",sparea%
  988. ,5    
  989. _ShowError(0,"Task sprites cannot be found")
  990. -$    
  991. _CloseDown : 
  992.  Always fatal
  993.  Load options (if any)
  994.  "OS_File",13,"Options",,,TaskPath$ 
  995.  f%,,,,l%
  996.  (f% = 1) 
  997.  (l% = 50) 
  998. 2#    f% = 
  999. (TaskPath$+"Options")
  1000. 3>    
  1001. #f%,BlankDisplay%,FollowCaret%,ShowPointer%,ShowPane%
  1002. 41    
  1003. #f%,Wwidth%,Wheight%,scalemul%,scalediv%
  1004. 5'    
  1005. #f%,AlwaysCaret%,CrossPointer%
  1006.     Wwidth%   = 300
  1007.     Wheight%  = 300
  1008.     scalemul% = 3
  1009.     scalediv% = 1
  1010. _CloseDown
  1011.  "XOS_Exit"
  1012. A!  : 
  1013.  Reset the spritepointer
  1014.  "XOS_SpriteOp",256+36,-1,,&31,0,0
  1015.  "XWimp_CloseDown",TaskHandle%,&4B534154
  1016.  "XOS_Exit"
  1017. _ShowError(Err%,Err$)
  1018.  click%
  1019.  "XOS_Exit"
  1020.     PollBlock%!0 = Err%
  1021.   $(PollBlock%+4)= Err$
  1022.  "XWimp_ReportError",PollBlock%,1,TaskName$ 
  1023.  ,click%
  1024. _CloseDown
  1025. Q7: +++++++++++++ UserMessage responds ++++++++++++++
  1026. _Help(message%)
  1027.  help$ : help$ = ""
  1028.  message%!32 
  1029.  DisplayHandle%
  1030. WW      help$ = " the window by moving the mouse,|mwhile holding \s or \a depressed."
  1031.       
  1032.  Pointer% 
  1033. Y4        
  1034.  Move% : help$ = "You can move" + help$
  1035. Z1        
  1036.   : help$ = "You can resize" + help$
  1037.       
  1038.  PaneHandle%
  1039. ]]      help$ = "|mmagnification = multiplier/divisor (now "+
  1040. scalemul%+"/"+
  1041. scalediv%+")."
  1042.       
  1043.  message%!36 
  1044. _9        
  1045.  0 : help$ = "This is the multiplier:"+help$
  1046. `6        
  1047.  1 : help$ = "This is the divisor:"+help$
  1048. aZ        
  1049.  2 : help$ = "Press \s to increase, and \a to decrease the multiplier:"+help$
  1050. bW        
  1051.  3 : help$ = "Press \s to increase, and \a to decrease the divisor:"+help$
  1052.         
  1053.  : help$ = ""
  1054.       
  1055.  OptionsHandle%
  1056.       
  1057.  message%!36 
  1058.         
  1059.  -1,0
  1060. hZ        
  1061.   1 : help$ = "With this button you control the pane\w below the display \w."
  1062. iM        
  1063.   2 : help$ = "This button toggles a pointer in the display \w."
  1064. j~        
  1065.   3 : help$ = "This button toggles the pointer in the display \w|min either a crosshair or in an actual pointer."
  1066.         
  1067.   4 : help$ = "With this button you can make the display \w focus on the caret.|mYou can sometimes move the pointer to the caret by pressing 
  1068. TAB."
  1069. l~        
  1070.   5 : help$ = "This button makes the display \w focus on the caret at all times,|mif 'follow caret' is selected."
  1071. my        
  1072.   6 : help$ = "When you select this button, the display \w is treated|mas an empty \w during magnification."
  1073. nD        
  1074.  help$ = "Zoom in or out using the up and down arrows."
  1075.       
  1076. q4  help$ = "This \w belongs to !Examine.|m"+help$
  1077. r(  message%!0  = (24 + 
  1078. (help$)) 
  1079.   message%!12 = message%!8
  1080.   message%!16 = &503
  1081. u!  $(message%+20) = help$+
  1082.  "Wimp_SendMessage",17,message%,message%!4
  1083.  Respond to DeskSave message
  1084. _DeskSave(file%)
  1085. #file%,"BASIC -quit "+TaskPath$+"!RunImage";
  1086. _DeskSaveOption(file%,ShowPane%    ,"pane")
  1087. _DeskSaveOption(file%,ShowPointer% ,"pointer")
  1088. _DeskSaveOption(file%,CrossPointer%,"cross")
  1089. _DeskSaveOption(file%,FollowCaret% ,"caret")
  1090. _DeskSaveOption(file%,AlwaysCaret% ,"always")
  1091. _DeskSaveOption(file%,BlankDisplay%,"blank")
  1092. #file%," -width "+
  1093. Wwidth%;
  1094. #file%," -height "+
  1095. Wheight%;
  1096. #file%," -mul "+
  1097. scalemul%;
  1098. #file%," -div "+
  1099. scalediv%
  1100. _DeskSaveOption(file%,option%,s$)
  1101.  option% 
  1102. #file%," +"+s$; 
  1103. #file%," -"+s$;
  1104. 7: ------------- UserMessage responds --------------
  1105.  !General
  1106.  Last modified 06-Mar-1990
  1107.  !General Library 
  1108.  Jan-Herman Buining
  1109.  NOT complete: only FNs and PROCs that I use,
  1110.                also, I've changed the menuproc slightly
  1111.  Wimp Application Support Module 
  1112.  Jan-Herman Buining
  1113.  Global variables
  1114.    MenuPtr%, MenuSize%, MenuEnd%
  1115.    LastMenuHdl%, LastMenuX%, LastMenuY%
  1116.  +++++ BIT HANDLING +++++
  1117. NFlag(Flags%)
  1118.   =((Flags% 
  1119.  %1000)=%1000)
  1120. ZFlag(Flags%)
  1121.   =((Flags% 
  1122.  %0100)=%0100)
  1123. CFlag(Flags%)
  1124.   =((Flags% 
  1125.  %0010)=%0010)
  1126. VFlag(Flags%)
  1127.   =((Flags% 
  1128.  %0001)=%0001)
  1129.  ----- BIT HANDLING -----
  1130.  +++++ MENU CREATION +++++
  1131. CreateMenu(Menu$,
  1132.  MenuPtr%,
  1133.  MenuEnd%)
  1134. D    
  1135.  Menu$ = Creation string, menu items are seperated by a ','
  1136.         
  1137. $    
  1138.          First item : Title
  1139.         
  1140. =    
  1141.          Next items : Normal            (Normal text
  1142. E    
  1143.                       @Ticked           (Tick prefixes icon)
  1144. U    
  1145.                       _Dotted           (UNDER dotted line -- Change by EdK)
  1146. K    
  1147.                       #Shaded           (Icon can not be selected)
  1148.         
  1149. J    
  1150.          Tick, Dot or Shade may also prefix the following items :
  1151.         
  1152. ?    
  1153.                       Submenu>Handle    (Submenu icon)
  1154. L    
  1155.                       Submenu>!Handle   (id. but generates message)
  1156. N    
  1157.                       String$Size$Valid (Writeable icon [Size$Valid])
  1158.         
  1159. "    
  1160.  StartPtr%,Title$,MaxLen%
  1161.     StartPtr%=MenuPtr%
  1162. C    
  1163.  (StartPtr%+28)>MenuEnd% 
  1164. _ShowError(0,"Menu area full")
  1165. &    
  1166. Split(Menu$,",",Title$,Menu$)
  1167.     Title$=
  1168. Title$,11)
  1169.     MaxLen%=
  1170. (Title$)-2
  1171.     $StartPtr%=Title$
  1172.     StartPtr%!12=&00070207
  1173.     MenuPtr%+=28
  1174.         
  1175. '      
  1176. Split(Menu$,",",Left$,Menu$)
  1177. ?      
  1178. MenuItem(Left$,Menu$,StartPtr%+28,MenuPtr%,MenuEnd%)
  1179. /      
  1180. (Left$)>MaxLen% 
  1181.  MaxLen%=
  1182. (Left$)
  1183.  Menu$=""
  1184. %    StartPtr%!16=(MaxLen%*&10)+&C
  1185.     StartPtr%!20=44
  1186.     StartPtr%!24=0
  1187.   =StartPtr%
  1188. MenuItem(
  1189.  Left$,Menu$,FirstEntry%,
  1190.  MenuPtr%,
  1191.  MenuEnd%)
  1192. &    
  1193.  Loc%,Mid$,Right$,Validation%
  1194. B    
  1195.  (MenuPtr%+24)>MenuEnd% 
  1196. _ShowError(0,"Menu area full")
  1197. 6    
  1198.  Menu$="" 
  1199.  MenuPtr%!00=&80 
  1200.  MenuPtr%!00=&00
  1201.     Validation%=
  1202.     MenuPtr%!08=&07000001
  1203. Left$,1) 
  1204. "      Left$=
  1205. Left$,
  1206. (Left$)-1)
  1207. ,      MenuPtr%!00=(MenuPtr%!00 
  1208.  (1<<0))
  1209. "      Left$=
  1210. Left$,
  1211. (Left$)-1)
  1212. L      
  1213.  MenuPtr%<>FirstEntry% 
  1214.  MenuPtr%!(-24)=(MenuPtr%!(-24) 
  1215.  (1<<1))
  1216. "      Left$=
  1217. Left$,
  1218. (Left$)-1)
  1219. -      MenuPtr%!08=(MenuPtr%!08 
  1220.  (1<<22))
  1221.         
  1222.     Loc%=
  1223. Left$,">")
  1224.  Loc%>0 
  1225.       Right$ = ""
  1226. (      
  1227. Split(Left$,">",Left$,Right$)
  1228.       
  1229. Right$,1)="!" 
  1230. '        Right$=
  1231. Right$,
  1232. (Right$)-1)
  1233. .        MenuPtr%!00=(MenuPtr%!00 
  1234.  (1<<3))
  1235.       
  1236.       MenuPtr%!04=
  1237. (Right$)
  1238.         
  1239.       MenuPtr%!04=-1
  1240.       Loc%=
  1241. Left$,"$")
  1242.       
  1243.  Loc%>0 
  1244. *        
  1245. Split(Left$,"$",Left$,Right$)
  1246.         Validation%=
  1247. .        MenuPtr%!00=(MenuPtr%!00 
  1248.  (1<<2))
  1249.       
  1250.         
  1251. *    
  1252. (Left$)<13 
  1253. (Validation%)) 
  1254.       $(MenuPtr%+12)=Left$
  1255.         
  1256. ,      MenuPtr%!08=(MenuPtr%!08 
  1257.  (1<<8))
  1258.       
  1259.  Validation% 
  1260. *        
  1261. Split(Right$,"$",Mid$,Right$)
  1262. 9        
  1263.  (MenuEnd%-(
  1264. (Right$)+
  1265. (Mid$)+2))<MenuPtr% 
  1266. -          
  1267. _ShowError(0,"Menu area full")
  1268.         
  1269. !        MenuEnd%-=(
  1270. (Mid$)+1)
  1271. '        $(MenuEnd%)=
  1272. Left$,
  1273. (Mid$))
  1274.          MenuPtr%!12=MenuEnd%
  1275. #        MenuEnd%-=(
  1276. (Right$)+1)
  1277.         $(MenuEnd%)=Right$
  1278.              MenuPtr%!16=MenuEnd%
  1279. !        MenuPtr%!20=
  1280. (Mid$)+1
  1281.         
  1282. (Mid$)<10 
  1283. !          Left$=
  1284. (Mid$)," ")
  1285.         
  1286. 3          Left$=
  1287. 10," ") : 
  1288.  Standard max width
  1289.         
  1290.       
  1291. 0        
  1292.  (MenuEnd%-(
  1293. (Left$)+1))<MenuPtr% 
  1294. -          
  1295. _ShoeError(0,"Menu area full")
  1296.         
  1297. "        MenuEnd%-=(
  1298. (Left$)+1)
  1299.         $(MenuEnd%)=Left$
  1300.          MenuPtr%!12=MenuEnd%
  1301.         MenuPtr%!16=-1
  1302. "        MenuPtr%!20=
  1303. (Left$)+1
  1304.       
  1305.         
  1306.     MenuPtr%+=24
  1307.  ----- MENU CREATION -----
  1308.  +++++ MENU HANDLING +++++
  1309. CloseMenus
  1310. #     
  1311.  Closes all open menu's
  1312. $!    
  1313.  "XWimp_CreateMenu",,-1
  1314. CreateMenu(MenuHdl%,X%,Y%)
  1315. (<    : 
  1316.  Shade the "Close" entry if the display is closed
  1317. )5    
  1318.  "WASP_Shade",MenuHandle%,5,
  1319. (DisplayOpen%)
  1320. *@    
  1321.  Create a menu, this acts as the first in the menu tree
  1322.     LastMenuHdl%=MenuHdl%
  1323.     LastMenuX%=X%
  1324.     LastMenuY%=Y%
  1325. .-    
  1326.  "XWimp_CreateMenu",,MenuHdl%,X%,Y%
  1327. CreateSubMenu(MenuHdl%,X%,Y%)
  1328. 2C    
  1329.  Create a submenu when this is needed after a menu warning
  1330. 30    
  1331.  "XWimp_CreateSubMenu",,MenuHdl%,X%,Y%
  1332.  ----- MENU HANDLING -----
  1333.  +++++ STRING HANDLING +++++
  1334. ExpandString(String$)
  1335. ;2    
  1336.  Expands a string containing OS variables
  1337.  Dummy$,Flags%
  1338.     Dummy$=
  1339. 255," ")
  1340. >C    
  1341.  "XOS_GSTrans",String$,Dummy$,
  1342. (Dummy$) 
  1343.  ,Dummy$ ;Flags%
  1344. ?,    
  1345. CFlag(Flags%)) 
  1346.  String$=Dummy$
  1347.   =String$
  1348. Split(String$,Seperator$,
  1349.  Left$,
  1350.  Right$)
  1351. C.    
  1352.  Splits a string in two pieces at the
  1353. D+    
  1354.  first occurrence of the seperator
  1355.  Loc%
  1356. F!    Loc%=
  1357. String$,Seperator$)
  1358.  Loc%>0 
  1359. H"      Left$=
  1360. String$,1,Loc%-1)
  1361. I*      Right$=
  1362. String$,
  1363. (String$)-Loc%)
  1364. J        
  1365.       Left$=String$
  1366.       Right$=""
  1367. M        
  1368.  ----- STRING HANDLING -----
  1369.