Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 102 lines (74 sloc) 2.717 kB
118980a @joshaber Initial commit.
authored
1 //
2 // JAListViewItem.m
3 //
4 // Created by Josh Abernathy on 10/27/10.
5 // Copyright 2010 Maybe Apps. All rights reserved.
6 //
7
8 #import "JAListViewItem.h"
9 #import "JAListView.h"
09ebc2f @joshaber Import changes from external project.
authored
10 #import "JASectionedListView.h"
118980a @joshaber Initial commit.
authored
11
12
13 @implementation JAListViewItem
14
15
16 #pragma mark NSView
17
09ebc2f @joshaber Import changes from external project.
authored
18 - (void)scrollWheel:(NSEvent *)event {
19 [self.listView markViewBeingUsedForInertialScrolling:self];
118980a @joshaber Initial commit.
authored
20 [super scrollWheel:event];
21 }
22
23
09ebc2f @joshaber Import changes from external project.
authored
24 #pragma mark NSResponder
25
26 - (BOOL)acceptsFirstResponder {
27 return YES;
28 }
29
30
118980a @joshaber Initial commit.
authored
31 #pragma mark API
32
33 @synthesize ignoreInListViewLayout;
34 @synthesize listView;
35 @synthesize selected;
36 @synthesize highlighted;
09ebc2f @joshaber Import changes from external project.
authored
37 @synthesize listViewPosition;
6cf375d @joshaber added a property to allow listview items to opt out of the listview's…
authored
38 @synthesize ignoresListViewPadding;
118980a @joshaber Initial commit.
authored
39
40 - (NSImage *)draggingImage {
41 NSBitmapImageRep *bitmap = [self bitmapImageRepForCachingDisplayInRect:self.bounds];
42 [self cacheDisplayInRect:self.bounds toBitmapImageRep:bitmap];
43
44 NSSize imageSize = [bitmap size];
45 NSImage *image = [[[NSImage alloc] initWithSize:imageSize] autorelease];
46 [image addRepresentation:bitmap];
47
48 NSImage *result = [[[NSImage alloc] initWithSize:imageSize] autorelease];
49 [result lockFocus];
50 NSGraphicsContext *currentContext = [NSGraphicsContext currentContext];
51 NSImageInterpolation savedInterpolation = [currentContext imageInterpolation];
52 [currentContext setImageInterpolation:NSImageInterpolationHigh];
53 [image drawInRect:NSMakeRect(0, 0, imageSize.width, imageSize.height) fromRect:NSMakeRect(0, 0, imageSize.width, imageSize.height) operation:NSCompositeSourceOver fraction:.5];
54 [currentContext setImageInterpolation:savedInterpolation];
55 [result unlockFocus];
56
57 return result;
58 }
59
09ebc2f @joshaber Import changes from external project.
authored
60 - (JAListViewPosition)listViewPosition {
61 JAListViewPosition position = JAListViewPositionNone;
62 NSUInteger index = (NSUInteger) [self.listView indexForView:self];
63 NSUInteger numberOfViews = [self.listView numberOfViews];
64
65 if([self.listView isKindOfClass:[JASectionedListView class]]) {
66 JASectionedListView *sectionedListView = (JASectionedListView *) self.listView;
67 NSUInteger section = 0;
68 NSUInteger newIndex = index;
69 [sectionedListView getSection:&section andIndex:&newIndex fromAbsoluteIndex:index];
70 index = newIndex;
71 numberOfViews = [sectionedListView numberOfViewsInSection:section];
72 }
73
74 if(index == numberOfViews - 1) {
75 position |= JAListViewPositionBottom;
76 }
77
78 if(index == 0) {
79 position |= JAListViewPositionTop;
80 }
81
82 if(position == JAListViewPositionNone) {
83 position = JAListViewPositionMiddle;
84 }
85
86 return position;
87 }
88
118980a @joshaber Initial commit.
authored
89 - (void)setSelected:(BOOL)newValue {
90 selected = newValue;
91
92 [self setNeedsDisplay:YES];
93 }
94
95 - (void)setHighlighted:(BOOL)newValue {
96 highlighted = newValue;
97
98 [self setNeedsDisplay:YES];
99 }
100
101 @end
Something went wrong with that request. Please try again.