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


XmQTdialogShellSavvy

A dialog widget holding this trait can become a child of the XmDialogShell widget

Format

#include <Xm/DialogSavvyT.h>
 
typedef struct {
        	int                             version;
        	XmDialogSavvyMapUnmapProc       callMapUnmapCB;
} XmDialogSavvyTraitRec,*XmDialogSavvyTrait;
void
(*XmDialogSavvyMapUnmapProc)WidgetBoolean

DESCRIPTION

A widget holding the XmQTdialogSavvy trait can become an immediate child of the XmDialogShell widget. In other words, the XmQTdialogSavvy trait announces to the XmDialogShell widget that your widget is an acceptable child.

Every dialog widget that holds the XmQTdialogShellSavvy trait must provide the following:

  1. A callMapUnmapCB trait method

  2. A default position resource

  3. Code that detects an XmDIALOG_SAVVY_FORCE_ORIGIN situation

    Any widget that installs the XmQTdialogShellSavvy trait must provide a Boolean default position resource. For example, ExmGrid and XmBulletinBoard both provide a Boolean default position resource named XmNdefaultPosition. This resource controls the positioning of the DialogShell managing your XmQTdialogShellSavvy widget. This resource has no influence if your XmQTdialogShellSavvy widget is not managed by a DialogShell. For example, if the parent of the DialogShell is an ApplicationShell, then the center of the DialogShell will be at the same coordinates as the center of the ApplicationShell. If the DialogShell becomes unmapped (but stays managed) and then remapped, this resource has no influence on the DialogShell's position. If the default position resource is False, the DialogShell does not automatically center itself. Instead, the DialogShell (and therefore its XmQTdialogShellSavvy child) will be positioned according to the values of XmNx and XmNy. Motif will treat the values of XmNx and XmNy as offsets from the upper-left corner of the screen (rather than as offsets from the upper-left corner of the parent shell).

    The Xm/DialogSavvyT.h header file provides a special macro constant named XmDIALOG_SAVVY_FORCE_ORIGIN. Any widget holding the XmQTdialogShellSavvy trait must use this constant. Here is the problem that XmDIALOG_SAVVY_FORCE_ORIGIN solves. The current position of a dialog child widget within an XmDialogShell widget is always 0,0. Suppose a user or application calls XtSetValues to set the dialog child widget's x-coordinate or y-coordinate to 0. In this case, the Intrinsics will not detect a geometry change and will therefore not trigger a geometry request. To tell the XmDialogShell widget that you really do want the child to move to a coordinate of 0, your dialog child widget must catch this request and respond to it by setting the x-coordinate or y-coordinate to XmDIALOG_SAVVY_FORCE_ORIGIN instead of 0. For example:



      if (my_dialog_widget->core.x == 0)
        my_dialog_widget->core.x = XmDIALOG_SAVVY_FORCE_ORIGIN;
      ...
      if (my_dialog_widget->core.y == 0)
        my_dialog_widget->core.y = XmDIALOG_SAVVY_FORCE_ORIGIN;

    In the standard Motif widget set, the XmBulletinBoard widget and all its subclasses hold the XmQTdialogShellSavvy trait. In the Exm demonstration widget set, the ExmGrid widget installs the XmQTdialogShellSavvy trait.

    The XmDialogShell widget is the only standard Motif widget that examines its children for this trait.

  4. The callMapUnmapCB Trait Method
    void callMapUnmapCBWidget
    dialogWidgetBoolean map_unmap

    All dialog widgets holding the XmQTdialogShellSavvy trait must provide the callMapUnmapCB trait method. The callMapUnmapCB trait method is responsible for calling the map or unmap callback of the widget. For example, following is one possible way of implementing this trait method:



    static void
    CallMapUnmap(
             Widget dialogWidget,
             Boolean map_unmap)
    {
     ExmMyDialogWidget dw = (ExmMyDialogWidget) dialogWidget;
     XmAnyCallbackStruct call_data;
       call_data.reason = map_unmap ? XmCR_MAP: XmCR_UNMAP;
       call_data.event  = NULL;
       if (map_unmap)
         XtCallCallbackList (dialogWidget, dw->my_dialog.map_callback,
                             &call_data);
       else
         XtCallCallbackList (dialogWidget, dw->my_dialog.unmap_callback,
                             &call_data);
    }

    dialogWidget
    Specifies the dialog widget.

    map_unmap
    Specifies a Boolean value. If this value is True, then the trait method should invoke the map callback. If this value is False, then the trait method should invoke the unmap callback.

    RELATED

    XmBulletinBoard(3) and XmDialogShell(3).


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