Files correlati : Ricompilazione Demo : [ ] Commento : Compilazione Linux git-svn-id: svn://10.65.10.50/trunk@11220 c028cbd2-c16b-5b4b-a496-9718f37d4682
		
			
				
	
	
		
			1345 lines
		
	
	
		
			41 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
			
		
		
	
	
			1345 lines
		
	
	
		
			41 KiB
		
	
	
	
		
			C
		
	
	
		
			Executable File
		
	
	
	
	
| /*******************************************************************************
 | |
| *  Copyright 1991-1996 by ORCA Software, Inc.                                  *
 | |
| *                                                                              *
 | |
| *  All rights reserved.  May not be reproduced or distributed, in printed or   *
 | |
| *  electronic form, without permission of ORCA Software, Inc.  May not be      *
 | |
| *  distributed as object code, separately or linked with other object modules, *
 | |
| *  without permission.                                                         *
 | |
| *******************************************************************************/
 | |
| 
 | |
| #define XI_INTERNAL
 | |
| #define XI_R3_COMPAT
 | |
| #include "xi.h"
 | |
| #include "xiutils.h"
 | |
| #include "xitext.h"
 | |
| #include "xistx.h"
 | |
| #include "xilm.h"
 | |
| #include "xilmst.h"
 | |
| 
 | |
| /* ERROR CODES 20101-20112 */
 | |
| 
 | |
| void realloc_ptrs( void ***ptrs, int nbr_ptrs, void *parent );
 | |
| 
 | |
| #define XI_PTR_INC 10
 | |
| 
 | |
| /*
 | |
|   realloc_ptrs: reallocate an array of pointers by adding one to
 | |
|   the current number of pointers.  This function will attempt to
 | |
|   reallocate by blocks to improve performance.
 | |
| */
 | |
| void
 | |
| realloc_ptrs( void ***ptrs, int nbr_ptrs, void *parent )
 | |
| {
 | |
|   int cur_nbr_alloc;
 | |
|   int nbr_alloc;
 | |
| 
 | |
|   cur_nbr_alloc = ( ( nbr_ptrs - 1 ) / XI_PTR_INC + 1 ) * XI_PTR_INC;
 | |
|   nbr_alloc = ( nbr_ptrs / XI_PTR_INC + 1 ) * XI_PTR_INC;
 | |
| 
 | |
|   if ( *ptrs == NULL )
 | |
|   {
 | |
|     *ptrs = ( void ** )
 | |
|             xi_tree_malloc( sizeof( void * ) * nbr_alloc, parent );
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     if ( cur_nbr_alloc != nbr_alloc )
 | |
|     {
 | |
|       *ptrs = ( void ** )
 | |
|               xi_tree_realloc( *ptrs, sizeof( void * ) * nbr_alloc );
 | |
|     }
 | |
|   }
 | |
| }
 | |
| 
 | |
| XI_OBJ_DEF *
 | |
| xi_create_itf_def( int cid, XI_EVENT_HANDLER xi_eh, XinRect * rctp, char *title,
 | |
|                   long app_data )
 | |
| {
 | |
|   XI_OBJ_DEF *itf;
 | |
|   XI_ITF_DEF *xi_id;
 | |
| 
 | |
|   itf = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), NULL );
 | |
|   itf->type = XIT_ITF;
 | |
|   itf->cid = cid;
 | |
|   itf->v.itf = xi_id = ( XI_ITF_DEF * ) xi_tree_malloc( sizeof( XI_ITF_DEF ), itf );
 | |
|   itf->app_data = app_data;
 | |
|   xi_id->xi_eh = xi_eh;
 | |
|   itf->v.itf->use_xil_win = FALSE;
 | |
|   if ( rctp )
 | |
|   {
 | |
|     xi_id->rctp = ( XinRect * ) xi_tree_malloc( sizeof( XinRect ), itf->v.itf );
 | |
|     *( xi_id->rctp ) = *rctp;
 | |
|   }
 | |
|   else
 | |
|     xi_id->rctp = NULL;
 | |
|   xi_id->title = title;
 | |
|   xi_id->ctl_close = TRUE;
 | |
|   xi_id->ctl_iconized = FALSE;
 | |
|   xi_id->ctl_iconizable = FALSE;
 | |
|   xi_id->maximized = FALSE;
 | |
|   xi_id->visible = TRUE;
 | |
|   xi_id->enabled = TRUE;
 | |
|   xi_id->parent = XI_NULL_WINDOW;
 | |
|   xi_id->border_style_set = FALSE;
 | |
|   xi_id->menu = NULL;
 | |
|   xi_id->icon_rid = 0;
 | |
|   itf->nbr_children = 0;
 | |
|   itf->children = NULL;
 | |
|   return itf;
 | |
| }
 | |
| 
 | |
| XI_OBJ_DEF *
 | |
| xi_add_form_def( XI_OBJ_DEF * itf, int cid, int tab_cid )
 | |
| {
 | |
|   XI_OBJ_DEF *form;
 | |
|   XI_FORM_DEF *xi_fd;
 | |
| 
 | |
|   form = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), itf );
 | |
|   form->type = XIT_FORM;
 | |
|   form->cid = cid;
 | |
|   form->parent = itf;
 | |
|   form->nbr_children = 0;
 | |
|   form->children = NULL;
 | |
|   form->v.form = xi_fd = ( XI_FORM_DEF * ) xi_tree_malloc( sizeof( XI_FORM_DEF ), form );
 | |
|   xi_fd->tab_cid = tab_cid;
 | |
|   if ( itf != NULL )
 | |
|   {
 | |
|     if ( itf->type != XIT_ITF )
 | |
|       XinError( 20101, XinSeverityFatal, 0L );
 | |
|     realloc_ptrs( ( void *** ) &itf->children, itf->nbr_children, itf );
 | |
|     itf->children[itf->nbr_children] = form;
 | |
|     itf->nbr_children++;
 | |
|   }
 | |
|   return form;
 | |
| }
 | |
| 
 | |
| XI_OBJ_DEF *
 | |
| xi_add_line_def( XI_OBJ_DEF * itf, int cid, XinPoint * pnt1,
 | |
|                 XinPoint * pnt2, unsigned long attrib, XinColor fore_color,
 | |
|                 XinColor back_color, BOOLEAN well )
 | |
| {
 | |
|   XI_OBJ_DEF *line_obj;
 | |
|   XI_LINE_DEF *xi_ld;
 | |
| 
 | |
|   line_obj = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), itf );
 | |
|   line_obj->type = XIT_LINE;
 | |
|   line_obj->cid = cid;
 | |
|   line_obj->parent = itf;
 | |
|   line_obj->v.line = xi_ld = ( XI_LINE_DEF * ) xi_tree_malloc( sizeof( XI_LINE_DEF ), line_obj );
 | |
|   xi_ld->pnt1 = *pnt1;
 | |
|   xi_ld->pnt2 = *pnt2;
 | |
|   xi_ld->fore_color = fore_color;
 | |
|   xi_ld->back_color = back_color;
 | |
|   xi_ld->well = well;
 | |
|   xi_ld->attrib = attrib;
 | |
|   if ( itf != NULL )
 | |
|   {
 | |
|     if ( itf->type != XIT_ITF )
 | |
|       XinError( 20108, XinSeverityFatal, 0L );
 | |
|     realloc_ptrs( ( void *** ) &itf->children, itf->nbr_children, itf );
 | |
|     itf->children[itf->nbr_children] = line_obj;
 | |
|     itf->nbr_children++;
 | |
|   }
 | |
|   return line_obj;
 | |
| }
 | |
| 
 | |
| XI_OBJ_DEF *
 | |
| xi_add_list_def( XI_OBJ_DEF * itf, int cid, int v, int h,
 | |
| int height, unsigned long attrib, XinColor enabled_color, XinColor back_color,
 | |
| XinColor disabled_color, XinColor disabled_back_color, XinColor active_color,
 | |
|                 int tab_cid )
 | |
| {
 | |
|   XI_OBJ_DEF *list;
 | |
|   XI_LIST_DEF *xi_ld;
 | |
| 
 | |
|   list = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), itf );
 | |
|   list->type = XIT_LIST;
 | |
|   list->cid = cid;
 | |
|   list->parent = itf;
 | |
|   list->nbr_children = 0;
 | |
|   list->children = NULL;
 | |
|   list->v.list = xi_ld = ( XI_LIST_DEF * ) xi_tree_malloc( sizeof( XI_LIST_DEF ), list );
 | |
|   xi_ld->xi_pnt.v = v;
 | |
