diff options
Diffstat (limited to 'platform/ios/Classes')
-rw-r--r-- | platform/ios/Classes/MuDocumentController.h | 2 | ||||
-rw-r--r-- | platform/ios/Classes/MuDocumentController.m | 45 |
2 files changed, 47 insertions, 0 deletions
diff --git a/platform/ios/Classes/MuDocumentController.h b/platform/ios/Classes/MuDocumentController.h index 4abacc42..29a9ac1a 100644 --- a/platform/ios/Classes/MuDocumentController.h +++ b/platform/ios/Classes/MuDocumentController.h @@ -15,6 +15,7 @@ enum { BARMODE_MAIN, BARMODE_SEARCH, + BARMODE_MORE, BARMODE_ANNOTATION, BARMODE_HIGHLIGHT, BARMODE_UNDERLINE, @@ -37,6 +38,7 @@ enum UISearchBar *searchBar; UIBarButtonItem *nextButton, *prevButton, *cancelButton, *searchButton, *outlineButton, *linkButton; UIBarButtonItem *moreButton; + UIBarButtonItem *printButton, *annotButton; UIBarButtonItem *highlightButton, *underlineButton, *strikeoutButton; UIBarButtonItem *inkButton; UIBarButtonItem *tickButton; diff --git a/platform/ios/Classes/MuDocumentController.m b/platform/ios/Classes/MuDocumentController.m index d56313c9..490ba40e 100644 --- a/platform/ios/Classes/MuDocumentController.m +++ b/platform/ios/Classes/MuDocumentController.m @@ -249,6 +249,8 @@ static void saveDoc(char *current_path, fz_document *doc) nextButton = [self resourceBasedButton:@"ic_arrow_right" withAction:@selector(onSearchNext:)]; reflowButton = [self resourceBasedButton:@"ic_reflow" withAction:@selector(onToggleReflow:)]; moreButton = [self resourceBasedButton:@"ic_more" withAction:@selector(onMore:)]; + annotButton = [self resourceBasedButton:@"ic_annotation" withAction:@selector(onAnnot:)]; + printButton = [self resourceBasedButton:@"ic_print" withAction:@selector(onPrint:)]; highlightButton = [self resourceBasedButton:@"ic_highlight" withAction:@selector(onHighlight:)]; underlineButton = [self resourceBasedButton:@"ic_underline" withAction:@selector(onUnderline:)]; strikeoutButton = [self resourceBasedButton:@"ic_strike" withAction:@selector(onStrikeout:)]; @@ -443,6 +445,14 @@ static void saveDoc(char *current_path, fz_document *doc) [self scrollViewDidScroll:canvas]; } +- (void) showMoreMenu +{ + [[self navigationItem] setRightBarButtonItems:[NSArray arrayWithObjects:printButton, annotButton, nil]]; + [[self navigationItem] setLeftBarButtonItem:cancelButton]; + + barmode = BARMODE_MORE; +} + - (void) showAnnotationMenu { [[self navigationItem] setRightBarButtonItems:[NSArray arrayWithObjects:inkButton, strikeoutButton, underlineButton, highlightButton, nil]]; @@ -465,9 +475,43 @@ static void saveDoc(char *current_path, fz_document *doc) - (void) onMore: (id)sender { + [self showMoreMenu]; +} + +- (void) onAnnot: (id)sender +{ [self showAnnotationMenu]; } +- (void) onPrint: (id)sender +{ + NSURL *url = [NSURL fileURLWithPath:[NSString stringWithUTF8String:filePath]]; + UIPrintInteractionController *pic = [UIPrintInteractionController sharedPrintController]; + if (pic && [UIPrintInteractionController canPrintURL:url] ) { + + UIPrintInfo *printInfo = [UIPrintInfo printInfo]; + printInfo.outputType = UIPrintInfoOutputGeneral; + printInfo.jobName = key; + printInfo.duplex = UIPrintInfoDuplexLongEdge; + pic.printInfo = printInfo; + pic.showsPageRange = YES; + pic.printingItem = url; + + void (^completionHandler)(UIPrintInteractionController *, BOOL, NSError *) = + ^(UIPrintInteractionController *pic, BOOL completed, NSError *error) { + if (!completed && error) + NSLog(@"FAILED! due to error in domain %@ with error code %u", + error.domain, (unsigned int)error.code); + }; + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + [pic presentFromBarButtonItem:printButton animated:YES + completionHandler:completionHandler]; + } else { + [pic presentAnimated:YES completionHandler:completionHandler]; + } + } +} + - (void) textSelectModeOn { [[self navigationItem] setRightBarButtonItems:[NSArray arrayWithObject:tickButton]]; @@ -594,6 +638,7 @@ static void saveDoc(char *current_path, fz_document *doc) [self resetSearch]; /* fallthrough */ case BARMODE_ANNOTATION: + case BARMODE_MORE: [[self navigationItem] setTitleView: nil]; [self addMainMenuButtons]; barmode = BARMODE_MAIN; |