void W_ReleaseView(WMView * view) { view->refCount--; if (view->refCount < 1) { destroyView(view); } }
void W_DestroyView(W_View * view) { view->refCount--; if (view->refCount < 1) { destroyView(view); } }
bool OrionMenuView::onEvent(M4EventType eventType, int param, int x, int y, bool &captureEvents) { static Common::Point movingPos(0, 0); static bool movingFlag = false; bool handledFlag = false; int localX, localY; MenuObjectsIterator i; if (!_screenFlags.visible) return false; if (!movingFlag) captureEvents = false; // If the escape key is pressed, then pass onto the Escape handler if (eventType == KEVENT_KEY) { if ((param == Common::KEYCODE_ESCAPE) && (_escapeHandler != NULL)) { // Execute the Escape handler function _currentItem = NULL; captureEvents = false; _escapeHandler(this); destroyView(); return true; } if (((param == Common::KEYCODE_RETURN) || (param == Common::KEYCODE_KP_ENTER)) && (_returnHandler != NULL)) { // Execute the Return handler function _currentItem = NULL; captureEvents = false; _returnHandler(this); return true; } MenuTextField *textItem = (MenuTextField *) getItem(SLTAG_TEXTFIELD); if (textItem && textItem->onEvent(KEVENT_KEY, param, x, y, _currentItem)) return true; } // Convert the screen position to a relative position within the menu surface localX = x - _coords.left; localY = y - _coords.top; // If there is an active object handling events, pass it on until it releases control if (_currentItem) { handledFlag = _currentItem->onEvent(eventType, param, localX, localY, _currentItem); if (_closeFlag) { // Dialog has been flagged to be closed captureEvents = false; destroyView(); return true; } if (_currentItem) { captureEvents = (Common::find(_menuObjects.begin(), _menuObjects.end(), _currentItem) != _menuObjects.end()); if (!captureEvents) // The menu object is no longer active, so reset current item _currentItem = NULL; } else { captureEvents = false; } if (handledFlag) return true; } if (eventType == KEVENT_KEY) { // Handle keypresses by looping through the item list to see if any of them want it for (i = _menuObjects.begin(); (i != _menuObjects.end()) && !handledFlag; ++i) { MenuObject *menuObj = *i; MenuObject *dummyItem; handledFlag = menuObj->onEvent(eventType, param, localX, localY, dummyItem); } return handledFlag; } else { // Handle mouse events by scanning the item list to see if the cursor is within any for (i = _menuObjects.begin(); (i != _menuObjects.end()) && !handledFlag; ++i) { MenuObject *menuObj = *i; if (menuObj->isInside(localX, localY)) { // Found an item, so pass it the event menuObj->onEvent(eventType, param, localX, localY, _currentItem); if (_closeFlag) { // Dialog has been flagged to be closed captureEvents = false; destroyView(); return true; } if (_currentItem) { captureEvents = (Common::find(_menuObjects.begin(), _menuObjects.end(), _currentItem) != _menuObjects.end()); if (!captureEvents) // The menu object is no longer active, so reset current item _currentItem = NULL; } else { captureEvents = false; } return true; } } } // None of the items have handled the event, so fall back on menu-wide event handling switch (eventType) { case MEVENT_LEFT_CLICK: case MEVENT_DOUBLECLICK: if (!_screenFlags.immovable) { // Move the entire dialog captureEvents = true; movingFlag = true; movingPos.x = x; movingPos.y = y; } break; case MEVENT_LEFT_DRAG: case MEVENT_DOUBLECLICK_DRAG: if (movingFlag) { moveRelative(x - movingPos.x, y - movingPos.y); movingPos.x = x; movingPos.y = y; } break; case MEVENT_LEFT_RELEASE: case MEVENT_DOUBLECLICK_RELEASE: captureEvents = false; movingFlag = false; break; default: break; } return true; }