77 private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr); |
77 private static native void nativeSetNSWindowMenuBar(long nsWindowPtr, long menuBarPtr); |
78 private static native Insets nativeGetNSWindowInsets(long nsWindowPtr); |
78 private static native Insets nativeGetNSWindowInsets(long nsWindowPtr); |
79 private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h); |
79 private static native void nativeSetNSWindowBounds(long nsWindowPtr, double x, double y, double w, double h); |
80 private static native void nativeSetNSWindowLocationByPlatform(long nsWindowPtr); |
80 private static native void nativeSetNSWindowLocationByPlatform(long nsWindowPtr); |
81 private static native void nativeSetNSWindowStandardFrame(long nsWindowPtr, |
81 private static native void nativeSetNSWindowStandardFrame(long nsWindowPtr, |
82 double x, double y, double w, double h); |
82 double x, double y, double w, double h); |
83 private static native void nativeSetNSWindowMinMax(long nsWindowPtr, double minW, double minH, double maxW, double maxH); |
83 private static native void nativeSetNSWindowMinMax(long nsWindowPtr, double minW, double minH, double maxW, double maxH); |
84 private static native void nativePushNSWindowToBack(long nsWindowPtr); |
84 private static native void nativePushNSWindowToBack(long nsWindowPtr); |
85 private static native void nativePushNSWindowToFront(long nsWindowPtr); |
85 private static native void nativePushNSWindowToFront(long nsWindowPtr); |
86 private static native void nativeSetNSWindowTitle(long nsWindowPtr, String title); |
86 private static native void nativeSetNSWindowTitle(long nsWindowPtr, String title); |
87 private static native void nativeRevalidateNSWindowShadow(long nsWindowPtr); |
87 private static native void nativeRevalidateNSWindowShadow(long nsWindowPtr); |
187 return (bits & mask) != 0; |
187 return (bits & mask) != 0; |
188 } |
188 } |
189 |
189 |
190 @SuppressWarnings({"unchecked", "rawtypes"}) |
190 @SuppressWarnings({"unchecked", "rawtypes"}) |
191 static ClientPropertyApplicator<JRootPane, CPlatformWindow> CLIENT_PROPERTY_APPLICATOR = new ClientPropertyApplicator<JRootPane, CPlatformWindow>(new Property[] { |
191 static ClientPropertyApplicator<JRootPane, CPlatformWindow> CLIENT_PROPERTY_APPLICATOR = new ClientPropertyApplicator<JRootPane, CPlatformWindow>(new Property[] { |
192 new Property<CPlatformWindow>(WINDOW_DOCUMENT_MODIFIED) { public void applyProperty(final CPlatformWindow c, final Object value) { |
192 new Property<CPlatformWindow>(WINDOW_DOCUMENT_MODIFIED) { public void applyProperty(final CPlatformWindow c, final Object value) { |
193 c.setStyleBits(DOCUMENT_MODIFIED, value == null ? false : Boolean.parseBoolean(value.toString())); |
193 c.setStyleBits(DOCUMENT_MODIFIED, value == null ? false : Boolean.parseBoolean(value.toString())); |
194 }}, |
194 }}, |
195 new Property<CPlatformWindow>(WINDOW_BRUSH_METAL_LOOK) { public void applyProperty(final CPlatformWindow c, final Object value) { |
195 new Property<CPlatformWindow>(WINDOW_BRUSH_METAL_LOOK) { public void applyProperty(final CPlatformWindow c, final Object value) { |
196 c.setStyleBits(TEXTURED, Boolean.parseBoolean(value.toString())); |
196 c.setStyleBits(TEXTURED, Boolean.parseBoolean(value.toString())); |
197 }}, |
197 }}, |
198 new Property<CPlatformWindow>(WINDOW_ALPHA) { public void applyProperty(final CPlatformWindow c, final Object value) { |
198 new Property<CPlatformWindow>(WINDOW_ALPHA) { public void applyProperty(final CPlatformWindow c, final Object value) { |
199 c.target.setOpacity(value == null ? 1.0f : Float.parseFloat(value.toString())); |
199 c.target.setOpacity(value == null ? 1.0f : Float.parseFloat(value.toString())); |
200 }}, |
200 }}, |
201 new Property<CPlatformWindow>(WINDOW_SHADOW) { public void applyProperty(final CPlatformWindow c, final Object value) { |
201 new Property<CPlatformWindow>(WINDOW_SHADOW) { public void applyProperty(final CPlatformWindow c, final Object value) { |
202 c.setStyleBits(HAS_SHADOW, value == null ? true : Boolean.parseBoolean(value.toString())); |
202 c.setStyleBits(HAS_SHADOW, value == null ? true : Boolean.parseBoolean(value.toString())); |
203 }}, |
203 }}, |
204 new Property<CPlatformWindow>(WINDOW_MINIMIZABLE) { public void applyProperty(final CPlatformWindow c, final Object value) { |
204 new Property<CPlatformWindow>(WINDOW_MINIMIZABLE) { public void applyProperty(final CPlatformWindow c, final Object value) { |
205 c.setStyleBits(MINIMIZABLE, Boolean.parseBoolean(value.toString())); |
205 c.setStyleBits(MINIMIZABLE, Boolean.parseBoolean(value.toString())); |
206 }}, |
206 }}, |
207 new Property<CPlatformWindow>(WINDOW_CLOSEABLE) { public void applyProperty(final CPlatformWindow c, final Object value) { |
207 new Property<CPlatformWindow>(WINDOW_CLOSEABLE) { public void applyProperty(final CPlatformWindow c, final Object value) { |
208 c.setStyleBits(CLOSEABLE, Boolean.parseBoolean(value.toString())); |
208 c.setStyleBits(CLOSEABLE, Boolean.parseBoolean(value.toString())); |
209 }}, |
209 }}, |
210 new Property<CPlatformWindow>(WINDOW_ZOOMABLE) { public void applyProperty(final CPlatformWindow c, final Object value) { |
210 new Property<CPlatformWindow>(WINDOW_ZOOMABLE) { public void applyProperty(final CPlatformWindow c, final Object value) { |
211 boolean zoomable = Boolean.parseBoolean(value.toString()); |
211 boolean zoomable = Boolean.parseBoolean(value.toString()); |
212 if (c.target instanceof RootPaneContainer |
212 if (c.target instanceof RootPaneContainer |
213 && c.getPeer().getPeerType() == PeerType.FRAME) { |
213 && c.getPeer().getPeerType() == PeerType.FRAME) { |
214 if (c.isInFullScreen && !zoomable) { |
214 if (c.isInFullScreen && !zoomable) { |
215 c.toggleFullScreen(); |
215 c.toggleFullScreen(); |
216 } |
216 } |
217 } |
217 } |
218 c.setStyleBits(ZOOMABLE, zoomable); |
218 c.setStyleBits(ZOOMABLE, zoomable); |
219 }}, |
219 }}, |
220 new Property<CPlatformWindow>(WINDOW_FULLSCREENABLE) { public void applyProperty(final CPlatformWindow c, final Object value) { |
220 new Property<CPlatformWindow>(WINDOW_FULLSCREENABLE) { public void applyProperty(final CPlatformWindow c, final Object value) { |
221 boolean fullscrenable = Boolean.parseBoolean(value.toString()); |
221 boolean fullscrenable = Boolean.parseBoolean(value.toString()); |
222 if (c.target instanceof RootPaneContainer |
222 if (c.target instanceof RootPaneContainer |
223 && c.getPeer().getPeerType() == PeerType.FRAME) { |
223 && c.getPeer().getPeerType() == PeerType.FRAME) { |
224 if (c.isInFullScreen && !fullscrenable) { |
224 if (c.isInFullScreen && !fullscrenable) { |
225 c.toggleFullScreen(); |
225 c.toggleFullScreen(); |
226 } |
226 } |
227 } |
227 } |
228 c.setStyleBits(FULLSCREENABLE, fullscrenable); |
228 c.setStyleBits(FULLSCREENABLE, fullscrenable); |
229 }}, |
229 }}, |
230 new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) { |
230 new Property<CPlatformWindow>(WINDOW_SHADOW_REVALIDATE_NOW) { public void applyProperty(final CPlatformWindow c, final Object value) { |
231 c.execute(ptr -> nativeRevalidateNSWindowShadow(ptr)); |
231 c.execute(ptr -> nativeRevalidateNSWindowShadow(ptr)); |
232 }}, |
232 }}, |
233 new Property<CPlatformWindow>(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) { |
233 new Property<CPlatformWindow>(WINDOW_DOCUMENT_FILE) { public void applyProperty(final CPlatformWindow c, final Object value) { |
234 if (value == null || !(value instanceof java.io.File)) { |
234 if (value == null || !(value instanceof java.io.File)) { |
235 c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, null)); |
235 c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, null)); |
236 return; |
236 return; |
237 } |
237 } |
238 |
238 |
239 final String filename = ((java.io.File)value).getAbsolutePath(); |
239 final String filename = ((java.io.File)value).getAbsolutePath(); |
240 c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, filename)); |
240 c.execute(ptr->nativeSetNSWindowRepresentedFilename(ptr, filename)); |
241 }}, |
241 }}, |
242 new Property<CPlatformWindow>(WINDOW_FULL_CONTENT) { |
242 new Property<CPlatformWindow>(WINDOW_FULL_CONTENT) { |
243 public void applyProperty(final CPlatformWindow c, final Object value) { |
243 public void applyProperty(final CPlatformWindow c, final Object value) { |
244 boolean isFullWindowContent = Boolean.parseBoolean(value.toString()); |
244 boolean isFullWindowContent = Boolean.parseBoolean(value.toString()); |
245 c.setStyleBits(FULL_WINDOW_CONTENT, isFullWindowContent); |
245 c.setStyleBits(FULL_WINDOW_CONTENT, isFullWindowContent); |
246 } |
246 } |
247 }, |
247 }, |
248 new Property<CPlatformWindow>(WINDOW_TRANSPARENT_TITLE_BAR) { |
248 new Property<CPlatformWindow>(WINDOW_TRANSPARENT_TITLE_BAR) { |
249 public void applyProperty(final CPlatformWindow c, final Object value) { |
249 public void applyProperty(final CPlatformWindow c, final Object value) { |
250 boolean isTransparentTitleBar = Boolean.parseBoolean(value.toString()); |
250 boolean isTransparentTitleBar = Boolean.parseBoolean(value.toString()); |
251 c.setStyleBits(TRANSPARENT_TITLE_BAR, isTransparentTitleBar); |
251 c.setStyleBits(TRANSPARENT_TITLE_BAR, isTransparentTitleBar); |
252 } |
252 } |
253 } |
253 } |
254 }) { |
254 }) { |
255 @SuppressWarnings("deprecation") |
255 @SuppressWarnings("deprecation") |
256 public CPlatformWindow convertJComponentToTarget(final JRootPane p) { |
256 public CPlatformWindow convertJComponentToTarget(final JRootPane p) { |
257 Component root = SwingUtilities.getRoot(p); |
257 Component root = SwingUtilities.getRoot(p); |
258 final ComponentAccessor acc = AWTAccessor.getComponentAccessor(); |
258 final ComponentAccessor acc = AWTAccessor.getComponentAccessor(); |