comparison mac/dw.m @ 813:7fa26d8cc8d0

Fix for column click handler not working.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Fri, 25 Mar 2011 21:23:43 +0000
parents f8bfb19090f9
children 00fa951abeb5
comparison
equal deleted inserted replaced
812:f8bfb19090f9 813:7fa26d8cc8d0
997 @end 997 @end
998 998
999 /* Subclass for a Container/List type */ 999 /* Subclass for a Container/List type */
1000 @interface DWContainer : NSTableView 1000 @interface DWContainer : NSTableView
1001 #ifdef BUILDING_FOR_SNOW_LEOPARD 1001 #ifdef BUILDING_FOR_SNOW_LEOPARD
1002 <NSTableViewDataSource> 1002 <NSTableViewDataSource,NSTableViewDelegate>
1003 #endif 1003 #endif
1004 { 1004 {
1005 void *userdata; 1005 void *userdata;
1006 NSMutableArray *tvcols; 1006 NSMutableArray *tvcols;
1007 NSMutableArray *data; 1007 NSMutableArray *data;
1008 NSMutableArray *types; 1008 NSMutableArray *types;
1009 NSPointerArray *titles; 1009 NSPointerArray *titles;
1010 NSColor *fgcolor; 1010 NSColor *fgcolor;
1011 int lastAddPoint, lastQueryPoint; 1011 int lastAddPoint, lastQueryPoint;
1012 id scrollview; 1012 id scrollview;
1013 int filesystem;
1013 } 1014 }
1014 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable; 1015 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable;
1015 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow; 1016 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow;
1016 -(BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex; 1017 -(BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
1017 -(void *)userdata; 1018 -(void *)userdata;
1018 -(void)setUserdata:(void *)input; 1019 -(void)setUserdata:(void *)input;
1020 -(void)setFilesystem:(int)input;
1019 -(id)scrollview; 1021 -(id)scrollview;
1020 -(void)setScrollview:(id)input; 1022 -(void)setScrollview:(id)input;
1021 -(void)addColumn:(NSTableColumn *)input andType:(int)type; 1023 -(void)addColumn:(NSTableColumn *)input andType:(int)type;
1022 -(NSTableColumn *)getColumn:(int)col; 1024 -(NSTableColumn *)getColumn:(int)col;
1023 -(int)addRow:(NSArray *)input; 1025 -(int)addRow:(NSArray *)input;
1078 return nil; 1080 return nil;
1079 } 1081 }
1080 -(BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { return NO; } 1082 -(BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { return NO; }
1081 -(void *)userdata { return userdata; } 1083 -(void *)userdata { return userdata; }
1082 -(void)setUserdata:(void *)input { userdata = input; } 1084 -(void)setUserdata:(void *)input { userdata = input; }
1085 -(void)setFilesystem:(int)input { filesystem = input; }
1083 -(id)scrollview { return scrollview; } 1086 -(id)scrollview { return scrollview; }
1084 -(void)setScrollview:(id)input { scrollview = input; } 1087 -(void)setScrollview:(id)input { scrollview = input; }
1085 -(void)addColumn:(NSTableColumn *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } } 1088 -(void)addColumn:(NSTableColumn *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } }
1086 -(NSTableColumn *)getColumn:(int)col { if(tvcols) { return [tvcols objectAtIndex:col]; } return nil; } 1089 -(NSTableColumn *)getColumn:(int)col { if(tvcols) { return [tvcols objectAtIndex:col]; } return nil; }
1087 -(int)insertRow:(NSArray *)input at:(int)index 1090 -(int)insertRow:(NSArray *)input at:(int)index
1195 -(void)doubleClicked:(id)sender 1198 -(void)doubleClicked:(id)sender
1196 { 1199 {
1197 /* Handler for container class */ 1200 /* Handler for container class */
1198 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9); 1201 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9);
1199 } 1202 }
1200 -(void)tableView:(NSTableView*)tableView mouseDownInHeaderOfTableColumn:(NSTableColumn *)tableColumn 1203 -(void)tableView:(NSTableView *)tableView mouseDownInHeaderOfTableColumn:(NSTableColumn *)tableColumn;
1201 { 1204 {
1205 NSUInteger index = [tvcols indexOfObject:tableColumn];
1206
1207 if(filesystem && index > 0)
1208 {
1209 index--;
1210 }
1202 /* Handler for column click class */ 1211 /* Handler for column click class */
1203 _event_handler(self, (NSEvent *)[tvcols indexOfObject:tableColumn], 17); 1212 _event_handler(self, (NSEvent *)index, 17);
1204 } 1213 }
1205 -(void)selectionChanged:(id)sender 1214 -(void)selectionChanged:(id)sender
1206 { 1215 {
1207 /* Handler for container class */ 1216 /* Handler for container class */
1208 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 12); 1217 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 12);
1253 } 1262 }
1254 1263
1255 /* Subclass for a Tree type */ 1264 /* Subclass for a Tree type */
1256 @interface DWTree : NSOutlineView 1265 @interface DWTree : NSOutlineView
1257 #ifdef BUILDING_FOR_SNOW_LEOPARD 1266 #ifdef BUILDING_FOR_SNOW_LEOPARD
1258 <NSOutlineViewDataSource> 1267 <NSOutlineViewDataSource,NSOutlineViewDelegate>
1259 #endif 1268 #endif
1260 { 1269 {
1261 void *userdata; 1270 void *userdata;
1262 NSTableColumn *imagecol; 1271 NSTableColumn *imagecol;
1263 NSTableColumn *textcol; 1272 NSTableColumn *textcol;
3199 else 3208 else
3200 { 3209 {
3201 [cont setAllowsMultipleSelection:NO]; 3210 [cont setAllowsMultipleSelection:NO];
3202 } 3211 }
3203 [cont setDataSource:cont]; 3212 [cont setDataSource:cont];
3213 [cont setDelegate:cont];
3204 [scrollview setDocumentView:cont]; 3214 [scrollview setDocumentView:cont];
3205 [cont setTag:cid]; 3215 [cont setTag:cid];
3206 [scrollview release]; 3216 [scrollview release];
3207 return cont; 3217 return cont;
3208 } 3218 }
4565 */ 4575 */
4566 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count) 4576 int API dw_filesystem_setup(HWND handle, unsigned long *flags, char **titles, int count)
4567 { 4577 {
4568 char **newtitles = malloc(sizeof(char *) * (count + 2)); 4578 char **newtitles = malloc(sizeof(char *) * (count + 2));
4569 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2)); 4579 unsigned long *newflags = malloc(sizeof(unsigned long) * (count + 2));
4580 DWContainer *cont = handle;
4570 4581
4571 newtitles[0] = "Icon"; 4582 newtitles[0] = "Icon";
4572 newtitles[1] = "Filename"; 4583 newtitles[1] = "Filename";
4573 4584
4574 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR; 4585 newflags[0] = DW_CFA_BITMAPORICON | DW_CFA_LEFT | DW_CFA_HORZSEPARATOR;
4576 4587
4577 memcpy(&newtitles[2], titles, sizeof(char *) * count); 4588 memcpy(&newtitles[2], titles, sizeof(char *) * count);
4578 memcpy(&newflags[2], flags, sizeof(unsigned long) * count); 4589 memcpy(&newflags[2], flags, sizeof(unsigned long) * count);
4579 4590
4580 dw_container_setup(handle, newflags, newtitles, count + 2, 0); 4591 dw_container_setup(handle, newflags, newtitles, count + 2, 0);
4592 [cont setFilesystem:YES];
4581 4593
4582 free(newtitles); 4594 free(newtitles);
4583 free(newflags); 4595 free(newflags);
4584 return TRUE; 4596 return TRUE;
4585 } 4597 }