3.6. Repeater Widget

Application header file <X11/Xaw/Repeater.h>
Class header file <X11/Xaw/RepeaterP.h>
Class repeaterWidgetClass
Class Name Repeater
Superclass Command

The Repeater widget is a subclass of the Command widget; see the Command documentation for details. The difference is that the Repeater can call its registered callbacks repeatedly, at an increasing rate. The default translation does so for the duration the user holds down pointer button 1 while the pointer is on the Repeater.

3.6.1. Resources

When creating a Repeater widget instance, the following resources are retrieved from the argument list or from the resource database:

Name ClassType Notes Default Value
accelerators Accelerators AcceleratorTable NULL
ancestorSensitive AncestorSensitive Boolean DTrue
background Background Pixel XtDefaultBackground
backgroundPixmap Pixmap Pixmap XtUnspecifiedPixmap
bitmap BitmapPixmap None
borderColor BorderColor Pixel XtDefaultForeground
borderPixmap Pixmap Pixmap XtUnspecifiedPixmap
borderWidth BorderWidth Dimension 1
callback Callback XtCallbackList NULL
colormap ColormapColormap Parent's Colormap
comerRoundPercent ComerRoundPercent Dimension 25
cursor CursorCursor None
cursorName Cursor String NULL
decay DecayInt S
depth Depthint CParent's Depth
destroyCallback Callback XtCallbackList NULL
encoding Encoding UnsignedChar XawTextEncoding8bit
flash BooleanBoolean False
font FontXFontStruct XtDeafaltFont
fontSet FontSetXFontSet XtDefaultFontSet
foreground Foreground Pixel XtDefaultForeground
height HeightDimension Agraphic height + 2 * internalHeight
highlightThickness Thickness Dimension A2(0 if Shaped)
initial Delay Delay Int 200
insensiliveBorder Insensitive Pixmap GreyPixmap
internalHight Height Dimension 2
intemalWidth Width Dimension 4
international Inlernational Boolean CFalse
justify JustifyJustify XtJuslifyCenter (center)
label LabelString name of widget
leftBitmap LeftBitmap Bitmap None
mappedWhenManaged MappedWhenManaged Boolean True
minimumDelay MinimumDelay Int 10
pointerColor Foreground Pixel XtDefaultForeground
pointerColorBackground Background Pixel XtDefaultBackground
repeatDelay Delay Int 50
resize ResizeBoolean True
screen ScreenPointer RParent'sScreen
sensitive Sensitive Boolean True
shapeStyle ShapeStyle ShapeSlyle Rectangle
startCallback StartCallback Callback NULL
stopCallback StopCallback Callback NULL
translations Translations TranslationTable See below
width WidthDimension Agraphic width + 2 * internalWidth
xPosition Position 0
yPosition Position 0

accelerators A list of event to action bindings to be executed by this widget, even though the event occurred in another widget. (See the X Toolkit Intrinsics-C Language Interface for details).
ancestorSensitiveThe sensitivity state of the ancestors of this widget. A widget is insensitive if either it or Any of its ancestors is insensitive. This resource should not be changed with XtSetValues, although it may be queried.
backgroundA Pixel Value which indexes the widget's colormap to derive the background color of the widget's window.
backgroundPixmapThe background pixmap of this widget's window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.
bitmapA bitmap to display instead of the label. The default size of the widget will be just large enough to contain the bitmap and the widget's internal width and height. The resource converter for this resource constructs bitmaps from the contents of files. (See section 2.5.3, Bitmap Conversion, for details.) If this bitmap is one bit deep then the l's will be rendered in the fore ground color, and the 0's in the background color. If bitmap has a depth greater than one, it is copied directly into the window.
borderColorA pixel value which indexes the widget's colormap to derive the border color of the widget's window.
borderPixmapThe border pixmap of this widget's window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.
borderWidthThe width of this widget's window border.
callbackA list of routines to be called when the notify action is invoked.
colormapThe colormap that this widget will use.
cornerRoundPercent When a ShapeStyle of roundedRectangle is used, this resource controls the radius of the rounded corner. The radius of the rounded corners is specified as a percentage of the length of the shortest side of the widget.
cursor The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.
cursorName The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.5.1)
decay The number of milliseconds that should be subtracted from each succeeding interval while the Repeater button is being held down until the interval has reached minimumDelay milliseconds.
depth The depth of this widget's window.
destroyCallback All functions on this list are called when this widget is destroyed.
encoding The encoding method used by the value of the label resource. The value may be XawTextEncoding8bit or XawTextEncodingChar2b. When international is set to true this resource is not used.
flash Whether or not to flash the Repeater button whenever the timer goes off.
font The text font to use when displaying the label, when the international resource is false.
fontSetThe text font set to use when displaying the label, when the international resource is true.
foregroundA pixel value which indexes the widget's colormap to derive the foreground color of the widget's window. This color is also used to render all l's in a bitmap one plane deep.
height
widthThe height and width of this widget in pixels.
highlightThicknessThe thickness of the rectangle that is used to highlight the internal border of this widget, alerting the user that it is ready to be selected. The default value is 2 pixels if the shapeStyle is rectangle, and 0 Pixels (no highlighting) otherwise.
initialDelayThe number of milliseconds between the beginning of the Repeater button being held down and the first invocation of the callback function.
insensitiveBorderThis pixmap will be tiled into the widget's border if the widget becomes insensitive.
internalHeight
internalWidthThe minimum amount of space to leave between the graphic and the vertical and horizontal edges of the window.
internationalThis is a boolean flag, only settable at widget creation time. A value of false signals the widget to use pre-R6 internationalization (specifically, the lack thereof), such as using fonts for displaying text, etc. A value of true directs the widget to act in an internationalized manner, such as utilizing font sets for displaying text, etc.
justifySpecifies left, center, or right alignment of graphic within the widget. This resource may be specified with the values XtJustifyLeft, XtJustifyCenter, or XtJustifyRight. A converter is registered for this resource that will convert the following strings: left, right, and center. This resource only has noticeable effect when the width of the widget is larger than necessary to display the graphic. Note that when the graphic is a multi-line label, the longest line will obey this justification while shorter lines will be left-justified with the longest one.
label Specifies the text string to be displayed in the widget's window if no bitmap is specified. The default is the name of this widget. Irregardless of the value of encoding or international, a single newline character (1 byte) will cause a line break.
leftBitmap Specifies a bitmap to display to the left of the graphic in the widget's window.
mappedWhenManaged If this resource is True, then the widget's window will automatically be mapped by the Toolkit when it is realized and managed.
minimumDelay The minimum time between callbacks in milliseconds.
pointerColor A pixel value which indexes the widget's colormap to derive the foreground color of the pointer symbol specified by the cursorName resource.
pointerColorBackground A pixel value which indexes the widget's colormap to derive the background color of the pointer symbol specified by the cursorName resource.
repeatDelay The number of milliseconds between each callback after the first (minus an increasing number of decays).
resize Specifies whether the widget should attempt to resize to its preferred dimensions whenever its resources are modified with XtSetValues. This attempt to resize may be denied by the parent of this widget. The parent is always free to resize the widget regardless of the state of this resource.
screen The screen on which this widget is displayed. This is not a Seattle resource.
sensitive Whether or not the toollkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.
shapeStyle Nonrectangular widgets may be created using this resource. Nonrectangular widgets are supported only on a server that supports the Shape Extension. If nonrectangular widgets are specified for a server lacking this extension, the shape is ignored and the widgets will be rectangular. The following shapes are currently supported: XmuShapeRectangle, XmuShapeOval, XmuShapeEllipse, and XmuShapeRoundedRectangle. A converter is registered for this resource that will convert the following strings: rectangle, oval, ellipse, and roundedRectangle.
startCallback The list of functions to invoke by the start action (typically when the Repeater button is first pressed). The callback data parameter is set to NULL.
stopCallback The list of functions to invoke by the stop action (typically when the Repeater button is released). The callback data parameter is set to NULL.
translations The event bindings associated with this widget.
x
yThe location of the upper left outside corner of this widget in its parent.

