[ Previous | Next | Contents | Glossary | Home | Search ]
Motif 2.1 Widget Writer's Guide


The ExmCommandButton widget class


#include <Exm/CommandB.h>


ExmCommandButton is a demonstration widget. OSF provides this widget solely to teach programmers how to write their own Motif widgets. OSF does not support this widget in any way.

The source code for the ExmCommandButton widget illustrates how to do the following:

  1. Create a Motif button widget. Such a button widget could serve, for example, as an OK button in a Dialog box.

  2. Establish Motif-style actions for buttons.

  3. Install the XmQTactivatable trait.

  4. Install the XmQTtakesDefault trait.

  5. Establish a simple Motif activate callback.

    ExmCommandButton is an instantiable widget.

    ExmCommandButton is a subclass of the ExmString widget and is also used as a superclass for other widgets, such as ExmTabButton. Therefore, ExmCommandButton inherits all of ExmString's resources for rendering compound strings. ExmCommandButton provides many action methods, but ExmString does not.

    When a user activates an ExmCommandButton widget, the widget calls the callback procedure associated with the XmNactivateCallback resource.

  6. Classes

    CommandButton inherits behavior and resources from Core, XmPrimitive, ExmSimple, and ExmString.

    The class pointer is exmCommandButtonWidgetClass.

    The class name is ExmCommandButton.

    New Resources

    The following table defines a set of widget resources used by the programmer 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, ExmN, XmC or ExmC prefix and use the remaining letters. To specify one of the defined values for a resource in a .Xdefaults file, remove the Xm or Exm 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).

    ExmCommandButton Resource Set
    Name Class Type Default Access
    XmNactivateCallback XmCCallback XtCallbackList NULL C

    Specifies the list of callbacks that is called when ExmCommandButton is activated. The type of the structure whose address is passed to this callback is XmAnyCallbackStruct. The reason is XmCR_ACTIVATE.

    Inherited Resources

    CommandButton inherits behavior and resources from the following superclasses. For a complete description of each resource, refer to the reference page for that superclass.

    ExmString Resource Set
    Name Class Type Default Access
    ExmNcompoundString ExmCCompoundString XmString NULL CSG
    XmNalignment XmCAlignment unsigned char XmALIGNMENT_CENTER CSG
    XmNrecomputeSize XmCRecomputeSize Boolean true CSG
    XmNrenderTable XmCRenderTable XmRenderTable dynamic CSG

    ExmSimple Resource Set
    Name Class Type Default Access
    ExmNsimpleShape ExmCSimpleShape unsigned char ExmSHAPE_OVAL CSG
    XmNmarginHeight XmCMarginHeight Dimension 4 CSG
    XmNmarginWidth XmCMarginWidth Dimension 4 CSG

    XmPrimitive Resource Set
    Name Class Type Default Access
    XmNbottomShadowColor XmCBottomShadowColor Pixel dynamic CSG
    XmNbottomShadowPixmap XmCBottomShadowPixmap Pixmap XmUNSPECIFIED_PIXMAP CSG
    XmNconvertCallback XmCCallback XtCallbackList NULL C
    XmNforeground XmCForeground Pixel dynamic CSG
    XmNhelpCallback XmCCallback XtCallbackList NULL C
    XmNhighlightColor XmCHighlightColor Pixel dynamic CSG
    XmNhighlightOnEnter XmCHighlightOnEnter Boolean false CSG
    XmNhighlightPixmap XmCHighlightPixmap Pixmap dynamic CSG
    XmNhighlightThickness XmCHighlightThickness Dimension 2 CSG
    XmNlayoutDirection XmCLayoutDirection XmDirection dynamic CG
    XmNnavigationType XmCNavigationType XmNavigationType XmNONE CSG
    XmNpopupHandlerCallback XmCCallback XtCallbackList NULL C
    XmNshadowThickness XmCShadowThickness Dimension 3 CSG
    XmNtopShadowColor XmCTopShadowColor Pixel dynamic CSG
    XmNtopShadowPixmap XmCTopShadowPixmap Pixmap dynamic CSG
    XmNtraversalOn XmCTraversalOn Boolean true CSG
    XmNunitType XmCUnitType unsigned char dynamic CSG
    XmNuserData XmCUserData XtPointer NULL CSG

    Core Resource Set
    Name Class Type Default Access
    XmNaccelerators XmCAccelerators XtAccelerators dynamic CSG
    XmNancestorSensitive XmCSensitive Boolean dynamic G
    XmNbackground XmCBackground Pixel dynamic CSG
    XmNbackgroundPixmap XmCPixmap Pixmap XmUNSPECIFIED_PIXMAP CSG
    XmNborderColor XmCBorderColor Pixel XtDefaultForeground CSG
    XmNborderPixmap XmCPixmap Pixmap XmUNSPECIFIED_PIXMAP CSG
    XmNborderWidth XmCBorderWidth Dimension 0 CSG
    XmNcolormap XmCColormap Colormap dynamic CG
    XmNdepth XmCDepth int dynamic CG
    XmNdestroyCallback XmCCallback XtCallbackList NULL C
    XmNheight XmCHeight Dimension dynamic CSG
    XmNinitialResourcesPersistent XmCInitialResourcesPersistent Boolean true C
    XmNmappedWhenManaged XmCMappedWhenManaged Boolean true CSG
    XmNscreen XmCScreen Screen * dynamic CG
    XmNsensitive XmCSensitive Boolean true CSG
    XmNtranslations XmCTranslations XtTranslations dynamic CSG
    XmNwidth XmCWidth Dimension dynamic CSG
    XmNx XmCPosition Position 0 CSG
    XmNy XmCPosition Position 0 CSG

    Callback Information

    A pointer to the following structure is passed to each callback:

    typedef struct
    * event;
    } XmAnyCallbackStruct;

    Indicates why the callback was invoked.

    Points to the XEvent that triggered the callback.


    ExmCommandButton provides the following translations:



    ~c <Btn1Down>:

    ExmCommandButtonActivate() ExmCommandButtonDisarm()

    ~s ~m ~a <Key>space:

    ~s ~m ~a <Key>Return:

    In addition to the preceding translations, ExmCommandButton also inherits all the traversal translations of XmPrimitive. For details on these translations, see the XmPrimitive(3) reference page.

    Action Routines

    The ExmCommandButton action routines are as follows:

    If the pointer is within the widget, calls the callback list of XmNactivateCallback.

    Arms the widget. Renders the border in the selected state and the shadow in the armed state.

    Draws the shadow in the armed state. Calls the callbacks named by XmNactivateCallback. Upon completion, draws the shadow in the disarmed state.

    If the widget is armed, this action disarms it. Draws the shadow in the disarmed state.

    If the widget is already armed, draws the shadow in the armed state. Otherwise, this action does nothing.

    If the widget is already armed, draws the shadow in the disarmed state. Otherwise, this action does nothing.

    Virtual Bindings

    For information about bindings for virtual buttons and keys, see VirtualBindings(3).


    Core(3), ExmSimple(3), ExmString(3), and XmPrimitive(3).

    [ Previous | Next | Contents | Glossary | Home | Search ]