modules/graphics/src/main/java/com/sun/glass/ui/gtk/GtkView.java

Print this page




  86                 _uploadPixelsByteArray(ptr, bytes.array(), bytes.arrayOffset(), pixels.getWidth(), pixels.getHeight());
  87             } else {
  88                 IntBuffer ints = (IntBuffer)data;
  89                 _uploadPixelsIntArray(ptr, ints.array(), ints.arrayOffset(), pixels.getWidth(), pixels.getHeight());
  90             }
  91         } else {
  92             // gznote: what are the circumstances under which this can happen?
  93             _uploadPixelsDirect(ptr, pixels.asByteBuffer(), pixels.getWidth(), pixels.getHeight());
  94         }
  95     }
  96     private native void _uploadPixelsDirect(long viewPtr, Buffer pixels, int width, int height);
  97     private native void _uploadPixelsByteArray(long viewPtr, byte[] pixels, int offset, int width, int height);
  98     private native void _uploadPixelsIntArray(long viewPtr, int[] pixels, int offset, int width, int height);
  99 
 100     @Override
 101     protected native boolean _enterFullscreen(long ptr, boolean animate, boolean keepRatio, boolean hideCursor);
 102 
 103     @Override
 104     protected native void _exitFullscreen(long ptr, boolean animate);
 105     







 106         
 107     protected void notifyInputMethodDraw(String text, int first, int length, int caret) {
 108         if (text != null) {
 109             preedit.replace(first, first + length, text);
 110             notifyInputMethod(preedit.toString(), null, null, null, 0, caret, 0);
 111             lastCaret = caret;
 112         } else {
 113             preedit.setLength(0);
 114         }


 115     }
 116     
 117     protected void notifyInputMethodCaret(int pos, int direction, int style) {
 118         switch (direction) {
 119             case 0: //XIMForwardChar
 120                 lastCaret += pos;
 121                 break;
 122             case 1: //XIMBackwardChar
 123                 lastCaret -= pos;
 124                 break;
 125             case 10: //XIMAbsolute
 126                 lastCaret = pos;
 127                 break;
 128             default:
 129                 //TODO: as we don't know the text structure, we cannot compute the position
 130                 // for other directions (like forward words, lines, etc...).
 131                 // Luckily, vast majority of IM uses XIMAbsolute (10)
 132         }
 133         notifyInputMethod(preedit.toString(), null, null, null, 0, lastCaret, 0);
 134     }


  86                 _uploadPixelsByteArray(ptr, bytes.array(), bytes.arrayOffset(), pixels.getWidth(), pixels.getHeight());
  87             } else {
  88                 IntBuffer ints = (IntBuffer)data;
  89                 _uploadPixelsIntArray(ptr, ints.array(), ints.arrayOffset(), pixels.getWidth(), pixels.getHeight());
  90             }
  91         } else {
  92             // gznote: what are the circumstances under which this can happen?
  93             _uploadPixelsDirect(ptr, pixels.asByteBuffer(), pixels.getWidth(), pixels.getHeight());
  94         }
  95     }
  96     private native void _uploadPixelsDirect(long viewPtr, Buffer pixels, int width, int height);
  97     private native void _uploadPixelsByteArray(long viewPtr, byte[] pixels, int offset, int width, int height);
  98     private native void _uploadPixelsIntArray(long viewPtr, int[] pixels, int offset, int width, int height);
  99 
 100     @Override
 101     protected native boolean _enterFullscreen(long ptr, boolean animate, boolean keepRatio, boolean hideCursor);
 102 
 103     @Override
 104     protected native void _exitFullscreen(long ptr, boolean animate);
 105     
 106     @Override protected void _finishInputMethodComposition(long ptr) {
 107         if (imEnabled) {
 108             // Discard any pre-edited text
 109             preedit.setLength(0);
 110             notifyInputMethod(preedit.toString(), null, null, null, 0, 0, 0);
 111         }
 112     }
 113 
 114     protected void notifyInputMethodDraw(String text, int first, int length, int caret) {
 115         if (text != null) {
 116             preedit.replace(first, first + length, text);


 117         } else {
 118             preedit.setLength(0);
 119         }
 120         notifyInputMethod(preedit.toString(), null, null, null, 0, caret, 0);
 121         lastCaret = caret;
 122     }
 123     
 124     protected void notifyInputMethodCaret(int pos, int direction, int style) {
 125         switch (direction) {
 126             case 0: //XIMForwardChar
 127                 lastCaret += pos;
 128                 break;
 129             case 1: //XIMBackwardChar
 130                 lastCaret -= pos;
 131                 break;
 132             case 10: //XIMAbsolute
 133                 lastCaret = pos;
 134                 break;
 135             default:
 136                 //TODO: as we don't know the text structure, we cannot compute the position
 137                 // for other directions (like forward words, lines, etc...).
 138                 // Luckily, vast majority of IM uses XIMAbsolute (10)
 139         }
 140         notifyInputMethod(preedit.toString(), null, null, null, 0, lastCaret, 0);
 141     }