Mercurial > dwindows
comparison mac/dw.m @ 856:9dc45928a75f
Added method to do column optimizations like on other platforms. Figure out the maximum width for a column and sizing to that.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 31 Mar 2011 20:58:22 +0000 |
parents | 0103a8751ab4 |
children | 718b91ac19d2 |
comparison
equal
deleted
inserted
replaced
855:0103a8751ab4 | 856:9dc45928a75f |
---|---|
1076 -(int)lastAddPoint; | 1076 -(int)lastAddPoint; |
1077 -(int)lastQueryPoint; | 1077 -(int)lastQueryPoint; |
1078 -(void)setLastQueryPoint:(int)input; | 1078 -(void)setLastQueryPoint:(int)input; |
1079 -(void)clear; | 1079 -(void)clear; |
1080 -(void)setup; | 1080 -(void)setup; |
1081 -(void)optimize; | |
1081 -(void)setForegroundColor:(NSColor *)input; | 1082 -(void)setForegroundColor:(NSColor *)input; |
1082 -(void)doubleClicked:(id)sender; | 1083 -(void)doubleClicked:(id)sender; |
1083 -(void)keyUp:(NSEvent *)theEvent; | 1084 -(void)keyUp:(NSEvent *)theEvent; |
1084 -(void)tableView:(NSTableView*)tableView mouseDownInHeaderOfTableColumn:(NSTableColumn *)tableColumn; | 1085 -(void)tableView:(NSTableView*)tableView mouseDownInHeaderOfTableColumn:(NSTableColumn *)tableColumn; |
1085 -(void)selectionChanged:(id)sender; | 1086 -(void)selectionChanged:(id)sender; |
1223 tvcols = [[[NSMutableArray alloc] init] retain]; | 1224 tvcols = [[[NSMutableArray alloc] init] retain]; |
1224 data = [[[NSMutableArray alloc] init] retain]; | 1225 data = [[[NSMutableArray alloc] init] retain]; |
1225 types = [[[NSMutableArray alloc] init] retain]; | 1226 types = [[[NSMutableArray alloc] init] retain]; |
1226 titles = [[NSPointerArray pointerArrayWithWeakObjects] retain]; | 1227 titles = [[NSPointerArray pointerArrayWithWeakObjects] retain]; |
1227 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectionChanged:) name:NSTableViewSelectionDidChangeNotification object:self]; | 1228 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectionChanged:) name:NSTableViewSelectionDidChangeNotification object:self]; |
1229 } | |
1230 -(void)optimize | |
1231 { | |
1232 if(tvcols) | |
1233 { | |
1234 int z; | |
1235 int colcount = (int)[tvcols count]; | |
1236 int rowcount = (int)[self numberOfRowsInTableView:self]; | |
1237 | |
1238 for(z=0;z<colcount;z++) | |
1239 { | |
1240 NSTableColumn *column = [tvcols objectAtIndex:z]; | |
1241 if([column resizingMask] != NSTableColumnNoResizing) | |
1242 { | |
1243 if(rowcount > 0) | |
1244 { | |
1245 int x; | |
1246 int width = 0; | |
1247 | |
1248 for(x=0;x<rowcount;x++) | |
1249 { | |
1250 NSCell *cell = [self preparedCellAtColumn:z row:x]; | |
1251 int thiswidth = [cell cellSize].width; | |
1252 | |
1253 if(thiswidth > width) | |
1254 { | |
1255 width = thiswidth; | |
1256 } | |
1257 } | |
1258 [column setWidth:width]; | |
1259 } | |
1260 else | |
1261 { | |
1262 [column sizeToFit]; | |
1263 } | |
1264 } | |
1265 } | |
1266 } | |
1228 } | 1267 } |
1229 -(void)setForegroundColor:(NSColor *)input | 1268 -(void)setForegroundColor:(NSColor *)input |
1230 { | 1269 { |
1231 int z, count = (int)[tvcols count]; | 1270 int z, count = (int)[tvcols count]; |
1232 | 1271 |
5258 void API dw_container_optimize(HWND handle) | 5297 void API dw_container_optimize(HWND handle) |
5259 { | 5298 { |
5260 int _locked_by_me = FALSE; | 5299 int _locked_by_me = FALSE; |
5261 DW_MUTEX_LOCK; | 5300 DW_MUTEX_LOCK; |
5262 DWContainer *cont = handle; | 5301 DWContainer *cont = handle; |
5263 /*[cont sizeToFit];*/ | 5302 [cont optimize]; |
5303 /* All resizable columns should expand */ | |
5264 [cont setColumnAutoresizingStyle:NSTableViewUniformColumnAutoresizingStyle]; | 5304 [cont setColumnAutoresizingStyle:NSTableViewUniformColumnAutoresizingStyle]; |
5265 DW_MUTEX_UNLOCK; | 5305 DW_MUTEX_UNLOCK; |
5266 } | 5306 } |
5267 | 5307 |
5268 /* | 5308 /* |