[futurebasic] Re: [FB] transparent static edit fields

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : July 2000 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Sun, 30 Jul 2000 04:50:47 -0400
Al Staffieri Jr. offered this code for transparent edit fields:

>This one doesn't use copybits and is much simpler. This works in both FB2 and
>FB3. In the HANDLEEVENTS loop, I keep calling FN doRefresh instead of going
>through an ON DIALOG FN just to keep it simple.
>
>LOCAL FN doRefresh
>  AUTOCLIP = _false
>  PEN 10, 10, 1, 39
>  LONG COLOR 25000, 25000, 5000
>  CALL MOVETO (0,0)
>  CALL LINETO (100,100)
>  AUTOCLIP = _true
>  LONG COLOR 0, 0, 0
>END FN
>
>WINDOW 1
>txt$ = "Hello. This edit field should be transparent."
>EDIT FIELD 1, txt$, (10,10)-(100,100), _statFramed
>
>DO
>  HANDLEEVENTS
>  FN doRefresh
>UNTIL 0

Thanks, Al. I played around with your code and came up with this 
simple demo to change EDIT FIELD color on the fly. Just make the BOX 
FILL coordinates the same as the EDIT FIELD/s you want to colorize.

Ken Shmidheiser

p.s. Anyone know how to get rid of the cursor flicker over the edit 
field? I know it comes from HANDLEEVENTS refresh, but wonder if 
there's a workaround.

(Watch for e-mail line breaks in the following FB^3 code)

/*
Demo of transparent edit fields
based on Al Staffieri Jr.'s code.
Works only on static edit fields.

Ken Shmidheiser
Somerset, KY
7-30-00

*/

BEGIN GLOBALS
DIM gRed& as LONG
DIM gGreen& as LONG
DIM gBlue& as LONG
DIM gColorTxt$
DIM gPlainJane$
END GLOBALS

gRed& = 57697
gGreen& = 57697
gBlue& = 57697

gPlainJane$ = "I am just a Plain Jane edit field."

LOCAL FN doRefresh
   AUTOCLIP = _false
   PEN 10, 10, 1, 39
   LONG COLOR gBlue&, gGreen&, gRed& 
   BOX FILL 10, 10 TO 300, 100
   AUTOCLIP = _true
   LONG COLOR 0, 0, 0
END FN

LOCAL FN initialize

   WINDOW 1, "Transparent Color Edit Field",(0,0)-(310,135),_docNoGrow

   APPLE MENU "(Transparent Color Edit Field Demo"
   MENU 1, 0, _enable, "File"
   MENU 1, 1, _enable, "Quit/Q"
   EDIT MENU 2

   MENU 3, 0, _enable, "Color"
   MENU 3, 1, _enable, "Red"
   MENU 3, 2, _enable, "Green"
   MENU 3, 3, _enable, "Blue"
   MENU 3, 4, _enable, "Yellow"

   txt1$ = CHR$(13) + "Hello." + CHR$(13)
   txt2$ = CHR$(13) + "This edit field should be transparent."
   txt3$ = CHR$(13) + "Go to Color menu above to change."
   txt$ = txt1$ + txt2$ + txt3$ + CHR$(13) + CHR$(13) + gColorTxt$
   EDIT = 3
   EDIT FIELD 1, txt$, (10,10)-(300,100), _statFramed, _centerJust
   EDIT FIELD 2, gPlainJane$, (10,113)-(300,125), _statFramed, _centerJust

END FN

LOCAL FN doDialog
   DIM evnt% as INT
   DIM id% as INT
   evnt% = DIALOG(0)
   id% = DIALOG(evnt%)

   SELECT(evnt%)
     CASE _wndClose
       SELECT(id%)
         CASE 1
           END
       END SELECT
   END SELECT

END FN

LOCAL FN doMenu
   DIM menuID% as INT
   DIM itemID% as INT
   menuID% = MENU(_menuID)
   itemID% = MENU(_itemID)

   SELECT CASE(menuID%)
     CASE 1
       SELECT(itemID%)
         CASE 1
           END
       END SELECT
     CASE 3
       SELECT(itemID%)
         CASE 1              'Red
           gRed& = 65535
           gGreen& = 0
           gBlue& = 0
           gColorTxt$ = "Now I am Red!"
           gPlainJane$ = "Now he's red and I'm still Plain Jane"
           FN initialize
    CASE 2         'Green
      gRed& = 0
      gGreen& = 65535
      gBlue& = 0
      gPlainJane$ = "Now he's green and I'm still Plain Jane"
      FN initialize
    CASE 3         'Blue
      gRed& = 0
      gGreen& = 0
      gBlue& = 65535
      gColorTxt$ = "Now I am Blue!"
      gPlainJane$ = "Now he's blue and I'm still Plain Jane"
      FN initialize
    CASE 4         'Yellow
      gRed& = 65535
      gGreen& = 65535
      gBlue& = 0
      gColorTxt$ = "Now I am Yellow!"
      gPlainJane$ = "Now he's yellow and I'm still Plain Jane"
      FN initialize
       END SELECT
   END SELECT
   MENU
END FN

ON DIALOG FN doDialog
ON MENU FN doMenu

FN initialize

DO
   HANDLEEVENTS
   FN doRefresh
UNTIL 0
END