3.6.2. Repeater Actions

The Repeater widget supports the following actions beyond those of the Command button:
start( ) This invokes the functions on the startCallback and callback lists and sets a timer to go off in initialDelay milliseconds. The timer will cause the callback functions to be invoked with increasing frequency until the stop action occurs.
stop( ) This invokes the functions on the stopCallback list and prevents any further timers from occurring until the next start action.

The following are the default translation bindings used by the Repeater widget:

<EnterWindow>: highlight( )
<LeaveWindow>: unhighlight( )
<BtnlDown>: set( ) start( )
<BtnlUp>: stop( ) unset( )

Home


3.7. Scrollbar Widget

Application header file <X11/Xaw/Scrollbar.h>
Class header file <X11/Xaw/ScrollbarP.h>
Class scrollbarWidgetClass
Class Name Scrollbar
Superclass Simple

A Scrollbar widget is a rectangle, called the "canvas," on which another rectangle, the " thumb," moves in one dimension, either vertically or horizontally. A Scrollbar can be used alone, as a value generator, or it can be used within a composite widget (for example, a Viewport). When a Scrollbar is used to move, or "scroll," the contents of another widget, the size and the position of the thumb usually give feedback as to what portion of the other widget's contents are visible.

Each pointer button invokes a specific action. Pointer buttons 1 and 3 do not move the thumb automatically. Instead, they return the pixel position of the cursor on the scroll region. When pointer button 2 is clicked, the thumb moves to the current pointer position. When pointer button 2 is held down and the pointer is moved, the thumb follows the pointer.

The pointer cursor in the scroll region changes depending on the current action. When no pointer button is pressed, the cursor appears as a double-headed arrow that points in the direction that scrolling can occur. When pointer button 1 or 3 is pressed, the cursor appears as a single-headed arrow that points in the logical direction that the thumb will move. When pointer button 2 is pressed, the cursor appears as an arrow that points to the top or the left of the thumb.

When the user scrolls, the application receives notification through callback procedures. For both discrete scrolling actions, the callback returns the Scrollbar widget, the client_data, and the pixel position of the pointer when the button was released. For continuous scrolling, the callback routine returns the scroll bar widget, the client data, and the current relative position of the thumb. When the thumb is moved using pointer button 2, the callback procedure is invoked continuously. When either button I or 3 is pressed, the callback procedure is invoked only when the button is released and the client callback procedure is responsible for moving the thumb.

3.7.1. Resources

When creating a Scrollbar widget instance, the following resources are retrieved from the argument list or from the resource database:

