bzr branch
/browse/iphone/tappity
| Line | Revision | Contents |
| 1 | 46 | // |
| 2 | // TappityView.m |
|
| 3 | // tappity |
|
| 4 | // |
|
| 5 | // Created by döme on 25.10.2009. |
|
| 6 | // Copyright 2009 __MyCompanyName__. All rights reserved. |
|
| 7 | // |
|
| 8 | ||
| 9 | #import "TappityView.h" |
|
| 10 | #import "TappityClient.h" |
|
| 11 | #import "Tappity.h" |
|
| 12 | ||
| 13 | ||
| 14 | @implementation TappityView |
|
| 15 | ||
| 16 | ||
| 17 | - (id)initWithFrame:(CGRect)frame |
|
| 18 | { |
|
| 19 | if ((self = [super initWithFrame: frame])) |
|
| 20 | { |
|
| 21 | 48 | |
| 22 | 46 | } |
| 23 | return self; |
|
| 24 | } |
|
| 25 | ||
| 26 | 48 | - (void) setImage: (UIImage*) img |
| 27 | { |
|
| 28 | @synchronized(self) |
|
| 29 | { |
|
| 30 | [img retain]; |
|
| 31 | [image release]; |
|
| 32 | image = img; |
|
| 33 | } |
|
| 34 | [self performSelectorOnMainThread: @selector(setNeedsDisplay) withObject: nil waitUntilDone: NO]; |
|
| 35 | //[self setNeedsDisplay]; |
|
| 36 | } |
|
| 37 | ||
| 38 | 49 | - (void) doDrawingInContext: (void*) _c |
| 39 | 48 | { |
| 40 | 49 | CGContextRef c = (CGContextRef)_c; |
| 41 | 48 | //[[UIColor blueColor] set]; |
| 42 | //CGContextFillRect(c, rect); |
|
| 43 | ||
| 44 | CGContextSetInterpolationQuality(c, kCGInterpolationNone); |
|
| 45 | CGContextSetAllowsAntialiasing(c, NO); |
|
| 46 | CGContextSetShouldAntialias(c, NO); |
|
| 47 | ||
| 48 | UIImage* img = nil; |
|
| 49 | |
|
| 50 | @synchronized(self) |
|
| 51 | { |
|
| 52 | img = image; |
|
| 53 | } |
|
| 54 | ||
| 55 | if (!img) |
|
| 56 | img = [UIImage imageNamed: @"image-not-found-icon.png"]; |
|
| 57 | |
|
| 58 | CGRect bounds = [self bounds]; |
|
| 59 | ||
| 60 | ||
| 61 | ||
| 62 | [img drawInRect: bounds blendMode: kCGBlendModeCopy alpha: 1.0f]; |
|
| 63 | } |
|
| 64 | ||
| 65 | 49 | - (void) drawRect: (CGRect) rect |
| 66 | { |
|
| 67 | CGContextRef c = UIGraphicsGetCurrentContext(); |
|
| 68 | |
|
| 69 | [self doDrawingInContext: c]; |
|
| 70 | } |
|
| 71 | ||
| 72 | 46 | |
| 73 | - (void)dealloc |
|
| 74 | { |
|
| 75 | self.tapClient = nil; |
|
| 76 | [super dealloc]; |
|
| 77 | } |
|
| 78 | ||
| 79 | - (NSArray*) touchesAsPlist: (NSSet*) touches |
|
| 80 | { |
|
| 81 | NSMutableArray* ary = [NSMutableArray array]; |
|
| 82 | for (UITouch* touch in touches) |
|
| 83 | { |
|
| 84 | NSMutableDictionary* dict = [NSMutableDictionary dictionary]; |
|
| 85 | [dict setObject: [NSNumber numberWithInteger: (NSInteger)touch] forKey: @"touchIdentifier"]; |
|
| 86 | [dict setObject: [NSNumber numberWithInteger: [touch phase]] forKey: @"touchPhase"]; |
|
| 87 | [dict setObject: [NSNumber numberWithInteger: [touch tapCount]] forKey: @"touchTapCount"]; |
|
| 88 | [dict setObject: [NSNumber numberWithFloat: [touch locationInView: self].x] forKey: @"touchX"]; |
|
| 89 | [dict setObject: [NSNumber numberWithFloat: [touch locationInView: self].x] forKey: @"touchY"]; |
|
| 90 | [dict setObject: [NSNumber numberWithFloat: [touch previousLocationInView: self].x] forKey: @"touchPX"]; |
|
| 91 | [dict setObject: [NSNumber numberWithFloat: [touch previousLocationInView: self].x] forKey: @"touchPY"]; |
|
| 92 | |
|
| 93 | [ary addObject: dict]; |
|
| 94 | } |
|
| 95 | return ary; |
|
| 96 | } |
|
| 97 | 47 | /* |
| 98 | 46 | - (void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event |
| 99 | { |
|
| 100 | NSLog(@"touchesBegan"); |
|
| 101 | _printGSEvent(event); |
|
| 102 | ||
| 103 | [tapClient sendTouch: event inPhase: UITouchPhaseBegan]; |
|
| 104 | } |
|
| 105 | ||
| 106 | - (void) touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event |
|
| 107 | { |
|
| 108 | NSLog(@"touchesEnded"); |
|
| 109 | _printGSEvent(event); |
|
| 110 | ||
| 111 | [tapClient sendTouch: event inPhase: UITouchPhaseEnded]; |
|
| 112 | } |
|
| 113 | ||
| 114 | - (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event |
|
| 115 | { |
|
| 116 | NSLog(@"touchesMoved"); |
|
| 117 | _printGSEvent(event); |
|
| 118 | ||
| 119 | [tapClient sendTouch: event inPhase: UITouchPhaseMoved]; |
|
| 120 | } |
|
| 121 | ||
| 122 | - (void) touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event |
|
| 123 | { |
|
| 124 | NSLog(@"touchesCancelled"); |
|
| 125 | _printGSEvent(event); |
|
| 126 | ||
| 127 | [tapClient sendTouch: event inPhase: UITouchPhaseCancelled]; |
|
| 128 | } |
|
| 129 | 47 | */ |
| 130 | 46 | |
| 131 | 48 | @synthesize tapClient, image; |
| 132 | 46 | |
| 133 | @end |
Loggerhead 1.17 is a web-based interface for Bazaar branches