/* PauseBox */ int WDPROC PauseBox(LPPW lppw) { HDC hdc; int width, height; TEXTMETRIC tm; RECT rect; char *current_pause_title = lppw->Title; static char TITLE_PAUSE_MOUSE[] = "waiting for mouse click"; #ifdef USE_MOUSE if (paused_for_mouse) current_pause_title = TITLE_PAUSE_MOUSE; #endif if (!lppw->hPrevInstance) CreatePauseClass(lppw); GetWindowRect(GetDesktopWindow(), &rect); if ( (lppw->Origin.x == CW_USEDEFAULT) || (lppw->Origin.x == 0) ) lppw->Origin.x = (rect.right + rect.left) / 2; if ( (lppw->Origin.y == CW_USEDEFAULT) || (lppw->Origin.y == 0) ) lppw->Origin.y = (rect.bottom + rect.top) / 2; hdc = GetDC(NULL); SelectObject(hdc, GetStockObject(SYSTEM_FONT)); GetTextMetrics(hdc, &tm); width = max(24, 4 + strlen(lppw->Message)) * tm.tmAveCharWidth; width = min(width, rect.right-rect.left); height = 28 * (tm.tmHeight + tm.tmExternalLeading) / 4; ReleaseDC(NULL,hdc); lppw->hWndPause = CreateWindowEx( WS_EX_DLGMODALFRAME | WS_EX_APPWINDOW, szPauseClass, current_pause_title, /* HBB 981202: WS_POPUPWINDOW would have WS_SYSMENU in it, but we don't * want, nor need, a System menu in our Pause windows. */ WS_POPUP | WS_BORDER | WS_CAPTION, lppw->Origin.x - width/2, lppw->Origin.y - height/2, width, height, lppw->hWndParent, NULL, lppw->hInstance, lppw); /* Don't show the pause "OK CANCEL" dialog for "pause mouse ..." -- well, show it only for "pause -1". Note: maybe to show in the window titlebar or somewhere else a message like graphwin.Title = "gnuplot pausing (waiting for mouse click)"; */ #ifdef USE_MOUSE if (!paused_for_mouse) #endif { ShowWindow(lppw->hWndPause, SW_SHOWNORMAL); BringWindowToTop(lppw->hWndPause); UpdateWindow(lppw->hWndPause); } lppw->bPause = TRUE; lppw->bPauseCancel = IDCANCEL; while (lppw->bPause) { if (term->waitforinput == NULL) { /* Only handle message queue events */ WinMessageLoop(); WaitMessage(); } else { /* Call the non-blocking sleep function, which also handles console input (caca terminal) and mousing of the current terminal (e.g. qt) */ win_sleep(50); } } DestroyWindow(lppw->hWndPause); return lppw->bPauseCancel; }
/* PauseBox */ int WDPROC PauseBox(LPPW lppw) { MSG msg; HDC hdc; int width, height; TEXTMETRIC tm; RECT rect; char *current_pause_title = lppw->Title; static char TITLE_PAUSE_MOUSE[] = "waiting for mouse click"; if (paused_for_mouse) current_pause_title = TITLE_PAUSE_MOUSE; if (!lppw->hPrevInstance) CreatePauseClass(lppw); GetWindowRect(GetDesktopWindow(), &rect); if ( (lppw->Origin.x == CW_USEDEFAULT) || (lppw->Origin.x == 0) ) lppw->Origin.x = (rect.right + rect.left) / 2; if ( (lppw->Origin.y == CW_USEDEFAULT) || (lppw->Origin.y == 0) ) lppw->Origin.y = (rect.bottom + rect.top) / 2; hdc = GetDC(NULL); SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT)); GetTextMetrics(hdc, &tm); width = max(24,4+_fstrlen(lppw->Message)) * tm.tmAveCharWidth; width = min(width, rect.right-rect.left); height = 28 * (tm.tmHeight + tm.tmExternalLeading) / 4; ReleaseDC(NULL,hdc); #ifndef WIN32 lppw->lpfnPauseButtonProc = #ifdef __DLL__ (WNDPROC)GetProcAddress(hdllInstance, "PauseButtonProc"); #else (WNDPROC)MakeProcInstance((FARPROC)PauseButtonProc ,hdllInstance); #endif #endif lppw->hWndPause = CreateWindowEx( WS_EX_DLGMODALFRAME | WS_EX_TOPMOST #ifdef WS_EX_APPWINDOW /* HBB 20001217: put the pause window into the taskbar, and make * float on top of everything. This is cleaner than adding a window * menu to it, as the 3.5 code did it: */ | WS_EX_APPWINDOW #endif , szPauseClass, current_pause_title, /* HBB 981202: WS_POPUPWINDOW would have WS_SYSMENU in it, but we don't * want, nor need, a System menu in our Pause windows. Actually, it was * emptied manually, in the WM_CREATE handler below, in the original code. * This solution seems cleaner. */ WS_POPUP | WS_BORDER | WS_CAPTION, lppw->Origin.x - width/2, lppw->Origin.y - height/2, width, height, lppw->hWndParent, NULL, lppw->hInstance, lppw); SendMessage(lppw->hCancel, BM_SETSTYLE, (WPARAM)BS_DEFPUSHBUTTON, (LPARAM)FALSE); /* Don't show the pause "OK CANCEL" dialog for "pause mouse ..." -- well, show it only for "pause -1". Note: maybe to show in the window titlebar or somewhere else a message like graphwin.Title = "gnuplot pausing (waiting for mouse click)"; */ if (!paused_for_mouse) { ShowWindow(lppw->hWndPause, SW_SHOWNORMAL); BringWindowToTop(lppw->hWndPause); UpdateWindow(lppw->hWndPause); } lppw->bPause = TRUE; lppw->bPauseCancel = IDCANCEL; while (lppw->bPause) { /* HBB 20021211: Nigel Nunn found a better way to avoid * 100% CPU load --> use it */ if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { /* wait until window closed */ TranslateMessage(&msg); DispatchMessage(&msg); } else WaitMessage(); } DestroyWindow(lppw->hWndPause); #ifndef WIN32 #ifndef __DLL__ FreeProcInstance((FARPROC)lppw->lpfnPauseButtonProc); #endif #endif return(lppw->bPauseCancel); }
/* PauseBox */ int WDPROC PauseBox(LPPW lppw) { MSG msg; HDC hdc; int width, height; TEXTMETRIC tm; RECT rect; char *current_pause_title = lppw->Title; static char TITLE_PAUSE_MOUSE[] = "waiting for mouse click"; if (paused_for_mouse) current_pause_title = TITLE_PAUSE_MOUSE; if (!lppw->hPrevInstance) CreatePauseClass(lppw); GetWindowRect(GetDesktopWindow(), &rect); if ( (lppw->Origin.x == CW_USEDEFAULT) || (lppw->Origin.x == 0) ) lppw->Origin.x = (rect.right + rect.left) / 2; if ( (lppw->Origin.y == CW_USEDEFAULT) || (lppw->Origin.y == 0) ) lppw->Origin.y = (rect.bottom + rect.top) / 2; hdc = GetDC(NULL); SelectObject(hdc, GetStockObject(SYSTEM_FONT)); GetTextMetrics(hdc, &tm); width = max(24, 4 + strlen(lppw->Message)) * tm.tmAveCharWidth; width = min(width, rect.right-rect.left); height = 28 * (tm.tmHeight + tm.tmExternalLeading) / 4; ReleaseDC(NULL,hdc); lppw->hWndPause = CreateWindowEx( WS_EX_DLGMODALFRAME | WS_EX_APPWINDOW, szPauseClass, current_pause_title, /* HBB 981202: WS_POPUPWINDOW would have WS_SYSMENU in it, but we don't * want, nor need, a System menu in our Pause windows. */ WS_POPUP | WS_BORDER | WS_CAPTION, lppw->Origin.x - width/2, lppw->Origin.y - height/2, width, height, lppw->hWndParent, NULL, lppw->hInstance, lppw); /* Don't show the pause "OK CANCEL" dialog for "pause mouse ..." -- well, show it only for "pause -1". Note: maybe to show in the window titlebar or somewhere else a message like graphwin.Title = "gnuplot pausing (waiting for mouse click)"; */ if (!paused_for_mouse) { ShowWindow(lppw->hWndPause, SW_SHOWNORMAL); BringWindowToTop(lppw->hWndPause); UpdateWindow(lppw->hWndPause); } lppw->bPause = TRUE; lppw->bPauseCancel = IDCANCEL; while (lppw->bPause) { /* HBB 20021211: Nigel Nunn found a better way to avoid * 100% CPU load --> use it */ if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) { /* wait until window closed */ TranslateMessage(&msg); DispatchMessage(&msg); } else WaitMessage(); } DestroyWindow(lppw->hWndPause); return lppw->bPauseCancel; }