Post by tsh73 on Dec 13, 2021 15:14:28 GMT -5
Another go at bmpbuttons matrix
Now 5x5
It will create single empty button BMP to populate initial bmpbuttons.
If it fail just run it again, it should pick one created first time.
Now it has got all the mechanics (
all letters are there, ordinary/red/bold;
buttonclick gets handle$
handle$ got coordinates in the string
)
but haven't got any logic (why this is done? What one supposed to do with it?)
So far so good. If you have any use for it please have a go.
I have an idea... then done I'll post it here as well.
Now 5x5
It will create single empty button BMP to populate initial bmpbuttons.
If it fail just run it again, it should pick one created first time.
Now it has got all the mechanics (
all letters are there, ordinary/red/bold;
buttonclick gets handle$
handle$ got coordinates in the string
)
but haven't got any logic (why this is done? What one supposed to do with it?)
So far so good. If you have any use for it please have a go.
I have an idea... then done I'll post it here as well.
'playing with bmpbuttons
'tsh73 dec 2021
nomainwin
desiredWidth = 400
desiredHeight = 400
gosub [ajustWindow]
'now, center window
UpperLeftX = (DisplayWidth - WindowWidth)/2
UpperLeftY = (DisplayHeight - WindowHeight)/2
'now, open your window with desired size
'BackgroundColor$ = "darkblue"
'of cource this is BASIC-generated code
bmpbutton #main.lttr00, "letr.bmp", btnClick, UL, 0, 0
bmpbutton #main.lttr01, "letr.bmp", btnClick, UL, 80, 0
bmpbutton #main.lttr02, "letr.bmp", btnClick, UL, 160, 0
bmpbutton #main.lttr03, "letr.bmp", btnClick, UL, 240, 0
bmpbutton #main.lttr04, "letr.bmp", btnClick, UL, 320, 0
bmpbutton #main.lttr10, "letr.bmp", btnClick, UL, 0, 80
bmpbutton #main.lttr11, "letr.bmp", btnClick, UL, 80, 80
bmpbutton #main.lttr12, "letr.bmp", btnClick, UL, 160, 80
bmpbutton #main.lttr13, "letr.bmp", btnClick, UL, 240, 80
bmpbutton #main.lttr14, "letr.bmp", btnClick, UL, 320, 80
bmpbutton #main.lttr20, "letr.bmp", btnClick, UL, 0, 160
bmpbutton #main.lttr21, "letr.bmp", btnClick, UL, 80, 160
bmpbutton #main.lttr22, "letr.bmp", btnClick, UL, 160, 160
bmpbutton #main.lttr23, "letr.bmp", btnClick, UL, 240, 160
bmpbutton #main.lttr24, "letr.bmp", btnClick, UL, 320, 160
bmpbutton #main.lttr30, "letr.bmp", btnClick, UL, 0, 240
bmpbutton #main.lttr31, "letr.bmp", btnClick, UL, 80, 240
bmpbutton #main.lttr32, "letr.bmp", btnClick, UL, 160, 240
bmpbutton #main.lttr33, "letr.bmp", btnClick, UL, 240, 240
bmpbutton #main.lttr34, "letr.bmp", btnClick, UL, 320, 240
bmpbutton #main.lttr40, "letr.bmp", btnClick, UL, 0, 320
bmpbutton #main.lttr41, "letr.bmp", btnClick, UL, 80, 320
bmpbutton #main.lttr42, "letr.bmp", btnClick, UL, 160, 320
bmpbutton #main.lttr43, "letr.bmp", btnClick, UL, 240, 320
bmpbutton #main.lttr44, "letr.bmp", btnClick, UL, 320, 320
open "BMP buttons" for window_nf as #main
#main, "trapclose [quit]"
wait
'-----------------------
[quit]
timer 0
close #main
end
'-------------------------------------------------
[ajustWindow]
UpperLeftX = 20
UpperLeftY = 20
WindowWidth = 200 '100 seems to be too much - works different
WindowHeight = 200
open "Ajusting..." for graphics_nsb_nf as #gr
' graphics
' graphics_nsb
' graphics_nsb_nf
#gr, "home ; down ; posxy x y"
'x, y give us width, height
width = 2*x : height = 2*y
#gr "backcolor white"
' #gr "font times_new_roman bold 30 80"
' #gr "font times_new_roman 30 80"
' #gr "place 10 65"
' #gr "\";"M"
gosub [btn]
#gr "getbmp tmp0 1 1 80 80"
bmpsave "tmp0", "letr.bmp"
#gr "font times_new_roman 30 80"
base$="ltrN"
for i = asc("A") to asc("Z")
#gr "place 1 1; boxfilled 81 81"
c$=chr$(i)
#gr "stringwidth? c$ w"
#gr "place ";40-w/2;" 65"
#gr "\";c$
gosub [btn]
#gr "getbmp ";base$;chr$(i);" 1 1 80 80"
next
#gr "font times_new_roman 30 80"
base$="ltrR"
for i = asc("A") to asc("Z")
#gr "place 1 1; boxfilled 81 81"
c$=chr$(i)
#gr "stringwidth? c$ w"
#gr "place ";40-w/2;" 65"
#gr "color red"
#gr "\";chr$(i)
gosub [btn]
#gr "getbmp ";base$;chr$(i);" 1 1 80 80"
next
#gr "color black"
#gr "font times_new_roman bold 30 80"
base$="ltrB"
for i = asc("A") to asc("Z")
#gr "place 1 1; boxfilled 81 81"
c$=chr$(i)
#gr "stringwidth? c$ w"
#gr "place ";40-w/2;" 65"
#gr "\";c$
gosub [btn]
#gr "getbmp ";base$;chr$(i);" 1 1 80 80"
next
close #gr
slackX = 200-width
slackY = 200-height
WindowWidth = desiredWidth + slackX
WindowHeight = desiredHeight + slackY
return
[btn]
#gr "size 3; color lightgray"
#gr "place 3 3; box 80 80"
#gr "color darkgray"
#gr "place 6 6; box 79 79"
#gr "color white; place 6 6; box 76 76"
#gr "size 1; color black"
#gr "place 1 1; box 81 81"
return
'====================================
sub btnClick handle$
'notice handle$
r=int(rnd(0)*26)
c$=chr$(r+asc("A"))
bmp$="ltr";mid$("NBR", int(rnd(0)*3)+1,1);c$
#handle$ "bitmap ";bmp$
end sub