GenView: 4.2 Advanced Concepts and Uses: Documents in a View

Up: GEOS SDK TechDocs | Up | Prev: 4.1 The Life of a View | Next: 4.3 Drawing the Document

The coordinate space is the graphics space owned by your geode for drawing. Your actual data may occupy any portion of it, but the view considers the entire space to be valid. However, you can constrain the view to a certain portion of the coordinate space--for example, if your data only fills 8.5 inches by 11 inches, you can instruct the view to scroll only in that 8.5 by 11 area (or any smaller or larger portion of it).

Document Coordinates

Applications do all their drawing to a device-independent coordinate space. Document coordinates occur in real-world points (72 points per inch). The default graphics system is 8192 points square, with the origin in the middle. The maximum size of a default document is about 113.8 inches on a side. GEOS uses a "large" graphics space as well, represented by 32-bit coordinates that allow documents up to 940 miles on a side. The GenView's coordinates are all given in these 32-bit values to accommodate either the large or the default system.

Your document's data may fill any or all of the coordinate space. Most small documents will have their upper-left corners at the origin and will occupy only a small portion of a 16-bit coordinate space.

Current Origin

GVI_origin, MSG_GEN_VIEW_SET_ORIGIN, MSG_GEN_VIEW_GET_ORIGIN, MSG_GEN_VIEW_SET_ORIGIN_LOW

The GenView must know where in the coordinate space it is located. To do this, it maintains an origin--the upper left coordinates of the window's scrollers. That is, the origin is the upper-left position in the document. The origin is stored in the field GVI_origin , a PointDWFixed structure containing two DWFixed structures. The PointDWFixed structure definition is shown below:

  typedef struct {
	DWFixed		PDF_x;		/* x origin coord */
	DWFixed		PDF_y;		/* y origin coord */
} PointDWFixed;

The view notifies its content each time the origin is changed with the message MSG_META_CONTENT_VIEW_ORIGIN_CHANGED . Typically, the view will also automatically scroll its window to the new origin when the origin changes. You can override this behavior, forcing the view not to scroll on origin changes, by setting the vardata attribute ATTR_GEN_VIEW_DO_NOT_WIN_SCROLL . This attribute, in effect, disconnects the scrollers from the visible position of the document. The notification message MSG_META_CONTENT_VIEW_ORIGIN_CHANGED will still be sent to the content; the window will not scroll, however.

The default origin of the view is (0,0), but this may be set in your Goc code as follows:

GVI_origin = {
    xPosition,			/* x coordinate of origin */
    yPosition			/* y coordinate of origin */
}

You can also change the origin during execution either by causing the view to scroll or by sending a MSG_GEN_VIEW_SET_ORIGIN . To retrieve the view's current origin, use MSG_GEN_VIEW_GET_ORIGIN .

MSG_GEN_VIEW_SET_ORIGIN

void	MSG_GEN_VIEW_SET_ORIGIN(@stack
        sdword	yOrigin,		/* y coordinate of new origin */
        sdword	xOrigin);		/* x coordinate of new origin */

This message changes the view's current origin, causing it to scroll immediately to the new location. The origin represents the upper-left corner of the view in the scrollable document space and is made up of two signed long integers. Each coordinate must be in document coordinates (points).

Source: Unrestricted.

Destination: Any GenView object.

Parameters: yOrigin The new Y coordinate of the origin.

xOrigin
The new X coordinate of the origin.

Return: Nothing.

Interception: Generally not intercepted.

See Also: MSG_GEN_VIEW_SCROLL , MSG_GEN_VIEW_SCROLL_..., MSG_GEN_VIEW_MAKE_RECT_VISIBLE

MSG_GEN_VIEW_GET_ORIGIN

void	MSG_GEN_VIEW_GET_ORIGIN(
        PointDWord *origin);

This message returns a PointDWord structure containing the current X and Y coordinates of the view's origin.

Source: Unrestricted.

Destination: Any GenView object.

Parameters: origin A pointer to an empty PointDWord structure.

Return: The origin pointer will point to a filled structure containing the X and Y coordinates of the current origin. This corresponds to the GenView's GVI_origin field.

Interception: Generally not intercepted.

See Also: MSG_GEN_VIEW_GET_DOC_BOUNDS , MSG_GEN_VIEW_GET_DOC_SIZE

MSG_GEN_VIEW_SET_ORIGIN_LOW

