API  0.9.6
 All Classes Files Functions Variables Macros Groups Pages
CPCollectionViewItem.j
Go to the documentation of this file.
1 /*
2  * CPCollectionViewItem.j
3  * AppKit
4  *
5  * Created by Francisco Tolmasky.
6  * Copyright 2009, 280 North, Inc.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 
23 
24 
28 @implementation CPCollectionViewItem : CPViewController
29 {
30  BOOL _isSelected;
31 }
32 
33 // Setting the Represented Object
38 - (void)setRepresentedObject:(id)anObject
39 {
40  [super setRepresentedObject:anObject];
41 
42  var view = [self view];
43 
44  if ([view respondsToSelector:@selector(setRepresentedObject:)])
45  [view setRepresentedObject:[self representedObject]];
46 }
47 
48 // Modifying the Selection
53 - (void)setSelected:(BOOL)shouldBeSelected
54 {
55  shouldBeSelected = !!shouldBeSelected;
56 
57  if (_isSelected === shouldBeSelected)
58  return;
59 
60  _isSelected = shouldBeSelected;
61 
62  var view = [self view];
63 
64  if ([view respondsToSelector:@selector(setSelected:)])
65  [view setSelected:[self isSelected]];
66 }
67 
71 - (BOOL)isSelected
72 {
73  return _isSelected;
74 }
75 
76 // Parent Collection View
80 - (CPCollectionView)collectionView
81 {
82  return [_view superview];
83 }
84 
85 @end