1 /* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef _ANDROID_VIEW_POINTER_ICON_H 18 #define _ANDROID_VIEW_POINTER_ICON_H 19 20 #include "jni.h" 21 22 #include <vector> 23 24 #include <utils/Errors.h> 25 #include <SkBitmap.h> 26 27 namespace android { 28 29 /* Pointer icon styles. 30 * Must match the definition in android.view.PointerIcon. 31 */ 32 enum { 33 POINTER_ICON_STYLE_CUSTOM = -1, 34 POINTER_ICON_STYLE_NULL = 0, 35 POINTER_ICON_STYLE_ARROW = 1000, 36 POINTER_ICON_STYLE_CONTEXT_MENU = 1001, 37 POINTER_ICON_STYLE_HAND = 1002, 38 POINTER_ICON_STYLE_HELP = 1003, 39 POINTER_ICON_STYLE_WAIT = 1004, 40 POINTER_ICON_STYLE_CELL = 1006, 41 POINTER_ICON_STYLE_CROSSHAIR = 1007, 42 POINTER_ICON_STYLE_TEXT = 1008, 43 POINTER_ICON_STYLE_VERTICAL_TEXT = 1009, 44 POINTER_ICON_STYLE_ALIAS = 1010, 45 POINTER_ICON_STYLE_COPY = 1011, 46 POINTER_ICON_STYLE_NO_DROP = 1012, 47 POINTER_ICON_STYLE_ALL_SCROLL = 1013, 48 POINTER_ICON_STYLE_HORIZONTAL_DOUBLE_ARROW = 1014, 49 POINTER_ICON_STYLE_VERTICAL_DOUBLE_ARROW = 1015, 50 POINTER_ICON_STYLE_TOP_RIGHT_DOUBLE_ARROW = 1016, 51 POINTER_ICON_STYLE_TOP_LEFT_DOUBLE_ARROW = 1017, 52 POINTER_ICON_STYLE_ZOOM_IN = 1018, 53 POINTER_ICON_STYLE_ZOOM_OUT = 1019, 54 POINTER_ICON_STYLE_GRAB = 1020, 55 POINTER_ICON_STYLE_GRABBING = 1021, 56 57 POINTER_ICON_STYLE_SPOT_HOVER = 2000, 58 POINTER_ICON_STYLE_SPOT_TOUCH = 2001, 59 POINTER_ICON_STYLE_SPOT_ANCHOR = 2002, 60 }; 61 62 /* 63 * Describes a pointer icon. 64 */ 65 struct PointerIcon { PointerIconPointerIcon66 inline PointerIcon() { 67 reset(); 68 } 69 70 int32_t style; 71 SkBitmap bitmap; 72 float hotSpotX; 73 float hotSpotY; 74 std::vector<SkBitmap> bitmapFrames; 75 int32_t durationPerFrame; 76 isNullIconPointerIcon77 inline bool isNullIcon() { 78 return style == POINTER_ICON_STYLE_NULL; 79 } 80 resetPointerIcon81 inline void reset() { 82 style = POINTER_ICON_STYLE_NULL; 83 bitmap.reset(); 84 hotSpotX = 0; 85 hotSpotY = 0; 86 bitmapFrames.clear(); 87 durationPerFrame = 0; 88 } 89 }; 90 91 /* Gets a system pointer icon with the specified style. */ 92 extern jobject android_view_PointerIcon_getSystemIcon(JNIEnv* env, 93 jobject contextObj, int32_t style); 94 95 /* Loads the bitmap associated with a pointer icon. 96 * If pointerIconObj is NULL, returns OK and a pointer icon with POINTER_ICON_STYLE_NULL. */ 97 extern status_t android_view_PointerIcon_load(JNIEnv* env, 98 jobject pointerIconObj, jobject contextObj, PointerIcon* outPointerIcon); 99 100 /* Obtain the data of pointerIconObj and put to outPointerIcon. */ 101 extern status_t android_view_PointerIcon_getLoadedIcon(JNIEnv* env, jobject pointerIconObj, 102 PointerIcon* outPointerIcon); 103 104 105 /* Loads the bitmap associated with a pointer icon by style. 106 * If pointerIconObj is NULL, returns OK and a pointer icon with POINTER_ICON_STYLE_NULL. */ 107 extern status_t android_view_PointerIcon_loadSystemIcon(JNIEnv* env, 108 jobject contextObj, int32_t style, PointerIcon* outPointerIcon); 109 110 } // namespace android 111 112 #endif // _ANDROID_OS_POINTER_ICON_H 113