Mercurial > dwindows
comparison mac/dw.m @ 668:7b99731c6484
Fixes for splitbars (horizontal and vertical definitions are reversed).
Fixes for container and listbox scrolling. Removed header view from listbox.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 27 Feb 2011 00:10:48 +0000 |
parents | 28727d9a835c |
children | 62aae18e7b7d |
comparison
equal
deleted
inserted
replaced
667:28727d9a835c | 668:7b99731c6484 |
---|---|
458 } | 458 } |
459 -(void)setDialog:(DWDialog *)input { dialog = input; } | 459 -(void)setDialog:(DWDialog *)input { dialog = input; } |
460 @end | 460 @end |
461 | 461 |
462 /* Subclass for a splitbar type */ | 462 /* Subclass for a splitbar type */ |
463 @interface DWSplitBar : NSSplitView { } | 463 @interface DWSplitBar : NSSplitView <NSSplitViewDelegate> { } |
464 - (void)splitViewDidResizeSubviews:(NSNotification *)aNotification; | 464 - (void)splitViewDidResizeSubviews:(NSNotification *)aNotification; |
465 @end | 465 @end |
466 | 466 |
467 @implementation DWSplitBar | 467 @implementation DWSplitBar |
468 - (void)splitViewDidResizeSubviews:(NSNotification *)aNotification | 468 - (void)splitViewDidResizeSubviews:(NSNotification *)aNotification |
564 NSMutableArray *tvcols; | 564 NSMutableArray *tvcols; |
565 NSMutableArray *data; | 565 NSMutableArray *data; |
566 NSMutableArray *types; | 566 NSMutableArray *types; |
567 NSPointerArray *titles; | 567 NSPointerArray *titles; |
568 int lastAddPoint; | 568 int lastAddPoint; |
569 id scrollview; | |
569 } | 570 } |
570 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable; | 571 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable; |
571 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow; | 572 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow; |
572 -(void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex; | 573 -(void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex; |
573 -(void *)userdata; | 574 -(void *)userdata; |
574 -(void)setUserdata:(void *)input; | 575 -(void)setUserdata:(void *)input; |
576 -(id)scrollview; | |
577 -(void)setScrollview:(id)input; | |
575 -(void)addColumn:(NSTableColumn *)input andType:(int)type; | 578 -(void)addColumn:(NSTableColumn *)input andType:(int)type; |
576 -(int)addRow:(NSArray *)input; | 579 -(int)addRow:(NSArray *)input; |
577 -(int)addRows:(int)number; | 580 -(int)addRows:(int)number; |
578 -(void)editCell:(id)input at:(int)row and:(int)col; | 581 -(void)editCell:(id)input at:(int)row and:(int)col; |
579 -(void)removeRow:(int)row; | 582 -(void)removeRow:(int)row; |
646 } | 649 } |
647 } | 650 } |
648 } | 651 } |
649 -(void *)userdata { return userdata; } | 652 -(void *)userdata { return userdata; } |
650 -(void)setUserdata:(void *)input { userdata = input; } | 653 -(void)setUserdata:(void *)input { userdata = input; } |
654 -(NSScrollView *)scrollview { return scrollview; } | |
655 -(void)setScrollview:(NSScrollView *)input { scrollview = input; } | |
651 -(void)addColumn:(NSTableColumn *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } } | 656 -(void)addColumn:(NSTableColumn *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } } |
652 -(int)addRow:(NSArray *)input { if(data) { [data addObjectsFromArray:input]; [titles addPointer:NULL]; return (int)[titles count]; } return 0; } | 657 -(int)addRow:(NSArray *)input { if(data) { [data addObjectsFromArray:input]; [titles addPointer:NULL]; return (int)[titles count]; } return 0; } |
653 -(int)addRows:(int)number | 658 -(int)addRows:(int)number |
654 { | 659 { |
655 if(tvcols) | 660 if(tvcols) |
1744 | 1749 |
1745 thisbox = [view box]; | 1750 thisbox = [view box]; |
1746 thisitem = thisbox->items; | 1751 thisitem = thisbox->items; |
1747 object = item; | 1752 object = item; |
1748 | 1753 |
1754 /* Query the objects */ | |
1755 if([ object isKindOfClass:[ DWContainer class ] ]) | |
1756 { | |
1757 DWContainer *cont = item; | |
1758 this = item = [cont scrollview]; | |
1759 } | |
1760 | |
1749 /* Duplicate the existing data */ | 1761 /* Duplicate the existing data */ |
1750 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); | 1762 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); |
1751 | 1763 |
1752 for(z=0;z<thisbox->count;z++) | 1764 for(z=0;z<thisbox->count;z++) |
1753 { | 1765 { |
1822 | 1834 |
1823 thisbox = [view box]; | 1835 thisbox = [view box]; |
1824 thisitem = thisbox->items; | 1836 thisitem = thisbox->items; |
1825 object = item; | 1837 object = item; |
1826 | 1838 |
1839 /* Query the objects */ | |
1840 if([ object isKindOfClass:[ DWContainer class ] ]) | |
1841 { | |
1842 DWContainer *cont = item; | |
1843 this = item = [cont scrollview]; | |
1844 } | |
1845 | |
1827 /* Duplicate the existing data */ | 1846 /* Duplicate the existing data */ |
1828 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); | 1847 tmpitem = malloc(sizeof(Item)*(thisbox->count+1)); |
1829 | 1848 |
1830 for(z=0;z<thisbox->count;z++) | 1849 for(z=0;z<thisbox->count;z++) |
1831 { | 1850 { |
2213 } | 2232 } |
2214 | 2233 |
2215 /* Common code for containers and listboxes */ | 2234 /* Common code for containers and listboxes */ |
2216 HWND _cont_new(ULONG id, int multi) | 2235 HWND _cont_new(ULONG id, int multi) |
2217 { | 2236 { |
2237 NSScrollView *scrollview = [[NSScrollView alloc] init]; | |
2218 DWContainer *cont = [[DWContainer alloc] init]; | 2238 DWContainer *cont = [[DWContainer alloc] init]; |
2239 | |
2240 [cont setScrollview:scrollview]; | |
2241 [scrollview setBorderType:NSBezelBorder]; | |
2242 [scrollview setHasVerticalScroller:YES]; | |
2243 [scrollview setAutohidesScrollers:YES]; | |
2244 | |
2219 if(multi) | 2245 if(multi) |
2220 { | 2246 { |
2221 [cont setAllowsMultipleSelection:YES]; | 2247 [cont setAllowsMultipleSelection:YES]; |
2222 } | 2248 } |
2223 else | 2249 else |
2224 { | 2250 { |
2225 [cont setAllowsMultipleSelection:NO]; | 2251 [cont setAllowsMultipleSelection:NO]; |
2226 } | 2252 } |
2227 [cont setDataSource:cont]; | 2253 [cont setDataSource:cont]; |
2254 [scrollview setDocumentView:cont]; | |
2228 return cont; | 2255 return cont; |
2229 } | 2256 } |
2230 | 2257 |
2231 /* | 2258 /* |
2232 * Create a new listbox window (widget) to be packed. | 2259 * Create a new listbox window (widget) to be packed. |
2235 * multi: Multiple select TRUE or FALSE. | 2262 * multi: Multiple select TRUE or FALSE. |
2236 */ | 2263 */ |
2237 HWND API dw_listbox_new(ULONG id, int multi) | 2264 HWND API dw_listbox_new(ULONG id, int multi) |
2238 { | 2265 { |
2239 DWContainer *cont = _cont_new(id, multi); | 2266 DWContainer *cont = _cont_new(id, multi); |
2267 [cont setHeaderView:nil]; | |
2240 int type = DW_CFA_STRING; | 2268 int type = DW_CFA_STRING; |
2241 [cont setup]; | 2269 [cont setup]; |
2242 NSTableColumn *column = [[NSTableColumn alloc] init]; | 2270 NSTableColumn *column = [[NSTableColumn alloc] init]; |
2243 [cont addTableColumn:column]; | 2271 [cont addTableColumn:column]; |
2244 [cont addColumn:column andType:type]; | 2272 [cont addColumn:column andType:type]; |
3123 * resource file. | 3151 * resource file. |
3124 */ | 3152 */ |
3125 HWND API dw_container_new(ULONG id, int multi) | 3153 HWND API dw_container_new(ULONG id, int multi) |
3126 { | 3154 { |
3127 DWContainer *cont = _cont_new(id, multi); | 3155 DWContainer *cont = _cont_new(id, multi); |
3156 NSScrollView *scrollview = [cont scrollview]; | |
3157 [scrollview setHasHorizontalScroller:YES]; | |
3128 NSTableHeaderView *header = [[NSTableHeaderView alloc] init]; | 3158 NSTableHeaderView *header = [[NSTableHeaderView alloc] init]; |
3129 [cont setHeaderView:header]; | 3159 [cont setHeaderView:header]; |
3130 return cont; | 3160 return cont; |
3131 } | 3161 } |
3132 | 3162 |
3590 * A handle to a splitbar window or NULL on failure. | 3620 * A handle to a splitbar window or NULL on failure. |
3591 */ | 3621 */ |
3592 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) | 3622 HWND API dw_splitbar_new(int type, HWND topleft, HWND bottomright, unsigned long id) |
3593 { | 3623 { |
3594 DWSplitBar *split = [[DWSplitBar alloc] init]; | 3624 DWSplitBar *split = [[DWSplitBar alloc] init]; |
3595 [split addSubview:topleft]; | 3625 HWND tmpbox = dw_box_new(DW_VERT, 0); |
3596 [split addSubview:bottomright]; | 3626 [split setDelegate:split]; |
3627 dw_box_pack_start(tmpbox, topleft, 0, 0, TRUE, TRUE, 0); | |
3628 [split addSubview:tmpbox]; | |
3629 tmpbox = dw_box_new(DW_VERT, 0); | |
3630 dw_box_pack_start(tmpbox, bottomright, 0, 0, TRUE, TRUE, 0); | |
3631 [split addSubview:tmpbox]; | |
3597 if(type == DW_VERT) | 3632 if(type == DW_VERT) |
3598 { | 3633 { |
3599 [split setVertical:YES]; | 3634 [split setVertical:NO]; |
3600 } | 3635 } |
3636 else | |
3637 { | |
3638 [split setVertical:YES]; | |
3639 } | |
3601 return split; | 3640 return split; |
3602 } | 3641 } |
3603 | 3642 |
3604 /* | 3643 /* |
3605 * Sets the position of a splitbar (pecentage). | 3644 * Sets the position of a splitbar (pecentage). |
4357 if([window isMiniaturized]) | 4396 if([window isMiniaturized]) |
4358 { | 4397 { |
4359 [window deminiaturize:nil]; | 4398 [window deminiaturize:nil]; |
4360 } | 4399 } |
4361 [[window contentView] windowResized:nil]; | 4400 [[window contentView] windowResized:nil]; |
4401 [[window contentView] windowDidBecomeMain:nil]; | |
4362 } | 4402 } |
4363 return 0; | 4403 return 0; |
4364 } | 4404 } |
4365 | 4405 |
4366 /* | 4406 /* |