1

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."

astronomerdave
  • 512
  • 1
  • 5
  • 18

2 Answers2

1

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);
astronomerdave
  • 512
  • 1
  • 5
  • 18
  • A side effect of this seems to be that I can no longer move the BulletinBoard anywhere else on the desktop. This is not a killer, but certainly undesirable. – astronomerdave Jun 18 '15 at 22:14
0

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.

FredK
  • 4,094
  • 1
  • 9
  • 11
  • As for your aside @FredK, buttonCB is defined thusly, void buttonCB(Widget w, XtPointer client_data, XtPointer call_data); and you're correct, I don't need the (XtCallbackProc) cast on the callback function. But I *DO* need the (XtPointer) cast on the client data or else I get a warning: passing arg 4 of 'XtAddCallback' makes a ointer from integer without a cast. – astronomerdave Jun 19 '15 at 20:35
  • Just to be clear, this is a BulletinBoardDialog that is created as a popup from pressing a button. I wouldn't want to remove the close button from the toplevel. Indeed, I already have that close button tied to my own callback, XmAddWMProtocolCallback(toplevel, XmInternAtom(display, "WM_DELETE_WINDOW", True), buttonCB, (XtPointer)SHUTDOWN); As I mentioned in the original question, I tried attaching a callback to the close button of the BulletinBoardDialog but that didn't work. – astronomerdave Jun 19 '15 at 22:02