|   xi_ld->xi_pnt.h = h;
 | |
|   xi_ld->height = height;
 | |
|   xi_ld->attrib = attrib;
 | |
|   xi_ld->enabled_color = enabled_color;
 | |
|   xi_ld->back_color = back_color;
 | |
|   xi_ld->disabled_color = disabled_color;
 | |
|   xi_ld->disabled_back_color = disabled_back_color;
 | |
|   xi_ld->active_color = active_color;
 | |
|   xi_ld->active_back_color = back_color;
 | |
|   xi_ld->tab_cid = tab_cid;
 | |
|   if ( itf != NULL )
 | |
|   {
 | |
|     if ( itf->type != XIT_ITF )
 | |
|       XinError( 20102, XinSeverityFatal, 0L );
 | |
|     realloc_ptrs( ( void *** ) &itf->children, itf->nbr_children, itf );
 | |
|     itf->children[itf->nbr_children] = list;
 | |
|     itf->nbr_children++;
 | |
|   }
 | |
|   return list;
 | |
| }
 | |
| 
 | |
| XI_OBJ_DEF *
 | |
| xi_add_column_def( XI_OBJ_DEF * list, int cid,
 | |
|               unsigned long attrib, int sort_number, int width, int text_size,
 | |
|                   char *heading_text )
 | |
| {
 | |
|   XI_OBJ_DEF *column;
 | |
|   XI_COLUMN_DEF *xi_cd;
 | |
| 
 | |
|   column = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), list );
 | |
|   column->type = XIT_COLUMN;
 | |
|   column->cid = cid;
 | |
|   column->parent = list;
 | |
|   column->v.column = xi_cd = ( XI_COLUMN_DEF * ) xi_tree_malloc( sizeof( XI_COLUMN_DEF ), column );
 | |
|   xi_cd->attrib = attrib;
 | |
|   xi_cd->sort_number = sort_number;
 | |
|   xi_cd->width = width;
 | |
|   xi_cd->text_size = text_size;
 | |
|   xi_cd->heading_text = ( char * ) xi_tree_malloc( strlen( heading_text ) + 1, column );
 | |
|   strcpy( xi_cd->heading_text, heading_text );
 | |
|   if ( list != NULL )
 | |
|   {
 | |
|     if ( list->type != XIT_LIST )
 | |
|       XinError( 20103, XinSeverityFatal, 0L );
 | |
|     realloc_ptrs( ( void *** ) &list->children, list->nbr_children, list );
 | |
|     list->children[list->nbr_children] = column;
 | |
|     list->nbr_children++;
 | |
|   }
 | |
|   return column;
 | |
| }
 | |
| 
 | |
| XI_OBJ_DEF *
 | |
| xi_add_field_def( XI_OBJ_DEF * form, int cid,
 | |
|                   int v, int h, int field_width, unsigned long attrib,
 | |
|                   int tab_cid, int text_size, XinColor enabled_color,
 | |
|   XinColor back_color, XinColor disabled_color, XinColor disabled_back_color,
 | |
|                   XinColor active_color )
 | |
| {
 | |
|   XI_OBJ_DEF *field;
 | |
|   XI_FIELD_DEF *xi_fd;
 | |
| 
 | |
|   if ( text_size <= 0 )
 | |
|     XinError( 20112, XinSeverityFatal, 0L );
 | |
|   field = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), form );
 | |
|   field->type = XIT_FIELD;
 | |
|   field->cid = cid;
 | |
|   field->parent = form;
 | |
|   field->v.field = xi_fd = ( XI_FIELD_DEF * ) xi_tree_malloc( sizeof( XI_FIELD_DEF ), field );
 | |
|   xi_fd->pnt.h = h;
 | |
|   xi_fd->pnt.v = v;
 | |
|   xi_fd->field_width = field_width;
 | |
|   xi_fd->attrib = attrib;
 | |
|   xi_fd->tab_cid = tab_cid;
 | |
|   xi_fd->text_size = text_size;
 | |
|   xi_fd->back_color = back_color;
 | |
|   xi_fd->enabled_color = enabled_color;
 | |
|   xi_fd->disabled_color = disabled_color;
 | |
|   xi_fd->disabled_back_color = disabled_back_color;
 | |
|   xi_fd->active_color = active_color;
 | |
|   xi_fd->active_back_color = back_color;
 | |
|   if ( form != NULL )
 | |
|   {
 | |
|     if ( form->type != XIT_FORM )
 | |
|       XinError( 20104, XinSeverityFatal, 0L );
 | |
|     realloc_ptrs( ( void *** ) &form->children,
 | |
|                   form->nbr_children, form );
 | |
|     form->children[form->nbr_children] = field;
 | |
|     form->nbr_children++;
 | |
|   }
 | |
|   return field;
 | |
| }
 | |
| 
 | |
| XI_OBJ_DEF *
 | |
| xi_add_container_def( XI_OBJ_DEF * itf, int cid,
 | |
|         XinRect * xi_rct, XI_CONTAINER_ORIENTATION orientation, int tab_cid )
 | |
| {
 | |
|   XI_OBJ_DEF *container;
 | |
|   XI_CONTAINER_DEF *xi_cd;
 | |
| 
 | |
|   container = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), itf );
 | |
|   container->type = XIT_CONTAINER;
 | |
|   container->cid = cid;
 | |
|   container->parent = itf;
 | |
|   container->nbr_children = 0;
 | |
|   container->children = NULL;
 | |
|   container->v.container = xi_cd =
 | |
|           ( XI_CONTAINER_DEF * ) xi_tree_malloc( sizeof( XI_CONTAINER_DEF ), container );
 | |
|   xi_cd->xi_rct = *xi_rct;
 | |
|   xi_cd->orientation = orientation;
 | |
|   xi_cd->tab_cid = tab_cid;
 | |
|   if ( itf != NULL )
 | |
|   {
 | |
|     if ( itf->type != XIT_ITF )
 | |
|       XinError( 20105, XinSeverityFatal, 0L );
 | |
|     realloc_ptrs( ( void *** ) &itf->children, itf->nbr_children, itf );
 | |
|     itf->children[itf->nbr_children] = container;
 | |
|     itf->nbr_children++;
 | |
|   }
 | |
|   return container;
 | |
| }
 | |
| 
 | |
| XI_OBJ_DEF *
 | |
| xi_add_button_def( XI_OBJ_DEF * parent, int cid, XinRect * rct,
 | |
|                   unsigned long attrib, char *text, int tab_cid )
 | |
| {
 | |
|   XI_OBJ_DEF *btn;
 | |
|   XI_BTN_DEF *xi_bd;
 | |
| 
 | |
|   btn = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), parent );
 | |
|   btn->type = XIT_BTN;
 | |
|   btn->cid = cid;
 | |
|   btn->parent = parent;
 | |
|   btn->v.btn = xi_bd = ( XI_BTN_DEF * ) xi_tree_malloc( sizeof( XI_BTN_DEF ), btn );
 | |
|   if ( rct != NULL )
 | |
|     xi_bd->xi_rct = *rct;
 | |
|   xi_bd->attrib = attrib;
 | |
|   xi_bd->text = ( char * ) xi_tree_malloc( strlen( text ) + 1, btn );
 | |
|   strcpy( xi_bd->text, text );
 | |
|   xi_bd->tab_cid = tab_cid;
 | |
|   if ( parent != NULL )
 | |
|   {
 | |
|     if ( !( parent->type == XIT_ITF || parent->type == XIT_CONTAINER ) )
 | |
|       XinError( 20106, XinSeverityFatal, 0L );
 | |
|     realloc_ptrs( ( void *** ) &parent->children, parent->nbr_children, parent );
 | |
|     parent->children[parent->nbr_children] = btn;
 | |
|     parent->nbr_children++;
 | |
|   }
 | |
|   return btn;
 | |
| }
 | |
| 
 | |
| XI_OBJ_DEF *
 | |
| xi_add_text_def( XI_OBJ_DEF * itf, int cid, XinRect * rct,
 | |
|                 unsigned long attrib, char *text )
 | |
| {
 | |
|   XI_OBJ_DEF *text_obj;
 | |
|   XI_TEXT_DEF *xi_td;
 | |
| 
 | |
|   text_obj = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), itf );
 | |
|   text_obj->type = XIT_TEXT;
 | |
|   text_obj->cid = cid;
 | |
|   text_obj->parent = itf;
 | |
|   text_obj->v.text = xi_td = ( XI_TEXT_DEF * ) xi_tree_malloc( sizeof( XI_TEXT_DEF ), text_obj );
 | |
|   xi_td->xi_rct = *rct;
 | |