Name ClassType Notes Default Value
acceleralors Accelerators AcceleratoTable NULL
ancestorSensitive AncestorScnsilive Boolean DTrue
background Background Pixel XtDefaultBackground
backgroundPixmap Pixmap Pixmap XtUnspecifiedPixmap
borderColor BorderColor Pixel XtDefaultForeground
borderPixmap Pixmap Pixmap XlUnspecificdPixmap
borderWidth BorderWidth Dimension 1
colormap Colormap Colormap parent's Colormap
cursor Cursorcursor None
cursorName Cursor String NULL
depth Depthint Cparent's Depth
destroyCallback Callback XtCallback List NULL
foreground Foreground Pixel XtDefaultForeground
heightHeight DimensionA depends on orientation
insensitiveBorderinsensitive PixmapGreyPixmap
internationalInternational BooleanCFalse
jumpProcCallbackXtCallbackList NULL
lengthLengthDimension 1
mappedWhenManagedMappedWhenManaged BooleanTrue
minimumThumbMinimumThumb Dimension7
orientationOrientation OrientationXtorientVertical (vertical)
pointerColorForeground PixelXtDefaultForeground
pointerColorBackgroundBackground PixelXtDefaultBackground
screenScreenScreen Rparent's Screen
scrollDCursorCursor CursorXC_sb_down_arrow
scrollHCursorCursor CursorXC_sb_h_double_arrow
scrollDCursorCursor CursorXC_sb_left_arrow
scrolLProcCallbackXtCallbackList NULL
scrollRCursorCursor CursorXC_sb_right_arrow
scrollUCursorCursor CursorXC_sb_up_arrow
scrollVCursorCursor CursorXC_sb_v_arrow
sensitiveSensitiveBoolean True
shownShownFloat 0.0
thicknessThicknessDimension 14
thumbThumbBitmap GreyPixmap
thumbProcCallbackXtCallbackList NULL
topOflbhurnbTopONumb Float0.0
translationsTranslations TranslationTableSee below
widthWidthDimension Adepends on orientation
xPositionPosition 0
yPositionPosition 0

accelerators A list of event to action bindings to be executed by this widget, even though the event occurred in another widget. (See the X Toolkit Intrinsics-C Language Interface for details).
ancestorSensitive The sensitivity state of the ancestors of this widget. A widget is insensitive if either it or any of its ancestors is insensitive. This resource should not be changed with XtSetValues, although it may be queried.
background A pixel value which indexes the widget's colormap to derive the background color of the widget's window.
backgroundPixmap The background pixmap of this widget's window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.
borderColor A pixel value which indexes the widget's colormap to derive the border color of the widget's window.
borderPixmap The border pixmap of this widget's window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.
borderWidth The width of this widget's window border.
colormap The colormap that this widget will use.
cursor The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.
cursorName The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.4.1)
depthThe depth of this widget's window.
destroyCallbackAll functions on this list are called when this widget is destroyed.
foregroundA pixel value which indexes the widget's colormap to derive the color used to draw the thumb.
height
widthThe height and width of this widget in pixels.
insensitiveBorderThis pixmap will be tiled into the widget's border if the widget becomes insensitive.
internationalThis is a boolean flag, only settable at widget creation time. While not utilized in this widget, it can and should be checked by any subclasses that have behavior that should vary with locale.
jumpProcAll functions on this callback list are called when the NotifyThumbaction is invoked. See the Scrollbar Actions section for details.
lengthThe height of a vertical scrollbar or the width of a horizontal scrollbar.
mappedWhenManaged If this resource is True, then the widget's window will automatically be mapped by the Toolkit when it is realized and managed.
minimumThumb The smallest size, in pixels, to which the thumb can shrink.
orientation The orientation is the direction that the thumb will be allowed to move. This value can be either XtorientVertical or XtorientHorizontal. A converter is registered for this resource that will convert the following: strings: vertical and horizontal.
pointerColor A pixel value which indexes the widget's colormap to derive the foreground color of the pointer symbol specified by the cursorName resource.
pointerColorBackground A pixel value which indexes the widget's colormap to derive the background color of the pointer symbol specified by the cursorName resource.
screen The screen on which this widget is displayed. This is not a settable resource.
scrollDCursor This cursor is used when scrolling backward in a vertical scrollbar.
scrollHCursor This cursor is used when a horizontal scrollbar is inactive.
scrollDCursor This cursor is used when scrolling forward in a horizontal scrollbar.
scrollProc All functions on this callback list may be called when the NotifyScroll action is invoked. See the Scrollbar Actions section for details.
scrollRCursor This cursor is used when scrolling backward in a horizontal scrollbar, or when thumbing a vertical scrollbar.
scrollUCursor This cursor is used when scrolling forward in a vertical scrollbar, or when thumbing a horizontal scrollbar.
scrollVCursor This cursor is used when a vertical scrollbar is inactive.
sensitive Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.
shown This is the size of the thumb, expressed as a percentage (0.0 - 1.0) of the length of the scrollbar.
thickness The width of a vertical scrollbar or the height of a horizontal scrollbar.
thumb This pixmap is used to tile (or stipple) the thumb of the scrollbar. If no tiling is desired, then set this resource to None. This resource will accept either a bitmap or a pixmap that is the same depth as the window. The resource converter for this resource constructs bitmaps from the contents of files. (See section 2.5.3, Bitmap Conversion, for details.)
topOfThumb The location of the top of the thumb, as a percentage (0.0 - 1.0) of the length of the scrollbar. This resource was called top in previous versions of the Athena widget set. The name collided with the a Form widget constraint resource, and had to be changed.
translations The event bindings associated with this widget.
x
yThe location of the upper left outside corner of this widget in its parent.

3.7.2. Scrollbar Actions

