[comp.windows.x.motif] Grey-ing things out

david@twg.com (David S. Herron) (09/01/90)

Question:  If you want to leave something on the screen but grey
	it out, how would this be done?

I am using Motif v1.01 from Intel on the Intel System Vr3.2 v2.2.

My application is made up of XmForm widgets containing widgets
of various kinds.  What comes to mind is to have an XmLabel widget
at the same spot, give it a grey pixmap, and give it the same attachments
and size as the object I'm greying out.  But I think that this will
simply make the object disappear.


-- 
<- David Herron, an MMDF & WIN/MHS guy, <david@twg.com>
<- Formerly: David Herron -- NonResident E-Mail Hack <david@ms.uky.edu>
<-
<- Sign me up for one "I survived Jaka's Story" T-shirt!

argv@turnpike.Eng.Sun.COM (Dan Heller) (09/04/90)

In article <7876@gollum.twg.com> david@twg.com (David S. Herron) writes:
> Question:  If you want to leave something on the screen but grey
> 	it out, how would this be done?
What is the object you want to grey out?  I will guess based on what
you said in your message that you have a form that contains a number
of widgets of various assortments and you'd like to grey out *all* of
them at the same time.

To do this, you should use the Xt function XtSetSensitive(widget, value)
where "widget" is a primitive or composite widget and "value" is
either True or False.  If the widget is a form, then the value is
propagated to all the widgets it manages.

Note: text widgets's text won't appear grey -- this may or may not
be a good thing :-)
--
dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.

david@twg.com (David S. Herron) (09/05/90)

In article <141752@sun.Eng.Sun.COM> argv@turnpike.Eng.Sun.COM (Dan Heller) writes:
>In article <7876@gollum.twg.com> david@twg.com (David S. Herron) writes:
>> Question:  If you want to leave something on the screen but grey
>> 	it out, how would this be done?
>What is the object you want to grey out?  I will guess based on what
>you said in your message that you have a form that contains a number
>of widgets of various assortments and you'd like to grey out *all* of
>them at the same time.

No, I want to grey out things individually.

For instance, in one window I have an XmScale which is sometimes active
and sometimes not.  Whether it is active is selected by the setting of
a button elsewhere on the screen.  I have two choices

-- XtUnmanageChild() the XmScale
-- grey it  (somehow)

If I unmanage it, it goes away.  And then, because it's in an XmForm,
the screen repositions itself and it looks kinda ugly.  Maybe I can
be careful with arrangement of objects on the screen so that the
repositioning of the screen doesn't look so ugly.  Maybe not.

"greying" is preferable.  It's a widely used metaphor to indicate
something which currently isn't available.  etc.



-- 
<- David Herron, an MMDF & WIN/MHS guy, <david@twg.com>
<- Formerly: David Herron -- NonResident E-Mail Hack <david@ms.uky.edu>
<-
<- Sign me up for one "I survived Jaka's Story" T-shirt!

argv@turnpike.Eng.Sun.COM (Dan Heller) (09/05/90)

In article <7892@gollum.twg.com> david@twg.com (David S. Herron) writes:
> >> Question:  If you want to leave something on the screen but grey
> >> 	it out, how would this be done?
> No, I want to grey out things individually.

It doesn't matter -- use XtSetSensitive() whether it's on an
individual object or on a composite widget in which you'd like
to grey out the entire lot.  This function sets the XtNsensitive
resource that's common to all widgets.  I don't think it was
clear to you before -- setting this resource to False has the
effect of greying out items.

--
dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.

dbrooks@osf.org (David Brooks) (09/07/90)

In article <7892@gollum.twg.com>, david@twg.com (David S. Herron) writes:
|> If I unmanage it, it goes away.  And then, because it's in an XmForm,
|> the screen repositions itself and it looks kinda ugly.

To avoid this repositioning, use XtUnmap instead of XtUnmanageChild.

|> 
|> "greying" is preferable.  It's a widely used metaphor to indicate
|> something which currently isn't available.  etc.

Agreed.
-- 
David Brooks				dbrooks@osf.org
Systems Engineering, OSF		uunet!osf.org!dbrooks
Experience Hackvergnuegen!

bd@hpopd.HP.COM (Bob Desinger) (09/10/90)

