1: #include <X/mit-copyright.h>
   2: 
   3: /* $Header: acttest.c,v 10.6 86/02/01 16:16:05 tony Rel $ */
   4: /* Copyright    Massachusetts Institute of Technology    1985	*/
   5: 
   6: /*
   7:  * XMenu:	MIT Project Athena, X Window System menu package.
   8:  *
   9:  *	acttest.c		Acttest is an XMenu selection / pane
  10:  *				activation testing utility.
  11:  *
  12:  *	Author:			Tony Della Fera, DEC
  13:  *				September, 1985
  14:  */
  15: 
  16: #include <X/Xlib.h>
  17: #include "../XMenu.h"
  18: #include <stdio.h>
  19: 
  20: main(argc, argv)
  21:     int argc;       /* Argument count. */
  22:     char **argv;    /* Argument vector. */
  23: {
  24:     register int i;     /* Counter. */
  25:     register int j;     /* Counter. */
  26:     register int stat;      /* Return status. */
  27:     register XMenu *menu;   /* Menu structure. */
  28:     char *data;         /* Test data. */
  29: 
  30:     int p_num = 0;      /* Pane number. */
  31:     int s_num = 0;      /* Selection number. */
  32:     int x, y;           /* Mouse X and Y position. */
  33: 
  34:     Window twin;        /* Temporary window. */
  35: 
  36:     /*
  37:      * Open the display.
  38:      */
  39:     if (XOpenDisplay(NULL) == NULL) {
  40:     printf("acttest: Error opening display.\n");
  41:     exit(0);
  42:     }
  43: 
  44:     /*
  45:      * Create the XMenu.
  46:      */
  47:     menu = (XMenu *)XMenuCreate(RootWindow, argv[0]);
  48:     if (menu == NULL) MenuError();
  49: 
  50:     /*
  51:      * Assemble the panes and selections.
  52:      */
  53:     printf("Acttest assembling panes: zero... ");
  54:     stat = XMenuAddPane(menu, "Pane Zero", 1);
  55:     if (stat == XM_FAILURE) MenuError();
  56:     stat = XMenuAddSelection(menu, 0, (char *)1, "Exit acctest.", 1);
  57:     if (stat == XM_FAILURE) MenuError();
  58:     stat = XMenuAddSelection(menu, 0, (char *)2, "Reactivate all panes.", 1);
  59:     if (stat == XM_FAILURE) MenuError();
  60:     stat = XMenuAddSelection(menu, 0, (char *)3, "Selection two.", 1);
  61:     if (stat == XM_FAILURE) MenuError();
  62:     stat = XMenuAddSelection(menu, 0, (char *)3, "Selection three.", 1);
  63:     if (stat == XM_FAILURE) MenuError();
  64: 
  65:     printf("one... ");
  66:     stat = XMenuAddPane(menu, "Pane One", 1);
  67:     if (stat == XM_FAILURE) MenuError();
  68:     stat = XMenuAddSelection(menu, 1, (char *)4, "Deactivate pane.", 1);
  69:     if (stat == XM_FAILURE) MenuError();
  70:     stat = XMenuAddSelection(menu, 1, (char *)3, "Selection one.", 1);
  71:     if (stat == XM_FAILURE) MenuError();
  72:     stat = XMenuAddSelection(menu, 1, (char *)3, "Selection two.", 1);
  73:     if (stat == XM_FAILURE) MenuError();
  74: 
  75:     printf("two... ");
  76:     stat = XMenuAddPane(menu, "Pane Two", 1);
  77:     if (stat == XM_FAILURE) MenuError();
  78:     stat = XMenuAddSelection(menu, 2, (char *)4, "Deactivate pane.", 1);
  79:     if (stat == XM_FAILURE) MenuError();
  80:     stat = XMenuAddSelection(menu, 2, (char *)3, "Selection one.", 1);
  81:     if (stat == XM_FAILURE) MenuError();
  82:     stat = XMenuAddSelection(menu, 2, (char *)3, "Selection two.", 1);
  83:     if (stat == XM_FAILURE) MenuError();
  84:     stat = XMenuAddSelection(menu, 2, (char *)3, "Selection three.", 1);
  85:     if (stat == XM_FAILURE) MenuError();
  86:     stat = XMenuAddSelection(menu, 2, (char *)3, "Selection four.", 1);
  87:     if (stat == XM_FAILURE) MenuError();
  88: 
  89:     printf("three... ");
  90:     stat = XMenuAddPane(menu, "Pane Three", 1);
  91:     if (stat == XM_FAILURE) MenuError();
  92:     stat = XMenuAddSelection(menu, 3, (char *)4, "Deactivate pane.", 1);
  93:     if (stat == XM_FAILURE) MenuError();
  94: 
  95:     printf("four... ");
  96:     stat = XMenuAddPane(menu, "Pane Four", 1);
  97:     if (stat == XM_FAILURE) MenuError();
  98:     stat = XMenuAddSelection(menu, 4, (char *)4, "Deactivate pane.", 1);
  99:     if (stat == XM_FAILURE) MenuError();
 100:     stat = XMenuAddSelection(menu, 4, (char *)3, "Selection one.", 1);
 101:     if (stat == XM_FAILURE) MenuError();
 102:     printf("done.\n");
 103: 
 104:     /*
 105:      * Recompute menu.
 106:      */
 107:     printf("Acttest recomputing menu dependencies.\n");
 108:     stat = XMenuRecompute(menu);
 109:     if (stat == XM_FAILURE) MenuError();
 110: 
 111:     /*
 112:      * Post the menu.
 113:      */
 114:     while (1) {
 115:     data = NULL;
 116:     printf(
 117:         "Acttest posting menu: pane = %d, selection = %d.\n",
 118:         p_num, s_num
 119:     );
 120:     XQueryMouse(RootWindow, &x, &y, &twin);
 121:     stat = XMenuActivate(
 122:         menu,
 123:         &p_num, &s_num,
 124:         x, y,
 125:         ButtonPressed,
 126:         &data
 127:     );
 128:     printf("Acttest results:  data = %d, pane = %d, selection = %d\n",
 129:         (int)data, p_num, s_num);
 130:     if (stat == XM_FAILURE) MenuError();
 131:     if (stat == XM_NO_SELECT) {
 132:         printf("Acttest reports no selection made.\n");
 133:         s_num = 0;
 134:         continue;
 135:     }
 136:     if (stat == XM_IA_SELECT) {
 137:         printf("Acttest reports no selection active.\n");
 138:         continue;
 139:     }
 140:     if ((int)data == 1) break;
 141:     if ((int)data == 2) {
 142:         printf("Acttest reactivating all selections.\n");
 143:         stat = XMenuSetPane(menu, 0, 1);
 144:         if (stat == XM_FAILURE) MenuError();
 145:         stat = XMenuSetSelection(menu, 0, 0, 1);
 146:         if (stat == XM_FAILURE) MenuError();
 147:         stat = XMenuSetSelection(menu, 0, 1, 1);
 148:         if (stat == XM_FAILURE) MenuError();
 149:         stat = XMenuSetSelection(menu, 0, 2, 1);
 150:         if (stat == XM_FAILURE) MenuError();
 151:         stat = XMenuSetSelection(menu, 0, 3, 1);
 152:         if (stat == XM_FAILURE) MenuError();
 153: 
 154:         stat = XMenuSetPane(menu, 1, 1);
 155:         if (stat == XM_FAILURE) MenuError();
 156:         stat = XMenuSetSelection(menu, 1, 0, 1);
 157:         if (stat == XM_FAILURE) MenuError();
 158:         stat = XMenuSetSelection(menu, 1, 1, 1);
 159:         if (stat == XM_FAILURE) MenuError();
 160:         stat = XMenuSetSelection(menu, 1, 2, 1);
 161:         if (stat == XM_FAILURE) MenuError();
 162: 
 163:         stat = XMenuSetPane(menu, 2, 1);
 164:         if (stat == XM_FAILURE) MenuError();
 165:         stat = XMenuSetSelection(menu, 2, 0, 1);
 166:         if (stat == XM_FAILURE) MenuError();
 167:         stat = XMenuSetSelection(menu, 2, 1, 1);
 168:         if (stat == XM_FAILURE) MenuError();
 169:         stat = XMenuSetSelection(menu, 2, 2, 1);
 170:         if (stat == XM_FAILURE) MenuError();
 171:         stat = XMenuSetSelection(menu, 2, 3, 1);
 172:         if (stat == XM_FAILURE) MenuError();
 173:         stat = XMenuSetSelection(menu, 2, 4, 1);
 174:         if (stat == XM_FAILURE) MenuError();
 175: 
 176:         stat = XMenuSetPane(menu, 3, 1);
 177:         if (stat == XM_FAILURE) MenuError();
 178:         stat = XMenuSetSelection(menu, 3, 0, 1);
 179:         if (stat == XM_FAILURE) MenuError();
 180: 
 181:         stat = XMenuSetPane(menu, 4, 1);
 182:         if (stat == XM_FAILURE) MenuError();
 183:         stat = XMenuSetSelection(menu, 4, 0, 1);
 184:         if (stat == XM_FAILURE) MenuError();
 185:         stat = XMenuSetSelection(menu, 4, 1, 1);
 186:         if (stat == XM_FAILURE) MenuError();
 187:         continue;
 188:     }
 189:     if ((int)data == 3) {
 190:         printf(
 191:         "Acttest deactivating selection %d in pane %d.\n",
 192:         s_num, p_num
 193:         );
 194:         stat = XMenuSetSelection(menu, p_num, s_num, 0);
 195:         if (stat == XM_FAILURE) MenuError();
 196:     }
 197:     if ((int)data == 4) {
 198:         printf("Acttest deactivating pane %d.\n", p_num);
 199:         stat = XMenuSetPane(menu, p_num, 0);
 200:         if (stat == XM_FAILURE) MenuError();
 201:     }
 202:     }
 203: 
 204:     /*
 205:      * Destroy XMenu.
 206:      */
 207:     printf("Acttest destroying menu.\n");
 208:     XMenuDestroy(menu);
 209: }
 210: 
 211: /*
 212:  * Print the XMenu error message.
 213:  */
 214: MenuError()
 215: {
 216:     printf("\nActtest reports XMenu error: %s.\n\n", XMenuError());
 217:     exit(0);
 218: }

Defined functions

MenuError defined in line 214; used 45 times
main defined in line 20; never used
Last modified: 1986-02-01
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1224
Valid CSS Valid XHTML 1.0 Strict