annotate android/dw.cpp @ 2566:4427af56eebe

Android: Add experimental event threading code, currently disabled.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 19 May 2021 20:13:11 +0000
parents f28d7d0ca5ed
children e34b627b2491
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2 * Dynamic Windows:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3 * A GTK like GUI implementation of the Android GUI.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4 *
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5 * (C) 2011-2021 Brian Smith <brian@dbsoft.org>
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6 * (C) 2011-2021 Mark Hessling <mark@rexx.org>
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7 *
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
8 * Requires Android API 19 (KitKat) or higher.
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
9 *
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
10 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
11
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
12 #include "dw.h"
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
13 #include <stdlib.h>
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
14 #include <string.h>
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
15 #include <sys/utsname.h>
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
16 #include <sys/socket.h>
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
17 #include <sys/un.h>
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
18 #include <sys/mman.h>
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
19 #include <sys/types.h>
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
20 #include <sys/stat.h>
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
21 #include <dlfcn.h>
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
22 #include <errno.h>
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
23 #include <fcntl.h>
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
24 #include <unistd.h>
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
25 #if defined(__ANDROID__) && (__ANDROID_API__+0) < 21
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
26 #include <sys/syscall.h>
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
27
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
28 /* Until Android API version 21 NDK does not define getsid wrapper in libc, although there is the corresponding syscall */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
29 inline pid_t getsid(pid_t pid)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
30 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
31 return static_cast< pid_t >(::syscall(__NR_getsid, pid));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
32 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
33 #endif
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
34
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
35 #ifdef __cplusplus
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
36 extern "C" {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
37 #endif
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
38
2566
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
39 /* Define this to enable threading for events...
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
40 * most Android events don't handle return values, so
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
41 * we can launch a new thread to handle the event.
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
42 * #define _DW_EVENT_THREADING
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
43 */
2484
cb5b67154399 Android: The DWindows class should be org.dbsoft.dwindows, remove dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2483
diff changeset
44 #define DW_CLASS_NAME "org/dbsoft/dwindows/DWindows"
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
45
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
46 /* Dynamic Windows internal variables */
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
47 static char _dw_app_id[_DW_APP_ID_SIZE+1]= {0};
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
48 static char _dw_app_name[_DW_APP_ID_SIZE+1]= {0};
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
49 static char _dw_exec_dir[MAX_PATH+1] = {0};
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
50 static int _dw_android_api = 0;
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
51
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
52 static pthread_key_t _dw_env_key;
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
53 static HEV _dw_main_event;
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
54 static JavaVM *_dw_jvm;
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
55 static jobject _dw_obj;
2477
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
56 static jobject _dw_class_loader;
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
57 static jmethodID _dw_class_method;
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
58
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
59 JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *pjvm, void *reserved)
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
60 {
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
61 JNIEnv *env;
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
62 jclass randomClass, classClass, classLoaderClass;
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
63 jmethodID getClassLoaderMethod;
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
64
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
65 /* Initialize the handle to the Java Virtual Machine */
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
66 _dw_jvm = pjvm;
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
67 _dw_jvm->GetEnv((void**)&env, JNI_VERSION_1_6);
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
68
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
69 randomClass = env->FindClass(DW_CLASS_NAME);
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
70 classClass = env->GetObjectClass(randomClass);
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
71 classLoaderClass = env->FindClass("java/lang/ClassLoader");
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
72 getClassLoaderMethod = env->GetMethodID(classClass, "getClassLoader",
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
73 "()Ljava/lang/ClassLoader;");
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
74 _dw_class_loader = env->NewGlobalRef(env->CallObjectMethod(randomClass, getClassLoaderMethod));
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
75 _dw_class_method = env->GetMethodID(classLoaderClass, "findClass",
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
76 "(Ljava/lang/String;)Ljava/lang/Class;");
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
77
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
78 return JNI_VERSION_1_6;
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
79 }
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
80
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
81 jclass _dw_find_class(JNIEnv *env, const char* name)
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
82 {
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
83 return static_cast<jclass>(env->CallObjectMethod(_dw_class_loader, _dw_class_method, env->NewStringUTF(name)));
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
84 }
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
85
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
86 // Do a quick check if an exception occurred...
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
87 // Display then clear it so we can continue...
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
88 // Return TRUE if an exception had occurred
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
89 int _dw_jni_check_exception(JNIEnv *env)
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
90 {
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
91 if(env->ExceptionCheck())
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
92 {
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
93 env->ExceptionDescribe();
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
94 env->ExceptionClear();
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
95 return TRUE;
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
96 }
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
97 return FALSE;
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
98 }
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
99
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
100 #define _DW_REFERENCE_NONE 0
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
101 #define _DW_REFERENCE_WEAK 1
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
102 #define _DW_REFERENCE_STRONG 2
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
103
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
104 // Handle returns from JNI functions and make sure the
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
105 // return value is sane...
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
106 // Reference: 0 no reference 1 weak 2 strong
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
107 jobject _dw_jni_check_result(JNIEnv *env, jobject obj, int reference)
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
108 {
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
109 jobject result = nullptr;
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
110
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
111 if(!_dw_jni_check_exception(env) && obj)
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
112 {
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
113 if(reference == _DW_REFERENCE_WEAK)
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
114 result = env->NewWeakGlobalRef(obj);
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
115 else if(reference == _DW_REFERENCE_STRONG)
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
116 result = env->NewGlobalRef(obj);
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
117 else
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
118 result = obj;
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
119 }
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
120 return result;
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
121 }
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
122
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
123 /* Call the dwmain entry point, Android has no args, so just pass the app path */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
124 void _dw_main_launch(char *arg)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
125 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
126 static HEV startup = nullptr;
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
127
2496
3bf2f08fdc45 Android: Remove ugly workaround for initialization issues.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2495
diff changeset
128 /* Safety check to prevent multiple initializations... */
2511
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
129 if(startup)
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
130 {
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
131 /* If we are called a second time.. post the event...
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
132 * so we stop waiting.
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
133 */
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
134 dw_event_post(startup);
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
135 return;
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
136 }
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
137 else
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
138 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
139 char *argv[2] = {arg, nullptr};
2511
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
140
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
141 /* Wait for a short while to see if we get called again...
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
142 * if we get called again we will be posted, if not...
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
143 * just wait for the timer to expire.
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
144 */
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
145 startup = dw_event_new();
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
146 /* Wait for 10 seconds to see if we get called again */
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
147 dw_event_wait(startup, 10000);
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
148
0945d0428dfe Android: New workaround for activity relaunch at startup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2510
diff changeset
149 /* Continue after being posted or after our timeout */
2513
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
150 dwmain(1, argv);
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
151 }
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
152 free(arg);
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
153 }
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
154
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
155 /* Called when DWindows activity starts up... so we create a thread
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
156 * to call the dwmain() entrypoint... then we wait for dw_main()
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
157 * to be called and return.
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
158 * Parameters:
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
159 * path: The path to the Android app.
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
160 */
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
161 JNIEXPORT void JNICALL
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
162 Java_org_dbsoft_dwindows_DWindows_dwindowsInit(JNIEnv* env, jobject obj, jstring path, jstring appID)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
163 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
164 char *arg = strdup(env->GetStringUTFChars((jstring)path, nullptr));
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
165 const char *appid = env->GetStringUTFChars((jstring)appID, nullptr);
2513
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
166
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
167 if(!_dw_main_event)
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
168 {
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
169 /* Save our class object pointer for later */
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
170 _dw_obj = env->NewGlobalRef(obj);
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
171
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
172 /* Save the JNIEnv for the main thread */
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
173 pthread_key_create(&_dw_env_key, nullptr);
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
174 pthread_setspecific(_dw_env_key, env);
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
175
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
176 /* Create the dwmain event */
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
177 _dw_main_event = dw_event_new();
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
178 }
2513
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
179
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
180 if(arg)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
181 {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
182 /* Store the passed in path for dw_app_dir() */
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
183 strncpy(_dw_exec_dir, arg, MAX_PATH);
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
184 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
185 if(appid)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
186 {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
187 /* Store our reported Android AppID */
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
188 strncpy(_dw_app_id, appid, _DW_APP_ID_SIZE);
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
189 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
190
2513
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
191 /* Launch the new thread to execute dwmain() */
0fa54c340902 Android: Second try at that new fix... move it into _dw_main_launch()
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2511
diff changeset
192 dw_thread_new((void *) _dw_main_launch, arg, 0);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
193 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
194
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
195 typedef struct _sighandler
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
196 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
197 struct _sighandler *next;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
198 ULONG message;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
199 HWND window;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
200 int id;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
201 void *signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
202 void *discfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
203 void *data;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
204
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
205 } SignalHandler;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
206
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
207 static SignalHandler *DWRoot = nullptr;
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
208
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
209 SignalHandler *_dw_get_handler(HWND window, int messageid)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
210 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
211 SignalHandler *tmp = DWRoot;
2483
9f7af6d8c6a4 Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2482
diff changeset
212 JNIEnv *env;
9f7af6d8c6a4 Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2482
diff changeset
213
9f7af6d8c6a4 Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2482
diff changeset
214 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) {
9f7af6d8c6a4 Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2482
diff changeset
215 /* Find any callbacks for this function */
9f7af6d8c6a4 Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2482
diff changeset
216 while (tmp) {
9f7af6d8c6a4 Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2482
diff changeset
217 if (tmp->message == messageid && env->IsSameObject(window, tmp->window)) {
9f7af6d8c6a4 Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2482
diff changeset
218 return tmp;
9f7af6d8c6a4 Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2482
diff changeset
219 }
9f7af6d8c6a4 Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2482
diff changeset
220 tmp = tmp->next;
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
221 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
222 }
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
223 return nullptr;
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
224 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
225
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
226 typedef struct
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
227 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
228 ULONG message;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
229 char name[30];
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
230
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
231 } DWSignalList;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
232
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
233 /* List of signals */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
234 #define SIGNALMAX 19
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
235
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
236 static DWSignalList DWSignalTranslate[SIGNALMAX] = {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
237 { 1, DW_SIGNAL_CONFIGURE },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
238 { 2, DW_SIGNAL_KEY_PRESS },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
239 { 3, DW_SIGNAL_BUTTON_PRESS },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
240 { 4, DW_SIGNAL_BUTTON_RELEASE },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
241 { 5, DW_SIGNAL_MOTION_NOTIFY },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
242 { 6, DW_SIGNAL_DELETE },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
243 { 7, DW_SIGNAL_EXPOSE },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
244 { 8, DW_SIGNAL_CLICKED },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
245 { 9, DW_SIGNAL_ITEM_ENTER },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
246 { 10, DW_SIGNAL_ITEM_CONTEXT },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
247 { 11, DW_SIGNAL_LIST_SELECT },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
248 { 12, DW_SIGNAL_ITEM_SELECT },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
249 { 13, DW_SIGNAL_SET_FOCUS },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
250 { 14, DW_SIGNAL_VALUE_CHANGED },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
251 { 15, DW_SIGNAL_SWITCH_PAGE },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
252 { 16, DW_SIGNAL_TREE_EXPAND },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
253 { 17, DW_SIGNAL_COLUMN_CLICK },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
254 { 18, DW_SIGNAL_HTML_RESULT },
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
255 { 19, DW_SIGNAL_HTML_CHANGED }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
256 };
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
257
2566
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
258
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
259 int _dw_event_handler2(void **params)
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
260 {
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
261 SignalHandler *handler = (SignalHandler *)params[9];
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
262 int message = DW_POINTER_TO_INT(params[8]);
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
263
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
264 if(handler)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
265 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
266 switch(message)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
267 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
268 /* Timer event */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
269 case 0:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
270 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
271 int (*timerfunc)(void *) = (int (* API)(void *))handler->signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
272
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
273 if(!timerfunc(handler->data))
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
274 dw_timer_disconnect(handler->id);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
275 return 0;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
276 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
277 /* Configure/Resize event */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
278 case 1:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
279 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
280 int (*sizefunc)(HWND, int, int, void *) = (int (* API)(HWND, int, int, void *))handler->signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
281 int width = DW_POINTER_TO_INT(params[3]);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
282 int height = DW_POINTER_TO_INT(params[4]);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
283
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
284 if(width > 0 && height > 0)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
285 {
2533
7c863a3a125f Android: Pass the cached window handle to the callback so the handles...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2532
diff changeset
286 return sizefunc(handler->window, width, height, handler->data);
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
287 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
288 return 0;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
289 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
290 case 2:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
291 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
292 int (*keypressfunc)(HWND, char, int, int, void *, char *) = (int (* API)(HWND, char, int, int, void *, char *))handler->signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
293 char *utf8 = (char *)params[1], ch = utf8 ? utf8[0] : '\0';
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
294 int vk = 0, special = 0;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
295
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
296 return keypressfunc(handler->window, ch, (int)vk, special, handler->data, utf8);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
297 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
298 /* Button press and release event */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
299 case 3:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
300 case 4:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
301 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
302 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
303 int button = 1;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
304
2533
7c863a3a125f Android: Pass the cached window handle to the callback so the handles...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2532
diff changeset
305 return buttonfunc(handler->window, DW_POINTER_TO_INT(params[3]), DW_POINTER_TO_INT(params[4]), button, handler->data);
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
306 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
307 /* Motion notify event */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
308 case 5:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
309 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
310 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
311
2533
7c863a3a125f Android: Pass the cached window handle to the callback so the handles...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2532
diff changeset
312 return motionfunc(handler->window, DW_POINTER_TO_INT(params[3]), DW_POINTER_TO_INT(params[4]), DW_POINTER_TO_INT(params[5]), handler->data);
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
313 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
314 /* Window close event */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
315 case 6:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
316 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
317 int (* API closefunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction;
2533
7c863a3a125f Android: Pass the cached window handle to the callback so the handles...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2532
diff changeset
318 return closefunc(handler->window, handler->data);
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
319 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
320 /* Window expose/draw event */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
321 case 7:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
322 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
323 DWExpose exp;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
324 int (* API exposefunc)(HWND, DWExpose *, void *) = (int (* API)(HWND, DWExpose *, void *))handler->signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
325
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
326 exp.x = DW_POINTER_TO_INT(params[3]);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
327 exp.y = DW_POINTER_TO_INT(params[4]);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
328 exp.width = DW_POINTER_TO_INT(params[5]);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
329 exp.height = DW_POINTER_TO_INT(params[6]);
2533
7c863a3a125f Android: Pass the cached window handle to the callback so the handles...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2532
diff changeset
330 int result = exposefunc(handler->window, &exp, handler->data);
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
331 return result;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
332 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
333 /* Clicked event for buttons and menu items */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
334 case 8:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
335 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
336 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
337
2533
7c863a3a125f Android: Pass the cached window handle to the callback so the handles...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2532
diff changeset
338 return clickfunc(handler->window, handler->data);
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
339 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
340 /* Container class selection event */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
341 case 9:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
342 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
343 int (*containerselectfunc)(HWND, char *, void *, void *) =(int (* API)(HWND, char *, void *, void *)) handler->signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
344
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
345 return containerselectfunc(handler->window, (char *)params[1], handler->data, params[7]);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
346 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
347 /* Container context menu event */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
348 case 10:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
349 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
350 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))handler->signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
351 char *text = (char *)params[1];
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
352 void *user = params[7];
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
353 int x = DW_POINTER_TO_INT(params[3]);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
354 int y = DW_POINTER_TO_INT(params[4]);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
355
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
356 return containercontextfunc(handler->window, text, x, y, handler->data, user);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
357 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
358 /* Generic selection changed event for several classes */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
359 case 11:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
360 case 14:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
361 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
362 int (* API valuechangedfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))handler->signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
363 int selected = DW_POINTER_TO_INT(params[3]);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
364
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
365 return valuechangedfunc(handler->window, selected, handler->data);
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
366 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
367 /* Tree class selection event */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
368 case 12:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
369 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
370 int (* API treeselectfunc)(HWND, HTREEITEM, char *, void *, void *) = (int (* API)(HWND, HTREEITEM, char *, void *, void *))handler->signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
371 char *text = (char *)params[1];
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
372 void *user = params[7];
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
373
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
374 return treeselectfunc(handler->window, params[0], text, handler->data, user);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
375 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
376 /* Set Focus event */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
377 case 13:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
378 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
379 int (* API setfocusfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
380
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
381 return setfocusfunc(handler->window, handler->data);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
382 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
383 /* Notebook page change event */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
384 case 15:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
385 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
386 int (* API switchpagefunc)(HWND, unsigned long, void *) = (int (* API)(HWND, unsigned long, void *))handler->signalfunction;
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
387 unsigned long pageID = DW_POINTER_TO_INT(params[3]);
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
388
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
389 return switchpagefunc(handler->window, pageID, handler->data);
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
390 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
391 /* Tree expand event */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
392 case 16:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
393 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
394 int (* API treeexpandfunc)(HWND, HTREEITEM, void *) = (int (* API)(HWND, HTREEITEM, void *))handler->signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
395
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
396 return treeexpandfunc(handler->window, (HTREEITEM)params[0], handler->data);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
397 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
398 /* Column click event */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
399 case 17:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
400 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
401 int (* API clickcolumnfunc)(HWND, int, void *) = (int (* API)(HWND, int, void *))handler->signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
402 int column_num = DW_POINTER_TO_INT(params[3]);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
403
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
404 return clickcolumnfunc(handler->window, column_num, handler->data);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
405 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
406 /* HTML result event */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
407 case 18:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
408 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
409 int (* API htmlresultfunc)(HWND, int, char *, void *, void *) = (int (* API)(HWND, int, char *, void *, void *))handler->signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
410 char *result = (char *)params[1];
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
411
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
412 return htmlresultfunc(handler->window, result ? DW_ERROR_NONE : DW_ERROR_UNKNOWN, result, params[7], handler->data);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
413 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
414 /* HTML changed event */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
415 case 19:
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
416 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
417 int (* API htmlchangedfunc)(HWND, int, char *, void *) = (int (* API)(HWND, int, char *, void *))handler->signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
418 char *uri = (char *)params[1];
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
419
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
420 return htmlchangedfunc(handler->window, DW_POINTER_TO_INT(params[3]), uri, handler->data);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
421 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
422 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
423 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
424 return -1;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
425 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
426
2566
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
427 int _dw_event_handler(jobject object, void **params) {
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
428 SignalHandler *handler = _dw_get_handler(object, DW_POINTER_TO_INT(params[8]));
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
429
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
430 if (handler)
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
431 {
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
432 params[9] = (void *)handler;
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
433
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
434 #ifdef _DW_EVENT_THREADING
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
435 /* We can't launch a thread for draw events it won't work */
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
436 if(DW_POINTER_TO_INT(params[8]) != 7)
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
437 dw_thread_new((void *)_dw_event_handler2, (void *)params, 0);
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
438 else
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
439 #endif
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
440 return _dw_event_handler2(params);
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
441
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
442 }
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
443 return 0;
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
444 }
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
445
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
446 /*
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
447 * Entry location for all event handlers from the Android UI
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
448 */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
449 JNIEXPORT jint JNICALL
2484
cb5b67154399 Android: The DWindows class should be org.dbsoft.dwindows, remove dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2483
diff changeset
450 Java_org_dbsoft_dwindows_DWindows_eventHandler(JNIEnv* env, jobject obj, jobject obj1, jobject obj2,
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
451 jint message, jstring str1, jstring str2,
2499
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
452 jint inta, jint intb, jint intc, jint intd) {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
453 const char *utf81 = str1 ? env->GetStringUTFChars(str1, nullptr) : nullptr;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
454 const char *utf82 = str2 ? env->GetStringUTFChars(str2, nullptr) : nullptr;
2566
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
455 void *params[10] = { (void *)obj2, (void *)utf81, (void *)utf82,
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
456 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb),
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
457 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), nullptr,
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
458 DW_INT_TO_POINTER(message), nullptr };
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
459
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
460 return _dw_event_handler(obj1, params);
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
461 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
462
2483
9f7af6d8c6a4 Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2482
diff changeset
463 /* A more simple method for quicker calls */
9f7af6d8c6a4 Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2482
diff changeset
464 JNIEXPORT void JNICALL
2484
cb5b67154399 Android: The DWindows class should be org.dbsoft.dwindows, remove dwtest.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2483
diff changeset
465 Java_org_dbsoft_dwindows_DWindows_eventHandlerSimple(JNIEnv* env, jobject obj, jobject obj1, jint message) {
2566
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
466 void *params[10] = { nullptr };
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
467
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
468 params[8] = DW_INT_TO_POINTER(message);
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
469 _dw_event_handler(obj1, params);
2483
9f7af6d8c6a4 Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2482
diff changeset
470 }
9f7af6d8c6a4 Android: Fix signal handlers so they actually work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2482
diff changeset
471
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
472 /* Handler for notebook page changes */
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
473 JNIEXPORT void JNICALL
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
474 Java_org_dbsoft_dwindows_DWindows_eventHandlerNotebook(JNIEnv* env, jobject obj, jobject obj1, jint message, jlong pageID) {
2566
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
475 void *params[10] = { nullptr };
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
476
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
477 params[8] = DW_INT_TO_POINTER(message);
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
478 _dw_event_handler(obj1, params);
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
479 }
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
480
2505
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
481 /* Handlers for HTML events */
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
482 JNIEXPORT void JNICALL
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
483 Java_org_dbsoft_dwindows_DWindows_eventHandlerHTMLResult(JNIEnv* env, jobject obj, jobject obj1,
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
484 jint message, jstring htmlResult, jlong data) {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
485 const char *result = env->GetStringUTFChars(htmlResult, nullptr);
2566
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
486 void *params[10] = { nullptr, DW_POINTER(result), nullptr, nullptr, nullptr, nullptr, nullptr,
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
487 DW_INT_TO_POINTER(data), DW_INT_TO_POINTER(message), nullptr };
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
488
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
489 _dw_event_handler(obj1, params);
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
490 }
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
491
2499
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
492 JNIEXPORT void JNICALL
2505
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
493 Java_org_dbsoft_dwindows_DWWebViewClient_eventHandlerHTMLChanged(JNIEnv* env, jobject obj, jobject obj1,
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
494 jint message, jstring URI, jint status) {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
495 const char *uri = env->GetStringUTFChars(URI, nullptr);
2566
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
496 void *params[10] = { nullptr, DW_POINTER(uri), nullptr, DW_INT_TO_POINTER(status), nullptr, nullptr,
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
497 nullptr, nullptr, DW_INT_TO_POINTER(message), nullptr };
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
498
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
499 _dw_event_handler(obj1, params);
2505
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
500 }
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
501
a149dabf6a1f Android: HTML touchups, implement DW_SIGNAL_HTML_CHANGED: STARTED and COMPLETE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2503
diff changeset
502 JNIEXPORT void JNICALL
2499
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
503 Java_org_dbsoft_dwindows_DWindows_eventHandlerInt(JNIEnv* env, jobject obj, jobject obj1, jint message,
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
504 jint inta, jint intb, jint intc, jint intd) {
2566
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
505 void *params[10] = { nullptr, nullptr, nullptr,
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
506 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb),
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
507 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), nullptr,
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
508 DW_INT_TO_POINTER(message), nullptr };
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
509
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
510 _dw_event_handler(obj1, params);
2499
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
511 }
ff3310fa6d72 Android: Implment DW_SIGNA_CONFIGURE on orientation change.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2498
diff changeset
512
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
513 JNIEXPORT void JNICALL
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
514 Java_org_dbsoft_dwindows_DWComboBox_eventHandlerInt(JNIEnv* env, jobject obj, jint message,
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
515 jint inta, jint intb, jint intc, jint intd) {
2566
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
516 void *params[10] = { nullptr, nullptr, nullptr,
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
517 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb),
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
518 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), nullptr,
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
519 DW_INT_TO_POINTER(message), nullptr };
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
520
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
521 _dw_event_handler(obj, params);
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
522 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
523
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
524 JNIEXPORT void JNICALL
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
525 Java_org_dbsoft_dwindows_DWSpinButton_eventHandlerInt(JNIEnv* env, jobject obj, jint message,
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
526 jint inta, jint intb, jint intc, jint intd) {
2566
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
527 void *params[10] = { nullptr, nullptr, nullptr,
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
528 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb),
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
529 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), nullptr,
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
530 DW_INT_TO_POINTER(message), nullptr };
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
531
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
532 _dw_event_handler(obj, params);
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
533 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
534
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
535 JNIEXPORT void JNICALL
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
536 Java_org_dbsoft_dwindows_DWListBox_eventHandlerInt(JNIEnv* env, jobject obj, jint message,
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
537 jint inta, jint intb, jint intc, jint intd) {
2566
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
538 void *params[10] = { nullptr, nullptr, nullptr,
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
539 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb),
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
540 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), nullptr,
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
541 DW_INT_TO_POINTER(message), nullptr };
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
542
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
543 _dw_event_handler(obj, params);
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
544 }
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
545
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
546 JNIEXPORT void JNICALL
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
547 Java_org_dbsoft_dwindows_DWRender_eventHandlerInt(JNIEnv* env, jobject obj, jint message,
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
548 jint inta, jint intb, jint intc, jint intd) {
2566
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
549 void *params[10] = { nullptr, nullptr, nullptr,
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
550 DW_INT_TO_POINTER(inta), DW_INT_TO_POINTER(intb),
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
551 DW_INT_TO_POINTER(intc), DW_INT_TO_POINTER(intd), nullptr,
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
552 DW_INT_TO_POINTER(message), nullptr };
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
553
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
554 _dw_event_handler(obj, params);
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
555 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
556
2560
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
557 JNIEXPORT void JNICALL
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
558 Java_org_dbsoft_dwindows_DWindows_eventHandlerContainer(JNIEnv* env, jobject obj, jobject obj1,
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
559 jint message, jstring jtitle, jint x, jint y, jlong data) {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
560 const char *title = jtitle ? env->GetStringUTFChars(jtitle, nullptr) : nullptr;
2566
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
561 void *params[10] = { nullptr, (void *)title, nullptr,
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
562 DW_INT_TO_POINTER(x), DW_INT_TO_POINTER(y),
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
563 nullptr, nullptr, (void *)data, DW_INT_TO_POINTER(message), nullptr };
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
564
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
565 _dw_event_handler(obj1, params);
2560
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
566 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
567
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
568 /* Handler for Timer events */
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
569 JNIEXPORT jint JNICALL
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
570 Java_org_dbsoft_dwindows_DWindows_eventHandlerTimer(JNIEnv* env, jobject obj, jlong sigfunc, jlong data) {
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
571 int (*timerfunc)(void *) = (int (* API)(void *))sigfunc;
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
572
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
573 pthread_setspecific(_dw_env_key, env);
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
574 return timerfunc((void *)data);
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
575 }
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
576
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
577 /* A more simple method for quicker calls */
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
578 JNIEXPORT void JNICALL
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
579 Java_org_dbsoft_dwindows_DWMenu_eventHandlerSimple(JNIEnv* env, jobject obj, jobject obj1, jint message) {
2566
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
580 void *params[10] = { nullptr };
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
581
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
582 params[8] = DW_INT_TO_POINTER(message);
4427af56eebe Android: Add experimental event threading code, currently disabled.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2561
diff changeset
583 _dw_event_handler(obj1, params);
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
584 }
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
585
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
586
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
587 /* This function adds a signal handler callback into the linked list.
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
588 */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
589 void _dw_new_signal(ULONG message, HWND window, int msgid, void *signalfunction, void *discfunc, void *data)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
590 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
591 SignalHandler *newsig = (SignalHandler *)malloc(sizeof(SignalHandler));
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
592
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
593 newsig->message = message;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
594 newsig->window = window;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
595 newsig->id = msgid;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
596 newsig->signalfunction = signalfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
597 newsig->discfunction = discfunc;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
598 newsig->data = data;
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
599 newsig->next = nullptr;
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
600
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
601 if (!DWRoot)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
602 DWRoot = newsig;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
603 else
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
604 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
605 SignalHandler *prev = nullptr, *tmp = DWRoot;
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
606 while(tmp)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
607 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
608 if(tmp->message == message &&
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
609 tmp->window == window &&
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
610 tmp->id == msgid &&
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
611 tmp->signalfunction == signalfunction)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
612 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
613 tmp->data = data;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
614 free(newsig);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
615 return;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
616 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
617 prev = tmp;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
618 tmp = tmp->next;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
619 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
620 if(prev)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
621 prev->next = newsig;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
622 else
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
623 DWRoot = newsig;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
624 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
625 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
626
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
627 /* Finds the message number for a given signal name */
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
628 ULONG _dw_findsigmessage(const char *signame)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
629 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
630 int z;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
631
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
632 for(z=0;z<SIGNALMAX;z++)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
633 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
634 if(strcasecmp(signame, DWSignalTranslate[z].name) == 0)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
635 return DWSignalTranslate[z].message;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
636 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
637 return 0L;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
638 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
639
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
640 unsigned long _dw_colors[] =
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
641 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
642 0x00000000, /* 0 black */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
643 0x000000bb, /* 1 red */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
644 0x0000bb00, /* 2 green */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
645 0x0000aaaa, /* 3 yellow */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
646 0x00cc0000, /* 4 blue */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
647 0x00bb00bb, /* 5 magenta */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
648 0x00bbbb00, /* 6 cyan */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
649 0x00bbbbbb, /* 7 white */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
650 0x00777777, /* 8 grey */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
651 0x000000ff, /* 9 bright red */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
652 0x0000ff00, /* 10 bright green */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
653 0x0000eeee, /* 11 bright yellow */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
654 0x00ff0000, /* 12 bright blue */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
655 0x00ff00ff, /* 13 bright magenta */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
656 0x00eeee00, /* 14 bright cyan */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
657 0x00ffffff, /* 15 bright white */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
658 0xff000000 /* 16 default color */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
659 };
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
660
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
661 /* Return the RGB color regardless if a predefined color was passed */
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
662 unsigned long _dw_get_color(unsigned long thiscolor)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
663 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
664 if(thiscolor & DW_RGB_COLOR)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
665 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
666 return thiscolor & ~DW_RGB_COLOR;
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
667 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
668 else if(thiscolor < 17)
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
669 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
670 return _dw_colors[thiscolor];
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
671 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
672 return 0;
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
673 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
674
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
675 int _dw_dark_mode_detected()
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
676 {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
677 JNIEnv *env;
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
678 int retval = DW_ERROR_UNKNOWN;
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
679
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
680 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
681 {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
682 // First get the class that contains the method you need to call
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
683 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
684 // Get the method that you want to call
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
685 jmethodID darkModeDetected = env->GetMethodID(clazz, "darkModeDetected",
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
686 "()I");
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
687 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
688 retval = env->CallIntMethod(_dw_obj, darkModeDetected);
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
689 _dw_jni_check_exception(env);
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
690 }
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
691 return retval;
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
692 }
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
693
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
694 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
695 * Runs a message loop for Dynamic Windows.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
696 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
697 void API dw_main(void)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
698 {
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
699 JNIEnv *env;
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
700
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
701 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
702 {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
703 // First get the class that contains the method you need to call
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
704 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
705 // Get the method that you want to call
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
706 jmethodID dwMain = env->GetMethodID(clazz, "dwMain",
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
707 "()V");
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
708 // Call the method on the object
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
709 env->CallVoidMethod(_dw_obj, dwMain);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
710 _dw_jni_check_exception(env);
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
711 }
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
712
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
713 /* We don't actually run a loop here,
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
714 * we launched a new thread to run the loop there.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
715 * Just wait for dw_main_quit() on the DWMainEvent.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
716 */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
717 dw_event_wait(_dw_main_event, DW_TIMEOUT_INFINITE);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
718 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
719
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
720 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
721 * Causes running dw_main() to return.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
722 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
723 void API dw_main_quit(void)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
724 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
725 dw_event_post(_dw_main_event);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
726 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
727
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
728 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
729 * Runs a message loop for Dynamic Windows, for a period of milliseconds.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
730 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
731 * milliseconds: Number of milliseconds to run the loop for.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
732 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
733 void API dw_main_sleep(int milliseconds)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
734 {
2514
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2513
diff changeset
735 JNIEnv *env;
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2513
diff changeset
736
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2513
diff changeset
737 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2513
diff changeset
738 {
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2513
diff changeset
739 // First get the class that contains the method you need to call
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2513
diff changeset
740 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2513
diff changeset
741 // Get the method that you want to call
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2513
diff changeset
742 jmethodID mainSleep = env->GetMethodID(clazz, "mainSleep",
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2513
diff changeset
743 "(I)V");
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2513
diff changeset
744 // Call the method on the object
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2513
diff changeset
745 env->CallVoidMethod(_dw_obj, mainSleep, milliseconds);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
746 _dw_jni_check_exception(env);
2514
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2513
diff changeset
747 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
748 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
749
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
750 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
751 * Processes a single message iteration and returns.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
752 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
753 void API dw_main_iteration(void)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
754 {
2514
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2513
diff changeset
755 /* If we sleep for 0 milliseconds... we will drop out
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2513
diff changeset
756 * of the loop at the first idle moment
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2513
diff changeset
757 */
5f711e86a211 Android: Implement dw_main_sleep() and dw_main_iteration().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2513
diff changeset
758 dw_main_sleep(0);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
759 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
760
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
761 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
762 * Cleanly terminates a DW session, should be signal handler safe.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
763 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
764 * exitcode: Exit code reported to the operating system.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
765 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
766 void API dw_exit(int exitcode)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
767 {
2487
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
768 JNIEnv *env;
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
769
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
770 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
771 {
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
772 // First get the class that contains the method you need to call
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
773 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
774 // Get the method that you want to call
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
775 jmethodID dwindowsExit = env->GetMethodID(clazz, "dwindowsExit",
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
776 "(I)V");
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
777 // Call the method on the object
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
778 env->CallVoidMethod(_dw_obj, dwindowsExit, exitcode);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
779 _dw_jni_check_exception(env);
2487
83f8f4f58a98 Android: Implement dw_exit() using Activity.finishActivity() instead of exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2486
diff changeset
780 }
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
781 // We shouldn't get here, but in case JNI can't call dwindowsExit...
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
782 exit(exitcode);
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
783 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
784
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
785 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
786 * Free's memory allocated by dynamic windows.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
787 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
788 * ptr: Pointer to dynamic windows allocated
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
789 * memory to be free()'d.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
790 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
791 void API dw_free(void *ptr)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
792 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
793 free(ptr);
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
794 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
795
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
796 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
797 * Returns a pointer to a static buffer which contains the
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
798 * current user directory. Or the root directory if it could
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
799 * not be determined.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
800 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
801 char * API dw_user_dir(void)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
802 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
803 static char _dw_user_dir[MAX_PATH+1] = {0};
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
804
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
805 if(!_dw_user_dir[0])
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
806 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
807 char *home = getenv("HOME");
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
808
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
809 if(home)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
810 strcpy(_dw_user_dir, home);
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
811 else
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
812 strcpy(_dw_user_dir, "/");
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
813 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
814 return _dw_user_dir;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
815 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
816
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
817 /*
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
818 * Returns a pointer to a static buffer which contains the
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
819 * private application data directory.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
820 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
821 char * API dw_app_dir(void)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
822 {
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
823 /* The path is passed in via JNI dwindowsInit() */
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
824 return _dw_exec_dir;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
825 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
826
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
827 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
828 * Sets the application ID used by this Dynamic Windows application instance.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
829 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
830 * appid: A string typically in the form: com.company.division.application
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
831 * appname: The application name used on Windows or nullptr.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
832 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
833 * DW_ERROR_NONE after successfully setting the application ID.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
834 * DW_ERROR_UNKNOWN if unsupported on this system.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
835 * DW_ERROR_GENERAL if the application ID is not allowed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
836 * Remarks:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
837 * This must be called before dw_init(). If dw_init() is called first
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
838 * it will create a unique ID in the form: org.dbsoft.dwindows.application
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
839 * or if the application name cannot be detected: org.dbsoft.dwindows.pid.#
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
840 * The appname is used on Windows and Android. If nullptr is passed the
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
841 * detected name will be used, but a prettier name may be desired.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
842 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
843 int API dw_app_id_set(const char *appid, const char *appname)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
844 {
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
845 if(appid)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
846 strncpy(_dw_app_id, appid, _DW_APP_ID_SIZE);
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
847 if(appname)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
848 strncpy(_dw_app_name, appname, _DW_APP_ID_SIZE);
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
849 return DW_ERROR_NONE;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
850 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
851
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
852 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
853 * Displays a debug message on the console...
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
854 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
855 * format: printf style format string.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
856 * ...: Additional variables for use in the format.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
857 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
858 void API dw_debug(const char *format, ...)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
859 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
860 va_list args;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
861 char outbuf[1025] = {0};
2482
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
862 JNIEnv *env;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
863
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
864 va_start(args, format);
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
865 vsnprintf(outbuf, 1024, format, args);
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
866 va_end(args);
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
867
2482
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
868 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
869 {
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
870 // Construct a String
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
871 jstring jstr = env->NewStringUTF(outbuf);
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
872 // First get the class that contains the method you need to call
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
873 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
874 // Get the method that you want to call
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
875 jmethodID debugMessage = env->GetMethodID(clazz, "debugMessage",
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
876 "(Ljava/lang/String;)V");
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
877 // Call the method on the object
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
878 env->CallVoidMethod(_dw_obj, debugMessage, jstr);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
879 _dw_jni_check_exception(env);
2482
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
880 }
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
881 else {
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
882 /* Output to stderr, if there is another way to send it
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
883 * on the implementation platform, change this.
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
884 */
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
885 fprintf(stderr, "%s", outbuf);
4888503c3e3e Android: Implement dw_debug() using the Android Log class.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2481
diff changeset
886 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
887 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
888
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
889 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
890 * Displays a Message Box with given text and title..
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
891 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
892 * title: The title of the message box.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
893 * flags: flags to indicate buttons and icon
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
894 * format: printf style format string.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
895 * ...: Additional variables for use in the format.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
896 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
897 * DW_MB_RETURN_YES, DW_MB_RETURN_NO, DW_MB_RETURN_OK,
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
898 * or DW_MB_RETURN_CANCEL based on flags and user response.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
899 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
900 int API dw_messagebox(const char *title, int flags, const char *format, ...)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
901 {
2486
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
902 va_list args;
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
903 char outbuf[1025] = {0};
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
904 JNIEnv *env;
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
905 int retval = 0;
2486
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
906
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
907 va_start(args, format);
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
908 vsnprintf(outbuf, 1024, format, args);
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
909 va_end(args);
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
910
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
911 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
912 {
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
913 // Construct a String
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
914 jstring jstr = env->NewStringUTF(outbuf);
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
915 jstring jstrtitle = env->NewStringUTF(title);
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
916 // First get the class that contains the method you need to call
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
917 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
918 // Get the method that you want to call
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
919 jmethodID messageBox = env->GetMethodID(clazz, "messageBox",
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
920 "(Ljava/lang/String;Ljava/lang/String;I)I");
cec43818bd3e Android: Implement dw_messagebox() ... seems we can't just cleanly exit().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2484
diff changeset
921 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
922 retval = env->CallIntMethod(_dw_obj, messageBox, jstrtitle, jstr, flags);
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
923 _dw_jni_check_exception(env);
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
924 }
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
925 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
926 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
927
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
928 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
929 * Opens a file dialog and queries user selection.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
930 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
931 * title: Title bar text for dialog.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
932 * defpath: The default path of the open dialog.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
933 * ext: Default file extention.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
934 * flags: DW_FILE_OPEN or DW_FILE_SAVE.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
935 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
936 * nullptr on error. A malloced buffer containing
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
937 * the file path on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
938 *
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
939 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
940 char * API dw_file_browse(const char *title, const char *defpath, const char *ext, int flags)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
941 {
2526
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
942 JNIEnv *env;
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
943 char *retval = nullptr;
2526
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
944
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
945 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
946 {
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
947 // Use a long parameter
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
948 jstring jstr = env->NewStringUTF(title);
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
949 jstring path = nullptr;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
950 jstring jext = nullptr;
2526
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
951 if(defpath)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
952 path = env->NewStringUTF(defpath);
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
953 if(ext)
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
954 jext = env->NewStringUTF(defpath);
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
955 // First get the class that contains the method you need to call
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
956 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
2526
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
957 // Get the method that you want to call
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
958 jmethodID fileBrowse = env->GetMethodID(clazz, "fileBrowse",
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
959 "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;I)Ljava/lang/String;");
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
960 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
961 jstring jresult = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, fileBrowse, jstr, path, jext, flags), _DW_REFERENCE_NONE);
2526
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
962 if(jresult)
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
963 retval = strdup(env->GetStringUTFChars(jresult, nullptr));
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
964 }
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
965 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
966 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
967
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
968 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
969 * Gets the contents of the default clipboard as text.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
970 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
971 * None.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
972 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
973 * Pointer to an allocated string of text or nullptr if clipboard empty or contents could not
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
974 * be converted to text.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
975 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
976 char * API dw_clipboard_get_text()
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
977 {
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
978 JNIEnv *env;
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
979
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
980 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
981 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
982 const char *utf8 = nullptr;
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
983
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
984 // First get the class that contains the method you need to call
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
985 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
986 // Get the method that you want to call
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
987 jmethodID clipboardGetText = env->GetMethodID(clazz, "clipboardGetText",
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
988 "()Ljava/lang/String;");
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
989 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
990 jstring result = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, clipboardGetText), _DW_REFERENCE_NONE);
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
991 // Get the UTF8 string result
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
992 if(result)
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
993 utf8 = env->GetStringUTFChars(result, nullptr);
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
994 return utf8 ? strdup(utf8) : nullptr;
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
995 }
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
996 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
997 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
998
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
999 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1000 * Sets the contents of the default clipboard to the supplied text.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1001 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1002 * str: Text to put on the clipboard.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1003 * len: Length of the text.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1004 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1005 void API dw_clipboard_set_text(const char *str, int len)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1006 {
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1007 JNIEnv *env;
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1008
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1009 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1010 {
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1011 // Construct a String
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1012 jstring jstr = env->NewStringUTF(str);
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1013 // First get the class that contains the method you need to call
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1014 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1015 // Get the method that you want to call
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1016 jmethodID clipboardSetText = env->GetMethodID(clazz, "clipboardSetText",
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1017 "(Ljava/lang/String;)V");
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1018 // Call the method on the object
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1019 env->CallVoidMethod(_dw_obj, clipboardSetText, jstr);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1020 _dw_jni_check_exception(env);
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1021 }
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1022 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1023
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1024 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1025 * Allocates and initializes a dialog struct.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1026 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1027 * data: User defined data to be passed to functions.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1028 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1029 * A handle to a dialog or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1030 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1031 DWDialog * API dw_dialog_new(void *data)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1032 {
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1033 DWDialog *tmp = (DWDialog *)malloc(sizeof(DWDialog));
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1034
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1035 if(tmp)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1036 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1037 tmp->eve = dw_event_new();
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1038 dw_event_reset(tmp->eve);
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1039 tmp->data = data;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1040 tmp->done = FALSE;
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1041 tmp->result = nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1042 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1043 return tmp;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1044 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1045
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1046 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1047 * Accepts a dialog struct and returns the given data to the
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1048 * initial called of dw_dialog_wait().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1049 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1050 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1051 * result: Data to be returned by dw_dialog_wait().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1052 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1053 * DW_ERROR_NONE (0) on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1054 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1055 int API dw_dialog_dismiss(DWDialog *dialog, void *result)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1056 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1057 dialog->result = result;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1058 dw_event_post(dialog->eve);
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1059 dialog->done = TRUE;
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
1060 return DW_ERROR_NONE;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1061 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1062
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1063 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1064 * Accepts a dialog struct waits for dw_dialog_dismiss() to be
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1065 * called by a signal handler with the given dialog struct.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1066 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1067 * dialog: Pointer to a dialog struct aquired by dw_dialog_new).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1068 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1069 * The data passed to dw_dialog_dismiss().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1070 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1071 void * API dw_dialog_wait(DWDialog *dialog)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1072 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1073 void *tmp = nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1074
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1075 while(!dialog->done)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1076 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1077 dw_main_iteration();
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1078 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1079 dw_event_close(&dialog->eve);
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1080 tmp = dialog->result;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1081 free(dialog);
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1082 return tmp;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1083 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1084
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1085 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1086 * Create a new Box to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1087 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1088 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1089 * pad: Number of pixels to pad around the box.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1090 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1091 * A handle to a box or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1092 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1093 HWND API dw_box_new(int type, int pad)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1094 {
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1095 JNIEnv *env;
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1096
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1097 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1098 {
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1099 // First get the class that contains the method you need to call
2477
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1100 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1101 // Get the method that you want to call
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1102 jmethodID boxNew = env->GetMethodID(clazz, "boxNew", "(II)Landroid/widget/LinearLayout;");
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1103 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1104 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, boxNew, type, pad), _DW_REFERENCE_WEAK);
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1105 return result;
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1106 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
1107 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1108 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1109
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1110 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1111 * Create a new Group Box to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1112 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1113 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1114 * pad: Number of pixels to pad around the box.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1115 * title: Text to be displayined in the group outline.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1116 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1117 * A handle to a groupbox window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1118 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1119 HWND API dw_groupbox_new(int type, int pad, const char *title)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1120 {
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1121 /* TODO: Just create a normal box for now */
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1122 return dw_box_new(type, pad);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1123 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1124
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1125 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1126 * Create a new scrollable Box to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1127 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1128 * type: Either DW_VERT (vertical) or DW_HORZ (horizontal).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1129 * pad: Number of pixels to pad around the box.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1130 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1131 * A handle to a scrollbox or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1132 */
2495
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1133 HWND API dw_scrollbox_new(int type, int pad)
5664c91d03fb Android: Attempts to sort out the various issues... still not working but...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2494
diff changeset
1134 {
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1135 JNIEnv *env;
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1136
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1137 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1138 {
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1139 // First get the class that contains the method you need to call
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1140 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1141 // Get the method that you want to call
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1142 jmethodID scrollBoxNew = env->GetMethodID(clazz, "scrollBoxNew",
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1143 "(II)Landroid/widget/ScrollView;");
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1144 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1145 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, scrollBoxNew, type, pad), _DW_REFERENCE_WEAK);
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1146 return result;
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1147 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
1148 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1149 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1150
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1151 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1152 * Returns the position of the scrollbar in the scrollbox.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1153 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1154 * handle: Handle to the scrollbox to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1155 * orient: The vertical or horizontal scrollbar.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1156 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1157 * The vertical or horizontal position in the scrollbox.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1158 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1159 int API dw_scrollbox_get_pos(HWND handle, int orient)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1160 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1161 return 0;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1162 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1163
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1164 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1165 * Gets the range for the scrollbar in the scrollbox.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1166 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1167 * handle: Handle to the scrollbox to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1168 * orient: The vertical or horizontal scrollbar.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1169 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1170 * The vertical or horizontal range of the scrollbox.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1171 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1172 int API dw_scrollbox_get_range(HWND handle, int orient)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1173 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1174 return 0;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1175 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1176
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1177 /* Internal box packing function called by the other 3 functions */
2477
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1178 void _dw_box_pack(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad, const char *funcname)
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1179 {
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1180 JNIEnv *env;
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1181
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1182 if(box && item && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1183 {
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1184 // First get the class that contains the method you need to call
2477
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1185 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1186 // Get the method that you want to call
2500
ac0b7e579229 Android: Implement dw_scrollbox_new() using ScrollView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2499
diff changeset
1187 jmethodID boxPack = env->GetMethodID(clazz, "boxPack", "(Landroid/view/View;Landroid/view/View;IIIIII)V");
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1188 // Call the method on the object
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
1189 env->CallVoidMethod(_dw_obj, boxPack, box, item, index, width, height, hsize, vsize, pad);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1190 _dw_jni_check_exception(env);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1191 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1192 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1193
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1194 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1195 * Remove windows (widgets) from the box they are packed into.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1196 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1197 * handle: Window handle of the packed item to be removed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1198 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1199 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1200 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1201 int API dw_box_unpack(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1202 {
2477
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1203 JNIEnv *env;
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1204
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1205 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
2477
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1206 {
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1207 // First get the class that contains the method you need to call
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1208 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1209 // Get the method that you want to call
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1210 jmethodID boxUnpack = env->GetMethodID(clazz, "boxUnpack", "(Landroid/view/View;)V");
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1211 // Call the method on the object
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1212 env->CallVoidMethod(_dw_obj, boxUnpack, handle);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1213 _dw_jni_check_exception(env);
2477
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1214 return DW_ERROR_NONE;
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1215 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1216 return DW_ERROR_GENERAL;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1217 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1218
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1219 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1220 * Remove windows (widgets) from a box at an arbitrary location.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1221 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1222 * box: Window handle of the box to be removed from.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1223 * index: 0 based index of packed items.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1224 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1225 * Handle to the removed item on success, 0 on failure or padding.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1226 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1227 HWND API dw_box_unpack_at_index(HWND box, int index)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1228 {
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1229 JNIEnv *env;
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
1230 HWND retval = nullptr;
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1231
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1232 if(box && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) {
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1233 // First get the class that contains the method you need to call
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1234 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1235 // Get the method that you want to call
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1236 jmethodID boxUnpackAtIndex = env->GetMethodID(clazz, "boxUnpackAtIndex",
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1237 "(Landroid/widget/LinearLayout;I)Landroid/view/View;");
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1238 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1239 retval = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, boxUnpackAtIndex, box, index), _DW_REFERENCE_WEAK);
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1240 }
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1241 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1242 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1243
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1244 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1245 * Pack windows (widgets) into a box at an arbitrary location.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1246 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1247 * box: Window handle of the box to be packed into.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1248 * item: Window handle of the item to pack.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1249 * index: 0 based index of packed items.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1250 * width: Width in pixels of the item or -1 to be self determined.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1251 * height: Height in pixels of the item or -1 to be self determined.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1252 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1253 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1254 * pad: Number of pixels of padding around the item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1255 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1256 void API dw_box_pack_at_index(HWND box, HWND item, int index, int width, int height, int hsize, int vsize, int pad)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1257 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1258 _dw_box_pack(box, item, index, width, height, hsize, vsize, pad, "dw_box_pack_at_index()");
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1259 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1260
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1261 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1262 * Pack windows (widgets) into a box from the start (or top).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1263 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1264 * box: Window handle of the box to be packed into.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1265 * item: Window handle of the item to pack.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1266 * width: Width in pixels of the item or -1 to be self determined.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1267 * height: Height in pixels of the item or -1 to be self determined.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1268 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1269 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1270 * pad: Number of pixels of padding around the item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1271 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1272 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1273 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1274 /* 65536 is the table limit on GTK...
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1275 * seems like a high enough value we will never hit it here either.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1276 */
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
1277 _dw_box_pack(box, item, -1, width, height, hsize, vsize, pad, "dw_box_pack_start()");
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1278 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1279
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1280 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1281 * Pack windows (widgets) into a box from the end (or bottom).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1282 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1283 * box: Window handle of the box to be packed into.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1284 * item: Window handle of the item to pack.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1285 * width: Width in pixels of the item or -1 to be self determined.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1286 * height: Height in pixels of the item or -1 to be self determined.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1287 * hsize: TRUE if the window (widget) should expand horizontally to fill space given.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1288 * vsize: TRUE if the window (widget) should expand vertically to fill space given.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1289 * pad: Number of pixels of padding around the item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1290 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1291 void API dw_box_pack_end(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1292 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1293 _dw_box_pack(box, item, 0, width, height, hsize, vsize, pad, "dw_box_pack_end()");
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1294 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1295
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1296 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1297 * Create a new button window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1298 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1299 * text: The text to be display by the static text widget.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1300 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1301 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1302 * A handle to a button window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1303 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1304 HWND API dw_button_new(const char *text, ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1305 {
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1306 JNIEnv *env;
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1307
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1308 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1309 {
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1310 // Construct a String
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1311 jstring jstr = env->NewStringUTF(text);
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1312 // First get the class that contains the method you need to call
2477
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1313 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1314 // Get the method that you want to call
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1315 jmethodID buttonNew = env->GetMethodID(clazz, "buttonNew",
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1316 "(Ljava/lang/String;I)Landroid/widget/Button;");
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1317 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1318 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, buttonNew, jstr, (int)cid), _DW_REFERENCE_WEAK);
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1319 return result;
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1320 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
1321 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1322 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1323
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1324 HWND _dw_entryfield_new(const char *text, ULONG cid, int password)
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1325 {
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1326 JNIEnv *env;
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1327
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1328 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1329 {
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1330 // Construct a String
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1331 jstring jstr = env->NewStringUTF(text);
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1332 // First get the class that contains the method you need to call
2477
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1333 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1334 // Get the method that you want to call
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1335 jmethodID entryfieldNew = env->GetMethodID(clazz, "entryfieldNew",
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1336 "(Ljava/lang/String;II)Landroid/widget/EditText;");
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1337 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1338 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, entryfieldNew, jstr, (int)cid, password), _DW_REFERENCE_WEAK);
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1339 return result;
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1340 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
1341 return nullptr;
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1342 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1343 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1344 * Create a new Entryfield window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1345 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1346 * text: The default text to be in the entryfield widget.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1347 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1348 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1349 * A handle to an entryfield window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1350 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1351 HWND API dw_entryfield_new(const char *text, ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1352 {
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1353 return _dw_entryfield_new(text, cid, FALSE);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1354 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1355
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1356 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1357 * Create a new Entryfield (password) window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1358 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1359 * text: The default text to be in the entryfield widget.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1360 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1361 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1362 * A handle to an entryfield password window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1363 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1364 HWND API dw_entryfield_password_new(const char *text, ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1365 {
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1366 return _dw_entryfield_new(text, cid, TRUE);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1367 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1368
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1369 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1370 * Sets the entryfield character limit.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1371 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1372 * handle: Handle to the spinbutton to be set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1373 * limit: Number of characters the entryfield will take.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1374 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1375 void API dw_entryfield_set_limit(HWND handle, ULONG limit)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1376 {
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1377 JNIEnv *env;
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1378
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1379 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1380 {
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1381 // First get the class that contains the method you need to call
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1382 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1383 // Get the method that you want to call
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1384 jmethodID entryfieldSetLimit = env->GetMethodID(clazz, "entryfieldSetLimit",
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1385 "(Landroid/widget/EditText;J)V");
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1386 // Call the method on the object
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1387 env->CallVoidMethod(_dw_obj, entryfieldSetLimit, handle, (jlong)limit);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1388 _dw_jni_check_exception(env);
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1389 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1390 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1391
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1392 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1393 * Create a new bitmap button window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1394 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1395 * text: Bubble help text to be displayed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1396 * id: An ID of a bitmap in the resource file.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1397 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1398 * A handle to a bitmap button window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1399 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1400 HWND API dw_bitmapbutton_new(const char *text, ULONG resid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1401 {
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1402 JNIEnv *env;
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1403
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1404 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1405 {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1406 // Construct a String
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1407 jstring jstr = env->NewStringUTF(text);
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1408 // First get the class that contains the method you need to call
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1409 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1410 // Get the method that you want to call
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1411 jmethodID bitmapButtonNew = env->GetMethodID(clazz, "bitmapButtonNew",
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1412 "(Ljava/lang/String;I)Landroid/widget/ImageButton;");
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1413 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1414 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, bitmapButtonNew, jstr, (int)resid), _DW_REFERENCE_WEAK);
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1415 return result;
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1416 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
1417 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1418 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1419
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1420 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1421 * Create a new bitmap button window (widget) to be packed from a file.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1422 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1423 * text: Bubble help text to be displayed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1424 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1425 * filename: Name of the file, omit extention to have
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1426 * DW pick the appropriate file extension.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1427 * (BMP on OS/2 or Windows, XPM on Unix)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1428 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1429 * A handle to a bitmap button window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1430 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1431 HWND API dw_bitmapbutton_new_from_file(const char *text, unsigned long cid, const char *filename)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1432 {
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1433 JNIEnv *env;
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1434
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1435 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1436 {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1437 // Construct a String
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1438 jstring jstr = env->NewStringUTF(text);
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1439 jstring path = env->NewStringUTF(text);
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1440 // First get the class that contains the method you need to call
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1441 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1442 // Get the method that you want to call
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1443 jmethodID bitmapButtonNewFromFile = env->GetMethodID(clazz, "bitmapButtonNewFromFile",
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1444 "(Ljava/lang/String;ILjava/lang/String;)Landroid/widget/ImageButton;");
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1445 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1446 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, bitmapButtonNewFromFile, jstr, (int)cid, path), _DW_REFERENCE_WEAK);
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1447 return result;
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1448 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
1449 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1450 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1451
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1452 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1453 * Create a new bitmap button window (widget) to be packed from data.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1454 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1455 * text: Bubble help text to be displayed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1456 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1457 * data: The contents of the image
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1458 * (BMP or ICO on OS/2 or Windows, XPM on Unix)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1459 * len: length of str
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1460 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1461 * A handle to a bitmap button window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1462 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1463 HWND API dw_bitmapbutton_new_from_data(const char *text, unsigned long cid, const char *data, int len)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1464 {
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1465 JNIEnv *env;
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1466
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1467 if(data && len > 0 && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1468 {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1469 // Construct a String
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1470 jstring jstr = env->NewStringUTF(text);
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1471 // Construct a byte array
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1472 jbyteArray bytearray = env->NewByteArray(len);
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1473 env->SetByteArrayRegion(bytearray, 0, len, reinterpret_cast<const jbyte *>(data));
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1474 // First get the class that contains the method you need to call
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1475 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1476 // Get the method that you want to call
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1477 jmethodID bitmapButtonNewFromData = env->GetMethodID(clazz, "bitmapButtonNewFromData",
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1478 "(Ljava/lang/String;I[BI)Landroid/widget/ImageButton;");
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1479 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1480 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, bitmapButtonNewFromData, jstr, (int)cid, bytearray, len), _DW_REFERENCE_WEAK);
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1481 // Clean up after the array now that we are finished
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1482 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0);
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1483 return result;
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
1484 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
1485 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1486 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1487
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1488 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1489 * Create a new spinbutton window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1490 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1491 * text: The text to be display by the static text widget.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1492 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1493 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1494 * A handle to a spinbutton window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1495 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1496 HWND API dw_spinbutton_new(const char *text, ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1497 {
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1498 JNIEnv *env;
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1499
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1500 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1501 {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1502 // Construct a String
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1503 jstring jstr = env->NewStringUTF(text);
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1504 // First get the class that contains the method you need to call
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1505 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1506 // Get the method that you want to call
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1507 jmethodID spinButtonNew = env->GetMethodID(clazz, "spinButtonNew",
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1508 "(Ljava/lang/String;I)Lorg/dbsoft/dwindows/DWSpinButton;");
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1509 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1510 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, spinButtonNew, jstr, (int)cid), _DW_REFERENCE_WEAK);
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1511 return result;
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1512 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
1513 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1514 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1515
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1516 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1517 * Sets the spinbutton value.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1518 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1519 * handle: Handle to the spinbutton to be set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1520 * position: Current value of the spinbutton.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1521 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1522 void API dw_spinbutton_set_pos(HWND handle, long position)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1523 {
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1524 JNIEnv *env;
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1525
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1526 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1527 {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1528 // First get the class that contains the method you need to call
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1529 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1530 // Get the method that you want to call
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1531 jmethodID spinButtonSetPos = env->GetMethodID(clazz, "spinButtonSetPos",
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1532 "(Lorg/dbsoft/dwindows/DWSpinButton;J)V");
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1533 // Call the method on the object
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1534 env->CallVoidMethod(_dw_obj, spinButtonSetPos, handle, (jlong)position);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1535 _dw_jni_check_exception(env);
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1536 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1537 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1538
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1539 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1540 * Sets the spinbutton limits.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1541 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1542 * handle: Handle to the spinbutton to be set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1543 * upper: Upper limit.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1544 * lower: Lower limit.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1545 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1546 void API dw_spinbutton_set_limits(HWND handle, long upper, long lower)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1547 {
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1548 JNIEnv *env;
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1549
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1550 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1551 {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1552 // First get the class that contains the method you need to call
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1553 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1554 // Get the method that you want to call
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1555 jmethodID spinButtonSetLimits = env->GetMethodID(clazz, "spinButtonSetLimits",
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1556 "(Lorg/dbsoft/dwindows/DWSpinButton;JJ)V");
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1557 // Call the method on the object
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1558 env->CallVoidMethod(_dw_obj, spinButtonSetLimits, handle, (jlong)upper, (jlong)lower);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1559 _dw_jni_check_exception(env);
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1560 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1561 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1562
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1563 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1564 * Returns the current value of the spinbutton.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1565 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1566 * handle: Handle to the spinbutton to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1567 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1568 * Number value displayed in the spinbutton.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1569 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1570 long API dw_spinbutton_get_pos(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1571 {
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1572 JNIEnv *env;
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1573 long retval = 0;
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1574
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1575 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1576 {
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1577 // First get the class that contains the method you need to call
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1578 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1579 // Get the method that you want to call
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1580 jmethodID spinButtonGetPos = env->GetMethodID(clazz, "spinButtonGetPos",
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1581 "(Lorg/dbsoft/dwindows/DWSpinButton;)J");
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1582 // Call the method on the object
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1583 retval = env->CallLongMethod(_dw_obj, spinButtonGetPos, handle);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1584 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1585 retval = 0;
2520
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1586 }
167af4b0004b Android: Implement spinbuttons and callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2519
diff changeset
1587 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1588 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1589
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1590 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1591 * Create a new radiobutton window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1592 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1593 * text: The text to be display by the static text widget.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1594 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1595 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1596 * A handle to a radio button window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1597 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1598 HWND API dw_radiobutton_new(const char *text, ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1599 {
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1600 JNIEnv *env;
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1601
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1602 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1603 {
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1604 // Construct a String
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1605 jstring jstr = env->NewStringUTF(text);
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1606 // First get the class that contains the method you need to call
2477
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1607 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1608 // Get the method that you want to call
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1609 jmethodID radioButtonNew = env->GetMethodID(clazz, "radioButtonNew",
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1610 "(Ljava/lang/String;I)Landroid/widget/RadioButton;");
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1611 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1612 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, radioButtonNew, jstr, (int)cid), _DW_REFERENCE_WEAK);
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1613 return result;
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1614 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
1615 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1616 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1617
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1618 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1619 * Create a new slider window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1620 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1621 * vertical: TRUE or FALSE if slider is vertical.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1622 * increments: Number of increments available.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1623 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1624 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1625 * A handle to a slider window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1626 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1627 HWND API dw_slider_new(int vertical, int increments, ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1628 {
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1629 JNIEnv *env;
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1630
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1631 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1632 {
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1633 // First get the class that contains the method you need to call
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1634 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1635 // Get the method that you want to call
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1636 jmethodID sliderNew = env->GetMethodID(clazz, "sliderNew", "(III)Landroid/widget/SeekBar;");
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1637 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1638 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, sliderNew, vertical, increments, (jint)cid), _DW_REFERENCE_WEAK);
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1639 return result;
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1640 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
1641 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1642 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1643
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1644 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1645 * Returns the position of the slider.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1646 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1647 * handle: Handle to the slider to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1648 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1649 * Position of the slider in the set range.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1650 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1651 unsigned int API dw_slider_get_pos(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1652 {
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1653 JNIEnv *env;
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1654 unsigned int retval = 0;
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1655
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1656 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1657 {
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1658 // First get the class that contains the method you need to call
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1659 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1660 // Get the method that you want to call
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1661 jmethodID percentGetPos = env->GetMethodID(clazz, "percentGetPos",
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1662 "(Landroid/widget/ProgressBar;)I");
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1663 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1664 retval = env->CallIntMethod(_dw_obj, percentGetPos, handle);
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1665 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1666 retval = 0;
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1667 }
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1668 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1669 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1670
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1671 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1672 * Sets the slider position.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1673 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1674 * handle: Handle to the slider to be set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1675 * position: Position of the slider withing the range.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1676 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1677 void API dw_slider_set_pos(HWND handle, unsigned int position)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1678 {
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1679 dw_percent_set_pos(handle, position);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1680 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1681
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1682 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1683 * Create a new scrollbar window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1684 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1685 * vertical: TRUE or FALSE if scrollbar is vertical.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1686 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1687 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1688 * A handle to a scrollbar window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1689 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1690 HWND API dw_scrollbar_new(int vertical, ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1691 {
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1692 return dw_slider_new(vertical, 100, cid);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1693 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1694
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1695 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1696 * Returns the position of the scrollbar.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1697 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1698 * handle: Handle to the scrollbar to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1699 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1700 * Position of the scrollbar in the set range.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1701 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1702 unsigned int API dw_scrollbar_get_pos(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1703 {
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1704 return dw_slider_get_pos(handle);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1705 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1706
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1707 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1708 * Sets the scrollbar position.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1709 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1710 * handle: Handle to the scrollbar to be set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1711 * position: Position of the scrollbar withing the range.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1712 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1713 void API dw_scrollbar_set_pos(HWND handle, unsigned int position)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1714 {
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1715 dw_percent_set_pos(handle, position);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1716 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1717
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1718 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1719 * Sets the scrollbar range.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1720 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1721 * handle: Handle to the scrollbar to be set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1722 * range: Maximum range value.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1723 * visible: Visible area relative to the range.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1724 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1725 void API dw_scrollbar_set_range(HWND handle, unsigned int range, unsigned int visible)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1726 {
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1727 JNIEnv *env;
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1728
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1729 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1730 {
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1731 // First get the class that contains the method you need to call
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1732 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1733 // Get the method that you want to call
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1734 jmethodID percentSetRange = env->GetMethodID(clazz, "percentSetRange",
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1735 "(Landroid/widget/ProgressBar;I)V");
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1736 // Call the method on the object
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1737 env->CallVoidMethod(_dw_obj, percentSetRange, handle, (jint)range);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1738 _dw_jni_check_exception(env);
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1739 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1740 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1741
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1742 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1743 * Create a new percent bar window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1744 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1745 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1746 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1747 * A handle to a percent bar window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1748 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1749 HWND API dw_percent_new(ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1750 {
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1751 JNIEnv *env;
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1752
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1753 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1754 {
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1755 // First get the class that contains the method you need to call
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1756 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1757 // Get the method that you want to call
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1758 jmethodID percentNew = env->GetMethodID(clazz, "percentNew",
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1759 "(I)Landroid/widget/ProgressBar;");
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1760 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1761 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, percentNew, (jint)cid), _DW_REFERENCE_WEAK);
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1762 return result;
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1763 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
1764 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1765 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1766
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1767 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1768 * Sets the percent bar position.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1769 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1770 * handle: Handle to the percent bar to be set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1771 * position: Position of the percent bar withing the range.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1772 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1773 void API dw_percent_set_pos(HWND handle, unsigned int position)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1774 {
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1775 JNIEnv *env;
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1776
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1777 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1778 {
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1779 // First get the class that contains the method you need to call
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1780 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1781 // Get the method that you want to call
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1782 jmethodID percentSetPos = env->GetMethodID(clazz, "percentSetPos",
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1783 "(Landroid/widget/ProgressBar;I)V");
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1784 // Call the method on the object
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1785 env->CallVoidMethod(_dw_obj, percentSetPos, handle, (jint)position);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1786 _dw_jni_check_exception(env);
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1787 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1788 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1789
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1790 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1791 * Create a new checkbox window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1792 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1793 * text: The text to be display by the static text widget.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1794 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1795 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1796 * A handle to a checkbox window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1797 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1798 HWND API dw_checkbox_new(const char *text, ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1799 {
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1800 JNIEnv *env;
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1801
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1802 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1803 {
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1804 // Construct a String
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1805 jstring jstr = env->NewStringUTF(text);
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1806 // First get the class that contains the method you need to call
2477
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
1807 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1808 // Get the method that you want to call
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1809 jmethodID checkboxNew = env->GetMethodID(clazz, "checkboxNew",
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1810 "(Ljava/lang/String;I)Landroid/widget/CheckBox;");
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1811 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1812 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, checkboxNew, jstr, (int)cid), _DW_REFERENCE_WEAK);
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1813 return result;
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
1814 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
1815 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1816 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1817
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1818 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1819 * Returns the state of the checkbox.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1820 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1821 * handle: Handle to the checkbox to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1822 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1823 * State of checkbox (TRUE or FALSE).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1824 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1825 int API dw_checkbox_get(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1826 {
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1827 JNIEnv *env;
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1828 int retval = FALSE;
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1829
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1830 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1831 {
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1832 // First get the class that contains the method you need to call
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1833 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1834 // Get the method that you want to call
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1835 jmethodID checkOrRadioGetChecked = env->GetMethodID(clazz, "checkOrRadioGetChecked",
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1836 "(Landroid/view/View;)Z");
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1837 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1838 retval = env->CallBooleanMethod(_dw_obj, checkOrRadioGetChecked, handle);
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1839 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1840 retval = FALSE;
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1841 }
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1842 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1843 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1844
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1845 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1846 * Sets the state of the checkbox.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1847 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1848 * handle: Handle to the checkbox to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1849 * value: TRUE for checked, FALSE for unchecked.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1850 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1851 void API dw_checkbox_set(HWND handle, int value)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1852 {
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1853 JNIEnv *env;
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1854
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
1855 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1856 {
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1857 // First get the class that contains the method you need to call
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
1858 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1859 // Get the method that you want to call
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1860 jmethodID checkOrRadioSetChecked = env->GetMethodID(clazz, "checkOrRadioSetChecked",
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1861 "(Landroid/view/View;I)V");
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1862 // Call the method on the object
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1863 env->CallVoidMethod(_dw_obj, checkOrRadioSetChecked, handle, value);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1864 _dw_jni_check_exception(env);
2492
e2ca6c1a4661 Android: Implement: slider, percent, scrollbar, checkbox_set/get box_unpack_at_index(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2490
diff changeset
1865 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1866 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1867
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1868 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1869 * Create a new listbox window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1870 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1871 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1872 * multi: Multiple select TRUE or FALSE.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1873 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
1874 * A handle to a listbox window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1875 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1876 HWND API dw_listbox_new(ULONG cid, int multi)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1877 {
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
1878 JNIEnv *env;
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
1879
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
1880 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
1881 {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
1882 // First get the class that contains the method you need to call
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
1883 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
1884 // Get the method that you want to call
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
1885 jmethodID listBoxNew = env->GetMethodID(clazz, "listBoxNew",
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
1886 "(II)Lorg/dbsoft/dwindows/DWListBox;");
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
1887 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1888 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, listBoxNew, (int)cid, multi), _DW_REFERENCE_WEAK);
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
1889 return result;
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
1890 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
1891 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1892 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1893
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1894 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1895 * Appends the specified text to the listbox's (or combobox) entry list.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1896 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1897 * handle: Handle to the listbox to be appended to.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1898 * text: Text to append into listbox.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1899 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1900 void API dw_listbox_append(HWND handle, const char *text)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1901 {
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1902 JNIEnv *env;
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1903
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1904 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1905 {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1906 // Construct a String
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1907 jstring jstr = env->NewStringUTF(text);
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1908 // First get the class that contains the method you need to call
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1909 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1910 // Get the method that you want to call
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1911 jmethodID listOrComboBoxAppend = env->GetMethodID(clazz, "listOrComboBoxAppend",
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1912 "(Landroid/view/View;Ljava/lang/String;)V");
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1913 // Call the method on the object
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1914 env->CallVoidMethod(_dw_obj, listOrComboBoxAppend, handle, jstr);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1915 _dw_jni_check_exception(env);
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
1916 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1917 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1918
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1919 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1920 * Inserts the specified text into the listbox's (or combobox) entry list.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1921 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1922 * handle: Handle to the listbox to be inserted into.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1923 * text: Text to insert into listbox.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1924 * pos: 0-based position to insert text
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1925 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1926 void API dw_listbox_insert(HWND handle, const char *text, int pos)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1927 {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1928 JNIEnv *env;
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1929
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1930 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1931 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1932 // Construct a String
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1933 jstring jstr = env->NewStringUTF(text);
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1934 // First get the class that contains the method you need to call
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1935 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1936 // Get the method that you want to call
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1937 jmethodID listOrComboBoxInsert = env->GetMethodID(clazz, "listOrComboBoxInsert",
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1938 "(Landroid/view/View;Ljava/lang/String;I)V");
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1939 // Call the method on the object
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1940 env->CallVoidMethod(_dw_obj, listOrComboBoxInsert, handle, jstr, pos);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1941 _dw_jni_check_exception(env);
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1942 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1943 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1944
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1945 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1946 * Appends the specified text items to the listbox's (or combobox) entry list.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1947 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1948 * handle: Handle to the listbox to be appended to.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1949 * text: Text strings to append into listbox.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1950 * count: Number of text strings to append
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1951 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1952 void API dw_listbox_list_append(HWND handle, char **text, int count)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1953 {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1954 int x;
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1955
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1956 /* TODO: this would be more efficient passing in an array */
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1957 for(x=0;x<count;x++)
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1958 dw_listbox_append(handle, text[x]);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1959 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1960
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1961 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1962 * Clears the listbox's (or combobox) list of all entries.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1963 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1964 * handle: Handle to the listbox to be cleared.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1965 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1966 void API dw_listbox_clear(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1967 {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1968 JNIEnv *env;
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1969
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1970 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1971 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1972 // First get the class that contains the method you need to call
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1973 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1974 // Get the method that you want to call
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1975 jmethodID listOrComboBoxClear = env->GetMethodID(clazz, "listOrComboBoxClear",
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1976 "(Landroid/view/View;)V");
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1977 // Call the method on the object
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1978 env->CallVoidMethod(_dw_obj, listOrComboBoxClear, handle);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
1979 _dw_jni_check_exception(env);
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1980 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1981 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1982
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1983 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1984 * Returns the listbox's item count.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1985 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1986 * handle: Handle to the listbox to be counted.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1987 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1988 * The number of items in the listbox.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1989 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1990 int API dw_listbox_count(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
1991 {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1992 JNIEnv *env;
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1993 int retval = 0;
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1994
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1995 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1996 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1997 // First get the class that contains the method you need to call
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1998 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
1999 // Get the method that you want to call
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2000 jmethodID listOrComboBoxCount = env->GetMethodID(clazz, "listOrComboBoxCount",
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2001 "(Landroid/view/View;)I");
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2002 // Call the method on the object
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2003 retval = env->CallIntMethod(_dw_obj, listOrComboBoxCount, handle);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2004 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2005 retval = 0;
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2006 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2007 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2008 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2009
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2010 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2011 * Sets the topmost item in the viewport.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2012 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2013 * handle: Handle to the listbox to be cleared.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2014 * top: Index to the top item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2015 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2016 void API dw_listbox_set_top(HWND handle, int top)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2017 {
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
2018 JNIEnv *env;
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
2019
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
2020 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
2021 {
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
2022 // First get the class that contains the method you need to call
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
2023 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
2024 // Get the method that you want to call
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2025 jmethodID listBoxSetTop = env->GetMethodID(clazz, "listBoxSetTop",
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
2026 "(Landroid/view/View;I)V");
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
2027 // Call the method on the object
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2028 env->CallVoidMethod(_dw_obj, listBoxSetTop, handle, top);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2029 _dw_jni_check_exception(env);
2519
551313c064f2 Android: Implement ListBox with ListView and fill in the missing listbox functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2518
diff changeset
2030 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2031 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2032
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2033 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2034 * Copies the given index item's text into buffer.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2035 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2036 * handle: Handle to the listbox to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2037 * index: Index into the list to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2038 * buffer: Buffer where text will be copied.
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2039 * length: Length of the buffer (including nullptr).
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2040 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2041 void API dw_listbox_get_text(HWND handle, unsigned int index, char *buffer, unsigned int length)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2042 {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2043 JNIEnv *env;
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2044
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2045 if(buffer && length > 0 && handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2046 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2047 // First get the class that contains the method you need to call
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2048 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2049 // Get the method that you want to call
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2050 jmethodID listOrComboBoxGetText = env->GetMethodID(clazz, "listOrComboBoxGetText",
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2051 "(Landroid/view/View;I)Ljava/lang/String;");
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2052 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2053 jstring result = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, listOrComboBoxGetText, handle, index), _DW_REFERENCE_NONE);
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2054 // Get the UTF8 string result
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2055 if(result)
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2056 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
2057 const char *utf8 = env->GetStringUTFChars(result, nullptr);
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2058
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2059 strncpy(buffer, utf8, length);
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2060 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2061 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2062 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2063
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2064 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2065 * Sets the text of a given listbox entry.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2066 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2067 * handle: Handle to the listbox to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2068 * index: Index into the list to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2069 * buffer: Buffer where text will be copied.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2070 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2071 void API dw_listbox_set_text(HWND handle, unsigned int index, const char *buffer)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2072 {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2073 JNIEnv *env;
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2074
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2075 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2076 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2077 // Construct a String
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2078 jstring jstr = env->NewStringUTF(buffer);
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2079 // First get the class that contains the method you need to call
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2080 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2081 // Get the method that you want to call
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2082 jmethodID listOrComboBoxSetText = env->GetMethodID(clazz, "listOrComboBoxSetText",
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2083 "(Landroid/view/View;ILjava/lang/String;)V");
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2084 // Call the method on the object
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2085 env->CallVoidMethod(_dw_obj, listOrComboBoxSetText, handle, index, jstr);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2086 _dw_jni_check_exception(env);
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2087 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2088 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2089
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2090 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2091 * Returns the index to the item in the list currently selected.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2092 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2093 * handle: Handle to the listbox to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2094 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2095 * The selected item index or DW_ERROR_UNKNOWN (-1) on error.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2096 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2097 int API dw_listbox_selected(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2098 {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2099 JNIEnv *env;
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2100 int retval = DW_ERROR_UNKNOWN;
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2101
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2102 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2103 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2104 // First get the class that contains the method you need to call
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2105 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2106 // Get the method that you want to call
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2107 jmethodID listOrComboBoxGetSelected = env->GetMethodID(clazz, "listOrComboBoxGetSelected",
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2108 "(Landroid/view/View;)I");
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2109 // Call the method on the object
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2110 retval = env->CallIntMethod(_dw_obj, listOrComboBoxGetSelected, handle);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2111 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2112 retval = DW_ERROR_UNKNOWN;
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2113 }
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2114 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2115 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2116
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2117 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2118 * Returns the index to the current selected item or -1 when done.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2119 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2120 * handle: Handle to the listbox to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2121 * where: Either the previous return or -1 to restart.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2122 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2123 * The next selected item or DW_ERROR_UNKNOWN (-1) on error.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2124 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2125 int API dw_listbox_selected_multi(HWND handle, int where)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2126 {
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2127 JNIEnv *env;
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2128 int retval = DW_ERROR_UNKNOWN;
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2129
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2130 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2131 {
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2132 // First get the class that contains the method you need to call
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2133 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2134 // Get the method that you want to call
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2135 jmethodID listBoxSelectedMulti = env->GetMethodID(clazz, "listBoxSelectedMulti",
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2136 "(Landroid/view/View;I)I");
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2137 // Call the method on the object
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2138 retval = env->CallIntMethod(_dw_obj, listBoxSelectedMulti, handle, where);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2139 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2140 retval = DW_ERROR_UNKNOWN;
2521
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2141 }
5f92284e2b08 Android: Implement bitmap buttons, implement dw_listbox_selected_multi().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2520
diff changeset
2142 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2143 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2144
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2145 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2146 * Sets the selection state of a given index.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2147 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2148 * handle: Handle to the listbox to be set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2149 * index: Item index.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2150 * state: TRUE if selected FALSE if unselected.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2151 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2152 void API dw_listbox_select(HWND handle, int index, int state)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2153 {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2154 JNIEnv *env;
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2155
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2156 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2157 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2158 // First get the class that contains the method you need to call
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2159 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2160 // Get the method that you want to call
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2161 jmethodID listOrComboBoxSelect = env->GetMethodID(clazz, "listOrComboBoxSelect",
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2162 "(Landroid/view/View;II)V");
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2163 // Call the method on the object
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2164 env->CallVoidMethod(_dw_obj, listOrComboBoxSelect, handle, index, state);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2165 _dw_jni_check_exception(env);
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2166 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2167 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2168
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2169 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2170 * Deletes the item with given index from the list.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2171 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2172 * handle: Handle to the listbox to be set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2173 * index: Item index.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2174 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2175 void API dw_listbox_delete(HWND handle, int index)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2176 {
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2177 JNIEnv *env;
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2178
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2179 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2180 {
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2181 // First get the class that contains the method you need to call
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2182 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2183 // Get the method that you want to call
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2184 jmethodID listOrComboBoxDelete = env->GetMethodID(clazz, "listOrComboBoxDelete",
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2185 "(Landroid/view/View;I)V");
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2186 // Call the method on the object
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2187 env->CallVoidMethod(_dw_obj, listOrComboBoxDelete, handle, index);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2188 _dw_jni_check_exception(env);
2517
d746323f2841 Android: Implement most of the dw_listbox_*() functions for ComboBoxes.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2515
diff changeset
2189 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2190 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2191
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2192 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2193 * Create a new Combobox window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2194 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2195 * text: The default text to be in the combpbox widget.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2196 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2197 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2198 * A handle to a combobox window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2199 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2200 HWND API dw_combobox_new(const char *text, ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2201 {
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2202 JNIEnv *env;
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2203
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2204 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2205 {
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2206 // Construct a String
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2207 jstring jstr = env->NewStringUTF(text);
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2208 // First get the class that contains the method you need to call
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2209 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2210 // Get the method that you want to call
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2211 jmethodID comboBoxNew = env->GetMethodID(clazz, "comboBoxNew",
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2212 "(Ljava/lang/String;I)Lorg/dbsoft/dwindows/DWComboBox;");
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2213 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2214 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, comboBoxNew, jstr, (int)cid), _DW_REFERENCE_WEAK);
2515
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2215 return result;
211044d98e86 Android: Initial attempt at our own ComboBox class, EditText with PopupList.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2514
diff changeset
2216 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2217 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2218 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2219
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2220 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2221 * Create a new Multiline Editbox window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2222 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2223 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2224 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2225 * A handle to a MLE window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2226 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2227 HWND API dw_mle_new(ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2228 {
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2229 JNIEnv *env;
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2230
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2231 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2232 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2233 // First get the class that contains the method you need to call
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2234 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2235 // Get the method that you want to call
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2236 jmethodID mleNew = env->GetMethodID(clazz, "mleNew",
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2237 "(I)Landroid/widget/EditText;");
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2238 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2239 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, mleNew, (int)cid), _DW_REFERENCE_WEAK);
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2240 return result;
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2241 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2242 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2243 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2244
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2245 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2246 * Adds text to an MLE box and returns the current point.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2247 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2248 * handle: Handle to the MLE to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2249 * buffer: Text buffer to be imported.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2250 * startpoint: Point to start entering text.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2251 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2252 * Current position in the buffer.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2253 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2254 unsigned int API dw_mle_import(HWND handle, const char *buffer, int startpoint)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2255 {
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2256 JNIEnv *env;
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2257 int retval = 0;
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2258
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2259 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2260 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2261 // Construct a String
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2262 jstring jstr = env->NewStringUTF(buffer);
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2263 // First get the class that contains the method you need to call
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2264 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2265 // Get the method that you want to call
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2266 jmethodID mleImport = env->GetMethodID(clazz, "mleImport",
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2267 "(Landroid/widget/EditText;Ljava/lang/String;I)I");
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2268 // Call the method on the object
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2269 retval = env->CallIntMethod(_dw_obj, mleImport, handle, jstr, startpoint);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2270 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2271 retval = 0;
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2272 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2273 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2274 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2275
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2276 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2277 * Grabs text from an MLE box.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2278 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2279 * handle: Handle to the MLE to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2280 * buffer: Text buffer to be exported.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2281 * startpoint: Point to start grabbing text.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2282 * length: Amount of text to be grabbed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2283 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2284 void API dw_mle_export(HWND handle, char *buffer, int startpoint, int length)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2285 {
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2286 if(buffer && length > 0) {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2287 char *text = dw_window_get_text(handle);
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2288
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2289 if (text) {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2290 int len = strlen(text);
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2291
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2292 if (startpoint < len)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2293 strncpy(buffer, &text[startpoint], length);
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2294 else
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2295 buffer[0] = '\0';
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2296 free(text);
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2297 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2298 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2299 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2300
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2301 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2302 * Obtains information about an MLE box.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2303 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2304 * handle: Handle to the MLE to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2305 * bytes: A pointer to a variable to return the total bytes.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2306 * lines: A pointer to a variable to return the number of lines.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2307 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2308 void API dw_mle_get_size(HWND handle, unsigned long *bytes, unsigned long *lines)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2309 {
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2310 char *text = dw_window_get_text(handle);
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2311
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2312 if(bytes) {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2313 if(text) {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2314 *bytes = strlen(text);
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2315 } else {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2316 *bytes = 0;
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2317 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2318 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2319 if(lines) {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2320 if(text)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2321 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2322 int count = 0;
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2323 char *tmp = text;
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2324
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2325 while((tmp = strchr(tmp, '\n'))) {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2326 count++;
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2327 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2328 *lines = count;
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2329 } else {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2330 *lines = 0;
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2331 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2332 }
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2333 if(text)
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2334 free(text);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2335 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2336
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2337 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2338 * Deletes text from an MLE box.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2339 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2340 * handle: Handle to the MLE to be deleted from.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2341 * startpoint: Point to start deleting text.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2342 * length: Amount of text to be deleted.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2343 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2344 void API dw_mle_delete(HWND handle, int startpoint, int length)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2345 {
2525
9fd26efff9da Android: Implement dw_mle_delete() so that the tested output is correct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2346 JNIEnv *env;
9fd26efff9da Android: Implement dw_mle_delete() so that the tested output is correct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2347
9fd26efff9da Android: Implement dw_mle_delete() so that the tested output is correct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2348 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
9fd26efff9da Android: Implement dw_mle_delete() so that the tested output is correct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2349 {
9fd26efff9da Android: Implement dw_mle_delete() so that the tested output is correct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2350 // First get the class that contains the method you need to call
9fd26efff9da Android: Implement dw_mle_delete() so that the tested output is correct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2351 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
9fd26efff9da Android: Implement dw_mle_delete() so that the tested output is correct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2352 // Get the method that you want to call
9fd26efff9da Android: Implement dw_mle_delete() so that the tested output is correct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2353 jmethodID mleDelete = env->GetMethodID(clazz, "mleDelete",
9fd26efff9da Android: Implement dw_mle_delete() so that the tested output is correct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2354 "(Landroid/widget/EditText;II)V");
9fd26efff9da Android: Implement dw_mle_delete() so that the tested output is correct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2355 // Call the method on the object
9fd26efff9da Android: Implement dw_mle_delete() so that the tested output is correct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2356 env->CallVoidMethod(_dw_obj, mleDelete, handle, startpoint, length);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2357 _dw_jni_check_exception(env);
2525
9fd26efff9da Android: Implement dw_mle_delete() so that the tested output is correct.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2523
diff changeset
2358 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2359 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2360
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2361 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2362 * Clears all text from an MLE box.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2363 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2364 * handle: Handle to the MLE to be cleared.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2365 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2366 void API dw_mle_clear(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2367 {
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2368 JNIEnv *env;
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2369
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2370 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2371 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2372 // First get the class that contains the method you need to call
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2373 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2374 // Get the method that you want to call
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2375 jmethodID mleClear = env->GetMethodID(clazz, "mleClear",
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2376 "(Landroid/widget/EditText;)V");
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2377 // Call the method on the object
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2378 env->CallVoidMethod(_dw_obj, mleClear, handle);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2379 _dw_jni_check_exception(env);
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2380 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2381 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2382
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2383 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2384 * Sets the visible line of an MLE box.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2385 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2386 * handle: Handle to the MLE to be positioned.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2387 * line: Line to be visible.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2388 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2389 void API dw_mle_set_visible(HWND handle, int line)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2390 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2391 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2392
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2393 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2394 * Sets the editablity of an MLE box.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2395 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2396 * handle: Handle to the MLE.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2397 * state: TRUE if it can be edited, FALSE for readonly.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2398 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2399 void API dw_mle_set_editable(HWND handle, int state)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2400 {
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2401 JNIEnv *env;
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2402
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2403 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2404 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2405 // First get the class that contains the method you need to call
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2406 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2407 // Get the method that you want to call
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2408 jmethodID mleSetEditable = env->GetMethodID(clazz, "mleSetEditable",
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2409 "(Landroid/widget/EditText;I)V");
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2410 // Call the method on the object
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2411 env->CallVoidMethod(_dw_obj, mleSetEditable, handle, state);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2412 _dw_jni_check_exception(env);
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2413 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2414 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2415
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2416 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2417 * Sets the word wrap state of an MLE box.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2418 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2419 * handle: Handle to the MLE.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2420 * state: TRUE if it wraps, FALSE if it doesn't.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2421 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2422 void API dw_mle_set_word_wrap(HWND handle, int state)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2423 {
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2424 JNIEnv *env;
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2425
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2426 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2427 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2428 // First get the class that contains the method you need to call
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2429 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2430 // Get the method that you want to call
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2431 jmethodID mleSetWordWrap = env->GetMethodID(clazz, "mleSetWordWrap",
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2432 "(Landroid/widget/EditText;I)V");
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2433 // Call the method on the object
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2434 env->CallVoidMethod(_dw_obj, mleSetWordWrap, handle, state);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2435 _dw_jni_check_exception(env);
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2436 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2437 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2438
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2439 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2440 * Sets the current cursor position of an MLE box.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2441 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2442 * handle: Handle to the MLE to be positioned.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2443 * point: Point to position cursor.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2444 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2445 void API dw_mle_set_cursor(HWND handle, int point)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2446 {
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2447 JNIEnv *env;
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2448
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2449 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2450 {
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2451 // First get the class that contains the method you need to call
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2452 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2453 // Get the method that you want to call
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2454 jmethodID mleSetWordWrap = env->GetMethodID(clazz, "mleSetWordWrap",
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2455 "(Landroid/widget/EditText;I)V");
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2456 // Call the method on the object
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2457 env->CallVoidMethod(_dw_obj, mleSetWordWrap, handle, point);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2458 _dw_jni_check_exception(env);
2510
f54051c3f2a5 Android: Implement MLE functions. Fix issues with checkboxes and sliders.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2505
diff changeset
2459 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2460 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2461
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2462 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2463 * Sets the word auto complete state of an MLE box.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2464 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2465 * handle: Handle to the MLE.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2466 * state: Bitwise combination of DW_MLE_COMPLETE_TEXT/DASH/QUOTE
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2467 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2468 void API dw_mle_set_auto_complete(HWND handle, int state)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2469 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2470 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2471
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2472 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2473 * Finds text in an MLE box.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2474 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2475 * handle: Handle to the MLE to be cleared.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2476 * text: Text to search for.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2477 * point: Start point of search.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2478 * flags: Search specific flags.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2479 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2480 * Position in buffer or DW_ERROR_UNKNOWN (-1) on error.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2481 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2482 int API dw_mle_search(HWND handle, const char *text, int point, unsigned long flags)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2483 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2484 return DW_ERROR_UNKNOWN;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2485 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2486
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2487 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2488 * Stops redrawing of an MLE box.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2489 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2490 * handle: Handle to the MLE to freeze.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2491 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2492 void API dw_mle_freeze(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2493 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2494 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2495
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2496 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2497 * Resumes redrawing of an MLE box.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2498 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2499 * handle: Handle to the MLE to thaw.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2500 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2501 void API dw_mle_thaw(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2502 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2503 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2504
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2505 HWND _dw_text_new(const char *text, ULONG cid, int status)
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2506 {
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2507 JNIEnv *env;
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2508
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2509 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2510 {
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2511 // Construct a String
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2512 jstring jstr = env->NewStringUTF(text);
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2513 // First get the class that contains the method you need to call
2477
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
2514 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2515 // Get the method that you want to call
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2516 jmethodID textNew = env->GetMethodID(clazz, "textNew",
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2517 "(Ljava/lang/String;II)Landroid/widget/TextView;");
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2518 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2519 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, textNew, jstr, (int)cid, status), _DW_REFERENCE_WEAK);
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2520 return result;
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2521 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2522 return nullptr;
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2523 }
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2524
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2525 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2526 * Create a new status text window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2527 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2528 * text: The text to be display by the static text widget.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2529 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2530 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2531 * A handle to a status text window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2532 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2533 HWND API dw_status_text_new(const char *text, ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2534 {
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2535 return _dw_text_new(text, cid, TRUE);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2536 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2537
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2538 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2539 * Create a new static text window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2540 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2541 * text: The text to be display by the static text widget.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2542 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2543 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2544 * A handle to a text window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2545 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2546 HWND API dw_text_new(const char *text, ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2547 {
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
2548 return _dw_text_new(text, cid, FALSE);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2549 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2550
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2551 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2552 * Creates a rendering context widget (window) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2553 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2554 * id: An id to be used with dw_window_from_id.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2555 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2556 * A handle to the widget or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2557 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2558 HWND API dw_render_new(unsigned long cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2559 {
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2560 JNIEnv *env;
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2561
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2562 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2563 {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2564 // First get the class that contains the method you need to call
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2565 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2566 // Get the method that you want to call
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2567 jmethodID renderNew = env->GetMethodID(clazz, "renderNew",
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2568 "(I)Lorg/dbsoft/dwindows/DWRender;");
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2569 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2570 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, renderNew, (int)cid), _DW_REFERENCE_WEAK);
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2571 return result;
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2572 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2573 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2574 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2575
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2576 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2577 * Invalidate the render widget triggering an expose event.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2578 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2579 * handle: A handle to a render widget to be redrawn.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2580 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2581 void API dw_render_redraw(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2582 {
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2583 JNIEnv *env;
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2584
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2585 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2586 {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2587 // First get the class that contains the method you need to call
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2588 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2589 // Get the method that you want to call
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2590 jmethodID renderRedraw = env->GetMethodID(clazz, "renderRedraw",
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2591 "(Lorg/dbsoft/dwindows/DWRender;)V");
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2592 // Call the method on the object
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2593 env->CallVoidMethod(_dw_obj, renderRedraw, handle);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2594 _dw_jni_check_exception(env);
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2595 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2596 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2597
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2598 /* Sets the current foreground drawing color.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2599 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2600 * red: red value.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2601 * green: green value.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2602 * blue: blue value.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2603 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2604 void API dw_color_foreground_set(unsigned long value)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2605 {
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2606 JNIEnv *env;
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2607
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2608 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2609 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2610 unsigned long color = _dw_get_color(value);
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2611
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2612 // First get the class that contains the method you need to call
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2613 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2614 // Get the method that you want to call
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2615 jmethodID colorSet = env->GetMethodID(clazz, "colorSet",
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2616 "(IIII)V");
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2617 // Call the method on the object
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2618 env->CallVoidMethod(_dw_obj, colorSet, 0, (jint)DW_RED_VALUE(color), (jint)DW_GREEN_VALUE(color), (jint)DW_BLUE_VALUE(color));
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2619 _dw_jni_check_exception(env);
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2620 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2621 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2622
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2623 /* Sets the current background drawing color.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2624 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2625 * red: red value.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2626 * green: green value.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2627 * blue: blue value.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2628 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2629 void API dw_color_background_set(unsigned long value)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2630 {
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2631 JNIEnv *env;
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2632
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2633 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2634 {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2635 unsigned long color = _dw_get_color(value);
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2636
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2637 // First get the class that contains the method you need to call
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2638 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2639 // Get the method that you want to call
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2640 jmethodID bgColorSet = env->GetMethodID(clazz, "bgColorSet",
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2641 "(IIII)V");
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2642 // Call the method on the object
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2643 env->CallVoidMethod(_dw_obj, bgColorSet, 0, (jint)DW_RED_VALUE(color), (jint)DW_GREEN_VALUE(color), (jint)DW_BLUE_VALUE(color));
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2644 _dw_jni_check_exception(env);
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2645 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2646 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2647
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2648 /* Allows the user to choose a color using the system's color chooser dialog.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2649 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2650 * value: current color
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2651 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2652 * The selected color or the current color if cancelled.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2653 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2654 unsigned long API dw_color_choose(unsigned long value)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2655 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2656 return value;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2657 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2658
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2659 /* Draw a point on a window (preferably a render window).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2660 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2661 * handle: Handle to the window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2662 * pixmap: Handle to the pixmap. (choose only one of these)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2663 * x: X coordinate.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2664 * y: Y coordinate.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2665 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2666 void API dw_draw_point(HWND handle, HPIXMAP pixmap, int x, int y)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2667 {
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2668 JNIEnv *env;
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2669
2534
c4255630cade Android: Fix the safety check in the dw_draw_*() functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2533
diff changeset
2670 if((handle || pixmap) && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2671 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2672 // First get the class that contains the method you need to call
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2673 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2674 // Get the method that you want to call
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2675 jmethodID drawPoint = env->GetMethodID(clazz, "drawPoint",
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2676 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;II)V");
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2677 // Call the method on the object
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
2678 env->CallVoidMethod(_dw_obj, drawPoint, handle, pixmap ? pixmap->bitmap : nullptr, x, y);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2679 _dw_jni_check_exception(env);
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2680 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2681 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2682
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2683 /* Draw a line on a window (preferably a render window).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2684 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2685 * handle: Handle to the window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2686 * pixmap: Handle to the pixmap. (choose only one of these)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2687 * x1: First X coordinate.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2688 * y1: First Y coordinate.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2689 * x2: Second X coordinate.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2690 * y2: Second Y coordinate.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2691 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2692 void API dw_draw_line(HWND handle, HPIXMAP pixmap, int x1, int y1, int x2, int y2)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2693 {
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2694 JNIEnv *env;
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2695
2534
c4255630cade Android: Fix the safety check in the dw_draw_*() functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2533
diff changeset
2696 if((handle || pixmap) && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2697 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2698 // First get the class that contains the method you need to call
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2699 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2700 // Get the method that you want to call
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2701 jmethodID drawLine = env->GetMethodID(clazz, "drawLine",
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2702 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIII)V");
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2703 // Call the method on the object
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
2704 env->CallVoidMethod(_dw_obj, drawLine, handle, pixmap ? pixmap->bitmap : nullptr, x1, y1, x2, y2);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2705 _dw_jni_check_exception(env);
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2706 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2707 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2708
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2709 /* Draw text on a window (preferably a render window).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2710 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2711 * handle: Handle to the window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2712 * pixmap: Handle to the pixmap. (choose only one of these)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2713 * x: X coordinate.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2714 * y: Y coordinate.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2715 * text: Text to be displayed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2716 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2717 void API dw_draw_text(HWND handle, HPIXMAP pixmap, int x, int y, const char *text)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2718 {
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2719 JNIEnv *env;
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2720
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2721 if((handle || pixmap) && text && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2722 {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2723 // Construct the string
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2724 jstring jstr = env->NewStringUTF(text);
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2725 // First get the class that contains the method you need to call
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2726 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2727 // Get the method that you want to call
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2728 jmethodID drawLine = env->GetMethodID(clazz, "drawText",
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2729 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IILjava/lang/String;Landroid/graphics/Typeface;ILandroid/view/View;)V");
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2730 // Call the method on the object
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2731 env->CallVoidMethod(_dw_obj, drawLine, handle, pixmap ? pixmap->bitmap : nullptr, x, y, jstr,
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2732 pixmap ? pixmap->typeface : nullptr, pixmap ? pixmap->fontsize : 0, pixmap ? pixmap->handle : nullptr);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2733 _dw_jni_check_exception(env);
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2734 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2735 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2736
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2737 /* Query the width and height of a text string.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2738 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2739 * handle: Handle to the window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2740 * pixmap: Handle to the pixmap. (choose only one of these)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2741 * text: Text to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2742 * width: Pointer to a variable to be filled in with the width.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2743 * height: Pointer to a variable to be filled in with the height.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2744 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2745 void API dw_font_text_extents_get(HWND handle, HPIXMAP pixmap, const char *text, int *width, int *height)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2746 {
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2747 JNIEnv *env;
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2748
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2749 if((handle || pixmap) && text && (width || height) && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2750 {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2751 // Construct the string
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2752 jstring jstr = env->NewStringUTF(text);
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2753 // First get the class that contains the method you need to call
2548
c4d75d30430c Android: Minor fixes to that last commit... missed dw.h changes and remove test code.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2547
diff changeset
2754 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2755 // Get the method that you want to call
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2756 jmethodID fontTextExtentsGet = env->GetMethodID(clazz, "fontTextExtentsGet",
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2757 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;Ljava/lang/String;Landroid/graphics/Typeface;ILandroid/view/View;)J");
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2758 // Call the method on the object
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2759 jlong dimensions = env->CallLongMethod(_dw_obj, fontTextExtentsGet, handle, pixmap ? pixmap->bitmap : nullptr, jstr,
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2760 pixmap ? pixmap->typeface : nullptr, pixmap ? pixmap->fontsize : 0, pixmap ? pixmap->handle : nullptr);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2761 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2762 dimensions = 0;
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2763
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2764 if(width)
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2765 *width = dimensions & 0xFFFF;
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2766 if(height)
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2767 *height = (dimensions >> 32) & 0xFFFF;
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
2768 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2769 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2770
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2771 /* Draw a polygon on a window (preferably a render window).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2772 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2773 * handle: Handle to the window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2774 * pixmap: Handle to the pixmap. (choose only one of these)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2775 * flags: DW_DRAW_FILL (1) to fill the polygon or DW_DRAW_DEFAULT (0).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2776 * npoints: Number of points passed in.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2777 * x: Pointer to array of X coordinates.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2778 * y: Pointer to array of Y coordinates.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2779 */
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2780 void API dw_draw_polygon(HWND handle, HPIXMAP pixmap, int flags, int npoints, int *x, int *y)
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2781 {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2782 JNIEnv *env;
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2783
2537
cd9d2ba251d5 Android: Reimplement drawPolygon() using drawPath() instead of drawLines/Points().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2535
diff changeset
2784 if((handle || pixmap) && npoints > 0 && x && y && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2785 {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2786 jintArray jx = env->NewIntArray(npoints);
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2787 jintArray jy = env->NewIntArray(npoints);
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2788
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2789 if(jx && jy)
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2790 {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2791 // Construct the integer arrays
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2792 env->SetIntArrayRegion(jx, 0, npoints, x);
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2793 env->SetIntArrayRegion(jy, 0, npoints, y);
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2794 // First get the class that contains the method you need to call
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2795 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2796 // Get the method that you want to call
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2797 jmethodID drawPolygon = env->GetMethodID(clazz, "drawPolygon",
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2798 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;II[I[I)V");
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2799 // Call the method on the object
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
2800 env->CallVoidMethod(_dw_obj, drawPolygon, handle, pixmap ? pixmap->bitmap : nullptr, flags, npoints, jx, jy);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2801 _dw_jni_check_exception(env);
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2802 }
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2803 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2804 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2805
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2806 /* Draw a rectangle on a window (preferably a render window).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2807 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2808 * handle: Handle to the window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2809 * pixmap: Handle to the pixmap. (choose only one of these)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2810 * flags: DW_DRAW_FILL (1) to fill the box or DW_DRAW_DEFAULT (0).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2811 * x: X coordinate.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2812 * y: Y coordinate.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2813 * width: Width of rectangle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2814 * height: Height of rectangle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2815 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2816 void API dw_draw_rect(HWND handle, HPIXMAP pixmap, int flags, int x, int y, int width, int height)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2817 {
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2818 JNIEnv *env;
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2819
2534
c4255630cade Android: Fix the safety check in the dw_draw_*() functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2533
diff changeset
2820 if((handle || pixmap) && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2821 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2822 // First get the class that contains the method you need to call
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2823 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2824 // Get the method that you want to call
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2825 jmethodID drawLine = env->GetMethodID(clazz, "drawRect",
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2826 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIII)V");
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2827 // Call the method on the object
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
2828 env->CallVoidMethod(_dw_obj, drawLine, handle, pixmap ? pixmap->bitmap : nullptr, x, y, width, height);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2829 _dw_jni_check_exception(env);
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
2830 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2831 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2832
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2833 /* Draw an arc on a window (preferably a render window).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2834 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2835 * handle: Handle to the window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2836 * pixmap: Handle to the pixmap. (choose only one of these)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2837 * flags: DW_DRAW_FILL (1) to fill the arc or DW_DRAW_DEFAULT (0).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2838 * DW_DRAW_FULL will draw a complete circle/elipse.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2839 * xorigin: X coordinate of center of arc.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2840 * yorigin: Y coordinate of center of arc.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2841 * x1: X coordinate of first segment of arc.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2842 * y1: Y coordinate of first segment of arc.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2843 * x2: X coordinate of second segment of arc.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2844 * y2: Y coordinate of second segment of arc.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2845 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2846 void API dw_draw_arc(HWND handle, HPIXMAP pixmap, int flags, int xorigin, int yorigin, int x1, int y1, int x2, int y2)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2847 {
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2848 JNIEnv *env;
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2849
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2850 if((handle || pixmap) && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2851 {
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2852 // First get the class that contains the method you need to call
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2853 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2854 // Get the method that you want to call
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2855 jmethodID drawLine = env->GetMethodID(clazz, "drawArc",
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2856 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIIIIII)V");
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2857 // Call the method on the object
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
2858 env->CallVoidMethod(_dw_obj, drawLine, handle, pixmap ? pixmap->bitmap : nullptr, flags, xorigin, yorigin, x1, y1, x2, y2);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
2859 _dw_jni_check_exception(env);
2535
d862d9e4069b Android: Implement most of the rest of drawing except for fonts...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2534
diff changeset
2860 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2861 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2862
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2863 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2864 * Create a tree object to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2865 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2866 * id: An ID to be used for getting the resource from the
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2867 * resource file.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2868 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2869 * A handle to a tree window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2870 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2871 HWND API dw_tree_new(ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2872 {
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2873 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2874 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2875
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2876 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2877 * Inserts an item into a tree window (widget) after another item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2878 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2879 * handle: Handle to the tree to be inserted.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2880 * item: Handle to the item to be positioned after.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2881 * title: The text title of the entry.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2882 * icon: Handle to coresponding icon.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2883 * parent: Parent handle or 0 if root.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2884 * itemdata: Item specific data.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2885 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2886 * A handle to a tree item or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2887 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2888 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, const char *title, HICN icon, HTREEITEM parent, void *itemdata)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2889 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
2890 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2891 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2892
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2893 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2894 * Inserts an item into a tree window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2895 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2896 * handle: Handle to the tree to be inserted.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2897 * title: The text title of the entry.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2898 * icon: Handle to coresponding icon.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2899 * parent: Parent handle or 0 if root.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2900 * itemdata: Item specific data.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2901 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2902 * A handle to a tree item or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2903 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2904 HTREEITEM API dw_tree_insert(HWND handle, const char *title, HICN icon, HTREEITEM parent, void *itemdata)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2905 {
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2906 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2907 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2908
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2909 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2910 * Gets the text an item in a tree window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2911 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2912 * handle: Handle to the tree containing the item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2913 * item: Handle of the item to be modified.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2914 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2915 * A malloc()ed buffer of item text to be dw_free()ed or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2916 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2917 char * API dw_tree_get_title(HWND handle, HTREEITEM item)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2918 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2919 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2920 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2921
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2922 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2923 * Gets the text an item in a tree window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2924 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2925 * handle: Handle to the tree containing the item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2926 * item: Handle of the item to be modified.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2927 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2928 * A handle to a tree item or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2929 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2930 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2931 {
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
2932 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2933 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2934
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2935 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2936 * Sets the text and icon of an item in a tree window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2937 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2938 * handle: Handle to the tree containing the item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2939 * item: Handle of the item to be modified.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2940 * title: The text title of the entry.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2941 * icon: Handle to coresponding icon.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2942 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2943 void API dw_tree_item_change(HWND handle, HTREEITEM item, const char *title, HICN icon)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2944 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2945 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2946
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2947 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2948 * Sets the item data of a tree item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2949 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2950 * handle: Handle to the tree containing the item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2951 * item: Handle of the item to be modified.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2952 * itemdata: User defined data to be associated with item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2953 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2954 void API dw_tree_item_set_data(HWND handle, HTREEITEM item, void *itemdata)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2955 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2956 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2957
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2958 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2959 * Gets the item data of a tree item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2960 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2961 * handle: Handle to the tree containing the item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2962 * item: Handle of the item to be modified.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2963 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2964 * A pointer to tree item data or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2965 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2966 void * API dw_tree_item_get_data(HWND handle, HTREEITEM item)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2967 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
2968 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2969 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2970
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2971 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2972 * Sets this item as the active selection.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2973 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2974 * handle: Handle to the tree window (widget) to be selected.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2975 * item: Handle to the item to be selected.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2976 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2977 void API dw_tree_item_select(HWND handle, HTREEITEM item)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2978 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2979 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2980
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2981 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2982 * Removes all nodes from a tree.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2983 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2984 * handle: Handle to the window (widget) to be cleared.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2985 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2986 void API dw_tree_clear(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2987 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2988 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2989
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2990 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2991 * Expands a node on a tree.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2992 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2993 * handle: Handle to the tree window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2994 * item: Handle to node to be expanded.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2995 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2996 void API dw_tree_item_expand(HWND handle, HTREEITEM item)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2997 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2998 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
2999
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3000 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3001 * Collapses a node on a tree.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3002 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3003 * handle: Handle to the tree window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3004 * item: Handle to node to be collapsed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3005 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3006 void API dw_tree_item_collapse(HWND handle, HTREEITEM item)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3007 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3008 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3009
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3010 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3011 * Removes a node from a tree.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3012 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3013 * handle: Handle to the window (widget) to be cleared.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3014 * item: Handle to node to be deleted.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3015 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3016 void API dw_tree_item_delete(HWND handle, HTREEITEM item)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3017 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3018 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3019
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3020 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3021 * Create a container object to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3022 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3023 * id: An ID to be used for getting the resource from the
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3024 * resource file.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3025 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3026 * A handle to a container window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3027 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3028 HWND API dw_container_new(ULONG cid, int multi)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3029 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3030 JNIEnv *env;
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3031
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3032 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3033 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3034 // First get the class that contains the method you need to call
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3035 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3036 // Get the method that you want to call
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3037 jmethodID containerNew = env->GetMethodID(clazz, "containerNew",
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3038 "(II)Landroid/widget/ListView;");
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3039 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3040 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, containerNew, (int)cid, multi), _DW_REFERENCE_WEAK);
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3041 return result;
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3042 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3043 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3044 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3045
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3046 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3047 * Sets up the container columns.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3048 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3049 * handle: Handle to the container to be configured.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3050 * flags: An array of unsigned longs with column flags.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3051 * titles: An array of strings with column text titles.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3052 * count: The number of columns (this should match the arrays).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3053 * separator: The column number that contains the main separator.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3054 * (this item may only be used in OS/2)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3055 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3056 * DW_ERROR_NONE (0) on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3057 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3058 int API dw_container_setup(HWND handle, unsigned long *flags, char **titles, int count, int separator)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3059 {
2559
b5e8a319fde6 Android: Fix logic error in dw_container_setup() causing return from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
3060 int retval = DW_ERROR_GENERAL;
b5e8a319fde6 Android: Fix logic error in dw_container_setup() causing return from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
3061
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3062 if(handle && flags && titles && count > 0)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3063 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3064 int z;
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3065
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3066 for(z=0;z<count;z++)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3067 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3068 JNIEnv *env;
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3069
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3070 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3071 {
2559
b5e8a319fde6 Android: Fix logic error in dw_container_setup() causing return from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
3072 retval = DW_ERROR_NONE;
b5e8a319fde6 Android: Fix logic error in dw_container_setup() causing return from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
3073
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3074 // Generate a string
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3075 jstring jstr = env->NewStringUTF(titles[z]);
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3076 // First get the class that contains the method you need to call
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3077 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3078 // Get the method that you want to call
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3079 jmethodID containerNew = env->GetMethodID(clazz, "containerAddColumn",
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3080 "(Landroid/widget/ListView;Ljava/lang/String;I)V");
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3081 // Call the method on the object
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3082 env->CallVoidMethod(_dw_obj, containerNew, handle, jstr, (int)flags[z]);
2559
b5e8a319fde6 Android: Fix logic error in dw_container_setup() causing return from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
3083 if(_dw_jni_check_exception(env))
b5e8a319fde6 Android: Fix logic error in dw_container_setup() causing return from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
3084 retval = DW_ERROR_GENERAL;
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3085 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3086 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3087 }
2559
b5e8a319fde6 Android: Fix logic error in dw_container_setup() causing return from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
3088 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3089 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3090
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3091 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3092 * Configures the main filesystem column title for localization.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3093 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3094 * handle: Handle to the container to be configured.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3095 * title: The title to be displayed in the main column.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3096 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3097 void API dw_filesystem_set_column_title(HWND handle, const char *title)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3098 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3099 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3100
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3101 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3102 * Sets up the filesystem columns, note: filesystem always has an icon/filename field.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3103 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3104 * handle: Handle to the container to be configured.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3105 * flags: An array of unsigned longs with column flags.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3106 * titles: An array of strings with column text titles.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3107 * count: The number of columns (this should match the arrays).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3108 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3109 * DW_ERROR_NONE (0) on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3110 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3111 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3112 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3113 unsigned long fsflags[2] = { DW_CFA_BITMAPORICON, DW_CFA_STRING };
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3114 char *fstitles[2] = { (char *)"Icon", (char *)"Filename" };
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3115 int retval = dw_container_setup(handle, fsflags, fstitles, 2, 0);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3116
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3117 if(retval == DW_ERROR_NONE)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3118 retval = dw_container_setup(handle, flags, titles, count, 0);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3119 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3120 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3121
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3122 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3123 * Allocates memory used to populate a container.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3124 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3125 * handle: Handle to the container window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3126 * rowcount: The number of items to be populated.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3127 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3128 * Handle to container items allocated or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3129 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3130 void * API dw_container_alloc(HWND handle, int rowcount)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3131 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3132 JNIEnv *env;
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3133
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3134 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3135 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3136 // First get the class that contains the method you need to call
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3137 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3138 // Get the method that you want to call
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3139 jmethodID containerAlloc = env->GetMethodID(clazz, "containerAlloc",
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3140 "(Landroid/widget/ListView;I)Landroid/widget/ListView;");
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3141 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3142 return (void *)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, containerAlloc, handle, rowcount), _DW_REFERENCE_WEAK);
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3143 }
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3144 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3145 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3146
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3147 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3148 * Sets an item in specified row and column to the given data.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3149 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3150 * handle: Handle to the container window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3151 * pointer: Pointer to the allocated memory in dw_container_alloc().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3152 * column: Zero based column of data being set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3153 * row: Zero based row of data being set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3154 * data: Pointer to the data to be added.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3155 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3156 void API dw_container_set_item(HWND handle, void *pointer, int column, int row, void *data)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3157 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3158 int rowstart = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_rowstart"));
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3159
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3160 dw_container_change_item(handle, column, row + rowstart, data);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3161 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3162
2561
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3163 /* Internal version that doesn't update the list immediately */
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3164 void API _dw_container_change_item(HWND handle, int column, int row, void *data)
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3165 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3166 JNIEnv *env;
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3167
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3168 if(handle && data && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3169 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3170 int columntype = dw_container_get_column_type(handle, column);
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3171
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3172 if((columntype & DW_CFA_BITMAPORICON))
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3173 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3174 jobject icon = *((jobject *)data);
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3175
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3176 if(icon)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3177 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3178 // First get the class that contains the method you need to call
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3179 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3180 // Get the method that you want to call
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3181 jmethodID containerChangeItem = env->GetMethodID(clazz, "containerChangeItemIcon",
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3182 "(Landroid/widget/ListView;IILandroid/graphics/drawable/Drawable;)V");
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3183 // Call the method on the object
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3184 env->CallVoidMethod(_dw_obj, containerChangeItem, handle, column, row, icon);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3185 _dw_jni_check_exception(env);
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3186 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3187 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3188 else if((columntype & DW_CFA_STRING))
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3189 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3190 const char *tmp = *((const char **)data);
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3191
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3192 if(tmp)
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3193 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3194 jstring jstr = env->NewStringUTF(tmp);
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3195 // First get the class that contains the method you need to call
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3196 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3197 // Get the method that you want to call
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3198 jmethodID containerChangeItem = env->GetMethodID(clazz, "containerChangeItemString",
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3199 "(Landroid/widget/ListView;IILjava/lang/String;)V");
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3200 // Call the method on the object
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3201 env->CallVoidMethod(_dw_obj, containerChangeItem, handle, column, row, jstr);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3202 _dw_jni_check_exception(env);
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3203 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3204 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3205 else if((columntype & DW_CFA_ULONG))
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3206 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3207 ULONG num = *((ULONG *)data);
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3208 // First get the class that contains the method you need to call
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3209 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3210 // Get the method that you want to call
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3211 jmethodID containerChangeItem = env->GetMethodID(clazz, "containerChangeItemInt",
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3212 "(Landroid/widget/ListView;III)V");
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3213 // Call the method on the object
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3214 env->CallVoidMethod(_dw_obj, containerChangeItem, handle, column, row, (int)num);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3215 _dw_jni_check_exception(env);
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3216 }
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3217 // TODO: Handle DATE and TIME
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3218 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3219 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3220
2561
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3221 /* Notify that the data changed, causing the container to refresh */
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3222 void _dw_container_refresh(HWND handle)
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3223 {
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3224 JNIEnv *env;
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3225
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3226 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3227 {
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3228 // First get the class that contains the method you need to call
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3229 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3230 // Get the method that you want to call
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3231 jmethodID containerRefresh = env->GetMethodID(clazz, "containerRefresh",
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3232 "(Landroid/widget/ListView;)V");
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3233 // Call the method on the object
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3234 env->CallVoidMethod(_dw_obj, containerRefresh, handle);
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3235 _dw_jni_check_exception(env);
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3236 }
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3237 }
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3238
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3239 /*
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3240 * Changes an existing item in specified row and column to the given data.
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3241 * Parameters:
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3242 * handle: Handle to the container window (widget).
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3243 * column: Zero based column of data being set.
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3244 * row: Zero based row of data being set.
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3245 * data: Pointer to the data to be added.
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3246 */
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3247 void API dw_container_change_item(HWND handle, int column, int row, void *data)
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3248 {
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3249 _dw_container_change_item(handle, column, row, data);
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3250 _dw_container_refresh(handle);
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3251 }
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3252
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3253 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3254 * Changes an existing item in specified row and column to the given data.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3255 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3256 * handle: Handle to the container window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3257 * column: Zero based column of data being set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3258 * row: Zero based row of data being set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3259 * data: Pointer to the data to be added.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3260 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3261 void API dw_filesystem_change_item(HWND handle, int column, int row, void *data)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3262 {
2561
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3263 _dw_container_change_item(handle, column + 2, row, data);
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3264 _dw_container_refresh(handle);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3265 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3266
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3267 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3268 * Changes an item in specified row and column to the given data.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3269 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3270 * handle: Handle to the container window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3271 * pointer: Pointer to the allocated memory in dw_container_alloc().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3272 * column: Zero based column of data being set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3273 * row: Zero based row of data being set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3274 * data: Pointer to the data to be added.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3275 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3276 void API dw_filesystem_change_file(HWND handle, int row, const char *filename, HICN icon)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3277 {
2561
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3278 _dw_container_change_item(handle, 0, row, (void *)&icon);
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3279 _dw_container_change_item(handle, 1, row, (void *)&filename);
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3280 _dw_container_refresh(handle);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3281 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3282
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3283 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3284 * Sets an item in specified row and column to the given data.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3285 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3286 * handle: Handle to the container window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3287 * pointer: Pointer to the allocated memory in dw_container_alloc().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3288 * column: Zero based column of data being set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3289 * row: Zero based row of data being set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3290 * data: Pointer to the data to be added.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3291 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3292 void API dw_filesystem_set_file(HWND handle, void *pointer, int row, const char *filename, HICN icon)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3293 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3294 dw_container_set_item(handle, pointer, 0, row, (void *)&icon);
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3295 dw_container_set_item(handle, pointer, 1, row, (void *)&filename);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3296 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3297
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3298 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3299 * Sets an item in specified row and column to the given data.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3300 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3301 * handle: Handle to the container window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3302 * pointer: Pointer to the allocated memory in dw_container_alloc().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3303 * column: Zero based column of data being set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3304 * row: Zero based row of data being set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3305 * data: Pointer to the data to be added.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3306 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3307 void API dw_filesystem_set_item(HWND handle, void *pointer, int column, int row, void *data)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3308 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3309 dw_container_set_item(handle, pointer, column + 2, row, data);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3310 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3311
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3312 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3313 * Sets the data of a row in the container.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3314 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3315 * pointer: Pointer to the allocated memory in dw_container_alloc().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3316 * row: Zero based row of data being set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3317 * data: Data pointer.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3318 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3319 void API dw_container_set_row_data(void *pointer, int row, void *data)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3320 {
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3321 HWND handle = (HWND)pointer;
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3322
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3323 if(handle)
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3324 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3325 int rowstart = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_rowstart"));
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3326
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3327 dw_container_change_row_data(handle, row + rowstart, data);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3328 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3329 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3330
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3331 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3332 * Changes the data of a row already inserted in the container.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3333 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3334 * handle: Handle to the container window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3335 * row: Zero based row of data being set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3336 * data: Data pointer.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3337 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3338 void API dw_container_change_row_data(HWND handle, int row, void *data)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3339 {
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3340 JNIEnv *env;
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3341
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3342 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3343 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3344 // First get the class that contains the method you need to call
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3345 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3346 // Get the method that you want to call
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3347 jmethodID containerChangeRowData = env->GetMethodID(clazz, "containerChangeRowData",
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3348 "(Landroid/widget/ListView;IJ)V");
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3349 // Call the method on the object
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3350 env->CallVoidMethod(_dw_obj, containerChangeRowData, handle, row, (jlong)data);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3351 _dw_jni_check_exception(env);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3352 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3353 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3354
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3355 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3356 * Gets column type for a container column.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3357 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3358 * handle: Handle to the container window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3359 * column: Zero based column.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3360 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3361 * Constant identifying the the column type.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3362 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3363 int API dw_container_get_column_type(HWND handle, int column)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3364 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3365 JNIEnv *env;
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3366 int retval = 0;
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3367
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3368 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3369 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3370 // First get the class that contains the method you need to call
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3371 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3372 // Get the method that you want to call
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3373 jmethodID containerGetColumnType = env->GetMethodID(clazz, "containerGetColumnType",
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3374 "(Landroid/widget/ListView;I)I");
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3375 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3376 retval = env->CallIntMethod(_dw_obj, containerGetColumnType, handle, column);
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3377 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3378 retval = 0;
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3379 }
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3380 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3381 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3382
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3383 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3384 * Gets column type for a filesystem container column.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3385 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3386 * handle: Handle to the container window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3387 * column: Zero based column.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3388 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3389 * Constant identifying the the column type.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3390 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3391 int API dw_filesystem_get_column_type(HWND handle, int column)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3392 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3393 return dw_container_get_column_type(handle, column + 2);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3394 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3395
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3396 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3397 * Sets the alternating row colors for container window (widget) handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3398 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3399 * handle: The window (widget) handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3400 * oddcolor: Odd row background color in DW_RGB format or a default color index.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3401 * evencolor: Even row background color in DW_RGB format or a default color index.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3402 * DW_RGB_TRANSPARENT will disable coloring rows.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3403 * DW_CLR_DEFAULT will use the system default alternating row colors.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3404 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3405 void API dw_container_set_stripe(HWND handle, unsigned long oddcolor, unsigned long evencolor)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3406 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3407 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3408
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3409 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3410 * Sets the width of a column in the container.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3411 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3412 * handle: Handle to window (widget) of container.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3413 * column: Zero based column of width being set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3414 * width: Width of column in pixels.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3415 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3416 void API dw_container_set_column_width(HWND handle, int column, int width)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3417 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3418 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3419
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3420 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3421 * Sets the title of a row in the container.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3422 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3423 * pointer: Pointer to the allocated memory in dw_container_alloc().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3424 * row: Zero based row of data being set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3425 * title: String title of the item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3426 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3427 void API dw_container_set_row_title(void *pointer, int row, const char *title)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3428 {
2560
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3429 HWND handle = (HWND)pointer;
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3430
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3431 if(handle)
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3432 {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3433 int rowstart = DW_POINTER_TO_INT(dw_window_get_data(handle, "_dw_rowstart"));
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3434
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3435 dw_container_change_row_title(handle, row + rowstart, title);
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3436 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3437 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3438
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3439
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3440 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3441 * Sets the title of a row in the container.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3442 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3443 * handle: Handle to window (widget) of container.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3444 * row: Zero based row of data being set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3445 * title: String title of the item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3446 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3447 void API dw_container_change_row_title(HWND handle, int row, const char *title)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3448 {
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3449 JNIEnv *env;
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3450
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3451 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3452 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3453 // Generate a string
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3454 jstring jstr = title ? env->NewStringUTF(title) : nullptr;
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3455 // First get the class that contains the method you need to call
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3456 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3457 // Get the method that you want to call
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3458 jmethodID containerChangeRowTitle = env->GetMethodID(clazz, "containerChangeRowTitle",
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3459 "(Landroid/widget/ListView;ILjava/lang/String;)V");
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3460 // Call the method on the object
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3461 env->CallVoidMethod(_dw_obj, containerChangeRowTitle, handle, row, jstr);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3462 _dw_jni_check_exception(env);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3463 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3464 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3465
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3466 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3467 * Sets the title of a row in the container.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3468 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3469 * handle: Handle to the container window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3470 * pointer: Pointer to the allocated memory in dw_container_alloc().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3471 * rowcount: The number of rows to be inserted.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3472 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3473 void API dw_container_insert(HWND handle, void *pointer, int rowcount)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3474 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3475 JNIEnv *env;
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3476
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3477 if(pointer && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3478 env->DeleteWeakGlobalRef((jobject)pointer);
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3479 dw_window_set_data(handle, "_dw_rowstart", NULL);
2561
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3480 _dw_container_refresh(handle);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3481 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3482
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3483 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3484 * Removes all rows from a container.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3485 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3486 * handle: Handle to the window (widget) to be cleared.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3487 * redraw: TRUE to cause the container to redraw immediately.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3488 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3489 void API dw_container_clear(HWND handle, int redraw)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3490 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3491 JNIEnv *env;
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3492
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3493 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3494 {
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3495 // First get the class that contains the method you need to call
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3496 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3497 // Get the method that you want to call
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3498 jmethodID containerClear = env->GetMethodID(clazz, "containerClear",
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3499 "(Landroid/widget/ListView;)V");
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3500 // Call the method on the object
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3501 env->CallVoidMethod(_dw_obj, containerClear, handle);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3502 _dw_jni_check_exception(env);
2561
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3503 _dw_container_refresh(handle);
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3504 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3505 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3506
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3507 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3508 * Removes the first x rows from a container.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3509 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3510 * handle: Handle to the window (widget) to be deleted from.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3511 * rowcount: The number of rows to be deleted.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3512 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3513 void API dw_container_delete(HWND handle, int rowcount)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3514 {
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3515 JNIEnv *env;
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3516
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3517 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3518 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3519 // First get the class that contains the method you need to call
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3520 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3521 // Get the method that you want to call
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3522 jmethodID containerDelete = env->GetMethodID(clazz, "containerDelete",
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3523 "(Landroid/widget/ListView;I)V");
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3524 // Call the method on the object
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3525 env->CallVoidMethod(_dw_obj, containerDelete, handle, rowcount);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3526 _dw_jni_check_exception(env);
2561
f28d7d0ca5ed Android: Attempt at implementing updating the container after insertion.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2560
diff changeset
3527 _dw_container_refresh(handle);
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3528 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3529 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3530
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3531 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3532 * Scrolls container up or down.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3533 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3534 * handle: Handle to the window (widget) to be scrolled.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3535 * direction: DW_SCROLL_UP, DW_SCROLL_DOWN, DW_SCROLL_TOP or
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3536 * DW_SCROLL_BOTTOM. (rows is ignored for last two)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3537 * rows: The number of rows to be scrolled.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3538 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3539 void API dw_container_scroll(HWND handle, int direction, long rows)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3540 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3541 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3542
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3543 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3544 * Starts a new query of a container.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3545 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3546 * handle: Handle to the window (widget) to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3547 * flags: If this parameter is DW_CRA_SELECTED it will only
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3548 * return items that are currently selected. Otherwise
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3549 * it will return all records in the container.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3550 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3551 * Pointer to data associated with first entry or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3552 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3553 char * API dw_container_query_start(HWND handle, unsigned long flags)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3554 {
2560
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3555 JNIEnv *env;
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3556 char *retval = nullptr;
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3557
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3558 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3559 {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3560 if(flags & DW_CR_RETDATA) {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3561 // First get the class that contains the method you need to call
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3562 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3563 // Get the method that you want to call
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3564 jmethodID containerGetDataStart = env->GetMethodID(clazz, "containerGetDataStart",
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3565 "(Landroid/widget/ListView;I)J");
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3566 // Call the method on the object
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3567 jlong data = env->CallLongMethod(_dw_obj, containerGetDataStart, handle, (int)flags);
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3568 if(!_dw_jni_check_exception(env))
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3569 retval = (char *)data;
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3570 } else {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3571 // First get the class that contains the method you need to call
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3572 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3573 // Get the method that you want to call
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3574 jmethodID containerGetDataStart = env->GetMethodID(clazz, "containerGetTitleStart",
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3575 "(Landroid/widget/ListView;I)Ljava/lang/String;");
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3576 // Call the method on the object
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3577 jstring jstr = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, containerGetDataStart, handle, (int)flags), _DW_REFERENCE_NONE);
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3578 if(jstr)
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3579 retval = (char *)env->GetStringUTFChars(jstr, nullptr);
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3580 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3581 }
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3582 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3583 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3584
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3585 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3586 * Continues an existing query of a container.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3587 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3588 * handle: Handle to the window (widget) to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3589 * flags: If this parameter is DW_CRA_SELECTED it will only
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3590 * return items that are currently selected. Otherwise
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3591 * it will return all records in the container.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3592 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3593 * Pointer to data associated with next entry or nullptr on error or completion.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3594 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3595 char * API dw_container_query_next(HWND handle, unsigned long flags)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3596 {
2560
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3597 JNIEnv *env;
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3598 char *retval = nullptr;
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3599
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3600 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3601 {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3602 if(flags & DW_CR_RETDATA) {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3603 // First get the class that contains the method you need to call
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3604 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3605 // Get the method that you want to call
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3606 jmethodID containerGetDataStart = env->GetMethodID(clazz, "containerGetDataNext",
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3607 "(Landroid/widget/ListView;I)J");
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3608 // Call the method on the object
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3609 jlong data = env->CallLongMethod(_dw_obj, containerGetDataStart, handle, (int)flags);
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3610 if(!_dw_jni_check_exception(env))
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3611 retval = (char *)data;
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3612 } else {
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3613 // First get the class that contains the method you need to call
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3614 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3615 // Get the method that you want to call
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3616 jmethodID containerGetDataStart = env->GetMethodID(clazz, "containerGetTitleNext",
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3617 "(Landroid/widget/ListView;I)Ljava/lang/String;");
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3618 // Call the method on the object
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3619 jstring jstr = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, containerGetDataStart, handle, (int)flags), _DW_REFERENCE_NONE);
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3620 if(jstr)
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3621 retval = (char *)env->GetStringUTFChars(jstr, nullptr);
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3622 }
3da35cd91ca7 Android: Implement querying containers and ENTER and CONTEXT callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2559
diff changeset
3623 }
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3624 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3625 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3626
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3627 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3628 * Cursors the item with the text speficied, and scrolls to that item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3629 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3630 * handle: Handle to the window (widget) to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3631 * text: Text usually returned by dw_container_query().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3632 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3633 void API dw_container_cursor(HWND handle, const char *text)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3634 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3635 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3636
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3637 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3638 * Cursors the item with the data speficied, and scrolls to that item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3639 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3640 * handle: Handle to the window (widget) to be queried.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3641 * data: Data usually returned by dw_container_query().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3642 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3643 void API dw_container_cursor_by_data(HWND handle, void *data)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3644 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3645 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3646
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3647 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3648 * Deletes the item with the text speficied.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3649 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3650 * handle: Handle to the window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3651 * text: Text usually returned by dw_container_query().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3652 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3653 void API dw_container_delete_row(HWND handle, const char *text)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3654 {
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3655 JNIEnv *env;
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3656
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3657 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3658 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3659 // Generate a string
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3660 jstring jstr = text ? env->NewStringUTF(text) : nullptr;
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3661 // First get the class that contains the method you need to call
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3662 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3663 // Get the method that you want to call
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3664 jmethodID containerRowDeleteByTitle = env->GetMethodID(clazz, "containerRowDeleteByTitle",
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3665 "(Landroid/widget/ListView;Ljava/lang/String;)V");
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3666 // Call the method on the object
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3667 env->CallVoidMethod(_dw_obj, containerRowDeleteByTitle, handle, jstr);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3668 _dw_jni_check_exception(env);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3669 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3670 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3671
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3672 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3673 * Deletes the item with the data speficied.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3674 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3675 * handle: Handle to the window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3676 * data: Data usually returned by dw_container_query().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3677 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3678 void API dw_container_delete_row_by_data(HWND handle, void *data)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3679 {
2558
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3680 JNIEnv *env;
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3681
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3682 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3683 {
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3684 // First get the class that contains the method you need to call
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3685 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3686 // Get the method that you want to call
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3687 jmethodID containerRowDeleteByData = env->GetMethodID(clazz, "containerRowDeleteByData",
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3688 "(Landroid/widget/ListView;J)V");
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3689 // Call the method on the object
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3690 env->CallVoidMethod(_dw_obj, containerRowDeleteByData, handle, (jlong)data);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3691 _dw_jni_check_exception(env);
ebc6a4ff5f1f Android: Implement container row data and titles, required for the callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2557
diff changeset
3692 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3693 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3694
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3695 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3696 * Optimizes the column widths so that all data is visible.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3697 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3698 * handle: Handle to the window (widget) to be optimized.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3699 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3700 void API dw_container_optimize(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3701 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3702 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3703
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3704 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3705 * Inserts an icon into the taskbar.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3706 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3707 * handle: Window handle that will handle taskbar icon messages.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3708 * icon: Icon handle to display in the taskbar.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3709 * bubbletext: Text to show when the mouse is above the icon.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3710 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3711 void API dw_taskbar_insert(HWND handle, HICN icon, const char *bubbletext)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3712 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3713 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3714
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3715 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3716 * Deletes an icon from the taskbar.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3717 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3718 * handle: Window handle that was used with dw_taskbar_insert().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3719 * icon: Icon handle that was used with dw_taskbar_insert().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3720 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3721 void API dw_taskbar_delete(HWND handle, HICN icon)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3722 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3723 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3724
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3725 HICN _dw_icon_load(const char *filename, const char *data, int len, int resid)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3726 {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3727 JNIEnv *env;
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3728
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3729 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3730 {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3731 // Construct a string
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3732 jstring file = nullptr;
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3733 if(filename)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3734 file = env->NewStringUTF(filename);
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3735 // Construct a byte array
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3736 jbyteArray bytearray = nullptr;
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3737 if(data && len > 0)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3738 {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3739 bytearray = env->NewByteArray(len);
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3740 env->SetByteArrayRegion(bytearray, 0, len, reinterpret_cast<const jbyte *>(data));
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3741 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3742 // First get the class that contains the method you need to call
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3743 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3744 // Get the method that you want to call
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3745 jmethodID iconNew = env->GetMethodID(clazz, "iconNew",
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3746 "(Ljava/lang/String;[BII)Landroid/graphics/drawable/Drawable;");
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3747 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3748 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, iconNew,
2559
b5e8a319fde6 Android: Fix logic error in dw_container_setup() causing return from the
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2558
diff changeset
3749 file, bytearray, len, resid), _DW_REFERENCE_STRONG);
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3750 // Clean up after the array now that we are finished
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3751 //if(bytearray)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3752 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0);
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3753 return result;
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3754 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3755 return nullptr;
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3756 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3757
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3758 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3759 * Obtains an icon from a module (or header in GTK).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3760 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3761 * module: Handle to module (DLL) in OS/2 and Windows.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3762 * id: A unsigned long id int the resources on OS/2 and
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3763 * Windows, on GTK this is converted to a pointer
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3764 * to an embedded XPM.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3765 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3766 * Handle to the created icon or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3767 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3768 HICN API dw_icon_load(unsigned long module, unsigned long resid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3769 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3770 return _dw_icon_load(nullptr, nullptr, 0, resid);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3771 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3772
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3773 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3774 * Obtains an icon from a file.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3775 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3776 * filename: Name of the file, omit extention to have
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3777 * DW pick the appropriate file extension.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3778 * (ICO on OS/2 or Windows, XPM on Unix)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3779 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3780 * Handle to the created icon or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3781 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3782 HICN API dw_icon_load_from_file(const char *filename)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3783 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3784 return _dw_icon_load(filename, nullptr, 0, 0);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3785 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3786
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3787 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3788 * Obtains an icon from data.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3789 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3790 * data: Data for the icon (ICO on OS/2 or Windows, XPM on Unix, PNG on Mac)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3791 * len: Length of the passed in data.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3792 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3793 * Handle to the created icon or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3794 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3795 HICN API dw_icon_load_from_data(const char *data, int len)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3796 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
3797 return _dw_icon_load(nullptr, data, len, 0);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3798 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3799
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3800 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3801 * Frees a loaded icon resource.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3802 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3803 * handle: Handle to icon returned by dw_icon_load().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3804 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3805 void API dw_icon_free(HICN handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3806 {
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3807 if(handle)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3808 {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3809 JNIEnv *env;
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3810
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3811 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3812 {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3813 env->DeleteGlobalRef(handle);
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3814 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
3815 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3816 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3817
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3818 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3819 * Create a new MDI Frame to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3820 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3821 * id: An ID to be used with dw_window_from_id or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3822 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3823 * Handle to the created MDI widget or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3824 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3825 HWND API dw_mdi_new(unsigned long cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3826 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3827 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3828 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3829
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3830 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3831 * Creates a splitbar window (widget) with given parameters.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3832 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3833 * type: Value can be DW_VERT or DW_HORZ.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3834 * topleft: Handle to the window to be top or left.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3835 * bottomright: Handle to the window to be bottom or right.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3836 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3837 * A handle to a splitbar window or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3838 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3839 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3840 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3841 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3842 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3843
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3844 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3845 * Sets the position of a splitbar (pecentage).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3846 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3847 * handle: The handle to the splitbar returned by dw_splitbar_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3848 * percent: The position of the splitbar.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3849 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3850 void API dw_splitbar_set(HWND handle, float percent)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3851 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3852 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3853
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3854 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3855 * Gets the position of a splitbar (pecentage).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3856 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3857 * handle: The handle to the splitbar returned by dw_splitbar_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3858 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3859 * Position of the splitbar (percentage).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3860 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3861 float API dw_splitbar_get(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3862 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3863 return 0;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3864 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3865
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3866 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3867 * Create a bitmap object to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3868 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3869 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3870 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3871 * Handle to the created bitmap widget or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3872 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3873 HWND API dw_bitmap_new(ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3874 {
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
3875 JNIEnv *env;
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
3876
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
3877 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
3878 {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
3879 // First get the class that contains the method you need to call
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
3880 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
3881 // Get the method that you want to call
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
3882 jmethodID mleNew = env->GetMethodID(clazz, "bitmapNew",
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
3883 "(I)Landroid/widget/ImageView;");
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
3884 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3885 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, mleNew, (int)cid), _DW_REFERENCE_WEAK);
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
3886 return result;
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
3887 }
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3888 return nullptr;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3889 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3890
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3891 /* Unified internal function to create an Android internal Bitmap */
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3892 jobject _dw_jbitmap_new(unsigned long width, unsigned long height, const char *filename, const char *data, int len, int resid)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3893 {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3894 JNIEnv *env;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3895
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3896 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3897 {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3898 // Construct a string
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3899 jstring file = nullptr;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3900 if(filename)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3901 file = env->NewStringUTF(filename);
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3902 // Construct a byte array
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3903 jbyteArray bytearray = nullptr;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3904 if(data && len > 0)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3905 {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3906 bytearray = env->NewByteArray(len);
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3907 env->SetByteArrayRegion(bytearray, 0, len, reinterpret_cast<const jbyte *>(data));
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3908 }
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3909 if(!_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3910 {
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3911 // First get the class that contains the method you need to call
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3912 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3913 // Get the method that you want to call
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3914 jmethodID pixmapNew = env->GetMethodID(clazz, "pixmapNew",
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3915 "(IILjava/lang/String;[BII)Landroid/graphics/Bitmap;");
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3916 // Call the method on the object
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3917 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, pixmapNew,
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3918 (jint) width,
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3919 (jint) height,
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3920 file, bytearray, len,
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3921 resid),
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3922 _DW_REFERENCE_STRONG);
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3923 // Clean up after the array now that we are finished
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3924 //if(bytearray)
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3925 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3926 return result;
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3927 }
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3928 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3929 return nullptr;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3930 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3931
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3932 void _dw_pixmap_get_dimensions(HPIXMAP pixmap)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3933 {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3934 JNIEnv *env;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3935
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3936 if(pixmap && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3937 {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3938 // First get the class that contains the method you need to call
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3939 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3940 // Get the method that you want to call
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3941 jmethodID pixmapGetDimensions = env->GetMethodID(clazz, "pixmapGetDimensions",
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3942 "(Landroid/graphics/Bitmap;)J");
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3943 // Call the method on the object
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3944 jlong dimensions = env->CallLongMethod(_dw_obj, pixmapGetDimensions, pixmap->bitmap);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3945 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
3946 dimensions = 0;
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3947
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3948 pixmap->width = dimensions & 0xFFFF;
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
3949 pixmap->height = (dimensions >> 32) & 0xFFFF;
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3950 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3951 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3952
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3953 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3954 * Creates a pixmap with given parameters.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3955 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3956 * handle: Window handle the pixmap is associated with.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3957 * width: Width of the pixmap in pixels.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3958 * height: Height of the pixmap in pixels.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3959 * depth: Color depth of the pixmap.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3960 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3961 * A handle to a pixmap or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3962 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3963 HPIXMAP API dw_pixmap_new(HWND handle, unsigned long width, unsigned long height, int depth)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3964 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3965 jobject jbitmap = _dw_jbitmap_new(width, height, nullptr, nullptr, 0, 0);
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3966
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3967 if(jbitmap)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3968 {
2539
822f814a54f4 Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2537
diff changeset
3969 HPIXMAP pixmap = (HPIXMAP)calloc(1, sizeof(struct _hpixmap));
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3970
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3971 if(pixmap)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3972 {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3973 pixmap->width = width;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3974 pixmap->height = height;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3975 pixmap->bitmap = jbitmap;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3976 pixmap->handle = handle;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3977
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3978 return pixmap;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3979 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3980 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3981 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3982 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3983
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3984 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3985 * Creates a pixmap from a file.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3986 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3987 * handle: Window handle the pixmap is associated with.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3988 * filename: Name of the file, omit extention to have
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3989 * DW pick the appropriate file extension.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3990 * (BMP on OS/2 or Windows, XPM on Unix)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3991 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3992 * A handle to a pixmap or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3993 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3994 HPIXMAP API dw_pixmap_new_from_file(HWND handle, const char *filename)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
3995 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3996 jobject jbitmap = _dw_jbitmap_new(0, 0, filename, nullptr, 0, 0);
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3997
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3998 if(jbitmap)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
3999 {
2539
822f814a54f4 Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2537
diff changeset
4000 HPIXMAP pixmap = (HPIXMAP)calloc(1, sizeof(struct _hpixmap));
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4001
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4002 if(pixmap)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4003 {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4004 pixmap->bitmap = jbitmap;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4005 pixmap->handle = handle;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4006 _dw_pixmap_get_dimensions(pixmap);
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4007
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4008 return pixmap;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4009 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4010 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4011 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4012 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4013
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4014 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4015 * Creates a pixmap from data in memory.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4016 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4017 * handle: Window handle the pixmap is associated with.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4018 * data: Source of the image data
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4019 * (BMP on OS/2 or Windows, XPM on Unix)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4020 * len: Length of data
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4021 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4022 * A handle to a pixmap or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4023 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4024 HPIXMAP API dw_pixmap_new_from_data(HWND handle, const char *data, int len)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4025 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4026 jobject jbitmap = _dw_jbitmap_new(0, 0, nullptr, data, len, 0);
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4027
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4028 if(jbitmap)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4029 {
2539
822f814a54f4 Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2537
diff changeset
4030 HPIXMAP pixmap = (HPIXMAP)calloc(1, sizeof(struct _hpixmap));
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4031
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4032 if(pixmap)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4033 {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4034 pixmap->bitmap = jbitmap;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4035 pixmap->handle = handle;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4036 _dw_pixmap_get_dimensions(pixmap);
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4037
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4038 return pixmap;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4039 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4040 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4041 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4042 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4043
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4044 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4045 * Sets the transparent color for a pixmap.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4046 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4047 * pixmap: Handle to a pixmap returned by
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4048 * dw_pixmap_new..
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4049 * color: Transparent RGB color
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4050 * Note: This is only necessary on platforms that
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4051 * don't handle transparency automatically
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4052 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4053 void API dw_pixmap_set_transparent_color( HPIXMAP pixmap, ULONG color )
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4054 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4055 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4056
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4057 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4058 * Creates a pixmap from internal resource graphic specified by id.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4059 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4060 * handle: Window handle the pixmap is associated with.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4061 * id: Resource ID associated with requested pixmap.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4062 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4063 * A handle to a pixmap or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4064 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4065 HPIXMAP API dw_pixmap_grab(HWND handle, ULONG resid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4066 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4067 jobject jbitmap = _dw_jbitmap_new(0, 0, nullptr, nullptr, 0, (int)resid);
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4068
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4069 if(jbitmap)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4070 {
2539
822f814a54f4 Android: Fix memory corruption issue due to incorrectly allocating HPIXMAP.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2537
diff changeset
4071 HPIXMAP pixmap = (HPIXMAP)calloc(1, sizeof(struct _hpixmap));
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4072
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4073 if(pixmap)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4074 {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4075 pixmap->bitmap = jbitmap;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4076 pixmap->handle = handle;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4077 _dw_pixmap_get_dimensions(pixmap);
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4078
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4079 return pixmap;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4080 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4081 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4082 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4083 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4084
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4085 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4086 * Sets the font used by a specified pixmap.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4087 * Normally the pixmap font is obtained from the associated window handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4088 * However this can be used to override that, or for pixmaps with no window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4089 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4090 * pixmap: Handle to a pixmap returned by dw_pixmap_new() or
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4091 * passed to the application via a callback.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4092 * fontname: Name and size of the font in the form "size.fontname"
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4093 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4094 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4095 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4096 int API dw_pixmap_set_font(HPIXMAP pixmap, const char *fontname)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4097 {
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4098 JNIEnv *env;
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4099
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4100 if(pixmap && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4101 {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4102 // Construct a string
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4103 jstring jstr = env->NewStringUTF(fontname);
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4104 // First get the class that contains the method you need to call
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4105 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4106 // Get the method that you want to call
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4107 jmethodID typefaceFromFontName = env->GetMethodID(clazz, "typefaceFromFontName",
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4108 "(Ljava/lang/String;)Landroid/graphics/Typeface;");
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4109 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4110 jobject typeface = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, typefaceFromFontName, jstr), _DW_REFERENCE_STRONG);
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4111 if(typeface)
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4112 {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4113 jobject oldtypeface = pixmap->typeface;
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4114 pixmap->typeface = typeface;
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4115 if(oldtypeface)
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4116 env->DeleteGlobalRef(oldtypeface);
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4117 pixmap->fontsize = atoi(fontname);
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4118 }
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4119 return DW_ERROR_NONE;
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4120 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4121 return DW_ERROR_GENERAL;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4122 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4123
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4124 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4125 * Destroys an allocated pixmap.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4126 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4127 * pixmap: Handle to a pixmap returned by
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4128 * dw_pixmap_new..
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4129 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4130 void API dw_pixmap_destroy(HPIXMAP pixmap)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4131 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4132 if(pixmap)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4133 {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4134 JNIEnv *env;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4135
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4136 if(pixmap && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4137 {
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4138 env->DeleteGlobalRef(pixmap->bitmap);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4139 if(pixmap->typeface)
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4140 env->DeleteGlobalRef(pixmap->typeface);
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4141 free(pixmap);
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4142 }
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4143 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4144 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4145
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4146 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4147 * Copies from one item to another.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4148 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4149 * dest: Destination window handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4150 * destp: Destination pixmap. (choose only one).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4151 * xdest: X coordinate of destination.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4152 * ydest: Y coordinate of destination.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4153 * width: Width of area to copy.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4154 * height: Height of area to copy.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4155 * src: Source window handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4156 * srcp: Source pixmap. (choose only one).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4157 * xsrc: X coordinate of source.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4158 * ysrc: Y coordinate of source.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4159 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4160 void API dw_pixmap_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4161 {
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
4162 dw_pixmap_stretch_bitblt(dest, destp, xdest, ydest, width, height, src, srcp, xsrc, ysrc, -1, -1);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4163 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4164
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4165 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4166 * Copies from one surface to another allowing for stretching.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4167 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4168 * dest: Destination window handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4169 * destp: Destination pixmap. (choose only one).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4170 * xdest: X coordinate of destination.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4171 * ydest: Y coordinate of destination.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4172 * width: Width of the target area.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4173 * height: Height of the target area.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4174 * src: Source window handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4175 * srcp: Source pixmap. (choose only one).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4176 * xsrc: X coordinate of source.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4177 * ysrc: Y coordinate of source.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4178 * srcwidth: Width of area to copy.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4179 * srcheight: Height of area to copy.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4180 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4181 * DW_ERROR_NONE on success and DW_ERROR_GENERAL on failure.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4182 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4183 int API dw_pixmap_stretch_bitblt(HWND dest, HPIXMAP destp, int xdest, int ydest, int width, int height, HWND src, HPIXMAP srcp, int xsrc, int ysrc, int srcwidth, int srcheight)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4184 {
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
4185 JNIEnv *env;
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
4186 int retval = DW_ERROR_GENERAL;
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
4187
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
4188 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
4189 {
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
4190 // First get the class that contains the method you need to call
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
4191 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
4192 // Get the method that you want to call
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
4193 jmethodID pixmapBitBlt = env->GetMethodID(clazz, "pixmapBitBlt",
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
4194 "(Lorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIIILorg/dbsoft/dwindows/DWRender;Landroid/graphics/Bitmap;IIII)I");
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
4195 // Call the method on the object
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
4196 retval = env->CallIntMethod(_dw_obj, pixmapBitBlt, dest, destp ? destp->bitmap : nullptr, xdest, ydest, width, height, src, srcp ? srcp->bitmap : nullptr, xsrc, ysrc, srcwidth, srcheight);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4197 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4198 retval = DW_ERROR_GENERAL;
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
4199 }
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
4200 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4201 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4202
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4203 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4204 * Create a new calendar window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4205 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4206 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4207 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4208 * Handle to the created calendar or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4209 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4210 HWND API dw_calendar_new(ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4211 {
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4212 JNIEnv *env;
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4213
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4214 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4215 {
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4216 // First get the class that contains the method you need to call
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4217 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4218 // Get the method that you want to call
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4219 jmethodID calendarNew = env->GetMethodID(clazz, "calendarNew",
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4220 "(I)Landroid/widget/CalendarView;");
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4221 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4222 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, calendarNew, (int)cid), _DW_REFERENCE_WEAK);
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4223 return result;
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4224 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
4225 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4226 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4227
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4228 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4229 * Sets the current date of a calendar.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4230 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4231 * handle: The handle to the calendar returned by dw_calendar_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4232 * year, month, day: To set the calendar to display.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4233 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4234 void API dw_calendar_set_date(HWND handle, unsigned int year, unsigned int month, unsigned int day)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4235 {
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4236 JNIEnv *env;
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4237
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4238 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4239 {
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4240 time_t date;
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4241 struct tm ts = {0};
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4242
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4243 // Convert to Unix time
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4244 ts.tm_year = year - 1900;
2526
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
4245 ts.tm_mon = month - 1;
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4246 ts.tm_mday = day;
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4247 date = mktime(&ts);
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4248
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4249 // First get the class that contains the method you need to call
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4250 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4251 // Get the method that you want to call
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4252 jmethodID calendarSetDate = env->GetMethodID(clazz, "calendarSetDate",
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4253 "(Landroid/widget/CalendarView;J)V");
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4254 // Call the method on the object
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4255 env->CallVoidMethod(_dw_obj, calendarSetDate, handle, (jlong)date);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4256 _dw_jni_check_exception(env);
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4257 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4258 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4259
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4260 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4261 * Gets the year, month and day set in the calendar widget.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4262 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4263 * handle: The handle to the calendar returned by dw_calendar_new().
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4264 * year: Variable to store the year or nullptr.
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4265 * month: Variable to store the month or nullptr.
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4266 * day: Variable to store the day or nullptr.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4267 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4268 void API dw_calendar_get_date(HWND handle, unsigned int *year, unsigned int *month, unsigned int *day)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4269 {
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4270 JNIEnv *env;
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4271
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4272 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4273 {
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4274 time_t date;
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4275 struct tm ts;
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4276
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4277 // First get the class that contains the method you need to call
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4278 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4279 // Get the method that you want to call
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4280 jmethodID calendarGetDate = env->GetMethodID(clazz, "calendarGetDate",
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4281 "(Landroid/widget/CalendarView;)J");
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4282 // Call the method on the object
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4283 date = (time_t)env->CallLongMethod(_dw_obj, calendarGetDate, handle);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4284 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4285 date = 0;
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4286 ts = *localtime(&date);
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4287 if(year)
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4288 *year = ts.tm_year + 1900;
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4289 if(month)
2526
d3f09b3f3703 Android: Initial dw_file_browse() implementation, still needs some work.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2525
diff changeset
4290 *month = ts.tm_mon + 1;
2523
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4291 if(day)
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4292 *day = ts.tm_mday;
82cdb3ad7c25 Android: Implement the calendar widget using CalendarView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2522
diff changeset
4293 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4294 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4295
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4296 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4297 * Causes the embedded HTML widget to take action.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4298 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4299 * handle: Handle to the window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4300 * action: One of the DW_HTML_* constants.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4301 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4302 void API dw_html_action(HWND handle, int action)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4303 {
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4304 JNIEnv *env;
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4305
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4306 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4307 {
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4308 // First get the class that contains the method you need to call
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4309 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4310 // Get the method that you want to call
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4311 jmethodID htmlAction = env->GetMethodID(clazz, "htmlAction",
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4312 "(Landroid/webkit/WebView;I)V");
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4313 // Call the method on the object
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4314 env->CallVoidMethod(_dw_obj, htmlAction, handle, action);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4315 _dw_jni_check_exception(env);
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4316 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4317 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4318
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4319 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4320 * Render raw HTML code in the embedded HTML widget..
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4321 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4322 * handle: Handle to the window.
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4323 * string: String buffer containing HTML code to
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4324 * be rendered.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4325 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4326 * DW_ERROR_NONE (0) on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4327 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4328 int API dw_html_raw(HWND handle, const char *string)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4329 {
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4330 JNIEnv *env;
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4331
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4332 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4333 {
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4334 // Construct a String
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4335 jstring jstr = env->NewStringUTF(string);
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4336 // First get the class that contains the method you need to call
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4337 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4338 // Get the method that you want to call
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4339 jmethodID htmlRaw = env->GetMethodID(clazz, "htmlRaw",
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4340 "(Landroid/webkit/WebView;Ljava/lang/String;)V");
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4341 // Call the method on the object
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4342 env->CallVoidMethod(_dw_obj, htmlRaw, handle, jstr);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4343 if(!_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4344 return DW_ERROR_NONE;
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4345 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4346 return DW_ERROR_GENERAL;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4347 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4348
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4349 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4350 * Render file or web page in the embedded HTML widget..
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4351 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4352 * handle: Handle to the window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4353 * url: Universal Resource Locator of the web or
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4354 * file object to be rendered.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4355 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4356 * DW_ERROR_NONE (0) on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4357 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4358 int API dw_html_url(HWND handle, const char *url)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4359 {
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4360 JNIEnv *env;
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4361
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4362 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4363 {
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4364 // Construct a String
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4365 jstring jstr = env->NewStringUTF(url);
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4366 // First get the class that contains the method you need to call
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4367 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4368 // Get the method that you want to call
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4369 jmethodID htmlLoadURL = env->GetMethodID(clazz, "htmlLoadURL",
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4370 "(Landroid/webkit/WebView;Ljava/lang/String;)V");
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4371 // Call the method on the object
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4372 env->CallVoidMethod(_dw_obj, htmlLoadURL, handle, jstr);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4373 if(!_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4374 return DW_ERROR_NONE;
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4375 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4376 return DW_ERROR_GENERAL;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4377 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4378
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4379 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4380 * Executes the javascript contained in "script" in the HTML window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4381 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4382 * handle: Handle to the HTML window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4383 * script: Javascript code to execute.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4384 * scriptdata: Data passed to the signal handler.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4385 * Notes: A DW_SIGNAL_HTML_RESULT event will be raised with scriptdata.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4386 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4387 * DW_ERROR_NONE (0) on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4388 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4389 int API dw_html_javascript_run(HWND handle, const char *script, void *scriptdata)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4390 {
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4391 JNIEnv *env;
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4392
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4393 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4394 {
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4395 // Construct a String
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4396 jstring jstr = env->NewStringUTF(script);
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4397 // First get the class that contains the method you need to call
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4398 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4399 // Get the method that you want to call
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4400 jmethodID htmlJavascriptRun = env->GetMethodID(clazz, "htmlJavascriptRun",
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4401 "(Landroid/webkit/WebView;Ljava/lang/String;J)V");
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4402 // Call the method on the object
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4403 env->CallVoidMethod(_dw_obj, htmlJavascriptRun, handle, jstr, (jlong)scriptdata);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4404 if(!_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4405 return DW_ERROR_NONE;
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4406 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4407 return DW_ERROR_UNKNOWN;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4408 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4409
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4410 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4411 * Create a new HTML window (widget) to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4412 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4413 * id: An ID to be used with dw_window_from_id() or 0L.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4414 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4415 * Handle to the created html widget or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4416 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4417 HWND API dw_html_new(unsigned long cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4418 {
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4419 JNIEnv *env;
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4420
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4421 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4422 {
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4423 // First get the class that contains the method you need to call
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4424 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4425 // Get the method that you want to call
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4426 jmethodID htmlNew = env->GetMethodID(clazz, "htmlNew",
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4427 "(I)Landroid/webkit/WebView;");
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4428 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4429 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, htmlNew, (int)cid), _DW_REFERENCE_WEAK);
2501
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4430 return result;
41984ffb5ca2 Android: Initial implement of HTML control with WebView.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2500
diff changeset
4431 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
4432 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4433 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4434
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4435 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4436 * Returns the current X and Y coordinates of the mouse pointer.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4437 * Parameters:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4438 * x: Pointer to variable to store X coordinate or nullptr.
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4439 * y: Pointer to variable to store Y coordinate or nullptr.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4440 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4441 void API dw_pointer_query_pos(long *x, long *y)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4442 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4443 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4444
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4445 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4446 * Sets the X and Y coordinates of the mouse pointer.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4447 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4448 * x: X coordinate.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4449 * y: Y coordinate.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4450 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4451 void API dw_pointer_set_pos(long x, long y)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4452 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4453 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4454
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4455 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4456 * Create a menu object to be popped up.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4457 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4458 * id: An ID to be used associated with this menu.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4459 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4460 * Handle to the created menu or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4461 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4462 HMENUI API dw_menu_new(ULONG cid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4463 {
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4464 JNIEnv *env;
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4465
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4466 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4467 {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4468 // First get the class that contains the method you need to call
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4469 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4470 // Get the method that you want to call
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4471 jmethodID menuNew = env->GetMethodID(clazz, "menuNew",
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4472 "(I)Lorg/dbsoft/dwindows/DWMenu;");
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4473 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4474 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, menuNew, (int)cid), _DW_REFERENCE_WEAK);
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4475 return result;
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4476 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
4477 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4478 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4479
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4480 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4481 * Create a menubar on a window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4482 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4483 * location: Handle of a window frame to be attached to.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4484 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4485 * Handle to the created menu bar or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4486 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4487 HMENUI API dw_menubar_new(HWND location)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4488 {
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4489 JNIEnv *env;
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4490
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4491 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4492 {
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4493 // First get the class that contains the method you need to call
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4494 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4495 // Get the method that you want to call
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4496 jmethodID menuBarNew = env->GetMethodID(clazz, "menuBarNew",
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4497 "(Landroid/view/View;)Lorg/dbsoft/dwindows/DWMenu;");
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4498 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4499 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, menuBarNew, location), _DW_REFERENCE_WEAK);
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4500 return result;
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4501 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
4502 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4503 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4504
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4505 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4506 * Destroys a menu created with dw_menubar_new or dw_menu_new.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4507 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4508 * menu: Handle of a menu.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4509 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4510 void API dw_menu_destroy(HMENUI *menu)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4511 {
2545
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4512 JNIEnv *env;
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4513
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4514 if(menu && *menu && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4515 {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4516 // First get the class that contains the method you need to call
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4517 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4518 // Get the method that you want to call
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4519 jmethodID menuDestroy = env->GetMethodID(clazz, "menuDestroy",
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4520 "(Lorg/dbsoft/dwindows/DWMenu;)V");
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4521 // Call the method on the object
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4522 env->CallVoidMethod(_dw_obj, menuDestroy, *menu);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4523 _dw_jni_check_exception(env);
2545
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4524 *menu = nullptr;
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4525 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4526 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4527
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4528 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4529 * Deletes the menu item specified.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4530 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4531 * menu: The handle to the menu in which the item was appended.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4532 * id: Menuitem id.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4533 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4534 * DW_ERROR_NONE (0) on success or DW_ERROR_UNKNOWN on failure.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4535 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4536 int API dw_menu_delete_item(HMENUI menux, unsigned long id)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4537 {
2545
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4538 JNIEnv *env;
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4539
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4540 if(menux && id > 0 && id < 30000 && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4541 {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4542 // First get the class that contains the method you need to call
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4543 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4544 // Get the method that you want to call
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4545 jmethodID menuDeleteItem = env->GetMethodID(clazz, "menuDeleteItem",
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4546 "(Lorg/dbsoft/dwindows/DWMenu;I)V");
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4547 // Call the method on the object
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4548 env->CallVoidMethod(_dw_obj, menuDeleteItem, menux, (int)id);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4549 if(!_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4550 return DW_ERROR_NONE;
2545
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4551 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4552 return DW_ERROR_UNKNOWN;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4553 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4554
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4555 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4556 * Pops up a context menu at given x and y coordinates.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4557 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4558 * menu: The handle the the existing menu.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4559 * parent: Handle to the window initiating the popup.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4560 * x: X coordinate.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4561 * y: Y coordinate.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4562 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4563 void API dw_menu_popup(HMENUI *menu, HWND parent, int x, int y)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4564 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4565 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4566
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4567 char _dw_removetilde(char *dest, const char *src)
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4568 {
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4569 int z, cur=0;
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4570 char accel = '\0';
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4571
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4572 for(z=0;z<strlen(src);z++)
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4573 {
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4574 if(src[z] != '~')
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4575 {
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4576 dest[cur] = src[z];
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4577 cur++;
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4578 }
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4579 else
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4580 {
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4581 accel = src[z+1];
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4582 }
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4583 }
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4584 dest[cur] = 0;
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4585 return accel;
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4586 }
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4587
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4588 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4589 * Adds a menuitem or submenu to an existing menu.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4590 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4591 * menu: The handle the the existing menu.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4592 * title: The title text on the menu item to be added.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4593 * id: An ID to be used for message passing.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4594 * flags: Extended attributes to set on the menu.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4595 * end: If TRUE memu is positioned at the end of the menu.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4596 * check: If TRUE menu is "check"able.
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4597 * submenu: Handle to an existing menu to be a submenu or nullptr.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4598 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4599 * Handle to the created menu item or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4600 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4601 HWND API dw_menu_append_item(HMENUI menux, const char *title, ULONG itemid, ULONG flags, int end, int check, HMENUI submenux)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4602 {
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4603 JNIEnv *env;
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4604
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4605 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4606 {
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4607 char *newtitle = (char *)alloca(strlen(title)+1);
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4608 char accel = _dw_removetilde(newtitle, title);
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4609 // Create a string
2544
dbfcc0e357d6 Android: Clean up the menus... add separator, remove tildes and implement callbacks.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2543
diff changeset
4610 jstring jstr = env->NewStringUTF(newtitle);
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4611 // First get the class that contains the method you need to call
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4612 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4613 // Get the method that you want to call
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4614 jmethodID menuAppendItem = env->GetMethodID(clazz, "menuAppendItem",
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4615 "(Lorg/dbsoft/dwindows/DWMenu;Ljava/lang/String;IIIILorg/dbsoft/dwindows/DWMenu;)Lorg/dbsoft/dwindows/DWMenuItem;");
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4616 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4617 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, menuAppendItem, menux, jstr, (int)itemid, (int)flags, end, check, submenux), _DW_REFERENCE_WEAK);
2543
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4618 return result;
f9367eb9a6e7 Android: Initial menu support, incomplete but basics functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2542
diff changeset
4619 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
4620 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4621 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4622
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4623 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4624 * Sets the state of a menu item check.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4625 * Deprecated; use dw_menu_item_set_state()
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4626 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4627 * menu: The handle the the existing menu.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4628 * id: Menuitem id.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4629 * check: TRUE for checked FALSE for not checked.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4630 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4631 void API dw_menu_item_set_check(HMENUI menux, unsigned long itemid, int check)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4632 {
2545
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4633 dw_menu_item_set_state(menux, itemid, check ? DW_MIS_CHECKED : DW_MIS_UNCHECKED);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4634 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4635
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4636 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4637 * Sets the state of a menu item.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4638 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4639 * menu: The handle to the existing menu.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4640 * id: Menuitem id.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4641 * flags: DW_MIS_ENABLED/DW_MIS_DISABLED
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4642 * DW_MIS_CHECKED/DW_MIS_UNCHECKED
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4643 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4644 void API dw_menu_item_set_state(HMENUI menux, unsigned long itemid, unsigned long state)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4645 {
2545
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4646 JNIEnv *env;
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4647
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4648 if(menux && itemid > 0 && itemid < 30000 && state && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4649 {
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4650 // First get the class that contains the method you need to call
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4651 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4652 // Get the method that you want to call
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4653 jmethodID menuSetState = env->GetMethodID(clazz, "menuSetState",
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4654 "(Lorg/dbsoft/dwindows/DWMenu;II)V");
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4655 // Call the method on the object
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4656 env->CallVoidMethod(_dw_obj, menuSetState, menux, (int)itemid, (int)state);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4657 _dw_jni_check_exception(env);
2545
f803f3b164cf Android: Implement dw_menu_item_set_state/check() dw_menu_item_delete() and dw_menu_destroy().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2544
diff changeset
4658 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4659 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4660
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4661 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4662 * Create a notebook object to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4663 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4664 * id: An ID to be used for getting the resource from the
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4665 * resource file.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4666 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4667 * Handle to the created notebook or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4668 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4669 HWND API dw_notebook_new(ULONG cid, int top)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4670 {
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4671 JNIEnv *env;
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4672
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4673 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4674 {
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4675 // First get the class that contains the method you need to call
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4676 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4677 // Get the method that you want to call
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4678 jmethodID notebookNew = env->GetMethodID(clazz, "notebookNew",
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4679 "(II)Landroid/widget/RelativeLayout;");
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4680 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4681 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, notebookNew, (int)cid, top), _DW_REFERENCE_WEAK);
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4682 return result;
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4683 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
4684 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4685 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4686
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4687 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4688 * Adds a new page to specified notebook.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4689 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4690 * handle: Window (widget) handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4691 * flags: Any additional page creation flags.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4692 * front: If TRUE page is added at the beginning.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4693 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4694 * ID of newly created notebook page.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4695 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4696 unsigned long API dw_notebook_page_new(HWND handle, ULONG flags, int front)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4697 {
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4698 JNIEnv *env;
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4699 unsigned long result = 0;
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4700
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4701 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4702 {
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4703 // First get the class that contains the method you need to call
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4704 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4705 // Get the method that you want to call
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4706 jmethodID notebookPageNew = env->GetMethodID(clazz, "notebookPageNew",
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
4707 "(Landroid/widget/RelativeLayout;JI)J");
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4708 // Call the method on the object
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
4709 result = (unsigned long)env->CallLongMethod(_dw_obj, notebookPageNew, handle, (jlong)flags, front);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4710 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4711 result = 0;
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4712 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4713 return result;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4714 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4715
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4716 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4717 * Remove a page from a notebook.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4718 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4719 * handle: Handle to the notebook widget.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4720 * pageid: ID of the page to be destroyed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4721 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4722 void API dw_notebook_page_destroy(HWND handle, unsigned int pageid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4723 {
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4724 JNIEnv *env;
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4725
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4726 if(handle && pageid && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4727 {
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4728 // First get the class that contains the method you need to call
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4729 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4730 // Get the method that you want to call
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4731 jmethodID notebookPageDestroy = env->GetMethodID(clazz, "notebookPageDestroy",
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
4732 "(Landroid/widget/RelativeLayout;J)V");
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4733 // Call the method on the object
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
4734 env->CallVoidMethod(_dw_obj, notebookPageDestroy, handle, (jlong)pageid);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4735 _dw_jni_check_exception(env);
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4736 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4737 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4738
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4739 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4740 * Queries the currently visible page ID.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4741 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4742 * handle: Handle to the notebook widget.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4743 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4744 * ID of visible notebook page.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4745 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4746 unsigned long API dw_notebook_page_get(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4747 {
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4748 JNIEnv *env;
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4749 unsigned long result = 0;
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4750
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4751 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) {
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4752 // First get the class that contains the method you need to call
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4753 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4754 // Get the method that you want to call
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4755 jmethodID notebookPageGet = env->GetMethodID(clazz, "notebookPageGet",
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
4756 "(Landroid/widget/RelativeLayout;)J");
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4757 // Call the method on the object
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
4758 result = (unsigned long)env->CallLongMethod(_dw_obj, notebookPageGet, handle);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4759 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4760 result = 0;
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4761 }
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4762 return result;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4763 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4764
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4765 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4766 * Sets the currently visible page ID.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4767 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4768 * handle: Handle to the notebook widget.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4769 * pageid: ID of the page to be made visible.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4770 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4771 void API dw_notebook_page_set(HWND handle, unsigned int pageid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4772 {
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4773 JNIEnv *env;
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4774
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4775 if(handle && pageid && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) {
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4776 // First get the class that contains the method you need to call
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4777 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4778 // Get the method that you want to call
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4779 jmethodID notebookPageSet = env->GetMethodID(clazz, "notebookPageSet",
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
4780 "(Landroid/widget/RelativeLayout;J)V");
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4781 // Call the method on the object
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
4782 env->CallVoidMethod(_dw_obj, notebookPageSet, handle, (jlong)pageid);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4783 _dw_jni_check_exception(env);
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4784 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4785 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4786
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4787 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4788 * Sets the text on the specified notebook tab.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4789 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4790 * handle: Notebook handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4791 * pageid: Page ID of the tab to set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4792 * text: Pointer to the text to set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4793 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4794 void API dw_notebook_page_set_text(HWND handle, ULONG pageid, const char *text)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4795 {
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4796 JNIEnv *env;
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4797
2502
b6319aed3298 Android: Massive thread safety overhaul. Not quite back to fully functional.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2501
diff changeset
4798 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4799 {
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4800 // Construct a String
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4801 jstring jstr = env->NewStringUTF(text);
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4802 // First get the class that contains the method you need to call
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4803 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4804 // Get the method that you want to call
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4805 jmethodID notebookPageSetText = env->GetMethodID(clazz, "notebookPageSetText",
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
4806 "(Landroid/widget/RelativeLayout;JLjava/lang/String;)V");
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4807 // Call the method on the object
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
4808 env->CallVoidMethod(_dw_obj, notebookPageSetText, handle, (jlong)pageid, jstr);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4809 _dw_jni_check_exception(env);
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4810 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4811 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4812
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4813 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4814 * Sets the text on the specified notebook tab status area.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4815 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4816 * handle: Notebook handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4817 * pageid: Page ID of the tab to set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4818 * text: Pointer to the text to set.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4819 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4820 void API dw_notebook_page_set_status_text(HWND handle, ULONG pageid, const char *text)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4821 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4822 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4823
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4824 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4825 * Packs the specified box into the notebook page.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4826 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4827 * handle: Handle to the notebook to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4828 * pageid: Page ID in the notebook which is being packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4829 * page: Box handle to be packed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4830 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4831 void API dw_notebook_pack(HWND handle, ULONG pageid, HWND page)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4832 {
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4833 JNIEnv *env;
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4834
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4835 if(handle && pageid && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4836 {
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4837 // First get the class that contains the method you need to call
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4838 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4839 // Get the method that you want to call
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
4840 jmethodID notebookPagePack = env->GetMethodID(clazz, "notebookPagePack",
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
4841 "(Landroid/widget/RelativeLayout;JLandroid/widget/LinearLayout;)V");
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4842 // Call the method on the object
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
4843 env->CallVoidMethod(_dw_obj, notebookPagePack, handle, (jlong)pageid, page);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4844 _dw_jni_check_exception(env);
2493
bca7e0ab0ccc Android: Work on the notebook control, doesn't work yet but everything filled in.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2492
diff changeset
4845 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4846 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4847
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4848 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4849 * Create a new Window Frame.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4850 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4851 * owner: The Owner's window handle or HWND_DESKTOP.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4852 * title: The Window title.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4853 * flStyle: Style flags.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4854 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
4855 * Handle to the created window or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4856 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4857 HWND API dw_window_new(HWND hwndOwner, const char *title, ULONG flStyle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4858 {
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
4859 JNIEnv *env;
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
4860
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
4861 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
4862 {
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
4863 // Construct a String
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
4864 jstring jstr = env->NewStringUTF(title);
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
4865 // First get the class that contains the method you need to call
2477
3fbf8783122d Android: First functional version. Notebook-less first page of dwtest works.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2476
diff changeset
4866 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
4867 // Get the method that you want to call
2476
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
4868 jmethodID windowNew = env->GetMethodID(clazz, "windowNew",
20c9e83cba2a Android: Implement dw_entryfield_new, dw_entryfield_password_new() dw_button_new(),
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2475
diff changeset
4869 "(Ljava/lang/String;I)Landroid/widget/LinearLayout;");
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
4870 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4871 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, windowNew, jstr, (int)flStyle), _DW_REFERENCE_WEAK);
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
4872 return result;
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
4873 }
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
4874 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4875 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4876
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4877 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4878 * Call a function from the window (widget)'s context (typically the message loop thread).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4879 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4880 * handle: Window handle of the widget.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4881 * function: Function pointer to be called.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4882 * data: Pointer to the data to be passed to the function.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4883 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4884 void API dw_window_function(HWND handle, void *function, void *data)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4885 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4886 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4887
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4888
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4889 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4890 * Changes the appearance of the mouse pointer.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4891 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4892 * handle: Handle to widget for which to change.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4893 * cursortype: ID of the pointer you want.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4894 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4895 void API dw_window_set_pointer(HWND handle, int pointertype)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4896 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4897 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4898
2503
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4899 int _dw_window_hide_show(HWND handle, int state)
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4900 {
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4901 JNIEnv *env;
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4902
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4903 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4904 {
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4905 // First get the class that contains the method you need to call
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4906 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4907 // Get the method that you want to call
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4908 jmethodID windowHideShow = env->GetMethodID(clazz, "windowHideShow",
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4909 "(Landroid/view/View;I)V");
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4910 // Call the method on the object
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4911 env->CallVoidMethod(_dw_obj, windowHideShow, handle, state);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4912 if(!_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4913 return DW_ERROR_NONE;
2503
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4914 }
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4915 return DW_ERROR_GENERAL;
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4916 }
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4917
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4918 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4919 * Makes the window visible.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4920 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4921 * handle: The window handle to make visible.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4922 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4923 * DW_ERROR_NONE (0) on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4924 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4925 int API dw_window_show(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4926 {
2503
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4927 return _dw_window_hide_show(handle, TRUE);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4928 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4929
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4930 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4931 * Makes the window invisible.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4932 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4933 * handle: The window handle to hide.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4934 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4935 * DW_ERROR_NONE (0) on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4936 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4937 int API dw_window_hide(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4938 {
2503
1c2a79313b04 Android: Implment dw_window_hide/show(). Set the initial visibility to GONE.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2502
diff changeset
4939 return _dw_window_hide_show(handle, FALSE);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4940 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4941
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4942 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4943 * Sets the colors used by a specified window (widget) handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4944 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4945 * handle: The window (widget) handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4946 * fore: Foreground color in DW_RGB format or a default color index.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4947 * back: Background color in DW_RGB format or a default color index.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4948 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4949 * DW_ERROR_NONE (0) on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4950 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4951 int API dw_window_set_color(HWND handle, ULONG fore, ULONG back)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4952 {
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4953 JNIEnv *env;
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4954
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4955 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4956 {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4957 unsigned long _fore = _dw_get_color(fore);
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4958 unsigned long _back = _dw_get_color(back);
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4959
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4960 // First get the class that contains the method you need to call
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4961 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4962 // Get the method that you want to call
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4963 jmethodID windowSetColor = env->GetMethodID(clazz, "windowSetColor",
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
4964 "(Landroid/view/View;IIIIIIIIII)V");
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4965 // Call the method on the object
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4966 env->CallVoidMethod(_dw_obj, windowSetColor, handle,
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
4967 (jint)fore, 0, (jint)DW_RED_VALUE(_fore), (jint)DW_GREEN_VALUE(_fore), (jint)DW_BLUE_VALUE(_fore),
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
4968 (jint)back, 0, (jint)DW_RED_VALUE(_back), (jint)DW_GREEN_VALUE(_back), (jint)DW_BLUE_VALUE(_back));
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4969 if(!_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
4970 return DW_ERROR_NONE;
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
4971 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4972 return DW_ERROR_GENERAL;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4973 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4974
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4975 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4976 * Sets the border size of a specified window (widget) handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4977 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4978 * handle: The window (widget) handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4979 * border: Size of the window border in pixels.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4980 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4981 * DW_ERROR_NONE (0) on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4982 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4983 int API dw_window_set_border(HWND handle, int border)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4984 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4985 return DW_ERROR_GENERAL;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4986 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4987
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4988 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4989 * Sets the style of a given window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4990 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4991 * handle: Window (widget) handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4992 * style: Style features enabled or disabled.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4993 * mask: Corresponding bitmask of features to be changed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4994 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4995 void API dw_window_set_style(HWND handle, ULONG style, ULONG mask)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4996 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4997 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4998
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
4999 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5000 * Sets the current focus item for a window/dialog.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5001 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5002 * handle: Handle to the dialog item to be focused.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5003 * Remarks:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5004 * This is for use after showing the window/dialog.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5005 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5006 void API dw_window_set_focus(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5007 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5008 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5009
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5010 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5011 * Sets the default focus item for a window/dialog.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5012 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5013 * window: Toplevel window or dialog.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5014 * defaultitem: Handle to the dialog item to be default.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5015 * Remarks:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5016 * This is for use before showing the window/dialog.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5017 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5018 void API dw_window_default(HWND handle, HWND defaultitem)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5019 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5020 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5021
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5022 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5023 * Sets window to click the default dialog item when an ENTER is pressed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5024 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5025 * window: Window (widget) to look for the ENTER press.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5026 * next: Window (widget) to move to next (or click)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5027 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5028 void API dw_window_click_default(HWND handle, HWND next)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5029 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5030 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5031
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5032 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5033 * Captures the mouse input to this window even if it is outside the bounds.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5034 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5035 * handle: Handle to receive mouse input.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5036 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5037 void API dw_window_capture(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5038 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5039 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5040
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5041 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5042 * Releases previous mouse capture.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5043 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5044 void API dw_window_release(void)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5045 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5046 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5047
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5048 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5049 * Changes a window's parent to newparent.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5050 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5051 * handle: The window handle to destroy.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5052 * newparent: The window's new parent window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5053 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5054 void API dw_window_reparent(HWND handle, HWND newparent)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5055 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5056 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5057
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5058 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5059 * Sets the font used by a specified window (widget) handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5060 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5061 * handle: The window (widget) handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5062 * fontname: Name and size of the font in the form "size.fontname"
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5063 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5064 * DW_ERROR_NONE (0) on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5065 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5066 int API dw_window_set_font(HWND handle, const char *fontname)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5067 {
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
5068 JNIEnv *env;
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
5069
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
5070 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
5071 {
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
5072 // Construct a string
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
5073 jstring jstr = env->NewStringUTF(fontname);
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
5074 // First get the class that contains the method you need to call
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
5075 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
5076 // Get the method that you want to call
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
5077 jmethodID windowHideShow = env->GetMethodID(clazz, "windowSetFont",
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
5078 "(Landroid/view/View;Ljava/lang/String;)V");
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
5079 // Call the method on the object
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
5080 env->CallVoidMethod(_dw_obj, windowHideShow, handle, jstr);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5081 if(!_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5082 return DW_ERROR_NONE;
2547
dbd15c13f5bb Android: Implement most of the font functions and control/widget color.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2545
diff changeset
5083 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5084 return DW_ERROR_GENERAL;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5085 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5086
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5087 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5088 * Returns the current font for the specified window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5089 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5090 * handle: The window handle from which to obtain the font.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5091 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5092 * A malloc()ed font name string to be dw_free()ed or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5093 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5094 char * API dw_window_get_font(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5095 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5096 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5097 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5098
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5099 /* Allows the user to choose a font using the system's font chooser dialog.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5100 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5101 * currfont: current font
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5102 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5103 * A malloced buffer with the selected font or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5104 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5105 char * API dw_font_choose(const char *currfont)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5106 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5107 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5108 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5109
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5110 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5111 * Sets the default font used on text based widgets.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5112 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5113 * fontname: Font name in Dynamic Windows format.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5114 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5115 void API dw_font_set_default(const char *fontname)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5116 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5117 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5118
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5119 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5120 * Destroys a window and all of it's children.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5121 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5122 * handle: The window handle to destroy.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5123 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5124 * DW_ERROR_NONE (0) on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5125 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5126 int API dw_window_destroy(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5127 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5128 return DW_ERROR_GENERAL;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5129 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5130
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5131 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5132 * Gets the text used for a given window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5133 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5134 * handle: Handle to the window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5135 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5136 * The text associsated with a given window or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5137 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5138 char * API dw_window_get_text(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5139 {
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5140 JNIEnv *env;
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5141
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5142 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5143 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5144 const char *utf8 = nullptr;
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5145
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5146 // First get the class that contains the method you need to call
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5147 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5148 // Get the method that you want to call
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5149 jmethodID windowGetText = env->GetMethodID(clazz, "windowGetText",
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5150 "(Landroid/view/View;)Ljava/lang/String;");
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5151 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5152 jstring result = (jstring)_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, windowGetText, handle), _DW_REFERENCE_NONE);
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5153 // Get the UTF8 string result
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5154 if(result)
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
5155 utf8 = env->GetStringUTFChars(result, nullptr);
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5156 return utf8 ? strdup(utf8) : nullptr;
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5157 }
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5158 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5159 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5160
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5161 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5162 * Sets the text used for a given window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5163 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5164 * handle: Handle to the window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5165 * text: The text associsated with a given window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5166 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5167 void API dw_window_set_text(HWND handle, const char *text)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5168 {
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5169 JNIEnv *env;
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5170
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5171 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5172 {
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5173 // Construct a String
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5174 jstring jstr = env->NewStringUTF(text);
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5175 // First get the class that contains the method you need to call
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5176 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5177 // Get the method that you want to call
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5178 jmethodID windowSetText = env->GetMethodID(clazz, "windowSetText",
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5179 "(Landroid/view/View;Ljava/lang/String;)V");
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5180 // Call the method on the object
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5181 env->CallVoidMethod(_dw_obj, windowSetText, handle, jstr);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5182 _dw_jni_check_exception(env);
2489
6c01b0132813 Android: Implement window and clipboard text setter and getters.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2488
diff changeset
5183 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5184 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5185
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5186 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5187 * Sets the text used for a given window's floating bubble help.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5188 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5189 * handle: Handle to the window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5190 * bubbletext: The text in the floating bubble tooltip.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5191 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5192 void API dw_window_set_tooltip(HWND handle, const char *bubbletext)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5193 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5194 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5195
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5196 void _dw_window_set_enabled(HWND handle, jboolean state)
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5197 {
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5198 JNIEnv *env;
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5199
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5200 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5201 {
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5202 // First get the class that contains the method you need to call
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5203 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5204 // Get the method that you want to call
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5205 jmethodID windowSetEnabled = env->GetMethodID(clazz, "windowSetEnabled",
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5206 "(Landroid/view/View;Z)V");
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5207 // Call the method on the object
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5208 env->CallVoidMethod(_dw_obj, windowSetEnabled, handle, state);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5209 _dw_jni_check_exception(env);
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5210 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5211 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5212
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5213 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5214 * Disables given window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5215 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5216 * handle: Handle to the window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5217 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5218 void API dw_window_disable(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5219 {
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5220 _dw_window_set_enabled(handle, JNI_FALSE);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5221 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5222
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5223 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5224 * Enables given window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5225 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5226 * handle: Handle to the window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5227 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5228 void API dw_window_enable(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5229 {
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5230 _dw_window_set_enabled(handle, JNI_TRUE);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5231 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5232
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5233 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5234 * Sets the bitmap used for a given static window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5235 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5236 * handle: Handle to the window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5237 * id: An ID to be used to specify the icon,
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5238 * (pass 0 if you use the filename param)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5239 * data: memory buffer containing image (Bitmap on OS/2 or
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5240 * Windows and a pixmap on Unix, pass
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5241 * nullptr if you use the id param)
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5242 * len: Length of data passed
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5243 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5244 void API dw_window_set_bitmap_from_data(HWND handle, unsigned long cid, const char *data, int len)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5245 {
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5246 JNIEnv *env;
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5247
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5248 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5249 {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5250 // Construct a byte array
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5251 jbyteArray bytearray = nullptr;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5252 if(data && len > 0)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5253 {
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5254 bytearray = env->NewByteArray(len);
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5255 env->SetByteArrayRegion(bytearray, 0, len, reinterpret_cast<const jbyte *>(data));
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5256 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5257 // First get the class that contains the method you need to call
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5258 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5259 // Get the method that you want to call
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5260 jmethodID windowSetBitmapFromData = env->GetMethodID(clazz, "windowSetBitmapFromData",
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5261 "(Landroid/view/View;I[BI)V");
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5262 // Call the method on the object
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5263 env->CallVoidMethod(_dw_obj, windowSetBitmapFromData, handle, (int)cid, bytearray, len);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5264 _dw_jni_check_exception(env);
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5265 // Clean up after the array now that we are finished
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5266 //if(bytearray)
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5267 //env->ReleaseByteArrayElements(bytearray, (jbyte *) data, 0);
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5268 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5269 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5270
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5271 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5272 * Sets the bitmap used for a given static window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5273 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5274 * handle: Handle to the window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5275 * id: An ID to be used to specify the icon,
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5276 * (pass 0 if you use the filename param)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5277 * filename: a path to a file (Bitmap on OS/2 or
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5278 * Windows and a pixmap on Unix, pass
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5279 * nullptr if you use the id param)
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5280 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5281 void API dw_window_set_bitmap(HWND handle, unsigned long resid, const char *filename)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5282 {
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5283 JNIEnv *env;
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5284
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5285 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5286 {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5287 // Construct a string
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5288 jstring jstr = nullptr;
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5289 if(filename) {
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5290 jstr = env->NewStringUTF(filename);
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5291 }
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5292 // First get the class that contains the method you need to call
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5293 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5294 // Get the method that you want to call
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5295 jmethodID windowSetBitmapFromData = env->GetMethodID(clazz, "windowSetBitmap",
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5296 "(Landroid/view/View;ILjava/lang/String;)V");
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5297 // Call the method on the object
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5298 env->CallVoidMethod(_dw_obj, windowSetBitmapFromData, handle, (int)resid, jstr);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5299 _dw_jni_check_exception(env);
2528
03f6870bcfcc Android: Implement dw_bitmap_new(), dw_dwindow_set_bitmap() and dw_window_set_bitmap_from_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2526
diff changeset
5300 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5301 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5302
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5303 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5304 * Sets the icon used for a given window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5305 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5306 * handle: Handle to the window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5307 * icon: Handle to icon to be used.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5308 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5309 void API dw_window_set_icon(HWND handle, HICN icon)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5310 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5311 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5312
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5313 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5314 * Gets the child window handle with specified ID.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5315 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5316 * handle: Handle to the parent window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5317 * id: Integer ID of the child.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5318 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5319 * HWND of window with ID or nullptr on error.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5320 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5321 HWND API dw_window_from_id(HWND handle, int id)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5322 {
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5323 JNIEnv *env;
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
5324 HWND retval = nullptr;
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5325
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5326 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5327 {
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5328 // First get the class that contains the method you need to call
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5329 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5330 // Get the method that you want to call
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5331 jmethodID windowFromId = env->GetMethodID(clazz, "windowFromId",
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5332 "(Landroid/view/View;I)Landroid/view/View;");
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5333 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5334 retval = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, windowFromId, handle, id), _DW_REFERENCE_NONE);
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5335 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5336 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5337 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5338
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5339 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5340 * Minimizes or Iconifies a top-level window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5341 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5342 * handle: The window handle to minimize.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5343 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5344 * DW_ERROR_NONE (0) on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5345 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5346 int API dw_window_minimize(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5347 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5348 return DW_ERROR_GENERAL;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5349 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5350
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5351 /* Causes entire window to be invalidated and redrawn.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5352 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5353 * handle: Toplevel window handle to be redrawn.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5354 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5355 void API dw_window_redraw(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5356 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5357 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5358
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5359 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5360 * Makes the window topmost.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5361 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5362 * handle: The window handle to make topmost.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5363 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5364 * DW_ERROR_NONE (0) on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5365 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5366 int API dw_window_raise(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5367 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5368 return DW_ERROR_GENERAL;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5369 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5370
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5371 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5372 * Makes the window bottommost.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5373 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5374 * handle: The window handle to make bottommost.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5375 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5376 * DW_ERROR_NONE (0) on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5377 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5378 int API dw_window_lower(HWND handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5379 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5380 return DW_ERROR_GENERAL;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5381 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5382
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5383 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5384 * Sets the size of a given window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5385 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5386 * handle: Window (widget) handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5387 * width: New width in pixels.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5388 * height: New height in pixels.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5389 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5390 void API dw_window_set_size(HWND handle, ULONG width, ULONG height)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5391 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5392 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5393
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5394 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5395 * Gets the size the system thinks the widget should be.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5396 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5397 * handle: Window (widget) handle of the item to query.
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5398 * width: Width in pixels of the item or nullptr if not needed.
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5399 * height: Height in pixels of the item or nullptr if not needed.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5400 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5401 void API dw_window_get_preferred_size(HWND handle, int *width, int *height)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5402 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5403 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5404
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5405 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5406 * Sets the gravity of a given window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5407 * Gravity controls which corner of the screen and window the position is relative to.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5408 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5409 * handle: Window (widget) handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5410 * horz: DW_GRAV_LEFT (default), DW_GRAV_RIGHT or DW_GRAV_CENTER.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5411 * vert: DW_GRAV_TOP (default), DW_GRAV_BOTTOM or DW_GRAV_CENTER.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5412 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5413 void API dw_window_set_gravity(HWND handle, int horz, int vert)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5414 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5415 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5416
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5417 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5418 * Sets the position of a given window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5419 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5420 * handle: Window (widget) handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5421 * x: X location from the bottom left.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5422 * y: Y location from the bottom left.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5423 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5424 void API dw_window_set_pos(HWND handle, LONG x, LONG y)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5425 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5426 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5427
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5428 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5429 * Sets the position and size of a given window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5430 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5431 * handle: Window (widget) handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5432 * x: X location from the bottom left.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5433 * y: Y location from the bottom left.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5434 * width: Width of the widget.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5435 * height: Height of the widget.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5436 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5437 void API dw_window_set_pos_size(HWND handle, LONG x, LONG y, ULONG width, ULONG height)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5438 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5439 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5440
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5441 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5442 * Gets the position and size of a given window (widget).
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5443 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5444 * handle: Window (widget) handle.
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5445 * x: X location from the bottom left or nullptr.
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5446 * y: Y location from the bottom left or nullptr.
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5447 * width: Width of the widget or nullptr.
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5448 * height: Height of the widget or nullptr.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5449 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5450 void API dw_window_get_pos_size(HWND handle, LONG *x, LONG *y, ULONG *width, ULONG *height)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5451 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5452 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5453
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5454 static jlong _dw_screen_dimensions = 0;
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5455
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5456 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5457 * Returns the width of the screen.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5458 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5459 int API dw_screen_width(void)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5460 {
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5461 if(!_dw_screen_dimensions)
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5462 {
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5463 JNIEnv *env;
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5464
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5465 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5466 {
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5467 // First get the class that contains the method you need to call
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5468 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5469 // Get the method that you want to call
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5470 jmethodID screenGetDimensions = env->GetMethodID(clazz, "screenGetDimensions",
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5471 "()J");
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5472 // Call the method on the object
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5473 _dw_screen_dimensions = env->CallLongMethod(_dw_obj, screenGetDimensions);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5474 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5475 _dw_screen_dimensions = 0;
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5476 }
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5477 }
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5478 return _dw_screen_dimensions & 0xFFFF;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5479 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5480
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5481 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5482 * Returns the height of the screen.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5483 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5484 int API dw_screen_height(void)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5485 {
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5486 if(!_dw_screen_dimensions)
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5487 {
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5488 JNIEnv *env;
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5489
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5490 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5491 {
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5492 // First get the class that contains the method you need to call
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5493 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5494 // Get the method that you want to call
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5495 jmethodID screenGetDimensions = env->GetMethodID(clazz, "screenGetDimensions",
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5496 "()J");
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5497 // Call the method on the object
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5498 _dw_screen_dimensions = env->CallLongMethod(_dw_obj, screenGetDimensions);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5499 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5500 _dw_screen_dimensions = 0;
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5501 }
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5502 }
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5503 return (_dw_screen_dimensions >> 32) & 0xFFFF;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5504 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5505
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5506 /* This should return the current color depth. */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5507 unsigned long API dw_color_depth_get(void)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5508 {
2531
f45ebd96ebe5 Android: First attempts at implementing drawing functions
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2530
diff changeset
5509 return 32;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5510 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5511
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5512 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5513 * Returns some information about the current operating environment.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5514 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5515 * env: Pointer to a DWEnv struct.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5516 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5517 void API dw_environment_query(DWEnv *env)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5518 {
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5519 static char osName[_DW_ENV_STRING_SIZE+1] = { 0 };
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5520
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5521 if(!osName[0])
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5522 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
5523 JNIEnv *jenv;
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5524 const char *release = nullptr;
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5525
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
5526 if((jenv = (JNIEnv *)pthread_getspecific(_dw_env_key)))
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5527 {
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5528 // First get the class that contains the method you need to call
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
5529 jclass clazz = _dw_find_class(jenv, DW_CLASS_NAME);
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5530 // Get the method that you want to call
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
5531 jmethodID androidGetRelease = jenv->GetMethodID(clazz, "androidGetRelease",
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5532 "()Ljava/lang/String;");
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5533 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5534 jstring jstr = (jstring)_dw_jni_check_result(jenv, jenv->CallObjectMethod(_dw_obj, androidGetRelease), _DW_REFERENCE_NONE);
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5535
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5536 if(jstr)
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
5537 release = jenv->GetStringUTFChars(jstr, nullptr);
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5538 }
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5539 snprintf(osName, _DW_ENV_STRING_SIZE-1, "Android%s%s",
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5540 release ? " " : "", release ? release : "");
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5541 }
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5542 memset(env, '\0', sizeof(DWEnv));
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5543
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5544 strncpy(env->osName, osName, sizeof(env->osName)-1);
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5545 strncpy(env->buildDate, __DATE__, sizeof(env->buildDate)-1);
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5546 strncpy(env->buildTime, __TIME__, sizeof(env->buildTime)-1);
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5547 strncpy(env->htmlEngine, "CHROME", sizeof(env->htmlEngine)-1);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5548 env->DWMajorVersion = DW_MAJOR_VERSION;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5549 env->DWMinorVersion = DW_MINOR_VERSION;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5550 env->DWSubVersion = DW_SUB_VERSION;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5551
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5552 /* Operating system major */
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5553 env->MajorVersion = _dw_android_api;
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5554 /* Operating system minor */
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
5555 env->MinorVersion = 0;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5556 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5557
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5558 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5559 * Emits a beep.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5560 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5561 * freq: Frequency.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5562 * dur: Duration.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5563 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5564 void API dw_beep(int freq, int dur)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5565 {
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5566 JNIEnv *env;
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5567
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5568 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5569 {
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5570 // First get the class that contains the method you need to call
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5571 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5572 // Get the method that you want to call
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5573 jmethodID doBeep = env->GetMethodID(clazz, "doBeep", "(I)V");
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5574 // Call the method on the object
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5575 env->CallVoidMethod(_dw_obj, doBeep, dur);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5576 _dw_jni_check_exception(env);
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5577 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5578 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5579
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5580 /* Call this after drawing to the screen to make sure
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5581 * anything you have drawn is visible.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5582 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5583 void API dw_flush(void)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5584 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5585 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5586
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5587 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5588 * Add a named user data item to a window handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5589 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5590 * window: Window handle to save data to.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5591 * dataname: A string pointer identifying which data to be saved.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5592 * data: User data to be saved to the window handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5593 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5594 void API dw_window_set_data(HWND window, const char *dataname, void *data)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5595 {
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5596 JNIEnv *env;
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5597
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5598 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5599 {
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5600 // Construct a String
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5601 jstring jstr = env->NewStringUTF(dataname);
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5602 // First get the class that contains the method you need to call
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5603 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5604 // Get the method that you want to call
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5605 jmethodID windowSetData = env->GetMethodID(clazz, "windowSetData",
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5606 "(Landroid/view/View;Ljava/lang/String;J)V");
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5607 // Call the method on the object
2518
c4e90a623437 Android: Fix not actually passing the data in dw_window_set_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
5608 env->CallVoidMethod(_dw_obj, windowSetData, window, jstr, (jlong)data);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5609 _dw_jni_check_exception(env);
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5610 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5611 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5612
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5613 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5614 * Gets a named user data item from a window handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5615 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5616 * window: Window handle to get data from.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5617 * dataname: A string pointer identifying which data to get.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5618 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5619 * Pointer to data or nullptr if no data is available.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5620 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5621 void * API dw_window_get_data(HWND window, const char *dataname)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5622 {
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5623 JNIEnv *env;
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5624 void *retval = nullptr;
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5625
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5626 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5627 {
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5628 // Construct a String
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5629 jstring jstr = env->NewStringUTF(dataname);
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5630 // First get the class that contains the method you need to call
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5631 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5632 // Get the method that you want to call
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5633 jmethodID windowGetData = env->GetMethodID(clazz, "windowGetData",
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5634 "(Landroid/view/View;Ljava/lang/String;)J");
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5635 // Call the method on the object
2518
c4e90a623437 Android: Fix not actually passing the data in dw_window_set_data().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2517
diff changeset
5636 retval = (void *)env->CallLongMethod(_dw_obj, windowGetData, window, jstr);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5637 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5638 retval = nullptr;
2488
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5639 }
666af45f33b5 Android: Implment a bunch of window functions: enable/disable/data/id
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2487
diff changeset
5640 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5641 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5642
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5643 /*
2532
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5644 * Compare two window handles.
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5645 * Parameters:
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5646 * window1: First window handle to compare.
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5647 * window2: Second window handle to compare.
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5648 * Returns:
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5649 * TRUE if the windows are the same object, FALSE if not.
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5650 */
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5651 int API dw_window_compare(HWND window1, HWND window2)
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5652 {
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5653 JNIEnv *env;
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5654 void *retval = nullptr;
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5655
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5656 if(window1 && window2 && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5657 {
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5658 if(env->IsSameObject(window1, window2))
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5659 return TRUE;
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5660 }
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5661 return FALSE;
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5662 }
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5663
457c91634881 Added dw_window_compare() to check if two window handles refer to the same object.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2531
diff changeset
5664 /*
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5665 * Add a callback to a timer event.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5666 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5667 * interval: Milliseconds to delay between calls.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5668 * sigfunc: The pointer to the function to be used as the callback.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5669 * data: User data to be passed to the handler function.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5670 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5671 * Timer ID for use with dw_timer_disconnect(), 0 on error.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5672 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5673 int API dw_timer_connect(int interval, void *sigfunc, void *data)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5674 {
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5675 JNIEnv *env;
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5676 int retval = 0;
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5677
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5678 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5679 {
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5680 // Use a long paramater
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5681 jlong longinterval = (jlong)interval;
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5682 // First get the class that contains the method you need to call
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5683 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5684 // Get the method that you want to call
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5685 jmethodID timerConnect = env->GetMethodID(clazz, "timerConnect",
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5686 "(JJJ)Ljava/util/Timer;");
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5687 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5688 retval = DW_POINTER_TO_INT(_dw_jni_check_result(env, env->CallObjectMethod(_dw_obj,
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5689 timerConnect, longinterval, (jlong)sigfunc, (jlong)data), _DW_REFERENCE_STRONG));
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5690 }
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5691 return retval;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5692 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5693
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5694 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5695 * Removes timer callback.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5696 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5697 * id: Timer ID returned by dw_timer_connect().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5698 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5699 void API dw_timer_disconnect(int timerid)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5700 {
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5701 JNIEnv *env;
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5702
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5703 if(timerid && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5704 {
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
5705 // Use a long parameter
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5706 jobject timer = (jobject)timerid;
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5707 // First get the class that contains the method you need to call
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5708 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5709 // Get the method that you want to call
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5710 jmethodID timerDisconnect = env->GetMethodID(clazz, "timerDisconnect",
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5711 "(Ljava/util/Timer;)V");
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5712 // Call the method on the object
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5713 env->CallVoidMethod(_dw_obj, timerDisconnect, timer);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5714 _dw_jni_check_exception(env);
2490
62e124eecd82 Android: Implement timers and beep. Some general code cleanup.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2489
diff changeset
5715 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5716 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5717
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5718 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5719 * Add a callback to a window event.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5720 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5721 * window: Window handle of signal to be called back.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5722 * signame: A string pointer identifying which signal to be hooked.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5723 * sigfunc: The pointer to the function to be used as the callback.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5724 * data: User data to be passed to the handler function.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5725 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5726 void API dw_signal_connect(HWND window, const char *signame, void *sigfunc, void *data)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5727 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5728 dw_signal_connect_data(window, signame, sigfunc, nullptr, data);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5729 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5730
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5731 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5732 * Add a callback to a window event with a closure callback.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5733 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5734 * window: Window handle of signal to be called back.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5735 * signame: A string pointer identifying which signal to be hooked.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5736 * sigfunc: The pointer to the function to be used as the callback.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5737 * discfunc: The pointer to the function called when this handler is removed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5738 * data: User data to be passed to the handler function.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5739 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5740 void API dw_signal_connect_data(HWND window, const char *signame, void *sigfunc, void *discfunc, void *data)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5741 {
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5742 ULONG message = 0, msgid = 0;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5743
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5744 if(window && signame && sigfunc)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5745 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5746 if((message = _dw_findsigmessage(signame)) != 0)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5747 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5748 _dw_new_signal(message, window, (int)msgid, sigfunc, discfunc, data);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5749 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5750 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5751 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5752
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5753 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5754 * Removes callbacks for a given window with given name.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5755 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5756 * window: Window handle of callback to be removed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5757 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5758 void API dw_signal_disconnect_by_name(HWND window, const char *signame)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5759 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5760 SignalHandler *prev = nullptr, *tmp = DWRoot;
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5761 ULONG message;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5762
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5763 if(!window || !signame || (message = _dw_findsigmessage(signame)) == 0)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5764 return;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5765
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5766 while(tmp)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5767 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5768 if(tmp->window == window && tmp->message == message)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5769 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5770 void (*discfunc)(HWND, void *) = (void (*)(HWND, void*))tmp->discfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5771
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5772 if(discfunc)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5773 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5774 discfunc(tmp->window, tmp->data);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5775 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5776
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5777 if(prev)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5778 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5779 prev->next = tmp->next;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5780 free(tmp);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5781 tmp = prev->next;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5782 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5783 else
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5784 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5785 DWRoot = tmp->next;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5786 free(tmp);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5787 tmp = DWRoot;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5788 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5789 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5790 else
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5791 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5792 prev = tmp;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5793 tmp = tmp->next;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5794 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5795 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5796 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5797
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5798 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5799 * Removes all callbacks for a given window.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5800 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5801 * window: Window handle of callback to be removed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5802 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5803 void API dw_signal_disconnect_by_window(HWND window)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5804 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5805 SignalHandler *prev = nullptr, *tmp = DWRoot;
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5806
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5807 while(tmp)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5808 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5809 if(tmp->window == window)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5810 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5811 void (*discfunc)(HWND, void *) = (void (*)(HWND, void*))tmp->discfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5812
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5813 if(discfunc)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5814 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5815 discfunc(tmp->window, tmp->data);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5816 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5817
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5818 if(prev)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5819 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5820 prev->next = tmp->next;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5821 free(tmp);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5822 tmp = prev->next;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5823 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5824 else
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5825 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5826 DWRoot = tmp->next;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5827 free(tmp);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5828 tmp = DWRoot;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5829 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5830 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5831 else
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5832 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5833 prev = tmp;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5834 tmp = tmp->next;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5835 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5836 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5837 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5838
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5839 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5840 * Removes all callbacks for a given window with specified data.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5841 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5842 * window: Window handle of callback to be removed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5843 * data: Pointer to the data to be compared against.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5844 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5845 void API dw_signal_disconnect_by_data(HWND window, void *data)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5846 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5847 SignalHandler *prev = nullptr, *tmp = DWRoot;
2481
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5848
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5849 while(tmp)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5850 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5851 if(tmp->window == window && tmp->data == data)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5852 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5853 void (*discfunc)(HWND, void *) = (void (*)(HWND, void*))tmp->discfunction;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5854
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5855 if(discfunc)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5856 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5857 discfunc(tmp->window, tmp->data);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5858 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5859
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5860 if(prev)
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5861 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5862 prev->next = tmp->next;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5863 free(tmp);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5864 tmp = prev->next;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5865 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5866 else
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5867 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5868 DWRoot = tmp->next;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5869 free(tmp);
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5870 tmp = DWRoot;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5871 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5872 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5873 else
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5874 {
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5875 prev = tmp;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5876 tmp = tmp->next;
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5877 }
94f0d61d6953 Android: Initial commit of signal handlers, connecting buttons to the new
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2477
diff changeset
5878 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5879 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5880
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5881 void _dw_strlwr(char *buf)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5882 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5883 int z, len = strlen(buf);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5884
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5885 for(z=0;z<len;z++)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5886 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5887 if(buf[z] >= 'A' && buf[z] <= 'Z')
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5888 buf[z] -= 'A' - 'a';
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5889 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5890 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5891
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5892 /* Open a shared library and return a handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5893 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5894 * name: Base name of the shared library.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5895 * handle: Pointer to a module handle,
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5896 * will be filled in with the handle.
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5897 */
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5898 int API dw_module_load(const char *name, HMOD *handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5899 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5900 int len;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5901 char *newname;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5902 char errorbuf[1025] = {0};
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5903
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5904
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5905 if(!handle)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5906 return -1;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5907
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5908 if((len = strlen(name)) == 0)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5909 return -1;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5910
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5911 /* Lenth + "lib" + ".so" + nullptr */
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5912 newname = (char *)malloc(len + 7);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5913
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5914 if(!newname)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5915 return -1;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5916
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5917 sprintf(newname, "lib%s.so", name);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5918 _dw_strlwr(newname);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5919
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5920 *handle = dlopen(newname, RTLD_NOW);
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5921 if(*handle == nullptr)
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5922 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5923 strncpy(errorbuf, dlerror(), 1024);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5924 printf("%s\n", errorbuf);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5925 sprintf(newname, "lib%s.so", name);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5926 *handle = dlopen(newname, RTLD_NOW);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5927 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5928
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5929 free(newname);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5930
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5931 return (nullptr == *handle) ? -1 : 0;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5932 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5933
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5934 /* Queries the address of a symbol within open handle.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5935 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5936 * handle: Module handle returned by dw_module_load()
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5937 * name: Name of the symbol you want the address of.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5938 * func: A pointer to a function pointer, to obtain
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5939 * the address.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5940 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5941 int API dw_module_symbol(HMOD handle, const char *name, void**func)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5942 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5943 if(!func || !name)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5944 return -1;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5945
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5946 if(strlen(name) == 0)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5947 return -1;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5948
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5949 *func = (void*)dlsym(handle, name);
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5950 return (nullptr == *func);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5951 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5952
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5953 /* Frees the shared library previously opened.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5954 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5955 * handle: Module handle returned by dw_module_load()
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5956 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5957 int API dw_module_close(HMOD handle)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5958 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5959 if(handle)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5960 return dlclose(handle);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5961 return 0;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5962 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5963
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5964 /*
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5965 * Returns the handle to an unnamed mutex semaphore.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5966 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5967 HMTX API dw_mutex_new(void)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5968 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5969 HMTX mutex = (HMTX)malloc(sizeof(pthread_mutex_t));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5970
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
5971 pthread_mutex_init(mutex, nullptr);
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5972 return mutex;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5973 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5974
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5975 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5976 * Closes a semaphore created by dw_mutex_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5977 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5978 * mutex: The handle to the mutex returned by dw_mutex_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5979 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5980 void API dw_mutex_close(HMTX mutex)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5981 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5982 if(mutex)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5983 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5984 pthread_mutex_destroy(mutex);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5985 free(mutex);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
5986 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5987 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
5988
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
5989 /* Check if we are on the UI thread */
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
5990 int _dw_is_ui_thread(void)
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
5991 {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
5992 JNIEnv *env;
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
5993 int retval = FALSE;
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
5994 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
5995 {
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
5996 // First get the class that contains the method you need to call
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
5997 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
5998 // Get the method that you want to call
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
5999 jmethodID isUIThread = env->GetMethodID(clazz, "isUIThread",
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
6000 "()Z");
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
6001 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
6002 retval = env->CallBooleanMethod(_dw_obj, isUIThread);
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
6003 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
6004 retval = FALSE;
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
6005 }
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
6006 return retval;
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
6007 }
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
6008
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6009 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6010 * Tries to gain access to the semaphore, if it can't it blocks.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6011 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6012 * mutex: The handle to the mutex returned by dw_mutex_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6013 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6014 void API dw_mutex_lock(HMTX mutex)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6015 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6016 /* We need to handle locks from the main thread differently...
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6017 * since we can't stop message processing... otherwise we
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6018 * will deadlock... so try to acquire the lock and continue
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6019 * processing messages in between tries.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6020 */
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
6021 if(_dw_is_ui_thread())
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6022 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6023 while(pthread_mutex_trylock(mutex) != 0)
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6024 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6025 /* Process any pending events */
2530
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
6026 dw_main_iteration();
b9923432cb1f Android: Implement View based render widget and icon support with Drawable.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2529
diff changeset
6027 sched_yield();
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6028 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6029 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6030 else
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6031 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6032 pthread_mutex_lock(mutex);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6033 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6034 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6035
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6036 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6037 * Tries to gain access to the semaphore.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6038 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6039 * mutex: The handle to the mutex returned by dw_mutex_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6040 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6041 * DW_ERROR_NONE on success, DW_ERROR_TIMEOUT if it is already locked.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6042 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6043 int API dw_mutex_trylock(HMTX mutex)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6044 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6045 if(pthread_mutex_trylock(mutex) == 0)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6046 return DW_ERROR_NONE;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6047 return DW_ERROR_TIMEOUT;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6048 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6049
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6050 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6051 * Reliquishes the access to the semaphore.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6052 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6053 * mutex: The handle to the mutex returned by dw_mutex_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6054 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6055 void API dw_mutex_unlock(HMTX mutex)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6056 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6057 pthread_mutex_unlock(mutex);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6058 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6059
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6060 /*
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6061 * Returns the handle to an unnamed event semaphore.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6062 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6063 HEV API dw_event_new(void)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6064 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6065 HEV eve = (HEV)malloc(sizeof(struct _dw_unix_event));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6066
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6067 if(!eve)
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6068 return nullptr;
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6069
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6070 /* We need to be careful here, mutexes on Linux are
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6071 * FAST by default but are error checking on other
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6072 * systems such as FreeBSD and OS/2, perhaps others.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6073 */
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6074 pthread_mutex_init (&(eve->mutex), nullptr);
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6075 pthread_mutex_lock (&(eve->mutex));
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6076 pthread_cond_init (&(eve->event), nullptr);
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6077
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6078 pthread_mutex_unlock (&(eve->mutex));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6079 eve->alive = 1;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6080 eve->posted = 0;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6081
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6082 return eve;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6083 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6084
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6085 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6086 * Resets a semaphore created by dw_event_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6087 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6088 * eve: The handle to the event returned by dw_event_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6089 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6090 int API dw_event_reset (HEV eve)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6091 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6092 if(!eve)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6093 return DW_ERROR_NON_INIT;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6094
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6095 pthread_mutex_lock (&(eve->mutex));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6096 pthread_cond_broadcast (&(eve->event));
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6097 pthread_cond_init (&(eve->event), nullptr);
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6098 eve->posted = 0;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6099 pthread_mutex_unlock (&(eve->mutex));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6100 return DW_ERROR_NONE;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6101 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6102
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6103 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6104 * Posts a semaphore created by dw_event_new(). Causing all threads
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6105 * waiting on this event in dw_event_wait to continue.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6106 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6107 * eve: The handle to the event returned by dw_event_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6108 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6109 int API dw_event_post (HEV eve)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6110 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6111 if(!eve)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6112 return DW_ERROR_NON_INIT;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6113
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6114 pthread_mutex_lock (&(eve->mutex));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6115 pthread_cond_broadcast (&(eve->event));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6116 eve->posted = 1;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6117 pthread_mutex_unlock (&(eve->mutex));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6118 return DW_ERROR_NONE;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6119 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6120
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6121 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6122 * Waits on a semaphore created by dw_event_new(), until the
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6123 * event gets posted or until the timeout expires.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6124 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6125 * eve: The handle to the event returned by dw_event_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6126 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6127 int API dw_event_wait(HEV eve, unsigned long timeout)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6128 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6129 int rc;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6130
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6131 if(!eve)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6132 return DW_ERROR_NON_INIT;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6133
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6134 pthread_mutex_lock (&(eve->mutex));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6135
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6136 if(eve->posted)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6137 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6138 pthread_mutex_unlock (&(eve->mutex));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6139 return DW_ERROR_NONE;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6140 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6141
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6142 if(timeout != -1)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6143 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6144 struct timeval now;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6145 struct timespec timeo;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6146
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
6147 gettimeofday(&now, nullptr);
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6148 timeo.tv_sec = now.tv_sec + (timeout / 1000);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6149 timeo.tv_nsec = now.tv_usec * 1000;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6150 rc = pthread_cond_timedwait(&(eve->event), &(eve->mutex), &timeo);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6151 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6152 else
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6153 rc = pthread_cond_wait(&(eve->event), &(eve->mutex));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6154
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6155 pthread_mutex_unlock (&(eve->mutex));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6156 if(!rc)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6157 return DW_ERROR_NONE;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6158 if(rc == ETIMEDOUT)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6159 return DW_ERROR_TIMEOUT;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6160 return DW_ERROR_GENERAL;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6161 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6162
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6163 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6164 * Closes a semaphore created by dw_event_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6165 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6166 * eve: The handle to the event returned by dw_event_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6167 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6168 int API dw_event_close(HEV *eve)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6169 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6170 if(!eve || !(*eve))
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6171 return DW_ERROR_NON_INIT;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6172
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6173 pthread_mutex_lock (&((*eve)->mutex));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6174 pthread_cond_destroy (&((*eve)->event));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6175 pthread_mutex_unlock (&((*eve)->mutex));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6176 pthread_mutex_destroy (&((*eve)->mutex));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6177 free(*eve);
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6178 *eve = nullptr;
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6179
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6180 return DW_ERROR_NONE;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6181 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6182
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6183 struct _dw_seminfo {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6184 int fd;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6185 int waiting;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6186 };
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6187
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6188 static void _dw_handle_sem(int *tmpsock)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6189 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6190 fd_set rd;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6191 struct _dw_seminfo *array = (struct _dw_seminfo *)malloc(sizeof(struct _dw_seminfo));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6192 int listenfd = tmpsock[0];
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6193 int bytesread, connectcount = 1, maxfd, z, posted = 0;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6194 char command;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6195 sigset_t mask;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6196
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6197 sigfillset(&mask); /* Mask all allowed signals */
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6198 pthread_sigmask(SIG_BLOCK, &mask, nullptr);
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6199
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6200 /* problems */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6201 if(tmpsock[1] == -1)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6202 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6203 free(array);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6204 return;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6205 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6206
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6207 array[0].fd = tmpsock[1];
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6208 array[0].waiting = 0;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6209
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6210 /* Free the memory allocated in dw_named_event_new. */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6211 free(tmpsock);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6212
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6213 while(1)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6214 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6215 FD_ZERO(&rd);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6216 FD_SET(listenfd, &rd);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6217 int DW_UNUSED(result);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6218
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6219 maxfd = listenfd;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6220
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6221 /* Added any connections to the named event semaphore */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6222 for(z=0;z<connectcount;z++)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6223 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6224 if(array[z].fd > maxfd)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6225 maxfd = array[z].fd;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6226
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6227 FD_SET(array[z].fd, &rd);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6228 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6229
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6230 if(select(maxfd+1, &rd, nullptr, nullptr, nullptr) == -1)
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6231 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6232 free(array);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6233 return;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6234 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6235
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6236 if(FD_ISSET(listenfd, &rd))
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6237 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6238 struct _dw_seminfo *newarray;
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
6239 int newfd = accept(listenfd, nullptr, nullptr);
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6240
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6241 if(newfd > -1)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6242 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6243 /* Add new connections to the set */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6244 newarray = (struct _dw_seminfo *)malloc(sizeof(struct _dw_seminfo)*(connectcount+1));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6245 memcpy(newarray, array, sizeof(struct _dw_seminfo)*(connectcount));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6246
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6247 newarray[connectcount].fd = newfd;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6248 newarray[connectcount].waiting = 0;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6249
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6250 connectcount++;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6251
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6252 /* Replace old array with new one */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6253 free(array);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6254 array = newarray;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6255 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6256 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6257
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6258 /* Handle any events posted to the semaphore */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6259 for(z=0;z<connectcount;z++)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6260 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6261 if(FD_ISSET(array[z].fd, &rd))
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6262 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6263 if((bytesread = read(array[z].fd, &command, 1)) < 1)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6264 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6265 struct _dw_seminfo *newarray;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6266
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6267 /* Remove this connection from the set */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6268 newarray = (struct _dw_seminfo *)malloc(sizeof(struct _dw_seminfo)*(connectcount-1));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6269 if(!z)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6270 memcpy(newarray, &array[1], sizeof(struct _dw_seminfo)*(connectcount-1));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6271 else
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6272 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6273 memcpy(newarray, array, sizeof(struct _dw_seminfo)*z);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6274 if(z!=(connectcount-1))
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6275 memcpy(&newarray[z], &array[z+1], sizeof(struct _dw_seminfo)*(z-connectcount-1));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6276 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6277 connectcount--;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6278
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6279 /* Replace old array with new one */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6280 free(array);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6281 array = newarray;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6282 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6283 else if(bytesread == 1)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6284 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6285 switch(command)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6286 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6287 case 0:
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6288 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6289 /* Reset */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6290 posted = 0;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6291 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6292 break;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6293 case 1:
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6294 /* Post */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6295 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6296 int s;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6297 char tmp = (char)0;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6298
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6299 posted = 1;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6300
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6301 for(s=0;s<connectcount;s++)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6302 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6303 /* The semaphore has been posted so
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6304 * we tell all the waiting threads to
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6305 * continue.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6306 */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6307 if(array[s].waiting)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6308 result = write(array[s].fd, &tmp, 1);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6309 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6310 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6311 break;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6312 case 2:
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6313 /* Wait */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6314 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6315 char tmp = (char)0;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6316
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6317 array[z].waiting = 1;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6318
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6319 /* If we are posted exit immeditately */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6320 if(posted)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6321 result = write(array[z].fd, &tmp, 1);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6322 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6323 break;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6324 case 3:
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6325 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6326 /* Done Waiting */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6327 array[z].waiting = 0;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6328 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6329 break;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6330 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6331 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6332 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6333 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6334 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6335 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6336
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6337 /* Using domain sockets on unix for IPC */
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6338 /* Create a named event semaphore which can be
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6339 * opened from other processes.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6340 * Parameters:
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6341 * eve: Pointer to an event handle to receive handle.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6342 * name: Name given to semaphore which can be opened
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6343 * by other processes.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6344 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6345 HEV API dw_named_event_new(const char *name)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6346 {
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
6347 struct sockaddr_un un = {0};
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6348 int ev, *tmpsock = (int *)malloc(sizeof(int)*2);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6349 DWTID dwthread;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6350
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6351 if(!tmpsock)
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6352 return nullptr;
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6353
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6354 tmpsock[0] = socket(AF_UNIX, SOCK_STREAM, 0);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6355 ev = socket(AF_UNIX, SOCK_STREAM, 0);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6356 un.sun_family=AF_UNIX;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6357 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6358 strcpy(un.sun_path, "/tmp/.dw/");
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6359 strcat(un.sun_path, name);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6360
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6361 /* just to be safe, this should be changed
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6362 * to support multiple instances.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6363 */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6364 remove(un.sun_path);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6365
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6366 bind(tmpsock[0], (struct sockaddr *)&un, sizeof(un));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6367 listen(tmpsock[0], 0);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6368 connect(ev, (struct sockaddr *)&un, sizeof(un));
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
6369 tmpsock[1] = accept(tmpsock[0], nullptr, nullptr);
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6370
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6371 if(tmpsock[0] < 0 || tmpsock[1] < 0 || ev < 0)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6372 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6373 if(tmpsock[0] > -1)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6374 close(tmpsock[0]);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6375 if(tmpsock[1] > -1)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6376 close(tmpsock[1]);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6377 if(ev > -1)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6378 close(ev);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6379 free(tmpsock);
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6380 return nullptr;
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6381 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6382
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6383 /* Create a thread to handle this event semaphore */
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6384 pthread_create(&dwthread, nullptr, (void *(*)(void *))_dw_handle_sem, (void *)tmpsock);
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6385 return (HEV)DW_INT_TO_POINTER(ev);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6386 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6387
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6388 /* Open an already existing named event semaphore.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6389 * Parameters:
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6390 * eve: Pointer to an event handle to receive handle.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6391 * name: Name given to semaphore which can be opened
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6392 * by other processes.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6393 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6394 HEV API dw_named_event_get(const char *name)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6395 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6396 struct sockaddr_un un;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6397 int ev = socket(AF_UNIX, SOCK_STREAM, 0);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6398 if(ev < 0)
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6399 return nullptr;
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6400
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6401 un.sun_family=AF_UNIX;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6402 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6403 strcpy(un.sun_path, "/tmp/.dw/");
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6404 strcat(un.sun_path, name);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6405 connect(ev, (struct sockaddr *)&un, sizeof(un));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6406 return (HEV)DW_INT_TO_POINTER(ev);
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6407 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6408
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6409 /* Resets the event semaphore so threads who call wait
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6410 * on this semaphore will block.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6411 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6412 * eve: Handle to the semaphore obtained by
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6413 * an open or create call.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6414 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6415 int API dw_named_event_reset(HEV eve)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6416 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6417 /* signal reset */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6418 char tmp = (char)0;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6419
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6420 if(DW_POINTER_TO_INT(eve) < 0)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6421 return DW_ERROR_NONE;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6422
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6423 if(write(DW_POINTER_TO_INT(eve), &tmp, 1) == 1)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6424 return DW_ERROR_NONE;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6425 return DW_ERROR_GENERAL;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6426 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6427
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6428 /* Sets the posted state of an event semaphore, any threads
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6429 * waiting on the semaphore will no longer block.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6430 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6431 * eve: Handle to the semaphore obtained by
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6432 * an open or create call.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6433 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6434 int API dw_named_event_post(HEV eve)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6435 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6436
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6437 /* signal post */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6438 char tmp = (char)1;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6439
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6440 if(DW_POINTER_TO_INT(eve) < 0)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6441 return DW_ERROR_NONE;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6442
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6443 if(write(DW_POINTER_TO_INT(eve), &tmp, 1) == 1)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6444 return DW_ERROR_NONE;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6445 return DW_ERROR_GENERAL;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6446 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6447
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6448 /* Waits on the specified semaphore until it becomes
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6449 * posted, or returns immediately if it already is posted.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6450 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6451 * eve: Handle to the semaphore obtained by
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6452 * an open or create call.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6453 * timeout: Number of milliseconds before timing out
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6454 * or -1 if indefinite.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6455 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6456 int API dw_named_event_wait(HEV eve, unsigned long timeout)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6457 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6458 fd_set rd;
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6459 struct timeval tv, *useme = nullptr;
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6460 int retval = 0;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6461 char tmp;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6462
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6463 if(DW_POINTER_TO_INT(eve) < 0)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6464 return DW_ERROR_NON_INIT;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6465
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6466 /* Set the timout or infinite */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6467 if(timeout != -1)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6468 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6469 tv.tv_sec = timeout / 1000;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6470 tv.tv_usec = timeout % 1000;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6471
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6472 useme = &tv;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6473 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6475 FD_ZERO(&rd);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6476 FD_SET(DW_POINTER_TO_INT(eve), &rd);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6477
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6478 /* Signal wait */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6479 tmp = (char)2;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6480 retval = write(DW_POINTER_TO_INT(eve), &tmp, 1);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6481
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6482 if(retval == 1)
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6483 retval = select(DW_POINTER_TO_INT(eve)+1, &rd, nullptr, nullptr, useme);
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6484
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6485 /* Signal done waiting. */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6486 tmp = (char)3;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6487 if(retval == 1)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6488 retval = write(DW_POINTER_TO_INT(eve), &tmp, 1);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6489
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6490 if(retval == 0)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6491 return DW_ERROR_TIMEOUT;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6492 else if(retval == -1)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6493 return DW_ERROR_INTERRUPT;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6494
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6495 /* Clear the entry from the pipe so
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6496 * we don't loop endlessly. :)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6497 */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6498 if(read(DW_POINTER_TO_INT(eve), &tmp, 1) == 1)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6499 return DW_ERROR_NONE;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6500 return DW_ERROR_GENERAL;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6501 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6502
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6503 /* Release this semaphore, if there are no more open
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6504 * handles on this semaphore the semaphore will be destroyed.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6505 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6506 * eve: Handle to the semaphore obtained by
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6507 * an open or create call.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6508 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6509 int API dw_named_event_close(HEV eve)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6510 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6511 /* Finally close the domain socket,
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6512 * cleanup will continue in _dw_handle_sem.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6513 */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6514 close(DW_POINTER_TO_INT(eve));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6515 return DW_ERROR_NONE;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6516 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6517
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6518 /*
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6519 * Generally an internal function called from a newly created
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6520 * thread to setup the Dynamic Windows environment for the thread.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6521 * However it is exported so language bindings can call it when
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6522 * they create threads that require access to Dynamic Windows.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6523 */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6524 void API _dw_init_thread(void)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6525 {
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
6526 JNIEnv *env;
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
6527
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6528 _dw_jvm->AttachCurrentThread(&env, nullptr);
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
6529 pthread_setspecific(_dw_env_key, env);
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6530 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6531
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6532 /*
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6533 * Generally an internal function called from a terminating
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6534 * thread to cleanup the Dynamic Windows environment for the thread.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6535 * However it is exported so language bindings can call it when
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6536 * they exit threads that require access to Dynamic Windows.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6537 */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6538 void API _dw_deinit_thread(void)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6539 {
2475
16d195d46f2a Android: Implement dw_window_new(), dw_box_new() and dw_box_pack().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2474
diff changeset
6540 _dw_jvm->DetachCurrentThread();
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6541 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6542
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6543 /*
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6544 * Setup thread independent color sets.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6545 */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6546 void _dwthreadstart(void *data)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6547 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6548 void (*threadfunc)(void *) = nullptr;
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6549 void **tmp = (void **)data;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6550
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6551 threadfunc = (void (*)(void *))tmp[0];
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6552
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6553 /* Initialize colors */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6554 _dw_init_thread();
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6555
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6556 threadfunc(tmp[1]);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6557 free(tmp);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6558
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6559 /* Free colors */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6560 _dw_deinit_thread();
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6561 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6562
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6563 /*
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6564 * Allocates a shared memory region with a name.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6565 * Parameters:
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6566 * handle: A pointer to receive a SHM identifier.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6567 * dest: A pointer to a pointer to receive the memory address.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6568 * size: Size in bytes of the shared memory region to allocate.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6569 * name: A string pointer to a unique memory name.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6570 */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6571 HSHM API dw_named_memory_new(void **dest, int size, const char *name)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6572 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6573 char namebuf[1025];
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6574 struct _dw_unix_shm *handle = (struct _dw_unix_shm *)malloc(sizeof(struct _dw_unix_shm));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6575
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6576 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6577 snprintf(namebuf, 1024, "/tmp/.dw/%s", name);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6578
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6579 if((handle->fd = open(namebuf, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR)) < 0)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6580 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6581 free(handle);
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6582 return nullptr;
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6583 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6584
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6585 if(ftruncate(handle->fd, size))
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6586 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6587 close(handle->fd);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6588 free(handle);
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6589 return nullptr;
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6590 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6591
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6592 /* attach the shared memory segment to our process's address space. */
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6593 *dest = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0);
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6594
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6595 if(*dest == MAP_FAILED)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6596 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6597 close(handle->fd);
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6598 *dest = nullptr;
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6599 free(handle);
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6600 return nullptr;
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6601 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6602
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6603 handle->size = size;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6604 handle->sid = getsid(0);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6605 handle->path = strdup(namebuf);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6606
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6607 return handle;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6608 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6609
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6610 /*
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6611 * Aquires shared memory region with a name.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6612 * Parameters:
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6613 * dest: A pointer to a pointer to receive the memory address.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6614 * size: Size in bytes of the shared memory region to requested.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6615 * name: A string pointer to a unique memory name.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6616 */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6617 HSHM API dw_named_memory_get(void **dest, int size, const char *name)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6618 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6619 char namebuf[1025];
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6620 struct _dw_unix_shm *handle = (struct _dw_unix_shm *)malloc(sizeof(struct _dw_unix_shm));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6621
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6622 mkdir("/tmp/.dw", S_IWGRP|S_IWOTH);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6623 snprintf(namebuf, 1024, "/tmp/.dw/%s", name);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6624
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6625 if((handle->fd = open(namebuf, O_RDWR)) < 0)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6626 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6627 free(handle);
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6628 return nullptr;
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6629 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6630
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6631 /* attach the shared memory segment to our process's address space. */
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6632 *dest = mmap(nullptr, size, PROT_READ | PROT_WRITE, MAP_SHARED, handle->fd, 0);
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6633
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6634 if(*dest == MAP_FAILED)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6635 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6636 close(handle->fd);
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6637 *dest = nullptr;
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6638 free(handle);
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6639 return nullptr;
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6640 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6641
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6642 handle->size = size;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6643 handle->sid = -1;
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6644 handle->path = nullptr;
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6645
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6646 return handle;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6647 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6648
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6649 /*
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6650 * Frees a shared memory region previously allocated.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6651 * Parameters:
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6652 * handle: Handle obtained from DB_named_memory_allocate.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6653 * ptr: The memory address aquired with DB_named_memory_allocate.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6654 */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6655 int API dw_named_memory_free(HSHM handle, void *ptr)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6656 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6657 struct _dw_unix_shm *h = (struct _dw_unix_shm *)handle;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6658 int rc = munmap(ptr, h->size);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6659
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6660 close(h->fd);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6661 if(h->path)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6662 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6663 /* Only remove the actual file if we are the
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6664 * creator of the file.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6665 */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6666 if(h->sid != -1 && h->sid == getsid(0))
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6667 remove(h->path);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6668 free(h->path);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6669 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6670 return rc;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6671 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6672 /*
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6673 * Creates a new thread with a starting point of func.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6674 * Parameters:
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6675 * func: Function which will be run in the new thread.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6676 * data: Parameter(s) passed to the function.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6677 * stack: Stack size of new thread (OS/2 and Windows only).
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6678 */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6679 DWTID API dw_thread_new(void *func, void *data, int stack)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6680 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6681 DWTID dwthread;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6682 void **tmp = (void **)malloc(sizeof(void *) * 2);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6683 int rc;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6684
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6685 tmp[0] = func;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6686 tmp[1] = data;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6687
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6688 rc = pthread_create(&dwthread, nullptr, (void *(*)(void *))_dwthreadstart, (void *)tmp);
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6689 if(rc == 0)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6690 return dwthread;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6691 return (DWTID)DW_ERROR_UNKNOWN;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6692 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6693
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6694 /*
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6695 * Ends execution of current thread immediately.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6696 */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6697 void API dw_thread_end(void)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6698 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6699 pthread_exit(nullptr);
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6700 }
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6701
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6702 /*
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6703 * Returns the current thread's ID.
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6704 */
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6705 DWTID API dw_thread_id(void)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6706 {
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6707 return (DWTID)pthread_self();
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6708 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6709
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6710 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6711 * Initializes the Dynamic Windows engine.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6712 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6713 * newthread: True if this is the only thread.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6714 * False if there is already a message loop running.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6715 * argc: Passed in from main()
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6716 * argv: Passed in from main()
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6717 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6718 * DW_ERROR_NONE (0) on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6719 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6720 int API dw_init(int newthread, int argc, char *argv[])
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6721 {
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6722 JNIEnv *env;
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6723
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6724 if(!_dw_app_id[0])
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6725 {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6726 /* Generate an Application ID based on the PID if all else fails. */
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6727 snprintf(_dw_app_id, _DW_APP_ID_SIZE, "%s.pid.%d", DW_APP_DOMAIN_DEFAULT, getpid());
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6728 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6729
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6730 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6731 {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6732 // Construct a String
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6733 jstring appid = env->NewStringUTF(_dw_app_id);
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6734 jstring appname = env->NewStringUTF(_dw_app_name);
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6735 // First get the class that contains the method you need to call
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6736 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6737 // Get the method that you want to call
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6738 jmethodID dwInit = env->GetMethodID(clazz, "dwInit",
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
6739 "(Ljava/lang/String;Ljava/lang/String;)I");
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6740 // Call the method on the object
2542
bb75e64e6138 Android: Implement dw_screen_* and dw_environment_query().
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2539
diff changeset
6741 _dw_android_api = env->CallIntMethod(_dw_obj, dwInit, appid, appname);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
6742 if(_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
6743 _dw_android_api = 0;
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6744 }
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6745 return DW_ERROR_NONE;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6746 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6747
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6748 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6749 * Cleanly terminates a DW session, should be signal handler safe.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6750 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6751 void API dw_shutdown(void)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6752 {
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
6753 JNIEnv *env;
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
6754
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
6755 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
6756 {
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
6757 // First get the class that contains the method you need to call
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
6758 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
6759 // Get the method that you want to call
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
6760 jmethodID dwindowsShutdown = env->GetMethodID(clazz, "dwindowsShutdown",
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
6761 "()V");
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
6762 // Call the method on the object
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
6763 env->CallVoidMethod(_dw_obj, dwindowsShutdown);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
6764 _dw_jni_check_exception(env);
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
6765 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6766 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6767
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6768 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6769 * Execute and external program in a seperate session.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6770 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6771 * program: Program name with optional path.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6772 * type: Either DW_EXEC_CON or DW_EXEC_GUI.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6773 * params: An array of pointers to string arguements.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6774 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6775 * Process ID on success or DW_ERROR_UNKNOWN (-1) on error.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6776 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6777 int API dw_exec(const char *program, int type, char **params)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6778 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6779 int ret = DW_ERROR_UNKNOWN;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6780
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6781 return ret;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6782 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6783
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6784 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6785 * Loads a web browser pointed at the given URL.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6786 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6787 * url: Uniform resource locator.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6788 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6789 * DW_ERROR_UNKNOWN (-1) on error; DW_ERROR_NONE (0) or a positive Process ID on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6790 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6791 int API dw_browse(const char *url)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6792 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6793 return DW_ERROR_UNKNOWN;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6794 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6795
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6796 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6797 * Creates a new print object.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6798 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6799 * jobname: Name of the print job to show in the queue.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6800 * flags: Flags to initially configure the print object.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6801 * pages: Number of pages to print.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6802 * drawfunc: The pointer to the function to be used as the callback.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6803 * drawdata: User data to be passed to the handler function.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6804 * Returns:
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6805 * A handle to the print object or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6806 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6807 HPRINT API dw_print_new(const char *jobname, unsigned long flags, unsigned int pages, void *drawfunc, void *drawdata)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6808 {
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6809 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6810 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6811
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6812 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6813 * Runs the print job, causing the draw page callbacks to fire.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6814 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6815 * print: Handle to the print object returned by dw_print_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6816 * flags: Flags to run the print job.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6817 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6818 * DW_ERROR_UNKNOWN on error or DW_ERROR_NONE on success.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6819 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6820 int API dw_print_run(HPRINT print, unsigned long flags)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6821 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6822 return DW_ERROR_UNKNOWN;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6823 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6824
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6825 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6826 * Cancels the print job, typically called from a draw page callback.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6827 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6828 * print: Handle to the print object returned by dw_print_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6829 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6830 void API dw_print_cancel(HPRINT print)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6831 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6832 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6833
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6834 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6835 * Creates a new system notification if possible.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6836 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6837 * title: The short title of the notification.
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6838 * imagepath: Path to an image to display or nullptr if none.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6839 * description: A longer description of the notification,
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6840 * or nullptr if none is necessary.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6841 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6842 * A handle to the notification which can be used to attach a "clicked" event if desired,
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6843 * or nullptr if it fails or notifications are not supported by the system.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6844 * Remarks:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6845 * This will create a system notification that will show in the notifaction panel
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6846 * on supported systems, which may be clicked to perform another task.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6847 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6848 HWND API dw_notification_new(const char *title, const char *imagepath, const char *description, ...)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6849 {
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6850 JNIEnv *env;
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6851
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6852 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6853 {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6854 // Construct a String
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6855 jstring appid = env->NewStringUTF(_dw_app_id);
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6856 jstring ntitle = env->NewStringUTF(title);
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6857 jstring ndesc = nullptr;
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6858 jstring image = nullptr;
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6859
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6860 if(description)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6861 {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6862 va_list args;
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6863 char outbuf[1025] = {0};
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6864
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6865 va_start(args, description);
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6866 vsnprintf(outbuf, 1024, description, args);
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6867 va_end(args);
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6868
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6869 ndesc = env->NewStringUTF(outbuf);
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6870 }
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6871 if(imagepath)
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6872 image = env->NewStringUTF(imagepath);
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6873
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6874 // First get the class that contains the method you need to call
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6875 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6876 // Get the method that you want to call
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6877 jmethodID notificationNew = env->GetMethodID(clazz, "notificationNew",
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6878 "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Landroidx/core/app/NotificationCompat$Builder;");
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6879 // Call the method on the object
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
6880 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, notificationNew, ntitle, image, ndesc, appid), _DW_REFERENCE_WEAK);
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6881 return result;
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6882 }
2556
d2d8c66ad062 Android: Initial container implementation... getting a NullPointerException crash in dwtest...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2551
diff changeset
6883 return nullptr;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6884 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6885
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6886 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6887 * Sends a notification created by dw_notification_new() after attaching signal handler.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6888 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6889 * notification: The handle to the notification returned by dw_notification_new().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6890 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6891 * DW_ERROR_NONE on success, DW_ERROR_UNKNOWN on error or not supported.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6892 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6893 int API dw_notification_send(HWND notification)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6894 {
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6895 JNIEnv *env;
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6896
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6897 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6898 {
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6899 // First get the class that contains the method you need to call
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6900 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6901 // Get the method that you want to call
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6902 jmethodID notificationNew = env->GetMethodID(clazz, "notificationSend",
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6903 "(Landroidx/core/app/NotificationCompat$Builder;)V");
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6904 // Call the method on the object
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6905 env->CallVoidMethod(_dw_obj, notificationNew, notification);
2557
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
6906 if(!_dw_jni_check_exception(env))
756331246f94 Android: Implement Java exception handling, make sure all return values from JNI are sane.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2556
diff changeset
6907 return DW_ERROR_NONE;
2522
66c490aa719d Android: Implement notifications, images on notifications incomplete.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2521
diff changeset
6908 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6909 return DW_ERROR_UNKNOWN;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6910 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6911
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6912 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6913 * Converts a UTF-8 encoded string into a wide string.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6914 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6915 * utf8string: UTF-8 encoded source string.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6916 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6917 * Wide string that needs to be freed with dw_free()
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6918 * or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6919 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6920 wchar_t * API dw_utf8_to_wchar(const char *utf8string)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6921 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6922 size_t buflen = strlen(utf8string) + 1;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6923 wchar_t *temp = (wchar_t *)malloc(buflen * sizeof(wchar_t));
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6924 if(temp)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6925 mbstowcs(temp, utf8string, buflen);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6926 return temp;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6927 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6928
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6929 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6930 * Converts a wide string into a UTF-8 encoded string.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6931 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6932 * wstring: Wide source string.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6933 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6934 * UTF-8 encoded string that needs to be freed with dw_free()
2529
060fdb2d807d Android: Initial pixmap implmentation using Android Bitmap.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2528
diff changeset
6935 * or nullptr on failure.
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6936 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6937 char * API dw_wchar_to_utf8(const wchar_t *wstring)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6938 {
2474
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6939 size_t bufflen = 8 * wcslen(wstring) + 1;
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6940 char *temp = (char *)malloc(bufflen);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6941 if(temp)
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6942 wcstombs(temp, wstring, bufflen);
a13e6db064f4 Android: Implement thread, semaphore, shared memory API functions.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2473
diff changeset
6943 return temp;
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6944 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6945
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6946 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6947 * Gets the state of the requested library feature.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6948 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6949 * feature: The requested feature for example DW_FEATURE_DARK_MODE
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6950 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6951 * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6952 * DW_FEATURE_DISABLED if the feature is supported but disabled.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6953 * DW_FEATURE_ENABLED if the feature is supported and enabled.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6954 * Other value greater than 1, same as enabled but with extra info.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6955 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6956 int API dw_feature_get(DWFEATURE feature)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6957 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6958 switch(feature)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6959 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6960 case DW_FEATURE_HTML: /* Supports the HTML Widget */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6961 case DW_FEATURE_HTML_RESULT: /* Supports the DW_SIGNAL_HTML_RESULT callback */
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
6962 case DW_FEATURE_NOTIFICATION: /* Supports sending system notifications */
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
6963 case DW_FEATURE_UTF8_UNICODE: /* Supports UTF8 encoded Unicode text */
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6964 case DW_FEATURE_MLE_WORD_WRAP: /* Supports word wrapping in Multi-line Edit boxes */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6965 case DW_FEATURE_CONTAINER_STRIPE: /* Supports striped line display in container widgets */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6966 return DW_FEATURE_ENABLED;
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
6967 case DW_FEATURE_DARK_MODE: /* Supports Dark Mode user interface */
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
6968 {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
6969 /* Dark Mode on Android requires Android 10 (API 29) */
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
6970 if(_dw_android_api >= 29) {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
6971 return _dw_dark_mode_detected();
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
6972 }
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
6973 return DW_FEATURE_UNSUPPORTED;
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
6974 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6975 default:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6976 return DW_FEATURE_UNSUPPORTED;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6977 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6978 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6979
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6980 /*
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6981 * Sets the state of the requested library feature.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6982 * Parameters:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6983 * feature: The requested feature for example DW_FEATURE_DARK_MODE
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6984 * state: DW_FEATURE_DISABLED, DW_FEATURE_ENABLED or any value greater than 1.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6985 * Returns:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6986 * DW_FEATURE_UNSUPPORTED if the library or OS does not support the feature.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6987 * DW_ERROR_NONE if the feature is supported and successfully configured.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6988 * DW_ERROR_GENERAL if the feature is supported but could not be configured.
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6989 * Remarks:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6990 * These settings are typically used during dw_init() so issue before
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6991 * setting up the library with dw_init().
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6992 */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6993 int API dw_feature_set(DWFEATURE feature, int state)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6994 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6995 switch(feature)
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6996 {
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6997 /* These features are supported but not configurable */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6998 case DW_FEATURE_HTML: /* Supports the HTML Widget */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
6999 case DW_FEATURE_HTML_RESULT: /* Supports the DW_SIGNAL_HTML_RESULT callback */
2494
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
7000 case DW_FEATURE_NOTIFICATION: /* Supports sending system notifications */
b3e28eed0e50 Android: Fix the basics of notebook control... return actual page IDs.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2493
diff changeset
7001 case DW_FEATURE_UTF8_UNICODE: /* Supports UTF8 encoded Unicode text */
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7002 case DW_FEATURE_MLE_WORD_WRAP: /* Supports word wrapping in Multi-line Edit boxes */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7003 case DW_FEATURE_CONTAINER_STRIPE: /* Supports striped line display in container widgets */
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7004 return DW_ERROR_GENERAL;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7005 /* These features are supported and configurable */
2551
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
7006 case DW_FEATURE_DARK_MODE: /* Supports Dark Mode user interface */
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
7007 {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
7008 /* Dark Mode on Android requires 10 (API 29) */
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
7009 if(_dw_android_api >= 29) {
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
7010 /* While technically configurable....
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
7011 * for now just return DW_ERROR_GENERAL
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
7012 */
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
7013 return DW_ERROR_GENERAL;
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
7014 }
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
7015 return DW_FEATURE_UNSUPPORTED;
127779860ac1 Android: Implement DW_CLR_DEFAULT and some basic dark mode support.
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents: 2548
diff changeset
7016 }
2473
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7017 default:
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7018 return DW_FEATURE_UNSUPPORTED;
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7019 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7020 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7021
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7022 #ifdef __cplusplus
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7023 }
aa420e366b2b Android: Initial skeletal commit for Android support, almost nothing implemented...
bsmith@81767d24-ef19-dc11-ae90-00e081727c95
parents:
diff changeset
7024 #endif