Mercurial > dwindows
comparison android/dw.cpp @ 2650:7101b5692601
Android: Attempt at implementing splitbar using ConstraintLayout.
Getting errors with the layout with HandyFTP, but I need to switch locations...
so committing unfinished.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Tue, 14 Sep 2021 05:53:51 +0000 |
parents | 22105f99dd6a |
children | 9535f533a230 |
comparison
equal
deleted
inserted
replaced
2649:76d876c441c9 | 2650:7101b5692601 |
---|---|
4102 * Returns: | 4102 * Returns: |
4103 * A handle to a splitbar window or nullptr on failure. | 4103 * A handle to a splitbar window or nullptr on failure. |
4104 */ | 4104 */ |
4105 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long cid) | 4105 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long cid) |
4106 { | 4106 { |
4107 JNIEnv *env; | |
4108 | |
4109 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | |
4110 { | |
4111 // First get the class that contains the method you need to call | |
4112 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | |
4113 // Get the method that you want to call | |
4114 jmethodID splitBarNew = env->GetMethodID(clazz, "splitBarNew", | |
4115 "(ILandroid/view/View;Landroid/view/View;I)Landroidx/constraintlayout/widget/ConstraintLayout;"); | |
4116 // Call the method on the object | |
4117 jobject result = _dw_jni_check_result(env, env->CallObjectMethod(_dw_obj, splitBarNew, type, topleft, bottomright, (int)cid), _DW_REFERENCE_WEAK); | |
4118 return result; | |
4119 } | |
4107 return nullptr; | 4120 return nullptr; |
4108 } | 4121 } |
4109 | 4122 |
4110 /* | 4123 /* |
4111 * Sets the position of a splitbar (pecentage). | 4124 * Sets the position of a splitbar (pecentage). |
4113 * handle: The handle to the splitbar returned by dw_splitbar_new(). | 4126 * handle: The handle to the splitbar returned by dw_splitbar_new(). |
4114 * percent: The position of the splitbar. | 4127 * percent: The position of the splitbar. |
4115 */ | 4128 */ |
4116 void API dw_splitbar_set(HWND handle, float percent) | 4129 void API dw_splitbar_set(HWND handle, float percent) |
4117 { | 4130 { |
4131 JNIEnv *env; | |
4132 | |
4133 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | |
4134 { | |
4135 jfloat position = (jfloat)percent; | |
4136 // First get the class that contains the method you need to call | |
4137 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | |
4138 // Get the method that you want to call | |
4139 jmethodID splitBarSet = env->GetMethodID(clazz, "splitBarSet", | |
4140 "(Landroidx/constraintlayout/widget/ConstraintLayout;F)V"); | |
4141 // Call the method on the object | |
4142 env->CallVoidMethod(_dw_obj, splitBarSet, handle, position); | |
4143 _dw_jni_check_exception(env); | |
4144 } | |
4118 } | 4145 } |
4119 | 4146 |
4120 /* | 4147 /* |
4121 * Gets the position of a splitbar (pecentage). | 4148 * Gets the position of a splitbar (pecentage). |
4122 * Parameters: | 4149 * Parameters: |
4124 * Returns: | 4151 * Returns: |
4125 * Position of the splitbar (percentage). | 4152 * Position of the splitbar (percentage). |
4126 */ | 4153 */ |
4127 float API dw_splitbar_get(HWND handle) | 4154 float API dw_splitbar_get(HWND handle) |
4128 { | 4155 { |
4129 return 0; | 4156 JNIEnv *env; |
4157 float retval = 0; | |
4158 | |
4159 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key))) | |
4160 { | |
4161 // First get the class that contains the method you need to call | |
4162 jclass clazz = _dw_find_class(env, DW_CLASS_NAME); | |
4163 // Get the method that you want to call | |
4164 jmethodID splitBarGet = env->GetMethodID(clazz, "splitBarGet", | |
4165 "(Landroidx/constraintlayout/widget/ConstraintLayout;)F"); | |
4166 // Call the method on the object | |
4167 retval = (float)env->CallFloatMethod(_dw_obj, splitBarGet, handle); | |
4168 if(_dw_jni_check_exception(env)) | |
4169 retval = 0; | |
4170 } | |
4171 return retval; | |
4130 } | 4172 } |
4131 | 4173 |
4132 /* | 4174 /* |
4133 * Create a bitmap object to be packed. | 4175 * Create a bitmap object to be packed. |
4134 * Parameters: | 4176 * Parameters: |