void Menu::handleMouseRelease(QPoint globalPosition) { handleMouseMove(globalPosition); itemReleased(TriggeredSource::Mouse); if (!rect().contains(mapFromGlobal(globalPosition)) && _mouseReleaseDelegate) { _mouseReleaseDelegate(globalPosition); } }
void update_input() { while (SDL_PollEvent(&event)) { switch (event.type) { case SDL_KEYDOWN: handleKeyPress(&event.key.keysym); break; case SDL_MOUSEMOTION: handleMouseMove(&event.motion); break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: handleMousePress(); break; case SDL_QUIT: done = TRUE; break; default: break; } } handleKeyDown(); if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_LEFT)) mouse_left(); if(SDL_GetMouseState(NULL, NULL) & SDL_BUTTON(SDL_BUTTON_RIGHT)) mouse_right(); }
bool PlaceableWindowProxy::eventFilter(QObject *, QEvent *event) { // This should never happen, but doesn't hurt to be defensive. if (!target_) { return false; } if (!visible_) { return false; } switch (event->type()) { case QEvent::MouseButtonPress: return handleMousePress(static_cast<QMouseEvent*>(event)); case QEvent::MouseButtonRelease: return handleMouseRelease(static_cast<QMouseEvent*>(event)); case QEvent::MouseMove: return handleMouseMove(static_cast<QMouseEvent*>(event)); case QEvent::Resize: return handleResize(static_cast<QResizeEvent*>(event)); default: return false; } }
void Menu::handleMousePress(QPoint globalPosition) { handleMouseMove(globalPosition); if (rect().contains(mapFromGlobal(globalPosition))) { itemPressed(TriggeredSource::Mouse); } else if (_mousePressDelegate) { _mousePressDelegate(globalPosition); } }
void MenuSystem::enableItem(ItemID id) { Item *item = getItem(id); if (item) { item->enabled = true; drawItem(id, false); _currItemID = kItemIdNone; Common::Point mousePos = _vm->_system->getEventManager()->getMousePos(); handleMouseMove(mousePos.x, mousePos.y); } }
bool InspectorOverlay::handleInputEvent(const WebInputEvent& inputEvent) { bool handled = false; if (isEmpty()) return false; if (WebInputEvent::isGestureEventType(inputEvent.type) && inputEvent.type == WebInputEvent::GestureTap) { // Only let GestureTab in (we only need it and we know PlatformGestureEventBuilder supports it). PlatformGestureEvent gestureEvent = PlatformGestureEventBuilder(m_webViewImpl->mainFrameImpl()->frameView(), static_cast<const WebGestureEvent&>(inputEvent)); handled = handleGestureEvent(gestureEvent); if (handled) return true; overlayMainFrame()->eventHandler().handleGestureEvent(gestureEvent); } if (WebInputEvent::isMouseEventType(inputEvent.type) && inputEvent.type != WebInputEvent::MouseEnter) { // PlatformMouseEventBuilder does not work with MouseEnter type, so we filter it out manually. PlatformMouseEvent mouseEvent = PlatformMouseEventBuilder(m_webViewImpl->mainFrameImpl()->frameView(), static_cast<const WebMouseEvent&>(inputEvent)); if (mouseEvent.type() == PlatformEvent::MouseMoved) handled = handleMouseMove(mouseEvent); else if (mouseEvent.type() == PlatformEvent::MousePressed) handled = handleMousePress(); if (handled) return true; if (mouseEvent.type() == PlatformEvent::MouseMoved) handled = overlayMainFrame()->eventHandler().handleMouseMoveEvent(mouseEvent) != WebInputEventResult::NotHandled; if (mouseEvent.type() == PlatformEvent::MousePressed) handled = overlayMainFrame()->eventHandler().handleMousePressEvent(mouseEvent) != WebInputEventResult::NotHandled; if (mouseEvent.type() == PlatformEvent::MouseReleased) handled = overlayMainFrame()->eventHandler().handleMouseReleaseEvent(mouseEvent) != WebInputEventResult::NotHandled; } if (WebInputEvent::isTouchEventType(inputEvent.type)) { PlatformTouchEvent touchEvent = PlatformTouchEventBuilder(m_webViewImpl->mainFrameImpl()->frameView(), static_cast<const WebTouchEvent&>(inputEvent)); handled = handleTouchEvent(touchEvent); if (handled) return true; overlayMainFrame()->eventHandler().handleTouchEvent(touchEvent); } if (WebInputEvent::isKeyboardEventType(inputEvent.type)) { PlatformKeyboardEvent keyboardEvent = PlatformKeyboardEventBuilder(static_cast<const WebKeyboardEvent&>(inputEvent)); overlayMainFrame()->eventHandler().keyEvent(keyboardEvent); } if (inputEvent.type == WebInputEvent::MouseWheel) { PlatformWheelEvent wheelEvent = PlatformWheelEventBuilder(m_webViewImpl->mainFrameImpl()->frameView(), static_cast<const WebMouseWheelEvent&>(inputEvent)); handled = overlayMainFrame()->eventHandler().handleWheelEvent(wheelEvent) != WebInputEventResult::NotHandled; } return handled; }
void Splitter::create(const Seed& cs) { pos = cs.pos; horizontal = cs.horizontal; BaseType::create(cs); theme.load(VSCLASS_WINDOW, this); onPainting([this](PaintCanvas& canvas) { handlePainting(canvas); }); onLeftMouseDown([this](const MouseEvent& mouseEvent) { return handleLButtonDown(mouseEvent); }); onMouseMove([this](const MouseEvent& mouseEvent) { return handleMouseMove(mouseEvent); }); onLeftMouseUp([this](const MouseEvent&) { return handleLButtonUp(); }); auto tip = WidgetCreator<ToolTip>::create(this, ToolTip::Seed()); tip->setText(Texts::get(Texts::resize)); onDestroy([tip] { tip->close(); }); }
bool System::handle_event(event e) { static EventArgs::MouseButtons mouse_button_maping[] = { EventArgs::Left, EventArgs::Middle, EventArgs::Right }; int event_type = e.type & event_type_filter; int mouse_event = e.mouse.type & mouse_event_filter; switch(event_type) { case event_mouse: { switch(mouse_event) { case mouse_move: return handleMouseMove(e.mouse.x, e.mouse.y); break; case mouse_wheel: return handleMouseWheel(e.mouse.delta); break; case mouse_button: return handleMouseButton(mouse_button_maping[e.mouse.button], e.mouse.type & event_key_down ? EventArgs::Down : EventArgs::Up); break; case mouse_dbclick: return handleMouseDouble(mouse_button_maping[e.mouse.button]); break; } } break; case event_keyboard: return handleKeyboard(e.keyboard.key, e.keyboard.type & event_key_down ? EventArgs::Down : EventArgs::Up); break; case event_char: return handleChar(e.text.code); break; case event_focus: handleFocusLost(); break; case event_viewport_resize: handleViewportChange(); break; } return false; }
BOOL CALLBACK DrawDlgProc (HWND hDlg, UINT iMessage, WPARAM wParam, LPARAM lParam) { switch (iMessage) { case WM_INITDIALOG: handleInit(hDlg); break; case WM_COMMAND: return(handleWMCommand(hDlg, lParam, wParam)); break; case WM_LBUTTONDOWN: handleLButtonDown(hDlg, lParam); break; case WM_MOUSEMOVE: handleMouseMove(hDlg, lParam, wParam); break; case WM_LBUTTONUP: handleLButtonUp(hDlg, lParam); break; /* As usual, add a destroy handler if this gets long */ case WM_DESTROY: /* Put a message box here to test this out */ //MessageBox(hDlg, "WM Destroy test", "WM_DESTROY", MB_OK); /* Then free up all allocated memory. */ freePointList(); freeJointList(); break; /* Probably should free some memory, etc. before * shutting down. */ default: return FALSE; } return TRUE; ReleaseDC(hDlg, hdc); ReleaseDC(GetDlgItem(hDlg,IDC_DRAWSPACE), hdc); } /* close DrawDlgProc() */
void MenuSystem::handleEvents() { Common::Event event; Common::EventManager *eventMan = _vm->_system->getEventManager(); while (eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_KEYDOWN: handleKeyDown(event.kbd); break; case Common::EVENT_QUIT: _running = false; break; case Common::EVENT_MOUSEMOVE: handleMouseMove(event.mouse.x, event.mouse.y); break; case Common::EVENT_LBUTTONUP: handleMouseClick(event.mouse.x, event.mouse.y); break; default: break; } } }
void PopupMenu::init() { _menu->setResizedCallback([this] { handleMenuResize(); }); _menu->setActivatedCallback([this](QAction *action, int actionTop, TriggeredSource source) { handleActivated(action, actionTop, source); }); _menu->setTriggeredCallback([this](QAction *action, int actionTop, TriggeredSource source) { handleTriggered(action, actionTop, source); }); _menu->setKeyPressDelegate([this](int key) { return handleKeyPress(key); }); _menu->setMouseMoveDelegate([this](QPoint globalPosition) { handleMouseMove(globalPosition); }); _menu->setMousePressDelegate([this](QPoint globalPosition) { handleMousePress(globalPosition); }); _menu->setMouseReleaseDelegate([this](QPoint globalPosition) { handleMouseRelease(globalPosition); }); handleCompositingUpdate(); setWindowFlags(Qt::WindowFlags(Qt::FramelessWindowHint) | Qt::BypassWindowManagerHint | Qt::Popup | Qt::NoDropShadowWindowHint); setMouseTracking(true); hide(); setAttribute(Qt::WA_NoSystemBackground, true); setAttribute(Qt::WA_TranslucentBackground, true); }
bool MouseNavigator::handleMouseMoveEvent( QMouseEvent* mouseEvent ) { bool eventUsed = false; if( mouseEvent->buttons() == Qt::LeftButton ) { const QPoint movePoint = mView->viewportToColumns( mouseEvent->pos() ); if( mLMBPressed ) { if( mDragStartPossible ) { mDragStartTimer->stop(); // moved enough for a drag? if( (movePoint-mDragStartPoint).manhattanLength() > QApplication::startDragDistance() ) startDrag(); if( ! mView->isReadOnly() ) mView->viewport()->setCursor( Qt::IBeamCursor ); } else // selecting handleMouseMove( movePoint ); } else if( ! mView->isReadOnly() ) { ByteArrayTableRanges* tableRanges = mView->tableRanges(); // visual feedback for possible dragging const bool InSelection = tableRanges->hasSelection() && tableRanges->selectionIncludes( mView->indexByPoint(movePoint) ); mView->viewport()->setCursor( InSelection ? Qt::ArrowCursor : Qt::IBeamCursor ); } eventUsed = true; } return eventUsed ? true : AbstractMouseController::handleMouseMoveEvent( mouseEvent ); }
/** Handles events. Returns true if handled, false otherwise.*/ bool OrbitCameraManipulator::handle( const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa ) { switch( ea.getEventType() ) { case osgGA::GUIEventAdapter::FRAME: return handleFrame( ea, aa ); case osgGA::GUIEventAdapter::RESIZE: return handleResize( ea, aa ); default: break; } if( ea.getHandled() ) { return false; } computeRayPointer( ea, aa ); bool handled = false; switch( ea.getEventType() ) { case osgGA::GUIEventAdapter::MOVE: handled = handleMouseMove( ea, aa ); break; case osgGA::GUIEventAdapter::DRAG: handled = handleMouseDrag( ea, aa ); break; case osgGA::GUIEventAdapter::PUSH: handled = handleMousePush( ea, aa ); break; case osgGA::GUIEventAdapter::RELEASE: handled = handleMouseRelease( ea, aa ); break; case osgGA::GUIEventAdapter::KEYDOWN: handled = handleKeyDown( ea, aa ); break; case osgGA::GUIEventAdapter::KEYUP: m_control_key_down = false; handled = handleKeyUp( ea, aa ); break; case osgGA::GUIEventAdapter::SCROLL: if( _flags & PROCESS_MOUSE_WHEEL ) handled = handleMouseWheel( ea, aa ); else handled = false; break; default: handled = false; } return handled; }
bool WebPopupMenuImpl::handleInputEvent(const WebInputEvent& inputEvent) { if (!m_widget) return false; // FIXME: WebKit seems to always return false on mouse events methods. For // now we'll assume it has processed them (as we are only interested in // whether keyboard events are processed). switch (inputEvent.type) { case WebInputEvent::MouseMove: handleMouseMove(static_cast<const WebMouseEvent&>(inputEvent)); return true; case WebInputEvent::MouseLeave: handleMouseLeave(static_cast<const WebMouseEvent&>(inputEvent)); return true; case WebInputEvent::MouseWheel: handleMouseWheel(static_cast<const WebMouseWheelEvent&>(inputEvent)); return true; case WebInputEvent::MouseDown: handleMouseDown(static_cast<const WebMouseEvent&>(inputEvent)); return true; case WebInputEvent::MouseUp: handleMouseUp(static_cast<const WebMouseEvent&>(inputEvent)); return true; // In Windows, RawKeyDown only has information about the physical key, but // for "selection", we need the information about the character the key // translated into. For English, the physical key value and the character // value are the same, hence, "selection" works for English. But for other // languages, such as Hebrew, the character value is different from the // physical key value. Thus, without accepting Char event type which // contains the key's character value, the "selection" won't work for // non-English languages, such as Hebrew. case WebInputEvent::RawKeyDown: case WebInputEvent::KeyDown: case WebInputEvent::KeyUp: case WebInputEvent::Char: return handleKeyEvent(static_cast<const WebKeyboardEvent&>(inputEvent)); case WebInputEvent::TouchStart: case WebInputEvent::TouchMove: case WebInputEvent::TouchEnd: case WebInputEvent::TouchCancel: return handleTouchEvent(static_cast<const WebTouchEvent&>(inputEvent)); case WebInputEvent::GestureScrollBegin: case WebInputEvent::GestureScrollEnd: case WebInputEvent::GestureScrollUpdate: case WebInputEvent::GestureFlingStart: case WebInputEvent::GestureFlingCancel: case WebInputEvent::GestureTap: case WebInputEvent::GestureTapUnconfirmed: case WebInputEvent::GestureTapDown: case WebInputEvent::GestureShowPress: case WebInputEvent::GestureTapCancel: case WebInputEvent::GestureDoubleTap: case WebInputEvent::GestureTwoFingerTap: case WebInputEvent::GestureLongPress: case WebInputEvent::GestureLongTap: case WebInputEvent::GesturePinchBegin: case WebInputEvent::GesturePinchEnd: case WebInputEvent::GesturePinchUpdate: return handleGestureEvent(static_cast<const WebGestureEvent&>(inputEvent)); case WebInputEvent::Undefined: case WebInputEvent::MouseEnter: case WebInputEvent::ContextMenu: return false; } return false; }
void Engine::Run() { m_Running = true; SDL_Event event; const EventType keydown("keydownEvent"); while (m_Running) { SINGLETONINSTANCE(Profiler)->Begin("ClearSingleFrameAllocator"); m_SingleFrameAllocator->Clear(); SINGLETONINSTANCE(Profiler)->End("ClearSingleFrameAllocator"); SINGLETONINSTANCE(Profiler)->Begin("EventHandling"); while (SDL_PollEvent(&event)) { switch(event.type) { case SDL_QUIT: m_Running = false; break; case SDL_VIDEORESIZE: GetWindow()->Resize(event.resize.w, event.resize.h); break; case SDL_KEYDOWN: threadSafeQueEvent( IEventDataPointer( new EventData<SDL_KeyboardEvent>(event.key, keydown)) ); handleKeyPress(&event.key, event.type); break; case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONUP: handleMouseButtonPress(&event.button, event.type); break; case SDL_MOUSEMOTION: handleMouseMove(&event.motion, event.type); break; default: break; } } //Process eventQueue //10ms event handling safeProcessEventQueue(10); SINGLETONINSTANCE(Profiler)->End("EventHandling"); int currentTime = Time::GetCurrentMS(); int deltaT = (currentTime - lastTime); SINGLETONINSTANCE(Profiler)->Begin("StepPhysics"); //Step the physics system m_Physics->Step(deltaT); SINGLETONINSTANCE(Profiler)->End("StepPhysics"); SINGLETONINSTANCE(Profiler)->Begin("CameraUpdate"); m_Graphics->m_SceneGraph->m_CameraObject->Update(deltaT); SINGLETONINSTANCE(Profiler)->End("CameraUpdate"); // Display the graphics SINGLETONINSTANCE(Profiler)->Begin("Rendering"); m_Graphics->Render(); SINGLETONINSTANCE(Profiler)->End("Rendering"); // Calculate and show FPS in title bar m_FPSCalculator->SetCurrentTime(currentTime); //char *title = new char[sizeof(char) * 50]; char *title = (char *)m_SingleFrameAllocator->Allocate(sizeof(char) * 50); sprintf_s(title, (sizeof(char) * 50), "FPS: %d, Memory: %d bytes", m_FPSCalculator->GetFPS(), m_SingleFrameAllocator->GetMemoryUsage()); m_Window->SetWindowTitle(title); lastTime = currentTime; } // while(m_Running) }
void form::handleEvent(SDL_Event &e){ if(e.type == event_mousemotion){ if(!renderStatred) handleMouseMove(e); }else if(e.type == event_frameTick){ //pass the motion! SDL_Event me; int mx, my; int state = SDL_GetMouseState(&mx,&my); me.type = event_mousemotion; me.motion.x = mx; me.motion.y = my; me.motion.xrel = mx-prevMouseX; me.motion.yrel = my - prevMouseY; if(mx!=prevMouseX||my!=prevMouseY){ //only handle mouse moves if the mouse had been moved. handleMouseMove(me); prevMouseX = mx; prevMouseY = my; } //render. SDL_FillRect((SDL_Surface*)e.user.data1,NULL,_BACKCOLOUR); render((SDL_Surface*)e.user.data1); //tick frameTick(&e); }else if(e.type == SDL_MOUSEBUTTONDOWN){ if(_DEGUGG) cout<<"Mousedown\n"; //if(!within(left,top,width,height,e.button.x,e.button.y))return; //check if anything is already clicked and hence bound. int bound = max(leftBindedControl,max(rightBindedControl,middleBindedControl)); int control = -1; //determine which control this message is sent to. e.button.x-=left; e.button.y-=top; if(bound!=-2){ //yep. control = bound; }else{ //find which control this is landing on. for(int i = 0; i < children.size(); i++){ if(within(children[i]->left,children[i]->top,children[i]->width,children[i]->height,e.button.x,e.button.y)) control = i; } } //send mousedown to the control. if(_DEGUGG) cout<<"Control: "<<control<<"\n"; if(control==-1){ this->mouseDown(&e); this->callEvent(&e,e.type); }else if(control>=0){ children[control]->mouseDown(&e); children[control]->handleEvent(e); } //manage focus if(control!=focusedControl){ if(focusedControl>=0) children[focusedControl]->loseFocus(); if(focusedControl==-1) this->loseFocus(); focusedControl = control; if(control>=0) children[control]->getFocus(); if(focusedControl==-1) this->getFocus(); } if(e.button.button == SDL_BUTTON_LEFT) leftBindedControl = control; if(e.button.button == SDL_BUTTON_RIGHT) rightBindedControl = control; if(e.button.button == SDL_BUTTON_MIDDLE) middleBindedControl = control; }else if(e.type == SDL_MOUSEBUTTONUP){ //if(!within(left,top,width,height,e.button.x,e.button.y))return; //find which control this event belongs to. int control, type; if(e.button.button == SDL_BUTTON_LEFT){ control = leftBindedControl; type = event_Lclick; leftBindedControl = -2; } if(e.button.button == SDL_BUTTON_RIGHT){ control = rightBindedControl; type = event_Rclick; rightBindedControl = -2; } if(e.button.button == SDL_BUTTON_MIDDLE){ control = middleBindedControl; type = event_Mclick; middleBindedControl = -2; } //handle click if(_DEGUGG) cout<<control<<"\n"; e.button.x-=left; e.button.y-=top; if(control >= 0){ if(within(children[control]->left,children[control]->top, children[control]->width,children[control]->height,e.button.x,e.button.y)){ SDL_Event te; te.type = type; children[control]->handleEvent(te); } }else{ SDL_Event te; te.type = type; this->callEvent(&te,te.type); } //send mouseup message if(control>=0)children[control]->mouseUp(&e); else this->mouseUp(&e); if(control>=0)children[control]->handleEvent(e); else this->callEvent(&e,e.type); }else if(e.type == event_keydown||e.type==event_keyup){ //keys only send to focus. if(focusedControl>0) children[focusedControl]->handleEvent(e); if(focusedControl==-1) this->callEvent(&e,e.type); } }
void Framework::loop() { /* main loop variable */ bool done = false; /* used to collect events */ SDL_Event event; /* wait for events */ while (!done) { /* handle the events in the queue */ while (SDL_PollEvent(&event)) { switch(event.type) { case SDL_MOUSEMOTION: /* give away mouse movement with buttons pressed */ handleMouseMove(event.motion.xrel, event.motion.yrel, event.motion.state); break; case SDL_MOUSEBUTTONUP: /* handle mouse button release for serving */ if (event.button.button == SDL_BUTTON_LEFT) if (!paused) serveBall(); case SDL_KEYDOWN: /* handle key presses */ handleKeyPress(&event.key.keysym); break; case SDL_QUIT: /* handle quit requests */ done = true; break; case SDL_USEREVENT: switch (event.user.code) { case NET2_EXTERNAL: if (((TimerData*)event.user.data1)->timer == NULL) { /* this means our timer has gone inactive and we are pleased to stop our work! */ } else { ((TimerData*)event.user.data1)->receiver->action(((TimerData*)event.user.data1)->event); } break; case NET2_ERROREVENT: printf("Error: %s(%d)\n", NET2_GetEventError(&event), NET2_GetSocket(&event)); break; case NET2_UDPRECEIVEEVENT: UDPpacket *p = NULL; p = NET2_UDPRead(NET2_GetSocket(&event)); while (p != NULL) // if we get NULL we are done { Peer* peer = getCreatePeer(p->address.host); receivePacket(peer, (char*)p->data, p->len); NET2_UDPFreePacket(p); p = NET2_UDPRead(NET2_GetSocket(&event)); } break; } } } int tdiff = SDL_GetTicks() - lasttime; if (tdiff > timeunit) { frames++; xdiff += tdiff; // always greater 0 because we decided to let tdiff be greater than timeunit if ((xdiff >= 100)&&(xdiff >= timeunit * 20)) { output.updateFPS(frames * 1000.0 / xdiff); // There are 1000 ticks / second frames = 0; xdiff = 0; } lasttime += tdiff; // Game status code updateGame(tdiff); // Rendering code drawScene(); } } }
void MenuSystem::initMenu(MenuID menuID) { _items.clear(); memcpy(_vm->_screen->_frontScreen, _background->getPixels(), 640 * 400); switch (menuID) { case kMenuIdMain: drawString(0, 75, 320, 1, 229, _vm->getSysString(kStrWhatCanIDoForYou)); addClickTextItem(kItemIdLoad, 0, 116, 320, 0, _vm->getSysString(kStrLoad), 253, 255); addClickTextItem(kItemIdSave, 0, 136, 320, 0, _vm->getSysString(kStrSave), 253, 255); addClickTextItem(kItemIdToggleText, 0, 166, 320, 0, _vm->getSysString(_vm->_cfgText ? kStrTextOn : kStrTextOff), 253, 255); addClickTextItem(kItemIdToggleVoices, 0, 186, 320, 0, _vm->getSysString(_vm->_cfgVoices ? kStrVoicesOn : kStrVoicesOff), 253, 255); addClickTextItem(kItemIdVolumesMenu, 0, 216, 320, 0, _vm->getSysString(kStrVolume), 253, 255); addClickTextItem(kItemIdPlay, 0, 246, 320, 0, _vm->getSysString(kStrPlay), 253, 255); addClickTextItem(kItemIdQuit, 0, 276, 320, 0, _vm->getSysString(kStrQuit), 253, 255); break; case kMenuIdLoad: if (ConfMan.getBool("originalsaveload")) { shadeRect(80, 92, 440, 141, 226, 225); drawString(0, 75, 320, 1, 229, _vm->getSysString(kStrLoadGame)); addClickTextItem(kItemIdSavegameUp, 0, 156, 545, 1, "^", 253, 255); addClickTextItem(kItemIdSavegameDown, 0, 196, 545, 1, "\\", 253, 255); addClickTextItem(kItemIdCancel, 0, 276, 320, 0, _vm->getSysString(kStrCancel), 253, 255); for (int i = 1; i <= 7; i++) { Common::String saveDesc = Common::String::format("SAVEGAME %d", i); addClickTextItem((ItemID)(kItemIdSavegame1 + i - 1), 0, 116 + 20 * (i - 1), 300, 0, saveDesc.c_str(), 231, 234); } loadSavegamesList(); setSavegameCaptions(true); } else { GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); int slot = dialog->runModalWithCurrentTarget(); delete dialog; if (slot >= 0) _vm->requestLoadgame(slot); _running = false; } break; case kMenuIdSave: if (ConfMan.getBool("originalsaveload")) { shadeRect(80, 92, 440, 141, 226, 225); drawString(0, 75, 320, 1, 229, _vm->getSysString(kStrSaveGame)); addClickTextItem(kItemIdSavegameUp, 0, 156, 545, 1, "^", 253, 255); addClickTextItem(kItemIdSavegameDown, 0, 196, 545, 1, "\\", 253, 255); addClickTextItem(kItemIdCancel, 0, 276, 320, 0, _vm->getSysString(kStrCancel), 253, 255); for (int i = 1; i <= 7; i++) { Common::String saveDesc = Common::String::format("SAVEGAME %d", i); addClickTextItem((ItemID)(kItemIdSavegame1 + i - 1), 0, 116 + 20 * (i - 1), 300, 0, saveDesc.c_str(), 231, 234); } int newSlotNum = loadSavegamesList() + 1; _savegames.push_back(SavegameItem(newSlotNum, Common::String::format("GAME %04d", _savegames.size()))); setSavegameCaptions(true); } else { GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); int slot = dialog->runModalWithCurrentTarget(); Common::String desc = dialog->getResultString(); if (desc.empty()) { // Create our own description for the saved game, the user didn't enter one desc = dialog->createDefaultSaveDescription(slot); } if (slot >= 0) _vm->requestSavegame(slot, desc); _running = false; } break; case kMenuIdVolumes: drawString(0, 75, 320, 1, 229, _vm->getSysString(kStrAdjustVolume)); drawString(0, 131, 200, 0, 246, _vm->getSysString(kStrMaster)); drawString(0, 156, 200, 0, 244, _vm->getSysString(kStrVoices)); drawString(0, 181, 200, 0, 244, _vm->getSysString(kStrMusic)); drawString(0, 206, 200, 0, 244, _vm->getSysString(kStrSoundFx)); drawString(0, 231, 200, 0, 244, _vm->getSysString(kStrBackground)); addClickTextItem(kItemIdDone, 0, 276, 200, 0, _vm->getSysString(kStrDone), 253, 255); addClickTextItem(kItemIdCancel, 0, 276, 440, 0, _vm->getSysString(kStrCancel), 253, 255); addClickTextItem(kItemIdMasterDown, 0, 131 + 25 * 0, 348, 1, "[", 243, 246); addClickTextItem(kItemIdVoicesDown, 0, 131 + 25 * 1, 348, 1, "[", 243, 246); addClickTextItem(kItemIdMusicDown, 0, 131 + 25 * 2, 348, 1, "[", 243, 246); addClickTextItem(kItemIdSoundFXDown, 0, 131 + 25 * 3, 348, 1, "[", 243, 246); addClickTextItem(kItemIdBackgroundDown, 0, 131 + 25 * 4, 348, 1, "[", 243, 246); addClickTextItem(kItemIdMasterUp, 0, 131 + 25 * 0, 372, 1, "]", 243, 246); addClickTextItem(kItemIdVoicesUp, 0, 131 + 25 * 1, 372, 1, "]", 243, 246); addClickTextItem(kItemIdMusicUp, 0, 131 + 25 * 2, 372, 1, "]", 243, 246); addClickTextItem(kItemIdSoundFXUp, 0, 131 + 25 * 3, 372, 1, "]", 243, 246); addClickTextItem(kItemIdBackgroundUp, 0, 131 + 25 * 4, 372, 1, "]", 243, 246); drawVolumeBar(kItemIdMaster); drawVolumeBar(kItemIdVoices); drawVolumeBar(kItemIdMusic); drawVolumeBar(kItemIdSoundFX); drawVolumeBar(kItemIdBackground); break; default: break; } for (Common::Array<Item>::iterator iter = _items.begin(); iter != _items.end(); ++iter) { if ((*iter).enabled) drawItem((*iter).id, false); } // Check if the mouse is already over an item _currItemID = kItemIdNone; Common::Point mousePos = _vm->_system->getEventManager()->getMousePos(); handleMouseMove(mousePos.x, mousePos.y); }
void Framework::loop() { /* main loop variable */ bool done = false; /* used to collect events */ SDL_Event event; /* wait for events */ while (!done) { /* handle the events in the queue */ while (SDL_PollEvent(&event)) { switch(event.type) { case SDL_MOUSEMOTION: /* give away mouse movement with buttons pressed */ handleMouseMove(event.motion.xrel, event.motion.yrel, event.motion.state); break; case SDL_MOUSEBUTTONUP: /* handle mouse button release for serving */ if (event.button.button == SDL_BUTTON_LEFT) if (!paused) serveBall(); case SDL_KEYDOWN: /* handle key presses */ handleKeyPress(&event.key.keysym); break; case SDL_QUIT: /* handle quit requests */ done = true; break; case SDL_USEREVENT: if (((TimerData*)event.user.data1)->timer == NULL) { /* this means our timer has gone inactive and we are pleased to stop our work! */ } else { ((TimerData*)event.user.data1)->receiver->action(((TimerData*)event.user.data1)->event); } break; } } int tdiff = SDL_GetTicks() - lasttime; if (tdiff > timeunit) { frames++; xdiff += tdiff; // always greater 0 because we decided to let tdiff be greater than timeunit if ((xdiff >= 500)&&(xdiff >= timeunit * 25)) { output.updateFPS(frames * 1000.0 / xdiff); // There are 1000 ticks / second frames = 0; xdiff = 0; ping(); } lasttime += tdiff; // Multiplayer code doNetworking(); // Game status code updateGame(tdiff); // Rendering code drawScene(); } } }
void Menu::mouseMoveEvent(QMouseEvent *e) { handleMouseMove(e->globalPos()); }
void MouseNavigator::autoScrollTimerDone() { if( mLMBPressed ) handleMouseMove( mView->viewportToColumns(mView->viewport()->mapFromGlobal( QCursor::pos() )) ); }
void handleMouse(int button, int state, int x, int y) { handleMouseMove(x, y); }