Newsgroup: comp.windows.x

 R5 table widget causing trouble with XtQueryGeometry
Organization: Universitaet Koblenz
Lines: 227
Distribution: world
NNTP-Posting-Host: glass.uni-koblenz.de

Contents:Problems with table widgets in R5

	The following part of a program  did work in R4, but refused to in R5. Of cause, the R4-version
	did not know about the xpTableWidgetClass  and XpTableChildPosition 			.
	Since compiling with R5, the program causes a zero width or height error
	. The trouble-shooter is the computation of the
	model_init_table - table widget: though its childs  exist, XtQueryGeometry returns a prefered width and height of 			zero. 
	Thus the following asignment cannot perform anything else but set the 			width and height of the newly created widget to zero. No wonder XtPopup 		or XtManage- Child create zero width or height errors .
	
	Question: Does anyone know, why XtQueryGeometry returns so low prefered
			values when working on table widgets or perhaps what
			to do about?

	I'll be happy, if someone is able to help me. 
	Germans are requested to answer in german.
	
	Siegfried Kaiser
	email: 

	
	The part of interest:


	/* Graphischer Neuaufbau des Model-Init-Formulars */
		/* Storing the old width and height of the viewport-	*/
		/* widget, which is the parent of the troubling table	*/
		/* widget, before the viewport widget is destroyed	*/
		/* The destroying of widgets before resizing them is a	*/
		/* relict from R3-age					*/
	
	if  
		XtUnmapWidget;
	XtDestroyWidget;
	
		/* Creating the subtree within the shell, of which the	*/
		/* root is the viewport widget				*/
	
	n = 0;
	XtSetArg; n++;
	XtSetArg; n++;
	XtSetArg; n++;
	XtSetArg; n++;
	model_init_form_view = XtCreateWidget;

	n = 0;
	model_init_table = XtCreateWidget;

		/* create_form_widget does create and position table	*/
		/* widget's childs. To position them it uses XpTable-	*/
		/* ChildPosition in R5 and XtTblPosition in R4		*/
					 
	create_form_widget;

		/* 							*/
		/* The crucial function call:				*/
		/* intended to return the maximum height possible: if	*/
		/* there isn't sufficient space to show the whole table	*/
		/* widget, then the viewport shall grow as large as 	*/
		/* possible, but not beyond the border of screen.	*/
		/* If there is enough space, the window is intended to	*/
		/* shrienk to the smallest possible height.		*/
		/*							*/

	XtQueryGeometry;

		/* According to the algorithms idea, the new value of	*/
		/* viewport widget's height is selected. Unfortunately	*/
		/* pref.height = 0 leads to new_height = 0.		*/
		
	if  new_height = pref.height;
	else new_height = form_view_height;

		/* Setting the new values to viewport widgets ancestors	*/

	w = XtNameToWidget;
	XtResizeWidget;
	XtResizeWidget;

	if 
	{
		/* In case the shell, which contains model_init_form_-	*/
		/* view and model_init_table, allready exists, is has	*/
		/* to be resized, too.					*/
		
	 n = 0;
	 XtSetArg; n++;
	 XtSetArg; n++;
	 XtSetArg; n++;
	 XtGetValues;
	 XtResizeWidget;
	}; /* end of if */

	n = 0;
	XtSetArg; n++;
	XtSetArg; n++;
	XtGetValues;
	XtResizeWidget;

	XtResizeWidget;
	
	resize_inits;

		/* If there is the shell's height set within the 	*/
		/* resource file, the program terminates within the	*/
		/* first XtManageChild on its second pass through the	*/
		/* observed function. The first pass succeeds.		*/

	XtManageChild;
	XtManageChild;


	if 
	{
		/* In case the shell isn't popped up it has to be done.	*/
		/* If there is no value set to the shell's height within*/
		/* the resource file, the program terminates here.	*/
		
	 XtPopup;
	 model_init_pop_flag = True;
	 set_model_init_attributes;
	}; /* end of if */

	get_actual_init;
	load_form;
	
	
	
	/*								*/
	/* If someone suspects the creation of table widget's contents	*/
	/* causes all the trouble, there are the sources of create_form */
	/*								*/
	
		
	create_form_widget
	t_obj              *ptr;
	Widget             table;
		
		/* ptr is a linear list containing attributes and para-	*/
		/* meters of the model and additionally the correspon-	*/
		/* ding widgets						*/
		
	{
	 Arg               args[10];
	 int               n,
			   row,
			   col;
	 t_obj             *ptr_obj;
	 t_ident           *ptr_ident;

		/* Initialization of the local variables		*/
		
	 ptr_obj = ptr;
	 col = 0;
	 row = 0;
 
	 /* Schleife ueber die Objekte bzw. das Pseudo-Objekt  */
		/* loop through the list of objects and pseudo-objects:	*/
		/* every object occuring in the model has zero or more	*/
		/* attributes and some parameters, which can be shared	*/
		/* by several objects. 					*/
		/* Because of locality the attributes of one object are	*/
		/* listed in a second linear list ,	*/
		/* whereas the parameters, which can belong to any ob-	*/
		/* ject are put together in a pseudo-object 		*/
		/* Thus the program loops through the list of objects	*/
		/* and pseudo-objects and for each object through the	*/
		/* list of its attributes resp. parameters.		*/
		
	 while (ptr_obj != NULL)
	 {
	 	/* Each object and pseudo-object is represented in a	*/
	 	/* label widget						*/
	  
	  n = 0;
	  XtSetArg; n++;
	  ptr_obj->label_w = XtCreateManagedWidget;
	  XpTableChildPosition;
	  col++;
	  row++;
	  ptr_ident = ptr_obj->ident;

	  /* Schleife ueber die Objekt-Attribute bzw. Parameter */
	  while (ptr_ident != NULL)
	  {
	  	/* Each attribute and parameter is represented in a	*/
	  	/* label and has a corresponding asciiText widget, in 	*/
	  	/* which it is to be initialized.			*/
	  	
	   n = 0;
	   XtSetArg; n++;
	   ptr_ident->label_w = XtCreateManagedWidget;
	   XpTableChildPosition;
	   col++;
    
	   n = 0;
	   XtSetArg; n++;
	   XtSetArg; n++;
	   XtSetArg; n++;
	   XtSetArg; n++;
	   XtSetArg; n++;
	   XtSetArg; n++;
	   ptr_ident->text_w = XtCreateManagedWidget;
	   XpTableChildPosition;
	   col--;
	   row++;
	   get_next_ident;
	  }; /* end of while */
	  col--;
	  get_next_obj;
	 }; /* end of while */
	} /* end of create_form_widget */


	

So far the problem in detail.