comparison ios/dw.m @ 2379:e35887009bb5

iOS: Remove tree functionality, combobox and radio button... include links to possible replacement functionality if I don't write it myself. Working on the container/listbox code... since there is only one column in the UITableView, need to figure out how to display the column data but in one column. Options are multiline labels and using a row for each column in a single segmeent for what would be a row on other platforms.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 19 Mar 2021 22:54:18 +0000
parents cc858be0cb81
children 93424ad710de
comparison
equal deleted inserted replaced
2378:cc858be0cb81 2379:e35887009bb5
1314 -(id)scrollview { return scrollview; } 1314 -(id)scrollview { return scrollview; }
1315 -(void)setScrollview:(id)input { scrollview = input; } 1315 -(void)setScrollview:(id)input { scrollview = input; }
1316 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } 1316 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
1317 @end 1317 @end
1318 1318
1319 /* TODO: UITableView does not support variable columns...
1320 * also OutlineView does not exist in iOS.
1321 */
1319 UITableViewCell *_dw_table_cell_view_new(UIImage *icon, NSString *text) 1322 UITableViewCell *_dw_table_cell_view_new(UIImage *icon, NSString *text)
1320 { 1323 {
1321 UITableViewCell *browsercell = [[[UITableViewCell alloc] init] autorelease]; 1324 UITableViewCell *browsercell = [[[UITableViewCell alloc] init] autorelease];
1322 [browsercell setAutoresizesSubviews:YES]; 1325 [browsercell setAutoresizesSubviews:YES];
1326
1323 if(icon) 1327 if(icon)
1324 { 1328 {
1325 UIImageView *iv = [[[UIImageView alloc] init] autorelease]; 1329 if(@available(iOS 14.0, *))
1326 [iv setAutoresizingMask:UIViewAutoresizingFlexibleHeight|(text ? 0 :UIViewAutoresizingFlexibleWidth)]; 1330 {
1327 [iv setImage:icon]; 1331 UIListContentConfiguration *content = [browsercell defaultContentConfiguration];
1328 [browsercell setImageView:iv]; 1332
1329 [browsercell addSubview:iv]; 1333 [content setImage:icon];
1334 }
1335 else
1336 {
1337 [browsercell setImage:icon];
1338 }
1330 } 1339 }
1331 if(text) 1340 if(text)
1332 { 1341 {
1333 /* Might switch to UITextFieldView in the future if they need to be editable */ 1342 if(@available(iOS 14.0, *))
1334 UILabel *label = [[[UILabel alloc] init] autorelease]; 1343 {
1335 [label setAutoresizingMask:UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth]; 1344 UIListContentConfiguration *content = [browsercell defaultContentConfiguration];
1336 [label setText:text]; 1345
1337 [browsercell setTextField:label]; 1346 [content setText:text];
1338 [browsercell addSubview:label]; 1347 }
1348 else
1349 {
1350 [browsercell setText:text];
1351 }
1339 } 1352 }
1340 return browsercell; 1353 return browsercell;
1341 } 1354 }
1342 1355
1343 void _dw_table_cell_view_layout(NSTableCellView *result)
1344 {
1345 /* Adjust the frames of the textField and imageView when both are present */
1346 if([result imageView] && [result textField])
1347 {
1348 UIImageView *iv = [result imageView];
1349 UIImage *icon = [iv image];
1350 UITextField *tf = [result textField];
1351 CGRect rect = result.frame;
1352 int width =[icon size].width;
1353
1354 [iv setFrame:CGRectMake(0,0,width,rect.size.height)];
1355
1356 /* Adjust the rect to allow space for the image */
1357 rect.origin.x += width;
1358 rect.size.width -= width;
1359 [tf setFrame:rect];
1360 }
1361 }
1362
1363 /* Subclass for a Container/List type */ 1356 /* Subclass for a Container/List type */
1364 @interface DWContainer : NSTableView <NSTableViewDataSource,NSTableViewDelegate> 1357 @interface DWContainer : UITableView <UITableViewDataSource,UITableViewDelegate>
1365 { 1358 {
1366 void *userdata; 1359 void *userdata;
1367 NSMutableArray *tvcols; 1360 NSMutableArray *tvcols;
1368 NSMutableArray *data; 1361 NSMutableArray *data;
1369 NSMutableArray *types; 1362 NSMutableArray *types;
1374 unsigned long _DW_COLOR_ROW_ODD, _DW_COLOR_ROW_EVEN; 1367 unsigned long _DW_COLOR_ROW_ODD, _DW_COLOR_ROW_EVEN;
1375 int lastAddPoint, lastQueryPoint; 1368 int lastAddPoint, lastQueryPoint;
1376 id scrollview; 1369 id scrollview;
1377 int filesystem; 1370 int filesystem;
1378 } 1371 }
1379 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable; 1372 -(NSInteger)numberOfRowsInTableView:(UITableView *)aTable;
1380 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow; 1373 -(id)tableView:(UITableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow;
1381 -(BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex; 1374 -(BOOL)tableView:(UITableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
1382 -(void *)userdata; 1375 -(void *)userdata;
1383 -(void)setUserdata:(void *)input; 1376 -(void)setUserdata:(void *)input;
1384 -(void)setFilesystem:(int)input; 1377 -(void)setFilesystem:(int)input;
1385 -(int)filesystem; 1378 -(int)filesystem;
1386 -(id)scrollview; 1379 -(id)scrollview;
1387 -(void)setScrollview:(id)input; 1380 -(void)setScrollview:(id)input;
1388 -(void)addColumn:(NSTableColumn *)input andType:(int)type;
1389 -(NSTableColumn *)getColumn:(int)col;
1390 -(int)addRow:(NSArray *)input; 1381 -(int)addRow:(NSArray *)input;
1391 -(int)addRows:(int)number; 1382 -(int)addRows:(int)number;
1392 -(void)editCell:(id)input at:(int)row and:(int)col; 1383 -(void)editCell:(id)input at:(int)row and:(int)col;
1393 -(void)removeRow:(int)row; 1384 -(void)removeRow:(int)row;
1394 -(void)setRow:(int)row title:(const char *)input; 1385 -(void)setRow:(int)row title:(const char *)input;
1398 -(int)lastAddPoint; 1389 -(int)lastAddPoint;
1399 -(int)lastQueryPoint; 1390 -(int)lastQueryPoint;
1400 -(void)setLastQueryPoint:(int)input; 1391 -(void)setLastQueryPoint:(int)input;
1401 -(void)clear; 1392 -(void)clear;
1402 -(void)setup; 1393 -(void)setup;
1403 -(void)optimize;
1404 -(CGSize)getsize; 1394 -(CGSize)getsize;
1405 -(void)setForegroundColor:(UIColor *)input; 1395 -(void)setForegroundColor:(UIColor *)input;
1406 -(void)doubleClicked:(id)sender; 1396 -(void)doubleClicked:(id)sender;
1407 -(void)keyUp:(UIEvent *)theEvent; 1397 -(void)keyUp:(UIEvent *)theEvent;
1408 -(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn;
1409 -(void)selectionChanged:(id)sender; 1398 -(void)selectionChanged:(id)sender;
1410 -(UIMenu *)menuForEvent:(UIEvent *)event; 1399 -(UIMenu *)menuForEvent:(UIEvent *)event;
1411 -(void)tableView:(NSTableView *)tableView didAddRowView:(NSTableRowView *)rowView forRow:(NSInteger)row; 1400 -(void)tableView:(UITableView *)tableView didAddRowView:(UITableRowView *)rowView forRow:(NSInteger)row;
1412 -(UIView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row; 1401 -(UIView *)tableView:(UITableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row;
1413 @end 1402 @end
1414 1403
1415 @implementation DWContainer 1404 @implementation DWContainer
1416 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable 1405 -(NSInteger)numberOfRowsInTableView:(UITableView *)aTable
1417 { 1406 {
1418 if(tvcols && data) 1407 if(tvcols && data)
1419 { 1408 {
1420 int cols = (int)[tvcols count]; 1409 int cols = (int)[tvcols count];
1421 int total = (int)[data count]; 1410 int total = (int)[data count];
1424 return total / cols; 1413 return total / cols;
1425 } 1414 }
1426 } 1415 }
1427 return 0; 1416 return 0;
1428 } 1417 }
1429 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow 1418 -(id)tableView:(UITableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow
1430 { 1419 {
1431 if(tvcols && data) 1420 if(tvcols && data)
1432 { 1421 {
1433 int z, col = -1; 1422 int z, col = -1;
1434 int count = (int)[tvcols count]; 1423 int count = (int)[tvcols count];
1451 } 1440 }
1452 } 1441 }
1453 } 1442 }
1454 return nil; 1443 return nil;
1455 } 1444 }
1456 -(BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { return NO; } 1445 -(BOOL)tableView:(UITableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { return NO; }
1457 -(void *)userdata { return userdata; } 1446 -(void *)userdata { return userdata; }
1458 -(void)setUserdata:(void *)input { userdata = input; } 1447 -(void)setUserdata:(void *)input { userdata = input; }
1459 -(void)setFilesystem:(int)input { filesystem = input; } 1448 -(void)setFilesystem:(int)input { filesystem = input; }
1460 -(int)filesystem { return filesystem; } 1449 -(int)filesystem { return filesystem; }
1461 -(id)scrollview { return scrollview; } 1450 -(id)scrollview { return scrollview; }
1462 -(void)setScrollview:(id)input { scrollview = input; } 1451 -(void)setScrollview:(id)input { scrollview = input; }
1463 -(void)addColumn:(NSTableColumn *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } }
1464 -(NSTableColumn *)getColumn:(int)col { if(tvcols) { return [tvcols objectAtIndex:col]; } return nil; }
1465 -(void)refreshColors 1452 -(void)refreshColors
1466 { 1453 {
1467 UIColor *oldodd = oddcolor; 1454 UIColor *oldodd = oddcolor;
1468 UIColor *oldeven = evencolor; 1455 UIColor *oldeven = evencolor;
1469 unsigned long thisodd = dw_oddcolor == DW_CLR_DEFAULT ? _DW_COLOR_ROW_ODD : dw_oddcolor; 1456 unsigned long thisodd = dw_oddcolor == DW_CLR_DEFAULT ? _DW_COLOR_ROW_ODD : dw_oddcolor;
1471 unsigned long thiseven = dw_evencolor == DW_CLR_DEFAULT ? _DW_COLOR_ROW_EVEN : dw_evencolor; 1458 unsigned long thiseven = dw_evencolor == DW_CLR_DEFAULT ? _DW_COLOR_ROW_EVEN : dw_evencolor;
1472 unsigned long _even = _get_color(thiseven); 1459 unsigned long _even = _get_color(thiseven);
1473 1460
1474 /* Get the UIColor for non-default colors */ 1461 /* Get the UIColor for non-default colors */
1475 if(thisodd != DW_RGB_TRANSPARENT) 1462 if(thisodd != DW_RGB_TRANSPARENT)
1476 oddcolor = [[UIColor colorWithDeviceRed: DW_RED_VALUE(_odd)/255.0 green: DW_GREEN_VALUE(_odd)/255.0 blue: DW_BLUE_VALUE(_odd)/255.0 alpha: 1] retain]; 1463 oddcolor = [[UIColor colorWithRed: DW_RED_VALUE(_odd)/255.0 green: DW_GREEN_VALUE(_odd)/255.0 blue: DW_BLUE_VALUE(_odd)/255.0 alpha: 1] retain];
1477 else 1464 else
1478 oddcolor = NULL; 1465 oddcolor = NULL;
1479 if(thiseven != DW_RGB_TRANSPARENT) 1466 if(thiseven != DW_RGB_TRANSPARENT)
1480 evencolor = [[UIColor colorWithDeviceRed: DW_RED_VALUE(_even)/255.0 green: DW_GREEN_VALUE(_even)/255.0 blue: DW_BLUE_VALUE(_even)/255.0 alpha: 1] retain]; 1467 evencolor = [[UIColor colorWithRed: DW_RED_VALUE(_even)/255.0 green: DW_GREEN_VALUE(_even)/255.0 blue: DW_BLUE_VALUE(_even)/255.0 alpha: 1] retain];
1481 else 1468 else
1482 evencolor = NULL; 1469 evencolor = NULL;
1483 [oldodd release]; 1470 [oldodd release];
1484 [oldeven release]; 1471 [oldeven release];
1485 } 1472 }
1492 } 1479 }
1493 -(void)checkDark 1480 -(void)checkDark
1494 { 1481 {
1495 /* Update any system colors based on the Dark Mode */ 1482 /* Update any system colors based on the Dark Mode */
1496 _DW_COLOR_ROW_EVEN = DW_RGB_TRANSPARENT; 1483 _DW_COLOR_ROW_EVEN = DW_RGB_TRANSPARENT;
1497 if(_is_dark(self)) 1484 _DW_COLOR_ROW_ODD = DW_RGB(230, 230, 230);
1498 _DW_COLOR_ROW_ODD = DW_RGB(100, 100, 100);
1499 else
1500 _DW_COLOR_ROW_ODD = DW_RGB(230, 230, 230);
1501 /* Only refresh if we've been setup already */ 1485 /* Only refresh if we've been setup already */
1502 if(titles) 1486 if(titles)
1503 [self refreshColors]; 1487 [self refreshColors];
1504 } 1488 }
1505 -(void)viewDidChangeEffectiveAppearance { [self checkDark]; } 1489 -(void)viewDidChangeEffectiveAppearance { [self checkDark]; }
1553 } 1537 }
1554 return (int)[titles count]; 1538 return (int)[titles count];
1555 } 1539 }
1556 return 0; 1540 return 0;
1557 } 1541 }
1558 -(void)tableView:(NSTableView *)tableView didAddRowView:(NSTableRowView *)rowView forRow:(NSInteger)row 1542 -(void)tableView:(UITableView *)tableView didAddRowView:(UITableRowView *)rowView forRow:(NSInteger)row
1559 { 1543 {
1560 /* Handle drawing alternating row colors if enabled */ 1544 /* Handle drawing alternating row colors if enabled */
1561 if ((row % 2) == 0) 1545 if ((row % 2) == 0)
1562 { 1546 {
1563 if(evencolor) 1547 if(evencolor)
1567 { 1551 {
1568 if(oddcolor) 1552 if(oddcolor)
1569 [rowView setBackgroundColor:oddcolor]; 1553 [rowView setBackgroundColor:oddcolor];
1570 } 1554 }
1571 } 1555 }
1572 -(UIView *)tableView:(NSTableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row; 1556 -(UIView *)tableView:(UITableView *)tableView viewForTableColumn:(NSTableColumn *)tableColumn row:(NSInteger)row;
1573 { 1557 {
1574 /* Not reusing cell views, so get the cell from our array */ 1558 /* Not reusing cell views, so get the cell from our array */
1575 int index = (int)(row * [tvcols count]) + (int)[tvcols indexOfObject:tableColumn]; 1559 int index = (int)(row * [tvcols count]) + (int)[tvcols indexOfObject:tableColumn];
1576 id celldata = [data objectAtIndex:index]; 1560 id celldata = [data objectAtIndex:index];
1577 1561
1578 /* The data is already a NSTableCellView so just return that */ 1562 /* The data is already a NSTableCellView so just return that */
1579 if([celldata isMemberOfClass:[NSTableCellView class]]) 1563 if([celldata isMemberOfClass:[UITableViewCell class]])
1580 { 1564 {
1581 NSTableCellView *result = celldata; 1565 UITableViewCell *result = celldata;
1582 NSTextAlignment align = [[tableColumn headerCell] alignment];
1583
1584 _dw_table_cell_view_layout(result);
1585 1566
1586 /* Copy the alignment setting from the column, 1567 /* Copy the alignment setting from the column,
1587 * and set the text color from the container. 1568 * and set the text color from the container.
1588 */ 1569 */
1589 if([result textField]) 1570 if(@available(iOS 14.0, *))
1590 { 1571 {
1591 UITextField *tf = [result textField]; 1572 UIListContentConfiguration *content = [result defaultContentConfiguration];
1592 1573
1593 [tf setAlignment:align];
1594 if(fgcolor) 1574 if(fgcolor)
1595 [tf setTextColor:fgcolor]; 1575 [[content textProperties] setColor:fgcolor];
1596 } 1576 }
1597 1577 else
1578 {
1579 if(fgcolor)
1580 [result setTextColor:fgcolor];
1581 }
1598 /* Return the result */ 1582 /* Return the result */
1599 return result; 1583 return result;
1600 } 1584 }
1601 return nil; 1585 return nil;
1602 } 1586 }
1693 data = [[[NSMutableArray alloc] init] retain]; 1677 data = [[[NSMutableArray alloc] init] retain];
1694 types = [[[NSMutableArray alloc] init] retain]; 1678 types = [[[NSMutableArray alloc] init] retain];
1695 if(!dw_oddcolor && !dw_evencolor) 1679 if(!dw_oddcolor && !dw_evencolor)
1696 dw_oddcolor = dw_evencolor = DW_CLR_DEFAULT; 1680 dw_oddcolor = dw_evencolor = DW_CLR_DEFAULT;
1697 [self checkDark]; 1681 [self checkDark];
1698 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectionChanged:) name:NSTableViewSelectionDidChangeNotification object:self];
1699 } 1682 }
1700 -(CGSize)getsize 1683 -(CGSize)getsize
1701 { 1684 {
1702 int cwidth = 0, cheight = 0; 1685 int cwidth = 0, cheight = 0;
1703 1686
1687 #if 0 /* TODO: Figure out how to calculate the table size */
1704 if(tvcols) 1688 if(tvcols)
1705 { 1689 {
1706 int z; 1690 int z;
1707 int colcount = (int)[tvcols count]; 1691 int colcount = (int)[tvcols count];
1708 int rowcount = (int)[self numberOfRowsInTableView:self]; 1692 int rowcount = (int)[self numberOfRowsInTableView:self];
1751 } 1735 }
1752 if(width) 1736 if(width)
1753 cwidth += width; 1737 cwidth += width;
1754 } 1738 }
1755 } 1739 }
1740 #endif
1756 cwidth += 16; 1741 cwidth += 16;
1757 cheight += 16; 1742 cheight += 16;
1758 return NSMakeSize(cwidth, cheight); 1743 return CGSizeMake(cwidth, cheight);
1759 }
1760 -(void)optimize
1761 {
1762 if(tvcols)
1763 {
1764 int z;
1765 int colcount = (int)[tvcols count];
1766 int rowcount = (int)[self numberOfRowsInTableView:self];
1767
1768 for(z=0;z<colcount;z++)
1769 {
1770 NSTableColumn *column = [tvcols objectAtIndex:z];
1771 if([column resizingMask] != NSTableColumnNoResizing)
1772 {
1773 if(rowcount > 0)
1774 {
1775 int x;
1776 NSCell *colcell = [column headerCell];
1777 int width = [colcell cellSize].width;
1778
1779 for(x=0;x<rowcount;x++)
1780 {
1781 NSTableCellView *cell = [self viewAtColumn:z row:x makeIfNecessary:YES];
1782 int thiswidth = 4;
1783
1784 if([cell imageView])
1785 thiswidth += [[cell imageView] image].size.width;
1786 if([cell textField])
1787 thiswidth += [[cell textField] intrinsicContentSize].width;
1788
1789 if(thiswidth > width)
1790 {
1791 width = thiswidth;
1792 }
1793 }
1794 /* If the image is missing default the optimized width to 16. */
1795 if(!width && [[types objectAtIndex:z] intValue] & DW_CFA_BITMAPORICON)
1796 {
1797 width = 16;
1798 }
1799 /* Sanity check... don't set the width to 0 */
1800 if(width)
1801 {
1802 [column setWidth:width+1];
1803 }
1804 }
1805 else
1806 {
1807 if(self.headerView)
1808 [column sizeToFit];
1809 }
1810 }
1811 }
1812 }
1813 } 1744 }
1814 -(void)setForegroundColor:(UIColor *)input 1745 -(void)setForegroundColor:(UIColor *)input
1815 { 1746 {
1816 int z, count = (int)[tvcols count]; 1747 int z, count = (int)[tvcols count];
1817 1748
1933 { 1864 {
1934 [node release]; 1865 [node release];
1935 } 1866 }
1936 } 1867 }
1937 1868
1938 /* Subclass for a Tree type */
1939 @interface DWTree : NSOutlineView <NSOutlineViewDataSource,NSOutlineViewDelegate>
1940 {
1941 void *userdata;
1942 NSTableColumn *treecol;
1943 NSMutableArray *data;
1944 /* Each data item consists of a linked lists of tree item data.
1945 * UIImage *, NSString *, Item Data *, NSMutableArray * of Children
1946 */
1947 id scrollview;
1948 UIColor *fgcolor;
1949 }
1950 -(id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item;
1951 -(BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item;
1952 -(int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item;
1953 -(UIView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item;
1954 -(BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item;
1955 -(void)addTree:(NSMutableArray *)item and:(NSMutableArray *)parent after:(NSMutableArray *)after;
1956 -(void *)userdata;
1957 -(void)setUserdata:(void *)input;
1958 -(void)treeSelectionChanged:(id)sender;
1959 -(void)treeItemExpanded:(NSNotification *)notification;
1960 -(UIScrollView *)scrollview;
1961 -(void)setScrollview:(UIScrollView *)input;
1962 -(void)deleteNode:(NSMutableArray *)item;
1963 -(void)setForegroundColor:(UIColor *)input;
1964 -(void)clear;
1965 @end
1966
1967 @implementation DWTree
1968 -(id)init
1969 {
1970 self = [super init];
1971
1972 if (self)
1973 {
1974 treecol = [[NSTableColumn alloc] initWithIdentifier:@"_DWTreeColumn"];
1975 [self addTableColumn:treecol];
1976 [self setOutlineTableColumn:treecol];
1977 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(treeSelectionChanged:) name:NSOutlineViewSelectionDidChangeNotification object:self];
1978 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(treeItemExpanded:) name:NSOutlineViewItemDidExpandNotification object:self];
1979 }
1980 return self;
1981 }
1982 -(id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item
1983 {
1984 if(item)
1985 {
1986 NSMutableArray *array = [item objectAtIndex:3];
1987 return ([array isKindOfClass:[NSNull class]]) ? nil : [array objectAtIndex:index];
1988 }
1989 else
1990 {
1991 return [data objectAtIndex:index];
1992 }
1993 }
1994 -(BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
1995 {
1996 return [self outlineView:outlineView numberOfChildrenOfItem:item] != 0;
1997 }
1998 -(int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
1999 {
2000 if(item)
2001 {
2002 if([item isKindOfClass:[NSMutableArray class]])
2003 {
2004 NSMutableArray *array = [item objectAtIndex:3];
2005 return ([array isKindOfClass:[NSNull class]]) ? 0 : (int)[array count];
2006 }
2007 else
2008 {
2009 return 0;
2010 }
2011 }
2012 else
2013 {
2014 return data ? (int)[data count] : 0;
2015 }
2016 }
2017 -(UIView *)outlineView:(NSOutlineView *)outlineView viewForTableColumn:(NSTableColumn *)tableColumn item:(id)item
2018 {
2019 NSTableCellView *view = [outlineView makeViewWithIdentifier:[tableColumn identifier] owner:self];
2020
2021 if([item isKindOfClass:[NSMutableArray class]])
2022 {
2023 NSMutableArray *this = (NSMutableArray *)item;
2024 UIImage *icon = [this objectAtIndex:0];
2025 NSString *text = [this objectAtIndex:1];
2026 if(![icon isKindOfClass:[UIImage class]])
2027 icon = nil;
2028 if(view)
2029 {
2030 UITextField *tf = [view textField];
2031 UIImageView *iv = [view imageView];
2032
2033 if(tf)
2034 {
2035 [tf setStringValue: text];
2036 if(fgcolor)
2037 [tf setTextColor:fgcolor];
2038 }
2039 if(iv)
2040 [iv setImage:icon];
2041 }
2042 else
2043 view = _dw_table_cell_view_new(icon, text);
2044 }
2045 _dw_table_cell_view_layout(view);
2046 return view;
2047 }
2048 -(BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item { return NO; }
2049 -(void)addTree:(NSMutableArray *)item and:(NSMutableArray *)parent after:(NSMutableArray *)after
2050 {
2051 NSMutableArray *children = data;
2052 if(parent)
2053 {
2054 children = [parent objectAtIndex:3];
2055 if([children isKindOfClass:[NSNull class]])
2056 {
2057 children = [[[NSMutableArray alloc] init] retain];
2058 [parent replaceObjectAtIndex:3 withObject:children];
2059 }
2060 }
2061 else
2062 {
2063 if(!data)
2064 {
2065 children = data = [[[NSMutableArray alloc] init] retain];
2066 }
2067 }
2068 if(after)
2069 {
2070 NSInteger index = [children indexOfObject:after];
2071 int count = (int)[children count];
2072 if(index != NSNotFound && (index+1) < count)
2073 [children insertObject:item atIndex:(index+1)];
2074 else
2075 [children addObject:item];
2076 }
2077 else
2078 {
2079 [children addObject:item];
2080 }
2081 }
2082 -(void *)userdata { return userdata; }
2083 -(void)setUserdata:(void *)input { userdata = input; }
2084 -(void)treeSelectionChanged:(id)sender
2085 {
2086 /* Handler for tree class */
2087 id item = [self itemAtRow:[self selectedRow]];
2088
2089 if(item)
2090 {
2091 _event_handler(self, (void *)item, 12);
2092 }
2093 }
2094 -(void)treeItemExpanded:(NSNotification *)notification
2095 {
2096 id item = [[notification userInfo ] objectForKey: @"NSObject"];
2097
2098 if(item)
2099 {
2100 _event_handler(self, (void *)item, 16);
2101 }
2102 }
2103 -(UIMenu *)menuForEvent:(UIEvent *)event
2104 {
2105 int row;
2106 CGPoint where = [self convertPoint:[event locationInWindow] fromView:nil];
2107 row = (int)[self rowAtPoint:where];
2108 id item = [self itemAtRow:row];
2109 _event_handler(self, (UIEvent *)item, 10);
2110 return nil;
2111 }
2112 -(UIScrollView *)scrollview { return scrollview; }
2113 -(void)setScrollview:(UIScrollView *)input { scrollview = input; }
2114 -(void)deleteNode:(NSMutableArray *)item { _free_tree_recurse(data, item); }
2115 -(void)setForegroundColor:(UIColor *)input
2116 {
2117 UITextFieldCell *cell = [treecol dataCell];
2118 fgcolor = input;
2119 [fgcolor retain];
2120 [cell setTextColor:fgcolor];
2121 }
2122 -(void)clear { NSMutableArray *toclear = data; data = nil; _free_tree_recurse(toclear, NULL); [self reloadData]; }
2123 -(void)keyDown:(UIEvent *)theEvent
2124 {
2125 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
2126
2127 if(vk == NSTabCharacter || vk == NSBackTabCharacter)
2128 [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
2129 [super keyDown:theEvent];
2130 }
2131 -(void)insertTab:(id)sender { if([[self window] firstResponder] == self) [[self window] selectNextKeyView:self]; }
2132 -(void)insertBacktab:(id)sender { if([[self window] firstResponder] == self) [[self window] selectPreviousKeyView:self]; }
2133 -(void)dealloc
2134 {
2135 UserData *root = userdata;
2136 _remove_userdata(&root, NULL, TRUE);
2137 _free_tree_recurse(data, NULL);
2138 [treecol release];
2139 dw_signal_disconnect_by_window(self);
2140 [super dealloc];
2141 }
2142 @end
2143 1869
2144 /* Subclass for a Calendar type */ 1870 /* Subclass for a Calendar type */
2145 @interface DWCalendar : UIDatePicker 1871 @interface DWCalendar : UIDatePicker
2146 { 1872 {
2147 void *userdata; 1873 void *userdata;
2154 -(void *)userdata { return userdata; } 1880 -(void *)userdata { return userdata; }
2155 -(void)setUserdata:(void *)input { userdata = input; } 1881 -(void)setUserdata:(void *)input { userdata = input; }
2156 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; } 1882 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
2157 @end 1883 @end
2158 1884
2159 /* Subclass for a Combobox type */
2160 @interface DWComboBox : NSComboBox <NSComboBoxDelegate>
2161 {
2162 void *userdata;
2163 id clickDefault;
2164 }
2165 -(void *)userdata;
2166 -(void)setUserdata:(void *)input;
2167 -(void)comboBoxSelectionDidChange:(NSNotification *)not;
2168 -(void)setClickDefault:(id)input;
2169 @end
2170
2171 @implementation DWComboBox
2172 -(void *)userdata { return userdata; }
2173 -(void)setUserdata:(void *)input { userdata = input; }
2174 -(void)comboBoxSelectionDidChange:(NSNotification *)not { _event_handler(self, (void *)[self indexOfSelectedItem], 11); }
2175 -(void)setClickDefault:(id)input { clickDefault = input; }
2176 -(void)keyUp:(UIEvent *)theEvent
2177 {
2178 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN)
2179 {
2180 [[self window] makeFirstResponder:clickDefault];
2181 } else
2182 {
2183 [super keyUp:theEvent];
2184 }
2185 }
2186 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); dw_signal_disconnect_by_window(self); [super dealloc]; }
2187 @end
2188
2189 /* Subclass for a stepper component of the spinbutton type */ 1885 /* Subclass for a stepper component of the spinbutton type */
2190 /* This is a bad way of doing this... but I can't get the other methods to work */ 1886 /* This is a bad way of doing this... but I can't get the other methods to work */
2191 @interface DWStepper : UIStepper 1887 @interface DWStepper : UIStepper
2192 { 1888 {
2193 id textfield; 1889 id textfield;
2195 } 1891 }
2196 -(void)setTextfield:(id)input; 1892 -(void)setTextfield:(id)input;
2197 -(id)textfield; 1893 -(id)textfield;
2198 -(void)setParent:(id)input; 1894 -(void)setParent:(id)input;
2199 -(id)parent; 1895 -(id)parent;
2200 -(void)mouseDown:(UIEvent *)event;
2201 -(void)mouseUp:(UIEvent *)event;
2202 @end 1896 @end
2203 1897
2204 @implementation DWStepper 1898 @implementation DWStepper
2205 -(void)setTextfield:(id)input { textfield = input; } 1899 -(void)setTextfield:(id)input { textfield = input; }
2206 -(id)textfield { return textfield; } 1900 -(id)textfield { return textfield; }
2207 -(void)setParent:(id)input { parent = input; } 1901 -(void)setParent:(id)input { parent = input; }
2208 -(id)parent { return parent; } 1902 -(id)parent { return parent; }
2209 -(void)mouseDown:(UIEvent *)event
2210 {
2211 [super mouseDown:event];
2212 if([[NSApp currentEvent] type] == DWEventTypeLeftMouseUp)
2213 [self mouseUp:event];
2214 }
2215 -(void)mouseUp:(UIEvent *)event
2216 {
2217 [textfield takeIntValueFrom:self];
2218 _event_handler(parent, (void *)[self integerValue], 14);
2219 }
2220 -(void)keyDown:(UIEvent *)theEvent
2221 {
2222 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
2223 if(vk == VK_UP || vk == VK_DOWN)
2224 {
2225 if(vk == VK_UP)
2226 [self setIntegerValue:([self integerValue]+[self increment])];
2227 else
2228 [self setIntegerValue:([self integerValue]-[self increment])];
2229 [self mouseUp:theEvent];
2230 }
2231 else
2232 {
2233 [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
2234 [super keyDown:theEvent];
2235 }
2236 }
2237 -(void)insertTab:(id)sender { if([[self window] firstResponder] == self) [[self window] selectNextKeyView:self]; }
2238 -(void)insertBacktab:(id)sender { if([[self window] firstResponder] == self) [[self window] selectPreviousKeyView:self]; }
2239 @end 1903 @end
2240 1904
2241 /* Subclass for a Spinbutton type */ 1905 /* Subclass for a Spinbutton type */
2242 @interface DWSpinButton : UIView <UITextFieldDelegate> 1906 @interface DWSpinButton : UIView <UITextFieldDelegate>
2243 { 1907 {
2261 self = [super init]; 1925 self = [super init];
2262 1926
2263 if(self) 1927 if(self)
2264 { 1928 {
2265 textfield = [[[UITextField alloc] init] autorelease]; 1929 textfield = [[[UITextField alloc] init] autorelease];
2266 /* Workaround for infinite loop in Snow Leopard 10.6 */
2267 if(DWOSMajor == 10 && DWOSMinor < 7)
2268 [textfield setFrameSize:NSMakeSize(10,10)];
2269 [self addSubview:textfield]; 1930 [self addSubview:textfield];
2270 stepper = [[[DWStepper alloc] init] autorelease]; 1931 stepper = [[[DWStepper alloc] init] autorelease];
2271 [self addSubview:stepper]; 1932 [self addSubview:stepper];
2272 [stepper setParent:self]; 1933 [stepper setParent:self];
2273 [stepper setTextfield:textfield]; 1934 [stepper setTextfield:textfield];
2274 [textfield takeIntValueFrom:stepper]; 1935 [textfield setText:[NSString stringWithFormat:@"%ld",(long)[stepper value]]];
2275 [textfield setDelegate:self]; 1936 [textfield setDelegate:self];
2276 } 1937 }
2277 return self; 1938 return self;
2278 } 1939 }
2279 -(void *)userdata { return userdata; } 1940 -(void *)userdata { return userdata; }
2280 -(void)setUserdata:(void *)input { userdata = input; } 1941 -(void)setUserdata:(void *)input { userdata = input; }
2281 -(UITextField *)textfield { return textfield; } 1942 -(UITextField *)textfield { return textfield; }
2282 -(UIStepper *)stepper { return stepper; } 1943 -(UIStepper *)stepper { return stepper; }
2283 -(void)controlTextDidChange:(NSNotification *)aNotification 1944 -(void)controlTextDidChange:(NSNotification *)aNotification
2284 { 1945 {
2285 [stepper takeIntValueFrom:textfield]; 1946 long val = [[textfield text] intValue];
2286 [textfield takeIntValueFrom:stepper]; 1947 [stepper setValue:(float)val];
2287 _event_handler(self, (void *)[stepper integerValue], 14); 1948 _event_handler(self, DW_INT_TO_POINTER(val), 14);
2288 } 1949 }
2289 -(void)setClickDefault:(id)input { clickDefault = input; } 1950 -(void)setClickDefault:(id)input { clickDefault = input; }
2290 -(void)keyUp:(UIEvent *)theEvent 1951 -(void)keyUp:(UIEvent *)theEvent
2291 { 1952 {
2292 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) 1953 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN)
3477 /* Spinbuttons don't need to be as wide */ 3138 /* Spinbuttons don't need to be as wide */
3478 if([object isMemberOfClass:[ DWSpinButton class]]) 3139 if([object isMemberOfClass:[ DWSpinButton class]])
3479 thiswidth = 50; 3140 thiswidth = 50;
3480 else 3141 else
3481 thiswidth = 150; 3142 thiswidth = 150;
3482 /* Comboboxes need some extra height for the border */
3483 if([object isMemberOfClass:[ DWComboBox class]])
3484 extraheight = 4;
3485 /* Yosemite and higher requires even more border space */
3486 if(DWOSMinor > 9 || DWOSMajor > 10)
3487 extraheight += 4;
3488 } 3143 }
3489 else 3144 else
3490 nsstr = [object stringValue]; 3145 nsstr = [object stringValue];
3491 3146
3492 if(font) 3147 if(font)
4117 HWND API dw_spinbutton_new(const char *text, ULONG cid) 3772 HWND API dw_spinbutton_new(const char *text, ULONG cid)
4118 { 3773 {
4119 DWSpinButton *spinbutton = [[DWSpinButton alloc] init]; 3774 DWSpinButton *spinbutton = [[DWSpinButton alloc] init];
4120 UIStepper *stepper = [spinbutton stepper]; 3775 UIStepper *stepper = [spinbutton stepper];
4121 UITextField *textfield = [spinbutton textfield]; 3776 UITextField *textfield = [spinbutton textfield];
3777 long val = atol(text);
3778
4122 [stepper setIncrement:1]; 3779 [stepper setIncrement:1];
4123 [stepper setTag:cid]; 3780 [stepper setTag:cid];
4124 [stepper setMinValue:-65536]; 3781 [stepper setMinValue:-65536];
4125 [stepper setMaxValue:65536]; 3782 [stepper setMaxValue:65536];
4126 [stepper setIntValue:atoi(text)]; 3783 [stepper setValue:(float)val];
4127 [textfield takeIntValueFrom:stepper]; 3784 [textfield setText:[NSString stringWithFormat:@"%ld",val]];
4128 return spinbutton; 3785 return spinbutton;
4129 } 3786 }
4130 3787
4131 /* 3788 /*
4132 * Sets the spinbutton value. 3789 * Sets the spinbutton value.
4137 void API dw_spinbutton_set_pos(HWND handle, long position) 3794 void API dw_spinbutton_set_pos(HWND handle, long position)
4138 { 3795 {
4139 DWSpinButton *spinbutton = handle; 3796 DWSpinButton *spinbutton = handle;
4140 UIStepper *stepper = [spinbutton stepper]; 3797 UIStepper *stepper = [spinbutton stepper];
4141 UITextField *textfield = [spinbutton textfield]; 3798 UITextField *textfield = [spinbutton textfield];
4142 [stepper setIntValue:(int)position]; 3799 [stepper setValue:(float)position];
4143 [textfield takeIntValueFrom:stepper]; 3800 [textfield [NSString stringWithFormat:@"%ld",position]];
4144 } 3801 }
4145 3802
4146 /* 3803 /*
4147 * Sets the spinbutton limits. 3804 * Sets the spinbutton limits.
4148 * Parameters: 3805 * Parameters:
4165 */ 3822 */
4166 long API dw_spinbutton_get_pos(HWND handle) 3823 long API dw_spinbutton_get_pos(HWND handle)
4167 { 3824 {
4168 DWSpinButton *spinbutton = handle; 3825 DWSpinButton *spinbutton = handle;
4169 UIStepper *stepper = [spinbutton stepper]; 3826 UIStepper *stepper = [spinbutton stepper];
4170 return (long)[stepper integerValue]; 3827 return (long)[stepper value];
4171 } 3828 }
4172 3829
4173 /* 3830 /*
4174 * Create a new radiobutton window (widget) to be packed. 3831 * Create a new radiobutton window (widget) to be packed.
4175 * Parameters: 3832 * Parameters:
4177 * id: An ID to be used with dw_window_from_id() or 0L. 3834 * id: An ID to be used with dw_window_from_id() or 0L.
4178 */ 3835 */
4179 HWND API dw_radiobutton_new(const char *text, ULONG cid) 3836 HWND API dw_radiobutton_new(const char *text, ULONG cid)
4180 { 3837 {
4181 DWButton *button = _dw_button_new(text, cid); 3838 DWButton *button = _dw_button_new(text, cid);
4182 /* TODO: Customize to be a radio button */ 3839 /* TODO: Customize to be a radio button https://github.com/DavydLiu/DLRadioButton */
4183 return button; 3840 return button;
4184 } 3841 }
4185 3842
4186 /* 3843 /*
4187 * Create a new slider window (widget) to be packed. 3844 * Create a new slider window (widget) to be packed.
4429 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *) 4086 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, text, char *)
4430 { 4087 {
4431 DW_FUNCTION_INIT; 4088 DW_FUNCTION_INIT;
4432 id object = handle; 4089 id object = handle;
4433 4090
4434 if([object isMemberOfClass:[DWComboBox class]]) 4091 if([object isMemberOfClass:[DWContainer class]])
4435 {
4436 DWComboBox *combo = handle;
4437
4438 [combo addItemWithObjectValue:[NSString stringWithUTF8String:text]];
4439 }
4440 else if([object isMemberOfClass:[DWContainer class]])
4441 { 4092 {
4442 DWContainer *cont = handle; 4093 DWContainer *cont = handle;
4443 NSString *nstr = [NSString stringWithUTF8String:text]; 4094 NSString *nstr = [NSString stringWithUTF8String:text];
4444 NSArray *newrow = [NSArray arrayWithObject:_dw_table_cell_view_new(nil, nstr)]; 4095 NSArray *newrow = [NSArray arrayWithObject:_dw_table_cell_view_new(nil, nstr)];
4445 4096
4446 [cont addRow:newrow]; 4097 [cont addRow:newrow];
4447 [cont reloadData]; 4098 [cont reloadData];
4448 [cont optimize];
4449 [cont setNeedsDisplay]; 4099 [cont setNeedsDisplay];
4450 } 4100 }
4451 DW_FUNCTION_RETURN_NOTHING; 4101 DW_FUNCTION_RETURN_NOTHING;
4452 } 4102 }
4453 4103
4464 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, text, const char *, pos, int) 4114 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, text, const char *, pos, int)
4465 { 4115 {
4466 DW_FUNCTION_INIT; 4116 DW_FUNCTION_INIT;
4467 id object = handle; 4117 id object = handle;
4468 4118
4469 if([object isMemberOfClass:[DWComboBox class]]) 4119 if([object isMemberOfClass:[DWContainer class]])
4470 {
4471 DWComboBox *combo = handle;
4472
4473 [combo insertItemWithObjectValue:[NSString stringWithUTF8String:text] atIndex:pos];
4474 }
4475 else if([object isMemberOfClass:[DWContainer class]])
4476 { 4120 {
4477 DWContainer *cont = handle; 4121 DWContainer *cont = handle;
4478 NSString *nstr = [NSString stringWithUTF8String:text]; 4122 NSString *nstr = [NSString stringWithUTF8String:text];
4479 NSArray *newrow = [NSArray arrayWithObject:_dw_table_cell_view_new(nil, nstr)]; 4123 NSArray *newrow = [NSArray arrayWithObject:_dw_table_cell_view_new(nil, nstr)];
4480 4124
4481 [cont insertRow:newrow at:pos]; 4125 [cont insertRow:newrow at:pos];
4482 [cont reloadData]; 4126 [cont reloadData];
4483 [cont optimize];
4484 [cont setNeedsDisplay]; 4127 [cont setNeedsDisplay];
4485 } 4128 }
4486 DW_FUNCTION_RETURN_NOTHING; 4129 DW_FUNCTION_RETURN_NOTHING;
4487 } 4130 }
4488 4131
4499 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, text, char **, count, int) 4142 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, text, char **, count, int)
4500 { 4143 {
4501 DW_FUNCTION_INIT; 4144 DW_FUNCTION_INIT;
4502 id object = handle; 4145 id object = handle;
4503 4146
4504 if([object isMemberOfClass:[DWComboBox class]]) 4147 if([object isMemberOfClass:[DWContainer class]])
4505 {
4506 DWComboBox *combo = handle;
4507 int z;
4508
4509 for(z=0;z<count;z++)
4510 {
4511 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text[z] ]];
4512 }
4513 }
4514 else if([object isMemberOfClass:[DWContainer class]])
4515 { 4148 {
4516 DWContainer *cont = handle; 4149 DWContainer *cont = handle;
4517 int z; 4150 int z;
4518 4151
4519 for(z=0;z<count;z++) 4152 for(z=0;z<count;z++)
4522 NSArray *newrow = [NSArray arrayWithObjects:_dw_table_cell_view_new(nil, nstr),nil]; 4155 NSArray *newrow = [NSArray arrayWithObjects:_dw_table_cell_view_new(nil, nstr),nil];
4523 4156
4524 [cont addRow:newrow]; 4157 [cont addRow:newrow];
4525 } 4158 }
4526 [cont reloadData]; 4159 [cont reloadData];
4527 [cont optimize];
4528 [cont setNeedsDisplay]; 4160 [cont setNeedsDisplay];
4529 } 4161 }
4530 DW_FUNCTION_RETURN_NOTHING; 4162 DW_FUNCTION_RETURN_NOTHING;
4531 } 4163 }
4532 4164
4541 DW_FUNCTION_RESTORE_PARAM1(handle, HWND) 4173 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
4542 { 4174 {
4543 DW_FUNCTION_INIT; 4175 DW_FUNCTION_INIT;
4544 id object = handle; 4176 id object = handle;
4545 4177
4546 if([object isMemberOfClass:[DWComboBox class]]) 4178 if([object isMemberOfClass:[DWContainer class]])
4547 {
4548 DWComboBox *combo = handle;
4549
4550 [combo removeAllItems];
4551 }
4552 else if([object isMemberOfClass:[DWContainer class]])
4553 { 4179 {
4554 DWContainer *cont = handle; 4180 DWContainer *cont = handle;
4555 4181
4556 [cont clear]; 4182 [cont clear];
4557 [cont reloadData]; 4183 [cont reloadData];
4572 { 4198 {
4573 DW_FUNCTION_INIT; 4199 DW_FUNCTION_INIT;
4574 id object = handle; 4200 id object = handle;
4575 int result = 0; 4201 int result = 0;
4576 4202
4577 if([object isMemberOfClass:[DWComboBox class]]) 4203 if([object isMemberOfClass:[DWContainer class]])
4578 {
4579 DWComboBox *combo = handle;
4580
4581 result = (int)[combo numberOfItems];
4582 }
4583 else if([object isMemberOfClass:[DWContainer class]])
4584 { 4204 {
4585 DWContainer *cont = handle; 4205 DWContainer *cont = handle;
4586 result = (int)[cont numberOfRowsInTableView:cont]; 4206 result = (int)[cont numberOfRowsInTableView:cont];
4587 } 4207 }
4588 DW_FUNCTION_RETURN_THIS(result); 4208 DW_FUNCTION_RETURN_THIS(result);
4600 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, top, int) 4220 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, top, int)
4601 { 4221 {
4602 DW_FUNCTION_INIT; 4222 DW_FUNCTION_INIT;
4603 id object = handle; 4223 id object = handle;
4604 4224
4605 if([object isMemberOfClass:[DWComboBox class]]) 4225 if([object isMemberOfClass:[DWContainer class]])
4606 {
4607 DWComboBox *combo = handle;
4608
4609 [combo scrollItemAtIndexToTop:top];
4610 }
4611 else if([object isMemberOfClass:[DWContainer class]])
4612 { 4226 {
4613 DWContainer *cont = handle; 4227 DWContainer *cont = handle;
4614 4228
4615 [cont scrollRowToVisible:top]; 4229 [cont scrollRowToVisible:top];
4616 } 4230 }
4631 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, index, unsigned int, buffer, char *, length, unsigned int) 4245 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, index, unsigned int, buffer, char *, length, unsigned int)
4632 { 4246 {
4633 DW_FUNCTION_INIT; 4247 DW_FUNCTION_INIT;
4634 id object = handle; 4248 id object = handle;
4635 4249
4636 if([object isMemberOfClass:[DWComboBox class]]) 4250 if([object isMemberOfClass:[DWContainer class]])
4637 {
4638 DWComboBox *combo = handle;
4639 int count = (int)[combo numberOfItems];
4640
4641 if(index > count)
4642 {
4643 *buffer = '\0';
4644 }
4645 else
4646 {
4647 NSString *nstr = [combo itemObjectValueAtIndex:index];
4648 strncpy(buffer, [ nstr UTF8String ], length - 1);
4649 }
4650 }
4651 else if([object isMemberOfClass:[DWContainer class]])
4652 { 4251 {
4653 DWContainer *cont = handle; 4252 DWContainer *cont = handle;
4654 int count = (int)[cont numberOfRowsInTableView:cont]; 4253 int count = (int)[cont numberOfRowsInTableView:cont];
4655 4254
4656 if(index > count) 4255 if(index > count)
4681 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, index, unsigned int, buffer, char *) 4280 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, index, unsigned int, buffer, char *)
4682 { 4281 {
4683 DW_FUNCTION_INIT; 4282 DW_FUNCTION_INIT;
4684 id object = handle; 4283 id object = handle;
4685 4284
4686 if([object isMemberOfClass:[DWComboBox class]]) 4285 if([object isMemberOfClass:[DWContainer class]])
4687 {
4688 DWComboBox *combo = handle;
4689 int count = (int)[combo numberOfItems];
4690
4691 if(index <= count)
4692 {
4693 [combo removeItemAtIndex:index];
4694 [combo insertItemWithObjectValue:[NSString stringWithUTF8String:buffer] atIndex:index];
4695 }
4696 }
4697 else if([object isMemberOfClass:[DWContainer class]])
4698 { 4286 {
4699 DWContainer *cont = handle; 4287 DWContainer *cont = handle;
4700 int count = (int)[cont numberOfRowsInTableView:cont]; 4288 int count = (int)[cont numberOfRowsInTableView:cont];
4701 4289
4702 if(index <= count) 4290 if(index <= count)
4704 NSString *nstr = [NSString stringWithUTF8String:buffer]; 4292 NSString *nstr = [NSString stringWithUTF8String:buffer];
4705 NSTableCellView *cell = [cont getRow:index and:0]; 4293 NSTableCellView *cell = [cont getRow:index and:0];
4706 4294
4707 [[cell textField] setStringValue:nstr]; 4295 [[cell textField] setStringValue:nstr];
4708 [cont reloadData]; 4296 [cont reloadData];
4709 [cont optimize];
4710 [cont setNeedsDisplay]; 4297 [cont setNeedsDisplay];
4711 } 4298 }
4712 } 4299 }
4713 DW_FUNCTION_RETURN_NOTHING; 4300 DW_FUNCTION_RETURN_NOTHING;
4714 } 4301 }
4725 { 4312 {
4726 DW_FUNCTION_INIT; 4313 DW_FUNCTION_INIT;
4727 id object = handle; 4314 id object = handle;
4728 int result = -1; 4315 int result = -1;
4729 4316
4730 if([object isMemberOfClass:[DWComboBox class]]) 4317 if([object isMemberOfClass:[DWContainer class]])
4731 {
4732 DWComboBox *combo = handle;
4733 result = (int)[combo indexOfSelectedItem];
4734 }
4735 else if([object isMemberOfClass:[DWContainer class]])
4736 { 4318 {
4737 DWContainer *cont = handle; 4319 DWContainer *cont = handle;
4738 result = (int)[cont selectedRow]; 4320 result = (int)[cont selectedRow];
4739 } 4321 }
4740 DW_FUNCTION_RETURN_THIS(result); 4322 DW_FUNCTION_RETURN_THIS(result);
4786 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, index, int, state, int) 4368 DW_FUNCTION_RESTORE_PARAM3(handle, HWND, index, int, state, int)
4787 { 4369 {
4788 DW_FUNCTION_INIT; 4370 DW_FUNCTION_INIT;
4789 id object = handle; 4371 id object = handle;
4790 4372
4791 if([object isMemberOfClass:[DWComboBox class]]) 4373 if([object isMemberOfClass:[DWContainer class]])
4792 {
4793 DWComboBox *combo = handle;
4794 if(state)
4795 [combo selectItemAtIndex:index];
4796 else
4797 [combo deselectItemAtIndex:index];
4798 }
4799 else if([object isMemberOfClass:[DWContainer class]])
4800 { 4374 {
4801 DWContainer *cont = handle; 4375 DWContainer *cont = handle;
4802 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)index]; 4376 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)index];
4803 4377
4804 [cont selectRowIndexes:selected byExtendingSelection:YES]; 4378 [cont selectRowIndexes:selected byExtendingSelection:YES];
4819 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, index, int) 4393 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, index, int)
4820 { 4394 {
4821 DW_FUNCTION_INIT; 4395 DW_FUNCTION_INIT;
4822 id object = handle; 4396 id object = handle;
4823 4397
4824 if([object isMemberOfClass:[DWComboBox class]]) 4398 if([object isMemberOfClass:[DWContainer class]])
4825 {
4826 DWComboBox *combo = handle;
4827
4828 [combo removeItemAtIndex:index];
4829 }
4830 else if([object isMemberOfClass:[DWContainer class]])
4831 { 4399 {
4832 DWContainer *cont = handle; 4400 DWContainer *cont = handle;
4833 4401
4834 [cont removeRow:index]; 4402 [cont removeRow:index];
4835 [cont reloadData]; 4403 [cont reloadData];
4842 * Create a new Combobox window (widget) to be packed. 4410 * Create a new Combobox window (widget) to be packed.
4843 * Parameters: 4411 * Parameters:
4844 * text: The default text to be in the combpbox widget. 4412 * text: The default text to be in the combpbox widget.
4845 * id: An ID to be used with dw_window_from_id() or 0L. 4413 * id: An ID to be used with dw_window_from_id() or 0L.
4846 */ 4414 */
4847 DW_FUNCTION_DEFINITION(dw_combobox_new, HWND, const char *text, ULONG cid) 4415 HWND API dw_combobox_new, HWND, const char *text, ULONG cid);
4848 DW_FUNCTION_ADD_PARAM2(text, cid) 4416 {
4849 DW_FUNCTION_RETURN(dw_combobox_new, HWND) 4417 /* TODO: Implment comboboxes. https://www.codeproject.com/Articles/301681/iPhone-ComboBox */
4850 DW_FUNCTION_RESTORE_PARAM2(text, const char *, cid, ULONG) 4418 return 0;
4851 {
4852 DW_FUNCTION_INIT;
4853 DWComboBox *combo = [[DWComboBox alloc] init];
4854 [combo setStringValue:[NSString stringWithUTF8String:text]];
4855 [combo setDelegate:combo];
4856 [combo setTag:cid];
4857 DW_FUNCTION_RETURN_THIS(combo);
4858 } 4419 }
4859 4420
4860 /* 4421 /*
4861 * Create a new Multiline Editbox window (widget) to be packed. 4422 * Create a new Multiline Editbox window (widget) to be packed.
4862 * Parameters: 4423 * Parameters:
5801 /* 5362 /*
5802 * Create a tree object to be packed. 5363 * Create a tree object to be packed.
5803 * Parameters: 5364 * Parameters:
5804 * id: An ID to be used for getting the resource from the 5365 * id: An ID to be used for getting the resource from the
5805 * resource file. 5366 * resource file.
5806 */ 5367 * Returns:
5807 DW_FUNCTION_DEFINITION(dw_tree_new, HWND, ULONG cid) 5368 * A handle to a tree window or NULL on failure.
5808 DW_FUNCTION_ADD_PARAM1(cid) 5369 */
5809 DW_FUNCTION_RETURN(dw_tree_new, HWND) 5370 HWND API dw_tree_new(ULONG cid)
5810 DW_FUNCTION_RESTORE_PARAM1(cid, ULONG) 5371 {
5811 { 5372 /* TODO: Implement tree for iOS if possible */
5812 DW_FUNCTION_INIT; 5373 return 0;
5813 UIScrollView *scrollview = [[UIScrollView alloc] init];
5814 DWTree *tree = [[DWTree alloc] init];
5815
5816 [tree setScrollview:scrollview];
5817 [scrollview setBorderType:NSBezelBorder];
5818 [scrollview setHasVerticalScroller:YES];
5819 [scrollview setAutohidesScrollers:YES];
5820
5821 [tree setAllowsMultipleSelection:NO];
5822 [tree setDataSource:tree];
5823 [tree setDelegate:tree];
5824 [scrollview setDocumentView:tree];
5825 [tree setHeaderView:nil];
5826 [tree setTag:cid];
5827 [tree autorelease];
5828 DW_FUNCTION_RETURN_THIS(tree);
5829 } 5374 }
5830 5375
5831 /* 5376 /*
5832 * Inserts an item into a tree window (widget) after another item. 5377 * Inserts an item into a tree window (widget) after another item.
5833 * Parameters: 5378 * Parameters:
5835 * item: Handle to the item to be positioned after. 5380 * item: Handle to the item to be positioned after.
5836 * title: The text title of the entry. 5381 * title: The text title of the entry.
5837 * icon: Handle to coresponding icon. 5382 * icon: Handle to coresponding icon.
5838 * parent: Parent handle or 0 if root. 5383 * parent: Parent handle or 0 if root.
5839 * itemdata: Item specific data. 5384 * itemdata: Item specific data.
5840 */ 5385 * Returns:
5841 DW_FUNCTION_DEFINITION(dw_tree_insert_after, HTREEITEM, HWND handle, HTREEITEM item, const char *title, HICN icon, HTREEITEM parent, void *itemdata) 5386 * A handle to a tree item or NULL on failure.
5842 DW_FUNCTION_ADD_PARAM6(handle, item, title, icon, parent, itemdata) 5387 */
5843 DW_FUNCTION_RETURN(dw_tree_insert_after, HTREEITEM) 5388 HTREEITEM API dw_tree_insert_after(HWND handle, HTREEITEM item, const char *title, HICN icon, HTREEITEM parent, void *itemdata)
5844 DW_FUNCTION_RESTORE_PARAM6(handle, HWND, item, HTREEITEM, title, char *, icon, HICN, parent, HTREEITEM, itemdata, void *) 5389 {
5845 { 5390 /* TODO: Implement tree for iOS if possible */
5846 DW_FUNCTION_INIT; 5391 return 0;
5847 DWTree *tree = handle;
5848 NSString *nstr = [[NSString stringWithUTF8String:title] retain];
5849 NSMutableArray *treenode = [[[NSMutableArray alloc] init] retain];
5850 if(icon)
5851 [treenode addObject:icon];
5852 else
5853 [treenode addObject:[NSNull null]];
5854 [treenode addObject:nstr];
5855 [treenode addObject:[NSValue valueWithPointer:itemdata]];
5856 [treenode addObject:[NSNull null]];
5857 [tree addTree:treenode and:parent after:item];
5858 if(parent)
5859 [tree reloadItem:parent reloadChildren:YES];
5860 else
5861 [tree reloadData];
5862 DW_FUNCTION_RETURN_THIS(treenode);
5863 } 5392 }
5864 5393
5865 /* 5394 /*
5866 * Inserts an item into a tree window (widget). 5395 * Inserts an item into a tree window (widget).
5867 * Parameters: 5396 * Parameters:
5868 * handle: Handle to the tree to be inserted. 5397 * handle: Handle to the tree to be inserted.
5869 * title: The text title of the entry. 5398 * title: The text title of the entry.
5870 * icon: Handle to coresponding icon. 5399 * icon: Handle to coresponding icon.
5871 * parent: Parent handle or 0 if root. 5400 * parent: Parent handle or 0 if root.
5872 * itemdata: Item specific data. 5401 * itemdata: Item specific data.
5402 * Returns:
5403 * A handle to a tree item or NULL on failure.
5873 */ 5404 */
5874 HTREEITEM API dw_tree_insert(HWND handle, const char *title, HICN icon, HTREEITEM parent, void *itemdata) 5405 HTREEITEM API dw_tree_insert(HWND handle, const char *title, HICN icon, HTREEITEM parent, void *itemdata)
5875 { 5406 {
5876 return dw_tree_insert_after(handle, NULL, title, icon, parent, itemdata); 5407 /* TODO: Implement tree for iOS if possible */
5408 return 0;
5877 } 5409 }
5878 5410
5879 /* 5411 /*
5880 * Gets the text an item in a tree window (widget). 5412 * Gets the text an item in a tree window (widget).
5881 * Parameters: 5413 * Parameters:
5882 * handle: Handle to the tree containing the item. 5414 * handle: Handle to the tree containing the item.
5883 * item: Handle of the item to be modified. 5415 * item: Handle of the item to be modified.
5884 */ 5416 * Returns:
5885 DW_FUNCTION_DEFINITION(dw_tree_get_title, char *, HWND handle, HTREEITEM item) 5417 * A malloc()ed buffer of item text to be dw_free()ed or NULL on error.
5886 DW_FUNCTION_ADD_PARAM2(handle, item) 5418 */
5887 DW_FUNCTION_RETURN(dw_tree_get_title, char *) 5419 char * API dw_tree_get_title(HWND handle, HTREEITEM item)
5888 DW_FUNCTION_RESTORE_PARAM2(DW_UNUSED(handle), HWND, item, HTREEITEM) 5420 {
5889 { 5421 /* TODO: Implement tree for iOS if possible */
5890 DW_FUNCTION_INIT; 5422 return NULL;
5891 char *retval = NULL;
5892 NSMutableArray *array = (NSMutableArray *)item;
5893 NSString *nstr = (NSString *)[array objectAtIndex:1];
5894 retval = strdup([nstr UTF8String]);
5895 DW_FUNCTION_RETURN_THIS(retval);
5896 } 5423 }
5897 5424
5898 /* 5425 /*
5899 * Gets the text an item in a tree window (widget). 5426 * Gets the text an item in a tree window (widget).
5900 * Parameters: 5427 * Parameters:
5901 * handle: Handle to the tree containing the item. 5428 * handle: Handle to the tree containing the item.
5902 * item: Handle of the item to be modified. 5429 * item: Handle of the item to be modified.
5903 */ 5430 * Returns:
5904 DW_FUNCTION_DEFINITION(dw_tree_get_parent, HTREEITEM, HWND handle, HTREEITEM item) 5431 * A handle to a tree item or NULL on failure.
5905 DW_FUNCTION_ADD_PARAM2(handle, item) 5432 */
5906 DW_FUNCTION_RETURN(dw_tree_get_parent, HTREEITEM) 5433 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item)
5907 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM) 5434 {
5908 { 5435 /* TODO: Implement tree for iOS if possible */
5909 DW_FUNCTION_INIT; 5436 return 0;
5910 HTREEITEM parent;
5911 DWTree *tree = handle;
5912
5913 parent = [tree parentForItem:item];
5914 DW_FUNCTION_RETURN_THIS(parent);
5915 } 5437 }
5916 5438
5917 /* 5439 /*
5918 * Sets the text and icon of an item in a tree window (widget). 5440 * Sets the text and icon of an item in a tree window (widget).
5919 * Parameters: 5441 * Parameters:
5920 * handle: Handle to the tree containing the item. 5442 * handle: Handle to the tree containing the item.
5921 * item: Handle of the item to be modified. 5443 * item: Handle of the item to be modified.
5922 * title: The text title of the entry. 5444 * title: The text title of the entry.
5923 * icon: Handle to coresponding icon. 5445 * icon: Handle to coresponding icon.
5924 */ 5446 */
5925 DW_FUNCTION_DEFINITION(dw_tree_item_change, void, HWND handle, HTREEITEM item, const char *title, HICN icon) 5447 void API dw_tree_item_change(HWND handle, HTREEITEM item, const char *title, HICN icon)
5926 DW_FUNCTION_ADD_PARAM4(handle, item, title, icon) 5448 {
5927 DW_FUNCTION_NO_RETURN(dw_tree_item_change) 5449 /* TODO: Implement tree for iOS if possible */
5928 DW_FUNCTION_RESTORE_PARAM4(handle, HWND, item, HTREEITEM, title, char *, icon, HICN) 5450
5929 {
5930 DW_FUNCTION_INIT;
5931 DWTree *tree = handle;
5932 NSMutableArray *array = (NSMutableArray *)item;
5933 DW_LOCAL_POOL_IN;
5934
5935 if(title)
5936 {
5937 NSString *oldstr = [array objectAtIndex:1];
5938 NSString *nstr = [[NSString stringWithUTF8String:title] retain];
5939 [array replaceObjectAtIndex:1 withObject:nstr];
5940 [oldstr release];
5941 }
5942 if(icon)
5943 {
5944 [array replaceObjectAtIndex:0 withObject:icon];
5945 }
5946 NSInteger row = [tree rowForItem:item];
5947 [tree reloadDataForRowIndexes:[NSIndexSet indexSetWithIndex:row]
5948 columnIndexes:[NSIndexSet indexSetWithIndex:0]];
5949 DW_LOCAL_POOL_OUT;
5950 DW_FUNCTION_RETURN_NOTHING;
5951 } 5451 }
5952 5452
5953 /* 5453 /*
5954 * Sets the item data of a tree item. 5454 * Sets the item data of a tree item.
5955 * Parameters: 5455 * Parameters:
5956 * handle: Handle to the tree containing the item. 5456 * handle: Handle to the tree containing the item.
5957 * item: Handle of the item to be modified. 5457 * item: Handle of the item to be modified.
5958 * itemdata: User defined data to be associated with item. 5458 * itemdata: User defined data to be associated with item.
5959 */ 5459 */
5960 DW_FUNCTION_DEFINITION(dw_tree_item_set_data, void, HWND handle, HTREEITEM item, void *itemdata) 5460 void API dw_tree_item_set_data(HWND handle, HTREEITEM item, void *itemdata)
5961 DW_FUNCTION_ADD_PARAM3(handle, item, itemdata) 5461 {
5962 DW_FUNCTION_NO_RETURN(dw_tree_item_set_data) 5462 /* TODO: Implement tree for iOS if possible */
5963 DW_FUNCTION_RESTORE_PARAM3(DW_UNUSED(handle), HWND, item, HTREEITEM, itemdata, void *) 5463
5964 {
5965 DW_FUNCTION_INIT;
5966 NSMutableArray *array = (NSMutableArray *)item;
5967 [array replaceObjectAtIndex:2 withObject:[NSValue valueWithPointer:itemdata]];
5968 DW_FUNCTION_RETURN_NOTHING;
5969 } 5464 }
5970 5465
5971 /* 5466 /*
5972 * Gets the item data of a tree item. 5467 * Gets the item data of a tree item.
5973 * Parameters: 5468 * Parameters:
5974 * handle: Handle to the tree containing the item. 5469 * handle: Handle to the tree containing the item.
5975 * item: Handle of the item to be modified. 5470 * item: Handle of the item to be modified.
5976 */ 5471 * Returns:
5977 DW_FUNCTION_DEFINITION(dw_tree_item_get_data, void *, HWND handle, HTREEITEM item) 5472 * A pointer to tree item data or NULL on failure.
5978 DW_FUNCTION_ADD_PARAM2(handle, item) 5473 */
5979 DW_FUNCTION_RETURN(dw_tree_item_get_data, void *) 5474 void * API dw_tree_item_get_data(HWND handle, HTREEITEM item)
5980 DW_FUNCTION_RESTORE_PARAM2(DW_UNUSED(handle), HWND, item, HTREEITEM) 5475 {
5981 { 5476 /* TODO: Implement tree for iOS if possible */
5982 DW_FUNCTION_INIT; 5477 return NULL;
5983 void *result = NULL;
5984 NSMutableArray *array = (NSMutableArray *)item;
5985 NSValue *value = [array objectAtIndex:2];
5986 if(value)
5987 result = [value pointerValue];
5988 DW_FUNCTION_RETURN_THIS(result);
5989 } 5478 }
5990 5479
5991 /* 5480 /*
5992 * Sets this item as the active selection. 5481 * Sets this item as the active selection.
5993 * Parameters: 5482 * Parameters:
5994 * handle: Handle to the tree window (widget) to be selected. 5483 * handle: Handle to the tree window (widget) to be selected.
5995 * item: Handle to the item to be selected. 5484 * item: Handle to the item to be selected.
5996 */ 5485 */
5997 DW_FUNCTION_DEFINITION(dw_tree_item_select, void, HWND handle, HTREEITEM item) 5486 void API dw_tree_item_select(HWND handle, HTREEITEM item)
5998 DW_FUNCTION_ADD_PARAM2(handle, item) 5487 {
5999 DW_FUNCTION_NO_RETURN(dw_tree_item_select) 5488 /* TODO: Implement tree for iOS if possible */
6000 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
6001 {
6002 DW_FUNCTION_INIT;
6003 DWTree *tree = handle;
6004 NSInteger itemIndex = [tree rowForItem:item];
6005 if(itemIndex > -1)
6006 {
6007 [tree selectRowIndexes:[NSIndexSet indexSetWithIndex:itemIndex] byExtendingSelection:NO];
6008 }
6009 DW_FUNCTION_RETURN_NOTHING;
6010 } 5489 }
6011 5490
6012 /* 5491 /*
6013 * Removes all nodes from a tree. 5492 * Removes all nodes from a tree.
6014 * Parameters: 5493 * Parameters:
6015 * handle: Handle to the window (widget) to be cleared. 5494 * handle: Handle to the window (widget) to be cleared.
6016 */ 5495 */
6017 DW_FUNCTION_DEFINITION(dw_tree_clear, void, HWND handle) 5496 void API dw_tree_clear(HWND handle)
6018 DW_FUNCTION_ADD_PARAM1(handle) 5497 {
6019 DW_FUNCTION_NO_RETURN(dw_tree_clear) 5498 /* TODO: Implement tree for iOS if possible */
6020 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
6021 {
6022 DW_FUNCTION_INIT;
6023 DWTree *tree = handle;
6024 [tree clear];
6025 DW_FUNCTION_RETURN_NOTHING;
6026 } 5499 }
6027 5500
6028 /* 5501 /*
6029 * Expands a node on a tree. 5502 * Expands a node on a tree.
6030 * Parameters: 5503 * Parameters:
6031 * handle: Handle to the tree window (widget). 5504 * handle: Handle to the tree window (widget).
6032 * item: Handle to node to be expanded. 5505 * item: Handle to node to be expanded.
6033 */ 5506 */
6034 DW_FUNCTION_DEFINITION(dw_tree_item_expand, void, HWND handle, HTREEITEM item) 5507 void API dw_tree_item_expand(HWND handle, HTREEITEM item)
6035 DW_FUNCTION_ADD_PARAM2(handle, item) 5508 {
6036 DW_FUNCTION_NO_RETURN(dw_tree_item_expand) 5509 /* TODO: Implement tree for iOS if possible */
6037 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
6038 {
6039 DW_FUNCTION_INIT;
6040 DWTree *tree = handle;
6041 [tree expandItem:item];
6042 DW_FUNCTION_RETURN_NOTHING;
6043 } 5510 }
6044 5511
6045 /* 5512 /*
6046 * Collapses a node on a tree. 5513 * Collapses a node on a tree.
6047 * Parameters: 5514 * Parameters:
6048 * handle: Handle to the tree window (widget). 5515 * handle: Handle to the tree window (widget).
6049 * item: Handle to node to be collapsed. 5516 * item: Handle to node to be collapsed.
6050 */ 5517 */
6051 DW_FUNCTION_DEFINITION(dw_tree_item_collapse, void, HWND handle, HTREEITEM item) 5518 void API dw_tree_item_collapse(HWND handle, HTREEITEM item)
6052 DW_FUNCTION_ADD_PARAM2(handle, item) 5519 {
6053 DW_FUNCTION_NO_RETURN(dw_tree_item_collapse) 5520 /* TODO: Implement tree for iOS if possible */
6054 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
6055 {
6056 DW_FUNCTION_INIT;
6057 DWTree *tree = handle;
6058 [tree collapseItem:item];
6059 DW_FUNCTION_RETURN_NOTHING;
6060 } 5521 }
6061 5522
6062 /* 5523 /*
6063 * Removes a node from a tree. 5524 * Removes a node from a tree.
6064 * Parameters: 5525 * Parameters:
6065 * handle: Handle to the window (widget) to be cleared. 5526 * handle: Handle to the window (widget) to be cleared.
6066 * item: Handle to node to be deleted. 5527 * item: Handle to node to be deleted.
6067 */ 5528 */
6068 DW_FUNCTION_DEFINITION(dw_tree_item_delete, void, HWND handle, HTREEITEM item) 5529 void API dw_tree_item_delete(HWND handle, HTREEITEM item)
6069 DW_FUNCTION_ADD_PARAM2(handle, item) 5530 {
6070 DW_FUNCTION_NO_RETURN(dw_tree_item_delete) 5531 /* TODO: Implement tree for iOS if possible */
6071 DW_FUNCTION_RESTORE_PARAM2(handle, HWND, item, HTREEITEM)
6072 {
6073 DW_FUNCTION_INIT;
6074 DWTree *tree = handle;
6075 [tree deleteNode:item];
6076 [tree reloadData];
6077 DW_FUNCTION_RETURN_NOTHING;
6078 } 5532 }
6079 5533
6080 /* 5534 /*
6081 * Create a container object to be packed. 5535 * Create a container object to be packed.
6082 * Parameters: 5536 * Parameters:
6880 /* 6334 /*
6881 * Optimizes the column widths so that all data is visible. 6335 * Optimizes the column widths so that all data is visible.
6882 * Parameters: 6336 * Parameters:
6883 * handle: Handle to the window (widget) to be optimized. 6337 * handle: Handle to the window (widget) to be optimized.
6884 */ 6338 */
6885 DW_FUNCTION_DEFINITION(dw_container_optimize, void, HWND handle) 6339 void dw_container_optimize(HWND handle)
6886 DW_FUNCTION_ADD_PARAM1(handle) 6340 {
6887 DW_FUNCTION_NO_RETURN(dw_container_optimize) 6341 /* TODO: Not sure if we need to implement this on iOS */
6888 DW_FUNCTION_RESTORE_PARAM1(handle, HWND)
6889 {
6890 DW_FUNCTION_INIT;
6891 DWContainer *cont = handle;
6892 [cont optimize];
6893 DW_FUNCTION_RETURN_NOTHING;
6894 } 6342 }
6895 6343
6896 /* 6344 /*
6897 * Inserts an icon into the taskbar. 6345 * Inserts an icon into the taskbar.
6898 * Parameters: 6346 * Parameters:
8498 } 7946 }
8499 else 7947 else
8500 { 7948 {
8501 if([control isMemberOfClass:[DWSpinButton class]]) 7949 if([control isMemberOfClass:[DWSpinButton class]])
8502 { 7950 {
8503 control = [control textfield];
8504 }
8505 else if([control isMemberOfClass:[DWComboBox class]])
8506 {
8507 /* TODO: Figure out why the combobox can't be
8508 * focused using makeFirstResponder method.
8509 */
8510 control = [control textfield]; 7951 control = [control textfield];
8511 } 7952 }
8512 [object setClickDefault:control]; 7953 [object setClickDefault:control];
8513 } 7954 }
8514 } 7955 }