Obviously, the automatic scrolling mechanism provided by the ScrolledWindow is much simpler than the
application−defined mechanism and it requires much less application intervention. However, there are some
drawbacks in the implementation of automatic scrolling. Automatic ScrolledWindows only scroll in single−pixel
increments. If other scrolling behavior is required, you must use application−defined scrolling. And while
application−defined scrolling is far more complicated, the advantage is that it provides more flexibility in the ways
that the object is scrolled.
10.2 Creating a ScrolledWindow
Creating a ScrolledWindow is no different from creating other kinds of Motif widgets. Applications that wish to use
ScrolledWindows must include the header file <Xm/ScrolledW.h>. The process of creating a ScrolledWindow is
shown in the following code fragment:
Widget scrollw;
scrollw = XtVaCreateManagedWidget ("name",
xmScrolledWindowWidgetClass, parent,
resource−value−list,
NULL);
The parent can be a Shell or any manager widget. The ScrolledWindow can be created as a managed widget, since
the addition of its child does not cause it to renegotiate its size. (See Chapter 8, Manager Widgets, for a discussion of
when manager widgets should be created as managed or unmanaged widgets.) The resource−value pairs control the
behavior of the ScrolledWindow, as well as its visual effects. The most important resources are
XmN-scrollingPolicy, XmN-visualPolicy, and XmN-scrollBarDisplayPolicy. The value for
XmNscrollingPolicy ...