@begin(header)
author: Mark S. Ackerman
show_author: ShowNone
author_organization: MIT Center for Coordination Science
node_expert: ackerman=ag@ics.uci.edu
expiration_date: 12/31/93
last_modifier: ackerman@ics.uci.edu
last_mod_date: 08/28/91
mod_num: 2
@end(header)
@begin(Q)
Date: 6 Jun 89 01:21:55 GMT
Subject: text in label widgets appears too late


I am trying to display 3 images at a time with a label preceeding each
image.  To do this I am using a viewport widget with a form widget
within it.  The images are stored in core widgets and the labels are
label widgets.  All works well, except that the labels each appear as
empty windows until the routine ends and control returns to
XtMainLoop.  At that time the text for each label finally appears.
Well, better late than never, but I really want it to appear at the
same time that the label window appears.  I've tried calling XFlush,
XSync and XtFormDoLayout, but none of these helped.  What am I doing
wrong?
@end(Q)

@begin(A)
Subject: Re: text in label widgets appears too late 
Organization: DEC/MIT Project Athena
Date: Mon, 12 Jun 89 10:36:38 EDT
From: Ralph R. Swick

> All works well, except that the labels each appear as
> empty windows until the routine ends and control returns to
> XtMainLoop.

Xaw/Label will not paint anything until it receives an Expose
event.  You could cons one yourself and dispatch it to the
widget if you really want to block event processing for a while.
@end(A)

@begin(M)
Date: 11 Dec 88 13:07:57 GMT
From: (Richard Hesketh)
Organization: Computing Lab, University of Kent at Canterbury, UK.
Subject: Re: label widget


>I am using a label widget to display a string. [..]

The Label Widget has an added resource, XtNresize, which when set to
FALSE causes the widget not to resize itself to its preferred size during
an XtSetValues call.

Richard Hesketh
@end(M)


@begin(M)
Date: 28 Aug 89 21:12:24 GMT
From: (Paul Asente)
Organization: DEC Western Software Lab
Subject: Re: Changing label

>
>> My problem is : I didn't get message #1 thru #(n-1) on my window,
>> but only the LAST message (#n). 
>> Could anybody help me out with this problem ?
>
>The X toolkit only processes events in XtMainLoop.  Even though you have asked
>the label widget to display a new string the event is not sent to the server
>until you get into XtMainLoop.   A quick fix to the problem is to put an
>XFlush() call into your client after the XtSetValues() call...

Well, close.  When you change the label, the toolkit clears the window to
generate expose events.  The label actually gets repainted as a result of
the expose events, so no repainting will be done until the expose event
arrives.

Additionally, if you are changing the label several times without
processing events in between, by the time the first expose comes back the
label has been changed so that it redisplays using the last value, and not
the first.

The moral of the story is not to use labels for things like this.

	-paul asente
@end(M)

@begin(M)
Date: 29 Aug 89 08:54:06 GMT
From: (Richard Hesketh)
Organization: Computing Lab, University of Kent at Canterbury, UK.
Subject: Re: Changing label


>> Any other suggestion ?
>
>You bet!  Here is a short example program that seems to work correctly.

I assume then that simply calling XtDispatchEvent() with a faked expose
event is frowned upon?  Although it works fine in practice, and looks a
lot cleaner.

Richard
@end(M)

@begin(M)
From: (Chris D. Peterson)
Subject: Re: Beginner question: forcing update of labelWidget display 
Date: Mon, 29 Jan 90 12:00:56 -0500


>    I need to display on "odometer" of sorts. I have been using the 
>  Athena Widgets, specifically the labelWidget...

>   To update the number displayed in the widget, I use [ a call to
> XtSetValues() ]

>  The problem is that the label is not updated very well. If I 
>  try to display a running count from 1 to 100, all I see is the 
>  final value (100). 

>    Is there a way to force the Widget to redisplay after each 
>  XSetValues call? Perhaps there is a better type of widget for
>  this? 

The problem is that the XtSetValues() call clears the Label Widget's
window, and tells that X Server to generate an exposure event for that
window.  The window will not actually get painted until your code
drops back into XtAppMainLoop() and resumes processing events.

Can you work around this?  Yes, but its pretty ugly, and could cause
your application to hang.  I would suggest that you would be better
served by looking to a more event-driven model for you application.

One way to look at toolkit programming is that nothing actually
happens until you drop back into XtAppMainLoop().  All your
application code is just setting state that will get processed once
you drop back into the Event Loop.  Remember that X is inherently
Asynchronous.  Your application will be ** MUCH ** more efficient if
it can also be asynchronous.  Yes, I know there are times when you
have to be synchronous, but in general it is best to work with the
model, rather than against it.

						Chris D. Peterson     
						MIT X Consortium 


@end(M)
