From: ezix@ucrengr.ucr.edu (edward j. zix)
Newsgroups: comp.windows.x.motif
Subject: XmForm vs. XmBulletinBoard (challenge)
Date: 25 Jan 93 21:31:41 GMT
Organization: University of California, Riverside


Here is a challenge to all you Motif Widget experts out there.

I am trying to reassign the x/y values of a button at run-time and I
want to use a XmForm to do this.  However I found it only works with
the XmBulletinBoard.

the following program does what I want it to do if a XmBulletinBoard
is used as the manager.  But if the XmForm is used, it doesn't work.

Can anyone get this program to work with the XmForm as a manager instead
of a XmBulletinBoard.  If you can or can't please email me at the
address below and tell me why you can or can't do this.  Please
to not reply to the address in the header because I won't receive it.

----------------

extern "C" {
#include <stdio.h>

#include <X11/Intrinsic.h>
#include <Xm/BulletinB.h>
#include <Xm/Form.h>
#include <Xm/MainW.h>
#include <Xm/PushB.h>
#include <Xm/Xm.h>
}


#define _USE_FORM_              // comment this to use a bulletin

// GLOBAL X target Widget.
Position    theX = 10;
Widget      targetButton;


void
moveCallback(Widget w, caddr_t client_data, caddr_t *call_data) {
    Arg     wargs[2];
    int     n = 0;

    theX += 5;

    XtSetArg(wargs[n], XmNx, theX);
    XtSetValues(targetButton, wargs, 1);
}


main(unsigned int argc, char **argv) {
    Widget  topLevel,
            manager,
            moveButton;
    int     i, n;
    Arg     wargs[10];

    //  Create shell
    topLevel = XtInitialize(argv[0], "FormTest", NULL, 0, &argc, argv);
    n = 0;
    XtSetArg(wargs[n], XmNwidth, 250); n++;
    XtSetValues(topLevel, wargs, n);

    //  Now create a Form or BulletinBoard manager widget.
    n = 0;
    XtSetArg(wargs[n], XmNwidth, 250); n++;
    XtSetArg(wargs[n], XmNheight, 110); n++;
    manager = XtCreateManagedWidget("aManager",
#ifdef  _USE_FORM_
                                        xmFormWidgetClass,
#else
                                        xmBulletinBoardWidgetClass,
#endif
                                        topLevel, wargs, n);

    //  Add the move button to the manager.
    n = 0;
    XtSetArg(wargs[n], XmNx, 10); n++;
    XtSetArg(wargs[n], XmNy, 10); n++;
    moveButton = XtCreateWidget("Move", xmPushButtonWidgetClass,
                                    manager, wargs, n);
    XtAddCallback(moveButton, XmNactivateCallback,
                        moveCallback, (XtPointer)NULL);
    XtManageChild(moveButton);

    // Add the target button to be moved
    n = 0;
    n = 0;
    XtSetArg(wargs[n], XmNx, 10); n++;
    XtSetArg(wargs[n], XmNy, 70); n++;
    targetButton = XtCreateWidget("Target", xmPushButtonWidgetClass,
                                    manager, wargs, n);
    XtManageChild(targetButton);

    XtRealizeWidget(topLevel);
    XtMainLoop();
}
------------------------
Please send your replies to the email address below.  Thanks.

--------------------------------------------------------------------------
Jerry Youngberg      INTERNET: youngber@ymi.com
Software Engineer,  Young Minds, Inc. CD-ROM Solutions for UNIX!
Ph (714)335-1350 FAX (714)798-0488
---> insert standard disclaimer here.