[comp.windows.x] Popup Dialog box: Some Questions!!

milind@aramis.rutgers.edu (Milind Deshpande) (08/14/89)

Donna Converse posted a sample code in this newsgroup about a week ago
which shows how a popup dialog box can be implemented. I have some questions
about the code and anyone on the net who saw the same code, please help me out.
(I mailed the same message to Donna, but it probably didn't get through.)

        1.  Where are XtNinput and XtNallowShellResize described? I was unable
to locate them in the Intrinsics manual. The reason for using these resources
in this code is not clear to me.

        2.  Why do you have to execute BOTH of the following in PopupPrompt()
routine? What is the exact difference between these 2 calls with respect to
a popup shell?
                XtRealizeWidget (popup);
                XtPopup (popup, ...);

        Can you not just XtPopup(popup, ...)? I read somewhere that a popup
shell need not be "realized" if you execute 'XtPopup()' on it. I removed
XtRealizeWidget() call, and the program works!

        3. Can anyone send me the description of "XtDialogAddButton()" routine?
It is not described in the Instrisics manpages.

        4. I ran this program, opened the main "popup" window and positioned
it on the screen. Then I MOVED it interactively BEFORE clicking on the
button named "Press to see Simple Demo". The Dialog window appeared at a
place where the main "popup" window had FIRST appeared.
(I had same problem with another program I wrote. The popup menu does
not 'move' with the main window when the main window is moved to another place
using window manager.) I want the dialog window to move with the "main window".
How can I obtain such a behaviour? Is the Window Manager causing this 
problem?

        Thanks.
Milind Deshpande (milind@alux5.att.com)

converse@EXPO.LCS.MIT.EDU (Donna Converse) (08/15/89)

> Donna Converse posted a sample code in this newsgroup about a week ago
> which shows how a popup dialog box can be implemented. I have some questions
> about the code and anyone on the net who saw the same code, please help me out.

>         1.  Where are XtNinput and XtNallowShellResize described? 

Intrinsics Section 4.1.3  "ShellPart Default Values"

> The reason for using these resources in this code is not clear to me.

Setting the input resource of the shell widget to true lets the window
manager know that your application expects to receive user keyboard and/or
mouse events.   Some window managers will not pass on events to the
application unless the application has indicated that it takes input.

Setting XtNallowShellResize to true will allow the shell to make resize
requests of the window manager in response to a resize request from the 
the child of the shell.  Suppose the user, in the example code, types
in a color name that is really long.  The popup window expands as the
input area expands, because XtNallowShellResize is true.   In the example
code, I set resizable on the value, but I forgot to set it on the label.
If you set resizable on the label you'll see the shell resize as the prompt
grows and shrinks.

>         2.  Why do you have to execute BOTH of the following in PopupPrompt()
> routine?  What is the exact difference between these 2 calls with respect to
> a popup shell?
>                 XtRealizeWidget (popup);
>                 XtPopup (popup, ...);

Good, you got me!   You don't have to execute both.
See section 5.3 "Creating Popup Children".  XtPopup will call XtRealizeWidget.

>         Can you not just XtPopup(popup, ...)? I read somewhere that a popup
> shell need not be "realized" if you execute 'XtPopup()' on it. I removed
> XtRealizeWidget() call, and the program works!

You are right on all points: there is no particular reason to call
XtRealizeWidget in this example.  Section 5.3 gives a reason why some
implementations would want to realize before calling XtPopup.

> 
>         3. Can anyone send me the description of "XtDialogAddButton()" routine?
> It is not described in the Instrisics manpages.

It is not documented in R3, but if it were, it would be with the Athena widgets.

void XtDialogAddButton(dialog, name, function, param)
Widget dialog;			/* dialog widget */
char *name;			/* name of the command button to add to dialog */
void (*function)();		/* button press callback function */	
caddr_t param;			/* button press callback client data */

>         4. I ran this program, opened the main "popup" window and positioned
> it on the screen. Then I MOVED it interactively BEFORE clicking on the
> button named "Press to see Simple Demo". The Dialog window appeared at a
> place where the main "popup" window had FIRST appeared.
> Is the Window Manager causing this problem?

This exactly describes a problem in R3 with XtTranslateCoords.  Until R4,
use XTranslateCoordinates instead.  It is not your window manager.
Sorry I didn't warn you about this in the example code.


Donna Converse
converse@expo.lcs.mit.edu

diamant@hpfclp.SDE.HP.COM (John Diamant) (08/21/89)

> >         1.  Where are XtNinput and XtNallowShellResize described? 
> 
> Intrinsics Section 4.1.3  "ShellPart Default Values"
> 
> Setting the input resource of the shell widget to true lets the window
> manager know that your application expects to receive user keyboard and/or
> mouse events.   Some window managers will not pass on events to the
> application unless the application has indicated that it takes input.

Donna, maybe you could shed some light on a question I've had about
XtNinput.  I understand what it's for and why it's needed.  What I'd
like to know is why the default is false.  It seems to me that most Xt
Intrinsics applications are likely to take input in most shells and that
it would have been easier to put the burden on the exceptional
applications which don't take user input rather than the ones that do.
Is there some reason for this default that I'm not seeing?  So far,
about the only application I know that doesn't take input is xclock!

Thanks in advance,

John Diamant
Software Engineering Systems Division
Hewlett-Packard Co.		Internet: diamant@hpfclp.sde.hp.com
Fort Collins, CO		    UUCP: {hplabs,hpfcla}!hpfclp!diamant

diamant@hpfclp.SDE.HP.COM (John Diamant) (08/24/89)

Re: XtNinput default value

In an earlier message, I said:

> I understand what it's for and why it's needed.  What I'd
> like to know is why the default is false.

Nevermind!  I had concluded that the default was false based on a
conversation I had with someone.  I just checked the source and
the default is true, just like I thought it should.  Sorry for
the unnecessary traffic.


Thanks in advance,

John Diamant
Software Engineering Systems Division
Hewlett-Packard Co.		Internet: diamant@hpfclp.sde.hp.com
Fort Collins, CO		    UUCP: {hplabs,hpfcla}!hpfclp!diamant
----------

converse@EXPO.LCS.MIT.EDU (Donna Converse) (08/26/89)

Concerning the Shell input resource

> In an earlier message, I said:
> 
> > I understand what it's for and why it's needed.  What I'd
> > like to know is why the default is false.
> 
> Nevermind!  I had concluded that the default was false based on a
> conversation I had with someone.  I just checked the source and
> the default is true, just like I thought it should. 

The default is false.  It is documented to be false in section 4.1.3
of the Intrinsics manual, and it is false in R3 code.

It will remain false, because the future releases of the Intrinsics library
must maintain compatibility with programs written under earlier versions.
As for why the default was originally decided to be false, I can't tell
you because I wasn't involved in the decision. 

I have heard that the default really wasn't false in R2 code, but it is
the documentation, not the code, that specifies the Intrinsics.  The
documentation has always stated that the default was false, and this
was also mentioned in the paper "Converting Widgets from X11R2 to X11R3".


Donna Converse
converse@expo.lcs.mit.edu