GenView: 2.2 Getting Started: View Basics: Defining the Basic View

Up: GEOS SDK TechDocs | Up | Prev: 2.1 Graphics System Review | Next: 2.3 Handling View Messages

To use a view to display a document, you should define it in your application's Goc code. The view can legally be a child of GenPrimary, GenDisplay, or GenInteraction. In simple applications, the view will be a child of the application's GenPrimary object. More complex applications will have multiple displays with a view in one or more GenDisplay objects.

The most basic view is resizable and has a white background. You may draw any size document in this view, and it will be clipped properly by the windowing system. At its most basic, the view is not scrollable; however, by setting two attributes as shown in The Basic GenView , the view becomes scrollable in both dimensions.

The most common view is resizable and scrollable with a white background. It generally has boundaries on its scrollable area, called document bounds. The Basic GenView shows this type of view.

Notice that the Goc code for the view is simple; much of the power of the view as a display tool rests in its dynamic flexibility. Once the basic view is defined, you can change its scale, color, scrolling behavior, and document bounds simply by sending messages to it. This dynamic flexibility is also exploited extensively by the GenViewControl.

Code Display 9-1 The Basic GenView

/*
 * The GenView object creates a window in which the application may draw all or
 * portions of its document. Whenever a portion of this window becomes "invalid"
 * (when the window is resized or moved, for example), the view will send
 * MSG_META_EXPOSED to its content (in this case the application's Process object)
 * indicating that a redraw is required. The view keeps track of the clipping
 * boundaries and will automatically display the document properly.
 */
/*
 * The view defined here provides a window with the default white background and
 * normal scrolling and sizing behavior. Its document boundaries are set to 11
 * by 17 inches (the default has all bounds set to zero). The view provides
 * scrollbars automatically, and the application does not need to understand how
 * scrolling is implemented; instead, the view will simply request a redraw of the
 * entire document.
 */
@object GenViewClass MyView = {
	/*
	 * The document bounds are set to build an 11 x 17 inch document. Document
	 * coordinates are in 1/72 inch (points), and document bounds must also be
	 * specified in points. The upper-left corner of the document is placed at
	 * (0,0), and the coordinates increase down and right to the far corner
	 * (792, 1224).
	 */
	GVI_docBounds = {
	    0,		/* left bound */
	    0,		/* top bound */
	    792,		/* right bound */
	    1224};		/* bottom bound */
	/*
	 * The GVI_horizAttrs and GVI_vertAttrs fields determine the view's
	 * scrolling, linking, and sizing behavior in the appropriate dimension.
	 * Setting the scrollable attribute in both these fields will make the view
	 * create and maintain scrollers (in OSF/Motif, these will appear as
	 * scrollbars). All scrolling will happen automatically.
	 * These lines are necessary if scrolling is desired.
	 */
	GVI_horizAttrs = @default | GVDA_SCROLLABLE;
	GVI_vertAttrs = @default | GVDA_SCROLLABLE;
	/*  Lastly, we must designate which object (our Process object in this case)
	 * will receive and handle the message to draw the displayed data
	 * (MSG_META_EXPOSED). This object is called the Content object and may
	 * be the Process, a GenContent, or a VisContent.
	 * Note that no message is defined here as with most action descriptors;
	 * the view will send only MSG_META_EXPOSED. You must set this attribute no
	 * matter what object is designated as the content; when using a
	 * GenContent or a VisContent, the object's name should appear in
	 * place of process. */
	GVI_content = process;
}

Up: GEOS SDK TechDocs | Up | Prev: 2.1 Graphics System Review | Next: 2.3 Handling View Messages