forked from netshade/Cocoa-Touch-Barcodes
-
Notifications
You must be signed in to change notification settings - Fork 1
/
NKDAbstractUPCEANBarcode.h
138 lines (120 loc) · 4.32 KB
/
NKDAbstractUPCEANBarcode.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
// -----------------------------------------------------------------------------------
// NKDAbstractUPCEANBarcode.h
// -----------------------------------------------------------------------------------
// Created by Jeff LaMarche on Sat May 11 2002.
// �2002 Naked Software. All rights reserved.
// -----------------------------------------------------------------------------------
// THIS SOURCE CODE IS PROVIDED AS-IS WITH NO WARRANTY OF ANY KIND
// -----------------------------------------------------------------------------------
// You may use and redistribute this source code without limitation
// -----------------------------------------------------------------------------------
#import <Foundation/Foundation.h>
#import "NKDBarcode.h"
#import "NSString-UPCEAN.h"
/*!
@header NKDAbstractUPCEANBarcode.h
This is an abstract object to encapsulate the functionality that the various UPC and EAN barcodes have in common,
including parity-swapping and digit encoding.
*/
/*!
@typedef Parity
@discussion Defines a type of "Parity" (as a BOOL) to make methods that take one of the precompiler defined parity values
more readable.
*/
typedef BOOL Parity;
/*!
@typedef Handedness
@discussion Defiens a type of Handedness (as a BOOL) to deal with the difference between left and right handed encoding schemes
*/
typedef BOOL Handedness;
/*!
@defined EVEN_PARITY
@discussion UPC / EAN codes use parity swapping to increase the number of values that can be encoded. This
defines EVEN_PARITY as YES to make the code more readable.
*/
#define EVEN_PARITY YES
/*!
@defined ODD_PARITY
@discussion UPC / EAN codes use parity swapping to increase the number of values that can be encoded. This
defines ODD_PARITY as NO to make the code more readable.
*/
#define ODD_PARITY NO
/*!
@defined LEFT_HANDEDNESS
*/
#define LEFT_HANDEDNESS
/*!
@defined RIGHT_HANDEDNESS
*/
#define RIGHT_HANDEDNESS
/*!
@class NKDAbstractUPCEANBarcode
@discussion This abstract class holds all the functionality shared by UPC-A, UPC-E, EAN-13 and EAN-8
*/
@interface NKDAbstractUPCEANBarcode : NKDBarcode
{
}
/*!
@method calculateWidth
@abstract Overridden to provide extra space to the left and right needed for printing first and last characters
*/
-(void)calculateWidth;
/*!
@method firstBar
@abstract Overridden to set a first bar position indented in from the left to provide room for the first digit
@result A value that is 10% of the total width. The total width is calculated at 120% needed to hold the barcode.
*/
-(float)firstBar;
/*!
@method lastBar
@abstract Overridden to set a last bar position indented from the right to provide room for the check digit.
@result A value that is 90% of the total width. The total width is calculated at 120% needed to hold the barcode.
*/
-(float)lastBar;
/*!
@method _encodeChar
@abstract Simple encoding scheme that returns a 7 character string
@discussion This routine returns the left-hand odd encoding. Either the handedness or parity can be converted using
the routines _swapParity: and _swapHandedness
@result String of 0s and 1s representing this character
*/
-(NSString *)_encodeChar:(char)inChar;
/*!
@method initiator
@abstract Returns start character for UPC-A
@result "101" The start and end character for UPC / EAN
*/
-(NSString *)initiator;
/*!
@method terminator
@abstract Returns end character for UPC or EAN barcode
@result "101" The start and end character for UPC / EAN
*/
-(NSString *)terminator;
/*!
@method digitsToRight
@abstract Overridden to specify that one character of the caption prints to the right of the barcode
@result 1
*/
-(int)digitsToRight;
/*!
@method barBottom:
@abstract Overridden to specify that guard bars, terminator and initiator should extend down into the caption area
@param index The index of the bar that you want to find the bottom for (assuming origin at lower left) as an index of
completeBarcode
@result Bottom of the bar specified in inches * screenResolution()
*/
-(float)barBottom:(int)index;
/*!
@method digitsToLeft
@abstract Overridden to specify that one character of the caption prints to the left of the barcode
@result 1
*/
-(int)digitsToLeft;
/*!
@method rightCaption
@abstract Overridden to specify that the check digit prints to the right of the caption
@result The check digit wrapped in an NSString *
*/
-(NSString *)rightCaption;
@end