Functions and Directives

Function GraSegPickResolution() Foundation

Determines size of the sensitive region around the mouse pointer used to search for segments.

Syntax
GraSegPickResolution( [<oPS>], ;
                      [<aCenter>], [<aSize>] ) --> lSuccess
Parameters
<oPS>
The argument <oPS> specifies the presentation space in which the sensitive rectangle is defined. If the current window is an XbpCrt window, <oPS>is optional. If it is NIL, the return value of SetAppWindow():presSpace() is used. In all other cases <oPS> is not optional. It must be created using XbpPresSpace():new(). A "Micro PS" cannot be used for this function.
<aCenter> := { <nX>, <nY> }
<aCenter> determines the point within the sensitive rectangle by which the rectangle is fixed to the tip of the mouse pointer. By default this point lies in the middle of the rectangle, meaning it is found at half the width and half the height.
<aSize> := { <nXSize>, <nYSize> }
<aSize> determines the dimension of the sensitive rectangle around the mouse pointer. <nXSize> specifies the number of pixels in the x direction (width) and <nYSize> specifies the number of pixels in the y direction (height). If <aSize> is not specified, the function sets a default size for the rectangle. This corresponds to the cell size of the currently set font (oFont:width and oFont:height; see XbpFont()).
Return

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().

Description

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().

Examples
Setting the size of the sensitive region
// 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 
Feedback

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.