comparison android/dw.cpp @ 2488:666af45f33b5

Android: Implment a bunch of window functions: enable/disable/data/id Add basic structure for the notebook control.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 30 Apr 2021 00:51:33 +0000
parents 83f8f4f58a98
children 6c01b0132813
comparison
equal deleted inserted replaced
2487:83f8f4f58a98 2488:666af45f33b5
899 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad) 899 void API dw_box_pack_start(HWND box, HWND item, int width, int height, int hsize, int vsize, int pad)
900 { 900 {
901 /* 65536 is the table limit on GTK... 901 /* 65536 is the table limit on GTK...
902 * seems like a high enough value we will never hit it here either. 902 * seems like a high enough value we will never hit it here either.
903 */ 903 */
904 _dw_box_pack(box, item, 65536, width, height, hsize, vsize, pad, "dw_box_pack_start()"); 904 _dw_box_pack(box, item, -1, width, height, hsize, vsize, pad, "dw_box_pack_start()");
905 } 905 }
906 906
907 /* 907 /*
908 * Pack windows (widgets) into a box from the end (or bottom). 908 * Pack windows (widgets) into a box from the end (or bottom).
909 * Parameters: 909 * Parameters:
3138 */ 3138 */
3139 void API dw_window_set_tooltip(HWND handle, const char *bubbletext) 3139 void API dw_window_set_tooltip(HWND handle, const char *bubbletext)
3140 { 3140 {
3141 } 3141 }
3142 3142
3143 void _dw_window_set_enabled(HWND handle, jboolean state)
3144 {
3145 JNIEnv *env;
3146
3147 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
3148 {
3149 // First get the class that contains the method you need to call
3150 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
3151 // Get the method that you want to call
3152 jmethodID windowSetEnabled = env->GetMethodID(clazz, "windowSetEnabled",
3153 "(Landroid/view/View;Z)V");
3154 // Call the method on the object
3155 env->CallVoidMethod(_dw_obj, windowSetEnabled, handle, state);
3156 }
3157 }
3158
3143 /* 3159 /*
3144 * Disables given window (widget). 3160 * Disables given window (widget).
3145 * Parameters: 3161 * Parameters:
3146 * handle: Handle to the window. 3162 * handle: Handle to the window.
3147 */ 3163 */
3148 void API dw_window_disable(HWND handle) 3164 void API dw_window_disable(HWND handle)
3149 { 3165 {
3166 _dw_window_set_enabled(handle, JNI_FALSE);
3150 } 3167 }
3151 3168
3152 /* 3169 /*
3153 * Enables given window (widget). 3170 * Enables given window (widget).
3154 * Parameters: 3171 * Parameters:
3155 * handle: Handle to the window. 3172 * handle: Handle to the window.
3156 */ 3173 */
3157 void API dw_window_enable(HWND handle) 3174 void API dw_window_enable(HWND handle)
3158 { 3175 {
3176 _dw_window_set_enabled(handle, JNI_TRUE);
3159 } 3177 }
3160 3178
3161 /* 3179 /*
3162 * Sets the bitmap used for a given static window. 3180 * Sets the bitmap used for a given static window.
3163 * Parameters: 3181 * Parameters:
3205 * Returns: 3223 * Returns:
3206 * HWND of window with ID or NULL on error. 3224 * HWND of window with ID or NULL on error.
3207 */ 3225 */
3208 HWND API dw_window_from_id(HWND handle, int id) 3226 HWND API dw_window_from_id(HWND handle, int id)
3209 { 3227 {
3210 return 0; 3228 JNIEnv *env;
3229 HWND retval = 0;
3230
3231 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
3232 {
3233 // First get the class that contains the method you need to call
3234 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
3235 // Get the method that you want to call
3236 jmethodID windowFromId = env->GetMethodID(clazz, "windowFromId",
3237 "(Landroid/view/View;I)Landroid/view/View;");
3238 // Call the method on the object
3239 retval = env->CallObjectMethod(_dw_obj, windowFromId, handle, id);
3240 }
3241 return retval;
3211 } 3242 }
3212 3243
3213 /* 3244 /*
3214 * Minimizes or Iconifies a top-level window. 3245 * Minimizes or Iconifies a top-level window.
3215 * Parameters: 3246 * Parameters:
3392 * dataname: A string pointer identifying which data to be saved. 3423 * dataname: A string pointer identifying which data to be saved.
3393 * data: User data to be saved to the window handle. 3424 * data: User data to be saved to the window handle.
3394 */ 3425 */
3395 void API dw_window_set_data(HWND window, const char *dataname, void *data) 3426 void API dw_window_set_data(HWND window, const char *dataname, void *data)
3396 { 3427 {
3428 JNIEnv *env;
3429
3430 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
3431 {
3432 // Construct a String
3433 jstring jstr = env->NewStringUTF(dataname);
3434 // First get the class that contains the method you need to call
3435 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
3436 // Get the method that you want to call
3437 jmethodID windowSetData = env->GetMethodID(clazz, "windowSetData",
3438 "(Landroid/view/View;Ljava/lang/String;J)V");
3439 // Call the method on the object
3440 env->CallVoidMethod(_dw_obj, windowSetData, window, jstr);
3441 }
3397 } 3442 }
3398 3443
3399 /* 3444 /*
3400 * Gets a named user data item from a window handle. 3445 * Gets a named user data item from a window handle.
3401 * Parameters: 3446 * Parameters:
3404 * Returns: 3449 * Returns:
3405 * Pointer to data or NULL if no data is available. 3450 * Pointer to data or NULL if no data is available.
3406 */ 3451 */
3407 void * API dw_window_get_data(HWND window, const char *dataname) 3452 void * API dw_window_get_data(HWND window, const char *dataname)
3408 { 3453 {
3409 return NULL; 3454 JNIEnv *env;
3455 void *retval = NULL;
3456
3457 if((env = (JNIEnv *)pthread_getspecific(_dw_env_key)))
3458 {
3459 // Construct a String
3460 jstring jstr = env->NewStringUTF(dataname);
3461 // First get the class that contains the method you need to call
3462 jclass clazz = _dw_find_class(env, DW_CLASS_NAME);
3463 // Get the method that you want to call
3464 jmethodID windowGetData = env->GetMethodID(clazz, "windowGetData",
3465 "(Landroid/view/View;Ljava/lang/String;)J");
3466 // Call the method on the object
3467 retval = DW_INT_TO_POINTER(env->CallLongMethod(_dw_obj, windowGetData, window, jstr));
3468 }
3469 return retval;
3410 } 3470 }
3411 3471
3412 /* 3472 /*
3413 * Add a callback to a timer event. 3473 * Add a callback to a timer event.
3414 * Parameters: 3474 * Parameters: