Annotation of 43BSD/contrib/X/XMenu/tests/instest.c, revision 1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.