BBC BASIC for Windows
« Flicker free Custom text box April 25 2016 »

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



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: Flicker free Custom text box April 25 2016  (Read 660 times)
michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
xx Flicker free Custom text box April 25 2016
« Thread started on: Mar 15th, 2016, 12:48am »

NOTE: ( it now has the mouse button/string separation information displayed ( from the string edit project)

*** I keep wanting to remove the mouse text edit because it adds complexity to a simple box, but if I don't complete it I will end up regretting it later ( I am sure)

Also: this is just a minor touch up. I do plan to make this professional like my buttons in TOOLs in this forum..

NO FLASHING TEXT EITHER!!!

*** In BBC BASIC OPTIONS :Make sure lower case keywords is off ***
*** if it is on.. restart the IDE after you turn it off **

Simplified and LOCALS added...

A note: if you look carefully you will see a need for decimals for the text box area length for fill.. The first example of the need for special variables (decimal to whole numbers)

This is the core text tool.. It has more potential as a non windows based tool.. (but now it looks like a windows text input.)
Of course I cant really post this without the color tool... As I have become attached to it
But it is simplified (just the bare bones..of what is needed to use it.

The command:
PROC_input(H,V,TEXTLIMIT)
example:
PROC_input(10,610,125)
To make it simple:
- 10,610, is the location of the input
- 125, is the text limit for input (useful for special input areas

I am thinking I may make the settings default.. Or.. Maybe I could create a group of special commands to give the global color settings for text foreground and background to eliminate some complexity.
Any ideas are appreciated.

The return string is MESSAGE$

Instructions..
1) Type a message until you can no longer type any more
2) Use your mouse to click on areas where you typed and see the information box (this will be your separation point in edit)
3) Press enter
4) look at the message.