|   xi_td->attrib = attrib;
 | |
|   xi_td->text = ( char * ) xi_tree_malloc( strlen( text ) + 1, text_obj );
 | |
|   strcpy( xi_td->text, text );
 | |
|   if ( itf != NULL )
 | |
|   {
 | |
|     if ( itf->type != XIT_ITF )
 | |
|       XinError( 20107, XinSeverityFatal, 0L );
 | |
|     realloc_ptrs( ( void *** ) &itf->children, itf->nbr_children, itf );
 | |
|     itf->children[itf->nbr_children] = text_obj;
 | |
|     itf->nbr_children++;
 | |
|   }
 | |
|   return text_obj;
 | |
| }
 | |
| 
 | |
| XI_OBJ_DEF *
 | |
| xi_add_rect_def( XI_OBJ_DEF * itf, int cid, XinRect * rct,
 | |
|               unsigned long attrib, XinColor fore_color, XinColor back_color )
 | |
| {
 | |
|   XI_OBJ_DEF *rect_obj;
 | |
|   XI_RECT_DEF *xi_rd;
 | |
| 
 | |
|   rect_obj = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), itf );
 | |
|   rect_obj->type = XIT_RECT;
 | |
|   rect_obj->cid = cid;
 | |
|   rect_obj->parent = itf;
 | |
|   rect_obj->v.rect = xi_rd = ( XI_RECT_DEF * ) xi_tree_malloc( sizeof( XI_RECT_DEF ), rect_obj );
 | |
|   xi_rd->xi_rct = *rct;
 | |
|   xi_rd->fore_color = fore_color;
 | |
|   xi_rd->back_color = back_color;
 | |
|   xi_rd->attrib = attrib;
 | |
|   if ( itf != NULL )
 | |
|   {
 | |
|     if ( itf->type != XIT_ITF )
 | |
|       XinError( 20111, XinSeverityFatal, 0L );
 | |
|     realloc_ptrs( ( void *** ) &itf->children, itf->nbr_children, itf );
 | |
|     itf->children[itf->nbr_children] = rect_obj;
 | |
|     itf->nbr_children++;
 | |
|   }
 | |
|   return rect_obj;
 | |
| }
 | |
| 
 | |
| XI_OBJ_DEF *
 | |
| xi_add_group_def( XI_OBJ_DEF * itf, int cid, int nbr_cids,
 | |
|                   int *cid_list )
 | |
| {
 | |
|   XI_OBJ_DEF *group;
 | |
|   XI_GROUP_DEF *xi_gd;
 | |
| 
 | |
|   group = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), itf );
 | |
|   group->type = XIT_GROUP;
 | |
|   group->cid = cid;
 | |
|   group->parent = itf;
 | |
|   group->v.group = xi_gd = ( XI_GROUP_DEF * ) xi_tree_malloc( sizeof( XI_GROUP_DEF ), group );
 | |
|   xi_gd->nbr_cids = nbr_cids;
 | |
|   if ( nbr_cids <= 0 )
 | |
|     XinError( 20109, XinSeverityFatal, 0L );
 | |
|   xi_gd->cids = ( int * ) xi_tree_malloc( sizeof( int ) * nbr_cids, xi_gd );
 | |
|   memcpy( ( char * ) xi_gd->cids, ( char * ) cid_list,
 | |
|           ( size_t ) ( sizeof( int ) * nbr_cids ) );
 | |
|   if ( itf != NULL )
 | |
|   {
 | |
|     if ( itf->type != XIT_ITF )
 | |
|       XinError( 20110, XinSeverityFatal, 0L );
 | |
|     realloc_ptrs( ( void *** ) &itf->children, itf->nbr_children, itf );
 | |
|     itf->children[itf->nbr_children] = group;
 | |
|     itf->nbr_children++;
 | |
|   }
 | |
|   return group;
 | |
| }
 | |
| 
 | |
| XI_OBJ_DEF *
 | |
| xi_get_column_def( XI_OBJ * column_obj,
 | |
|                   LM_COLUMN_DATA * lmcdp, int index,
 | |
|                   void *parent )
 | |
| {
 | |
|   XI_OBJ_DEF *column;
 | |
|   XI_COLUMN_DEF *xi_cd;
 | |
| 
 | |
|   column = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), parent );
 | |
|   column->type = XIT_COLUMN;
 | |
|   column->cid = column_obj->cid;
 | |
|   column->app_data = column_obj->app_data;
 | |
|   column->v.column = xi_cd = ( XI_COLUMN_DEF * ) xi_tree_malloc(
 | |
|                                             sizeof( XI_COLUMN_DEF ), column );
 | |
|   xi_cd->attrib = lmcdp->attrib;
 | |
|   xi_cd->sort_number = index * 10;
 | |
|   if ( xi_get_xil_pref( column_obj->itf ) )
 | |
|   {
 | |
|     xi_cd->pixel_width = lmcdp->pix_width;
 | |
|     xi_cd->width = lmcdp->width;
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     xi_cd->pixel_width = lmcdp->pix_width;
 | |
|     xi_cd->width = lmcdp->width * XI_FU_MULTIPLE;
 | |
|   }
 | |
|   xi_cd->text_size = lmcdp->text_size;
 | |
|   xi_cd->heading_text = ( char * ) xi_tree_malloc( strlen(
 | |
|                                           lmcdp->heading_text ) + 1, column );
 | |
|   strcpy( xi_cd->heading_text, lmcdp->heading_text );
 | |
|   xi_cd->center_heading = lmcdp->center_heading;
 | |
|   xi_cd->heading_well = lmcdp->heading_well;
 | |
|   xi_cd->heading_platform = lmcdp->heading_platform;
 | |
|   xi_cd->column_well = lmcdp->column_well;
 | |
|   xi_cd->column_platform = lmcdp->column_platform;
 | |
|   if ( lmcdp->font )
 | |
|   {
 | |
|     /* Make a copy because lmcdp->font will be destroyed with the column */
 | |
|     if ( ( BOOLEAN ) xi_get_pref( XI_PREF_R4_API ) )
 | |
|     {
 | |
|       XinFontCopy( &xi_cd->font, lmcdp->font );
 | |
|       xi_cd->font_id = NULL;
 | |
|     }
 | |
| #ifdef XI_USE_XVT
 | |
|     else
 | |
|     {
 | |
|       XinFontCopy( &xi_cd->font, lmcdp->font );
 | |
|       xi_cd->font_id = XinFontXvtConvertBack( xi_cd->font );
 | |
|       xi_cd->font = NULL;
 | |
|     }
 | |
| #endif
 | |
|   }
 | |
|   xi_cd->icon_rid = lmcdp->icon_rid;
 | |
|   xi_cd->icon_x = lmcdp->icon_x;
 | |
|   xi_cd->icon_y = lmcdp->icon_y;
 | |
|   xi_cd->bitmap = xi_bitmap_copy( lmcdp->bitmap );
 | |
|   xi_cd->size_rows = lmcdp->size_rows;
 | |
|   xi_cd->suppress_update_heading = lmcdp->suppress_update_heading;
 | |
|   xi_cd->suppress_update_cells = lmcdp->suppress_update_cells;
 | |
|   xi_cd->vertical_align_center = lmcdp->vertical_align_center;
 | |
|   xi_cd->vertical_align_bottom = lmcdp->vertical_align_bottom;
 | |
|   xi_cd->wrap_text = lmcdp->wrap_text;
 | |
|   xi_cd->wrap_text_scrollbar = lmcdp->wrap_text_scrollbar;
 | |
|   xi_cd->cr_ok = lmcdp->cr_ok;
 | |
|   xi_cd->var_len_text = lmcdp->var_len_text;
 | |
|   xi_cd->auto_tab = lmcdp->auto_tab;
 | |
|   xi_cd->icon_mode = lmcdp->icon_mode;
 | |
|   return column;
 | |
| }
 | |
| 
 | |
| XI_OBJ_DEF *
 | |
| xi_get_list_def( XI_OBJ * list_obj )
 | |
| {
 | |
|   XI_OBJ_DEF *list;
 | |
|   XI_LIST_DEF *xi_ld;
 | |
|   XI_LIST_DATA *list_data;
 | |
|   LM_DATA *lmp;
 | |
|   XinPoint p;
 | |
|   int i;
 | |
|   int nbr_recs;
 | |
|   long *recs;
 | |
| 
 | |
|   list_data = list_obj->v.list;
 | |
|   lmp = ( LM_DATA * ) list_data->lm;
 | |
|   list = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), NULL );
 | |
