📄 defaultlcdui.c
字号:
*=======================================================================*/KNIEXPORT KNI_RETURNTYPE_VOIDJava_javax_microedition_lcdui_Graphics_drawSubstring() { int anchor = KNI_GetParameterAsInt(6); int y = KNI_GetParameterAsInt(5); int x = KNI_GetParameterAsInt(4); int length = KNI_GetParameterAsInt(3); int offset = KNI_GetParameterAsInt(2); int strLen; KNI_StartHandles(7); KNI_DeclareHandle(str); KNI_DeclareHandle(thisClass); KNI_DeclareHandle(font); KNI_DeclareHandle(gHandle); KNI_DeclareHandle(fHandle); KNI_DeclareHandle(cHandle); KNI_DeclareHandle(iHandle); KNI_GetParameterAsObject(1, str); KNI_GetParameterAsObject(0, thisClass); strLen = KNI_GetStringLength(str); if (strLen < 0) { KNI_ThrowNew("java/lang/NullPointerException", ""); } else if ( (offset < 0) || (offset > strLen) || (length < 0) || (length > strLen) || ((offset + length) < 0) || ((offset + length) > strLen)) { KNI_ThrowNew("java/lang/StringIndexOutOfBoundsException", ""); } else if (!checkAnchor(anchor, VCENTER)) { KNI_ThrowNew("java/lang/IllegalArgumentException", ""); } else if (length != 0) { unicode* chars; jshort myClip[4]; /* Defined in Graphics.java as 4 shorts */ int FONTPARAMS; chars = (unicode*)midpMalloc(length<<1); if (chars == NULL) { KNI_ThrowNew("java/lang/OutOfMemoryError", ""); } else { KNI_GetStringRegion(str, offset, length, chars); KNI_GetObjectClass(thisClass, gHandle); KNI_FONT(thisClass, gHandle, font); KNI_GetObjectClass(font, fHandle); DECLARE_KNI_FONT_PARAMS(font, fHandle); KNI_TRANSLATE(thisClass, x, y, gHandle); LCDUIdrawChars(KNI_PIXEL(thisClass, gHandle), KNI_CLIP(thisClass, gHandle, myClip, cHandle), KNI_IMAGEDST(thisClass, gHandle, iHandle, NULL), KNI_LINESTYLE(thisClass, gHandle), FONTPARAMS, x, y, anchor, chars, length); midpFree(chars); } } KNI_EndHandles(); KNI_ReturnVoid();}/*========================================================================= * FUNCTION: drawChar(CIII)V * CLASS: javax.microedition.lcdui.Graphics * TYPE: virtual native function * OVERVIEW: Draws the specified character using the current font * and color. * INTERFACE (operand stack manipulation): * parameters: ch the character to be drawn * x the x coordinate of the anchor point * y the y coordinate of the anchor point * anchor the anchor point for positioning the text * returns: <nothing> *=======================================================================*/KNIEXPORT KNI_RETURNTYPE_VOIDJava_javax_microedition_lcdui_Graphics_drawChar() { int anchor = KNI_GetParameterAsInt(4); int y = KNI_GetParameterAsInt(3); int x = KNI_GetParameterAsInt(2); unicode c = KNI_GetParameterAsShort(1); KNI_StartHandles(6); KNI_DeclareHandle(thisClass); KNI_DeclareHandle(font); KNI_DeclareHandle(gHandle); KNI_DeclareHandle(fHandle); KNI_DeclareHandle(cHandle); KNI_DeclareHandle(iHandle); KNI_GetParameterAsObject(0, thisClass); if (!checkAnchor(anchor, VCENTER)) { KNI_ThrowNew("java/lang/IllegalArgumentException", ""); } else { jshort myClip[4]; /* Defined in Graphics.java as 4 shorts */ int FONTPARAMS; KNI_GetObjectClass(thisClass, gHandle); KNI_FONT(thisClass, gHandle, font); KNI_GetObjectClass(font, fHandle); DECLARE_KNI_FONT_PARAMS(font, fHandle); KNI_TRANSLATE(thisClass, x, y, gHandle); LCDUIdrawChars(KNI_PIXEL(thisClass, gHandle), KNI_CLIP(thisClass, gHandle, myClip, cHandle), KNI_IMAGEDST(thisClass, gHandle, iHandle, NULL), KNI_LINESTYLE(thisClass, gHandle), FONTPARAMS, x, y, anchor, &c, 1); } KNI_EndHandles(); KNI_ReturnVoid();}/*========================================================================= * FUNCTION: drawChars([CIIIII)V * CLASS: javax.microedition.lcdui.Graphics * TYPE: virtual native function * OVERVIEW: Draws the specified characters using the current font * and color. * INTERFACE (operand stack manipulation): * parameters: data the array of characters to be drawn * offset zero-based index of first character to be * drawn * length number of characters to be drawn * x the x coordinate of the anchor point * y the y coordinate of the anchor point * anchor the anchor point for positioning the text * returns: <nothing> *=======================================================================*/KNIEXPORT KNI_RETURNTYPE_VOIDJava_javax_microedition_lcdui_Graphics_drawChars() { int anchor = KNI_GetParameterAsInt(6); int y = KNI_GetParameterAsInt(5); int x = KNI_GetParameterAsInt(4); int length = KNI_GetParameterAsInt(3); int offset = KNI_GetParameterAsInt(2); int chLen; KNI_StartHandles(7); KNI_DeclareHandle(ch); KNI_DeclareHandle(thisClass); KNI_DeclareHandle(font); KNI_DeclareHandle(gHandle); KNI_DeclareHandle(fHandle); KNI_DeclareHandle(cHandle); KNI_DeclareHandle(iHandle); KNI_GetParameterAsObject(1, ch); KNI_GetParameterAsObject(0, thisClass); chLen = KNI_GetArrayLength(ch); if (chLen < 0) { KNI_ThrowNew("java/lang/NullPointerException", ""); } else if ( (offset < 0) || (offset > chLen) || (length < 0) || (length > chLen) || ((offset + length) < 0) || ((offset + length) > chLen)) { KNI_ThrowNew("java/lang/ArrayIndexOutOfBoundsException", ""); } else if (!checkAnchor(anchor, VCENTER)) { KNI_ThrowNew("java/lang/IllegalArgumentException", ""); } else if (length != 0) { unicode* chars; jshort myClip[4]; /* Defined in Graphics.java as 4 shorts */ int FONTPARAMS; chars = (unicode*)midpMalloc(length<<1); if (chars == NULL) { KNI_ThrowNew("java/lang/OutOfMemoryError", ""); } else { KNI_GetRawArrayRegion(ch, (offset<<1), (length<<1), (jbyte*)chars); KNI_GetObjectClass(thisClass, gHandle); KNI_FONT(thisClass, gHandle, font); KNI_GetObjectClass(font, fHandle); DECLARE_KNI_FONT_PARAMS(font, fHandle); KNI_TRANSLATE(thisClass, x, y, gHandle); LCDUIdrawChars(KNI_PIXEL(thisClass, gHandle), KNI_CLIP(thisClass, gHandle, myClip, cHandle), KNI_IMAGEDST(thisClass, gHandle, iHandle, NULL), KNI_LINESTYLE(thisClass, gHandle), FONTPARAMS, x, y, anchor, chars, length); midpFree(chars); } } KNI_EndHandles(); KNI_ReturnVoid();}/*========================================================================= * FUNCTION: drawImage(Ljavax/microedition/lcdui/Image;III)V * CLASS: javax.microedition.lcdui.Graphics * TYPE: virtual native function * OVERVIEW: Draws the specified image by using the anchor point. * INTERFACE (operand stack manipulation): * parameters: image the image to be drawn * x the x coordinate of the anchor point * y the y coordinate of the anchor point * anchor the anchor point for positioning the image * returns: <nothing> *=======================================================================*/KNIEXPORT KNI_RETURNTYPE_VOIDJava_javax_microedition_lcdui_Graphics_drawImage() { jint anchor = KNI_GetParameterAsInt(4); jint y = KNI_GetParameterAsInt(3); jint x = KNI_GetParameterAsInt(2); KNI_StartHandles(5); KNI_DeclareHandle(img); KNI_DeclareHandle(thisClass); KNI_DeclareHandle(gHandle); KNI_DeclareHandle(cHandle); KNI_DeclareHandle(iHandle); KNI_GetParameterAsObject(1, img); KNI_GetParameterAsObject(0, thisClass); if (KNI_IsNullHandle(img)) { KNI_ThrowNew("java/lang/NullPointerException", ""); } else if (!checkAnchor(anchor, BASELINE)) { KNI_ThrowNew("java/lang/IllegalArgumentException", ""); } else { jshort myClip[4]; /* Defined in Graphics.java as 4 shorts */ int defErr = -1; if ((int)getImageData(img, (void*)&defErr) == -1) { printf("getImageData() returned ptr to -1; ignore image\n"); } else { jbyte ret; jint width = (int)KNI_GetIntField(img, _CACHE_FIELDID(iHandle, "width", "I", _i_width_cache)); jint height = (int)KNI_GetIntField(img, _CACHE_FIELDID(iHandle, "height", "I", _i_height_cache)); jint x_src = 0, y_src = 0; KNI_GetObjectClass(thisClass, gHandle); KNI_TRANSLATE(thisClass, x, y, gHandle); KNI_CLIP(thisClass, gHandle, myClip, cHandle); ret = adjustToViewableRegion(&x, &y, &x_src, &y_src, &width, &height, myClip, anchor, 0); if (ret != NO_IMAGE) { LCDUIdrawRegionTransform(myClip, KNI_IMAGEDST(thisClass, gHandle, iHandle, NULL), getImageData(img, NULL), x, y, anchor, x_src, y_src, width, height, 0, ret == 2 ? KNI_TRUE : KNI_FALSE); } } } KNI_EndHandles(); KNI_ReturnVoid();}/*======================================================================== * FUNCTION: drawRGB([IIIIIIIZ)V * CLASS: javax.microedition.lcdui.Graphics * TYPE: virtual native function * OVERVIEW: Draws from the given data array of 0xAARRGGBB pixels * INTERFACE (Operand stack manipulation): * parameters: rgbData an array of rgb pixels to draw * offset offset in rgbData of the first pixel to use * scanlen distance between pixels in the same * column but adjacent rows * x x coordinate of the upper left corner * of the region to draw * y y coordinate of the upper left corner * of the region to draw * width width of the target region * height height of the target region * processAlpha use/ignore alpha channel bytes * returns: <nothing> *======================================================================*/KNIEXPORT KNI_RETURNTYPE_VOIDJava_javax_microedition_lcdui_Graphics_drawRGB() { jboolean processAlpha = KNI_GetParameterAsBoolean(8); jint height = KNI_GetParameterAsInt(7); jint width = KNI_GetParameterAsInt(6); jint y = KNI_GetParameterAsInt(5); jint x = KNI_GetParameterAsInt(4); jint scanlen = KNI_GetParameterAsInt(3); jint offset = KNI_GetParameterAsInt(2); jint buflen; jint *rgbBuffer; KNI_StartHandles(5); KNI_DeclareHandle(rgbData); KNI_DeclareHandle(thisClass); KNI_DeclareHandle(gHandle); KNI_DeclareHandle(cHandle); KNI_DeclareHandle(iHandle); KNI_GetParameterAsObject(1, rgbData); KNI_GetParameterAsObject(0, thisClass); if (KNI_IsNullHandle(rgbData)) { KNI_ThrowNew("java/lang/NullPointerException", ""); } else { buflen = KNI_GetArrayLength(rgbData); if ((height < 0) || (width < 0) || (y < 0) || (x < 0) || (scanlen < 0) || (offset < 0) || ((offset + (height * scanlen)) > buflen)) { KNI_ThrowNew("java/lang/ArrayIndexOutOfBoundsException", ""); } else { rgbBuffer = (jint*)midpMalloc(sizeof(jint) * buflen); if (rgbBuffer == NULL) { KNI_ThrowNew("java/lang/OutOfMemoryError", ""); } else { jshort myClip[4]; /* Defined in Graphics.java as 4 shorts */ jbyte ret; jint x_src = 0, y_src = 0; KNI_GetRawArrayRegion(rgbData, 0, buflen * sizeof(int), (jbyte*)rgbBuffer); KNI_GetObjectClass(thisClass, gHandle); KNI_TRANSLATE(thisClass, x, y, g
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -