/* This is called by the last active TextFieldLFImpl to retrieve * the contents of the native editor, which was saved by * MIDPWindow.disableAndSyncNativeEditor() into a malloc'ed buffer above. * See disableAndSyncNativeEditor above for more info. */ KNIEXPORT KNI_RETURNTYPE_OBJECT KNIDECL(javax_microedition_lcdui_TextFieldLFImpl_mallocToJavaChars) { int strLen = KNI_GetParameterAsInt(2); jchar *tmp = (jchar*)KNI_GetParameterAsInt(1); KNI_StartHandles(1); KNI_DeclareHandle(chars); #if 0 SNI_NewArray(SNI_CHAR_ARRAY, strLen, chars); if (!KNI_IsNullHandle(chars)) { memcpy(JavaCharArray(chars), tmp, strLen*sizeof(jchar)); } #endif midpFree((void*)tmp); KNI_EndHandlesAndReturnObject(chars); }
/* Return the content of the editor in a Java string. */ KNIEXPORT KNI_RETURNTYPE_OBJECT KNIDECL(javax_microedition_lcdui_TextFieldLFImpl_getNativeEditorContent) { KNI_StartHandles(1); KNI_DeclareHandle(chars); #if 0 if (editBoxShown) { int strLen = GetWindowTextLength(hwndTextActive); jchar *tmp = (jchar*)midpMalloc((strLen + 1) * sizeof(jchar)); if (tmp) { GetWindowText(hwndTextActive, (LPTSTR)tmp, strLen+1); /* 0-terminated */ SNI_NewArray(SNI_CHAR_ARRAY, strLen, chars); if (!KNI_IsNullHandle(chars)) { memcpy(JavaCharArray(chars), tmp, strLen*sizeof(jchar)); } midpFree((void*)tmp); } } #endif KNI_EndHandlesAndReturnObject(chars); }
/** * Gets the combined advance width of multiple characters, starting at * the specified offset and for the specified number of characters using * this <tt>Font</tt>. * <p> * Java declaration: * <pre> * charsWidth([CII)I * </pre> * * @param ch the array of characters to be measured * @param offset the index of the first character to measure * @param length the number of characters to measure * * @return the total width of the character range in pixels */ KNIEXPORT KNI_RETURNTYPE_INT KNIDECL(javax_microedition_lcdui_Font_charsWidth) { int length = (int)KNI_GetParameterAsInt(3); int offset = (int)KNI_GetParameterAsInt(2); int chLen; jint result = 0; KNI_StartHandles(2); KNI_DeclareHandle(ch); KNI_DeclareHandle(thisObject); KNI_GetParameterAsObject(1, ch); KNI_GetParameterAsObject(0, thisObject); if ((chLen = KNI_GetArrayLength(ch)) == -1) { KNI_ThrowNew(midpNullPointerException, NULL); } else if ( (offset < 0) || (offset > chLen) || (length < 0) || (length > chLen) || ((offset + length) < 0) || ((offset + length) > chLen)) { KNI_ThrowNew(midpArrayIndexOutOfBoundsException, NULL); } else if (length != 0) { int face, style, size; DECLARE_FONT_PARAMS(thisObject); SNI_BEGIN_RAW_POINTERS; result = gx_get_charswidth(face, style, size, &(JavaCharArray(ch)[offset]), length); SNI_END_RAW_POINTERS; } KNI_EndHandles(); KNI_ReturnInt(result); }