-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
145 changed files
with
8,173 additions
and
1,055 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,14 @@ | ||
Pod::Spec.new do |spec| | ||
spec.name = 'BarCodeKit' | ||
spec.version = '1.1.0' | ||
spec.platform = :ios, '7.0' | ||
spec.version = '1.2.0' | ||
spec.license = 'BSD' | ||
spec.source = { :git => '[email protected]:parts/barcodekit.git', :tag => spec.version.to_s } | ||
spec.source_files = 'Core/Source/*.{h,m}', 'Core/*.h' | ||
spec.ios.source_files = 'Core/Source/iOS/*.{h,m}', 'Core/Source/*.{h,m}', 'Core/*.h' | ||
spec.osx.source_files = 'Core/Source/Mac/*.{h,m}', 'Core/Source/*.{h,m}', 'Core/*.h' | ||
spec.requires_arc = true | ||
spec.homepage = 'http://www.cocoanetics.com/parts/barcodekit/' | ||
spec.summary = 'A framework to generate bar codes on iOS.' | ||
spec.summary = 'A framework to generate bar codes on iOS or Mac.' | ||
spec.author = { 'Oliver Drobnik' => '[email protected]' } | ||
spec.ios.frameworks = 'Foundation', 'UIKit' | ||
spec.osx.frameworks = 'Foundation', 'AppKit' | ||
end |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>English</string> | ||
<key>CFBundleExecutable</key> | ||
<string>${EXECUTABLE_NAME}</string> | ||
<key>CFBundleIconFile</key> | ||
<string></string> | ||
<key>CFBundleIdentifier</key> | ||
<string>com.cocoanetics.${PRODUCT_NAME:rfc1034identifier}</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>${PRODUCT_NAME}</string> | ||
<key>CFBundlePackageType</key> | ||
<string>FMWK</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0</string> | ||
<key>CFBundleSignature</key> | ||
<string>????</string> | ||
<key>CFBundleVersion</key> | ||
<string>1</string> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>Copyright © 2013 Oliver Drobnik. All rights reserved.</string> | ||
<key>NSPrincipalClass</key> | ||
<string></string> | ||
</dict> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,16 @@ | ||
// | ||
// Prefix header | ||
// | ||
// The contents of this file are implicitly included at the beginning of every source file. | ||
// BarCodeKit Prefix header | ||
// | ||
|
||
#import <Availability.h> | ||
|
||
|
||
#ifdef __OBJC__ | ||
#import <Foundation/Foundation.h> | ||
#import <UIKit/UIKit.h> | ||
|
||
#if TARGET_OS_IPHONE | ||
#import <UIKit/UIKit.h> | ||
#else | ||
#import <Cocoa/Cocoa.h> | ||
#endif | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// | ||
// BCKCodabarCode.h | ||
// BarCodeKit | ||
// | ||
// Created by Geoff Breemer on 14/09/13. | ||
// Copyright (c) 2013 Oliver Drobnik. All rights reserved. | ||
// | ||
|
||
#import "BCKCode.h" | ||
|
||
/** | ||
Specialized subclass of BCKCode to represent a Codabar barcode. | ||
*/ | ||
@interface BCKCodabarCode : BCKCode <BCKCoding> | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,196 @@ | ||
// | ||
// BCKCodabarCode.m | ||
// BarCodeKit | ||
// | ||
// Created by Geoff Breemer on 14/09/13. | ||
// Copyright (c) 2013 Oliver Drobnik. All rights reserved. | ||
// | ||
|
||
#import "BCKCodabarCode.h" | ||
#import "BCKCodabarCodeCharacter.h" | ||
#import "BCKCodabarContentCodeCharacter.h" | ||
#import "NSError+BCKCode.h" | ||
|
||
@implementation BCKCodabarCode | ||
|
||
#pragma mark - BCKCoding Methods | ||
|
||
+ (NSString *)barcodeStandard | ||
{ | ||
return @"Not an international standard"; | ||
} | ||
|
||
+ (NSString *)barcodeDescription | ||
{ | ||
return @"Codabar"; | ||
} | ||
|
||
+ (BOOL)canEncodeContent:(NSString *)content error:(NSError **)error | ||
{ | ||
BCKCodabarCodeCharacter *codeCharacter; | ||
NSString *message; | ||
|
||
if ([content length] < 3) | ||
{ | ||
if (error) | ||
{ | ||
message = [NSString stringWithFormat:@"%@ requires at least three characters", NSStringFromClass([self class])]; | ||
|
||
if (error) | ||
{ | ||
*error = [NSError BCKCodeErrorWithMessage:message]; | ||
} | ||
|
||
return NO; | ||
} | ||
} | ||
|
||
for (NSUInteger index=0; index<[content length]; index++) | ||
{ | ||
NSString *character = [content substringWithRange:NSMakeRange(index, 1)]; | ||
|
||
// If it is the first or last character create a start/stop characters. For all others create a content code character | ||
if ((index==0) || (index==[content length]-1)) | ||
{ | ||
codeCharacter = [BCKCodabarCodeCharacter startStopCodeCharacter:character]; | ||
} | ||
else | ||
{ | ||
codeCharacter = [[BCKCodabarContentCodeCharacter alloc] initWithCharacter:character]; | ||
} | ||
|
||
if (!codeCharacter) | ||
{ | ||
if (error) | ||
{ | ||
if (index==0) | ||
{ | ||
message = [NSString stringWithFormat:@"Character at index %d '%@' is an invalid start character for %@", (int)index, character, NSStringFromClass([self class])]; | ||
} | ||
else if (index==[content length]-1) | ||
{ | ||
message = [NSString stringWithFormat:@"Character at index %d '%@' is an invalid stop character for %@", (int)index, character, NSStringFromClass([self class])]; | ||
} | ||
else { | ||
message = [NSString stringWithFormat:@"Character at index %d '%@' cannot be encoded in %@", (int)index, character, NSStringFromClass([self class])]; | ||
} | ||
|
||
*error = [NSError BCKCodeErrorWithMessage:message]; | ||
} | ||
|
||
return NO; | ||
} | ||
} | ||
|
||
return YES; | ||
} | ||
|
||
- (NSArray *)codeCharacters | ||
{ | ||
// If the array was created earlier just return it | ||
if (_codeCharacters) | ||
{ | ||
return _codeCharacters; | ||
} | ||
|
||
// Array that holds all code characters, including start/stop and space characters | ||
NSMutableArray *finalArray = [NSMutableArray array]; | ||
|
||
// Encode the barcode's content and add it to the array | ||
for (NSUInteger index=0; index<[_content length]; index++) | ||
{ | ||
NSString *character = [_content substringWithRange:NSMakeRange(index, 1)]; | ||
|
||
// Start character | ||
if (index==0) | ||
{ | ||
[finalArray addObject:[BCKCodabarCodeCharacter startStopCodeCharacter:character]]; | ||
[finalArray addObject:[BCKCodabarCodeCharacter spacingCodeCharacter]]; | ||
} | ||
// Stop character | ||
else if (index == [_content length]-1) | ||
{ | ||
[finalArray addObject:[BCKCodabarCodeCharacter startStopCodeCharacter:character]]; | ||
} | ||
// All other characters | ||
else | ||
{ | ||
[finalArray addObject:[BCKCodabarCodeCharacter codeCharacterForCharacter:character]]; | ||
[finalArray addObject:[BCKCodabarCodeCharacter spacingCodeCharacter]]; | ||
} | ||
} | ||
|
||
_codeCharacters = [finalArray copy]; | ||
|
||
return _codeCharacters; | ||
} | ||
|
||
- (NSUInteger)horizontalQuietZoneWidth | ||
{ | ||
return 17; | ||
} | ||
|
||
- (CGFloat)aspectRatio | ||
{ | ||
return 0; | ||
} | ||
|
||
- (CGFloat)fixedHeight | ||
{ | ||
return 34; | ||
} | ||
|
||
- (CGFloat)_captionFontSizeWithOptions:(NSDictionary *)options | ||
{ | ||
return 10; | ||
} | ||
|
||
- (BOOL)_shouldShowCheckDigitsFromOptions:(NSDictionary *)options | ||
{ | ||
NSNumber *num = [options objectForKey:BCKCodeDrawingShowCheckDigitsOption]; | ||
|
||
if (num) | ||
{ | ||
return [num boolValue]; | ||
} | ||
else | ||
{ | ||
return 0; // default | ||
} | ||
} | ||
|
||
- (NSString *)captionTextForZone:(BCKCodeDrawingCaption)captionZone withRenderOptions:(NSDictionary *)options | ||
{ | ||
NSString *contentWithoutStartStop = @""; | ||
|
||
if (captionZone == BCKCodeDrawingCaptionTextZone) | ||
{ | ||
// Check digits must not be shown, remove the start and end code characters | ||
if (![self _shouldShowCheckDigitsFromOptions:options]) | ||
{ | ||
for (NSUInteger index=0; index<[_content length]; index++) | ||
{ | ||
if ( (index !=0 ) && (index != ([_content length] - 1)) ) | ||
{ | ||
contentWithoutStartStop = [contentWithoutStartStop stringByAppendingString:[_content substringWithRange:NSMakeRange(index, 1)]]; | ||
} | ||
} | ||
|
||
return contentWithoutStartStop; | ||
} | ||
// Check digits are to be shown so return the content string as provided to the subclass, including the start and stop character | ||
else | ||
{ | ||
return _content; | ||
} | ||
} | ||
|
||
return nil; | ||
} | ||
|
||
- (BOOL)showCheckDigitsInCaption | ||
{ | ||
return YES; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// | ||
// BCKCodabarCodeCharacter.h | ||
// BarCodeKit | ||
// | ||
// Created by Geoff Breemer on 14/09/13. | ||
// Copyright (c) 2013 Oliver Drobnik. All rights reserved. | ||
// | ||
|
||
#import "BCKCodeCharacter.h" | ||
|
||
/** | ||
Specialized class of BCKCodeCharacter used for generating Codabar code characters. | ||
*/ | ||
@interface BCKCodabarCodeCharacter : BCKCodeCharacter | ||
|
||
/** | ||
@name Creating Characters | ||
*/ | ||
|
||
/** | ||
Generates a Codabar start/stop code character. Supported start/stop characters are A, B, C, D, T, N, * and E. Does not count as a marker. | ||
@param character The start/stop code character. | ||
@returns the start/stop code character. | ||
*/ | ||
+ (BCKCodabarCodeCharacter *)startStopCodeCharacter:(NSString *)character; | ||
|
||
/** | ||
Generates a Codabar spacing code character. Does not count as a marker. | ||
@returns the spacing marker code character. | ||
*/ | ||
+ (BCKCodabarCodeCharacter *)spacingCodeCharacter; | ||
|
||
/** | ||
Generates a code character to represent a Codabar content character. | ||
@param character The character to encode. | ||
@returns The content code character for the character. | ||
*/ | ||
+ (BCKCodabarCodeCharacter *)codeCharacterForCharacter:(NSString *)character; | ||
|
||
/** | ||
Whether the code character is a start/stop character. | ||
*/ | ||
@property (nonatomic, readonly, getter = isStartStop) BOOL isStartStop; | ||
|
||
@end |
Oops, something went wrong.