|
@@ -24,6 +24,7 @@
|
|
|
#import "CSelfSignAnnotation.h"
|
|
|
#import "CPDFAnnotationModel.h"
|
|
|
#import "CStringConstants.h"
|
|
|
+#import <ComPDFKit/CPDFView+Editing.h>
|
|
|
|
|
|
#import <PDF_Reader_Pro-Swift.h>
|
|
|
|
|
@@ -1025,6 +1026,15 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
|
|
|
if (!menuItems) {
|
|
|
menuItems = [NSMutableArray array];
|
|
|
}
|
|
|
+
|
|
|
+ if (self.isSelectEditCharRange || [self isSelecteditAreaWithPoint:point]) {
|
|
|
+
|
|
|
+ [menuItems insertObject:[NSMenuItem separatorItem] atIndex:0];
|
|
|
+ [menuItems insertObject:[self fontColorMenuItem] atIndex:0];
|
|
|
+ [menuItems insertObject:[self fontSizeMenuItem] atIndex:0];
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
if (self.toolMode != CEditPDFToolMode) {
|
|
|
return menuItems;
|
|
|
}
|
|
@@ -1035,6 +1045,73 @@ static inline CPDFAreaOfInterest CAreaOfInterestForResizeHandle(CRectEdges mask,
|
|
|
return menuItems;
|
|
|
}
|
|
|
|
|
|
+#pragma mark - Edit
|
|
|
+- (NSMenuItem *)fontColorMenuItem {
|
|
|
+ NSMenuItem *fontColorItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Text Color", nil)
|
|
|
+ action:@selector(menuItemEditingClick_FontColor:)
|
|
|
+ keyEquivalent:@""];
|
|
|
+ fontColorItem.target = self;
|
|
|
+ return fontColorItem;
|
|
|
+}
|
|
|
+
|
|
|
+- (NSMenuItem *)fontSizeMenuItem {
|
|
|
+ CGFloat size = [self editingSelectionFontSizeWithTextArea:self.editingAreas.firstObject];
|
|
|
+ NSArray *fontSizes = [self fontSizes];
|
|
|
+ NSMenu *submenu = [[NSMenu alloc] init];
|
|
|
+ for (NSUInteger i=0; i<fontSizes.count; i++) {
|
|
|
+ CGFloat fontSize = [[[self fontSizes] objectAtIndex:i] floatValue];
|
|
|
+ NSMenuItem *item = [[NSMenuItem alloc] initWithTitle:[NSString stringWithFormat:@"%d pt", (int)fontSize]
|
|
|
+ action:@selector(menuItemEditingClick_FontSize:)
|
|
|
+ keyEquivalent:@""];
|
|
|
+ item.target = self;
|
|
|
+ item.tag = i;
|
|
|
+ [submenu addItem:item];
|
|
|
+ if (fabs(fontSize-size) < 0.1) {
|
|
|
+ item.state = NSControlStateValueOn;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ NSMenuItem *fontSizeItem = [[NSMenuItem alloc] initWithTitle:NSLocalizedString(@"Font Size", nil) action:nil keyEquivalent:@""];
|
|
|
+ fontSizeItem.submenu = submenu;
|
|
|
+ return fontSizeItem;
|
|
|
+}
|
|
|
+
|
|
|
+- (void)menuItemEditingClick_FontSize:(NSMenuItem *)item {
|
|
|
+ CGFloat fontSize = [[[self fontSizes] objectAtIndex:item.tag] floatValue];
|
|
|
+ [self setEditingSelectionFontSize:fontSize withTextArea:self.editingAreas.firstObject isAutoSize:YES];
|
|
|
+ if ([[self pdfListViewDelegate] respondsToSelector:@selector(PDFListViewDidTextFontChanged:)]){
|
|
|
+ [[self pdfListViewDelegate] PDFListViewDidTextFontChanged:self];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (void)menuItemEditingClick_alignment:(NSMenuItem *)item {
|
|
|
+ [self setCurrentSelectionAlignment:(NSTextAlignment)item.tag withTextArea:self.editingAreas.firstObject];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)menuItemEditingClick_FontColor:(NSMenuItem *)item {
|
|
|
+#warning ---zhuyi
|
|
|
+// [self endEditIsRemoveBlock];
|
|
|
+
|
|
|
+ NSColor *color = [self editingSelectionFontColorWithTextArea:self.editingAreas.firstObject];
|
|
|
+ [[NSColorPanel sharedColorPanel] orderFront:nil];
|
|
|
+ [[NSColorPanel sharedColorPanel] setTarget:self];
|
|
|
+ [NSColorPanel sharedColorPanel].color = color;
|
|
|
+ [NSColorPanel sharedColorPanel].showsAlpha = NO;
|
|
|
+ [[NSColorPanel sharedColorPanel] setAction:@selector(fontColorChangeAction:)];
|
|
|
+}
|
|
|
+
|
|
|
+- (void)fontColorChangeAction:(id)sender {
|
|
|
+ [self setEditingSelectionFontColor:[NSColorPanel sharedColorPanel].color withTextArea:self.editingAreas.firstObject];
|
|
|
+
|
|
|
+ if ([[self pdfListViewDelegate] respondsToSelector:@selector(PDFListViewDidTextColorChanged:withColor:)]){
|
|
|
+ [[self pdfListViewDelegate] PDFListViewDidTextColorChanged:self withColor:[NSColorPanel sharedColorPanel].color];
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+- (NSArray *)fontSizes {
|
|
|
+ return @[@"6", @"7", @"8", @"9", @"10", @"11", @"12", @"13", @"14", @"15", @"16", @"17", @"18", @"24", @"36", @"48", @"72", @"96", @"144", @"288"];
|
|
|
+}
|
|
|
+
|
|
|
#pragma mark - Cursor
|
|
|
|
|
|
- (void)setCursorForMouse:(NSEvent *)theEvent {
|