|   list->type = XIT_LIST;
 | |
|   list->cid = list_obj->cid;
 | |
|   list->app_data = list_obj->app_data;
 | |
|   list->v.list = xi_ld = ( XI_LIST_DEF * ) xi_tree_malloc( sizeof( XI_LIST_DEF ), list );
 | |
|   xi_ld->xi_pnt = list_data->xi_pnt;
 | |
|   xi_ld->height = list_data->height;
 | |
|   xi_ld->pixel_height = lmp->pixel_height;
 | |
|   xi_ld->attrib = lmp->attrib;
 | |
|   xi_ld->enabled_color = lmp->enabled_color;
 | |
|   xi_ld->back_color = lmp->back_color;
 | |
|   xi_ld->disabled_color = lmp->disabled_color;
 | |
|   xi_ld->disabled_back_color = lmp->disabled_back_color;
 | |
|   xi_ld->active_color = lmp->active_color;
 | |
|   xi_ld->active_back_color = lmp->active_back_color;
 | |
|   xi_ld->white_space_color = lmp->white_space_color;
 | |
|   xi_ld->rule_color = lmp->rule_color;
 | |
|   xi_ld->tab_cid = list_data->tab_cid;
 | |
|   xi_ld->no_heading = lmp->no_heading;
 | |
|   xi_ld->one_row_list = list_data->one_row_list;
 | |
|   xi_ld->scroll_bar = list_data->scroll_bar;
 | |
|   xi_ld->sizable_columns = lmp->sizable_columns;
 | |
|   xi_ld->movable_columns = lmp->movable_columns;
 | |
|   xi_ld->scroll_bar_button = list_data->scroll_bar_button;
 | |
|   xi_ld->fixed_columns = lmp->fixed_columns;
 | |
|   xi_ld->resize_with_window = lmp->resize_with_window;
 | |
|   xi_ld->horz_sync_list = lmp->horz_sync_list;
 | |
|   xi_ld->vert_sync_list = lmp->vert_sync_list;
 | |
|   xi_ld->row_focus_border = lmp->row_focus_border;
 | |
|   xi_ld->row_focus_border_color = lmp->row_focus_border_color;
 | |
|   xi_ld->max_lines_in_cell = lmp->max_lines_in_cell;
 | |
|   xi_ld->single_select = lmp->single_select;
 | |
|   if ( xi_get_xil_pref( list_obj->parent ) )
 | |
|     xi_ld->width = lmp->pixel_width;
 | |
|   else
 | |
|   {
 | |
|     p.h = lmp->pixel_width;
 | |
|     xi_pu_to_fu( list_obj->itf, &p, 1 );
 | |
|     xi_ld->width = p.h;
 | |
|   }
 | |
|   xi_ld->min_cell_height = lmp->min_cell_height;
 | |
|   xi_ld->min_heading_height = lmp->min_heading_height;
 | |
|   xi_ld->no_horz_lines = lmp->no_horz_lines;
 | |
|   xi_ld->no_vert_lines = lmp->no_vert_lines;
 | |
|   xi_ld->drop_and_delete = lmp->drop_and_delete;
 | |
|   xi_ld->select_cells = lmp->select_cells;
 | |
|   xi_ld->get_all_records = lmp->get_all_records;
 | |
|   if ( lmp->font )
 | |
|   {
 | |
|     if ( ( BOOLEAN ) xi_get_pref( XI_PREF_R4_API ) )
 | |
|     {
 | |
|       XinFontCopy( &xi_ld->font, lmp->font );
 | |
|       xi_ld->font_id = NULL;
 | |
|     }
 | |
| #ifdef XI_USE_XVT
 | |
|     else
 | |
|     {
 | |
|       XinFontCopy( &xi_ld->font, lmp->font );
 | |
|       xi_ld->font_id = XinFontXvtConvertBack( xi_ld->font );
 | |
|       xi_ld->font = NULL;
 | |
|     }
 | |
| #endif
 | |
|   }
 | |
| 
 | |
|   recs = lm_get_list_info( list_data->lm, &nbr_recs );
 | |
|   if ( nbr_recs > 0 )
 | |
|   {
 | |
|     XI_EVENT xiev;
 | |
|     XI_OBJ *itf;
 | |
| 
 | |
|     itf = list_obj->itf;
 | |
|     MEMCLEAR( xiev );
 | |
|     xiev.type = XIE_GET_PERCENT;
 | |
|     xiev.v.get_percent.record = recs[0];
 | |
|     xiev.v.get_percent.list = list_obj;
 | |
|     ( *( XI_EVENT_HANDLER ) itf->v.itf->xi_eh ) ( itf, &xiev );
 | |
|     xi_ld->start_percent = xiev.v.get_percent.percent;
 | |
|   }
 | |
|   xi_ld->first_vis_column = lmp->first_vis;
 | |
| 
 | |
|   list->nbr_children = lmp->nbr_columns;
 | |
|   realloc_ptrs( ( void *** ) &list->children, list->nbr_children,
 | |
|                 list );
 | |
|   for ( i = 0; i < list->nbr_children; ++i )
 | |
|     list->children[i] = xi_get_column_def( list_obj->children[i],
 | |
|                                           lmp->lm_column_data[i], i, list );
 | |
|   return list;
 | |
| }
 | |
| 
 | |
| XI_OBJ_DEF *
 | |
| xi_get_column_def2( XI_OBJ * column_obj )
 | |
| {
 | |
|   XI_OBJ *list_obj;
 | |
|   LM_DATA *lmp;
 | |
|   int i;
 | |
| 
 | |
|   list_obj = column_obj->parent;
 | |
|   lmp = ( LM_DATA * ) list_obj->v.list->lm;
 | |
| 
 | |
|   for ( i = 0; i < list_obj->nbr_children; ++i )
 | |
|     if ( list_obj->children[i] == column_obj )
 | |
|       return xi_get_column_def( column_obj, lmp->lm_column_data[i], i, NULL );
 | |
|   return 0;
 | |
| }
 | |
| 
 | |
| XI_OBJ_DEF *
 | |
| xi_get_def( XI_OBJ * xi_obj )
 | |
| {
 | |
|   switch ( xi_obj->type )
 | |
|   {
 | |
| case XIT_LIST:
 | |
|       return xi_get_list_def( xi_obj );
 | |
|     case XIT_COLUMN:
 | |
|       return xi_get_column_def2( xi_obj );
 | |
|     case XIT_FIELD:
 | |
|       {
 | |
|         XI_OBJ_DEF *field;
 | |
|         XI_FIELD_DEF *xi_fd;
 | |
|         XI_FIELD_DATA *field_data;
 | |
|         STX_DATA *stxp;
 | |
| 
 | |
|         field_data = xi_obj->v.field;
 | |
|         stxp = ( STX_DATA * ) field_data->stx;
 | |
|         field = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), NULL );
 | |
|         field->type = XIT_FIELD;
 | |
|         field->cid = xi_obj->cid;
 | |
|         field->app_data = xi_obj->app_data;
 | |
|         field->v.field = xi_fd =
 | |
|                 ( XI_FIELD_DEF * ) xi_tree_malloc( sizeof( XI_FIELD_DEF ), field );
 | |
|         xi_fd->xi_rct = field_data->xi_rct;
 | |
|         xi_fd->pnt = field_data->xi_pnt;
 | |
|         xi_fd->field_width = field_data->field_width;
 | |
|         xi_fd->var_len_text = field_data->var_len_text;
 | |
|         xi_fd->attrib = stxp->attrib;
 | |
|         xi_fd->tab_cid = field_data->tab_cid;
 | |
|         xi_fd->text_size = stxp->text_size;
 | |
|         xi_fd->back_color = stxp->back_color;
 | |
|         xi_fd->enabled_color = stxp->enabled_color;
 | |
|         xi_fd->disabled_color = stxp->disabled_color;
 | |
|         xi_fd->disabled_back_color = stxp->disabled_back_color;
 | |
|         xi_fd->active_color = stxp->active_color;
 | |
|         xi_fd->active_back_color = stxp->active_back_color;
 | |
|         xi_fd->hilight_color = stxp->hilight_color;
 | |
|         xi_fd->shadow_color = stxp->shadow_color;
 | |
|         xi_fd->button = field_data->button;
 | |
|         xi_fd->button_on_left = field_data->button_on_left;
 | |
|         xi_fd->no_button_space = field_data->no_button_space;
 | |
|         xi_fd->icon_rid = field_data->icon_rid;
 | |
|         xi_fd->button_bitmap = xi_bitmap_copy( field_data->button_bitmap );
 | |
|         xi_fd->well = field_data->well;
 | |
|         xi_fd->platform = field_data->platform;
 | |
|         xi_fd->mnemonic = field_data->mnemonic;
 | |
|         if ( field_data->font_set )
 | |
|         {
 | |
|           if ( ( BOOLEAN ) xi_get_pref( XI_PREF_R4_API ) )
 | |
|           {
 | |
|             XinFontCopy( &xi_fd->font, stxp->font );
 | |
|             xi_fd->font_id = NULL;
 | |
|           }
 | |
| #ifdef XI_USE_XVT
 | |
|           else
 | |
|           {
 | |
|             XinFontCopy( &xi_fd->font, stxp->font );
 | |
|             xi_fd->font_id = XinFontXvtConvertBack( xi_fd->font );
 | |
|             xi_fd->font = NULL;
 | |
|           }
 | |
| #endif
 | |
|         }
 | |
|         return field;
 | |
|       }
 | |
