Mercurial > dwindows
changeset 2714:26bb1e4a97d0
Android: Add glue to bring up the color wheel when calling dw_color_choose().
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Fri, 03 Dec 2021 20:21:13 +0000 |
parents | 6594bb323ab5 |
children | e9ad53d2271b |
files | android/DWindows.kt android/dw.cpp |
diffstat | 2 files changed, 36 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/android/DWindows.kt Fri Dec 03 00:00:28 2021 +0000 +++ b/android/DWindows.kt Fri Dec 03 20:21:13 2021 +0000 @@ -5071,6 +5071,23 @@ return retval } + fun colorChoose(color: Int, alpha: Int, red: Int, green: Int, blue: Int): Int + { + var retval: Int = 0 + + waitOnUiThread { + val dialog = Dialog(this) + val colorWheel = ColorWheel(this, null, 0) + + dialog.setContentView(colorWheel) + colorWheel.rgb = Color.rgb(red, green, blue) + dialog.window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT) + dialog.show() + retval = colorWheel.rgb + } + return retval + } + fun messageBox(title: String, body: String, flags: Int): Int { var retval = 0
--- a/android/dw.cpp Fri Dec 03 00:00:28 2021 +0000 +++ b/android/dw.cpp Fri Dec 03 20:21:13 2021 +0000 @@ -2966,8 +2966,25 @@ */ unsigned long API dw_color_choose(unsigned long value) { - /* TODO: Implement this */ - return value; + JNIEnv *env; + unsigned long newcolor = value; + + if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) + { + unsigned long _value = _dw_get_color(value); + + // First get the class that contains the method you need to call + jclass clazz = _dw_find_class(env, DW_CLASS_NAME); + // Get the method that you want to call + jmethodID colorChoose = env->GetMethodID(clazz, "colorChoose", + "(IIIII)I"); + // Call the method on the object + newcolor = (unsigned long)env->CallIntMethod(_dw_obj, colorChoose, (jint)value, 0, + (jint)DW_RED_VALUE(_value), (jint)DW_GREEN_VALUE(_value), (jint)DW_BLUE_VALUE(_value)); + if(!_dw_jni_check_exception(env)) + return value; + } + return newcolor; } /* Draw a point on a window (preferably a render window).