XmScrolledWindow(Xm) 6 January 1993 XmScrolledWindow(Xm) Name XmScrolledWindow - the ScrolledWindow widget class Syntax #include <Xm/ScrolledW.h> Description The ScrolledWindow widget combines one or two ScrollBar widgets and a viewing area to implement a visible window onto some other (usually larger) data display. The visible part of the window can be scrolled through the larger display by the use of ScrollBars. To use ScrolledWindow, an application first creates a ScrolledWindow widget, any needed ScrollBar widgets, and a widget capable of displaying any desired data as the work area of ScrolledWindow. ScrolledWindow posi- tions the work area widget and displays the ScrollBars if so requested. When the user performs some action on the ScrollBar, the application is notified through the normal ScrollBar callback interface. ScrolledWindow can be configured to operate automatically so that it per- forms all scrolling and display actions with no need for application pro- gram involvement. It can also be configured to provide a minimal support framework in which the application is responsible for processing all user input and making all visual changes to the displayed data in response to that input. When ScrolledWindow is performing automatic scrolling it creates a clip- ping window and automatically creates the scroll bars. Conceptually, this window becomes the viewport through which the user examines the larger underlying data area. The application simply creates the desired data, then makes that data the work area of the ScrolledWindow. When the user moves the slider to change the displayed data, the workspace is moved under the viewing area so that a new portion of the data becomes visible. Sometimes it is impractical for an application to create a large data space and simply display it through a small clipping window. For example, in a text editor, creating a single data area that consisted of a large file would involve an undesirable amount of overhead. The application needs to use a ScrolledWindow (a small viewport onto some larger data), but needs to be notified when the user scrolled the viewport so it could bring in more data from storage and update the display area. For these cases the ScrolledWindow can be configured so that it provides only visual layout support. No clipping window is created, and the application must maintain the data displayed in the work area, as well as respond to user input on the ScrollBars. The user can specify resources in a resource file for the automatically created widgets that contain the horizontal and vertical scrollbars of the ScrolledWindow widget. The names of these widgets are ``HorScrollBar'' and ``VertScrollBar'', and remain consistent whether created by XmCreateScrolledList, XmCreateScrolledText or XmCre- ateScrolledWindow. Classes ScrolledWindow inherits behavior and resources from Core, Composite, Con- straint, and XmManager classes. The class pointer is xmScrolledWindowWidgetClass. The class name is XmScrolledWindow. New resources The following table defines a set of widget resources used by the pro- grammer to specify data. The programmer can also set the resource values for the inherited classes to set attributes for this widget. To reference a resource by name or by class in a .Xdefaults file, remove the ``XmN'' or ``XmC'' prefix and use the remaining letters. To specify one of the defined values for a resource in a .Xdefaults file, remove the ``Xm'' prefix and use the remaining letters (in either lowercase or uppercase, but include any underscores between words). The codes in the access column indicate if the given resource can be set at creation time (C), set by using XtSetValues (S), retrieved by using XtGetValues (G), or is not applicable (N/A). XmScrolledWindow resource set ____________________________________________________________________________ Name Class Type Default Access ____________________________________________________________________________ XmNclipWindow XmCClipWindow Widget dynamic G XmNhorizontal- XmCHorizontal- Widget dynamic CSG ScrollBar ScrollBar XmNscrollBar- XmCScrollBar- unsigned char dynamic DisplayPolicy DisplayPolicy XmNscrollBarPlace- XmCScrollBarPlace-unsigned char XmBOTTOM_RIGHT ment ment XmNscrolledWindow- XmCScrolledWindow-Dimension 0 CSG MarginHeight MarginHeight XmNscrolledWindow- XmCScrolledWindow-Dimension 0 CSG MarginWidth MarginWidth XmNscrollingPolicy XmCScrollingPolicyunsigned char XmAPPLICATION_- DEFINED XmNspacing XmCSpacing Dimension 4 CSG XmNtraverseObscured-XmCCallback XtCallbackListNULL CSG Callback XmNvertical- XmCVertical- Widget dynamic CSG ScrollBar ScrollBar XmNvisualPolicy XmCVisualPolicy unsigned char dynamic G XmNworkWindow XmCWorkWindow Widget NULL CSG XmNclipWindow Specifies the widget ID of the clipping area. This is automati- cally created by ScrolledWindow when the XmNvisualPolicy resource is set to XmCONSTANT and can only be read by the application. Any attempt to set this resource to a new value causes a warning mes- sage to be printed by the scrolled window. If the XmNvisualPolicy resource is set to XmVARIABLE, this resource is set to NULL, and no clipping window is created. XmNhorizontalScrollBar Specifies the widget ID of the horizontal ScrollBar. This is au- tomatically created by ScrolledWindow when the XmNscrollingPolicy is initialized to XmAUTOMATIC; otherwise, the default is NULL. XmNscrollBarDisplayPolicy Controls the automatic placement of the ScrollBars. If it is set to XmASNEEDED and if XmNscrollingPolicy is set to XmAUTOMATIC, ScrollBars are displayed only if the workspace exceeds the clip area in one or both dimensions. A resource value of XmSTATIC causes the ScrolledWindow to display the ScrollBars whenever they are managed, regardless of the relationship between the clip win- dow and the work area. This resource must be XmSTATIC when XmNscrollingPolicy is XmAPPLICATIONDEFINED. The default is XmASNEEDED when XmNscrollingPolicy is XmAUTOMATIC, and XmSTATIC otherwise. XmNscrollBarPlacement Specifies the positioning of the ScrollBars in relation to the work window. The following are the values: + XmTOPLEFT -- The horizontal ScrollBar is placed above the work window; the vertical ScrollBar to the left. + XmBOTTOMLEFT -- The horizontal ScrollBar is placed below the work window; the vertical ScrollBar to the left. + XmTOPRIGHT -- The horizontal ScrollBar is placed above the work window; the vertical ScrollBar to the right. + XmBOTTOMRIGHT -- The horizontal ScrollBar is placed below the work window; the vertical ScrollBar to the right. The default value may depend on the value of the XmNstringDirec- tion resource. XmNscrolledWindowMarginHeight Specifies the margin height on the top and bottom of the Scrol- ledWindow. XmNscrolledWindowMarginWidth Specifies the margin width on the right and left sides of the ScrolledWindow. XmNscrollingPolicy Performs automatic scrolling of the work area with no application interaction. If the value of this resource is XmAUTOMATIC, Scrol- ledWindow automatically creates the ScrollBars; attaches call- backs to the ScrollBars; sets the visual policy to XmCONSTANT; and automatically moves the work area through the clip window in response to any user interaction with the ScrollBars. An applica- tion can also add its own callbacks to the ScrollBars. This allows the application to be notified of a scroll event without having to perform any layout procedures. ____________________________________________________________________________ NOTE Since the ScrolledWindow adds callbacks to the ScrollBars, an application should not perform an XtRemoveAll- Callbacks on any of the ScrollBar widgets. ____________________________________________________________________________ When XmNscrollingPolicy is set to XmAPPLICATIONDEFINED, the application is responsible for all aspects of scrolling. The ScrollBars must be created by the application, and it is respon- sible for performing any visual changes in the work area in response to user input. This resource must be set to the desired policy at the time the ScrolledWindow is created. It cannot be changed through XtSet- Values. XmNspacing Specifies the distance that separates the ScrollBars from the work window. XmNtraverseObscuredCallback Specifies a list of callbacks that is called when traversing to a widget or gadget that is obscured due to its position in the work area relative to the location of the ScrolledWindow viewport. This resource is valid only when XmNscrollingPolicy is XmAU- TOMATIC. If this resource is NULL, an obscured widget cannot be traversed to. The callback reason is XmCROBSCUREDTRAVERSAL. XmNverticalScrollBar Specifies the widget ID of the vertical ScrollBar. This is auto- matically created by ScrolledWindow when the XmNscrollingPolicy is initialized to XmAUTOMATIC; otherwise, the default is NULL. XmNvisualPolicy Grows the ScrolledWindow to match the size of the work area, or it can be used as a static viewport onto a larger data space. If the visual policy is XmVARIABLE, the ScrolledWindow forces the ScrollBar display policy to XmSTATIC and allow the work area to grow or shrink at any time and adjusts its layout to accommodate the new size. When the policy is XmCONSTANT, the work area grows or shrinks as requested, but a clipping window forces the size of the visible portion to remain constant. The only time the viewing area can grow is in response to a resize from the ScrolledWindow's parent. The default is XmCONSTANT when XmNscrollingPolicy is XmAUTOMATIC, and XmVARIABLE otherwise. _________________________________________________________________________ NOTE This resource must be set to the desired policy at the time the ScrolledWindow is created. It cannot be changed through XtSetValues. _________________________________________________________________________ XmNworkWindow Specifies the widget ID of the viewing area. Inherited resources ScrolledWindow inherits behavior and resources from the following superc- lasses. For a complete description of each resource, refer to the man page for that superclass. XmManager resource set ____________________________________________________________________________ Name Class Type Default Access ____________________________________________________________________________ XmNbottomShadow- XmCBottomShadow- Pixel dynamic CSG Color Color XmNbottomShadow- XmCBottomShadow- Pixmap XmUNSPECIFIED_- CSG Pixmap Pixmap PIXMAP XmNforeground XmCForeground Pixel dynamic CSG XmNhelpCallback XmCCallback XtCallbackList NULL C XmNhighlightColor XmCHighlightColor Pixel dynamic CSG XmNhighlightPixmapXmCHighlightPixmap Pixmap dynamic CSG XmNinitialFocus XmCInitialFocus Widget NULL CSG XmNnavigationType XmCNavigationType XmNavigationType XmTAB_GROUP CSG XmNshadowThicknessXmCShadowThickness Dimension dynamic CSG XmNstringDirectionXmCStringDirection XmStringDirectiondynamic CG XmNtopShadowColor XmCTopShadowColor Pixel dynamic CSG XmNtopShadowPixmapXmCTopShadowPixmap Pixmap dynamic CSG XmNtraversalOn XmCTraversalOn Boolean True CSG XmNunitType XmCUnitType unsigned char dynamic CSG XmNuserData XmCUserData XtPointer NULL CSG Composite resource set ____________________________________________________________________________ Name Class Type Default Access ____________________________________________________________________________ XmNchildren XmCReadOnly WidgetList NULL G XmNinsertPosition XmCInsertPosition XtOrderProc NULL CSG XmNnumChildren XmCReadOnly Cardinal 0 G Core resource set _______________________________________________________________________________ Name Class Type Default Access _______________________________________________________________________________ XmNaccelerators XmCAccelerators XtAcceleratorsdynamic CSG XmNancestorSensi- XmCSensitive Boolean dynamic G tive XmNbackground XmCBackground Pixel dynamic CSG XmNbackground- XmCPixmap Pixmap XmUNSPECIFIED_- CSG Pixmap PIXMAP XmNborderColor XmCBorderColor Pixel XtDefaultForegroundCSG XmNborderPixmap XmCPixmap Pixmap XmUNSPECIFIED_- CSG PIXMAP XmNborderWidth XmCBorderWidth Dimension 0 CSG XmNcolormap XmCColormap Colormap dynamic CG XmNdepth XmCDepth int dynamic CG XmNdestroyCallback XmCCallback XtCallbackListNULL C XmNheight XmCHeight Dimension dynamic CSG XmNinitialResources-XmCInitialResources-Boolean True C Persistent Persistent XmNmappedWhen- XmCMapped- Boolean True CSG Managed WhenManaged XmNscreen XmCScreen Screen * dynamic CG XmNsensitive XmCSensitive Boolean True CSG XmNtranslations XmCTranslations XtTranslationsdynamic CSG XmNwidth XmCWidth Dimension dynamic CSG XmNx XmCPosition Position 0 CSG XmNy XmCPosition Position 0 CSG Callback information The application must use the ScrollBar callbacks to be notified of user input. ScrolledWindow defines a callback structure for use with XmNtraverseOb- scuredCallback callbacks. The XmNtraverseObscuredCallback resource pro- vides a mechanism for traversal to obscured widgets (or gadgets) due to their position in the work area of a ScrolledWindow. The XmNtraverseOb- scuredCallback routine has responsibility for adjusting the position of the work area such that the specified traversal destination widget is positioned within the viewport of the ScrolledWindow. A NULL XmNtraver- seObscuredCallback resource causes obscured widgets within the Scrol- ledWindow to be non-traversable. Traversal to an obscured widget or gadget requires these conditions to be met: the widget or gadget can be obscured only due to its position in the work area of a ScrolledWindow relative to the viewport; the viewport of the associated ScrolledWindow is fully visible, or can be made so by vir- tue of ancestral XmNtraverseObscuredCallback routines; and the XmNtraver- seObscuredCallback resource must be non-NULL. When ScrolledWindow widgets are nested, the XmNtraverseObscuredCallback routine for each ScrolledWindow that obscures the traversal destination is called in ascending order within the given hierarchy. A pointer to the following structure is passed to callbacks for XmNtraverseObscuredCallback. typedef struct { int reason; XEvent *event; Widget traversal_destination; XmTraversalDirection direction; } XmTraverseObscuredCallbackStruct; reason Indicates why the callback was invoked. event Points to the XEvent that triggered the callback. traversaldestination Specifies the widget or gadget to traverse to, which will be a descendant of the work window. direction Specifies the direction of traversal. See the description of the direction parameter in the XmProcessTraversal man page for an explanation of the valid values. Translations XmScrolledWindow includes the translations from XmManager. Additional behavior This widget has the additional behavior described below: KPageUp: If XmNscrollingPolicy is XmAUTOMATIC, scrolls the window up the height of the viewport. The distance scrolled may be reduced to provide some overlap. The actual distance scrolled depends on the XmNpageIncrement resource of the vertical ScrollBar. KPageDown: If XmNscrollingPolicy is XmAUTOMATIC, scrolls the window down the height of the viewport. The distance scrolled may be reduced to provide some overlap. The actual distance scrolled depends on the XmNpageIncrement resource of the vertical ScrollBar. KPageLeft: If XmNscrollingPolicy is XmAUTOMATIC, scrolls the window left the width of the viewport. The distance scrolled may be reduced to provide some overlap. The actual distance scrolled depends on the XmNpageIncrement resource of the horizontal ScrollBar. KPageRight: If XmNscrollingPolicy is XmAUTOMATIC, scrolls the window right the width of the viewport. The distance scrolled may be reduced to provide some overlap. The actual distance scrolled depends on the XmNpageIncrement resource of the horizontal ScrollBar. KBeginLine: If XmNscrollingPolicy is XmAUTOMATIC, scrolls the window horizontally to the edge corresponding to the horizontal ScrollBar's minimum value. KEndLine: If XmNscrollingPolicy is XmAUTOMATIC, scrolls the window horizon- tally to the edge corresponding to the horizontal ScrollBar's maximum value. KBeginData: If XmNscrollingPolicy is XmAUTOMATIC, scrolls the window verti- cally to the edge corresponding to the vertical ScrollBar's mini- mum value. KEndData: If XmNscrollingPolicy is XmAUTOMATIC, scrolls the window verti- cally to the edge corresponding to the vertical ScrollBar's max- imum value. Certain applications will want to replace the page bindings with ones that are specific to the content of the scrolled area. Geometry management ScrolledWindow makes extensive use of the XtQueryGeometry functionality to facilitate geometry communication between application levels. In the XmAPPLICATIONDEFINED scrolling policy, the WorkWindow's query procedure is called by the ScrolledWindow whenever the ScrolledWindow is going to change its size. The widget calculates the largest possible workspace area and passes this size to the WorkWindow widget's query procedure. The query procedure can then examine this new size and determine if any changes, such as managing or unmanaging a ScrollBar, are necessary. The query procedure performs whatever actions it needs and then returns to the ScrolledWindow. The ScrolledWindow then examines the ScrollBars to see which (if any) are managed, allocates a portion of the visible space for them, and resizes the WorkWindow to fit in the rest of the space. When the scrolling policy is XmCONSTANT, the ScrolledWindow can be queried to return the optimal size for a given dimension. The optimal size is defined to be the size that just encloses the WorkWindow. By using this mechanism, an application can size the ScrolledWindow so that it needs to display a ScrollBar only for one dimension. When the ScrolledWindow's query procedure is called via XtQueryGeometry, the request is examined to see if the width or height has been specified. If so, the routine uses the given dimension as the basis for its calcula- tions. It determines the minimum value for the other dimension that just encloses the WorkWindow, fills in the appropriate elements in the reply structure, and returns to the calling program. Occasionally, using the specified width or height and the other minimum dimension results in nei- ther ScrollBar appearing. When this happens, the query procedure sets both the width and height fields, indicating that in this situation the ideal size causes a change in both dimensions. If the calling application sets both the width and height fields, the ScrolledWindow determines the minimum size for both dimensions and return those values in the reply structure. Virtual bindings The bindings for virtual keys are vendor specific. For information about bindings for virtual buttons and keys, see VirtualBindings(Xm). See also Composite(Xm), Constraint(Xm), Core(Xm), XmCreateScrolledWindow(Xm), XmManager(Xm), XmProcessTraversal(Xm), XmScrollBar(Xm), XmScrollVisible(Xm) and XmScrolledWindowSetAreas(Xm).