comparison mac/dw.m @ 708:5fe2ca5ef88b

Fixes for container event handling. Also made container/listbox cells non-editable.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Sat, 12 Mar 2011 02:54:04 +0000
parents 86d76fc09237
children 5a268d5f1cfa
comparison
equal deleted inserted replaced
707:86d76fc09237 708:5fe2ca5ef88b
703 { 703 {
704 double proportion = [self knobProportion]; 704 double proportion = [self knobProportion];
705 int result = (int)([self doubleValue] * range); 705 int result = (int)([self doubleValue] * range);
706 int newpos = result; 706 int newpos = result;
707 int page = (int)(proportion * range); 707 int page = (int)(proportion * range);
708 int max = (int)(range - page);
709 708
710 switch ([sender hitPart]) 709 switch ([sender hitPart])
711 { 710 {
712 711
713 case NSScrollerDecrementLine: 712 case NSScrollerDecrementLine:
810 int lastAddPoint, lastQueryPoint; 809 int lastAddPoint, lastQueryPoint;
811 id scrollview; 810 id scrollview;
812 } 811 }
813 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable; 812 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable;
814 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow; 813 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow;
815 /*-(void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex;*/ 814 -(BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex;
816 -(void *)userdata; 815 -(void *)userdata;
817 -(void)setUserdata:(void *)input; 816 -(void)setUserdata:(void *)input;
818 -(id)scrollview; 817 -(id)scrollview;
819 -(void)setScrollview:(id)input; 818 -(void)setScrollview:(id)input;
820 -(void)addColumn:(NSTableColumn *)input andType:(int)type; 819 -(void)addColumn:(NSTableColumn *)input andType:(int)type;
830 -(int)lastAddPoint; 829 -(int)lastAddPoint;
831 -(int)lastQueryPoint; 830 -(int)lastQueryPoint;
832 -(void)setLastQueryPoint:(int)input; 831 -(void)setLastQueryPoint:(int)input;
833 -(void)clear; 832 -(void)clear;
834 -(void)setup; 833 -(void)setup;
834 -(void)doubleClicked:(id)sender;
835 -(void)selectionChanged:(id)sender; 835 -(void)selectionChanged:(id)sender;
836 -(NSMenu *)menuForEvent:(NSEvent *)event; 836 -(NSMenu *)menuForEvent:(NSEvent *)event;
837 @end 837 @end
838 838
839 @implementation DWContainer 839 @implementation DWContainer
871 return ([this isKindOfClass:[NSNull class]]) ? nil : this; 871 return ([this isKindOfClass:[NSNull class]]) ? nil : this;
872 } 872 }
873 } 873 }
874 return nil; 874 return nil;
875 } 875 }
876 /*-(void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex 876 -(BOOL)tableView:(NSTableView *)aTableView shouldEditTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex { return NO; }
877 {
878 if(tvcols)
879 {
880 int z, col = -1;
881 int count = (int)[tvcols count];
882
883 for(z=0;z<count;z++)
884 {
885 if([tvcols objectAtIndex:z] == aTableColumn)
886 {
887 col = z;
888 break;
889 }
890 }
891 if(col != -1)
892 {
893 int index = (int)(rowIndex * count) + col;
894 [data replaceObjectAtIndex:index withObject:anObject];
895 }
896 }
897 }*/
898 -(void *)userdata { return userdata; } 877 -(void *)userdata { return userdata; }
899 -(void)setUserdata:(void *)input { userdata = input; } 878 -(void)setUserdata:(void *)input { userdata = input; }
900 -(NSScrollView *)scrollview { return scrollview; } 879 -(NSScrollView *)scrollview { return scrollview; }
901 -(void)setScrollview:(NSScrollView *)input { scrollview = input; } 880 -(void)setScrollview:(NSScrollView *)input { scrollview = input; }
902 -(void)addColumn:(NSTableColumn *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } } 881 -(void)addColumn:(NSTableColumn *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } }
993 data = [[[NSMutableArray alloc] init] retain]; 972 data = [[[NSMutableArray alloc] init] retain];
994 types = [[[NSMutableArray alloc] init] retain]; 973 types = [[[NSMutableArray alloc] init] retain];
995 titles = [[NSPointerArray pointerArrayWithWeakObjects] retain]; 974 titles = [[NSPointerArray pointerArrayWithWeakObjects] retain];
996 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectionChanged:) name:NSTableViewSelectionDidChangeNotification object:[self window]]; 975 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectionChanged:) name:NSTableViewSelectionDidChangeNotification object:[self window]];
997 } 976 }
998 -(void)selectionChanged:(id)sender 977 -(void)doubleClicked:(id)sender
999 { 978 {
1000 /* Handler for container class */ 979 /* Handler for container class */
1001 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9); 980 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9);
981 }
982 -(void)selectionChanged:(id)sender
983 {
984 /* Handler for container class */
985 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 12);
1002 /* Handler for listbox class */ 986 /* Handler for listbox class */
1003 _event_handler(self, (NSEvent *)(int)[self selectedRow], 11); 987 _event_handler(self, (NSEvent *)(int)[self selectedRow], 11);
1004 } 988 }
1005 -(NSMenu *)menuForEvent:(NSEvent *)event 989 -(NSMenu *)menuForEvent:(NSEvent *)event
1006 { 990 {
3967 */ 3951 */
3968 HWND API dw_container_new(ULONG cid, int multi) 3952 HWND API dw_container_new(ULONG cid, int multi)
3969 { 3953 {
3970 int _locked_by_me = FALSE; 3954 int _locked_by_me = FALSE;
3971 DW_MUTEX_LOCK; 3955 DW_MUTEX_LOCK;
3972 DWContainer *cont = _cont_new(cid, multi); 3956 DWContainer *cont = _cont_new(cid, multi);
3973 NSScrollView *scrollview = [cont scrollview]; 3957 NSScrollView *scrollview = [cont scrollview];
3974 [scrollview setHasHorizontalScroller:YES]; 3958 [scrollview setHasHorizontalScroller:YES];
3975 NSTableHeaderView *header = [[NSTableHeaderView alloc] init]; 3959 NSTableHeaderView *header = [[NSTableHeaderView alloc] init];
3976 [cont setHeaderView:header]; 3960 [cont setHeaderView:header];
3961 [cont setTarget:cont];
3962 [cont setDoubleAction:@selector(doubleClicked:)];
3977 [header release]; 3963 [header release];
3978 DW_MUTEX_UNLOCK; 3964 DW_MUTEX_UNLOCK;
3979 return cont; 3965 return cont;
3980 } 3966 }
3981 3967
3982 /* 3968 /*
3983 * Sets up the container columns. 3969 * Sets up the container columns.
3984 * Parameters: 3970 * Parameters: