home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / m / motifpg2.zip / ch03 / Ex3-8.c next >
C/C++ Source or Header  |  1992-07-08  |  2KB  |  95 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.  *  Ex3-8.c - demonstrate passing data to callback function
  9.  */
  10.  
  11. /*
  12.  *  So that we can use fprintf:
  13.  */
  14. #include <stdio.h>
  15.  
  16. /* 
  17.  * Standard Toolkit include files:
  18.  */
  19. #include <X11/Intrinsic.h>
  20. #include <Xm/Xm.h>
  21.  
  22. /*
  23.  * Public include files for widgets used in this file.
  24.  */
  25. #include <Xm/PushB.h>
  26. #include <Xm/RowColumn.h>
  27.  
  28. /*
  29.  * quit button callback function
  30.  */
  31. /*ARGSUSED*/
  32. void Quit(w, client_data, call_data)
  33. Widget w;
  34. XtPointer client_data, call_data;
  35.     exit(0); 
  36. }
  37.  
  38. /*
  39.  * "Press me!" button callback function
  40.  */
  41. /*ARGSUSED*/
  42. void PressMe(w, client_data, call_data)
  43. Widget w;
  44. XtPointer client_data, call_data;
  45.     fprintf(stderr, "%s\n", client_data); 
  46. }
  47.  
  48. main(argc, argv)
  49. int argc;
  50. char **argv;
  51. {
  52.     XtAppContext app_context;
  53.     Widget rowColumn, quit, pressme, topLevel;
  54.  
  55.     /*
  56.      * Register the default language procedure
  57.      */
  58.     XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL);
  59.  
  60.     topLevel = XtVaAppInitialize(
  61.             &app_context,       /* Application context */
  62.             "XRowColumn",       /* application class name */
  63.             NULL, 0,            /* command line option list */
  64.             &argc, argv,        /* command line args */
  65.             NULL,               /* for missing app-defaults file */
  66.             NULL);              /* terminate varargs list */
  67.  
  68.     rowColumn = XtVaCreateManagedWidget(
  69.             "rowColumn",            /* widget name */
  70.             xmRowColumnWidgetClass, /* widget class */
  71.             topLevel,               /* parent widget*/
  72.             NULL);                  /* terminate varargs list*/
  73.  
  74.     quit = XtVaCreateManagedWidget(
  75.             "quit",                     /* widget name */
  76.             xmPushButtonWidgetClass,    /* widget class */
  77.             rowColumn,                  /* parent widget*/
  78.             NULL);                      /* terminate varargs list*/
  79.  
  80.     pressme = XtVaCreateManagedWidget(
  81.             "pressme",                  /* widget name   */
  82.             xmPushButtonWidgetClass,    /* widget class */
  83.             rowColumn,                  /* parent widget*/
  84.             NULL);                      /* terminate varargs list*/
  85.  
  86.     XtAddCallback(quit, XmNactivateCallback, Quit, 0);
  87.     XtAddCallback(pressme, XmNactivateCallback, PressMe, "Thanks");
  88.  
  89.     XtRealizeWidget(topLevel);
  90.  
  91.     XtAppMainLoop(app_context);
  92. }
  93.