Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
sburlot committed Feb 22, 2009
0 parents commit 06a5b14
Show file tree
Hide file tree
Showing 17 changed files with 1,372 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .gitignore
@@ -0,0 +1,12 @@
.DS_Store
*.swp
*~.nib

build/*

*.pbxuser
*.perspective
*.perspectivev3
*.mode1v3
*.mode2v3

27 changes: 27 additions & 0 deletions Classes/CustomCellBackgroundView.h
@@ -0,0 +1,27 @@
//
// CustomCellBackgroundView.h
// TableTest
//
// Created by Stephan on 22.02.09.
// Copyright 2009 Coriolis Technologies. All rights reserved.
//

#import <UIKit/UIKit.h>


typedef enum {
CustomCellBackgroundViewPositionTop,
CustomCellBackgroundViewPositionMiddle,
CustomCellBackgroundViewPositionBottom,
CustomCellBackgroundViewPositionSingle
} CustomCellBackgroundViewPosition;

@interface CustomCellBackgroundView : UIView {
UIColor *borderColor;
UIColor *fillColor;
CustomCellBackgroundViewPosition position;
}

@property(nonatomic, retain) UIColor *borderColor, *fillColor;
@property(nonatomic) CustomCellBackgroundViewPosition position;
@end
115 changes: 115 additions & 0 deletions Classes/CustomCellBackgroundView.m
@@ -0,0 +1,115 @@
//
// CustomCellBackgroundView.m
//
// Created by Mike Akers on 11/21/08.
// Copyright 2008 __MyCompanyName__. All rights reserved.
//

#import "CustomCellBackgroundView.h"

static void addRoundedRectToPath(CGContextRef context, CGRect rect,
float ovalWidth,float ovalHeight);

@implementation CustomCellBackgroundView
@synthesize borderColor, fillColor, position;

- (BOOL) isOpaque {
return NO;
}

- (id)initWithFrame:(CGRect)frame {
if (self = [super initWithFrame:frame]) {
// Initialization code
}
return self;
}

- (void)drawRect:(CGRect)rect {
// Drawing code
CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(c, [fillColor CGColor]);
CGContextSetStrokeColorWithColor(c, [borderColor CGColor]);

if (position == CustomCellBackgroundViewPositionTop) {
CGContextFillRect(c, CGRectMake(0.0f, rect.size.height - 10.0f, rect.size.width, 10.0f));
CGContextBeginPath(c);
CGContextMoveToPoint(c, 0.0f, rect.size.height - 10.0f);
CGContextAddLineToPoint(c, 0.0f, rect.size.height);
CGContextAddLineToPoint(c, rect.size.width, rect.size.height);
CGContextAddLineToPoint(c, rect.size.width, rect.size.height - 10.0f);
CGContextStrokePath(c);
CGContextClipToRect(c, CGRectMake(0.0f, 0.0f, rect.size.width, rect.size.height - 10.0f));
} else if (position == CustomCellBackgroundViewPositionBottom) {
CGContextFillRect(c, CGRectMake(0.0f, 0.0f, rect.size.width, 10.0f));
CGContextBeginPath(c);
CGContextMoveToPoint(c, 0.0f, 10.0f);
CGContextAddLineToPoint(c, 0.0f, 0.0f);
CGContextStrokePath(c);
CGContextBeginPath(c);
CGContextMoveToPoint(c, rect.size.width, 0.0f);
CGContextAddLineToPoint(c, rect.size.width, 10.0f);
CGContextStrokePath(c);
CGContextClipToRect(c, CGRectMake(0.0f, 10.0f, rect.size.width, rect.size.height));
} else if (position == CustomCellBackgroundViewPositionMiddle) {
CGContextFillRect(c, rect);
CGContextBeginPath(c);
CGContextMoveToPoint(c, 0.0f, 0.0f);
CGContextAddLineToPoint(c, 0.0f, rect.size.height);
CGContextAddLineToPoint(c, rect.size.width, rect.size.height);
CGContextAddLineToPoint(c, rect.size.width, 0.0f);
CGContextStrokePath(c);
return; // no need to bother drawing rounded corners, so we return
}

// At this point the clip rect is set to only draw the appropriate
// corners, so we fill and stroke a rounded rect taking the entire rect

CGContextBeginPath(c);
addRoundedRectToPath(c, rect, 10.0f, 10.0f);
CGContextFillPath(c);

CGContextSetLineWidth(c, 1);
CGContextBeginPath(c);
addRoundedRectToPath(c, rect, 10.0f, 10.0f);
CGContextStrokePath(c);
}


- (void)dealloc {
[borderColor release];
[fillColor release];
[super dealloc];
}


@end

static void addRoundedRectToPath(CGContextRef context, CGRect rect,
float ovalWidth,float ovalHeight)

{
float fw, fh;

if (ovalWidth == 0 || ovalHeight == 0) {// 1
CGContextAddRect(context, rect);
return;
}

CGContextSaveGState(context);// 2

CGContextSetShouldAntialias(context, YES);
CGContextTranslateCTM (context, CGRectGetMinX(rect),// 3
CGRectGetMinY(rect));
CGContextScaleCTM (context, ovalWidth, ovalHeight);// 4
fw = CGRectGetWidth (rect) / ovalWidth;// 5
fh = CGRectGetHeight (rect) / ovalHeight;// 6

CGContextMoveToPoint(context, fw, fh/2); // 7
CGContextAddArcToPoint(context, fw, fh, fw/2, fh, 1);// 8
CGContextAddArcToPoint(context, 0, fh, 0, fh/2, 1);// 9
CGContextAddArcToPoint(context, 0, 0, fw/2, 0, 1);// 10
CGContextAddArcToPoint(context, fw, 0, fw, fh/2, 1); // 11
CGContextClosePath(context);// 12

CGContextRestoreGState(context);// 13
}
20 changes: 20 additions & 0 deletions Classes/CustomCellView.h
@@ -0,0 +1,20 @@
//
// CustomCellView.h
// TableTest
//
// Created by Stephan on 22.02.09.
// Copyright 2009 Coriolis Technologies. All rights reserved.
//

#import <UIKit/UIKit.h>


@interface CustomCellView : UITableViewCell {

IBOutlet UILabel *textLabel;

}

@property (nonatomic, retain) UILabel *textLabel;

@end
38 changes: 38 additions & 0 deletions Classes/CustomCellView.m
@@ -0,0 +1,38 @@
//
// CustomCellView.m
// TableTest
//
// Created by Stephan on 22.02.09.
// Copyright 2009 Coriolis Technologies. All rights reserved.
//

#import "CustomCellView.h"


@implementation CustomCellView

@synthesize textLabel;

- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
// Initialization code
}
return self;
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}


- (void)dealloc
{
[textLabel release];
[super dealloc];
}

@end
22 changes: 22 additions & 0 deletions Classes/TableTestAppDelegate.h
@@ -0,0 +1,22 @@
//
// TableTestAppDelegate.h
// TableTest
//
// Created by Stephan on 22.02.09.
// Copyright Coriolis Technologies 2009. All rights reserved.
//

#import <UIKit/UIKit.h>

@class TableTestViewController;

@interface TableTestAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
TableTestViewController *viewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet TableTestViewController *viewController;

@end

33 changes: 33 additions & 0 deletions Classes/TableTestAppDelegate.m
@@ -0,0 +1,33 @@
//
// TableTestAppDelegate.m
// TableTest
//
// Created by Stephan on 22.02.09.
// Copyright Coriolis Technologies 2009. All rights reserved.
//

#import "TableTestAppDelegate.h"
#import "TableTestViewController.h"

@implementation TableTestAppDelegate

@synthesize window;
@synthesize viewController;


- (void)applicationDidFinishLaunching:(UIApplication *)application {

// Override point for customization after app launch
[window addSubview:viewController.view];
[window makeKeyAndVisible];
}


- (void)dealloc {
[viewController release];
[window release];
[super dealloc];
}


@end
22 changes: 22 additions & 0 deletions Classes/TableTestViewController.h
@@ -0,0 +1,22 @@
//
// TableTestViewController.h
// TableTest
//
// Created by Stephan on 22.02.09.
// Copyright Coriolis Technologies 2009. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface TableTestViewController : UIViewController {

IBOutlet UITableView *tableView;
NSArray *cellList;

}

@property (nonatomic, retain) UITableView *tableView;
@property (nonatomic, retain) NSArray *cellList;

@end

0 comments on commit 06a5b14

Please sign in to comment.