[futurebasic] RE: Rotated Text

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

From: Dale Blackwell <dblackwell@...>
Date: Fri, 8 Oct 1999 21:15:06 -0700
I have found a beautiful routine for text rotation available in a folder
"Miscellaneous Examples," in the "Technical," folder, in the "Examples"
folder that came with FB II.  It rotates my text 90° as advertised but I
have one small problem.

The routine permits the user to vary both the color of the text and the
background of the rectangle which is rotated.  However much I try, I can
modify the color of the text but I've had no luck changing the background
color against which the text rests following rotation.  The only color I
can get is white.  There's obviously something here I don't understand.

Has anyone used the following code?  It is by far the simplest I've found
for text rotation (okay, it only rotates to 90° but that's exactly what I
need). Does anyone see how it is possible to alter the background color of
the final text block?


'*******************************************
'* Rotate Pixmap 90°                       *
'* written in FutureBASIC II.              *
'* must have 32-bit QuickDraw to run       *
'*******************************************
'
'
LOCAL MODE
DIM TxtRect.8
DIM boundsT,boundsL,boundsB,boundsR
DIM rectT,rectL,rectB,rectR
DIM ascent,descent,widMax,leading
LOCAL FN RotateTextBox (RTxt$, @TRect&, TxtJ, Font, Size, FrmC, TxtC)
  TxtRect;8 = TRect&
  CALL
SETRECT(boundsT,0,0,TxtRect.Right-TxtRect.Left,TxtRect.Bottom-TxtRect.Top)
  rectT;8   = @boundsT
  LONG IF boundsB > boundsR
    boundsR = boundsB
  XELSE
    boundsB = boundsR
  END IF
  CALL GETGWORLD(oldPort&,oldDevice&)
  myErr=FN NEWGWORLD(offGWorld&,8,boundsT,0,0,_KeepLocal)
  PixMapHndl& = [offGWorld&+_portpixmap]
  Qderr=FN LOCKPIXELS(PixMapHndl&)
  LONG IF myErr=0
    SWAP rectR,rectB    : CALL SETGWORLD(offGWorld&,0)
    CALL TEXTFONT(Font) : CALL TEXTSIZE(Size)
    COLOR TxtC : CALL TEXTBOX(@RTxt$+1,LEN(RTxt$),rectT,TxtJ)
    COLOR FrmC : CALL FRAMERECT(rectT) : SWAP rectR,rectB
    myPixMapHdl& = [offGWorld&+_portpixmap]
    RowBytes%    ={[myPixMapHdl&]+_pmrowbytes} AND &H3FFF
    BlockPtr&    = FN NEWPTR _clear(RowBytes%*(boundsB+1))'* Temp block of mem
    bitsPtr&     = FN GETPIXBASEADDR(myPixMapHdl&)
    FromStart& = bitsPtr&
    FOR J=0 TO boundsB-1                          '* now rotate pixmap data*
      TooStart& = BlockPtr&
      FOR K=boundsR-1 TO 0 STEP -1
        POKE (TooStart&+J),PEEK(FromStart&+K)
        TooStart& = TooStart&  + RowBytes%
      NEXT K
      FromStart&  = FromStart& + RowBytes%
    NEXT J
    BLOCKMOVE BlockPtr&,bitsPtr&,RowBytes%*rectB
    X=FN DISPOSPTR(BlockPtr&)
    CALL SETGWORLD(oldPort&,oldDevice&)
    CALL COPYBITS(#offGWorld&+2,#oldPort&+2,rectT,TxtRect,0,0)
    CALL DISPOSEGWORLD(offGWorld&)
  END IF
END FN
'
'
DIM rect.8

WINDOW 1,"Sample Rotate",(0,0)-(500,400)
LONG COLOR 32767,32767,0
BOX FILL 0,0 TO 9999,9999
COLOR -1
'
CALL SETRECT (rect, 100, 100, 300, 350)
Font=0 : Size=12
Txt$ = "This is a Test of the rotated Text Function. " + CHR$(13)
Txt$ = Txt$+Txt$+Txt$ + "Click Mouse to Exit"
FN RotateTextBox (Txt$, rect, 2, Font, Size, 3 ,7)
'
DO
UNTIL FN BUTTON OR LEN(INKEY$)