The actions supported by the Scrollbar widget are:
StartScroll(value) The possible values are Forward, Backward, or Continuous. This must be the first action to begin a new movement.
NotifyScroll(value) The possible values are Proportional or FullLength. If the argument to StartScroll was Forward or Backward, NotifyScroll executes the scrollProc callbacks and passes either; the position of the pointer, if value is Proportional, or the full length of the scroll bar, if value is FullLength. If the argument to StartScroll was Continuous, NotifyScroll returns without executing any callbacks.
EndScroll( ) This must be the last action after a movement is complete.
MoveThumb( ) Repositions the Scrollbar's thumb to the current pointer location.
NotifyThumb( ) Calls the jumpProc callbacks and passes the relative position of the pointer as a percentage of the scroll bar length.

The default bindings for Scrollbar are:

<Btnl Down>: StartScroll(Forward)
<Btn2Down>: StartScroll(Continuous) MoveThumb( ) NotifyThumb( )
<Btn3Down>: StartScroll(Backward)
<Btn2Motion>: MoveThumb( ) NotifyThumb( )
<BtnUp>: NotifyScroll(Proportional) EndScroll( )

Examples of additional bindings a user might wish to specify in a resource file are:
*Scrollbar.Translations: \ ~Meta<Key>space: StartScroll(Forward) NotifyScroll(FullLength) \n\ Meta<Key>space: StartScroll(Backward) NotifyScroll(FullLength) \n\ EndScroll( )

3.7.3. Scrollbar Callbacks

There are two callback lists provided by the Scrollbar widget. The procedural interface for these functions is described here.
The calling interface to the scrollProc callback procedure is:

void ScrollProc(scrollbar, client data, position)
Widget scrollbar;
XtPointer client_data;
XtPointer position; /* int */

scrollbar Specifies the Scrollbar widget.
client data Specifies the client data.
posinon Specifies a pixel position in integer form.

The scrollProc callback is used for incremental scrolling and is called by the NotifyScroll action. The position argument is a signed quantity and should be cast to an int when used. Using the default button bindings, button 1 returns a positive value, and button 3 returns a negative value. In both cases, the magnitude of the value is the distance of the pointer in pixels from the top (or left) of the Scrollbar. The value will never be greater than the length of the Scrollbar.

The calling interface to the jumpProc callback procedure is:

void JumpProc(scrollbar, client data, percent)
Widget scrollbar;
XtPointer client data;
XtPointer percent ptr; /* float* */

scrollbar Specifies the ID of the scroll bar widget.
client data pecifies the client data.
prcent_ptr pecifies the floating point position of the thumb (0.0- 1.0).

The jumpProc callback is used to implement smooth scrolling and is called by the NotifyThumb action. Percent_ptr must be cast to a pointer to float before use; i.e.

float percent = *(float*)percent_ptr;

With the default button bindings, button 2 moves the thumb interactively, and the jumpProc is called on each new position of the pointer, while the pointer button remains down. The value specified by percent_ptr is the current location of the thumb (from the top or left of the Scrollbar) expressed as a percentage of the length of the Scrollbar.

3.7.4. Convenience Routines

To set the position and length of a Scrollbar thumb, use XawScrollbarSetThumb.
void XawScrollbarSetThumb(w, top, shown)
Widget w;
float top;
float shown;
w Specifies the Scrollbar widget.
top Specifies the position of the top of the thumb as a Fraction of the length of the Scrollbar.
Shown Specifies the length of the thumb as a fraction of the total length of the Scrollbar.

XawScrollbarThumb moves the visible thumb to a new position (0.0 -1.0) and length (0.0 1.0). Either the top or shown arguments can be specified as -1.0, in which case the current value is left unchanged. Values greater than 1.0 are truncated to 1.0.

If called from jumpProc, XawScrollbarSetThumb has no effect.

3.7.5. Setting Float Resources

The shown and topOfThumb resources are of typefloat. These resources can be difficult to get into an argument list. The reason is that C performs an automatic cast of the float value to an integer value, usually truncating the important information. The following code fragment is one portable method of getting a float into an argument list.

top=0.5;

if (size(float) > sizeof(XtArgVal)) {
/*
* If a float is larger than an XtArgVal then pass this
* resource value by reference.
*/
XtSetArg(args[0], XtNshown, &top);
}
else {
/*
* Convince C not to perform an automatic conversion, which
* would truncate 0.5 to 0.
*/
XtArgVal * I_top = (XtArgVal *) &top;
XtSetArg(args[0], XtNshown, *l_top);
}

Home


3.8. Simple Widget

Application Header file <Xaw/Simple.h>
Class Header file <Xaw/SimpleP.h>
Class simpleWidgetClass
Class Name Simple
Superclass Core

The Simple widget is not very useful by itself, as it has no semantics of its own. It main purpose is to be used as a common superclass for the other simple Athena widgets. This widget adds six resources to the resource list provided by the Core widget and its superclasses.

3.8.1. Resources

When creating a Simple widget instance, the following resources are retrieved from the argument list or from the resource database:

