How to draw custom shaped cursor without using an image?

We can customize our cursors in almost every Adobe software. Generally we do so by providing a beautiful image for our custom cursor.

In Acrobat, In addition to customize the cursor, we can draw different shapes in cursor view at run time.
For example: if we want to our cursor to look like a cross hair, across the whole page in pdf & centered at mouse point, for all resolutions available in market.

To initiate our cutom cursor, Create a custom Tool and register its AdjustCursor callback.

static ACCB1 ASBool ACCB2 CursorToolAdjustCursor (AVTool tool, AVPageView pageView, AVDevCoord x, AVDevCoord y)
{
    // Invalidate previously drawn rects
    AVPageViewInvalidateRect(pageView, &g_vRect);
    AVPageViewInvalidateRect(pageView, &g_hRect);
    AVPageViewDrawNow(pageView);
 
   // Get window resolutions
    AVWindow currWindow = AVPageViewGetAVWindow(pageView);
    ASFixedMatrix windowSize = {0};
    AVPageViewGetPageToDevMatrix(pageView, &windowSize);

    g_vRect.left = x;
    g_vRect.top = 0;
    g_vRect.right = x + 1;
    g_vRect.bottom = windowSize.v;

    g_hRect.left = 0;
    g_hRect.top = y;
    g_hRect.right = windowSize.h; 
    g_hRect.bottom = y + 1;

    PDColorValueRec pdVal;
    pdVal.space=PDDeviceRGB;
    pdVal.value[0]=0;
    pdVal.value[1]=0;
    pdVal.value[2]=0;
    AVPageViewSetColor(pageView, &pdVal);
 
   // draw crosshair with centre at current mouse corrdinates
    AVPageViewDrawRect(pageView, &g_vRect);
    AVPageViewDrawRect(pageView, &g_hRect);
    return false;
}
The result looks like a animated cross hair cursor, whose centre is moving with mouse pointer.
 
AVPageViewDrawRect draws the rectangle in the current pageview in which mouse pointer is. Acrobat provides simlar methods like AVPageViewDrawRectOutline, AVPageViewDrawPolygon, AVPageViewDrawPolygonOutline etc. A combination of these methods can be used for more beautiful designs for cursor.
150 150 Burnignorance | Where Minds Meet And Sparks Fly!