comparison android/dw.cpp @ 2720:9ce1649b0fbd

Android: Fix vertical sliders/scrollbars by creating a DWSlider class to encapsulate the SeekBar... then override the measurements and adjust the width. The width on the SeekBar needs to be set to the height after rotation... Since that is not the actually correct width, we need to wrap it in a frame.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 09 Dec 2021 01:57:52 +0000
parents 6754e8f70142
children cacde852e2db
comparison
equal deleted inserted replaced
2719:6754e8f70142 2720:9ce1649b0fbd
1927 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) 1927 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
1928 { 1928 {
1929 // First get the class that contains the method you need to call 1929 // First get the class that contains the method you need to call
1930 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); 1930 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
1931 // Get the method that you want to call 1931 // Get the method that you want to call
1932 jmethodID sliderNew = env->GetMethodID(clazz, "sliderNew", "(III)Landroid/widget/SeekBar;"); 1932 jmethodID sliderNew = env->GetMethodID(clazz, "sliderNew",
1933 "(III)Lorg/dbsoft/dwindows/DWSlider;");
1933 // Call the method on the object 1934 // Call the method on the object
1934 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, sliderNew, vertical, increments, (jint)cid), _DW_REFERENCE_WEAK); 1935 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, sliderNew, vertical, increments, (jint)cid), _DW_REFERENCE_WEAK);
1935 return result; 1936 return result;
1936 } 1937 }
1937 return nullptr; 1938 return nullptr;
1953 { 1954 {
1954 // First get the class that contains the method you need to call 1955 // First get the class that contains the method you need to call
1955 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); 1956 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
1956 // Get the method that you want to call 1957 // Get the method that you want to call
1957 jmethodID percentGetPos = env->GetMethodID(clazz, "percentGetPos", 1958 jmethodID percentGetPos = env->GetMethodID(clazz, "percentGetPos",
1958 "(Landroid/widget/ProgressBar;)I"); 1959 "(Landroid/view/View;)I");
1959 // Call the method on the object 1960 // Call the method on the object
1960 retval = env->CallIntMethod(_dw_obj, percentGetPos, handle); 1961 retval = env->CallIntMethod(_dw_obj, percentGetPos, handle);
1961 if(_dw_jni_check_exception(env)) 1962 if(_dw_jni_check_exception(env))
1962 retval = 0; 1963 retval = 0;
1963 } 1964 }
1990 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) 1991 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
1991 { 1992 {
1992 // First get the class that contains the method you need to call 1993 // First get the class that contains the method you need to call
1993 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); 1994 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
1994 // Get the method that you want to call 1995 // Get the method that you want to call
1995 jmethodID scrollBarNew = env->GetMethodID(clazz, "scrollBarNew", "(II)Landroid/widget/SeekBar;"); 1996 jmethodID scrollBarNew = env->GetMethodID(clazz, "scrollBarNew",
1997 "(II)Lorg/dbsoft/dwindows/DWSlider;");
1996 // Call the method on the object 1998 // Call the method on the object
1997 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, scrollBarNew, vertical, (jint)cid), _DW_REFERENCE_WEAK); 1999 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, scrollBarNew, vertical, (jint)cid), _DW_REFERENCE_WEAK);
1998 return result; 2000 return result;
1999 } 2001 }
2000 return nullptr; 2002 return nullptr;
2038 { 2040 {
2039 // First get the class that contains the method you need to call 2041 // First get the class that contains the method you need to call
2040 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); 2042 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
2041 // Get the method that you want to call 2043 // Get the method that you want to call
2042 jmethodID percentSetRange = env->GetMethodID(clazz, "percentSetRange", 2044 jmethodID percentSetRange = env->GetMethodID(clazz, "percentSetRange",
2043 "(Landroid/widget/ProgressBar;I)V"); 2045 "(Landroid/view/View;I)V");
2044 // Call the method on the object 2046 // Call the method on the object
2045 env->CallVoidMethod(_dw_obj, percentSetRange, handle, (jint)range); 2047 env->CallVoidMethod(_dw_obj, percentSetRange, handle, (jint)range);
2046 _dw_jni_check_exception(env); 2048 _dw_jni_check_exception(env);
2047 } 2049 }
2048 } 2050 }
2086 { 2088 {
2087 // First get the class that contains the method you need to call 2089 // First get the class that contains the method you need to call
2088 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); 2090 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
2089 // Get the method that you want to call 2091 // Get the method that you want to call
2090 jmethodID percentSetPos = env->GetMethodID(clazz, "percentSetPos", 2092 jmethodID percentSetPos = env->GetMethodID(clazz, "percentSetPos",
2091 "(Landroid/widget/ProgressBar;I)V"); 2093 "(Landroid/view/View;I)V");
2092 // Call the method on the object 2094 // Call the method on the object
2093 env->CallVoidMethod(_dw_obj, percentSetPos, handle, (jint)position); 2095 env->CallVoidMethod(_dw_obj, percentSetPos, handle, (jint)position);
2094 _dw_jni_check_exception(env); 2096 _dw_jni_check_exception(env);
2095 } 2097 }
2096 } 2098 }