forked from omz/ColorSense-for-Xcode
-
Notifications
You must be signed in to change notification settings - Fork 66
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
Ole Zorn
committed
Sep 8, 2012
0 parents
commit 86b6745
Showing
10 changed files
with
926 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,14 @@ | ||
build | ||
*.xcodeproj/*.pbxuser | ||
*.xcodeproj/*.perspectivev3 | ||
*.xcodeproj/xcuserdata | ||
.DS_Store | ||
.swp | ||
~.nib | ||
.pbxuser | ||
.perspective | ||
*.perspectivev3 | ||
*.mode1v3 | ||
*.xcworkspacedata | ||
*.xcuserstate | ||
*xcuserdata* |
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,18 @@ | ||
// | ||
// OMColorFrameView.h | ||
// OMColorHelper | ||
// | ||
// Created by Ole Zorn on 09/07/12. | ||
// | ||
// | ||
|
||
#import <Cocoa/Cocoa.h> | ||
|
||
@interface OMColorFrameView : NSView { | ||
|
||
NSColor *_color; | ||
} | ||
|
||
@property (nonatomic, retain) NSColor *color; | ||
|
||
@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,36 @@ | ||
// | ||
// OMColorFrameView.m | ||
// OMColorHelper | ||
// | ||
// Created by Ole Zorn on 09/07/12. | ||
// | ||
// | ||
|
||
#import "OMColorFrameView.h" | ||
|
||
@implementation OMColorFrameView | ||
|
||
@synthesize color=_color; | ||
|
||
- (void)drawRect:(NSRect)dirtyRect | ||
{ | ||
[self.color setStroke]; | ||
[NSBezierPath strokeRect:NSInsetRect(self.bounds, 0.5, 0.5)]; | ||
} | ||
|
||
- (void)setColor:(NSColor *)color | ||
{ | ||
if (color != _color) { | ||
[_color release]; | ||
_color = [color retain]; | ||
[self setNeedsDisplay:YES]; | ||
} | ||
} | ||
|
||
- (void)dealloc | ||
{ | ||
[_color release]; | ||
[super dealloc]; | ||
} | ||
|
||
@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,63 @@ | ||
// | ||
// OMColorHelper.h | ||
// OMColorHelper | ||
// | ||
// Created by Ole Zorn on 09/07/12. | ||
// | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <AppKit/AppKit.h> | ||
|
||
typedef enum OMColorType { | ||
OMColorTypeNone = 0, | ||
|
||
OMColorTypeUIRGBA, //[UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0] | ||
OMColorTypeUIRGBAInit, //[[UIColor alloc] initWithRed:1.0 green:0.0 blue:0.0 alpha:1.0] | ||
OMColorTypeUIWhite, //[UIColor colorWithWhite:0.5 alpha:1.0] | ||
OMColorTypeUIWhiteInit, //[[UIColor alloc] initWithWhite:0.5 alpha:1.0] | ||
OMColorTypeUIConstant, //[UIColor redColor] | ||
|
||
OMColorTypeNSRGBACalibrated, //[NSColor colorWithCalibratedRed:1.0 green:0.0 blue:0.0 alpha:1.0] | ||
OMColorTypeNSRGBADevice, //[NSColor colorWithDeviceRed:1.0 green:0.0 blue:0.0 alpha:1.0] | ||
OMColorTypeNSWhiteCalibrated, //[NSColor colorWithCalibratedWhite:0.5 alpha:1.0] | ||
OMColorTypeNSWhiteDevice, //[NSColor colorWithDeviceWhite:0.5 alpha:1.0] | ||
OMColorTypeNSConstant, //[NSColor redColor] | ||
|
||
} OMColorType; | ||
|
||
BOOL OMColorTypeIsNSColor(OMColorType colorType) { return colorType >= OMColorTypeNSRGBACalibrated; } | ||
|
||
//TODO: Maybe support HSB and CMYK color types... | ||
|
||
@class OMColorFrameView, OMPlainColorWell; | ||
|
||
@interface OMColorHelper : NSObject { | ||
|
||
OMPlainColorWell *_colorWell; | ||
OMColorFrameView *_colorFrameView; | ||
NSRange _selectedColorRange; | ||
OMColorType _selectedColorType; | ||
NSTextView *_textView; | ||
NSDictionary *_constantColorsByName; | ||
|
||
NSRegularExpression *_rgbaUIColorRegex; | ||
NSRegularExpression *_rgbaNSColorRegex; | ||
NSRegularExpression *_whiteNSColorRegex; | ||
NSRegularExpression *_whiteUIColorRegex; | ||
NSRegularExpression *_constantColorRegex; | ||
} | ||
|
||
@property (nonatomic, retain) OMPlainColorWell *colorWell; | ||
@property (nonatomic, retain) OMColorFrameView *colorFrameView; | ||
@property (nonatomic, retain) NSTextView *textView; | ||
@property (nonatomic, assign) NSRange selectedColorRange; | ||
@property (nonatomic, assign) OMColorType selectedColorType; | ||
|
||
- (void)dismissColorWell; | ||
- (void)activateColorHighlighting; | ||
- (void)deactivateColorHighlighting; | ||
- (NSColor *)colorInText:(NSString *)text selectedRange:(NSRange)selectedRange type:(OMColorType *)type matchedRange:(NSRangePointer)matchedRange; | ||
- (NSString *)colorStringForColor:(NSColor *)color withType:(OMColorType)colorType; | ||
|
||
@end |
Oops, something went wrong.