Issue 479
[zxing.git] / iphone / ZXingWidget / Classes / ZXingWidgetController.h
1 /**
2  * Copyright 2009 Jeff Verkoeyen
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *    http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #include <UIKit/UIKit.h>
18 #include <AudioToolbox/AudioToolbox.h>
19 #import <AVFoundation/AVFoundation.h>
20 #include "Decoder.h"
21 #include "parsedResults/ParsedResult.h"
22 #include "OverlayView.h"
23
24 @protocol ZXingDelegate;
25
26 #if !TARGET_IPHONE_SIMULATOR
27 #define HAS_AVFF 1
28 #endif
29
30 @interface ZXingWidgetController : UIViewController<DecoderDelegate,
31                                                     CancelDelegate,
32                                                     UINavigationControllerDelegate
33 #if HAS_AVFF
34                                                     , AVCaptureVideoDataOutputSampleBufferDelegate
35 #endif
36                                                     > {
37   NSSet *readers;
38   ParsedResult *result;
39   OverlayView *overlayView;
40   SystemSoundID beepSound;
41   BOOL showCancel;
42   NSURL *soundToPlay;
43   id<ZXingDelegate> delegate;
44   BOOL wasCancelled;
45   BOOL oneDMode;
46 #if HAS_AVFF
47   AVCaptureSession *captureSession;
48   AVCaptureVideoPreviewLayer *prevLayer;
49 #endif
50   BOOL decoding;
51 }
52
53 #if HAS_AVFF
54 @property (nonatomic, retain) AVCaptureSession *captureSession;
55 @property (nonatomic, retain) AVCaptureVideoPreviewLayer *prevLayer;
56 #endif
57 @property (nonatomic, retain ) NSSet *readers;
58 @property (nonatomic, assign) id<ZXingDelegate> delegate;
59 @property (nonatomic, retain) NSURL *soundToPlay;
60 @property (nonatomic, retain) ParsedResult *result;
61 @property (nonatomic, retain) OverlayView *overlayView;
62
63 - (id)initWithDelegate:(id<ZXingDelegate>)delegate showCancel:(BOOL)shouldShowCancel OneDMode:(BOOL)shouldUseoOneDMode;
64
65 - (BOOL)fixedFocus;
66 @end
67
68 @protocol ZXingDelegate
69 - (void)zxingController:(ZXingWidgetController*)controller didScanResult:(NSString *)result;
70 - (void)zxingControllerDidCancel:(ZXingWidgetController*)controller;
71 @end