PEG Markdown Highlight
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines
example_cocoa/HGMarkdownHighlightingStyle.h
00001 /* PEG Markdown Highlight
00002  * Copyright 2011-2012 Ali Rantakari -- http://hasseg.org
00003  * Licensed under the GPL2+ and MIT licenses (see LICENSE for more info).
00004  * 
00005  * HGMarkdownHighlightingStyle.h
00006  */
00007 
00008 #import <Cocoa/Cocoa.h>
00009 #import "pmh_definitions.h"
00010 #import "pmh_styleparser.h"
00011 
00012 
00013 #define HG_MKSTYLE(elem, add, remove, traits)   [[[HGMarkdownHighlightingStyle alloc] initWithType:(elem) attributesToAdd:(add) toRemove:(remove) fontTraitsToAdd:(traits)] autorelease]
00014 #define HG_D(...)   [NSDictionary dictionaryWithObjectsAndKeys:__VA_ARGS__, nil]
00015 #define HG_A(...)   [NSArray arrayWithObjects:__VA_ARGS__, nil]
00016 
00017 #define HG_FORE         NSForegroundColorAttributeName
00018 #define HG_BACK         NSBackgroundColorAttributeName
00019 
00020 #define HG_COLOR_RGB(r,g,b) [NSColor colorWithCalibratedRed:(r) green:(g) blue:(b) alpha:1.0]
00021 #define HG_COLOR_HSB(h,s,b) [NSColor colorWithCalibratedHue:(h) saturation:(s) brightness:(b) alpha:1.0]
00022 #define HG_COLOR_HEX(hex)   HG_COLOR_RGB(((hex & 0xFF0000) >> 16)/255.0, ((hex & 0xFF00) >> 8)/255.0, (hex & 0xFF)/255.0)
00023 
00024 // brightness/saturation
00025 #define HG_VDARK(h) HG_COLOR_HSB(h, 0.7, 0.1)
00026 #define HG_DARK(h)  HG_COLOR_HSB(h, 1, 0.4)
00027 #define HG_MED(h)   HG_COLOR_HSB(h, 1, 1)
00028 #define HG_LIGHT(h) HG_COLOR_HSB(h, 0.2, 1)
00029 #define HG_DIM(h)   HG_COLOR_HSB(h, 0.2, 0.5)
00030 
00031 // version of color 'c' with alpha 'a'
00032 #define HG_ALPHA(c,a) [NSColor colorWithCalibratedHue:[c hueComponent] saturation:[c saturationComponent] brightness:[c brightnessComponent] alpha:(a)]
00033 
00034 // hues
00035 #define HG_GREEN    0.34
00036 #define HG_YELLOW   0.15
00037 #define HG_BLUE     0.67
00038 #define HG_RED      0
00039 #define HG_MAGENTA  0.87
00040 #define HG_CYAN     0.5
00041 
00042 #define HG_DARK_GRAY    HG_COLOR_HSB(0, 0, 0.2)
00043 #define HG_MED_GRAY     HG_COLOR_HSB(0, 0, 0.5)
00044 #define HG_LIGHT_GRAY   HG_COLOR_HSB(0, 0, 0.9)
00045 
00046 
00055 @interface HGMarkdownHighlightingStyle : NSObject
00056 {
00057     NSDictionary *attributesToAdd;
00058     NSArray *attributesToRemove;
00059     NSFontTraitMask fontTraitsToAdd;
00060     pmh_element_type elementType;
00061 }
00062 
00063 + (NSColor *) colorFromARGBColor:(pmh_attr_argb_color *)argb_color;
00064 
00066 - (id) initWithType:(pmh_element_type)elemType
00067     attributesToAdd:(NSDictionary *)toAdd
00068            toRemove:(NSArray *)toRemove
00069     fontTraitsToAdd:(NSFontTraitMask)traits;
00070 
00072 - (id) initWithStyleAttributes:(pmh_style_attribute *)attributes baseFont:(NSFont *)baseFont;
00073 
00075 @property pmh_element_type elementType;
00076 
00083 @property NSFontTraitMask fontTraitsToAdd;
00084 
00091 @property(copy) NSDictionary *attributesToAdd;
00092 
00098 @property(copy) NSArray *attributesToRemove;
00099 
00100 @end