Name ClassType Notes Default Value
accelerator Acceserators AcceleratoTable NULL
ancestorSensitive AncestorSensitive Boolean DTrue
background Background Pixel XtDefaultBackground
backgroundPixmap Pixmap Pixmap XtUnspecifiedPixmap
borderColor BorderColor Pixel XtDefaultForeground
borderPixmap Pixmap Pixmap XtUnspecifiedPixmap
borderWidth BorderWidth Dimension 1
colormap Colormap Colormap Parent's Colormap
cursor CursorCursor None
cursorName Cursor String NULL
depth Depthint CParent's Depth
destroyCallback Callback XtCallbackList NULL
height HeightDimension 0
insensitiveBorder Insensitive Pixmap GreyPixmap
international International Boolean CFalse
mappedWhenManaged MappedWhenManaged Boolean True
pointerColor Foreground Pixel XtDefaultForeground
pointerColorBackground Background Pixel XtDefaultBackground
screen ScreenScreen RParent's Screcn
sensitive Sensitive Boolean True
translations Translations TranslationTable NULL
width WidthDimension 0
xPosition Position 0
yPosition Position 0

accelerators A list of event to action bindings to be executed by this widget, even though the event occurred in another widget. (See the X Toolkit Intrinsics-C Language Interface for details).
ancestorSensitive The sensitivity state of the ancestors of this widget. A widget is insensitive if either it or any of its ancestors is insensitive. This resource should not be changed with XtSetValues, although it may be queried.
background A pixel value which indexes the widget's colormap to derive the background color of the widget's window.
backgroundPixmap The background pixmap of this widget's window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.
borderColor A pixel value which indexes the widget's colormap to derive the border color of the widget's window.
borderPixmap The border pixmap of this widget's window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.
borderWidth The width of this widget's window border.
colormap The colormap that this widget will use.
cursor The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.
cursorName The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.5.1)
depth The depth of this widget's window.
destroyCallbackAll functions on this list are called when this widget is destroyed.
height
widthThe height and width of this widget in pixels.
insensitiveBorderThis pixmap will be tiled into the widget's border if the widget becomes insensitive.
internationalThis is a boolean flag, only settable at widget creation time. While not utilized in this widget, it can and should be checked by any subclasses that have behavior that should vary with locale.
mappedWhenManaged If this resource is True, then the widget's window will automatically be mapped by the Toolkit when it is realized and managed.
pointerColor A pixel value which indexes the widget's colormap to derive the foreground color of the pointer symbol specified by the cursorName resource.
pointerColorBackground A pixel value which indexes the widget's colormap to derive the background color of the pointer symbol specified by the cursorName resource.
screen The screen on which this widget is displayed. This is not a settable resource.
sensitive Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.
translations The event bindings associated with this widget.
x
yThe location of the upper left outside corner of this widget in its parent.

Home


3.9. StripChart Widget

Application Header file <Xaw/StripChart.h>
Class Header file <Xaw/StripCharP.h>
Class stripChartWidgetClass
Class Name StripChart
Superclass Simple

The StripChart widget is used to provide a roughly real time graphical chart of a single value. For example, it is used by the common client program xload to provide a graph of processor load. The StripChart reads data from an application, and updates the chart at the update interval specified.

3.9.1. Resources

When creating a StripChart widget instance, the following resources are retrieved from the argument list or from the resource database:

Name ClassType Notes Defaull Value
accelerators Accelerators AcceleratorTable NULL
ancestorSensitiveAncestorSensitive BooleanDTrue
backgroundBackground PixelXtDefaultBackground
backgroundPixmapPixmap PixmapXtUnspecifiedPixmap
borderColorBorderColor PixelXtDefaultForeground
borderPixmapPixmapPixmap XtUnspecifiedPixmap
borderWidthBorderWidth Dimension1
colormapColormapColorrnap Parent's Colormap
cursorCursorCursor None
cursorNameCursorString NULL
depthDepthint CParent's Depth
destroyCallbackCallback XtCallbackListNULL
foregroundForeground PixelXtDefaultForeGround
getValueCallbackXtCallbackList NULL
heightHeightDimension 120
highlightForeground PixelXtDefaultForeground
insensitiveBorderInsensitive PixmapGreyPixmap
internationalInternational BooleanCFalse
jumpScrollJumpScroll intAhalf the width of the widget
mappedWhenManagedMappedWhenManaged BooleanTrue
minScaleScaleint 1
pointerColorForeground PixelXtDefaultForeground
pointerColorBackgroundBackground PixelXtDefaultBackground
screenScrecnPointer RParent's Screen
sensitiveSensitiveBoolean True
translationTranslations TranslationTableNULL
updateIntcrvalint 10
widthWidthDimension 120
xPositionPosition 0
yPositionPosition 0

