comparison android/dw.cpp @ 2706:4e9eba7f7226

Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos().
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 19 Nov 2021 02:20:11 +0000
parents 4f12dc8e8f18
children a3f6ca621453
comparison
equal deleted inserted replaced
2705:ddcbed595a84 2706:4e9eba7f7226
1422 * Returns: 1422 * Returns:
1423 * The vertical or horizontal position in the scrollbox. 1423 * The vertical or horizontal position in the scrollbox.
1424 */ 1424 */
1425 int API dw_scrollbox_get_pos(HWND handle, int orient) 1425 int API dw_scrollbox_get_pos(HWND handle, int orient)
1426 { 1426 {
1427 return 0; 1427 JNIEnv *env;
1428 int retval = DW_ERROR_UNKNOWN;
1429
1430 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
1431 {
1432 // First get the class that contains the method you need to call
1433 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
1434 // Get the method that you want to call
1435 jmethodID scrollBoxGetPos = env->GetMethodID(clazz, "scrollBoxGetPos",
1436 "(Landroid/widget/ScrollView;I)I");
1437 // Call the method on the object
1438 retval = env->CallIntMethod(_dw_obj, scrollBoxGetPos, handle, orient);
1439 if(_dw_jni_check_exception(env))
1440 retval = DW_ERROR_UNKNOWN;
1441 }
1442 return retval;
1428 } 1443 }
1429 1444
1430 /* 1445 /*
1431 * Gets the range for the scrollbar in the scrollbox. 1446 * Gets the range for the scrollbar in the scrollbox.
1432 * Parameters: 1447 * Parameters:
1435 * Returns: 1450 * Returns:
1436 * The vertical or horizontal range of the scrollbox. 1451 * The vertical or horizontal range of the scrollbox.
1437 */ 1452 */
1438 int API dw_scrollbox_get_range(HWND handle, int orient) 1453 int API dw_scrollbox_get_range(HWND handle, int orient)
1439 { 1454 {
1440 return 0; 1455 JNIEnv *env;
1456 int retval = DW_ERROR_UNKNOWN;
1457
1458 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
1459 {
1460 // First get the class that contains the method you need to call
1461 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
1462 // Get the method that you want to call
1463 jmethodID scrollBoxGetRange = env->GetMethodID(clazz, "scrollBoxGetRange",
1464 "(Landroid/widget/ScrollView;I)I");
1465 // Call the method on the object
1466 retval = env->CallIntMethod(_dw_obj, scrollBoxGetRange, handle, orient);
1467 if(_dw_jni_check_exception(env))
1468 retval = DW_ERROR_UNKNOWN;
1469 }
1470 return retval;
1441 } 1471 }
1442 1472
1443 /* Internal box packing function called by the other 3 functions */ 1473 /* Internal box packing function called by the other 3 functions */
1444 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, const char *funcname) 1474 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, const char *funcname)
1445 { 1475 {