michael
Senior Member
member is offline


Posts: 335
|
 |
FN_MMBUTTONS.. April 25 2016. Button perfection?
« Thread started on: Apr 26th, 2016, 01:56am » |
|
NOTE: This is the best version of a non windows based buttons tool
Now its as simple as this:
status$=FN_MMBUTTONS(3,"OK 500 500 CANCEL 200 800 QUIT 200 400")
3 declares how many buttons are being made OK 500 500 is the first button and its location CANCEL 200 800 is the second button and its location QUIT 200 400 is the 3rd button and its location
status$ is just a string that a user might make to get a response from all those buttons.
NOW THATS EASY AS APPLE PIE!! ( and the Library tools and variables are hidden too..)
I think this is ready for assessment and possible approval in the project.
Code:
INSTALL @lib$+"STRINGLIB"
REM SET GRAPHICS MODE TO 8 USING VDU
VDU 22,8
REM SET LINE THICKNESS TO 3
VDU 23,23,1|
REM Turn off the text cursor _
OFF
VDU 5 : REM Treat text as graphics (transparent background)
REPEAT
status$=FN_MMBUTTONS(3,"OK 500 500 CANCEL 200 800 QUIT 200 400"):REM 3 buttons with names and locations (OK I CHEATED)
PROC_color("b",0,0,0)
MOVE 0,500:PROC_color("f",255,255,255)
PRINT "YOU CLICKED ON :";status$
UNTIL status$="QUIT"
WAIT 0
END
REM this procedure will display and monitor the buttons you want ( that is pretty cool eh?)
DEF FN_MMBUTTONS(coun%,namesloc$)
LOCAL hh%,vv%,exitcondition%,activepwrsave%(),buttonlist%,checkstr$
LOCAL initialwd$,moub%,mouy%,moux%,x,n%,i%,ti%,build$(),response1$
PRIVATE BTTNLIST$(),array$()
DIM build$(2)
DIM BTTNLIST$(50)
DIM activepwrsave%(50)
exitcondition%=0
buttonlist%=0
FOR x=0 TO 50
activepwrsave%(x)=1
NEXT
n% = FN_split(namesloc$, " ", array$())
ti%=0
FOR i% = n%-1 TO 0 STEP -1
build$(ti%)=array$(i%):ti%=ti%+1
IF ti%=3 THEN ti%=0:BTTNLIST$(coun%-1)=build$(2)+" "+build$(1)+" "+build$(0):coun%=coun%-1
NEXT
REPEAT
REM Display the buttons first
initialwd$=BTTNLIST$(buttonlist%)
n% = FN_split(initialwd$, " ", array$())
FOR i% = n%-1 TO 0 STEP -1
hh%=VAL(array$(1)):vv%=VAL(array$(2))
REM MOUSE b-- 1-rightbttn 2-mid bttn 4-left bttn
MOUSE moux%,mouy%,moub%
checkstr$=array$(0)
IF LEN(checkstr$)>1 AND activepwrsave%(buttonlist%)=0 THEN IF moux%>hh% AND mouy%>vv%-30 AND moux%<hh%+140 AND mouy%<vv%+15 THEN PROCpr(hh%,vv%,0,array$(0)+" ",255,255,255):activepwrsave%(buttonlist%)=1
IF LEN(checkstr$)>1 AND activepwrsave%(buttonlist%)=1 THEN IF moux%<hh% OR mouy%<vv%-30 OR moux%>hh%+140 OR mouy%>vv%+15 THEN PROCpr(hh%,vv%,0,array$(0)+" ",200,200,200):activepwrsave%(buttonlist%)=0
IF LEN(checkstr$)>1 THEN IF moux%>hh% AND mouy%>vv%-30 AND moux%<hh%+140 AND mouy%<vv%+15 AND moub%=4 THEN response1$=array$(0):exitcondition%=1:activepwrsave%(buttonlist%)=0
NEXT
buttonlist%=buttonlist%+1:IF LEN(BTTNLIST$(buttonlist%))<1 THEN buttonlist%=0
IF buttonlist%>50 THEN buttonlist%=0
UNTIL exitcondition%=1
=response1$
REM PUT YOUR PROCEDURES AND FUNCTIONS BELLOW THE MAIN PROGRAM END ****************
REM ***********************this is my super custom text box tool ***********************
REM X,Y,text color,boarder color,message,r,g,b
REM This should be private to the library now***************************
DEF PROCpr(x%,y%,c%,msg$,r%,g%,b%)
LOCAL initialx%,tx%,reduction%,fxx%
initialx%=LEN(msg$)
LET tx%= x%+initialx%+25
reduction%=0
COLOUR 0,r%,g%,b%
GCOL 0
reduction%=initialx%/2
reduction%=reduction%*6
IF initialx%<20 THEN reduction%=reduction%/2
initialx%=initialx%*22-reduction%
FOR fxx%=17 TO 49
LINE x%+3,y%+20-fxx%,x%+initialx%,y%+20-fxx%
NEXT fxx%
PROC_color("f",0,0,0)
MOVE tx%,y%
PRINT msg$
GCOL c%
MOVE 0,0 REM hide that thing
ENDPROC
REM ******************this is a custom Foreground and Background control tool (too much?) *****************
REM color "F"or"B", r,g,b
DEF PROC_color(fb$,r%,g%,b%)
IF fb$="f" OR fb$="F" THEN COLOUR 0,r%,g%,b% : GCOL 0
IF fb$="b" OR fb$="B" THEN COLOUR 1,r%,g%,b% : GCOL 128+1
ENDPROC
#
|