1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef ZVISION_PUSH_TOGGLE_CONTROL_H 24 #define ZVISION_PUSH_TOGGLE_CONTROL_H 25 26 #include "zvision/scripting/control.h" 27 28 #include "common/rect.h" 29 #include "common/events.h" 30 #include "common/array.h" 31 32 namespace ZVision { 33 34 class PushToggleControl : public Control { 35 public: 36 PushToggleControl(ZVision *engine, uint32 key, Common::SeekableReadStream &stream); 37 ~PushToggleControl(); 38 39 /** 40 * Called when LeftMouse is pushed. Default is NOP. 41 * 42 * @param screenSpacePos The position of the mouse in screen space 43 * @param backgroundImageSpacePos The position of the mouse in background image space 44 */ 45 bool onMouseDown(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); 46 /** 47 * Called when LeftMouse is lifted. Calls ScriptManager::setStateValue(_key, 1); 48 * 49 * @param screenSpacePos The position of the mouse in screen space 50 * @param backgroundImageSpacePos The position of the mouse in background image space 51 */ 52 bool onMouseUp(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); 53 /** 54 * Called on every MouseMove. Tests if the mouse is inside _hotspot, and if so, sets the cursor. 55 * 56 * @param engine The base engine 57 * @param screenSpacePos The position of the mouse in screen space 58 * @param backgroundImageSpacePos The position of the mouse in background image space 59 * @return Was the cursor changed? 60 */ 61 bool onMouseMove(const Common::Point &screenSpacePos, const Common::Point &backgroundImageSpacePos); 62 63 private: 64 /** 65 * The area that will trigger the event 66 * This is in image space coordinates, NOT screen space 67 */ 68 Common::Array<Common::Rect> _hotspots; 69 /** The cursor to use when hovering over _hotspot */ 70 int _cursor; 71 /** Button maximal values count */ 72 uint _countTo; 73 74 Common::EventType _event; 75 76 bool contain(const Common::Point &point); 77 }; 78 79 } // End of namespace ZVision 80 81 #endif 82