|     case XIT_TEXT:
 | |
|       {
 | |
|         XI_OBJ_DEF *text;
 | |
|         XI_TEXT_DEF *xi_td;
 | |
|         XI_TEXT_DATA *text_data;
 | |
| 
 | |
|         text_data = xi_obj->v.text;
 | |
|         text = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), NULL );
 | |
|         text->type = XIT_TEXT;
 | |
|         text->cid = xi_obj->cid;
 | |
|         text->app_data = xi_obj->app_data;
 | |
|         text->v.text = xi_td =
 | |
|                 ( XI_TEXT_DEF * ) xi_tree_malloc( sizeof( XI_TEXT_DEF ), text );
 | |
|         xi_td->xi_rct = text_data->xi_rct;
 | |
|         xi_td->attrib = text_data->attrib;
 | |
|         if ( text_data->text )
 | |
|         {
 | |
|           xi_td->text = ( char * ) xi_tree_malloc( strlen( text_data->text ) + 1,
 | |
|                                                   xi_td );
 | |
|           strcpy( xi_td->text, text_data->text );
 | |
|         }
 | |
|         xi_td->fore_color = text_data->fore_color;
 | |
|         xi_td->back_color = text_data->back_color;
 | |
|         xi_td->mnemonic = text_data->mnemonic;
 | |
|         xi_td->mnemonic_instance = text_data->mnemonic_instance;
 | |
|         if ( text_data->font )
 | |
|         {
 | |
|           if ( ( BOOLEAN ) xi_get_pref( XI_PREF_R4_API ) )
 | |
|           {
 | |
|             XinFontCopy( &xi_td->font, text_data->font );
 | |
|             xi_td->font_id = NULL;
 | |
|           }
 | |
| #ifdef XI_USE_XVT
 | |
|           else
 | |
|           {
 | |
|             XinFontCopy( &xi_td->font, text_data->font );
 | |
|             xi_td->font_id = XinFontXvtConvertBack( xi_td->font );
 | |
|             xi_td->font = NULL;
 | |
|           }
 | |
| #endif
 | |
|         }
 | |
|         return text;
 | |
|       }
 | |
|     case XIT_BTN:
 | |
|       {
 | |
|         XI_OBJ_DEF *btn;
 | |
|         XI_BTN_DEF *xi_bd;
 | |
|         XI_BTN_DATA *btn_data;
 | |
| 
 | |
|         btn_data = xi_obj->v.btn;
 | |
|         btn = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), NULL );
 | |
|         btn->type = XIT_BTN;
 | |
|         btn->cid = xi_obj->cid;
 | |
|         btn->app_data = xi_obj->app_data;
 | |
|         btn->v.btn = xi_bd =
 | |
|                 ( XI_BTN_DEF * ) xi_tree_malloc( sizeof( XI_BTN_DEF ), btn );
 | |
|         xi_bd->xi_rct = btn_data->xi_rct;
 | |
|         xi_bd->pixel_rect = btn_data->rct;
 | |
|         xi_bd->attrib = btn_data->attrib;
 | |
|         if ( btn_data->text )
 | |
|         {
 | |
|           xi_bd->text = ( char * ) xi_tree_malloc( strlen( btn_data->text ) + 1,
 | |
|                                                   xi_bd );
 | |
|           strcpy( xi_bd->text, btn_data->text );
 | |
|         }
 | |
|         xi_bd->tab_cid = btn_data->tab_cid;
 | |
|         xi_bd->dflt = btn_data->dflt;
 | |
|         xi_bd->cancel = btn_data->cancel;
 | |
|         xi_bd->down_icon_rid = btn_data->down_icon_rid;
 | |
|         xi_bd->up_icon_rid = btn_data->up_icon_rid;
 | |
|         xi_bd->disabled_icon_rid = btn_data->disabled_icon_rid;
 | |
|         xi_bd->icon_x = btn_data->icon_x;
 | |
|         xi_bd->icon_y = btn_data->icon_y;
 | |
|         xi_bd->up_bitmap = xi_bitmap_copy( btn_data->up_bitmap );
 | |
|         xi_bd->down_bitmap = xi_bitmap_copy( btn_data->down_bitmap );
 | |
|         xi_bd->disabled_bitmap = xi_bitmap_copy( btn_data->disabled_bitmap );
 | |
|         xi_bd->checked = btn_data->checked;
 | |
|         xi_bd->fore_color = btn_data->fore_color;
 | |
|         xi_bd->draw_as = btn_data->draw_as;
 | |
|         xi_bd->drawable = btn_data->drawable;
 | |
|         xi_bd->mnemonic = btn_data->mnemonic;
 | |
|         xi_bd->mnemonic_instance = btn_data->mnemonic_instance;
 | |
|         if ( btn_data->font )
 | |
|         {
 | |
|           if ( ( BOOLEAN ) xi_get_pref( XI_PREF_R4_API ) )
 | |
|           {
 | |
|             XinFontCopy( &xi_bd->font, btn_data->font );
 | |
|             xi_bd->font_id = NULL;
 | |
|           }
 | |
| #ifdef XI_USE_XVT
 | |
|           else
 | |
|           {
 | |
|             XinFontCopy( &xi_bd->font, btn_data->font );
 | |
|             xi_bd->font_id = XinFontXvtConvertBack( xi_bd->font );
 | |
|             xi_bd->font = NULL;
 | |
|           }
 | |
| #endif
 | |
|         }
 | |
|         return btn;
 | |
|       }
 | |
|     case XIT_LINE:
 | |
|       {
 | |
|         XI_OBJ_DEF *line;
 | |
|         XI_LINE_DEF *xi_ld;
 | |
|         XI_LINE_DATA *line_data;
 | |
| 
 | |
|         line_data = xi_obj->v.line;
 | |
|         line = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), NULL );
 | |
|         line->type = XIT_LINE;
 | |
|         line->cid = xi_obj->cid;
 | |
|         line->app_data = xi_obj->app_data;
 | |
|         line->v.line = xi_ld =
 | |
|                 ( XI_LINE_DEF * ) xi_tree_malloc( sizeof( XI_LINE_DEF ), line );
 | |
|         xi_ld->pnt1 = line_data->xi_pnt1;
 | |
|         xi_ld->pnt2 = line_data->xi_pnt2;
 | |
|         xi_ld->pixel_pnt1 = line_data->pnt1;
 | |
|         xi_ld->pixel_pnt2 = line_data->pnt2;
 | |
|         xi_ld->fore_color = line_data->fore_color;
 | |
|         xi_ld->back_color = line_data->back_color;
 | |
|         xi_ld->well = line_data->well;
 | |
|         xi_ld->attrib = line_data->attrib;
 | |
|         return line;
 | |
|       }
 | |
|     case XIT_RECT:
 | |
|       {
 | |
|         XI_OBJ_DEF *rect;
 | |
|         XI_RECT_DEF *xi_rd;
 | |
|         XI_RECT_DATA *rect_data;
 | |
| 
 | |
|         rect_data = xi_obj->v.rect;
 | |
|         rect = ( XI_OBJ_DEF * ) xi_tree_malloc( sizeof( XI_OBJ_DEF ), NULL );
 | |
|         rect->type = XIT_RECT;
 | |
|         rect->cid = xi_obj->cid;
 | |
|         rect->app_data = xi_obj->app_data;
 | |
|         rect->v.rect = xi_rd =
 | |
|                 ( XI_RECT_DEF * ) xi_tree_malloc( sizeof( XI_RECT_DEF ), rect );
 | |
|         xi_rd->xi_rct = rect_data->xi_rct;
 | |
|         xi_rd->pixel_rect = rect_data->rct;
 | |
|         xi_rd->fore_color = rect_data->fore_color;
 | |
|         xi_rd->back_color = rect_data->back_color;
 | |
|         xi_rd->hilight_color = rect_data->hilight_color;
 | |
|         xi_rd->shadow_color = rect_data->shadow_color;
 | |
|         xi_rd->well = rect_data->well;
 | |
|         xi_rd->attrib = rect_data->attrib;
 | |
|         xi_rd->bitmap = xi_bitmap_copy( rect_data->bitmap );
 | |
|         return rect;
 | |
|       }
 | |
