The parameters to the resize procedure are the canvas, and the width and height of the
If you need to handle resize events for the canvas or the view windows, provide an event
handler for those windows, using the attributes WIN_EVENT_PROC and WIN_CON-
(see Section 5.7, “Handling Input in the Canvas Package,” for more informa-
5.5 Scrolling Canvases
Many applications need to view and manipulate a large object through a smaller viewing
window. To facilitate this, packages that are subclassed from the openwin class may have
scrollbars attached to their subwindows.
The following code fragment creates a canvas that can be scrolled in both directions:
Scrollbar h_scrollbar, v_scrollbar;
canvas = (Canvas)xv_create(frame, CANVAS,
h_scrollbar = (Scrollbar)xv_create(canvas, SCROLLBAR,
v_scrollbar = (Scrollbar)xv_create(canvas, SCROLLBAR,
Because the SCROLLBAR package is being used here, the header ﬁle <xview/scrollbar.h> must
be included. Chapter 10, Scrollbars, discusses scrollbars more completely and also gives fur-
ther examples of how to scroll canvases.
The owner of the scrollbars is the canvas so that the scrollbars are automatically attached to
the canvas’s view. If the user scrolls the canvas, your canvas’s repaint procedure will be
called provided that the canvas’s
WIN_RETAINED attribute is set to FALSE. This is important
because setting WIN_RETAINED to TRUE assumes that you are not interested in handling
repainting for scrolling. In other words, as long as the user does not do anything that changes
the contents of the image, you do not need to be informed when the user scrolls the image. If
you want to be informed of scrolling, set
WIN_RETAINED to FALSE and your repaint routine
will be called with the exposed area parameter describing the new area that just scrolled into
view.* If there are many views in the canvas, the paint window associated with the view that
scrolled is in the second parameter to the repaint function: the paint_window.
*The exposed area passed to the repaint procedure is of type Xv_xrectlist if CANVAS_X_PAINT_WINDOW is
set to TRUE or Rectlist if CANVAS_X_PAINT_WINDOW is set to FALSE.
Canvases and Openwin 101