summaryrefslogtreecommitdiff
path: root/platform/ios/Classes/MuOutlineController.m
diff options
context:
space:
mode:
Diffstat (limited to 'platform/ios/Classes/MuOutlineController.m')
-rw-r--r--platform/ios/Classes/MuOutlineController.m76
1 files changed, 76 insertions, 0 deletions
diff --git a/platform/ios/Classes/MuOutlineController.m b/platform/ios/Classes/MuOutlineController.m
new file mode 100644
index 00000000..694fcef3
--- /dev/null
+++ b/platform/ios/Classes/MuOutlineController.m
@@ -0,0 +1,76 @@
+//
+// MuOutlineController.m
+// MuPDF
+//
+// Copyright (c) 2013 Artifex Software, Inc. All rights reserved.
+//
+
+#import "MuOutlineController.h"
+
+@implementation MuOutlineController
+
+- (id) initWithTarget: (id)aTarget titles: (NSMutableArray*)aTitles pages: (NSMutableArray*)aPages
+{
+ self = [super initWithStyle: UITableViewStylePlain];
+ if (self) {
+ [self setTitle: @"Table of Contents"];
+ target = aTarget; // only keep a weak reference, to avoid retain cycles
+ titles = [aTitles retain];
+ pages = [aPages retain];
+ [[self tableView] setSeparatorStyle: UITableViewCellSeparatorStyleNone];
+ }
+ return self;
+}
+
+- (void) dealloc
+{
+ [titles release];
+ [pages release];
+ [super dealloc];
+}
+
+- (BOOL) shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation)o
+{
+ return YES;
+}
+
+- (NSInteger) numberOfSectionsInTableView: (UITableView*)tableView
+{
+ return 1;
+}
+
+- (NSInteger) tableView: (UITableView*)tableView numberOfRowsInSection: (NSInteger)section
+{
+ return [titles count];
+}
+
+- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
+{
+ return 28;
+}
+
+- (UITableViewCell*) tableView: (UITableView*)tableView cellForRowAtIndexPath: (NSIndexPath*)indexPath
+{
+ static NSString *cellid = @"MuCellIdent";
+ UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: cellid];
+ if (!cell)
+ {
+ cell = [[[UITableViewCell alloc] initWithStyle: UITableViewCellStyleValue1 reuseIdentifier: cellid] autorelease];
+ [[cell textLabel] setFont: [UIFont systemFontOfSize: 16]];
+ [[cell detailTextLabel] setFont: [UIFont systemFontOfSize: 16]];
+ }
+ NSString *title = [titles objectAtIndex: [indexPath row]];
+ NSString *page = [pages objectAtIndex: [indexPath row]];
+ [[cell textLabel] setText: title];
+ [[cell detailTextLabel] setText: [NSString stringWithFormat: @"%d", [page intValue]+1]];
+ return cell;
+}
+
+- (void) tableView: (UITableView*)tableView didSelectRowAtIndexPath: (NSIndexPath*)indexPath
+{
+ NSNumber *page = [pages objectAtIndex: [indexPath row]];
+ [target gotoPage: [page intValue] animated: NO];
+ [[self navigationController] popViewControllerAnimated: YES];
+}
+
+@end