diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2017-01-09 13:27:17 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2017-01-09 17:46:26 +0100 |
commit | 9d96d035d3b7af53256ee64b5ddb0ad8bcf8df38 (patch) | |
tree | 408cbbb72315089db1b8efe58bce322f8734bb1b /platform/ios/Classes/MuTextSelectView.m | |
parent | 50b39c939345c36eb5e95c8a71ccdb8cd24c9aad (diff) | |
download | mupdf-9d96d035d3b7af53256ee64b5ddb0ad8bcf8df38.tar.xz |
Remove platform/ios directory.
The iOS viewer has been moved to its own git repository.
Diffstat (limited to 'platform/ios/Classes/MuTextSelectView.m')
-rw-r--r-- | platform/ios/Classes/MuTextSelectView.m | 111 |
1 files changed, 0 insertions, 111 deletions
diff --git a/platform/ios/Classes/MuTextSelectView.m b/platform/ios/Classes/MuTextSelectView.m deleted file mode 100644 index fdf1b0f2..00000000 --- a/platform/ios/Classes/MuTextSelectView.m +++ /dev/null @@ -1,111 +0,0 @@ -#include "common.h" -#import "MuTextSelectView.h" -#import "MuWord.h" - -@implementation MuTextSelectView -{ - NSArray *words; - CGSize pageSize; - UIColor *color; - CGPoint start; - CGPoint end; -} - -- (instancetype) initWithWords:(NSArray *)_words pageSize:(CGSize)_pageSize -{ - self = [super initWithFrame:CGRectMake(0,0,100,100)]; - if (self) - { - [self setOpaque:NO]; - words = [_words retain]; - pageSize = _pageSize; - color = [[UIColor colorWithRed:0x25/255.0 green:0x72/255.0 blue:0xAC/255.0 alpha:0.5] retain]; - UIPanGestureRecognizer *rec = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(onDrag:)]; - [self addGestureRecognizer:rec]; - [rec release]; - } - return self; -} - --(void) dealloc -{ - [words release]; - [color release]; - [super dealloc]; -} - -- (NSArray *) selectionRects -{ - NSMutableArray *arr = [NSMutableArray array]; - __block CGRect r; - - [MuWord selectFrom:start to:end fromWords:words - onStartLine:^{ - r = CGRectNull; - } onWord:^(MuWord *w) { - r = CGRectUnion(r, w.rect); - } onEndLine:^{ - if (!CGRectIsNull(r)) - [arr addObject:[NSValue valueWithCGRect:r]]; - }]; - - return arr; -} - -- (NSString *) selectedText -{ - __block NSMutableString *text = [NSMutableString string]; - __block NSMutableString *line; - - [MuWord selectFrom:start to:end fromWords:words - onStartLine:^{ - line = [NSMutableString string]; - } onWord:^(MuWord *w) { - if (line.length > 0) - [line appendString:@" "]; - [line appendString:w.string]; - } onEndLine:^{ - if (text.length > 0) - [text appendString:@"\n"]; - [text appendString:line]; - }]; - - return text; -} - --(void) onDrag:(UIPanGestureRecognizer *)rec -{ - CGSize scale = fitPageToScreen(pageSize, self.bounds.size); - CGPoint p = [rec locationInView:self]; - p.x /= scale.width; - p.y /= scale.height; - - if (rec.state == UIGestureRecognizerStateBegan) - start = p; - - end = p; - - [self setNeedsDisplay]; -} - -- (void) drawRect:(CGRect)rect -{ - CGSize scale = fitPageToScreen(pageSize, self.bounds.size); - CGContextRef cref = UIGraphicsGetCurrentContext(); - CGContextScaleCTM(cref, scale.width, scale.height); - __block CGRect r; - - [color set]; - - [MuWord selectFrom:start to:end fromWords:words - onStartLine:^{ - r = CGRectNull; - } onWord:^(MuWord *w) { - r = CGRectUnion(r, w.rect); - } onEndLine:^{ - if (!CGRectIsNull(r)) - UIRectFill(r); - }]; -} - -@end |