void EventHandler::Update( ) { SDL_Event event; while ( SDL_PollEvent( &event ) ) { switch ( event.type ) { case SDL_QUIT : AddQuitEvent(); break; case SDL_KEYDOWN : case SDL_KEYUP : HandleKeyBoard( event ); break; case SDL_MOUSEBUTTONDOWN : case SDL_MOUSEBUTTONUP : HandleMouseButton( event ); break; case SDL_MOUSEMOTION : HandleMouseMove( event ); break; default : break; } } }
void CXTPSkinObjectFrame::OnNcMouseLeave() { if (HandleMouseMove(CPoint(-1, -1))) return; Default(); }
/** ** Handle scrolling area. ** ** @param state Scroll direction/state. ** @param fast Flag scroll faster. ** ** @todo Support dynamic acceleration of scroll speed. ** @todo If the scroll key is longer pressed the area is scrolled faster. */ void DoScrollArea(int state, bool fast, bool isKeyboard) { CViewport *vp; int stepx; int stepy; static int remx = 0; // FIXME: docu static int remy = 0; // FIXME: docu int speed = isKeyboard ? UI.KeyScrollSpeed : UI.MouseScrollSpeed; if (state == ScrollNone) { return; } vp = UI.SelectedViewport; if (fast) { stepx = (int)(speed * vp->MapWidth / 2 * PixelTileSize.x * FRAMES_PER_SECOND / 4); stepy = (int)(speed * vp->MapHeight / 2 * PixelTileSize.y * FRAMES_PER_SECOND / 4); } else {// dynamic: let these variables increase up to fast.. // FIXME: pixels per second should be configurable stepx = (int)(speed * PixelTileSize.x * FRAMES_PER_SECOND / 4); stepy = (int)(speed * PixelTileSize.y * FRAMES_PER_SECOND / 4); } if ((state & (ScrollLeft | ScrollRight)) && (state & (ScrollLeft | ScrollRight)) != (ScrollLeft | ScrollRight)) { stepx = stepx * 100 * 100 / VideoSyncSpeed / FRAMES_PER_SECOND / (SkipFrames + 1); remx += stepx - (stepx / 100) * 100; stepx /= 100; if (remx > 100) { ++stepx; remx -= 100; } } else { stepx = 0; } if ((state & (ScrollUp | ScrollDown)) && (state & (ScrollUp | ScrollDown)) != (ScrollUp | ScrollDown)) { stepy = stepy * 100 * 100 / VideoSyncSpeed / FRAMES_PER_SECOND / (SkipFrames + 1); remy += stepy - (stepy / 100) * 100; stepy /= 100; if (remy > 100) { ++stepy; remy -= 100; } } else { stepy = 0; } if (state & ScrollUp) { stepy = -stepy; } if (state & ScrollLeft) { stepx = -stepx; } const PixelDiff offset(stepx, stepy); vp->Set(vp->MapPos, vp->Offset + offset); // This recalulates some values HandleMouseMove(CursorScreenPos); }
void CXTPSkinObjectFrame::HandleTimer(UINT_PTR uTimerID) { if (uTimerID == XTP_TID_REFRESHFRAME) { RefreshFrameStyle(); KillTimer(XTP_TID_REFRESHFRAME); return; } if (uTimerID == XTP_TID_MOUSELEAVE) { RECT rect; POINT pt; GetWindowRect(&rect); ::GetCursorPos (&pt); if (::GetCapture() != NULL) return; LRESULT lHitTest = HandleNcHitTest(MAKELPARAM(pt.x, pt.y)); if ((lHitTest == HTCLIENT || lHitTest == HTNOWHERE || lHitTest == HTBOTTOMRIGHT || lHitTest == HTBOTTOMLEFT) || !::PtInRect (&rect, pt)) { HandleMouseMove(CPoint(-1, -1)); CancelMouseLeaveTracking(); } return; } }
void CXTPSkinObjectFrame::OnNcMouseMove(UINT nHitTest, CPoint point) { if (HandleMouseMove(point)) return; CXTPSkinObject::OnNcMouseMove(nHitTest, point); }
void MapWidget::mouseReleaseEvent(QMouseEvent* event) { if (event->button()==1) { HandleMouseMove(event); requestNewMap=true; update(); } }
/** ** Handle scrolling area. ** ** @param state Scroll direction/state. ** @param fast Flag scroll faster. ** ** @todo Support dynamic acceleration of scroll speed. ** @todo If the scroll key is longer pressed the area is scrolled faster. */ void DoScrollArea(int state, bool fast) { CViewport *vp; int stepx; int stepy; static int remx = 0; // FIXME: docu static int remy = 0; // FIXME: docu if (state == ScrollNone) { return; } vp = UI.SelectedViewport; if (fast) { stepx = vp->MapWidth / 2 * TileSizeX * FRAMES_PER_SECOND; stepy = vp->MapHeight / 2 * TileSizeY * FRAMES_PER_SECOND; } else {// dynamic: let these variables increase upto fast.. // FIXME: pixels per second should be configurable stepx = TileSizeX * FRAMES_PER_SECOND; stepy = TileSizeY * FRAMES_PER_SECOND; } if ((state & (ScrollLeft | ScrollRight)) && (state & (ScrollLeft | ScrollRight)) != (ScrollLeft | ScrollRight)) { stepx = stepx * 100 * 100 / VideoSyncSpeed / FRAMES_PER_SECOND / (SkipFrames + 1); remx += stepx - (stepx / 100) * 100; stepx /= 100; if (remx > 100) { ++stepx; remx -= 100; } } else { stepx = 0; } if ((state & (ScrollUp | ScrollDown)) && (state & (ScrollUp | ScrollDown)) != (ScrollUp | ScrollDown)) { stepy = stepy * 100 * 100 / VideoSyncSpeed / FRAMES_PER_SECOND / (SkipFrames + 1); remy += stepy - (stepy / 100) * 100; stepy /= 100; if (remy > 100) { ++stepy; remy -= 100; } } else { stepy = 0; } if (state & ScrollUp) { stepy = -stepy; } if (state & ScrollLeft) { stepx = -stepx; } vp->Set(vp->MapX, vp->MapY, vp->OffsetX + stepx, vp->OffsetY + stepy); // This recalulates some values HandleMouseMove(CursorX, CursorY); }
bool HandleMouseEvent(const Lum::OS::MouseEvent& event) { if (!visible) { return false; } if (event.type==Lum::OS::MouseEvent::down && PointIsIn(event) && event.button==Lum::OS::MouseEvent::button1) { requestNewMap=false; startLon=lon; startLat=lat; startX=event.x; startY=event.y; return true; } else if (event.IsGrabEnd() && event.button==Lum::OS::MouseEvent::button1) { HandleMouseMove(event); requestNewMap=true; Redraw(); } else if (event.type==Lum::OS::MouseEvent::move && event.IsGrabed() && event.button==Lum::OS::MouseEvent::none && event.qualifier==Lum::OS::qualifierButton1) { HandleMouseMove(event); Redraw(); return true; } else if (event.type==Lum::OS::MouseEvent::down && event.button==Lum::OS::MouseEvent::button4) { ZoomIn(1.35); return true; } else if (event.type==Lum::OS::MouseEvent::down && event.button==Lum::OS::MouseEvent::button5) { ZoomOut(1.35); return true; } return false; }
bool Widget::TriggerMouseMove(const MouseMotionEvent &event, bool emit) { HandleMouseMove(event); if (emit) emit = !onMouseMove.emit(event); if (GetContainer()) { MouseMotionEvent translatedEvent = MouseMotionEvent(event.pos+GetPosition(), event.rel); GetContainer()->TriggerMouseMove(translatedEvent, emit); } return !emit; }
bool Widget::TriggerMouseMove(const MouseMotionEvent &event, bool handled) { HandleMouseMove(event); if (!handled) handled = onMouseMove.emit(event); if (GetContainer()) { MouseMotionEvent translatedEvent = MouseMotionEvent(event.pos+GetPosition(), event.rel); handled = GetContainer()->TriggerMouseMove(translatedEvent, handled); } return handled; }
void OnMouseEvent(wxMouseEvent& event) { try { HandleMouseMove(event.GetPosition()); event.Skip(); return; } catch(oglplus::Error& err) { HandleError(err, this); } catch(const std::exception& se) { HandleError(se, this); } }
/** ** Handle interactive input event. */ local void DoEvent(SDL_Event* event) { switch( event->type ) { case SDL_MOUSEBUTTONDOWN: DebugLevel3("\tbutton press %d\n",event->button.button); HandleButtonDown(event->button.button); break; case SDL_MOUSEBUTTONUP: DebugLevel3("\tbutton release %d\n",event->button.button); HandleButtonUp(event->button.button); break; // FIXME SDL: check if this is only usefull for the cursor // if this is the case we don't need this. case SDL_MOUSEMOTION: DebugLevel3("\tmotion notify %d,%d\n",event->motion.x,event->motion.y); HandleMouseMove(event->motion.x,event->motion.y); if (TheUI.WarpX != -1 || TheUI.WarpY != -1) { int xw; int yw; xw = TheUI.WarpX; yw = TheUI.WarpY; TheUI.WarpX = -1; TheUI.WarpY = -1; SDL_WarpMouse(xw,yw); } MustRedraw|=RedrawCursor; break; case SDL_ACTIVEEVENT: DebugLevel3("\tFocus changed\n"); if( !event->active.state ) { CursorOn=-1; } break; case SDL_KEYDOWN: DebugLevel3("\tKey press\n"); SdlHandleKey(&event->key.keysym); break; case SDL_KEYUP: DebugLevel3("\tKey release\n"); break; case SDL_QUIT: Exit(0); break; } }
bool HwndSourceHookMenuPopup::OnFilterMessage(suic::ObjectPtr sender, suic::MessageParameter& mp) { suic::ElementPtr rootElement = suic::ElementPtr::cast(sender); bool handled = false; HWND hwnd = HandleToHwnd(mp.hwnd); switch (mp.message) { case WM_NCLBUTTONDOWN: case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: HandleMouseDown(hwnd); break; case WM_NCRBUTTONDOWN: case WM_RBUTTONDOWN: HandleMouseDown(hwnd); break; case WM_LBUTTONUP: HandleMouseUp(); handled = true; break; case WM_MOUSEMOVE: case WM_NCMOUSEMOVE: handled = HandleMouseMove(mp); break; case WM_MOUSEACTIVATE: mp.result = MA_NOACTIVATE; handled = true; break; case WM_CLOSE: ClosePopup(rootElement.get()); break; case WM_NCACTIVATE: { if (mp.wParam == 0 && g_trackmenuitem) { g_trackmenuitem->CloseSubmenu(); g_trackmenuitem->InvalidateVisual(true); suic::SystemHelper::RemoveHwndMessageSystemHook(this); } } break; } return handled; }
bool PawsManager::HandleEvent( iEvent &event ) { if (event.Name == MouseMove) return HandleMouseMove (event); if (event.Name == MouseDown) return HandleMouseDown (event); if (event.Name == MouseDoubleClick) return HandleDoubleClick (event); if (event.Name == MouseUp) return HandleMouseUp (event); if (event.Name == KeyboardDown || event.Name == KeyboardUp) return HandleKeyDown( event ); return false; }
WXLRESULT wxToolMenuBar::MSWWindowProc(WXUINT nMsg, WXWPARAM wParam, WXLPARAM lParam) { switch ( nMsg ) { case WM_SIZE: break; case WM_MOUSEMOVE: // we don't handle mouse moves, so always pass the message to // wxControl::MSWWindowProc HandleMouseMove(wParam, lParam); break; case WM_PAINT: break; } return MSWDefWindowProc(nMsg, wParam, lParam); }
// // ‘”Ќ ÷»я: WndProc(HWND, UINT, WPARAM, LPARAM) // // Ќј«Ќј„≈Ќ»≈: обрабатывает сообщени¤ в главном окне. // // WM_COMMAND - обработка меню приложени¤ // WM_PAINT -«акрасить главное окно // WM_DESTROY - ввести сообщение о выходе и вернутьс¤. // // LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) { int wmId, wmEvent; PAINTSTRUCT ps; HDC hdc; switch (message) { case WM_MOUSEMOVE: HandleMouseMove(); break; case WM_COMMAND: wmId = LOWORD(wParam); wmEvent = HIWORD(wParam); // –азобрать выбор в меню: switch (wmId) { case IDM_ABOUT: DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About); break; case IDM_EXIT: DestroyWindow(hWnd); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } break; case WM_PAINT: hdc = BeginPaint(hWnd, &ps); PaintOpenGL(); // TODO: добавьте любой код отрисовки... EndPaint(hWnd, &ps); break; case WM_DESTROY: PostQuitMessage(0); break; default: return DefWindowProc(hWnd, message, wParam, lParam); } return 0; }
void CPlayerController::HandleEvent(const ALLEGRO_EVENT& ev) { if (!m_player) return; if (ev.type == ALLEGRO_EVENT_MOUSE_AXES) { HandleMouseMove(ev); } else if (ev.type == ALLEGRO_EVENT_KEY_DOWN || ev.type == ALLEGRO_EVENT_KEY_CHAR) { m_keys[ev.keyboard.keycode] = true; HandleKeyDown(ev); } else if(ev.type == ALLEGRO_EVENT_KEY_UP) { m_keys[ev.keyboard.keycode] = false; HandleKeyUp(ev); } }
void MapWidget::mouseMoveEvent(QMouseEvent* event) { HandleMouseMove(event); requestNewMap=false; update(); }
/** ** Handle interactive input event. */ local void DoEvent(void) { XEvent event; int xw, yw; XNextEvent(TheDisplay,&event); switch( event.type ) { case ButtonPress: DebugLevel3("\tbutton press %d\n",event.xbutton.button); HandleButtonDown(event.xbutton.button); break; case ButtonRelease: DebugLevel3("\tbutton release %d\n",event.xbutton.button); HandleButtonUp(event.xbutton.button); break; case Expose: DebugLevel1("\texpose\n"); MustRedraw=-1; break; case MotionNotify: DebugLevel3("\tmotion notify %d,%d\n" ,event.xbutton.x,event.xbutton.y); HandleMouseMove(event.xbutton.x,event.xbutton.y); if (TheUI.WarpX != -1 || TheUI.WarpY != -1) { xw = TheUI.WarpX; yw = TheUI.WarpY; TheUI.WarpX = -1; TheUI.WarpY = -1; XWarpPointer(TheDisplay,TheMainWindow,TheMainWindow, 0,0,0,0,xw,yw); } MustRedraw|=RedrawCursor; break; case FocusIn: DebugLevel3("\tfocus in\n"); break; case FocusOut: DebugLevel3("\tfocus out\n"); CursorOn=-1; break; case ClientMessage: DebugLevel3("\tclient message\n"); if (event.xclient.format == 32) { if ((Atom)event.xclient.data.l[0] == WmDeleteWindowAtom) { Exit(0); } } break; case KeyPress: DebugLevel3("\tKey press\n"); { char buf[128]; int num; KeySym keysym; X11HandleModifiers((XKeyEvent*)&event); num=XLookupString((XKeyEvent*)&event,buf,sizeof(buf),&keysym,0); DebugLevel3("\tKey %lx `%s'\n",keysym,buf); if( num==1 ) { X11HandleKey(*buf); } else { X11HandleKey(keysym); } } break; case KeyRelease: DebugLevel3("\tKey release\n"); X11HandleKeyUp(XLookupKeysym((XKeyEvent*)&event,0)); break; } }
/* ================ rvGEWorkspace::HandleMessage Handles window messages to the workspace ================ */ void rvGEWorkspace::HandleMessage ( UINT msg, WPARAM wParam, LPARAM lParam ) { switch ( msg ) { case WM_CLOSE: { if ( IsModified ( ) ) { if ( IDYES == gApp.MessageBox ( va("Save changes to the document \"%s\" before closing?", GetFilename() ), MB_YESNO|MB_ICONQUESTION ) ) { SendMessage ( mApplication->GetMDIFrame(), WM_COMMAND, MAKELONG(ID_GUIED_FILE_SAVE,0), 0 ); } } GetApplication ( )->GetNavigator().SetWorkspace(NULL); GetApplication ( )->GetTransformer().SetWorkspace(NULL); GetApplication ( )->GetProperties().SetWorkspace(NULL); break; } case WM_CAPTURECHANGED: if ( (HWND)lParam != mWnd ) { mDragScroll = false; mDragType = rvGESelectionMgr::HT_NONE; } break; case WM_SETCURSOR: { POINT point; idVec2 cursor; GetCursorPos ( &point ); cursor.Set ( point.x, point.y ); WindowToWorkspace ( cursor ); if ( mDragType == rvGESelectionMgr::HT_NONE ) { UpdateCursor ( cursor.x, cursor.y ); } else { UpdateCursor ( mDragType ); } break; } case WM_MOUSEWHEEL: if ( (short)HIWORD(wParam) > 0 ) { ZoomIn ( ); } else if ( (short)HIWORD(wParam) < 0 ) { ZoomOut ( ); } break; case WM_MOUSEMOVE: HandleMouseMove ( wParam, lParam ); break; case WM_MBUTTONDOWN: HandleMButtonDown ( wParam, lParam ); break; case WM_MBUTTONUP: HandleMButtonUp ( wParam, lParam ); break; case WM_LBUTTONDOWN: HandleLButtonDown ( wParam, lParam ); break; case WM_LBUTTONUP: HandleLButtonUp ( wParam, lParam ); break; case WM_LBUTTONDBLCLK: HandleLButtonDblClk ( wParam, lParam ); break; case WM_INITMENUPOPUP: SendMessage ( mApplication->GetMDIFrame(), msg, wParam, lParam ); break; case WM_COMMAND: HandleCommand ( wParam, lParam ); break; case WM_RBUTTONDOWN: HandleRButtonDown ( wParam, lParam ); break; case WM_SIZE: UpdateScrollbars(); break; case WM_VSCROLL: HandleScroll ( SB_VERT, wParam, lParam ); break; case WM_HSCROLL: HandleScroll ( SB_HORZ, wParam, lParam ); break; case WM_KEYDOWN: HandleKeyDown ( wParam, lParam ); break; } }