|     default:
 | |
|       break;
 | |
|   }
 | |
|   return NULL;
 | |
| }
 | |
| 
 | |
| /*--------------------------------------------------------------------------*/
 | |
| /* xi_def_free_internal                                                     */
 | |
| /*--------------------------------------------------------------------------*/
 | |
| static void
 | |
| xi_def_free_internal( XI_OBJ_DEF* obj_def )
 | |
| {
 | |
|   int num;
 | |
| 
 | |
|   switch ( obj_def->type )
 | |
|   {
 | |
|     case XIT_ITF:
 | |
|       if ( obj_def->v.itf->font != NULL )
 | |
|         XinFontDestroy( obj_def->v.itf->font );
 | |
| #ifdef XI_USE_XVT
 | |
|       else if ( obj_def->v.itf->font_id != NULL )
 | |
|         XinFontXvtDestroy( obj_def->v.itf->font_id );
 | |
| #endif
 | |
|       xi_bitmap_destroy( obj_def->v.itf->bitmap );
 | |
|       break;
 | |
|     case XIT_LIST:
 | |
|       if ( obj_def->v.list->font != NULL )
 | |
|         XinFontDestroy( obj_def->v.list->font );
 | |
| #ifdef XI_USE_XVT
 | |
|       else if ( obj_def->v.list->font_id != NULL )
 | |
|         XinFontXvtDestroy( obj_def->v.list->font_id );
 | |
| #endif
 | |
|       break;
 | |
|     case XIT_COLUMN:
 | |
|       if ( obj_def->v.column->font != NULL )
 | |
|         XinFontDestroy( obj_def->v.column->font );
 | |
| #ifdef XI_USE_XVT
 | |
|       else if ( obj_def->v.column->font_id != NULL )
 | |
|         XinFontXvtDestroy( obj_def->v.column->font_id );
 | |
| #endif
 | |
|       xi_bitmap_destroy( obj_def->v.column->bitmap );
 | |
|       break;
 | |
|     case XIT_FIELD:
 | |
|       if ( obj_def->v.field->font != NULL )
 | |
|         XinFontDestroy( obj_def->v.field->font );
 | |
| #ifdef XI_USE_XVT
 | |
|       else if ( obj_def->v.field->font_id != NULL )
 | |
|         XinFontXvtDestroy( obj_def->v.field->font_id );
 | |
| #endif
 | |
|       xi_bitmap_destroy( obj_def->v.field->button_bitmap );
 | |
|       break;
 | |
|     case XIT_TEXT:
 | |
|       if ( obj_def->v.text->font != NULL )
 | |
|         XinFontDestroy( obj_def->v.text->font );
 | |
| #ifdef XI_USE_XVT
 | |
|       else if ( obj_def->v.text->font_id != NULL )
 | |
|         XinFontXvtDestroy( obj_def->v.text->font_id );
 | |
| #endif
 | |
|       break;
 | |
|     case XIT_BTN:
 | |
|     {
 | |
|       XI_BTN_DEF* btn_def = obj_def->v.btn;
 | |
| 
 | |
|       if ( btn_def->font != NULL )
 | |
|         XinFontDestroy( btn_def->font );
 | |
| #ifdef XI_USE_XVT
 | |
|       else if ( btn_def->font_id != NULL )
 | |
|         XinFontXvtDestroy( btn_def->font_id );
 | |
| #endif
 | |
|       xi_bitmap_destroy( btn_def->down_bitmap );
 | |
|       xi_bitmap_destroy( btn_def->up_bitmap );
 | |
|       xi_bitmap_destroy( btn_def->disabled_bitmap );
 | |
|       break;
 | |
|     }
 | |
|     case XIT_RECT:
 | |
|       xi_bitmap_destroy( obj_def->v.rect->bitmap );
 | |
|       break;
 | |
|     default:
 | |
|       break;
 | |
|   }
 | |
|   for ( num = 0; num < obj_def->nbr_children; num++ )
 | |
|     xi_def_free_internal( obj_def->children[ num ] );
 | |
| }
 | |
| 
 | |
| /*--------------------------------------------------------------------------*/
 | |
| /* xi_def_free                                                              */
 | |
| /*--------------------------------------------------------------------------*/
 | |
| void
 | |
| xi_def_free( XI_OBJ_DEF* obj_def )
 | |
| {
 | |
|   xi_def_free_internal( obj_def );
 | |
|   xi_tree_free( obj_def );
 | |
| }
 | |
| 
 | |
| /*--------------------------------------------------------------------------*/
 | |
| /* get_button_def_rect                                                      */
 | |
| /*--------------------------------------------------------------------------*/
 | |
| static void
 | |
| get_button_def_rect( XinFont * font, XI_OBJ_DEF * obj_def,
 | |
|                     XinRect * rect )
 | |
| {
 | |
|   *rect = obj_def->v.btn->pixel_rect;
 | |
|   if ( rect->right == 0 && rect->left == 0 && rect->top == 0
 | |
|       && rect->bottom == 0 )
 | |
|   {
 | |
|     *rect = obj_def->v.btn->xi_rct;
 | |
|     xi_fu_to_pu_font( font, ( XinPoint * ) rect, 2 );
 | |
|   }
 | |
|   if ( rect->top == rect->bottom )
 | |
|     rect->bottom = rect->top + ( int ) xi_get_pref( XI_PREF_BUTTON_HEIGHT );
 | |
| }
 | |
| 
 | |
| /*--------------------------------------------------------------------------*/
 | |
| /* get_container_def_rect                                                   */
 | |
| /*--------------------------------------------------------------------------*/
 | |
| static void
 | |
| get_container_def_rect( XinFont * font, XI_OBJ_DEF * obj_def,
 | |
|                         XinRect * rect )
 | |
| {
 | |
|   *rect = obj_def->v.container->pixel_rect;
 | |
|   if ( !rect->right && !rect->left && !rect->top && !rect->bottom )
 | |
|   {
 | |
|     *rect = obj_def->v.container->xi_rct;
 | |
|     xi_fu_to_pu_font( font, ( XinPoint * ) rect, 2 );
 | |
|   }
 | |
| }
 | |
| 
 | |
| /*--------------------------------------------------------------------------*/
 | |
| /* get_column_def_rect                                                   */
 | |
| /*--------------------------------------------------------------------------*/
 | |
| static void
 | |
| get_column_def_rect( XinFont * font, XI_OBJ_DEF * obj_def,
 | |
|                     XinRect * rect )
 | |
| {
 | |
|   XI_OBJ_DEF *list;
 | |
|   XI_OBJ_DEF *itf;
 | |
| 
 | |
|   /* left and height is undefined without list context */
 | |
|   rect->top = rect->bottom = 0;
 | |
|   rect->left = 0;
 | |
|   if ( obj_def->v.column->pixel_width )
 | |
|     rect->right = obj_def->v.column->pixel_width;
 | |
|   else
 | |
|   {
 | |
|     rect->right = obj_def->v.column->width;
 | |
|     list = obj_def->parent;
 | |
|     if ( list == NULL )
 | |
|       itf = NULL;
 | |
|     else
 | |
|       itf = list->parent;
 | |
| 
 | |
|     if ( xi_def_get_xil_pref( itf ) )
 | |
|     {
 | |
|       if ( font )
 | |
|         rect->right *= xi_get_fu_width_font( font );
 | |
|       else
 | |
|         rect->right *= xi_get_fu_width( NULL );
 | |
|     }
 | |
|     else
 | |
|       xi_fu_to_pu_font( font, ( XinPoint * ) rect, 2 );
 | |
| 
 | |
|   }
 | |
| }
 | |
| 
 | |
| /*--------------------------------------------------------------------------*/
 | |
| /* get_interface_def_rect                                                   */
 | |
| /*--------------------------------------------------------------------------*/
 | |
| static void
 | |
| get_interface_def_rect( XinFont * font, XI_OBJ_DEF * obj_def,
 | |
|                         XinRect * rect )
 | |
