Mercurial > dwindows
comparison android/dw.cpp @ 2852:5018df4f952e
Win/Android/Template: Add return values to dw_window_set_bitmap(_from_data).
Also update the readme regarding this change.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 15 Nov 2022 00:34:20 +0000 |
parents | da90bf6d0564 |
children | de1a0cd26691 |
comparison
equal
deleted
inserted
replaced
2851:fdd21139c07f | 2852:5018df4f952e |
---|---|
6195 * (pass 0 if you use the filename param) | 6195 * (pass 0 if you use the filename param) |
6196 * data: memory buffer containing image (Bitmap on OS/2 or | 6196 * data: memory buffer containing image (Bitmap on OS/2 or |
6197 * Windows and a pixmap on Unix, pass | 6197 * Windows and a pixmap on Unix, pass |
6198 * nullptr if you use the id param) | 6198 * nullptr if you use the id param) |
6199 * len: Length of data passed | 6199 * len: Length of data passed |
6200 */ | 6200 * Returns: |
6201 void API dw_window_set_bitmap_from_data(HWND handle, unsigned long cid, const char *data, int len) | 6201 * DW_ERROR_NONE on success. |
6202 { | 6202 * DW_ERROR_UNKNOWN if the parameters were invalid. |
6203 JNIEnv *env; | 6203 * DW_ERROR_GENERAL if the bitmap was unable to be loaded. |
6204 */ | |
6205 int API dw_window_set_bitmap_from_data(HWND handle, unsigned long cid, const char *data, int len) | |
6206 { | |
6207 JNIEnv *env; | |
6208 int retval = DW_ERROR_UNKNOWN; | |
6204 | 6209 |
6205 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | 6210 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) |
6206 { | 6211 { |
6207 // Construct a byte array | 6212 // Construct a byte array |
6208 jbyteArray bytearray = nullptr; | 6213 jbyteArray bytearray = nullptr; |
6213 } | 6218 } |
6214 // First get the class that contains the method you need to call | 6219 // First get the class that contains the method you need to call |
6215 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 6220 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
6216 // Get the method that you want to call | 6221 // Get the method that you want to call |
6217 jmethodID windowSetBitmapFromData = env->GetMethodID(clazz, "windowSetBitmapFromData", | 6222 jmethodID windowSetBitmapFromData = env->GetMethodID(clazz, "windowSetBitmapFromData", |
6218 "(Landroid/view/View;I[BI)V"); | 6223 "(Landroid/view/View;I[BI)I"); |
6219 // Call the method on the object | 6224 // Call the method on the object |
6220 env->CallVoidMethod(_dw_obj, windowSetBitmapFromData, handle, (int)cid, bytearray, len); | 6225 retval = env->CallIntMethod(_dw_obj, windowSetBitmapFromData, handle, (int)cid, bytearray, len); |
6221 _dw_jni_check_exception(env); | 6226 _dw_jni_check_exception(env); |
6222 // Clean up after the array now that we are finished | 6227 // Clean up after the array now that we are finished |
6223 //if(bytearray) | 6228 //if(bytearray) |
6224 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0); | 6229 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0); |
6225 } | 6230 } |
6231 return retval; | |
6226 } | 6232 } |
6227 | 6233 |
6228 /* | 6234 /* |
6229 * Sets the bitmap used for a given static window. | 6235 * Sets the bitmap used for a given static window. |
6230 * Parameters: | 6236 * Parameters: |
6232 * id: An ID to be used to specify the icon, | 6238 * id: An ID to be used to specify the icon, |
6233 * (pass 0 if you use the filename param) | 6239 * (pass 0 if you use the filename param) |
6234 * filename: a path to a file (Bitmap on OS/2 or | 6240 * filename: a path to a file (Bitmap on OS/2 or |
6235 * Windows and a pixmap on Unix, pass | 6241 * Windows and a pixmap on Unix, pass |
6236 * nullptr if you use the id param) | 6242 * nullptr if you use the id param) |
6237 */ | 6243 * Returns: |
6238 void API dw_window_set_bitmap(HWND handle, unsigned long resid, const char *filename) | 6244 * DW_ERROR_NONE on success. |
6239 { | 6245 * DW_ERROR_UNKNOWN if the parameters were invalid. |
6240 JNIEnv *env; | 6246 * DW_ERROR_GENERAL if the bitmap was unable to be loaded. |
6247 */ | |
6248 int API dw_window_set_bitmap(HWND handle, unsigned long resid, const char *filename) | |
6249 { | |
6250 JNIEnv *env; | |
6251 int retval = DW_ERROR_UNKNOWN; | |
6241 | 6252 |
6242 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | 6253 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) |
6243 { | 6254 { |
6244 // Construct a string | 6255 // Construct a string |
6245 jstring jstr = nullptr; | 6256 jstring jstr = nullptr; |
6248 } | 6259 } |
6249 // First get the class that contains the method you need to call | 6260 // First get the class that contains the method you need to call |
6250 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 6261 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
6251 // Get the method that you want to call | 6262 // Get the method that you want to call |
6252 jmethodID windowSetBitmapFromData = env->GetMethodID(clazz, "windowSetBitmap", | 6263 jmethodID windowSetBitmapFromData = env->GetMethodID(clazz, "windowSetBitmap", |
6253 "(Landroid/view/View;ILjava/lang/String;)V"); | 6264 "(Landroid/view/View;ILjava/lang/String;)I"); |
6254 // Call the method on the object | 6265 // Call the method on the object |
6255 env->CallVoidMethod(_dw_obj, windowSetBitmapFromData, handle, (int)resid, jstr); | 6266 retval = env->CallIntMethod(_dw_obj, windowSetBitmapFromData, handle, (int)resid, jstr); |
6256 _dw_jni_check_exception(env); | 6267 _dw_jni_check_exception(env); |
6257 if(jstr) | 6268 if(jstr) |
6258 env->DeleteLocalRef(jstr); | 6269 env->DeleteLocalRef(jstr); |
6259 } | 6270 } |
6271 return retval; | |
6260 } | 6272 } |
6261 | 6273 |
6262 /* | 6274 /* |
6263 * Sets the icon used for a given window. | 6275 * Sets the icon used for a given window. |
6264 * Parameters: | 6276 * Parameters: |