3. Composite Widgets

Box Widget

Paned Widget

  /*****************************************************
   *
   *                composite.c
   *
   *  A very simple X program that shows how the composite
   *  widgets in the Athena widget set are used
   *
   *  This program constructs a paned widget that has
   *  three children.  Each of the children is a box
   *  widget that contains a quit button.  All three of
   *  the children can be resized.
   *
   ****************************************************/

  #include  < X11/StringDefs.h > 
  #include  < X11/Intrinsic.h > 
  #include  < X11/Xaw/Paned.h > 
  #include  < X11/Xaw/Box.h > 
  #include "../lib/lib.h"

  main(argc,argv)
  int argc;
  char **argv; {
       Widget toplevel;
       Widget paned;
       Widget box1, box2, box3;
       Widget quit1, quit2, quit3;
       Arg  wargs[10];
       int  n;

       toplevel = XtInitialize(argv[0],"simple",NULL, 0,
		 &argc, argv);

       paned = XtCreateManagedWidget("paned",panedWidgetClass,
		 toplevel, NULL, 0);

       box1 = XtCreateManagedWidget("box1",boxWidgetClass,
		 paned, NULL, 0);

       n=0;
       XtSetArg(wargs[n], XtNmin, 25); n++;
       XtSetArg(wargs[n], XtNmax, 75); n++;
       XtSetArg(wargs[n], XtNpreferredPaneSize, 50); n++;
       XtSetValues(box1,wargs,n);

       quit1 = quit_button(box1);

       box2 = XtCreateManagedWidget("box2",boxWidgetClass,
		 paned, NULL, 0);

       n=0;
       XtSetArg(wargs[n], XtNmin, 25); n++;
       XtSetArg(wargs[n], XtNmax, 75); n++;
       XtSetArg(wargs[n], XtNpreferredPaneSize, 50); n++;
       XtSetValues(box2,wargs,n);

       quit2 = quit_button(box2);

       box3 = XtCreateManagedWidget("box3",boxWidgetClass,
		 paned, NULL, 0);

       n=0;
       XtSetArg(wargs[n], XtNmin, 25); n++;
       XtSetArg(wargs[n], XtNmax, 75); n++;
       XtSetArg(wargs[n], XtNpreferredPaneSize, 50); n++;
       XtSetValues(box3,wargs,n);

       quit3 = quit_button(box3);

       XtRealizeWidget(toplevel);

       XtMainLoop();

  }

Form Widget



  /*****************************************************
   *
   *                composite.c
   *
   *  A very simple X program that shows how the composite
   *  widgets in the Athena widget set are used
   *
   *  This program constructs a form widget that has
   *  several children.  Each of the children is a box
   *  widget that contains a quit button.  The three
   *  children have different constraint resources
   *  and show how they can be used.
   *
   ****************************************************/

  #include  < X11/StringDefs.h > 
  #include  < X11/Intrinsic.h > 
  #include  < X11/Xaw/Form.h > 
  #include  < X11/Xaw/Box.h > 
  #include "../lib/lib.h"

  main(argc,argv)
  int argc;
  char **argv; {
       Widget toplevel;
       Widget form;
       Widget box1, box2, box3;
       Widget quit1, quit2, quit3;
       Arg  wargs[10];
       int  n;

       toplevel = XtInitialize(argv[0],"simple",NULL, 0,
		 &argc, argv);

       n = 0;
       XtSetArg(wargs[n],XtNheight,250); n++;
       XtSetArg(wargs[n],XtNwidth, 150); n++;
       XtSetValues(toplevel,wargs,n);

       form = XtCreateManagedWidget("form",formWidgetClass,
		 toplevel, NULL, 0);

       box1 = XtCreateManagedWidget("box1",boxWidgetClass,
		 form, NULL, 0);

       n=0;
       XtSetArg(wargs[n], XtNtop, XtChainTop); n++;
       XtSetArg(wargs[n], XtNbottom, XtChainTop); n++;
       XtSetValues(box1,wargs,n);

       quit1 = quit_button(box1);

       box2 = XtCreateManagedWidget("box2",boxWidgetClass,
		 form, NULL, 0);

       n=0;
       XtSetArg(wargs[n], XtNfromVert, box1); n++;
       XtSetValues(box2,wargs,n);

       quit2 = quit_button(box2);

       box3 = XtCreateManagedWidget("box3",boxWidgetClass,
		 form, NULL, 0);

       n=0;
       XtSetArg(wargs[n], XtNbottom, XtChainBottom); n++;
       XtSetArg(wargs[n], XtNtop, XtChainBottom); n++;
       XtSetArg(wargs[n], XtNfromVert, box2); n++;
       XtSetValues(box3,wargs,n);

       quit3 = quit_button(box3);

       XtRealizeWidget(toplevel);

       XtMainLoop();

  }

Dialog Widget

  /*****************************************************
   *
   *                composite.c
   *
   *  A very simple X program that shows how the composite
   *  widgets in the Athena widget set are used
   *
   *  This program constructs a dialog widget that is used
   *  to enter a name.  This widget has three buttons,
   *  one for accepting the name (printing it), one
   *  to cancel the current value, and the last one for
   *  exiting from the program.
   *
   ****************************************************/

  #include  < X11/StringDefs.h > 
  #include  < X11/Intrinsic.h > 
  #include  < X11/Xaw/Dialog.h > 
  #include  < stdio.h > 


  void sprint(w,dialog,call)
  Widget w;
  Widget dialog;
  XtPointer call; {
       char *s;

       s = XawDialogGetValueString(dialog);
       printf("%s\n",s);

  }


  void reset(w,dialog,call)
  Widget w;
  Widget dialog;
  XtPointer call; {
       char *s;
       Arg wargs[5];

       s = (char *)malloc(1);
       s[0] = 0;

       XtSetArg(wargs[0],XtNvalue,s);
       XtSetValues(dialog,wargs,1);

  }

  void quit(w,dialog,call)
  Widget w;
  Widget dialog;
  XtPointer call; {

       exit(0);

  }


  main(argc,argv)
  int argc;
  char **argv; {
       Widget toplevel;
       Widget dialog;
       Arg  wargs[10];
       int  n;

       toplevel = XtInitialize(argv[0],"simple",NULL, 0,
		 &argc, argv);

       n = 0;
       XtSetArg(wargs[n],XtNheight,250); n++;
       XtSetArg(wargs[n],XtNwidth, 200); n++;
       XtSetValues(toplevel,wargs,n);

       dialog = XtCreateManagedWidget("dialog",dialogWidgetClass,
		 toplevel, NULL, 0);

       n=0;
       XtSetArg(wargs[n], XtNlabel, "Enter a name"); n++;
       XtSetArg(wargs[n], XtNvalue, ""); n++;
       XtSetValues(dialog,wargs,n);

       XawDialogAddButton(dialog,"accept",sprint,dialog);
       XawDialogAddButton(dialog,"cancel",reset,dialog);
       XawDialogAddButton(dialog,"quit",quit,dialog);


       XtRealizeWidget(toplevel);

       XtMainLoop();

  }


  Go to Simple Widgets        Go to Index        Go to Pixmaps and Bitmaps