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

The Parent's changed_managed Method

The Intrinsics call a parent widget's change_managed method when either of the following happens:

  1. One of its unmanaged children becomes managed.

  2. One of its managed children becomes unmanaged.

    When one of these things happen, the parent widget often must move or resize some of its children. The parent can

    1. Move a child by calling XtMoveWidget

    2. Resize a child by calling XtResizeWidget

    3. Move and/or resize a child by calling either XtConfigureWidget or XmeConfigureObject

      Of these four routines, we recommend using XmeConfigureObject because it is the only routine that knows how to update the appropriate drag and drop fields. Each of the four functions update the appropriate geometry resources of the child and, if the child is realized, reconfigure the child's window.

      The change_managed method of a Motif manager widget must call the XmeNavigChangeManaged routine. The XmeNavigChangeManaged function establishes the correct keyboard traversal policy for all the children of the manager. Typically, your widget calls XmeNavigChangeManaged at the end of the change_managed method.

      The following code from the ExmGrid demonstration widget illustrates how to write a change_managed method:

      static void
              Widget w
       Dimension gridWidth, gridHeight;
       ExmGridWidgetClass gwc = (ExmGridWidgetClass) XtClass(w);
          if (!XtIsRealized(w))  {
        /* If the user or application has set an initial (creation)
           size, honor it. If the user or application has not set
           an initial size, XtWidth and XtHeight will return 0. */
              gridWidth = XtWidth(w);
              gridHeight = XtHeight(w);
          } else {
        /* Otherwise, just force width and height to 0 so that CalcSize
           will recalculate the appropriate size. */
              gridWidth = 0;
              gridHeight = 0;
        /* The CalcSize method determines the ideal size of Grid. */
          if (gwc->grid_class.calc_size)
              (*(gwc->grid_class.calc_size))(w, NULL, &gridWidth,
              CalcSize (w, NULL, &gridWidth, &gridHeight);
       /* Ask parent of Grid if Grid's new size is acceptable. Keep asking
          parent returns either XtGeometryYes or XtGeometryNo. */
          while (XtMakeResizeRequest (w, gridWidth, gridHeight,
                                      &gridWidth, &gridHeight) ==
          /* Now that we have a size for the Grid, we can layout the children
             of the grid. */
          if (gwc->grid_class.layout)
              (*(gwc->grid_class.layout))(w, NULL);
              Layout (w, NULL);
          /* Update keyboard traversal. */
          XmeNavigChangeManaged (w);

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