comparison android/dw.cpp @ 2686:95f61d3f3d0d

Android: Initial attempt at implmenting dw_window_get_preferred_size(). This function missing was causing layout issues in code using this function. The SeekBar (slider/scrollbar/etc) code seems to be backwards but it works this way.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 27 Oct 2021 22:00:31 +0000
parents a7868380098f
children 42ff9d95e87b
comparison
equal deleted inserted replaced
2685:17c34bdaec6c 2686:95f61d3f3d0d
5791 * width: Width in pixels of the item or nullptr if not needed. 5791 * width: Width in pixels of the item or nullptr if not needed.
5792 * height: Height in pixels of the item or nullptr if not needed. 5792 * height: Height in pixels of the item or nullptr if not needed.
5793 */ 5793 */
5794 void API dw_window_get_preferred_size(HWND handle, int *width, int *height) 5794 void API dw_window_get_preferred_size(HWND handle, int *width, int *height)
5795 { 5795 {
5796 if(width || height)
5797 {
5798 JNIEnv *env;
5799
5800 if(handle && (env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
5801 {
5802 // First get the class that contains the method you need to call
5803 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
5804 // Get the method that you want to call
5805 jmethodID windowGetPreferredSize = env->GetMethodID(clazz, "windowGetPreferredSize",
5806 "(Landroid/view/View;)J");
5807 // Call the method on the object
5808 jlong dimensions = env->CallLongMethod(_dw_obj, windowGetPreferredSize, handle);
5809 if(_dw_jni_check_exception(env))
5810 dimensions = 0;
5811 if(width)
5812 *width = (int)((dimensions >> 32) & 0xFFFF);
5813 if(height)
5814 *height = (int)(dimensions & 0xFFFF);
5815 }
5816 else
5817 {
5818 if(width)
5819 *width = 0;
5820 if(height)
5821 *height = 0;
5822 }
5823 }
5796 } 5824 }
5797 5825
5798 /* 5826 /*
5799 * Sets the gravity of a given window (widget). 5827 * Sets the gravity of a given window (widget).
5800 * Gravity controls which corner of the screen and window the position is relative to. 5828 * Gravity controls which corner of the screen and window the position is relative to.