comparison ios/dw.m @ 2385:a126b04b9996

iOS: dwcompat now builds on iOS as well... Fixes for running dwtest.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 23 Mar 2021 20:02:07 +0000
parents 32ebd33be56b
children deb2345f4518
comparison
equal deleted inserted replaced
2384:32ebd33be56b 2385:a126b04b9996
578 int srcwidth; 578 int srcwidth;
579 int srcheight; 579 int srcheight;
580 } DWBitBlt; 580 } DWBitBlt;
581 581
582 /* Subclass for a test object type */ 582 /* Subclass for a test object type */
583 @interface DWObject : NSObject {} 583 @interface DWObject : NSObject
584 {
585 /* A normally hidden window, at the top of the view hierarchy.
586 * Since iOS messageboxes and such require a view controller,
587 * we show this hidden window when necessary and use it during
588 * the creation of alerts and dialog boxes that don't have one.
589 */
590 UIWindow *hiddenWindow;
591 }
584 -(void)uselessThread:(id)sender; 592 -(void)uselessThread:(id)sender;
585 -(void)menuHandler:(id)param; 593 -(void)menuHandler:(id)param;
586 -(void)doBitBlt:(id)param; 594 -(void)doBitBlt:(id)param;
587 -(void)doFlush:(id)param; 595 -(void)doFlush:(id)param;
588 @end 596 @end
837 } 845 }
838 -(BOOL)acceptsFirstResponder { return YES; } 846 -(BOOL)acceptsFirstResponder { return YES; }
839 @end 847 @end
840 848
841 @implementation DWObject 849 @implementation DWObject
850 -(id)init
851 {
852 hiddenWindow = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
853 [hiddenWindow setBackgroundColor:[UIColor clearColor]];
854 [hiddenWindow setWindowLevel:UIWindowLevelAlert];
855 [hiddenWindow setHidden:YES];
856 return [super init];
857 }
842 -(void)uselessThread:(id)sender { /* Thread only to initialize threading */ } 858 -(void)uselessThread:(id)sender { /* Thread only to initialize threading */ }
843 -(void)menuHandler:(id)param 859 -(void)menuHandler:(id)param
844 { 860 {
845 _event_handler(param, nil, 8); 861 _event_handler(param, nil, 8);
846 } 862 }
865 handler:^(UIAlertAction * action) { iResponse = 2; }]; 881 handler:^(UIAlertAction * action) { iResponse = 2; }];
866 if([params count] > 5) 882 if([params count] > 5)
867 action = [UIAlertAction actionWithTitle:[params objectAtIndex:5] style:UIAlertActionStyleDefault 883 action = [UIAlertAction actionWithTitle:[params objectAtIndex:5] style:UIAlertActionStyleDefault
868 handler:^(UIAlertAction * action) { iResponse = 3; }]; 884 handler:^(UIAlertAction * action) { iResponse = 3; }];
869 885
870 [alert presentViewController:alert animated:YES completion:nil]; 886 /* Unhide our hidden window and make it key */
887 [hiddenWindow setHidden:NO];
888 [hiddenWindow makeKeyAndVisible];
889 [[hiddenWindow rootViewController] presentViewController:alert animated:YES completion:nil];
890 /* Once the dialog is gone we can rehide our window */
891 [hiddenWindow setHidden:YES];
871 [alert release]; 892 [alert release];
872 [params addObject:[NSNumber numberWithInteger:iResponse]]; 893 [params addObject:[NSNumber numberWithInteger:iResponse]];
873 } 894 }
874 -(void)safeCall:(SEL)sel withObject:(id)param 895 -(void)safeCall:(SEL)sel withObject:(id)param
875 { 896 {
7273 DW_FUNCTION_RETURN(dw_window_new, HWND) 7294 DW_FUNCTION_RETURN(dw_window_new, HWND)
7274 DW_FUNCTION_RESTORE_PARAM3(hwndOwner, HWND, title, char *, flStyle, ULONG) 7295 DW_FUNCTION_RESTORE_PARAM3(hwndOwner, HWND, title, char *, flStyle, ULONG)
7275 { 7296 {
7276 DW_FUNCTION_INIT; 7297 DW_FUNCTION_INIT;
7277 DWWindow *window = [[DWWindow alloc] init]; 7298 DWWindow *window = [[DWWindow alloc] init];
7299 DWView *view = [[DWView alloc] init];
7300
7301 [window addSubview:view];
7278 7302
7279 /* TODO: Handle style flags */ 7303 /* TODO: Handle style flags */
7280 if(@available(iOS 13.0, *)) { 7304 if(@available(iOS 13.0, *)) {
7281 [window setLargeContentTitle:[NSString stringWithUTF8String:title]]; 7305 [window setLargeContentTitle:[NSString stringWithUTF8String:title]];
7282 } 7306 }
7394 { 7418 {
7395 [object setTextColor:(fg ? fg : [UIColor labelColor])]; 7419 [object setTextColor:(fg ? fg : [UIColor labelColor])];
7396 } 7420 }
7397 if([object isMemberOfClass:[DWButton class]]) 7421 if([object isMemberOfClass:[DWButton class]])
7398 { 7422 {
7399 [object setTextColor:(fg ? fg : [UIColor labelColor])]; 7423 [[object titleLabel] setTextColor:(fg ? fg : [UIColor labelColor])];
7400 } 7424 }
7401 if([object isKindOfClass:[UITextField class]] || [object isKindOfClass:[UIButton class]]) 7425 if([object isKindOfClass:[UITextField class]] || [object isKindOfClass:[UIButton class]])
7402 { 7426 {
7403 [object setBackgroundColor:(bg ? bg : [UIColor systemBackgroundColor])]; 7427 [object setBackgroundColor:(bg ? bg : [UIColor systemBackgroundColor])];
7404 } 7428 }