Mercurial > dwindows
comparison android/dw.cpp @ 2557:756331246f94
Android: Implement Java exception handling, make sure all return values from JNI are sane.
This allows you to break in _dw_jni_check_exception() on or before return TRUE to catch
any Java exceptions, otherwise they will be cleared and the functions will return failure.
Fix the NullPointerException from the last commit, it was in windowGetData with a
non existant key in the data SimpleArrayMap.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Mon, 17 May 2021 21:11:40 +0000 |
parents | d2d8c66ad062 |
children | ebc6a4ff5f1f |
comparison
equal
deleted
inserted
replaced
2556:d2d8c66ad062 | 2557:756331246f94 |
---|---|
76 jclass _dw_find_class(JNIEnv *env, const char* name) | 76 jclass _dw_find_class(JNIEnv *env, const char* name) |
77 { | 77 { |
78 return static_cast<jclass>(env->CallObjectMethod(_dw_class_loader, _dw_class_method, env->NewStringUTF(name))); | 78 return static_cast<jclass>(env->CallObjectMethod(_dw_class_loader, _dw_class_method, env->NewStringUTF(name))); |
79 } | 79 } |
80 | 80 |
81 // Do a quick check if an exception occurred... | |
82 // Display then clear it so we can continue... | |
83 // Return TRUE if an exception had occurred | |
84 int _dw_jni_check_exception(JNIEnv *env) | |
85 { | |
86 if(env->ExceptionCheck()) | |
87 { | |
88 env->ExceptionDescribe(); | |
89 env->ExceptionClear(); | |
90 return TRUE; | |
91 } | |
92 return FALSE; | |
93 } | |
94 | |
95 #define _DW_REFERENCE_NONE 0 | |
96 #define _DW_REFERENCE_WEAK 1 | |
97 #define _DW_REFERENCE_STRONG 2 | |
98 | |
99 // Handle returns from JNI functions and make sure the | |
100 // return value is sane... | |
101 // Reference: 0 no reference 1 weak 2 strong | |
102 jobject _dw_jni_check_result(JNIEnv *env, jobject obj, int reference) | |
103 { | |
104 jobject result = nullptr; | |
105 | |
106 if(!_dw_jni_check_exception(env) && obj) | |
107 { | |
108 if(reference == 1) | |
109 result = env->NewWeakGlobalRef(obj); | |
110 else if(reference == 2) | |
111 result = env->NewGlobalRef(obj); | |
112 else | |
113 result = obj; | |
114 } | |
115 return result; | |
116 } | |
81 | 117 |
82 /* Call the dwmain entry point, Android has no args, so just pass the app path */ | 118 /* Call the dwmain entry point, Android has no args, so just pass the app path */ |
83 void _dw_main_launch(char *arg) | 119 void _dw_main_launch(char *arg) |
84 { | 120 { |
85 static HEV startup = nullptr; | 121 static HEV startup = nullptr; |
590 } | 626 } |
591 | 627 |
592 int _dw_dark_mode_detected() | 628 int _dw_dark_mode_detected() |
593 { | 629 { |
594 JNIEnv *env; | 630 JNIEnv *env; |
631 int retval = DW_ERROR_UNKNOWN; | |
595 | 632 |
596 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | 633 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) |
597 { | 634 { |
598 // First get the class that contains the method you need to call | 635 // First get the class that contains the method you need to call |
599 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 636 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
600 // Get the method that you want to call | 637 // Get the method that you want to call |
601 jmethodID darkModeDetected = env->GetMethodID(clazz, "darkModeDetected", | 638 jmethodID darkModeDetected = env->GetMethodID(clazz, "darkModeDetected", |
602 "()I"); | 639 "()I"); |
603 // Call the method on the object | 640 // Call the method on the object |
604 return env->CallIntMethod(_dw_obj, darkModeDetected); | 641 retval = env->CallIntMethod(_dw_obj, darkModeDetected); |
605 } | 642 _dw_jni_check_exception(env); |
606 return DW_ERROR_UNKNOWN; | 643 } |
644 return retval; | |
607 } | 645 } |
608 | 646 |
609 /* | 647 /* |
610 * Runs a message loop for Dynamic Windows. | 648 * Runs a message loop for Dynamic Windows. |
611 */ | 649 */ |
620 // Get the method that you want to call | 658 // Get the method that you want to call |
621 jmethodID dwMain = env->GetMethodID(clazz, "dwMain", | 659 jmethodID dwMain = env->GetMethodID(clazz, "dwMain", |
622 "()V"); | 660 "()V"); |
623 // Call the method on the object | 661 // Call the method on the object |
624 env->CallVoidMethod(_dw_obj, dwMain); | 662 env->CallVoidMethod(_dw_obj, dwMain); |
663 _dw_jni_check_exception(env); | |
625 } | 664 } |
626 | 665 |
627 /* We don't actually run a loop here, | 666 /* We don't actually run a loop here, |
628 * we launched a new thread to run the loop there. | 667 * we launched a new thread to run the loop there. |
629 * Just wait for dw_main_quit() on the DWMainEvent. | 668 * Just wait for dw_main_quit() on the DWMainEvent. |
655 // Get the method that you want to call | 694 // Get the method that you want to call |
656 jmethodID mainSleep = env->GetMethodID(clazz, "mainSleep", | 695 jmethodID mainSleep = env->GetMethodID(clazz, "mainSleep", |
657 "(I)V"); | 696 "(I)V"); |
658 // Call the method on the object | 697 // Call the method on the object |
659 env->CallVoidMethod(_dw_obj, mainSleep, milliseconds); | 698 env->CallVoidMethod(_dw_obj, mainSleep, milliseconds); |
699 _dw_jni_check_exception(env); | |
660 } | 700 } |
661 } | 701 } |
662 | 702 |
663 /* | 703 /* |
664 * Processes a single message iteration and returns. | 704 * Processes a single message iteration and returns. |
687 // Get the method that you want to call | 727 // Get the method that you want to call |
688 jmethodID dwindowsExit = env->GetMethodID(clazz, "dwindowsExit", | 728 jmethodID dwindowsExit = env->GetMethodID(clazz, "dwindowsExit", |
689 "(I)V"); | 729 "(I)V"); |
690 // Call the method on the object | 730 // Call the method on the object |
691 env->CallVoidMethod(_dw_obj, dwindowsExit, exitcode); | 731 env->CallVoidMethod(_dw_obj, dwindowsExit, exitcode); |
732 _dw_jni_check_exception(env); | |
692 } | 733 } |
693 // We shouldn't get here, but in case JNI can't call dwindowsExit... | 734 // We shouldn't get here, but in case JNI can't call dwindowsExit... |
694 exit(exitcode); | 735 exit(exitcode); |
695 } | 736 } |
696 | 737 |
786 // Get the method that you want to call | 827 // Get the method that you want to call |
787 jmethodID debugMessage = env->GetMethodID(clazz, "debugMessage", | 828 jmethodID debugMessage = env->GetMethodID(clazz, "debugMessage", |
788 "(Ljava/lang/String;)V"); | 829 "(Ljava/lang/String;)V"); |
789 // Call the method on the object | 830 // Call the method on the object |
790 env->CallVoidMethod(_dw_obj, debugMessage, jstr); | 831 env->CallVoidMethod(_dw_obj, debugMessage, jstr); |
832 _dw_jni_check_exception(env); | |
791 } | 833 } |
792 else { | 834 else { |
793 /* Output to stderr, if there is another way to send it | 835 /* Output to stderr, if there is another way to send it |
794 * on the implementation platform, change this. | 836 * on the implementation platform, change this. |
795 */ | 837 */ |
811 int API dw_messagebox(const char *title, int flags, const char *format, ...) | 853 int API dw_messagebox(const char *title, int flags, const char *format, ...) |
812 { | 854 { |
813 va_list args; | 855 va_list args; |
814 char outbuf[1025] = {0}; | 856 char outbuf[1025] = {0}; |
815 JNIEnv *env; | 857 JNIEnv *env; |
858 int retval = 0; | |
816 | 859 |
817 va_start(args, format); | 860 va_start(args, format); |
818 vsnprintf(outbuf, 1024, format, args); | 861 vsnprintf(outbuf, 1024, format, args); |
819 va_end(args); | 862 va_end(args); |
820 | 863 |
827 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 870 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
828 // Get the method that you want to call | 871 // Get the method that you want to call |
829 jmethodID messageBox = env->GetMethodID(clazz, "messageBox", | 872 jmethodID messageBox = env->GetMethodID(clazz, "messageBox", |
830 "(Ljava/lang/String;Ljava/lang/String;I)I"); | 873 "(Ljava/lang/String;Ljava/lang/String;I)I"); |
831 // Call the method on the object | 874 // Call the method on the object |
832 return env->CallIntMethod(_dw_obj, messageBox, jstrtitle, jstr, flags); | 875 retval = env->CallIntMethod(_dw_obj, messageBox, jstrtitle, jstr, flags); |
833 } | 876 _dw_jni_check_exception(env); |
834 return 0; | 877 } |
878 return retval; | |
835 } | 879 } |
836 | 880 |
837 /* | 881 /* |
838 * Opens a file dialog and queries user selection. | 882 * Opens a file dialog and queries user selection. |
839 * Parameters: | 883 * Parameters: |
847 * | 891 * |
848 */ | 892 */ |
849 char * API dw_file_browse(const char *title, const char *defpath, const char *ext, int flags) | 893 char * API dw_file_browse(const char *title, const char *defpath, const char *ext, int flags) |
850 { | 894 { |
851 JNIEnv *env; | 895 JNIEnv *env; |
896 char *retval = nullptr; | |
852 | 897 |
853 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | 898 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) |
854 { | 899 { |
855 // Use a long parameter | 900 // Use a long parameter |
856 jstring jstr = env->NewStringUTF(title); | 901 jstring jstr = env->NewStringUTF(title); |
864 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 909 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
865 // Get the method that you want to call | 910 // Get the method that you want to call |
866 jmethodID fileBrowse = env->GetMethodID(clazz, "fileBrowse", | 911 jmethodID fileBrowse = env->GetMethodID(clazz, "fileBrowse", |
867 "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/String;"); | 912 "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/String;"); |
868 // Call the method on the object | 913 // Call the method on the object |
869 jstring jresult = (jstring)env->CallObjectMethod(_dw_obj, fileBrowse, jstr, path, jext, flags); | 914 jstring jresult = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, fileBrowse, jstr, path, jext, flags), _DW_REFERENCE_NONE); |
870 if(jresult) | 915 if(jresult) |
871 return strdup(env->GetStringUTFChars(jresult, nullptr)); | 916 retval = strdup(env->GetStringUTFChars(jresult, nullptr)); |
872 } | 917 } |
873 return nullptr; | 918 return retval; |
874 } | 919 } |
875 | 920 |
876 /* | 921 /* |
877 * Gets the contents of the default clipboard as text. | 922 * Gets the contents of the default clipboard as text. |
878 * Parameters: | 923 * Parameters: |
893 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 938 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
894 // Get the method that you want to call | 939 // Get the method that you want to call |
895 jmethodID clipboardGetText = env->GetMethodID(clazz, "clipboardGetText", | 940 jmethodID clipboardGetText = env->GetMethodID(clazz, "clipboardGetText", |
896 "()Ljava/lang/String;"); | 941 "()Ljava/lang/String;"); |
897 // Call the method on the object | 942 // Call the method on the object |
898 jstring result = (jstring)env->CallObjectMethod(_dw_obj, clipboardGetText); | 943 jstring result = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, clipboardGetText), _DW_REFERENCE_NONE); |
899 // Get the UTF8 string result | 944 // Get the UTF8 string result |
900 if(result) | 945 if(result) |
901 utf8 = env->GetStringUTFChars(result, nullptr); | 946 utf8 = env->GetStringUTFChars(result, nullptr); |
902 return utf8 ? strdup(utf8) : nullptr; | 947 return utf8 ? strdup(utf8) : nullptr; |
903 } | 948 } |
923 // Get the method that you want to call | 968 // Get the method that you want to call |
924 jmethodID clipboardSetText = env->GetMethodID(clazz, "clipboardSetText", | 969 jmethodID clipboardSetText = env->GetMethodID(clazz, "clipboardSetText", |
925 "(Ljava/lang/String;)V"); | 970 "(Ljava/lang/String;)V"); |
926 // Call the method on the object | 971 // Call the method on the object |
927 env->CallVoidMethod(_dw_obj, clipboardSetText, jstr); | 972 env->CallVoidMethod(_dw_obj, clipboardSetText, jstr); |
973 _dw_jni_check_exception(env); | |
928 } | 974 } |
929 } | 975 } |
930 | 976 |
931 /* | 977 /* |
932 * Allocates and initializes a dialog struct. | 978 * Allocates and initializes a dialog struct. |
1006 // First get the class that contains the method you need to call | 1052 // First get the class that contains the method you need to call |
1007 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1053 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1008 // Get the method that you want to call | 1054 // Get the method that you want to call |
1009 jmethodID boxNew = env->GetMethodID(clazz, "boxNew", "(II)Landroid/widget/LinearLayout;"); | 1055 jmethodID boxNew = env->GetMethodID(clazz, "boxNew", "(II)Landroid/widget/LinearLayout;"); |
1010 // Call the method on the object | 1056 // Call the method on the object |
1011 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, boxNew, type, pad)); | 1057 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, boxNew, type, pad), _DW_REFERENCE_WEAK); |
1012 return result; | 1058 return result; |
1013 } | 1059 } |
1014 return nullptr; | 1060 return nullptr; |
1015 } | 1061 } |
1016 | 1062 |
1047 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1093 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1048 // Get the method that you want to call | 1094 // Get the method that you want to call |
1049 jmethodID scrollBoxNew = env->GetMethodID(clazz, "scrollBoxNew", | 1095 jmethodID scrollBoxNew = env->GetMethodID(clazz, "scrollBoxNew", |
1050 "(II)Landroid/widget/ScrollView;"); | 1096 "(II)Landroid/widget/ScrollView;"); |
1051 // Call the method on the object | 1097 // Call the method on the object |
1052 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, scrollBoxNew, type, pad)); | 1098 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, scrollBoxNew, type, pad), _DW_REFERENCE_WEAK); |
1053 return result; | 1099 return result; |
1054 } | 1100 } |
1055 return nullptr; | 1101 return nullptr; |
1056 } | 1102 } |
1057 | 1103 |
1092 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1138 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1093 // Get the method that you want to call | 1139 // Get the method that you want to call |
1094 jmethodID boxPack = env->GetMethodID(clazz, "boxPack", "(Landroid/view/View;Landroid/view/View;IIIIII)V"); | 1140 jmethodID boxPack = env->GetMethodID(clazz, "boxPack", "(Landroid/view/View;Landroid/view/View;IIIIII)V"); |
1095 // Call the method on the object | 1141 // Call the method on the object |
1096 env->CallVoidMethod(_dw_obj, boxPack, box, item, index, width, height, hsize, vsize, pad); | 1142 env->CallVoidMethod(_dw_obj, boxPack, box, item, index, width, height, hsize, vsize, pad); |
1143 _dw_jni_check_exception(env); | |
1097 } | 1144 } |
1098 } | 1145 } |
1099 | 1146 |
1100 /* | 1147 /* |
1101 * Remove windows (widgets) from the box they are packed into. | 1148 * Remove windows (widgets) from the box they are packed into. |
1114 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1161 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1115 // Get the method that you want to call | 1162 // Get the method that you want to call |
1116 jmethodID boxUnpack = env->GetMethodID(clazz, "boxUnpack", "(Landroid/view/View;)V"); | 1163 jmethodID boxUnpack = env->GetMethodID(clazz, "boxUnpack", "(Landroid/view/View;)V"); |
1117 // Call the method on the object | 1164 // Call the method on the object |
1118 env->CallVoidMethod(_dw_obj, boxUnpack, handle); | 1165 env->CallVoidMethod(_dw_obj, boxUnpack, handle); |
1166 _dw_jni_check_exception(env); | |
1119 return DW_ERROR_NONE; | 1167 return DW_ERROR_NONE; |
1120 } | 1168 } |
1121 return DW_ERROR_GENERAL; | 1169 return DW_ERROR_GENERAL; |
1122 } | 1170 } |
1123 | 1171 |
1139 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1187 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1140 // Get the method that you want to call | 1188 // Get the method that you want to call |
1141 jmethodID boxUnpackAtIndex = env->GetMethodID(clazz, "boxUnpackAtIndex", | 1189 jmethodID boxUnpackAtIndex = env->GetMethodID(clazz, "boxUnpackAtIndex", |
1142 "(Landroid/widget/LinearLayout;I)Landroid/view/View;"); | 1190 "(Landroid/widget/LinearLayout;I)Landroid/view/View;"); |
1143 // Call the method on the object | 1191 // Call the method on the object |
1144 retval = env->CallObjectMethod(_dw_obj, boxUnpackAtIndex, box, index); | 1192 retval = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, boxUnpackAtIndex, box, index), _DW_REFERENCE_WEAK); |
1145 } | 1193 } |
1146 return retval; | 1194 return retval; |
1147 } | 1195 } |
1148 | 1196 |
1149 /* | 1197 /* |
1218 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1266 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1219 // Get the method that you want to call | 1267 // Get the method that you want to call |
1220 jmethodID buttonNew = env->GetMethodID(clazz, "buttonNew", | 1268 jmethodID buttonNew = env->GetMethodID(clazz, "buttonNew", |
1221 "(Ljava/lang/String;I)Landroid/widget/Button;"); | 1269 "(Ljava/lang/String;I)Landroid/widget/Button;"); |
1222 // Call the method on the object | 1270 // Call the method on the object |
1223 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, buttonNew, jstr, (int)cid)); | 1271 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, buttonNew, jstr, (int)cid), _DW_REFERENCE_WEAK); |
1224 return result; | 1272 return result; |
1225 } | 1273 } |
1226 return nullptr; | 1274 return nullptr; |
1227 } | 1275 } |
1228 | 1276 |
1238 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1286 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1239 // Get the method that you want to call | 1287 // Get the method that you want to call |
1240 jmethodID entryfieldNew = env->GetMethodID(clazz, "entryfieldNew", | 1288 jmethodID entryfieldNew = env->GetMethodID(clazz, "entryfieldNew", |
1241 "(Ljava/lang/String;II)Landroid/widget/EditText;"); | 1289 "(Ljava/lang/String;II)Landroid/widget/EditText;"); |
1242 // Call the method on the object | 1290 // Call the method on the object |
1243 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, entryfieldNew, jstr, (int)cid, password)); | 1291 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, entryfieldNew, jstr, (int)cid, password), _DW_REFERENCE_WEAK); |
1244 return result; | 1292 return result; |
1245 } | 1293 } |
1246 return nullptr; | 1294 return nullptr; |
1247 } | 1295 } |
1248 /* | 1296 /* |
1288 // Get the method that you want to call | 1336 // Get the method that you want to call |
1289 jmethodID entryfieldSetLimit = env->GetMethodID(clazz, "entryfieldSetLimit", | 1337 jmethodID entryfieldSetLimit = env->GetMethodID(clazz, "entryfieldSetLimit", |
1290 "(Landroid/widget/EditText;J)V"); | 1338 "(Landroid/widget/EditText;J)V"); |
1291 // Call the method on the object | 1339 // Call the method on the object |
1292 env->CallVoidMethod(_dw_obj, entryfieldSetLimit, handle, (jlong)limit); | 1340 env->CallVoidMethod(_dw_obj, entryfieldSetLimit, handle, (jlong)limit); |
1341 _dw_jni_check_exception(env); | |
1293 } | 1342 } |
1294 } | 1343 } |
1295 | 1344 |
1296 /* | 1345 /* |
1297 * Create a new bitmap button window (widget) to be packed. | 1346 * Create a new bitmap button window (widget) to be packed. |
1313 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1362 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1314 // Get the method that you want to call | 1363 // Get the method that you want to call |
1315 jmethodID bitmapButtonNew = env->GetMethodID(clazz, "bitmapButtonNew", | 1364 jmethodID bitmapButtonNew = env->GetMethodID(clazz, "bitmapButtonNew", |
1316 "(Ljava/lang/String;I)Landroid/widget/ImageButton;"); | 1365 "(Ljava/lang/String;I)Landroid/widget/ImageButton;"); |
1317 // Call the method on the object | 1366 // Call the method on the object |
1318 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, bitmapButtonNew, jstr, (int)resid)); | 1367 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, bitmapButtonNew, jstr, (int)resid), _DW_REFERENCE_WEAK); |
1319 return result; | 1368 return result; |
1320 } | 1369 } |
1321 return nullptr; | 1370 return nullptr; |
1322 } | 1371 } |
1323 | 1372 |
1345 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1394 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1346 // Get the method that you want to call | 1395 // Get the method that you want to call |
1347 jmethodID bitmapButtonNewFromFile = env->GetMethodID(clazz, "bitmapButtonNewFromFile", | 1396 jmethodID bitmapButtonNewFromFile = env->GetMethodID(clazz, "bitmapButtonNewFromFile", |
1348 "(Ljava/lang/String;ILjava/lang/String;)Landroid/widget/ImageButton;"); | 1397 "(Ljava/lang/String;ILjava/lang/String;)Landroid/widget/ImageButton;"); |
1349 // Call the method on the object | 1398 // Call the method on the object |
1350 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, bitmapButtonNewFromFile, jstr, (int)cid, path)); | 1399 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, bitmapButtonNewFromFile, jstr, (int)cid, path), _DW_REFERENCE_WEAK); |
1351 return result; | 1400 return result; |
1352 } | 1401 } |
1353 return nullptr; | 1402 return nullptr; |
1354 } | 1403 } |
1355 | 1404 |
1379 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1428 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1380 // Get the method that you want to call | 1429 // Get the method that you want to call |
1381 jmethodID bitmapButtonNewFromData = env->GetMethodID(clazz, "bitmapButtonNewFromData", | 1430 jmethodID bitmapButtonNewFromData = env->GetMethodID(clazz, "bitmapButtonNewFromData", |
1382 "(Ljava/lang/String;I[BI)Landroid/widget/ImageButton;"); | 1431 "(Ljava/lang/String;I[BI)Landroid/widget/ImageButton;"); |
1383 // Call the method on the object | 1432 // Call the method on the object |
1384 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, bitmapButtonNewFromData, jstr, (int)cid, bytearray, len)); | 1433 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, bitmapButtonNewFromData, jstr, (int)cid, bytearray, len), _DW_REFERENCE_WEAK); |
1385 // Clean up after the array now that we are finished | 1434 // Clean up after the array now that we are finished |
1386 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0); | 1435 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0); |
1387 return result; | 1436 return result; |
1388 } | 1437 } |
1389 return nullptr; | 1438 return nullptr; |
1409 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1458 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1410 // Get the method that you want to call | 1459 // Get the method that you want to call |
1411 jmethodID spinButtonNew = env->GetMethodID(clazz, "spinButtonNew", | 1460 jmethodID spinButtonNew = env->GetMethodID(clazz, "spinButtonNew", |
1412 "(Ljava/lang/String;I)Lorg/dbsoft/dwindows/DWSpinButton;"); | 1461 "(Ljava/lang/String;I)Lorg/dbsoft/dwindows/DWSpinButton;"); |
1413 // Call the method on the object | 1462 // Call the method on the object |
1414 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, spinButtonNew, jstr, (int)cid)); | 1463 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, spinButtonNew, jstr, (int)cid), _DW_REFERENCE_WEAK); |
1415 return result; | 1464 return result; |
1416 } | 1465 } |
1417 return nullptr; | 1466 return nullptr; |
1418 } | 1467 } |
1419 | 1468 |
1434 // Get the method that you want to call | 1483 // Get the method that you want to call |
1435 jmethodID spinButtonSetPos = env->GetMethodID(clazz, "spinButtonSetPos", | 1484 jmethodID spinButtonSetPos = env->GetMethodID(clazz, "spinButtonSetPos", |
1436 "(Lorg/dbsoft/dwindows/DWSpinButton;J)V"); | 1485 "(Lorg/dbsoft/dwindows/DWSpinButton;J)V"); |
1437 // Call the method on the object | 1486 // Call the method on the object |
1438 env->CallVoidMethod(_dw_obj, spinButtonSetPos, handle, (jlong)position); | 1487 env->CallVoidMethod(_dw_obj, spinButtonSetPos, handle, (jlong)position); |
1488 _dw_jni_check_exception(env); | |
1439 } | 1489 } |
1440 } | 1490 } |
1441 | 1491 |
1442 /* | 1492 /* |
1443 * Sets the spinbutton limits. | 1493 * Sets the spinbutton limits. |
1457 // Get the method that you want to call | 1507 // Get the method that you want to call |
1458 jmethodID spinButtonSetLimits = env->GetMethodID(clazz, "spinButtonSetLimits", | 1508 jmethodID spinButtonSetLimits = env->GetMethodID(clazz, "spinButtonSetLimits", |
1459 "(Lorg/dbsoft/dwindows/DWSpinButton;JJ)V"); | 1509 "(Lorg/dbsoft/dwindows/DWSpinButton;JJ)V"); |
1460 // Call the method on the object | 1510 // Call the method on the object |
1461 env->CallVoidMethod(_dw_obj, spinButtonSetLimits, handle, (jlong)upper, (jlong)lower); | 1511 env->CallVoidMethod(_dw_obj, spinButtonSetLimits, handle, (jlong)upper, (jlong)lower); |
1512 _dw_jni_check_exception(env); | |
1462 } | 1513 } |
1463 } | 1514 } |
1464 | 1515 |
1465 /* | 1516 /* |
1466 * Returns the current value of the spinbutton. | 1517 * Returns the current value of the spinbutton. |
1481 // Get the method that you want to call | 1532 // Get the method that you want to call |
1482 jmethodID spinButtonGetPos = env->GetMethodID(clazz, "spinButtonGetPos", | 1533 jmethodID spinButtonGetPos = env->GetMethodID(clazz, "spinButtonGetPos", |
1483 "(Lorg/dbsoft/dwindows/DWSpinButton;)J"); | 1534 "(Lorg/dbsoft/dwindows/DWSpinButton;)J"); |
1484 // Call the method on the object | 1535 // Call the method on the object |
1485 retval = env->CallLongMethod(_dw_obj, spinButtonGetPos, handle); | 1536 retval = env->CallLongMethod(_dw_obj, spinButtonGetPos, handle); |
1537 if(_dw_jni_check_exception(env)) | |
1538 retval = 0; | |
1486 } | 1539 } |
1487 return retval; | 1540 return retval; |
1488 } | 1541 } |
1489 | 1542 |
1490 /* | 1543 /* |
1507 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1560 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1508 // Get the method that you want to call | 1561 // Get the method that you want to call |
1509 jmethodID radioButtonNew = env->GetMethodID(clazz, "radioButtonNew", | 1562 jmethodID radioButtonNew = env->GetMethodID(clazz, "radioButtonNew", |
1510 "(Ljava/lang/String;I)Landroid/widget/RadioButton;"); | 1563 "(Ljava/lang/String;I)Landroid/widget/RadioButton;"); |
1511 // Call the method on the object | 1564 // Call the method on the object |
1512 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, radioButtonNew, jstr, (int)cid)); | 1565 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, radioButtonNew, jstr, (int)cid), _DW_REFERENCE_WEAK); |
1513 return result; | 1566 return result; |
1514 } | 1567 } |
1515 return nullptr; | 1568 return nullptr; |
1516 } | 1569 } |
1517 | 1570 |
1533 // First get the class that contains the method you need to call | 1586 // First get the class that contains the method you need to call |
1534 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1587 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1535 // Get the method that you want to call | 1588 // Get the method that you want to call |
1536 jmethodID sliderNew = env->GetMethodID(clazz, "sliderNew", "(III)Landroid/widget/SeekBar;"); | 1589 jmethodID sliderNew = env->GetMethodID(clazz, "sliderNew", "(III)Landroid/widget/SeekBar;"); |
1537 // Call the method on the object | 1590 // Call the method on the object |
1538 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, sliderNew, vertical, increments, (jint)cid)); | 1591 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, sliderNew, vertical, increments, (jint)cid), _DW_REFERENCE_WEAK); |
1539 return result; | 1592 return result; |
1540 } | 1593 } |
1541 return nullptr; | 1594 return nullptr; |
1542 } | 1595 } |
1543 | 1596 |
1549 * Position of the slider in the set range. | 1602 * Position of the slider in the set range. |
1550 */ | 1603 */ |
1551 unsigned int API dw_slider_get_pos(HWND handle) | 1604 unsigned int API dw_slider_get_pos(HWND handle) |
1552 { | 1605 { |
1553 JNIEnv *env; | 1606 JNIEnv *env; |
1607 unsigned int retval = 0; | |
1554 | 1608 |
1555 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | 1609 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) |
1556 { | 1610 { |
1557 // First get the class that contains the method you need to call | 1611 // First get the class that contains the method you need to call |
1558 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1612 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1559 // Get the method that you want to call | 1613 // Get the method that you want to call |
1560 jmethodID percentGetPos = env->GetMethodID(clazz, "percentGetPos", | 1614 jmethodID percentGetPos = env->GetMethodID(clazz, "percentGetPos", |
1561 "(Landroid/widget/ProgressBar;)I"); | 1615 "(Landroid/widget/ProgressBar;)I"); |
1562 // Call the method on the object | 1616 // Call the method on the object |
1563 return env->CallIntMethod(_dw_obj, percentGetPos, handle); | 1617 retval = env->CallIntMethod(_dw_obj, percentGetPos, handle); |
1564 } | 1618 if(_dw_jni_check_exception(env)) |
1565 return 0; | 1619 retval = 0; |
1620 } | |
1621 return retval; | |
1566 } | 1622 } |
1567 | 1623 |
1568 /* | 1624 /* |
1569 * Sets the slider position. | 1625 * Sets the slider position. |
1570 * Parameters: | 1626 * Parameters: |
1630 // Get the method that you want to call | 1686 // Get the method that you want to call |
1631 jmethodID percentSetRange = env->GetMethodID(clazz, "percentSetRange", | 1687 jmethodID percentSetRange = env->GetMethodID(clazz, "percentSetRange", |
1632 "(Landroid/widget/ProgressBar;I)V"); | 1688 "(Landroid/widget/ProgressBar;I)V"); |
1633 // Call the method on the object | 1689 // Call the method on the object |
1634 env->CallVoidMethod(_dw_obj, percentSetRange, handle, (jint)range); | 1690 env->CallVoidMethod(_dw_obj, percentSetRange, handle, (jint)range); |
1691 _dw_jni_check_exception(env); | |
1635 } | 1692 } |
1636 } | 1693 } |
1637 | 1694 |
1638 /* | 1695 /* |
1639 * Create a new percent bar window (widget) to be packed. | 1696 * Create a new percent bar window (widget) to be packed. |
1652 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1709 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1653 // Get the method that you want to call | 1710 // Get the method that you want to call |
1654 jmethodID percentNew = env->GetMethodID(clazz, "percentNew", | 1711 jmethodID percentNew = env->GetMethodID(clazz, "percentNew", |
1655 "(I)Landroid/widget/ProgressBar;"); | 1712 "(I)Landroid/widget/ProgressBar;"); |
1656 // Call the method on the object | 1713 // Call the method on the object |
1657 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, percentNew, (jint)cid)); | 1714 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, percentNew, (jint)cid), _DW_REFERENCE_WEAK); |
1658 return result; | 1715 return result; |
1659 } | 1716 } |
1660 return nullptr; | 1717 return nullptr; |
1661 } | 1718 } |
1662 | 1719 |
1677 // Get the method that you want to call | 1734 // Get the method that you want to call |
1678 jmethodID percentSetPos = env->GetMethodID(clazz, "percentSetPos", | 1735 jmethodID percentSetPos = env->GetMethodID(clazz, "percentSetPos", |
1679 "(Landroid/widget/ProgressBar;I)V"); | 1736 "(Landroid/widget/ProgressBar;I)V"); |
1680 // Call the method on the object | 1737 // Call the method on the object |
1681 env->CallVoidMethod(_dw_obj, percentSetPos, handle, (jint)position); | 1738 env->CallVoidMethod(_dw_obj, percentSetPos, handle, (jint)position); |
1739 _dw_jni_check_exception(env); | |
1682 } | 1740 } |
1683 } | 1741 } |
1684 | 1742 |
1685 /* | 1743 /* |
1686 * Create a new checkbox window (widget) to be packed. | 1744 * Create a new checkbox window (widget) to be packed. |
1702 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1760 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1703 // Get the method that you want to call | 1761 // Get the method that you want to call |
1704 jmethodID checkboxNew = env->GetMethodID(clazz, "checkboxNew", | 1762 jmethodID checkboxNew = env->GetMethodID(clazz, "checkboxNew", |
1705 "(Ljava/lang/String;I)Landroid/widget/CheckBox;"); | 1763 "(Ljava/lang/String;I)Landroid/widget/CheckBox;"); |
1706 // Call the method on the object | 1764 // Call the method on the object |
1707 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, checkboxNew, jstr, (int)cid)); | 1765 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, checkboxNew, jstr, (int)cid), _DW_REFERENCE_WEAK); |
1708 return result; | 1766 return result; |
1709 } | 1767 } |
1710 return nullptr; | 1768 return nullptr; |
1711 } | 1769 } |
1712 | 1770 |
1718 * State of checkbox (TRUE or FALSE). | 1776 * State of checkbox (TRUE or FALSE). |
1719 */ | 1777 */ |
1720 int API dw_checkbox_get(HWND handle) | 1778 int API dw_checkbox_get(HWND handle) |
1721 { | 1779 { |
1722 JNIEnv *env; | 1780 JNIEnv *env; |
1781 int retval = FALSE; | |
1723 | 1782 |
1724 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | 1783 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) |
1725 { | 1784 { |
1726 // First get the class that contains the method you need to call | 1785 // First get the class that contains the method you need to call |
1727 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1786 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1728 // Get the method that you want to call | 1787 // Get the method that you want to call |
1729 jmethodID checkOrRadioGetChecked = env->GetMethodID(clazz, "checkOrRadioGetChecked", | 1788 jmethodID checkOrRadioGetChecked = env->GetMethodID(clazz, "checkOrRadioGetChecked", |
1730 "(Landroid/view/View;)Z"); | 1789 "(Landroid/view/View;)Z"); |
1731 // Call the method on the object | 1790 // Call the method on the object |
1732 return env->CallBooleanMethod(_dw_obj, checkOrRadioGetChecked, handle); | 1791 retval = env->CallBooleanMethod(_dw_obj, checkOrRadioGetChecked, handle); |
1733 } | 1792 if(_dw_jni_check_exception(env)) |
1734 return FALSE; | 1793 retval = FALSE; |
1794 } | |
1795 return retval; | |
1735 } | 1796 } |
1736 | 1797 |
1737 /* | 1798 /* |
1738 * Sets the state of the checkbox. | 1799 * Sets the state of the checkbox. |
1739 * Parameters: | 1800 * Parameters: |
1751 // Get the method that you want to call | 1812 // Get the method that you want to call |
1752 jmethodID checkOrRadioSetChecked = env->GetMethodID(clazz, "checkOrRadioSetChecked", | 1813 jmethodID checkOrRadioSetChecked = env->GetMethodID(clazz, "checkOrRadioSetChecked", |
1753 "(Landroid/view/View;I)V"); | 1814 "(Landroid/view/View;I)V"); |
1754 // Call the method on the object | 1815 // Call the method on the object |
1755 env->CallVoidMethod(_dw_obj, checkOrRadioSetChecked, handle, value); | 1816 env->CallVoidMethod(_dw_obj, checkOrRadioSetChecked, handle, value); |
1817 _dw_jni_check_exception(env); | |
1756 } | 1818 } |
1757 } | 1819 } |
1758 | 1820 |
1759 /* | 1821 /* |
1760 * Create a new listbox window (widget) to be packed. | 1822 * Create a new listbox window (widget) to be packed. |
1774 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 1836 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1775 // Get the method that you want to call | 1837 // Get the method that you want to call |
1776 jmethodID listBoxNew = env->GetMethodID(clazz, "listBoxNew", | 1838 jmethodID listBoxNew = env->GetMethodID(clazz, "listBoxNew", |
1777 "(II)Lorg/dbsoft/dwindows/DWListBox;"); | 1839 "(II)Lorg/dbsoft/dwindows/DWListBox;"); |
1778 // Call the method on the object | 1840 // Call the method on the object |
1779 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, listBoxNew, (int)cid, multi)); | 1841 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, listBoxNew, (int)cid, multi), _DW_REFERENCE_WEAK); |
1780 return result; | 1842 return result; |
1781 } | 1843 } |
1782 return nullptr; | 1844 return nullptr; |
1783 } | 1845 } |
1784 | 1846 |
1801 // Get the method that you want to call | 1863 // Get the method that you want to call |
1802 jmethodID listOrComboBoxAppend = env->GetMethodID(clazz, "listOrComboBoxAppend", | 1864 jmethodID listOrComboBoxAppend = env->GetMethodID(clazz, "listOrComboBoxAppend", |
1803 "(Landroid/view/View;Ljava/lang/String;)V"); | 1865 "(Landroid/view/View;Ljava/lang/String;)V"); |
1804 // Call the method on the object | 1866 // Call the method on the object |
1805 env->CallVoidMethod(_dw_obj, listOrComboBoxAppend, handle, jstr); | 1867 env->CallVoidMethod(_dw_obj, listOrComboBoxAppend, handle, jstr); |
1868 _dw_jni_check_exception(env); | |
1806 } | 1869 } |
1807 } | 1870 } |
1808 | 1871 |
1809 /* | 1872 /* |
1810 * Inserts the specified text into the listbox's (or combobox) entry list. | 1873 * Inserts the specified text into the listbox's (or combobox) entry list. |
1826 // Get the method that you want to call | 1889 // Get the method that you want to call |
1827 jmethodID listOrComboBoxInsert = env->GetMethodID(clazz, "listOrComboBoxInsert", | 1890 jmethodID listOrComboBoxInsert = env->GetMethodID(clazz, "listOrComboBoxInsert", |
1828 "(Landroid/view/View;Ljava/lang/String;I)V"); | 1891 "(Landroid/view/View;Ljava/lang/String;I)V"); |
1829 // Call the method on the object | 1892 // Call the method on the object |
1830 env->CallVoidMethod(_dw_obj, listOrComboBoxInsert, handle, jstr, pos); | 1893 env->CallVoidMethod(_dw_obj, listOrComboBoxInsert, handle, jstr, pos); |
1894 _dw_jni_check_exception(env); | |
1831 } | 1895 } |
1832 } | 1896 } |
1833 | 1897 |
1834 /* | 1898 /* |
1835 * Appends the specified text items to the listbox's (or combobox) entry list. | 1899 * Appends the specified text items to the listbox's (or combobox) entry list. |
1863 // Get the method that you want to call | 1927 // Get the method that you want to call |
1864 jmethodID listOrComboBoxClear = env->GetMethodID(clazz, "listOrComboBoxClear", | 1928 jmethodID listOrComboBoxClear = env->GetMethodID(clazz, "listOrComboBoxClear", |
1865 "(Landroid/view/View;)V"); | 1929 "(Landroid/view/View;)V"); |
1866 // Call the method on the object | 1930 // Call the method on the object |
1867 env->CallVoidMethod(_dw_obj, listOrComboBoxClear, handle); | 1931 env->CallVoidMethod(_dw_obj, listOrComboBoxClear, handle); |
1932 _dw_jni_check_exception(env); | |
1868 } | 1933 } |
1869 } | 1934 } |
1870 | 1935 |
1871 /* | 1936 /* |
1872 * Returns the listbox's item count. | 1937 * Returns the listbox's item count. |
1887 // Get the method that you want to call | 1952 // Get the method that you want to call |
1888 jmethodID listOrComboBoxCount = env->GetMethodID(clazz, "listOrComboBoxCount", | 1953 jmethodID listOrComboBoxCount = env->GetMethodID(clazz, "listOrComboBoxCount", |
1889 "(Landroid/view/View;)I"); | 1954 "(Landroid/view/View;)I"); |
1890 // Call the method on the object | 1955 // Call the method on the object |
1891 retval = env->CallIntMethod(_dw_obj, listOrComboBoxCount, handle); | 1956 retval = env->CallIntMethod(_dw_obj, listOrComboBoxCount, handle); |
1957 if(_dw_jni_check_exception(env)) | |
1958 retval = 0; | |
1892 } | 1959 } |
1893 return retval; | 1960 return retval; |
1894 } | 1961 } |
1895 | 1962 |
1896 /* | 1963 /* |
1910 // Get the method that you want to call | 1977 // Get the method that you want to call |
1911 jmethodID listBoxSetTop = env->GetMethodID(clazz, "listBoxSetTop", | 1978 jmethodID listBoxSetTop = env->GetMethodID(clazz, "listBoxSetTop", |
1912 "(Landroid/view/View;I)V"); | 1979 "(Landroid/view/View;I)V"); |
1913 // Call the method on the object | 1980 // Call the method on the object |
1914 env->CallVoidMethod(_dw_obj, listBoxSetTop, handle, top); | 1981 env->CallVoidMethod(_dw_obj, listBoxSetTop, handle, top); |
1982 _dw_jni_check_exception(env); | |
1915 } | 1983 } |
1916 } | 1984 } |
1917 | 1985 |
1918 /* | 1986 /* |
1919 * Copies the given index item's text into buffer. | 1987 * Copies the given index item's text into buffer. |
1933 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 2001 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
1934 // Get the method that you want to call | 2002 // Get the method that you want to call |
1935 jmethodID listOrComboBoxGetText = env->GetMethodID(clazz, "listOrComboBoxGetText", | 2003 jmethodID listOrComboBoxGetText = env->GetMethodID(clazz, "listOrComboBoxGetText", |
1936 "(Landroid/view/View;I)Ljava/lang/String;"); | 2004 "(Landroid/view/View;I)Ljava/lang/String;"); |
1937 // Call the method on the object | 2005 // Call the method on the object |
1938 jstring result = (jstring)env->CallObjectMethod(_dw_obj, listOrComboBoxGetText, handle, index); | 2006 jstring result = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, listOrComboBoxGetText, handle, index), _DW_REFERENCE_NONE); |
1939 // Get the UTF8 string result | 2007 // Get the UTF8 string result |
1940 if(result) | 2008 if(result) |
1941 { | 2009 { |
1942 const char *utf8 = env->GetStringUTFChars(result, nullptr); | 2010 const char *utf8 = env->GetStringUTFChars(result, nullptr); |
1943 | 2011 |
1966 // Get the method that you want to call | 2034 // Get the method that you want to call |
1967 jmethodID listOrComboBoxSetText = env->GetMethodID(clazz, "listOrComboBoxSetText", | 2035 jmethodID listOrComboBoxSetText = env->GetMethodID(clazz, "listOrComboBoxSetText", |
1968 "(Landroid/view/View;ILjava/lang/String;)V"); | 2036 "(Landroid/view/View;ILjava/lang/String;)V"); |
1969 // Call the method on the object | 2037 // Call the method on the object |
1970 env->CallVoidMethod(_dw_obj, listOrComboBoxSetText, handle, index, jstr); | 2038 env->CallVoidMethod(_dw_obj, listOrComboBoxSetText, handle, index, jstr); |
2039 _dw_jni_check_exception(env); | |
1971 } | 2040 } |
1972 } | 2041 } |
1973 | 2042 |
1974 /* | 2043 /* |
1975 * Returns the index to the item in the list currently selected. | 2044 * Returns the index to the item in the list currently selected. |
1990 // Get the method that you want to call | 2059 // Get the method that you want to call |
1991 jmethodID listOrComboBoxGetSelected = env->GetMethodID(clazz, "listOrComboBoxGetSelected", | 2060 jmethodID listOrComboBoxGetSelected = env->GetMethodID(clazz, "listOrComboBoxGetSelected", |
1992 "(Landroid/view/View;)I"); | 2061 "(Landroid/view/View;)I"); |
1993 // Call the method on the object | 2062 // Call the method on the object |
1994 retval = env->CallIntMethod(_dw_obj, listOrComboBoxGetSelected, handle); | 2063 retval = env->CallIntMethod(_dw_obj, listOrComboBoxGetSelected, handle); |
2064 if(_dw_jni_check_exception(env)) | |
2065 retval = DW_ERROR_UNKNOWN; | |
1995 } | 2066 } |
1996 return retval; | 2067 return retval; |
1997 } | 2068 } |
1998 | 2069 |
1999 /* | 2070 /* |
2016 // Get the method that you want to call | 2087 // Get the method that you want to call |
2017 jmethodID listBoxSelectedMulti = env->GetMethodID(clazz, "listBoxSelectedMulti", | 2088 jmethodID listBoxSelectedMulti = env->GetMethodID(clazz, "listBoxSelectedMulti", |
2018 "(Landroid/view/View;I)I"); | 2089 "(Landroid/view/View;I)I"); |
2019 // Call the method on the object | 2090 // Call the method on the object |
2020 retval = env->CallIntMethod(_dw_obj, listBoxSelectedMulti, handle, where); | 2091 retval = env->CallIntMethod(_dw_obj, listBoxSelectedMulti, handle, where); |
2092 if(_dw_jni_check_exception(env)) | |
2093 retval = DW_ERROR_UNKNOWN; | |
2021 } | 2094 } |
2022 return retval; | 2095 return retval; |
2023 } | 2096 } |
2024 | 2097 |
2025 /* | 2098 /* |
2040 // Get the method that you want to call | 2113 // Get the method that you want to call |
2041 jmethodID listOrComboBoxSelect = env->GetMethodID(clazz, "listOrComboBoxSelect", | 2114 jmethodID listOrComboBoxSelect = env->GetMethodID(clazz, "listOrComboBoxSelect", |
2042 "(Landroid/view/View;II)V"); | 2115 "(Landroid/view/View;II)V"); |
2043 // Call the method on the object | 2116 // Call the method on the object |
2044 env->CallVoidMethod(_dw_obj, listOrComboBoxSelect, handle, index, state); | 2117 env->CallVoidMethod(_dw_obj, listOrComboBoxSelect, handle, index, state); |
2118 _dw_jni_check_exception(env); | |
2045 } | 2119 } |
2046 } | 2120 } |
2047 | 2121 |
2048 /* | 2122 /* |
2049 * Deletes the item with given index from the list. | 2123 * Deletes the item with given index from the list. |
2062 // Get the method that you want to call | 2136 // Get the method that you want to call |
2063 jmethodID listOrComboBoxDelete = env->GetMethodID(clazz, "listOrComboBoxDelete", | 2137 jmethodID listOrComboBoxDelete = env->GetMethodID(clazz, "listOrComboBoxDelete", |
2064 "(Landroid/view/View;I)V"); | 2138 "(Landroid/view/View;I)V"); |
2065 // Call the method on the object | 2139 // Call the method on the object |
2066 env->CallVoidMethod(_dw_obj, listOrComboBoxDelete, handle, index); | 2140 env->CallVoidMethod(_dw_obj, listOrComboBoxDelete, handle, index); |
2141 _dw_jni_check_exception(env); | |
2067 } | 2142 } |
2068 } | 2143 } |
2069 | 2144 |
2070 /* | 2145 /* |
2071 * Create a new Combobox window (widget) to be packed. | 2146 * Create a new Combobox window (widget) to be packed. |
2087 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 2162 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
2088 // Get the method that you want to call | 2163 // Get the method that you want to call |
2089 jmethodID comboBoxNew = env->GetMethodID(clazz, "comboBoxNew", | 2164 jmethodID comboBoxNew = env->GetMethodID(clazz, "comboBoxNew", |
2090 "(Ljava/lang/String;I)Lorg/dbsoft/dwindows/DWComboBox;"); | 2165 "(Ljava/lang/String;I)Lorg/dbsoft/dwindows/DWComboBox;"); |
2091 // Call the method on the object | 2166 // Call the method on the object |
2092 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, comboBoxNew, jstr, (int)cid)); | 2167 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, comboBoxNew, jstr, (int)cid), _DW_REFERENCE_WEAK); |
2093 return result; | 2168 return result; |
2094 } | 2169 } |
2095 return nullptr; | 2170 return nullptr; |
2096 } | 2171 } |
2097 | 2172 |
2112 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 2187 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
2113 // Get the method that you want to call | 2188 // Get the method that you want to call |
2114 jmethodID mleNew = env->GetMethodID(clazz, "mleNew", | 2189 jmethodID mleNew = env->GetMethodID(clazz, "mleNew", |
2115 "(I)Landroid/widget/EditText;"); | 2190 "(I)Landroid/widget/EditText;"); |
2116 // Call the method on the object | 2191 // Call the method on the object |
2117 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, mleNew, (int)cid)); | 2192 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, mleNew, (int)cid), _DW_REFERENCE_WEAK); |
2118 return result; | 2193 return result; |
2119 } | 2194 } |
2120 return nullptr; | 2195 return nullptr; |
2121 } | 2196 } |
2122 | 2197 |
2143 // Get the method that you want to call | 2218 // Get the method that you want to call |
2144 jmethodID mleImport = env->GetMethodID(clazz, "mleImport", | 2219 jmethodID mleImport = env->GetMethodID(clazz, "mleImport", |
2145 "(Landroid/widget/EditText;Ljava/lang/String;I)I"); | 2220 "(Landroid/widget/EditText;Ljava/lang/String;I)I"); |
2146 // Call the method on the object | 2221 // Call the method on the object |
2147 retval = env->CallIntMethod(_dw_obj, mleImport, handle, jstr, startpoint); | 2222 retval = env->CallIntMethod(_dw_obj, mleImport, handle, jstr, startpoint); |
2223 if(_dw_jni_check_exception(env)) | |
2224 retval = 0; | |
2148 } | 2225 } |
2149 return retval; | 2226 return retval; |
2150 } | 2227 } |
2151 | 2228 |
2152 /* | 2229 /* |
2228 // Get the method that you want to call | 2305 // Get the method that you want to call |
2229 jmethodID mleDelete = env->GetMethodID(clazz, "mleDelete", | 2306 jmethodID mleDelete = env->GetMethodID(clazz, "mleDelete", |
2230 "(Landroid/widget/EditText;II)V"); | 2307 "(Landroid/widget/EditText;II)V"); |
2231 // Call the method on the object | 2308 // Call the method on the object |
2232 env->CallVoidMethod(_dw_obj, mleDelete, handle, startpoint, length); | 2309 env->CallVoidMethod(_dw_obj, mleDelete, handle, startpoint, length); |
2310 _dw_jni_check_exception(env); | |
2233 } | 2311 } |
2234 } | 2312 } |
2235 | 2313 |
2236 /* | 2314 /* |
2237 * Clears all text from an MLE box. | 2315 * Clears all text from an MLE box. |
2249 // Get the method that you want to call | 2327 // Get the method that you want to call |
2250 jmethodID mleClear = env->GetMethodID(clazz, "mleClear", | 2328 jmethodID mleClear = env->GetMethodID(clazz, "mleClear", |
2251 "(Landroid/widget/EditText;)V"); | 2329 "(Landroid/widget/EditText;)V"); |
2252 // Call the method on the object | 2330 // Call the method on the object |
2253 env->CallVoidMethod(_dw_obj, mleClear, handle); | 2331 env->CallVoidMethod(_dw_obj, mleClear, handle); |
2332 _dw_jni_check_exception(env); | |
2254 } | 2333 } |
2255 } | 2334 } |
2256 | 2335 |
2257 /* | 2336 /* |
2258 * Sets the visible line of an MLE box. | 2337 * Sets the visible line of an MLE box. |
2281 // Get the method that you want to call | 2360 // Get the method that you want to call |
2282 jmethodID mleSetEditable = env->GetMethodID(clazz, "mleSetEditable", | 2361 jmethodID mleSetEditable = env->GetMethodID(clazz, "mleSetEditable", |
2283 "(Landroid/widget/EditText;I)V"); | 2362 "(Landroid/widget/EditText;I)V"); |
2284 // Call the method on the object | 2363 // Call the method on the object |
2285 env->CallVoidMethod(_dw_obj, mleSetEditable, handle, state); | 2364 env->CallVoidMethod(_dw_obj, mleSetEditable, handle, state); |
2365 _dw_jni_check_exception(env); | |
2286 } | 2366 } |
2287 } | 2367 } |
2288 | 2368 |
2289 /* | 2369 /* |
2290 * Sets the word wrap state of an MLE box. | 2370 * Sets the word wrap state of an MLE box. |
2303 // Get the method that you want to call | 2383 // Get the method that you want to call |
2304 jmethodID mleSetWordWrap = env->GetMethodID(clazz, "mleSetWordWrap", | 2384 jmethodID mleSetWordWrap = env->GetMethodID(clazz, "mleSetWordWrap", |
2305 "(Landroid/widget/EditText;I)V"); | 2385 "(Landroid/widget/EditText;I)V"); |
2306 // Call the method on the object | 2386 // Call the method on the object |
2307 env->CallVoidMethod(_dw_obj, mleSetWordWrap, handle, state); | 2387 env->CallVoidMethod(_dw_obj, mleSetWordWrap, handle, state); |
2388 _dw_jni_check_exception(env); | |
2308 } | 2389 } |
2309 } | 2390 } |
2310 | 2391 |
2311 /* | 2392 /* |
2312 * Sets the current cursor position of an MLE box. | 2393 * Sets the current cursor position of an MLE box. |
2325 // Get the method that you want to call | 2406 // Get the method that you want to call |
2326 jmethodID mleSetWordWrap = env->GetMethodID(clazz, "mleSetWordWrap", | 2407 jmethodID mleSetWordWrap = env->GetMethodID(clazz, "mleSetWordWrap", |
2327 "(Landroid/widget/EditText;I)V"); | 2408 "(Landroid/widget/EditText;I)V"); |
2328 // Call the method on the object | 2409 // Call the method on the object |
2329 env->CallVoidMethod(_dw_obj, mleSetWordWrap, handle, point); | 2410 env->CallVoidMethod(_dw_obj, mleSetWordWrap, handle, point); |
2411 _dw_jni_check_exception(env); | |
2330 } | 2412 } |
2331 } | 2413 } |
2332 | 2414 |
2333 /* | 2415 /* |
2334 * Sets the word auto complete state of an MLE box. | 2416 * Sets the word auto complete state of an MLE box. |
2385 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 2467 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
2386 // Get the method that you want to call | 2468 // Get the method that you want to call |
2387 jmethodID textNew = env->GetMethodID(clazz, "textNew", | 2469 jmethodID textNew = env->GetMethodID(clazz, "textNew", |
2388 "(Ljava/lang/String;II)Landroid/widget/TextView;"); | 2470 "(Ljava/lang/String;II)Landroid/widget/TextView;"); |
2389 // Call the method on the object | 2471 // Call the method on the object |
2390 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, textNew, jstr, (int)cid, status)); | 2472 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, textNew, jstr, (int)cid, status), _DW_REFERENCE_WEAK); |
2391 return result; | 2473 return result; |
2392 } | 2474 } |
2393 return nullptr; | 2475 return nullptr; |
2394 } | 2476 } |
2395 | 2477 |
2436 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 2518 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
2437 // Get the method that you want to call | 2519 // Get the method that you want to call |
2438 jmethodID renderNew = env->GetMethodID(clazz, "renderNew", | 2520 jmethodID renderNew = env->GetMethodID(clazz, "renderNew", |
2439 "(I)Lorg/dbsoft/dwindows/DWRender;"); | 2521 "(I)Lorg/dbsoft/dwindows/DWRender;"); |
2440 // Call the method on the object | 2522 // Call the method on the object |
2441 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, renderNew, (int)cid)); | 2523 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, renderNew, (int)cid), _DW_REFERENCE_WEAK); |
2442 return result; | 2524 return result; |
2443 } | 2525 } |
2444 return nullptr; | 2526 return nullptr; |
2445 } | 2527 } |
2446 | 2528 |
2460 // Get the method that you want to call | 2542 // Get the method that you want to call |
2461 jmethodID renderRedraw = env->GetMethodID(clazz, "renderRedraw", | 2543 jmethodID renderRedraw = env->GetMethodID(clazz, "renderRedraw", |
2462 "(Lorg/dbsoft/dwindows/DWRender;)V"); | 2544 "(Lorg/dbsoft/dwindows/DWRender;)V"); |
2463 // Call the method on the object | 2545 // Call the method on the object |
2464 env->CallVoidMethod(_dw_obj, renderRedraw, handle); | 2546 env->CallVoidMethod(_dw_obj, renderRedraw, handle); |
2547 _dw_jni_check_exception(env); | |
2465 } | 2548 } |
2466 } | 2549 } |
2467 | 2550 |
2468 /* Sets the current foreground drawing color. | 2551 /* Sets the current foreground drawing color. |
2469 * Parameters: | 2552 * Parameters: |
2484 // Get the method that you want to call | 2567 // Get the method that you want to call |
2485 jmethodID colorSet = env->GetMethodID(clazz, "colorSet", | 2568 jmethodID colorSet = env->GetMethodID(clazz, "colorSet", |
2486 "(IIII)V"); | 2569 "(IIII)V"); |
2487 // Call the method on the object | 2570 // Call the method on the object |
2488 env->CallVoidMethod(_dw_obj, colorSet, 0, (jint)DW_RED_VALUE(color), (jint)DW_GREEN_VALUE(color), (jint)DW_BLUE_VALUE(color)); | 2571 env->CallVoidMethod(_dw_obj, colorSet, 0, (jint)DW_RED_VALUE(color), (jint)DW_GREEN_VALUE(color), (jint)DW_BLUE_VALUE(color)); |
2572 _dw_jni_check_exception(env); | |
2489 } | 2573 } |
2490 } | 2574 } |
2491 | 2575 |
2492 /* Sets the current background drawing color. | 2576 /* Sets the current background drawing color. |
2493 * Parameters: | 2577 * Parameters: |
2508 // Get the method that you want to call | 2592 // Get the method that you want to call |
2509 jmethodID bgColorSet = env->GetMethodID(clazz, "bgColorSet", | 2593 jmethodID bgColorSet = env->GetMethodID(clazz, "bgColorSet", |
2510 "(IIII)V"); | 2594 "(IIII)V"); |
2511 // Call the method on the object | 2595 // Call the method on the object |
2512 env->CallVoidMethod(_dw_obj, bgColorSet, 0, (jint)DW_RED_VALUE(color), (jint)DW_GREEN_VALUE(color), (jint)DW_BLUE_VALUE(color)); | 2596 env->CallVoidMethod(_dw_obj, bgColorSet, 0, (jint)DW_RED_VALUE(color), (jint)DW_GREEN_VALUE(color), (jint)DW_BLUE_VALUE(color)); |
2597 _dw_jni_check_exception(env); | |
2513 } | 2598 } |
2514 } | 2599 } |
2515 | 2600 |
2516 /* Allows the user to choose a color using the system's color chooser dialog. | 2601 /* Allows the user to choose a color using the system's color chooser dialog. |
2517 * Parameters: | 2602 * Parameters: |
2542 // Get the method that you want to call | 2627 // Get the method that you want to call |
2543 jmethodID drawPoint = env->GetMethodID(clazz, "drawPoint", | 2628 jmethodID drawPoint = env->GetMethodID(clazz, "drawPoint", |
2544 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;II)V"); | 2629 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;II)V"); |
2545 // Call the method on the object | 2630 // Call the method on the object |
2546 env->CallVoidMethod(_dw_obj, drawPoint, handle, pixmap ? pixmap->bitmap : nullptr, x, y); | 2631 env->CallVoidMethod(_dw_obj, drawPoint, handle, pixmap ? pixmap->bitmap : nullptr, x, y); |
2632 _dw_jni_check_exception(env); | |
2547 } | 2633 } |
2548 } | 2634 } |
2549 | 2635 |
2550 /* Draw a line on a window (preferably a render window). | 2636 /* Draw a line on a window (preferably a render window). |
2551 * Parameters: | 2637 * Parameters: |
2567 // Get the method that you want to call | 2653 // Get the method that you want to call |
2568 jmethodID drawLine = env->GetMethodID(clazz, "drawLine", | 2654 jmethodID drawLine = env->GetMethodID(clazz, "drawLine", |
2569 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIII)V"); | 2655 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIII)V"); |
2570 // Call the method on the object | 2656 // Call the method on the object |
2571 env->CallVoidMethod(_dw_obj, drawLine, handle, pixmap ? pixmap->bitmap : nullptr, x1, y1, x2, y2); | 2657 env->CallVoidMethod(_dw_obj, drawLine, handle, pixmap ? pixmap->bitmap : nullptr, x1, y1, x2, y2); |
2658 _dw_jni_check_exception(env); | |
2572 } | 2659 } |
2573 } | 2660 } |
2574 | 2661 |
2575 /* Draw text on a window (preferably a render window). | 2662 /* Draw text on a window (preferably a render window). |
2576 * Parameters: | 2663 * Parameters: |
2594 jmethodID drawLine = env->GetMethodID(clazz, "drawText", | 2681 jmethodID drawLine = env->GetMethodID(clazz, "drawText", |
2595 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IILjava/lang/String;Landroid/graphics/Typeface;ILandroid/view/View;)V"); | 2682 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IILjava/lang/String;Landroid/graphics/Typeface;ILandroid/view/View;)V"); |
2596 // Call the method on the object | 2683 // Call the method on the object |
2597 env->CallVoidMethod(_dw_obj, drawLine, handle, pixmap ? pixmap->bitmap : nullptr, x, y, jstr, | 2684 env->CallVoidMethod(_dw_obj, drawLine, handle, pixmap ? pixmap->bitmap : nullptr, x, y, jstr, |
2598 pixmap ? pixmap->typeface : nullptr, pixmap ? pixmap->fontsize : 0, pixmap ? pixmap->handle : nullptr); | 2685 pixmap ? pixmap->typeface : nullptr, pixmap ? pixmap->fontsize : 0, pixmap ? pixmap->handle : nullptr); |
2686 _dw_jni_check_exception(env); | |
2599 } | 2687 } |
2600 } | 2688 } |
2601 | 2689 |
2602 /* Query the width and height of a text string. | 2690 /* Query the width and height of a text string. |
2603 * Parameters: | 2691 * Parameters: |
2621 jmethodID fontTextExtentsGet = env->GetMethodID(clazz, "fontTextExtentsGet", | 2709 jmethodID fontTextExtentsGet = env->GetMethodID(clazz, "fontTextExtentsGet", |
2622 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;Ljava/lang/String;Landroid/graphics/Typeface;ILandroid/view/View;)J"); | 2710 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;Ljava/lang/String;Landroid/graphics/Typeface;ILandroid/view/View;)J"); |
2623 // Call the method on the object | 2711 // Call the method on the object |
2624 jlong dimensions = env->CallLongMethod(_dw_obj, fontTextExtentsGet, handle, pixmap ? pixmap->bitmap : nullptr, jstr, | 2712 jlong dimensions = env->CallLongMethod(_dw_obj, fontTextExtentsGet, handle, pixmap ? pixmap->bitmap : nullptr, jstr, |
2625 pixmap ? pixmap->typeface : nullptr, pixmap ? pixmap->fontsize : 0, pixmap ? pixmap->handle : nullptr); | 2713 pixmap ? pixmap->typeface : nullptr, pixmap ? pixmap->fontsize : 0, pixmap ? pixmap->handle : nullptr); |
2714 if(_dw_jni_check_exception(env)) | |
2715 dimensions = 0; | |
2626 | 2716 |
2627 if(width) | 2717 if(width) |
2628 *width = dimensions & 0xFFFF; | 2718 *width = dimensions & 0xFFFF; |
2629 if(height) | 2719 if(height) |
2630 *height = (dimensions >> 32) & 0xFFFF; | 2720 *height = (dimensions >> 32) & 0xFFFF; |
2659 // Get the method that you want to call | 2749 // Get the method that you want to call |
2660 jmethodID drawPolygon = env->GetMethodID(clazz, "drawPolygon", | 2750 jmethodID drawPolygon = env->GetMethodID(clazz, "drawPolygon", |
2661 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;II[I[I)V"); | 2751 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;II[I[I)V"); |
2662 // Call the method on the object | 2752 // Call the method on the object |
2663 env->CallVoidMethod(_dw_obj, drawPolygon, handle, pixmap ? pixmap->bitmap : nullptr, flags, npoints, jx, jy); | 2753 env->CallVoidMethod(_dw_obj, drawPolygon, handle, pixmap ? pixmap->bitmap : nullptr, flags, npoints, jx, jy); |
2754 _dw_jni_check_exception(env); | |
2664 } | 2755 } |
2665 } | 2756 } |
2666 } | 2757 } |
2667 | 2758 |
2668 /* Draw a rectangle on a window (preferably a render window). | 2759 /* Draw a rectangle on a window (preferably a render window). |
2686 // Get the method that you want to call | 2777 // Get the method that you want to call |
2687 jmethodID drawLine = env->GetMethodID(clazz, "drawRect", | 2778 jmethodID drawLine = env->GetMethodID(clazz, "drawRect", |
2688 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIII)V"); | 2779 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIII)V"); |
2689 // Call the method on the object | 2780 // Call the method on the object |
2690 env->CallVoidMethod(_dw_obj, drawLine, handle, pixmap ? pixmap->bitmap : nullptr, x, y, width, height); | 2781 env->CallVoidMethod(_dw_obj, drawLine, handle, pixmap ? pixmap->bitmap : nullptr, x, y, width, height); |
2782 _dw_jni_check_exception(env); | |
2691 } | 2783 } |
2692 } | 2784 } |
2693 | 2785 |
2694 /* Draw an arc on a window (preferably a render window). | 2786 /* Draw an arc on a window (preferably a render window). |
2695 * Parameters: | 2787 * Parameters: |
2715 // Get the method that you want to call | 2807 // Get the method that you want to call |
2716 jmethodID drawLine = env->GetMethodID(clazz, "drawArc", | 2808 jmethodID drawLine = env->GetMethodID(clazz, "drawArc", |
2717 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIIIIII)V"); | 2809 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIIIIII)V"); |
2718 // Call the method on the object | 2810 // Call the method on the object |
2719 env->CallVoidMethod(_dw_obj, drawLine, handle, pixmap ? pixmap->bitmap : nullptr, flags, xorigin, yorigin, x1, y1, x2, y2); | 2811 env->CallVoidMethod(_dw_obj, drawLine, handle, pixmap ? pixmap->bitmap : nullptr, flags, xorigin, yorigin, x1, y1, x2, y2); |
2812 _dw_jni_check_exception(env); | |
2720 } | 2813 } |
2721 } | 2814 } |
2722 | 2815 |
2723 /* | 2816 /* |
2724 * Create a tree object to be packed. | 2817 * Create a tree object to be packed. |
2895 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 2988 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
2896 // Get the method that you want to call | 2989 // Get the method that you want to call |
2897 jmethodID containerNew = env->GetMethodID(clazz, "containerNew", | 2990 jmethodID containerNew = env->GetMethodID(clazz, "containerNew", |
2898 "(II)Landroid/widget/ListView;"); | 2991 "(II)Landroid/widget/ListView;"); |
2899 // Call the method on the object | 2992 // Call the method on the object |
2900 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, containerNew, (int)cid, multi)); | 2993 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, containerNew, (int)cid, multi), _DW_REFERENCE_WEAK); |
2901 return result; | 2994 return result; |
2902 } | 2995 } |
2903 return nullptr; | 2996 return nullptr; |
2904 } | 2997 } |
2905 | 2998 |
2934 // Get the method that you want to call | 3027 // Get the method that you want to call |
2935 jmethodID containerNew = env->GetMethodID(clazz, "containerAddColumn", | 3028 jmethodID containerNew = env->GetMethodID(clazz, "containerAddColumn", |
2936 "(Landroid/widget/ListView;Ljava/lang/String;I)V"); | 3029 "(Landroid/widget/ListView;Ljava/lang/String;I)V"); |
2937 // Call the method on the object | 3030 // Call the method on the object |
2938 env->CallVoidMethod(_dw_obj, containerNew, handle, jstr, (int)flags[z]); | 3031 env->CallVoidMethod(_dw_obj, containerNew, handle, jstr, (int)flags[z]); |
3032 _dw_jni_check_exception(env); | |
2939 } | 3033 } |
2940 } | 3034 } |
2941 } | 3035 } |
2942 return DW_ERROR_GENERAL; | 3036 return DW_ERROR_GENERAL; |
2943 } | 3037 } |
2963 * DW_ERROR_NONE (0) on success. | 3057 * DW_ERROR_NONE (0) on success. |
2964 */ | 3058 */ |
2965 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) | 3059 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) |
2966 { | 3060 { |
2967 unsigned long fsflags[2] = { DW_CFA_BITMAPORICON, DW_CFA_STRING }; | 3061 unsigned long fsflags[2] = { DW_CFA_BITMAPORICON, DW_CFA_STRING }; |
2968 char *fstitles[2] = { "Icon", "Filename" }; | 3062 char *fstitles[2] = { (char *)"Icon", (char *)"Filename" }; |
2969 dw_container_setup(handle, fsflags, fstitles, 2, 0); | 3063 dw_container_setup(handle, fsflags, fstitles, 2, 0); |
2970 dw_container_setup(handle, flags, titles, count, 0); | 3064 dw_container_setup(handle, flags, titles, count, 0); |
2971 return DW_ERROR_GENERAL; | 3065 return DW_ERROR_GENERAL; |
2972 } | 3066 } |
2973 | 3067 |
2989 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 3083 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
2990 // Get the method that you want to call | 3084 // Get the method that you want to call |
2991 jmethodID containerAlloc = env->GetMethodID(clazz, "containerAlloc", | 3085 jmethodID containerAlloc = env->GetMethodID(clazz, "containerAlloc", |
2992 "(Landroid/widget/ListView;I)Landroid/widget/ListView;"); | 3086 "(Landroid/widget/ListView;I)Landroid/widget/ListView;"); |
2993 // Call the method on the object | 3087 // Call the method on the object |
2994 return (void *)env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, containerAlloc, handle, rowcount)); | 3088 return (void *)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, containerAlloc, handle, rowcount), _DW_REFERENCE_WEAK); |
2995 } | 3089 } |
2996 return nullptr; | 3090 return nullptr; |
2997 } | 3091 } |
2998 | 3092 |
2999 /* | 3093 /* |
3039 // Get the method that you want to call | 3133 // Get the method that you want to call |
3040 jmethodID containerChangeItem = env->GetMethodID(clazz, "containerChangeItemIcon", | 3134 jmethodID containerChangeItem = env->GetMethodID(clazz, "containerChangeItemIcon", |
3041 "(Landroid/widget/ListView;IILandroid/graphics/drawable/Drawable;)V"); | 3135 "(Landroid/widget/ListView;IILandroid/graphics/drawable/Drawable;)V"); |
3042 // Call the method on the object | 3136 // Call the method on the object |
3043 env->CallVoidMethod(_dw_obj, containerChangeItem, handle, column, row, icon); | 3137 env->CallVoidMethod(_dw_obj, containerChangeItem, handle, column, row, icon); |
3138 _dw_jni_check_exception(env); | |
3044 } | 3139 } |
3045 } | 3140 } |
3046 else if((columntype & DW_CFA_STRING)) | 3141 else if((columntype & DW_CFA_STRING)) |
3047 { | 3142 { |
3048 const char *tmp = *((const char **)data); | 3143 const char *tmp = *((const char **)data); |
3055 // Get the method that you want to call | 3150 // Get the method that you want to call |
3056 jmethodID containerChangeItem = env->GetMethodID(clazz, "containerChangeItemString", | 3151 jmethodID containerChangeItem = env->GetMethodID(clazz, "containerChangeItemString", |
3057 "(Landroid/widget/ListView;IILjava/lang/String;)V"); | 3152 "(Landroid/widget/ListView;IILjava/lang/String;)V"); |
3058 // Call the method on the object | 3153 // Call the method on the object |
3059 env->CallVoidMethod(_dw_obj, containerChangeItem, handle, column, row, jstr); | 3154 env->CallVoidMethod(_dw_obj, containerChangeItem, handle, column, row, jstr); |
3155 _dw_jni_check_exception(env); | |
3060 } | 3156 } |
3061 } | 3157 } |
3062 else if((columntype & DW_CFA_ULONG)) | 3158 else if((columntype & DW_CFA_ULONG)) |
3063 { | 3159 { |
3064 ULONG num = *((ULONG *)data); | 3160 ULONG num = *((ULONG *)data); |
3067 // Get the method that you want to call | 3163 // Get the method that you want to call |
3068 jmethodID containerChangeItem = env->GetMethodID(clazz, "containerChangeItemInt", | 3164 jmethodID containerChangeItem = env->GetMethodID(clazz, "containerChangeItemInt", |
3069 "(Landroid/widget/ListView;III)V"); | 3165 "(Landroid/widget/ListView;III)V"); |
3070 // Call the method on the object | 3166 // Call the method on the object |
3071 env->CallVoidMethod(_dw_obj, containerChangeItem, handle, column, row, (int)num); | 3167 env->CallVoidMethod(_dw_obj, containerChangeItem, handle, column, row, (int)num); |
3168 _dw_jni_check_exception(env); | |
3072 } | 3169 } |
3073 // TODO: Handle DATE and TIME | 3170 // TODO: Handle DATE and TIME |
3074 } | 3171 } |
3075 } | 3172 } |
3076 | 3173 |
3162 * Constant identifying the the column type. | 3259 * Constant identifying the the column type. |
3163 */ | 3260 */ |
3164 int API dw_container_get_column_type(HWND handle, int column) | 3261 int API dw_container_get_column_type(HWND handle, int column) |
3165 { | 3262 { |
3166 JNIEnv *env; | 3263 JNIEnv *env; |
3264 int retval = 0; | |
3167 | 3265 |
3168 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | 3266 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) |
3169 { | 3267 { |
3170 // First get the class that contains the method you need to call | 3268 // First get the class that contains the method you need to call |
3171 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 3269 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
3172 // Get the method that you want to call | 3270 // Get the method that you want to call |
3173 jmethodID containerGetColumnType = env->GetMethodID(clazz, "containerGetColumnType", | 3271 jmethodID containerGetColumnType = env->GetMethodID(clazz, "containerGetColumnType", |
3174 "(Landroid/widget/ListView;I)I"); | 3272 "(Landroid/widget/ListView;I)I"); |
3175 // Call the method on the object | 3273 // Call the method on the object |
3176 return env->CallIntMethod(_dw_obj, containerGetColumnType, handle, column); | 3274 retval = env->CallIntMethod(_dw_obj, containerGetColumnType, handle, column); |
3177 } | 3275 if(_dw_jni_check_exception(env)) |
3178 return 0; | 3276 retval = 0; |
3277 } | |
3278 return retval; | |
3179 } | 3279 } |
3180 | 3280 |
3181 /* | 3281 /* |
3182 * Gets column type for a filesystem container column. | 3282 * Gets column type for a filesystem container column. |
3183 * Parameters: | 3283 * Parameters: |
3271 // Get the method that you want to call | 3371 // Get the method that you want to call |
3272 jmethodID containerClear = env->GetMethodID(clazz, "containerClear", | 3372 jmethodID containerClear = env->GetMethodID(clazz, "containerClear", |
3273 "(Landroid/widget/ListView;)V"); | 3373 "(Landroid/widget/ListView;)V"); |
3274 // Call the method on the object | 3374 // Call the method on the object |
3275 env->CallVoidMethod(_dw_obj, containerClear, handle); | 3375 env->CallVoidMethod(_dw_obj, containerClear, handle); |
3376 _dw_jni_check_exception(env); | |
3276 } | 3377 } |
3277 } | 3378 } |
3278 | 3379 |
3279 /* | 3380 /* |
3280 * Removes the first x rows from a container. | 3381 * Removes the first x rows from a container. |
3419 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 3520 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
3420 // Get the method that you want to call | 3521 // Get the method that you want to call |
3421 jmethodID iconNew = env->GetMethodID(clazz, "iconNew", | 3522 jmethodID iconNew = env->GetMethodID(clazz, "iconNew", |
3422 "(Ljava/lang/String;[BII)Landroid/graphics/drawable/Drawable;"); | 3523 "(Ljava/lang/String;[BII)Landroid/graphics/drawable/Drawable;"); |
3423 // Call the method on the object | 3524 // Call the method on the object |
3424 jobject result = env->NewGlobalRef(env->CallObjectMethod(_dw_obj, iconNew, | 3525 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, iconNew, |
3425 file, bytearray, len, resid)); | 3526 file, bytearray, len, resid), _DW_REFERENCE_WEAK); |
3426 // Clean up after the array now that we are finished | 3527 // Clean up after the array now that we are finished |
3427 //if(bytearray) | 3528 //if(bytearray) |
3428 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0); | 3529 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0); |
3429 return result; | 3530 return result; |
3430 } | 3531 } |
3556 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 3657 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
3557 // Get the method that you want to call | 3658 // Get the method that you want to call |
3558 jmethodID mleNew = env->GetMethodID(clazz, "bitmapNew", | 3659 jmethodID mleNew = env->GetMethodID(clazz, "bitmapNew", |
3559 "(I)Landroid/widget/ImageView;"); | 3660 "(I)Landroid/widget/ImageView;"); |
3560 // Call the method on the object | 3661 // Call the method on the object |
3561 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, mleNew, (int)cid)); | 3662 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, mleNew, (int)cid), _DW_REFERENCE_WEAK); |
3562 return result; | 3663 return result; |
3563 } | 3664 } |
3564 return nullptr; | 3665 return nullptr; |
3565 } | 3666 } |
3566 | 3667 |
3580 if(data && len > 0) | 3681 if(data && len > 0) |
3581 { | 3682 { |
3582 bytearray = env->NewByteArray(len); | 3683 bytearray = env->NewByteArray(len); |
3583 env->SetByteArrayRegion(bytearray, 0, len, reinterpret_cast<const jbyte *>(data)); | 3684 env->SetByteArrayRegion(bytearray, 0, len, reinterpret_cast<const jbyte *>(data)); |
3584 } | 3685 } |
3585 // First get the class that contains the method you need to call | 3686 if(!_dw_jni_check_exception(env)) |
3586 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 3687 { |
3587 // Get the method that you want to call | 3688 // First get the class that contains the method you need to call |
3588 jmethodID pixmapNew = env->GetMethodID(clazz, "pixmapNew", | 3689 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
3589 "(IILjava/lang/String;[BII)Landroid/graphics/Bitmap;"); | 3690 // Get the method that you want to call |
3590 // Call the method on the object | 3691 jmethodID pixmapNew = env->GetMethodID(clazz, "pixmapNew", |
3591 jobject result = env->NewGlobalRef(env->CallObjectMethod(_dw_obj, pixmapNew, | 3692 "(IILjava/lang/String;[BII)Landroid/graphics/Bitmap;"); |
3592 (jint)width, (jint)height, | 3693 // Call the method on the object |
3593 file, bytearray, len, resid)); | 3694 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, pixmapNew, |
3594 // Clean up after the array now that we are finished | 3695 (jint) width, |
3595 //if(bytearray) | 3696 (jint) height, |
3697 file, bytearray, len, | |
3698 resid), | |
3699 _DW_REFERENCE_STRONG); | |
3700 // Clean up after the array now that we are finished | |
3701 //if(bytearray) | |
3596 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0); | 3702 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0); |
3597 return result; | 3703 return result; |
3704 } | |
3598 } | 3705 } |
3599 return nullptr; | 3706 return nullptr; |
3600 } | 3707 } |
3601 | 3708 |
3602 void _dw_pixmap_get_dimensions(HPIXMAP pixmap) | 3709 void _dw_pixmap_get_dimensions(HPIXMAP pixmap) |
3610 // Get the method that you want to call | 3717 // Get the method that you want to call |
3611 jmethodID pixmapGetDimensions = env->GetMethodID(clazz, "pixmapGetDimensions", | 3718 jmethodID pixmapGetDimensions = env->GetMethodID(clazz, "pixmapGetDimensions", |
3612 "(Landroid/graphics/Bitmap;)J"); | 3719 "(Landroid/graphics/Bitmap;)J"); |
3613 // Call the method on the object | 3720 // Call the method on the object |
3614 jlong dimensions = env->CallLongMethod(_dw_obj, pixmapGetDimensions, pixmap->bitmap); | 3721 jlong dimensions = env->CallLongMethod(_dw_obj, pixmapGetDimensions, pixmap->bitmap); |
3722 if(_dw_jni_check_exception(env)) | |
3723 dimensions = 0; | |
3615 | 3724 |
3616 pixmap->width = dimensions & 0xFFFF; | 3725 pixmap->width = dimensions & 0xFFFF; |
3617 pixmap->height = (dimensions >> 32) & 0xFFFF; | 3726 pixmap->height = (dimensions >> 32) & 0xFFFF; |
3618 } | 3727 } |
3619 } | 3728 } |
3773 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 3882 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
3774 // Get the method that you want to call | 3883 // Get the method that you want to call |
3775 jmethodID typefaceFromFontName = env->GetMethodID(clazz, "typefaceFromFontName", | 3884 jmethodID typefaceFromFontName = env->GetMethodID(clazz, "typefaceFromFontName", |
3776 "(Ljava/lang/String;)Landroid/graphics/Typeface;"); | 3885 "(Ljava/lang/String;)Landroid/graphics/Typeface;"); |
3777 // Call the method on the object | 3886 // Call the method on the object |
3778 jobject typeface = env->NewGlobalRef(env->CallObjectMethod(_dw_obj, typefaceFromFontName, jstr)); | 3887 jobject typeface = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, typefaceFromFontName, jstr), _DW_REFERENCE_STRONG); |
3779 if(typeface) | 3888 if(typeface) |
3780 { | 3889 { |
3781 jobject oldtypeface = pixmap->typeface; | 3890 jobject oldtypeface = pixmap->typeface; |
3782 pixmap->typeface = typeface; | 3891 pixmap->typeface = typeface; |
3783 if(oldtypeface) | 3892 if(oldtypeface) |
3802 JNIEnv *env; | 3911 JNIEnv *env; |
3803 | 3912 |
3804 if(pixmap && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | 3913 if(pixmap && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) |
3805 { | 3914 { |
3806 env->DeleteGlobalRef(pixmap->bitmap); | 3915 env->DeleteGlobalRef(pixmap->bitmap); |
3916 if(pixmap->typeface) | |
3917 env->DeleteGlobalRef(pixmap->typeface); | |
3807 free(pixmap); | 3918 free(pixmap); |
3808 } | 3919 } |
3809 } | 3920 } |
3810 } | 3921 } |
3811 | 3922 |
3858 // Get the method that you want to call | 3969 // Get the method that you want to call |
3859 jmethodID pixmapBitBlt = env->GetMethodID(clazz, "pixmapBitBlt", | 3970 jmethodID pixmapBitBlt = env->GetMethodID(clazz, "pixmapBitBlt", |
3860 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIIILorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIII)I"); | 3971 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIIILorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIII)I"); |
3861 // Call the method on the object | 3972 // Call the method on the object |
3862 retval = env->CallIntMethod(_dw_obj, pixmapBitBlt, dest, destp ? destp->bitmap : nullptr, xdest, ydest, width, height, src, srcp ? srcp->bitmap : nullptr, xsrc, ysrc, srcwidth, srcheight); | 3973 retval = env->CallIntMethod(_dw_obj, pixmapBitBlt, dest, destp ? destp->bitmap : nullptr, xdest, ydest, width, height, src, srcp ? srcp->bitmap : nullptr, xsrc, ysrc, srcwidth, srcheight); |
3974 if(_dw_jni_check_exception(env)) | |
3975 retval = DW_ERROR_GENERAL; | |
3863 } | 3976 } |
3864 return retval; | 3977 return retval; |
3865 } | 3978 } |
3866 | 3979 |
3867 /* | 3980 /* |
3881 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 3994 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
3882 // Get the method that you want to call | 3995 // Get the method that you want to call |
3883 jmethodID calendarNew = env->GetMethodID(clazz, "calendarNew", | 3996 jmethodID calendarNew = env->GetMethodID(clazz, "calendarNew", |
3884 "(I)Landroid/widget/CalendarView;"); | 3997 "(I)Landroid/widget/CalendarView;"); |
3885 // Call the method on the object | 3998 // Call the method on the object |
3886 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, calendarNew, (int)cid)); | 3999 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, calendarNew, (int)cid), _DW_REFERENCE_WEAK); |
3887 return result; | 4000 return result; |
3888 } | 4001 } |
3889 return nullptr; | 4002 return nullptr; |
3890 } | 4003 } |
3891 | 4004 |
3915 // Get the method that you want to call | 4028 // Get the method that you want to call |
3916 jmethodID calendarSetDate = env->GetMethodID(clazz, "calendarSetDate", | 4029 jmethodID calendarSetDate = env->GetMethodID(clazz, "calendarSetDate", |
3917 "(Landroid/widget/CalendarView;J)V"); | 4030 "(Landroid/widget/CalendarView;J)V"); |
3918 // Call the method on the object | 4031 // Call the method on the object |
3919 env->CallVoidMethod(_dw_obj, calendarSetDate, handle, (jlong)date); | 4032 env->CallVoidMethod(_dw_obj, calendarSetDate, handle, (jlong)date); |
4033 _dw_jni_check_exception(env); | |
3920 } | 4034 } |
3921 } | 4035 } |
3922 | 4036 |
3923 /* | 4037 /* |
3924 * Gets the year, month and day set in the calendar widget. | 4038 * Gets the year, month and day set in the calendar widget. |
3942 // Get the method that you want to call | 4056 // Get the method that you want to call |
3943 jmethodID calendarGetDate = env->GetMethodID(clazz, "calendarGetDate", | 4057 jmethodID calendarGetDate = env->GetMethodID(clazz, "calendarGetDate", |
3944 "(Landroid/widget/CalendarView;)J"); | 4058 "(Landroid/widget/CalendarView;)J"); |
3945 // Call the method on the object | 4059 // Call the method on the object |
3946 date = (time_t)env->CallLongMethod(_dw_obj, calendarGetDate, handle); | 4060 date = (time_t)env->CallLongMethod(_dw_obj, calendarGetDate, handle); |
4061 if(_dw_jni_check_exception(env)) | |
4062 date = 0; | |
3947 ts = *localtime(&date); | 4063 ts = *localtime(&date); |
3948 if(year) | 4064 if(year) |
3949 *year = ts.tm_year + 1900; | 4065 *year = ts.tm_year + 1900; |
3950 if(month) | 4066 if(month) |
3951 *month = ts.tm_mon + 1; | 4067 *month = ts.tm_mon + 1; |
3971 // Get the method that you want to call | 4087 // Get the method that you want to call |
3972 jmethodID htmlAction = env->GetMethodID(clazz, "htmlAction", | 4088 jmethodID htmlAction = env->GetMethodID(clazz, "htmlAction", |
3973 "(Landroid/webkit/WebView;I)V"); | 4089 "(Landroid/webkit/WebView;I)V"); |
3974 // Call the method on the object | 4090 // Call the method on the object |
3975 env->CallVoidMethod(_dw_obj, htmlAction, handle, action); | 4091 env->CallVoidMethod(_dw_obj, htmlAction, handle, action); |
4092 _dw_jni_check_exception(env); | |
3976 } | 4093 } |
3977 } | 4094 } |
3978 | 4095 |
3979 /* | 4096 /* |
3980 * Render raw HTML code in the embedded HTML widget.. | 4097 * Render raw HTML code in the embedded HTML widget.. |
3998 // Get the method that you want to call | 4115 // Get the method that you want to call |
3999 jmethodID htmlRaw = env->GetMethodID(clazz, "htmlRaw", | 4116 jmethodID htmlRaw = env->GetMethodID(clazz, "htmlRaw", |
4000 "(Landroid/webkit/WebView;Ljava/lang/String;)V"); | 4117 "(Landroid/webkit/WebView;Ljava/lang/String;)V"); |
4001 // Call the method on the object | 4118 // Call the method on the object |
4002 env->CallVoidMethod(_dw_obj, htmlRaw, handle, jstr); | 4119 env->CallVoidMethod(_dw_obj, htmlRaw, handle, jstr); |
4003 return DW_ERROR_NONE; | 4120 if(!_dw_jni_check_exception(env)) |
4121 return DW_ERROR_NONE; | |
4004 } | 4122 } |
4005 return DW_ERROR_GENERAL; | 4123 return DW_ERROR_GENERAL; |
4006 } | 4124 } |
4007 | 4125 |
4008 /* | 4126 /* |
4027 // Get the method that you want to call | 4145 // Get the method that you want to call |
4028 jmethodID htmlLoadURL = env->GetMethodID(clazz, "htmlLoadURL", | 4146 jmethodID htmlLoadURL = env->GetMethodID(clazz, "htmlLoadURL", |
4029 "(Landroid/webkit/WebView;Ljava/lang/String;)V"); | 4147 "(Landroid/webkit/WebView;Ljava/lang/String;)V"); |
4030 // Call the method on the object | 4148 // Call the method on the object |
4031 env->CallVoidMethod(_dw_obj, htmlLoadURL, handle, jstr); | 4149 env->CallVoidMethod(_dw_obj, htmlLoadURL, handle, jstr); |
4032 return DW_ERROR_NONE; | 4150 if(!_dw_jni_check_exception(env)) |
4151 return DW_ERROR_NONE; | |
4033 } | 4152 } |
4034 return DW_ERROR_GENERAL; | 4153 return DW_ERROR_GENERAL; |
4035 } | 4154 } |
4036 | 4155 |
4037 /* | 4156 /* |
4057 // Get the method that you want to call | 4176 // Get the method that you want to call |
4058 jmethodID htmlJavascriptRun = env->GetMethodID(clazz, "htmlJavascriptRun", | 4177 jmethodID htmlJavascriptRun = env->GetMethodID(clazz, "htmlJavascriptRun", |
4059 "(Landroid/webkit/WebView;Ljava/lang/String;J)V"); | 4178 "(Landroid/webkit/WebView;Ljava/lang/String;J)V"); |
4060 // Call the method on the object | 4179 // Call the method on the object |
4061 env->CallVoidMethod(_dw_obj, htmlJavascriptRun, handle, jstr, (jlong)scriptdata); | 4180 env->CallVoidMethod(_dw_obj, htmlJavascriptRun, handle, jstr, (jlong)scriptdata); |
4062 return DW_ERROR_NONE; | 4181 if(!_dw_jni_check_exception(env)) |
4182 return DW_ERROR_NONE; | |
4063 } | 4183 } |
4064 return DW_ERROR_UNKNOWN; | 4184 return DW_ERROR_UNKNOWN; |
4065 } | 4185 } |
4066 | 4186 |
4067 /* | 4187 /* |
4081 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 4201 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
4082 // Get the method that you want to call | 4202 // Get the method that you want to call |
4083 jmethodID htmlNew = env->GetMethodID(clazz, "htmlNew", | 4203 jmethodID htmlNew = env->GetMethodID(clazz, "htmlNew", |
4084 "(I)Landroid/webkit/WebView;"); | 4204 "(I)Landroid/webkit/WebView;"); |
4085 // Call the method on the object | 4205 // Call the method on the object |
4086 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, htmlNew, (int)cid)); | 4206 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, htmlNew, (int)cid), _DW_REFERENCE_WEAK); |
4087 return result; | 4207 return result; |
4088 } | 4208 } |
4089 return nullptr; | 4209 return nullptr; |
4090 } | 4210 } |
4091 | 4211 |
4126 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 4246 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
4127 // Get the method that you want to call | 4247 // Get the method that you want to call |
4128 jmethodID menuNew = env->GetMethodID(clazz, "menuNew", | 4248 jmethodID menuNew = env->GetMethodID(clazz, "menuNew", |
4129 "(I)Lorg/dbsoft/dwindows/DWMenu;"); | 4249 "(I)Lorg/dbsoft/dwindows/DWMenu;"); |
4130 // Call the method on the object | 4250 // Call the method on the object |
4131 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, menuNew, (int)cid)); | 4251 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, menuNew, (int)cid), _DW_REFERENCE_WEAK); |
4132 return result; | 4252 return result; |
4133 } | 4253 } |
4134 return nullptr; | 4254 return nullptr; |
4135 } | 4255 } |
4136 | 4256 |
4151 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 4271 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
4152 // Get the method that you want to call | 4272 // Get the method that you want to call |
4153 jmethodID menuBarNew = env->GetMethodID(clazz, "menuBarNew", | 4273 jmethodID menuBarNew = env->GetMethodID(clazz, "menuBarNew", |
4154 "(Landroid/view/View;)Lorg/dbsoft/dwindows/DWMenu;"); | 4274 "(Landroid/view/View;)Lorg/dbsoft/dwindows/DWMenu;"); |
4155 // Call the method on the object | 4275 // Call the method on the object |
4156 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, menuBarNew, location)); | 4276 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, menuBarNew, location), _DW_REFERENCE_WEAK); |
4157 return result; | 4277 return result; |
4158 } | 4278 } |
4159 return nullptr; | 4279 return nullptr; |
4160 } | 4280 } |
4161 | 4281 |
4175 // Get the method that you want to call | 4295 // Get the method that you want to call |
4176 jmethodID menuDestroy = env->GetMethodID(clazz, "menuDestroy", | 4296 jmethodID menuDestroy = env->GetMethodID(clazz, "menuDestroy", |
4177 "(Lorg/dbsoft/dwindows/DWMenu;)V"); | 4297 "(Lorg/dbsoft/dwindows/DWMenu;)V"); |
4178 // Call the method on the object | 4298 // Call the method on the object |
4179 env->CallVoidMethod(_dw_obj, menuDestroy, *menu); | 4299 env->CallVoidMethod(_dw_obj, menuDestroy, *menu); |
4300 _dw_jni_check_exception(env); | |
4180 *menu = nullptr; | 4301 *menu = nullptr; |
4181 } | 4302 } |
4182 } | 4303 } |
4183 | 4304 |
4184 /* | 4305 /* |
4200 // Get the method that you want to call | 4321 // Get the method that you want to call |
4201 jmethodID menuDeleteItem = env->GetMethodID(clazz, "menuDeleteItem", | 4322 jmethodID menuDeleteItem = env->GetMethodID(clazz, "menuDeleteItem", |
4202 "(Lorg/dbsoft/dwindows/DWMenu;I)V"); | 4323 "(Lorg/dbsoft/dwindows/DWMenu;I)V"); |
4203 // Call the method on the object | 4324 // Call the method on the object |
4204 env->CallVoidMethod(_dw_obj, menuDeleteItem, menux, (int)id); | 4325 env->CallVoidMethod(_dw_obj, menuDeleteItem, menux, (int)id); |
4205 return DW_ERROR_NONE; | 4326 if(!_dw_jni_check_exception(env)) |
4327 return DW_ERROR_NONE; | |
4206 } | 4328 } |
4207 return DW_ERROR_UNKNOWN; | 4329 return DW_ERROR_UNKNOWN; |
4208 } | 4330 } |
4209 | 4331 |
4210 /* | 4332 /* |
4267 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 4389 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
4268 // Get the method that you want to call | 4390 // Get the method that you want to call |
4269 jmethodID menuAppendItem = env->GetMethodID(clazz, "menuAppendItem", | 4391 jmethodID menuAppendItem = env->GetMethodID(clazz, "menuAppendItem", |
4270 "(Lorg/dbsoft/dwindows/DWMenu;Ljava/lang/String;IIIILorg/dbsoft/dwindows/DWMenu;)Lorg/dbsoft/dwindows/DWMenuItem;"); | 4392 "(Lorg/dbsoft/dwindows/DWMenu;Ljava/lang/String;IIIILorg/dbsoft/dwindows/DWMenu;)Lorg/dbsoft/dwindows/DWMenuItem;"); |
4271 // Call the method on the object | 4393 // Call the method on the object |
4272 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, menuAppendItem, menux, jstr, (int)itemid, (int)flags, end, check, submenux)); | 4394 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, menuAppendItem, menux, jstr, (int)itemid, (int)flags, end, check, submenux), _DW_REFERENCE_WEAK); |
4273 return result; | 4395 return result; |
4274 } | 4396 } |
4275 return nullptr; | 4397 return nullptr; |
4276 } | 4398 } |
4277 | 4399 |
4307 // Get the method that you want to call | 4429 // Get the method that you want to call |
4308 jmethodID menuSetState = env->GetMethodID(clazz, "menuSetState", | 4430 jmethodID menuSetState = env->GetMethodID(clazz, "menuSetState", |
4309 "(Lorg/dbsoft/dwindows/DWMenu;II)V"); | 4431 "(Lorg/dbsoft/dwindows/DWMenu;II)V"); |
4310 // Call the method on the object | 4432 // Call the method on the object |
4311 env->CallVoidMethod(_dw_obj, menuSetState, menux, (int)itemid, (int)state); | 4433 env->CallVoidMethod(_dw_obj, menuSetState, menux, (int)itemid, (int)state); |
4434 _dw_jni_check_exception(env); | |
4312 } | 4435 } |
4313 } | 4436 } |
4314 | 4437 |
4315 /* | 4438 /* |
4316 * Create a notebook object to be packed. | 4439 * Create a notebook object to be packed. |
4330 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 4453 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
4331 // Get the method that you want to call | 4454 // Get the method that you want to call |
4332 jmethodID notebookNew = env->GetMethodID(clazz, "notebookNew", | 4455 jmethodID notebookNew = env->GetMethodID(clazz, "notebookNew", |
4333 "(II)Landroid/widget/RelativeLayout;"); | 4456 "(II)Landroid/widget/RelativeLayout;"); |
4334 // Call the method on the object | 4457 // Call the method on the object |
4335 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, notebookNew, (int)cid, top)); | 4458 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, notebookNew, (int)cid, top), _DW_REFERENCE_WEAK); |
4336 return result; | 4459 return result; |
4337 } | 4460 } |
4338 return nullptr; | 4461 return nullptr; |
4339 } | 4462 } |
4340 | 4463 |
4359 // Get the method that you want to call | 4482 // Get the method that you want to call |
4360 jmethodID notebookPageNew = env->GetMethodID(clazz, "notebookPageNew", | 4483 jmethodID notebookPageNew = env->GetMethodID(clazz, "notebookPageNew", |
4361 "(Landroid/widget/RelativeLayout;JI)J"); | 4484 "(Landroid/widget/RelativeLayout;JI)J"); |
4362 // Call the method on the object | 4485 // Call the method on the object |
4363 result = (unsigned long)env->CallLongMethod(_dw_obj, notebookPageNew, handle, (jlong)flags, front); | 4486 result = (unsigned long)env->CallLongMethod(_dw_obj, notebookPageNew, handle, (jlong)flags, front); |
4487 if(_dw_jni_check_exception(env)) | |
4488 result = 0; | |
4364 } | 4489 } |
4365 return result; | 4490 return result; |
4366 } | 4491 } |
4367 | 4492 |
4368 /* | 4493 /* |
4382 // Get the method that you want to call | 4507 // Get the method that you want to call |
4383 jmethodID notebookPageDestroy = env->GetMethodID(clazz, "notebookPageDestroy", | 4508 jmethodID notebookPageDestroy = env->GetMethodID(clazz, "notebookPageDestroy", |
4384 "(Landroid/widget/RelativeLayout;J)V"); | 4509 "(Landroid/widget/RelativeLayout;J)V"); |
4385 // Call the method on the object | 4510 // Call the method on the object |
4386 env->CallVoidMethod(_dw_obj, notebookPageDestroy, handle, (jlong)pageid); | 4511 env->CallVoidMethod(_dw_obj, notebookPageDestroy, handle, (jlong)pageid); |
4512 _dw_jni_check_exception(env); | |
4387 } | 4513 } |
4388 } | 4514 } |
4389 | 4515 |
4390 /* | 4516 /* |
4391 * Queries the currently visible page ID. | 4517 * Queries the currently visible page ID. |
4405 // Get the method that you want to call | 4531 // Get the method that you want to call |
4406 jmethodID notebookPageGet = env->GetMethodID(clazz, "notebookPageGet", | 4532 jmethodID notebookPageGet = env->GetMethodID(clazz, "notebookPageGet", |
4407 "(Landroid/widget/RelativeLayout;)J"); | 4533 "(Landroid/widget/RelativeLayout;)J"); |
4408 // Call the method on the object | 4534 // Call the method on the object |
4409 result = (unsigned long)env->CallLongMethod(_dw_obj, notebookPageGet, handle); | 4535 result = (unsigned long)env->CallLongMethod(_dw_obj, notebookPageGet, handle); |
4536 if(_dw_jni_check_exception(env)) | |
4537 result = 0; | |
4410 } | 4538 } |
4411 return result; | 4539 return result; |
4412 } | 4540 } |
4413 | 4541 |
4414 /* | 4542 /* |
4427 // Get the method that you want to call | 4555 // Get the method that you want to call |
4428 jmethodID notebookPageSet = env->GetMethodID(clazz, "notebookPageSet", | 4556 jmethodID notebookPageSet = env->GetMethodID(clazz, "notebookPageSet", |
4429 "(Landroid/widget/RelativeLayout;J)V"); | 4557 "(Landroid/widget/RelativeLayout;J)V"); |
4430 // Call the method on the object | 4558 // Call the method on the object |
4431 env->CallVoidMethod(_dw_obj, notebookPageSet, handle, (jlong)pageid); | 4559 env->CallVoidMethod(_dw_obj, notebookPageSet, handle, (jlong)pageid); |
4560 _dw_jni_check_exception(env); | |
4432 } | 4561 } |
4433 } | 4562 } |
4434 | 4563 |
4435 /* | 4564 /* |
4436 * Sets the text on the specified notebook tab. | 4565 * Sets the text on the specified notebook tab. |
4452 // Get the method that you want to call | 4581 // Get the method that you want to call |
4453 jmethodID notebookPageSetText = env->GetMethodID(clazz, "notebookPageSetText", | 4582 jmethodID notebookPageSetText = env->GetMethodID(clazz, "notebookPageSetText", |
4454 "(Landroid/widget/RelativeLayout;JLjava/lang/String;)V"); | 4583 "(Landroid/widget/RelativeLayout;JLjava/lang/String;)V"); |
4455 // Call the method on the object | 4584 // Call the method on the object |
4456 env->CallVoidMethod(_dw_obj, notebookPageSetText, handle, (jlong)pageid, jstr); | 4585 env->CallVoidMethod(_dw_obj, notebookPageSetText, handle, (jlong)pageid, jstr); |
4586 _dw_jni_check_exception(env); | |
4457 } | 4587 } |
4458 } | 4588 } |
4459 | 4589 |
4460 /* | 4590 /* |
4461 * Sets the text on the specified notebook tab status area. | 4591 * Sets the text on the specified notebook tab status area. |
4486 // Get the method that you want to call | 4616 // Get the method that you want to call |
4487 jmethodID notebookPagePack = env->GetMethodID(clazz, "notebookPagePack", | 4617 jmethodID notebookPagePack = env->GetMethodID(clazz, "notebookPagePack", |
4488 "(Landroid/widget/RelativeLayout;JLandroid/widget/LinearLayout;)V"); | 4618 "(Landroid/widget/RelativeLayout;JLandroid/widget/LinearLayout;)V"); |
4489 // Call the method on the object | 4619 // Call the method on the object |
4490 env->CallVoidMethod(_dw_obj, notebookPagePack, handle, (jlong)pageid, page); | 4620 env->CallVoidMethod(_dw_obj, notebookPagePack, handle, (jlong)pageid, page); |
4621 _dw_jni_check_exception(env); | |
4491 } | 4622 } |
4492 } | 4623 } |
4493 | 4624 |
4494 /* | 4625 /* |
4495 * Create a new Window Frame. | 4626 * Create a new Window Frame. |
4512 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 4643 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
4513 // Get the method that you want to call | 4644 // Get the method that you want to call |
4514 jmethodID windowNew = env->GetMethodID(clazz, "windowNew", | 4645 jmethodID windowNew = env->GetMethodID(clazz, "windowNew", |
4515 "(Ljava/lang/String;I)Landroid/widget/LinearLayout;"); | 4646 "(Ljava/lang/String;I)Landroid/widget/LinearLayout;"); |
4516 // Call the method on the object | 4647 // Call the method on the object |
4517 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, windowNew, jstr, (int)flStyle)); | 4648 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, windowNew, jstr, (int)flStyle), _DW_REFERENCE_WEAK); |
4518 return result; | 4649 return result; |
4519 } | 4650 } |
4520 return nullptr; | 4651 return nullptr; |
4521 } | 4652 } |
4522 | 4653 |
4553 // Get the method that you want to call | 4684 // Get the method that you want to call |
4554 jmethodID windowHideShow = env->GetMethodID(clazz, "windowHideShow", | 4685 jmethodID windowHideShow = env->GetMethodID(clazz, "windowHideShow", |
4555 "(Landroid/view/View;I)V"); | 4686 "(Landroid/view/View;I)V"); |
4556 // Call the method on the object | 4687 // Call the method on the object |
4557 env->CallVoidMethod(_dw_obj, windowHideShow, handle, state); | 4688 env->CallVoidMethod(_dw_obj, windowHideShow, handle, state); |
4558 return DW_ERROR_NONE; | 4689 if(!_dw_jni_check_exception(env)) |
4690 return DW_ERROR_NONE; | |
4559 } | 4691 } |
4560 return DW_ERROR_GENERAL; | 4692 return DW_ERROR_GENERAL; |
4561 } | 4693 } |
4562 | 4694 |
4563 /* | 4695 /* |
4609 "(Landroid/view/View;IIIIIIIIII)V"); | 4741 "(Landroid/view/View;IIIIIIIIII)V"); |
4610 // Call the method on the object | 4742 // Call the method on the object |
4611 env->CallVoidMethod(_dw_obj, windowSetColor, handle, | 4743 env->CallVoidMethod(_dw_obj, windowSetColor, handle, |
4612 (jint)fore, 0, (jint)DW_RED_VALUE(_fore), (jint)DW_GREEN_VALUE(_fore), (jint)DW_BLUE_VALUE(_fore), | 4744 (jint)fore, 0, (jint)DW_RED_VALUE(_fore), (jint)DW_GREEN_VALUE(_fore), (jint)DW_BLUE_VALUE(_fore), |
4613 (jint)back, 0, (jint)DW_RED_VALUE(_back), (jint)DW_GREEN_VALUE(_back), (jint)DW_BLUE_VALUE(_back)); | 4745 (jint)back, 0, (jint)DW_RED_VALUE(_back), (jint)DW_GREEN_VALUE(_back), (jint)DW_BLUE_VALUE(_back)); |
4614 return DW_ERROR_NONE; | 4746 if(!_dw_jni_check_exception(env)) |
4747 return DW_ERROR_NONE; | |
4615 } | 4748 } |
4616 return DW_ERROR_GENERAL; | 4749 return DW_ERROR_GENERAL; |
4617 } | 4750 } |
4618 | 4751 |
4619 /* | 4752 /* |
4720 // Get the method that you want to call | 4853 // Get the method that you want to call |
4721 jmethodID windowHideShow = env->GetMethodID(clazz, "windowSetFont", | 4854 jmethodID windowHideShow = env->GetMethodID(clazz, "windowSetFont", |
4722 "(Landroid/view/View;Ljava/lang/String;)V"); | 4855 "(Landroid/view/View;Ljava/lang/String;)V"); |
4723 // Call the method on the object | 4856 // Call the method on the object |
4724 env->CallVoidMethod(_dw_obj, windowHideShow, handle, jstr); | 4857 env->CallVoidMethod(_dw_obj, windowHideShow, handle, jstr); |
4725 return DW_ERROR_NONE; | 4858 if(!_dw_jni_check_exception(env)) |
4859 return DW_ERROR_NONE; | |
4726 } | 4860 } |
4727 return DW_ERROR_GENERAL; | 4861 return DW_ERROR_GENERAL; |
4728 } | 4862 } |
4729 | 4863 |
4730 /* | 4864 /* |
4790 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 4924 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
4791 // Get the method that you want to call | 4925 // Get the method that you want to call |
4792 jmethodID windowGetText = env->GetMethodID(clazz, "windowGetText", | 4926 jmethodID windowGetText = env->GetMethodID(clazz, "windowGetText", |
4793 "(Landroid/view/View;)Ljava/lang/String;"); | 4927 "(Landroid/view/View;)Ljava/lang/String;"); |
4794 // Call the method on the object | 4928 // Call the method on the object |
4795 jstring result = (jstring)env->CallObjectMethod(_dw_obj, windowGetText, handle); | 4929 jstring result = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, windowGetText, handle), _DW_REFERENCE_NONE); |
4796 // Get the UTF8 string result | 4930 // Get the UTF8 string result |
4797 if(result) | 4931 if(result) |
4798 utf8 = env->GetStringUTFChars(result, nullptr); | 4932 utf8 = env->GetStringUTFChars(result, nullptr); |
4799 return utf8 ? strdup(utf8) : nullptr; | 4933 return utf8 ? strdup(utf8) : nullptr; |
4800 } | 4934 } |
4820 // Get the method that you want to call | 4954 // Get the method that you want to call |
4821 jmethodID windowSetText = env->GetMethodID(clazz, "windowSetText", | 4955 jmethodID windowSetText = env->GetMethodID(clazz, "windowSetText", |
4822 "(Landroid/view/View;Ljava/lang/String;)V"); | 4956 "(Landroid/view/View;Ljava/lang/String;)V"); |
4823 // Call the method on the object | 4957 // Call the method on the object |
4824 env->CallVoidMethod(_dw_obj, windowSetText, handle, jstr); | 4958 env->CallVoidMethod(_dw_obj, windowSetText, handle, jstr); |
4959 _dw_jni_check_exception(env); | |
4825 } | 4960 } |
4826 } | 4961 } |
4827 | 4962 |
4828 /* | 4963 /* |
4829 * Sets the text used for a given window's floating bubble help. | 4964 * Sets the text used for a given window's floating bubble help. |
4846 // Get the method that you want to call | 4981 // Get the method that you want to call |
4847 jmethodID windowSetEnabled = env->GetMethodID(clazz, "windowSetEnabled", | 4982 jmethodID windowSetEnabled = env->GetMethodID(clazz, "windowSetEnabled", |
4848 "(Landroid/view/View;Z)V"); | 4983 "(Landroid/view/View;Z)V"); |
4849 // Call the method on the object | 4984 // Call the method on the object |
4850 env->CallVoidMethod(_dw_obj, windowSetEnabled, handle, state); | 4985 env->CallVoidMethod(_dw_obj, windowSetEnabled, handle, state); |
4986 _dw_jni_check_exception(env); | |
4851 } | 4987 } |
4852 } | 4988 } |
4853 | 4989 |
4854 /* | 4990 /* |
4855 * Disables given window (widget). | 4991 * Disables given window (widget). |
4900 // Get the method that you want to call | 5036 // Get the method that you want to call |
4901 jmethodID windowSetBitmapFromData = env->GetMethodID(clazz, "windowSetBitmapFromData", | 5037 jmethodID windowSetBitmapFromData = env->GetMethodID(clazz, "windowSetBitmapFromData", |
4902 "(Landroid/view/View;I[BI)V"); | 5038 "(Landroid/view/View;I[BI)V"); |
4903 // Call the method on the object | 5039 // Call the method on the object |
4904 env->CallVoidMethod(_dw_obj, windowSetBitmapFromData, handle, (int)cid, bytearray, len); | 5040 env->CallVoidMethod(_dw_obj, windowSetBitmapFromData, handle, (int)cid, bytearray, len); |
5041 _dw_jni_check_exception(env); | |
4905 // Clean up after the array now that we are finished | 5042 // Clean up after the array now that we are finished |
4906 //if(bytearray) | 5043 //if(bytearray) |
4907 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0); | 5044 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0); |
4908 } | 5045 } |
4909 } | 5046 } |
4934 // Get the method that you want to call | 5071 // Get the method that you want to call |
4935 jmethodID windowSetBitmapFromData = env->GetMethodID(clazz, "windowSetBitmap", | 5072 jmethodID windowSetBitmapFromData = env->GetMethodID(clazz, "windowSetBitmap", |
4936 "(Landroid/view/View;ILjava/lang/String;)V"); | 5073 "(Landroid/view/View;ILjava/lang/String;)V"); |
4937 // Call the method on the object | 5074 // Call the method on the object |
4938 env->CallVoidMethod(_dw_obj, windowSetBitmapFromData, handle, (int)resid, jstr); | 5075 env->CallVoidMethod(_dw_obj, windowSetBitmapFromData, handle, (int)resid, jstr); |
5076 _dw_jni_check_exception(env); | |
4939 } | 5077 } |
4940 } | 5078 } |
4941 | 5079 |
4942 /* | 5080 /* |
4943 * Sets the icon used for a given window. | 5081 * Sets the icon used for a given window. |
4968 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 5106 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
4969 // Get the method that you want to call | 5107 // Get the method that you want to call |
4970 jmethodID windowFromId = env->GetMethodID(clazz, "windowFromId", | 5108 jmethodID windowFromId = env->GetMethodID(clazz, "windowFromId", |
4971 "(Landroid/view/View;I)Landroid/view/View;"); | 5109 "(Landroid/view/View;I)Landroid/view/View;"); |
4972 // Call the method on the object | 5110 // Call the method on the object |
4973 retval = env->CallObjectMethod(_dw_obj, windowFromId, handle, id); | 5111 retval = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, windowFromId, handle, id), _DW_REFERENCE_NONE); |
4974 } | 5112 } |
4975 return retval; | 5113 return retval; |
4976 } | 5114 } |
4977 | 5115 |
4978 /* | 5116 /* |
5108 // Get the method that you want to call | 5246 // Get the method that you want to call |
5109 jmethodID screenGetDimensions = env->GetMethodID(clazz, "screenGetDimensions", | 5247 jmethodID screenGetDimensions = env->GetMethodID(clazz, "screenGetDimensions", |
5110 "()J"); | 5248 "()J"); |
5111 // Call the method on the object | 5249 // Call the method on the object |
5112 _dw_screen_dimensions = env->CallLongMethod(_dw_obj, screenGetDimensions); | 5250 _dw_screen_dimensions = env->CallLongMethod(_dw_obj, screenGetDimensions); |
5251 if(_dw_jni_check_exception(env)) | |
5252 _dw_screen_dimensions = 0; | |
5113 } | 5253 } |
5114 } | 5254 } |
5115 return _dw_screen_dimensions & 0xFFFF; | 5255 return _dw_screen_dimensions & 0xFFFF; |
5116 } | 5256 } |
5117 | 5257 |
5131 // Get the method that you want to call | 5271 // Get the method that you want to call |
5132 jmethodID screenGetDimensions = env->GetMethodID(clazz, "screenGetDimensions", | 5272 jmethodID screenGetDimensions = env->GetMethodID(clazz, "screenGetDimensions", |
5133 "()J"); | 5273 "()J"); |
5134 // Call the method on the object | 5274 // Call the method on the object |
5135 _dw_screen_dimensions = env->CallLongMethod(_dw_obj, screenGetDimensions); | 5275 _dw_screen_dimensions = env->CallLongMethod(_dw_obj, screenGetDimensions); |
5276 if(_dw_jni_check_exception(env)) | |
5277 _dw_screen_dimensions = 0; | |
5136 } | 5278 } |
5137 } | 5279 } |
5138 return (_dw_screen_dimensions >> 32) & 0xFFFF; | 5280 return (_dw_screen_dimensions >> 32) & 0xFFFF; |
5139 } | 5281 } |
5140 | 5282 |
5164 jclass clazz = _dw_find_class(jenv, DW_CLASS_NAME); | 5306 jclass clazz = _dw_find_class(jenv, DW_CLASS_NAME); |
5165 // Get the method that you want to call | 5307 // Get the method that you want to call |
5166 jmethodID androidGetRelease = jenv->GetMethodID(clazz, "androidGetRelease", | 5308 jmethodID androidGetRelease = jenv->GetMethodID(clazz, "androidGetRelease", |
5167 "()Ljava/lang/String;"); | 5309 "()Ljava/lang/String;"); |
5168 // Call the method on the object | 5310 // Call the method on the object |
5169 jstring jstr = (jstring)jenv->CallObjectMethod(_dw_obj, androidGetRelease); | 5311 jstring jstr = (jstring)_dw_jni_check_result(jenv, jenv->CallObjectMethod(_dw_obj, androidGetRelease), _DW_REFERENCE_NONE); |
5170 | 5312 |
5171 if(jstr) | 5313 if(jstr) |
5172 release = jenv->GetStringUTFChars(jstr, nullptr); | 5314 release = jenv->GetStringUTFChars(jstr, nullptr); |
5173 } | 5315 } |
5174 snprintf(osName, _DW_ENV_STRING_SIZE-1, "Android%s%s", | 5316 snprintf(osName, _DW_ENV_STRING_SIZE-1, "Android%s%s", |
5206 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 5348 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
5207 // Get the method that you want to call | 5349 // Get the method that you want to call |
5208 jmethodID doBeep = env->GetMethodID(clazz, "doBeep", "(I)V"); | 5350 jmethodID doBeep = env->GetMethodID(clazz, "doBeep", "(I)V"); |
5209 // Call the method on the object | 5351 // Call the method on the object |
5210 env->CallVoidMethod(_dw_obj, doBeep, dur); | 5352 env->CallVoidMethod(_dw_obj, doBeep, dur); |
5353 _dw_jni_check_exception(env); | |
5211 } | 5354 } |
5212 } | 5355 } |
5213 | 5356 |
5214 /* Call this after drawing to the screen to make sure | 5357 /* Call this after drawing to the screen to make sure |
5215 * anything you have drawn is visible. | 5358 * anything you have drawn is visible. |
5238 // Get the method that you want to call | 5381 // Get the method that you want to call |
5239 jmethodID windowSetData = env->GetMethodID(clazz, "windowSetData", | 5382 jmethodID windowSetData = env->GetMethodID(clazz, "windowSetData", |
5240 "(Landroid/view/View;Ljava/lang/String;J)V"); | 5383 "(Landroid/view/View;Ljava/lang/String;J)V"); |
5241 // Call the method on the object | 5384 // Call the method on the object |
5242 env->CallVoidMethod(_dw_obj, windowSetData, window, jstr, (jlong)data); | 5385 env->CallVoidMethod(_dw_obj, windowSetData, window, jstr, (jlong)data); |
5386 _dw_jni_check_exception(env); | |
5243 } | 5387 } |
5244 } | 5388 } |
5245 | 5389 |
5246 /* | 5390 /* |
5247 * Gets a named user data item from a window handle. | 5391 * Gets a named user data item from a window handle. |
5265 // Get the method that you want to call | 5409 // Get the method that you want to call |
5266 jmethodID windowGetData = env->GetMethodID(clazz, "windowGetData", | 5410 jmethodID windowGetData = env->GetMethodID(clazz, "windowGetData", |
5267 "(Landroid/view/View;Ljava/lang/String;)J"); | 5411 "(Landroid/view/View;Ljava/lang/String;)J"); |
5268 // Call the method on the object | 5412 // Call the method on the object |
5269 retval = (void *)env->CallLongMethod(_dw_obj, windowGetData, window, jstr); | 5413 retval = (void *)env->CallLongMethod(_dw_obj, windowGetData, window, jstr); |
5414 if(_dw_jni_check_exception(env)) | |
5415 retval = nullptr; | |
5270 } | 5416 } |
5271 return retval; | 5417 return retval; |
5272 } | 5418 } |
5273 | 5419 |
5274 /* | 5420 /* |
5314 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 5460 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
5315 // Get the method that you want to call | 5461 // Get the method that you want to call |
5316 jmethodID timerConnect = env->GetMethodID(clazz, "timerConnect", | 5462 jmethodID timerConnect = env->GetMethodID(clazz, "timerConnect", |
5317 "(JJJ)Ljava/util/Timer;"); | 5463 "(JJJ)Ljava/util/Timer;"); |
5318 // Call the method on the object | 5464 // Call the method on the object |
5319 retval = DW_POINTER_TO_INT(env->NewGlobalRef(env->CallObjectMethod(_dw_obj, | 5465 retval = DW_POINTER_TO_INT(_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, |
5320 timerConnect, longinterval, (jlong)sigfunc, (jlong)data))); | 5466 timerConnect, longinterval, (jlong)sigfunc, (jlong)data), _DW_REFERENCE_STRONG)); |
5321 } | 5467 } |
5322 return retval; | 5468 return retval; |
5323 } | 5469 } |
5324 | 5470 |
5325 /* | 5471 /* |
5340 // Get the method that you want to call | 5486 // Get the method that you want to call |
5341 jmethodID timerDisconnect = env->GetMethodID(clazz, "timerDisconnect", | 5487 jmethodID timerDisconnect = env->GetMethodID(clazz, "timerDisconnect", |
5342 "(Ljava/util/Timer;)V"); | 5488 "(Ljava/util/Timer;)V"); |
5343 // Call the method on the object | 5489 // Call the method on the object |
5344 env->CallVoidMethod(_dw_obj, timerDisconnect, timer); | 5490 env->CallVoidMethod(_dw_obj, timerDisconnect, timer); |
5491 _dw_jni_check_exception(env); | |
5345 } | 5492 } |
5346 } | 5493 } |
5347 | 5494 |
5348 /* | 5495 /* |
5349 * Add a callback to a window event. | 5496 * Add a callback to a window event. |
5618 | 5765 |
5619 /* Check if we are on the UI thread */ | 5766 /* Check if we are on the UI thread */ |
5620 int _dw_is_ui_thread(void) | 5767 int _dw_is_ui_thread(void) |
5621 { | 5768 { |
5622 JNIEnv *env; | 5769 JNIEnv *env; |
5623 | 5770 int retval = FALSE; |
5624 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | 5771 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) |
5625 { | 5772 { |
5626 // First get the class that contains the method you need to call | 5773 // First get the class that contains the method you need to call |
5627 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 5774 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
5628 // Get the method that you want to call | 5775 // Get the method that you want to call |
5629 jmethodID isUIThread = env->GetMethodID(clazz, "isUIThread", | 5776 jmethodID isUIThread = env->GetMethodID(clazz, "isUIThread", |
5630 "()Z"); | 5777 "()Z"); |
5631 // Call the method on the object | 5778 // Call the method on the object |
5632 return env->CallBooleanMethod(_dw_obj, isUIThread); | 5779 retval = env->CallBooleanMethod(_dw_obj, isUIThread); |
5633 } | 5780 if(_dw_jni_check_exception(env)) |
5634 return FALSE; | 5781 retval = FALSE; |
5782 } | |
5783 return retval; | |
5635 } | 5784 } |
5636 | 5785 |
5637 /* | 5786 /* |
5638 * Tries to gain access to the semaphore, if it can't it blocks. | 5787 * Tries to gain access to the semaphore, if it can't it blocks. |
5639 * Parameters: | 5788 * Parameters: |
6365 // Get the method that you want to call | 6514 // Get the method that you want to call |
6366 jmethodID dwInit = env->GetMethodID(clazz, "dwInit", | 6515 jmethodID dwInit = env->GetMethodID(clazz, "dwInit", |
6367 "(Ljava/lang/String;Ljava/lang/String;)I"); | 6516 "(Ljava/lang/String;Ljava/lang/String;)I"); |
6368 // Call the method on the object | 6517 // Call the method on the object |
6369 _dw_android_api = env->CallIntMethod(_dw_obj, dwInit, appid, appname); | 6518 _dw_android_api = env->CallIntMethod(_dw_obj, dwInit, appid, appname); |
6519 if(_dw_jni_check_exception(env)) | |
6520 _dw_android_api = 0; | |
6370 } | 6521 } |
6371 return DW_ERROR_NONE; | 6522 return DW_ERROR_NONE; |
6372 } | 6523 } |
6373 | 6524 |
6374 /* | 6525 /* |
6385 // Get the method that you want to call | 6536 // Get the method that you want to call |
6386 jmethodID dwindowsShutdown = env->GetMethodID(clazz, "dwindowsShutdown", | 6537 jmethodID dwindowsShutdown = env->GetMethodID(clazz, "dwindowsShutdown", |
6387 "()V"); | 6538 "()V"); |
6388 // Call the method on the object | 6539 // Call the method on the object |
6389 env->CallVoidMethod(_dw_obj, dwindowsShutdown); | 6540 env->CallVoidMethod(_dw_obj, dwindowsShutdown); |
6541 _dw_jni_check_exception(env); | |
6390 } | 6542 } |
6391 } | 6543 } |
6392 | 6544 |
6393 /* | 6545 /* |
6394 * Execute and external program in a seperate session. | 6546 * Execute and external program in a seperate session. |
6500 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | 6652 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); |
6501 // Get the method that you want to call | 6653 // Get the method that you want to call |
6502 jmethodID notificationNew = env->GetMethodID(clazz, "notificationNew", | 6654 jmethodID notificationNew = env->GetMethodID(clazz, "notificationNew", |
6503 "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroidx/core/app/NotificationCompat$Builder;"); | 6655 "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroidx/core/app/NotificationCompat$Builder;"); |
6504 // Call the method on the object | 6656 // Call the method on the object |
6505 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, notificationNew, ntitle, image, ndesc, appid)); | 6657 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, notificationNew, ntitle, image, ndesc, appid), _DW_REFERENCE_WEAK); |
6506 return result; | 6658 return result; |
6507 } | 6659 } |
6508 return nullptr; | 6660 return nullptr; |
6509 } | 6661 } |
6510 | 6662 |
6526 // Get the method that you want to call | 6678 // Get the method that you want to call |
6527 jmethodID notificationNew = env->GetMethodID(clazz, "notificationSend", | 6679 jmethodID notificationNew = env->GetMethodID(clazz, "notificationSend", |
6528 "(Landroidx/core/app/NotificationCompat$Builder;)V"); | 6680 "(Landroidx/core/app/NotificationCompat$Builder;)V"); |
6529 // Call the method on the object | 6681 // Call the method on the object |
6530 env->CallVoidMethod(_dw_obj, notificationNew, notification); | 6682 env->CallVoidMethod(_dw_obj, notificationNew, notification); |
6531 return DW_ERROR_NONE; | 6683 if(!_dw_jni_check_exception(env)) |
6684 return DW_ERROR_NONE; | |
6532 } | 6685 } |
6533 return DW_ERROR_UNKNOWN; | 6686 return DW_ERROR_UNKNOWN; |
6534 } | 6687 } |
6535 | 6688 |
6536 /* | 6689 /* |