[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

463.0. "2 - 2 - 2 Problems in 1!" by HGOVC::KENBERKUN (Klaatu Barato Nikto) Thu Mar 23 1989 05:15

I'm going to combine notes 444  and 450  because these too problems are now 
becoming interrelated.  I have decided that under proper circumstances 
I would like to resize my entire window (see  note 450 for 
discussion of whether this is appropriate or not).  But I still can't 
get my application to do it.

In addition, I'm still having trouble setting up my window hierarchy.  
I still am calling Fetch twice.  Below is my current C code and UIL 
code.  It follows the examples I've seen.  Including DECburger by the 
way, which I love and slavishly copy from, and is wonderful, but still doesn't 
answer all my questions.

So the two questions are:

1. How to set things up so that I only need to do one call to 
FetchWidget

2. How to get my program to resize the window.

The code below shows my main program and a routine to resize the 
window.  The UIL is shown below that.  As the code stands now I get no 
workwidget and my image is never displayed and the program dies.  If I 
put in a second FetchWidget and take out the window WorkWidget line 
from the Controls section of MainWindow in the UIL then the program 
runs, but I get no resize.  Actually, it can make the workwindow 
smaller, but not the mainwindow, and of course it can't make the 
workwindow larger than the mainwindow (that I can see).

Thank you again for your patience and perseverance.

Ken B.

	.
	.                                             
	.
main( argc, argv)
    int	    argc;
    char    *argv[];
{

    Arg argl[2];
    static DRMCount	    callback_num = 8;
    static DRMRegisterArg  callback_namevec[] = {  
			{"exitproc" ,(caddr_t)exitproc},
			{"openproc" ,(caddr_t)openproc},
			{"saveproc" ,(caddr_t)saveproc},
			{"WidgetIDproc", (caddr_t)WidgetIDproc}, 
			{"FileBoxproc", (caddr_t)FileBoxproc},
			{"CancelFileBoxproc", (caddr_t)CancelFileBoxproc},
			{"NoMatchFileBoxproc", (caddr_t)NoMatchFileBoxproc},
			{"MyExpoproc", (caddr_t)MyExpoproc}
					 };


    DwtInitializeDRM();

    toplevel = XtInitialize(	"Yadman",
				"TopLevel",
				NULL,
				0,
				&argc,
				&argv );

    XtSetArg(argl[0], XtNallowShellResize,DwtSTrue);
    XtSetValues(toplevel,argl,1);

    if ( DwtOpenHierarchy(	1,
				UID_database,
				NULL,
				&Hierarchy ) != DRMSuccess )
				error( "Can't open hierarchy!" );

    DwtRegisterDRMNames(    callback_namevec, callback_num );


    if ( DwtFetchWidget(	Hierarchy,
				"MainWindow",
				toplevel,
				&mainwidget,
				&dummy ) != DRMSuccess )
				error( "Can't fetch main window!" );


    XtManageChild ( workwidget);
    XtManageChild ( mainwidget);
    XtRealizeWidget( toplevel);

    prefetch();  	/* get all the widgets ahead of time for snappy
			   response */
    XtMainLoop ();

}

	.
	.
	.
static void MyWindowResize()

{



	XtResizeWidget(toplevel,current_instance.pic
			,current_instance.pic
			,NULL);
	XtResizeWidget(workwidget,current_instance.pic
			,current_instance.pic
			,NULL);
	XtManageChild(workwidget);
	XtManageChild(mainwidget);

}



UIL Code

	.
	.
	.

object

	MainWindow : exported main_window 
	    {
	     arguments {
		x = 0;
		y = 0;
		width = 400;
		height = 400;
	     };
	     callbacks {
		create = procedure WidgetIDproc( k_MainWindow );
	     };
	     controls {
		window     WorkWindow;
		menu_bar   MenuBar;
	     };
	};
	
object

	WorkWindow : exported window
	    {
	     arguments {
		x = 0;
		y = 0;
		width = 400;
		height = 400;
	    };
	    callbacks {
		create = procedure WidgetIDproc (k_WorkWindow );
		expose = procedure MyExpoproc ( k_WorkWindow );
	    };
	};
	.
	.
	.
    

T.RTitleUserPersonal
Name
DateLines
463.1LEOVAX::TREGGIARIThu Mar 23 1989 07:5226
    
    I can see two problems in your C code.
    
    1.  DwtSTrue is a string, you need the boolean value TRUE.  so

    XtSetArg(argl[0], XtNallowShellResize,DwtSTrue);
    
        should be 

    XtSetArg(argl[0], XtNallowShellResize,TRUE);
    
    
    2. Your resize routine is all wrong.  Only a widget's geometry
       manager is supposed to call XtResizeWidget, NOT the application.
       You should be calling XtSetValues.  If you want to control the
       size of the main window from the size of the window widget,
       then create the main window widget with a width and height of
       0.  When you do this, the main window widget calculates its
       size from the size of its work area widget.  To later change the
       size, call XtSetValues (setting width and height) on the
       window widget.  The main window and shell should resize
       appropriately.
    
    Leo
       

463.21 down...HGOVC::KENBERKUNKlaatu Barato NiktoFri Mar 24 1989 05:408
    Thanks, that worked perfectly.
    
    Now, any ideas for the other problem?
    
    Ken B.
    

463.3AITG::DERAMODaniel V. {AITG,ZFC}:: D'EramoFri Mar 24 1989 14:1819
     Could you post WidgetIDproc?
     
     You should be able to get by with only one call to
     DwtFetchWidget.  Before that one call returns, the create
     callback WidgetIDproc should have been called for both the
     main window widget and the work window widget.  A
     well-placed printf will show whether this is actually
     happening.
     
     If it isn't happening, try changing the UIL so that the
     width and height of the main window widget are explicitly
     set to zero.  This will cause it to be initially sized so as
     to fit in its children.  Although I don't believe the
     explicitly sized main window widget should be ignoring
     children that are explicitly sized too large to fit in it,
     it's worth a try to test it.
     
     Dan

463.4Solved, Thank YouHGOVC::KENBERKUNKlaatu Barato NiktoFri Mar 24 1989 22:5513
    Problem solved.  It was do to sloppy programming.  When I was fetching
    the widget explicitly I was referring to it as workwidget.  When
    I was fetching the heirarchy I was actually putting the widget id
    into an array, WidgitID, but in the rest of the program I was still
    referring to workwidget.  
    
    So .3's suggestion of putting a printf in the WidgitIDproc pointed
    me in the right direction and I found it.  
    
    Thanks very much to everyone.
    
    Ken B.