Mercurial > dwindows
comparison ios/dw.m @ 2426:6220f0580088
iOS: DWContainer attempt to get touch and selection handlers working.
Also implement the size calculations for a single column and
foreground color.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 04 Apr 2021 19:06:23 +0000 |
parents | 60a459df758d |
children | 4f078d24fe83 |
comparison
equal
deleted
inserted
replaced
2425:60a459df758d | 2426:6220f0580088 |
---|---|
1810 -(void)setLastQueryPoint:(int)input; | 1810 -(void)setLastQueryPoint:(int)input; |
1811 -(void)clear; | 1811 -(void)clear; |
1812 -(void)setup; | 1812 -(void)setup; |
1813 -(CGSize)getsize; | 1813 -(CGSize)getsize; |
1814 -(void)setForegroundColor:(UIColor *)input; | 1814 -(void)setForegroundColor:(UIColor *)input; |
1815 -(void)doubleClicked:(id)sender; | |
1816 -(void)selectionChanged:(id)sender; | |
1817 -(DWMenu *)menuForEvent:(UIEvent *)event; | 1815 -(DWMenu *)menuForEvent:(UIEvent *)event; |
1818 @end | 1816 @end |
1819 | 1817 |
1820 @implementation DWContainer | 1818 @implementation DWContainer |
1821 -(NSInteger)tableView:(UITableView *)aTable numberOfRowsInSection:(NSInteger)section | 1819 -(NSInteger)tableView:(UITableView *)aTable numberOfRowsInSection:(NSInteger)section |
2048 } | 2046 } |
2049 -(CGSize)getsize | 2047 -(CGSize)getsize |
2050 { | 2048 { |
2051 int cwidth = 0, cheight = 0; | 2049 int cwidth = 0, cheight = 0; |
2052 | 2050 |
2053 #if 0 /* TODO: Figure out how to calculate the table size */ | |
2054 if(tvcols) | 2051 if(tvcols) |
2055 { | 2052 { |
2056 int z; | |
2057 int colcount = (int)[tvcols count]; | 2053 int colcount = (int)[tvcols count]; |
2058 int rowcount = (int)[self numberOfRowsInSection:0]; | 2054 int rowcount = (int)[self numberOfRowsInSection:0]; |
2059 | 2055 int width = 0; |
2060 for(z=0;z<colcount;z++) | 2056 |
2061 { | 2057 if(rowcount > 0) |
2062 NSTableColumn *column = [tvcols objectAtIndex:z]; | 2058 { |
2063 int width = [column width]; | 2059 int x; |
2064 | 2060 |
2065 if(rowcount > 0) | 2061 for(x=0;x<rowcount;x++) |
2066 { | 2062 { |
2067 int x; | 2063 UITableViewCell *cell = [data objectAtIndex:(x*colcount)]; |
2068 | 2064 int thiswidth = 4, thisheight = 0; |
2069 for(x=0;x<rowcount;x++) | 2065 |
2066 if([cell imageView]) | |
2070 { | 2067 { |
2071 NSTableCellView *cell = [self viewAtColumn:z row:x makeIfNecessary:YES]; | 2068 thiswidth += [[cell imageView] image].size.width; |
2072 int thiswidth = 4, thisheight = 0; | 2069 thisheight = [[cell imageView] image].size.height; |
2073 | |
2074 if([cell imageView]) | |
2075 { | |
2076 thiswidth += [[cell imageView] image].size.width; | |
2077 thisheight = [[cell imageView] image].size.height; | |
2078 } | |
2079 if([cell textField]) | |
2080 { | |
2081 int textheight = [[cell textField] intrinsicContentSize].width; | |
2082 thiswidth += [[cell textField] intrinsicContentSize].width; | |
2083 if(textheight > thisheight) | |
2084 thisheight = textheight; | |
2085 } | |
2086 | |
2087 /* If on the first column... add up the heights */ | |
2088 if(z == 0) | |
2089 cheight += thisheight; | |
2090 | |
2091 if(thiswidth > width) | |
2092 { | |
2093 width = thiswidth; | |
2094 } | |
2095 } | 2070 } |
2096 /* If the image is missing default the optimized width to 16. */ | 2071 if([cell textLabel]) |
2097 if(!width && [[types objectAtIndex:z] intValue] & DW_CFA_BITMAPORICON) | |
2098 { | 2072 { |
2099 width = 16; | 2073 int textheight = [[cell textLabel] intrinsicContentSize].width; |
2074 thiswidth += [[cell textLabel] intrinsicContentSize].width; | |
2075 if(textheight > thisheight) | |
2076 thisheight = textheight; | |
2077 } | |
2078 | |
2079 cheight += thisheight; | |
2080 | |
2081 if(thiswidth > width) | |
2082 { | |
2083 width = thiswidth; | |
2100 } | 2084 } |
2101 } | 2085 } |
2102 if(width) | 2086 /* If the image is missing default the optimized width to 16. */ |
2103 cwidth += width; | 2087 if(!width && [[types objectAtIndex:0] intValue] & DW_CFA_BITMAPORICON) |
2104 } | 2088 { |
2105 } | 2089 width = 16; |
2106 #endif | 2090 } |
2091 } | |
2092 if(width) | |
2093 cwidth += width; | |
2094 } | |
2107 cwidth += 16; | 2095 cwidth += 16; |
2108 cheight += 16; | 2096 cheight += 16; |
2109 return CGSizeMake(cwidth, cheight); | 2097 return CGSizeMake(cwidth, cheight); |
2110 } | 2098 } |
2111 -(void)setForegroundColor:(UIColor *)input | 2099 -(void)setForegroundColor:(UIColor *)input |
2112 { | 2100 { |
2113 #if 0 /* TODO: Fix this without columns */ | 2101 UIColor *oldfgcolor = fgcolor; |
2114 int z, count = (int)[tvcols count]; | |
2115 | 2102 |
2116 fgcolor = input; | 2103 fgcolor = input; |
2117 [fgcolor retain]; | 2104 [fgcolor retain]; |
2118 | 2105 [oldfgcolor release]; |
2119 for(z=0;z<count;z++) | 2106 } |
2120 { | 2107 -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath |
2121 NSTableColumn *tableColumn = [tvcols objectAtIndex:z]; | |
2122 UITextFieldCell *cell = [tableColumn dataCell]; | |
2123 [cell setTextColor:fgcolor]; | |
2124 } | |
2125 #endif | |
2126 } | |
2127 -(void)doubleClicked:(id)sender | |
2128 { | 2108 { |
2129 void *params[2]; | 2109 void *params[2]; |
2130 | 2110 |
2131 params[0] = (void *)[self getRowTitle:(int)[self indexPathForSelectedRow].row]; | 2111 params[0] = (void *)[self getRowTitle:(int)indexPath.row]; |
2132 params[1] = (void *)[self getRowData:(int)[self indexPathForSelectedRow].row]; | 2112 params[1] = (void *)[self getRowData:(int)indexPath.row]; |
2133 | 2113 |
2134 /* Handler for container class */ | 2114 /* If multiple selection is enabled, treat it as selectionChanged: */ |
2135 _dw_event_handler(self, (UIEvent *)params, 9); | 2115 if([self allowsMultipleSelection]) |
2136 } | 2116 { |
2137 -(void)selectionChanged:(id)sender | 2117 /* Handler for container class */ |
2138 { | 2118 _dw_event_handler(self, (UIEvent *)params, 12); |
2139 void *params[2]; | 2119 /* Handler for listbox class */ |
2140 | 2120 _dw_event_handler(self, DW_INT_TO_POINTER((int)indexPath.row), 11); |
2141 params[0] = (void *)[self getRowTitle:(int)[self indexPathForSelectedRow].row]; | 2121 } |
2142 params[1] = (void *)[self getRowData:(int)[self indexPathForSelectedRow].row]; | 2122 else /* Otherwise treat it as doubleClicked: */ |
2143 | 2123 { |
2144 /* Handler for container class */ | 2124 /* Handler for container class */ |
2145 _dw_event_handler(self, (UIEvent *)params, 12); | 2125 _dw_event_handler(self, (UIEvent *)params, 9); |
2146 /* Handler for listbox class */ | 2126 } |
2147 _dw_event_handler(self, DW_INT_TO_POINTER((int)[self indexPathForSelectedRow].row), 11); | |
2148 } | 2127 } |
2149 -(DWMenu *)menuForEvent:(UIEvent *)event | 2128 -(DWMenu *)menuForEvent:(UIEvent *)event |
2150 { | 2129 { |
2151 #if 0 /* TODO: Fix this */ | 2130 #if 0 /* TODO: Fix this */ |
2152 int row; | 2131 int row; |
5532 DW_FUNCTION_RETURN(dw_container_new, HWND) | 5511 DW_FUNCTION_RETURN(dw_container_new, HWND) |
5533 DW_FUNCTION_RESTORE_PARAM2(cid, ULONG, multi, int) | 5512 DW_FUNCTION_RESTORE_PARAM2(cid, ULONG, multi, int) |
5534 { | 5513 { |
5535 DW_FUNCTION_INIT; | 5514 DW_FUNCTION_INIT; |
5536 DWContainer *cont = _dw_cont_new(cid, multi); | 5515 DWContainer *cont = _dw_cont_new(cid, multi); |
5537 /* TODO: Switch to new action system | |
5538 [cont setDoubleAction:@selector(doubleClicked:)];*/ | |
5539 DW_FUNCTION_RETURN_THIS(cont); | 5516 DW_FUNCTION_RETURN_THIS(cont); |
5540 } | 5517 } |
5541 | 5518 |
5542 /* | 5519 /* |
5543 * Sets up the container columns. | 5520 * Sets up the container columns. |