modules/graphics/src/main/java/com/sun/glass/ui/Window.java

Print this page




 271         // Note: we can't always catch screen changes when parent is moved...
 272         this.screen = null; // should infer from the parent
 273 
 274         this.ptr = _createChildWindow(parent);
 275         if (this.ptr == 0L) {
 276             throw new RuntimeException("could not create platform window");
 277         }
 278     }
 279 
 280     public boolean isClosed() {
 281         Application.checkEventThread();
 282         return this.ptr == 0L;
 283     }
 284 
 285     private void checkNotClosed() {
 286         if (this.ptr == 0L) {
 287             throw new IllegalStateException("The window has already been closed");
 288         }
 289     }
 290 











 291     protected abstract boolean _close(long ptr);
 292     public void close() {
 293         Application.checkEventThread();
 294         if (this.view != null) {
 295             if (this.ptr != 0L) {
 296                 _setView(this.ptr, null);
 297             }
 298             this.view.setWindow(null);
 299             this.view.close();
 300             this.view = null;
 301         }
 302         if (this.ptr != 0L) {
 303             _close(this.ptr);
 304         }
 305     }
 306 
 307     private boolean isChild() {
 308         Application.checkEventThread();
 309         return this.parent != 0L;
 310     }


1004     protected abstract void _setIcon(long ptr, Pixels pixels);
1005 
1006     // In the future we may want to pass a collection of Pixels, so that
1007     // the native platform could pick up the icon with the best dimensions
1008     public void setIcon(final Pixels pixels) {
1009         Application.checkEventThread();
1010         checkNotClosed();
1011         _setIcon(this.ptr, pixels);
1012     }
1013 
1014     protected abstract void _setCursor(long ptr, Cursor cursor);
1015 
1016     /**
1017      * Sets given cursor as the cursor for this window.
1018      * If the cursor is NONE, it is automatically hidden,
1019      * otherwise it is automatically shown.
1020      * @see Cursor#setVisible(boolean)
1021      */
1022     public void setCursor(Cursor cursor) {
1023         Application.checkEventThread();

1024         _setCursor(this.ptr, cursor);
1025     }

1026 
1027     protected abstract void _toFront(long ptr);
1028     /**
1029      * Bring the window to front in the z-order.
1030      * This method DOES NOT activate the window. To make it active use
1031      * the requestFocus() method right after calling toFront().
1032      */
1033     public void toFront() {
1034         Application.checkEventThread();
1035         checkNotClosed();
1036         toFrontImpl(this, null);
1037     }
1038 
1039     private void toFrontImpl(Window w, List<Window> list) {
1040         // for z-order stacking, pop the window
1041         // and push it on the end (closest Z)
1042         visibleWindows.remove(w);
1043         visibleWindows.add(w);
1044         _toFront(w.ptr);
1045         raiseOurOwnedWindows(w, list);




 271         // Note: we can't always catch screen changes when parent is moved...
 272         this.screen = null; // should infer from the parent
 273 
 274         this.ptr = _createChildWindow(parent);
 275         if (this.ptr == 0L) {
 276             throw new RuntimeException("could not create platform window");
 277         }
 278     }
 279 
 280     public boolean isClosed() {
 281         Application.checkEventThread();
 282         return this.ptr == 0L;
 283     }
 284 
 285     private void checkNotClosed() {
 286         if (this.ptr == 0L) {
 287             throw new IllegalStateException("The window has already been closed");
 288         }
 289     }
 290 
 291     private boolean cursorUpdateEnabled = true;
 292 
 293     public void setUpdatesCursor(boolean  updatesCursor) {
 294         cursorUpdateEnabled = updatesCursor;
 295         _setUpdatesCursor(this.ptr, updatesCursor);
 296     }
 297 
 298     protected void _setUpdatesCursor(long ptr, boolean updatesCursor) {
 299         // The native field should be set only on Windows
 300     }
 301 
 302     protected abstract boolean _close(long ptr);
 303     public void close() {
 304         Application.checkEventThread();
 305         if (this.view != null) {
 306             if (this.ptr != 0L) {
 307                 _setView(this.ptr, null);
 308             }
 309             this.view.setWindow(null);
 310             this.view.close();
 311             this.view = null;
 312         }
 313         if (this.ptr != 0L) {
 314             _close(this.ptr);
 315         }
 316     }
 317 
 318     private boolean isChild() {
 319         Application.checkEventThread();
 320         return this.parent != 0L;
 321     }


1015     protected abstract void _setIcon(long ptr, Pixels pixels);
1016 
1017     // In the future we may want to pass a collection of Pixels, so that
1018     // the native platform could pick up the icon with the best dimensions
1019     public void setIcon(final Pixels pixels) {
1020         Application.checkEventThread();
1021         checkNotClosed();
1022         _setIcon(this.ptr, pixels);
1023     }
1024 
1025     protected abstract void _setCursor(long ptr, Cursor cursor);
1026 
1027     /**
1028      * Sets given cursor as the cursor for this window.
1029      * If the cursor is NONE, it is automatically hidden,
1030      * otherwise it is automatically shown.
1031      * @see Cursor#setVisible(boolean)
1032      */
1033     public void setCursor(Cursor cursor) {
1034         Application.checkEventThread();
1035         if (cursorUpdateEnabled) {
1036             _setCursor(this.ptr, cursor);
1037         }
1038     }
1039 
1040     protected abstract void _toFront(long ptr);
1041     /**
1042      * Bring the window to front in the z-order.
1043      * This method DOES NOT activate the window. To make it active use
1044      * the requestFocus() method right after calling toFront().
1045      */
1046     public void toFront() {
1047         Application.checkEventThread();
1048         checkNotClosed();
1049         toFrontImpl(this, null);
1050     }
1051 
1052     private void toFrontImpl(Window w, List<Window> list) {
1053         // for z-order stacking, pop the window
1054         // and push it on the end (closest Z)
1055         visibleWindows.remove(w);
1056         visibleWindows.add(w);
1057         _toFront(w.ptr);
1058         raiseOurOwnedWindows(w, list);