< prev index next >

modules/graphics/src/main/java/com/sun/glass/ui/mac/MacView.java

Print this page




  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package com.sun.glass.ui.mac;
  26 
  27 import com.sun.glass.ui.Pixels;
  28 import com.sun.glass.ui.View;
  29 import java.nio.Buffer;
  30 import java.nio.ByteBuffer;
  31 import java.nio.IntBuffer;
  32 import java.util.Map;

  33 
  34 /**
  35  * MacOSX platform implementation class for View.
  36  */
  37 final class MacView extends View {
  38     
  39     private native static void _initIDs();
  40     static {
  41         _initIDs();
  42         multiClickTime = _getMultiClickTime_impl();
  43         multiClickMaxX = _getMultiClickMaxX_impl();
  44         multiClickMaxY = _getMultiClickMaxY_impl();
  45     }
  46 
  47     // Constants
  48     private static final long multiClickTime;
  49     private static final int multiClickMaxX, multiClickMaxY;
  50 
  51     private native static long _getMultiClickTime_impl();
  52     private native static int _getMultiClickMaxX_impl();


 101         return ptr;
 102     }
 103     
 104     native protected long _getNativeLayer(long ptr);
 105     public long getNativeLayer() {
 106         return _getNativeLayer(getNativeView());
 107     }
 108     
 109     native protected int _getNativeRemoteLayerId(long ptr, String serverName);
 110     @Override public int getNativeRemoteLayerId(String serverName) {
 111         // used when run inside plugin
 112         return _getNativeRemoteLayerId(getNativeLayer(), serverName);
 113     }
 114 
 115     native protected void _hostRemoteLayerId(long ptr, int nativeLayerId);
 116     public void hostRemoteLayerId(int nativeLayerId) {
 117         // used when run inside plugin
 118         _hostRemoteLayerId(getNativeLayer(), nativeLayerId);
 119     }
 120     
 121     protected void notifyInputMethodMac(String str, int attrib, int length, int cursor) {

 122         byte atts[] = new byte[1];
 123         atts[0] = (byte) attrib;
 124         int attBounds[] = new int[2];
 125         attBounds[0] = 0;
 126         attBounds[1] = length;
 127         if(attrib == 4) {
 128             // attrib == 4 means we are going to commit changes, so commitLength should be non-zero
 129             notifyInputMethod(str, null, attBounds, atts, length, cursor, 0);
 130         } else {
 131             // all other cases = just an update, update preview text but do not commit it






















 132             notifyInputMethod(str, null, attBounds, atts, 0, cursor, 0);

 133         }
 134     }
 135 }
 136 


  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 package com.sun.glass.ui.mac;
  26 
  27 import com.sun.glass.ui.Pixels;
  28 import com.sun.glass.ui.View;
  29 import java.nio.Buffer;
  30 import java.nio.ByteBuffer;
  31 import java.nio.IntBuffer;
  32 import java.util.Map;
  33 import java.util.TreeSet;
  34 
  35 /**
  36  * MacOSX platform implementation class for View.
  37  */
  38 final class MacView extends View {
  39     
  40     private native static void _initIDs();
  41     static {
  42         _initIDs();
  43         multiClickTime = _getMultiClickTime_impl();
  44         multiClickMaxX = _getMultiClickMaxX_impl();
  45         multiClickMaxY = _getMultiClickMaxY_impl();
  46     }
  47 
  48     // Constants
  49     private static final long multiClickTime;
  50     private static final int multiClickMaxX, multiClickMaxY;
  51 
  52     private native static long _getMultiClickTime_impl();
  53     private native static int _getMultiClickMaxX_impl();


 102         return ptr;
 103     }
 104     
 105     native protected long _getNativeLayer(long ptr);
 106     public long getNativeLayer() {
 107         return _getNativeLayer(getNativeView());
 108     }
 109     
 110     native protected int _getNativeRemoteLayerId(long ptr, String serverName);
 111     @Override public int getNativeRemoteLayerId(String serverName) {
 112         // used when run inside plugin
 113         return _getNativeRemoteLayerId(getNativeLayer(), serverName);
 114     }
 115 
 116     native protected void _hostRemoteLayerId(long ptr, int nativeLayerId);
 117     public void hostRemoteLayerId(int nativeLayerId) {
 118         // used when run inside plugin
 119         _hostRemoteLayerId(getNativeLayer(), nativeLayerId);
 120     }
 121     
 122     protected void notifyInputMethodMac(String str, int attrib, int length,
 123                                             int cursor, int selStart, int selLength) {
 124         byte atts[] = new byte[1];
 125         atts[0] = (byte) attrib;
 126         int attBounds[] = new int[2];
 127         attBounds[0] = 0;
 128         attBounds[1] = length;
 129         if(attrib == 4) {
 130             // attrib == 4 means we are going to commit changes, so commitLength should be non-zero
 131             notifyInputMethod(str, null, attBounds, atts, length, cursor, 0);
 132         } else {
 133             // all other cases = just an update, update preview text but do not commit it
 134             if (selLength > 0
 135                     && str != null && str.length() > 0
 136                     && selStart >= 0
 137                     && selLength + selStart <= str.length()) {
 138 
 139                 TreeSet<Integer> b = new TreeSet<>();
 140                 b.add(0);
 141                 b.add(selStart);
 142                 b.add(selStart + selLength);
 143                 b.add(str.length());
 144 
 145                 int[] boundary = b.stream().mapToInt(Integer::intValue).toArray();
 146                 byte[] values = new byte[boundary.length - 1];
 147 
 148                 for (int i = 0; i < boundary.length - 1; i++) {
 149                     values[i] = (boundary[i] == selStart)
 150                                         ? IME_ATTR_TARGET_CONVERTED
 151                                         : IME_ATTR_CONVERTED;
 152                 }
 153 
 154                 notifyInputMethod(str, boundary, boundary, values, 0, cursor, 0);
 155             } else {
 156                 notifyInputMethod(str, null, attBounds, atts, 0, cursor, 0);
 157             }
 158         }
 159     }
 160 }
 161 
< prev index next >