comparison ios/dw.m @ 2792:9c6fdafd10be

iOS: Implement dw_window_get_text() on top-level windows. Simplify, remove redundant code and remove deprecated code.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 14 Jul 2022 06:02:01 +0000
parents b62859fbd9a3
children 24977a1ec6fc
comparison
equal deleted inserted replaced
2791:b62859fbd9a3 2792:9c6fdafd10be
9506 DW_FUNCTION_RESTORE_PARAM1(handle, HWND) 9506 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
9507 { 9507 {
9508 DW_FUNCTION_INIT; 9508 DW_FUNCTION_INIT;
9509 id object = _dw_text_handle(handle); 9509 id object = _dw_text_handle(handle);
9510 id control = handle; 9510 id control = handle;
9511 NSString *nsstr = nil;
9511 char *retval = NULL; 9512 char *retval = NULL;
9512 9513
9513 if([control isKindOfClass:[UIButton class]]) 9514 if([control isKindOfClass:[UIButton class]])
9514 { 9515 {
9515 NSString *nsstr = [control titleForState:UIControlStateNormal]; 9516 nsstr = [control titleForState:UIControlStateNormal];
9516 9517 }
9518 else if([object isKindOfClass:[UILabel class]] || [object isKindOfClass:[UITextField class]])
9519 {
9520 nsstr = [object text];
9521 }
9522 else if([object isMemberOfClass:[DWWindow class]])
9523 {
9524 DWWindow *window = object;
9525 UIView *view = [[window rootViewController] view];
9526 NSArray *array = [view subviews];
9527
9528 for(id obj in array)
9529 {
9530 if([obj isMemberOfClass:[UINavigationBar class]])
9531 {
9532 UINavigationBar *nav = obj;
9533 UINavigationItem *item = [[nav items] firstObject];
9534
9535 nsstr = [item title];
9536 }
9537 }
9538 }
9539 if(nsstr && [nsstr length] > 0)
9517 retval = strdup([nsstr UTF8String]); 9540 retval = strdup([nsstr UTF8String]);
9518 }
9519 else if([object isKindOfClass:[UILabel class]] || [object isKindOfClass:[UITextField class]])
9520 {
9521 NSString *nsstr = [object text];
9522
9523 retval = strdup([nsstr UTF8String]);
9524 }
9525 #ifdef DW_INCLUDE_DEPRECATED
9526 else if([object isKindOfClass:[UIControl class]])
9527 {
9528 UIControl *control = object;
9529 NSString *nsstr = [control text];
9530
9531 if(nsstr && [nsstr length] > 0)
9532 retval = strdup([nsstr UTF8String]);
9533 }
9534 #endif
9535 DW_FUNCTION_RETURN_THIS(retval); 9541 DW_FUNCTION_RETURN_THIS(retval);
9536 } 9542 }
9537 9543
9538 /* 9544 /*
9539 * Sets the text used for a given window. 9545 * Sets the text used for a given window.
9579 9585
9580 [item setTitle:nstr]; 9586 [item setTitle:nstr];
9581 } 9587 }
9582 } 9588 }
9583 } 9589 }
9584 #ifdef DW_INCLUDE_DEPRECATED
9585 else if([object isKindOfClass:[UIControl class]])
9586 {
9587 UIControl *control = object;
9588 [control setText:[NSString stringWithUTF8String:text]];
9589 item = _dw_box_item(handle);
9590 }
9591 #endif
9592 /* If we changed the text... 9590 /* If we changed the text...
9593 * Check to see if any of the sizes need to be recalculated 9591 * Check to see if any of the sizes need to be recalculated
9594 */ 9592 */
9595 if(item && (item->origwidth == DW_SIZE_AUTO || item->origheight == DW_SIZE_AUTO)) 9593 if(item && (item->origwidth == DW_SIZE_AUTO || item->origheight == DW_SIZE_AUTO))
9596 { 9594 {