diff options
author | Paul Gardiner <paul.gardiner@artifex.com> | 2013-10-14 16:55:57 +0100 |
---|---|---|
committer | Paul Gardiner <paul.gardiner@artifex.com> | 2013-10-16 09:59:37 +0100 |
commit | 636d2f27a9a2f4ed855d6d73a8fe497e1cf184fa (patch) | |
tree | 6634d6997e1d7db63883515a81128328448687b4 /platform/ios | |
parent | 566c82a6b6d21fe06985b98346369329c101c88e (diff) | |
download | mupdf-636d2f27a9a2f4ed855d6d73a8fe497e1cf184fa.tar.xz |
iOS: add support for selecting form choice fields
Diffstat (limited to 'platform/ios')
-rw-r--r-- | platform/ios/Classes/MuChoiceFieldController.h | 20 | ||||
-rw-r--r-- | platform/ios/Classes/MuChoiceFieldController.m | 82 | ||||
-rw-r--r-- | platform/ios/Classes/MuChoiceFieldController.xib | 639 | ||||
-rw-r--r-- | platform/ios/Classes/MuDialogCreator.h | 1 | ||||
-rw-r--r-- | platform/ios/Classes/MuDocumentController.m | 9 | ||||
-rw-r--r-- | platform/ios/Classes/MuPageViewNormal.m | 78 | ||||
-rw-r--r-- | platform/ios/MuPDF.xcodeproj/project.pbxproj | 10 |
7 files changed, 836 insertions, 3 deletions
diff --git a/platform/ios/Classes/MuChoiceFieldController.h b/platform/ios/Classes/MuChoiceFieldController.h new file mode 100644 index 00000000..d99f8cd5 --- /dev/null +++ b/platform/ios/Classes/MuChoiceFieldController.h @@ -0,0 +1,20 @@ +// +// MuChoiceFieldController.h +// MuPDF +// +// Copyright (c) 2013 Artifex Software, Inc. All rights reserved. +// + +#import <UIKit/UIKit.h> + +@interface MuChoiceFieldController : UIViewController<UIPickerViewDataSource, UIPickerViewDelegate> +{ + void (^okayBlock)(NSArray *); + NSArray *choices; + int selected; +} +@property (retain, nonatomic) IBOutlet UIPickerView *picker; +- (id)initWithChoices:(NSArray *)choices okayAction:(void (^)(NSArray *))block; +- (IBAction)okayTapped:(id)sender; +- (IBAction)cancelTapped:(id)sender; +@end diff --git a/platform/ios/Classes/MuChoiceFieldController.m b/platform/ios/Classes/MuChoiceFieldController.m new file mode 100644 index 00000000..ffd4c212 --- /dev/null +++ b/platform/ios/Classes/MuChoiceFieldController.m @@ -0,0 +1,82 @@ +// +// MuChoiceFieldController.m +// MuPDF +// +// Copyright (c) 2013 Artifex Software, Inc. All rights reserved. +// + +#import "MuChoiceFieldController.h" + +@interface MuChoiceFieldController () + +@end + +@implementation MuChoiceFieldController + +- (id)initWithChoices:(NSArray *)_choices okayAction:(void (^)(NSArray *))block +{ + self = [super initWithNibName:@"MuChoiceFieldController" bundle:nil]; + if (self) + { + okayBlock = Block_copy(block); + choices = [_choices retain]; + selected = -1; + } + return self; +} + +- (void)viewDidLoad +{ + [super viewDidLoad]; + _picker.dataSource = self; + _picker.delegate = self; + // Do any additional setup after loading the view from its nib. +} + +- (void)didReceiveMemoryWarning +{ + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +- (void)dealloc +{ + [okayBlock release]; + [choices release]; + [_picker release]; + [super dealloc]; +} + +- (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView +{ + return 1; +} + +- (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component +{ + return [choices count]; +} + +- (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component +{ + return [choices objectAtIndex:row]; +} + +- (void) pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component +{ + selected = row; +} + +- (IBAction)okayTapped:(id)sender +{ + if (selected > -1) + okayBlock([NSArray arrayWithObject:[choices objectAtIndex:selected]]); + [self dismissViewControllerAnimated:YES completion:nil]; +} + +- (IBAction)cancelTapped:(id)sender +{ + [self dismissViewControllerAnimated:YES completion:nil]; +} + +@end diff --git a/platform/ios/Classes/MuChoiceFieldController.xib b/platform/ios/Classes/MuChoiceFieldController.xib new file mode 100644 index 00000000..0b225782 --- /dev/null +++ b/platform/ios/Classes/MuChoiceFieldController.xib @@ -0,0 +1,639 @@ +<?xml version="1.0" encoding="UTF-8"?> +<archive type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="8.00"> + <data> + <int key="IBDocument.SystemTarget">1552</int> + <string key="IBDocument.SystemVersion">11G63b</string> + <string key="IBDocument.InterfaceBuilderVersion">3084</string> + <string key="IBDocument.AppKitVersion">1138.51</string> + <string key="IBDocument.HIToolboxVersion">569.00</string> + <object class="NSMutableDictionary" key="IBDocument.PluginVersions"> + <string key="NS.key.0">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="NS.object.0">2083</string> + </object> + <array key="IBDocument.IntegratedClassDependencies"> + <string>IBNSLayoutConstraint</string> + <string>IBProxyObject</string> + <string>IBUIButton</string> + <string>IBUILabel</string> + <string>IBUIPickerView</string> + <string>IBUIView</string> + </array> + <array key="IBDocument.PluginDependencies"> + <string>com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + </array> + <object class="NSMutableDictionary" key="IBDocument.Metadata"> + <string key="NS.key.0">PluginDependencyRecalculationVersion</string> + <integer value="1" key="NS.object.0"/> + </object> + <array class="NSMutableArray" key="IBDocument.RootObjects" id="1000"> + <object class="IBProxyObject" id="372490531"> + <string key="IBProxiedObjectIdentifier">IBFilesOwner</string> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + </object> + <object class="IBProxyObject" id="975951072"> + <string key="IBProxiedObjectIdentifier">IBFirstResponder</string> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + </object> + <object class="IBUIView" id="191373211"> + <reference key="NSNextResponder"/> + <int key="NSvFlags">274</int> + <array class="NSMutableArray" key="NSSubviews"> + <object class="IBUILabel" id="852968923"> + <reference key="NSNextResponder" ref="191373211"/> + <int key="NSvFlags">292</int> + <string key="NSFrame">{{20, 47}, {281, 21}}</string> + <reference key="NSSuperview" ref="191373211"/> + <reference key="NSWindow"/> + <reference key="NSNextKeyView" ref="5968742"/> + <string key="NSReuseIdentifierKey">_NS:9</string> + <bool key="IBUIOpaque">NO</bool> + <bool key="IBUIClipsSubviews">YES</bool> + <int key="IBUIContentMode">7</int> + <bool key="IBUIUserInteractionEnabled">NO</bool> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + <string key="IBUIText">Choose value</string> + <object class="NSColor" key="IBUITextColor" id="96159386"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MQA</bytes> + </object> + <nil key="IBUIHighlightedColor"/> + <int key="IBUIBaselineAdjustment">0</int> + <int key="IBUITextAlignment">1</int> + <object class="IBUIFontDescription" key="IBUIFontDescription"> + <int key="type">1</int> + <double key="pointSize">17</double> + </object> + <object class="NSFont" key="IBUIFont"> + <string key="NSName">Helvetica</string> + <double key="NSSize">17</double> + <int key="NSfFlags">16</int> + </object> + <bool key="IBUIAdjustsFontSizeToFit">NO</bool> + </object> + <object class="IBUIButton" id="831564724"> + <reference key="NSNextResponder" ref="191373211"/> + <int key="NSvFlags">292</int> + <string key="NSFrame">{{20, 416}, {280, 44}}</string> + <reference key="NSSuperview" ref="191373211"/> + <reference key="NSWindow"/> + <reference key="NSNextKeyView" ref="65437148"/> + <string key="NSReuseIdentifierKey">_NS:9</string> + <bool key="IBUIOpaque">NO</bool> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + <int key="IBUIContentHorizontalAlignment">0</int> + <int key="IBUIContentVerticalAlignment">0</int> + <int key="IBUIButtonType">1</int> + <string key="IBUINormalTitle">Okay</string> + <reference key="IBUIHighlightedTitleColor" ref="96159386"/> + <object class="NSColor" key="IBUINormalTitleColor"> + <int key="NSColorSpace">1</int> + <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes> + </object> + <object class="NSColor" key="IBUINormalTitleShadowColor" id="607563219"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MC41AA</bytes> + </object> + <object class="IBUIFontDescription" key="IBUIFontDescription" id="616815177"> + <int key="type">2</int> + <double key="pointSize">15</double> + </object> + <object class="NSFont" key="IBUIFont" id="536603733"> + <string key="NSName">Helvetica-Bold</string> + <double key="NSSize">15</double> + <int key="NSfFlags">16</int> + </object> + </object> + <object class="IBUIButton" id="65437148"> + <reference key="NSNextResponder" ref="191373211"/> + <int key="NSvFlags">292</int> + <string key="NSFrame">{{20, 476}, {281, 44}}</string> + <reference key="NSSuperview" ref="191373211"/> + <reference key="NSWindow"/> + <string key="NSReuseIdentifierKey">_NS:9</string> + <bool key="IBUIOpaque">NO</bool> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + <int key="IBUIContentHorizontalAlignment">0</int> + <int key="IBUIContentVerticalAlignment">0</int> + <int key="IBUIButtonType">1</int> + <string key="IBUINormalTitle">Cancel</string> + <reference key="IBUIHighlightedTitleColor" ref="96159386"/> + <object class="NSColor" key="IBUINormalTitleColor"> + <int key="NSColorSpace">1</int> + <bytes key="NSRGB">MC4xOTYwNzg0MzQ2IDAuMzA5ODAzOTMyOSAwLjUyMTU2ODY1NgA</bytes> + </object> + <reference key="IBUINormalTitleShadowColor" ref="607563219"/> + <reference key="IBUIFontDescription" ref="616815177"/> + <reference key="IBUIFont" ref="536603733"/> + </object> + <object class="IBUIPickerView" id="5968742"> + <reference key="NSNextResponder" ref="191373211"/> + <int key="NSvFlags">290</int> + <string key="NSFrame">{{20, 119}, {280, 216}}</string> + <reference key="NSSuperview" ref="191373211"/> + <reference key="NSWindow"/> + <reference key="NSNextKeyView" ref="831564724"/> + <string key="NSReuseIdentifierKey">_NS:9</string> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + <bool key="IBUIShowsSelectionIndicator">YES</bool> + </object> + </array> + <string key="NSFrame">{{0, 20}, {320, 548}}</string> + <reference key="NSSuperview"/> + <reference key="NSWindow"/> + <reference key="NSNextKeyView" ref="852968923"/> + <object class="NSColor" key="IBUIBackgroundColor"> + <int key="NSColorSpace">3</int> + <bytes key="NSWhite">MC4zMzMzMzMzMzMzAA</bytes> + </object> + <object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/> + <object class="IBUIScreenMetrics" key="IBUISimulatedDestinationMetrics"> + <string key="IBUISimulatedSizeMetricsClass">IBUIScreenMetrics</string> + <object class="NSMutableDictionary" key="IBUINormalizedOrientationToSizeMap"> + <bool key="EncodedWithXMLCoder">YES</bool> + <array key="dict.sortedKeys"> + <integer value="1"/> + <integer value="3"/> + </array> + <array key="dict.values"> + <string>{320, 568}</string> + <string>{568, 320}</string> + </array> + </object> + <string key="IBUITargetRuntime">IBCocoaTouchFramework</string> + <string key="IBUIDisplayName">Retina 4 Full Screen</string> + <int key="IBUIType">2</int> + </object> + <string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string> + </object> + </array> + <object class="IBObjectContainer" key="IBDocument.Objects"> + <array class="NSMutableArray" key="connectionRecords"> + <object class="IBConnectionRecord"> + <object class="IBCocoaTouchOutletConnection" key="connection"> + <string key="label">view</string> + <reference key="source" ref="372490531"/> + <reference key="destination" ref="191373211"/> + </object> + <int key="connectionID">3</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBCocoaTouchOutletConnection" key="connection"> + <string key="label">picker</string> + <reference key="source" ref="372490531"/> + <reference key="destination" ref="5968742"/> + </object> + <int key="connectionID">87</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBCocoaTouchEventConnection" key="connection"> + <string key="label">okayTapped:</string> + <reference key="source" ref="831564724"/> + <reference key="destination" ref="372490531"/> + <int key="IBEventType">7</int> + </object> + <int key="connectionID">88</int> + </object> + <object class="IBConnectionRecord"> + <object class="IBCocoaTouchEventConnection" key="connection"> + <string key="label">cancelTapped:</string> + <reference key="source" ref="65437148"/> + <reference key="destination" ref="372490531"/> + <int key="IBEventType">7</int> + </object> + <int key="connectionID">89</int> + </object> + </array> + <object class="IBMutableOrderedSet" key="objectRecords"> + <array key="orderedObjects"> + <object class="IBObjectRecord"> + <int key="objectID">0</int> + <array key="object" id="0"/> + <reference key="children" ref="1000"/> + <nil key="parent"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">1</int> + <reference key="object" ref="191373211"/> + <array class="NSMutableArray" key="children"> + <object class="IBNSLayoutConstraint" id="39033334"> + <reference key="firstItem" ref="65437148"/> + <int key="firstAttribute">5</int> + <int key="relation">0</int> + <reference key="secondItem" ref="191373211"/> + <int key="secondAttribute">5</int> + <float key="multiplier">1</float> + <object class="IBNSLayoutSymbolicConstant" key="constant"> + <double key="value">20</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="191373211"/> + <int key="scoringType">8</int> + <float key="scoringTypeFloat">29</float> + <int key="contentType">3</int> + </object> + <object class="IBNSLayoutConstraint" id="1029677805"> + <reference key="firstItem" ref="191373211"/> + <int key="firstAttribute">4</int> + <int key="relation">0</int> + <reference key="secondItem" ref="65437148"/> + <int key="secondAttribute">4</int> + <float key="multiplier">1</float> + <object class="IBLayoutConstant" key="constant"> + <double key="value">29</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="191373211"/> + <int key="scoringType">3</int> + <float key="scoringTypeFloat">9</float> + <int key="contentType">3</int> + </object> + <object class="IBNSLayoutConstraint" id="942754903"> + <reference key="firstItem" ref="191373211"/> + <int key="firstAttribute">4</int> + <int key="relation">0</int> + <reference key="secondItem" ref="831564724"/> + <int key="secondAttribute">4</int> + <float key="multiplier">1</float> + <object class="IBLayoutConstant" key="constant"> + <double key="value">89</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="191373211"/> + <int key="scoringType">3</int> + <float key="scoringTypeFloat">9</float> + <int key="contentType">3</int> + </object> + <object class="IBNSLayoutConstraint" id="745573488"> + <reference key="firstItem" ref="831564724"/> + <int key="firstAttribute">9</int> + <int key="relation">0</int> + <reference key="secondItem" ref="65437148"/> + <int key="secondAttribute">9</int> + <float key="multiplier">1</float> + <object class="IBLayoutConstant" key="constant"> + <double key="value">0.0</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="191373211"/> + <int key="scoringType">6</int> + <float key="scoringTypeFloat">24</float> + <int key="contentType">2</int> + </object> + <object class="IBNSLayoutConstraint" id="374543723"> + <reference key="firstItem" ref="191373211"/> + <int key="firstAttribute">6</int> + <int key="relation">0</int> + <reference key="secondItem" ref="831564724"/> + <int key="secondAttribute">6</int> + <float key="multiplier">1</float> + <object class="IBNSLayoutSymbolicConstant" key="constant"> + <double key="value">20</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="191373211"/> + <int key="scoringType">8</int> + <float key="scoringTypeFloat">29</float> + <int key="contentType">3</int> + </object> + <object class="IBNSLayoutConstraint" id="357946085"> + <reference key="firstItem" ref="831564724"/> + <int key="firstAttribute">5</int> + <int key="relation">0</int> + <reference key="secondItem" ref="191373211"/> + <int key="secondAttribute">5</int> + <float key="multiplier">1</float> + <object class="IBNSLayoutSymbolicConstant" key="constant"> + <double key="value">20</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="191373211"/> + <int key="scoringType">8</int> + <float key="scoringTypeFloat">29</float> + <int key="contentType">3</int> + </object> + <object class="IBNSLayoutConstraint" id="981314549"> + <reference key="firstItem" ref="191373211"/> + <int key="firstAttribute">6</int> + <int key="relation">0</int> + <reference key="secondItem" ref="5968742"/> + <int key="secondAttribute">6</int> + <float key="multiplier">1</float> + <object class="IBNSLayoutSymbolicConstant" key="constant"> + <double key="value">20</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="191373211"/> + <int key="scoringType">8</int> + <float key="scoringTypeFloat">29</float> + <int key="contentType">3</int> + </object> + <object class="IBNSLayoutConstraint" id="855118322"> + <reference key="firstItem" ref="5968742"/> + <int key="firstAttribute">5</int> + <int key="relation">0</int> + <reference key="secondItem" ref="191373211"/> + <int key="secondAttribute">5</int> + <float key="multiplier">1</float> + <object class="IBNSLayoutSymbolicConstant" key="constant"> + <double key="value">20</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="191373211"/> + <int key="scoringType">8</int> + <float key="scoringTypeFloat">29</float> + <int key="contentType">3</int> + </object> + <object class="IBNSLayoutConstraint" id="543940552"> + <reference key="firstItem" ref="5968742"/> + <int key="firstAttribute">3</int> + <int key="relation">0</int> + <reference key="secondItem" ref="191373211"/> + <int key="secondAttribute">3</int> + <float key="multiplier">1</float> + <object class="IBLayoutConstant" key="constant"> + <double key="value">119</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="191373211"/> + <int key="scoringType">3</int> + <float key="scoringTypeFloat">9</float> + <int key="contentType">3</int> + </object> + <object class="IBNSLayoutConstraint" id="856939218"> + <reference key="firstItem" ref="852968923"/> + <int key="firstAttribute">6</int> + <int key="relation">0</int> + <reference key="secondItem" ref="65437148"/> + <int key="secondAttribute">6</int> + <float key="multiplier">1</float> + <object class="IBLayoutConstant" key="constant"> + <double key="value">0.0</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="191373211"/> + <int key="scoringType">6</int> + <float key="scoringTypeFloat">24</float> + <int key="contentType">2</int> + </object> + <object class="IBNSLayoutConstraint" id="37372808"> + <reference key="firstItem" ref="852968923"/> + <int key="firstAttribute">3</int> + <int key="relation">0</int> + <reference key="secondItem" ref="191373211"/> + <int key="secondAttribute">3</int> + <float key="multiplier">1</float> + <object class="IBLayoutConstant" key="constant"> + <double key="value">47</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="191373211"/> + <int key="scoringType">3</int> + <float key="scoringTypeFloat">9</float> + <int key="contentType">3</int> + </object> + <object class="IBNSLayoutConstraint" id="576864315"> + <reference key="firstItem" ref="852968923"/> + <int key="firstAttribute">5</int> + <int key="relation">0</int> + <reference key="secondItem" ref="191373211"/> + <int key="secondAttribute">5</int> + <float key="multiplier">1</float> + <object class="IBNSLayoutSymbolicConstant" key="constant"> + <double key="value">20</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="191373211"/> + <int key="scoringType">8</int> + <float key="scoringTypeFloat">29</float> + <int key="contentType">3</int> + </object> + <reference ref="852968923"/> + <reference ref="831564724"/> + <reference ref="65437148"/> + <reference ref="5968742"/> + </array> + <reference key="parent" ref="0"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">-1</int> + <reference key="object" ref="372490531"/> + <reference key="parent" ref="0"/> + <string key="objectName">File's Owner</string> + </object> + <object class="IBObjectRecord"> + <int key="objectID">-2</int> + <reference key="object" ref="975951072"/> + <reference key="parent" ref="0"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">4</int> + <reference key="object" ref="852968923"/> + <array class="NSMutableArray" key="children"/> + <reference key="parent" ref="191373211"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">11</int> + <reference key="object" ref="576864315"/> + <reference key="parent" ref="191373211"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">22</int> + <reference key="object" ref="831564724"/> + <array class="NSMutableArray" key="children"/> + <reference key="parent" ref="191373211"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">41</int> + <reference key="object" ref="37372808"/> + <reference key="parent" ref="191373211"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">48</int> + <reference key="object" ref="357946085"/> + <reference key="parent" ref="191373211"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">49</int> + <reference key="object" ref="374543723"/> + <reference key="parent" ref="191373211"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">59</int> + <reference key="object" ref="65437148"/> + <array class="NSMutableArray" key="children"/> + <reference key="parent" ref="191373211"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">60</int> + <reference key="object" ref="1029677805"/> + <reference key="parent" ref="191373211"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">62</int> + <reference key="object" ref="39033334"/> + <reference key="parent" ref="191373211"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">64</int> + <reference key="object" ref="745573488"/> + <reference key="parent" ref="191373211"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">68</int> + <reference key="object" ref="942754903"/> + <reference key="parent" ref="191373211"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">73</int> + <reference key="object" ref="856939218"/> + <reference key="parent" ref="191373211"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">74</int> + <reference key="object" ref="5968742"/> + <array class="NSMutableArray" key="children"> + <object class="IBNSLayoutConstraint" id="1019750097"> + <reference key="firstItem" ref="5968742"/> + <int key="firstAttribute">8</int> + <int key="relation">0</int> + <nil key="secondItem"/> + <int key="secondAttribute">0</int> + <float key="multiplier">1</float> + <object class="IBLayoutConstant" key="constant"> + <double key="value">216</double> + </object> + <float key="priority">1000</float> + <reference key="containingView" ref="5968742"/> + <int key="scoringType">3</int> + <float key="scoringTypeFloat">9</float> + <int key="contentType">1</int> + </object> + </array> + <reference key="parent" ref="191373211"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">76</int> + <reference key="object" ref="1019750097"/> + <reference key="parent" ref="5968742"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">83</int> + <reference key="object" ref="981314549"/> + <reference key="parent" ref="191373211"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">81</int> + <reference key="object" ref="543940552"/> + <reference key="parent" ref="191373211"/> + </object> + <object class="IBObjectRecord"> + <int key="objectID">82</int> + <reference key="object" ref="855118322"/> + <reference key="parent" ref="191373211"/> + </object> + </array> + </object> + <dictionary class="NSMutableDictionary" key="flattenedProperties"> + <string key="-1.CustomClassName">MuChoiceFieldController</string> + <string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="-2.CustomClassName">UIResponder</string> + <string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="1.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <array class="NSMutableArray" key="1.IBViewMetadataConstraints"> + <reference ref="576864315"/> + <reference ref="37372808"/> + <reference ref="856939218"/> + <reference ref="543940552"/> + <reference ref="855118322"/> + <reference ref="981314549"/> + <reference ref="357946085"/> + <reference ref="374543723"/> + <reference ref="745573488"/> + <reference ref="942754903"/> + <reference ref="1029677805"/> + <reference ref="39033334"/> + </array> + <string key="11.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="22.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <boolean value="NO" key="22.IBViewMetadataTranslatesAutoresizingMaskIntoConstraints"/> + <string key="4.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <boolean value="NO" key="4.IBViewMetadataTranslatesAutoresizingMaskIntoConstraints"/> + <string key="41.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="48.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="49.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="59.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <boolean value="NO" key="59.IBViewMetadataTranslatesAutoresizingMaskIntoConstraints"/> + <string key="60.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="62.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="64.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="68.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="73.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="74.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <array class="NSMutableArray" key="74.IBViewMetadataConstraints"> + <reference ref="1019750097"/> + </array> + <boolean value="NO" key="74.IBViewMetadataTranslatesAutoresizingMaskIntoConstraints"/> + <string key="76.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="81.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="82.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + <string key="83.IBPluginDependency">com.apple.InterfaceBuilder.IBCocoaTouchPlugin</string> + </dictionary> + <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/> + <nil key="activeLocalization"/> + <dictionary class="NSMutableDictionary" key="localizations"/> + <nil key="sourceID"/> + <int key="maxID">89</int> + </object> + <object class="IBClassDescriber" key="IBDocument.Classes"> + <array class="NSMutableArray" key="referencedPartialClassDescriptions"> + <object class="IBPartialClassDescription"> + <string key="className">MuChoiceFieldController</string> + <string key="superclassName">UIViewController</string> + <dictionary class="NSMutableDictionary" key="actions"> + <string key="cancelTapped:">id</string> + <string key="okayTapped:">id</string> + </dictionary> + <dictionary class="NSMutableDictionary" key="actionInfosByName"> + <object class="IBActionInfo" key="cancelTapped:"> + <string key="name">cancelTapped:</string> + <string key="candidateClassName">id</string> + </object> + <object class="IBActionInfo" key="okayTapped:"> + <string key="name">okayTapped:</string> + <string key="candidateClassName">id</string> + </object> + </dictionary> + <object class="NSMutableDictionary" key="outlets"> + <string key="NS.key.0">picker</string> + <string key="NS.object.0">UIPickerView</string> + </object> + <object class="NSMutableDictionary" key="toOneOutletInfosByName"> + <string key="NS.key.0">picker</string> + <object class="IBToOneOutletInfo" key="NS.object.0"> + <string key="name">picker</string> + <string key="candidateClassName">UIPickerView</string> + </object> + </object> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">./Classes/MuChoiceFieldController.h</string> + </object> + </object> + <object class="IBPartialClassDescription"> + <string key="className">NSLayoutConstraint</string> + <string key="superclassName">NSObject</string> + <object class="IBClassDescriptionSource" key="sourceIdentifier"> + <string key="majorKey">IBProjectSource</string> + <string key="minorKey">./Classes/NSLayoutConstraint.h</string> + </object> + </object> + </array> + </object> + <int key="IBDocument.localizationMode">0</int> + <string key="IBDocument.TargetRuntimeIdentifier">IBCocoaTouchFramework</string> + <bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool> + <int key="IBDocument.defaultPropertyAccessControl">3</int> + <bool key="IBDocument.UseAutolayout">YES</bool> + <string key="IBCocoaTouchPluginVersion">2083</string> + </data> +</archive> diff --git a/platform/ios/Classes/MuDialogCreator.h b/platform/ios/Classes/MuDialogCreator.h index 9417facf..cba863af 100644 --- a/platform/ios/Classes/MuDialogCreator.h +++ b/platform/ios/Classes/MuDialogCreator.h @@ -9,4 +9,5 @@ @protocol MuDialogCreator <NSObject> - (void) invokeTextDialog:(NSString *)aString okayAction:(void (^)(NSString *))block; +- (void) invokeChoiceDialog:(NSArray *)anArray okayAction:(void (^)(NSArray *))block; @end diff --git a/platform/ios/Classes/MuDocumentController.m b/platform/ios/Classes/MuDocumentController.m index 7b52f3e8..01583ac3 100644 --- a/platform/ios/Classes/MuDocumentController.m +++ b/platform/ios/Classes/MuDocumentController.m @@ -11,6 +11,7 @@ #import "MuPageViewReflow.h" #import "MuDocumentController.h" #import "MuTextFieldController.h" +#import "MuChoiceFieldController.h" #define GAP 20 #define INDICATOR_Y -44-24 @@ -629,6 +630,14 @@ static void flattenOutline(NSMutableArray *titles, NSMutableArray *pages, fz_out [tf release]; } +- (void) invokeChoiceDialog:(NSArray *)anArray okayAction:(void (^)(NSArray *))block +{ + MuChoiceFieldController *cf = [[MuChoiceFieldController alloc] initWithChoices:anArray okayAction:block]; + cf.modalPresentationStyle = UIModalPresentationFormSheet; + [self presentViewController:cf animated:YES completion:nil]; + [cf release]; +} + - (void) onGotoPageFinished { scroll_animating = NO; diff --git a/platform/ios/Classes/MuPageViewNormal.m b/platform/ios/Classes/MuPageViewNormal.m index a342ae8e..8c247297 100644 --- a/platform/ios/Classes/MuPageViewNormal.m +++ b/platform/ios/Classes/MuPageViewNormal.m @@ -95,6 +95,31 @@ static int setFocussedWidgetText(fz_document *doc, fz_page *page, const char *te return accepted; } +static int setFocussedWidgetChoice(fz_document *doc, fz_page *page, const char *text) +{ + int accepted; + + fz_try(ctx) + { + pdf_document *idoc = pdf_specifics(doc); + if (idoc) + { + pdf_widget *focus = pdf_focused_widget(idoc); + if (focus) + { + pdf_choice_widget_set_value(idoc, focus, 1, (char **)&text); + accepted = 1; + } + } + } + fz_catch(ctx) + { + accepted = 0; + } + + return accepted; +} + static fz_display_list *create_page_list(fz_document *doc, fz_page *page) { fz_display_list *list; @@ -763,6 +788,32 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa }]; } +- (void) invokeChoiceDialog:(NSArray *)choices +{ + [dialogCreator invokeChoiceDialog:choices okayAction:^(NSArray *selection) { + CGRect tframe = tileFrame; + float tscale = tileScale; + CGRect vframe = tframe; + vframe.origin.x -= imageView.frame.origin.x; + vframe.origin.y -= imageView.frame.origin.y; + + dispatch_async(queue, ^{ + BOOL accepted = setFocussedWidgetChoice(doc, page, [[selection objectAtIndex:0] UTF8String]); + if (accepted) + { + [self updatePageAndTileWithTileFrame:tframe tileScale:tscale viewFrame:vframe]; + } + else + { + dispatch_async(dispatch_get_main_queue(), ^{ + [self invokeChoiceDialog:choices]; + }); + } + }); + + }]; +} + - (int) passTapToPage:(CGPoint)pt { pdf_document *idoc = pdf_specifics(doc); @@ -770,10 +821,14 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa pdf_ui_event event; int changed = 0; pdf_widget *focus; + char **opts = NULL; + char *text = NULL; if (!idoc) return; + fz_var(opts); + fz_var(text); fz_try(ctx) { event.etype = PDF_EVENT_TYPE_POINTER; @@ -791,18 +846,30 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa { case PDF_WIDGET_TYPE_TEXT: { - char *text = pdf_text_widget_text(idoc, focus); - NSString *stext = [NSString stringWithUTF8String:text?text:""]; - fz_free(ctx, text); + text = pdf_text_widget_text(idoc, focus); + NSString *stext = [[NSString stringWithUTF8String:text?text:""] retain]; dispatch_async(dispatch_get_main_queue(), ^{ [self invokeTextDialog:stext]; + [stext release]; }); break; } case PDF_WIDGET_TYPE_LISTBOX: case PDF_WIDGET_TYPE_COMBOBOX: + { + int nopts = pdf_choice_widget_options(idoc, focus, NULL); + opts = fz_malloc(ctx, nopts * sizeof(*opts)); + (void)pdf_choice_widget_options(idoc, focus, opts); + NSMutableArray *arr = [[NSMutableArray arrayWithCapacity:nopts] retain]; + for (int i = 0; i < nopts; i++) + [arr addObject:[NSString stringWithUTF8String:opts[i]]]; + dispatch_async(dispatch_get_main_queue(), ^{ + [self invokeChoiceDialog:arr]; + [arr release]; + }); break; + } case PDF_WIDGET_TYPE_SIGNATURE: break; @@ -812,6 +879,11 @@ static void updatePixmap(fz_document *doc, fz_display_list *page_list, fz_displa } } } + fz_always(ctx) + { + fz_free(ctx, text); + fz_free(ctx, opts); + } fz_catch(ctx) { } diff --git a/platform/ios/MuPDF.xcodeproj/project.pbxproj b/platform/ios/MuPDF.xcodeproj/project.pbxproj index b4783e32..520a1e18 100644 --- a/platform/ios/MuPDF.xcodeproj/project.pbxproj +++ b/platform/ios/MuPDF.xcodeproj/project.pbxproj @@ -47,6 +47,8 @@ DAB9F4C017F1B24000117D2E /* ic_magnifying_glass.png in Resources */ = {isa = PBXBuildFile; fileRef = DAB9F4BA17F1B24000117D2E /* ic_magnifying_glass.png */; }; DAB9F4C217F1CB6D00117D2E /* ic_reflow.png in Resources */ = {isa = PBXBuildFile; fileRef = DAB9F4C117F1CB6D00117D2E /* ic_reflow.png */; }; DABDEF5A17EC484A00AC35F1 /* MuDocRef.m in Sources */ = {isa = PBXBuildFile; fileRef = DABDEF5917EC484A00AC35F1 /* MuDocRef.m */; }; + DABF8CC3180C28E60069CB6D /* MuChoiceFieldController.xib in Resources */ = {isa = PBXBuildFile; fileRef = DABF8CC2180C28E60069CB6D /* MuChoiceFieldController.xib */; }; + DABF8CC6180C2C650069CB6D /* MuChoiceFieldController.m in Sources */ = {isa = PBXBuildFile; fileRef = DABF8CC5180C2C640069CB6D /* MuChoiceFieldController.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -114,6 +116,9 @@ DAB9F4C117F1CB6D00117D2E /* ic_reflow.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = ic_reflow.png; path = "../android/res/drawable-ldpi/ic_reflow.png"; sourceTree = "<group>"; }; DABDEF5817EC484A00AC35F1 /* MuDocRef.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MuDocRef.h; path = Classes/MuDocRef.h; sourceTree = "<group>"; }; DABDEF5917EC484A00AC35F1 /* MuDocRef.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MuDocRef.m; path = Classes/MuDocRef.m; sourceTree = "<group>"; }; + DABF8CC2180C28E60069CB6D /* MuChoiceFieldController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; name = MuChoiceFieldController.xib; path = Classes/MuChoiceFieldController.xib; sourceTree = "<group>"; }; + DABF8CC4180C2C640069CB6D /* MuChoiceFieldController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MuChoiceFieldController.h; path = Classes/MuChoiceFieldController.h; sourceTree = "<group>"; }; + DABF8CC5180C2C640069CB6D /* MuChoiceFieldController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = MuChoiceFieldController.m; path = Classes/MuChoiceFieldController.m; sourceTree = "<group>"; }; DADD8D6917EB24C000C49E0B /* MuPageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MuPageView.h; path = Classes/MuPageView.h; sourceTree = "<group>"; }; /* End PBXFileReference section */ @@ -227,6 +232,9 @@ DAB20D4318042D830030623F /* MuTextFieldController.m */, DAB20D4418042D830030623F /* MuTextFieldController.xib */, DAB20D4718045AC40030623F /* MuDialogCreator.h */, + DABF8CC4180C2C640069CB6D /* MuChoiceFieldController.h */, + DABF8CC5180C2C640069CB6D /* MuChoiceFieldController.m */, + DABF8CC2180C28E60069CB6D /* MuChoiceFieldController.xib */, ); name = Classes; sourceTree = "<group>"; @@ -321,6 +329,7 @@ DAB9F4C017F1B24000117D2E /* ic_magnifying_glass.png in Resources */, DAB9F4C217F1CB6D00117D2E /* ic_reflow.png in Resources */, DAB20D4618042D830030623F /* MuTextFieldController.xib in Resources */, + DABF8CC3180C28E60069CB6D /* MuChoiceFieldController.xib in Resources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -366,6 +375,7 @@ DABDEF5A17EC484A00AC35F1 /* MuDocRef.m in Sources */, DAAC6A2E17FC6E4A00A0E83A /* MuTapResult.m in Sources */, DAB20D4518042D830030623F /* MuTextFieldController.m in Sources */, + DABF8CC6180C2C650069CB6D /* MuChoiceFieldController.m in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; |