The CW_DICE function creates a compound widget that implements a single die. The widget uses a button with a bitmap label. If the user presses the button, the die tumbles for a moment, then the new value is displayed and an event is issued.

The primary purpose of this compound widget is to serve as a full example of a realistic compound widget for the IDL User's Guide .

The returned value of this function is the widget ID of the newly-created die widget.

This routine is written in the IDL language. Its source code can be found in the file in the lib subdirectory of the IDL distribution.

Calling Sequence

Result = CW_DICE( Parent )



The widget ID of the parent widget.



The widget simulates the tumbling of a dice by changing the bitmap on the dice several times before settling down to a final value. The number of "tumbles" is specified by the TUMBLE_CNT keyword. The default is 10.


The amount of time in seconds between each tumble of the dice. The default is .05 seconds.


The "user value" to be assigned to the widget.


The widget ID returned by most compound widgets is actually the ID of the compound widget's base widget. This means that many keywords to the WIDGET_CONTROL and WIDGET_INFO routines that affect or return information on base widgets can be used with compound widgets.

To get or set the value of a CW_DICE widget, use the GET_VALUE and SET_VALUE keywords to WIDGET_CONTROL. The value of a CW_DICE widget is an integer in the range [1,6].

If a value outside the range [1,6] is specified by the SET_VALUE keyword, the die tumbles to a new value as if the user had pressed the button, but no event is issued.

See Compound Widgets for a more complete discussion of controlling compound widgets using WIDGET_CONTROL and WIDGET_INFO .

Widget Events Returned by the CW_DICE Widget

This widget generates event structures with the following definition:

event = {CW_DICE_EVENT, ID: base, TOP:, HANDLER: 0L, VALUE:0}

The VALUE field is the value of the die face. Such events are only sent when the user presses the dice button.


See Using CW_DICE in a Widget Program for an example using CW_DICE.