void Window::getCursorPos( int &x, int &y ) { POINTL ptl; WinQueryPointerPos( HWND_DESKTOP, &ptl ); WinMapWindowPoints( HWND_DESKTOP, hWndClient, &ptl, 1 ); x = ptl.x; y = ptl.y; }
QPoint QCursor::pos() { POINTL p; WinQueryPointerPos(HWND_DESKTOP, &p); // flip y coordinate p.y = qt_display_height() - (p.y + 1); return QPoint(p.x, p.y); }
void OS2Factory::getMousePos( int &rXPos, int &rYPos ) const { POINTL ptl; WinQueryPointerPos( HWND_DESKTOP, &ptl ); rXPos = ptl.x; rYPos = ( getScreenHeight() - 1 ) - ptl.y; // Invert Y }
void PopupMenu( HWND hwnd, PMINIRECORDCORE pRec) { HWND hMenu; POINTL ptl; do { // only show the menu if we're over an item if (pRec == 0) break; // if 0 or 1 item is selected, show the single object menu; // if more than 1 is selected, show the multiple object menu if ((pRec->flRecordAttr & CRA_SELECTED) == 0) { hMenu = hmnuSingle; WinSendMsg( hCnr, CM_SETRECORDEMPHASIS, (MP)pRec, MPFROM2SHORT( TRUE, CRA_SOURCE)); } else { if (WinSendMsg( hCnr, CM_QUERYRECORDEMPHASIS, (MP)CMA_FIRST, (MP)CRA_SELECTED) != (MP)pRec) hMenu = hmnuMultiple; else if (WinSendMsg( hCnr, CM_QUERYRECORDEMPHASIS, (MP)pRec, (MP)CRA_SELECTED) != 0) hMenu = hmnuMultiple; else hMenu = hmnuSingle; } // if we're using the single object menu, save the item it refers to // and set the appropriate menu text; otherwise, set this to zero if (hMenu == hmnuMultiple) precMenu = 0; else { precMenu = pRec; WinSendMsg( hMenu, MM_SETITEMTEXT, (MP)IDM_DELETE, (MP)((((PULONG)&pRec[1])[eDEL] == hDelIco) ? "~Undelete" : "~Delete")); } // popup the menu at the mouse pointer WinQueryPointerPos( HWND_DESKTOP, &ptl); WinPopupMenu( HWND_DESKTOP, hwnd, hMenu, ptl.x, ptl.y, 0, PU_HCONSTRAIN | PU_VCONSTRAIN | PU_MOUSEBUTTON1 | PU_KEYBOARD); } while (fFalse); return; }
MRESULT EXPENTRY ClientWndProc (HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2) { static HWND hwndMenuPopup ; HPS hps ; POINTL ptlMouse ; switch (msg) { case WM_CREATE: hwndMenuPopup = WinLoadMenu (hwnd, NULL, ID_POPUP) ; WinSetWindowPos (hwndMenuPopup, NULL, 0, 0, 0, 0, SWP_SIZE) ; WinSetParent (hwndMenuPopup, HWND_DESKTOP, FALSE) ; return 0 ; case WM_BUTTON2UP: WinQueryPointerPos (HWND_DESKTOP, &ptlMouse) ; ptlMouse.y += WinQuerySysValue (HWND_DESKTOP, SV_CYMENU) ; WinSetWindowPos (hwndMenuPopup, NULL, (SHORT) ptlMouse.x, (SHORT) ptlMouse.y, 0, 0, SWP_MOVE) ; WinSendMsg (hwndMenuPopup, MM_SELECTITEM, MPFROM2SHORT (IDM_POPUP, FALSE), MPFROMSHORT (FALSE)) ; WinSetCapture (HWND_DESKTOP, hwndMenuPopup) ; return 0 ; case WM_COMMAND: switch (COMMANDMSG(&msg)->cmd) { case IDM_ABOUT: WinDlgBox (HWND_DESKTOP, hwnd, AboutDlgProc, NULL, IDD_ABOUT, NULL) ; return 0 ; } break ; case WM_PAINT: hps = WinBeginPaint (hwnd, NULL, NULL) ; GpiErase (hps) ; WinEndPaint (hps) ; return 0 ; } return WinDefWindowProc (hwnd, msg, mp1, mp2) ; }
void ShowObjMenu( HWND hwnd) { ULONG rc = 0; ULONG ulHndl; PRWSHDR pHdr = 0; PMINIRECORDCORE pRec; POINTL ptl; do { pRec = precMenu; precMenu = 0; // this should only be called if the single-object menu was used if (pRec == 0) ERRNBR( 1) // get the object's handle from the Key column ulHndl = strtoul( ((char**)&pRec[1])[eKEY], 0, 10); // get the mouse position & convert to container coordinates WinQueryPointerPos( HWND_DESKTOP, &ptl); WinMapWindowPoints( HWND_DESKTOP, hCnr, &ptl, 1); // this command calls wpDisplayMenu() with the "important" arguments // preset by RwsServer; hwnd is the window that should get the focus // when the menu is dismissed, and ptl is the menu location in hwnd // coordinates - both arguments are optional; the command returns // the popupmenu's hwnd which we don't use here ERRRTN( RwsCall( &pHdr, RWSP_CMD, RWSCMD_POPUPMENU, RWSR_ASIS, 0, 3, RWSI_OHNDL, 0, ulHndl, RWSI_ASIS, 0, hCnr, RWSI_PBUF, sizeof(POINTL), (ULONG)&ptl)) } while (fFalse); if (rc) { RwsGetRcString( rc, sizeof( szError), szError); printf( "ShowObjMenu: rc= %d %s\n", rc, szError); } // free the server request block RwsFreeMem( pHdr); return; }
void info_wait(int id) { POINTL pt; if (id) load_string(id, szWait, sizeof(szWait)); else szWait[0] = '\0'; if (hwnd_status) { WinInvalidateRect(hwnd_status, (PRECTL)NULL, TRUE); WinUpdateWindow(hwnd_status); } /* find out if cursor over hwnd_bmp */ if (!WinQueryPointerPos(HWND_DESKTOP, &pt)) return; if (hwnd_bmp == WinWindowFromPoint(HWND_DESKTOP, &pt, TRUE)) WinSendMsg(hwnd_bmp, WM_MOUSEMOVE, MPFROM2SHORT(pt.x, pt.y), (MPARAM)0); }
/**************************************************************************** * ShowMouse * * - Hides/shows the mouse depending on the state of the game * * - No I/O. * ****************************************************************************/ VOID ShowMouse(BOOL bShowMouse) { static INT cPointerLvl = 0; /* Pointer level, 0 = visible */ static POINTL ptl; /* Pointer position when hidden */ if (bShowMouse) { if (cPointerLvl == 1) { cPointerLvl = 0; WinSetPointerPos(HWND_DESKTOP, ptl.x, ptl.y); WinShowPointer(HWND_DESKTOP, TRUE); } } else { if (iGameMode != GAME_MODE_INIT1 && iGameMode != GAME_MODE_INIT2 && prfProfile.bMOUSECONTROL && cPointerLvl == 0) { cPointerLvl = 1; WinQueryPointerPos(HWND_DESKTOP, &ptl); WinShowPointer(HWND_DESKTOP, FALSE); } } }
static void kstMenu(HWND hwnd, KSTPTR p) { POINTL pt ; ULONG opts ; if (p->hwndMn == NULLHANDLE) { p->hwndMn = WinLoadMenu(hwnd, NULLHANDLE, IDM_KEYST) ; } if (p->hwndMn == NULLHANDLE) { return ; } WinQueryPointerPos(HWND_DESKTOP, &pt) ; opts = PU_HCONSTRAIN | PU_VCONSTRAIN | PU_KEYBOARD | PU_MOUSEBUTTON1 | PU_MOUSEBUTTON2 ; WinPopupMenu(HWND_DESKTOP, hwnd, p->hwndMn, pt.x, pt.y, IDM_KEYTGL, opts) ; }
VOID _System threadMouMovMgr(ULONG ul) { ULONG ulPost; POINTL ptl; INT i; ULONG covrd; // numero corrente spostamenti mouse da traiettoria impostata ULONG cstops; // numero di movimenti volontari mouse necessari per // cancellare movimento automatico if (DosCreateEventSem(NULL, &g.mou.hev, DC_SEM_SHARED, 0)) { stlrlog(IDERR_CREATESERVEVSEM); return; } /* endif */ DosSetPriority(PRTYS_THREAD, PRTYC_TIMECRITICAL, 31, 0); for (;;) { restart: // label su cui punta quando esce dal loop interno g.is.mousebtn &= ~MOVEMOUPTR; covrd = 0; DosWaitEventSem(g.mou.hev, SEM_INDEFINITE_WAIT); cstops = (o.mou.moveSteps & 0x2f) >> 3; for (i = 0; i < o.mou.moveSteps; ++i) { WinQueryPointerPos(HWND_DESKTOP, &ptl); // se il mouse Š stato spostato dall'utente x 3 volte if (memcmp(&ptl, &g.mou.ptc, sizeof(POINTL)) && ++covrd > cstops) break; g.mou.wr.cx += g.mou.dp.x; g.mou.wr.cy += g.mou.dp.y; g.mou.ptc.x = (LONG)(g.mou.wr.cx >> 16); g.mou.ptc.y = (LONG)(g.mou.wr.cy >> 16); WinSetPointerPos(HWND_DESKTOP, g.mou.ptc.x, g.mou.ptc.y); DosSleep(1); // se semaforo Š stato resettato perch‚ il puntatore del mouse deve // essere spostato su una finestra differente ricomincia dall'inizio DosQueryEventSem(g.mou.hev, &ulPost); if (!ulPost) goto restart; } /* endfor */ DosResetEventSem(g.mou.hev, &ulPost); g.mou.hwndNew = g.mou.hwnd = NULLHANDLE; } /* endfor */ DosCloseEventSem(g.mou.hev); }
void Window::setPointer( int type ) { LONG getPointer = -1; switch( type ) { case PTR_ARROW : getPointer = SPTR_ARROW; break; case PTR_TEXT : getPointer = SPTR_TEXT; break; case PTR_WAIT : getPointer = SPTR_WAIT; break; case PTR_MOVE : getPointer = SPTR_SIZENS; break; case PTR_HAND : getPointer = SPTR_ARROW; break; } if( getPointer != -1 ) currentPointer = WinQuerySysPointer( HWND_DESKTOP, getPointer, FALSE ); else currentPointer = NULLHANDLE; // Display the new pointer by focring a WM_MOUSEMOVE POINTL pos; WinQueryPointerPos( HWND_DESKTOP, &pos ); WinSetPointerPos( HWND_DESKTOP, pos.x, pos.y ); }
MRESULT Window::stdWndProc( HWND hWnd, ULONG iMessage, MPARAM mParam1, MPARAM mParam2, BOOL *returned ) { switch( iMessage ) { // case WM_FOCUSCHANGE : case WM_SETSELECTION : case WM_ACTIVATE : { if( type != Window::LISTBOX && type != Window::COMBOLISTBOX ) { focus( (BOOL)mParam1 );//SHORT1FROMMP( mParam2 ) ); } break; } case WM_SETFOCUS : { if( type != Window::LISTBOX && type != Window::COMBOLISTBOX ) focusSet( (BOOL)mParam2 ); break; } case WM_BUTTON1DOWN : { if( type == SCROLLBAR ) setFocus(); HWND hwnd = WinQueryFocus( HWND_DESKTOP ); if( mouseListener.getSize() != 0 ) { mouseButtonDown = TRUE; WinSetCapture( HWND_DESKTOP, hWnd ); WinStartTimer( Application::hab, hWndClient, 1, 50 ); Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::DOWN ); } if( hwnd != WinQueryFocus( HWND_DESKTOP ) ) return (MRESULT)TRUE; break; } case WM_BUTTON1UP : { if( type == LISTBOX || type == COMBOLISTBOX ) { performFocusEvent( (int)WinSendMsg( (HWND)mParam2, LM_QUERYSELECTION, MPARAM(0), MPARAM(NULL) ) ); } else if( mouseListener.getSize() != 0 ) { mouseButtonDown = FALSE; WinStopTimer( Application::hab, hWndClient, 1 ); WinSetCapture( HWND_DESKTOP, NULLHANDLE ); Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::RELEASE ); // return (MPARAM)TRUE; } break; } case WM_BUTTON2DOWN : { if( mouseListener.getSize() != 0 ) { WinSetCapture( HWND_DESKTOP, hWnd ); WinStartTimer( Application::hab, hWndClient, 1, 50 ); Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::RIGHT, AMouseEvent::DOWN ); } break; } case WM_BUTTON2UP : { if( mouseListener.getSize() != 0 ) { WinStopTimer( Application::hab, hWndClient, 1 ); WinSetCapture( HWND_DESKTOP, NULLHANDLE ); Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::RIGHT, AMouseEvent::RELEASE ); } break; } case WM_BUTTON1CLICK : { if( mouseListener.getSize() != 0 ) { // Check if triple click int newTick = WinGetCurrentTime( Application::hab ); if( newTick - lastTick <= WinQuerySysValue( HWND_DESKTOP, SV_DBLCLKTIME ) ) { Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::TRIPLECLICK ); } else { Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::CLICK ); } } break; } case WM_BUTTON2CLICK : { if( mouseListener.getSize() != 0 ) { Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::RIGHT, AMouseEvent::CLICK ); } break; } case WM_BUTTON1DBLCLK : { if( mouseListener.getSize() != 0 ) { Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::LEFT, AMouseEvent::DOUBLECLICK ); } lastTick = WinGetCurrentTime( Application::hab ); break; } case WM_BUTTON2DBLCLK : { if( mouseListener.getSize() != 0 ) { Point pos( SHORT1FROMMP(mParam1), SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, AMouseEvent::RIGHT, AMouseEvent::DOUBLECLICK ); } break; } case WM_MOUSEMOVE : { if( currentPointer != NULLHANDLE ) WinSetPointer( HWND_DESKTOP, currentPointer ); if( mouseListener.getSize() != 0 ) { Point pos( (SHORT)SHORT1FROMMP(mParam1), (SHORT)SHORT2FROMMP(mParam1) ); performMouseEvent( &pos, 0, AMouseEvent::MOVE ); } if( currentPointer != NULLHANDLE ) return (MPARAM)TRUE; break; } case WM_TIMER : { if( mouseButtonDown ) { POINTL ptl; WinQueryPointerPos( HWND_DESKTOP, &ptl ); WinMapWindowPoints( HWND_DESKTOP, hWnd, &ptl, 1 ); if( ptl.y < 0 || ptl.y > height ) { Point pos( ptl.x, ptl.y ); performMouseEvent( &pos, 0, AMouseEvent::MOVE ); } } break; } case WM_SIZE : { int oldWidth = width, oldHeight = height; SWP swp; WinQueryWindowPos( hWndFrame, &swp ); width = swp.cx; height = swp.cy; size( oldWidth, oldHeight ); break; } case WM_HSCROLL : { int pos = SHORT1FROMMP( mParam2 ), id = SHORT1FROMMP( mParam1 ); switch( SHORT2FROMMP( mParam2 ) ) { case SB_PAGERIGHT : { performScrollbarEvent( id, Scrollbar::PAGERIGHT, pos ); break; } case SB_PAGELEFT : { performScrollbarEvent( id, Scrollbar::PAGELEFT, pos ); break; } case SB_LINERIGHT : { performScrollbarEvent( id, Scrollbar::LINERIGHT, pos ); break; } case SB_LINELEFT : { performScrollbarEvent( id, Scrollbar::LINELEFT, pos ); break; } case SB_SLIDERTRACK : { performScrollbarEvent( id, Scrollbar::HORZTRACK, pos ); break; } case SB_SLIDERPOSITION : { performScrollbarEvent( id, Scrollbar::HORZRELEASED, pos ); break; } } break; } case WM_SYSCOMMAND : { // Check if the parent is a dialog, then chain the WM_SYSCOMMAND if( parent->getType() == DIALOG ) WinSendMsg( ((Window *)parent)->getHWND(), WM_SYSCOMMAND, mParam1, mParam2 ); break; } case WM_VSCROLL : { int id = SHORT1FROMMP( mParam1 ); Scrollbar *scrollbar = (Scrollbar *)getControl( id ); int pos; if( scrollbar ) pos = scrollbar->convertScrollPosToReal( SHORT1FROMMP( mParam2 ) ); else pos = SHORT1FROMMP( mParam2 ); switch( SHORT2FROMMP( mParam2 ) ) { case SB_PAGEDOWN : { performScrollbarEvent( id, Scrollbar::PAGEDOWN, pos ); break; } case SB_PAGEUP : { performScrollbarEvent( id, Scrollbar::PAGEUP, pos ); break; } case SB_LINEDOWN : { performScrollbarEvent( id, Scrollbar::LINEDOWN, pos ); break; } case SB_LINEUP : { performScrollbarEvent( id, Scrollbar::LINEUP, pos ); break; } case SB_SLIDERTRACK : { performScrollbarEvent( id, Scrollbar::VERTTRACK, pos ); break; } case SB_SLIDERPOSITION : { performScrollbarEvent( id, Scrollbar::VERTRELEASED, pos ); break; } } break; } case WM_MOVE : { SWP swp; WinQueryWindowPos( hWndFrame, &swp ); x = swp.x; y = swp.y; move(); break; } case WM_CLOSE : { if( close() ) break; else return (MPARAM)FALSE; } case WM_COMMAND : { if( SHORT1FROMMP( mParam2 ) == CMDSRC_PUSHBUTTON ) { Window *control = (Window *)getControl( SHORT1FROMMP(mParam1)); if( control != NULL ) { if( control->type == PUSHBUTTON ) { control->performButtonEvent( control, control->id ); return FALSE; } } else return FALSE; // In case ESC would close the dialog } break; } case WM_CHAR : { if( type == LISTBOX ) { performFocusEvent( (int)WinSendMsg( (HWND)mParam2, LM_QUERYSELECTION, MPARAM(0), MPARAM(NULL) ) ); } if( (SHORT1FROMMP( mParam1 ) & KC_KEYUP) || (SHORT1FROMMP( mParam1 ) & KC_DEADKEY) || (SHORT1FROMMP( mParam1 ) & KC_INVALIDCOMP) ) break; /* if( SHORT1FROMMP( mParam1 ) & KC_COMPOSITE ) mParam1 = MPFROM2SHORT( SHORT1FROMMP( mParam1 ) & ~KC_VIRTUALKEY, SHORT2FROMMP( mParam1 ) );*/ int modifiers = 0; if( SHORT1FROMMP( mParam1 ) & KC_SHIFT ) modifiers |= KeyDef::SHIFT; if( SHORT1FROMMP( mParam1 ) & KC_ALT ) modifiers |= KeyDef::kALT; if( SHORT1FROMMP( mParam1 ) & KC_CTRL) modifiers |= KeyDef::CTRL; if( SHORT1FROMMP( mParam1 ) & KC_VIRTUALKEY ) { int key = 0, vKey = SHORT2FROMMP( mParam2 ); // Maybe NumLock is on if( SHORT1FROMMP(mParam1) & KC_CHAR && !(vKey == VK_ENTER || vKey == VK_NEWLINE || vKey == VK_TAB || vKey == VK_BACKSPACE )) key = SHORT1FROMMP( mParam2 ); else if( vKey == VK_UP ) key = KeyDef::UP; else if( vKey == VK_DOWN ) key = KeyDef::DOWN; else if( vKey == VK_LEFT ) key = KeyDef::LEFT; else if( vKey == VK_RIGHT ) key = KeyDef::RIGHT; else if( vKey == VK_PAGEUP ) key = KeyDef::PAGEUP; else if( vKey == VK_PAGEDOWN ) key = KeyDef::PAGEDOWN; else if( vKey == VK_INSERT ) key = KeyDef::INSERT; else if( vKey == VK_DELETE ) key = KeyDef::kDELETE; else if( vKey == VK_HOME ) key = KeyDef::HOME; else if( vKey == VK_END ) key = KeyDef::END; else if( vKey == VK_ESC ) key = KeyDef::ESCAPE; else if( vKey == VK_F1 ) key = KeyDef::F1; else if( vKey == VK_F2 ) key = KeyDef::F2; else if( vKey == VK_F3 ) key = KeyDef::F3; else if( vKey == VK_F4 ) key = KeyDef::F4; else if( vKey == VK_F5 ) key = KeyDef::F5; else if( vKey == VK_F6 ) key = KeyDef::F6; else if( vKey == VK_F7 ) key = KeyDef::F7; else if( vKey == VK_F8 ) key = KeyDef::F8; else if( vKey == VK_F9 ) key = KeyDef::F9; else if( vKey == VK_F10 ) key = KeyDef::F10; else if( vKey == VK_F11 ) key = KeyDef::F11; else if( vKey == VK_F12 ) key = KeyDef::F12; else if( vKey == VK_ENTER ) key = KeyDef::ENTER; else if( vKey == VK_NEWLINE ) key = KeyDef::RETURN; else if( vKey == VK_BACKSPACE ) key = KeyDef::BACKSPACE; else if( vKey == VK_TAB ) key = KeyDef::TAB; else if( vKey == VK_BACKTAB ) { key = KeyDef::TAB; modifiers |= KeyDef::SHIFT; } else if( vKey == VK_SPACE ) key = KeyDef::SPACE; if( parent->getType() == DIALOG ) ((Dialog *)parent)->focusHotkey( key ); if( key != 0 ) if( performKeyEvent( this, modifiers, key ) ) return MPARAM(TRUE); // Do not pass up and down key to dialog if this is a combobox (would // move focus) /* if( getFilterDialogArrows() && (vKey == VK_UP || vKey == VK_DOWN) ) return (MPARAM)TRUE;*/ } else { int key = SHORT1FROMMP( mParam2 ); if( performKeyEvent( this, modifiers, key ) ) return MPARAM(TRUE); } break; } case WM_CONTROL : { Window *control = (Window *)getControl( SHORT1FROMMP(mParam1)); if( control != NULL ) { if( control->type == Window::LISTBOX || control->type == Window::COMBOLISTBOX ) { switch( SHORT2FROMMP(mParam1) ) { case LN_KILLFOCUS : control->focus( FALSE ); break; case LN_SETFOCUS : control->focus( TRUE );break; case LN_ENTER : control->performSelectionEvent( (int)WinSendMsg( (HWND)mParam2, LM_QUERYSELECTION, MPARAM(0), MPARAM(NULL) ) ); break; } } else if( control->type == Window::SCROLLBAR ) { switch( SHORT2FROMMP(mParam1) ) { case SLN_KILLFOCUS : control->focus( FALSE ); break; case SLN_SETFOCUS : control->setFocus(); break; } } else if( control->type == Window::RADIOBUTTON || control->type == Window::CHECKBOX ) { switch( SHORT2FROMMP( mParam1) ) { case BN_CLICKED : case BN_DBLCLICKED : control->performButtonEvent( control, control->id ); break; } } } break; } case DM_DRAGOVER: { PDRAGINFO pDInfo; PDRAGITEM pDItem; if( !acceptDropFiles ) return MRFROM2SHORT(DOR_NODROPOP, 0); pDInfo = (PDRAGINFO)mParam1; DrgAccessDraginfo(pDInfo); pDItem = DrgQueryDragitemPtr(pDInfo, 0); USHORT usOp = 0, usDrop = DOR_NEVERDROP; /* Inspect each item to see if it is acceptable */ ULONG ulItems = DrgQueryDragitemCount (pDInfo); for (INT i = 0; i < ulItems; i++) { pDItem = DrgQueryDragitemPtr(pDInfo, i); /* The item is acceptable only if it is copyable and the */ /* operation is a copy, or it is moveable and the operation */ /* is a move, and it can render <DRM_OS2FILE, NULL> */ if (pDItem->fsSupportedOps & DO_COPYABLE) { usOp = DO_COPY; /* Only check files, all types */ if (DrgVerifyRMF(pDItem, "DRM_OS2FILE", 0)) usDrop = DOR_DROP; else { usDrop = DOR_NEVERDROP; break; } } else { /* Must be a file but not droppable in type op */ usDrop = DOR_NODROPOP; usOp = 0; break; } } /* end for all items dragged */ DrgFreeDraginfo(pDInfo); return MRFROM2SHORT(usDrop, usOp); } case DM_DROP: { PDRAGINFO pDInfo; PDRAGITEM pDItem; pDInfo = (PDRAGINFO)mParam1; DrgAccessDraginfo(pDInfo); pDItem = DrgQueryDragitemPtr(pDInfo, 0); ULONG ulItems = DrgQueryDragitemCount (pDInfo); ULONG p; char **files; files = (char **)malloc( sizeof( char * ) * ulItems ); for (INT i=0; i < ulItems; i++) { CHAR DragSrcPath[CCHMAXPATH], DragSrcName[CCHMAXPATH]; pDItem = DrgQueryDragitemPtr(pDInfo, i); DrgQueryStrName(pDItem->hstrContainerName, sizeof(DragSrcPath), (PSZ)DragSrcPath); if (!(PSZ)DragSrcPath) break; if (DragSrcPath[(strlen(DragSrcPath)-1)] != '\\') strcat((PSZ)DragSrcPath, "\\"); /* Use the dragitem source name, it's the real name */ DrgQueryStrName(pDItem->hstrSourceName, sizeof(DragSrcName), (PSZ)DragSrcName); if (!((PSZ)DragSrcName)) break; strcat((PSZ)DragSrcPath, (PSZ)DragSrcName); FILESTATUS3 fsFile; DosError(FERR_DISABLEHARDERR); APIRET rc = DosQueryPathInfo(DragSrcPath, FIL_STANDARD, &fsFile, sizeof(FILESTATUS3)); DosError(FERR_ENABLEHARDERR); if (!rc && !(fsFile.attrFile & FILE_DIRECTORY)) { files[i] = (char *)malloc( strlen(DragSrcPath) + 1 ); strcpy( files[i], DragSrcPath ); DrgSendTransferMsg(pDItem->hwndItem, DM_ENDCONVERSATION, MPFROMLONG(pDItem->ulItemID), MPFROMLONG(DMFL_TARGETSUCCESSFUL)); } else { DosBeep(100,10); // EditorDisplay[BufNum]->DisplayMessage( pszDropNoFile ); } } filesDropped( files, ulItems ); for( i = 0; i < ulItems; i++ ) free( (void *)files[i] ); free( (void *)files ); DrgFreeDraginfo(pDInfo); break; } case WM_USER + 1 : { return (MPARAM)execFromMainThread( (int)mParam1, (void *)mParam2 ); } case WM_USER + 2 : { setFocus(); break; } } *returned = FALSE; return (MRESULT)NULL; }
/***************************************************************************** * Control: control facility for the vout *****************************************************************************/ static int Control( vout_display_t *vd, int query, va_list args ) { vout_display_sys_t *sys = vd->sys; switch (query) { case VOUT_DISPLAY_HIDE_MOUSE: { POINTL ptl; WinQueryPointerPos( HWND_DESKTOP, &ptl ); if( WinWindowFromPoint( HWND_DESKTOP, &ptl, TRUE ) == sys->client ) { WinShowPointer( HWND_DESKTOP, FALSE ); sys->is_mouse_hidden = true; } return VLC_SUCCESS; } case VOUT_DISPLAY_CHANGE_FULLSCREEN: { vout_display_cfg_t cfg = *va_arg(args, const vout_display_cfg_t *); if( sys->parent_window ) vout_window_SetFullScreen(sys->parent_window, cfg.is_fullscreen); else WinPostMsg( sys->client, WM_VLC_FULLSCREEN_CHANGE, MPFROMLONG( cfg.is_fullscreen ), 0 ); return VLC_SUCCESS; } case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE: { const vout_display_cfg_t *cfg = va_arg(args, const vout_display_cfg_t *); bool is_forced = va_arg(args, int); if( is_forced ) { if( sys->parent_window ) { vout_window_SetSize(sys->parent_window, cfg->display.width, cfg->display.height); /* Workaround : * If changing aspect ratio after resizing a main window, * an embedded window is misplaced. So reposition it, here. */ WinSetWindowPos( WinQueryWindow( sys->parent, QW_PARENT ), HWND_TOP, 0, 1, 0, 0, SWP_MOVE ); WinSetWindowPos( WinQueryWindow( sys->parent, QW_PARENT ), HWND_TOP, 0, 0, 0, 0, SWP_MOVE ); } else WinPostMsg( sys->client, WM_VLC_SIZE_CHANGE, MPFROMLONG( cfg->display.width ), MPFROMLONG( cfg->display.height )); } return VLC_SUCCESS; } case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT: case VOUT_DISPLAY_CHANGE_SOURCE_CROP: { const video_format_t *source = va_arg(args, const video_format_t *); if( query == VOUT_DISPLAY_CHANGE_SOURCE_ASPECT ) { sys->kvas.ulAspectWidth = ( int64_t )source->i_width * source->i_sar_num / source->i_sar_den; sys->kvas.ulAspectHeight = source->i_height; } else { sys->kvas.rclSrcRect.xLeft = source->i_x_offset; sys->kvas.rclSrcRect.yTop = source->i_y_offset; sys->kvas.rclSrcRect.xRight = source->i_x_offset + source->i_visible_width; sys->kvas.rclSrcRect.yBottom = source->i_y_offset + source->i_visible_height; } kvaSetup( &sys->kvas ); return VLC_SUCCESS; } case VOUT_DISPLAY_RESET_PICTURES: case VOUT_DISPLAY_CHANGE_WINDOW_STATE: case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED: case VOUT_DISPLAY_CHANGE_ZOOM: case VOUT_DISPLAY_GET_OPENGL: /* TODO */ break; } msg_Err(vd, "Unsupported query(=%d) in vout display KVA", query); return VLC_EGENERIC; }
MRESULT EXPENTRY WndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { // static POINTS DragStartPtrPos; POINTL ptl; static char Row, Col; static BOOL HasMoved = FALSE; static BOOL IntroSoundPlayed = FALSE; static BOOL RealPaint = TRUE; // indicates whether the board // has to be repainted or just copied INT aktscan; CHAR msgtext[256]; ULONG ulResponse; // ERRORID errId; switch( msg ){ case WM_CREATE: if( !InfoData.LoadHigh() ){ // get previously saved highscores InfoData.ResetHigh(); WinMessageBox( HWND_DESKTOP, hwndMain, "The file scores.dat " \ "(which is in the current directory) was somehow corrupted." \ " All Highscores will be reset to Zero.", "Error when loading Highscores", 0, MB_OK | MB_INFORMATION ); } // allocate memory for global variables; see GLOBALS struct in tgraph.h pg = new GLOBALS; // initialize globals to zero memset( pg, 0, sizeof( GLOBALS )); // store globals pointer into client window words; see WinRegisterClass // WinSetWindowULong( hwnd, QWL_USER, (ULONG) pg ); wcprintf("1: %x", WinGetLastError( hab ) ); DosCreateEventSem( NULL, &hevWaitAfterScan, 0, FALSE ); // Sem is created in reset state DosCreateEventSem( NULL, &hevHiScoreWin, 0, FALSE ); DosCreateEventSem( NULL, &hevWaitAfterSound, 0, FALSE ); DosCreateEventSem( NULL, &hevWaitSoundReady, 0, TRUE ); // Sem is created in posted state // hevWaitAfterScan and hewWaitAfterSound are used to indicate // when the respective WM_CREATE routines are done. // after that they are in posted state, as desired // initialize globals with important data pg->hab = hab; pg->hwndClient = hwnd; pg->hwndFrame = WinQueryWindow( hwnd, QW_PARENT ); pg->hwndTitlebar = WinWindowFromID( pg->hwndFrame, FID_TITLEBAR ); pg->hwndMenubar = WinWindowFromID( pg->hwndFrame, FID_MENU ); // create graphics and sound threads pg->tidTSound = _beginthread( &threadsound, NULL, LEN_STACK, NULL ); pg->tidTGraph = _beginthread( &threadgraph, NULL, LEN_STACK, NULL ); DosWaitEventSem( hevWaitAfterSound, SEM_INDEFINITE_WAIT ); WinPostMsg( pg->hwndTSound, WM_SOUND_INTRO, MPFROMHWND(hwnd), 0 ); // wait for the sound's WM_CREATE DosWaitEventSem( hevWaitAfterScan, SEM_INDEFINITE_WAIT ); // wait for the graphics' WM_CREATE InfoData.ShipsNotFound = GBoard.GetShipNumber(); wcprintf("create: %x", WinGetLastError( hab ) ); return (MRESULT)0; case WM_CONTROL: break; case WM_QUIT: break; case WM_CLOSE: // this message is sent before WM_QUIT InfoData.SaveHigh( WinGetCurrentTime(hab) ); // save the highscores and provide a random seed // get pointer to globals from window words // pg = (PGLOBALS) WinQueryWindowULong( hwnd, QWL_USER ); // tell object windows to quit, then exit their threads // WinSendMsg( pg->hwndTGraph, WM_DESTROY, mp1, mp2 ); WinPostMsg( pg->hwndTGraph, WM_QUIT, mp1, mp2 ); // WinSendMsg( pg->hwndTSound, WM_DESTROY, mp1, mp2 ); WinPostMsg( pg->hwndTSound, WM_QUIT, mp1, mp2 ); DosCloseEventSem( hevWaitAfterScan ); DosCloseEventSem( hevHiScoreWin ); DosCloseEventSem( hevWaitAfterSound ); DosCloseEventSem( hevWaitSoundReady ); WriteProfile( hab ); delete pg; return (MRESULT) 0; case WM_ERASEBACKGROUND: wcprintf("erasebackground"); // return (MRESULT) FALSE; return (MRESULT) TRUE; case WM_PAINT: /////////////////////////////////// { RECTL rectl; WinQueryWindowRect( pg->hwndClient, &rectl ); wcprintf("Linienrechteck: Breite: %d H”he: %d", rectl.xRight, rectl.yTop ); // test size: GpiSetColor( hpsGlob, CLR_RED ); ptl.x = rectl.xLeft; ptl.y = rectl.yBottom; GpiMove( hpsGlob, &ptl ); ptl.x = rectl.xRight; ptl.y = rectl.yTop; GpiLine( hpsGlob, &ptl ); } /////////////////////////// break; case WM_SIZE: wcprintf("main wnd function wm-size"); RealPaint = TRUE; GBoard.SetPMBoardValues( SHORT1FROMMP( mp2 ), SHORT2FROMMP( mp2 ) ); WndResize( hwnd ); wcprintf("size: %x", WinGetLastError( hab ) ); break; case WM_BEGINDRAG: WinSetCapture( HWND_DESKTOP, hwnd ); // capture the mouse pointer GBoard.SetfDrag( TRUE ); // indicate that mouse is being dragged GBoard.ResetFirstDraw(); // for initialization of drag op. fHideSquare = TRUE; WinSendMsg( pg->hwndTGraph, WM_SHOWPOINTERPOS, MPFROMHWND(hwnd), MPFROM2SHORT( 0, 0 ) ); // GBoard.ShowPointerPos( hwnd, 0, 0 ); // removes the square ptl.x = SHORT1FROMMP(mp1); ptl.y = SHORT2FROMMP(mp1); Row = GBoard.GetBoardRow( ptl.y ); // starting point of drag Col = GBoard.GetBoardCol( ptl.x ); // operation; static! return (MRESULT)TRUE; case WM_MOUSEMOVE: if( GBoard.GetfDrag() ){ // if mouse is being dragged WinSendMsg( pg->hwndTGraph, WM_DRAWDRAGLINE, mp1, MPFROM2SHORT( Row, Col ) ); HasMoved = TRUE; } else { // mouse is moved normally if( !fHideSquare ) WinSendMsg( pg->hwndTGraph, WM_SHOWPOINTERPOS, MPFROMHWND(hwnd), mp1 ); // GBoard.ShowPointerPos( hwnd, SHORT1FROMMP(mp1), // SHORT2FROMMP(mp1)); } break; case WM_ENDDRAG: WinSetCapture( HWND_DESKTOP, NULLHANDLE ); // release the captured // mouse pointer if( HasMoved ){ // mousemove has actually been moved WinSendMsg( pg->hwndTGraph, WM_MARKDRAGLINE, MPFROM2SHORT( Row, Col ), 0 ); HasMoved = FALSE; } GBoard.SetfDrag( FALSE ); GBoard.ClearDrawPoint(); // because no square is drawn right now fHideSquare = FALSE; WinSendMsg( pg->hwndTGraph, WM_SHOWPOINTERPOS, MPFROMHWND(hwnd), mp1 ); // GBoard.ShowPointerPos( hwnd, SHORT1FROMMP(mp1), SHORT2FROMMP(mp1)); // draws square at the current ptr pos break; case WM_CHAR: // key was pressed if( SHORT2FROMMP( mp2 ) != VK_SPACE ) break; // only space is interesting if( GBoard.GetfDrag() ) break; // do nothing while dragging if( !GBoard.GetfShowLines() ){ // lines not visible yet GBoard.SetfShowLines( TRUE ); WinSendMsg( pg->hwndTGraph, WM_DISPLAYLINES, 0, 0 ); } break; case WM_BUTTON1CLICK: if( !InfoData.ShipsNotFound ) break; // game is finished ptl.x = (LONG)SHORT1FROMMP( mp1 ); ptl.y = (LONG)SHORT2FROMMP( mp1 ); Row = GBoard.GetBoardRow( ptl.y ); Col = GBoard.GetBoardCol( ptl.x ); if( !Row || !Col ) break; fHideSquare = TRUE; WinSendMsg( pg->hwndTGraph, WM_SHOWPOINTERPOS, MPFROMHWND(hwnd), MPFROM2SHORT( 0, 0 ) ); // GBoard.ShowPointerPos( hwnd, 0, 0 ); // hides pointer square if(( aktscan = GBoard.GetDiscovered( Row, Col )) != -1 ){ WinSendMsg( pg->hwndTGraph, WM_DRAWPMPLACE, MPFROMHWND(hwnd), MPFROMSH2CH( MAKESHORT(Row, Col), (CHAR)aktscan,(CHAR)TRUE)); // umstricken auf WinPostMsg // toggle Place display } else { // scan Place DosResetEventSem( hevWaitAfterScan, &ulResponse ); // DosBeep(500, 150 ); WinPostMsg( pg->hwndTGraph, WM_GRAPH_SCAN, MPFROMHWND(hwnd), MPFROM2SHORT( Row, Col ) ); // DosBeep( 800, 150 ); WinWaitEventSem( hevWaitAfterScan, SEM_INDEFINITE_WAIT ); // DosBeep( 1000, 150 ); // first the scanning sounds must be played (and finished) aktscan = GBoard.Scan( Row, Col ); if( aktscan == GBoard.GetShipNumber() + 10 ){ InfoData.ShipsNotFound--; WinPostMsg( pg->hwndTSound, WM_SOUND_FOUNDSHIP, MPFROMHWND(hwnd), 0 ); } else { if( aktscan ) WinPostMsg( pg->hwndTSound, WM_SOUND_FOUND, MPFROMHWND(hwnd), MPFROMLONG( aktscan ) ); else WinPostMsg( pg->hwndTSound, WM_SOUND_FOUND0, MPFROMHWND(hwnd), 0 ); } WinWaitEventSem( hevWaitAfterScan, SEM_INDEFINITE_WAIT ); // waits until scanning is done, and only then displays the // field icon // hps = WinGetPS( hwnd ); WinSendMsg( pg->hwndTGraph, WM_DRAWPMPLACE, MPFROMHWND(hwnd), MPFROMSH2CH( MAKESHORT(Row, Col), (CHAR)aktscan,(CHAR)TRUE)); // umstricken auf WinPostMsg WinPostMsg( pg->hwndTGraph, WM_SHOWSTATUSLINE, 0, 0 ); // ShowStatusLine( hps, GBoard.MovesNeeded(), InfoData.ShipsNotFound, // GBoard.GetWinWidth(), GBoard.GetWinHeight() ); // WinReleasePS( hps ); if( !InfoData.ShipsNotFound ){ // game is finished, all ships found Score = GBoard.MovesNeeded(); if ( !InfoData.ReturnLastHigh() // still space in the hiscore table || Score < InfoData.ReturnLastHigh() ){ // player kicks last one out // player enters highscore table WinPostMsg( pg->hwndTSound, WM_SOUND_NEWHISCORE, MPFROMHWND(hwnd), 0 ); WinWaitEventSem( hevHiScoreWin, SEM_INDEFINITE_WAIT ); // waits until the NEWHISCORE sound is actually played WinDlgBox( HWND_DESKTOP, hwnd, HighScoreDlgProc, (HMODULE)0, IDR_HIGHSCOREDLG, NULL ); WinPostMsg( hwnd, WM_COMMAND, MPFROMSHORT(IDM_GAMEHIGH), (MPARAM)0 ); // show highscore-table DosResetEventSem( hevHiScoreWin, &ulResponse ); // resets the sem again } else { WinPostMsg( pg->hwndTSound, WM_SOUND_LOST, MPFROMHWND(hwnd), 0 ); WinWaitEventSem( hevHiScoreWin, SEM_INDEFINITE_WAIT ); // waits until the NEWHISCORE sound is actually played sprintf( msgtext, "You needed %d moves to find the lost ships. " \ "To enter the highscore list you need %d moves." \ " So try again!", Score, InfoData.ReturnLastHigh() - 1 ); WinMessageBox( HWND_DESKTOP, hwnd, msgtext, "Oh, Shit!", 0, MB_OK | MB_INFORMATION | MB_HELP ); } } } fHideSquare = FALSE; WinSendMsg( pg->hwndTGraph, WM_SHOWPOINTERPOS, MPFROMHWND(hwnd), MPFROM2SHORT( ptl.x, ptl.y ) ); // GBoard.ShowPointerPos( hwnd, ptl.x, ptl.y ); // redisplay ptr square break; case WM_BUTTON2CLICK: fHideSquare = TRUE; WinSendMsg( pg->hwndTGraph, WM_SHOWPOINTERPOS, MPFROMHWND(hwnd), MPFROM2SHORT( 0, 0 ) ); ptl.x = (LONG)SHORT1FROMMP( mp1 ); ptl.y = (LONG)SHORT2FROMMP( mp1 ); Row = GBoard.GetBoardRow( ptl.y ); Col = GBoard.GetBoardCol( ptl.x ); WinSendMsg( pg->hwndTGraph, WM_DRAWPMMARK, MPFROMHWND(hwnd), MPFROM2SHORT( Row, Col ) ); fHideSquare = FALSE; WinSendMsg( pg->hwndTGraph, WM_SHOWPOINTERPOS, MPFROMHWND(hwnd), MPFROM2SHORT( ptl.x, ptl.y ) ); break; case WM_COMMAND: switch( SHORT1FROMMP( mp1 ) ){ case IDM_GAMENEW: GBoard.NewGame(); InfoData.ShipsNotFound = GBoard.GetShipNumber(); RealPaint = TRUE; WinInvalidateRect( hwnd, NULL, TRUE ); break; case IDM_GAMESETTINGS: if( WinDlgBox( HWND_DESKTOP, hwndFrame, GameSettingsDlgProc, (HMODULE)0, IDR_GAMESETTINGSDLG, NULL ) ){ // screen must be repainted RealPaint = TRUE; WinInvalidateRect( hwnd, NULL, TRUE ); } break; case IDM_GAMEHIGH: if( !WinDlgBox( HWND_DESKTOP, hwndFrame, ShowHighDlgProc, (HMODULE)0, IDR_SHOWHIGHDLG, NULL ) ){ // user requested "Clear" if( WinMessageBox( HWND_DESKTOP, hwndMain, "Do you really want to eradicate all those " \ "arduously achieved highscores?", "Clear Highscores", 0, MB_OKCANCEL | MB_WARNING ) == MBID_OK ) InfoData.ResetHigh(); } break; case IDM_HELPINDEX: // help index WinSendMsg( hwndHelp, HM_HELP_INDEX, 0, 0 ); break; case IDM_HELPGENERAL: // general help WinSendMsg( hwndHelp, HM_EXT_HELP, 0, 0 ); break; case IDM_HELPEXTENDED: // help on help (system page) WinSendMsg( hwndHelp, HM_DISPLAY_HELP, 0, 0 ); break; case IDM_HELPKEYS: // keys help WinSendMsg( hwndHelp, HM_KEYS_HELP, 0, 0 ); break; case IDM_HELPPRODUCTINFO: ulResponse = WinDlgBox( HWND_DESKTOP, hwndFrame, ProdInfoDlgProc, (HMODULE)0, IDR_PRODINFODLG, NULL ); break; } break; case HM_QUERY_KEYS_HELP: // system asks which page to display return MRFROMSHORT( PANEL_HELPKEYS ); case HM_HELPSUBITEM_NOT_FOUND: return (MRESULT)FALSE; case WM_USER_ACK: // graphics task finished its work // DosBeep( 1000, 150 ); switch( (ULONG)mp1 ){ case WM_USER_PAINT: WinQueryPointerPos( HWND_DESKTOP, &ptl ); WinMapWindowPoints( HWND_DESKTOP, hwnd, &ptl, 1); fHideSquare = FALSE; WinSendMsg( pg->hwndTGraph, WM_SHOWPOINTERPOS, MPFROMHWND(hwnd), MPFROM2SHORT( ptl.x, ptl.y ) ); // GBoard.ShowPointerPos( hwnd, ptl.x, ptl.y ); // painting has finished, square can be displayed now break; } break; case WM_SOUND_ACK: switch( (ULONG)mp1 ){ case WM_SOUND_INTRO: break; } break; default: return (MRESULT)WinDefWindowProc( hwnd, msg, mp1, mp2 ); } // end switch( msg ) return (MRESULT)WinDefWindowProc( hwnd, msg, mp1, mp2 ); } // end MRESULT EXPENTRY WndProc()
MRESULT EXPENTRY tButProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { HWND hwndFly = WinQueryWindowULong( hwnd, QWL_USER ); switch( msg ) { case WM_MOUSEMOVE: { if( !hwndFly && useBubbles ) WinStartTimer( 0, hwnd, 1 /* unused id */, 500 ); return ( *oldButProc )( hwnd, msg, mp1, mp2 ); } break; case WM_TIMER: { RGB rgb; HPS hps; HAB hab; RECTL rectl; ULONG breite, hoehe; POINTL p; char str[200]; if( hwndFly ) break; hab = WinQueryAnchorBlock( hwnd ); WinLoadString( hab, NULLHANDLE, WinQueryWindowUShort( hwnd, QWS_ID ), sizeof( str ), str ); hwndFly = WinCreateWindow( HWND_DESKTOP, WC_STATIC, str, SS_TEXT | DT_VCENTER | DT_CENTER, 0, 0, 0, 0, hwnd, HWND_TOP, 0, 0, NULL ); rgb.bBlue = 0; rgb.bGreen = 254; rgb.bRed = 254; WinSetPresParam( hwndFly, PP_BACKGROUNDCOLOR, sizeof( RGB ), &rgb ); rgb.bBlue = 0; rgb.bGreen = 0; rgb.bRed = 0; WinSetPresParam( hwndFly, PP_FOREGROUNDCOLOR, sizeof( RGB ), &rgb ); WinSetPresParam( hwndFly, PP_FONTNAMESIZE, sizeof( DefCntrFont ), DefCntrFont ); queryDimensions( hwndFly, str, &breite, &hoehe ); WinQueryPointerPos( HWND_DESKTOP, &p ); p.y -= WinQuerySysValue( HWND_DESKTOP, SV_CYTITLEBAR ); p.y -= hoehe/2; p.x += 5; WinSetWindowPos( hwndFly, HWND_TOP, p.x, p.y, breite+4, hoehe+2, SWP_SHOW | SWP_MOVE | SWP_SIZE ); WinSetWindowULong( hwnd, QWL_USER, (ULONG) hwndFly ); } break; case UM_FLYOVER_BEGIN: useBubbles = 1; break; case UM_FLYOVER_END: WinStopTimer( 0, hwnd, 1 /* unused id */ ); if( hwndFly ) WinDestroyWindow( hwndFly ); WinSetWindowULong( hwnd, QWL_USER, 0 ); break; default: return ( *oldButProc )( hwnd, msg, mp1, mp2 ); } return FALSE; }
/**************************************************************************** * ClientWndProc * * - Typical PM client window procedure. (see below) * * - Standard client window I/O * ****************************************************************************/ MRESULT EXPENTRY ClientWndProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { RECTL rcl; SWP swp; HPS hpsPaint; static HPS hps; /* Permanent HPS */ static INT cx, cy; /* Client window dimensions */ static BOOL bSlowUpdateNow = FALSE; /* Update toggle for asteroids * * and enemy which are slow. */ static POINTL ptlCenter; /* Center of client window */ switch (msg) { /* Recieved from WinCreateStdWindow */ case WM_CREATE: /* Get permanent PS for entire window */ hps = WinGetPS(hwnd); /* Load private Asteroid fonts from ASTEROID.DLL */ if (GpiLoadFonts(hab, "ASTEROID") != GPI_OK) { WinReleasePS(hps); WinAlarm(HWND_DESKTOP, WA_WARNING); WinMessageBox(HWND_DESKTOP,NULLHANDLE, "Please put ASTEROID.DLL in a directory in your LIBPATH.", "Error reading ASTEROID.DLL", 0,MB_ICONHAND|MB_OK|MB_APPLMODAL); WinPostMsg(hwnd,WM_QUIT,(MPARAM) 0L,(MPARAM) 0L); return (MRESULT) TRUE; } /* Register/create logical fonts for use */ InitFonts(hps); /* Display About dialoge box */ WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)AboutDlgProc, NULLHANDLE, IDD_ABOUT, NULL); return 0; /* Recieved during attract mode when user starts game */ case WM_STARTGAME: /* Determine the number of players */ cPlayers = (INT)LONGFROMMP(mp1); /* Initialize each player */ for (Player=0;Player<cPlayers;Player++) { Level[Player] = 1; Ships[Player] = prfProfile.iSHIPS; DeletePhotons(); InitAsteroids(); InitEnemy(); } /* Start with player 1 */ Player = 0; iGameMode = GAME_MODE_NEXT; iGameModeCnt = GAME_PAUSE_TIME-1; /* Hide the pointer if mouse controls are enabled */ ShowMouse(FALSE); /* Paint everything */ WinSendMsg(hwnd, WM_PAINT, MPVOID, MPVOID); return 0; /* Recieved at startup and at the completion of a game */ case WM_INITGAME: /* Make mouse visible if we hid it before */ ShowMouse(TRUE); /* Fix menu to reflect attract mode */ EnableMenuItem(hwndMenu, IDM_START, TRUE); EnableMenuItem(hwndMenu, IDM_STOP, FALSE); /* Initialize player and enemy data structures */ cPlayers = 0; Level[0] = 1; for (Player=0;Player<2;Player++) { Score[Player] = 0L; Ships[Player] = 0; DeletePhotons(); } Player = 0; /* Initialize asteroids (and enemy) for attract mode */ InitAsteroids(); InitEnemy(); /* Depending on whether ASTEROID was just started or a game just * * completed display the "High Score" or "Press 1 or 2" screen. */ if (SHORT1FROMMP(mp1) == 0) { iGameMode = GAME_MODE_INIT1; iGameModeCnt = GAME_INIT_TIME; } else { iGameMode = GAME_MODE_INIT2; iGameModeCnt = GAME_INIT_TIME; } /* Paint everything */ WinSendMsg(hwnd, WM_PAINT, MPVOID, MPVOID); return 0; /* Usually recieved from the system, sometime forced by the program to * * ensure the screen is not corrupt. */ case WM_PAINT: /* Clear entire window to insure no "droppings" */ WinQueryWindowRect(hwnd,&rcl); WinFillRect(hps, &rcl, CLR_BLACK); WinInvalidateRect(hwnd, &rcl, FALSE); /* Get the update region and paint it black */ hpsPaint = WinBeginPaint(hwnd, (HPS)NULL, &rcl); WinFillRect(hpsPaint, &rcl, CLR_BLACK); WinEndPaint(hpsPaint); /* Only in normal play mode should we draw the ship */ if ((iGameMode == GAME_MODE_PLAY) && (iShipMode[Player] != EXPLOSION) && (iShipMode[Player] != HYPERSPACE)) DrawShip(hps, cx, cy, DRAW_INIT); else if ((iGameMode == GAME_MODE_PLAY) && (iShipMode[Player] == EXPLOSION)) ExplodeShip(hps, cx, cy); /* Draw the enemy if it is on the screen */ if (iEnemyMode[Player] != NONE) if (iEnemyMode[Player] != EXPLOSION) DrawEnemy(hps, cx, cy,DRAW_INIT); else ExplodeEnemy(hps, cx, cy); /* Draw photons and asteroids in all modes but the "Enter your * * initials" mode, otherwise draw that screen. */ if (iGameMode != GAME_MODE_HIGH) { DrawPhotons(hps, cx, cy, DRAW_INIT); DrawAsteroids(hps, cx, cy, DRAW_INIT); } else DrawHighScore(hps, cx, cy, DRAW_INIT); /* Always draw the score */ DrawScore(hps, cx, cy, DRAW_INIT); return 0; /* Left mouse button down. This simulates the move/track function * * in the system menu. */ case WM_BUTTON1DOWN: if (prfProfile.bMOUSECONTROL && iGameMode != GAME_MODE_INIT1 && iGameMode != GAME_MODE_INIT2 && !TogglePause(CHECK)) { UPDATE_FIRE(iShipMode[Player], TRUE); return (MRESULT)TRUE; } return WinSendMsg(hwndFrame, WM_TRACKFRAME, (MPARAM) (SHORT1FROMMP(mp2) | TF_MOVE), MPVOID); case WM_BUTTON1UP: if (prfProfile.bMOUSECONTROL) { UPDATE_FIRE(iShipMode[Player], FALSE); return (MRESULT)TRUE; } return 0; /* Left mouse button double clicked. Toggle frame control display. */ case WM_BUTTON1DBLCLK: if (!prfProfile.bMOUSECONTROL || iGameMode == GAME_MODE_INIT1 || iGameMode == GAME_MODE_INIT2 || TogglePause(CHECK)) { if (prfProfile.bCONTROLS = !prfProfile.bCONTROLS) ShowFrameControls(); else HideFrameControls(); } return 0; case WM_BUTTON2DOWN: if (prfProfile.bMOUSECONTROL) { UPDATE_SHIELD(iShipMode[Player], iShipShieldCnt[Player]); return (MRESULT)TRUE; } return 0; case WM_BUTTON2CLICK: if (prfProfile.bMOUSECONTROL) { UPDATE_HYPERSPACE(iShipMode[Player], iShipModeCnt[Player]); return (MRESULT)TRUE; } return 0; /* Right mouse button double clicked. Display the about dialog box. */ case WM_BUTTON2DBLCLK: if (!prfProfile.bMOUSECONTROL || iGameMode == GAME_MODE_INIT1 || iGameMode == GAME_MODE_INIT2 || TogglePause(CHECK)) { WinDlgBox(HWND_DESKTOP, hwndClient, (PFNWP)AboutDlgProc, NULLHANDLE, IDD_ABOUT, NULL); } return 0; /* User typed a key. Most of this is self explanatory. */ case WM_CHAR: ProcessChar((CHAR) (CHARMSG(&msg)->vkey-1), CHARMSG(&msg)->fs & KC_VIRTUALKEY, (CHAR) (CHARMSG(&msg)->chr), (BOOL) !(CHARMSG(&msg)->fs & KC_KEYUP)); return 0; /* User entered a command via the menu bar. */ case WM_COMMAND: DoCommand(hwnd, msg, mp1, mp2); return 0; /* Suspend/un-suspend game depending on focus */ case WM_SETFOCUS: if ((BOOL) SHORT1FROMMP(mp2)) TogglePause(SUSPEND_OFF); else if (!prfProfile.bBACKGRND) TogglePause(SUSPEND_ON); return 0; /* Keep track of the client window size. Profile information is not * * updated here because there are better places (i.e. at exit) */ case WM_SIZE: cx = (INT)SHORT1FROMMP(mp2); cy = (INT)SHORT2FROMMP(mp2); /* Keep track of client window position. Also updates profile info. */ case WM_MOVE: WinQueryWindowPos(hwndFrame,&swp); if (!(swp.fl & SWP_MAXIMIZE) && !(swp.fl & SWP_MINIMIZE)) { prfProfile.x = swp.x;prfProfile.y = swp.y; prfProfile.cx = swp.cx;prfProfile.cy = swp.cy; } if (swp.fl & SWP_MINIMIZE) if (!prfProfile.bBACKGRND) { /* Set icon */ WinSendMsg(hwndFrame, WM_SETICON, (MPARAM) WinLoadPointer(HWND_DESKTOP, NULLHANDLE, ID_RESOURCE), MPVOID); TogglePause(SUSPEND_ON); } else WinSendMsg(hwndFrame, WM_SETICON, MPVOID, MPVOID); else TogglePause(SUSPEND_OFF); ptlCenter.x = swp.cx / 2; ptlCenter.y = swp.cy / 2; WinMapWindowPoints(hwndClient, HWND_DESKTOP, &ptlCenter, 1L); return 0; /* Recieved approximately 31 times a second. This is the longest and * * ugliest of the messages, partly because there are so many cases * * to keep track of, partly because it must be highly optimized. */ case WM_TIMER: if (prfProfile.bMOUSECONTROL && iGameMode != GAME_MODE_INIT1 && iGameMode != GAME_MODE_INIT2) { POINTL ptl; static BOOL bUp, bLeft, bRight; WinQueryPointerPos(HWND_DESKTOP, &ptl); if (bUp || (ptl.y - ptlCenter.y > 0)) UPDATE_THRUST(iShipMode[Player], bUp = (ptl.y - ptlCenter.y > 0)); if (bLeft || (ptlCenter.x - ptl.x > 0)) UPDATE_LEFT(iShipMode[Player], bLeft = (ptlCenter.x - ptl.x > 0)); if (bRight || (ptlCenter.x - ptl.x < 0)) UPDATE_RIGHT(iShipMode[Player], bRight = (ptlCenter.x - ptl.x < 0)); WinSetPointerPos(HWND_DESKTOP, ptlCenter.x, ptlCenter.y); } /* Determine the current game mode */ switch (iGameMode) { /* Either initialization/attract mode screen. */ case GAME_MODE_INIT1: case GAME_MODE_INIT2: /* Switch screens when count expires */ if (--iGameModeCnt == 0) { if (iGameMode == GAME_MODE_INIT1) iGameMode = GAME_MODE_INIT2; else iGameMode = GAME_MODE_INIT1; iGameModeCnt = GAME_INIT_TIME; /* Score must be redrawn because the attract mode screens * * draw the score differently. */ DrawScore(hps, cx, cy, DRAW_REINIT); } /* Update photons, asteroids, enemy, and score */ UpdatePhotons(hps, cx, cy); if (uiSpeed == SPEED_OS2 || (bSlowUpdateNow = !bSlowUpdateNow)) { UpdateAsteroids(hps, cx, cy); UpdateEnemy(hps, cx, cy); DrawScore(hps, cx, cy, DRAW_REFRESH); } break; /* Completion of one player's turn or new game */ case GAME_MODE_NEXT: /* Initially, erase and redraw everything for new player */ if (iGameModeCnt-- == GAME_PAUSE_TIME) { if ((cPlayers == MAXPLAYERS) && (Ships[(Player+1) % MAXPLAYERS])) { DrawAsteroids(hps, cx, cy, DRAW_ERASE); DrawPhotons(hps, cx, cy, DRAW_ERASE); Player = (Player+1) % MAXPLAYERS; } DrawScore(hps, cx, cy, DRAW_REINIT); DrawAsteroids(hps, cx, cy, DRAW_INIT); } /* During countdown update score and asteroids */ else if (iGameModeCnt > 0) { if (uiSpeed == SPEED_OS2 || (bSlowUpdateNow = !bSlowUpdateNow)) { DrawScore(hps, cx, cy, DRAW_REFRESH); UpdateAsteroids(hps, cx, cy); } } /* At end of countdown start the player */ else { InitShip(); InitEnemy(); iGameMode = GAME_MODE_PLAY; DrawScore(hps, cx, cy, DRAW_REINIT); } break; /* Normal play mode */ case GAME_MODE_PLAY: /* Update ship, photons, asteroids, enemy, and score */ UpdateShip(hps, cx, cy); UpdatePhotons(hps, cx, cy); if (uiSpeed == SPEED_OS2 || (bSlowUpdateNow = !bSlowUpdateNow)) { UpdateAsteroids(hps, cx, cy); UpdateEnemy(hps, cx, cy); /* Erase old and draw new scores if there is a change*/ if (bChangeScore) { bChangeScore = FALSE; DrawScore(hps, cx, cy, DRAW_REINIT); } /* Else just refresh the score */ else DrawScore(hps, cx, cy, DRAW_REFRESH); } break; /* Game over mode. This is the longest and ugliest case because * * conditions are highly dependent on the number of players, * * multiplayer game status, and the number and order of high * * scores. */ case GAME_MODE_OVER: /* Initially, just update the score and number of ships */ if (iGameModeCnt-- == GAME_PAUSE_TIME) DrawScore(hps, cx, cy, DRAW_REINIT); /* During countdown refresh the score and update the asteroids */ else if (iGameModeCnt > 0) { if (uiSpeed == SPEED_OS2 || (bSlowUpdateNow = !bSlowUpdateNow)) { DrawScore(hps, cx, cy, DRAW_REFRESH); UpdateAsteroids(hps, cx, cy); } } /* At the end of the countdown, if there are any other players, * * continue with them. */ else { /* Countinue on with any remaining players. */ if ((cPlayers == MAXPLAYERS) && (Ships[(Player+1) % MAXPLAYERS])) { /* Erase all of the old asteroids. */ DrawAsteroids(hps, cx, cy, DRAW_ERASE); /* Setup everything for the next player */ Player = (Player+1) % MAXPLAYERS; InitShip(); InitEnemy(); iGameMode = GAME_MODE_PLAY; DrawAsteroids(hps, cx, cy, DRAW_INIT); DrawScore(hps, cx, cy, DRAW_REINIT); } /* Check for new high scores and update table as necessary. */ else { /* Erase all of the old asteroids. */ DrawAsteroids(hps, cx, cy, DRAW_ERASE); /* The following if/else block is admittedly a kludge, it is * * simple and it does work, however. Ideally it should * * sort the high scores and update the high score table in * * descending order. */ /* If player 1 scored higher than player 2 then check * * player 1 first for a high score. */ if (Score[0] > Score[1]) for (Player=0;Player<cPlayers;Player++) /* If the player's score is > than the lowest, * * update the high score table. */ if (Score[Player] > prfProfile.lSCORES[9]) { UpdateHighScores(); iGameMode = GAME_MODE_HIGH; } /* Otherwise, make sure he is not asked for his * * initials. */ else Score[Player] = 0; /* Otherwise, check player 2 first */ else for (Player=cPlayers;Player>=0;Player--) /* If the player's score is > than the lowest, * * update the high score table. */ if (Score[Player] > prfProfile.lSCORES[9]) { UpdateHighScores(); iGameMode = GAME_MODE_HIGH; } /* Otherwise, make sure he is not asked for his * * initials. */ else Score[Player] = 0L; /* If there was no high score, go into attract mode */ if (iGameMode != GAME_MODE_HIGH) WinSendMsg(hwnd,WM_INITGAME,MPFROMSHORT(1),(MPARAM) 0L); /* Else, check for player 1's initials first then 2's * * This is not faithful, in the arcade game the player * * with the higher score always goes first. */ else { if (Score[0] > 0L) Player = 0; else Player = 1; DrawScore(hps, cx, cy, DRAW_REINIT); DrawHighScore(hps, cx, cy, DRAW_INIT); } } } break; /* Mode which prompts players to enter their initials */ case GAME_MODE_HIGH: /* If the player's position is > 0 then refresh the screen */ if (Score[Player] > 0L) DrawHighScore(hps, cx, cy, DRAW_REFRESH); /* Else, the current player is done go to the next */ else if ((cPlayers == MAXPLAYERS) && (Player == 0) && (Score[1] > 0L)) { Player++; DrawHighScore(hps, cx, cy, DRAW_REINIT); } /* If there are no more high scores then go into attract mode */ else WinSendMsg(hwnd, WM_INITGAME, MPFROMSHORT(1), MPVOID); break; } return 0; /* Used by help manager */ case HM_QUERY_KEYS_HELP: return((MRESULT)IDH_CLIENTKEYS); /* Recieved always from the system or in the case of an initialization* * error. Both messages will normally save the profile information.* * Ideally the profile section should be moved to a subroutine and the* * the following should be broken into two distinct cases. */ case WM_SAVEAPPLICATION: case WM_DESTROY: /* If the fonts were not found bApplicationOk will be false, in * * that case the window profile information should not be updated.*/ if (TRUE) { /* Copy window position and size info into profile structure */ WinQueryWindowPos(hwndFrame, &swp); if (swp.fl & SWP_MAXIMIZE) prfProfile.ulMINMAX = SWP_MAXIMIZE; else if (swp.fl & SWP_MINIMIZE) prfProfile.ulMINMAX = SWP_MINIMIZE; else { prfProfile.ulMINMAX = 0; prfProfile.x = swp.x;prfProfile.y = swp.y; prfProfile.cx = swp.cx;prfProfile.cy = swp.cy; } /* Write profile information */ PrfWriteProfileData(HINI_USERPROFILE, szClientClass, "Data", &prfProfile, sizeof(PROFILEREC)); } /* If the application is terminating release the fonts and the hps. */ if (msg == WM_DESTROY) { /* Make sure mouse is visible if we hid it before */ ShowMouse(TRUE); /* Release font identifiers and DLL resource module */ GpiSetCharSet(hps, LCID_DEFAULT); GpiDeleteSetId(hps, LCID_LARGE); GpiDeleteSetId(hps, LCID_SMALL); GpiUnloadFonts(hab, "ASTEROID"); /* Release the "permanent" presentation space */ WinReleasePS(hps); } return 0; } return WinDefWindowProc(hwnd, msg, mp1, mp2); }
/************************************************************************** * * Name : MyWindowProc * * Description: The window procedure associated with the client area in * the standard frame window. It processes all messages * either sent or posted to the client area, depending on * the message command and parameters. * * Concepts : * * API's : WinLoadString * WinInvalidateRegion * WinPostMsg * WinDefWindowProc * WinBeginPaint * GpiSetColor * GpiSetBackColor * GpiSetBackMix * GpiCharStringAt * WinEndPaint * * Parameters : hwnd = window handle * msg = message code * mp1 = first message parameter * mp2 = second message parameter * * Return : depends on message sent * *************************************************************************/ MRESULT EXPENTRY MyWindowProc( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { switch( msg ) { case WM_TIMER: { WinInvalidateRegion( hwnd, 0L, FALSE ); break; } case WM_CREATE: /* * Window initialization is performed here in WM_CREATE processing * WinLoadString loads strings from the resource file. */ WinLoadString( hab, (HMODULE)0L, IDS_HELLO, STRINGLENGTH, szHello ); WinLoadString( hab, (HMODULE)0L, IDS_1, STRINGLENGTH, sz1 ); WinLoadString( hab, (HMODULE)0L, IDS_2, STRINGLENGTH, sz2 ); WinLoadString( hab, (HMODULE)0L, IDS_3, STRINGLENGTH, sz3 ); strcpy( szString, szHello ); /* Copy text Hello into szString*/ break; case WM_COMMAND: /* * When the user chooses option 1, 2, or 3 from the Options pull- * down, the text string is set to 1, 2, or 3, and * WinInvalidateRegion sends a WM_PAINT message. * When Exit is chosen, the application posts itself a WM_CLOSE * message. */ { USHORT command; /* WM_COMMAND command value */ command = SHORT1FROMMP(mp1); /* Extract the command value */ switch (command) { case ID_EXITPROG: WinPostMsg( hwnd, WM_CLOSE, (MPARAM)0, (MPARAM)0 ); break; default: return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } break; } case WM_ERASEBACKGROUND: /* * Return TRUE to request PM to paint the window background * in SYSCLR_WINDOW. */ return (MRESULT)( TRUE ); case WM_PAINT: /* * Window contents are drawn here in WM_PAINT processing. */ { HPS hps; /* Presentation Space handle */ RECTL rc; /* Rectangle coordinates */ POINTL pt; /* String screen coordinates */ POINTL pPos; LONG lColor,r,g,b; FATTRS fat; HPS shps = WinGetScreenPS(HWND_DESKTOP); fat.usRecordLength = sizeof(FATTRS); /* sets size of structure */ fat.fsSelection = 0; /* uses default selection */ fat.lMatch = 0L; /* does not force match */ fat.idRegistry = 0; /* uses default registry */ fat.usCodePage = 0; /* code-page 850 */ fat.lMaxBaselineExt = 14L; /* requested font height is 12 pels */ fat.lAveCharWidth = 14L; /* requested font width is 12 pels */ fat.fsType = 0; /* uses default type */ fat.fsFontUse = FATTR_FONTUSE_NOMIX;/* doesn't mix with graphics */ strcpy(fat.szFacename ,"Courier"); WinQueryPointerPos(HWND_DESKTOP, &pPos); hps = WinBeginPaint( hwnd, 0L, &rc ); GpiCreateLogColorTable(shps, 0, LCOLF_RGB, 0, 0, NULL); GpiCreateLogColorTable(hps, 0, LCOLF_RGB, 0, 0, NULL); pt.x = 10; pt.y = 27; /* Set the text coordinates, */ lColor=GpiQueryPel(shps, &pPos); GpiSetBackColor( hps, 16777215); /* its background and */ WinFillRect( hps, &rc, lColor); GpiSetBackMix( hps, BM_OVERPAINT ); /* how it mixes, */ b = lColor & 0x000000FF; lColor = lColor >> 8; g = lColor & 0x000000FF; lColor = lColor >> 8; r = lColor & 0x000000FF; WinReleasePS(shps); sprintf(szString,"Color: #%.2X%.2X%.2X",r,g,b); GpiCreateLogFont(hps, NULL, 1L, &fat); GpiSetCharSet(hps, 1L); GpiSetCharMode(hps, CM_MODE1); GpiCharStringAt( hps,&pt ,(LONG)strlen( szString ), szString ); WinEndPaint( hps ); /* Drawing is complete */ break; } case WM_CLOSE: WinPostMsg( hwnd, WM_QUIT, (MPARAM)0,(MPARAM)0 );/* Cause termination*/ break; default: /* * Everything else comes here. This call MUST exist * in your window procedure. */ return WinDefWindowProc( hwnd, msg, mp1, mp2 ); } return (MRESULT)FALSE; } /* End of MyWindowProc */
MRESULT EXPENTRY OS2Loop::processEvent( HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2 ) { OS2Factory *pFactory = (OS2Factory*)OS2Factory::instance( getIntf() ); GenericWindow *pWin = pFactory->m_windowMap[hwnd]; // To invert Y RECTL rcl; WinQueryWindowRect( hwnd, &rcl ); GenericWindow &win = *pWin; switch( msg ) { case WM_PAINT: { HPS hps; RECTL rclPaint; hps = WinBeginPaint( hwnd, NULLHANDLE, &rclPaint ); EvtRefresh evt( getIntf(), rclPaint.xLeft, // Find top and invert it ( rcl.yTop - 1 ) - ( rclPaint.yTop - 1 ), rclPaint.xRight - rclPaint.xLeft + 1, rclPaint.yTop - rclPaint.yBottom + 1 ); win.processEvent( evt ); WinEndPaint( hps ); return 0; } case WM_COMMAND: { EvtMenu evt( getIntf(), SHORT1FROMMP( mp1 )); win.processEvent( evt ); return 0; } case WM_MOUSEMOVE: { pFactory->changeCursor( pFactory->getCursorType()); // Compute the absolute position of the mouse POINTL ptl; WinQueryPointerPos( HWND_DESKTOP, &ptl ); int x = ptl.x; int y = ( pFactory->getScreenHeight() - 1 ) - ptl.y; EvtMotion evt( getIntf(), x, y ); win.processEvent( evt ); return MRFROMLONG( TRUE ); } case WM_MOUSELEAVE: { EvtLeave evt( getIntf() ); win.processEvent( evt ); return MRFROMLONG( TRUE ); } case WM_BUTTON1DOWN: { WinSetCapture( HWND_DESKTOP, hwnd ); EvtMouse evt( getIntf(), GET_X_MP( mp1 ), GET_Y_MP( mp1 ), EvtMouse::kLeft, EvtMouse::kDown, getMod( mp2 ) ); win.processEvent( evt ); return MRFROMLONG( TRUE ); } case WM_BUTTON2DOWN: { WinSetCapture( HWND_DESKTOP, hwnd ); EvtMouse evt( getIntf(), GET_X_MP( mp1 ), GET_Y_MP( mp1 ), EvtMouse::kRight, EvtMouse::kDown, getMod( mp2 ) ); win.processEvent( evt ); return MRFROMLONG( TRUE ); } case WM_BUTTON1UP: { WinSetCapture( HWND_DESKTOP, NULLHANDLE ); EvtMouse evt( getIntf(), GET_X_MP( mp1 ), GET_Y_MP( mp1 ), EvtMouse::kLeft, EvtMouse::kUp, getMod( mp2 ) ); win.processEvent( evt ); return MRFROMLONG( TRUE ); } case WM_BUTTON2UP: { WinSetCapture( HWND_DESKTOP, NULLHANDLE ); EvtMouse evt( getIntf(), GET_X_MP( mp1 ), GET_Y_MP( mp1 ), EvtMouse::kRight, EvtMouse::kUp, getMod( mp2 ) ); win.processEvent( evt ); return MRFROMLONG( TRUE ); } case WM_BUTTON1DBLCLK: { WinSetCapture( HWND_DESKTOP, NULLHANDLE ); EvtMouse evt( getIntf(), GET_X_MP( mp1 ), GET_Y_MP( mp1 ), EvtMouse::kLeft, EvtMouse::kDblClick, getMod( mp2 ) ); win.processEvent( evt ); return MRFROMLONG( TRUE ); } case WM_BUTTON2DBLCLK: { WinSetCapture( HWND_DESKTOP, NULLHANDLE ); EvtMouse evt( getIntf(), GET_X_MP( mp1 ), GET_Y_MP( mp1 ), EvtMouse::kRight, EvtMouse::kDblClick, getMod( mp2 ) ); win.processEvent( evt ); return MRFROMLONG( TRUE ); } case WM_CHAR: { // The key events are first processed here and not translated // into WM_CHAR events because we need to know the status of // the modifier keys. USHORT fsFlags = SHORT1FROMMP( mp1 ); USHORT usCh = SHORT1FROMMP( mp2 ); USHORT usVk = SHORT2FROMMP( mp2 ); // Get VLC key code from the virtual key code int key = ( fsFlags & KC_VIRTUALKEY ) ? virtKeyToVlcKey[ usVk ] : 0; if( !key ) { // This appears to be a "normal" (ascii) key key = tolower( usCh ); } if( key ) { // Get the modifier int mod = 0; if( fsFlags & KC_CTRL ) { mod |= EvtInput::kModCtrl; } if( fsFlags & KC_SHIFT ) { mod |= EvtInput::kModShift; } if( fsFlags & KC_ALT ) { mod |= EvtInput::kModAlt; } // Get the state EvtKey::ActionType_t state; if( fsFlags & KC_KEYUP ) { state = EvtKey::kUp; } else { state = EvtKey::kDown; } EvtKey evt( getIntf(), key, state, mod ); win.processEvent( evt ); } return MRFROMLONG( TRUE ); } default: break; } return WinDefWindowProc( hwnd, msg, mp1, mp2 ); }
MRESULT EXPENTRY fnwpReadColumnClient(HWND hwnd,USHORT msg,MPARAM mp1,MPARAM mp2) { static HDC hdcPs; RECTL rclRect; POINTL ptl; LONG lSaveEdge; SWP swp; HWND hwndMenu; static USHORT usMenuStyle; static CLRDLG stColor; static USHORT usLastPopupItem; switch(msg) { case WM_CHAR: if (bSendNextKeystroke) if (ProcessKeystroke(&stCFG,mp1,mp2)) return((MRESULT)TRUE); return( WinDefWindowProc(hwnd,msg,mp1,mp2)); case WM_CREATE: hdcPs = WinOpenWindowDC(hwnd); usLastPopupItem = IDMPU_SYNC; stRead.lBackgrndColor = stCFG.lReadColBackgrndColor; stRead.bActive = FALSE; stRead.lScrollIndex = 0; stRead.hwndScroll = (HWND)NULL; stRead.wDirection = CS_READ; stColor.cbSize = sizeof(CLRDLG); usMenuStyle = (PU_POSITIONONITEM | PU_MOUSEBUTTON2 | PU_HCONSTRAIN | PU_VCONSTRAIN | PU_KEYBOARD | PU_MOUSEBUTTON1); WinSendMsg(hwnd,UM_TRACKFRAME,0L,0L); break; case WM_ACTIVATE: if(SHORT1FROMMP(mp1)) { if (!bFrameActivated) { WinSetFocus(HWND_DESKTOP,hwndFrame); WinSendMsg(WinQueryHelpInstance(hwndClient),HM_SET_ACTIVE_WINDOW,0L,0L); bFrameActivated = TRUE; } } else bFrameActivated = FALSE; break; case WM_VSCROLL: switch(HIUSHORT(mp2)) { case SB_LINEDOWN: ColScroll(&stRead,1,FALSE); break; case SB_LINEUP: ColScroll(&stRead,-1,FALSE); break; case SB_PAGEDOWN: ColScroll(&stRead,stRead.lCharHeight,FALSE); break; case SB_PAGEUP: ColScroll(&stRead,-stRead.lCharHeight,FALSE); break; case SB_SLIDERPOSITION: ColScroll(&stRead,LOUSHORT(mp2),TRUE); break; } break; case WM_COMMAND: switch (SHORT1FROMMP(mp1)) { case IDMPU_ASCII_FONT: if (!stCFG.bStickyMenus) usLastPopupItem = IDMPU_FONT; else usLastPopupItem = IDMPU_SYNC; if (stCFG.wColReadFont != wASCIIfont) { stCFG.wColReadFont = wASCIIfont; WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE); } break; case IDMPU_HEX_FONT: if (!stCFG.bStickyMenus) usLastPopupItem = IDMPU_FONT; else usLastPopupItem = IDMPU_SYNC; if (stCFG.wColReadFont != wHEXfont) { stCFG.wColReadFont = wHEXfont; WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE); } break; case IDMPU_SYNC: usLastPopupItem = IDMPU_SYNC; if (bStopDisplayThread) stRead.lScrollIndex = stWrite.lScrollIndex; else stRead.lScrollIndex = 0; stRead.lScrollRow = GetColScrollRow(&stRead,0); WinSendMsg(stRead.hwndScroll, SBM_SETPOS, MPFROMSHORT(stRead.lScrollRow), MPFROMSHORT(0)); if (stRead.bSync) { stRow.lScrollIndex = stRead.lScrollIndex; stRow.lScrollRow = GetRowScrollRow(&stRow); } WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE); break; case IDMPU_COLORS: if (!stCFG.bStickyMenus) usLastPopupItem = IDMPU_COLORS; else usLastPopupItem = IDMPU_SYNC; stColor.lForeground = stCFG.lReadColForegrndColor; stColor.lBackground = stCFG.lReadColBackgrndColor; sprintf(stColor.szCaption,"Lexical Receive Data Display Colors"); if (WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)fnwpSetColorDlg, (USHORT)NULL, CLR_DLG, MPFROMP(&stColor))) { stCFG.lReadColForegrndColor = stColor.lForeground; stCFG.lReadColBackgrndColor = stColor.lBackground; stRead.lBackgrndColor = stColor.lBackground; stRead.lForegrndColor = stColor.lForeground; WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE); } break; case IDMPU_LOCK_WIDTH: if (!stCFG.bStickyMenus) usLastPopupItem = IDMPU_LOCK_WIDTH; else usLastPopupItem = IDMPU_SYNC; if (stCFG.fLockWidth == LOCK_READ) stCFG.fLockWidth = LOCK_NONE; else { stCFG.lLockWidth = ((stRead.lWidth / stCell.cx) + 1); stCFG.fLockWidth = LOCK_READ; } break; case IDMPU_DISP_FILTERS: if (!stCFG.bStickyMenus) usLastPopupItem = IDMPU_DISP_FILTERS; else usLastPopupItem = IDMPU_SYNC; if (WinDlgBox(HWND_DESKTOP, hwnd, (PFNWP)fnwpDisplaySetupDlgProc, (USHORT)NULL, DISP_FILTER_DLG, MPFROMP(&stRead))) { stCFG.bReadTestNewLine = stRead.bTestNewLine; stCFG.bSkipReadBlankLines = stRead.bSkipBlankLines; stCFG.byReadNewLineChar = stRead.byNewLineChar; stCFG.bFilterRead = stRead.bFilter; stCFG.fFilterReadMask = stRead.fFilterMask; stCFG.byReadMask = stRead.byDisplayMask; if (stRead.bSync) { if (!stCFG.bSyncToRead) { stWrite.bSync = FALSE; stCFG.bSyncToWrite = FALSE; stCFG.bSyncToRead = TRUE; if (stCFG.fDisplaying & (DISP_DATA | DISP_FILE)) { ClearColScrollBar(&stWrite); SetupColScrolling(&stRead); } } } else { if (stCFG.bSyncToRead) { stCFG.bSyncToRead = FALSE; if (stCFG.fDisplaying & (DISP_DATA | DISP_FILE)) SetupColScrolling(&stWrite); } } WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE); } break; } break; // case WM_CHORD: case WM_BUTTON2DOWN: if(bFrameActivated) { hwndMenu = WinLoadMenu(stRead.hwnd,(HMODULE)NULL,IDMPU_COL_DISP_POPUP); if (mp1 != 0) { WinQueryPointerPos(HWND_DESKTOP,&ptl); if (!stCFG.bStickyMenus) usMenuStyle |= PU_MOUSEBUTTON2DOWN; else usMenuStyle &= ~PU_MOUSEBUTTON2DOWN; } else { usMenuStyle &= ~PU_MOUSEBUTTON2DOWN; WinQueryWindowPos(hwndFrame,&swp); ptl.x = (swp.x + (swp.cx - (swp.cx / 4))); ptl.y = (swp.y + (swp.cy / 2)); } if (stCFG.wColReadFont == wASCIIfont) PopupMenuItemCheck(hwndMenu,IDMPU_ASCII_FONT,TRUE); else PopupMenuItemCheck(hwndMenu,IDMPU_HEX_FONT,TRUE); if (stCFG.fLockWidth == LOCK_READ) PopupMenuItemCheck(hwndMenu,IDMPU_LOCK_WIDTH,TRUE); if (!bStopDisplayThread) WinSendMsg(hwndMenu,MM_SETITEMTEXT,(MPARAM)IDMPU_SYNC,"~Reset Display"); WinPopupMenu(HWND_DESKTOP,stRead.hwndClient,hwndMenu,ptl.x,ptl.y,usLastPopupItem,usMenuStyle); } else return WinDefWindowProc(hwnd,msg,mp1,mp2); break; case WM_BUTTON1DOWN: if(bFrameActivated) { WinCopyRect(habAnchorBlock,&rclRect,&stRead.rcl); lSaveEdge = rclRect.xLeft; if (TrackChildWindow(habAnchorBlock,hwndClient,&rclRect,TF_LEFT)) { if (rclRect.xLeft != lSaveEdge) { WinSendMsg(stWrite.hwndClient,UM_TRACKSIB,0L,(MPARAM)rclRect.xLeft); WinSendMsg(stRead.hwndClient,UM_TRACKSIB,(MPARAM)rclRect.xLeft,0L); if (stCFG.fLockWidth == LOCK_WRITE) stCFG.lLockWidth = ((stWrite.lWidth / stCell.cx) + 1); else stCFG.lLockWidth = ((stRead.lWidth / stCell.cx) + 1); } } } else return WinDefWindowProc(hwnd,msg,mp1,mp2); break; case WM_DESTROY: GpiDestroyPS(hdcPs); break; case UM_SHOWNEW: stRead.lScrollIndex = 0; stRead.lScrollRow = 0; ClearColScrollBar(&stRead); case UM_SHOWAGAIN: stRead.bActive = TRUE; if ((stCFG.fDisplaying & (DISP_DATA | DISP_FILE)) && !stCFG.bSyncToWrite) SetupColScrolling(&stRead); WinShowWindow(stRead.hwnd,TRUE); WinSendMsg(hwnd,UM_TRACKFRAME,0L,0L); WinInvalidateRect(stRead.hwndClient,(PRECTL)NULL,FALSE); WinInvalidateRect(hwndStatus,(PRECTL)NULL,FALSE); break; case UM_HIDEWIN: ClearColScrollBar(&stRead); stRead.bActive = FALSE; WinShowWindow(hwnd,FALSE); WinSetWindowPos(stRead.hwnd,HWND_BOTTOM,0L,0L,0L,0L,(SWP_MOVE | SWP_SIZE | SWP_ZORDER)); break; case WM_PAINT: #ifdef this_junk if (!pstCFG->bDisplayingData && (stCFG.bSyncToRead || stCFG.bSyncToWrite)) ColumnPaint(&stRead,WinPeekMsg(habAnchorBlock,&stQmsg,stWrite.hwndClient,WM_PAINT,WM_PAINT,PM_REMOVE)); else #endif ColumnPaint(&stRead); break; case UM_TRACKSIB: ColumnSize(&stRead,(LONG)mp1,(LONG)mp2,TRUE); break; case UM_TRACKFRAME: ColumnSize(&stRead,(LONG)mp1,(LONG)mp2,FALSE); break; case WM_ERASEBACKGROUND: return (MRESULT)(TRUE); case WM_CLOSE: WinPostMsg(hwnd,WM_QUIT,0L,0L); default: return WinDefWindowProc(hwnd,msg,mp1,mp2); } return(FALSE); }
MRESULT EXPENTRY NEWCFGDlgProc(HWND hwndDlg, ULONG msg, MPARAM mp1, MPARAM mp2) { HWND hwndFrame = hwndDlg; /* ##START Form.37 Top of window procedure */ /* Code sections - Top of window procedure */ /* ##END Top of window procedure */ switch (msg) { /* Form event Opened WM_INITDLG */ case WM_INITDLG : HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); { /* ##START Form.1 */ /* Form events - Opened */ { INT x_screen, y_screen, x_offset, y_offset; POINTL pt; SWP swp; WinQueryWindowPos( hwndDlg, &swp ); WinQueryPointerPos( HWND_DESKTOP, &pt ); swp.x = pt.x - (swp.cx /2); swp.y = pt.y - (swp.cy /2); x_screen = WinQuerySysValue( HWND_DESKTOP, SV_CXSCREEN ); y_screen = WinQuerySysValue( HWND_DESKTOP, SV_CYSCREEN ); x_offset = x_screen*.005; y_offset = y_screen*.005; if ( swp.cx + swp.x > x_screen ) swp.x = x_screen - (swp.cx + x_offset); if ( swp.x <= 0 ) swp.x = x_offset; if ( swp.y + swp.cy > y_screen ) swp.y = y_screen - (swp.cy + y_offset); if ( swp.y <= 0 ) swp.y = y_offset; WinSetWindowPos(hwndDlg, HWND_TOP, swp.x, swp.y, 0, 0, SWP_ACTIVATE | SWP_MOVE | SWP_SHOW ); } /* ##END */ } break; /* Form event Closed WM_CLOSE */ case WM_CLOSE : /* ##START Form.2 */ /* ##END */ HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); break; case WM_COMMAND : switch (SHORT1FROMMP(mp1)) { /* Button 2001 Clicked/Selected */ case 2001: { /* ##START 2001.0 */ /* Event Clicked/selected - Update 2001 */ UPDATECONFIG = TRUE; ISCANCELLED = FALSE; WinPostMsg(hwndDlg, WM_CLOSE, 0, 0); /* ##END */ } break; /* Button 2002 Clicked/Selected */ case 2002: { /* ##START 2002.0 */ /* Event Clicked/selected - ~Cancel 2002 */ ISCANCELLED = TRUE; WinPostMsg(hwndDlg, WM_CLOSE, 0, 0); /* ##END */ } break; /* Button 2004 Clicked/Selected */ case 2004: { /* ##START 2004.0 */ /* Event Clicked/selected - Do not Update 2004 */ ISCANCELLED = FALSE; WinPostMsg(hwndDlg, WM_CLOSE, 0, 0); /* ##END */ } break; } /* end switch */ break; /* ##START Form.38 User defined messages */ /* ##END User defined messages */ default : HandleMessage(hwndFrame, hwndDlg, msg, mp1, mp2); return WinDefDlgProc(hwndDlg,msg,mp1,mp2); } /* end switch for main msg dispatch */ return (MRESULT)FALSE; } /* end dialog procedure */
MRESULT EXPENTRY stlrTitleBarProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { PSTLRFRAME p; /* ------------------------------------------------------------------- window creation : store the handle of the owner window, the initial titlebar size, convert the title substituting \r\n with 1 space, update the titlebar font ------------------------------------------------------------------- */ if (msg == WM_CREATE) { // if this is a global exception window, if the window ID is not // FID_TITLEBAR or if the owner window is not a frame, go to the // default system titlebar procedure if (!pd.ppib || (((PCREATESTRUCT)mp2)->id != FID_TITLEBAR) || !_isFrameWindow(((PCREATESTRUCT)mp2)->hwndOwner)) goto defaultTitlebarProcedure; // get the frame data p = (PSTLRFRAME)WinQueryWindowPtr(((PCREATESTRUCT)mp2)->hwndOwner, g.cd.frame.cbData); // /*-*/ dbgPrintf5("*** pd.ppib:%08x, id: %04x, isOwnerFrame: %d, p: %08x\n", // pd.ppib, ((PCREATESTRUCT)mp2)->id, // _isFrameWindow(((PCREATESTRUCT)mp2)->hwndOwner), p); // if the frame window is a win32frame initialize the frame data now if (!p || ((p == FL_WIN32FRAME) && (NULL == (p = _initWin32Frame(((PCREATESTRUCT)mp2)->hwndOwner))))) goto defaultTitlebarProcedure; // memorizza handle frame window WinSetWindowPtr(hwnd, g.cd.tbar.cbData, p); p->hTBar = hwnd; if (((PCREATESTRUCT)mp2)->pszText) p->cchTxt = psznconvcpy(p->achTxt, ((PCREATESTRUCT)mp2)->pszText, 260); p->wrclTitle.x = ((PCREATESTRUCT)mp2)->x; p->wrclTitle.y = ((PCREATESTRUCT)mp2)->y; p->wrclTitle.cx = ((PCREATESTRUCT)mp2)->cx; p->wrclTitle.cy = ((PCREATESTRUCT)mp2)->cy; // cambia font secondo preferenze if (o.tb.on && !(o.gen.disabled || pd.we.tbar)) _setPPFont(hwnd, o.tb.achFont); /* ------------------------------------------------------------------- hiliting/unhiliting of the titlebar : store the handle of the owner window, the initial titlebar size, convert the title substituting \r\n with 1 space, update the titlebar font ------------------------------------------------------------------- */ } else if (msg == TBM_SETHILITE) { if (_getFrameData(hwnd, p)) { p->is.tbhilited = (BOOL)mp1; if (!o.gen.disabled && o.tb.on && !pd.we.tbar) { if (o.tb.ovrPP || (p->is.tbhilited && !p->is.tbactpp) || !(p->is.tbhilited || p->is.tbictpp)) { if (WinIsWindowShowing(hwnd)) { p->hps = WinGetPS(hwnd); DrawTitlebar(p); WinReleasePS(p->hps); } /* endif */ return (MRESULT)TRUE; // Š solo apparentemente ridondante, in realt… Š necessario quando // non Š ovrPP ed Š presente solo PP att. o inatt. } else if (!(p->is.tbactpp && p->is.tbictpp)) { repaintWindow(hwnd); } /* endif */ } /* endif */ } /* endif */ /* ------------------------------------------------------------------- titlebar font/color changed - if the font changed repaint the window - if any color changed reset the presparm presence flag ------------------------------------------------------------------- */ } else if (msg == WM_PRESPARAMCHANGED) { if (!pd.we.tbar && _getFrameData(hwnd, p)) { ULONG ul; switch ((LONG)mp1) { case PP_FONTNAMESIZE: p->cyfont = 0; if (o.gen.disabled) break; if (WinIsWindowShowing(hwnd)) repaintWindow(hwnd); return (MRESULT)FALSE; case PP_ACTIVETEXTBGNDCOLOR: case PP_ACTIVETEXTBGNDCOLORINDEX: case PP_ACTIVECOLOR: case PP_ACTIVECOLORINDEX: p->is.tbactpp = _getPPColor(hwnd, (ULONG)mp1, &ul) != 0; break; case PP_INACTIVETEXTBGNDCOLOR: case PP_INACTIVETEXTBGNDCOLORINDEX: case PP_INACTIVECOLOR: case PP_INACTIVECOLORINDEX: p->is.tbictpp = _getPPColor(hwnd, (ULONG)mp1, &ul) != 0; break; } /* endswitch */ } /* endif */ /* ------------------------------------------------------------------- the titlebar text changed. If this is a Win-OS/2 window set the window words to 0 so that the enhancements are skipped, otherwise store the new text. ------------------------------------------------------------------- */ } else if (msg == WM_SETWINDOWPARAMS) { if (!pd.we.tbar && _getFrameData(hwnd, p)) { // unsubclass winOS2 windows titlebars if (p->is.winos2) { _resetDefaultProc(hwnd); // WinSetWindowULong(hwnd, g.cd.tbar.cbData, 0); } else { if ((PWNDPARAMS)mp1 && (((PWNDPARAMS)mp1)->fsStatus & WPM_TEXT) && ((PWNDPARAMS)mp1)->pszText) { p->cchTxt = psznconvcpy(p->achTxt, ((PWNDPARAMS)mp1)->pszText, 260); p->cyfont = 0; } /* endif */ } /* endif */ } /* endif */ /* ------------------------------------------------------------------- titlebar size/position changed : store new size and position ------------------------------------------------------------------- */ } else if (msg == WM_WINDOWPOSCHANGED) { if ((((PSWP)mp1)->fl & (SWP_SIZE | SWP_MOVE)) && _getFrameData(hwnd, p)) { p->wrclTitle.x = ((PSWP)mp1)->x; p->wrclTitle.y = ((PSWP)mp1)->y; p->wrclTitle.cx = ((PSWP)mp1)->cx; p->wrclTitle.cy = ((PSWP)mp1)->cy; } /* endif */ // ************************************************************************** // these messages are processed only if Styler/2 is not disabled: } else if (!o.gen.disabled) { /* ------------------------------------------------------------------- check if this is the roll-the-window mouse event : ------------------------------------------------------------------- */ if ((msg == o.roll.moumsg) && (SHORT2FROMMP(mp2) == o.roll.moukbd)) { if (!pd.we.wroll && o.roll.mou && _getFrameData(hwnd, p) && !p->is.win32 && (o.roll.on || p->is.RLon)) { toggleRollCmd(p->hwnd, p); return (MRESULT)TRUE; } /* endif */ /* ------------------------------------------------------------------- check if this is the hide-titlebar mouse event : ------------------------------------------------------------------- */ } else if ((msg == o.tbh.moumsg) && (SHORT2FROMMP(mp2) == o.tbh.moukbd)) { if (!pd.we.tbarhide && o.tbh.mou && _getFrameData(hwnd, p) && !p->is.win32 // opzione titlehide attiva e non dialogo o disattivazione titlehide && ((o.tbh.on && !(p->is.dialog && o.tbh.noDlg)) || p->is.titleHide)) { toggleTitleBarHidingCmd(p->hwnd, p); return (MRESULT)TRUE; } /* endif */ /* ------------------------------------------------------------------- check if this is the change-Zorder mouse event : ------------------------------------------------------------------- */ } else if ((msg == o.sizpos.ZordMoumsg) && (SHORT2FROMMP(mp2) == o.sizpos.ZordMoukbd)) { if (!pd.we.sizemove && o.sizpos.Zmove && _getFrameData(hwnd, p)) { _stlrMsgPost(p->hwnd, STLR_ZORDACTIV, SW2_SFMOVETOBOTTOM); return (MRESULT)TRUE; } /* endif */ /* ------------------------------------------------------------------- check if this is the snap-to-screen-edge mouse event : ------------------------------------------------------------------- */ } else if ((msg == o.sizpos.snapMoumsg) && (SHORT2FROMMP(mp2) == o.sizpos.snapMoukbd)) { if (!pd.we.sizemove && o.sizpos.snap && _getFrameData(hwnd, p)) { // get the rectangle of the window and of its parent RECTL r, rParent; WinQueryWindowRect(p->hwnd, &r); WinQueryWindowRect(_winParent(p->hwnd), &rParent); // click on the left side of the titlebar if (MOUSEX(mp1) < (p->wrclTitle.cx / 3)) { r.xLeft = -p->ptBrd.x; // click on the right side of the titlebar } else if (MOUSEX(mp1) > (p->wrclTitle.cx * 2 / 3)) { r.xLeft = rParent.xRight - r.xRight + p->ptBrd.x; // click on the (horizontal) middle of the titlebar } else { r.xLeft = (rParent.xRight - r.xRight) / 2; } /* endif */ // click on the bottom of the titlebar if (MOUSEY(mp1) < (g.sys.cyTbar / 3)) { r.yBottom = -p->ptBrd.y; // click on the top of the titlebar } else if (MOUSEY(mp1) > (g.sys.cyTbar * 2 / 3)) { r.yBottom = rParent.yTop - r.yTop + p->ptBrd.y; // click on the (vertical) middle of the titlebar } else { r.yBottom = (rParent.yTop - r.yTop) / 2; } /* endif */ WinSetWindowPos(p->hwnd, 0, r.xLeft, r.yBottom, 0, 0, SWP_MOVE | SWP_NOADJUST); } /* endif */ /* ------------------------------------------------------------------- enhanced window painting ------------------------------------------------------------------- */ } else if (msg == WM_PAINT) { if (!pd.we.tbar && o.tb.on && _getFrameData(hwnd, p) && (o.tb.ovrPP || (p->is.tbhilited && !p->is.tbactpp) || !(p->is.tbhilited || p->is.tbictpp))) { p->hps = WinBeginPaint(hwnd, NULLHANDLE, NULL); DrawTitlebar(p); WinEndPaint(p->hps); return (MRESULT)FALSE; } /* endif */ /* ------------------------------------------------------------------- override the default window tracking : ------------------------------------------------------------------- */ } else if ((msg == WM_BUTTON1DOWN) || (msg == WM_BUTTON2DOWN)) { if (_getFrameData(hwnd, p)) { // override window motion by titlebar drag : // store the current mouse position (mp1) // the window motion will start only when the mouse will move g.tbdrag.mpPos = mp1; // if the window is not already moving store which mouse button // has to be released to stop the titlebar drag if (!g.tbdrag.hwnd) g.tbdrag.msg = ++msg; // store the handle of the titlebar (mouse motion events are not // processed when this is NULLHANDLE) g.tbdrag.hwnd = hwnd; // cattura i msg successivi del mouse WinSetCapture(HWND_DESKTOP, hwnd); return (MRESULT)TRUE; } /* endif */ /* ------------------------------------------------------------------- terminate window motion through titlebar drag events : ------------------------------------------------------------------- */ } else if ((msg == WM_BUTTON1UP) || (msg == WM_BUTTON2UP)) { if ((g.tbdrag.hwnd == hwnd) && (g.tbdrag.msg == msg) && _getFrameData(hwnd, p)) { HWND hwndParent; WinSetCapture(HWND_DESKTOP, NULLHANDLE); g.tbdrag.msg = 0; g.tbdrag.hwnd = NULLHANDLE; // if the Ctrl key is not pressed and the window is not yet active // end the window is a size-move feature exception or the event // is not related to the Z-order motion feature or the snap-to- // parent-edge feature activate the window bringing it to the top if (!(SHORT2FROMMP(mp2) & KC_CTRL) && (g.hwnd.active != p->hwnd) && (pd.we.sizemove || (!(o.sizpos.Zmove && (msg == (o.sizpos.ZordMoumsg - 0x3a1)) && (SHORT2FROMMP(mp2) == o.sizpos.ZordMoukbd)) && (!(o.sizpos.snap && (msg == (o.sizpos.snapMoumsg - 0x3a1)) && (SHORT2FROMMP(mp2) == o.sizpos.snapMoukbd)))))) WinSetWindowPos(p->hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER); } /* endif */ /* ------------------------------------------------------------------- open the system menu on the titlebar : ------------------------------------------------------------------- */ } else if (msg == WM_CONTEXTMENU) { if (!pd.we.tbar && o.tb.menu && _getFrameData(hwnd, p)) { // if this is the titlebar of a WPS folder simulate a context // menu event on the client window if (p->is.folder) { p->hClient = WinWindowFromID(p->hwnd, FID_CLIENT); WinPostMsg(p->hClient, WM_CONTEXTMENU, (MPARAM)0x7fff7fff, MPVOID); // otherwise get the handle of the system menu and bring it to // the top via WinPopupMenu() } else if (p->hSMenu) { POINTL ptl; WinQueryPointerPos(g.hwnd.desktop, &ptl); g.cd.menu.pfnwp(p->hSMenu, MM_QUERYITEM, (MPARAM)SC_SYSMENU, MPFROMP(&p->mi)); g.hwnd.sysMenu = p->mi.hwndSubMenu; WinPopupMenu(g.hwnd.desktop, p->hSMenu, g.hwnd.sysMenu, ptl.x, ptl.y, 0, PU_HCONSTRAIN | PU_VCONSTRAIN | PU_NONE | PU_KEYBOARD | PU_MOUSEBUTTON1); } /* endif */ } /* endif */ return (MRESULT)TRUE; /* ------------------------------------------------------------------- trap WM_MOUSEMOVE to implement various features : - do not move maximized windows ------------------------------------------------------------------- */ } else if (msg == WM_MOUSEMOVE) { // if mouse button 1 or 2 were pressed and then the mouse position // changed if ((g.tbdrag.hwnd == hwnd) && (g.tbdrag.mpPos != mp1) && _getFrameData(hwnd, p)) { WinSetCapture(HWND_DESKTOP, NULLHANDLE); g.tbdrag.hwnd = NULLHANDLE; g.tbdrag.msg = 0; // if this is a maximized window and the don't-move-max-window // feature is set ignore the event if (o.maxwin.nomove && p->is.max && !(pd.we.maxwin || p->is.shield || p->is.ovrdnomovemax)) return (MRESULT)TRUE; WinSendMsg(p->hwnd, WM_TRACKFRAME, (MPARAM)TF_MOVE, g.tbdrag.mpPos); // ??????????????????????????????? // this is needed because the next WM_BUTTONxUP is captured by // the WM_TRACKFRAME processing // if (!(SHORT2FROMMP(mp2) & KC_CTRL)) // WinSetWindowPos(p->hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ACTIVATE | SWP_ZORDER); return (MRESULT)TRUE; } else if (g.is.onctrl != OCTLTBAR) { g.is.onctrl = OCTLTBAR; // ??????????????? this should be redundant // _resetHideMouTimer(); } /* endif */ } /* endif */ // ------------------------------------------------------------------- } /* endif */ defaultTitlebarProcedure: return g.cd.tbar.pfnwp(hwnd, msg, mp1, mp2); }
static MRESULT EXPENTRY launchPadWindowProc(HWND hwnd, ULONG msg, MPARAM mp1, MPARAM mp2) { WPFolder* thisPtr; launchPad * lp; LPObject *lpo; static USHORT id=0;//Initialisation new in V1.00a switch(msg) { #if 0 case DM_ENDCONVERSATION: case DM_DRAGFILECOMPLETE: case DM_DROPNOTIFY: case DM_FILERENDERED: case DM_RENDERCOMPLETE: break; return (MRESULT)FALSE; case WM_ENDDRAG: break; return (MRESULT)TRUE; #endif case WM_PAINT: { RECTL rcl; launchPad * lp; HPS hps=WinBeginPaint(hwnd,NULLHANDLE, &rcl); WinFillRect(hps, &rcl, SYSCLR_DIALOGBACKGROUND); lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER); if(lp) { if(lp->lpQueryNumObjects()==0) { WinQueryWindowRect(hwnd,&rcl); WinDrawBorder(hps,&rcl,1,1,SYSCLR_WINDOWFRAME,SYSCLR_DIALOGBACKGROUND, DB_STANDARD); } } WinEndPaint(hps); return (MRESULT) 0; } case DM_DRAGOVER: return handleDragOver(hwnd, mp1, mp2); case DM_DROP: { ULONG ulCount; ULONG ulNumberOfObjects; PDRAGITEM pDragItem; SOMClass *folderClass; WPObject * wpObject; PDRAGINFO pDragInfo; TRY_LOUD(LP_FRAMEDROP) { /* A new object dropped on the launchpad */ pDragInfo=(PDRAGINFO)mp1; if(DrgAccessDraginfo(pDragInfo)) { /* Get number of items */ ulNumberOfObjects = DrgQueryDragitemCount( pDragInfo); if(ulNumberOfObjects>1){ /* Free the draginfo */ DrgDeleteDraginfoStrHandles(pDragInfo); DrgFreeDraginfo(pDragInfo); } else { ulCount=0; pDragItem=DrgQueryDragitemPtr( pDragInfo, ulCount); wpObject=(WPObject*)OBJECT_FROM_PREC(DrgQueryDragitemPtr( pDragInfo, ulCount)->ulItemID); lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER); if(lp) { if(somIsObj(wpObject)) { POINTL ptl; int numB; SWP swp; WinQueryWindowPos(hwnd,&swp); ptl.x=pDragInfo->xDrop; ptl.y=pDragInfo->yDrop; /* Pos in window coords */ WinMapWindowPoints(HWND_DESKTOP, hwnd, &ptl, 1); numB=(ptl.x-xButtonOffset)/(swp.cy+xButtonDelta); numB=((ptl.x-numB*swp.cy) > swp.cy/2 ? numB+1: numB); /* Do a link */ lp->lpAddButton(wpObject, numB); handleDragLeave(hwnd, mp1, mp2); } } DrgDeleteDraginfoStrHandles(pDragInfo); DrgFreeDraginfo(pDragInfo); } } handleDragLeave(hwnd, mp1, mp2); } CATCH(LP_FRAMEDROP) { } END_CATCH; break; } case DM_DRAGLEAVE: return handleDragLeave(hwnd, mp1, mp2); break; case WM_COMMAND: if(SHORT1FROMMP(mp2)==CMDSRC_PUSHBUTTON) { /* It's a push button */ lpo=(LPObject*)WinQueryWindowULong(WinWindowFromID(hwnd,SHORT1FROMMP(mp1)),QWL_USER); if(lpo) { if(somIsObj(lpo->wpObject)) lpo->wpObject->wpViewObject(NULLHANDLE, OPEN_DEFAULT,0); } } return (MRESULT)FALSE; /***********************************************/ /* Stuff for fly over help */ case WM_MOUSEMOVE: launchPad * lp; lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER); if(lp) { if(lp->lpQueryNumObjects()!=0) { break; } } #if 0 tempID=WinQueryWindowUShort(hwnd,QWS_ID);/* get the id of the window under the pointer */ if(id!=tempID) { // New Button? WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,tempID,(ULONG)iTBFlyOverDelay); // New timer for delay id=tempID; // Save ID } else { if(!hwndBubbleWindow) WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,tempID,(ULONG)iTBFlyOverDelay); // New timer for delay } #endif if(!hwndBubbleWindow) WinStartTimer(WinQueryAnchorBlock(hwnd), hwnd, 2,(ULONG)iTBFlyOverDelay); // New timer for delay break; case WM_DESTROY: WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd,1);//Stop timer if running if(hwndBubbleWindow) WinDestroyWindow(hwndBubbleWindow);/* close the bubblewindow */ hwndBubbleWindow=0; /* Stop delay timer if running */ WinStopTimer(WinQueryAnchorBlock(hwnd),hwnd, 2); break; case WM_NEWBUBBLE: ULONG bubbleEnabled; HWND hwndStore; POINTL ptl; RECTL rclWork; LONG ulWinTextLen; POINTL aptlPoints[TXTBOX_COUNT]; LONG deltaX,deltaY; HPS hps; RECTL rcl; /* we have to build a new information window */ if(hwndBubbleWindow){// if(){...} new in V1.00a WinDestroyWindow(hwndBubbleWindow);/* close the bubblewindow */ hwndBubbleWindow=NULL; } // Query the pointer position WinQueryPointerPos(HWND_DESKTOP,&ptl); WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1); WinQueryWindowRect(hwnd,&rclWork); if(!hwndBubbleWindow && WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl) && bTBFlyOverEnabled) { static HWND hwndBubbleClient; ULONG style=FCF_BORDER|FCF_NOBYTEALIGN; char winText[255]; /* Get window text for size calculating */ lp=(launchPad*)WinQueryWindowULong(hwnd,QWL_USER); if(lp) { strncpy(winText, lp->lpQueryFlyOverText(), sizeof(winText)); winText[sizeof(winText)-1]=0; } ulWinTextLen=(LONG)strlen(winText); // Query text length /* Delete 'Returns' in object title */ char *pBuchst; char *pRest; pRest=winText; while((pBuchst=strchr(pRest,13))!=NULL) { *pBuchst=' '; pBuchst++; if(*pBuchst==10) *pBuchst=' '; pRest=pBuchst; } /* Create help window */ hwndBubbleWindow=WinCreateStdWindow(HWND_DESKTOP, 0, &style, WC_STATIC, "", SS_TEXT|DT_CENTER|DT_VCENTER, NULLHANDLE, 400, &hwndBubbleClient); hwndShadow=WinCreateWindow(HWND_DESKTOP, WC_STATIC, "", SS_TEXT|DT_CENTER|DT_VCENTER, 0, 0, 0, 0, hwndBubbleWindow, hwndBubbleWindow, 401, NULLHANDLE, NULLHANDLE); oldProc=WinSubclassWindow(hwndShadow, shadowProc); // Set the font for the help WinSetPresParam(hwndBubbleClient,PP_FONTNAMESIZE, sizeof(chrTBFlyFontName), chrTBFlyFontName); /* Calculate text size in pixel */ hps=WinBeginPaint(hwndBubbleClient,(HPS)NULL,(PRECTL)NULL); GpiQueryTextBox(hps,ulWinTextLen,winText,TXTBOX_COUNT,aptlPoints); WinEndPaint(hps); /* Set colors */ WinSetPresParam(hwndBubbleClient, PP_BACKGROUNDCOLOR,sizeof(rgbTBFlyBackground) , &rgbTBFlyBackground ); WinSetPresParam(hwndBubbleClient, PP_FOREGROUNDCOLOR,sizeof(rgbTBFlyForeground) , &rgbTBFlyForeground ); /* Calculate bubble positon and show bubble */ WinQueryPointerPos(HWND_DESKTOP,&ptl);//Query pointer position in the desktop window WinQueryWindowRect(HWND_DESKTOP,&rcl);//Query desktop size aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+7+xVal+ptl.x > rcl.xRight ? deltaX=-aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x-xVal-xVal-7 : deltaX=0 ; aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2+yVal+ptl.y > rcl.yTop ? deltaY=-aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y-2*yVal-7 : deltaY=0 ; WinSetWindowPos(hwndBubbleWindow, HWND_TOP, ptl.x+xVal+deltaX,ptl.y+yVal+deltaY, aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+8, aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2, SWP_ZORDER|SWP_SIZE|SWP_MOVE|SWP_SHOW); WinSetWindowPos(hwndShadow, hwndBubbleWindow, ptl.x+xVal+deltaX+5 ,ptl.y+yVal+deltaY-5, aptlPoints[TXTBOX_BOTTOMRIGHT].x-aptlPoints[TXTBOX_BOTTOMLEFT].x+8, aptlPoints[TXTBOX_TOPLEFT].y-aptlPoints[TXTBOX_BOTTOMLEFT].y+2, SWP_ZORDER|SWP_SIZE|SWP_MOVE|SWP_SHOW); /* Set bubble text */ WinSetWindowText(hwndBubbleClient,winText); WinStartTimer(WinQueryAnchorBlock(hwnd),hwnd,1,35); } // end if(!hwndBubbleWindow) break; case WM_TIMER: switch (SHORT1FROMMP(mp1)) { case 1: //Intervall timer { POINTL ptl; RECTL rclWork; /* Test pointer position */ WinQueryPointerPos(HWND_DESKTOP, &ptl); WinMapWindowPoints(HWND_DESKTOP, hwnd,&ptl, 1); WinQueryWindowRect(hwnd, &rclWork); if(!WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl)) { // Window has changed WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, 1); // stop the running timer if(hwndBubbleWindow) WinDestroyWindow(hwndBubbleWindow);/* close the bubblewindow */ hwndBubbleWindow=0; id=0; } break; } case 2:// delay over {//our own timer. POINTL ptl; RECTL rclWork; WinStopTimer(WinQueryAnchorBlock(hwnd), hwnd, 2);//Stop the delay timer /* Check the pointer position */ WinQueryPointerPos(HWND_DESKTOP,&ptl); WinMapWindowPoints(HWND_DESKTOP,hwnd,&ptl,1); WinQueryWindowRect(hwnd,&rclWork); if(WinPtInRect(WinQueryAnchorBlock(hwnd),&rclWork,&ptl)) WinPostMsg(hwnd,WM_NEWBUBBLE,NULL,NULL);//Request a help window return (MRESULT)FALSE; } default: break; } break; default: break; } return pfnwpOldLPProc(hwnd, msg, mp1, mp2); }
/***************************************************************************** * Control: control facility for the vout *****************************************************************************/ static int Control( vout_display_t *vd, int query, va_list args ) { vout_display_sys_t *sys = vd->sys; switch (query) { case VOUT_DISPLAY_HIDE_MOUSE: { POINTL ptl; WinQueryPointerPos( HWND_DESKTOP, &ptl ); if( !sys->is_mouse_hidden && WinWindowFromPoint( HWND_DESKTOP, &ptl, TRUE ) == sys->client ) { WinShowPointer( HWND_DESKTOP, FALSE ); sys->is_mouse_hidden = true; } return VLC_SUCCESS; } case VOUT_DISPLAY_CHANGE_FULLSCREEN: { bool fs = va_arg(args, int); WinPostMsg( sys->client, WM_VLC_FULLSCREEN_CHANGE, MPFROMLONG(fs), 0 ); return VLC_SUCCESS; } case VOUT_DISPLAY_CHANGE_WINDOW_STATE: { const unsigned state = va_arg( args, unsigned ); const bool is_on_top = (state & VOUT_WINDOW_STATE_ABOVE) != 0; if( is_on_top ) WinSetWindowPos( sys->frame, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER ); sys->is_on_top = is_on_top; return VLC_SUCCESS; } case VOUT_DISPLAY_CHANGE_DISPLAY_SIZE: case VOUT_DISPLAY_CHANGE_ZOOM: { const vout_display_cfg_t *cfg = va_arg(args, const vout_display_cfg_t *); WinPostMsg( sys->client, WM_VLC_SIZE_CHANGE, MPFROMLONG( cfg->display.width ), MPFROMLONG( cfg->display.height )); return VLC_SUCCESS; } case VOUT_DISPLAY_CHANGE_SOURCE_ASPECT: case VOUT_DISPLAY_CHANGE_SOURCE_CROP: { if( query == VOUT_DISPLAY_CHANGE_SOURCE_ASPECT ) { vout_display_place_t place; vout_display_PlacePicture(&place, &vd->source, vd->cfg, false); sys->kvas.ulAspectWidth = place.width; sys->kvas.ulAspectHeight = place.height; } else { video_format_t src_rot; video_format_ApplyRotation(&src_rot, &vd->source); sys->kvas.rclSrcRect.xLeft = src_rot.i_x_offset; sys->kvas.rclSrcRect.yTop = src_rot.i_y_offset; sys->kvas.rclSrcRect.xRight = src_rot.i_x_offset + src_rot.i_visible_width; sys->kvas.rclSrcRect.yBottom = src_rot.i_y_offset + src_rot.i_visible_height; } kvaSetup( &sys->kvas ); return VLC_SUCCESS; } case VOUT_DISPLAY_RESET_PICTURES: case VOUT_DISPLAY_CHANGE_DISPLAY_FILLED: /* TODO */ break; } msg_Err(vd, "Unsupported query(=%d) in vout display KVA", query); return VLC_EGENERIC; }