Mercurial > dwindows
diff android/dw.cpp @ 2519:551313c064f2
Android: Implement ListBox with ListView and fill in the missing listbox functions.
Multiple selection doesn't seem to be working, so might need some more work.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sat, 08 May 2021 21:34:55 +0000 |
parents | c4e90a623437 |
children | 167af4b0004b |
line wrap: on
line diff
--- a/android/dw.cpp Sat May 08 08:43:47 2021 +0000 +++ b/android/dw.cpp Sat May 08 21:34:55 2021 +0000 @@ -433,6 +433,16 @@ _dw_event_handler(obj, params, message); } +JNIEXPORT void JNICALL +Java_org_dbsoft_dwindows_DWListBox_eventHandlerInt(JNIEnv* env, jobject obj, jint message, + jint inta, jint intb, jint intc, jint intd) { + void *params[8] = { NULL, NULL, NULL, + DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb), + DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), NULL }; + + _dw_event_handler(obj, params, message); +} + /* Handler for Timer events */ JNIEXPORT jint JNICALL Java_org_dbsoft_dwindows_DWindows_eventHandlerTimer(JNIEnv* env, jobject obj, jlong sigfunc, jlong data) { @@ -1517,6 +1527,19 @@ */ HWND API dw_listbox_new(ULONG cid, int multi) { + 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 listBoxNew = env->GetMethodID(clazz, "listBoxNew", + "(II)Lorg/dbsoft/dwindows/DWListBox;"); + // Call the method on the object + jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, listBoxNew, (int)cid, multi)); + return result; + } return 0; } @@ -1639,6 +1662,18 @@ */ void API dw_listbox_set_top(HWND handle, int top) { + JNIEnv *env; + + 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 listSetTop = env->GetMethodID(clazz, "listSetTop", + "(Landroid/view/View;I)V"); + // Call the method on the object + env->CallVoidMethod(_dw_obj, listSetTop, handle, top); + } } /*