| {
 | |
|   BOOLEAN first_rect = TRUE;
 | |
|   XI_OBJ_DEF **defp;
 | |
|   int i,
 | |
|   n;
 | |
| 
 | |
|   MEMCLEAR( *rect );
 | |
|   defp = obj_def->children;
 | |
|   n = obj_def->nbr_children;
 | |
|   for ( i = 0; i < n; defp++, i++ )
 | |
|   {
 | |
|     if ( first_rect )
 | |
|     {
 | |
|       if ( xi_get_def_rect( *defp, rect ) != NULL )
 | |
|         first_rect = FALSE;
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       XinRect rct;
 | |
| 
 | |
|       if ( xi_get_def_rect( *defp, &rct ) != NULL )
 | |
|         XinRectEnclose( rect, &rct, rect );
 | |
|     }
 | |
|   }
 | |
|   if ( obj_def->type == XIT_ITF )
 | |
|   {
 | |
|     int fu_width,
 | |
|     fu_height,
 | |
|     ws_right,
 | |
|     ws_bottom;
 | |
|     int ws_right_pix,
 | |
|     ws_bottom_pix;
 | |
| 
 | |
|     rect->left = 0;
 | |
|     rect->top = 0;
 | |
|     if ( !xi_def_get_xil_pref( obj_def ) )
 | |
|     {
 | |
|       if ( font )
 | |
|       {
 | |
|         fu_width = xi_get_fu_width_font( font );
 | |
|         fu_height = xi_get_fu_height_font( font );
 | |
|       }
 | |
|       else
 | |
|       {
 | |
|         fu_width = xi_get_fu_width( NULL );
 | |
|         fu_height = xi_get_fu_height( NULL );
 | |
|       }
 | |
|       ws_right = ( int ) xi_get_pref( XI_PREF_ITF_WS_RIGHT );
 | |
|       ws_bottom = ( int ) xi_get_pref( XI_PREF_ITF_WS_BOTTOM );
 | |
|       if ( obj_def->v.itf->use_whitespace )
 | |
|       {
 | |
|         ws_right = obj_def->v.itf->whitespace_right;
 | |
|         ws_bottom = obj_def->v.itf->whitespace_bottom;
 | |
|       }
 | |
|       ws_right_pix = fu_width * ws_right / XI_FU_MULTIPLE;
 | |
|       ws_bottom_pix = fu_height * ws_bottom / XI_FU_MULTIPLE;
 | |
|       rect->bottom += ws_bottom_pix;
 | |
|       rect->right += ws_right_pix;
 | |
|     }
 | |
|   }
 | |
| }
 | |
| 
 | |
| /*--------------------------------------------------------------------------*/
 | |
| /* get_field_def_rect                                                       */
 | |
| /*--------------------------------------------------------------------------*/
 | |
| static void
 | |
| get_field_def_rect( XinFont * font, XI_OBJ_DEF * obj_def,
 | |
|                     XinRect * rect )
 | |
| {
 | |
|   XI_FIELD_DEF *flddef = obj_def->v.field;
 | |
|   XinFont *parent_font = xi_def_get_font( obj_def->parent );
 | |
| 
 | |
| 
 | |
|   if ( flddef->xi_rct.top || flddef->xi_rct.left ||
 | |
|       flddef->xi_rct.bottom || flddef->xi_rct.right )
 | |
|   {
 | |
|     *rect = flddef->xi_rct;
 | |
|     xi_fu_to_pu_font( parent_font, ( XinPoint * ) rect, 2 );
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     if ( flddef->pixel_origin.v || flddef->pixel_origin.h )
 | |
|     {
 | |
|       rect->top = flddef->pixel_origin.v;
 | |
|       rect->left = flddef->pixel_origin.h;
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       rect->top = flddef->pnt.v;
 | |
|       rect->left = flddef->pnt.h;
 | |
|       xi_fu_to_pu_font( parent_font, ( XinPoint * ) rect, 1 );
 | |
|     }
 | |
|     {
 | |
|       XinPoint pnt;
 | |
| 
 | |
|       if ( flddef->pixel_width )
 | |
|         pnt.h = 2 * XI_FU_MULTIPLE;
 | |
|       else
 | |
|         pnt.h = flddef->field_width;
 | |
|       pnt.v = XI_FU_MULTIPLE;
 | |
|       xi_fu_to_pu_font( font, &pnt, 1 );
 | |
|       rect->bottom = rect->top + pnt.v;
 | |
|       if ( flddef->pixel_width )
 | |
|         rect->right = rect->left + flddef->pixel_width + pnt.h;
 | |
|       else
 | |
|         /* add 4 for the 3d rect */
 | |
|         rect->right = rect->left + pnt.h + 4;
 | |
|     }
 | |
|   }
 | |
|   XinFontDestroy( parent_font );
 | |
|   if ( flddef->button )
 | |
|   {
 | |
|     XinRect r;
 | |
|     int fu_width,
 | |
|     fu_height,
 | |
|     btn_dim_x,
 | |
|     btn_dim_x2,
 | |
|     btn_space;
 | |
| 
 | |
|     r.top = 0;
 | |
|     r.left = 0;
 | |
|     r.bottom = 8;
 | |
|     r.right = 8;
 | |
|     xi_fu_to_pu_font( font, ( XinPoint * ) & r, 2 );
 | |
|     fu_width = r.right;
 | |
|     fu_height = r.bottom;
 | |
|     btn_dim_x = ( fu_height * XI_FU_MULTIPLE ) / fu_width;
 | |
| #if XIWS != XIWS_WM
 | |
|     /* make buttons 70% wide as high */
 | |
|     btn_dim_x = ( int ) ( ( long ) btn_dim_x * 83L / 100L );
 | |
| #endif
 | |
|     btn_space = btn_dim_x / 6;
 | |
|     /* btn_dim_x2 is the button width + space, rounded up to */
 | |
|     /* the next even form unit */
 | |
|     btn_dim_x2 = btn_dim_x + btn_space;
 | |
|     btn_dim_x2 = ( ( btn_dim_x2 + XI_FU_MULTIPLE ) / XI_FU_MULTIPLE ) * XI_FU_MULTIPLE;
 | |
|     btn_dim_x = ( int ) ( ( ( long ) btn_dim_x * fu_width ) / XI_FU_MULTIPLE );
 | |
|     btn_dim_x2 = ( int ) ( ( ( long ) btn_dim_x2 * fu_width ) / XI_FU_MULTIPLE );
 | |
|     if ( flddef->button_on_left )
 | |
|     {
 | |
|       rect->right += btn_dim_x;
 | |
|       if ( flddef->pixel_button_distance )
 | |
|         rect->right += flddef->pixel_button_distance;
 | |
|       else
 | |
|         rect->right += ( btn_dim_x2 - btn_dim_x );
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       rect->right += btn_dim_x;
 | |
|       if ( flddef->pixel_button_distance )
 | |
|         rect->right += flddef->pixel_button_distance;
 | |
|       else
 | |
|       {
 | |
|         rect->right += ( btn_dim_x2 - btn_dim_x );
 | |
|         /* convert to form units */
 | |
|         rect->right = ( int ) ( ( ( long ) rect->right * XI_FU_MULTIPLE ) / fu_width );
 | |
|         /* round up to nearest FU multiple */
 | |
|         rect->right = ( ( rect->right + XI_FU_MULTIPLE ) / XI_FU_MULTIPLE ) * XI_FU_MULTIPLE;
 | |
|         /* convert to pixels */
 | |
|         rect->right = ( int ) ( ( ( long ) rect->right * fu_width ) / XI_FU_MULTIPLE );
 | |
|       }
 | |
|     }
 | |
|   }
 | |
| }
 | |
| 
 | |
| /*--------------------------------------------------------------------------*/
 | |
| /* get_list_def_rect                                                       */
 | |
| /*--------------------------------------------------------------------------*/
 | |
| static void
 | |
| get_list_def_rect( XinFont * font, XI_OBJ_DEF * obj_def,
 | |
|                   XinRect * rect )
 | |
