|  |     If you want to position the application window, you should change
    the DwtNx and DwtNy resources of the top-level widget returned
    by XtInitialize() or XtAppCreateShell(). The main-window widget
    is contained within the top-level "shell" widget, which ignores
    whatever x,y offset you specify for its child.
    
    Dave
 | 
|  |     Permit me to reopen an old wound to ask a stupid question...
    
    I was perusing the UIL Compiler manual ["Guide to the XUI User
    Interface Language Compiler", AA-MA94A-TE], and the code for the
    famous DECburger demo code printed in appendix A.  Therein is given:
    
    !widget				!the main window widget
    					!this displays the current order
    					!as it is taken
    	S_MAIN_WINDOW : main_window {
    		arguments {
    			x = 10;
    			y = 20;
    			width = 0;
    			height = 0;
    		};
    		controls {		!has two children 
    
    			...
    [page A-19]
    
    Funny, x and y don't seem to work in the example either...
    
    I'm not sure I completely understand the justification for not
    respecting x and y on the main_window.  Is it a "protect
    self-distructive application developers [like me] from themselves"
    feature?
    
    					-- Brian Beattie
      
 | 
|  |     It is by design.
    
    The shell X and Y are the ones that are going to be used by the window
    manager to determine the placement of whatever the shell contains.
    (The shell is the widget returned by XtInitialize)
    
    If the main window "tells the shell" (ie set the value) of some X and Y
    value the shell doesn't care.
    
    Since shells _only_ contain one child they don't need to be able to
    manage the geometry of children.
    
    To achieve the effect of some empty space around a main window, one
    would use the following hierarchy:
    
    shell -> dialog box -> main window
    
    Dialog box will act on the X and Y of the main window.
    
    But usually what people want to do is position the main window relative
    to the root, that requires setting the shell's X and Y.  
 | 
|  | 
re:.2
   As .3 stated, the Shell determines the screen position.  It would be
convenient if UIL/DRM recognized Shells, then you could specify the Shell
in your UIL file and place the x,y in the definition.  (Better yet, the
toolkit could provide a "popup_main_window" as a new widget and build the
Shell for you as they do in popup_dialogs :-)  There are a variety
of possibilities for working around this problem (defining shells as
user_defined widgets, placing the main_window inside a popup_attached_db,
etc.) which have been discussed elsewhere in this notes file or in DECWINDOWS_
PROGRAMMING.  For a simple solution which doesn't require too much work,
I can suggest the following which uses the FetchSetValues scheme for setting
the Shell's x and y from UIL values :
( fyi: The C code is available in	CLT::WIDGET$KITS:[UIGEN]DRIVER.C )
-------- in UIL file -------------
value	k_main_object_x_value : exported 10;
	k_main_object_y_value : exported 20;
-------- in C main program -------
unsigned int main (argc, argv)
...
/*	The FetchSetValues after XtInitialize will fetch all of these named
	values from the UID database as the application starts up. These
	values will be applied to the Shell returned from XtInitialize. */
Arg r_toplevel_fetch_arguments[] = {
	{DwtNx,"k_main_object_x_value"},
	{DwtNy,"k_main_object_y_value"}};
int l_toplevel_fetch_count = array_size(r_toplevel_fetch_arguments);
    DwtInitializeDRM ();                        /* init DRM, before Xt */
    ShellInitializeForDRM();	/* Tell DRM about Shell for FetchSetValue */
    ar_toplevel_object  = XtInitialize ( ...)
    if (DwtOpenHierarchy ( ...	&ar_DRMHierarchy)
    ...
    /* Kludge %%%:  To get around FetchSetValues complaining about the widget
	to be SetValued not having a parent, force the top_level shell to point
	to itself as parent.  Repair kludge after FetchSetValues. */
    XtParent(ar_toplevel_object) = ar_toplevel_object;
    /* Set the x, y, icons and other shell attributes for this application. */
    if (DwtFetchSetValues(ar_DRMHierarchy,
		ar_toplevel_object,
		r_toplevel_fetch_arguments,
		l_toplevel_fetch_count) != DRMSuccess)
	{
	printf("Can't set main window attributes.\n");
	return 0;
	};
    /* Kludge fixup: reset parent */
    XtParent(ar_toplevel_object) = NULL;
    DwtRegisterDRMNames (r_DRMNames, l_DRMNames_count) ;
    if (DwtFetchWidget ( ... )
...
unsigned int ShellInitializeForDRM()
/*==========================================================================
** Registers the TopLevelShell widget class w/DRM (for the icon fetching.)
**-------------------------------------------------------------------------*/
{
    DwtInitializeDRM();
    if (!DwtRegisterClass(DRMwcUnknown,"toplevelshell",
	"XtCreateApplicationShell",XtCreateApplicationShell,
	topLevelShellWidgetClass))
     {
	printf("Top level shell class registration failed.\n");
	return 0;
     };
    if (!DwtRegisterClass(DRMwcUnknown,"applicationshell",
	"XtCreateApplicationShell",XtCreateApplicationShell,
	applicationShellWidgetClass))
     {
	printf("Top level shell class registration failed.\n");
	return 0;
     };
     return 1;
}
 |