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 java.awt.Point;
23:
24: import org.apache.harmony.awt.nativebridge.windows.Win32;
25: import org.apache.harmony.awt.nativebridge.windows.WindowsDefs;
26: import org.apache.harmony.awt.wtk.NativeMouseInfo;
27:
28: /**
29: * Implementation of NativeMouseInfo for Windows platform.
30: */
31: public class WinMouseInfo implements NativeMouseInfo {
32:
33: private static final Win32 win32 = Win32.getInstance();
34:
35: /**
36: * @see org.apache.harmony.awt.wtk.NativeMouseInfo#getLocation()
37: */
38: public Point getLocation() {
39: Win32.POINT pt = WinEventQueue.win32.createPOINT(false);
40: win32.GetCursorPos(pt);
41: return new Point(pt.get_x(), pt.get_y());
42: }
43:
44: /**
45: * @see org.apache.harmony.awt.wtk.NativeMouseInfo#getNumberOfButtons()
46: */
47: public int getNumberOfButtons() {
48: int nButtons = win32
49: .GetSystemMetrics(WindowsDefs.SM_CMOUSEBUTTONS);
50: return ((nButtons > 0) ? nButtons : -1);
51: }
52:
53: }
|