void	MSG_GEN_VIEW_SET_ORIGIN_LOW(@stack
        sdword		yOrigin,
        sdword		xOrigin);

This low-level scroll message is just like MSG_GEN_VIEW_SET_ORIGIN except that it will not propagate to linked views.

Source: Unrestricted--usually encapsulated by MSG_GEN_VIEW_SET_ORIGIN for later dispatch with MSG_GEN_VIEW_SEND_TO_HLINK or MSG_GEN_VIEW_SEND_TO_VLINK handler.

Destination: Any GenView.

Parameters: yOrigin The new vertical origin of the GenView, in document coordinates. For no change, pass GVSOL_NO_CHANGE.

xOrigin
The new horizontal origin of the GenView, in document coordinates. For no change, pass GVSOL_NO_CHANGE.

Return: Nothing.

Interception: Generally not intercepted.

Structures: GVSOL_NO_CHANGE is equal to 0x8000000.

Document Bounds

GVI_docBounds, MSG_GEN_VIEW_SET_DOC_BOUNDS, MSG_GEN_VIEW_GET_DOC_BOUNDS

Because most documents will not actually require the entire document space, the view has an instance data field that defines the view's scrollable boundaries. This field is a RectDWord structure containing four signed dwords, each of which represents a specific boundary of the document. The RectDWord structure is shown below:

  typedef struct {
	sdword		RD_left;		/* left bound */
	sdword		RD_top;		/* top bound */
	sdword		RD_right;		/* right bound */
	sdword		RD_bottom;		/* bottom bound */
} RectDword;

The document bounds are stored in the view's GVI_docBounds instance field. The defaults are shown in the following code; note that each of the values in the field must be in document coordinates.

GVI_docBounds = {0, 0, 0, 0};					/* zero size */

To change the scrollable document bounds at run-time, send the view a message MSG_GEN_VIEW_SET_DOC_BOUNDS . To retrieve the current document bounds, send MSG_GEN_VIEW_GET_DOC_BOUNDS .

MSG_GEN_VIEW_SET_DOC_BOUNDS

void	MSG_GEN_VIEW_SET_DOC_BOUNDS(@stack
        sdword	bottom,		/* new bottom document bound */
        sdword	right,		/* new right document bound */
        sdword	top,		/* new top document bound */
        sdword	left);		/* new left document bound */

This message sets the view's scrollable document bounds to those passed. Each of the four parameters must be given in document coordinates (points), and all are signed long integers. If the new document bounds cause the view to show invalid coordinates, the view will scroll until it is showing valid document space.

Source: Unrestricted.

Destination: Any GenView object.

Parameters: bottom , right , top , left
As described in the header above.

Return: Nothing.

Interception: Generally not intercepted.

MSG_GEN_VIEW_GET_DOC_BOUNDS

void	MSG_GEN_VIEW_GET_DOC_BOUNDS(
        RectDWord *bounds);

This message returns the current boundaries of the view's scrollable document space.

Source: Unrestricted.

Destination: Any GenView object.

Parameters: bounds A pointer to an empty RectDWord structure, to be filled in by the method.

Return: The structure pointed to by bounds will be filled with the current scrollable document boundaries of the GenView, as stored in GVI_docBounds .

Interception: Generally not intercepted.

Current Coordinates in the View

MSG_GEN_VIEW_GET_VISIBLE_RECT

To learn what visible rectangle the view is currently displaying, send it a MSG_GEN_VIEW_GET_VISIBLE_RECT . This message will return the current visible rectangle in document coordinates (a RectDWord structure). If the view is not on the screen, the message will return a structure full of zeros.

MSG_GEN_VIEW_GET_VISIBLE_RECT

void	MSG_GEN_VIEW_GET_VISIBLE_RECT(
        RectDWord *rect);

This message returns the rectangle currently visible in the view, in document coordinates.

Source: Unrestricted.

Destination: Any GenView object.

Parameters: rect A pointer to an empty RectDWord structure to be filled in by the method.

Return: The structure pointed to by rect will contain the bounds of the visible portion of the document. If the view window is not visible on the screen, the structure will contain all zeros.

Interception: Generally not intercepted.

Tips: If your document is particularly complex, you might want to call this message and draw only the visible portions upon receiving either MSG_META_EXPOSED or MSG_VIS_DRAW .


Up: GEOS SDK TechDocs | Up | Prev: 4.1 The Life of a View | Next: 4.3 Drawing the Document