> Question:  If you want to leave something on the screen but grey
> 	it out, how would this be done?

Use XtSetSensitive() on the widget or gadget.
-- bd

dave@objy.objy.com (Dave Hu) (09/11/90)

The XmNsensitive resource of the Core widget class generally controls
this sort of behavior. When True, the widget accepts user input and has
the "normal" appearance. When False, the widget no longer accepts user
input and exhibits the "greyed" appearance. The Motif Programming Reference
suggests using the XtSetSensitive function to manipulate this resource.

I haven't tried this with a simple XmLabel or an XmForm, but since they
inherit from the Core class, I think you've got a good chance of it working... 

Dave.

arm@sps.com (Annette Myjak) (09/14/90)

recently, david@twg.com (David S. Herron) started a discussion about
how to grey things out.  several people suggested using 

XtSetSensitive(widget, False) 

to accomplish this.

i also have several labels that'd i'd like to grey out when their
corresponding text widgets are insensitive.  i tried XtSetSensitive
on these labels, but they're still black, NOT grey.  did i miss
something, or does this not work in my collection of windowing stuff
(Interactive 386's X11R3 and Motif 1.0)?

(was able to make the text widgets insensitive with no problem -- can't
input text here anymore!  but alas, no grey labels as of yet : ( ).


more suggestions?

thanks,
annette myjak
arm@sps.com

blumer@dg-rtp.dg.com (Todd Blumer) (09/14/90)

I have experienced two problems with XtSetSensitive() (or XmNsensitive)
under Motif 1.0.1.

First, setting XmNsensitive to False on PushButtonGadgets will cause the
push button to change size (that is, the buttons previously had their
size explicitly set).

Second, using the XmNsensitive resource on text widgets can sometimes
cause a sigsegv or sigbus.  I did not take the time or effort to
identify the exact sequence of events that caused the sigsegv, but
it went something like:

	type a value into the text box
	set XmNsensitive to False
	...
	set XmNsensitive to True
	change the value in the text box
	... <do some other things> ...
	upon creation of a new text widget, (buried somewhere in the Motif
		library code), a sigsegv occurs.

Has anyone else seen either of these problems?  Do you have a good
solution?  For the text widget, I just made a label describing the
text to be "greyed" and set XmNeditable on the text widget to False.
The sigsegv went away.

--
Todd Blumer (blumer@dg-rtp.dg.com   ...!mcnc!rti!dg-rtp!blumer)
Data General Corp.
Research Triangle Park, NC  27709
(919) 248-6338

argv@turnpike.Eng.Sun.COM (Dan Heller) (09/14/90)

In article <1990Sep13.185713.12667@dg-rtp.dg.com> blumer@dg-rtp.dg.com (Todd Blumer) writes:
> I have experienced two problems with XtSetSensitive() (or XmNsensitive)
> under Motif 1.0.1.
> 
> First, setting XmNsensitive to False on PushButtonGadgets will cause the
> push button to change size (that is, the buttons previously had their
> size explicitly set).

I haven't had such a problem, but I don't set the explicit width of
my widgets (I let the parent do that as it should :-).  It could
be that your problem is more in depth than you think, but it does
seem as tho you found a bug.

> Second, using the XmNsensitive resource on text widgets can sometimes
> cause a sigsegv or sigbus.  I did not take the time or effort to
> identify the exact sequence of events that caused the sigsegv, but
> it went something like:
> 
> 	type a value into the text box
> 	set XmNsensitive to False
> 	...
> 	set XmNsensitive to True
> 	change the value in the text box
> 	... <do some other things> ...

I have had problems doing this exact same thing, but my symptoms
are that the cursor blinks faster and faster until the application
core dumps eventually.  I traced it down to the fact that the Text
widget doesn't reset/turn off its timer correctly and when you reset
the Text's sensitivity, a new timer is added and the old one isn't
relased.  Eventually, it gets overrun.  This is especialy compounded
when you have your own timers in your app.

My solution is that I set a global resources:

    *Text.blinkRate: 0

I don't know if this will help you.
--
dan
----------------------------------------------------
O'Reilly && Associates   argv@sun.com / argv@ora.com
Opinions expressed reflect those of the author only.