Code:
     
    REM gbx% and gby% NEED to be whole numbers and need to be global ( they hold shared text input location )
      gbx%=0:gby%=0:split%=0:cursor%=0 :REM GLOBAL VARIABLES
      REM split% holds the divide location of the string so edits can be made. ( this is where it gets technical)
      tempstr$=""
      lx=0:ly=0:lh=0:lv=0
      REM define my line position
      li=0
      MODE 22
      COLOUR 1,225,225,225 REM Set background color to windows common color gray (my custom RGB text background color)
      GCOL 0 : REM Set graphics foreground to palette color 0  (BLACK)
      GCOL 128+1 : REM Set graphics background to palette color 1
      VDU 5 : REM Treat text as graphics (transparent background)
      OFF:CLG:PROC_color("F",255,255,255)
      REM H,V,TEXTLIMIT (getting simpler?)
      PROC_input(200,610,50):REM **************************END OF PROGRAM ****************************
      * REFRESH OFF
      PROC_color("f",0,0,0)


      PRINT :PRINT "":PRINT:PRINT "Your message is:":PRINT MESSAGE$
      PRINT "Program done . Waiting for you to close the window. Please do it"
      * REFRESH
      END
      REM H,V,TEXTLIMIT (simpler?)
      DEF PROC_input(bx,by,textlimit)
      LOCAL rback%,gback%,bback%
      rback%=255:gback%=255:bback%=255
      LOCAL rfore%,gfore%,bfore%,fill
      rfore%=0:gfore=0:bfore=0
      gbx%=bx:gby%=by:initialx%=0:sl%=0:key$="":MESSAGE$="":MES$=""
      initialx%=textlimit*16.2
      FOR fill=1 TO 58
        PROC_color("f",255,255,255):LINE bx+3,by+20-fill,bx+initialx%,by+20-fill
      NEXT fill
      PROC_color("f",0,0,0):LINE bx+3,by+20,bx+initialx%,by+20:LINE bx+3,by+20-fill,bx+initialx%,by+20-fill:
      REPEAT
        REPEAT
          key$ =INKEY$(1)
          PROC_color("F",rfore%,gfore%,bfore%)
          MOVE bx,by:PRINT MESSAGE$;"_" :* REFRESH
          sl%=LEN(MESSAGE$)
          remains%=sl%-cursor%
          lstring$=LEFT$(MESSAGE$,cursor%):rstring$=RIGHT$(MESSAGE$,remains%)
          PROC_moubox
        UNTIL key$ <>""
        sl%=LEN(MESSAGE$)
        IF INKEY(-48) sl%=LEN(MESSAGE$)-1:key$=""
        REPEAT UNTIL INKEY(0)=-1
        IF MESSAGE$<> MESSAGE$ OR sl%<LEN(MESSAGE$) THEN
          PROC_color("F",rback%,gback%,bback%)
          MOVE bx,by
          PRINT MESSAGE$;"_"
        ENDIF
        MES$=MID$(MESSAGE$,0,sl%)
        MESSAGE$=MES$
        PROC_color("F",rback%,gback%,bback%):MOVE bx,by:PRINT MESSAGE$;"_"
        IF LEN(key$) = 1 THEN
          IF LEN(MESSAGE$)<textlimit THEN PROC_color("F",rback%,gback%,bback%):MOVE bx,by:PRINT MESSAGE$;"_": MESSAGE$=MESSAGE$+key$:* REFRESH OFF
          REM (jump)
        ENDIF
      UNTIL INKEY(-74)
      ENDPROC
      DEF PROC_moubox
      REM MOUSE b-- 1-rightbttn  2-mid bttn  4-left bttn
      MOUSE x,y,b
      LOCAL templen$,tempstr$,strlen%,resposx%,lv%,rr%,gg%,bb%
      strlen%=LEN(MESSAGE$)*16
      strlen%=strlen%+gbx%
      IF y>gby%-35 AND y<gby%+20 THEN
        lv%=gbx%
        FOR checkx%=lv% TO strlen% STEP 16
          IF x>checkx%-13 AND x<checkx%+3 THEN resposx%=checkx%-gbx%
        NEXT checkx%
      ENDIF
      split%=resposx%/16
      templen$=STR$(LEN(MESSAGE$))
      tempstr$= "X : "+STR$(x)+" Y : "+STR$(y)+"   "+"String length : "+templen$+" Text Split%= "+STR$(split%)+" Char: ("+MID$(MESSAGE$,split%,1)+ ") LEFT ("+lstring$+ ")Count:"+STR$(cursor%)+" RIGHT ("+rstring$+") "
      cursor%=split%
      REPEAT
        tempstr$=tempstr$+" "
      UNTIL LEN(tempstr$)>60
      * REFRESH OFF
      IF b=4 OR b=1 THEN PROC_pr(30,905,15,15,tempstr$,100,100,200)
      * REFRESH
      IF x<500 AND y<500 THEN
        REM PROC_color("F",100,100,100):LINE lx,ly,lh,lv
        IF b=4 THEN lx=x:ly=y
        IF b=1 THEN lh=x:lv=y
        rr%=RND(255)
        gg%=RND(255)
        bb%=RND(255)
        IF x<500 AND y<500 THEN PROC_color("F",rr%,gg%,bb%):LINE lx,ly,lh,lv
      ENDIF
      ENDPROC
      REM ***********************this is my super custom text box tool ***********************
      REM X,Y,text color,boarder color,message,r,g,b
      REM ************************************************************************
      DEF PROC_pr(X,Y,C,CT,msg$,r,g,b)
      initialx%=LEN(msg$)
      COLOUR 0,r,g,b
      GCOL 0
      LET tx= X+initialx%+25
      LET ty= Y:reduction%=0
      reduction%=initialx%/2
      reduction%=reduction%*6
      IF initialx%<20 THEN reduction%=reduction%/2
      initialx%=initialx%*22-reduction%
      FOR fill=1 TO 58
        LINE X+3,Y+20-fill,X+initialx%,Y+20-fill
      NEXT fill
      GCOL CT
      MOVE tx,ty
      PRINT msg$
      GCOL C
      LINE X,Y+20,X+initialx%,Y+20
      LINE X,Y+20,X,Y-40
      LINE X,Y-40,X+initialx%,Y-40
      LINE X+initialx%,Y-40,X+initialx%,Y+20
      LINE X-5,Y+25,X+initialx%+5,Y+25
      LINE X-5,Y+25, X-5,Y-45
      LINE X+initialx%+5,Y+25,X+initialx%+5,Y-45
      LINE X-5,Y-45,X+initialx%+5,Y-45
      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 26th, 2016, 10:59pm by michael » User IP Logged

I like making program generators and like reinventing the wheel
michael
Senior Member
ImageImageImageImage


member is offline

Avatar




PM


Posts: 335
xx Re: Flicker free Custom text box April 25 2016
« Reply #1 on: Apr 26th, 2016, 05:41am »

I touched this up..
This modification should solve the issues of flashing graphics.
Now it is smooth.

Keep in mind that this is a temporary solution for show case and is not the final project as it is old programming ways that I plan to make professional for all platforms.

I do want a non windows alternative for all platforms.
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