v02i008: a differnet interface to widget creation, Patch1

Mike Wexler mikew at wyse.wyse.com
Thu Oct 27 08:42:25 AEST 1988


Submitted-by: Dan Heller <island!ceylon!argv at Sun.COM>
Posting-number: Volume 2, Issue 8
Archive-name: widgetwrap/patch1



These update diffs don't fix any bugs (since none were reported), but
instead provide some enhancements: You can now create shell widgets
and popup widgets using this library.

*** OLD/Patchlevel.h	Sat Oct 15 19:47:04 1988
--- Patchlevel.h	Fri Oct 21 12:41:19 1988
***************
*** 1 ****
! #define PATCHLEVEL 0
--- 1 ----
! #define PATCHLEVEL 1
*** OLD/WidgetWrap.c	Sat Oct 15 19:45:58 1988
--- WidgetWrap.c	Fri Oct 21 12:40:30 1988
***************
*** 30,35 ****
--- 30,37 ----
   *
   *    XtNmanaged		pass "False" to create a non-managed widget.
   *    XtNargList		takes _two_ parameters.
+  *    XtNpopupShell		pass "True" to create a PopupShellWidget.
+  *    XtNapplicShell		pass "True" to create an applicationShellWidget
   *
   * The XtNargList makes it possible to pass attributes to the create/get/set
   * calls that are probably common to many widgets to be created or reset.
***************
*** 92,103 ****
      va_list	var;
      Arg		args[MAXARGS];
      int		err = 0, nargs, i = 0;
-     int		managed = True;
      String	argstr;
      XtArgVal	argval;
      char	*name, buf[32];
      WidgetClass class;
!     Widget	parent;
  
      va_start(var);
  
--- 94,104 ----
      va_list	var;
      Arg		args[MAXARGS];
      int		err = 0, nargs, i = 0;
      String	argstr;
      XtArgVal	argval;
      char	*name, buf[32];
      WidgetClass class;
!     Widget	parent, (*create_func)() = XtCreateManagedWidget;
  
      va_start(var);
  
***************
*** 122,130 ****
  		err++;
  		break;
  	    }
! 	} else if (!strcmp(argstr, XtNmanaged))
! 	    /* managed is _really_ boolean, but varargs only works with ints */
! 	    managed = va_arg(var, int);
  	else {
  	    argval = va_arg(var, XtArgVal);
  	    XtSetArg(args[i], argstr, argval);
--- 123,134 ----
  		err++;
  		break;
  	    }
! 	} else if (!strcmp(argstr, XtNmanaged) && !va_arg(var, int))
! 	    create_func = XtCreateWidget;
! 	else if (!strcmp(argstr, XtNpopupShell) && va_arg(var, int))
! 	    create_func = XtCreatePopupShell;
! 	else if (!strcmp(argstr, XtNapplicShell) && va_arg(var, int))
! 	    create_func = XtCreateApplicationShell;
  	else {
  	    argval = va_arg(var, XtArgVal);
  	    XtSetArg(args[i], argstr, argval);
***************
*** 136,145 ****
      if (err)
  	return NULL;
  
!     if (managed)
! 	return XtCreateManagedWidget(name, class, parent, args, i);
!     else
! 	return XtCreateWidget(name, class, parent, args, i);
  }
  
  /*
--- 140,146 ----
      if (err)
  	return NULL;
  
!     return (create_func)(name, class, parent, args, i);
  }
  
  /*
*** OLD/WidgetWrap.h	Sat Oct 15 19:45:59 1988
--- WidgetWrap.h	Fri Oct 21 12:40:30 1988
***************
*** 8,13 ****
--- 8,15 ----
  #define MAXARGS		50
  #define XtNargList	"Arglist"
  #define XtNmanaged	"Managed"
+ #define XtNpopupShell	"popupShell"
+ #define XtNapplicShell	"applicationShell"
  
  extern void WidgetSet(), WidgetGet();
  extern Widget WidgetCreate();
*** OLD/WidgetWrap.man	Sat Oct 15 19:48:28 1988
--- WidgetWrap.man	Fri Oct 21 12:59:46 1988
***************
*** 58,71 ****
  .fi
  .in -4
  As you can see, the list must be NULL terminated.  You may pass up to
! to MAXARGS argument pairs (which is defined in WidgetWrap.h).  There are
! special args available to the Create/Get/Set functions that are available:
  .sp
! .in +2
! XtNmanaged\ \ \ \ pass "False" to create a non-managed widget.
! XtNargList\ \ \ \ takes \fItwo\fP parameters.
! .in -2
  .sp
  The XtNargList makes it possible to pass attributes to the Create/Get/Set
  calls that are probably common to many widgets to be created or reset.
  .sp
--- 58,84 ----
  .fi
  .in -4
  As you can see, the list must be NULL terminated.  You may pass up to
! to MAXARGS argument pairs (which is defined in WidgetWrap.h).  This limit
! is for WidgetCreate() only; WidgetSet() may take any number of arguments.
  .sp
! There are special arguments available to the functions that are available:
  .sp
+ .in +4
+ .ta 1.5i
+ .ti -2
+ XtNmanaged	pass "False" for a non-managed widget.
+ .ti -2
+ XtNapplicShell	uses XtCreateApplicationShell
+ .ti -2
+ XtNpopupShell	uses XtCreatePopupShell
+ .ti -2
+ XtNargList	takes \fItwo\fP parameters: args and num_args.
+ .in -4
+ .sp
+ WidgetCreate uses XtCreateManagedWidget by default, so if XtNmanaged is
+ specified with an argument of False, then XtCreateWidget is used instead.
+ The similar situation is done for XtNpopupShell and XtNapplicShell.
+ .sp
  The XtNargList makes it possible to pass attributes to the Create/Get/Set
  calls that are probably common to many widgets to be created or reset.
  .sp
***************
*** 95,103 ****
  automatically by calling GenericWidgetName() since most of the time,
  user's don't care what the name of a widget is, this capability is available.
  .SH DIAGNOSTICS
! WidgetCreate() will return NULL if a widget cannot be created.  It uses
! the routines (and is a front end for) XtCreateWidget() and
! XtCreateManagedWidget().
  .SH "SEE ALSO"
  XtCreateWidget(3X),
  XtCreateManagedWidget(3X),
--- 108,117 ----
  automatically by calling GenericWidgetName() since most of the time,
  user's don't care what the name of a widget is, this capability is available.
  .SH DIAGNOSTICS
! WidgetCreate() will return NULL if a widget cannot be created.  It is an
! error to try to use more than one of XtNapplicShell, XtNPopupShell, and
! XtNmanaged, but no error is reported.  The last attribute set to True will
! be used.
  .SH "SEE ALSO"
  XtCreateWidget(3X),
  XtCreateManagedWidget(3X),
-- 
Mike Wexler(wyse!mikew)    Phone: (408)433-1000 x1330
Moderator of comp.sources.x



More information about the Comp.sources.x mailing list