API 0.9.5
AppKit/CPCollectionViewItem.j
Go to the documentation of this file.
00001 /*
00002  * CPCollectionViewItem.j
00003  * AppKit
00004  *
00005  * Created by Francisco Tolmasky.
00006  * Copyright 2009, 280 North, Inc.
00007  *
00008  * This library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU Lesser General Public
00010  * License as published by the Free Software Foundation; either
00011  * version 2.1 of the License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with this library; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
00021  */
00022 
00023 
00024 
00028 @implementation CPCollectionViewItem : CPViewController
00029 {
00030     BOOL    _isSelected;
00031 }
00032 
00033 // Setting the Represented Object
00038 - (void)setRepresentedObject:(id)anObject
00039 {
00040     [super setRepresentedObject:anObject];
00041 
00042     var view = [self view];
00043 
00044     if ([view respondsToSelector:@selector(setRepresentedObject:)])
00045         [view setRepresentedObject:[self representedObject]];
00046 }
00047 
00048 // Modifying the Selection
00053 - (void)setSelected:(BOOL)shouldBeSelected
00054 {
00055     shouldBeSelected = !!shouldBeSelected;
00056 
00057     if (_isSelected === shouldBeSelected)
00058         return;
00059 
00060     _isSelected = shouldBeSelected;
00061 
00062     var view = [self view];
00063 
00064     if ([view respondsToSelector:@selector(setSelected:)])
00065         [view setSelected:[self isSelected]];
00066 }
00067 
00071 - (BOOL)isSelected
00072 {
00073     return _isSelected;
00074 }
00075 
00076 // Parent Collection View
00080 - (CPCollectionView)collectionView
00081 {
00082     return [_view superview];
00083 }
00084 
00085 @end
 All Classes Files Functions Variables Defines