[BACK]Return to wpause.c CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gnuplot / win

Annotation of OpenXM_contrib/gnuplot/win/wpause.c, Revision 1.1

1.1     ! maekawa     1: #ifndef lint
        !             2: static char *RCSid = "$Id: wpause.c,v 1.8 1998/03/22 22:35:29 drd Exp $";
        !             3: #endif
        !             4:
        !             5: /* GNUPLOT - win/wpause.c */
        !             6: /*[
        !             7:  * Copyright 1992, 1993, 1998   Russell Lang
        !             8:  *
        !             9:  * Permission to use, copy, and distribute this software and its
        !            10:  * documentation for any purpose with or without fee is hereby granted,
        !            11:  * provided that the above copyright notice appear in all copies and
        !            12:  * that both that copyright notice and this permission notice appear
        !            13:  * in supporting documentation.
        !            14:  *
        !            15:  * Permission to modify the software is granted, but not the right to
        !            16:  * distribute the complete modified source code.  Modifications are to
        !            17:  * be distributed as patches to the released version.  Permission to
        !            18:  * distribute binaries produced by compiling modified sources is granted,
        !            19:  * provided you
        !            20:  *   1. distribute the corresponding source modifications from the
        !            21:  *    released version in the form of a patch file along with the binaries,
        !            22:  *   2. add special version identification to distinguish your version
        !            23:  *    in addition to the base release version number,
        !            24:  *   3. provide your name and address as the primary contact for the
        !            25:  *    support of your modified version, and
        !            26:  *   4. retain our contact information in regard to use of the base
        !            27:  *    software.
        !            28:  * Permission to distribute the released version of the source code along
        !            29:  * with corresponding source modifications in the form of a patch file is
        !            30:  * granted with same provisions 2 through 4 for binary distributions.
        !            31:  *
        !            32:  * This software is provided "as is" without express or implied warranty
        !            33:  * to the extent permitted by applicable law.
        !            34: ]*/
        !            35:
        !            36: /*
        !            37:  * AUTHORS
        !            38:  *
        !            39:  *   Russell Lang
        !            40:  *
        !            41:  * Send your comments or suggestions to
        !            42:  *  info-gnuplot@dartmouth.edu.
        !            43:  * This is a mailing list; to join it send a note to
        !            44:  *  majordomo@dartmouth.edu.
        !            45:  * Send bug reports to
        !            46:  *  bug-gnuplot@dartmouth.edu.
        !            47:  */
        !            48: /* PauseBox() */
        !            49:
        !            50: /* MessageBox ALWAYS appears in the middle of the screen so instead */
        !            51: /* we use this PauseBox so we can decide where it is to be placed */
        !            52:
        !            53: #define STRICT
        !            54: #include <windows.h>
        !            55: #include <windowsx.h>
        !            56: #include <string.h>
        !            57: #include "wgnuplib.h"
        !            58: #include "wresourc.h"
        !            59: #include "wcommon.h"
        !            60:
        !            61: /* Pause Window */
        !            62: LRESULT CALLBACK WINEXPORT WndPauseProc(HWND, UINT, WPARAM, LPARAM);
        !            63: LRESULT CALLBACK WINEXPORT PauseButtonProc(HWND, UINT, WPARAM, LPARAM);
        !            64:
        !            65: /* Create Pause Class */
        !            66: /* called from PauseBox the first time a pause window is created */
        !            67: void
        !            68: CreatePauseClass(LPPW lppw)
        !            69: {
        !            70:        WNDCLASS wndclass;
        !            71:
        !            72:        wndclass.style = 0;
        !            73:        wndclass.lpfnWndProc = (WNDPROC)WndPauseProc;
        !            74:        wndclass.cbClsExtra = 0;
        !            75:        wndclass.cbWndExtra = sizeof(void FAR *);
        !            76:        wndclass.hInstance = lppw->hInstance;
        !            77:        wndclass.hIcon = NULL;
        !            78:        wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
        !            79:        wndclass.hbrBackground = (HBRUSH)(COLOR_BTNFACE+1);
        !            80:        wndclass.lpszMenuName = NULL;
        !            81:        wndclass.lpszClassName = szPauseClass;
        !            82:        RegisterClass(&wndclass);
        !            83: }
        !            84:
        !            85: /* PauseBox */
        !            86: int WDPROC
        !            87: PauseBox(LPPW lppw)
        !            88: {
        !            89:        MSG msg;
        !            90:        HDC hdc;
        !            91:        int width, height;
        !            92:        TEXTMETRIC tm;
        !            93:        RECT rect;
        !            94:
        !            95:        if (!lppw->hPrevInstance)
        !            96:                CreatePauseClass(lppw);
        !            97:        GetWindowRect(GetDesktopWindow(), &rect);
        !            98:        if ( (lppw->Origin.x == CW_USEDEFAULT) || (lppw->Origin.x == 0) )
        !            99:                lppw->Origin.x = (rect.right + rect.left) / 2;
        !           100:        if ( (lppw->Origin.y == CW_USEDEFAULT) || (lppw->Origin.y == 0) )
        !           101:                lppw->Origin.y = (rect.bottom + rect.top) / 2;
        !           102:
        !           103:        hdc = GetDC(NULL);
        !           104:        SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));
        !           105:        GetTextMetrics(hdc, &tm);
        !           106:        width  = max(24,4+_fstrlen(lppw->Message)) * tm.tmAveCharWidth;
        !           107:        width = min(width, rect.right-rect.left);
        !           108:        height = 28 * (tm.tmHeight + tm.tmExternalLeading) / 4;
        !           109:        ReleaseDC(NULL,hdc);
        !           110:
        !           111: #ifndef WIN32
        !           112:        lppw->lpfnPauseButtonProc =
        !           113: #ifdef __DLL__
        !           114:                (WNDPROC)GetProcAddress(hdllInstance, "PauseButtonProc");
        !           115: #else
        !           116:                (WNDPROC)MakeProcInstance((FARPROC)PauseButtonProc ,hdllInstance);
        !           117: #endif
        !           118: #endif
        !           119:        lppw->hWndPause = CreateWindowEx(WS_EX_DLGMODALFRAME,
        !           120:                szPauseClass, lppw->Title,
        !           121: /* HBB 981202: WS_POPUPWINDOW would have WS_SYSMENU in it, but we don't
        !           122:  * want, nor need, a System menu in our Pause windows. Actually, it was
        !           123:  * emptied manually, in the WM_CREATE handler below, in the original code.
        !           124:  * This solution seems cleaner. */
        !           125:                WS_POPUP | WS_BORDER | WS_CAPTION,
        !           126:                lppw->Origin.x - width/2, lppw->Origin.y - height/2,
        !           127:                width, height,
        !           128:                lppw->hWndParent, NULL, lppw->hInstance, lppw);
        !           129:        ShowWindow(lppw->hWndPause, SW_SHOWNORMAL);
        !           130:        BringWindowToTop(lppw->hWndPause);
        !           131:        UpdateWindow(lppw->hWndPause);
        !           132:
        !           133:        lppw->bPause = TRUE;
        !           134:        lppw->bPauseCancel = IDCANCEL;
        !           135:        while (lppw->bPause)
        !           136:                while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) {
        !           137:                        /* wait until window closed */
        !           138:                        TranslateMessage(&msg);
        !           139:                        DispatchMessage(&msg);
        !           140:                }
        !           141:        DestroyWindow(lppw->hWndPause);
        !           142: #ifndef WIN32
        !           143: #ifndef __DLL__
        !           144:        FreeProcInstance((FARPROC)lppw->lpfnPauseButtonProc);
        !           145: #endif
        !           146: #endif
        !           147:
        !           148:        return(lppw->bPauseCancel);
        !           149: }
        !           150:
        !           151: LRESULT CALLBACK WINEXPORT
        !           152: WndPauseProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
        !           153: {
        !           154:        HDC hdc;
        !           155:        PAINTSTRUCT ps;
        !           156:        RECT rect;
        !           157:        TEXTMETRIC tm;
        !           158:        LPPW lppw;
        !           159:        int cxChar, cyChar, middle;
        !           160:
        !           161:        lppw = (LPPW)GetWindowLong(hwnd, 0);
        !           162:
        !           163:        switch(message) {
        !           164:                case WM_KEYDOWN:
        !           165:                        if (wParam == VK_RETURN) {
        !           166:                                if (lppw->bDefOK)
        !           167:                                        SendMessage(hwnd, WM_COMMAND, IDOK, 0L);
        !           168:                                else
        !           169:                                        SendMessage(hwnd, WM_COMMAND, IDCANCEL, 0L);
        !           170:                        }
        !           171:                        return(0);
        !           172:                case WM_COMMAND:
        !           173:                        switch(LOWORD(wParam)) {
        !           174:                                case IDCANCEL:
        !           175:                                case IDOK:
        !           176:                                        lppw->bPauseCancel = LOWORD(wParam);
        !           177:                                        lppw->bPause = FALSE;
        !           178:                                        break;
        !           179:                        }
        !           180:                        return(0);
        !           181:                case WM_SETFOCUS:
        !           182:                        SetFocus(lppw->bDefOK ? lppw->hOK : lppw->hCancel);
        !           183:                        return(0);
        !           184:                case WM_PAINT:
        !           185:                        {
        !           186:                        hdc = BeginPaint(hwnd, &ps);
        !           187:                        SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));
        !           188:                        SetTextAlign(hdc, TA_CENTER);
        !           189:                        GetClientRect(hwnd, &rect);
        !           190:                        SetBkMode(hdc,TRANSPARENT);
        !           191:                        TextOut(hdc,(rect.right+rect.left)/2, (rect.bottom+rect.top)/6,
        !           192:                                lppw->Message,_fstrlen(lppw->Message));
        !           193:                        EndPaint(hwnd, &ps);
        !           194:                        return 0;
        !           195:                        }
        !           196:                case WM_CREATE:
        !           197:                        {
        !           198:                        /* HBB 981202 HMENU sysmenu = GetSystemMenu(hwnd, FALSE); */
        !           199:                        lppw = ((CREATESTRUCT FAR *)lParam)->lpCreateParams;
        !           200:                        SetWindowLong(hwnd, 0, (LONG)lppw);
        !           201:                        lppw->hWndPause = hwnd;
        !           202:                        hdc = GetDC(hwnd);
        !           203:                        SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));
        !           204:                        GetTextMetrics(hdc, &tm);
        !           205:                        cxChar = tm.tmAveCharWidth;
        !           206:                        cyChar = tm.tmHeight + tm.tmExternalLeading;
        !           207:                        ReleaseDC(hwnd,hdc);
        !           208:                        middle = ((LPCREATESTRUCT) lParam)->cx / 2;
        !           209:                        lppw->hOK = CreateWindow((LPSTR)"button", (LPSTR)"OK",
        !           210:                                WS_CHILD | WS_VISIBLE | BS_DEFPUSHBUTTON,
        !           211:                                        middle - 10*cxChar, 3*cyChar,
        !           212:                                        8*cxChar, 7*cyChar/4,
        !           213:                                        hwnd, (HMENU)IDOK,
        !           214:                                        ((LPCREATESTRUCT) lParam)->hInstance, NULL);
        !           215:                        lppw->bDefOK = TRUE;
        !           216:                        lppw->hCancel = CreateWindow((LPSTR)"button", (LPSTR)"Cancel",
        !           217:                                WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
        !           218:                                        middle + 2*cxChar, 3*cyChar,
        !           219:                                        8*cxChar, 7*cyChar/4,
        !           220:                                        hwnd, (HMENU)IDCANCEL,
        !           221:                                        ((LPCREATESTRUCT) lParam)->hInstance, NULL);
        !           222:                        lppw->lpfnOK = (WNDPROC) GetWindowLong(lppw->hOK, GWL_WNDPROC);
        !           223: #ifdef WIN32
        !           224:                        SetWindowLong(lppw->hOK, GWL_WNDPROC, (LONG)PauseButtonProc);
        !           225: #else
        !           226:                        SetWindowLong(lppw->hOK, GWL_WNDPROC, (LONG)lppw->lpfnPauseButtonProc);
        !           227: #endif
        !           228:                        lppw->lpfnCancel = (WNDPROC) GetWindowLong(lppw->hCancel, GWL_WNDPROC);
        !           229: #ifdef WIN32
        !           230:                        SetWindowLong(lppw->hCancel, GWL_WNDPROC, (LONG)PauseButtonProc);
        !           231: #else
        !           232:                        SetWindowLong(lppw->hCancel, GWL_WNDPROC, (LONG)lppw->lpfnPauseButtonProc);
        !           233: #endif
        !           234:                        if (GetParent(hwnd))
        !           235:                                EnableWindow(GetParent(hwnd),FALSE);
        !           236: #if 0 /* HBB 981203 */
        !           237:                        DeleteMenu(sysmenu,SC_RESTORE,MF_BYCOMMAND);
        !           238:                        DeleteMenu(sysmenu,SC_SIZE,MF_BYCOMMAND);
        !           239:                        DeleteMenu(sysmenu,SC_MINIMIZE,MF_BYCOMMAND);
        !           240:                        DeleteMenu(sysmenu,SC_MAXIMIZE,MF_BYCOMMAND);
        !           241:                        DeleteMenu(sysmenu,SC_TASKLIST,MF_BYCOMMAND);
        !           242:                        DeleteMenu(sysmenu,0,MF_BYCOMMAND); /* a separator */
        !           243:                        DeleteMenu(sysmenu,0,MF_BYCOMMAND); /* a separator */
        !           244: #endif
        !           245:                        }
        !           246:                        return 0;
        !           247:                case WM_DESTROY:
        !           248:                        GetWindowRect(hwnd, &rect);
        !           249:                        lppw->Origin.x = (rect.right+rect.left)/2;
        !           250:                        lppw->Origin.y = (rect.bottom+rect.top)/2;
        !           251:                        lppw->bPause = FALSE;
        !           252:                        if (GetParent(hwnd))
        !           253:                                EnableWindow(GetParent(hwnd),TRUE);
        !           254:                        break;
        !           255:        }
        !           256:        return DefWindowProc(hwnd, message, wParam, lParam);
        !           257: }
        !           258:
        !           259:
        !           260: LRESULT CALLBACK WINEXPORT
        !           261: PauseButtonProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
        !           262: {
        !           263:        LPPW lppw;
        !           264: #ifdef WIN32
        !           265:        LONG n = GetWindowLong(hwnd, GWL_ID);
        !           266: #else
        !           267:        WORD n = GetWindowWord(hwnd, GWW_ID);
        !           268: #endif
        !           269:        lppw = (LPPW)GetWindowLong(GetParent(hwnd), 0);
        !           270:        switch(message) {
        !           271:                case WM_KEYDOWN:
        !           272:                        switch(wParam) {
        !           273:                          case VK_TAB:
        !           274:                          case VK_BACK:
        !           275:                          case VK_LEFT:
        !           276:                          case VK_RIGHT:
        !           277:                          case VK_UP:
        !           278:                          case VK_DOWN:
        !           279:                                lppw->bDefOK = !(n == IDOK);
        !           280:                                if (lppw->bDefOK) {
        !           281:                                        SendMessage(lppw->hOK,     BM_SETSTYLE, (WPARAM)BS_DEFPUSHBUTTON, (LPARAM)TRUE);
        !           282:                                        SendMessage(lppw->hCancel, BM_SETSTYLE, (WPARAM)BS_PUSHBUTTON, (LPARAM)TRUE);
        !           283:                                        SetFocus(lppw->hOK);
        !           284:                                }
        !           285:                                else {
        !           286:                                        SendMessage(lppw->hOK,     BM_SETSTYLE, (WPARAM)BS_PUSHBUTTON, (LPARAM)TRUE);
        !           287:                                        SendMessage(lppw->hCancel, BM_SETSTYLE, (WPARAM)BS_DEFPUSHBUTTON, (LPARAM)TRUE);
        !           288:                                        SetFocus(lppw->hCancel);
        !           289:                                }
        !           290:                                break;
        !           291:                          default:
        !           292:                                SendMessage(GetParent(hwnd), message, wParam, lParam);
        !           293:                        }
        !           294:                        break;
        !           295:        }
        !           296:        return CallWindowProc(((n == IDOK) ? lppw->lpfnOK : lppw->lpfnCancel),
        !           297:                 hwnd, message, wParam, lParam);
        !           298: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>