01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: /**
18: * @author Dmitry A. Durnev
19: * @version $Revision$
20: */package org.apache.harmony.awt.wtk.windows;
21:
22: import org.apache.harmony.awt.wtk.NativeCursor;
23:
24: public class WinCursor implements NativeCursor {
25: final long hCursor;
26:
27: final WinEventQueue eventQueue;
28:
29: /*is this a system cursor?(such cursors are shared and can't be destroyed
30: by user*/
31: final boolean system;
32:
33: WinCursor(WinEventQueue eventQueue, final long handle,
34: final boolean system) {
35: hCursor = handle;
36: this .system = system;
37: this .eventQueue = eventQueue;
38: }
39:
40: WinCursor(WinEventQueue eventQueue, final long handle) {
41: this (eventQueue, handle, true); //create system(predefined) cursors by default
42: }
43:
44: /**
45: * @see org.apache.harmony.awt.wtk.NativeCursor#setCursor()
46: */
47: public void setCursor(long winID) {
48: WinEventQueue.Task task = new WinEventQueue.Task() {
49: @Override
50: public void perform() {
51: WinEventQueue.win32.SetCursor(hCursor);
52: }
53: };
54: eventQueue.performTask(task);
55: }
56:
57: /**
58: * @see org.apache.harmony.awt.wtk.NativeCursor#destroyCursor()
59: */
60: public void destroyCursor() {
61: if (!system) {
62: WinEventQueue.win32.DestroyCursor(hCursor);
63: }
64: }
65:
66: /**
67: * @see org.apache.harmony.awt.wtk.NativeCursor#getId()
68: */
69: public long getId() {
70: return hCursor;
71: }
72:
73: }
|