# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1637288411 0 # Node ID 4e9eba7f72267dc9963169483ca6fabdd0f7ad95 # Parent ddcbed595a8402ac8b1e1aff9e1d5235750a3a72 Android: Implement dw_scrollbox_get_range() and dw_scrollbox_get_pos(). diff -r ddcbed595a84 -r 4e9eba7f7226 android/DWindows.kt --- a/android/DWindows.kt Thu Nov 18 12:04:40 2021 +0000 +++ b/android/DWindows.kt Fri Nov 19 02:20:11 2021 +0000 @@ -1693,7 +1693,7 @@ return box } - fun scrollBoxNew(type: Int, pad: Int) : ScrollView? { + fun scrollBoxNew(type: Int, pad: Int): ScrollView? { var scrollBox: ScrollView? = null waitOnUiThread { @@ -1720,6 +1720,34 @@ return scrollBox } + fun scrollBoxGetPos(scrollBox: ScrollView, orient: Int): Int { + var retval: Int = -1 + + waitOnUiThread { + // DW_VERT 1 + if(orient == 1) { + retval = scrollBox.scrollY + } else { + retval = scrollBox.scrollX + } + } + return retval + } + + fun scrollBoxGetRange(scrollBox: ScrollView, orient: Int): Int { + var retval: Int = -1 + + waitOnUiThread { + // DW_VERT 1 + if(orient == 1) { + retval = scrollBox.getChildAt(0).height + } else { + retval = scrollBox.getChildAt(0).width + } + } + return retval + } + // Update the layoutParams of a box after a change private fun boxUpdate(box: LinearLayout) { diff -r ddcbed595a84 -r 4e9eba7f7226 android/dw.cpp --- a/android/dw.cpp Thu Nov 18 12:04:40 2021 +0000 +++ b/android/dw.cpp Fri Nov 19 02:20:11 2021 +0000 @@ -1424,7 +1424,22 @@ */ int API dw_scrollbox_get_pos(HWND handle, int orient) { - return 0; + JNIEnv *env; + int retval = DW_ERROR_UNKNOWN; + + if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) + { + // First get the class that contains the method you need to call + jclass clazz = _dw_find_class(env, DW_CLASS_NAME); + // Get the method that you want to call + jmethodID scrollBoxGetPos = env->GetMethodID(clazz, "scrollBoxGetPos", + "(Landroid/widget/ScrollView;I)I"); + // Call the method on the object + retval = env->CallIntMethod(_dw_obj, scrollBoxGetPos, handle, orient); + if(_dw_jni_check_exception(env)) + retval = DW_ERROR_UNKNOWN; + } + return retval; } /* @@ -1437,7 +1452,22 @@ */ int API dw_scrollbox_get_range(HWND handle, int orient) { - return 0; + JNIEnv *env; + int retval = DW_ERROR_UNKNOWN; + + if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) + { + // First get the class that contains the method you need to call + jclass clazz = _dw_find_class(env, DW_CLASS_NAME); + // Get the method that you want to call + jmethodID scrollBoxGetRange = env->GetMethodID(clazz, "scrollBoxGetRange", + "(Landroid/widget/ScrollView;I)I"); + // Call the method on the object + retval = env->CallIntMethod(_dw_obj, scrollBoxGetRange, handle, orient); + if(_dw_jni_check_exception(env)) + retval = DW_ERROR_UNKNOWN; + } + return retval; } /* Internal box packing function called by the other 3 functions */