110 }
111 });
112 }
113
114 /*
115 * If true we operate in normal mode and nested runloop is executed in JavaRunLoopMode
116 * If false we operate in singleThreaded FX/AWT interop mode and nested loop uses NSDefaultRunLoopMode
117 */
118 private static final boolean inAWT;
119
120 public LWCToolkit() {
121 areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
122 //set system property if not yet assigned
123 System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
124 initAppkit(ThreadGroupUtils.getRootThreadGroup(), GraphicsEnvironment.isHeadless());
125 }
126
127 /*
128 * System colors with default initial values, overwritten by toolkit if system values differ and are available.
129 */
130 private final static int NUM_APPLE_COLORS = 3;
131 public final static int KEYBOARD_FOCUS_COLOR = 0;
132 public final static int INACTIVE_SELECTION_BACKGROUND_COLOR = 1;
133 public final static int INACTIVE_SELECTION_FOREGROUND_COLOR = 2;
134 private static int[] appleColors = {
135 0xFF808080, // keyboardFocusColor = Color.gray;
136 0xFFC0C0C0, // secondarySelectedControlColor
137 0xFF303030, // controlDarkShadowColor
138 };
139
140 private native void loadNativeColors(final int[] systemColors, final int[] appleColors);
141
142 @Override
143 protected void loadSystemColors(final int[] systemColors) {
144 if (systemColors == null) return;
145 loadNativeColors(systemColors, appleColors);
146 }
147
148 @SuppressWarnings("serial") // JDK implementation class
149 private static class AppleSpecificColor extends Color {
150 private final int index;
151 AppleSpecificColor(int index) {
152 super(appleColors[index]);
153 this.index = index;
664 * an {@code InvocationTargetException}
665 *
666 * @param event the event to check for an exception
667 * @throws InvocationTargetException if exception occurred when event was processed
668 */
669 private static void checkException(InvocationEvent event) throws InvocationTargetException {
670 Throwable eventException = event.getException();
671 if (eventException == null) return;
672
673 if (eventException instanceof UndeclaredThrowableException) {
674 eventException = ((UndeclaredThrowableException)eventException).getUndeclaredThrowable();
675 }
676 throw new InvocationTargetException(eventException);
677 }
678
679 /**
680 * Schedules a {@code Runnable} execution on the Appkit thread after a delay
681 * @param r a {@code Runnable} to execute
682 * @param delay a delay in milliseconds
683 */
684 native static void performOnMainThreadAfterDelay(Runnable r, long delay);
685
686 // DnD support
687
688 @Override
689 public DragSourceContextPeer createDragSourceContextPeer(
690 DragGestureEvent dge) throws InvalidDnDOperationException {
691 final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent());
692 if (f != null) {
693 return f.createDragSourceContextPeer(dge);
694 }
695
696 return CDragSourceContextPeer.createDragSourceContextPeer(dge);
697 }
698
699 @Override
700 @SuppressWarnings("unchecked")
701 public <T extends DragGestureRecognizer> T createDragGestureRecognizer(
702 Class<T> abstractRecognizerClass, DragSource ds, Component c,
703 int srcActions, DragGestureListener dgl) {
704 final LightweightFrame f = SunToolkit.getLightweightFrame(c);
|
110 }
111 });
112 }
113
114 /*
115 * If true we operate in normal mode and nested runloop is executed in JavaRunLoopMode
116 * If false we operate in singleThreaded FX/AWT interop mode and nested loop uses NSDefaultRunLoopMode
117 */
118 private static final boolean inAWT;
119
120 public LWCToolkit() {
121 areExtraMouseButtonsEnabled = Boolean.parseBoolean(System.getProperty("sun.awt.enableExtraMouseButtons", "true"));
122 //set system property if not yet assigned
123 System.setProperty("sun.awt.enableExtraMouseButtons", ""+areExtraMouseButtonsEnabled);
124 initAppkit(ThreadGroupUtils.getRootThreadGroup(), GraphicsEnvironment.isHeadless());
125 }
126
127 /*
128 * System colors with default initial values, overwritten by toolkit if system values differ and are available.
129 */
130 private static final int NUM_APPLE_COLORS = 3;
131 public static final int KEYBOARD_FOCUS_COLOR = 0;
132 public static final int INACTIVE_SELECTION_BACKGROUND_COLOR = 1;
133 public static final int INACTIVE_SELECTION_FOREGROUND_COLOR = 2;
134 private static int[] appleColors = {
135 0xFF808080, // keyboardFocusColor = Color.gray;
136 0xFFC0C0C0, // secondarySelectedControlColor
137 0xFF303030, // controlDarkShadowColor
138 };
139
140 private native void loadNativeColors(final int[] systemColors, final int[] appleColors);
141
142 @Override
143 protected void loadSystemColors(final int[] systemColors) {
144 if (systemColors == null) return;
145 loadNativeColors(systemColors, appleColors);
146 }
147
148 @SuppressWarnings("serial") // JDK implementation class
149 private static class AppleSpecificColor extends Color {
150 private final int index;
151 AppleSpecificColor(int index) {
152 super(appleColors[index]);
153 this.index = index;
664 * an {@code InvocationTargetException}
665 *
666 * @param event the event to check for an exception
667 * @throws InvocationTargetException if exception occurred when event was processed
668 */
669 private static void checkException(InvocationEvent event) throws InvocationTargetException {
670 Throwable eventException = event.getException();
671 if (eventException == null) return;
672
673 if (eventException instanceof UndeclaredThrowableException) {
674 eventException = ((UndeclaredThrowableException)eventException).getUndeclaredThrowable();
675 }
676 throw new InvocationTargetException(eventException);
677 }
678
679 /**
680 * Schedules a {@code Runnable} execution on the Appkit thread after a delay
681 * @param r a {@code Runnable} to execute
682 * @param delay a delay in milliseconds
683 */
684 static native void performOnMainThreadAfterDelay(Runnable r, long delay);
685
686 // DnD support
687
688 @Override
689 public DragSourceContextPeer createDragSourceContextPeer(
690 DragGestureEvent dge) throws InvalidDnDOperationException {
691 final LightweightFrame f = SunToolkit.getLightweightFrame(dge.getComponent());
692 if (f != null) {
693 return f.createDragSourceContextPeer(dge);
694 }
695
696 return CDragSourceContextPeer.createDragSourceContextPeer(dge);
697 }
698
699 @Override
700 @SuppressWarnings("unchecked")
701 public <T extends DragGestureRecognizer> T createDragGestureRecognizer(
702 Class<T> abstractRecognizerClass, DragSource ds, Component c,
703 int srcActions, DragGestureListener dgl) {
704 final LightweightFrame f = SunToolkit.getLightweightFrame(c);
|