Permalink
Browse files

Removed the CPCollectionView

  • Loading branch information...
1 parent 7f4bfc5 commit 9559781a7d018c7a7ecbfd5008eecccaa91e19be @hlship committed Sep 13, 2009
Showing with 35 additions and 58 deletions.
  1. +14 −17 src/main/webapp/app/TwitView.j
  2. +21 −41 src/main/webapp/app/TwitterController.j
@@ -6,29 +6,26 @@
CPTextField _label;
}
-- (void) setRepresentedObject:(JSONObject)obj
+- (id)initWithFrame:(CGRect)frame
{
- if (!_label)
- {
- _label = [[CPTextField alloc] initWithFrame:CGRectMakeZero()];
- [_label setFont:[CPFont systemFontOfSize:12]];
- [_label setTextColor:[CPColor whiteColor]];
- [_label setAutoresizingMask:CPViewWidthSizable];
- [self addSubview:_label];
- }
+ self = [super initWithFrame:frame];
+
+ _label = [[CPTextField alloc] initWithFrame:frame];
+ [_label setFont:[CPFont systemFontOfSize:12]];
+ [_label setTextColor:[CPColor whiteColor]];
+ [_label setAutoresizingMask:CPViewWidthSizable];
+ [_label setLineBreakMode:CPLineBreakByWordWrapping];
- [_label setStringValue:obj.text];
-
- [_label setFrameSize:CGSizeMake(200, 60)];
+ [self addSubview:_label];
- [_label setLineBreakMode:CPLineBreakByWordWrapping];
+ return self;
}
-- (void)setSelected:(BOOL)isSelected
+- (void)setRepresentedObject:(JSONObject)obj
{
- var color = isSelected ? [CPColor blueColor] :nil;
-
- [self setBackgroundColor:color];
+ CPLog.debug(obj.text);
+
+ [_label setStringValue:obj.text];
}
@end
@@ -10,7 +10,6 @@
CPPanel _panel;
CPTextField _field;
CPScollView _scrollView;
- CPCollectionView _timelineView;
}
- (id)init
@@ -42,28 +41,7 @@
[_scrollView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable];
[_scrollView setAutohidesScrollers:YES];
-
- var scrollViewBounds = [[_scrollView contentView] bounds];
-
- var itemPrototype = [[CPCollectionViewItem alloc] init];
- [itemPrototype setView:[[TwitView alloc] initWithFrame:CGRectMakeZero()]];
-
- _timelineView = [[CPCollectionView alloc] initWithFrame:CGRectMake(0, 0,
- CGRectGetWidth(scrollViewBounds), 60)];
- [_timelineView setItemPrototype:itemPrototype];
- [_timelineView setDelegate:self];
- [_timelineView setMaxNumberOfColumns:1];
-
- [_timelineView setAutoresizingMask:CPViewWidthSizable];
-
- [_scrollView setDocumentView:_timelineView];
- [[CPNotificationCenter defaultCenter]
- addObserver:self
- selector:@selector(scrollViewDidResize:)
- name:CPViewFrameDidChangeNotification
- object:_scrollView];
-
// Will fire an initial notification because the value changed.
[_scrollView setPostsFrameChangedNotifications:YES];
@@ -74,19 +52,6 @@
return self;
}
-
-- (void)scrollViewDidResize:(id)notification
-{
- var bounds = [_scrollView bounds];
-
- CPLog.debug("new size: " + CPRectGetWidth(bounds) + " x " + CPRectGetHeight(bounds));
-
- var newSize = CGSizeMake(CPRectGetWidth(bounds), 60);
-
- [_timelineView setMinItemSize:newSize];
- [_timelineView setMaxItemSize:newSize];
-}
-
- (void)show
{
[_panel orderFront:self];
@@ -108,7 +73,27 @@
{
var timeline = JSON.parse(data);
- [_timelineView setContent:timeline];
+ [self updateTimeline:timeline];
+}
+
+- (void)updateTimeline:(CPArray) timeline
+{
+ var width = CPRectGetWidth([_scrollView bounds]) - 4;
+ var container = [_scrollView contentView];
+
+ var count = [timeline count];
+
+ CPLog.debug("updateTimeline: " + count + " rows")
+
+ for (row = 0; row < count; row++)
+ {
+ var frame = CGRectMake(2, 64 * row + 2, width, 60);
+ var view = [[TwitView alloc] initWithFrame:frame];
+ [view setRepresentedObject:[timeline objectAtIndex:row]];
+ [view setAutoresizingMask:CPViewWidthSizable];
+
+ [container addSubview:view];
+ }
}
@@ -117,9 +102,4 @@
CPLog.error(error);
}
-- (void)adjustTimelineSize
-{
-
-}
-
@end

0 comments on commit 9559781

Please sign in to comment.