BBC BASIC for Windows
« Efficient windowless buttons.. »

Welcome Guest. Please Login or Register.
Apr 5th, 2018, 10:41pm



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

If you require a dump of the post on your message board, please come to the support board and request it.


Thank you Conforums members.

BBC BASIC for Windows Resources
Online BBC BASIC for Windows documentation
BBC BASIC for Windows Beginners' Tutorial
BBC BASIC Home Page
BBC BASIC on Rosetta Code
BBC BASIC discussion group
BBC BASIC for Windows Programmers' Reference

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Efficient windowless buttons..  (Read 471 times)
michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
cheesy Efficient windowless buttons..
« Thread started on: Apr 25th, 2016, 05:09am »

Did I just make a Button tool that is superior in ease of use to the windows buttons? I think so!

CPU time is low and there is NO flicker!

( Nothing is perfect until it is tested .. I wont laugh too much)

response1$ is your GLOBAL return string from your buttons
example
BTTNLIST$(1)="CANCEL 200 800 "
Its an string array. You will be able to make 50 unique active buttons on the same screen!!
SO .. CANCEL is your button
200 800 is the location of that button...

OK I probably don't need 50 buttons (but you never know)
Maybe a person might make a button game?

PROC_monitorbuttons will return a string named response1$ which will tell you which button was pressed..

Its that easy!!

BUT I have decided that you would redefine active buttons for each active screen, as having an active button monitor would add processor time and unnecessary coding.
I think I removed any unnecessary variables.. (and there is no flicker!!)
I know of another way to make this so that it has absolutely no effect on other parts of the program.. (really)
Code:
  
    INSTALL @lib$+"STRINGLIB"
      REM set global button tracker string array
      REM response1$ is your response from the buttons.  It must remain global for users program.
      response1$=""
      DIM BTTNLIST$(50):REM 50 buttons should be enough for any program?

      REM !!!  MAKE SURE IN BBC BASIC OPTIONS TO DISABLE  Lower Case Keywords  ( OR you will have keyword errors )
      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
        BTTNLIST$(0)="OK 500 500 ":REM Activate the button first then name the button and make start coordinates (also tells mouse where to look)
        BTTNLIST$(1)="CANCEL 200 800 ":REM I did it like this because I think a user can just manually switch this on
        BTTNLIST$(2)="QUIT 200 400 "
        PROC_monitorbuttons
      UNTIL response1$="QUIT"
      WAIT 0
      END
      REM this procedure will display and monitor the buttons you want ( that is pretty cool eh?)
      DEF PROC_monitorbuttons
      LOCAL hh%,vv%,exitcondition%,activepwrsave%(),buttonlist%,checkstr$
      LOCAL initialwd$,moub%,mouy%,moux%,x,n%,i%
      DIM activepwrsave%(50)
      exitcondition%=0
      buttonlist%=0
      FOR x=0 TO 50
        activepwrsave%(x)=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 PROC_button(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 PROC_button(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
      PROC_color("b",0,0,0):CLG
      MOVE 0,500:PROC_color("f",255,255,255)
      PRINT "YOU CLICKED ON :";response1$
      PRINT "H string ";array$(1);" number ";hh%
      MOVE 0,450
      PRINT "V string";array$(2);" number ";vv%
      ENDPROC
      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 ************************************************************************
      DEF PROC_button(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
 
« Last Edit: Apr 25th, 2016, 07:34am by michael » User IP Logged

I like making program generators and like reinventing the wheel
Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls