Mercurial > dwindows
changeset 2776:858155527b05
Android: Minor tree changes... mostly testing my system to push changes to GitHub.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 21 Jun 2022 07:55:53 +0000 |
parents | 5f77f52df8ac |
children | 7d7eac751f7d |
files | android/DWindows.kt android/dw.cpp dw.h |
diffstat | 3 files changed, 28 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/android/DWindows.kt Thu May 26 16:18:33 2022 +0000 +++ b/android/DWindows.kt Tue Jun 21 07:55:53 2022 +0000 @@ -77,6 +77,10 @@ private var level: Int private var isExpanded: Boolean private var isSelected: Boolean + var itemData: Long = 0 + var itemIcon: Drawable? = null + var parentItem: DWTreeItem? = null + fun addChild(child: DWTreeItem) { child.setParent(this) child.setLevel(level + 1) @@ -4519,7 +4523,7 @@ return tree } - fun treeInsertAfter(tree: DWTree, title: String, icon: Drawable, parent: DWTreeItem?, itemdata: Long): DWTreeItem? + fun treeInsertAfter(tree: DWTree, item: DWTreeItem?, title: String, icon: Drawable, parent: DWTreeItem?, itemdata: Long): DWTreeItem? { var treeitem: DWTreeItem? = null @@ -4531,7 +4535,10 @@ tree.roots.add(treeitem!!) } else { parent.addChild(treeitem!!) - } + treeitem!!.parentItem = parent + } + treeitem!!.itemData = itemdata + treeitem!!.itemIcon = icon } return treeitem }
--- a/android/dw.cpp Thu May 26 16:18:33 2022 +0000 +++ b/android/dw.cpp Tue Jun 21 07:55:53 2022 +0000 @@ -402,7 +402,7 @@ char *text = (char *)params[1]; void *user = params[7]; - retval = treeselectfunc(handler->window, params[0], text, handler->data, user); + retval = treeselectfunc(handler->window, (jobject)params[0], text, handler->data, user); break; } /* Set Focus event */ @@ -3314,7 +3314,22 @@ */ HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, const char *title, HICN icon, HTREEITEM parent, void *itemdata) { - /* TODO: Implement the tree if possible. */ + JNIEnv *env; + + if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) + { + // Construct the string + jstring jstr = env->NewStringUTF(title); + // 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 treeInsertAfter = env->GetMethodID(clazz, "treeInsertAfter", + "(Lorg/dbsoft/dwindows/DWTree;Lorg/dbsoft/dwindows/DWTreeItem;Ljava/lang/String;Landroid/graphics/drawable/Drawable;Lorg/dbsoft/dwindows/DWTreeItem;J)Lorg/dbsoft/dwindows/DWTreeItem;"); + // Call the method on the object + jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, treeInsertAfter, handle, item, + jstr, icon, parent, (jlong)itemdata), _DW_REFERENCE_WEAK); + return result; + } return nullptr; } @@ -3331,8 +3346,7 @@ */ HTREEITEM API dw_tree_insert(HWND handle, const char *title, HICN icon, HTREEITEM parent, void *itemdata) { - /* TODO: Implement the tree if possible. */ - return nullptr; + return dw_tree_insert_after(handle, nullptr, title, icon, parent, itemdata); } /*