comparison ios/dw.m @ 2588:8253e17b20ad

iOS: Remove some bogus secondary color code in DWBox. Add fallback code to give general sizes for DWCalendar widgets... because intrinsicContentSize is returing -1,-1. Use size autodetection for calendar when packing in dwtest.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 24 May 2021 23:29:15 +0000
parents 461006160d11
children e879afecf3ab
comparison
equal deleted inserted replaced
2587:461006160d11 2588:8253e17b20ad
686 /* Subclass for a box type */ 686 /* Subclass for a box type */
687 @interface DWBox : UIView 687 @interface DWBox : UIView
688 { 688 {
689 Box *box; 689 Box *box;
690 void *userdata; 690 void *userdata;
691 UIColor *bgcolor;
692 } 691 }
693 -(id)init; 692 -(id)init;
694 -(void)dealloc; 693 -(void)dealloc;
695 -(Box *)box; 694 -(Box *)box;
696 -(void *)userdata; 695 -(void *)userdata;
697 -(void)setUserdata:(void *)input; 696 -(void)setUserdata:(void *)input;
698 -(void)drawRect:(CGRect)rect;
699 -(void)keyDown:(UIKey *)key API_AVAILABLE(ios(13.4)); 697 -(void)keyDown:(UIKey *)key API_AVAILABLE(ios(13.4));
700 -(void)setColor:(unsigned long)input;
701 @end 698 @end
702 699
703 @implementation DWBox 700 @implementation DWBox
704 -(id)init 701 -(id)init
705 { 702 {
725 [super dealloc]; 722 [super dealloc];
726 } 723 }
727 -(Box *)box { return box; } 724 -(Box *)box { return box; }
728 -(void *)userdata { return userdata; } 725 -(void *)userdata { return userdata; }
729 -(void)setUserdata:(void *)input { userdata = input; } 726 -(void)setUserdata:(void *)input { userdata = input; }
730 -(void)drawRect:(CGRect)rect
731 {
732 if(bgcolor)
733 {
734 [bgcolor set];
735 UIRectFill([self bounds]);
736 }
737 }
738 -(void)keyDown:(UIKey *)key API_AVAILABLE(ios(13.4)){ _dw_event_handler(self, key, 2); } 727 -(void)keyDown:(UIKey *)key API_AVAILABLE(ios(13.4)){ _dw_event_handler(self, key, 2); }
739 -(void)setColor:(unsigned long)input
740 {
741 id orig = bgcolor;
742
743 if(input == _dw_colors[DW_CLR_DEFAULT])
744 {
745 bgcolor = nil;
746 }
747 else
748 {
749 bgcolor = [[UIColor colorWithRed: DW_RED_VALUE(input)/255.0 green: DW_GREEN_VALUE(input)/255.0 blue: DW_BLUE_VALUE(input)/255.0 alpha: 1] retain];
750 if(UIGraphicsGetCurrentContext())
751 {
752 [bgcolor set];
753 UIRectFill([self bounds]);
754 }
755 }
756 [self setNeedsDisplay];
757 [orig release];
758 }
759 @end 728 @end
760 729
761 @interface DWWindow : UIWindow 730 @interface DWWindow : UIWindow
762 { 731 {
763 DWMenu *windowmenu, *popupmenu; 732 DWMenu *windowmenu, *popupmenu;
3706 } 3675 }
3707 } 3676 }
3708 /* Handle calendar */ 3677 /* Handle calendar */
3709 else if([object isMemberOfClass:[DWCalendar class]]) 3678 else if([object isMemberOfClass:[DWCalendar class]])
3710 { 3679 {
3711 CGSize size = [object intrinsicContentSize]; 3680 DWCalendar *calendar = object;
3712 3681 CGSize size = [calendar intrinsicContentSize];
3682
3683 /* If we can't detect the size... */
3684 if(size.width < 1 || size.height < 1)
3685 {
3686 if(DWOSMajor >= 14)
3687 {
3688 /* Bigger new style in ios 14 */
3689 thiswidth = 200;
3690 thisheight = 200;
3691 }
3692 else
3693 {
3694 /* Smaller spinner style in iOS 13 and earlier */
3695 thiswidth = 200;
3696 thisheight = 100;
3697 }
3698 }
3699 else
3700 {
3713 thiswidth = size.width; 3701 thiswidth = size.width;
3714 thisheight = size.height; 3702 thisheight = size.height;
3703 }
3715 } 3704 }
3716 /* MLE and Container */ 3705 /* MLE and Container */
3717 else if([object isMemberOfClass:[DWMLE class]] || 3706 else if([object isMemberOfClass:[DWMLE class]] ||
3718 [object isMemberOfClass:[DWContainer class]]) 3707 [object isMemberOfClass:[DWContainer class]])
3719 { 3708 {
8133 } 8122 }
8134 else if([object isMemberOfClass:[DWBox class]]) 8123 else if([object isMemberOfClass:[DWBox class]])
8135 { 8124 {
8136 DWBox *box = object; 8125 DWBox *box = object;
8137 8126
8138 [box setColor:_back];
8139 [box setBackgroundColor:bg]; 8127 [box setBackgroundColor:bg];
8140 } 8128 }
8141 else if([object isKindOfClass:[UITableView class]]) 8129 else if([object isKindOfClass:[UITableView class]])
8142 { 8130 {
8143 DWContainer *cont = handle; 8131 DWContainer *cont = handle;