Permalink
Browse files

first commit

  • Loading branch information...
0 parents commit bbc58883251a20bf7a5efe2b2bff189e5f2896e5 @pppoe committed Jun 1, 2011
@@ -0,0 +1,3 @@
+build
+*.pbxuser
+*.perspectivev3
@@ -0,0 +1,12 @@
+//
+// OmniGrid.h
+// OmniGridView
+//
+// Created by Haoxiang on 5/17/11.
+// Copyright 2011 Dev.Mr.pppoe. All rights reserved.
+//
+
+#import "OmniGridLoc.h"
+#import "OmniGridCell.h"
+#import "OmniGridView.h"
+#import "OmniGridViewDelegate.h"
@@ -0,0 +1,25 @@
+//
+// OmniGridCell.h
+// OmniGridView
+//
+// Created by Haoxiang on 5/17/11.
+// Copyright 2011 Dev.Mr.pppoe. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@class OmniGridView;
+
+@interface OmniGridCell : UIView {
+// OmniGridLoc *_gridLoc;
+ UIView *_contentView;
+ UILabel *_textLabel;
+ int _state;
+}
+
+@property (nonatomic, readonly) UIView *contentView;
+@property (nonatomic, readonly) UILabel *textLabel;
+
+//- (id)initWithGridLoc:(OmniGridLoc *)gridLoc;
+
+@end
@@ -0,0 +1,54 @@
+//
+// OmniGridCell.m
+// OmniGridView
+//
+// Created by Haoxiang on 5/17/11.
+// Copyright 2011 Dev.Mr.pppoe. All rights reserved.
+//
+
+#import "OmniGridCell.h"
+//#import "OmniGridView.h"
+
+@implementation OmniGridCell
+@dynamic contentView;
+@dynamic textLabel;
+
+//- (id)initWithGridLoc:(OmniGridView *)gridView {
+//
+// if ((self = [super init])) {
+// // Initialization code.
+// }
+// return self;
+//}
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+- (UIView *)contentView {
+ if (!_contentView)
+ {
+ _contentView = [[UIView alloc] initWithFrame:self.bounds];
+ [self addSubview:_contentView];
+ [_contentView release];
+ }
+ return _contentView;
+}
+
+- (UILabel *)textLabel {
+ if (!_textLabel)
+ {
+ _textLabel = [[UILabel alloc] initWithFrame:self.bounds];
+ [self.contentView addSubview:_textLabel];
+ [_textLabel release];
+ }
+ return _textLabel;
+}
+
+- (void)setFrame:(CGRect)frame {
+ super.frame = frame;
+ _contentView.frame = self.bounds;
+ _textLabel.frame = self.bounds;
+}
+
+@end
@@ -0,0 +1,23 @@
+//
+// OmniGridLoc.h
+// OmniGridView
+//
+// Created by Haoxiang on 5/17/11.
+// Copyright 2011 Dev.Mr.pppoe. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@interface OmniGridLoc : NSObject {
+ int _row;
+ int _col;
+}
+
+@property (nonatomic, readonly) int row;
+@property (nonatomic, readonly) int col;
+
++ (OmniGridLoc *)locAtRow:(int)row andColumn:(int)col;
+
+- (id)initWithRow:(int)row andColumn:(int)col;
+
+@end
@@ -0,0 +1,28 @@
+//
+// OmniGridLoc.m
+// OmniGridView
+//
+// Created by Haoxiang on 5/17/11.
+// Copyright 2011 Dev.Mr.pppoe. All rights reserved.
+//
+
+#import "OmniGridLoc.h"
+
+@implementation OmniGridLoc
+@synthesize row = _row;
+@synthesize col = _col;
+
+- (id)initWithRow:(int)row andColumn:(int)col {
+ if ((self = [super init]))
+ {
+ _row = row;
+ _col = col;
+ }
+ return self;
+}
+
++ (OmniGridLoc *)locAtRow:(int)row andColumn:(int)col {
+ return [[[OmniGridLoc alloc] initWithRow:row andColumn:col] autorelease];
+}
+
+@end
@@ -0,0 +1,16 @@
+//
+// OmniGridTestViewController.h
+// OmniGridView
+//
+// Created by Haoxiang on 5/17/11.
+// Copyright 2011 Dev.Mr.pppoe. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+
+@interface OmniGridTestViewController : UIViewController {
+
+}
+
+@end
@@ -0,0 +1,87 @@
+//
+// OmniGridTestViewController.m
+// OmniGridView
+//
+// Created by Haoxiang on 5/17/11.
+// Copyright 2011 Dev.Mr.pppoe. All rights reserved.
+//
+
+#import "OmniGridTestViewController.h"
+#import "OmniGrid.h"
+
+#import <QuartzCore/QuartzCore.h>
+
+@interface OmniGridTestViewController (Private) <OmniGridViewDelegate>
+
+@end
+
+@implementation OmniGridTestViewController
+
+- (void)viewDidLoad {
+ [super viewDidLoad];
+
+ OmniGridView *gridView = [[OmniGridView alloc] initWithFrame:CGRectMake(0, 0, 400, 400)];
+ gridView.gridDelegate = self;
+ gridView.backgroundColor = [UIColor lightGrayColor];
+ [self.view addSubview:gridView];
+ [gridView release];
+}
+
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
+ // Return YES for supported orientations.
+ return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight);
+}
+
+- (void)didReceiveMemoryWarning {
+ // Releases the view if it doesn't have a superview.
+ [super didReceiveMemoryWarning];
+
+ // Release any cached data, images, etc. that aren't in use.
+}
+
+- (void)viewDidUnload {
+ [super viewDidUnload];
+}
+
+- (void)dealloc {
+ [super dealloc];
+}
+
+@end
+
+#pragma mark OmniGridViewDelegate
+@implementation OmniGridTestViewController (Private)
+
+- (OmniGridCell *)gridCellAt:(OmniGridLoc *)gridLoc inGridView:(OmniGridView *)gridView {
+ OmniGridCell *gridCell = [gridView dequeueReusableGridCell];
+ if (!gridCell)
+ {
+ gridCell = [[OmniGridCell alloc] init];
+ gridCell.layer.borderColor = [UIColor blackColor].CGColor;
+ gridCell.layer.borderWidth = 1.0f;
+ gridCell.textLabel.textAlignment = UITextAlignmentCenter;
+ }
+
+ gridCell.textLabel.text = [NSString stringWithFormat:@"(%d,%d)", gridLoc.row, gridLoc.col];
+
+ return gridCell;
+}
+
+- (float)gridCellHeightInGridView:(OmniGridView *)gridView {
+ return 200.0f;
+}
+
+- (float)gridCellWidthInGridView:(OmniGridView *)gridView {
+ return 200.0f;
+}
+
+- (int)numberOfGridCellsInRow:(int)row inGridView:(OmniGridView *)gridView {
+ return 12;
+}
+
+- (int)numberOfRowsInGridView:(OmniGridView *)gridView {
+ return 12;
+}
+
+@end
+
@@ -0,0 +1,26 @@
+//
+// OmniGridView.h
+// OmniGridView
+//
+// Created by Haoxiang on 5/17/11.
+// Copyright 2011 Dev.Mr.pppoe. All rights reserved.
+//
+
+#import <UIKit/UIKit.h>
+
+@protocol OmniGridViewDelegate;
+@class OmniGridCell;
+
+@interface OmniGridView : UIScrollView <UIScrollViewDelegate> {
+ id<OmniGridViewDelegate> _gridDelegate;
+ NSMutableDictionary *_gridCellsDict;
+ NSMutableArray *_reusableGridCells;
+}
+
+@property (nonatomic, assign) id<OmniGridViewDelegate> gridDelegate;
+
+- (void)reloadData;
+
+- (OmniGridCell *)dequeueReusableGridCell;
+
+@end
Oops, something went wrong.

0 comments on commit bbc5888

Please sign in to comment.