[futurebasic] Re: [FB] EDIT FIELD Rect

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : August 1999 : Group Archive : Group : All Groups

From: Mel Patrick <mel@...>
Date: Mon, 2 Aug 1999 16:54:10 -0700
> BUTTON&(btnid%) returns the address of a structure that contains, among
>other things, the button's rectangle. Does anyone know of a way to get the
>rect of an EDIT FIELD?

Here's a function that draws a 3D effect around an edit field (and 
hence, has to know the RECT to draw around). It looks best if you 
have a PPAT coloured window in the background (like a lot of the 
dialogs you see that use the light grey background).

So, if you had six edit fields in your window, you'd put in a routine 
in your WNDRefresh function (where ever that lives). Therefore to 
draw the 3D effect around each edit field :

         FOR count=1 TO 6
           FN threeDFX(count):'         draw a 3D edit field around boxes
         NEXT count

This is the function that performs the silicon snake oil magic.

LOCAL FN threeDFX(whichEF):'      draws a 3D shaded box around an edit field
   DIM rect;0,t,l,b,r:'                                   default rect to use
   DIM newFore;0,foreR,foreG,foreB:'            new foreground colours to use
   LONG IF gcolorDepth>=4:'                       do we have a colour system?
     CALL GETFORECOLOR(oldFore):'        record the current foreground colour
     foreR=17476:foreG=17476:foreB=17476:'            sets a dark grey colour
     editHndl&=TEHANDLE(whichEF):'    get a handle to the specific edit field
     LONG IF editHndl&:'    sure we got one, it's probably blow up if not fnd
       CALL RGBFORECOLOR(newFore):'               and reset it on the way out
       BLOCKMOVE [editHndl&],@rect,8:'               get the destination rect
       CALL INSETRECT(rect,-3,-3):'                adjusts it out of the rect
       r=r-2:b=b-2
       PEN 2,2,1,_patCopy,0:'                                set the transfer
       CALL MOVETO(l,t):'                            draw top horizontal line
       CALL LINETO(r,t):'                                   draw the top line
       CALL MOVETO(l,t):'                             draw the left side line
       CALL LINETO(l,b):'      to complete the top and left sides of the rect
       PEN 1,1,1,_patCopy,0:'                                set the transfer
       foreR=61166:foreG=61166:foreB=61166:'                       sets white
       CALL RGBFORECOLOR(newFore):'               and reset it on the way out
       CALL MOVETO(l+2,b):'               draw the 1st bottom horizontal line
       CALL LINETO(r,b):'                                         do that now
       CALL MOVETO(l+1,b+1):'    set up for the second horizontal bottom line
       CALL LINETO(r,b+1):'                                   and draw it now
       CALL MOVETO(r,b+1):'       start setting up the right side of the rect
       CALL LINETO(r,t+2):'                               draw the first line
       CALL MOVETO(r+1,b+1):'                           and now the last line
       CALL LINETO(r+1,t+1):'                    and this will finish the job
       CALL PENNORMAL
     END IF
     CALL RGBFORECOLOR(oldFore):'                 and reset it on the way out
   END IF
END FN

Ain't exactly rocket science huh....;-)


Mel Patrick
mel@...