Setting a Window's Parent

To establish a parent-child relationship between two windows use the set window parent function, sw_parent():

void sw_parent(child_wnp, parent_wnp)
 
WINDOWPTR child_wnp;
/* Pointer to the window to set parent of
*/
WINDOWPTR parent_wnp;
/* Pointer to the window's new parent
*/

sw_parent() assigns one window as another window's parent. Making a window a child does not affect the linked list of windows until the window is put up. It will then determine which linked list is modified when the window is placed on the screen. When the child window is put up with wn_up(), it will be linked into the parent's linked list. The row begin and column begin specified in the window definition call are used to place the child window relative to the parent window's interior work area. Any part of the window that does not fit within the parent window's interior work area is not displayed.

sw_parent() is usually called right after a window is defined. It should never be called for a window that is already up.

Caution: When you use sw_parent(), the window row and column begin coordinates in the child window structure are used to place the window relative to its parent's work area. If the user has resized the parent's work area, it is possible that no portion of the child window will be visible when it is set on its parent. If this is a consideration in your application, you can call wn_mod() on the child window after setting the window's parent, to adjust the child window's coordinates so that at least part of the child window is visible. Or, for even more control, you can reference the parent window's row begin, row end, column begin, and column end structure members (wnp->rb, wnp->cb, wnp->re, wnp->ce) directly to determine the size of the parent window's work area. Although it is not generally a good idea to reference Vermont Views structure members directly, the names of the members mentioned above are unlikely to change in future releases.

The wn_child.c tutorial demonstrates the basics of window children.


Home Contents Previous Next