accelerators A list of event to action bindings to be executed by this widget, even though the event occurred in another widget. (See the X Toolkit Intrinsics-C Language Interface for details).
ancestorSensitive The sensitivity state of the ancestors of this widget. A widget is insensitive if either it or any of its ancestors is insensitive. This resource should not be changed with XtSetValues, although it may be queried.
background A pixel value which indexes the widget's colormap to derive the background color of the widget's window.
backgroundPixmap The background pixmap of this widget's window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the background color.
borderColor A pixel value which indexes the widget's colormap to derive the border color of the widget's window.
borderPixmap The border pixmap of this widget's window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.
borderWidth The width of this widget's window border.
colormap The colormap that this widget will use.
cursor The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.
cursorName The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.5.1)
depthThe depth of this widget's window.
destroyCallbackAll functions on this list are called when this widget is destroyed.
foregroundA pixel value which indexes the widget's colormap to derive the color that will be used to draw the graph.
getValueA list of callback functions to call every update seconds. This list should contain one function, which returns the value to be graphed by the StripChart widget. The following section describes the procedural interface. Behavior when this list has more than one function is undefined.
height
widthThe height and width of this widget in pixels.
highlightA pixel value which indexes the widget's colormap to derive the color that will be used to draw the scale lines on the graph.
insensitiveBorderThis pixmap will be tiled into the widget's border if the widget becomes insensitive.
internationalThis is a boolean flag, only settable at widget creation time. While not utilized in this widget, it can and should be checked by any subclasses that have behavior that should vary with locale.
jumpScrollWhen the graph reaches the right edge of the window it must be scrolled to the left. This resource specifies the number of pixels it will jump. Smooth scrolling can be achieved by setting this resource to 1.
mappedWhenManaged If this resource is True, then the widget's window will automatically be mapped by the Toolkit when it is realized and managed.
minScale The minimum scale for the graph. The number of divisions on the graph will always be greater than or equal to this value.
pointerColor A pixel value which indexes the widget's colormap to derive the foreground color of the pointer symbol specified by the cursorName resource.
pointerColorBackground A pixel value which indexes the widget's colormap to derive the background color of the pointer symbol specified by the cursorName resource.
screen The screen on which this widget is displayed. This is not a settable resource.
sensitive Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.
translations The event bindings associated with this widget.
update The number of seconds between graph updates. Each update is represented on the graph as a 1 pixel wide line. Every update seconds the getValue procedure will be used to get a new graph point, and this point will be added to the right end of the StripChart.
x
yThe location of the upper left outside corner of this widget in its parent.

3.9.2. Getting the StripChart Value

The StripChart widget will call the application routine passed to it as the getValue callback function every update seconds to obtain another point for the StripChart graph. The calling interface for the getValue callback is:

void (*getValueProc)(w, client_data, value)
Widget w;
XtPointer client data;
XtPointer value; /* double * */

wSpecifies the StripChart widget.
client data Specifies the client data.
valueReturns a pointer to a double. The application should set the address pointed to by this argument to a double containing the value to be graphed on the StripChart.

This function is used by the StripChart to call an application routine. The routine will pass the value to be graphed back to the StripChart in the value field of this routine.

Home


3.10. Toggle Widget

Application Header file <Xaw/Toggle.h>
Class Header file <Xaw/ToggleP.h>
Class toggleWidgetClass
Class Name Toggle
Superclass Command

The Toggle widget is an area, often rectangular, that displays a graphic. The graphic may be a text string containing multiple lines of characters in an 8 bit or 16 bit character set (to be displayed with a font), or in a multi-byte encoding (for use with a fontset). The graphic may also be a bitmap or pixmap.

This widget maintains a Boolean state (e.g. True/False or On/Off) and changes state whenever it is selected. When the pointer is on the Toggle widget, the Toggle widget may become highlighted by drawing a rectangle around its perimeter. This highlighting indicates that the Toggle widget is ready for selection. When pointer button 1 is pressed and released, the Toggle widget indicates that it has changed state by reversing its foreground and background colors, and its notify action is invoked, calling all functions on its callback list. If the pointer is moved off of the widget before the pointer button is released, the Toggle widget reverts to its previous foreground and background colors, and releasing the pointer button has no effect. This behavior allows the user to cancel the operation.

Toggle wpp1oyidgets may also be part of a "radio group." A radio group is a list of at least two Toggle widget in which no more than one Toggle may be set at any time. A radio group is identified by the widget ID of any one of its members. The convenience routine XawToggleGetCurrent will return information about the Toggle widget in the radio group. Toggle widget state is preserved across changes in sensitivity.

3.10.1. Resources

When creating a Toggle widget instance, the following resources are retrieved from the argument list or from the resource database:

Name Class Type NotesDefault Value
accelerators Accelerators AcceleratorTable NULL
ancestorSensitive AncestorScnsitive Boolean DTrue
background Background Pixel XtDefaultBackground
backgroundPixmap Pixmap Pixmap XtUnspecifiedPixmap
bitmap BitmapPixmap None
borderColor BorderColor Pixel XtDefaultForeground
borderPixmap Pixmap Pixmap XtUnspecifiedPixmap
boderWidth BorderWidth Dimension 1
callback Callback XtCallbackList NULL
colormap Colormap Colormap Parent's Colormap
comerRoundPercent cornerRoundPercent Dimension 25
cursor CursorCursor None
cursorName Cursor String NULL
depthDepth intC Parent's Depth
destroyCallbackCallback XtCallbackList NULL
encodingEncoding UnsignedChar XawTextEncoding8bit
fontFont XFontStruct XtDefaultFont
fontSetFontSet XFontSet XtDefaultFontSet
foregroundForeground Pixel XtDefaultForeground
heightHeight DimensionA graphic height + 2 * internalHeight
highlightThickness ThicknessDimension A2 (0 if Shaped)
insensitiveBorderInsensitive Pixmap GreyPixmap
internalHeightHeight Dimension 2
internalWidthWidth Dimension 4
internationalInternational BooleanC False
justifyJustify Justify XtJustifyCenter (center)
labelLabel String nameof widget
leftBitmapLeftBitmap Bitmap None
mappedWhenManagedMappedWhenManaged Boolean True
pointerColorForeground Pixel XtDefaultForeground
pointerColorBackground BackgroundPixel XtDefaultBackground
radioDataRadioData Pointer Name of widget
radioGroupWidget Widget No radio group
resizeResize Boolean True
screenScreen ScreenR Parent's Screen
sensitiveSensitive Boolean True
shapeStypeShapeStyle ShapeStyle Rectangle
stateState Boolean Off
translationsTranslations TranslationTable See below
widthWidth DimensionA graphic width + 2 * internalWidth
xPosition Position 0
yPosition Position 0

