blob: 3bfd64526ad6747ae57a2473f410614bafd43b31 [file] [log] [blame]
Jeff Brown2352b972011-04-12 22:39:53 -07001/*
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 <utils/Errors.h>
23#include <SkBitmap.h>
24
25namespace android {
26
27/* Pointer icon styles.
28 * Must match the definition in android.view.PointerIcon.
29 */
30enum {
31 POINTER_ICON_STYLE_CUSTOM = -1,
32 POINTER_ICON_STYLE_NULL = 0,
33 POINTER_ICON_STYLE_ARROW = 1000,
34 POINTER_ICON_STYLE_SPOT_HOVER = 2000,
35 POINTER_ICON_STYLE_SPOT_TOUCH = 2001,
36 POINTER_ICON_STYLE_SPOT_ANCHOR = 2002,
37};
38
39/*
40 * Describes a pointer icon.
41 */
42struct PointerIcon {
43 inline PointerIcon() {
44 reset();
45 }
46
47 int32_t style;
48 SkBitmap bitmap;
49 float hotSpotX;
50 float hotSpotY;
51
52 inline bool isNullIcon() {
53 return style == POINTER_ICON_STYLE_NULL;
54 }
55
56 inline void reset() {
57 style = POINTER_ICON_STYLE_NULL;
58 bitmap.reset();
59 hotSpotX = 0;
60 hotSpotY = 0;
61 }
62};
63
64/* Gets a system pointer icon with the specified style. */
65extern jobject android_view_PointerIcon_getSystemIcon(JNIEnv* env,
66 jobject contextObj, int32_t style);
67
68/* Loads the bitmap associated with a pointer icon.
69 * If pointerIconObj is NULL, returns OK and a pointer icon with POINTER_ICON_STYLE_NULL. */
70extern status_t android_view_PointerIcon_load(JNIEnv* env,
71 jobject pointerIconObj, jobject contextObj, PointerIcon* outPointerIcon);
72
73/* Loads the bitmap associated with a pointer icon by style.
74 * If pointerIconObj is NULL, returns OK and a pointer icon with POINTER_ICON_STYLE_NULL. */
75extern status_t android_view_PointerIcon_loadSystemIcon(JNIEnv* env,
76 jobject contextObj, int32_t style, PointerIcon* outPointerIcon);
77
78} // namespace android
79
80#endif // _ANDROID_OS_POINTER_ICON_H