void change_displayed_size (int r, int c) { int rc; grab_video (); video_init (r, c); VioAssociate (0, hvps); VioDestroyPS (hvps); rc = VioCreatePS (&hvps, r, c, 0, 1, 0); rc = VioAssociate (hdc, hvps); rc = VioSetDeviceCellSize (cyChar, cxChar, hvps); VioSetCurType (pci, hvps); vio_rows = r; vio_cols = c; release_video (); }
USHORT __pascal VIOASSOCIATE(HDC hdc, HVPS hvps) { return VioAssociate(hdc, hvps); }
MRESULT EXPENTRY FlyWndProc (HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { SIZEL sizl; int rc, key, mou_r, mou_c, mou_ev, new_vio_rows, new_vio_cols; int deltaX, deltaY, pix_rows, pix_cols, new_x0, new_y0; static int mou_c1=-1, mou_r1=-1; struct _item *L; HWND hwndMenu; SWP swp; QMSG *qmsg; USHORT vk, fl; switch (msg) { case WM_CREATE: hdc = WinOpenWindowDC (hwnd); sizl.cx = sizl.cy = 0; grab_video (); hps = GpiCreatePS (hab, hdc, &sizl, PU_PELS | GPIF_DEFAULT | GPIT_MICRO | GPIA_ASSOC); rc = VioCreatePS (&hvps, 80, 25, 0, 1, 0); VioGetDeviceCellSize (&cyChar, &cxChar, hvps); set_cursor (0); VioSetCurType (pci, hvps); release_video (); DosPostEventSem (hev_VideoReady); return 0; case WM_MOUSEMOVE: mou_ev = MOUEV_MOVE; goto MOUSE; case WM_BUTTON1CLICK: mou_ev = MOUEV_B1SC; goto MOUSE; case WM_BUTTON1DBLCLK: mou_ev = MOUEV_B1DC; goto MOUSE; case WM_BUTTON1MOTIONSTART: mou_ev = MOUEV_B1MS; goto MOUSE; case WM_BUTTON1MOTIONEND: mou_ev = MOUEV_B1ME; goto MOUSE; case WM_BUTTON1DOWN: mou_ev = MOUEV_B1DN; goto MOUSE; case WM_BUTTON1UP: mou_ev = MOUEV_B1UP; goto MOUSE; case WM_BUTTON2CLICK: mou_ev = MOUEV_B2SC; goto MOUSE; case WM_BUTTON2DBLCLK: mou_ev = MOUEV_B2DC; goto MOUSE; case WM_BUTTON2MOTIONSTART: mou_ev = MOUEV_B2MS; goto MOUSE; case WM_BUTTON2MOTIONEND: mou_ev = MOUEV_B2ME; goto MOUSE; case WM_BUTTON2DOWN: mou_ev = MOUEV_B2DN; goto MOUSE; case WM_BUTTON2UP: mou_ev = MOUEV_B2UP; goto MOUSE; case WM_BUTTON3DBLCLK: mou_ev = MOUEV_B3DC; goto MOUSE; case WM_BUTTON3CLICK: mou_ev = MOUEV_B3SC; goto MOUSE; case WM_BUTTON3MOTIONSTART: mou_ev = MOUEV_B3MS; goto MOUSE; case WM_BUTTON3MOTIONEND: mou_ev = MOUEV_B3ME; goto MOUSE; case WM_BUTTON3DOWN: mou_ev = MOUEV_B3DN; goto MOUSE; case WM_BUTTON3UP: mou_ev = MOUEV_B3UP; goto MOUSE; MOUSE: if (fl_opt.mouse_active != TRUE) break; mou_r = vio_rows - 1 - (SHORT2FROMMP (mp1)/cyChar); mou_c = SHORT1FROMMP (mp1)/cxChar; if (mou_r < 0 || mou_c < 0) break; // prevent MOUEV_MOVE message with same coordinates if (mou_ev == MOUEV_MOVE && mou_r == mou_r1 && mou_c == mou_c1) break; mou_r1 = mou_r, mou_c1 = mou_c; que_put (FMSG_BASE_MOUSE + FMSG_BASE_MOUSE_EVTYPE*mou_ev + FMSG_BASE_MOUSE_X*mou_c + FMSG_BASE_MOUSE_Y*mou_r); break; case WM_PAINT: WinBeginPaint (hwnd, hps, NULL); grab_video (); VioShowBuf (0, 2 * vio_rows * vio_cols, hvps); release_video (); WinEndPaint (hps); return 0; case WM_CHAR: if (SHORT1FROMMP (mp1) & KC_KEYUP) return 0; if (SHORT2FROMMP (mp2) == VK_SHIFT || SHORT2FROMMP (mp2) == VK_CTRL || SHORT2FROMMP (mp2) == VK_ALT) return 0; key = pmkey2asvkey (SHORT2FROMMP(mp2), CHAR4FROMMP(mp1), SHORT1FROMMP(mp2), CHAR3FROMMP(mp1), SHORT1FROMMP(mp1)); if (key != -1) que_put (key); return 0; case WM_TRANSLATEACCEL: qmsg = (QMSG *)mp1; vk = SHORT2FROMMP (qmsg->mp2); fl = SHORT1FROMMP (qmsg->mp1) & (KC_ALT | KC_SHIFT | KC_CTRL | KC_KEYUP); if (vk == VK_MENU || vk == VK_F1) return FALSE; //if ((fl & KC_ALT) && vk >= VK_F1 && vk <= VK_F24) return FALSE; break; case WM_CLOSE: que_put (FMSG_BASE_SYSTEM + FMSG_BASE_SYSTEM_TYPE*SYSTEM_QUIT); return 0; case WM_SIZE: if (cxChar != 0 && cyChar != 0) { pix_rows = SHORT2FROMMP (mp2); pix_cols = SHORT1FROMMP (mp2); new_vio_rows = pix_rows / cyChar; new_vio_cols = pix_cols / cxChar; if (new_vio_rows != vio_rows || new_vio_cols != vio_cols) { grab_video (); VioAssociate (0, hvps); VioDestroyPS (hvps); rc = VioCreatePS (&hvps, new_vio_rows, new_vio_cols, 0, 1, 0); VioSetDeviceCellSize (cyChar, cxChar, hvps); VioGetDeviceCellSize (&cyChar, &cxChar, hvps); rc = VioAssociate (hdc, hvps); VioSetCurType (pci, hvps); release_video (); que_put (FMSG_BASE_SYSTEM + FMSG_BASE_SYSTEM_TYPE*SYSTEM_RESIZE + FMSG_BASE_SYSTEM_INT2*new_vio_rows + FMSG_BASE_SYSTEM_INT1*new_vio_cols); } deltaX = new_vio_cols*cxChar - pix_cols; deltaY = new_vio_rows*cyChar - pix_rows; //if (deltaX != 0 || deltaY != 0) if (abs(deltaX) > MAX_DELTA || abs(deltaY) > MAX_DELTA) { WinPostMsg (hwndFrame, WM_FLY_RESIZE, MPFROM2SHORT (SHORTBASE+deltaX, SHORTBASE+deltaY), NULL); } } WinDefAVioWindowProc (hwnd, msg, (ULONG)mp1, (ULONG)mp2); return 0; case WM_COMMAND: que_put (FMSG_BASE_MENU + LOUSHORT (mp1)); break; case WM_FLY_LOADMENU: L = PVOIDFROMMP (mp1); // obtain handle for window menu hwndMenu = WinWindowFromID (WinQueryWindow (hwnd, QW_PARENT), FID_MENU); fill_submenu (hwndMenu, L); fly_active_menu = L; break; case WM_FLY_UNLOADMENU: L = PVOIDFROMMP (mp1); // obtain handle for window menu hwndMenu = WinWindowFromID (WinQueryWindow (hwnd, QW_PARENT), FID_MENU); empty_submenu (hwndMenu, L); fly_active_menu = NULL; break; case WM_FLY_RESIZE: deltaX = SHORT1FROMMP (mp1) - SHORTBASE; deltaY = SHORT2FROMMP (mp1) - SHORTBASE; rc = WinQueryWindowPos (hwndFrame, &swp); rc = WinSetWindowPos (hwndFrame, 0, swp.x, swp.y-deltaY, swp.cx+deltaX, swp.cy+deltaY, SWP_SIZE|SWP_MOVE); break; case WM_FLY_MOVE_CANVAS: new_x0 = SHORT1FROMMP (mp1) - SHORTBASE; new_y0 = SHORT2FROMMP (mp1) - SHORTBASE; rc = WinQueryWindowPos (hwndFrame, &swp); WinSetWindowPos (hwndFrame, 0, new_x0, new_y0-swp.cy, 0, 0, SWP_MOVE); //DosPostEventSem (hev_VideoReady); break; case WM_FLY_MENU_CHSTATUS: hwndMenu = WinWindowFromID (WinQueryWindow (hwnd, QW_PARENT), FID_MENU); WinEnableMenuItem (hwndMenu, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1)); item_status_change++; break; case WM_FLY_MENU_CHSTATE: hwndMenu = WinWindowFromID (WinQueryWindow (hwnd, QW_PARENT), FID_MENU); WinSendMsg (hwndMenu, MM_SETITEMATTR, MPFROM2SHORT (SHORT1FROMMP(mp1), TRUE), MPFROM2SHORT (MIA_CHECKED, SHORT2FROMMP(mp1) ? MIA_CHECKED : 0)); break; case WM_DESTROY: grab_video (); VioAssociate (0, hvps); VioDestroyPS (hvps); GpiDestroyPS (hps); release_video (); que_put (FMSG_BASE_SYSTEM + FMSG_BASE_SYSTEM_TYPE*SYSTEM_DIE); return 0; } return WinDefWindowProc (hwnd, msg, mp1, mp2); }