[comp.windows.x.motif] Can I disable buttons on an XmMessageBox widget?

steve@gabriela.Tymnet.COM (Steve Sandke) (06/13/91)

Sorry if this is a basic question...

I'd like to "turn off" some of the buttons (Help, for example) on an XmMessageBox widget.  Simply
greying them out would be enough.  I know how to do this for a widget, but I don't have an actual widget
for the buttons.

Any help would be greatly appreciated.

-- 
-------------------
Steve Sandke
steve@orchid.tymnet.com

kendall@hottub.b11.ingr.com (Kendall Schmidt) (06/13/91)

In article <500@tymix.Tymnet.COM>, steve@gabriela.Tymnet.COM (Steve Sandke) writes:
|> Sorry if this is a basic question...
|> 
|> I'd like to "turn off" some of the buttons (Help, for example) on an XmMessageBox widget.  Simply
|> greying them out would be enough.  I know how to do this for a widget, but I don't have an actual widget
|> for the buttons.
|> 
|> Any help would be greatly appreciated.
|> 
|> -- 

After you create the message box you can get the widget id of one of its
children by calling XmMessageBoxGetChild.  You can then unmanage the child
widget of the message box.

  Ex:

  XtUnmanageChild( XmMessageBoxGetChild(myMessageBox, XmDIALOG_CANCEL_BUTTON));
  XtUnmanageChild( XmMessageBoxGetChild(myMessageBox, XmDIALOG_HELP_BUTTON));

This will unmanage both the help and cancel buttons of the message box. 
-- 

  Kendall Schmidt	    |	Intergraph Corp.   |	e-mail:
  Graphics Standards	    |	Huntsville, AL.	   |	kendall@ingr.com
  X Window System	    |	205-730-4061	   |	uunet!ingr!kendall

lanzo@wgate.UUCP (Mark Lanzo) (06/13/91)

In a prior article steve@gabriela.Tymnet.COM (Steve Sandke) wrote:
    
SS>  I'd like to "turn off" some of the buttons (Help, for example) 
SS>  on an XmMessageBox widget.  Simply greying them out would be enough.  
SS>  I know how to do this for a widget, but I don't have an actual widget
SS>  for the buttons.

XmMessageBoxGetChild() will return the actual widgets for the buttons.

For instance, to get rid of the help button:

    XtUnmanageChild(XmMessageBoxGetChild(msgbox,XmDIALOG_HELP_BUTTON));

The components you can request are:

    XmDIALOG_CANCEL_BUTTON
    XmDIALOG_DEFAULT_BUTTON
    XmDIALOG_HELP_BUTTON
    XmDIALOG_MESSAGE_LABEL
    XmDIALOG_OK_BUTTON
    XmDIALOG_SEPARATOR
    XmDIALOG_SYMBOL_LABEL

CAUTION:  I believe that some of these components are actually 
implemented as gadgets rather than widgets.  Some operations
you may want to do may be illegal.  For example, you may not be
able to specify a background color for the label.

		-- Mark --

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

ASIDE:  This isn't really related to the subject thread, but my
warning above reminds me of a quibble I have with Motif -  It seems
to me that certain logical operations should transparently work on
either widgets or gadgets, without the programmer having to know
which class of object he is dealing with.  

For example, if you want to know the state of a toggle button widget, 
you need to use the function XmToggleButttonGetState().  If on the 
other hand you have a toggle button *gadget*, you must call 
XmToggleButtonGadgetGetState().  It seems to me that XmToggleButtonGetState
should work for both the widget and the gadget.

I got bitten by this one a while back when I modified a lot of code
to use gadgets instead of widgets.  I spent a lot of time scratching 
my head wondering why things didn't work until I discovered that I was
still using the widget "GetState" routine.  It hadn't even occurred to
me that the gadget was not an essentially transparent replacement for
the widget.

So what's everyone else's opinion on this?

reha@cunixf.cc.columbia.edu (Reha Elci) (06/15/91)

I've tried my best but not from XtSetValues; the only things that seems
to work is right after Xm..Create, read widget values from resources &
do an XtDestroyWidget on them.

Reha Elci

gaf@uucs1.UUCP (gaf) (06/15/91)

For example, to get rid of the HELP button (now why would you want to do that):

XtUnmanageChild(XmMessageBoxGetChild(XmDIALOG_HELP_BUTTON));

This will make the button disappear from the message box.  The other buttons
will be rearranged to fit.
-- 
Guy Finney					It's that feeling of deja-vu
UUCS inc.   Phoenix, Az				all over again.
ncar!noao!asuvax!hrc!uucs1!gaf	sun!sunburn!gtx!uucs1!gaf