comparison 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
comparison
equal deleted inserted replaced
2518:c4e90a623437 2519:551313c064f2
431 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), NULL }; 431 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), NULL };
432 432
433 _dw_event_handler(obj, params, message); 433 _dw_event_handler(obj, params, message);
434 } 434 }
435 435
436 JNIEXPORT void JNICALL
437 Java_org_dbsoft_dwindows_DWListBox_eventHandlerInt(JNIEnv* env, jobject obj, jint message,
438 jint inta, jint intb, jint intc, jint intd) {
439 void *params[8] = { NULL, NULL, NULL,
440 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb),
441 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), NULL };
442
443 _dw_event_handler(obj, params, message);
444 }
445
436 /* Handler for Timer events */ 446 /* Handler for Timer events */
437 JNIEXPORT jint JNICALL 447 JNIEXPORT jint JNICALL
438 Java_org_dbsoft_dwindows_DWindows_eventHandlerTimer(JNIEnv* env, jobject obj, jlong sigfunc, jlong data) { 448 Java_org_dbsoft_dwindows_DWindows_eventHandlerTimer(JNIEnv* env, jobject obj, jlong sigfunc, jlong data) {
439 int (*timerfunc)(void *) = (int (* API)(void *))sigfunc; 449 int (*timerfunc)(void *) = (int (* API)(void *))sigfunc;
440 450
1515 * Returns: 1525 * Returns:
1516 * A handle to a listbox window or NULL on failure. 1526 * A handle to a listbox window or NULL on failure.
1517 */ 1527 */
1518 HWND API dw_listbox_new(ULONG cid, int multi) 1528 HWND API dw_listbox_new(ULONG cid, int multi)
1519 { 1529 {
1530 JNIEnv *env;
1531
1532 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
1533 {
1534 // First get the class that contains the method you need to call
1535 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
1536 // Get the method that you want to call
1537 jmethodID listBoxNew = env->GetMethodID(clazz, "listBoxNew",
1538 "(II)Lorg/dbsoft/dwindows/DWListBox;");
1539 // Call the method on the object
1540 jobject result = env->NewWeakGlobalRef(env->CallObjectMethod(_dw_obj, listBoxNew, (int)cid, multi));
1541 return result;
1542 }
1520 return 0; 1543 return 0;
1521 } 1544 }
1522 1545
1523 /* 1546 /*
1524 * Appends the specified text to the listbox's (or combobox) entry list. 1547 * Appends the specified text to the listbox's (or combobox) entry list.
1637 * handle: Handle to the listbox to be cleared. 1660 * handle: Handle to the listbox to be cleared.
1638 * top: Index to the top item. 1661 * top: Index to the top item.
1639 */ 1662 */
1640 void API dw_listbox_set_top(HWND handle, int top) 1663 void API dw_listbox_set_top(HWND handle, int top)
1641 { 1664 {
1665 JNIEnv *env;
1666
1667 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
1668 {
1669 // First get the class that contains the method you need to call
1670 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
1671 // Get the method that you want to call
1672 jmethodID listSetTop = env->GetMethodID(clazz, "listSetTop",
1673 "(Landroid/view/View;I)V");
1674 // Call the method on the object
1675 env->CallVoidMethod(_dw_obj, listSetTop, handle, top);
1676 }
1642 } 1677 }
1643 1678
1644 /* 1679 /*
1645 * Copies the given index item's text into buffer. 1680 * Copies the given index item's text into buffer.
1646 * Parameters: 1681 * Parameters: