Home » Archimedes archive » Acorn User » AU 1998-08.adf » Freeware » PD/Xuen11/!Xuen/!runimage
PD/Xuen11/!Xuen/!runimage
This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.
Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.
| Tape/disk: | Home » Archimedes archive » Acorn User » AU 1998-08.adf » Freeware |
| Filename: | PD/Xuen11/!Xuen/!runimage |
| Read OK: | ✔ |
| File size: | F1F0 bytes |
| Load address: | 0000 |
| Exec address: | 0000 |
File contents
10REM ***********************************************
20REM Name : Xuen
30REM Purpose : Make RiscOS Desktop more efficient(!)
40REM Author : Barny Short
50REM Date : 30-May-1998
60REM ***********************************************
70appversion$="11.0"
80REM ***********************************************
90
100GlobalErrorState%=0
110RandomToolTip%=1:REM Enable(=1)/Disable(=0) random tool tips
120ON ERROR PROCerror(REPORT$+" at line "+STR$ERL):CLOSE#0:END
130
140REMON ERROR GOTO@@@@
150
160LIBRARY "<Obey$Dir>.Resources.Libs.OS"
170LIBRARY "<Obey$Dir>.Resources.Libs.Filer"
180LIBRARY "<Obey$Dir>.Resources.Libs.Wimp"
190LIBRARY "<Obey$Dir>.Resources.Libs.Tooltip"
200
210PictureType%=&d94:REM Artworks
220DocumentType%=&bc5:REM Impression Document
230User$="Admin":REM Default User name is Admin
240
250app$="Xuen"
260AppPath$=""
270AppDate$=""
280DIM apppath 255, apppathvar 32, appdatevar 32
290$appdatevar="<Sys$Time> <Sys$Date>"+CHR$0
300$apppathvar="<Xuenbs$Dir>"+CHR$0
310
320REM Aquire the start path to use for delete operations
330SYS"OS_GSTrans",apppathvar,apppath,255
340AppPath$=FNstring(apppath)
350
360
370DIM errorblock% 2048, block% 2048, block2% 2048, clistring 255
380DIM winblock% 2048, winopenblock% 2048, transblock% 2048, ptrblock% 2048
390DIM unknownstring% 32
400$unknownstring% = "unknown_app"+CHR$0
410
420DIM InvalidDrive$(255)
430InvalidDriveCount%=0
440
450DIM dragspritename% 256, boundspritebox% 32
460
470
480REM Auto link buffer add stuff
490alba_destinationdir$=""
500alba_type%=-1:REM -1 means nothing in cache
510alba_newlinkfile$=""
520alba_newlinkleaf$=""
530alba_time%=0
540
550CACHE_SIZE% = 4096
560pause% = 200
570open_type%=1
580close_type%=2
590add_window%=1
600subtract_window%=2
610drag_type%=5
620adjust%=1
630menu%=2
640select%=4
650iconbarhandle%=0
660dircount%=0
670linkloadaddr%=0
680objecttype%=0
690linkmenu%=0
700addlink%=0
710iconbar_timer%=TIME:iconbar_timerflag%=0
720whandle_tooltip%=0:ToolTip%=0:tooltip_timer%=0
730override_tooltip%=0:OldToolTip%=0
740whandle_tree%=0
750internalstackposition%=-2
760oldstackposition%=0
770currentwindow%=0
780currentmenuhandle%=0
790firstmenuhandle%=-3
800IconBarMenuOpen%=0
810StartMenuSeperator%=-1
820StartMenuSeperator2%=-1
830StartMenuSeperator3%=-1
840SysFilePrefix%=126
850BottomEdgeFlag=0
860after%=0
870whandle_dummyback%=0
880LastRightEdge%=0
890CascadeRow%=0
900CurrentButton%=0
910tptr%=0
920
930REM Filer tree related stuff
940FilerViewW% = 642
950FilerViewH% = 512
960
970GlobalMenuItemCount%=0
980GlobalMenuSepCount%=0
990GlobalToolTip$=""
1000GlobalState% = 0
1010GlobalStatePreBoot% = 0
1020GlobalStatePostBoot% = 1
1030GlobalStateIdle% = 2
1040GlobalStateShutDown% = 3
1050GlobalStep% = 0
1060GlobalShowBootMenuFlag%=0
1070RECURSE_BOOT% = 1
1080RECURSE_RUN% = 2
1090
1100REM Insert your choice of random tooltips here
1110RandTipMax%=5:REM Total number of random tooltips
1120DIM RandTip$(RandTipMax%)
1130RandTip$(1)="If it's getting complicated, you're doing it wrong"
1140RandTip$(2)="You use computers too much!"
1150RandTip$(3)="Hablo espanol!"
1160RandTip$(4)="Have you read Dilbert today?"
1170RandTip$(5)="Take your vits!"
1180
1190IconBarAnimSize%=6
1200DIM IconBarAnim$(IconBarAnimSize%)
1210IconBarAnim$(0)="Sxuen0"
1220IconBarAnim$(1)="Sxuen30"
1230IconBarAnim$(2)="Sxuen60"
1240IconBarAnim$(3)="Sxuen90"
1250IconBarAnim$(4)="Sxuen120"
1260IconBarAnim$(5)="Sxuen150"
1270IconBarAnimStep=0
1280IconBarAnimDir=0.5
1290
1300WindowListIcon%=-1
1310WindowListTimer%=0
1320
1330MaxWindowListSize%=64
1340WindowListSize%=0
1350DIM WindowListName$(MaxWindowListSize%)
1360DIM WindowListHandle%(MaxWindowListSize%)
1370
1380CurrentMenuType%=0
1390MainMenuType% = 0
1400WindowListMenuType% = 1
1410ShortCutMenuType% = 2
1420
1430MenuIsOpenFlag%=0
1440
1450DIM dblock% 1024, bootblock% 1024, shortcutmenu% 16000, shortcutmenudata% 20384
1460DIM main_menu% 256, tool_menu% 256, typebuf% 256, iconbarlabel% 32, iconbardata% 32
1470DIM string% 1024, bootstring% 1024, infodata% 2048, tooltipdata% 2048, tooltipicon% 512
1480DIM cache% CACHE_SIZE%
1490DIM dirlist%(32), dirptr%(32)
1500
1510cache_ext%=0
1520task_handle%=0
1530drag_button%=adjust%
1540DX%=0
1550drag_icon%=0
1560path$=""
1570in_leftregion=FALSE
1580in_rightregion=FALSE
1590qf_timer=TIME
1600regionxs%=16
1610regionys%=64
1620$iconbarlabel%=""+CHR$0
1630$iconbardata%="S!xuen"+CHR$0
1640globalmenuptr%=shortcutmenu%
1650
1660$iconbardata%=IconBarAnim$(0)+CHR$0
1670
1680
1690REM ***************************************************
1700
1710quit%=FALSE
1720
1730SYS"Hourglass_On"
1740PROCinit
1750REM PROCerror("Xuen path = "+AppPath$+CHR$0)
1760PROCGetScreenSize
1770PROCCreateToolTip
1780PROCloadcache
1790SYS"Hourglass_Off"
1800
1810REM If ALT is pressed then skip auto booting/loading anything
1820IF NOT(INKEY-3) THEN
1830 PROCRecurseDirectory(AppPath$+".Users."+User$+".Links.~~Boot", RECURSE_BOOT%)
1840 IF NOT(quit%) PROCRecurseDirectory(AppPath$+".Users."+User$+".Links.~~Run", RECURSE_RUN%)
1850 GlobalState%=GlobalStatePostBoot%
1860 IF NOT(quit%) PROCRecurseDirectory(AppPath$+".Users."+User$+".Links", RECURSE_BOOT%)
1870ENDIF
1880
1890GlobalState%=GlobalStateIdle%
1900
1910WHILE NOT quit%
1920PROCpoll
1930ENDWHILE
1940
1950REM Ensure all buffers are empty
1960PROCalba_purge(0)
1970GlobalState%=GlobalStateShutDown%
1980REM Reset quit to enable another quit
1990REM during program shutdown to be detected ...
2000quit%=FALSE
2010PROCRecurseDirectory(AppPath$+".Users."+User$+".Links.~~RunQuit", RECURSE_RUN%)
2020PROCDestroyToolTip
2030SYS "Wimp_CloseDown"
2040END
2050
2060REM Error handler
2070PROCerror(REPORT$+" at line "+STR$ERL):CLOSE#0
2080GlobalErrorState%+=1
2090IF GlobalErrorState%=1 GOTO 1960
2100IF GlobalErrorState%=2 GOTO 2030
2110REM Multiple errors have occured - die ungracefully
2120END
2130
2140REM ***************************************************
2150
2160DEFPROCGetDate
2170REM Aquire date and time
2180SYS"OS_GSTrans",appdatevar,apppath,255
2190AppDate$=FNstring(apppath)
2200ENDPROC
2210
2220REM ***************************************************
2230
2240REM poll loop
2250DEFPROCpoll
2260SYS"Wimp_Poll",0,block% TO reason%
2270REM IF reason%<>0 PROCerror(STR$(reason%)+CHR$0)
2280CASE reason% OF
2290WHEN 0:PROCnull_reason
2300WHEN 2:PROCPollReason2
2310WHEN 3:SYS "Wimp_CloseWindow",,block%
2320WHEN 6:PROCclick(block%!12)
2330WHEN 7:PROCdragdrop
2340REMWHEN 8:PROCkeypressed
2350WHEN 9:PROCmenuselect
2360WHEN 17,18:PROCreceive(reason%)
2370REM WHEN 19:PROCerror("Unsupported window definition.")
2380ENDCASE
2390ENDPROC
2400
2410REM ***************************************************
2420
2430DEFPROCPollReason2
2440IF ((!block%) >= OS_MX%) THEN
2450REM PROCerror("Window tobeopened:"+STR$~(!block%)+" behind: "+STR$~(block%!28)+CHR$0)
2460SYS "Wimp_OpenWindow",,block%
2470ELSE
2480REMcurrentwindow%=!block%:PROCOpenToolTip(2)
2490REM This is very wierd - the windowhandle is invalid and equals
2500REM the mouse pointer x position - must be a menu I reckon or
2510REM could be a bug in RISCOS.
2520MenuIsOpenFlag%=1
2530ENDIF
2540
2550ENDPROC
2560
2570DEFPROCGetScreenSize
2580SYS"OS_ReadModeVariable",-1,4 TO ,,OS_EX%:REM Eigen
2590SYS"OS_ReadModeVariable",-1,5 TO ,,OS_EY%
2600SYS"OS_ReadModeVariable",-1,11 TO ,,OS_WX%:REM Size
2610SYS"OS_ReadModeVariable",-1,12 TO ,,OS_WY%
2620OS_MX%=(1+OS_WX%) << OS_EX%
2630OS_MY%=(1+OS_WY%) << OS_EY%
2640ENDPROC
2650
2660REMDEFPROCkeypressed
2670REMLOCAL Char%
2680REMChar%=block%!24
2690REMIF Char%=&1CD PROCerror("Insert pressed on icon "+CHR$0)
2700REMREM Is this the delete or backspace key?
2710REMIF (Char%=8 OR Char%=&7f) THEN
2720REMREM Is this in a menu?
2730REMPROCerror("Window handle = "+STR$~(block%!0)+" -- main_menu% = "+STR$~(main_menu%)+CHR$0)
2740REMELSE
2750REMSYS "Wimp_ProcessKey",Char%
2760REMENDIF
2770REMENDPROC
2780
2790DEFPROCReopenDummyWindow
2800 !block2%=whandle_dummyback%
2810 SYS"Wimp_GetWindowState",,block2%
2820 block2%!8=-1024:block2%!16=-1024
2830 block2%!28=-2
2840 SYS"Wimp_OpenWindow",,block2%
2850 after%=whandle_dummyback%
2860 REM MenuIsOpenFlag%=0
2870
2880
2890 WindowListSize%=0
2900ENDPROC
2910
2920DEFPROCcascade
2930LOCAL q%,OldAfter%,after%
2940LOCAL sx%, sy%, ox%, oy%
2950LOCAL ReopenFlag%, StackFlag%, ValidFlag%
2960LOCAL PaneFlag%, IsOpenFlag%, IsMoveableFlag%
2970LOCAL CurrentWin%,CurrentIcon%
2980LOCAL n%
2990
3000PROCBuildWindowList
3010
3020cascade%=0
3030LastRightEdge%=0
3040CascadeRow%=0
3050
3060SYS"Wimp_GetPointerInfo",,block2%
3070CurrentWinPtr%=block2%!12
3080CurrentIcon%=block2%!16
3090
3100IF WindowListSize%=0 ENDPROC
3110
3120FORn%=0 TO (WindowListSize%-1)
3130 q%=winblock%
3140 PaneFlag%=FALSE
3150 REM Get Current window immediately under pointer
3160 CurrentWin% = WindowListHandle%(n%)
3170 !q%=CurrentWin%
3180 REM Try and cascade this desktop window ...
3190 SYS "Wimp_GetWindowState",,q%
3200
3210 q%!28=-1
3220
3230 REM Reposition window
3240 PaneFlag%=FALSE
3250 IF (((q%!32) AND ((2^22)+(2^23)))>0) PaneFlag%=TRUE
3260 IF (((q%!32) AND 32)=32) PaneFlag%=TRUE
3270 IsOpenFlag% = ((q%!32) AND (2^16))
3280 IsMoveableFlag% = ((q%!32) AND 2)
3290
3300 ReopenFlag%=TRUE
3310 StackFlag%=TRUE
3320 ValidFlag%=TRUE
3330
3340 IF (StackFlag%=TRUE) THEN
3350 ox%=q%!4
3360 oy%=q%!16
3370 sx%=(q%!12)-(q%!4)
3380 sy%=(q%!16)-(q%!8)
3390
3400 REM Try and fit as many windows horizontally as possible
3410 IF ((LastRightEdge%+sx%)<(OS_MX%-40)) THEN
3420 q%!4=LastRightEdge%
3430 q%!16=(OS_MY%-40)-(CascadeRow%*40):REM 1160
3440 q%!12=(q%!4)+sx%
3450 IF ((q%!12)>(OS_MX%-40)) q%!12=(OS_MX%-40)
3460 q%!8=(q%!16)-sy%
3470 IF ((q%!8)<40) q%!8=40
3480 LastRightEdge%=(q%!12)+48
3490 ELSE
3500 LastRightEdge%=0
3510 CascadeRow%+=1
3520 q%!4=(CascadeRow%*8)
3530 q%!16=(OS_MY%-40)-(CascadeRow%*40):REM 1160
3540 q%!12=(q%!4)+sx%
3550 IF ((q%!12)>(OS_MX%-40)) q%!12=(OS_MX%-40)
3560 q%!8=(q%!16)-sy%
3570 IF ((q%!8)<40) q%!8=40
3580 LastRightEdge%=(q%!12)+48
3590 ENDIF
3600
3610 REM Having allowed space for this window in the
3620 REM window cascade, are we sure we want to move
3630 REM it just yet?
3640 IF (ReopenFlag%=TRUE) THEN
3650 SYS "XWimp_SendMessage",2,q%,CurrentWin%
3660 ENDIF
3670 cascade%+=1
3680 ENDIF:REM End of IF StackFlag ...
3690NEXT n%
3700ENDPROC
3710
3720REM *********************************************
3730REM * Animate the icon bar icon *
3740REM *********************************************
3750DEFPROCAnimateIconBar
3760$iconbardata%=IconBarAnim$(IconBarAnimStep)
3770IconBarAnimStep+=IconBarAnimDir
3780IF (IconBarAnimStep<0 OR IconBarAnimStep=IconBarAnimSize%) THEN
3790IconBarAnimStep=0
3800REM IconBarAnimDir = IconBarAnimDir*-1
3810REM IconBarAnimStep+=IconBarAnimDir
3820ENDIF
3830REM Activate an update on the task bar icon .....
3840!block2%=-2
3850block2%!4=iconbarhandle%
3860SYS"Wimp_GetIconState",,block2%
3870block2%!8=0:REM Don't change anything,
3880block2%!12=0:REM Just signal an update ...
3890REM Insert the relevant word depending on system state ...
3900IF (GlobalState%<GlobalStateIdle%) $iconbarlabel%="Zz..."+CHR$0
3910IF (GlobalState%=GlobalStateIdle%) $iconbarlabel%=" "+CHR$0:REM User$+CHR$0
3920IF (GlobalState%=GlobalStateShutDown%) $iconbarlabel%="Bye.."+CHR$0
3930GlobalStep%+=1
3940SYS"Wimp_SetIconState",,block2%
3950ENDPROC
3960
3970REM *********************************************
3980REM Idle WIMP poll
3990REM *********************************************
4000DEFPROCnull_reason
4010LOCAL window%,icon%,wlicon%,button%
4020
4030SYS"Wimp_GetPointerInfo",,ptrblock%
4040X%=ptrblock%!0
4050Y%=ptrblock%!4
4060button%=ptrblock%!8
4070window%=ptrblock%!12
4080icon%=ptrblock%!16
4090currentwindow%=window%
4100
4110IF (CurrentMenuType% = WindowListMenuType% AND (button% AND7)>0) THEN
4120 IF (window%=currentmenuhandle% AND icon%>=0) THEN
4130 wlicon% = icon% DIV3
4140 IF (wlicon%<>WindowListIcon%) THEN
4150 WindowListIcon%=wlicon%:WindowListTimer%=TIME
4160 ENDIF
4170 IF (TIME>(WindowListTimer%+200)) THEN
4180 REM Open this window
4190 PROCwindowmenuselect(wlicon%)
4200REM IF ((button% AND7)=4) SYS"Wimp_CreateMenu",,-1
4210 REM PROCerror("Icon handle = "+STR$(icon% DIV3)+" ("+STR$icon%+")"+CHR$0)
4220 WindowListIcon%=-1
4230 ENDIF
4240
4250 ELSE
4260 WindowListIcon%=-1
4270 ENDIF
4280 ELSE
4290 WindowListIcon%=-1
4300ENDIF
4310
4320REM Purge the buffer once every 10s
4330PROCalba_purge(1000)
4340PROCAnimateIconBar
4350IF (ToolTip%=1) PROCUpdateToolTipTime
4360
4370REM This may be needed to stop flicker
4380REM *fx19
4390IF (((ptrblock%!12)=-2 AND (ptrblock%!16=iconbarhandle%))) THEN
4400PROCmove_overiconbar
4410ELSE
4420OldToolTip%=0
4430
4440REMIF (((TIME-tooltip_timer%)>100) AND ToolTip%>0) THEN
4450IF (ToolTip%>0) THEN
4460IF (ptrblock%!16 <> whandle_tooltip%) iconbar_timerflag%=0
4470PROCCloseToolTip
4480ELSE
4490REMiconbar_timer%=TIME
4500iconbar_timerflag%=0
4510ENDIF
4520ENDIF
4530
4540IF ((X%>regionxs% AND X%<(OS_MX%-regionxs%)) OR Y%>regionys%) PROCoutoffocus
4550IF (Y%=0) THEN
4560 IF (BottomEdgeFlag=0) PROCpointeronbottomedge
4570 ELSE
4580 BottomEdgeFlag=0
4590ENDIF
4600
4610ENDPROC
4620
4630REM ***************************************************
4640
4650DEFPROCpointeronbottomedge
4660LOCAL stackposition%
4670REM Make iconbar at top of stack
4680BottomEdgeFlag=1
4690SYS"Wimp_ProcessKey",&1dc
4700ENDPROC
4710
4720DEFPROCpointernotoniconbar
4730IF (ToolTip%=0 OR (ToolTip%<>0 AND currentwindow%<>whandle_tooltip%)) THEN
4740 IF firstmenuhandle%=-2 firstmenuhandle%=currentwindow%
4750ENDIF
4760
4770!block%=-2
4780SYS"Wimp_GetWindowState",,block%
4790stackposition%=block%!28
4800IF (stackposition%<>oldstackposition%) THEN
4810IF (currentwindow%<>firstmenuhandle% AND firstmenuhandle%>-2) THEN
4820SYS"Wimp_ProcessKey",&1dc
4830firstmenuhandle%=-3
4840!block%=-2
4850SYS"Wimp_GetWindowState",,block%
4860stackposition%=block%!28
4870oldstackposition%=stackposition%
4880ENDIF
4890ENDIF
4900ENDPROC
4910
4920
4930DEFPROCoutoffocus
4940IF (in_leftregion) THEN PROCleaveleftregion
4950IF (in_rightregion) THEN PROCleaverightregion
4960qf_timer=TIME
4970ENDPROC
4980
4990DEFPROCleaveleftregion
5000in_leftregion=FALSE
5010ENDPROC
5020
5030DEFPROCleaverightregion
5040in_rightregion=FALSE
5050ENDPROC
5060
5070DEFPROCfocusdelay
5080IF ((TIME-pause%)>qf_timer) THEN qf_timer=-1:PROCOpenInfoBox
5090ENDPROC
5100
5110DEFPROCleft_corner
5120IF (in_leftregion=FALSE) ec_timer=TIME:ec_flag=FALSE
5130in_leftregion=TRUE
5140REM Check if windows need opening
5150IF (TIME-ec_timer>=50 AND ec_flag=FALSE) THEN
5160PROCreopenfiler:ec_flag=TRUE
5170ENDIF
5180
5190ENDPROC
5200
5210DEFPROCright_corner
5220IF (in_rightregion=FALSE) ec_timer=TIME:ec_flag=FALSE
5230in_rightregion=TRUE
5240REM Check if windows need closing
5250REMIF (TIME-ec_timer>=100 AND ec_flag=FALSE) THEN
5260IF (ec_flag=FALSE) THEN
5270PROCclosefiler:PROCCloseInfoBox:ec_flag=TRUE
5280ENDIF
5290ENDPROC
5300
5310REM ***************************************************
5320
5330DEFPROCOpenInfoBox
5340
5350
5360
5370!block%=whandle_info%
5380SYS"Wimp_GetWindowState",,block%
5390SYS"Wimp_OpenWindow",,block%
5400ENDPROC
5410
5420DEFPROCCloseInfoBox
5430!block%=whandle_info%
5440SYS"Wimp_CloseWindow",,block%
5450ENDPROC
5460
5470REM ***************************************************
5480
5490DEFPROCinit_drag(icon%)
5500qf_timer=-1
5510SYS"Wimp_GetPointerInfo",,block%
5520ox%=block%!0
5530oy%=block%!4
5540block%!4=icon%
5550drag_icon%=icon%
5560block%!4=drag_type%
5570block%!8=ox%-32
5580block%!12=oy%-32
5590block%!16=ox%+32
5600block%!20=oy%+32
5610block%!24=&80000000
5620block%!28=&80000000
5630block%!32=&7FFFFFFF
5640block%!36=&7FFFFFFF
5650SYS"Wimp_DragBox",,block%
5660
5670REM Start a sprite drag ....
5680IF (icon%=add_window%) $dragspritename%="yes"+CHR$0
5690IF (icon%=subtract_window%) $dragspritename%="no"+CHR$0
5700!boundspritebox%=0
5710boundspritebox%!4=0
5720boundspritebox%!8=ox%+24
5730boundspritebox%!12=oy%+24
5740SYS"DragASprite_Start",2+8+64+128,1,dragspritename%,boundspritebox%
5750ENDPROC
5760
5770DEFPROCdragdrop
5780SYS"Wimp_GetPointerInfo",,block%
5790block%!20=block%!12
5800block%!24=block%!16
5810block%!28=!block%
5820block%!32=block%!4
5830block%!36=0
5840!block%=64:block%!12=0
5850block%!16=1:block%!40=&fff
5860$(block%+44) =""
5870SYS"Wimp_SendMessage",18,block%,block%!20,block%!24
5880
5890REM Cancel a sprite drag .......
5900SYS"DragASprite_Stop"
5910ENDPROC
5920
5930REM ************************************************
5940REM function to deal with incoming messages
5950REM ************************************************
5960DEFPROCreceive(reason%)
5970message%=block%!16
5980REM PROCerror("Message : &"+STR$~(message%)+CHR$0)
5990CASE message% OF
6000WHEN 0:quit%=TRUE
6010WHEN 3:PROCdata_load_add_link:REM PROCerror("DataLoad:"+FNstring(block%+44)+" Leafname:"+FNGetLeafName(block%+44)+" Type:&"+STR$~(!(block%+40))+CHR$0)
6020WHEN 2:PROCdata_ack
6030WHEN 5:PROCdata_open
6040WHEN 10:PROCdesktop_ack
6050WHEN &502:PROCservice_help
6060WHEN &400C0:PROCsubmenu_warning
6070WHEN &400C1:PROCGetScreenSize
6080WHEN &400C9:IconBarMenuOpen%=0
6090ENDCASE
6100ENDPROC
6110
6120DEFPROCservice_help
6130block%!12 =block%!8
6140block%!16=&503
6150!block%=256
6160IF (block%!32 = -2) THEN
6170 $(block%+20) ="\TXuen icon.|M\Sshow shortcuts.|MClick MENU to show options.|M\Ashow currently open window list.|MDrag and drop an icon onto the Xuen icon to install it into the shortcuts menu.|M"+CHR$0
6180 SYS"Wimp_SendMessage",17,block%,block%!4
6190ELSE
6200 $(block%+20) ="This is the Xuen application.|M"+CHR$0
6210 SYS"Wimp_SendMessage",17,block%,block%!4
6220
6230ENDIF
6240
6250REM IF (block%!32 = main_menu%) THEN
6260IF (CurrentMenuType% = MainMenuType%) THEN
6270REM $(block%+20) ="'Advanced' option enables the boot configuration to be changed from the shortcut menu.|M'Toolbox' has some useful little programming tools such as saving the ROM and RAM spritefiles to the current directory.|M"+CHR$0
6280REM SYS"Wimp_SendMessage",17,block%,block%!4
6290ENDIF
6300ENDPROC
6310
6320REM *******************************************************
6330REM User has double clicked on a fileicon
6340REM Response - store a link to this file in the ~ directory
6350REM *******************************************************
6360DEFPROCdata_open
6370LOCAL type%, destinationdir$
6380REM Flush cache if stuff in it ...
6390IF (alba_type%>0 AND alba_type%<>4096) THEN PROCalba_purge(0)
6400
6410alba_newlinkfile$=FNstring(block%+44)
6420alba_newlinkleaf$=FNGetLeafName(block%+44)
6430type%=!(block%+40)
6440alba_type%=type%
6450REM PROCerror("Type = "+STR$(type%)+CHR$0)
6460destinationdir$=AppPath$+".Users."+User$+".Links."
6470
6480
6490IF (type%=4096) THEN
6500REM Store this directory access
6510destinationdir$=destinationdir$+CHR$(SysFilePrefix%)+"Folders"
6520ENDIF
6530
6540IF (type%=8192) THEN
6550REM Store this application access
6560destinationdir$=destinationdir$+CHR$(SysFilePrefix%)+"Programs"
6570ENDIF
6580
6590IF (type%<4096) THEN
6600 IF (type%=DocumentType%) THEN
6610 destinationdir$=destinationdir$+CHR$(SysFilePrefix%)+"Document"
6620 ENDIF
6630
6640 IF (type%=PictureType%) THEN
6650 destinationdir$=destinationdir$+CHR$(SysFilePrefix%)+"Picture"
6660 ENDIF
6670
6680 IF (type%<>PictureType% AND type%<>DocumentType%) THEN
6690 destinationdir$=destinationdir$+CHR$(SysFilePrefix%)+"Files"
6700 ENDIF
6710ENDIF
6720
6730alba_destinationdir$=destinationdir$
6740alba_time%=TIME
6750
6760REM Ignore all links generated during the preboot/run stage
6770IF GlobalState%=0 alba_type%=-1
6780ENDPROC
6790
6800DEFPROCautoaddnewshortcut
6810LOCAL autodropdirectory$
6820LOCAL number%, next%,numberofitems%
6830LOCAL oldestdate%,oldestname$,oldesttype%,oldestnext%,oldnext%
6840LOCAL delstring$
6850autodropdirectory$ = alba_destinationdir$
6860PROCensuredir(autodropdirectory$)
6870REM Auto insert directorys have a limit of 9 items
6880REM Is link directory empty?
6890numberofitems%=0
6900next%=0
6910oldestdate%=0
6920WHILE(next%<>-1 AND numberofitems%<=16)
6930$string%=autodropdirectory$+CHR$0
6940oldnext%=next%
6950SYS "OS_GBPB",11,string%,dblock%,1,next%,63,"*" TO ,,,number%,next%
6960IF next%<>-1 THEN
6970numberofitems%+=1
6980IF ((dblock%!24)<oldestdate% OR oldestdate%=0) oldestdate%=dblock%!24:oldestname$=FNstring(dblock%+29):oldestnext%=oldnext%
6990ENDIF
7000ENDWHILE
7010IF (numberofitems%<9) THEN
7020 REM If so then automatically insert
7030 PROCaddnewshortcut(autodropdirectory$,alba_newlinkfile$,alba_newlinkleaf$)
7040ELSE
7050 REM Intelligently delete an old file and
7060 REM Get filetype of this file
7070 $string%=autodropdirectory$+CHR$0
7080 SYS "OS_GBPB",12,string%,dblock%,1,oldestnext%,63,"*"
7090 oldesttype%=dblock%!20
7100 REM PROCerror("Oldest file to remove : "+oldestname$+" of type "+STR$~(oldesttype%)+CHR$0)
7110 REM Delete the oldest link in this dir ...
7120 REM Final check - Only allow delete on &af3 files.
7130 IF (oldesttype%=&af3) THEN
7140 delstring$="delete "+autodropdirectory$+"."+oldestname$
7150 REM PROCerror("about to OSCLI "+delstring$+CHR$0)
7160 OSCLI(delstring$+CHR$0)
7170 REM insert a new one ...
7180 PROCaddnewshortcut(autodropdirectory$,alba_newlinkfile$,alba_newlinkleaf$)
7190 ENDIF
7200ENDIF
7210alba_type%=-1
7220ENDPROC
7230
7240REM Prompt user to select directory for new link
7250DEFPROCdata_load_add_link
7260LOCAL path$,leaf$,type%,leafptr%,linkname$
7270IF (FNCheckLinksDirExists=0) ENDPROC
7280path$=FNstring(block%+44)
7290leaf$=FNGetLeafName(block%+44)
7300type%=!(block%+40)
7310linkname$=AppPath$+".Users."+User$+".Links."+leaf$
7320newlinkleaf$=leaf$
7330newlinkfile$=FNstring(block%+44)
7340REM Is link directory empty?
7350$string%=AppPath$+".Users."+User$+".Links"+CHR$0
7360SYS "OS_GBPB",10,string%,dblock%,1,0,63,"*" TO ,,,number%
7370IF number%=0 THEN
7380REM If so then automatically add to root directory
7390PROCaddnewshortcut(AppPath$+".Users."+User$+".Links",newlinkfile$,newlinkleaf$)
7400ELSE
7410PROCshowshortcutmenu(1)
7420ENDIF
7430ENDPROC
7440
7450REM Add new link to the shortcut directory
7460DEFPROCaddnewshortcut(dropdirectory$,add_newlinkfile$,add_newlinkleaf$)
7470LOCAL linkname$,leafptr%,IgnoreLink%,Index%,Char%
7480linkname$=dropdirectory$+"."+add_newlinkleaf$
7490$string%=add_newlinkfile$+CHR$0
7500REMPROCerror("Contents of "+linkname$+"="+add_newlinkfile$+CHR$0)
7510leafptr%=string%
7520REM Check for any illegal characters in filename and if so
7530REM ignore the generation of this link
7540IgnoreLink%=FALSE
7550FORIndex%=0TO LEN(add_newlinkleaf$)
7560Char%=ASC(MID$(add_newlinkleaf$,Index%,1))
7570IF Char%=ASC"$" OR Char%=ASC"." THEN
7580 IgnoreLink%=TRUE
7590ENDIF
7600NEXT
7610IF IgnoreLink%=FALSE THEN
7620 REM Check to see if this file already exists and if so
7630 REM prompt for overwrite.
7640 X%=OPENOUT(linkname$+CHR$0)
7650 WHILE((?leafptr%) > 31)
7660 BPUT#X%, ?leafptr%
7670 leafptr%+=1
7680 ENDWHILE
7690 BPUT#X%, 10:REM Output a terminating LF
7700 CLOSE#X%
7710 REM Set type appropriately
7720 OSCLI("SetType "+linkname$+" af3"+CHR$0)
7730ENDIF
7740ENDPROC
7750
7760DEFPROCalba_purge(expiry%)
7770IF (alba_type%<0) THEN ENDPROC
7780IF (expiry%>0 AND (alba_time%+expiry%)>TIME) THEN ENDPROC
7790PROCautoaddnewshortcut
7800ENDPROC
7810
7820REM ***************************************************
7830REM Window and iconbar click handler
7840REM See below for menu click handler
7850REM **************************************************
7860DEFPROCclick(win%)
7870CASE win% OF
7880WHEN -2:PROCclick_iconbar(block%!8)
7890WHEN whandle_info%:PROCclick_info(block%!8)
7900ENDCASE
7910ENDPROC
7920
7930REM **************************************************
7940REM Menu click handler
7950REM **************************************************
7960DEFPROCmenuselect
7970CASE CurrentMenuType% OF
7980WHEN MainMenuType%:PROCmainmenuselect
7990WHEN ShortCutMenuType%:PROCshortcutmenuselect
8000WHEN WindowListMenuType%:PROCwindowmenuselect(!block%)
8010ENDCASE
8020ENDPROC
8030
8040REM ***************************************************
8050
8060DEFPROCclick_iconbar(button%)
8070CurrentButton%=button%
8080CASE button% OF
8090WHEN 0:PROCmove_overiconbar
8100WHEN 1:PROCclick_iconbaradjust
8110WHEN 2:PROCclick_iconbargeneral
8120WHEN 4:PROCclick_iconbarselect
8130ENDCASE
8140ENDPROC
8150
8160DEFPROCclick_iconbargeneral
8170IF ToolTip%=1 PROCPersistCloseToolTip
8180SYS"Wimp_GetPointerInfo",,block%
8190override_tooltip%=1
8200IconBarMenuOpen%=1:REM Inhibit tool tip display over menu
8210IF (CurrentButton%=1) PROCshowwindowmenu:ENDPROC
8220IF (CurrentButton%=2) PROCshowmainmenu:ENDPROC
8230IF (CurrentButton%=4) PROCshowshortcutmenu(0):ENDPROC
8240ENDPROC
8250
8260
8270DEFPROCclick_iconbarselect
8280IF (INKEY-1) AND (INKEY-2) THEN
8290 REM Open cache windows
8300 PROCreopenfiler
8310 ENDPROC
8320ENDIF
8330IF (INKEY-2) THEN
8340 REM Start drag to add a window
8350 SYS"Wimp_GetPointerInfo",,block%
8360 IF (block%!8) PROCinit_drag(add_window%)
8370 ELSE
8380 REM Click menu
8390 PROCclick_iconbargeneral
8400ENDIF
8410ENDPROC
8420
8430DEFPROCclick_iconbaradjust
8440IF (INKEY-1) AND (INKEY-2) THEN
8450REM Close cache windows
8460PROCclosefiler:PROCCloseInfoBox
8470ENDPROC
8480ENDIF
8490IF (INKEY-2) THEN
8500SYS"Wimp_GetPointerInfo",,block%
8510REM Start drag to remove a window
8520IF (block%!8) PROCinit_drag(subtract_window%)
8530ELSE
8540PROCclick_iconbargeneral
8550ENDIF
8560ENDPROC
8570
8580REM **************************************************
8590REM Pointer is over the iconbar
8600REM **************************************************
8610DEFPROCmove_overiconbar
8620IF IconBarMenuOpen%=1 iconbar_timerflag%=0
8630REM Is pointer over iconbar icon? If so inc iconbar_timer
8640IF (iconbar_timerflag%=0 AND IconBarMenuOpen%<>1) iconbar_timerflag%=1:iconbar_timer%=TIME
8650IF (((TIME-iconbar_timer%)>25) AND iconbar_timerflag%=1 AND OldToolTip%<>1) THEN
8660 REM What sort of tool tip?
8670 RSeed%=RND(-TIME)
8680
8690 IF (RandomToolTip%=1) THEN
8700 IF (RND(5)=1) THEN
8710 PROCOpenToolTip(2):iconbar_timerflag%=2
8720 ELSE
8730 PROCOpenToolTip(1):iconbar_timerflag%=2
8740 ENDIF
8750 ELSE
8760 PROCOpenToolTip(1):iconbar_timerflag%=2
8770 ENDIF
8780ENDIF
8790
8800REM Is user dragging over icon bar icon with a button
8810REM pressed for over 2 s ?
8820Y%=ptrblock%!4
8830IF (((TIME-iconbar_timer%)>200) AND IconBarMenuOpen%=0 AND ((ptrblock%!8 AND7)>0) ) THEN
8840 IF ToolTip%=1 PROCPersistCloseToolTip
8850 override_tooltip%=1
8860 IconBarMenuOpen%=1:REM Inhibit tool tip display over menu
8870 IF INKEY-3 THEN
8880 PROCshowshortcutmenu(0)
8890 ELSE
8900 REM Close all other menus
8910 REM SYS"Wimp_CreateMenu",,-1
8920 PROCshowwindowmenu
8930 ENDIF
8940ENDIF
8950
8960REM Has tool tip been open for long enough?
8970IF (((TIME-iconbar_timer%)>1000) AND ToolTip%>0) PROCPersistCloseToolTip:iconbar_timerflag%=0
8980ENDPROC
8990
9000
9010REM **************************************************
9020
9030DEFFNCheckLinksDirExists
9040LOCAL dir$,result%
9050dir$=AppPath$+".Users."+User$+".Links"
9060REM Does the Links directory exist?
9070$string%=dir$+CHR$0
9080SYS"OS_File",17,string% TO result%
9090REM If not, create one.
9100IF (result%=0) THEN OSCLI("CDIR "+dir$+CHR$0)
9110SYS"OS_File",17,string% TO result%
9120REM Has it created it? If not, error.
9130IF (result%=0) THEN
9140PROCerror("Fatal : Couldn't create "+dir$+CHR$0)
9150=0
9160ENDIF
9170=1
9180
9190REM **************************************************
9200
9210DEFPROCshowmainmenu
9220CurrentMenuType% = MainMenuType%
9230PROCshowmenu(main_menu%,!block%-64, 96+(8*44)+24)
9240ENDPROC
9250
9260REM **************************************************
9270REM Build list of currently valid open windows
9280REM **************************************************
9290DEFPROCBuildWindowList
9300LOCAL q%,OldAfter%
9310LOCAL sx%, sy%, ox%, oy%
9320LOCAL ReopenFlag%, StackFlag%, ValidFlag%
9330LOCAL PaneFlag%, IsOpenFlag%, IsMoveableFlag%
9340LOCAL CurrentWin%,CurrentIcon%
9350LOCAL WindowName$, ErrorFlag%,Windex%
9360
9370q%=winblock%
9380PaneFlag%=FALSE
9390WindowName$=""
9400
9410REM Start from bottom of window stack by
9420REM opening the dummy window at the bottom ...
9430PROCReopenDummyWindow
9440
9450REM Get Current window immediately under pointer
9460SYS"Wimp_GetPointerInfo",,block2%
9470CurrentWinPtr%=block2%!12
9480CurrentIcon%=block2%!16
9490
9500after%=whandle_dummyback%
9510
9520REM Go through all windows ...
9530REPEAT
9540OldAfter%=after%
9550!q%=after%
9560REM _Try_ and reopen this desktop window ...
9570SYS "XWimp_GetWindowState",,q% TO ;ErrorFlag%
9580CurrentWin%=!q%
9590IF (after%=-1 OR (ErrorFlag%AND1)=1) ENDPROC
9600Windex%=0
9610REPEAT
9620IF (CurrentWin%=WindowListHandle%(Windex%)) Windex%=-2
9630Windex%+=1
9640UNTIL Windex%>=WindowListSize% OR Windex%<0
9650after%=q%!28
9660
9670 PaneFlag%=FALSE
9680 IF (((q%!32) AND ((2^22)+(2^23)))>0) PaneFlag%=TRUE
9690 IF (((q%!32) AND 32)=32) PaneFlag%=TRUE
9700 IsOpenFlag% = ((q%!32) AND (2^16))
9710 IsMoveableFlag% = ((q%!32) AND 2)
9720
9730 ReopenFlag%=TRUE
9740 StackFlag%=TRUE
9750 ValidFlag%=TRUE
9760
9770 REM If this window is not at all on screen then ignore it
9780 REM OS_M? = ?X|Y ScreenOS?Size
9790 ox%=q%!4:ttox%=ox%
9800 oy%=q%!16:ttoy%=oy%
9810 sx%=(q%!12)-(q%!4):ttsx%=sx%
9820 sy%=(q%!16)-(q%!8):ttsy%=sy%
9830IF (ox%>OS_MX%) OR (oy%>OS_MY%) OR ((ox%+sx%)<0) OR ((oy%+sy%)<0) THEN ValidFlag%=FALSE
9840
9850
9860REM Is this the currently open menu window?
9870IF (CurrentWin%=currentmenuhandle%) ValidFlag%=FALSE
9880
9890REM Is this the icon bar?
9900REM IF (CurrentWin%=-2) ValidFlag%=FALSE
9910
9920REM Under pointer and _no_ horiz/vert scroll bars and fully visible (likely to be part of menu so leave alone)
9930IF (CurrentWin%=CurrentWinPtr% AND ((q%!32) AND (2^28))=0 AND ((q%!32) AND (2^30))=0 AND ((q%!32) AND (2^17))>0 AND after%=-1) ValidFlag%=FALSE
9940
9950 IF (CurrentWin%=whandle_tooltip%) ValidFlag%=FALSE
9960 IF (PaneFlag%=TRUE) ValidFlag%=FALSE
9970
9980 IF (ValidFlag%=TRUE) THEN
9990
10000 IF (WindowListSize%<MaxWindowListSize%) THEN
10010 WindowListHandle%(WindowListSize%)=CurrentWin%
10020 WindowListSize%+=1
10030 ENDIF
10040 ENDIF:REM End of IF ValidFlag% ...
10050
10060UNTIL CurrentWin%=-1
10070ENDPROC
10080
10090
10100REM **************************************************
10110REM Open the Window List menu
10120REM **************************************************
10130DEFPROCshowwindowmenu
10140LOCAL TitleBarFlag%, CurrentWin%, SourceTaskHandle%
10150LOCAL TitleBarPtr%, TitleBarLength%, ErrorFlag%, SuccessFlag%
10160LOCAL Index%,WindowName$,KludgeLength%,IsIndirected%
10170
10180LOCAL currentmenuptr%, locali%, width%, title$, item$
10190LOCAL WindowNum%
10200LOCAL a%
10210
10220IF (ToolTip%=1) PROCPersistCloseToolTip
10230SYS"Hourglass_On"
10240REM Build List of current windows
10250PROCBuildWindowList
10260
10270REM Build menu
10280initialmenusize%=WindowListSize%
10290currentmenuptr% = shortcutmenu%
10300title$="Windows"
10310TitlePtr%=currentmenuptr%
10320$TitlePtr%=title$
10330width%=(LEN(title$)-2)*16
10340currentmenuptr%!12 = &00070207
10350currentmenuptr%!20=44
10360currentmenuptr%!24=0
10370ptr%=currentmenuptr%+28
10380
10390IF (initialmenusize%>0) THEN
10400 locali%=0
10410 FORWindowNum%=(WindowListSize%-1) TO 0 STEP-1
10420 REM Initialise menu object
10430 IsDirect%=0
10440 !ptr%=8:REM mflags = &80 means last menu item
10450 ptr%!4=-1:REM pointer to sub menu
10460 ptr%!8=&7000313-512:REM icon type
10470 CurrentWin% = WindowListHandle%(WindowNum%)
10480 REM Get Task Handle
10490 !block2%=0
10500 SYS"XWimp_SendMessage",0,block2%,CurrentWin% TO ,,SourceTaskHandle% ;ErrorFlag%
10510 REM Is this window definition a valid one?
10520 SourceTaskName% = unknownstring%
10530 IF ((ErrorFlag%AND1)=0) THEN
10540 SYS"XTaskManager_TaskNameFromHandle",SourceTaskHandle% TO SourceTaskName% ;ErrorFlag%
10550 IF ((ErrorFlag%AND1)=1) SourceTaskName%=unknownstring%
10560 ENDIF
10570
10580 WindowName$="???"
10590 IF ((ErrorFlag%AND1)=0) THEN
10600 !block2%=CurrentWin%
10610 REM Get Window Info NB. Set Bit0 of R1 to disable icon info
10620 SYS "Wimp_GetWindowInfo",,block2%+1 TO ; ErrorFlag%
10630 TitleBarFlag% = !(block2%+60)
10640 IF ((TitleBarFlag% AND 1) AND (ErrorFlag%AND1)=0) THEN
10650 REM This title contains text
10660 IF (TitleBarFlag% AND 256) THEN
10670 REM Title data is indirected
10680 TitleBarPtr% = !(block2%+76)
10690 TitleBarLength%=!(block2%+84)
10700 REM Major Kludge !!! TODO
10710 !block2%=0
10720 SYS"Wimp_SendMessage",0,block2%,CurrentWin% TO ,,SourceTaskHandle%
10730 REM Copy source task data to destination task data
10740 SYS"XWimp_TransferBlock",SourceTaskHandle%,TitleBarPtr%,task_handle%,transblock%,TitleBarLength% TO ;ErrorFlag%
10750 REM Have we got the whole name?
10760 SuccessFlag%=0
10770 IF TitleBarLength%>0 THEN
10780 FORIndex%=0TO (TitleBarLength%-1)
10790 IF (?(transblock%+Index%)<32) SuccessFlag%=1
10800 NEXT
10810 ENDIF
10820 REM PROCerror("InDirected name = "+$(transblock%)+CHR$0)
10830
10840 IF SuccessFlag%=0 THEN
10850 Index%-=1
10860 REM Get rest of title bar (Major Kludge) TODO
10870 KludgeLength%=0
10880 REPEAT
10890 SYS"XWimp_TransferBlock",SourceTaskHandle%,TitleBarPtr%+Index%,task_handle%,transblock%+Index%,1 TO ;ErrorFlag%
10900 Index%+=1
10910 KludgeLength%+=1
10920 UNTIL ?(TitleBarPtr%+(Index%-1))<32 OR ((ErrorFlag%AND1)=1) OR KludgeLength%>253
10930 ?(transblock%+Index%) = 13
10940 ?(transblock%+Index%+1) = 0
10950 ENDIF
10960
10970 TitleBarPtr% = transblock%
10980 ELSE
10990 REM Is Directed data
11000 REM PROCerror("Direct window name = "+$(block2%+76)+CHR$0)
11010 TitleBarPtr% = block2%+76
11020 TitleBarLength%=12
11030 IsDirect%=1
11040 ENDIF:REM End of IF is indirected?
11050
11060 REM Has the title string got anything in it?
11070 IF (?TitleBarPtr%>=32 AND (ErrorFlag%AND1)=0) THEN
11080 IF (IsDirect%=0) THEN
11090 TitleBarString$ = FNgetname(TitleBarPtr%)
11100 REM PROCerror("Aquired title:"+TitleBarString$+CHR$0)
11110 ELSE
11120 TitleBarString$=""
11130 Z%=0
11140 REPEAT
11150 Y%=?(TitleBarPtr%+Z%)
11160 IF (Y%>=32) TitleBarString$=TitleBarString$+CHR$(Y%)
11170 Z%+=1
11180 UNTIL Z%>11 OR Y%<32
11190 ENDIF
11200
11210 WindowName$ = TitleBarString$
11220 IF (LEN(TitleBarString$)>45) THEN
11230 WindowName$ = LEFT$(TitleBarString$, 4)
11240 WindowName$ = WindowName$ + "..."
11250 WindowName$ = WindowName$ + RIGHT$(TitleBarString$, 38)
11260 ENDIF
11270 ENDIF
11280 ENDIF :REM End of Has text?
11290
11300 item$=WindowName$
11310
11320 $(shortcutmenudata%+(locali%*64)) = item$+CHR$0
11330
11340 taskname$ = FNstring(SourceTaskName%)
11350 taskiconname$=taskname$
11360 IF (LEN(taskname$)>0) THEN
11370 sn=3
11380 IF INSTR(taskname$,"Filer")>0 taskiconname$ = "small_dir":sn=0
11390 IF taskname$="unknown_app" taskiconname$="small_app":sn=0
11400 IF taskname$="Task Manager" taskiconname$="switcher":sn=1
11410 IF taskname$="Palette Utility" taskiconname$="palette":sn=1
11420 IF taskname$="Calculator" taskiconname$="!calc":sn=1
11430 IF taskname$="Characters" taskiconname$="!chars":sn=1
11440 IF taskname$="StrongHelp" taskiconname$="!stronghlp":sn=1
11450 IF (sn AND1)=1 THEN ptr%!8=&7000B13-512:REM half size icon
11460 IF (sn AND2)=2 THEN taskiconname$ = "!"+taskname$
11470 ENDIF
11480 REM PROCerror("Entry:"+item$+" Icon:"+taskiconname$+" Handle:"+STR$(CurrentWin%)+" TaskName:"+taskname$+CHR$0)
11490 REM Does taskiconname sprite exist?
11500 IF NOT(FNSpriteExist(taskiconname$)) taskiconname$="application"
11510 REM Is taskiconname too long to fit in name buffer?
11520 IF (LEN(taskiconname$)>12) taskiconname$="application"
11530 REM Build rest of item data
11540 $(shortcutmenudata%+(locali%*64)+46) = "S"+taskiconname$+CHR$0
11550 !(shortcutmenudata%+(locali%*64)+60) = CurrentWin%
11560 ptr%!12 = shortcutmenudata%+(locali%*64)
11570 ptr%!16 = shortcutmenudata%+(locali%*64)+46
11580 ptr%!20 = 46:REM menu item string buffer = 46 bytes
11590 a%=(LEN(item$)+4)*16
11600 ptr%+=24
11610 locali%+=1
11620 IF (a%>width%) THEN width%=a%
11630 ELSE
11640 initialmenusize%-=1
11650 ENDIF
11660 NEXT
11670ENDIF
11680REM If menu is empty, define an 'empty' item
11690IF initialmenusize%=0 THEN
11700 REM Make default first entry be greyed out label 'empty'
11710 initialmenusize%+=1
11720 item$="Empty"+CHR$0
11730 !ptr%=&80
11740 ptr%!4=-1:REM pointer to sub menu
11750 ptr%!8=&2400029:REM greyed out UNSELECTABLE icon type
11760 $(ptr%+12)=item$
11770 a%=(LEN(item$)+4)*16
11780 IF a%>width% width%=a%
11790 ptr%+=24
11800ENDIF
11810REM Define last item in menu
11820currentmenuptr%!16=width%
11830!(ptr%-24)=&88:REM Set last menu item
11840SYS"Hourglass_Off"
11850REM Open menu
11860SYS"Wimp_GetPointerInfo",,block%
11870CurrentMenuType% = WindowListMenuType%
11880WindowListIcon%=-1
11890PROCshowmenu(shortcutmenu%,!block%-64, 96+((initialmenusize%)*44))
11900ENDPROC
11910
11920REM ***********************************************
11930REM Does Sprite Exist?
11940REM ***********************************************
11950DEFFNSpriteExist(SpriteName$)
11960LOCAL ROMBase%, RAMBase%, ErrorFlag%
11970SYS "Wimp_BaseOfSprites" TO ROMBase%,RAMBase%
11980$dragspritename% = SpriteName$
11990SYS"XOS_SpriteOp",296,ROMBase%,dragspritename% TO ; ErrorFlag%
12000IF (ErrorFlag% AND 1)=0 THEN =TRUE
12010SYS"XOS_SpriteOp",296,RAMBase%,dragspritename% TO ; ErrorFlag%
12020IF (ErrorFlag% AND 1)=0 THEN =TRUE
12030=FALSE
12040
12050REM **************************************************
12060REM Start building the shortcutmenu
12070REM **************************************************
12080DEFPROCshowshortcutmenu(arg%)
12090IF (ToolTip%=1) PROCPersistCloseToolTip
12100addlink%=arg%
12110IF (FNCheckLinksDirExists=0) ENDPROC
12120dirptr%(0)=shortcutmenu%
12130REM linkmenudepth%=0:REM At top level
12140
12150REMPROCSingleDirectoryRead(AppPath$+".Users."+User$+".Links", User$, 0, 0)
12160PROCSingleDirectoryRead(AppPath$+".Users."+User$+".Links", "ShortCuts", 0, 0)
12170initialmenudottedlinesize%=0
12180initialmenusize%=dirlist%(0)
12190IF initialmenusize%=0 initialmenusize%=1
12200initialmenusize% = GlobalMenuItemCount%
12210SYS"Wimp_GetPointerInfo",,block%
12220CurrentMenuType% = ShortCutMenuType%
12230PROCshowmenu(shortcutmenu%,!block%-64, 96+(GlobalMenuItemCount%*44)+(GlobalMenuSepCount%*24))
12240ENDPROC
12250
12260
12270
12280REM *****************************************************
12290REM Read contents of a directory into the menu data areas
12300REM storing filename and icon type
12310REM *****************************************************
12320DEFPROCSingleDirectoryRead(localdir$,dirfilename$,linkdepth%, addwrite%)
12330LOCAL oldlocaldir$,olddirfilename$,oldlinkdepth%, olddirptr%
12340LOCAL dirsize%, DirScan%
12350LOCAL dir$,next%,type%,item$,currentdir%,ptr%
12360LOCAL currentmenuptr%, locali%, width%,title$
12370LOCAL TitlePtr%, MenuExtent%,itemsprite$
12380LOCAL filetype%, filetypeinfo%,linktype%,objecttype%,linktypeinfo%
12390LOCAL ValidLoadFlag%, KeepMenuItem%
12400LOCAL NumberOfLinks%, UseLargeSprite%
12410
12420SYS"Hourglass_On"
12430
12440oldlocaldir$ = localdir$
12450olddirfilename$ = dirfilename$
12460oldlinkdepth% = linkdepth%
12470olddirptr%=dirptr%(linkdepth%)
12480DirScan%=FALSE
12490
12500IF (addlink%=1) THEN
12510 itemsprite$="Pptr_link"
12520 ELSE
12530 itemsprite$=""
12540ENDIF
12550
12560REPEAT:REM Repeat until loaded in directory with no errors
12570localdir$ = oldlocaldir$
12580dirfilename$ = olddirfilename$
12590linkdepth% = oldlinkdepth%
12600dirptr%(oldlinkdepth%)=olddirptr%
12610DirScan%=TRUE
12620
12630REM Calculate pointer to shortcutmenu% & index into
12640REM shortcutmenudata%
12650dir$=localdir$
12660a%=0
12670currentmenuptr%=shortcutmenu%
12680i%=0
12690WHILE a%<linkdepth%
12700currentmenuptr%+=(28+(dirlist%(a%)*24))
12710i%+=dirlist%(a%)
12720a%+=1
12730ENDWHILE
12740
12750REM Initialise root menu seperator to be undefined
12760IF (linkdepth%=0) THEN
12770 StartMenuSeperator%=-1
12780 StartMenuSeperator2%=-1
12790 StartMenuSeperator3%=-1
12800ENDIF
12810
12820REMPROCerror("MenuPtr = "+STR$~(currentmenuptr%)+CHR$0)
12830next%=0
12840numberofitems%=0
12850
12860REM Get number of items in current directory localdir$
12870WHILE (next%<>-1)
12880$string%=dir$+CHR$0
12890SYS "OS_GBPB",10,string%,dblock%,1,next%,63,"*" TO ,,,number%,next%
12900IF next%<>-1 THEN
12910 numberofitems%+=1
12920 item$=FNgetname(dblock%+&14)
12930 REM Discount this menu item if its a ~~ item and advanced
12940 REM menus disabled.
12950 IF (GlobalShowBootMenuFlag%=0 AND MID$(item$,1,1)=CHR$(SysFilePrefix%) AND MID$(item$,2,1)=CHR$(SysFilePrefix%)) THEN numberofitems%-=1
12960ENDIF
12970ENDWHILE
12980
12990
13000REM PROCerror("Directory size = "+STR$(numberofitems%)+CHR$0)
13010
13020dirlist%(linkdepth%)=numberofitems%
13030nextmenuptr%=currentmenuptr%+(28+((numberofitems%+addwrite%)*24))
13040dirptr%(linkdepth%+1)=nextmenuptr%
13050
13060locali%=i%
13070REM Build titleless menu
13080REM title$="Menu "+STR$(currentdir%)+CHR$0
13090title$=dirfilename$+CHR$0
13100IF (linkdepth%=1) THEN
13110 IF (LEFT$(dirfilename$,1)=CHR$(SysFilePrefix%)) THEN
13120 IF (MID$(dirfilename$,2,1)<>CHR$(SysFilePrefix%)) THEN
13130 title$=RIGHT$(dirfilename$,LEN(dirfilename$)-1)+CHR$0
13140 ENDIF
13150 IF (MID$(dirfilename$,2,1)=CHR$(SysFilePrefix%)) THEN
13160 title$=RIGHT$(dirfilename$,LEN(dirfilename$)-2)+CHR$0
13170 ENDIF
13180 ENDIF
13190ENDIF
13200
13210TitlePtr%=currentmenuptr%
13220$TitlePtr%=title$
13230width%=(LEN(title$)-2)*16
13240currentmenuptr%!12 = &00070207
13250currentmenuptr%!20=44
13260currentmenuptr%!24=0
13270ptr%=currentmenuptr%+28
13280
13290next%=0
13300GlobalMenuItemCount%=0
13310GlobalMenuSepCount%=0
13320NumberOfLinks%=numberofitems%
13330
13340WHILE (next%<NumberOfLinks% AND DirScan%=TRUE)
13350KeepMenuItem%=TRUE
13360ValidLoadFlag%=TRUE
13370UseLargeSprite%=FALSE
13380SYS "OS_GBPB",10,dir$,dblock%,1,next%,63,"*"
13390next%+=1
13400locali%=i%
13410REM Get Object type (2 = directory, 1 = file)
13420type% = dblock%?&10
13430REM Get name of this object
13440item$=FNgetname(dblock%+&14)
13450REM Get file attributes
13460filetypeinfo%= !dblock% >>> 20
13470filetype%=(!dblock% >> 8)AND &FFF
13480
13490REM Initialise menu object
13500!ptr%=8:REM mflags = &80=LastMenuItem &8=WarnSubmenuOpen
13510ptr%!4=-1:REM pointer to sub menu
13520REM Store this filer object, whatever it is
13530!(shortcutmenudata%+(locali%*64)+32+28) = type%
13540
13550REM Is this object a directory?
13560IF (type% =2) THEN
13570 REM If so, then add to directory list
13580 $(shortcutmenudata%+(locali%*64)+32) = itemsprite$+CHR$0
13590 ptr%!4 = nextmenuptr%:REM Pointer to submenu
13600 ELSE
13610 REM This is a link and not a directory
13620 REM PROCerror("Processing "+item$+CHR$0)
13630 REM Get filetype of link object
13640 $string%=FNGetLinkContents(dir$+"."+item$)+CHR$0
13650
13660 IF (FNCheckValidDrive(FNstring(string%)) =1) THEN
13670 SYS "OS_File",17,string% TO objecttype%,,linkloadaddr%
13680 linktype%=(linkloadaddr%>>8) AND &FFF
13690 linktypeinfo%= linkloadaddr% >>> 20
13700 ELSE
13710 objecttype%=0
13720 ENDIF
13730 REMPROCerror(FNGetLinkContents(dir$+"."+item$)+" is a "+STR$(linktypeinfo%)+CHR$0)
13740 IF (objecttype%=0) THEN
13750 REM PROCerror("Error : Link("+FNGetLinkContents(dir$+"."+item$)+") not found."+CHR$0)
13760 REM Delete this link and rescan the directory
13770 REM Safety first - ensure this file is actually a link in
13780 REM case the <Xuenbs$Dir> system variable has become corrupt (!)
13790 IF (filetype%=&af3) THEN
13800 REM PROCerror("Invalid link "+dir$+"."+item$+" has been found and will be deleted when you click OK."+CHR$0)
13810 OSCLI("delete "+dir$+"."+item$+CHR$0)
13820 DirScan%=FALSE
13830 ValidLoadFlag%=FALSE
13840 ELSE
13850 PROCerror("Error: Another prog has altered the <Xuenbs$Dir> system variable or someone has placed a non-link "+dir$+"."+item$+" into the links directory. Rerun the !Xuen application or remove the offending file from the !Xuen.Links directory."+CHR$0)
13860 ENDIF
13870 ENDIF
13880
13890 IF (objecttype%=1) THEN
13900 REM This link is a pointer to a file
13910 REM PROCerror(FNstring(string%)+" is a file"+CHR$0)
13920 $(shortcutmenudata%+(locali%*64)+32) = "Ssmall_"+STR$~(linktype%)+";"+itemsprite$+CHR$0
13930 IF NOT(FNSpriteExist("small_"+STR$~linktype%)) THEN
13940 REM Small icon don't exist - use large type and flag it so.
13950 $(shortcutmenudata%+(locali%*64)+32) = "Sfile_"+STR$~(linktype%)+";"+itemsprite$+CHR$0:UseLargeSprite%=TRUE
13960 ENDIF
13970
13980 ENDIF
13990
14000 REM For some wierd reason the following two variables must
14010 REM be evaluated outside of the objecttype test. I think
14020 REM it must be something to do with the pipeline and/or a
14030 REM bug in the BASIC rom.
14040 shriek%=ASC("!")
14050 namestart%=ASC(LEFT$(item$,1))
14060 IF (objecttype%=2) THEN
14070 REM This link is a pointer to an application or directory
14080 IF (namestart%<>shriek%) THEN
14090 $(shortcutmenudata%+(locali%*64)+32) = "Ssmall_dir;"+itemsprite$+CHR$0
14100 ELSE
14110 $(shortcutmenudata%+(locali%*64)+32) = "Ssm"+item$+";"+itemsprite$+CHR$0
14120 IF NOT(FNSpriteExist("sm"+item$)) THEN
14130 REM Small icon don't exist - use large type and flag it so.
14140 $(shortcutmenudata%+(locali%*64)+32) = "S"+item$+";"+itemsprite$+CHR$0:UseLargeSprite%=TRUE
14150 ENDIF
14160 ENDIF
14170 ENDIF
14180
14190ENDIF
14200
14210REM Build rest of menu item attributes
14220ptr%!8=&7000313:REM icon type
14230REM IF (type%=2 AND objecttype%=0) ptr%!8=&7400313:REM Invalid
14240IF (addlink%=1) THEN
14250 ptr%!8=&3000313
14260ENDIF
14270IF (UseLargeSprite%) ptr%!8 = (ptr%!8)+&800
14280$(shortcutmenudata%+(locali%*64))=item$+CHR$0
14290ptr%!12 = shortcutmenudata%+(locali%*64)
14300ptr%!16 = shortcutmenudata%+(locali%*64)+32
14310ptr%!20 = 28:REM menu item string buffer = 28 bytes
14320
14330REM Are we dealing with any ~ or ~~ filenames ?
14340IF (linkdepth%=0 AND MID$(item$,1,1)=CHR$(SysFilePrefix%)) THEN
14350
14360 REM Single ~ prefix filenames
14370 IF (MID$(item$,2,1)<>CHR$(SysFilePrefix%)) THEN
14380 IF (StartMenuSeperator%<0) THEN
14390 StartMenuSeperator%=locali%
14400 REM Does this item need a dotted line above it?
14410 IF (locali%>0) THEN
14420 !(ptr%-24)=(!(ptr%-24)) + 2
14430 GlobalMenuSepCount%+=1
14440 ENDIF
14450 ENDIF
14460 REMIF (locali%>=StartMenuSeperator% AND StartMenuSeperator%>=0)
14470 $(shortcutmenudata%+(locali%*64))=RIGHT$(item$,LEN(item$)-1)+CHR$0
14480 REM StartMenuSeperator2%=locali%+1
14490 ENDIF
14500
14510 REM Double ~ prefix filenames
14520 IF (MID$(item$,2,1)=CHR$(SysFilePrefix%)) THEN
14530 IF (GlobalShowBootMenuFlag%=0) THEN
14540 KeepMenuItem%=FALSE
14550 ELSE
14560 IF (StartMenuSeperator2%<0) THEN
14570 StartMenuSeperator2%=locali%
14580 REM Does this item need a dotted line above it?
14590 IF (locali%>0)
14600 !(ptr%-24)=(!(ptr%-24)) + 2
14610 GlobalMenuSepCount%+=1
14620 ENDIF
14630 ENDIF
14640 REM IF (locali%>=StartMenuSeperator2% AND StartMenuSeperator2%>=0)
14650 $(shortcutmenudata%+(locali%*64))=RIGHT$(item$,LEN(item$)-2)+CHR$0
14660 StartMenuSeperator3%=locali%+1
14670 ENDIF
14680 ENDIF
14690
14700ENDIF:REM End of 'Are we dealing with ...
14710
14720IF (KeepMenuItem%) THEN
14730 a%=(LEN(item$)+4)*16
14740 IF a%>width% width%=a%
14750 ptr%+=24
14760 i%+=1
14770 GlobalMenuItemCount% +=1
14780ENDIF
14790ENDWHILE
14800
14810REM Do we need to add an extra writeable icon on end of menu?
14820IF (addwrite%) THEN
14821 locali%=i%
14830 item$="New"
14840 !ptr%=4+&80:REM mflags = &80=LastMenuItem &4=Writeable
14850 ptr%!4=-1:REM pointer to sub menu
14852 ptr%!8 = &7200111:REM icon type
14870 $(shortcutmenudata%+(locali%*64))=item$+CHR$0
14871 $(shortcutmenudata%+(locali%*64)+32)=CHR$0
14880 ptr%!12 = shortcutmenudata%+(locali%*64)
14890 ptr%!16 = shortcutmenudata%+(locali%*64)+32
14900 ptr%!20 = 28:REM menu item string buffer = 28 bytes
14901 a%=(LEN(item$)+4)*16
15060 IF a%>width% width%=a%
15070 ptr%+=24
15080 i%+=1
15090 GlobalMenuItemCount% +=1
15091 numberofitems%+=1
15110ENDIF
15120
15130REM Has this list got anything in it?
15140IF (numberofitems%>0) THEN
15150!(ptr%-24)= (!(ptr%-24) OR&88):REM Set last menu item
15160ELSE
15170width%=(LEN(title$)-2)*16
15180REM Make default first entry be greyed out label 'empty'
15190item$="Empty"+CHR$0
15200$(shortcutmenudata%+(locali%*64)+32) = itemsprite$+CHR$0
15210!ptr%=&88:REM mflags = &80 means last menu item 8=IssueWarn
15220ptr%!4=-1:REM pointer to sub menu
15230ptr%!8=&3000313:REM grey colour SELECTABLE icon type (Add link)
15240$(shortcutmenudata%+(locali%*64))=item$
15250$(ptr%+12)=item$
15260ptr%!12 = shortcutmenudata%+(locali%*64)
15270ptr%!16 = shortcutmenudata%+(locali%*64)+32
15280ptr%!20 = 28:REM menu item string buffer = 28 bytes
15290a%=(LEN(item$)+4)*16
15300IF a%>width% width%=a%
15310i%+=1
15320GlobalMenuItemCount%+=1
15330ENDIF
15340currentmenuptr%!16=width%
15350
15360REM End of directory scanning
15370UNTIL DirScan%=TRUE
15380dirlist%(linkdepth%)=numberofitems%
15390
15400REM IF (dirlist%(linkdepth%)=0) dirlist%(linkdepth%)=1
15410SYS"Hourglass_Off"
15420ENDPROC
15430
15440REM *************************************************
15450REM A Submenu is about to open
15460REM *************************************************
15470DEFPROCsubmenu_warning
15480LOCAL ptr%,localdir$,depth%,index%,selection%,leaf$,i%
15490LOCAL prefix$
15500localdir$=AppPath$+".Users."+User$+".Links"
15510
15520REM Navigate menu index data to determine where we are
15530depth%=0
15540index%=0
15550ptr%=block%+32
15560WHILE !((block%+32)+(depth%*4)) <> -1
15570selection%=!((block%+32)+(depth%*4))
15580leaf$=FNstring(shortcutmenudata%+((index%+selection%)*64))
15590REM Is this a system directory name?
15600i%=selection%
15610IF (depth%=0) THEN
15620 prefix$=""
15630 IF (i%>=StartMenuSeperator% AND StartMenuSeperator%>=0) prefix$=CHR$(SysFilePrefix%)
15640 IF (i%>=StartMenuSeperator2% AND StartMenuSeperator2%>=0) prefix$=CHR$(SysFilePrefix%)+CHR$(SysFilePrefix%)
15650 IF (i%>=StartMenuSeperator3% AND StartMenuSeperator3%>=0) prefix$=""
15660 leaf$=prefix$+leaf$
15670ENDIF
15680
15690localdir$=localdir$+"."+leaf$
15700index%+=dirlist%(depth%)
15710depth%+=1
15720ENDWHILE
15730PROCSingleDirectoryRead(localdir$,leaf$,depth%, 0)
15740SYS"Wimp_CreateSubMenu",,block%!20,block%!24,block%!28
15750ENDPROC
15760
15770REM *****************************************************
15780REM Recursive Directory boot
15790REM *****************************************************
15800DEFPROCRecurseDirectory(localdir$, recurseaction%)
15810LOCAL dir$, next%,type%, item$, objectcount%, currentdir%,filetype%
15820LOCAL number%,LD%
15830LOCAL linktype%,linkdir$
15840dir$=localdir$
15850next%=0
15860WHILE next%<>-1 AND NOT(quit%)
15870
15880SYS "OS_GBPB",12,dir$,bootblock%,1,next%,63,"*" TO ,,,number%,next%
15890REM Get Object type (2 = directory, 1 = file)
15900type% = bootblock%?&10
15910filetype% = bootblock%!20
15920REM Get name of this object
15930item$=FNgetname(bootblock%+24)
15940REM Has this directory got anything in it?
15950IF (next%<>-1) THEN
15960 REM Is this a directory (ie type=2)
15970 IF (type%=2) THEN
15980 PROCRecurseDirectory(dir$+"."+item$, recurseaction%)
15990 ELSE
16000 REM Must be a link to a file or application
16010 REM What type of thing does this link point to?
16020 REM PROCerror("Opening "+dir$+CHR$0)
16030 LD%=OPENIN(dir$+"."+item$+CHR$0)
16040 linkdir$=""
16050 REPEAT
16060 LD$=CHR$(BGET#LD%)
16070 IF (ASC(LD$)>31) linkdir$+=LD$
16080 UNTIL ASC(LD$)<32 OR EOF#LD%
16090 CLOSE#LD%
16100 REM What type is the linkdir?
16110 $bootstring%=linkdir$+CHR$0
16120 IF (FNCheckValidDrive(linkdir$) =1) THEN
16130 SYS "XOS_File",5,bootstring% TO linktype%
16140 IF (LEFT$(item$,1)="!" OR linktype%<>2) THEN
16150 REM Must be either a file or app or dir so let's boot it
16160 REM If directory, only boot if begin with a ! (Save time)
16170 IF (recurseaction%=RECURSE_BOOT%) THEN
16180 $clistring = "Filer_Boot "+linkdir$+CHR$0
16190 SYS "XOS_CLI", clistring
16200 ENDIF
16210 IF (recurseaction%=RECURSE_RUN%) THEN
16220 $clistring = "Filer_Run "+linkdir$+CHR$0
16230 SYS "XOS_CLI", clistring
16240 ENDIF
16250 ENDIF
16260 ELSE
16270 REM Remove this link
16280 IF (filetype%=&af3) THEN
16290REM PROCerror("Deleting "+dir$+"."+item$+CHR$0)
16300 OSCLI("delete "+dir$+"."+item$+CHR$0)
16310 ENDIF
16320
16330 ENDIF
16340 ENDIF
16350ENDIF
16360
16370REM Enable user to carry on during bootup and
16380REM trap any unwanted links that are generated at bootup
16390PROCpoll
16400PROCpoll
16410PROCpoll
16420
16430ENDWHILE
16440ENDPROC
16450
16460REM ***********************************************
16470
16480DEFFNCheckValidDrive(isvpath$)
16490LOCAL fs_drive$, pptr%, char$, a%
16500REM Check that isvpath$ resides on a valid file system
16510REM and a valid drive.
16520REM If not then return 0 else return 1
16530pptr%=1
16540fs_drive$=""
16550REPEAT
16560char$=MID$(isvpath$,pptr%,1)
16570IF (char$<>".") fs_drive$=fs_drive$+char$
16580pptr%=pptr%+1
16590UNTIL (pptr%>LEN(isvpath$) OR char$=".")
16600REM Check fs_drive$ with all currently invalid devices
16610a%=0
16620WHILE(a%<InvalidDriveCount%)
16630IF (fs_drive$=InvalidDrive$(a%)) a%=InvalidDriveCount%+1
16640a%+=1
16650ENDWHILE
16660REM return if it matches an invalid drive
16670IF (a%>InvalidDriveCount%) THEN =0
16680REM Is this device valid?
16690$clistring=fs_drive$+CHR$0
16700SYS"XOS_File",5,clistring TO result%
16710IF (result%<=8192) THEN
16720 REM This is a valid drive
16730 =1
16740ENDIF
16750REM Update list of invalid drives
16760InvalidDrive$(InvalidDriveCount%) = fs_drive$
16770InvalidDriveCount%+=1
16780=0
16790
16800REM ***************************************
16810REM Return first line of the given file
16820REM ***************************************
16830DEFFNGetLinkContents(glinkfilename$)
16840LOCAL linkdir$,LD%
16850 LD%=OPENIN(glinkfilename$+CHR$0)
16860 linkdir$=""
16870 REPEAT
16880 LD$=CHR$(BGET#LD%)
16890 IF (ASC(LD$)>31) linkdir$+=LD$
16900 UNTIL ASC(LD$)<32 OR EOF#LD%
16910 CLOSE#LD%
16920 =linkdir$
16930
16940REM **************************************
16950REM Click on shortcut menu list
16960REM **************************************
16970DEFPROCshortcutmenuselect
16980LOCAL currentmenuptr%,lastmenuptr%,dir$,linkdir$,dropdir$,currentdropdir$,leaf$
16990LOCAL droppardir$,parent$
17000LOCAL ReOpenFlag%
17010LOCAL IconFlagsAddr%
17020LOCAL prefix$,IsLinkDirectory%,IsGreyedOut%
17030LOCAL LeftAlt%, RightAlt%,ThisIsWriteable%,RebuildLastSubMenu%
17040LOCAL AddWriteableFlag%
17050
17060AddWriteableFlag%=0
17070IsGreyedOut%=0
17080IsLinkDirectory%=0
17090LeftAlt%=0:RightAlt%=0:ThisIsWriteable%=0:RebuildLastSubMenu%=0
17100IF INKEY-6 LeftAlt%=1
17110IF INKEY-9 RightAlt%=1
17120
17130REM PROCerror("Clicked on shortcut menu - blaj"+CHR$0)
17140
17150ReOpenFlag%=FALSE
17160dir$=AppPath$+".Users."+User$+".Links"
17170dropdir$=dir$
17180droppardir$=dir$
17190parent$=User$
17200leaf$=User$
17210currentdropdir$=dir$
17220currentmenuptr%=shortcutmenu%
17230lastmenuptr%=currentmenuptr%
17240globalmenuptr%=shortcutmenu%
17250REM block%+00 is selection number of menu,
17260nestlevel%=0
17270sel1%=block%!nestlevel%
17280
17290REM Recurse menu directory pointers until selection found
17300REPEAT
17310selection%=block%!(nestlevel%*4)
17320nextselection%=block%!((nestlevel%+1)*4)
17330REMPROCerror("Menu Selection = "+STR$(selection%)+CHR$0)
17340REM Get pointer to icon definition from menu definition
17350submenuptr%=!(currentmenuptr%+28+(selection%*24)+4)
17360dataptr%=!(currentmenuptr%+28+(selection%*24)+12)
17370parent$=leaf$
17380leaf$=FNstring(dataptr%)
17390ItemFlags% = !(currentmenuptr%+28+(selection%*24))
17400REM Is this a system file name? not writeable ... )
17410IF (nestlevel%=0 AND (ItemFlags% AND 4)=0) THEN
17420 prefix$=""
17430 IF (selection%>=StartMenuSeperator% AND StartMenuSeperator%>=0) prefix$=CHR$(SysFilePrefix%)
17440 IF (selection%>=StartMenuSeperator2% AND StartMenuSeperator2%>=0) prefix$ = CHR$(SysFilePrefix%)+CHR$(SysFilePrefix%)
17450 IF (selection%>=StartMenuSeperator3% AND StartMenuSeperator3%>=0) prefix$ = ""
17460 leaf$=prefix$+leaf$
17470ENDIF
17480REM Construct path to object
17490currentdropdir$=dropdir$
17500IF (selection%<>-1) THEN
17510 dir$=dir$+"."+leaf$
17520 IF (nextselection%<>-1) THEN
17530 droppardir$=droppardir$+"."+leaf$
17540 IF (submenuptr%<>-1) lastmenuptr%=submenuptr%
17550 ELSE
17560 REM nextselection=-1 so Must be at selected item of last menu
17570 IF (submenuptr%<>-1) IsLinkDirectory%=1
17580 IconFlagsAddr%=currentmenuptr%+28+8+(selection%*24)
17590 IF (!IconFlagsAddr%=&3000313) IsGreyedOut%=1:REM PROCerror("Is greyed out!"+CHR$0)
17600 ENDIF
17610 nestlevel%+=1
17620 REM Is this menu entry a pointer to a submenu?
17630 IF (submenuptr%<>-1) THEN
17640 dropdir$=dropdir$+"."+leaf$
17650 currentmenuptr%=submenuptr%
17660 ENDIF
17670ENDIF
17680UNTIL nextselection%=-1
17690submenuptr%=!(currentmenuptr%+28+(selection%*24)+4)
17700nestlevel%-=1
17710
17720REMPROCerror("Clicked on "+leaf$+"["+STR$nestlevel%+"] in directory "+droppardir$+CHR$0)
17730REM Is this menu item writeable?
17740REM If so, create a new directory out of the "writings"
17750ItemFlags% = !(lastmenuptr%+28+(selection%*24))
17760IF ((ItemFlags% AND 4)=4) THEN
17770REM PROCerror("Selection:"+STR$selection%+" At level:"+STR$nestlevel%+" Writable ... ItemFlags="+STR$~ItemFlags%+CHR$0)
17780 REM Create new directory
17790 OSCLI("CDIR "+dropdir$+"."+leaf$+CHR$0)
17800 REM Rebuild last sub menu
17810 RebuildLastSubMenu%=1
17820 ReOpenFlag%=TRUE
17830
17840 ELSE
17850
17860 IF (addlink%=1) THEN
17870 REM PROCerror("Adding shortcut["+newlinkleaf$+"] into "+dropdir$+CHR$0)
17880 PROCaddnewshortcut(currentdropdir$,newlinkfile$,newlinkleaf$)
17890 REM Rebuild last sub menu
17900 RebuildLastSubMenu%=1
17910 ReOpenFlag%=TRUE
17920 ENDIF
17930
17940 IF (addlink%=0) THEN
17950 REM Should we insert a writeable something into this menu?
17960 IF (LeftAlt%<>0) THEN
17970REM PROCerror("Inserting a writeable icon into level:"+STR$nestlevel%+CHR$0)
17980 AddWriteableFlag%=1
17990 RebuildLastSubMenu%=1
18000
18210 ReOpenFlag%=TRUE
18220 ENDIF
18230
18240 REM Is the Right ALT key pressed?
18250 REM If so delete this link LALT(-6) RALT(-9) L/R ALT(-3)
18260 IF (RightAlt%<>0 AND IsLinkDirectory%=0 AND IsGreyedOut%=0) THEN
18270 REM PROCerror("Deleting link "+dir$+CHR$0)
18280 OSCLI("delete "+dir$+CHR$0)
18290 REM Alter menu structure
18300 IconFlagsAddr%=currentmenuptr%+28+8+(selection%*24)
18310 !IconFlagsAddr% = (!IconFlagsAddr%)+(2^22):REM Grey out sprite
18320 !IconFlagsAddr% = !IconFlagsAddr% AND &ffffff:REM Grey out
18330 !IconFlagsAddr% = !IconFlagsAddr%+&1000000:REM text
18340 REM RebuildLastSubMenu%=1
18350 ReOpenFlag%=1
18360 ENDIF
18370
18380 REM Should we delete this directory of links?
18390 IF (RightAlt%<>0 AND IsLinkDirectory%=1 AND IsGreyedOut%=0) THEN
18400 REM PROCerror("Deleting directory "+dir$+CHR$0)
18410 $string% = "delete "+dir$+CHR$0
18420 SYS "XOS_CLI",string% TO ; ErrorFlag%
18430 IF (ErrorFlag% AND 1) PROCerror("Error removing "+dir$+". The directory may not be empty."+CHR$0)
18440 REMOSCLI("delete "+dir$+CHR$0)
18450 REM Alter menu structure
18460 IconFlagsAddr%=currentmenuptr%+28+8+(selection%*24)
18470 REM PROCerror("Flags:"+STR$~(!IconFlagsAddr%)+CHR$0)
18480 REM !IconFlagsAddr% = (!IconFlagsAddr%)+(2^22):REM Grey sprite
18490 REM !IconFlagsAddr% = !IconFlagsAddr% AND &ffffff:REM Grey out
18500 REM !IconFlagsAddr% = !IconFlagsAddr%+&1000000:REM text
18510 RebuildLastSubMenu%=1
18520 ReOpenFlag%=1
18530 ENDIF
18540
18550 REM Is this runnable?
18560 REM PROCerror("submenu="+STR$submenuptr%+" Dir?:"+STR$IsLinkDirectory%+CHR$0)
18570 IF (LeftAlt%=0 AND RightAlt%=0 AND IsLinkDirectory%=0 AND IsGreyedOut%=0) THEN
18580 REM Get the desktop filer to run this link
18590 dir$="Filer_Run "+FNGetLinkContents(dir$)
18600 REM PROCerror("* "+dir$+CHR$0)
18610 REM PROCerror("OSCLI "+dir$+CHR$0)
18620 OSCLI(dir$+CHR$0)
18630 ENDIF
18640 ENDIF:REM IF adlink%=0 ...
18650ENDIF:REM IF writeable ...
18660
18670REM Check if ADJUST pressed in which case, reprint menus.
18680SYS"Wimp_GetPointerInfo",,block2%
18690button%=block2%!8
18700IF button%=1 ReOpenFlag%=TRUE
18710
18720IF (RebuildLastSubMenu%) THEN
18730REM PROCerror("Rebuilding submenu '"+parent$+"' from "+droppardir$+" at Depth="+STR$(nestlevel%)+CHR$0)
18740PROCSingleDirectoryRead(droppardir$,parent$,nestlevel%,AddWriteableFlag%)
18750ENDIF
18760
18770IF (ReOpenFlag%) THEN
18780 PROCshowmenu(shortcutmenu%,0,0)
18790 ELSE
18800 IconBarMenuOpen%=0:REM Reenable icon bar tooltip
18810ENDIF
18820ENDPROC
18830
18840DEFPROCclick_info(button%)
18850CASE button% OF
18860WHEN 2:CurrentMenuType%=MainMenuType%:PROCshowmenu(main_menu%,!block%-64, (block%!4)+32)
18870ENDCASE
18880ENDPROC
18890
18900DEFPROCwindowmenuselect(WindowMenuIndex%)
18910LOCAL OpenWin%, ErrorFlag%, button%
18920LOCAL WinMenuItemFlag%, Action%
18930REM block%+00 is selection number of first menu,
18940REM block%+04 is selection number of second level etc.
18950REMsel1%=!block%:sel2%=block%!4
18960sel1%=WindowMenuIndex%
18970SYS"Wimp_GetPointerInfo",,block%
18980button%=block%!8
18990REM PROCerror("["+STR$sel1%+"] Opening "+$(shortcutmenudata%+(sel1%*64))+CHR$0)
19000OpenWin%=!(shortcutmenudata%+(sel1%*64)+60)
19010!winopenblock%=OpenWin%
19020SYS"XWimp_GetWindowState",,winopenblock% TO ; ErrorFlag%
19030IF (ErrorFlag%<>0) THEN
19040 winopenblock%!28=-1
19050 Action%=0:REM Open Window
19060 IF (INKEY-1) Action%=1:REM Open parent (SHIFT)
19070 REM IF (INKEY-3) Action%=2:REM Close (ALT)
19080
19090 IF (Action%=0) THEN
19100 SYS "XWimp_SendMessage",2, winopenblock%,OpenWin%
19110 ENDIF
19120
19130 IF (Action%=1) THEN
19140 SYS "XWimp_SendMessage",3, winopenblock%,OpenWin%
19150 ENDIF
19160
19170 IF (Action%=2) THEN
19180 !winopenblock%=OpenWin%
19190 SYS "XWimp_CloseWindow",,winopenblock%
19200 REM Grey out this menu entry
19210 WinMenuItemFlag% = !(shortcutmenu%+28+(sel1%*24)+8)
19220 WinMenuItemFlag% = WinMenuItemFlag% OR &400000
19230 !(shortcutmenu%+28+(sel1%*24)+8) = WinMenuItemFlag%
19240 ENDIF
19250
19260ENDIF
19270
19280REM Check if ADJUST pressed in which case, reprint menus.
19290IF button%=1 THEN
19300PROCshowmenu(shortcutmenu%,0,0)
19310CurrentMenuType% = WindowListMenuType%
19320ELSE
19330REM SYS"Wimp_CreateMenu",,-1
19340IconBarMenuOpen%=0:REM Reenable icon bar tooltip
19350ENDIF
19360
19370ENDPROC
19380
19390DEFPROCmainmenuselect
19400REM block%+00 is selection number of first menu,
19410REM block%+04 is selection number of second level etc.
19420sel1%=!block%:sel2%=block%!4
19430SYS"Wimp_GetPointerInfo",,block%
19440button%=block%!8
19450CASE sel1% OF
19460WHEN 0:PROCOpenInfoBox
19470WHEN 1:PROCClickToolMenu(sel2%)
19480WHEN 2:PROCerror("Sorry, TODO."+CHR$0):REM PROCClickUserMenu
19490WHEN 3:PROCClickHelpButton
19500WHEN 4:PROCToggleAdvancedMenus
19510WHEN 5:PROCcascade
19520WHEN 6:PROCShowTree
19530WHEN 7:quit%=TRUE
19540ENDCASE
19550REM Check if ADJUST pressed in which case, reprint menus.
19560IF button%=1 THEN
19570PROCshowmenu(main_menu%,0,0)
19580ELSE
19590IconBarMenuOpen%=0:REM Reenable icon bar tooltip
19600ENDIF
19610ENDPROC
19620
19630DEFPROCClickHelpButton
19640OSCLI("Filer_Run <xuenbs$dir>.!help")
19650ENDPROC
19660
19670DEFPROCClickToolMenu(sel2%)
19680CASE sel2% OF
19690WHEN 0:PROCclear
19700WHEN 1:PROCsmash
19710WHEN 2:PROCOpenLinks
19720WHEN 3:PROCSaveSpritePools
19730ENDCASE
19740ENDPROC
19750
19760DEFPROCSaveSpritePools
19770OSCLI("Filer_Run "+AppPath$+".Resources.GetSprites"+CHR$0)
19780ENDPROC
19790
19800DEFPROCsmash
19810OSCLI("Filer_Run "+AppPath$+".Resources.SmashClose"+CHR$0)
19820ENDPROC
19830
19840DEFPROCOpenLinks
19850OSCLI("Filer_Opendir "+AppPath$+".Users."+User$+".Links"+CHR$0)
19860ENDPROC
19870
19880DEFPROCshowmenu(menu%,mx%,my%)
19890SYS"Wimp_CreateMenu",,menu%,mx%,my% TO currentmenuhandle%
19900ENDPROC
19910
19920REM ***************************************************
19930
19940DEFPROCShowTree
19950!block% = whandle_tree%
19960block%!4 = 64
19970block%!8 = 64
19980block%!12 = 1024
19990block%!16 = 912
20000block%!20 = 0
20010block%!24 = 0
20020block%!28 = -1
20030SYS"Wimp_OpenWindow",,block%
20040
20050REM PROCerror("Sorry, TODO."+CHR$0)
20060ENDPROC
20070
20080REM ***************************************************
20090
20100DEFPROCToggleAdvancedMenus
20110LOCAL flag%
20120GlobalShowBootMenuFlag% = GlobalShowBootMenuFlag% EOR 1
20130flags%=!(main_menu%+28+(4*24))
20140flags% = flag% EOR (GlobalShowBootMenuFlag%<<0)
20150REM PROCerror("Flags = "+STR$~(flags%)+CHR$0)
20160!(main_menu%+28+(4*24))=flags%
20170ENDPROC
20180
20190REM ***************************************************
20200
20210
20220REM Tell WIMP to initialise a new menu.
20230REM This should really be done by loading in a MENU template.
20240DEFPROCsetupmenu(menu%)
20250READ title$,num%:$menu%=title$
20260width%=(LEN(title$)-2)*16
20270menu%!12=&00070207:menu%!20=44:menu%!24=0
20280ptr%=menu%+28:FOR i%=1TOnum%
20290READ mflags%,subptr%,item$
20300!ptr%=mflags%:ptr%!4=subptr%
20310ptr%!8=&7000021:$(ptr%+12)=item$
20320a%=(LEN(item$)+1)*16
20330IF a%>width% width%=a%
20340ptr%+=24:NEXT
20350menu%!16=width%
20360ENDPROC
20370
20380REM ***************************************************
20390
20400DEFPROCinit
20410REM Do ~~Open and ~~Close files exist? If not, create empty
20420REM copies of them to prevent !Start crashing.
20430
20440PROCensuredir(AppPath$+".Users")
20450PROCensuredir(AppPath$+".Users."+User$)
20460PROCensuredir(AppPath$+".Users."+User$+".Links")
20470PROCensuredir(AppPath$+".Users."+User$+".Links")
20480PROCensuredir(AppPath$+".Users."+User$+".Links.~~Boot")
20490PROCensuredir(AppPath$+".Users."+User$+".Links.~~Run")
20500PROCensuredir(AppPath$+".Users."+User$+".Links.~~RunQuit")
20510
20520$string%=AppPath$+".Users."+User$+".~~Open"
20530SYS"OS_File",17,string% TO result%
20540IF (result%=0) THEN X%=OPENOUT(AppPath$+".Users."+User$+".~~Open"):CLOSE#X%
20550$string%=AppPath$+".Users."+User$+".~~Close"
20560SYS"OS_File",17,string% TO result%
20570IF (result%=0) THEN X%=OPENOUT(AppPath$+".Users."+User$+".~~Close"):CLOSE#X%
20580
20590SYS "Wimp_Initialise",200,&4B534154,app$ TO current_wimp_version%,task_handle%
20600
20610REM Create INFO window
20620!infodata% = 0: infodata%!4 = 0
20630infodata%!8 = 642: infodata%!12 = 212
20640infodata%!16 = 0: infodata%!20 = 0
20650infodata%!24 = -1:REM Top
20660infodata%!28 = 1+2+16+64
20670infodata%!32 = &01090207
20680infodata%!36 = &000C0103
20690infodata%!40 = 0: infodata%!44 = 0
20700infodata%!48 = 642: infodata%!52 = 212
20710infodata%!56 = %111000000000000000000011001
20720infodata%!60 = 0
20730infodata%!64 = 1
20740infodata%!68 = 0
20750$(infodata%+72) = "Info"
20760infodata%!84=0:REM No icons yet ...
20770REM Create INFO icon block ...
20780tptr%=infodata%+88
20790tptr% = FNAddIcon(8,164, 642-156,40, "Xuen",tptr%,infodata%+84,0)
20800tptr% = FNAddIcon(8,112, 642-156,40, "Desktop Tool",tptr%,infodata%+84, 0)
20810tptr% = FNAddIcon(8,60, 642-156,40, "Barny Short", tptr%, infodata%+84, 0)
20820tptr% = FNAddIcon(8,8, 642-156,40, appversion$+" May-98", tptr%, infodata%+84, 0)
20830tptr% = FNAddIcon(642-136,8, 128,212-16,"!xuen",tptr%,infodata%+84,1)
20840SYS"Wimp_CreateWindow",,infodata% TO whandle_info%
20850
20860
20870REM Create TREE window
20880!infodata% = 0: infodata%!4 = 0
20890infodata%!8 = FilerViewW%: infodata%!12 = FilerViewH%
20900infodata%!16 = 0: infodata%!20 = 0
20910infodata%!24 = -1:REM Top
20920infodata%!28 = 1+2+16+64+(1<<2)+(1<<3)
20930infodata%!32 = &01090207
20940infodata%!36 = &000C0103
20950infodata%!40 = 0: infodata%!44 = 0
20960infodata%!48 = FilerViewW%: infodata%!52 = FilerViewH%
20970infodata%!56 = %111000000000000000000011001
20980infodata%!60 = 0
20990infodata%!64 = 1
21000infodata%!68 = 0
21010$(infodata%+72) = "Filer Tree"
21020infodata%!84=0:REM No icons yet ...
21030REM Create INFO icon block ...
21040tptr%=infodata%+88
21050tptr% = FNAddIcon(144,(FilerViewH%/4)*3, 642-156,40, "A",tptr%,infodata%+84,0)
21060tptr% = FNAddIcon(144,(FilerViewH%/4)*2, 642-156,40, "B",tptr%,infodata%+84, 0)
21070tptr% = FNAddIcon(144,FilerViewH%/4, 642-156,40, "C", tptr%, infodata%+84, 0)
21080tptr% = FNAddIcon(144,8, 642-156,40, "D", tptr%, infodata%+84, 0)
21090tptr% = FNAddIcon(8,8, 128,212-16,"!xuen",tptr%,infodata%+84,1)
21100SYS"Wimp_CreateWindow",,infodata% TO whandle_tree%
21110
21120
21130
21140REM Create toolbox menu
21150RESTORE 21360
21160PROCsetupmenu(tool_menu%)
21170REM Create main menu
21180RESTORE 21260
21190PROCsetupmenu(main_menu%)
21200REM Install an icon on the icon bar using the shortcut icon
21210iconbarhandle%=FNcreate_icon(-2,0,-16,84,106,&1700310B,"!xuen",iconbarlabel%,iconbardata%,32)
21220ENDPROC
21230
21240REM ***************************************************
21250
21260DATA "Xuen",8
21270DATA 0,whandle_info%,"Info"
21280DATA 0,tool_menu%,"Toolbox"
21290DATA 0,-1,"User"
21300DATA 0,-1,"Help"
21310DATA 0,-1,"Advanced"
21320DATA 0,-1,"Cascade"
21330DATA 2,-1,"Tree"
21340DATA &80,-1,"Quit"
21350
21360DATA "Toolbox",4
21370DATA 0,-1,"Clean"
21380DATA 0,-1,"SmashnClose"
21390DATA 0,-1,"Edit Links"
21400DATA &80,-1,"SaveSprites"
21410
21420REM ********************************************************
21430
5� ***********************************************
� Name : Xuen
5� Purpose : Make RiscOS Desktop more efficient(!)
(� Author : Barny Short
2� Date : 30-May-1998
<5� ***********************************************
Fappversion$="11.0"
P5� ***********************************************
Z
dGlobalErrorState%=0
n>RandomToolTip%=1:� Enable(=1)/Disable(=0) random tool tips
x'� � �error(�$+" at line "+Þ):�#0:�
�
��ON ERROR GOTO@@@@
�
�%ț "<Obey$Dir>.Resources.Libs.OS"
�(ț "<Obey$Dir>.Resources.Libs.Filer"
�'ț "<Obey$Dir>.Resources.Libs.Wimp"
�*ț "<Obey$Dir>.Resources.Libs.Tooltip"
�
� PictureType%=&d94:� Artworks
�,DocumentType%=&bc5:� Impression Document
�.User$="Admin":� Default User name is Admin
�
�app$="Xuen"
AppPath$=""
AppDate$=""
/� apppath 255, apppathvar 32, appdatevar 32
"*$appdatevar="<Sys$Time> <Sys$Date>"+�0
,!$apppathvar="<Xuenbs$Dir>"+�0
6
@8� Aquire the start path to use for delete operations
J)È™"OS_GSTrans",apppathvar,apppath,255
TAppPath$=�string(apppath)
^
h
r@� errorblock% 2048, block% 2048, block2% 2048, clistring 255
|J� winblock% 2048, winopenblock% 2048, transblock% 2048, ptrblock% 2048
�� unknownstring% 32
�&$unknownstring% = "unknown_app"+�0
�
�� InvalidDrive$(255)
�InvalidDriveCount%=0
�
�-� dragspritename% 256, boundspritebox% 32
�
�
� � Auto link buffer add stuff
�alba_destinationdir$=""
�-alba_type%=-1:� -1 means nothing in cache
�alba_newlinkfile$=""
alba_newlinkleaf$=""
alba_time%=0
&CACHE_SIZE% = 4096
0pause% = 200
:open_type%=1
Dclose_type%=2
Nadd_window%=1
Xsubtract_window%=2
bdrag_type%=5
l
adjust%=1
vmenu%=2
�
select%=4
�iconbarhandle%=0
�dircount%=0
�linkloadaddr%=0
�objecttype%=0
�linkmenu%=0
�addlink%=0
�)iconbar_timer%=�:iconbar_timerflag%=0
�2whandle_tooltip%=0:ToolTip%=0:tooltip_timer%=0
�%override_tooltip%=0:OldToolTip%=0
�whandle_tree%=0
�internalstackposition%=-2
�oldstackposition%=0
currentwindow%=0
currentmenuhandle%=0
firstmenuhandle%=-3
IconBarMenuOpen%=0
*StartMenuSeperator%=-1
4StartMenuSeperator2%=-1
>StartMenuSeperator3%=-1
HSysFilePrefix%=126
RBottomEdgeFlag=0
\after%=0
fwhandle_dummyback%=0
pLastRightEdge%=0
zCascadeRow%=0
�CurrentButton%=0
�tptr%=0
�
�� Filer tree related stuff
�FilerViewW% = 642
�FilerViewH% = 512
�
�GlobalMenuItemCount%=0
�GlobalMenuSepCount%=0
�GlobalToolTip$=""
�GlobalState% = 0
�GlobalStatePreBoot% = 0
�GlobalStatePostBoot% = 1
GlobalStateIdle% = 2
GlobalStateShutDown% = 3
GlobalStep% = 0
$GlobalShowBootMenuFlag%=0
.RECURSE_BOOT% = 1
8RECURSE_RUN% = 2
B
L0� Insert your choice of random tooltips here
V3RandTipMax%=5:� Total number of random tooltips
`� RandTip$(RandTipMax%)
jDRandTip$(1)="If it's getting complicated, you're doing it wrong"
t-RandTip$(2)="You use computers too much!"
~ RandTip$(3)="Hablo espanol!"
�.RandTip$(4)="Have you read Dilbert today?"
�!RandTip$(5)="Take your vits!"
�
�IconBarAnimSize%=6
�$� IconBarAnim$(IconBarAnimSize%)
�IconBarAnim$(0)="Sxuen0"
�IconBarAnim$(1)="Sxuen30"
�IconBarAnim$(2)="Sxuen60"
�IconBarAnim$(3)="Sxuen90"
�IconBarAnim$(4)="Sxuen120"
�IconBarAnim$(5)="Sxuen150"
�IconBarAnimStep=0
IconBarAnimDir=0.5
WindowListIcon%=-1
WindowListTimer%=0
(
2MaxWindowListSize%=64
<WindowListSize%=0
F)� WindowListName$(MaxWindowListSize%)
P+� WindowListHandle%(MaxWindowListSize%)
Z
dCurrentMenuType%=0
nMainMenuType% = 0
xWindowListMenuType% = 1
�ShortCutMenuType% = 2
�
�MenuIsOpenFlag%=0
�
�Q� dblock% 1024, bootblock% 1024, shortcutmenu% 16000, shortcutmenudata% 20384
�U� main_menu% 256, tool_menu% 256, typebuf% 256, iconbarlabel% 32, iconbardata% 32
�Y� string% 1024, bootstring% 1024, infodata% 2048, tooltipdata% 2048, tooltipicon% 512
�� cache% CACHE_SIZE%
�� dirlist%(32), dirptr%(32)
�
�cache_ext%=0
�task_handle%=0
�drag_button%=adjust%
DX%=0
drag_icon%=0
path$=""
"in_leftregion=�
,in_rightregion=�
6qf_timer=�
@regionxs%=16
Jregionys%=64
T$iconbarlabel%=""+�0
^$iconbardata%="S!xuen"+�0
h globalmenuptr%=shortcutmenu%
r
|$$iconbardata%=IconBarAnim$(0)+�0
�
�
�9� ***************************************************
�
�quit%=�
�
�ș"Hourglass_On"
� �init
�.� PROCerror("Xuen path = "+AppPath$+CHR$0)
��GetScreenSize
��CreateToolTip
��loadcache
�ș"Hourglass_Off"
?� If ALT is pressed then skip auto booting/loading anything
� �(�-3) �
&O �RecurseDirectory(AppPath$+".Users."+User$+".Links.~~Boot", RECURSE_BOOT%)
0X � �(quit%) �RecurseDirectory(AppPath$+".Users."+User$+".Links.~~Run", RECURSE_RUN%)
:& GlobalState%=GlobalStatePostBoot%
DS � �(quit%) �RecurseDirectory(AppPath$+".Users."+User$+".Links", RECURSE_BOOT%)
N�
X
b!GlobalState%=GlobalStateIdle%
l
vȕ � quit%
� �poll
��
�
�"� Ensure all buffers are empty
��alba_purge(0)
�%GlobalState%=GlobalStateShutDown%
�'� Reset quit to enable another quit
�0� during program shutdown to be detected ...
�quit%=�
�P�RecurseDirectory(AppPath$+".Users."+User$+".Links.~~RunQuit", RECURSE_RUN%)
��DestroyToolTip
�ș "Wimp_CloseDown"
��
� Error handler
!�error(�$+" at line "+Þ):�#0
GlobalErrorState%+=1
* � GlobalErrorState%=1 � �thG
4 � GlobalErrorState%=2 � �dnG
>5� Multiple errors have occured - die ungracefully
H�
R
\9� ***************************************************
f
p
��GetDate
z� Aquire date and time
�)ș"OS_GSTrans",appdatevar,apppath,255
�AppDate$=�string(apppath)
��
�
�9� ***************************************************
�
�� poll loop
�
��poll
�$ș"Wimp_Poll",0,block% � reason%
�2� IF reason%<>0 PROCerror(STR$(reason%)+CHR$0)
�Ȏ reason% �
�� 0:�null_reason
�� 2:�PollReason2
%� 3:ș "Wimp_CloseWindow",,block%
� 6:�click(block%!12)
� 7:�dragdrop
$�WHEN 8:PROCkeypressed
.� 9:�menuselect
8� 17,18:�receive(reason%)
B9� WHEN 19:PROCerror("Unsupported window definition.")
L�
V�
`
j9� ***************************************************
t
~��PollReason2
�� ((!block%) >= OS_MX%) �
�X� PROCerror("Window tobeopened:"+STR$~(!block%)+" behind: "+STR$~(block%!28)+CHR$0)
� ș "Wimp_OpenWindow",,block%
��
�.�currentwindow%=!block%:PROCOpenToolTip(2)
�A� This is very wierd - the windowhandle is invalid and equals
�?� the mouse pointer x position - must be a menu I reckon or
�� could be a bug in RISCOS.
�MenuIsOpenFlag%=1
��
�
��
��GetScreenSize
3ș"OS_ReadModeVariable",-1,4 � ,,OS_EX%:� Eigen
+ș"OS_ReadModeVariable",-1,5 � ,,OS_EY%
(3ș"OS_ReadModeVariable",-1,11 � ,,OS_WX%:� Size
2,ș"OS_ReadModeVariable",-1,12 � ,,OS_WY%
<OS_MX%=(1+OS_WX%) << OS_EX%
FOS_MY%=(1+OS_WY%) << OS_EY%
P�
Z
d�DEFPROCkeypressed
n�LOCAL Char%
x�Char%=block%!24
�=�IF Char%=&1CD PROCerror("Insert pressed on icon "+CHR$0)
�-�REM Is this the delete or backspace key?
�#�IF (Char%=8 OR Char%=&7f) THEN
��REM Is this in a menu?
�^�PROCerror("Window handle = "+STR$~(block%!0)+" -- main_menu% = "+STR$~(main_menu%)+CHR$0)
� �ELSE
� �SYS "Wimp_ProcessKey",Char%
�
�ENDIF
��ENDPROC
�
���ReopenDummyWindow
� !block2%=whandle_dummyback%
�% ș"Wimp_GetWindowState",,block2%
% block2%!8=-1024:block2%!16=-1024
block2%!28=-2
" È™"Wimp_OpenWindow",,block2%
" after%=whandle_dummyback%
, � MenuIsOpenFlag%=0
6
@
J WindowListSize%=0
T�
^
h
��cascade
r� q%,OldAfter%,after%
|� sx%, sy%, ox%, oy%
�)� ReopenFlag%, StackFlag%, ValidFlag%
�-� PaneFlag%, IsOpenFlag%, IsMoveableFlag%
�� CurrentWin%,CurrentIcon%
�� n%
�
��BuildWindowList
�
�cascade%=0
�LastRightEdge%=0
�CascadeRow%=0
�
�$ș"Wimp_GetPointerInfo",,block2%
�CurrentWinPtr%=block2%!12
CurrentIcon%=block2%!16
� WindowListSize%=0 �
&
0�n%=0 � (WindowListSize%-1)
: q%=winblock%
D PaneFlag%=�
N3 � Get Current window immediately under pointer
X( CurrentWin% = WindowListHandle%(n%)
b !q%=CurrentWin%
l. � Try and cascade this desktop window ...
v! È™ "Wimp_GetWindowState",,q%
�
�
q%!28=-1
�
� � Reposition window
� PaneFlag%=�
�2 � (((q%!32) � ((2^22)+(2^23)))>0) PaneFlag%=�
�& � (((q%!32) � 32)=32) PaneFlag%=�
�% IsOpenFlag% = ((q%!32) � (2^16))
�$ IsMoveableFlag% = ((q%!32) � 2)
�
� ReopenFlag%=�
� StackFlag%=�
� ValidFlag%=�
� (StackFlag%=�) �
ox%=q%!4
oy%=q%!16
* sx%=(q%!12)-(q%!4)
4 sy%=(q%!16)-(q%!8)
>
H< � Try and fit as many windows horizontally as possible
R, � ((LastRightEdge%+sx%)<(OS_MX%-40)) �
\ q%!4=LastRightEdge%
f0 q%!16=(OS_MY%-40)-(CascadeRow%*40):� 1160
p q%!12=(q%!4)+sx%
z0 � ((q%!12)>(OS_MX%-40)) q%!12=(OS_MX%-40)
� q%!8=(q%!16)-sy%
� � ((q%!8)<40) q%!8=40
� LastRightEdge%=(q%!12)+48
� �
� LastRightEdge%=0
� CascadeRow%+=1
� q%!4=(CascadeRow%*8)
�0 q%!16=(OS_MY%-40)-(CascadeRow%*40):� 1160
� q%!12=(q%!4)+sx%
�0 � ((q%!12)>(OS_MX%-40)) q%!12=(OS_MX%-40)
� q%!8=(q%!16)-sy%
� � ((q%!8)<40) q%!8=40
� LastRightEdge%=(q%!12)+48
�
3 � Having allowed space for this window in the
$3 � window cascade, are we sure we want to move
. � it just yet?
8 � (ReopenFlag%=�) �
B. È™ "XWimp_SendMessage",2,q%,CurrentWin%
L �
V cascade%+=1
` �:� End of IF StackFlag ...
j� n%
t�
~
�3� *********************************************
�3� * Animate the icon bar icon *
�3� *********************************************
���AnimateIconBar
�/$iconbardata%=IconBarAnim$(IconBarAnimStep)
�#IconBarAnimStep+=IconBarAnimDir
�>� (IconBarAnimStep<0 � IconBarAnimStep=IconBarAnimSize%) �
�IconBarAnimStep=0
�)� IconBarAnimDir = IconBarAnimDir*-1
�%� IconBarAnimStep+=IconBarAnimDir
��
�3� Activate an update on the task bar icon .....
!block2%=-2
block2%!4=iconbarhandle%
"È™"Wimp_GetIconState",,block2%
(block2%!8=0:� Don't change anything,
(,block2%!12=0:� Just signal an update ...
2<� Insert the relevant word depending on system state ...
<?� (GlobalState%<GlobalStateIdle%) $iconbarlabel%="Zz..."+�0
FM� (GlobalState%=GlobalStateIdle%) $iconbarlabel%=" "+�0:� User$+CHR$0
PC� (GlobalState%=GlobalStateShutDown%) $iconbarlabel%="Bye.."+�0
ZGlobalStep%+=1
d"È™"Wimp_SetIconState",,block2%
n�
x
�3� *********************************************
�� Idle WIMP poll
�3� *********************************************
���null_reason
�#� window%,icon%,wlicon%,button%
�
�&ș"Wimp_GetPointerInfo",,ptrblock%
�X%=ptrblock%!0
�Y%=ptrblock%!4
�button%=ptrblock%!8
�window%=ptrblock%!12
�icon%=ptrblock%!16
�currentwindow%=window%
A� (CurrentMenuType% = WindowListMenuType% � (button% �7)>0) �
0 � (window%=currentmenuhandle% � icon%>=0) �
" wlicon% = icon% �3
,$ � (wlicon%<>WindowListIcon%) �
61 WindowListIcon%=wlicon%:WindowListTimer%=�
@ �
J$ � (�>(WindowListTimer%+200)) �
T � Open this window
^! �windowmenuselect(wlicon%)
h6� IF ((button% AND7)=4) SYS"Wimp_CreateMenu",,-1
rN � PROCerror("Icon handle = "+STR$(icon% DIV3)+" ("+STR$icon%+")"+CHR$0)
| WindowListIcon%=-1
� �
�
� �
� WindowListIcon%=-1
� �
� �
� WindowListIcon%=-1
��
�
�%� Purge the buffer once every 10s
��alba_purge(1000)
��AnimateIconBar
�%� (ToolTip%=1) �UpdateToolTipTime
(� This may be needed to stop flicker
� *fx19
&=� (((ptrblock%!12)=-2 � (ptrblock%!16=iconbarhandle%))) �
0�move_overiconbar
:�
DOldToolTip%=0
N
X9�IF (((TIME-tooltip_timer%)>100) AND ToolTip%>0) THEN
b� (ToolTip%>0) �
l=� (ptrblock%!16 <> whandle_tooltip%) iconbar_timerflag%=0
v�CloseToolTip
��
��iconbar_timer%=TIME
�iconbar_timerflag%=0
��
��
�
�I� ((X%>regionxs% � X%<(OS_MX%-regionxs%)) � Y%>regionys%) �outoffocus
�� (Y%=0) �
�. � (BottomEdgeFlag=0) �pointeronbottomedge
� �
� BottomEdgeFlag=0
��
�
�
9� ***************************************************
*��pointeronbottomedge
4� stackposition%
>"� Make iconbar at top of stack
HBottomEdgeFlag=1
RÈ™"Wimp_ProcessKey",&1dc
\�
f
p��pointernotoniconbar
zG� (ToolTip%=0 � (ToolTip%<>0 � currentwindow%<>whandle_tooltip%)) �
�: � firstmenuhandle%=-2 firstmenuhandle%=currentwindow%
��
�
�!block%=-2
�#ș"Wimp_GetWindowState",,block%
�stackposition%=block%!28
�+� (stackposition%<>oldstackposition%) �
�@� (currentwindow%<>firstmenuhandle% � firstmenuhandle%>-2) �
�ș"Wimp_ProcessKey",&1dc
�firstmenuhandle%=-3
�!block%=-2
�#ș"Wimp_GetWindowState",,block%
�stackposition%=block%!28
$oldstackposition%=stackposition%
�
�
$�
.
8
B��outoffocus
L(� (in_leftregion) � �leaveleftregion
V*� (in_rightregion) � �leaverightregion
`qf_timer=�
j�
t
~��leaveleftregion
�in_leftregion=�
��
�
���leaverightregion
�in_rightregion=�
��
�
���focusdelay
�6� ((�-pause%)>qf_timer) � qf_timer=-1:�OpenInfoBox
��
�
���left_corner
,� (in_leftregion=�) ec_timer=�:ec_flag=�
in_leftregion=�
#� Check if windows need opening
$� (�-ec_timer>=50 � ec_flag=�) �
(�reopenfiler:ec_flag=�
2�
<
F�
P
Z��right_corner
d-� (in_rightregion=�) ec_timer=�:ec_flag=�
nin_rightregion=�
x#� Check if windows need closing
�3�IF (TIME-ec_timer>=100 AND ec_flag=FALSE) THEN
�� (ec_flag=�) �
�'�closefiler:�CloseInfoBox:ec_flag=�
��
��
�
�9� ***************************************************
�
���OpenInfoBox
�
�
�
�!block%=whandle_info%
#È™"Wimp_GetWindowState",,block%
È™"Wimp_OpenWindow",,block%
�
"
,��CloseInfoBox
6!block%=whandle_info%
@ È™"Wimp_CloseWindow",,block%
J�
T
^9� ***************************************************
h
r��init_drag(icon%)
|qf_timer=-1
�#ș"Wimp_GetPointerInfo",,block%
�ox%=block%!0
�oy%=block%!4
�block%!4=icon%
�drag_icon%=icon%
�block%!4=drag_type%
�block%!8=ox%-32
�block%!12=oy%-32
�block%!16=ox%+32
�block%!20=oy%+32
�block%!24=&80000000
�block%!28=&80000000
�block%!32=&7FFFFFFF
block%!36=&7FFFFFFF
È™"Wimp_DragBox",,block%
&� Start a sprite drag ....
03� (icon%=add_window%) $dragspritename%="yes"+�0
:7� (icon%=subtract_window%) $dragspritename%="no"+�0
D!boundspritebox%=0
Nboundspritebox%!4=0
Xboundspritebox%!8=ox%+24
bboundspritebox%!12=oy%+24
lFÈ™"DragASprite_Start",2+8+64+128,1,dragspritename%,boundspritebox%
v�
�
���dragdrop
�#ș"Wimp_GetPointerInfo",,block%
�block%!20=block%!12
�block%!24=block%!16
�block%!28=!block%
�block%!32=block%!4
�block%!36=0
�!block%=64:block%!12=0
�block%!16=1:block%!40=&fff
�$(block%+44) =""
�6ș"Wimp_SendMessage",18,block%,block%!20,block%!24
�
"� Cancel a sprite drag .......
È™"DragASprite_Stop"
�
*6� ************************************************
4-� function to deal with incoming messages
>6� ************************************************
H��receive(reason%)
Rmessage%=block%!16
\4� PROCerror("Message : &"+STR$~(message%)+CHR$0)
fȎ message% �
p� 0:quit%=�
z�� 3:�data_load_add_link:� PROCerror("DataLoad:"+FNstring(block%+44)+" Leafname:"+FNGetLeafName(block%+44)+" Type:&"+STR$~(!(block%+40))+CHR$0)
�� 2:�data_ack
�� 5:�data_open
�� 10:�desktop_ack
�� &502:�service_help
�� &400C0:�submenu_warning
�� &400C1:�GetScreenSize
�� &400C9:IconBarMenuOpen%=0
��
��
�
���service_help
�block%!12 =block%!8
�block%!16=&503
!block%=256
� (block%!32 = -2) �
� $(block%+20) ="\TXuen icon.|M\Sshow shortcuts.|MClick MENU to show options.|M\Ashow currently open window list.|MDrag and drop an icon onto the Xuen icon to install it into the shortcuts menu.|M"+�0
$, È™"Wimp_SendMessage",17,block%,block%!4
.�
87 $(block%+20) ="This is the Xuen application.|M"+�0
B, È™"Wimp_SendMessage",17,block%,block%!4
L
V�
`
j&� IF (block%!32 = main_menu%) THEN
t*� (CurrentMenuType% = MainMenuType%) �
~�� $(block%+20) ="'Advanced' option enables the boot configuration to be changed from the shortcut menu.|M'Toolbox' has some useful little programming tools such as saving the ROM and RAM spritefiles to the current directory.|M"+CHR$0
�.� SYS"Wimp_SendMessage",17,block%,block%!4
��
��
�
�=� *******************************************************
�+� User has double clicked on a fileicon
�=� Response - store a link to this file in the ~ directory
�=� *******************************************************
���data_open
�� type%, destinationdir$
�$� Flush cache if stuff in it ...
�8� (alba_type%>0 � alba_type%<>4096) � �alba_purge(0)
(alba_newlinkfile$=�string(block%+44)
-alba_newlinkleaf$=�GetLeafName(block%+44)
type%=!(block%+40)
(alba_type%=type%
2,� PROCerror("Type = "+STR$(type%)+CHR$0)
<6destinationdir$=AppPath$+".Users."+User$+".Links."
F
P
Z� (type%=4096) �
d!� Store this directory access
n?destinationdir$=destinationdir$+�(SysFilePrefix%)+"Folders"
x�
�
�� (type%=8192) �
�#� Store this application access
�@destinationdir$=destinationdir$+�(SysFilePrefix%)+"Programs"
��
�
�� (type%<4096) �
� � (type%=DocumentType%) �
�A destinationdir$=destinationdir$+�(SysFilePrefix%)+"Document"
� �
�
� � (type%=PictureType%) �
�@ destinationdir$=destinationdir$+�(SysFilePrefix%)+"Picture"
�
5 � (type%<>PictureType% � type%<>DocumentType%) �
"> destinationdir$=destinationdir$+�(SysFilePrefix%)+"Files"
, �
6�
@
J(alba_destinationdir$=destinationdir$
Talba_time%=�
^
h=� Ignore all links generated during the preboot/run stage
r"� GlobalState%=0 alba_type%=-1
|�
�
���autoaddnewshortcut
�� autodropdirectory$
�#� number%, next%,numberofitems%
�>� oldestdate%,oldestname$,oldesttype%,oldestnext%,oldnext%
�� delstring$
�-autodropdirectory$ = alba_destinationdir$
�"�ensuredir(autodropdirectory$)
�4� Auto insert directorys have a limit of 9 items
�� Is link directory empty?
�numberofitems%=0
�next%=0
�oldestdate%=0
&ȕ(next%<>-1 � numberofitems%<=16)
"$string%=autodropdirectory$+�0
oldnext%=next%
&Eș "OS_GBPB",11,string%,dblock%,1,next%,63,"*" � ,,,number%,next%
0� next%<>-1 �
:numberofitems%+=1
D|� ((dblock%!24)<oldestdate% � oldestdate%=0) oldestdate%=dblock%!24:oldestname$=�string(dblock%+29):oldestnext%=oldnext%
N�
X�
b� (numberofitems%<9) �
l& � If so then automatically insert
vL �addnewshortcut(autodropdirectory$,alba_newlinkfile$,alba_newlinkleaf$)
��
�+ � Intelligently delete an old file and
� � Get filetype of this file
�# $string%=autodropdirectory$+�0
�9 ș "OS_GBPB",12,string%,dblock%,1,oldestnext%,63,"*"
� oldesttype%=dblock%!20
�^ � PROCerror("Oldest file to remove : "+oldestname$+" of type "+STR$~(oldesttype%)+CHR$0)
�- � Delete the oldest link in this dir ...
�5 � Final check - Only allow delete on &af3 files.
� � (oldesttype%=&af3) �
�< delstring$="delete "+autodropdirectory$+"."+oldestname$
�4 � PROCerror("about to OSCLI "+delstring$+CHR$0)
� �(delstring$+�0)
� insert a new one ...
L �addnewshortcut(autodropdirectory$,alba_newlinkfile$,alba_newlinkleaf$)
�
�
*alba_type%=-1
4�
>
H2� Prompt user to select directory for new link
R��data_load_add_link
\*� path$,leaf$,type%,leafptr%,linkname$
f � (�CheckLinksDirExists=0) �
ppath$=�string(block%+44)
z!leaf$=�GetLeafName(block%+44)
�type%=!(block%+40)
�6linkname$=AppPath$+".Users."+User$+".Links."+leaf$
�newlinkleaf$=leaf$
�#newlinkfile$=�string(block%+44)
�� Is link directory empty?
�1$string%=AppPath$+".Users."+User$+".Links"+�0
�;ș "OS_GBPB",10,string%,dblock%,1,0,63,"*" � ,,,number%
�� number%=0 �
�4� If so then automatically add to root directory
�P�addnewshortcut(AppPath$+".Users."+User$+".Links",newlinkfile$,newlinkleaf$)
��
��showshortcutmenu(1)
��
�
,� Add new link to the shortcut directory
$F��addnewshortcut(dropdirectory$,add_newlinkfile$,add_newlinkleaf$)
.1� linkname$,leafptr%,IgnoreLink%,Index%,Char%
81linkname$=dropdirectory$+"."+add_newlinkleaf$
B $string%=add_newlinkfile$+�0
LC�PROCerror("Contents of "+linkname$+"="+add_newlinkfile$+CHR$0)
Vleafptr%=string%
`<� Check for any illegal characters in filename and if so
j(� ignore the generation of this link
tIgnoreLink%=�
~"�Index%=0� �(add_newlinkleaf$)
�(Char%=�(�add_newlinkleaf$,Index%,1))
�� Char%=�"$" � Char%=�"." �
� IgnoreLink%=�
��
��
�� IgnoreLink%=� �
�9 � Check to see if this file already exists and if so
� � prompt for overwrite.
� X%=�(linkname$+�0)
� ȕ((?leafptr%) > 31)
� �#X%, ?leafptr%
� leafptr%+=1
�
' �#X%, 10:� Output a terminating LF
�#X%
� Set type appropriately
(& �("SetType "+linkname$+" af3"+�0)
2�
<�
F
P��alba_purge(expiry%)
Z� (alba_type%<0) � �
d.� (expiry%>0 � (alba_time%+expiry%)>�) � �
n�autoaddnewshortcut
x�
�
�9� ***************************************************
�&� Window and iconbar click handler
�&� See below for menu click handler
�8� **************************************************
���click(win%)
�
Ȏ win% �
�!� -2:�click_iconbar(block%!8)
�)� whandle_info%:�click_info(block%!8)
��
��
�
�8� **************************************************
� Menu click handler
8� **************************************************
��menuselect
"Ȏ CurrentMenuType% �
,#� MainMenuType%:�mainmenuselect
6+� ShortCutMenuType%:�shortcutmenuselect
@4� WindowListMenuType%:�windowmenuselect(!block%)
J�
T�
^
h9� ***************************************************
r
|��click_iconbar(button%)
�CurrentButton%=button%
�Ȏ button% �
�� 0:�move_overiconbar
�� 1:�click_iconbaradjust
�� 2:�click_iconbargeneral
�� 4:�click_iconbarselect
��
��
�
���click_iconbargeneral
�%� ToolTip%=1 �PersistCloseToolTip
�#ș"Wimp_GetPointerInfo",,block%
�override_tooltip%=1
;IconBarMenuOpen%=1:� Inhibit tool tip display over menu
*� (CurrentButton%=1) �showwindowmenu:�
(� (CurrentButton%=2) �showmainmenu:�
&0� (CurrentButton%=4) �showshortcutmenu(0):�
0�
:
D
N��click_iconbarselect
X� (�-1) � (�-2) �
b � Open cache windows
l �reopenfiler
v �
��
�
� (�-2) �
�! � Start drag to add a window
�$ ș"Wimp_GetPointerInfo",,block%
�) � (block%!8) �init_drag(add_window%)
� �
� � Click menu
� �click_iconbargeneral
��
��
�
���click_iconbaradjust
�� (�-1) � (�-2) �
!� Close cache windows
!�closefiler:�CloseInfoBox
!�
! �
!*
� (�-2) �
!4#È™"Wimp_GetPointerInfo",,block%
!>#� Start drag to remove a window
!H-� (block%!8) �init_drag(subtract_window%)
!R�
!\�click_iconbargeneral
!f�
!p�
!z
!�8� **************************************************
!�!� Pointer is over the iconbar
!�8� **************************************************
!���move_overiconbar
!�-� IconBarMenuOpen%=1 iconbar_timerflag%=0
!�;� Is pointer over iconbar icon? If so inc iconbar_timer
!�X� (iconbar_timerflag%=0 � IconBarMenuOpen%<>1) iconbar_timerflag%=1:iconbar_timer%=�
!�I� (((�-iconbar_timer%)>25) � iconbar_timerflag%=1 � OldToolTip%<>1) �
!� � What sort of tool tip?
!� RSeed%=�(-�)
!�
!� � (RandomToolTip%=1) �
!� � (�(5)=1) �
"+ �OpenToolTip(2):iconbar_timerflag%=2
" �
"+ �OpenToolTip(1):iconbar_timerflag%=2
"$ �
". �
"8+ �OpenToolTip(1):iconbar_timerflag%=2
"B �
"L�
"V
"`7� Is user dragging over icon bar icon with a button
"j� pressed for over 2 s ?
"tY%=ptrblock%!4
"~O� (((�-iconbar_timer%)>200) � IconBarMenuOpen%=0 � ((ptrblock%!8 �7)>0) ) �
"�& � ToolTip%=1 �PersistCloseToolTip
"� override_tooltip%=1
"�< IconBarMenuOpen%=1:� Inhibit tool tip display over menu
"� � �-3 �
"� �showshortcutmenu(0)
"� �
"� � Close all other menus
"� � SYS"Wimp_CreateMenu",,-1
"� �showwindowmenu
"� �
"��
"�
# -� Has tool tip been open for long enough?
#
X� (((�-iconbar_timer%)>1000) � ToolTip%>0) �PersistCloseToolTip:iconbar_timerflag%=0
#�
#
#(
#28� **************************************************
#<
#FݤCheckLinksDirExists
#P� dir$,result%
#Z*dir$=AppPath$+".Users."+User$+".Links"
#d%� Does the Links directory exist?
#n$string%=dir$+�0
#x$ș"OS_File",17,string% � result%
#�� If not, create one.
#�&� (result%=0) � �("CDIR "+dir$+�0)
#�$ș"OS_File",17,string% � result%
#�'� Has it created it? If not, error.
#�� (result%=0) �
#�.�error("Fatal : Couldn't create "+dir$+�0)
#�=0
#��
#�=1
#�
#�8� **************************************************
#�
#���showmainmenu
$$CurrentMenuType% = MainMenuType%
$2�showmenu(main_menu%,!block%-64, 96+(8*44)+24)
$�
$"
$,8� **************************************************
$60� Build list of currently valid open windows
$@8� **************************************************
$J��BuildWindowList
$T� q%,OldAfter%
$^� sx%, sy%, ox%, oy%
$h)� ReopenFlag%, StackFlag%, ValidFlag%
$r-� PaneFlag%, IsOpenFlag%, IsMoveableFlag%
$|� CurrentWin%,CurrentIcon%
$�%� WindowName$, ErrorFlag%,Windex%
$�
$�q%=winblock%
$�PaneFlag%=�
$�WindowName$=""
$�
$�*� Start from bottom of window stack by
$�0� opening the dummy window at the bottom ...
$��ReopenDummyWindow
$�
$�2� Get Current window immediately under pointer
$�$ș"Wimp_GetPointerInfo",,block2%
$�CurrentWinPtr%=block2%!12
%CurrentIcon%=block2%!16
%
%after%=whandle_dummyback%
%&
%0 � Go through all windows ...
%:�
%DOldAfter%=after%
%N!q%=after%
%X.� _Try_ and reopen this desktop window ...
%b/ș "XWimp_GetWindowState",,q% � ;ErrorFlag%
%lCurrentWin%=!q%
%v&� (after%=-1 � (ErrorFlag%�1)=1) �
%�
Windex%=0
%��
%�9� (CurrentWin%=WindowListHandle%(Windex%)) Windex%=-2
%�Windex%+=1
%�*� Windex%>=WindowListSize% � Windex%<0
%�after%=q%!28
%�
%� PaneFlag%=�
%�2 � (((q%!32) � ((2^22)+(2^23)))>0) PaneFlag%=�
%�& � (((q%!32) � 32)=32) PaneFlag%=�
%�% IsOpenFlag% = ((q%!32) � (2^16))
%�$ IsMoveableFlag% = ((q%!32) � 2)
%�
& ReopenFlag%=�
& StackFlag%=�
& ValidFlag%=�
&
&*< � If this window is not at all on screen then ignore it
&4! � OS_M? = ?X|Y ScreenOS?Size
&> ox%=q%!4:ttox%=ox%
&H oy%=q%!16:ttoy%=oy%
&R! sx%=(q%!12)-(q%!4):ttsx%=sx%
&\! sy%=(q%!16)-(q%!8):ttsy%=sy%
&fP� (ox%>OS_MX%) � (oy%>OS_MY%) � ((ox%+sx%)<0) � ((oy%+sy%)<0) � ValidFlag%=�
&p
&z
&�.� Is this the currently open menu window?
&�3� (CurrentWin%=currentmenuhandle%) ValidFlag%=�
&�
&�� Is this the icon bar?
&�*� IF (CurrentWin%=-2) ValidFlag%=FALSE
&�
&�p� Under pointer and _no_ horiz/vert scroll bars and fully visible (likely to be part of menu so leave alone)
&ʀ� (CurrentWin%=CurrentWinPtr% � ((q%!32) � (2^28))=0 � ((q%!32) � (2^30))=0 � ((q%!32) � (2^17))>0 � after%=-1) ValidFlag%=�
&�
&�2 � (CurrentWin%=whandle_tooltip%) ValidFlag%=�
&�! � (PaneFlag%=�) ValidFlag%=�
&�
&� � (ValidFlag%=�) �
'
'. � (WindowListSize%<MaxWindowListSize%) �
'5 WindowListHandle%(WindowListSize%)=CurrentWin%
'$ WindowListSize%+=1
'. �
'8! �:� End of IF ValidFlag% ...
'B
'L� CurrentWin%=-1
'V�
'`
'j
't8� **************************************************
'~� Open the Window List menu
'�8� **************************************************
'���showwindowmenu
'�3� TitleBarFlag%, CurrentWin%, SourceTaskHandle%
'�=� TitleBarPtr%, TitleBarLength%, ErrorFlag%, SuccessFlag%
'�4� Index%,WindowName$,KludgeLength%,IsIndirected%
'�
'�5� currentmenuptr%, locali%, width%, title$, item$
'�� WindowNum%
'�� a%
'�
'�'� (ToolTip%=1) �PersistCloseToolTip
'�ș"Hourglass_On"
( #� Build List of current windows
(
�BuildWindowList
(
(� Build menu
(($initialmenusize%=WindowListSize%
(2#currentmenuptr% = shortcutmenu%
(<title$="Windows"
(FTitlePtr%=currentmenuptr%
(P$TitlePtr%=title$
(Zwidth%=(�(title$)-2)*16
(d"currentmenuptr%!12 = &00070207
(ncurrentmenuptr%!20=44
(xcurrentmenuptr%!24=0
(�ptr%=currentmenuptr%+28
(�
(�� (initialmenusize%>0) �
(� locali%=0
(�, �WindowNum%=(WindowListSize%-1) � 0 �-1
(� � Initialise menu object
(� IsDirect%=0
(�1 !ptr%=8:� mflags = &80 means last menu item
(�% ptr%!4=-1:� pointer to sub menu
(�% ptr%!8=&7000313-512:� icon type
(�1 CurrentWin% = WindowListHandle%(WindowNum%)
(� � Get Task Handle
(� !block2%=0
)S ș"XWimp_SendMessage",0,block2%,CurrentWin% � ,,SourceTaskHandle% ;ErrorFlag%
). � Is this window definition a valid one?
)& SourceTaskName% = unknownstring%
)" � ((ErrorFlag%�1)=0) �
),Z ș"XTaskManager_TaskNameFromHandle",SourceTaskHandle% � SourceTaskName% ;ErrorFlag%
)6: � ((ErrorFlag%�1)=1) SourceTaskName%=unknownstring%
)@ �
)J
)T WindowName$="???"
)^ � ((ErrorFlag%�1)=0) �
)h !block2%=CurrentWin%
)r@ � Get Window Info NB. Set Bit0 of R1 to disable icon info
)|8 ș "Wimp_GetWindowInfo",,block2%+1 � ; ErrorFlag%
)�$ TitleBarFlag% = !(block2%+60)
)�3 � ((TitleBarFlag% � 1) � (ErrorFlag%�1)=0) �
)�" � This title contains text
)�! � (TitleBarFlag% � 256) �
)�# � Title data is indirected
)�% TitleBarPtr% = !(block2%+76)
)�& TitleBarLength%=!(block2%+84)
)� � Major Kludge !!! TODO
)� !block2%=0
)�I ș"Wimp_SendMessage",0,block2%,CurrentWin% � ,,SourceTaskHandle%
)�; � Copy source task data to destination task data
)�v ș"XWimp_TransferBlock",SourceTaskHandle%,TitleBarPtr%,task_handle%,transblock%,TitleBarLength% � ;ErrorFlag%
)�& � Have we got the whole name?
* SuccessFlag%=0
* � TitleBarLength%>0 �
*( �Index%=0� (TitleBarLength%-1)
*&6 � (?(transblock%+Index%)<32) SuccessFlag%=1
*0 �
*:
�
*D? � PROCerror("InDirected name = "+$(transblock%)+CHR$0)
*N
*X � SuccessFlag%=0 �
*b Index%-=1
*l5 � Get rest of title bar (Major Kludge) TODO
*v KludgeLength%=0
*� �
*�x ș"XWimp_TransferBlock",SourceTaskHandle%,TitleBarPtr%+Index%,task_handle%,transblock%+Index%,1 � ;ErrorFlag%
*� Index%+=1
*� KludgeLength%+=1
*�R � ?(TitleBarPtr%+(Index%-1))<32 � ((ErrorFlag%�1)=1) � KludgeLength%>253
*�$ ?(transblock%+Index%) = 13
*�% ?(transblock%+Index%+1) = 0
*� �
*�
*�# TitleBarPtr% = transblock%
*�
�
*� � Is Directed data
*�A � PROCerror("Direct window name = "+$(block2%+76)+CHR$0)
+" TitleBarPtr% = block2%+76
+ TitleBarLength%=12
+ IsDirect%=1
+ $ �:� End of IF is indirected?
+*
+42 � Has the title string got anything in it?
+>2 � (?TitleBarPtr%>=32 � (ErrorFlag%�1)=0) �
+H � (IsDirect%=0) �
+R2 TitleBarString$ = �getname(TitleBarPtr%)
+\= � PROCerror("Aquired title:"+TitleBarString$+CHR$0)
+f �
+p TitleBarString$=""
+z Z%=0
+� �
+� Y%=?(TitleBarPtr%+Z%)
+�; � (Y%>=32) TitleBarString$=TitleBarString$+�(Y%)
+� Z%+=1
+� � Z%>11 � Y%<32
+�
�
+�
+�& WindowName$ = TitleBarString$
+�$ � (�(TitleBarString$)>45) �
+�, WindowName$ = �TitleBarString$, 4)
+�+ WindowName$ = WindowName$ + "..."
+�; WindowName$ = WindowName$ + �TitleBarString$, 38)
+�
�
, �
, � :� End of Has text?
,
,$ item$=WindowName$
,.
,83 $(shortcutmenudata%+(locali%*64)) = item$+�0
,B
,L+ taskname$ = �string(SourceTaskName%)
,V taskiconname$=taskname$
,` � (�(taskname$)>0) �
,j sn=3
,t@ � �taskname$,"Filer")>0 taskiconname$ = "small_dir":sn=0
,~@ � taskname$="unknown_app" taskiconname$="small_app":sn=0
,�@ � taskname$="Task Manager" taskiconname$="switcher":sn=1
,�B � taskname$="Palette Utility" taskiconname$="palette":sn=1
,�; � taskname$="Calculator" taskiconname$="!calc":sn=1
,�< � taskname$="Characters" taskiconname$="!chars":sn=1
,�@ � taskname$="StrongHelp" taskiconname$="!stronghlp":sn=1
,�: � (sn �1)=1 � ptr%!8=&7000B13-512:� half size icon
,�3 � (sn �2)=2 � taskiconname$ = "!"+taskname$
,� �
,�s � PROCerror("Entry:"+item$+" Icon:"+taskiconname$+" Handle:"+STR$(CurrentWin%)+" TaskName:"+taskname$+CHR$0)
,�( � Does taskiconname sprite exist?
,�C � �(�SpriteExist(taskiconname$)) taskiconname$="application"
,�8 � Is taskiconname too long to fit in name buffer?
- : � (�(taskiconname$)>12) taskiconname$="application"
-
� Build rest of item data
-B $(shortcutmenudata%+(locali%*64)+46) = "S"+taskiconname$+�0
-9 !(shortcutmenudata%+(locali%*64)+60) = CurrentWin%
-(/ ptr%!12 = shortcutmenudata%+(locali%*64)
-22 ptr%!16 = shortcutmenudata%+(locali%*64)+46
-<8 ptr%!20 = 46:� menu item string buffer = 46 bytes
-F a%=(�(item$)+4)*16
-P ptr%+=24
-Z locali%+=1
-d � (a%>width%) � width%=a%
-n �
-x initialmenusize%-=1
-� �
-� �
-��
-�.� If menu is empty, define an 'empty' item
-�� initialmenusize%=0 �
-�; � Make default first entry be greyed out label 'empty'
-� initialmenusize%+=1
-� item$="Empty"+�0
-� !ptr%=&80
-�$ ptr%!4=-1:� pointer to sub menu
-�8 ptr%!8=&2400029:� greyed out UNSELECTABLE icon type
-� $(ptr%+12)=item$
-� a%=(�(item$)+4)*16
. � a%>width% width%=a%
.
ptr%+=24
.�
."� Define last item in menu
.,currentmenuptr%!16=width%
.6'!(ptr%-24)=&88:� Set last menu item
.@È™"Hourglass_Off"
.J� Open menu
.T#È™"Wimp_GetPointerInfo",,block%
.^*CurrentMenuType% = WindowListMenuType%
.hWindowListIcon%=-1
.rC�showmenu(shortcutmenu%,!block%-64, 96+((initialmenusize%)*44))
.|�
.�
.�5� ***********************************************
.�� Does Sprite Exist?
.�5� ***********************************************
.�ݤSpriteExist(SpriteName$)
.�$� ROMBase%, RAMBase%, ErrorFlag%
.�/ș "Wimp_BaseOfSprites" � ROMBase%,RAMBase%
.�"$dragspritename% = SpriteName$
.�@ș"XOS_SpriteOp",296,ROMBase%,dragspritename% � ; ErrorFlag%
.�� (ErrorFlag% � 1)=0 � =�
.�@ș"XOS_SpriteOp",296,RAMBase%,dragspritename% � ; ErrorFlag%
.�� (ErrorFlag% � 1)=0 � =�
.�=�
/
/8� **************************************************
/%� Start building the shortcutmenu
/&8� **************************************************
/0��showshortcutmenu(arg%)
/:'� (ToolTip%=1) �PersistCloseToolTip
/Daddlink%=arg%
/N � (�CheckLinksDirExists=0) �
/Xdirptr%(0)=shortcutmenu%
/b'� linkmenudepth%=0:REM At top level
/l
/vL�PROCSingleDirectoryRead(AppPath$+".Users."+User$+".Links", User$, 0, 0)
/�N�SingleDirectoryRead(AppPath$+".Users."+User$+".Links", "ShortCuts", 0, 0)
/� initialmenudottedlinesize%=0
/� initialmenusize%=dirlist%(0)
/�+� initialmenusize%=0 initialmenusize%=1
/�+initialmenusize% = GlobalMenuItemCount%
/�#ș"Wimp_GetPointerInfo",,block%
/�(CurrentMenuType% = ShortCutMenuType%
/�^�showmenu(shortcutmenu%,!block%-64, 96+(GlobalMenuItemCount%*44)+(GlobalMenuSepCount%*24))
/��
/�
/�
/�
/�;� *****************************************************
0;� Read contents of a directory into the menu data areas
0$� storing filename and icon type
0;� *****************************************************
0 G��SingleDirectoryRead(localdir$,dirfilename$,linkdepth%, addwrite%)
0*<� oldlocaldir$,olddirfilename$,oldlinkdepth%, olddirptr%
04� dirsize%, DirScan%
0>-� dir$,next%,type%,item$,currentdir%,ptr%
0H-� currentmenuptr%, locali%, width%,title$
0R(� TitlePtr%, MenuExtent%,itemsprite$
0\B� filetype%, filetypeinfo%,linktype%,objecttype%,linktypeinfo%
0f#� ValidLoadFlag%, KeepMenuItem%
0p%� NumberOfLinks%, UseLargeSprite%
0z
0�ș"Hourglass_On"
0�
0�oldlocaldir$ = localdir$
0�"olddirfilename$ = dirfilename$
0�oldlinkdepth% = linkdepth%
0�"olddirptr%=dirptr%(linkdepth%)
0�DirScan%=�
0�
0�� (addlink%=1) �
0� itemsprite$="Pptr_link"
0� �
0� itemsprite$=""
0��
1
17�:� Repeat until loaded in directory with no errors
1localdir$ = oldlocaldir$
1$"dirfilename$ = olddirfilename$
1.linkdepth% = oldlinkdepth%
18%dirptr%(oldlinkdepth%)=olddirptr%
1BDirScan%=�
1L
1V5� Calculate pointer to shortcutmenu% & index into
1`� shortcutmenudata%
1jdir$=localdir$
1ta%=0
1~!currentmenuptr%=shortcutmenu%
1�i%=0
1�ȕ a%<linkdepth%
1�+currentmenuptr%+=(28+(dirlist%(a%)*24))
1�i%+=dirlist%(a%)
1� a%+=1
1��
1�
1�4� Initialise root menu seperator to be undefined
1�� (linkdepth%=0) �
1� StartMenuSeperator%=-1
1� StartMenuSeperator2%=-1
1� StartMenuSeperator3%=-1
2 �
2
29�PROCerror("MenuPtr = "+STR$~(currentmenuptr%)+CHR$0)
2next%=0
2(numberofitems%=0
22
2<8� Get number of items in current directory localdir$
2FÈ• (next%<>-1)
2P$string%=dir$+�0
2ZEș "OS_GBPB",10,string%,dblock%,1,next%,63,"*" � ,,,number%,next%
2d� next%<>-1 �
2n numberofitems%+=1
2x item$=�getname(dblock%+&14)
2�< � Discount this menu item if its a ~~ item and advanced
2� � menus disabled.
2�v � (GlobalShowBootMenuFlag%=0 � �item$,1,1)=�(SysFilePrefix%) � �item$,2,1)=�(SysFilePrefix%)) � numberofitems%-=1
2��
2��
2�
2�
2�?� PROCerror("Directory size = "+STR$(numberofitems%)+CHR$0)
2�
2�'dirlist%(linkdepth%)=numberofitems%
2�Enextmenuptr%=currentmenuptr%+(28+((numberofitems%+addwrite%)*24))
2�&dirptr%(linkdepth%+1)=nextmenuptr%
2�
3locali%=i%
3� Build titleless menu
3,� title$="Menu "+STR$(currentdir%)+CHR$0
3"title$=dirfilename$+�0
3,� (linkdepth%=1) �
36- � (�dirfilename$,1)=�(SysFilePrefix%)) �
3@1 � (�dirfilename$,2,1)<>�(SysFilePrefix%)) �
3J1 title$=�dirfilename$,�(dirfilename$)-1)+�0
3T �
3^0 � (�dirfilename$,2,1)=�(SysFilePrefix%)) �
3h1 title$=�dirfilename$,�(dirfilename$)-2)+�0
3r �
3| �
3��
3�
3�TitlePtr%=currentmenuptr%
3�$TitlePtr%=title$
3�width%=(�(title$)-2)*16
3�"currentmenuptr%!12 = &00070207
3�currentmenuptr%!20=44
3�currentmenuptr%!24=0
3�ptr%=currentmenuptr%+28
3�
3�next%=0
3�GlobalMenuItemCount%=0
3�GlobalMenuSepCount%=0
4!NumberOfLinks%=numberofitems%
4
4*ȕ (next%<NumberOfLinks% � DirScan%=�)
4&KeepMenuItem%=�
40ValidLoadFlag%=�
4:UseLargeSprite%=�
4D/È™ "OS_GBPB",10,dir$,dblock%,1,next%,63,"*"
4Nnext%+=1
4Xlocali%=i%
4b/� Get Object type (2 = directory, 1 = file)
4ltype% = dblock%?&10
4v� Get name of this object
4�item$=�getname(dblock%+&14)
4�� Get file attributes
4�"filetypeinfo%= !dblock% >>> 20
4�#filetype%=(!dblock% >> 8)� &FFF
4�
4�� Initialise menu object
4�:!ptr%=8:� mflags = &80=LastMenuItem &8=WarnSubmenuOpen
4�#ptr%!4=-1:� pointer to sub menu
4�-� Store this filer object, whatever it is
4�3!(shortcutmenudata%+(locali%*64)+32+28) = type%
4�
4�!� Is this object a directory?
4�� (type% =2) �
5( � If so, then add to directory list
5: $(shortcutmenudata%+(locali%*64)+32) = itemsprite$+�0
5/ ptr%!4 = nextmenuptr%:� Pointer to submenu
5 �
5*) � This is a link and not a directory
54, � PROCerror("Processing "+item$+CHR$0)
5>" � Get filetype of link object
5H1 $string%=�GetLinkContents(dir$+"."+item$)+�0
5R
5\0 � (�CheckValidDrive(�string(string%)) =1) �
5f: ș "OS_File",17,string% � objecttype%,,linkloadaddr%
5p) linktype%=(linkloadaddr%>>8) � &FFF
5z) linktypeinfo%= linkloadaddr% >>> 20
5� �
5� objecttype%=0
5� �
5�U �PROCerror(FNGetLinkContents(dir$+"."+item$)+" is a "+STR$(linktypeinfo%)+CHR$0)
5� � (objecttype%=0) �
5�Y � PROCerror("Error : Link("+FNGetLinkContents(dir$+"."+item$)+") not found."+CHR$0)
5�1 � Delete this link and rescan the directory
5�= � Safety first - ensure this file is actually a link in
5�D � case the <Xuenbs$Dir> system variable has become corrupt (!)
5� � (filetype%=&af3) �
5�q � PROCerror("Invalid link "+dir$+"."+item$+" has been found and will be deleted when you click OK."+CHR$0)
5�% �("delete "+dir$+"."+item$+�0)
5� DirScan%=�
6 ValidLoadFlag%=�
6 �
6� �error("Error: Another prog has altered the <Xuenbs$Dir> system variable or someone has placed a non-link "+dir$+"."+item$+" into the links directory. Rerun the !Xuen application or remove the offending file from the !Xuen.Links directory."+�0)
6$ �
6. �
68
6B � (objecttype%=1) �
6L( � This link is a pointer to a file
6V7 � PROCerror(FNstring(string%)+" is a file"+CHR$0)
6`W $(shortcutmenudata%+(locali%*64)+32) = "Ssmall_"+�~(linktype%)+";"+itemsprite$+�0
6j/ � �(�SpriteExist("small_"+�~linktype%)) �
6t@ � Small icon don't exist - use large type and flag it so.
6~n $(shortcutmenudata%+(locali%*64)+32) = "Sfile_"+�~(linktype%)+";"+itemsprite$+�0:UseLargeSprite%=�
6� �
6�
6� �
6�
6�= � For some wierd reason the following two variables must
6�; � be evaluated outside of the objecttype test. I think
6�< � it must be something to do with the pipeline and/or a
6� � bug in the BASIC rom.
6� shriek%=�("!")
6� namestart%=�(�item$,1))
6� � (objecttype%=2) �
6�= � This link is a pointer to an application or directory
7 � (namestart%<>shriek%) �
7
J $(shortcutmenudata%+(locali%*64)+32) = "Ssmall_dir;"+itemsprite$+�0
7 �
7L $(shortcutmenudata%+(locali%*64)+32) = "Ssm"+item$+";"+itemsprite$+�0
7(& � �(�SpriteExist("sm"+item$)) �
72A � Small icon don't exist - use large type and flag it so.
7<b $(shortcutmenudata%+(locali%*64)+32) = "S"+item$+";"+itemsprite$+�0:UseLargeSprite%=�
7F �
7P �
7Z �
7d
7n�
7x
7�(� Build rest of menu item attributes
7�ptr%!8=&7000313:� icon type
7�@� IF (type%=2 AND objecttype%=0) ptr%!8=&7400313:REM Invalid
7�� (addlink%=1) �
7� ptr%!8=&3000313
7��
7�.� (UseLargeSprite%) ptr%!8 = (ptr%!8)+&800
7�.$(shortcutmenudata%+(locali%*64))=item$+�0
7�,ptr%!12 = shortcutmenudata%+(locali%*64)
7�/ptr%!16 = shortcutmenudata%+(locali%*64)+32
7�5ptr%!20 = 28:� menu item string buffer = 28 bytes
7�
7�1� Are we dealing with any ~ or ~~ filenames ?
86� (linkdepth%=0 � �item$,1,1)=�(SysFilePrefix%)) �
8
8 � Single ~ prefix filenames
8") � (�item$,2,1)<>�(SysFilePrefix%)) �
8,! � (StartMenuSeperator%<0) �
86" StartMenuSeperator%=locali%
8@4 � Does this item need a dotted line above it?
8J � (locali%>0) �
8T# !(ptr%-24)=(!(ptr%-24)) + 2
8^ GlobalMenuSepCount%+=1
8h �
8r �
8|B �IF (locali%>=StartMenuSeperator% AND StartMenuSeperator%>=0)
8�< $(shortcutmenudata%+(locali%*64))=�item$,�(item$)-1)+�0
8�% � StartMenuSeperator2%=locali%+1
8� �
8�
8� � Double ~ prefix filenames
8�( � (�item$,2,1)=�(SysFilePrefix%)) �
8�% � (GlobalShowBootMenuFlag%=0) �
8� KeepMenuItem%=�
8� �
8�# � (StartMenuSeperator2%<0) �
8�$ StartMenuSeperator2%=locali%
8�5 � Does this item need a dotted line above it?
8� � (locali%>0)
9$ !(ptr%-24)=(!(ptr%-24)) + 2
9 GlobalMenuSepCount%+=1
9
�
9& �
90G � IF (locali%>=StartMenuSeperator2% AND StartMenuSeperator2%>=0)
9:> $(shortcutmenudata%+(locali%*64))=�item$,�(item$)-2)+�0
9D% StartMenuSeperator3%=locali%+1
9N �
9X �
9b
9l'�:� End of 'Are we dealing with ...
9v
9�� (KeepMenuItem%) �
9� a%=(�(item$)+4)*16
9� � a%>width% width%=a%
9�
ptr%+=24
9�
i%+=1
9� GlobalMenuItemCount% +=1
9��
9��
9�
9�?� Do we need to add an extra writeable icon on end of menu?
9�� (addwrite%) �
9� locali%=i%
9� item$="New"
9�9 !ptr%=4+&80:� mflags = &80=LastMenuItem &4=Writeable
:$ ptr%!4=-1:� pointer to sub menu
:" ptr%!8 = &7200111:� icon type
:/ $(shortcutmenudata%+(locali%*64))=item$+�0
:, $(shortcutmenudata%+(locali%*64)+32)=�0
: - ptr%!12 = shortcutmenudata%+(locali%*64)
:*0 ptr%!16 = shortcutmenudata%+(locali%*64)+32
:46 ptr%!20 = 28:� menu item string buffer = 28 bytes
:5 a%=(�(item$)+4)*16
:� � a%>width% width%=a%
:�
ptr%+=24
:�
i%+=1
:� GlobalMenuItemCount% +=1
:� numberofitems%+=1
;�
;
;'� Has this list got anything in it?
;$� (numberofitems%>0) �
;.6!(ptr%-24)= (!(ptr%-24) �&88):� Set last menu item
;8�
;Bwidth%=(�(title$)-2)*16
;L:� Make default first entry be greyed out label 'empty'
;Vitem$="Empty"+�0
;`9$(shortcutmenudata%+(locali%*64)+32) = itemsprite$+�0
;j=!ptr%=&88:� mflags = &80 means last menu item 8=IssueWarn
;t#ptr%!4=-1:� pointer to sub menu
;~Aptr%!8=&3000313:� grey colour SELECTABLE icon type (Add link)
;�+$(shortcutmenudata%+(locali%*64))=item$
;�$(ptr%+12)=item$
;�,ptr%!12 = shortcutmenudata%+(locali%*64)
;�/ptr%!16 = shortcutmenudata%+(locali%*64)+32
;�5ptr%!20 = 28:� menu item string buffer = 28 bytes
;�a%=(�(item$)+4)*16
;�� a%>width% width%=a%
;� i%+=1
;�GlobalMenuItemCount%+=1
;��
;�currentmenuptr%!16=width%
;�
<