Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 86b6745c33cd8a6c99812a208d15bba4e0a00b42 Ole Zorn committed Sep 8, 2012
@@ -0,0 +1,14 @@
+build
+*.xcodeproj/*.pbxuser
+*.xcodeproj/*.perspectivev3
+*.xcodeproj/xcuserdata
+.DS_Store
+.swp
+~.nib
+.pbxuser
+.perspective
+*.perspectivev3
+*.mode1v3
+*.xcworkspacedata
+*.xcuserstate
+*xcuserdata*
@@ -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
@@ -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
@@ -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.

0 comments on commit 86b6745

Please sign in to comment.