| {
 | |
|   XI_LIST_DEF *list_def;
 | |
|   int list_xborder,
 | |
|   list_col_div,
 | |
|   width,
 | |
|   list_bottom;
 | |
|   int col_offset;
 | |
|   XinFont *parent_font = xi_def_get_font( obj_def->parent );
 | |
| 
 | |
|   list_def = obj_def->v.list;
 | |
|   lm_get_metrics( obj_def, &list_xborder, &list_col_div, &list_bottom );
 | |
|   col_offset = ( int ) xi_get_pref( XI_PREF_COLUMN_OFFSET );
 | |
|   if ( xi_def_get_xil_pref( obj_def->parent ) )
 | |
|   {
 | |
|     rect->top = list_def->xi_pnt.v;
 | |
|     rect->left = list_def->xi_pnt.h;
 | |
|     width = list_def->width;
 | |
|   }
 | |
|   else
 | |
|   {
 | |
|     if ( list_def->pixel_origin.h || list_def->pixel_origin.v )
 | |
|     {
 | |
|       rect->top = list_def->pixel_origin.h;
 | |
|       rect->left = list_def->pixel_origin.v;
 | |
|     }
 | |
|     else
 | |
|     {
 | |
|       rect->top = list_def->xi_pnt.v;
 | |
|       rect->left = list_def->xi_pnt.h;
 | |
|       xi_fu_to_pu_font( parent_font, ( XinPoint * ) rect, 1 );
 | |
|     }
 | |
|     width = list_def->pixel_width;
 | |
|     if ( !width )
 | |
|     {
 | |
|       XinPoint p;
 | |
| 
 | |
|       p.h = list_def->width;
 | |
|       p.v = 0;
 | |
|       xi_fu_to_pu_font( font, &p, 1 );
 | |
|       width = p.h;
 | |
|     }
 | |
|   }
 | |
|   XinFontDestroy( parent_font );
 | |
|   rect->bottom = 0;
 | |
|   if ( width )
 | |
|     rect->right = rect->left + width + 2 * BORDER_WIDTH;
 | |
|   else
 | |
|   {
 | |
|     XI_OBJ_DEF **defp;
 | |
|     int i,
 | |
|     n;
 | |
| 
 | |
|     defp = obj_def->children;
 | |
|     n = obj_def->nbr_children;
 | |
|     rect->right = rect->left;
 | |
|     for ( i = 0; i < n; defp++, i++ )
 | |
|     {
 | |
|       XinRect rct;
 | |
| 
 | |
|       xi_get_def_rect( *defp, &rct );
 | |
|       rect->right += rct.right;
 | |
|       if ( i )
 | |
|         rect->right += list_col_div;
 | |
|       else
 | |
|         rect->right += 2 * col_offset;
 | |
|     }
 | |
|     rect->right += BORDER_WIDTH * 2;
 | |
|   }
 | |
|   rect->bottom = list_bottom;
 | |
|   if ( list_def->scroll_bar )
 | |
|     rect->right = rect->right + ( int ) xi_get_pref( XI_PREF_SB_OFFSET )
 | |
|             + ( int ) XinMetricGet( XinMetricVerticalScrollBarWidth ) - 1;
 | |
|   if ( width )
 | |
|     rect->bottom += ( int ) XinMetricGet( XinMetricHorizontalScrollBarHeight ) + 3;
 | |
| }
 | |
| 
 | |
| /*--------------------------------------------------------------------------*/
 | |
| /* xi_get_def_rect                                                          */
 | |
| /*--------------------------------------------------------------------------*/
 | |
| 
 | |
| XinRect *
 | |
| xi_get_def_rect_internal( XI_OBJ_DEF * xi_obj_def, XinRect * rect, BOOLEAN r4_api )
 | |
| {
 | |
|   XinFont *font = NULL;
 | |
| 
 | |
|   xi_init_internal( r4_api );
 | |
|   font = xi_def_get_font( xi_obj_def );
 | |
|   MEMCLEAR( *rect );
 | |
|   switch ( xi_obj_def->type )
 | |
|   {
 | |
|     case XIT_BTN:
 | |
|       get_button_def_rect( font, xi_obj_def, rect );
 | |
|       break;
 | |
|     case XIT_CONTAINER:
 | |
|       get_container_def_rect( font, xi_obj_def, rect );
 | |
|       break;
 | |
|     case XIT_COLUMN:
 | |
|       get_column_def_rect( font, xi_obj_def, rect );
 | |
|       break;
 | |
|     case XIT_ITF:
 | |
|     case XIT_FORM:
 | |
|       get_interface_def_rect( font, xi_obj_def, rect );
 | |
|       break;
 | |
|     case XIT_FIELD:
 | |
|       get_field_def_rect( font, xi_obj_def, rect );
 | |
|       break;
 | |
|     case XIT_LIST:
 | |
|       get_list_def_rect( font, xi_obj_def, rect );
 | |
|       break;
 | |
|     case XIT_TEXT:
 | |
|       *rect = xi_obj_def->v.text->pixel_rect;
 | |
|       if ( !rect->left && !rect->right && !rect->top && !rect->bottom )
 | |
|       {
 | |
|         XinFontDestroy( font );
 | |
|         font = xi_def_get_font( xi_obj_def->parent );
 | |
|         *rect = xi_obj_def->v.text->xi_rct;
 | |
|         xi_fu_to_pu_font( font, ( XinPoint * ) rect, 2 );
 | |
|       }
 | |
|       break;
 | |
|     case XIT_GROUP:
 | |
|       /* no bounding rect for these guys! */
 | |
|       XinFontDestroy( font );
 | |
|       return ( NULL );
 | |
|     case XIT_RECT:
 | |
|       *rect = xi_obj_def->v.rect->xi_rct;
 | |
|       xi_fu_to_pu_font( font, ( XinPoint * ) rect, 2 );
 | |
|       break;
 | |
|     case XIT_LINE:
 | |
|       {
 | |
|         XI_LINE_DEF *line;
 | |
| 
 | |
|         line = xi_obj_def->v.line;
 | |
|         rect->top = min( line->pnt1.v, line->pnt2.v );
 | |
|         rect->bottom = max( line->pnt1.v, line->pnt2.v );
 | |
|         rect->left = min( line->pnt1.h, line->pnt2.h );
 | |
|         rect->right = max( line->pnt1.h, line->pnt2.h );
 | |
|         xi_fu_to_pu_font( font, ( XinPoint * ) rect, 2 );
 | |
|         break;
 | |
|       }
 | |
|     case XIT_CELL:
 | |
|     case XIT_ROW:
 | |
|     default:
 | |
|       XinError( 20019, XinSeverityFatal, 0L );
 | |
|   }
 | |
|   XinFontDestroy( font );
 | |
|   return ( rect );
 | |
| }
 | |
| 
 | |
| /* --------------------------------------------------------------------------*/
 | |
| /*  xi_button_set_default                                                    */
 | |
| /* --------------------------------------------------------------------------*/
 | |
| static void
 | |
| invalidate_button_rect( XI_OBJ * xi_obj )
 | |
| {
 | |
|   XinRect rect = xi_obj->v.btn->rct;
 | |
|   XinWindow win;
 | |
| 
 | |
|   if ( xi_obj->v.btn->type == XIBT_TABBTN )
 | |
|     rect.bottom += 2;
 | |
|   win = xi_obj->itf->v.itf->xin_win;
 | |
|   xi_invalidate_rect( win, &rect );
 | |
| }
 | |
| 
 | |
| BOOLEAN
 | |
| xi_button_set_default( XI_OBJ * xi_obj, BOOLEAN set )
 | |
| {
 | |
|   if ( xi_obj == NULL )
 | |
|     return FALSE;
 | |
|   if ( set )                    /* clear previous default button */
 | |
|   {
 | |
|     if ( xi_obj->type != XIT_BTN )
 | |
|       return FALSE;
 | |
|     if ( !xi_obj->v.btn->dflt )
 | |
|     {
 | |
|       xi_button_set_default( xi_obj->itf, FALSE );
 | |
|       xi_obj->v.btn->dflt = TRUE;
 | |
|       invalidate_button_rect( xi_obj );
 | |
|     }
 | |
|     return TRUE;
 | |
|   }
 | |
|   switch ( xi_obj->type )
 | |
|   {
 | |
|     case XIT_BTN:
 | |
|       if ( xi_obj->v.btn->dflt )
 | |
|       {
 | |
|         xi_obj->v.btn->dflt = FALSE;
 | |
|         invalidate_button_rect( xi_obj );
 | |
|       }
 | |
|       return TRUE;
 | |
|     case XIT_CONTAINER:
 | |
|     case XIT_ITF:
 | |
|       {
 | |
|         XI_OBJ **ptr;
 | |
|         int i;
 | |
|         int n;
 | |
| 
 | |
|         ptr = xi_obj->children;
 | |
|         n = xi_obj->nbr_children;
 | |
|         for ( i = 0; i < n; ptr++, i++ )
 | |
|           xi_button_set_default( *ptr, FALSE );
 | |
|         return TRUE;
 | |
|       }
 | |
|     default:
 | |
|       break;
 | |
|   }
 | |
|   return FALSE;
 | |
| }
 |