3 * The Cheat - The legendary universal game trainer for Mac OS X.
4 * http://www.brokenzipper.com/trac/wiki/TheCheat
6 * Copyright (c) 2003-2011, Charles McGarvey et al.
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.
13 #import "VariableTable.h"
16 @interface VariableTable ( PrivateAPI
)
18 - (void)_setVisibleRows
:(NSRange
)rows
;
23 @implementation VariableTable
28 NSScrollView
*scrollView
= (NSScrollView
*)[(NSClipView
*)[self superview
] superview
];
29 NSScroller
*oldScroller
= [[scrollView verticalScroller
] retain
];
31 TrackerScroller
*scroller
= [[TrackerScroller alloc
] initWithFrame
:[oldScroller frame
]];
33 [scroller setControlSize
:[oldScroller controlSize
]];
34 [scroller setDoubleValue
:[oldScroller floatValue
]];
35 [scroller setKnobProportion
:[oldScroller knobProportion
]];
36 [scroller setControlTint
:[oldScroller controlTint
]];
38 // set the new scroller
39 [scrollView setHasVerticalScroller
:NO
];
40 [scrollView setVerticalScroller
:scroller
];
41 [scrollView setHasVerticalScroller
:YES
];
43 [scroller setDelegate
:self];
45 [oldScroller release
];
47 /*if ( [super respondsToSelector:@selector(awakeFromNib)] ) {
53 - (NSRange
)visibleRows
58 - (void)_setVisibleRows
:(NSRange
)rows
73 NSRange range
= [self rowsInRect
:[(NSClipView
*)[self superview
] documentVisibleRect
]];
74 id delegate
= [self delegate
];
76 if ( !NSEqualRanges( range
, _visibleRows
) ) {
77 [self _setVisibleRows
:range
];
78 if ( [delegate respondsToSelector
:@selector(tableView
:didChangeVisibleRows
:)] ) {
79 [delegate tableView
:self didChangeVisibleRows
:range
];
85 - (void)keyDown
:(NSEvent
*)theEvent
88 [super keyDown
:theEvent
];
91 - (void)keyUp
:(NSEvent
*)theEvent
93 NSRange range
= [self rowsInRect
:[(NSClipView
*)[self superview
] documentVisibleRect
]];
94 id delegate
= [self delegate
];
96 [super keyUp
:theEvent
];
100 if ( !NSEqualRanges( range
, _visibleRows
) ) {
101 [self _setVisibleRows
:range
];
102 if ( [delegate respondsToSelector
:@selector(tableView
:didChangeVisibleRows
:)] ) {
103 [delegate tableView
:self didChangeVisibleRows
:range
];
106 else if ( _updatePending
) {
112 - (void)scrollerDidStartScrolling
:(TrackerScroller
*)scroller
117 - (void)scrollerDidStopScrolling
:(TrackerScroller
*)scroller
119 NSRange range
= [self rowsInRect
:[(NSClipView
*)[self superview
] documentVisibleRect
]];
120 id delegate
= [self delegate
];
124 if ( !NSEqualRanges( range
, _visibleRows
) ) {
125 [self _setVisibleRows
:range
];
126 if ( [delegate respondsToSelector
:@selector(tableView
:didChangeVisibleRows
:)] ) {
127 [delegate tableView
:self didChangeVisibleRows
:range
];
130 else if ( _updatePending
) {