accelerators A list of event to action bindings to be executed by this widget, even though the event occurred in another widget. (See the X Toolkit Intrinsics-C Language Interface for details).
ancestorSensitive The sensitivity state of the ancestors of this widget. A widget is insensitive if either it or any of its ancestors is insensitive. This resource should not be changed with XtSetValues, although it may be queried.
background A pixel value which indexes the widget's colormap to derive the background color of the widget's window.
backgroundPixmapThe background pixmap of this widget's window. If this resource is set o anything other than XtUnspecifiedPixmap, the pixmap specified will e used instead of the background color.
bitmapA bitmap to display instead of the label. The default size of the widget ill be just large enough to contain the bitmap and the widget's internal width and height. The resource converter for this resource constructs bit maps from the contents of files. (See section 2.5.3, Bitmap Conversion, for details.) If this bitmap is one bit deep then the 1 's will be rendered in the foreground color, and the 0's in the background color. If bitmap has a depth greater than one, it is copied directly into the window.
borderColorA pixel value which indexes the widget's colormap to derive the border color of the widget's window.
borderPixmapThe border pixmap of this widget's window. If this resource is set to anything other than XtUnspecifiedPixmap, the pixmap specified will be used instead of the border color.
borderWidthThe width of this widget's window border.
callbackA list of routines to be called when the notify action is invoked.
colormapThe colormap that this widget will use.
cornerRoundPercent When a ShapeStyle of roundedRectangle is used, this resource controls the radius of the rounded comer. The radius of the rounded corners is specified as a percentage of the length of the shortest side of the widget.
cursor The image that will be displayed as the pointer cursor whenever it is in this widget. The use of this resource is deprecated in favor of cursorName.
cursorName The name of the symbol to use to represent the pointer cursor. This resource will override the cursor resource if both are specified. (See 2.5.1)
depth The depth of this widget's window.
destroyCallback All functions on this list are called when this widget is destroyed.
encoding The encoding method used by the value of the label resource. The value may be XawTextEncoding8bit or XawTextEncodingChar2b. When international is set to true this resource is not used.
font The text font to use when displaying the label, when the international resource is false.
fontSet The text font set to use when displaying the label, when the international resource is true.
foreground A pixel value which indexes the widget's colormap to derive the foreground color of the widget's window. This color is also used to render all l's in a bitmap one plane deep.
height
width The height and width of this widget in pixels.
highlightThickness The thickness of the rectangle that is used to highlight the internal border of this widget, alerting the user that it is ready to be selected. The default value is 2 pixels if the shapeStyle is rectangle, and 0 Pixels (no highlighting) otherwise.
insensitiveBorderThis pixmap will be tiled into the widget's border if the widget becomes insensitive.
internalHeight
internalWidthThe minimum amount of space to leave between the graphic and the vertical and horizontal edges of the window.
internationalThis is a boolean flag, only settable at widget creation time. A value of false signals the widget to use pre-R6 internationalization (specifically, the lack thereof), such as using fonts for displaying text, etc. A value of true directs the widget to act in an internationalized manner, such as utilizing font sets for displaying text, etc.
justifySpecifies left, center, or right alignment of graphic within the widget. This resource may be specified with the values XtJustifyLeft, XtJustifyCenter, or XtJustifyRight. A converter is registered for this resource that will convert the following strings: left, right, and center. This resource only has noticeable effect when the width of the widget is larger than necessary to display the graphic. Note that when the graphic is a multi-line label, the longest line will obey this justification while shorter lines will be left-justified with the longest one.
label Specifies the text string to be displayed in the widget's window if no bitmap is specified. The default is the name of this widget. Irregardless of the value of encoding or international, a single newline character ( 1 byte) will cause a line break.
leftBitmap Specifies a bitmap to display to the left of the graphic in the widget's window.
mappedWhenManaged If this resource is True, then the widget's window will automatically be mapped by the Toolkit when it is realized and managed.
pointerColor A pixel value which indexes the widget's colormap to derive the foreground color of the pointer symbol specified by the cursorName resource.
pointerColorBackground A pixel value which indexes the widget's colormap to derive the background color of the pointer symbol specified by the cursorName resource.
radioData Specifies the data that will be returned by XawToggleGetCurrent when this is the currently set widget in the radio group. This value is also used to identify the Toggle that will be set by a call to XawToggleSetCurrent. The value NULL will be returned by XawToggleGetCurrent if no widget in a radio group is currently set. Programmers must not specify NULL (or Zero) as radioData.
radioGroup Specifies another Toggle widget that is in the radio group to which this Toggle widget should be added. A radio group is a group of at least two Toggle widgets, only one of which may be set at a time. If this value is NULL (the default) then the Toggle will not be part of any radio group and can change state without affecting any other Toggle widgets. If the widget specified in this resource is not already in a radio group then a new radio group will be created containing these two Toggle widgets. No Toggle widget can be in multiple radio groups. The behavior of a radio group of one toggle is undefined. A converter is registered which will convert widget names to widgets without caching.
resize Specifies whether the widget should attempt to resize to its preferred dimensions whenever its resources are modified with XtSetValues. This attempt to resize may be denied by the parent of this widget. The parent is always free to resize the widget regardless of the state of this resource.
screen The screen on which this widget is displayed. This is not a settable resource.
sensitive Whether or not the toolkit should pass user events to this widget. The widget will not get input events if either ancestorSensitive or sensitive is False.
shapeStyle Nonrectangular widgets may be created using this resource. Nonrectangular widgets are supported only on a server that supports the ShapeExtension. If nonrectangular widgets are specified for a server lacking this extension, the shape is ignored and the widgets will be rectangular. The following shapes are currently supported: XmuShapeRectangle, XmuShapeOval, XmuShapeEllipse, and XmuShapeRoundedRectangle. A converter is registered for this resource that will convert the following strings: rectangle, oval, ellipse, and roundedRectangle.
state Specifies whether the Toggle widget is set (True) or unset (False).
translations The event bindings associated with this widget.
x
yThe location of the upper left outside corner of this widget in its parent.

