1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef MOUSE_EVENT_H 17 #define MOUSE_EVENT_H 18 19 #include "mmi_point.h" 20 #include "composite_event.h" 21 22 namespace OHOS { 23 struct MouseProperty { 24 int action; 25 int actionButton; 26 int pressedButtons; 27 MmiPoint mmiPoint; 28 float xOffset; 29 float yOffset; 30 float cursorDelta; 31 float scrollingDelta; 32 uint32_t scrollType; 33 }; 34 35 class MouseEvent : public CompositeEvent { 36 public: 37 void Initialize(MultimodalProperty &multiProperty, MouseProperty &mouseProperty); 38 39 virtual int GetAction(); 40 41 virtual int GetActionButton(); 42 43 virtual int GetPressedButtons(); 44 45 virtual MmiPoint GetCursor(); 46 47 virtual void SetCursorOffset(float offsetX, float offsetY); 48 49 virtual float GetCursorDelta(int axis); 50 51 virtual float GetScrollingDelta(int axis); 52 53 bool Marshalling(Parcel &parcel) const override; 54 static MouseEvent *Unmarshalling(Parcel &parcel); 55 56 static constexpr int NONE = 0; 57 58 static constexpr int PRESS = 1; 59 60 static constexpr int RELEASE = 2; 61 62 static constexpr int MOVE = 3; 63 64 static constexpr int HOVER_ENTER = 4; 65 66 static constexpr int HOVER_MOVE = 5; 67 68 static constexpr int HOVER_EXIT = 6; 69 70 static constexpr int SCROLL = 7; 71 72 static constexpr int NONE_BUTTON = 0; 73 74 static constexpr int LEFT_BUTTON = 1 << 0; 75 76 static constexpr int RIGHT_BUTTON = 1 << 1; 77 78 static constexpr int MIDDLE_BUTTON = 1 << 2; 79 80 static constexpr int BACK_BUTTON = 1 << 3; 81 82 static constexpr int FORWARD_BUTTON = 1 << 4; 83 84 static constexpr int AXIS_X = 0; 85 86 static constexpr int AXIS_Y = 1; 87 88 static constexpr int AXIS_Z = 2; 89 90 static constexpr int VERTICAL_SCROLL = 0; 91 92 static constexpr int HORIZONTAL_SCROLL = 1; 93 protected: 94 MouseProperty mouseProperty_; 95 }; 96 } // namespace OHOS 97 #endif // MOUSE_EVENT_H 98