[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference bulova::decw_jan-89_to_nov-90

Title:DECWINDOWS 26-JAN-89 to 29-NOV-90
Notice:See 1639.0 for VMS V5.3 kit; 2043.0 for 5.4 IFT kit
Moderator:STAR::VATNE
Created:Mon Oct 30 1989
Last Modified:Mon Dec 31 1990
Last Successful Update:Fri Jun 06 1997
Number of topics:3726
Total number of notes:19516

376.0. "Setting the X,Y coordinates of main widget " by RABBET::FARRELL (Money, there is no substitute!) Fri Mar 10 1989 10:03

I think this question got lost in the "mix-up" with the conference last week.

Could someone please tell me how to position the main widget window in any
of my DECwindows applications programs?

The x= and y= doesn't seem to work.  It *always* comes up at 0,0.

Is this done with Geometry?  If so, why have x,y agruments in the main window?

		$$$$ ted $$$$

T.RTitleUserPersonal
Name
DateLines
376.1exitTBD1::BURLEIGHDave, DECwindows TrainingFri Mar 10 1989 13:028
    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

376.2DECburger tried it too, and failedDPDMAI::BEATTIEBut, Is BLISS ignorance?Fri Jul 07 1989 17:1431
    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
      

376.3The shell x and y matterSDSVAX::SWEENEYHoney, I iconified the kidsFri Jul 07 1989 17:4422
    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.  

376.4One method here, others discussed elsewhereR2ME2::OBRYANWhen in doubt, let the user decide.Mon Jul 10 1989 02:4991
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;
}

376.5PSW::WINALSKICareful with that VAX, EugeneMon Jul 10 1989 17:074
Why doesn't UIL/DRM recognize shells?

--PSW