Mercurial > dwindows
comparison android/dw.cpp @ 2493:bca7e0ab0ccc
Android: Work on the notebook control, doesn't work yet but everything filled in.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 02 May 2021 01:05:20 +0000 |
parents | e2ca6c1a4661 |
children | b3e28eed0e50 |
comparison
equal
deleted
inserted
replaced
2492:e2ca6c1a4661 | 2493:bca7e0ab0ccc |
---|---|
2931 * Returns: | 2931 * Returns: |
2932 * Handle to the created notebook or NULL on error. | 2932 * Handle to the created notebook or NULL on error. |
2933 */ | 2933 */ |
2934 HWND API dw_notebook_new(ULONG cid, int top) | 2934 HWND API dw_notebook_new(ULONG cid, int top) |
2935 { | 2935 { |
2936 JNIEnv *env; | |
2937 | |
2938 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | |
2939 { | |
2940 // First get the class that contains the method you need to call | |
2941 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | |
2942 // Get the method that you want to call | |
2943 jmethodID notebookNew = env->GetMethodID(clazz, "notebookNew", | |
2944 "(II)Landroid/widget/RelativeLayout;"); | |
2945 // Call the method on the object | |
2946 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, notebookNew, (int)cid, top)); | |
2947 return result; | |
2948 } | |
2936 return 0; | 2949 return 0; |
2937 } | 2950 } |
2938 | 2951 |
2939 /* | 2952 /* |
2940 * Adds a new page to specified notebook. | 2953 * Adds a new page to specified notebook. |
2945 * Returns: | 2958 * Returns: |
2946 * ID of newly created notebook page. | 2959 * ID of newly created notebook page. |
2947 */ | 2960 */ |
2948 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front) | 2961 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front) |
2949 { | 2962 { |
2950 return 0; | 2963 JNIEnv *env; |
2964 unsigned long result = 0; | |
2965 | |
2966 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | |
2967 { | |
2968 // First get the class that contains the method you need to call | |
2969 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | |
2970 // Get the method that you want to call | |
2971 jmethodID notebookPageNew = env->GetMethodID(clazz, "notebookPageNew", | |
2972 "(Landroid/widget/RelativeLayout;JI)Ljava/lang/Object;"); | |
2973 // Call the method on the object | |
2974 result = DW_POINTER_TO_INT(env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, notebookPageNew, handle, (jlong)flags, front))); | |
2975 } | |
2976 return result; | |
2951 } | 2977 } |
2952 | 2978 |
2953 /* | 2979 /* |
2954 * Remove a page from a notebook. | 2980 * Remove a page from a notebook. |
2955 * Parameters: | 2981 * Parameters: |
2956 * handle: Handle to the notebook widget. | 2982 * handle: Handle to the notebook widget. |
2957 * pageid: ID of the page to be destroyed. | 2983 * pageid: ID of the page to be destroyed. |
2958 */ | 2984 */ |
2959 void API dw_notebook_page_destroy(HWND handle, unsigned int pageid) | 2985 void API dw_notebook_page_destroy(HWND handle, unsigned int pageid) |
2960 { | 2986 { |
2987 JNIEnv *env; | |
2988 | |
2989 if(handle && pageid && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | |
2990 { | |
2991 jobject tab = (jobject)DW_INT_TO_POINTER(pageid); | |
2992 | |
2993 // First get the class that contains the method you need to call | |
2994 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | |
2995 // Get the method that you want to call | |
2996 jmethodID notebookPageDestroy = env->GetMethodID(clazz, "notebookPageDestroy", | |
2997 "(Landroid/widget/RelativeLayout;Lcom/google/android/material/tabs/TabLayout/Tab;)V"); | |
2998 // Call the method on the object | |
2999 env->CallVoidMethod(_dw_obj, notebookPageDestroy, handle, tab); | |
3000 | |
3001 // Release the global reference | |
3002 env->DeleteWeakGlobalRef(tab); | |
3003 } | |
2961 } | 3004 } |
2962 | 3005 |
2963 /* | 3006 /* |
2964 * Queries the currently visible page ID. | 3007 * Queries the currently visible page ID. |
2965 * Parameters: | 3008 * Parameters: |
2967 * Returns: | 3010 * Returns: |
2968 * ID of visible notebook page. | 3011 * ID of visible notebook page. |
2969 */ | 3012 */ |
2970 unsigned long API dw_notebook_page_get(HWND handle) | 3013 unsigned long API dw_notebook_page_get(HWND handle) |
2971 { | 3014 { |
2972 return 0; | 3015 JNIEnv *env; |
3016 unsigned long result = 0; | |
3017 | |
3018 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) { | |
3019 // First get the class that contains the method you need to call | |
3020 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | |
3021 // Get the method that you want to call | |
3022 jmethodID notebookPageGet = env->GetMethodID(clazz, "notebookPageGet", | |
3023 "(Landroid/widget/RelativeLayout;)Lcom/google/android/material/tabs/TabLayout/Tab;"); | |
3024 // Call the method on the object | |
3025 result = DW_POINTER_TO_INT(env->CallObjectMethod(_dw_obj, notebookPageGet, handle)); | |
3026 } | |
3027 return result; | |
2973 } | 3028 } |
2974 | 3029 |
2975 /* | 3030 /* |
2976 * Sets the currently visible page ID. | 3031 * Sets the currently visible page ID. |
2977 * Parameters: | 3032 * Parameters: |
2978 * handle: Handle to the notebook widget. | 3033 * handle: Handle to the notebook widget. |
2979 * pageid: ID of the page to be made visible. | 3034 * pageid: ID of the page to be made visible. |
2980 */ | 3035 */ |
2981 void API dw_notebook_page_set(HWND handle, unsigned int pageid) | 3036 void API dw_notebook_page_set(HWND handle, unsigned int pageid) |
2982 { | 3037 { |
3038 JNIEnv *env; | |
3039 | |
3040 if(handle && pageid && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) { | |
3041 jobject tab = (jobject) DW_INT_TO_POINTER(pageid); | |
3042 | |
3043 // First get the class that contains the method you need to call | |
3044 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | |
3045 // Get the method that you want to call | |
3046 jmethodID notebookPageSet = env->GetMethodID(clazz, "notebookPageSet", | |
3047 "(Landroid/widget/RelativeLayout;Lcom/google/android/material/tabs/TabLayout/Tab;)V"); | |
3048 // Call the method on the object | |
3049 env->CallVoidMethod(_dw_obj, notebookPageSet, handle, tab); | |
3050 } | |
2983 } | 3051 } |
2984 | 3052 |
2985 /* | 3053 /* |
2986 * Sets the text on the specified notebook tab. | 3054 * Sets the text on the specified notebook tab. |
2987 * Parameters: | 3055 * Parameters: |
2989 * pageid: Page ID of the tab to set. | 3057 * pageid: Page ID of the tab to set. |
2990 * text: Pointer to the text to set. | 3058 * text: Pointer to the text to set. |
2991 */ | 3059 */ |
2992 void API dw_notebook_page_set_text(HWND handle, ULONG pageid, const char *text) | 3060 void API dw_notebook_page_set_text(HWND handle, ULONG pageid, const char *text) |
2993 { | 3061 { |
3062 JNIEnv *env; | |
3063 | |
3064 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | |
3065 { | |
3066 jobject tab = (jobject)DW_INT_TO_POINTER(pageid); | |
3067 | |
3068 // Construct a String | |
3069 jstring jstr = env->NewStringUTF(text); | |
3070 // First get the class that contains the method you need to call | |
3071 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | |
3072 // Get the method that you want to call | |
3073 jmethodID notebookPageSetText = env->GetMethodID(clazz, "notebookPageSetText", | |
3074 "(Landroid/widget/RelativeLayout;Lcom/google/android/material/tabs/TabLayout/Tab;Ljava/lang/String;)V"); | |
3075 // Call the method on the object | |
3076 env->CallVoidMethod(_dw_obj, notebookPageSetText, handle, tab, jstr); | |
3077 } | |
2994 } | 3078 } |
2995 | 3079 |
2996 /* | 3080 /* |
2997 * Sets the text on the specified notebook tab status area. | 3081 * Sets the text on the specified notebook tab status area. |
2998 * Parameters: | 3082 * Parameters: |
3011 * pageid: Page ID in the notebook which is being packed. | 3095 * pageid: Page ID in the notebook which is being packed. |
3012 * page: Box handle to be packed. | 3096 * page: Box handle to be packed. |
3013 */ | 3097 */ |
3014 void API dw_notebook_pack(HWND handle, ULONG pageid, HWND page) | 3098 void API dw_notebook_pack(HWND handle, ULONG pageid, HWND page) |
3015 { | 3099 { |
3100 JNIEnv *env; | |
3101 | |
3102 if(handle && pageid && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | |
3103 { | |
3104 jobject tab = (jobject)DW_INT_TO_POINTER(pageid); | |
3105 | |
3106 // First get the class that contains the method you need to call | |
3107 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | |
3108 // Get the method that you want to call | |
3109 jmethodID notebookPack = env->GetMethodID(clazz, "notebookPack", | |
3110 "(Landroid/widget/RelativeLayout;Lcom/google/android/material/tabs/TabLayout/Tab;Landroid/widget/LinearLayout;)V"); | |
3111 // Call the method on the object | |
3112 env->CallVoidMethod(_dw_obj, notebookPack, handle, tab, page); | |
3113 } | |
3016 } | 3114 } |
3017 | 3115 |
3018 /* | 3116 /* |
3019 * Create a new Window Frame. | 3117 * Create a new Window Frame. |
3020 * Parameters: | 3118 * Parameters: |