home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Datafile PD-CD 5
/
DATAFILE_PDCD5.iso
/
utilities
/
a
/
altmenu
/
!MakeMenu
/
!RunImage
(
.txt
)
< prev
next >
Wrap
RISC OS BBC BASIC V Source
|
1996-12-11
|
11KB
|
442 lines
MakeMenu
Carl Hetherington 1996
$+" at line "+
"<MakeMenu$Dir>.Libraries.WimpLib"
"<MakeMenu$Dir>.Libraries.FileLib"
"<MakeMenu$Dir>.Libraries.MenuLib"
wimp% 8192
mess% 1024
/mess%=
init_mess("<MakeMenu$Dir>.Messages")
task%=
init_wimp
*iconbaricon%=
iconbaricon("!MakeMenu")
windows% 2048
"Wimp_OpenTemplate",,"<MakeMenu$Dir>.Templates"
&infowin%=
loadwindow(0,199,"info")
*savewin%=
loadwindow(200,599,"saveas")
(itemwin%=
loadwindow(600,999,"item")
0newmenuwin%=
loadwindow(1000,1099,"newmenu")
"Wimp_CloseTemplate"
writeicon(infowin%,3,
m("Vsn"))
9max_menus%=32: max_items%=32:
titles% 16*max_menus%
menu$(max_menus%,max_items%),win%(max_menus%),id$(max_menus%),items%(max_menus%)
command$(max_menus%,max_items%),ptr%(max_menus%)
idmenu% 28+(24*max_menus%)
icons_size%=16*1024
icons% icons_size%: icons_p%=icons%: icons_max%=icons%+icons_size%
menus%=0
null% 1: ?null%=0
filetype%=&2AB
menu_create("AltMenu")
menu_block% 512
menu_initialise
))r%=
menu_load("<MakeMenu$Dir>.Menus")
r%<>-1
complain(
m("badmenu"))
+Oiconbaritems%=
menu_create("iconbar",menu_block%): iconbarmenu%=menu_block%
,Fd%=
menu_create("edit",menu_block%+240): editmenu%=menu_block%+240
finish%=
action%=
poll(0)
action%
2 :
"Wimp_OpenWindow",,wimp%
3 :
"Wimp_CloseWindow",,wimp%
6 :
mouseclick
7 :
dragboxend
8 :
"Wimp_ProcessKey",,wimp%!24
9 :
menuselection
17,18 :
message:
savemessages
finish%=
closedown_mess
closedown_wimp
notmywin(w%)
l%,n%
l%=1
menus%
w%=win%(l%)
w%=infowin%
w%=savewin%
w%=itemwin%
message
wimp%!16
0 : finish%=
mouseclick
x%=wimp%!0
y%=wimp%!4
buttons%=wimp%!8
win%=wimp%!12
icon%=wimp%!16
win%=-2
icon%=iconbaricon%
buttons%
4 :
menu_show("AltMenu")
l%=1
menus%:
menuenable(idmenu%,l%):
barmenu(x%,iconbarmenu%,iconbaritems%): current_menu%=1
buttons%=4
win%=itemwin%
icon%
2 :
enableicon(itemwin%,3):
disableicon(itemwin%,5):
disableicon(itemwin%,6):
seticonstate(itemwin%,2,1):
seticonstate(itemwin%,4,0)
4 :
disableicon(itemwin%,3):
enableicon(itemwin%,5):
enableicon(itemwin%,6):
seticonstate(itemwin%,2,0):
seticonstate(itemwin%,4,1)
6 :
menudisable(idmenu%,
n_from_win(current_win%)):
iconmenu(itemwin%,6,idmenu%): current_menu%=3
7 :
current_state%
r:
menu_newitem(
n_from_win(current_win%))
sI
menu_edititem(
n_from_win(current_win%),current_icon%)
u#
closewindow(itemwin%)
8 :
closewindow(itemwin%)
buttons%=4
win%=savewin%
savewinclick
buttons%=2
win%<>-2
win%<>infowin%
win%<>savewin%
};current_menu%=2: current_win%=win%: current_icon%=icon%
icon%<1
menudisable(editmenu%,2)
menuenable(editmenu%,2)
windowmenu(editmenu%)
buttons%=4
win%=newmenuwin%
icon%
readicon(newmenuwin%,0)
/l%=0:
l%<=menus%
id$(l%)<>t$: l%+=1:
id$(l%)=t$
complain("This identifier has already been used. Please try another.")
menu_create(t$)
closewindow(newmenuwin%)
3 :
closewindow(newmenuwin%)
menuselection
current_menu%
wimp%!0
2 :
writeicon(newmenuwin%,0,""):
openwindow(newmenuwin%)
3 :
wimp%!4>-1
menu_show(id$(wimp%!4+1))
4 :
clear:
menu_create("AltMenu")
iconbaritems%-1 : finish%=
wimp%!0
writeicon(itemwin%,0,""):
writeicon(itemwin%,3,"")
writeicon(itemwin%,5,""):
seticonstate(itemwin%,2,1)
seticonstate(itemwin%,4,0):
disableicon(itemwin%,5)
enableicon(itemwin%,3)
disableicon(itemwin%,6):
openwindow(itemwin%): current_state%=1
writeicon(itemwin%,0,
readicon(win%,icon%))
n_from_win(win%): cmd$=command$(n%,icon%): sub%=(
cmd$,1)=">")
sub%
writeicon(itemwin%,3,"")
writeicon(itemwin%,5,
cmd$,
cmd$-1))
seticonstate(itemwin%,2,0):
disableicon(itemwin%,3)
seticonstate(itemwin%,4,1):
enableicon(itemwin%,5):
enableicon(itemwin%,6)
openwindow(itemwin%)
writeicon(itemwin%,3,cmd$)
writeicon(itemwin%,5,"")
seticonstate(itemwin%,2,1):
enableicon(itemwin%,3)
seticonstate(itemwin%,4,0):
disableicon(itemwin%,5):
disableicon(itemwin%,6)
openwindow(itemwin%)
current_state%=2
writeicon(itemwin%,5,id$(wimp%!0+1))
dosave(filename$)
"OS_Find",&8F,filename$
file%
/$wimp%="ALTM":
"OS_GBPB",2,file%,wimp%,4
Fill the ptr%() array with where each menu is going to end up in the file
l%=1
menus%
ptr%(l%)=p%
p%=p%+28
p%=p%+(items%(l%)*24)
m%=1
items%(l%)
-c$=command$(l%,m%):
c$,1)=">"
c$="|"
p%=p%+
(c$)+1
align(p%)
Build each menu (in wimp%) and send it to the file
l%=1
menus%
p%=wimp%
B$p%=id$(l%): p%!12=&70207: p%!16=(12*16)+12: p%!20=44: p%!24=0
p%+=28
m%=1
items%(l%)
m%=items%(l%)
p%!0=&80
p%!0=0
c$=command$(l%,m%)
c$,1)=">"
p%!4=ptr%(
n_from_id(
c$-1))))
p%!4=-1
)p%!8=&07000001: $(p%+12)=menu$(l%,m%)
p%+=24
m%=1
items%(l%)
c$=command$(l%,m%)
c$,1)=">"
c$="|"
$p%=c$: p%=p%+
(c$)+1
align(p%)
"OS_GBPB",2,file%,wimp%,p%-wimp%
"OS_Find",0,file%
"OS_File",18,filename$,filetype%
"Wimp_CreateMenu",,-1
writeicon(savewin%,1,filename$)
n_from_win(w%)
l%<menus%
win%(l%)<>w%
l%+=1
win%(l%)<>w%
n_from_id(i$)
l%<menus%
id$(l%)<>i$
l%+=1
id$(l%)<>i$
menu_makewindow(n%)
menu_createwindow(n%,id$(n%))
l%=1
items%(n%)
menu_createitemicon(n%,menu$(n%,l%))
menu_create(i$)
menus%=max_menus%
complain("No more menus can be defined."):
/menus%+=1: id$(menus%)=i$: items%(menus%)=0
menu_createwindow(menus%,i$)
make_ids_menu
menu_createwindow(n%,id$)
"Wimp_OpenTemplate",,"<MakeMenu$Dir>.Templates"
p%=titles%+((n%-1)*16)
"Wimp_LoadTemplate",,wimp%,p%,p%+15,-1,"menu",0
width%=(12*16)+64+12
+9wimp%!40=0: wimp%!44=-96: wimp%!48=width%: wimp%!52=0
,&wimp%!8=wimp%!16-wimp%!56+wimp%!48
-&wimp%!12=wimp%!4+wimp%!52-wimp%!44
.1wimp%?68=width%
&FF: wimp%?69=width%
&100
"Wimp_CreateWindow",,wimp%
win%(n%)
"Wimp_CloseTemplate"
16wimp%!0=win%(n%):
"Wimp_GetWindowInfo",,wimp%+1
$(wimp%!76)=id$
wimp%!4=wimp%!44+32
wimp%!8=wimp%!56-24-44
wimp%!12=wimp%!4+(12*16)+12
wimp%!16=wimp%!8+44
7.wimp%!20=%00100111000000000011000100111001
8[wimp%!24=
ip(id$):
wimp%!24=0
complain("Insufficient memory for menu creation"):
wimp%!28=null%
wimp%!32=16
"Wimp_CreateIcon",,wimp%
ip(t$)
icons_p%+16>icons_max%
D*o%=icons_p%: $o%=t$: icons_p%+=16: =o%
menu_show(i$)
l%<menus%
id$(l%)<>i$
N l%+=1
id$(l%)<>i$
fullsize(win%(l%))
menu_newitem(n%)
Y;text$=
readicon(itemwin%,0): cmd$=
readicon(itemwin%,3)
ZKsub%=
geticonstate(itemwin%,4):
sub%
cmd$=">"+
readicon(itemwin%,5)
[Kitems%(n%)+=1: menu$(n%,items%(n%))=text$: command$(n%,items%(n%))=cmd$
menu_createitemicon(n%,text$)
menu_createitemicon(n%,text$)
cMwimp%!0=0: wimp%!4=-96-(items%(n%)*44): wimp%!8=(12*16)+64+12: wimp%!12=0
"Wimp_SetExtent",win%(n%),wimp%
e5wimp%!0=win%(n%):
"Wimp_GetWindowState",,wimp%
(wimp%!32
1<<16)>0
fullsize(win%(n%))
g6wimp%!0=win%(n%):
"Wimp_GetWindowInfo",,wimp%+1
wimp%!4=wimp%!44+32
i*wimp%!8=wimp%!56-24-((wimp%!88)*44)-44
wimp%!12=wimp%!4+(12*16)+12
wimp%!16=wimp%!8+44
l.wimp%!20=%00000111000000000011000100111001
mXwimp%!24=
ip(text$):
wimp%!24=0
complain("Insufficient memory for new item"):
wimp%!28=null%
wimp%!32=16
"Wimp_CreateIcon",,wimp%
qVwimp%!0=win%(n%): wimp%!4=h%: wimp%!8=0: wimp%!12=0:
"Wimp_SetIconState",,wimp%
menu_edititem(n%,x%)
y;text$=
readicon(itemwin%,0): cmd$=
readicon(itemwin%,3)
zKsub%=
geticonstate(itemwin%,4):
sub%
cmd$=">"+
readicon(itemwin%,5)
{,menu$(n%,x%)=text$: command$(n%,x%)=cmd$
writeicon(current_win%,x%,text$)
doload(filename$,dwin%,dic%)
dwin%
itemwin%:
"OS_Byte",121,3
writeicon(itemwin%,0,
leaf(filename$))
k%=3
k%=6
writeicon(itemwin%,3,"Edit "+filename$)
writeicon(itemwin%,3,"Filer_Run "+filename$)
"OS_File",17,filename$
,,load%: ftype%=(load%
&FFF00)
&100
ftype%=&2AB
"OS_Find",&4F,filename$
handle%:
"OS_GBPB",4,handle%,wimp%,4
)$(wimp%+4)="ALTM":
!wimp%=wimp%!4
clear
"OS_GBPB",3,handle%,wimp%,28,p%
,,,not%,p%
not%=0
menus%+=1
id$(menus%)=$wimp%
items%=0
"OS_GBPB",3,handle%,wimp%,24,p%
,,,,p%
)items%+=1: command$(menus%,items%)=""
wimp%!4>-1
"OS_GBPB",3,handle%,wimp%+1024,12,(wimp%!4+4)
-command$(menus%,items%)=">"+$(wimp%+1024)
$menu$(menus%,items%)=$(wimp%+12)
wimp%!0=&80
l%=1
items%
"OS_GBPB",3,handle%,wimp%,256,p%: p%=p%+
($wimp%)+1
command$(menus%,l%)=""
command$(menus%,l%)=$wimp%
items%(menus%)=items%
align(p%)
not%>0
"OS_F