Function GraSegPickResolution() Foundation
Determines size of the sensitive region around the mouse pointer used to search for segments.
GraSegPickResolution( [<oPS>], ;
[<aCenter>], [<aSize>] ) --> lSuccess
The return value of GraSegPickResolution() is .T. (true) when the sensitive rectangle was defined, otherwise it is .F. (false). If the return value equals .F., the cause of error can be determined using GraError().
The function GraSegPickResolution() determines the resolution with which graphic segments are found using the function GraSegFind(). A rectangular area is defined around the mouse pointer and is moved along with the mouse pointer. If this rectangle overlaps a graphic segment, the corresponding segment ID is included in the array returned by GraSegFind().
// In the example three different colored segments are drawn.
// When the left mouse button clicks in a segment, the priority
// of the applicable segment is placed first so that the
// clicked segment is brought into the foreground.
// By pressing F10, values for the size of the sensitive
// rectangle around the mouse pointer used to find the
// segments can be changed.
#include "Gra.ch"
#include "Xbp.ch"
#include "Appevent.ch"
PROCEDURE Main
LOCAL nBox1, nBox2, nArc, aAttr, aColor, bSetColor
LOCAL aSegment, aFound, mp1, mp2, nEvent := xbe_None
LOCAL GetList := {}, nX, nY
CLS
// area attributes for
aAttr := Array( GRA_AA_COUNT ) // circle and box
aAttr [ GRA_AA_SYMBOL ] := GRA_SYM_HALFTONE
// code block to change color
bSetColor := {|nColor| aAttr [ GRA_AA_COLOR ] := nColor, ;
GraSetAttrArea( NIL, aAttr ) }
// graphic mouse coordinates
SetAppWindow():mouseMode := XBPCRT_MOUSEMODE_PM
SetMouse(.T.) // activate mouse
aSegment := {}
aColor := { GRA_CLR_RED, GRA_CLR_GREEN, GRA_CLR_BLUE }
AAdd( aSegment, GraSegOpen( NIL, GRA_SEG_MODIFIABLE ) )
Eval( bSetColor, aColor[1] ) // create segments (red box)
GraBox( NIL, { 80,120}, {200,200}, GRA_FILL )
GraSegClose()
AAdd( aSegment, GraSegOpen( NIL, GRA_SEG_MODIFIABLE ) )
Eval( bSetColor, aColor[2] ) // green box
GraBox( NIL, {150, 70}, {330,150}, GRA_FILL )
GraSegClose()
AAdd( aSegment, GraSegOpen( NIL, GRA_SEG_MODIFIABLE ) )
Eval( bSetColor, aColor[3] ) // blue circle
GraArc( NIL, {120,100}, 80,,,, GRA_FILL )
GraSegClose()
DO WHILE nEvent <> xbeM_RbClick // cancel with right mouse click
nEvent := AppEvent( @mp1, @mp2,,0 )
IF nEvent == xbeM_LbDown // left mouse click
aFound := GraSegFind(NIL, mp1 )
@ MaxRow(),0 SAY Space(80)
IF ! Empty( aFound ) // segment in foreground
GraSegPriority( NIL, aFound[1], 0, GRA_SEG_HIGHER_PRI )
GraSegDraw( NIL, aFound[1] )
SetPos( MaxRow(), 0 )
Aeval( aFound, {|n| QQout(n)} )
ENDIF
ELSEIF nEvent == xbeK_F10 // input new values
SetMouse(.F.) // deactivate mouse
nX := 16 // for input
nY := 8
SetCursor(1)
@ 0,0 SAY "Resolution in X:" GET nX PICTURE "99"
@ 1,0 SAY "Resolution in Y:" GET nY PICTURE "99"
READ
SetCursor(0)
SetMouse(.T.)
IF Updated() // resize sensitive region
GraSegPickResolution( , , {nX,nY} )
ENDIF
ENDIF
ENDDO
RETURN
If you see anything in the documentation that is not correct, does not match your experience with the particular feature or requires further clarification, please use this form to report a documentation issue.