home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / m / motifpg2.zip / ch08 / xtryaccel.c < prev   
C/C++ Source or Header  |  1992-07-08  |  2KB  |  104 lines

  1. /*
  2.  * Copyright 1989, 1992 O'Reilly and Associates, Inc.
  3.  * See ../Copyright for complete rights and liability information.
  4.  */
  5.  
  6.  
  7. /*
  8.  * xtryaccel.c
  9.  */
  10.  
  11. #include <stdio.h>
  12. /*
  13.  * Include files required for all Toolkit programs
  14.  */
  15. #include <X11/Intrinsic.h>    /* Intrinsics Definitions */
  16. #include <X11/StringDefs.h>    /* Standard Name-String definitions */
  17.  
  18. /*
  19.  * Public include file for widgets we actually use in this file.
  20.  */
  21. #include <X11/Xaw/Command.h>        /* Athena Label Widget */
  22. #include <X11/Xaw/Box.h>        /* Athena Label Widget */
  23.  
  24. /*
  25.  * Goodbye button callback function
  26.  */
  27. /* ARGSUSED */
  28. void Quit(w, client_data, call_data)
  29. Widget w;
  30. XtPointer client_data, call_data;
  31.     exit(0);
  32. }
  33.  
  34. /*
  35.  * Hello button callback function
  36.  */
  37. /* ARGSUSED */
  38. void PressMe(w, client_data, call_data)
  39. Widget w;
  40. XtPointer client_data, call_data;
  41.     fprintf(stderr, "It was nice knowing you.\n");
  42. }
  43.  
  44. main(argc, argv)
  45. int argc;
  46. char **argv;
  47. {
  48.     XtAppContext app_context;
  49.     Widget topLevel, box, quit, pressme;
  50.  
  51.     XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL);
  52.  
  53.     topLevel = XtVaAppInitialize(
  54.         &app_context,       /* Application context */
  55.     "XTryAccel",        /* Application class */
  56.         NULL, 0,            /* command line option list */
  57.         &argc, argv,        /* command line args */
  58.         NULL,               /* for missing app-defaults file */
  59.         NULL);              /* terminate varargs list */
  60.  
  61.     box = XtCreateManagedWidget(
  62.     "box",        /* arbitrary widget name */
  63.     boxWidgetClass,    /* widget class from Label.h */
  64.     topLevel,    /* parent widget*/
  65.     NULL,        /* argument list */
  66.     0        /* arg list size */
  67.     );
  68.  
  69.     quit = XtCreateManagedWidget(
  70.     "quit",            /* arbitrary widget name */
  71.     commandWidgetClass,    /* widget class from Label.h */
  72.     box,            /* parent widget*/
  73.     NULL,            /* argument list */
  74.     0            /* arg list size */
  75.     );
  76.  
  77.     pressme = XtCreateManagedWidget(
  78.     "pressme",        /* arbitrary widget name */
  79.     commandWidgetClass,    /* widget class from Label.h */
  80.     box,            /* parent widget*/
  81.     NULL,            /* argument list */
  82.     0            /* arg list size */
  83.     );
  84.  
  85.     XtAddCallback(quit, XtNcallback, Quit, NULL);
  86.     XtAddCallback(pressme, XtNcallback, PressMe, NULL);
  87.  
  88.     /*
  89.      *  Create windows for widgets and map them.
  90.      */
  91.     XtRealizeWidget(topLevel);
  92.     
  93.     XtInstallAccelerators(box, quit);
  94.     XtInstallAccelerators(box, pressme);
  95.     
  96.     /*
  97.      *  Loop for events.
  98.      */
  99.     XtAppMainLoop(app_context);
  100. }
  101.  
  102.