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 / xmotdbltst.c < prev    next >
C/C++ Source or Header  |  1992-07-08  |  2KB  |  97 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.  * xmotdbltst.c - simple program to test getting motion events and 
  9.  * double clicks in the same widget.
  10.  */
  11.  
  12. #include <stdio.h>
  13. /*
  14.  * Include files required for all Toolkit programs
  15.  */
  16. #include <Xm/Xm.h>    /* Intrinsics and Motif Definitions */
  17.  
  18. /*
  19.  * Public include file for widgets we actually use in this file.
  20.  */
  21. #include <Xm/PushB.h>        /* Push Button Widget */
  22.  
  23. #define NUM_ACTIONS 3
  24.  
  25. /*ARGSUSED*/
  26. static void ActionA(w, event, params, num_params)
  27. Widget w;
  28. XButtonEvent *event;
  29. String *params;
  30. Cardinal *num_params;
  31. {
  32.     printf("action A executed\n");
  33. }
  34.  
  35. /*ARGSUSED*/
  36. static void ActionB(w, event, params, num_params)
  37. Widget w;
  38. XButtonEvent *event;
  39. String *params;
  40. Cardinal *num_params;
  41. {
  42.     printf("action B executed\n");
  43. }
  44.  
  45. /*ARGSUSED*/
  46. static void ActionC(w, event, params, num_params)
  47. Widget w;
  48. XButtonEvent *event;
  49. String *params;
  50. Cardinal *num_params;
  51. {
  52.     printf("action C executed\n");
  53. }
  54.  
  55. main(argc, argv)
  56. int argc;
  57. char **argv;
  58. {
  59.     XtAppContext app_context;
  60.     Widget topLevel, trial;
  61.     
  62.     static XtActionsRec trial_actions[] = {
  63.       {"actionA", ActionA},
  64.       {"actionB", ActionB},
  65.       {"actionC", ActionC},
  66.     };
  67.     
  68.     XtSetLanguageProc(NULL, (XtLanguageProc)NULL, NULL);
  69.  
  70.     topLevel = XtVaAppInitialize(
  71.         &app_context,       /* Application context */
  72.     "XMotdbltst",       /* Application class */
  73.         NULL, 0,            /* command line option list */
  74.         &argc, argv,        /* command line args */
  75.         NULL,               /* for missing app-defaults file */
  76.         NULL);              /* terminate varargs list */
  77.  
  78.     trial = XtCreateManagedWidget(
  79.     "trial",            /* arbitrary widget name */
  80.     xmPushButtonWidgetClass,    /* widget class from Label.h */
  81.     topLevel,            /* parent widget*/
  82.     NULL,                /* argument list */
  83.     0);                /* arg list size */
  84.  
  85.     XtAppAddActions(app_context, trial_actions, NUM_ACTIONS);
  86.  
  87.     /*
  88.      *  Create windows for widgets and map them.
  89.      */
  90.     XtRealizeWidget(topLevel);
  91.  
  92.     /*
  93.      *  Loop for events.
  94.      */
  95.     XtAppMainLoop(app_context);
  96. }
  97.