Remove close button from BulletinBoard widget in Motif

388 Views Asked by At

Is it possible to remove the close button from a BulletinBoard widget in Motif? Or, alternatively, attach a callback function to it? I know I can do this for the toplevel widget but can't seem to do it for a BulletinBoard.

For the toplevel shell I can do this to attach a callback function to the close button:

XmAddWMProtocolCallback(toplevel, XmInternAtom(display,"WM_DELETE_WINDOW",True),
        (XtCallbackProc)buttonCB, (XtPointer)data);

Or I can remove it entirely with this:

XtVaSetValues(toplevel, XmNmwmFunctions, MWM_FUNC_ALL | MWM_FUNC_CLOSE, NULL);

But neither of these work for a BulletinBoard widget. The latter has no effect. The former gives an error, "Warning: Widget must be a VendorShell."

2

There are 2 best solutions below

1
On

I found a way to do this already. Instead of using XtVaSetValues, I found I can use XtSetArg(myBB, ...) at the time the BB widget is created. In other words,

n=0;
XtSetArg(args[n], XmNheight, 300); n++;
XtSetArg(args[n], XmNwidth,  300); n++;
// ...etc...
XtSetArg(args[n], XmNmwmFunctions, MWM_FUNC_ALL|MWM_FUNC_CLOSE); n++;  // <--- answer
myBB = XmCreateBulletinBoardDialog(parent, "myBB", args, n);
2
On

An XmBulletinBoard widget does not have a close button. You are calling XmCreateBulletinBoardDialog, which creates an XmDialogShell with an XmBulletinBoard as its child.

Your attempt to remove the dialog's close button is incorrect.

You should use

MWM_FUNC_ALL | MWM_FUNC_RESIZE | MWM_FUNC_MOVE | MWM_FUNC_MINIMIZE | MWM_FUNC_MAXIMIZE

But it is much better to tie the close button to your own method as you tries, except you are adding the protocol callback to the wrong widget - you need it on the DialogShell, not the BulletinBoard. So use XtParent(myBB).

As an aside, you should not cast buttonCB in your call; if the compiler is complaining without the cast, your buttonCB function does not have the correct signature.