36 import java.awt.peer.*;
37 import java.lang.reflect.*;
38 import java.security.*;
39 import java.util.*;
40 import java.util.concurrent.Callable;
41
42 import sun.awt.*;
43 import sun.lwawt.*;
44 import sun.lwawt.LWWindowPeer.PeerType;
45 import sun.security.action.GetBooleanAction;
46
47 class NamedCursor extends Cursor {
48 NamedCursor(String name) {
49 super(name);
50 }
51 }
52
53 /**
54 * Mac OS X Cocoa-based AWT Toolkit.
55 */
56 public class LWCToolkit extends LWToolkit {
57 // While it is possible to enumerate all mouse devices
58 // and query them for the number of buttons, the code
59 // that does it is rather complex. Instead, we opt for
60 // the easy way and just support up to 5 mouse buttons,
61 // like Windows.
62 private static final int BUTTONS = 5;
63
64 private static native void initIDs();
65
66 static native void executeNextAppKitEvent();
67
68 private static CInputMethodDescriptor sInputMethodDescriptor;
69
70 static {
71 System.err.flush();
72 java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<Object>() {
73 public Object run() {
74 System.loadLibrary("awt");
75 System.loadLibrary("fontmanager");
76 return null;
261 {
262 public OSXPlatformFont(String name, int style)
263 {
264 super(name, style);
265 }
266 protected char getMissingGlyphCharacter()
267 {
268 // Follow up for real implementation
269 return (char)0xfff8; // see http://developer.apple.com/fonts/LastResortFont/
270 }
271 }
272 public FontPeer getFontPeer(String name, int style) {
273 return new OSXPlatformFont(name, style);
274 }
275
276 @Override
277 protected MouseInfoPeer createMouseInfoPeerImpl() {
278 return new CMouseInfoPeer();
279 }
280
281
282 @Override
283 protected int getScreenHeight() {
284 return GraphicsEnvironment.getLocalGraphicsEnvironment()
285 .getDefaultScreenDevice().getDefaultConfiguration().getBounds().height;
286 }
287
288 @Override
289 protected int getScreenWidth() {
290 return GraphicsEnvironment.getLocalGraphicsEnvironment()
291 .getDefaultScreenDevice().getDefaultConfiguration().getBounds().width;
292 }
293
294 @Override
295 protected void initializeDesktopProperties() {
296 super.initializeDesktopProperties();
297 Map <Object, Object> fontHints = new HashMap<Object, Object>();
298 fontHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
299 fontHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
300 desktopProperties.put(SunToolkit.DESKTOPFONTHINTS, fontHints);
301 desktopProperties.put("awt.mouse.numButtons", BUTTONS);
316 desktopProperties.put("DnD.Cursor.MoveNoDrop", new NamedCursor("DnD.Cursor.MoveNoDrop"));
317 desktopProperties.put("DnD.Cursor.LinkNoDrop", new NamedCursor("DnD.Cursor.LinkNoDrop"));
318
319 }
320
321
322 /*
323 * The method returns true if some events were processed during that timeout.
324 * @see sun.awt.SunToolkit#syncNativeQueue(long)
325 */
326 @Override
327 protected boolean syncNativeQueue(long timeout) {
328 return nativeSyncQueue(timeout);
329 }
330
331 @Override
332 public native void beep();
333
334 @Override
335 public int getScreenResolution() throws HeadlessException {
336 return ((CGraphicsDevice) GraphicsEnvironment
337 .getLocalGraphicsEnvironment().getDefaultScreenDevice()).getScreenResolution();
338 }
339
340 @Override
341 public Insets getScreenInsets(final GraphicsConfiguration gc) {
342 final CGraphicsConfig cgc = (CGraphicsConfig) gc;
343 final int displayId = cgc.getDevice().getCoreGraphicsScreen();
344 Rectangle fullScreen, workArea;
345 final long screen = CWrapper.NSScreen.screenByDisplayId(displayId);
346 try {
347 fullScreen = CWrapper.NSScreen.frame(screen).getBounds();
348 workArea = CWrapper.NSScreen.visibleFrame(screen).getBounds();
349 } finally {
350 CWrapper.NSObject.release(screen);
351 }
352 // Convert between Cocoa's coordinate system and Java.
353 int bottom = workArea.y - fullScreen.y;
354 int top = fullScreen.height - workArea.height - bottom;
355 int left = workArea.x - fullScreen.x;
356 int right = fullScreen.width - workArea.width - left;
357 return new Insets(top, left, bottom, right);
|
36 import java.awt.peer.*;
37 import java.lang.reflect.*;
38 import java.security.*;
39 import java.util.*;
40 import java.util.concurrent.Callable;
41
42 import sun.awt.*;
43 import sun.lwawt.*;
44 import sun.lwawt.LWWindowPeer.PeerType;
45 import sun.security.action.GetBooleanAction;
46
47 class NamedCursor extends Cursor {
48 NamedCursor(String name) {
49 super(name);
50 }
51 }
52
53 /**
54 * Mac OS X Cocoa-based AWT Toolkit.
55 */
56 public final class LWCToolkit extends LWToolkit {
57 // While it is possible to enumerate all mouse devices
58 // and query them for the number of buttons, the code
59 // that does it is rather complex. Instead, we opt for
60 // the easy way and just support up to 5 mouse buttons,
61 // like Windows.
62 private static final int BUTTONS = 5;
63
64 private static native void initIDs();
65
66 static native void executeNextAppKitEvent();
67
68 private static CInputMethodDescriptor sInputMethodDescriptor;
69
70 static {
71 System.err.flush();
72 java.security.AccessController.doPrivileged(new java.security.PrivilegedAction<Object>() {
73 public Object run() {
74 System.loadLibrary("awt");
75 System.loadLibrary("fontmanager");
76 return null;
261 {
262 public OSXPlatformFont(String name, int style)
263 {
264 super(name, style);
265 }
266 protected char getMissingGlyphCharacter()
267 {
268 // Follow up for real implementation
269 return (char)0xfff8; // see http://developer.apple.com/fonts/LastResortFont/
270 }
271 }
272 public FontPeer getFontPeer(String name, int style) {
273 return new OSXPlatformFont(name, style);
274 }
275
276 @Override
277 protected MouseInfoPeer createMouseInfoPeerImpl() {
278 return new CMouseInfoPeer();
279 }
280
281 @Override
282 protected int getScreenHeight() {
283 return GraphicsEnvironment.getLocalGraphicsEnvironment()
284 .getDefaultScreenDevice().getDefaultConfiguration().getBounds().height;
285 }
286
287 @Override
288 protected int getScreenWidth() {
289 return GraphicsEnvironment.getLocalGraphicsEnvironment()
290 .getDefaultScreenDevice().getDefaultConfiguration().getBounds().width;
291 }
292
293 @Override
294 protected void initializeDesktopProperties() {
295 super.initializeDesktopProperties();
296 Map <Object, Object> fontHints = new HashMap<Object, Object>();
297 fontHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
298 fontHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
299 desktopProperties.put(SunToolkit.DESKTOPFONTHINTS, fontHints);
300 desktopProperties.put("awt.mouse.numButtons", BUTTONS);
315 desktopProperties.put("DnD.Cursor.MoveNoDrop", new NamedCursor("DnD.Cursor.MoveNoDrop"));
316 desktopProperties.put("DnD.Cursor.LinkNoDrop", new NamedCursor("DnD.Cursor.LinkNoDrop"));
317
318 }
319
320
321 /*
322 * The method returns true if some events were processed during that timeout.
323 * @see sun.awt.SunToolkit#syncNativeQueue(long)
324 */
325 @Override
326 protected boolean syncNativeQueue(long timeout) {
327 return nativeSyncQueue(timeout);
328 }
329
330 @Override
331 public native void beep();
332
333 @Override
334 public int getScreenResolution() throws HeadlessException {
335 return (int) ((CGraphicsDevice) GraphicsEnvironment
336 .getLocalGraphicsEnvironment().getDefaultScreenDevice())
337 .getXResolution();
338 }
339
340 @Override
341 public Insets getScreenInsets(final GraphicsConfiguration gc) {
342 final CGraphicsConfig cgc = (CGraphicsConfig) gc;
343 final int displayId = cgc.getDevice().getCoreGraphicsScreen();
344 Rectangle fullScreen, workArea;
345 final long screen = CWrapper.NSScreen.screenByDisplayId(displayId);
346 try {
347 fullScreen = CWrapper.NSScreen.frame(screen).getBounds();
348 workArea = CWrapper.NSScreen.visibleFrame(screen).getBounds();
349 } finally {
350 CWrapper.NSObject.release(screen);
351 }
352 // Convert between Cocoa's coordinate system and Java.
353 int bottom = workArea.y - fullScreen.y;
354 int top = fullScreen.height - workArea.height - bottom;
355 int left = workArea.x - fullScreen.x;
356 int right = fullScreen.width - workArea.width - left;
357 return new Insets(top, left, bottom, right);
|