3.10.2. Toggle Actions

The Toggle widget supports the following actions:

The following are the default translation bindings used by the Toggle widget:

<EnterWindow>: highlight(Always)
<LeaveWindow>: unhighlight( )
<BtnlDown>,<BtnlUp>: toggle( ) notify( )

3.10.3. Toggle Actions

The full list of actions supported by Toggle is:
highlight(condition) Displays the internal highlight border in the color (foreground or background) that contrasts with the interior color of the Toggle widget. The conditions WhenUnset and Always are understood by this action procedure. If no argument is passed then WhenUnset is assumed.
unhighlight( ) Displays the internal highlight border in the color (foreground or background) that matches the interior color of the Toggle widget.
set( )Enters the set state, in which notify is possible. This action causes the Toggle widget to display its interior in the foreground color. The label or bitmap is displayed in the background color.
unset( )Cancels the set state and displays the interior of the Toggle widget in the background color. The label or bitmap is displayed in the foreground color.
toggle( )Changes the current state of the Toggle widget, causing to be set if it was previously unset, and unset if it was previously set. If the widget is to be set, and is in a radio group then this procedure may unset another Toggle widget causing all routines on its callback list to be invoked. The callback routines for the Toggle that is to be unset will be called before the one that is to be set.
reset( )Cancels any set or highlight and displays the interior of the Toggle widget in the background color, with the label displayed in the foreground color.
notify( )When the Toggle widget is in the set state this action calls all functions in the callback list named by the callback resource. The value of the call_data argument in these callback functions is undefined.

NOTE
When a bitmap of depth greater that one (1) is specified the set( ), unset( ), and reset( ) actions have no effect, since there are no foreground and background colors used in a multi-plane pixmap.

3.10.4. Radio Groups

There are typically two types of radio groups desired by applications. The default translations for the Toggle widget implement a "zero or one of many" radio group. This means that there may be no more than one Toggle widget active, but there need not be any Toggle widgets active.

The other type of radio group is "one of many" and has the more strict policy that there will always be exactly one radio button active. Toggle widgets can be used to provide this interface with a slight modification to the translation table of each Toggle in the group.

<EnterWindow>: highlight(Always)
<LeaveWindow>: unhighlight( )
<BtnlDown>,<BtnlUp>: set( ) notify( )

This translation table will not allow any Toggle to be unset except as a result of another Toggle becoming set. It is the application programmer's responsibility to choose an initial state for the radio group by setting the state resource of one of its member widgets to True.

3.10.5. Convenience Routines

The following functions allow easy access to the Toggle widget's radio group functionality.
3.10.5.1. Changing the Toggle's Radio_Group.

To enable an application to change the Toggle's radio group, add the Toggle to a radio group, or remove the Toggle from a radio group, use XawToggleChangeRadioGroup.

void XawToggleChangeRadioGroup(w, radio_group)
Widget w, radio group;
w Specifies the Toggle widget.
radio_group Specifies any Toggle in the new radio group. If NULL then the Toggle will be removed from any radio group of which it is a member.

If a Toggle is already set in the new radio group, and the Toggle to be added is also set then the previously set Toggle in the radio group is unset and its callback procedures are invoked.

Finding the Currently selected Toggle in a radio group of Toggles

To find the currently selected Toggle in a radio group of Toggle widgets use XawToggleGetCurrent.

XtPointerXawToggleGetCurrent(radio_group);
Widget radio_group;
radio_group Specifies any Toggle widget in the radio group.

The value returned by this function is the radioData of the Toggle in this radio group that is currently set. The default value for radioData is the name of that Toggle widget. If no Toggle is set in the radio group specified then NULL is returned.

Changing the Toggle that is set in a radio group.

To change the Toggle that is currently set in a radio group use XawToggleSetCurrent.

void XawToggleSetCurrent(radio_group, radio_data);
Widget radio_group;
XtPointer radio_data;
radio_group Specifies any Toggle widget in the radio group.
radio_data Specifies the radioData identifying the Toggle that should be set in the radio group specified by the radio_group argument.

XawToggleSetCurrent locates the Toggle widget to be set by matching radio_data against the radioData for each Toggle in the radio group. If none match, XawToggleSetCurrent returns without making any changes. If more than one Toggle matches, XawToggleSetCurrent will choose a Toggle to set arbitrarily. If this causes any Toggle widgets to change state, all routines in their callback lists will be invoked. The callback routines for a Toggle that is to be unset will be called before the one that is to be set.

Unsetting all Toggles in a radio group.

To unset all Toggle widgets in a radio group use XawToggleUnsetCurrent.

void XawToggleUnsetCurrent(radio_group);
Widget radio_group;
radio_group Specifies any Toggle widget in the radio group.

If this causes a Toggle widget to change state, all routines on its callback list will be invoked.

Home

Contents Part 1/Chapter 3 Next Chapter