Gadgets provide essentially the same functionality as the equivalent primitive widgets. They are more efficient in execution time and data space. This performance improvement is so dramatic that applications should use gadgets in place of widgets where ever possible.
NOTE: Since gadgets don't have windows, requests for window id's are reported as errors. Also, gadgets must have a parent that is a widget, .i.e. the parent must have a window.
For a more complete description of this Motif widget, consult "OSF/Motif Programmer's Reference."
arm_action is an action that is executed when mouse button 1 is pressed.
disarm_action is an action that is executed when mouse button 1 is released.
: value sets the current resource to value. Since most resources have mixed case, you should enclose any resource name in quotes. Resource names are the Motif names with the XmN prefix removed. Some resources can only be set before the widget is created. For efficiency, set as many resources as you can before creation.
scalar_value? returns the value of the current resource whose
type is integer.
string_value? returns the value of the current resource whose type is string.
pointer_value? returns the value of the current resource whose type is a pointer of any kind.
create! creates an instance of the widget. Any resources that have been specified prior to the create! will be set. An id? message also sends a create!.
on! realizes the widget. Realizing a widget creates its windows and displays it when it is managed.
<motifinit
motif application= "Arrow Button Gadget Example";
motif_form new: aForm parent=motif ;
scalar new: _arrow_width = 24; scalar new: _arrow_offset = [expr = `-_arrow_width / 2' ?];
! up motif_arrow_button_gadget new: up parent=aForm @ `width' : _arrow_width @ "arrowDirection" : XmARROW_UP @ `topAttachment' : XmATTACH_FORM @ `leftAttachment' : XmATTACH_POSITION @ `leftPosition' : 50 @ `leftOffset' : _arrow_offset arm_action=arm disarm_action=disarm activate_action=activate create! ;
actions new: arm tick_actions+ "!arm"; actions new: disarm tick_actions+ "!disarm"; actions new: activate tick_actions+ "!activate";
!right motif_arrow_button_gadget new: right parent=aForm @ "arrowDirection" : XmARROW_RIGHT @ `rightAttachment' : XmATTACH_FORM @ `topAttachment' : XmATTACH_POSITION @ `topPosition' : 50 @ `topOffset' : _arrow_offset @ `arrowDirection' : XmARROW_RIGHT @ `width' : _arrow_width create! ; !down motif_arrow_button_gadget new: down parent=aForm @ `bottomAttachment' : XmATTACH_FORM @ `leftAttachment' : XmATTACH_POSITION @ `leftPosition' : 50 @ `leftOffset' : _arrow_offset @ `arrowDirection' : XmARROW_DOWN @ `width' : _arrow_width @ "arrowDirection" : XmARROW_DOWN create! ; !left motif_arrow_button_gadget new: left parent=aForm @ "arrowDirection" : XmARROW_LEFT @ `leftAttachment' : XmATTACH_FORM @ `topAttachment' : XmATTACH_POSITION @ `topPosition' : 50 @ `topOffset' : _arrow_offset @ `arrowDirection' : XmARROW_LEFT @ `width' : _arrow_width create! ;
motif_label new: aButton parent=aForm @ "labelString" : "Translate" @ `bottomAttachment' : XmATTACH_WIDGET @ `bottomWidget' : [object # down id?] @ `leftAttachment' : XmATTACH_WIDGET @ `leftWidget' : [object # left id?] @ `rightAttachment' : XmATTACH_WIDGET @ `rightWidget' : [object # right id?] @ `topAttachment' : XmATTACH_WIDGET @ `topWidget' : [object # up id?] create! ;
motif on! start!;