var bfont : int := Font.New ("System:12")
var menu1 := 0
function mouseover (x1, y1, x2, y2 : int) : boolean
var mousex, mousey, mouseb : int
mousewhere (mousex, mousey, mouseb)
if mousex >= x1 and mousex <= x2 then
if mousey >= y1 and mousey <= y2 then
result true
end if
end if
result false
end mouseover
procedure button (x1, y1, x2, y2, c, tc : int, s : string, num : int, var i : int, font : int, b : boolean)
var mousex, mousey, mouseb : int
mousewhere (mousex, mousey, mouseb)
if mouseover (x1, y1, x2, y2) then
drawline (x1, y1, x2, y1, 30)
drawline (x2, y1, x2, y2, 30)
drawline (x2, y2, x1, y2, 25)
drawline (x1, y2, x1, y1, 25)
if mouseb = 1 then
i := num
drawfillbox (x1 + 1, y1 + 1, x2 - 1, y2 - 1, 1)
Font.Draw (s, (x1 + ((x2 - x1) div 2)) - (Font.Width (s, bfont) div 2) + 1, ((y1 + ((y2 - y1) div 2)) - 4) - 1, font, 14)
else
drawfillbox (x1 + 1, y1 + 1, x2 - 1, y2 - 1, c)
Font.Draw (s, (x1 + ((x2 - x1) div 2)) - (Font.Width (s, bfont) div 2) + 1, ((y1 + ((y2 - y1) div 2)) - 4) - 1, font, tc)
end if
else
drawline (x1, y1, x2, y1, 25)
drawline (x2, y1, x2, y2, 25)
drawline (x2, y2, x1, y2, 30)
drawline (x1, y2, x1, y1, 30)
drawfillbox (x1 + 1, y1 + 1, x2 - 1, y2 - 1, c)
Font.Draw (s, (x1 + ((x2 - x1) div 2)) - (Font.Width (s, bfont) div 2), (y1 + ((y2 - y1) div 2)) - 4, font, tc)
end if
end button
function menu (num, x1, x2, y1, ksp, dssp, c1, c2 : int, s : array 1 .. * of string) : int
var dsp := 0
dsp := ksp + dssp - 10
var res := 0
var ii : int := num
for i : 1 .. num * 10 by 10
if (i div 10) not= num then
button (x1, (y1 + (dsp * (i div 10))) + i, x2, y1 + ((dsp * (i div 10)) + i) + ksp, c1, 7, s (ii), ii, res, bfont, true)
else
button (x1, (y1 + (dsp * (i div 10))) + i, x2, y1 + ((dsp * (i div 10)) + i) + ksp, c2, 14, s (ii), ii, res, bfont, false)
end if
ii := ii - 1
end for
result res
end menu
View.Set ("offscreenonly")
var menutext : array 1 .. 6 of string
menutext (1) := "text 1"
menutext (2) := "text 2"
menutext (3) := "text 3"
menutext (4) := "text 4"
menutext (5) := "text 5"
loop
locate (1, 1)
put "menu # ", menu (5, 220, 420, 150, 20, 10, 8, 9, menutext), " selected..."
View.Update
delay (10)
end loop
|