Overview of View Management

Views are a rectangular subset of a window.

Views simplify the management of the user interface elements in a window by allowing windows to be broken up into more manageable components. Thus a window with a line of icons along the top, an editable field, and a couple of scrollbars may have several dozen views--one for each scrollbar, one for the edit area, and one for each icon button along the top.

### More about views

Creating Views

YAAF uses the "Visual Basic" model for managing views. Views are considered to be self-contained objects which manage a small subset of the window. Views also expose a custom interface to the rest of the application; some views can b completely self-contained, and some may require access to external databases or files.

There are two ways a veiw can be created; either manually or by reading information about the view's placement from a view resource. View resources are currently created by CompileVRes; this creates a 'VRes' view which defines the location of a view.

Views which are created from a view resource must register themselves with a view factory; this is a mechanism for creating a view from it's definition in a 'VRes' resource.

Rectangular Regions

At it's heart, a view is simply a rectangular subset of a window or a parent's view.

### More on rectangles

Drawing

Drawing in a view is done through the XGDraw object. This is a stack-based object which sets the clipping region to the view's location in the window, sets the coordinate system so that (0,0) is at the upper left of the view.

### More on drawing

Colors

Drawing is performed in RGB space. To maximize portability, the object Color is defined which stores the RGB values of the current foreground or background color. Defined in <XDrawData.h>, this can also store a palette ID for a predefined palette that is used for drawing.

### More on colors.

Fonts

### More on fonts.

Classes

XGOwner

This is the object which "owns" collections of views. Both XGViews and XGWindows are descendant of XGOwner, which means that both can contain at least one view.

XGView

The root of the view management system. To create your own view object (such as a control, an edit region, or something else), you would create a class which inherits it's functionality from the XGView class.

XGPrinter

This is the printer object; this defines a single global object which provides basic printing. (Not available on X.)

XGDraw

The core drawing class; this provides for drawing inside of a view.

XGFont

Basic font handling routine; this manages fonts and font handles in a portable manner.

XGViewFactory

This is the basic view factory object, used internally by YAAF for building views from a 'VRes' resource.

XGArgStream

Created by a view factory to permit a custom view to store static initialization variables in a 'VRes' resource and pull it from the resource.

XGViewTemplate

The view template object; this inserts the specified view into a linked list that is accessed by the XGViewFactory.

Macros

RegisterView

If the view is constructed in the proper fashion, this macro expands to an XGViewTemplate declaration.

RegisterViewID

This constructs the XGViewTemplate from the name of the view class and a different view identifier.