Mercurial > dwindows
diff 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 |
line wrap: on
line diff
--- a/android/dw.cpp Sat May 01 00:41:53 2021 +0000 +++ b/android/dw.cpp Sun May 02 01:05:20 2021 +0000 @@ -2933,6 +2933,19 @@ */ HWND API dw_notebook_new(ULONG cid, int top) { + JNIEnv *env; + + if((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 notebookNew = env->GetMethodID(clazz, "notebookNew", + "(II)Landroid/widget/RelativeLayout;"); + // Call the method on the object + jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, notebookNew, (int)cid, top)); + return result; + } return 0; } @@ -2947,7 +2960,20 @@ */ unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front) { - return 0; + JNIEnv *env; + unsigned long result = 0; + + 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 notebookPageNew = env->GetMethodID(clazz, "notebookPageNew", + "(Landroid/widget/RelativeLayout;JI)Ljava/lang/Object;"); + // Call the method on the object + result = DW_POINTER_TO_INT(env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, notebookPageNew, handle, (jlong)flags, front))); + } + return result; } /* @@ -2958,6 +2984,23 @@ */ void API dw_notebook_page_destroy(HWND handle, unsigned int pageid) { + JNIEnv *env; + + if(handle && pageid && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) + { + jobject tab = (jobject)DW_INT_TO_POINTER(pageid); + + // 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 notebookPageDestroy = env->GetMethodID(clazz, "notebookPageDestroy", + "(Landroid/widget/RelativeLayout;Lcom/google/android/material/tabs/TabLayout/Tab;)V"); + // Call the method on the object + env->CallVoidMethod(_dw_obj, notebookPageDestroy, handle, tab); + + // Release the global reference + env->DeleteWeakGlobalRef(tab); + } } /* @@ -2969,7 +3012,19 @@ */ unsigned long API dw_notebook_page_get(HWND handle) { - return 0; + JNIEnv *env; + unsigned long result = 0; + + 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 notebookPageGet = env->GetMethodID(clazz, "notebookPageGet", + "(Landroid/widget/RelativeLayout;)Lcom/google/android/material/tabs/TabLayout/Tab;"); + // Call the method on the object + result = DW_POINTER_TO_INT(env->CallObjectMethod(_dw_obj, notebookPageGet, handle)); + } + return result; } /* @@ -2980,6 +3035,19 @@ */ void API dw_notebook_page_set(HWND handle, unsigned int pageid) { + JNIEnv *env; + + if(handle && pageid && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) { + jobject tab = (jobject) DW_INT_TO_POINTER(pageid); + + // 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 notebookPageSet = env->GetMethodID(clazz, "notebookPageSet", + "(Landroid/widget/RelativeLayout;Lcom/google/android/material/tabs/TabLayout/Tab;)V"); + // Call the method on the object + env->CallVoidMethod(_dw_obj, notebookPageSet, handle, tab); + } } /* @@ -2991,6 +3059,22 @@ */ void API dw_notebook_page_set_text(HWND handle, ULONG pageid, const char *text) { + JNIEnv *env; + + if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) + { + jobject tab = (jobject)DW_INT_TO_POINTER(pageid); + + // Construct a String + jstring jstr = env->NewStringUTF(text); + // 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 notebookPageSetText = env->GetMethodID(clazz, "notebookPageSetText", + "(Landroid/widget/RelativeLayout;Lcom/google/android/material/tabs/TabLayout/Tab;Ljava/lang/String;)V"); + // Call the method on the object + env->CallVoidMethod(_dw_obj, notebookPageSetText, handle, tab, jstr); + } } /* @@ -3013,6 +3097,20 @@ */ void API dw_notebook_pack(HWND handle, ULONG pageid, HWND page) { + JNIEnv *env; + + if(handle && pageid && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) + { + jobject tab = (jobject)DW_INT_TO_POINTER(pageid); + + // 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 notebookPack = env->GetMethodID(clazz, "notebookPack", + "(Landroid/widget/RelativeLayout;Lcom/google/android/material/tabs/TabLayout/Tab;Landroid/widget/LinearLayout;)V"); + // Call the method on the object + env->CallVoidMethod(_dw_obj, notebookPack, handle, tab, page); + } } /*