Mercurial > dwindows
comparison mac/dw.m @ 810:746cdd753e7a
Added coloring support for the Container/Tree/Listbox controls.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 24 Mar 2011 21:05:25 +0000 |
parents | 1ef0f4c03c14 |
children | 50ed3e92215b |
comparison
equal
deleted
inserted
replaced
809:1ef0f4c03c14 | 810:746cdd753e7a |
---|---|
1002 void *userdata; | 1002 void *userdata; |
1003 NSMutableArray *tvcols; | 1003 NSMutableArray *tvcols; |
1004 NSMutableArray *data; | 1004 NSMutableArray *data; |
1005 NSMutableArray *types; | 1005 NSMutableArray *types; |
1006 NSPointerArray *titles; | 1006 NSPointerArray *titles; |
1007 NSColor *fgcolor; | |
1007 int lastAddPoint, lastQueryPoint; | 1008 int lastAddPoint, lastQueryPoint; |
1008 id scrollview; | 1009 id scrollview; |
1009 } | 1010 } |
1010 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable; | 1011 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable; |
1011 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow; | 1012 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow; |
1027 -(int)lastAddPoint; | 1028 -(int)lastAddPoint; |
1028 -(int)lastQueryPoint; | 1029 -(int)lastQueryPoint; |
1029 -(void)setLastQueryPoint:(int)input; | 1030 -(void)setLastQueryPoint:(int)input; |
1030 -(void)clear; | 1031 -(void)clear; |
1031 -(void)setup; | 1032 -(void)setup; |
1033 -(void)setForegroundColor:(NSColor *)input; | |
1032 -(void)doubleClicked:(id)sender; | 1034 -(void)doubleClicked:(id)sender; |
1033 -(void)tableView:(NSTableView*)tableView mouseDownInHeaderOfTableColumn:(NSTableColumn *)tableColumn; | 1035 -(void)tableView:(NSTableView*)tableView mouseDownInHeaderOfTableColumn:(NSTableColumn *)tableColumn; |
1034 -(void)selectionChanged:(id)sender; | 1036 -(void)selectionChanged:(id)sender; |
1035 -(NSMenu *)menuForEvent:(NSEvent *)event; | 1037 -(NSMenu *)menuForEvent:(NSEvent *)event; |
1036 @end | 1038 @end |
1170 tvcols = [[[NSMutableArray alloc] init] retain]; | 1172 tvcols = [[[NSMutableArray alloc] init] retain]; |
1171 data = [[[NSMutableArray alloc] init] retain]; | 1173 data = [[[NSMutableArray alloc] init] retain]; |
1172 types = [[[NSMutableArray alloc] init] retain]; | 1174 types = [[[NSMutableArray alloc] init] retain]; |
1173 titles = [[NSPointerArray pointerArrayWithWeakObjects] retain]; | 1175 titles = [[NSPointerArray pointerArrayWithWeakObjects] retain]; |
1174 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectionChanged:) name:NSTableViewSelectionDidChangeNotification object:self]; | 1176 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectionChanged:) name:NSTableViewSelectionDidChangeNotification object:self]; |
1177 } | |
1178 -(void)setForegroundColor:(NSColor *)input | |
1179 { | |
1180 int z, count = (int)[tvcols count]; | |
1181 | |
1182 fgcolor = input; | |
1183 [fgcolor retain]; | |
1184 | |
1185 for(z=0;z<count;z++) | |
1186 { | |
1187 NSTableColumn *tableColumn = [tvcols objectAtIndex:z]; | |
1188 NSTextFieldCell *cell = [tableColumn dataCell]; | |
1189 [cell setTextColor:fgcolor]; | |
1190 } | |
1175 } | 1191 } |
1176 -(void)doubleClicked:(id)sender | 1192 -(void)doubleClicked:(id)sender |
1177 { | 1193 { |
1178 /* Handler for container class */ | 1194 /* Handler for container class */ |
1179 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9); | 1195 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9); |
1245 NSMutableArray *data; | 1261 NSMutableArray *data; |
1246 /* Each data item consists of a linked lists of tree item data. | 1262 /* Each data item consists of a linked lists of tree item data. |
1247 * NSImage *, NSString *, Item Data *, NSMutableArray * of Children | 1263 * NSImage *, NSString *, Item Data *, NSMutableArray * of Children |
1248 */ | 1264 */ |
1249 id scrollview; | 1265 id scrollview; |
1266 NSColor *fgcolor; | |
1250 } | 1267 } |
1251 -(id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item; | 1268 -(id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item; |
1252 -(BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item; | 1269 -(BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item; |
1253 -(int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item; | 1270 -(int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item; |
1254 -(id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item; | 1271 -(id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item; |
1259 -(void)treeSelectionChanged:(id)sender; | 1276 -(void)treeSelectionChanged:(id)sender; |
1260 -(void)treeItemExpanded:(NSNotification *)notification; | 1277 -(void)treeItemExpanded:(NSNotification *)notification; |
1261 -(NSScrollView *)scrollview; | 1278 -(NSScrollView *)scrollview; |
1262 -(void)setScrollview:(NSScrollView *)input; | 1279 -(void)setScrollview:(NSScrollView *)input; |
1263 -(void)deleteNode:(NSPointerArray *)item; | 1280 -(void)deleteNode:(NSPointerArray *)item; |
1281 -(void)setForegroundColor:(NSColor *)input; | |
1264 -(void)clear; | 1282 -(void)clear; |
1265 @end | 1283 @end |
1266 | 1284 |
1267 @implementation DWTree | 1285 @implementation DWTree |
1268 -(id)init | 1286 -(id)init |
1395 return nil; | 1413 return nil; |
1396 } | 1414 } |
1397 -(NSScrollView *)scrollview { return scrollview; } | 1415 -(NSScrollView *)scrollview { return scrollview; } |
1398 -(void)setScrollview:(NSScrollView *)input { scrollview = input; } | 1416 -(void)setScrollview:(NSScrollView *)input { scrollview = input; } |
1399 -(void)deleteNode:(NSPointerArray *)item { _free_tree_recurse(data, item); } | 1417 -(void)deleteNode:(NSPointerArray *)item { _free_tree_recurse(data, item); } |
1418 -(void)setForegroundColor:(NSColor *)input | |
1419 { | |
1420 NSTextFieldCell *cell = [textcol dataCell]; | |
1421 fgcolor = input; | |
1422 [fgcolor retain]; | |
1423 [cell setTextColor:fgcolor]; | |
1424 } | |
1400 -(void)clear { NSMutableArray *toclear = data; data = nil; _free_tree_recurse(toclear, NULL); [self reloadData]; } | 1425 -(void)clear { NSMutableArray *toclear = data; data = nil; _free_tree_recurse(toclear, NULL); [self reloadData]; } |
1401 -(void)dealloc | 1426 -(void)dealloc |
1402 { | 1427 { |
1403 UserData *root = userdata; | 1428 UserData *root = userdata; |
1404 _remove_userdata(&root, NULL, TRUE); | 1429 _remove_userdata(&root, NULL, TRUE); |
6084 { | 6109 { |
6085 DWButton *button = object; | 6110 DWButton *button = object; |
6086 | 6111 |
6087 [[button cell] setBackgroundColor:bg]; | 6112 [[button cell] setBackgroundColor:bg]; |
6088 } | 6113 } |
6114 else if([object isKindOfClass:[NSTableView class]]) | |
6115 { | |
6116 DWContainer *cont = handle; | |
6117 | |
6118 [cont setBackgroundColor:bg]; | |
6119 [cont setForegroundColor:fg]; | |
6120 } | |
6089 return 0; | 6121 return 0; |
6090 } | 6122 } |
6091 | 6123 |
6092 /* | 6124 /* |
6093 * Sets the font used by a specified window (widget) handle. | 6125 * Sets the font used by a specified window (widget) handle. |