|
@@ -43,12 +43,6 @@ NSNotificationName const CPDFListViewActiveAnnotationsChangeNotification = @"CPD
|
|
|
|
|
|
NSNotificationName const CPDFListViewAnnotationsAttributeHasChangeNotification = @"CPDFListViewAnnotationsAttributeHasChangeNotification";
|
|
|
|
|
|
-@interface CPDFListView ()
|
|
|
-
|
|
|
-@property (nonatomic,retain) NSColor *pageBackgroundColor;
|
|
|
-
|
|
|
-@end
|
|
|
-
|
|
|
@implementation CPDFListView
|
|
|
|
|
|
#pragma mark - Init
|
|
@@ -92,6 +86,37 @@ NSNotificationName const CPDFListViewAnnotationsAttributeHasChangeNotification =
|
|
|
self.clickLineAnnotation = nil;
|
|
|
self.isClickDoubleCreatLine = NO;
|
|
|
|
|
|
+ KMPDFViewMode viewMode = KMPDFViewModeNormal;
|
|
|
+ if ([[NSUserDefaults standardUserDefaults] objectForKey:@"kPDFViewModeKey"]) {
|
|
|
+ viewMode = (KMPDFViewMode)[[[NSUserDefaults standardUserDefaults] objectForKey:@"kPDFViewModeKey"] integerValue];
|
|
|
+ }
|
|
|
+ NSData * data = nil;
|
|
|
+ if ([[NSUserDefaults standardUserDefaults] objectForKey:@"kKMPDFViewModeThemesArray"]) {
|
|
|
+ data = [[NSUserDefaults standardUserDefaults] objectForKey:@"kKMPDFViewModeThemesArray"];
|
|
|
+ }
|
|
|
+ NSArray * appArray = [NSKeyedUnarchiver unarchiveObjectWithData:data];
|
|
|
+ NSMutableArray * mutableArray = [NSMutableArray arrayWithArray:appArray];
|
|
|
+ if (mutableArray.count == 0) {
|
|
|
+ NSColor *normalColor = [NSColor whiteColor];
|
|
|
+ NSColor *softColor = [NSColor colorWithDeviceRed:238.0/255.0 green:232.0/255.0 blue:216.0/255.0 alpha:1.0];
|
|
|
+ NSColor *nightColor = [NSColor blackColor];
|
|
|
+ NSColor *greenColor = [NSColor colorWithDeviceRed:153.0/255.0 green:207.0/255.0 blue:161.0/255.0 alpha:1.0];
|
|
|
+ mutableArray = [NSMutableArray arrayWithArray:@[normalColor, softColor,nightColor, greenColor]];
|
|
|
+ }
|
|
|
+ NSColor *pageBackgroundColor = mutableArray[viewMode];
|
|
|
+ if (viewMode == KMPDFViewModeOther &&
|
|
|
+ [[NSUserDefaults standardUserDefaults] objectForKey:@"kPDFViewModeColorKey"]) {
|
|
|
+ CGFloat red,green,blue,alpha;
|
|
|
+ NSArray *colors = [[NSUserDefaults standardUserDefaults] objectForKey:@"kPDFViewModeColorKey"];
|
|
|
+ red = colors.count>0 ? [colors[0] floatValue] : 0;
|
|
|
+ green = colors.count>1 ? [colors[1] floatValue] : 0;
|
|
|
+ blue = colors.count>2 ? [colors[2] floatValue] : 0;
|
|
|
+ alpha = colors.count>3 ? [colors[3] floatValue] : 0;
|
|
|
+ pageBackgroundColor = [NSColor colorWithDeviceRed:red green:green blue:blue alpha:alpha];
|
|
|
+ }
|
|
|
+ self.viewMode = viewMode;
|
|
|
+ [self setPageBackgroundColorWithColor:pageBackgroundColor viewMode:viewMode];
|
|
|
+
|
|
|
self.activeAnnotations = [NSMutableArray array];
|
|
|
self.selectAnnotations = [NSMutableArray array];
|
|
|
self.dragHoverPoints = [NSMutableArray array];
|
|
@@ -312,9 +337,22 @@ NSNotificationName const CPDFListViewAnnotationsAttributeHasChangeNotification =
|
|
|
return;
|
|
|
}
|
|
|
_viewMode = viewMode;
|
|
|
- self.pageBackgroundColor = color;
|
|
|
- [self setNeedsDisplay:YES];
|
|
|
+ if (viewMode == KMPDFViewModeNormal) {
|
|
|
+ self.displayMode = CPDFDisplayModeNormal;
|
|
|
+ } else if (viewMode == KMPDFViewModeSoft) {
|
|
|
+ self.displayMode = CPDFDisplayModeSoft;
|
|
|
+ } else if (viewMode == KMPDFViewModeNight) {
|
|
|
+ self.displayMode = CPDFDisplayModeNight;
|
|
|
+ } else if (viewMode == KMPDFViewModeGreen) {
|
|
|
+ self.displayMode = CPDFDisplayModeGreen;
|
|
|
+ } else {
|
|
|
+ self.displayMode = CPDFDisplayModeCustom;
|
|
|
+ self.displayModeCustomColor = color;
|
|
|
+ }
|
|
|
|
|
|
+ [self layoutDocumentView];
|
|
|
+ [self setNeedsDisplayForVisiblePages];
|
|
|
+
|
|
|
[[NSUserDefaults standardUserDefaults] setObject:[NSNumber numberWithInteger:viewMode] forKey:@"kPDFViewModeKey"];
|
|
|
[[NSUserDefaults standardUserDefaults] synchronize];
|
|
|
}
|
|
@@ -1092,7 +1130,6 @@ NSNotificationName const CPDFListViewAnnotationsAttributeHasChangeNotification =
|
|
|
}
|
|
|
|
|
|
- (void)drawPage:(CPDFPage *)pdfPage toContext:(CGContextRef)context {
|
|
|
-
|
|
|
[super drawPage:pdfPage toContext:context];
|
|
|
|
|
|
[self drawSelectionForPage:pdfPage inContext:context];
|
|
@@ -1180,7 +1217,6 @@ NSNotificationName const CPDFListViewAnnotationsAttributeHasChangeNotification =
|
|
|
CGContextStrokePath(context);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
- (void)drawSelectionForPage:(CPDFPage *)pdfPage inContext:(CGContextRef)context {
|