From: | David McMinn |
Date: | 14 Aug 2001 at 16:32:06 |
Subject: | Re: Clipprint |
Hi Thilo
> Does anyone know a how to print a Text into
> a window while the text can be clipped on the left & right
> side (maybe from top and bottom too).
You need to use layers.library. Here's a piece of code from my Viewfonts
program which does it:
DEFTYPE.Rectangle myrect ; Bounds of a rectangle which encloses preview
DEFTYPE.Region *new_region, *old_region ; Two regions, used for clipping
; the text to the Rectangle
DEFTYPE._RastPort *mycliprp ; The rastport with the clipping region set
; Address of rastport in window, I suppose you could use RastPort(x)
*mycliprp = *e\_window\RPort
; Set up boundaries for clip region, taking origin from top left
; of window.
myrect\MinX = *e\_window\BorderLeft + 4
myrect\MinY = *e\_window\BorderTop + y1
myrect\MaxX = *e\_window\Width - *e\_window\BorderRight - 4
myrect\MaxY = myrect\MinY + y2 - y1
; Create a new region, and if successfully created, set the bounds of it
; (from rectangle)
*new_region = NewRegion_
If *new_region
; I think this creates the mask for the clipping
If OrRectRegion_(*new_region, &myrect)
*old_region = InstallClipRegion_(*e\_window\WLayer, *new_region)
; ALL graphics.library COMMANDS ARE NOW CLIPPED!!
; I used graphics.library things to print my text just to make sure,
; for example:
;SetRast_ *mycliprp,..... ; to clear the clipped area of the rastport
;Move_ *mycliprp,x,y ; Move graphics cursor to position
;Text_ *mycliprp,&text$,Len(text$) ; Draw text
; Restore old clipping region and free the newer one.
*new_region = InstallClipRegion_(*e\_window\WLayer, *old_region)
FreeScreenDrawInfo_ *e\_screen,*sdi:*sdi=0
End If
DisposeRegion_ *new_region
*new_region = 0
End If
---------------------------------------------------------------------
To unsubscribe, e-mail: blitz-list-unsubscribe@netsoc.ucd.ie
For additional commands, e-mail: blitz-list-help@netsoc.ucd.ie