-
Notifications
You must be signed in to change notification settings - Fork 443
/
Copy pathOMColorHelper.h
64 lines (50 loc) · 2.29 KB
/
OMColorHelper.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
//
// 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, strong) OMPlainColorWell *colorWell;
@property (nonatomic, strong) OMColorFrameView *colorFrameView;
@property (nonatomic, strong) 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;
- (double)dividedValue:(double)value withDivisorRange:(NSRange)divisorRange inString:(NSString *)text;
@end