summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--platform/ios/Classes/MuDocumentController.m23
-rw-r--r--platform/ios/Classes/MuHitView.h2
-rw-r--r--platform/ios/Classes/MuHitView.m25
-rw-r--r--platform/ios/Classes/MuPageView.h2
-rw-r--r--platform/ios/Classes/MuPageViewNormal.m6
-rw-r--r--platform/ios/Classes/MuPageViewReflow.h2
-rw-r--r--platform/ios/Classes/MuPageViewReflow.m5
-rw-r--r--platform/ios/Classes/MuTapResult.h46
-rw-r--r--platform/ios/Classes/MuTapResult.m94
-rw-r--r--platform/ios/MuPDF.xcodeproj/project.pbxproj8
10 files changed, 211 insertions, 2 deletions
diff --git a/platform/ios/Classes/MuDocumentController.m b/platform/ios/Classes/MuDocumentController.m
index e089e0bb..8a82fa1f 100644
--- a/platform/ios/Classes/MuDocumentController.m
+++ b/platform/ios/Classes/MuDocumentController.m
@@ -460,7 +460,28 @@ static void flattenOutline(NSMutableArray *titles, NSMutableArray *pages, fz_out
float x1 = (width - GAP) - x0;
p.x -= ofs.x;
p.y -= ofs.y;
- if (p.x < x0) {
+ __block BOOL tapHandled = NO;
+ for (UIView<MuPageView> *view in [canvas subviews])
+ {
+ CGPoint pp = [sender locationInView:view];
+ if (CGRectContainsPoint(view.bounds, pp))
+ {
+ MuTapResult *result = [view handleTap:pp];
+ [result switchCaseInternal:^(MuTapResultInternalLink *link) {
+ [self gotoPage:link.pageNumber animated:NO];
+ tapHandled = YES;
+ } caseExternal:^(MuTapResultExternalLink *link) {
+ // Not currently supported
+ } caseRemote:^(MuTapResultRemoteLink *link) {
+ // Not currently supported
+ }];
+ if (tapHandled)
+ break;
+ }
+ }
+ if (tapHandled) {
+ // Do nothing further
+ } else if (p.x < x0) {
[self gotoPage: current-1 animated: YES];
} else if (p.x > x1) {
[self gotoPage: current+1 animated: YES];
diff --git a/platform/ios/Classes/MuHitView.h b/platform/ios/Classes/MuHitView.h
index 1be5dcb2..aa10d25b 100644
--- a/platform/ios/Classes/MuHitView.h
+++ b/platform/ios/Classes/MuHitView.h
@@ -6,6 +6,7 @@
//
#import <UIKit/UIKit.h>
+#import "MuTapResult.h"
#undef ABS
#undef MIN
@@ -25,4 +26,5 @@
- (id) initWithSearchResults: (int)n forDocument: (fz_document *)doc;
- (id) initWithLinks: (fz_link*)links forDocument: (fz_document *)doc;
- (void) setPageSize: (CGSize)s;
+- (MuTapResult *) handleTap:(CGPoint)pt;
@end
diff --git a/platform/ios/Classes/MuHitView.m b/platform/ios/Classes/MuHitView.m
index be67601a..5fe47d3d 100644
--- a/platform/ios/Classes/MuHitView.m
+++ b/platform/ios/Classes/MuHitView.m
@@ -66,6 +66,31 @@
[self setNeedsDisplay];
}
+- (MuTapResult *) handleTap:(CGPoint)pt
+{
+ CGSize scale = fitPageToScreen(pageSize, self.bounds.size);
+ pt.x /= scale.width;
+ pt.y /= scale.height;
+
+ for (int i = 0; i < hitCount; i++)
+ {
+ if (CGRectContainsPoint(hitRects[i], pt))
+ {
+ if (linkPage[i] >= 0)
+ {
+ return [[[MuTapResultInternalLink alloc] initWithPageNumber:linkPage[i]] autorelease];
+ }
+ if (linkUrl[i])
+ {
+ NSString *url = [NSString stringWithUTF8String:linkUrl[i]];
+ return [[[MuTapResultExternalLink alloc] initWithUrl:url] autorelease];
+ }
+ }
+ }
+
+ return nil;
+}
+
- (void) drawRect: (CGRect)r
{
CGSize scale = fitPageToScreen(pageSize, self.bounds.size);
diff --git a/platform/ios/Classes/MuPageView.h b/platform/ios/Classes/MuPageView.h
index 963a4aa0..d0b2f48d 100644
--- a/platform/ios/Classes/MuPageView.h
+++ b/platform/ios/Classes/MuPageView.h
@@ -6,6 +6,7 @@
//
#import <UIKit/UIKit.h>
+#import "MuTapResult.h"
@protocol MuPageView
-(int) number;
@@ -16,4 +17,5 @@
-(void) clearSearchResults;
-(void) resetZoomAnimated: (BOOL)animated;
-(void) setScale:(float)scale;
+-(MuTapResult *) handleTap:(CGPoint)pt;
@end
diff --git a/platform/ios/Classes/MuPageViewNormal.m b/platform/ios/Classes/MuPageViewNormal.m
index ccdd4fcd..3c25475e 100644
--- a/platform/ios/Classes/MuPageViewNormal.m
+++ b/platform/ios/Classes/MuPageViewNormal.m
@@ -525,4 +525,10 @@ static UIImage *renderPage(fz_document *doc, fz_display_list *page_list, fz_disp
- (void) setScale:(float)scale {}
+- (MuTapResult *) handleTap:(CGPoint)pt
+{
+ CGPoint lpt = [self convertPoint:pt toView:linkView];
+ return linkView ? [linkView handleTap:lpt] : nil;
+}
+
@end
diff --git a/platform/ios/Classes/MuPageViewReflow.h b/platform/ios/Classes/MuPageViewReflow.h
index 28638bc8..c7593c4d 100644
--- a/platform/ios/Classes/MuPageViewReflow.h
+++ b/platform/ios/Classes/MuPageViewReflow.h
@@ -9,7 +9,7 @@
#import "MuDocRef.h"
#import "MuPageView.h"
-@interface MuPageViewReflow : UIWebView <UIWebViewDelegate,UIGestureRecognizerDelegate,MuPageView>
+@interface MuPageViewReflow : UIWebView <UIWebViewDelegate,MuPageView>
{
int number;
float scale;
diff --git a/platform/ios/Classes/MuPageViewReflow.m b/platform/ios/Classes/MuPageViewReflow.m
index 541731fb..de47aae3 100644
--- a/platform/ios/Classes/MuPageViewReflow.m
+++ b/platform/ios/Classes/MuPageViewReflow.m
@@ -133,4 +133,9 @@ NSString *textAsHtml(fz_document *doc, int pageNum)
[self stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.getElementById('content').style.zoom=\"%f\"", scale]];
}
+-(MuTapResult *) handleTap:(CGPoint)pt
+{
+ return nil;
+}
+
@end
diff --git a/platform/ios/Classes/MuTapResult.h b/platform/ios/Classes/MuTapResult.h
new file mode 100644
index 00000000..c0d930c5
--- /dev/null
+++ b/platform/ios/Classes/MuTapResult.h
@@ -0,0 +1,46 @@
+//
+// MuTapResult.h
+// MuPDF
+//
+// Copyright (c) 2013 Artifex Software, Inc. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+@class MuTapResultInternalLink;
+@class MuTapResultExternalLink;
+@class MuTapResultRemoteLink;
+
+@interface MuTapResult : NSObject
+-(void) switchCaseInternal:(void (^)(MuTapResultInternalLink *))internalLinkBlock
+ caseExternal:(void (^)(MuTapResultExternalLink *))externalLinkBlock
+ caseRemote:(void (^)(MuTapResultRemoteLink *))remoteLinkBlock;
+@end
+
+@interface MuTapResultInternalLink : MuTapResult
+{
+ int pageNumber;
+}
+@property(readonly) int pageNumber;
+-(id)initWithPageNumber:(int)aNumber;
+@end
+
+@interface MuTapResultExternalLink : MuTapResult
+{
+ NSString *url;
+}
+@property(readonly) NSString *url;
+-(id)initWithUrl:(NSString *)aString;
+@end
+
+@interface MuTapResultRemoteLink : MuTapResult
+{
+ NSString *fileSpec;
+ int pageNumber;
+ BOOL newWindow;
+}
+@property(readonly) NSString *fileSpec;
+@property(readonly) int pageNumber;
+@property(readonly) BOOL newWindow;
+-(id)initWithFileSpec:(NSString *)aString pageNumber:(int)aNumber newWindow:(BOOL)aBool;
+@end
diff --git a/platform/ios/Classes/MuTapResult.m b/platform/ios/Classes/MuTapResult.m
new file mode 100644
index 00000000..7e3d71d1
--- /dev/null
+++ b/platform/ios/Classes/MuTapResult.m
@@ -0,0 +1,94 @@
+//
+// MuTapResult.m
+// MuPDF
+//
+// Copyright (c) 2013 Artifex Software, Inc. All rights reserved.
+//
+
+#import "MuTapResult.h"
+
+@implementation MuTapResult
+
+-(void) switchCaseInternal:(void (^)(MuTapResultInternalLink *))internalLinkBlock caseExternal:(void (^)(MuTapResultExternalLink *))externalLinkBlock caseRemote:(void (^)(MuTapResultRemoteLink *))remoteLinkBlock {}
+
+@end
+
+
+@implementation MuTapResultInternalLink
+
+@synthesize pageNumber;
+
+-(id) initWithPageNumber:(int)aNumber
+{
+ self = [super init];
+ if (self)
+ {
+ pageNumber = aNumber;
+ }
+ return self;
+}
+
+-(void) switchCaseInternal:(void (^)(MuTapResultInternalLink *))internalLinkBlock caseExternal:(void (^)(MuTapResultExternalLink *))externalLinkBlock caseRemote:(void (^)(MuTapResultRemoteLink *))remoteLinkBlock
+{
+ internalLinkBlock(self);
+}
+
+@end
+
+
+@implementation MuTapResultExternalLink
+
+@synthesize url;
+
+-(id) initWithUrl:(NSString *)aString
+{
+ self = [super init];
+ if (self)
+ {
+ url = [aString retain];
+ }
+ return self;
+}
+
+-(void) dealloc
+{
+ [url release];
+ [super dealloc];
+}
+
+-(void) switchCaseInternal:(void (^)(MuTapResultInternalLink *))internalLinkBlock caseExternal:(void (^)(MuTapResultExternalLink *))externalLinkBlock caseRemote:(void (^)(MuTapResultRemoteLink *))remoteLinkBlock
+{
+ externalLinkBlock(self);
+}
+
+@end
+
+
+@implementation MuTapResultRemoteLink
+
+@synthesize fileSpec, pageNumber, newWindow;
+
+-(id) initWithFileSpec:(NSString *)aString pageNumber:(int)aNumber newWindow:(BOOL)aBool
+{
+ self = [super init];
+ if (self)
+ {
+ fileSpec = [aString retain];
+ pageNumber = aNumber;
+ newWindow = aBool;
+ }
+ return self;
+}
+
+-(void) dealloc
+{
+ [fileSpec release];
+ [super dealloc];
+}
+
+-(void) switchCaseInternal:(void (^)(MuTapResultInternalLink *))internalLinkBlock caseExternal:(void (^)(MuTapResultExternalLink *))externalLinkBlock caseRemote:(void (^)(MuTapResultRemoteLink *))remoteLinkBlock
+{
+ remoteLinkBlock(self);
+}
+
+@end \ No newline at end of file
diff --git a/platform/ios/MuPDF.xcodeproj/project.pbxproj b/platform/ios/MuPDF.xcodeproj/project.pbxproj
index 487f439d..ef6ea07f 100644
--- a/platform/ios/MuPDF.xcodeproj/project.pbxproj
+++ b/platform/ios/MuPDF.xcodeproj/project.pbxproj
@@ -36,6 +36,7 @@
DA1C68B517E86A500061F586 /* MuAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DA1C68A917E864CB0061F586 /* MuAppDelegate.m */; };
DA1C68C417E8969C0061F586 /* common.m in Sources */ = {isa = PBXBuildFile; fileRef = DA1C68C317E8969C0061F586 /* common.m */; };
DAA6E56F17F03F96002B1E4E /* MuPageViewReflow.m in Sources */ = {isa = PBXBuildFile; fileRef = DAA6E56E17F03AAE002B1E4E /* MuPageViewReflow.m */; };
+ DAAC6A2E17FC6E4A00A0E83A /* MuTapResult.m in Sources */ = {isa = PBXBuildFile; fileRef = DAAC6A2D17FC6E4A00A0E83A /* MuTapResult.m */; };
DAB9F4BB17F1B24000117D2E /* ic_arrow_left.png in Resources */ = {isa = PBXBuildFile; fileRef = DAB9F4B517F1B24000117D2E /* ic_arrow_left.png */; };
DAB9F4BC17F1B24000117D2E /* ic_arrow_right.png in Resources */ = {isa = PBXBuildFile; fileRef = DAB9F4B617F1B24000117D2E /* ic_arrow_right.png */; };
DAB9F4BD17F1B24000117D2E /* ic_cancel.png in Resources */ = {isa = PBXBuildFile; fileRef = DAB9F4B717F1B24000117D2E /* ic_cancel.png */; };
@@ -96,6 +97,8 @@
DA1C68C317E8969C0061F586 /* common.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = common.m; sourceTree = "<group>"; };
DAA6E56D17F03AAE002B1E4E /* MuPageViewReflow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MuPageViewReflow.h; path = Classes/MuPageViewReflow.h; sourceTree = "<group>"; };
DAA6E56E17F03AAE002B1E4E /* MuPageViewReflow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MuPageViewReflow.m; path = Classes/MuPageViewReflow.m; sourceTree = "<group>"; };
+ DAAC6A2C17FC6E4A00A0E83A /* MuTapResult.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MuTapResult.h; path = Classes/MuTapResult.h; sourceTree = "<group>"; };
+ DAAC6A2D17FC6E4A00A0E83A /* MuTapResult.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MuTapResult.m; path = Classes/MuTapResult.m; sourceTree = "<group>"; };
DAB9F4B517F1B24000117D2E /* ic_arrow_left.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ic_arrow_left.png; path = "../android/res/drawable-ldpi/ic_arrow_left.png"; sourceTree = "<group>"; };
DAB9F4B617F1B24000117D2E /* ic_arrow_right.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ic_arrow_right.png; path = "../android/res/drawable-ldpi/ic_arrow_right.png"; sourceTree = "<group>"; };
DAB9F4B717F1B24000117D2E /* ic_cancel.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ic_cancel.png; path = "../android/res/drawable-ldpi/ic_cancel.png"; sourceTree = "<group>"; };
@@ -212,6 +215,8 @@
DABDEF5917EC484A00AC35F1 /* MuDocRef.m */,
DAA6E56D17F03AAE002B1E4E /* MuPageViewReflow.h */,
DAA6E56E17F03AAE002B1E4E /* MuPageViewReflow.m */,
+ DAAC6A2C17FC6E4A00A0E83A /* MuTapResult.h */,
+ DAAC6A2D17FC6E4A00A0E83A /* MuTapResult.m */,
);
name = Classes;
sourceTree = "<group>";
@@ -348,6 +353,7 @@
96C8ED011779A88E00A30AF4 /* main.m in Sources */,
DA1C68C417E8969C0061F586 /* common.m in Sources */,
DABDEF5A17EC484A00AC35F1 /* MuDocRef.m in Sources */,
+ DAAC6A2E17FC6E4A00A0E83A /* MuTapResult.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -393,6 +399,7 @@
968E1E5B1779A54F0050CEA3 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ GCC_OPTIMIZATION_LEVEL = 0;
INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
PRODUCT_NAME = "$(TARGET_NAME)";
@@ -405,6 +412,7 @@
968E1E5C1779A54F0050CEA3 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
+ GCC_OPTIMIZATION_LEVEL = s;
INFOPLIST_FILE = "$(SRCROOT)/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
PRODUCT_NAME = "$(TARGET_NAME)";