comparison ios/dw.m @ 2591:f3d423cdbc2e

iOS: Collection of various fixes... UIButtonTypeRoundedRect is deprecated use UIButtonTypeSystem for text buttons. Use UIButtonTypeCustom for bitmap buttons so it doesn't tint the images. Fix error in the timer disconnect handler from the HTIMER change. Set the largetContentTitle with dw_window_set_text() on DWWindow along with changing the navigation bar title if it exists.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 25 May 2021 15:15:09 +0000
parents e879afecf3ab
children cc2befdc97e8
comparison
equal deleted inserted replaced
2590:8352c38bc20b 2591:f3d423cdbc2e
346 case 0: 346 case 0:
347 { 347 {
348 int (* API timerfunc)(void *) = (int (* API)(void *))handler->signalfunction; 348 int (* API timerfunc)(void *) = (int (* API)(void *))handler->signalfunction;
349 349
350 if(!timerfunc(handler->data)) 350 if(!timerfunc(handler->data))
351 dw_timer_disconnect(handler->id); 351 dw_timer_disconnect(handler->window);
352 return 0; 352 return 0;
353 } 353 }
354 /* Configure/Resize event */ 354 /* Configure/Resize event */
355 case 1: 355 case 1:
356 { 356 {
4079 _dw_box_pack(box, item, 0, width, height, hsize, vsize, pad, "dw_box_pack_end()"); 4079 _dw_box_pack(box, item, 0, width, height, hsize, vsize, pad, "dw_box_pack_end()");
4080 DW_FUNCTION_RETURN_NOTHING; 4080 DW_FUNCTION_RETURN_NOTHING;
4081 } 4081 }
4082 4082
4083 /* Internal function to create a basic button, used by all button types */ 4083 /* Internal function to create a basic button, used by all button types */
4084 HWND _dw_internal_button_new(const char *text, ULONG cid) 4084 HWND _dw_internal_button_new(const char *text, ULONG cid, UIButtonType type)
4085 { 4085 {
4086 DWButton *button = [[DWButton buttonWithType:UIButtonTypeRoundedRect] retain]; 4086 DWButton *button = [[DWButton buttonWithType:type] retain];
4087 if(text) 4087 if(text)
4088 { 4088 {
4089 [button setTitle:[NSString stringWithUTF8String:text] forState:UIControlStateNormal]; 4089 [button setTitle:[NSString stringWithUTF8String:text] forState:UIControlStateNormal];
4090 } 4090 }
4091 [button addTarget:button 4091 [button addTarget:button
4108 DW_FUNCTION_DEFINITION(dw_button_new, HWND, const char *text, ULONG cid) 4108 DW_FUNCTION_DEFINITION(dw_button_new, HWND, const char *text, ULONG cid)
4109 DW_FUNCTION_ADD_PARAM2(text, cid) 4109 DW_FUNCTION_ADD_PARAM2(text, cid)
4110 DW_FUNCTION_RETURN(dw_button_new, HWND) 4110 DW_FUNCTION_RETURN(dw_button_new, HWND)
4111 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG) 4111 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
4112 { 4112 {
4113 DWButton *button = _dw_internal_button_new(text, cid); 4113 DWButton *button = _dw_internal_button_new(text, cid, UIButtonTypeSystem);
4114 [button setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter]; 4114 [button setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];
4115 DW_FUNCTION_RETURN_THIS(button); 4115 DW_FUNCTION_RETURN_THIS(button);
4116 } 4116 }
4117 4117
4118 /* 4118 /*
4178 { 4178 {
4179 NSBundle *bundle = [NSBundle mainBundle]; 4179 NSBundle *bundle = [NSBundle mainBundle];
4180 NSString *respath = [bundle resourcePath]; 4180 NSString *respath = [bundle resourcePath];
4181 NSString *filepath = [respath stringByAppendingFormat:@"/%lu.png", cid]; 4181 NSString *filepath = [respath stringByAppendingFormat:@"/%lu.png", cid];
4182 UIImage *image = [[UIImage alloc] initWithContentsOfFile:filepath]; 4182 UIImage *image = [[UIImage alloc] initWithContentsOfFile:filepath];
4183 DWButton *button = _dw_internal_button_new("", cid); 4183 DWButton *button = _dw_internal_button_new("", cid, UIButtonTypeCustom);
4184 if(image) 4184 if(image)
4185 { 4185 {
4186 [button setImage:image forState:UIControlStateNormal]; 4186 [button setImage:image forState:UIControlStateNormal];
4187 } 4187 }
4188 [image release]; 4188 [image release];
4211 if(!image && ext) 4211 if(!image && ext)
4212 { 4212 {
4213 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]]; 4213 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]];
4214 image = [[UIImage alloc] initWithContentsOfFile:nstr]; 4214 image = [[UIImage alloc] initWithContentsOfFile:nstr];
4215 } 4215 }
4216 DWButton *button = _dw_internal_button_new("", cid); 4216 DWButton *button = _dw_internal_button_new("", cid, UIButtonTypeCustom);
4217 if(image) 4217 if(image)
4218 { 4218 {
4219 [button setImage:image forState:UIControlStateNormal]; 4219 [button setImage:image forState:UIControlStateNormal];
4220 } 4220 }
4221 [image release]; 4221 [image release];
4236 DW_FUNCTION_RETURN(dw_bitmapbutton_new_from_data, HWND) 4236 DW_FUNCTION_RETURN(dw_bitmapbutton_new_from_data, HWND)
4237 DW_FUNCTION_RESTORE_PARAM4(DW_UNUSED(text), const char *, cid, ULONG, data, const char *, len, int) 4237 DW_FUNCTION_RESTORE_PARAM4(DW_UNUSED(text), const char *, cid, ULONG, data, const char *, len, int)
4238 { 4238 {
4239 NSData *thisdata = [NSData dataWithBytes:data length:len]; 4239 NSData *thisdata = [NSData dataWithBytes:data length:len];
4240 UIImage *image = [[UIImage alloc] initWithData:thisdata]; 4240 UIImage *image = [[UIImage alloc] initWithData:thisdata];
4241 DWButton *button = _dw_internal_button_new("", cid); 4241 DWButton *button = _dw_internal_button_new("", cid, UIButtonTypeCustom);
4242 if(image) 4242 if(image)
4243 { 4243 {
4244 [button setImage:image forState:UIControlStateNormal]; 4244 [button setImage:image forState:UIControlStateNormal];
4245 } 4245 }
4246 [image release]; 4246 [image release];
4336 DW_FUNCTION_DEFINITION(dw_radiobutton_new, HWND, const char *text, ULONG cid) 4336 DW_FUNCTION_DEFINITION(dw_radiobutton_new, HWND, const char *text, ULONG cid)
4337 DW_FUNCTION_ADD_PARAM2(text, cid) 4337 DW_FUNCTION_ADD_PARAM2(text, cid)
4338 DW_FUNCTION_RETURN(dw_radiobutton_new, HWND) 4338 DW_FUNCTION_RETURN(dw_radiobutton_new, HWND)
4339 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG) 4339 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
4340 { 4340 {
4341 DWButton *button = _dw_internal_button_new(text, cid); 4341 DWButton *button = _dw_internal_button_new(text, cid, UIButtonTypeSystem);
4342 [button setType:_DW_BUTTON_TYPE_RADIO]; 4342 [button setType:_DW_BUTTON_TYPE_RADIO];
4343 DW_FUNCTION_RETURN_THIS(button); 4343 DW_FUNCTION_RETURN_THIS(button);
4344 } 4344 }
4345 4345
4346 /* 4346 /*
4488 DW_FUNCTION_DEFINITION(dw_checkbox_new, HWND, const char *text, ULONG cid) 4488 DW_FUNCTION_DEFINITION(dw_checkbox_new, HWND, const char *text, ULONG cid)
4489 DW_FUNCTION_ADD_PARAM2(text, cid) 4489 DW_FUNCTION_ADD_PARAM2(text, cid)
4490 DW_FUNCTION_RETURN(dw_checkbox_new, HWND) 4490 DW_FUNCTION_RETURN(dw_checkbox_new, HWND)
4491 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG) 4491 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG)
4492 { 4492 {
4493 DWButton *button = _dw_internal_button_new(text, cid); 4493 DWButton *button = _dw_internal_button_new(text, cid, UIButtonTypeSystem);
4494 [button setType:_DW_BUTTON_TYPE_CHECK]; 4494 [button setType:_DW_BUTTON_TYPE_CHECK];
4495 DW_FUNCTION_RETURN_THIS(button); 4495 DW_FUNCTION_RETURN_THIS(button);
4496 } 4496 }
4497 4497
4498 /* 4498 /*
8027 DW_FUNCTION_RESTORE_PARAM1(handle, HWND) 8027 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
8028 { 8028 {
8029 NSObject *object = handle; 8029 NSObject *object = handle;
8030 int retval = DW_ERROR_NONE; 8030 int retval = DW_ERROR_NONE;
8031 8031
8032 if([ object isMemberOfClass:[ DWWindow class ] ]) 8032 if([ object isMemberOfClass:[DWWindow class]])
8033 { 8033 {
8034 DWWindow *window = handle; 8034 DWWindow *window = handle;
8035 CGRect rect = [window frame]; 8035 CGRect rect = [window frame];
8036 8036
8037 /* If we haven't been sized by a call.. */ 8037 /* If we haven't been sized by a call.. */
8567 } 8567 }
8568 else if([object isMemberOfClass:[DWWindow class]]) 8568 else if([object isMemberOfClass:[DWWindow class]])
8569 { 8569 {
8570 DWWindow *window = object; 8570 DWWindow *window = object;
8571 NSArray *array = [window subviews]; 8571 NSArray *array = [window subviews];
8572 8572 NSString *nstr = [NSString stringWithUTF8String:text];
8573
8574 [window setLargeContentTitle:nstr];
8575
8573 for(id obj in array) 8576 for(id obj in array)
8574 { 8577 {
8575 if([obj isMemberOfClass:[UINavigationBar class]]) 8578 if([obj isMemberOfClass:[UINavigationBar class]])
8576 { 8579 {
8577 UINavigationBar *nav = obj; 8580 UINavigationBar *nav = obj;
8578 UINavigationItem *item = [[nav items] firstObject]; 8581 UINavigationItem *item = [[nav items] firstObject];
8579 8582
8580 [item setTitle:[NSString stringWithUTF8String:text]]; 8583 [item setTitle:nstr];
8581 } 8584 }
8582 } 8585 }
8583 } 8586 }
8584 #ifdef DW_INCLUDE_DEPRECATED 8587 #ifdef DW_INCLUDE_DEPRECATED
8585 else if([object isKindOfClass:[UIControl class]]) 8588 else if([object isKindOfClass:[UIControl class]])