[comp.windows.x] Writing error messages to a text window

nosmo%eagle@HUB.UCSB.EDU (Vincent Brooke Kraemer) (11/01/88)

Okay?  I admit it.  I'm confused.

I am writing an application in which I want to write error messages to a text
widget.  I don't want these messages to be written to the "xterm" (stdout 
or stderr), since I would like to keep all interaction localized for the
program. 

I have attempted a couple of different strategies to implement this
idea, and have come up empty each time.  What strategy will work (in X11R3),
using one of the Widget sets (I would prefer to use the Athena Widgets, but
I'm flexible)?

many thanks,
Vince (nosmo@cornu.ucsb.edu) Kraemer

swick@ATHENA.MIT.EDU (Ralph R. Swick) (11/01/88)

Here's a quick hack to examples/Xaw/xcommand.c;
embellish (or discard) as your heart desires :-)

*** /u1/X/src/examples/Xaw/xcommand.c	Fri Feb 26 00:28:01 1988
--- popup.c	Tue Nov  1 09:14:39 1988
***************
*** 1,6 ****
--- 1,9 ----
  #include <stdio.h>
  #include <X11/Intrinsic.h>
  #include <X11/Command.h>
+ #include <X11/Cardinals.h>
+ #include <X11/Shell.h>
+ #include <X11/StringDefs.h>
  
  static XrmOptionDescRec options[] = {
  {"-label",	"*label",	XrmoptionSepArg,	NULL}
***************
*** 12,18 ****
--- 15,42 ----
      fprintf( stderr, "Usage: %s\n", call );
  }
  
+ void ErrorPopup(parent, text)
+     Widget parent;
+     String text;
+ {
+     Arg args[4];
+     Position x, y;
+     Dimension w, h;
+     Widget popup;
  
+     XtSetArg( args[0], XtNwidth, &w );
+     XtSetArg( args[1], XtNheight, &h );
+     XtGetValues( parent, args, TWO );
+     XtTranslateCoords( parent, (Position)w/2, (Position)h/2, &x, &y );
+     XtSetArg( args[0], XtNx, x );
+     XtSetArg( args[1], XtNy, y );
+     popup = XtCreatePopupShell( "error", transientShellWidgetClass,
+ 			        parent, args, TWO );
+     XtSetArg( args[0], XtNlabel, text );
+     XtCreateManagedWidget( "text", labelWidgetClass, popup, args, ONE );
+     XtPopup(popup, XtGrabNone);
+ }
+ 
  /* ARGSUSED */
  void Activate(w, closure, call_data)
      Widget w;
***************
*** 19,27 ****
      caddr_t closure;
      caddr_t call_data;
  {
!     printf( "button was activated.\n" );
  }
- 
  
  void main(argc, argv)
      unsigned int argc;
--- 43,50 ----
      caddr_t closure;
      caddr_t call_data;
  {
!     ErrorPopup( w, "button was activated" );
  }
  
  void main(argc, argv)
      unsigned int argc;