comparison android/dw.cpp @ 2500:ac0b7e579229

Android: Implement dw_scrollbox_new() using ScrollView.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 05 May 2021 21:59:23 +0000
parents ff3310fa6d72
children 41984ffb5ca2
comparison
equal deleted inserted replaced
2499:ff3310fa6d72 2500:ac0b7e579229
824 * Returns: 824 * Returns:
825 * A handle to a groupbox window or NULL on failure. 825 * A handle to a groupbox window or NULL on failure.
826 */ 826 */
827 HWND API dw_groupbox_new(int type, int pad, const char *title) 827 HWND API dw_groupbox_new(int type, int pad, const char *title)
828 { 828 {
829 return 0; 829 /* TODO: Just create a normal box for now */
830 return dw_box_new(type, pad);
830 } 831 }
831 832
832 /* 833 /*
833 * Create a new scrollable Box to be packed. 834 * Create a new scrollable Box to be packed.
834 * Parameters: 835 * Parameters:
836 * pad: Number of pixels to pad around the box. 837 * pad: Number of pixels to pad around the box.
837 * Returns: 838 * Returns:
838 * A handle to a scrollbox or NULL on failure. 839 * A handle to a scrollbox or NULL on failure.
839 */ 840 */
840 HWND API dw_scrollbox_new(int type, int pad) 841 HWND API dw_scrollbox_new(int type, int pad)
841 {
842 /* TODO: Just create a normal box for now */
843 return dw_box_new(type, pad);
844 }
845
846 /*
847 * Returns the position of the scrollbar in the scrollbox.
848 * Parameters:
849 * handle: Handle to the scrollbox to be queried.
850 * orient: The vertical or horizontal scrollbar.
851 * Returns:
852 * The vertical or horizontal position in the scrollbox.
853 */
854 int API dw_scrollbox_get_pos(HWND handle, int orient)
855 {
856 return 0;
857 }
858
859 /*
860 * Gets the range for the scrollbar in the scrollbox.
861 * Parameters:
862 * handle: Handle to the scrollbox to be queried.
863 * orient: The vertical or horizontal scrollbar.
864 * Returns:
865 * The vertical or horizontal range of the scrollbox.
866 */
867 int API dw_scrollbox_get_range(HWND handle, int orient)
868 {
869 return 0;
870 }
871
872 /* Internal box packing function called by the other 3 functions */
873 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, const char *funcname)
874 { 842 {
875 JNIEnv *env; 843 JNIEnv *env;
876 844
877 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) 845 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
878 { 846 {
879 // First get the class that contains the method you need to call 847 // First get the class that contains the method you need to call
880 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); 848 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
881 // Get the method that you want to call 849 // Get the method that you want to call
882 jmethodID boxPack = env->GetMethodID(clazz, "boxPack", "(Landroid/widget/LinearLayout;Landroid/view/View;IIIIII)V"); 850 jmethodID scrollBoxNew = env->GetMethodID(clazz, "scrollBoxNew",
851 "(II)Landroid/widget/ScrollView;");
852 // Call the method on the object
853 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, scrollBoxNew, type, pad));
854 return result;
855 }
856 return 0;
857 }
858
859 /*
860 * Returns the position of the scrollbar in the scrollbox.
861 * Parameters:
862 * handle: Handle to the scrollbox to be queried.
863 * orient: The vertical or horizontal scrollbar.
864 * Returns:
865 * The vertical or horizontal position in the scrollbox.
866 */
867 int API dw_scrollbox_get_pos(HWND handle, int orient)
868 {
869 return 0;
870 }
871
872 /*
873 * Gets the range for the scrollbar in the scrollbox.
874 * Parameters:
875 * handle: Handle to the scrollbox to be queried.
876 * orient: The vertical or horizontal scrollbar.
877 * Returns:
878 * The vertical or horizontal range of the scrollbox.
879 */
880 int API dw_scrollbox_get_range(HWND handle, int orient)
881 {
882 return 0;
883 }
884
885 /* Internal box packing function called by the other 3 functions */
886 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, const char *funcname)
887 {
888 JNIEnv *env;
889
890 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
891 {
892 // First get the class that contains the method you need to call
893 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
894 // Get the method that you want to call
895 jmethodID boxPack = env->GetMethodID(clazz, "boxPack", "(Landroid/view/View;Landroid/view/View;IIIIII)V");
883 // Call the method on the object 896 // Call the method on the object
884 env->CallVoidMethod(_dw_obj, boxPack, box, item, index, width, height, hsize, vsize, pad); 897 env->CallVoidMethod(_dw_obj, boxPack, box, item, index, width, height, hsize, vsize, pad);
885 } 898 }
886 } 899 }
887 900