Annotation of researchv9/X11/src/X.V11R1/clients/xmh/popup.c, revision 1.1

1.1     ! root        1: /* $Header: popup.c,v 1.1 87/09/11 08:18:25 toddb Exp $ */
        !             2: /* popup.c -- Handle pop-up windows. */
        !             3: 
        !             4: #include "xmh.h"
        !             5: 
        !             6: /*
        !             7: static Window confirmwindow = NULL;
        !             8: static char *confirmstring;
        !             9: 
        !            10: static Window confirmparent;
        !            11: static count = 0;
        !            12: 
        !            13: static Window promptwindow;
        !            14: static int (*promptfunc)();
        !            15: static char promptstring[210];
        !            16: 
        !            17: extern TellPrompt();
        !            18: extern DestroyPromptWindow();
        !            19: 
        !            20: ArgList arglist, promptarglist;
        !            21: */
        !            22: 
        !            23: /*
        !            24: InitPopup()
        !            25: {
        !            26: }
        !            27: */
        !            28: 
        !            29: static Scrn lastscrn = NULL;
        !            30: static char laststr[500];
        !            31: 
        !            32: static Window confirmwindow = NULL;
        !            33: static int buttoncount = 0;
        !            34: static Window promptwindow = NULL;
        !            35: static void (*promptfunction)();
        !            36: 
        !            37: void CenterWindow(parent, child)
        !            38: Window parent, child;
        !            39: {
        !            40:     int x, y, parentwidth, parentheight, childwidth, childheight;
        !            41:     GetWindowSize(parent, &parentwidth, &parentheight);
        !            42:     GetWindowSize(child, &childwidth, &childheight);
        !            43:     x = (parentwidth - childwidth) / 2;
        !            44:     y = (parentheight - childheight) / 2;
        !            45:     if (x < 0) x = 0;
        !            46:     QXMoveWindow(theDisplay, child, x, y);
        !            47: }
        !            48: 
        !            49: 
        !            50: int Confirm(scrn, str)
        !            51: Scrn scrn;
        !            52: char *str;
        !            53: {
        !            54:     static Arg arglist[] = {
        !            55:        {XtNname, (XtArgVal)"confirm"}
        !            56:     };
        !            57:     extern void RedoLastButton();
        !            58:     if (lastscrn == scrn && strcmp(str, laststr) == 0) {
        !            59:        DestroyConfirmWindow();
        !            60:        return TRUE;
        !            61:     }
        !            62:     DestroyConfirmWindow();
        !            63:     lastscrn = scrn;
        !            64:     scrn = LastButtonScreen();
        !            65:     (void) strcpy(laststr, str);
        !            66:     confirmwindow = XtDialogCreate(DISPLAY scrn->window, str, (char *)NULL,
        !            67:                                   arglist, XtNumber(arglist));
        !            68:     XtDialogAddButton(DISPLAY confirmwindow,
        !            69:                      "yes", RedoLastButton, (caddr_t)NULL);
        !            70:     XtDialogAddButton(DISPLAY confirmwindow,
        !            71:                      "no", DestroyConfirmWindow, (caddr_t)NULL);
        !            72:     CenterWindow(scrn->window, confirmwindow);
        !            73:     QXMapWindow(theDisplay, confirmwindow);
        !            74:     buttoncount = 0;
        !            75:     return FALSE;
        !            76: }
        !            77: 
        !            78: 
        !            79: DestroyConfirmWindow()
        !            80: {
        !            81:     lastscrn = NULL;
        !            82:     *laststr = 0;
        !            83:     if (confirmwindow) {
        !            84:        QXDestroyWindow(theDisplay, confirmwindow);
        !            85:        (void) XtSendDestroyNotify(DISPLAY confirmwindow);
        !            86:        confirmwindow = NULL;
        !            87:     }
        !            88: }
        !            89: 
        !            90: 
        !            91: HandleConfirmEvent(event)
        !            92: XEvent *event;
        !            93: {
        !            94:     if (confirmwindow &&
        !            95:            (event->type == ButtonRelease || event->type == KeyPress)) {
        !            96:        if (++buttoncount > 1)
        !            97:            DestroyConfirmWindow();
        !            98:     }
        !            99: }
        !           100: 
        !           101: 
        !           102: DestroyPromptWindow()
        !           103: {
        !           104:     if (promptwindow) {
        !           105:        (void) XtSendDestroyNotify(DISPLAY promptwindow);
        !           106:        QXDestroyWindow(theDisplay, promptwindow);
        !           107:        promptwindow = NULL;
        !           108:     }
        !           109: }
        !           110: 
        !           111: 
        !           112: TellPrompt()
        !           113: {
        !           114:     (*promptfunction)(XtDialogGetValueString(DISPLAY promptwindow));
        !           115:     DestroyPromptWindow();
        !           116: }
        !           117: 
        !           118: MakePrompt(scrn, prompt, func)
        !           119: Scrn scrn;
        !           120: char *prompt;
        !           121: void (*func)();
        !           122: {
        !           123:     static Arg arglist[] = {
        !           124:        {XtNname, (XtArgVal)"prompt"}
        !           125:     };
        !           126:     DestroyPromptWindow();
        !           127:     promptwindow = XtDialogCreate(DISPLAY scrn->window, prompt, "",
        !           128:                                  arglist, XtNumber(arglist));
        !           129:     XtDialogAddButton(DISPLAY promptwindow,
        !           130:                      "goAhead", TellPrompt, (caddr_t)NULL);
        !           131:     XtDialogAddButton(DISPLAY promptwindow,
        !           132:                      "cancel", DestroyPromptWindow,
        !           133:                      (caddr_t)NULL);
        !           134:     CenterWindow(scrn->window, promptwindow);
        !           135:     QXMapWindow(theDisplay, promptwindow);
        !           136:     promptfunction = func;
        !           137: }

unix.superglobalmegacorp.com

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