|
@@ -16,6 +16,8 @@
|
|
#import <objc/runtime.h>
|
|
#import <objc/runtime.h>
|
|
#import <PDF_Master-Swift.h>
|
|
#import <PDF_Master-Swift.h>
|
|
|
|
|
|
|
|
+CGFloat DEFAULT_SNAPSHOT_HEIGHT = 200.0;
|
|
|
|
+
|
|
@implementation CPDFListView (Extension)
|
|
@implementation CPDFListView (Extension)
|
|
|
|
|
|
- (CPDFAnnotation *)addPDFSelection:(CPDFSelection *)currentSelection annotationTyoe:(CAnnotationType)annotationType {
|
|
- (CPDFAnnotation *)addPDFSelection:(CPDFSelection *)currentSelection annotationTyoe:(CAnnotationType)annotationType {
|
|
@@ -452,6 +454,44 @@
|
|
return NO;
|
|
return NO;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#pragma mark Snapshots
|
|
|
|
+
|
|
|
|
+- (void)takeSnapshot:(id)sender {
|
|
|
|
+ NSPoint point;
|
|
|
|
+ CPDFPage *page = nil;
|
|
|
|
+ NSRect rect = NSZeroRect;
|
|
|
|
+ BOOL autoFits = NO;
|
|
|
|
+
|
|
|
|
+ if (self.toolMode == CSelectToolMode && NSIsEmptyRect(self.selectionRect) == NO && self.selectionPageIndex != NSNotFound) {
|
|
|
|
+ page = [self currentSelectionPage];
|
|
|
|
+ rect = NSIntersectionRect(self.selectionRect, [page boundsForBox:CPDFDisplayCropBox]);
|
|
|
|
+ autoFits = YES;
|
|
|
|
+ }
|
|
|
|
+ if (NSIsEmptyRect(rect)) {
|
|
|
|
+ // the represented object should be the location for the menu event
|
|
|
|
+ point = [sender representedObject] ? [[sender representedObject] pointValue] : [self convertPoint:[[self window] mouseLocationOutsideOfEventStream] fromView:nil];
|
|
|
|
+ page = [self pageForPoint:point nearest:NO];
|
|
|
|
+ if (page == nil) {
|
|
|
|
+ // Get the center
|
|
|
|
+ NSRect viewFrame = [self frame];
|
|
|
|
+// point = KMCenterPoint(viewFrame);
|
|
|
|
+ point = NSMakePoint(NSMidX(viewFrame), NSMidY(viewFrame));
|
|
|
|
+ page = [self pageForPoint:point nearest:YES];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ point = [self convertPoint:point toPage:page];
|
|
|
|
+
|
|
|
|
+ rect = [self convertRect:[page boundsForBox:CPDFDisplayCropBox] fromPage:page];
|
|
|
|
+ rect.origin.y = point.y - 0.5 * DEFAULT_SNAPSHOT_HEIGHT;
|
|
|
|
+ rect.size.height = DEFAULT_SNAPSHOT_HEIGHT;
|
|
|
|
+
|
|
|
|
+ rect = [self convertRect:rect toPage:page];
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ([[self pdfListViewDelegate] respondsToSelector:@selector(PDFListView:showSnapshotAtPageNumber:forRect:scaleFactor:autoFits:)])
|
|
|
|
+ [[self pdfListViewDelegate] PDFListView:self showSnapshotAtPageNumber:[page pageIndex] forRect:rect scaleFactor:[self scaleFactor] autoFits:autoFits];
|
|
|
|
+}
|
|
|
|
+
|
|
@end
|
|
@end
|
|
|
|
|
|
@implementation CPDFView (KMExtension)
|
|
@implementation CPDFView (KMExtension)
|