]> Dogcows Code - chaz/thecheat/blob - VariableTable.m
Remove support of Mac OS X 10.3 and earlier system, change codes for Mac OS X 10.7.
[chaz/thecheat] / VariableTable.m
1
2 /*
3 * The Cheat - The legendary universal game trainer for Mac OS X.
4 * http://www.brokenzipper.com/trac/wiki/TheCheat
5 *
6 * Copyright (c) 2003-2011, Charles McGarvey et al.
7 *
8 * Distributable under the terms and conditions of the 2-clause BSD
9 * license; see the file COPYING for the legal text of the license.
10 */
11
12
13 #import "VariableTable.h"
14
15
16 @interface VariableTable ( PrivateAPI )
17
18 - (void)_setVisibleRows:(NSRange)rows;
19
20 @end
21
22
23 @implementation VariableTable
24
25
26 - (void)awakeFromNib
27 {
28 NSScrollView *scrollView = (NSScrollView *)[(NSClipView *)[self superview] superview];
29 NSScroller *oldScroller = [[scrollView verticalScroller] retain];
30
31 TrackerScroller *scroller = [[TrackerScroller alloc] initWithFrame:[oldScroller frame]];
32
33 [scroller setControlSize:[oldScroller controlSize]];
34 [scroller setDoubleValue:[oldScroller floatValue]];
35 [scroller setKnobProportion:[oldScroller knobProportion]];
36 [scroller setControlTint:[oldScroller controlTint]];
37
38 // set the new scroller
39 [scrollView setHasVerticalScroller:NO];
40 [scrollView setVerticalScroller:scroller];
41 [scrollView setHasVerticalScroller:YES];
42
43 [scroller setDelegate:self];
44 [scroller release];
45 [oldScroller release];
46
47 /*if ( [super respondsToSelector:@selector(awakeFromNib)] ) {
48 [super awakeFromNib];
49 }*/
50 }
51
52
53 - (NSRange)visibleRows
54 {
55 return _visibleRows;
56 }
57
58 - (void)_setVisibleRows:(NSRange)rows
59 {
60 _visibleRows = rows;
61 }
62
63
64 - (void)reloadData
65 {
66 if ( _dontUpdate ) {
67 _updatePending = YES;
68 return;
69 }
70
71 [super reloadData];
72
73 NSRange range = [self rowsInRect:[(NSClipView *)[self superview] documentVisibleRect]];
74 id delegate = [self delegate];
75
76 if ( !NSEqualRanges( range, _visibleRows ) ) {
77 [self _setVisibleRows:range];
78 if ( [delegate respondsToSelector:@selector(tableView:didChangeVisibleRows:)] ) {
79 [delegate tableView:self didChangeVisibleRows:range];
80 }
81 }
82 }
83
84
85 - (void)keyDown:(NSEvent *)theEvent
86 {
87 _dontUpdate = YES;
88 [super keyDown:theEvent];
89 }
90
91 - (void)keyUp:(NSEvent *)theEvent
92 {
93 NSRange range = [self rowsInRect:[(NSClipView *)[self superview] documentVisibleRect]];
94 id delegate = [self delegate];
95
96 [super keyUp:theEvent];
97
98 _dontUpdate = NO;
99
100 if ( !NSEqualRanges( range, _visibleRows ) ) {
101 [self _setVisibleRows:range];
102 if ( [delegate respondsToSelector:@selector(tableView:didChangeVisibleRows:)] ) {
103 [delegate tableView:self didChangeVisibleRows:range];
104 }
105 }
106 else if ( _updatePending ) {
107 [self reloadData];
108 _updatePending = NO;
109 }
110 }
111
112 - (void)scrollerDidStartScrolling:(TrackerScroller *)scroller
113 {
114 _dontUpdate = YES;
115 }
116
117 - (void)scrollerDidStopScrolling:(TrackerScroller *)scroller
118 {
119 NSRange range = [self rowsInRect:[(NSClipView *)[self superview] documentVisibleRect]];
120 id delegate = [self delegate];
121
122 _dontUpdate = NO;
123
124 if ( !NSEqualRanges( range, _visibleRows ) ) {
125 [self _setVisibleRows:range];
126 if ( [delegate respondsToSelector:@selector(tableView:didChangeVisibleRows:)] ) {
127 [delegate tableView:self didChangeVisibleRows:range];
128 }
129 }
130 else if ( _updatePending ) {
131 [self reloadData];
132 _updatePending = NO;
133 }
134 }
135
136
137 @end
This page took 0.044004 seconds and 4 git commands to generate.