Ruler Object Library: 4.3 Managing Rulers: Grid Spacing and Constraint

Up: GEOS SDK TechDocs | Up | Prev: 4.2 Mouse Tracking | Next: 4.4 Guide Constraints and Guidelines

Applications which provide rulers often do so to allow the user to work with the mouse more accurately. Such applications might also provide a grid. A grid helps locate the mouse pointer's exact location on the document without the need to watch the ruler. The ruler can also constrain mouse movement to the grid.

To allow the user to change the grid spacing, include a RulerGridControl. The features structures for the RulerGridControl are shown below.

Code Display 19-5 RulerGridControlClass Features

typedef WordFlags  RGCFeatures; 
#define  RGCF_GRID_SPACING 				(0x04)
#define RGCF_SNAP_TO_GRID 				(0x02)
#define RGCF_SHOW_GRID 				(0x01)
#define R GC_DEFAULT_FEATURES \
			(RGCF_GRID_SPACING | RGCF_SNAP_TO_GRID | RGCF_SHOW_GRID)
#define RGC_DEFAULT_TOOLBOX_FEATURES (0)

MSG_VIS_RULER_SHOW_GRID

void MSG_VIS_RULER_SHOW_GRID(); 

Use this message to request that the grid be drawn to the main view, setting the VRA_SHOW_GRID flag.

MSG_VIS_RULER_HIDE_GRID

void MSG_VIS_RULER_HIDE_GRID(); 

Use this message to request that the grid not be drawn to the main view, clearing the VRA_SHOW_GRID flag.

MSG_VIS_RULER_DRAW_GRID

void MSG_VIS_RULER_DRAW_GRID(
        GStateHandle gstate);

This message will draw the grid to the passed GState if the VRA_SHOW_GRID_FLAG is set.

MSG_VIS_RULER_TURN_GRID_SNAPPING_ON

void MSG_VIS_RULER_TURN_GRID_SNAPPING_ON();

Set the default VisRulerConstrainStrategy to support grid snapping, setting the VRCS_SNAP_TO_GRID_X_ABSOLUTE and VRCS_SNAP_TO_GRID_Y_ABSOLUTE flags.

MSG_VIS_RULER_TURN_GRID_SNAPPING_OFF

void MSG_VIS_RULER_TURN_GRID_SNAPPING_OFF();

Set the default VisRulerConstrainStrategy to not include grid snapping, turning off the VRCS_SNAP_TO_GRID_X_ABSOLUTE and VRCS_SNAP_TO_GRID_Y_ABSOLUTE flags.

MSG_VIS_RULER_SET_GRID_SPACING

void MSG_VIS_RULER_SET_GRID_SPACING(
        WWFixedAsDWord spacing);

Set the grid's horizontal and vertical spacing, working with the VRI_grid field.

MSG_VIS_RULER_SET_HORIZONTAL_GRID_SPACING

void MSG_VIS_RULER_SET_HORIZONTAL_GRID_SPACING(
        WWFixedAsDWord spacing);

Set the horizontal grid spacing, leaving the vertical alone.

MSG_VIS_RULER_SET_VERTICAL_GRID_SPACING

void MSG_VIS_RULER_SET_VERTICAL_GRID_SPACING(
        WWFixedAsDWord spacing);

Set the vertical grid spacing, leaving the horizontal alone

MSG_VIS_RULER_GET_GRID_SPACING

void MSG_VIS_RULER_GET_GRID_SPACING(
        GridSpacing* gridspace);

This message returns the current grid spacing.

Structures: This message works with the GridSpacing structure. Do not confuse this structure with the Grid structure.

typedef struct {
	WWFixed GS_y;
	WWFixed GS_x;
} GridSpacing;

MSG_VIS_RULER_GET_STRATEGIC_GRID_SPACING

void MSG_VIS_RULER_GET_STRATEGIC_GRID_SPACING(
        GridSpacing* gridspace);

This message returns a grid spacing that will look nice on the screen at the current scale factor.

Structures: This message works with the GridSpacing structure. Do not confuse this structure with the Grid structure.

typedef struct {
	WWFixed GS_y;
	WWFixed GS_x;
}   GridSpacing;

MSG_VIS_RULER_SNAP_TO_GRID

void MSG_VIS_RULER_SNAP_TO_GRID(
        PointDWFixed _far* point);

This message snaps the passed coordinate to the grid.

Parameters: point Point to snap to grid.

Return: Nothing returned explicitly, however structure in point modified so that point is snapped to grid.

MSG_VIS_RULER_SNAP_TO_GRID_X

void MSG_VIS_RULER_SNAP_TO_GRID_X(
        PointDWFixed _far* point);

Snap the passed point's x coordinate to the grid.

Parameters: point Point to snap to grid.

Return: Nothing returned explicitly, however structure in point modified so that point is snapped to grid.

MSG_VIS_RULER_SNAP_TO_GRID_Y

void MSG_VIS_RULER_SNAP_TO_GRID_Y(
        PointDWFixed _far* point);

Snap the passed point's y coordinate to the grid.

Parameters: point Point to snap to grid.

Return: Nothing returned explicitly, however structure in point modified so that point is snapped to grid.

MSG_VIS_RULER_SNAP_RELATIVE_TO_REFERENCE

void MSG_VIS_RULER_SNAP_RELATIVE_TO_REFERENCE(
        PointDWFixed _far* point);

Returns the point closest to the passed point that is an integral number of grid spacings from the reference point.

Parameters: point Point to snap.

Return: Nothing returned explicitly, however structure in point modified so that point is snapped.

MSG_VIS_RULER_SNAP_RELATIVE_TO_REFERENCE_X

void MSG_VIS_RULER_SNAP_RELATIVE_TO_REFERENCE_X(
        PointDWFixed _far* point);

Returns the point horizontally closest to the passed point that is an integral number of grid spacings from the reference point.

Parameters: point Point to snap.

Return: Nothing returned explicitly, however structure in point modified so that point is snapped.

MSG_VIS_RULER_SNAP_RELATIVE_TO_REFERENCE_Y

void MSG_VIS_RULER_SNAP_RELATIVE_TO_REFERENCE_Y(
        PointDWFixed _far* point);

Returns the point vertically closest to the passed point that is an integral number of grid spacings from the reference point.

Parameters: point Point to snap.

Return: Nothing returned explicitly, however structure in point modified so that point is snapped.


Up: GEOS SDK TechDocs | Up | Prev: 4.2 Mouse Tracking | Next: 4.4 Guide Constraints and Guidelines